id stringlengths 24 27 | content stringlengths 37 384k | max_stars_repo_path stringlengths 51 51 |
|---|---|---|
condefects-python_data_1001 | s = input()
a, b = map(int, input().split())
n = a - 1
m = b - 1
x = s[n]
y = s[m]
print(x)
print(y)
print(s[:n] + y + s[a:m] + x + s[m + 1 :])
s = input()
a, b = map(int, input().split())
n = a - 1
m = b - 1
x = s[n]
y = s[m]
print(s[:n] + y + s[a:m] + x + s[m + 1 :]) | ConDefects/ConDefects/Code/abc236_a/Python/45430544 |
condefects-python_data_1002 | 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/arc134_b/Python/42294633 |
condefects-python_data_1003 | from collections import deque
N = int(input())
s = list(input())
index = {chr(ord('a') + x): deque() for x in range(26)}
for i in range(N):
index[s[i]].append(i)
l, r = 0, N
while r - l > 1:
for x in range(ord(s[l]) - ord('a')):
c = chr(ord('a') + x)
while len(index[c]) > 0:
i = in... | ConDefects/ConDefects/Code/arc134_b/Python/40879387 |
condefects-python_data_1004 | import sys
from collections import Counter
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
N = int(readline())
S = readline().rstrip()
C = Counter(S)
S = list(S)
alp = 'abcdefghijklmnopqrstuvwxyz'
now = 0
left = 0
right = N - 1
while left < right:
while C[alp[now]] == 0:
... | ConDefects/ConDefects/Code/arc134_b/Python/42982979 |
condefects-python_data_1005 | N = int(input())
S = list(input())
T = [0] * N
X = [[] for _ in range(26)]
cmin = 26
for i, s in enumerate(S):
a = ord(s) - 97
T[i] = a
X[a].append(i)
cmin = min(cmin, a)
j = N
i = 0
while i < j:
if T[i] != cmin:
if X[cmin]:
if i < X[cmin][-1] < j:
j = X[cmin].pop... | ConDefects/ConDefects/Code/arc134_b/Python/45004334 |
condefects-python_data_1006 | r, c = map(int, input().split())
if min(r,c, 15-r, 15-c) % 2 == 1:
print('black')
else:
print('white')
r, c = map(int, input().split())
if max(abs(r-8), abs(c-8)) % 2 == 1:
print('black')
else:
print('white') | ConDefects/ConDefects/Code/abc264_b/Python/45725806 |
condefects-python_data_1007 | r,c=map(int,input().split())
if min(r,c)%2==1:print("black")
else:print("white")
r,c=map(int,input().split())
if max(abs(r-7),abs(c-7))%2==0:print("black")
else:print("white") | ConDefects/ConDefects/Code/abc264_b/Python/44649966 |
condefects-python_data_1008 | r,c = map(int,input().split())
if (abs(r-8)+abs(c-8))%2==0:
print("black")
else:
print("white")
r,c = map(int,input().split())
if max(abs(r-8),abs(c-8)) %2 == 1:
print("black")
else:
print("white") | ConDefects/ConDefects/Code/abc264_b/Python/44650000 |
condefects-python_data_1009 | R,C = map(int,input().split())
t = min(R,C)
ans = 'white'
if t % 2 == 1:
ans = 'black'
print(ans)
R,C = map(int,input().split())
t = min(R,C,16-R,16-C)
ans = 'white'
if t % 2 == 1:
ans = 'black'
print(ans) | ConDefects/ConDefects/Code/abc264_b/Python/44791735 |
condefects-python_data_1010 | r,c=map(int,input().split())
print(("white","blue")[max(abs(r-8),abs(c-8))%2])
r,c=map(int,input().split())
print(("white","black")[max(abs(r-8),abs(c-8))%2]) | ConDefects/ConDefects/Code/abc264_b/Python/44581422 |
condefects-python_data_1011 | r,c = list(map(int,input().split(" ")))
if((abs(8-r)+abs(8-c))%2 == 0):
print("black")
else:
print("white")
r,c = list(map(int,input().split(" ")))
if(max([abs(8-r),abs(8-c)])%2 != 0):
print("black")
else:
print("white") | ConDefects/ConDefects/Code/abc264_b/Python/45323702 |
condefects-python_data_1012 | R,C = map(int,input().split())
if max(abs(R-8)%2,abs(C-8)) % 2 != 0:
print("white")
else:
print("black")
R,C = map(int,input().split())
if max(abs(R-8),abs(C-8)) % 2 == 0:
print("white")
else:
print("black") | ConDefects/ConDefects/Code/abc264_b/Python/44655850 |
condefects-python_data_1013 | R,C=map(int,input().split())
dist=min(R-8,C-8)
if dist%2==1: print("black")
else: print("white")
R,C=map(int,input().split())
dist=max(abs(R-8),abs(C-8))
if dist%2==1: print("black")
else: print("white") | ConDefects/ConDefects/Code/abc264_b/Python/45507078 |
condefects-python_data_1014 | N=int(input())
x=0
A=list(map(int,input().split()))
T={}
for i in range(N):
x^=A[i]
T[A[i]]=1
if x in T:
print('Win')
exit()
if N%2==1:
print('Win')
else:
print('No')
N=int(input())
x=0
A=list(map(int,input().split()))
T={}
for i in range(N):
x^=A[i]
T[A[i]]=1
if x in T:
print('Win')
exit()
if N%2=... | ConDefects/ConDefects/Code/arc131_c/Python/41901450 |
condefects-python_data_1015 | import sys
input = sys.stdin.readline
inf = float('inf')
def read(dtype=int):
return list(map(dtype, input().split()))
n = int(input())
a = read()
c = 0
for i in a:
c ^= i
for j in range(30):
if all(i >> j & 1 for i in a):
print("Win")
exit()
print("Win" if n == 1 or n == 3 or c in a el... | ConDefects/ConDefects/Code/arc131_c/Python/40380616 |
condefects-python_data_1016 | from collections import deque
N,M = map(int,input().split())
XY = list(set([tuple(map(int,input().split())) for _ in range(M)]))
to = [[] for _ in range(N+1)]
deg = [0 for _ in range(N+1)]
for X,Y in XY:
if X == Y: continue
to[X].append(Y)
deg[Y] += 1
dq = deque([i for i in range(1,N+1) if deg[i] == 0])
... | ConDefects/ConDefects/Code/abc291_e/Python/45325123 |
condefects-python_data_1017 | n, m = map(int, input().split())
b = [None for _ in range(n)]
for i in range(n):
b[i] = list(map(int, input().split()))
def check():
c = list(map(list, zip(*b)))
for i in range(m):
for j in range(n - 1):
if c[i][j + 1] != c[i][j] + 7:
return False
temp = b[0]
for i in range(m - 1):
... | ConDefects/ConDefects/Code/abc225_c/Python/45226527 |
condefects-python_data_1018 | #import
import sys
import string
import collections
import itertools
import math
#constant
alphabet=string.ascii_lowercase
ALPHABET=string.ascii_uppercase
inf=float("inf")
mod=998244353
sift4=((-1,0),(0,-1),(1,0),(0,1))
sift6=((-1,0,0),(0,-1,0),(0,0,-1),(1,0,0),(0,1,0),(0,0,1))
sift8=((-1,0),(-1,-1),(0,-1),(1,-1),(1,0... | ConDefects/ConDefects/Code/abc225_c/Python/44888915 |
condefects-python_data_1019 | from sys import stdin
def check(b, n, m):
for i in range(n):
if b[i][0] % 7 + m > 8:
return False
if i + 1 < n and b[i + 1][0] != b[i][0] + 7:
return False
for j in range(m - 1):
if b[i][j + 1] != b[i][j] + 1:
return False
return True... | ConDefects/ConDefects/Code/abc225_c/Python/45664223 |
condefects-python_data_1020 | def a(n,m,B):
x=B[0][0]
for i in range(n):
for j in range(m):
if B[i][j]!=x+i*7+j:
return "No"
return "Yes"
n,m=map(int,input().split())
B=[list(map(int,input().split())) for _ in range(n)]
print(a(n,m,B))
def a(n,m,B):
x=B[0][0]
for i in range(n):
for j ... | ConDefects/ConDefects/Code/abc225_c/Python/44469125 |
condefects-python_data_1021 | import sys
from collections import deque,defaultdict
import itertools
import heapq
import bisect
import queue
#sys.setrecursionlimit(10 ** 9)
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
li_st = lambda: list(map(str, input().spli... | ConDefects/ConDefects/Code/abc225_c/Python/44416948 |
condefects-python_data_1022 | n, m = map(int, input().split())
b = [list(map(int, input().split())) for i in range(n)]
ans = True
for i in range(m-1):
if b[0][i]+1 != b[0][i+1]:
ans = False
if b[0][i]%7+1 != b[0][i+1]%7:
ans = False
for i in range(n-1):
for j in range(m):
if b[i][j]+7 != b[i+1][j]:
... | ConDefects/ConDefects/Code/abc225_c/Python/45041161 |
condefects-python_data_1023 | n,m = map(int,input().split())
B = [list(map(int,input().split())) for _ in range(n)]
ok = True
for i in range(n):
for j in range(m):
if j+1 < m and B[i][j]+1 != B[i][j+1]:
ok = False
if i+1 < n and B[i][j]+7 != B[i+1][j]:
ok = False
if B[i][j]%7 == 0:
ok... | ConDefects/ConDefects/Code/abc225_c/Python/44703471 |
condefects-python_data_1024 | from collections import defaultdict
n, m = map(int, input().split())
b0 = list(map(int, input().split()))
ans = 'Yes'
for i in range(m-1):
if b0[i+1] - b0[i] != 1:
ans = 'No'
for i in range(n-1):
b = list(map(int, input().split()))
for i in range(m):
if b[i] - b0[i] != 7:
ans = 'No'
b0 = b
prin... | ConDefects/ConDefects/Code/abc225_c/Python/44135956 |
condefects-python_data_1025 | n,m = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(n)]
start = A[0][0]
r = start- (start//7)*7
if r+m-1>7:
print("No")
exit()
else:
for i in range(n):
for j in range(m):
if A[i][j] != start+7*i+j:
print("No")
exit()
print("Yes")
n,m = map(int,input().spl... | ConDefects/ConDefects/Code/abc225_c/Python/44853585 |
condefects-python_data_1026 | N, M = map(int, input().split())
B = [ list(map(int, input().split())) for _ in range(N) ]
flag = True
lim = 10**100*7+7
j0 = (B[0][0]-1)%7
if j0 + M-1 >= 7:
flag = False
i0 = (B[0][0])//7
for i in range(N):
for j in range(M):
if B[i][j] != (i+i0)*7 + j + j0 +1 or B[i][j] > lim:
flag = False... | ConDefects/ConDefects/Code/abc225_c/Python/44146392 |
condefects-python_data_1027 | import sys
sys.setrecursionlimit(10**7)
def input():
return sys.stdin.readline().rstrip()
def main():
N, M = map(int, input().split())
B = [list(map(int, input().split())) for _ in range(N)]
for i in range(N):
for j in range(M):
if B[i][j] % 7 > j + 1:
print("No... | ConDefects/ConDefects/Code/abc225_c/Python/45469943 |
condefects-python_data_1028 | N, M = map(int, input().split())
B = [[int(i) for i in input().split()] for _ in range(N)]
flg = True
for i in range(N):
for j in range(M - 1):
if B[i][j] + 1 != B[i][j + 1]:
flg = False
if B[i][j] % 7 + 1 != B[i][j + 1] % 7:
flg = False
for j in range(M):
for i in range(N - 1):
if B[i][j]... | ConDefects/ConDefects/Code/abc225_c/Python/44435353 |
condefects-python_data_1029 | N,M = map(int,input().split())
ans = 'Yes'
B = []
for i in range(N):
b = list(map(int,input().split()))
for j in range(M-1):
if ((b[j+1] - 1) % 7) - ((b[j] - 1) % 7) != 1:
ans = 'No'
B.append(b)
for i in range(N-1):
if B[i+1][0] - B[i][0] != 7:
ans = 'No'
print(ans)
N,M = map(int,input().split()... | ConDefects/ConDefects/Code/abc225_c/Python/44317781 |
condefects-python_data_1030 | import sys
sys.setrecursionlimit(10 ** 7)
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
self.val = [0] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
t = self.parents[x]
self.val[x] = self.... | ConDefects/ConDefects/Code/abc328_f/Python/50086721 |
condefects-python_data_1031 | S = input()
S = [ord(s)-ord('a') for s in S]
inf = 1<<30
MOD = 998244353
ans = 0
for i in range(1,len(S)-1):
s = S[:i]
t = S[i:]
ls = len(s)
lt = len(t)
ns = [[inf]*26 for _ in range(ls+1)]
nt = [[inf]*26 for _ in range(lt+1)]
for j in range(ls-1,-1,-1):
for k in range(26):
... | ConDefects/ConDefects/Code/abc299_f/Python/41069355 |
condefects-python_data_1032 | import sys
input = sys.stdin.readline
mod = 998244353
S = list(map(lambda c: ord(c)-ord('a'), input().rstrip()))
N = len(S)
ans = 0
for k in range(1, N): # beginning of the second T
l = -1
for i in range(k):
if S[i] == S[k]:
l = i
break
if l == -1:
continue
dp... | ConDefects/ConDefects/Code/abc299_f/Python/40872561 |
condefects-python_data_1033 | a, b = map(int, input().split())
print(round(b / a, 3))
a, b = map(int, input().split())
print("{:.3f}".format(round(b / a, 3))) | ConDefects/ConDefects/Code/abc274_a/Python/46147571 |
condefects-python_data_1034 | from decimal import Decimal, ROUND_UP
a,b = map(int,input().split())
print(Decimal(str(b/a)).quantize(Decimal(10) ** -3,rounding=ROUND_UP))
from decimal import Decimal, ROUND_UP
a,b = map(int,input().split())
print(Decimal(str(b/a)).quantize(Decimal(10) ** -3)) | ConDefects/ConDefects/Code/abc274_a/Python/45984868 |
condefects-python_data_1035 | a, b = map(int, input().split())
print(f'{b/a:.08f}')
a, b = map(int, input().split())
print('{:.03f}'.format(round(b/a, 3))) | ConDefects/ConDefects/Code/abc274_a/Python/45757801 |
condefects-python_data_1036 | A, B = map(int, input().split())
print(round(B/A, 3))
A, B = map(int, input().split())
print('{:.03f}'.format(round(B/A, 3)))
| ConDefects/ConDefects/Code/abc274_a/Python/45467023 |
condefects-python_data_1037 | a,b=map(int,input().split())
ans=(1000*b+5)//a/1000
print("{:.3f}".format(ans))
a,b=map(int,input().split())
ans=(1000*b+a/2)//a/1000
print("{:.3f}".format(ans))
| ConDefects/ConDefects/Code/abc274_a/Python/44864361 |
condefects-python_data_1038 | a, b = map(int,input().split())
s = b / a
print(f"{s:.3}")
a, b = map(int,input().split())
s = b / a
print(f"{s:.3f}") | ConDefects/ConDefects/Code/abc274_a/Python/46127383 |
condefects-python_data_1039 | n=int(input())
S=input()
dp=["2"]*(n+1)
Q=[[] for _ in range(n)]
for l in range(n):
i=0
for r in range(l,min(l+200,n)):
s=S[l:r+1]
while dp[i]<s:
i+=1
Q[r].append((i,s))
for i,s in Q[l]:
dp[i]=min(dp[i],s)
Q[l].clear()
print(dp.index("2"))
n=int(input())
S=input()
dp=["2"]*(n+1)
Q=[[] for... | ConDefects/ConDefects/Code/abc240_h/Python/29809348 |
condefects-python_data_1040 | import time
from typing import Generic, Iterable, Iterator, TypeVar, Optional, List
from array import array
from bisect import bisect_left, bisect_right, insort
import collections
import copy
import heapq
import itertools
import decimal
from decimal import Decimal
import math
import string
import sys
sys.setrecursionli... | ConDefects/ConDefects/Code/abc323_f/Python/50030718 |
condefects-python_data_1041 | def push_down(sx, sy, tx, ty):
times = abs(tx - sx) + abs(ty + 1 - sy) + ty
if sx == tx and sy < ty:
times += 2
return times, tx, 1, tx, 0
sx, sy, tx, ty, gx, gy = map(int, input().split())
sx -= gx
sy -= gy
tx -= gx
ty -= gy
if tx < 0:
tx *= -1
sx *= -1
if ty < 0:
ty *= -1
sy *= -1
ans... | ConDefects/ConDefects/Code/abc323_f/Python/53065562 |
condefects-python_data_1042 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
def II(): return int(input())
def MI(): return map(int,input().split())
def LM(): return list(MI())
def LL(n): return [LM() for _ in range(n)]
def LS(n,remove_br=False): return [list(input())[:-1] if remove_br else list(input()) for _ in range(n)]
def... | ConDefects/ConDefects/Code/abc323_f/Python/50223990 |
condefects-python_data_1043 | # +-----------+--------------------------------------------------------------+
# | main | |
# +-----------+--------------------------------------------------------------+
def main():
XA, YA, XB, YB, XC, YC = map(int, input().split())
XB -= XA
... | ConDefects/ConDefects/Code/abc323_f/Python/50628101 |
condefects-python_data_1044 | from io import BytesIO, IOBase
import os
from random import getrandbits, randrange
from string import ascii_lowercase, ascii_uppercase
import sys
from math import ceil, floor, sqrt, pi, factorial, gcd, log, log10, log2, inf, cos, sin
from copy import deepcopy, copy
from collections import Counter, deque, defaultdict
fr... | ConDefects/ConDefects/Code/arc134_a/Python/45479683 |
condefects-python_data_1045 | import sys
sys.setrecursionlimit(10**9)
from collections import defaultdict
from collections import deque
import heapq
import math
import bisect
import itertools
def MI():return map(int,input().split())
def II():return int(input())
N,L,W=MI()
A=list(MI())
A.append(L+1)
now=0
ans=0
for a in A:
if now<a:
k=(... | ConDefects/ConDefects/Code/arc134_a/Python/43954461 |
condefects-python_data_1046 | n,l,w=map(int,input().split())
a=list(map(int,input().split()))
tmp=0
ans=0
for i in a:
ans+=max(0,(i-tmp+w-1)//w)
tmp=i+l
ans+=max(0,(l-tmp+w-1)//w)
print (ans)
n,l,w=map(int,input().split())
a=list(map(int,input().split()))
tmp=0
ans=0
for i in a:
ans+=max(0,(i-tmp+w-1)//w)
tmp=i+w
ans+=max(0,(l-tmp+w-1)//w)... | ConDefects/ConDefects/Code/arc134_a/Python/45282634 |
condefects-python_data_1047 | import sys
readline = sys.stdin.readline
n,m = map(int,readline().split())
g = [[] for _ in range(n)]
for _ in range(m):
a,b = map(int,readline().split())
g[a-1].append(b-1)
g[b-1].append(a-1)
dist = [-1]*n
dp = [0]*n
dist[0] = 0
dp[0] = 1
MOD = 998244353
num = 1 # dist = d-1 となる点の個数
val = 1 # dist = d-... | ConDefects/ConDefects/Code/abc319_g/Python/46211313 |
condefects-python_data_1048 | N, M = map(int, input().split())
ans = [N] * N
for i in map(int, input().split()):
ans[i-1] = 0
for i in range(N-2, 0, -1):
ans[i-1] = min(ans[i-1], ans[i]+1)
print('\n'.join(map(str, ans)))
N, M = map(int, input().split())
ans = [N] * N
for i in map(int, input().split()):
ans[i-1] = 0
for i in range(N... | ConDefects/ConDefects/Code/abc322_c/Python/46201794 |
condefects-python_data_1049 | import collections
n = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)
cnt = 0
for v in c.values():
if v == 2:
cnt += (n-1)*v*(v-1)//2 * (n-2)
if v >= 3:
cnt += v*(v-1)*(v-2)//6
cnt += (n-v)*v*(v-1)//2
ans = n*(n-1)*(n-2)//6 - cnt
print(ans)
import collecti... | ConDefects/ConDefects/Code/abc252_d/Python/45257814 |
condefects-python_data_1050 | N = int(input())
A = list(map(int,input().split()))
B=[]
for i in range(1000000):
B.append(0)
for i in A:
B[i]+=1
ans = N*(N-1)*(N-2)/6
for i in B:
ans -= i*(i-1)/2*(N-i)
ans -= i*(i-1)*(i-2)/6
print(ans)
N = int(input())
A = list(map(int,input().split()))
B=[]
for i in range(1000000):
B.append(0)
for i in A... | ConDefects/ConDefects/Code/abc252_d/Python/45497724 |
condefects-python_data_1051 | from sortedcontainers import SortedList
import math
n=int(input())
s=input()
sl=[0]*10
for i in range(n):
sl[int(s[i])]+=1
max=math.ceil(math.sqrt(10**n))
ans=0
for i in range(1,max):
ii=str(i*i)
now=[0]*10
for j in ii:
now[int(j)]+=1
now[0]+=n-len(ii)
# print(now)
if now==sl:
... | ConDefects/ConDefects/Code/abc324_d/Python/54149573 |
condefects-python_data_1052 | from math import isqrt
n = int(input())
s = input()
S = [int(s[i]) for i in range(n)]
S.sort(reverse=True)
max_perfect = 10**n
ans = 0
i = 1
while i**2 < max_perfect:
st = str(i**2)
j = [int(z) for z in str(i**2)]
j.sort(reverse=True)
if len(j) < n:
j += [0]*(n-len(j))
if S == j:
ans += 1
i+=1
print... | ConDefects/ConDefects/Code/abc324_d/Python/54743756 |
condefects-python_data_1053 | import sys, math
from collections import deque, defaultdict, Counter
from itertools import permutations, combinations, product
from bisect import bisect_left, bisect_right
from copy import deepcopy
from fractions import Fraction
from decimal import Decimal
from heapq import heapify, heappop, heappush, heappushpop
from ... | ConDefects/ConDefects/Code/abc324_d/Python/53953051 |
condefects-python_data_1054 | from collections import deque
import sys
import bisect
import math
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
li = lambda: list(map(int, input().split()))
INF = 2**63 - 1
MOD = 998244353
move = ((1, 0), (0, 1), (-1, 0), (0, -1))
move_diag = ((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 1... | ConDefects/ConDefects/Code/abc324_d/Python/54739961 |
condefects-python_data_1055 | #4
#4320
N=int(input())
S=list(input())
S.sort()
ans=0
num1=1
num2=N
for i in S:
if i=="0":
num2-=1
while len(str(num1**2))<=len(S):
s=list(str(num1**2))
s.sort()
num3=len(s)
for i in s:
if i=="0":
num3-=1
if num3==num2 and s==S[len(S)-len(s):]:
ans+=1
num... | ConDefects/ConDefects/Code/abc324_d/Python/54958173 |
condefects-python_data_1056 | n = int(input())
s = [int(x) for x in input()]
s.sort()
ans = 0
for x in range(1, 10**7):
t = [int(c) for c in str(x * x)]
if len(t) > n:
break
while len(t) < n:
t.append(0)
t.sort()
if s == t:
ans += 1
print(ans)
n = int(input())
s = [int(x) for x in input()]
s.sort()
ans ... | ConDefects/ConDefects/Code/abc324_d/Python/53183863 |
condefects-python_data_1057 | # D - Square Permutation
import copy
from collections import Counter
N, dic = None, None
def main():
global N, dic
N = int(input())
S = list(input())
dic = Counter(S)
upper = get_upper_limit(S)
i = 1
ans = 0
while i**2 <= upper:
if can_sort(i**2):
ans += 1
#print(i**2, ans)
... | ConDefects/ConDefects/Code/abc324_d/Python/54390162 |
condefects-python_data_1058 | N = int(input())
S = input()
S = ''.join(sorted(S,reverse=True))
pos = 1
cnt = 0
while pos**2 < 10**N:
tmp = str(pos*pos)
tmp = ''.join(sorted(tmp,reverse=True))
for i in range(len(tmp)):
if tmp[i] != S[i]:
break
else:
if len(tmp) < N:
if S[len(tmp)] == '0':
... | ConDefects/ConDefects/Code/abc324_d/Python/53944042 |
condefects-python_data_1059 | from collections import defaultdict
N = int(input())
dic = defaultdict(int)
S = input()
S_cnt = [0]*10
for i in S:
S_cnt[int(i)] += 1
ans = 0
for i in range(1,int(10**6.5) + 1):
tmp = list(str(i**2))
cnt = [0]*10
for j in tmp:
cnt[int(j)] += 1
flag = True
if S_cnt[0] < cnt[0]:
... | ConDefects/ConDefects/Code/abc324_d/Python/54432109 |
condefects-python_data_1060 | import sys
def main():
input = sys.stdin.readline
n = int(input())
s = sorted(input()[:-1])
max_val = int("".join(s[::-1]))
s = list(map(int, s))
cnt = 0
for i in range(1,10**8+1):
if i*i > max_val:
break
lst = list(map(int, str(i*i)))
if len(lst) < n:
... | ConDefects/ConDefects/Code/abc324_d/Python/53028745 |
condefects-python_data_1061 | class UnionFind():
def __init__(self, n):
self.par = [-1] * n
self.rank = [0] * n
self.siz = [1] * n
def find(self, x):
if self.par[x] == -1: return x
else:
self.par[x] = self.find(self.par[x])
return self.par[x]
def same(self, x, y):
ret... | ConDefects/ConDefects/Code/abc334_e/Python/52777689 |
condefects-python_data_1062 | class UnionFind:
def __init__(self, n):
self.parent = list(range(n))
self.count = n
def find(self, i):
if self.parent[i] == i:
return i
self.parent[i] = self.find(self.parent[i])
return self.parent[i]
def unite(self, i, j):
i, j = self.find(i), s... | ConDefects/ConDefects/Code/abc334_e/Python/52492868 |
condefects-python_data_1063 | from collections import deque, defaultdict
from bisect import bisect_left, bisect_right
from atcoder.segtree import SegTree
from atcoder.lazysegtree import LazySegTree
from atcoder.dsu import DSU
from itertools import permutations, combinations
import math, sys
sys.setrecursionlimit(10**7)
MOD = 998244353
INF = 10**20
... | ConDefects/ConDefects/Code/abc329_f/Python/52733588 |
condefects-python_data_1064 | n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
ans2=ans>>a[i]+1
ans2=(ans2|1)<<a[i]
ans=ans2
print (ans)
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
ans2=(ans>>a[i])+1
ans2=(ans2|1)<<a[i]
ans=ans2
print (ans) | ConDefects/ConDefects/Code/arc139_a/Python/45429015 |
condefects-python_data_1065 | n=int(input())
a=[0]+list(map(int,input().split()))
f=1
for i in range(1,n+1):
if a[i]<a[i-1]:
f|=1<<a[i]
if a[i]>=a[i-1]:
ok=1<<100
ng=-1
while ok-ng>1:
m=(ok+ng)//2
if (m<<(a[i]+1))+(1<<a[i])>f:
ok=m
else:
ng=m
f=(ok<<(a[i]+1))+(1<<a[i])
print(f)
n=int(input(... | ConDefects/ConDefects/Code/arc139_a/Python/41107434 |
condefects-python_data_1066 |
n = int(input())
t = list(map(int, input().split()))
p = 2**t[0]
for i in range(1, n):
d = 2**t[i]
w = d
if w <= p:
kz = (p-w+d)//d
w += kz*d
p = w
print(p)
n = int(input())
t = list(map(int, input().split()))
p = 2**t[0]
for i in range(1, n):
d = 2**t[i]
w = d
if w <= p:
kz = (p-w+d)//... | ConDefects/ConDefects/Code/arc139_a/Python/43325170 |
condefects-python_data_1067 | from collections import defaultdict
N,K = map(int,input().split())
A = list(map(int,input().split()))
B = set((map(int,input().split())))
D = defaultdict(set)
for i in range(N):
D[A[i]].add(i)
m = max(A)
if len(B&D[m]) == 0:
print("No")
else:
print("Yes")
from collections import defaultdict
N,K = map(in... | ConDefects/ConDefects/Code/abc252_b/Python/45103207 |
condefects-python_data_1068 | import sys
import copy
from collections import deque,defaultdict
import math
import heapq
from itertools import accumulate
import itertools
from functools import reduce
#import pypyjit
#pypyjit.set_param('max_unroll_recursion=-1')
sys.setrecursionlimit(10**8)
mod = 10**9 + 7
INF = math.inf
input = lambda: sys.stdin.re... | ConDefects/ConDefects/Code/abc252_b/Python/45243368 |
condefects-python_data_1069 | from sys import stdin
N,Q = map(int, stdin.readline().split())
S = list(stdin.readline()[:-1])
TF = [0]*(N+10)
BIT = [0]*(N+10)
def get(pos):
s = 0
while pos > 0:
s += BIT[pos]
pos -= pos & -pos
return s
def add(pos,val):
while pos <= N+5:
BIT[pos] += val
pos += pos & ... | ConDefects/ConDefects/Code/abc341_e/Python/53935483 |
condefects-python_data_1070 | from atcoder.segtree import SegTree
n,q=map(int,input().split())
S=input()
L=[0]*(n+1)
for i in range(1,n-1):
if S[i]!=S[i-1]:
L[i]=1
def op(a,b):
return a+b
st=SegTree(op,0,L)
# print(1)
for i in range(q):
num,l,r=map(int,input().split())
if num==1:
st.set(l-1,(st.get(l-1)+1)%2)
... | ConDefects/ConDefects/Code/abc341_e/Python/54316816 |
condefects-python_data_1071 | from atcoder.segtree import SegTree
def op(x,y):
return max(x,y)
N,Q = map(int,input().split())
S = input()
check = SegTree(op,-float("inf"),[0 for i in range(N-1)])
for i in range(N-1):
if S[i]==S[i+1]:
check.set(i,1)
for i in range(Q):
query = list(map(int,input().split()))
q = query.pop(0)
if q == 1:
... | ConDefects/ConDefects/Code/abc341_e/Python/54515840 |
condefects-python_data_1072 | from heapq import heappop,heappush
INF=1<<60
N,M=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
dp=[0]
for i in range(N):
ndp=[INF]*((i+1)*(i+2)//2+1)
for j in range(len(dp)):
ndp[j]=min(ndp[j],dp[j])
ndp[j+i+1]=min(ndp[j+i+1],dp[j]+A[i])
dp=ndp
bo... | ConDefects/ConDefects/Code/abc332_g/Python/52980637 |
condefects-python_data_1073 | s = input()
n = len(s)
answer = -1
for i in range(n):
if s[i] == 'a':
answer = i
print(answer)
s = input()
n = len(s)
answer = -1
for i in range(n):
if s[i] == 'a':
answer = i+1
print(answer)
| ConDefects/ConDefects/Code/abc276_a/Python/45247098 |
condefects-python_data_1074 | a=input()
b=len(a)
for i in range(b-1,0,-1):
if a[i]=="a":
print(i+1)
quit()
print(-1)
a=input()
b=len(a)
for i in range(b-1,-1,-1):
if a[i]=="a":
print(i+1)
quit()
print(-1) | ConDefects/ConDefects/Code/abc276_a/Python/45957302 |
condefects-python_data_1075 | s=input()
for i in range(len(s)):
if s[-i-1]=="a":
print((len(s))-i)
break
print(-1)
break
s=input()
for i in range(len(s)):
if s[-i-1]=="a":
print((len(s))-i)
break
else:
print(-1) | ConDefects/ConDefects/Code/abc276_a/Python/45481761 |
condefects-python_data_1076 | h, m = map(int, input().split())
while True:
if h // 10 * 10 + m // 10 < 24 and h % 10 * 10 + m % 10 < 60:
exit(print(h, m))
m += 1
if m % 60 == 0:
h += 1
m = 0
h, m = map(int, input().split())
while True:
if h // 10 * 10 + m // 10 < 24 and h % 10 * 10 + m % 10 < 60:
exit(print(h, m))
m += 1
... | ConDefects/ConDefects/Code/abc278_b/Python/45695932 |
condefects-python_data_1077 | def f(h , m) :
a = h // 10
b = h % 10
c = m // 10
d = m % 10
h2 = a * 10 + c
m2 = b * 10 + d
if 0 <= h2 <= 23 and 0 <= m2 <= 59 :
print(a * 10 + b , c * 10 + d)
exit()
h , m = map(int,input().split())
while True :
f(h , m)
total = h * 60 + m + 1
h = total // 60
m = total % 60
def f(... | ConDefects/ConDefects/Code/abc278_b/Python/45297542 |
condefects-python_data_1078 | h, m = map(int, input().split())
def check(h, m):
b = h % 10
c = m // 10
newm = (m-c*10)+b*10
add = ((m-c*10)+b*10) // 60
newh = (h-b)+c+add
return 0 <= newm < 60 and 0 <= newh < 23
while True:
if check(h, m): break
m += 1
h += m//60
m %= 60
h %= 24
print(h, m)
h, m ... | ConDefects/ConDefects/Code/abc278_b/Python/45484239 |
condefects-python_data_1079 | #!/usr/bin/env python3
ch, cm = [int(x) for x in input().split()]
while True:
while cm < 60:
if (0 <= ch // 10 * 10 + cm // 10 <= 23) and (
0 <= (ch % 10) * 10 + cm % 10 <= 59
):
print(ch, cm)
exit()
cm += 1
ch += 1
cm = 0
#!/usr/bin/env python3... | ConDefects/ConDefects/Code/abc278_b/Python/45512302 |
condefects-python_data_1080 | H, M = map(int, input().split())
while True:
if H < 20:
if int(str(H)[-1]) < 6:
print(H,M)
exit()
else:
M += 1
if M == 60:
H += 1
H = H % 24
M = 0
else:
if int(str(M)[0]) < 4:
print(H,M)
exit()
else:
M += 1
if M == 60:
... | ConDefects/ConDefects/Code/abc278_b/Python/45108856 |
condefects-python_data_1081 | S = list(map(int, input().split()))
S_sort = S.copy()
S_sort.sort()
bad=0
for i in range(8):
if S==S_sort:
if S[i]>=675 or S[i]<=100:
bad+=1
else:
for j in range(8):
if not S[j]%25==0:
bad+=1
else:
bad+=1... | ConDefects/ConDefects/Code/abc308_a/Python/46165457 |
condefects-python_data_1082 | arr = list(map(int, input().split()))
fl = True
for i in range(1, 8):
if arr[i - 1] > arr[i]:
fl = False
if arr[i - 1] % 25 != 0 or arr[i] % 25 != 0:
fl = False
print("Yes" if fl else "No")
arr = list(map(int, input().split()))
fl = True
if arr[0] < 100 or arr[-1] > 675:
fl = False
for i in... | ConDefects/ConDefects/Code/abc308_a/Python/45959405 |
condefects-python_data_1083 | S = list(map(int, input().split()))
res = 'Yes'
for i in range(len(S) - 1):
if S[i] >= S[i + 1]:
res = 'No'
break
for i in range(len(S)):
if S[i] % 25 or not 100 <= S[i] <= 675:
res = 'No'
break
print(res)
S = list(map(int, input().split()))
res = 'Yes'
for i i... | ConDefects/ConDefects/Code/abc308_a/Python/46165135 |
condefects-python_data_1084 | S = list(map(int,input().split()))
ans = "Yes"
for i in range(len(S)-1):
if not(S[i] <= S[i+1]):
ans = "No"
for j in range(len(S)):
if not(S[i] % 25 == 0 and 100 <= S[i] <= 675):
ans = "No"
print(ans)
S = list(map(int,input().split()))
ans = "Yes"
for i in range(len(S)-1):
if not(S[i] <= S[i+1]):
ans... | ConDefects/ConDefects/Code/abc308_a/Python/45947529 |
condefects-python_data_1085 | s=list(map(int,input().split()))
ss=sorted(s)
pack=[]
if s==ss and s[0] >100 and s[-1]<675:
for i in s:
if i%25==0:
pack.append(i)
print("Yes" if len(pack)==8 else "No")
s=list(map(int,input().split()))
ss=sorted(s)
pack=[]
if s==ss and s[0]>=100 and s[-1]<=675:
for i in s:
if i%25==0:
pack.a... | ConDefects/ConDefects/Code/abc308_a/Python/46170943 |
condefects-python_data_1086 | S = list(map(int,input().split()))
for i in range(len(S)-1):
if S[i] >= S[i+1] or S[i] % 25 or S[i] < 100 or S[i] > 675:
print("No")
exit()
if S[-1] % 25 or S[-1] < 100 or S[-1] > 675:
print("No")
else: print("Yes")
S = list(map(int,input().split()))
for i in range(len(S)-1):
if S[i] > S... | ConDefects/ConDefects/Code/abc308_a/Python/45931202 |
condefects-python_data_1087 | S = list(map(int, input().split()))
N = len(S)
for i in range(N):
if sorted(S) == S or not(100 <= S[i] <= 675) or S[i]%25 != 0:
print('No')
exit()
else:
print('Yes')
S = list(map(int, input().split()))
N = len(S)
for i in range(N):
if sorted(S) != S or not(100 <= S[i] <= 675) or S[i]%25 !... | ConDefects/ConDefects/Code/abc308_a/Python/46000754 |
condefects-python_data_1088 | S=list(map(int,input().split()))
check_S=sorted(S)
check="True"
check_num=0
for i in range (len(S)):
if check_num<S[i] and 100<=S[i]<=675 and S[i]%25==0:
check_num=S[i]
else:
check="False"
if check=="True":
print("Yes")
else:
print("No")
S=list(map(int,input().split()))
check_S=sorted(S... | ConDefects/ConDefects/Code/abc308_a/Python/46023709 |
condefects-python_data_1089 | N,M,S = map(int,input().split())
a = list(map(int,input().split()))
b = [0]
for i in range(N-1,-1,-1):
b.append(b[-1]+a[i])
ans = 0
for j in range(N+1):
for i in range(N+1):
if i == j:
continue
yi = S - (N-j)*M
yi /= j-i
yj = S - (N-i)*M
yj /= i-j
if y... | ConDefects/ConDefects/Code/arc128_c/Python/41096330 |
condefects-python_data_1090 | N,M,S=map(int,input().split())
A=list(map(int,input().split()))
sums=0
C=[0]*N
for i in range(N-1,-1,-1):
sums+=A[i]
C[i]=sums/(N-i)
ans=0
#print(C)
for i in range(N):
for j in range(N):
#print(i,j,ans)
if i==j:
continue
if C[i]<C[j]:
continue
if S/(N-i)<=M:
ans=max(ans,S*C[i])
... | ConDefects/ConDefects/Code/arc128_c/Python/33842964 |
condefects-python_data_1091 | n, m, S = map(int,input().split())
a = list(map(int,input().split()))
asum = [0] * (n + 1)
for i in range(n):
asum[i + 1] += asum[i] + a[i]
ans = 0
for i in range(n + 1):
for j in range(i, n + 1):
s = S
s -= m * (n - j)
if s < 0:
continue
if j - i == 0:
an... | ConDefects/ConDefects/Code/arc128_c/Python/28766899 |
condefects-python_data_1092 | 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/arc128_c/Python/29987786 |
condefects-python_data_1093 | N, L, R = map(int, input().split())
A = list(map(int, input().split()))
for a in A:
if a <= L:
print(L, end = ' ')
else:
print(R, end = ' ')
N, L, R = map(int, input().split())
A = list(map(int, input().split()))
for a in A:
if a <= L:
print(L, end = ' ')
elif L < a < R:
... | ConDefects/ConDefects/Code/abc330_b/Python/54726392 |
condefects-python_data_1094 | N, L, R = map(int, input().split())
A = sorted([*map(int, input().split())])
for a in A:
if a <= L:
print(L, end=' ')
elif a >= R:
print(R, end=' ')
else:
print(a, end=' ')
N, L, R = map(int, input().split())
A = [*map(int, input().split())]
for a in A:
if a <= L:
pri... | ConDefects/ConDefects/Code/abc330_b/Python/55040608 |
condefects-python_data_1095 | N, L, R = map(int, input().split())
a = list(map(int, input().split()))
ans = []
for i in a:
if i < L:
ans.append(L)
elif i > L and i < R:
ans.append(i)
else:
ans.append(R)
print(*ans)
N, L, R = map(int, input().split())
a = list(map(int, input().split()))
ans = []
for i in a:
... | ConDefects/ConDefects/Code/abc330_b/Python/54214263 |
condefects-python_data_1096 | A, B = input().split()
A, B = int(A), int(B)
res = A^B + B^A
print(res)
A, B = input().split()
A, B = int(A), int(B)
res = (A**B) + (B**A)
print(res) | ConDefects/ConDefects/Code/abc320_a/Python/55169721 |
condefects-python_data_1097 | a, b, c = map(int,input().split())
l = [a,b,c]
l_2 = sorted(l)
if b == l_2[1]:
print("Yes")
else:
print("no")
a, b, c = map(int,input().split())
l = [a,b,c]
l_2 = sorted(l)
if b == l_2[1]:
print("Yes")
else:
print("No") | ConDefects/ConDefects/Code/abc253_a/Python/45454292 |
condefects-python_data_1098 | a, b, c = map(int, input().split())
if (a + c) // 2 == b:
print('Yes')
else:
print('No')
a, b, c = map(int, input().split())
if a <= b <= c or c <= b <= a:
print('Yes')
else:
print('No')
| ConDefects/ConDefects/Code/abc253_a/Python/45510646 |
condefects-python_data_1099 | n,m,e=map(int,input().split())
s=[list(map(int,input().split())) for i in range(e)]
q=int(input())
event=[int(input()) for i in range(q)]
p=set()
for i in range(e):
s[i][0]-=1
s[i][1]-=1
for i in range(q):
event[i]-=1
for k in event:
p.add(k)
#unionfind#
from collections import defaultdict
class UnionFind():
... | ConDefects/ConDefects/Code/abc264_e/Python/45504321 |
condefects-python_data_1100 | import bisect, collections, copy, heapq, itertools, math, sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
# P = 10**9+7
P = 998244353
N, M = map(int, input().split())
S = [list(map(int, input().split())) for _ in range(N+M)]
dp = [[10**20]*(N+M) for _ in range(1<<(N+M))]
q = collections.deque([])
for i in... | ConDefects/ConDefects/Code/abc274_e/Python/45512531 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.