id
stringlengths
24
27
content
stringlengths
37
384k
max_stars_repo_path
stringlengths
51
51
condefects-python_data_1801
import sys input = sys.stdin.readline def ip():return int(input()) def mp():return map(int, input().split()) def lmp():return list(map(int, input().split())) # ABC250 E 1421 - Prefix Equality N = ip() A = lmp() B = lmp() aset = set() bset = set() xorset = set() # xorset: A, B どちらかだけに含まれる要素の集合 bp = 0 same = [False] * (N...
ConDefects/ConDefects/Code/abc250_e/Python/44674065
condefects-python_data_1802
from collections import defaultdict n=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) ans=[[0,-1] for _ in range(n)] nowa=set() nowb=set() notcheck=set() d=defaultdict(int) cnt=0 for i in range(n): if a[i] in notcheck: notcheck.remove(a[i]) if notcheck: ans[i][0]=ans[i-1...
ConDefects/ConDefects/Code/abc250_e/Python/46017900
condefects-python_data_1803
def func(): pattern1 = ["H","D","C","S"] pattern2 = ["A","2","3","4","5","6","7","8","9","T","J","Q","K"] pat_set = set() # 入力を取得 N = int(input()) for n in range(N): s = input() if (not(s[0] in pattern1)) or (not(s[1] in pattern2)) or (not(s in pat_set)): print("No") ...
ConDefects/ConDefects/Code/abc277_b/Python/45992139
condefects-python_data_1804
n=int(input()) a=[] b=['H', 'D', 'C', 'S'] first = set(b) second = set(['A', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K']) tmp = set() answer = "Yes" for i in range(n): c=input() if (c[0] not in first or c[1] not in second or c in tmp): answer = "No" tmp.add(c) print(answer) n...
ConDefects/ConDefects/Code/abc277_b/Python/45577199
condefects-python_data_1805
n = int(input()) one = ["H", "D", "C", "S"] two = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "T", "J", "Q", "K"] spawned = [] for i in range(n): s = input() if not s[0] in one or not s[1] in two or not s in spawned: print("No") exit(0) else: spawned.append(s) print("Yes") n...
ConDefects/ConDefects/Code/abc277_b/Python/46214171
condefects-python_data_1806
import sys ipt = sys.stdin.readline N,Q = map(int,ipt().split()) A = list(map(int,ipt().split())) query = [] for i in range(Q): q = list(map(int,ipt().split()))+[i] query.append(q) query.sort(key=lambda x:x[1]) ans = [None]*Q B = [0]*60 S = [0]*60 D = [] def GEM(X,idx,L=None): """ Gaussian Eliminati...
ConDefects/ConDefects/Code/abc223_h/Python/26668974
condefects-python_data_1807
from collections import defaultdict class UnionFind: def __init__(self,N,label=None,f=None,weighted=False,rollback=False): self.N=N self.parents=[None]*self.N self.size=[1]*self.N self.roots={i for i in range(self.N)} self.label=label if self.label!=None: ...
ConDefects/ConDefects/Code/abc335_e/Python/55029036
condefects-python_data_1808
from collections import deque, defaultdict, Counter from bisect import bisect_left, bisect_right from atcoder.segtree import SegTree from atcoder.lazysegtree import LazySegTree from atcoder.dsu import DSU from atcoder.scc import SCCGraph from itertools import permutations, combinations from heapq import heappop, heappu...
ConDefects/ConDefects/Code/abc335_e/Python/54715880
condefects-python_data_1809
def chmax(A, idx, val): if A[idx] < val: A[idx] = val from atcoder.dsu import DSU INF = float("INF") N, M = map(int, input().split()) A = list(map(int, input().split())) G = [[] for v in range(N)] uf = DSU(N) for _ in range(M): a, b = map(lambda x: int(x) - 1, input().split()) G[a].append(b) G[b].append(a...
ConDefects/ConDefects/Code/abc335_e/Python/54978942
condefects-python_data_1810
n_strings = int(input()) data = [] for i in range(n_strings): info = input().split() data.append((info[0], int(info[1]))) max_strings = set() max_score = 0 max_index = 0 for i in range(n_strings): string, score = data[i] if score > max_score and string not in max_strings: max_score = score ...
ConDefects/ConDefects/Code/abc251_c/Python/44644261
condefects-python_data_1811
n, k = map(int, input().split()) s = [input() for _ in range(n)] s.sort() for i in range(k): print(s[i]) n, k = map(int, input().split()) s = [input() for _ in range(k)] s.sort() for i in range(k): print(s[i])
ConDefects/ConDefects/Code/abc288_b/Python/44592257
condefects-python_data_1812
a,b=map(int,input().split()) c=[] for i in range(a): c.append(str(input())) c.sort() c=c[0:b] for i in c: print(i) a,b=map(int,input().split()) c=[] for i in range(a): c.append(str(input())) c=c[0:b] c.sort() for i in c: print(i)
ConDefects/ConDefects/Code/abc288_b/Python/45965822
condefects-python_data_1813
N, K = map(int, input().split()) A = list(map(int, input().split())) d = {} for a in A: if a not in d: d[a] = 0 d[a] += 1 n = 0 for a in d: n = max(n, d[a]) M = [] for a in d: if n == d[a]: M.append(a) M.sort() M.reverse() m = len(M) ans = M[m - 1] - M[0] + (N - n) * K for j in range(m -...
ConDefects/ConDefects/Code/agc065_a/Python/49045953
condefects-python_data_1814
x, y, z = map(int, input().split()) if x*y < 0: print(abs(x)) else: if abs(y) > abs(x): print(abs(x)) else: if x*z <0: print(abs(x)+2*abs(z)) else: if abs(z) < abs(x): print(abs(x)) else: print(-1) x, y, z = map(int, input().split()) if x*y < 0: print(abs(x)) els...
ConDefects/ConDefects/Code/abc270_b/Python/46011134
condefects-python_data_1815
x, y, z = map(int, input().split()) if y < 0 < x or y > 0 > x: print(abs(x)) elif 0 < y < x or 0 > y > x: if 0 < y < z or 0 > y > z: print(-1) elif 0 < z < x or 0 > z > x: print(abs(x)) else: print(abs(x) + abs(z) * 2) x, y, z = map(int, input().split()) if y < 0 < x or y > 0...
ConDefects/ConDefects/Code/abc270_b/Python/45342389
condefects-python_data_1816
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') X, Y, Z = MI() if X * Y > 0: if abs(X) < abs(Y): ...
ConDefects/ConDefects/Code/abc270_b/Python/46011140
condefects-python_data_1817
#!/usr/bin/env python3 x, y, z = [int(x) for x in input().split()] if (0 < x - y < x and x > 0) or (x < x - y < 0 and x < 0): if 0 < y - z < y: print(abs(x)) elif (y - z < 0 and y > 0) or (y - z > 0 and y < 0): print(-1) else: print(abs(z) * 2 + abs(x)) else: print(abs(x)) #!...
ConDefects/ConDefects/Code/abc270_b/Python/45519272
condefects-python_data_1818
n=int(input()) b=input().split() a=[int(i) for i in b] ans=a[0] sum_=0 for i in a: sum_+=i ans=min(ans,sum_) print(sum(a)-ans) n=int(input()) b=input().split() a=[int(i) for i in b] ans=0 sum_=0 for i in a: sum_+=i ans=min(ans,sum_) print(sum(a)-ans)
ConDefects/ConDefects/Code/abc339_c/Python/54709074
condefects-python_data_1819
n = int(input()) A = list(map(int, input().split())) B = [0]*n B[0] = A[0] mi = 0 for i in range(1,n): B[i] = B[i-1] + A[i] if B[i] < B[mi]: mi = i # print(B, mi) ans = sum(A[mi+1:]) print(ans) n = int(input()) A = list(map(int, input().split())) B = [0]*n B[0] = A[0] mi = 0 for i in range(1,n): B[i] = B[i-1...
ConDefects/ConDefects/Code/abc339_c/Python/54653451
condefects-python_data_1820
n = int(input()) A = list(map(int, input().split())) x = 0 s = 0 for i in A: s += i if s < 0: x = max(x, -s) s=0 print(sum(A) + x) n = int(input()) A = list(map(int, input().split())) x = 0 s = 0 for i in A: s += i if s < 0: x += (-s) s=0 print(sum(A) + x)
ConDefects/ConDefects/Code/abc339_c/Python/54915341
condefects-python_data_1821
n = int(input()) alist = list(map(int, input().split())) acc = 0 imin = 0 amin = 0 for i in range(n): acc += alist[i] if acc <= amin: amin = acc imin = i print(sum(alist[imin+1:])) n = int(input()) alist = list(map(int, input().split())) acc = 0 imin = -1 amin = 0 for i in range(n): acc += ...
ConDefects/ConDefects/Code/abc339_c/Python/54222445
condefects-python_data_1822
n = int(input()) a_s = list(map(int, input().split())) num = 0 passengers = [] current_passenger = 0 for i in range(len(a_s)): current_passenger = current_passenger + a_s[i] passengers.append(current_passenger) if min(passengers) >= 0: print(max(passengers)) else: print(passengers[-1] + abs(min(passe...
ConDefects/ConDefects/Code/abc339_c/Python/54873036
condefects-python_data_1823
# Perfect Bus def calc(N, A): start = 0 total = 0 for i in A: total += i if -start > total: start = -total print("total: " + str(total)) print("start: " + str(start)) return start + total def main(): N = int(input()) A = [int(i) for i in input().split...
ConDefects/ConDefects/Code/abc339_c/Python/54482593
condefects-python_data_1824
N = int(input()) A = list(map(int, input().split())) total = 0 min_diff = float('inf') for i in range(N): total += A[i] min_diff = min(min_diff, total) print(total + abs(min_diff)) N = int(input()) A = list(map(int, input().split())) total = 0 min_diff = 0 for i in range(N): total += A[i] min_diff...
ConDefects/ConDefects/Code/abc339_c/Python/54545063
condefects-python_data_1825
## https://atcoder.jp/contests/abc250/tasks/abc250_g MAX_INT = 10 ** 18 class LazySegmentTree: """ 非再帰版遅延セグメント木。 更新は「加法」、取得は「最大値」のもの限定。 取得のところの都合で取得演算子は可換になっている必要がある。 """ def __init__(self, init_array): n = 1 while n < len(init_array): n *= 2 self....
ConDefects/ConDefects/Code/abc250_g/Python/51402169
condefects-python_data_1826
from heapq import heappush,heappop n = int(input()) P = list(map(int,input().split())) ans = 0 cand_heapq = [] selled_heapq = [] for p in P: s1 = -1 s2 = -1 if cand_heapq and cand_heapq[0] < p: s1 = p-cand_heapq[0] elif selled_heapq and selled_heapq[0] < p: s2 = p-selled_hea...
ConDefects/ConDefects/Code/abc250_g/Python/31608048
condefects-python_data_1827
from heapq import * n = int(input()) p = list(map(int, input().split())) ans = 0 q = [] for v in p: if q and p[0] < v: ans += v - heappop(q) heappush(q, v) heappush(q, v) print(ans) from heapq import * n = int(input()) p = list(map(int, input().split())) ans = 0 q = [] for v in p: if q an...
ConDefects/ConDefects/Code/abc250_g/Python/36759156
condefects-python_data_1828
s = input() r = s[::-1] if s.find('B') % 2 == r.find('B') % 2: if s.find('R') < s.find('K') < 8 - s.find('R') + 1: print('Yes') exit() print('No') s = input() r = s[::-1] if s.find('B') % 2 == r.find('B') % 2: if s.find('R') < s.find('K') < 8 - r.find('R') + 1: print('Yes') exit...
ConDefects/ConDefects/Code/abc297_b/Python/46013217
condefects-python_data_1829
def main(): s = input() slist = list(s) if not "K" in s.split("R")[1]: print("No") return firstB = s.index("B") secondB = s.rindex("B") if firstB+secondB % 2 == 0: print("No") return print("Yes") if __name__ == "__main__": main() def main(): ...
ConDefects/ConDefects/Code/abc297_b/Python/45489946
condefects-python_data_1830
S = input() K = S.find('K') B1 = S.find('B') B2 = S.rfind('B') R1 = S.find('R') R2 = S.rfind('R') if B1+B2 % 2 != 0 and R1 < K < R2: print('Yes') else: print('No') S = input() K = S.find('K') B1 = S.find('B') B2 = S.rfind('B') R1 = S.find('R') R2 = S.rfind('R') if ((B1+B2) % 2) != 0 and (R1 < K < R2): ...
ConDefects/ConDefects/Code/abc297_b/Python/45577916
condefects-python_data_1831
n,m,k,s,t,x = map(int, input().split()) uvl = [list(map(int, input().split())) for _ in range(m)] mod = 998244353 from collections import defaultdict gd = defaultdict(set) for u,v in uvl: gd[u-1].add(v-1) gd[v-1].add(u-1) dp = [[[0] * 2 for i in range(n)] for j in range(k+1)] dp[0][s-1][0] = 1 for i in range(...
ConDefects/ConDefects/Code/abc244_e/Python/45970204
condefects-python_data_1832
class Input_kyopro: def II(self): return int(input()) def MI(self): return map( int,input().split()) def MS(self): return map(str,input().split()) def LMI(self): return list(self.MI()) def LMS(self): return list(self.MS()) def LLI(self,N): return [self.LMI() for _ in range(N)] def LLS(self,N...
ConDefects/ConDefects/Code/abc301_e/Python/45949713
condefects-python_data_1833
s = list(input()) t = list(input()) ans = [] idx = 0 for i in range(len(s)): for j in range(idx, len(t)): print(i,j) if s[i] == t[j]: print("A") ans.append(j+1) idx = j+1 break print(*ans) s = list(input()) t = list(input()) ans = [] idx = 0 for i in ...
ConDefects/ConDefects/Code/abc352_b/Python/54958483
condefects-python_data_1834
S = str(input()) T = str(input()) a = 0 b = [] c = [] for i in range(len(T)): if S[a] == T[i]: b.append(i+1) a+=1 else: pass c.append(b) print(c[0]) S = str(input()) T = str(input()) a = 0 b = [] c = [] for i in range(len(T)): if S[a] == T[i]: b.append(i+1) a+=1 else: pass c....
ConDefects/ConDefects/Code/abc352_b/Python/55135076
condefects-python_data_1835
s = input() s2 = input() x = 0 l = [] while len(l) != len(s): for i in range(len(s)): for j in range(x, len(s2)): if s[i] == s2[j]: l.append(j + 1) x = j break print(*l) s = input() s2 = input() x = 0 l = [] while len(l) != len(s): for i in ra...
ConDefects/ConDefects/Code/abc352_b/Python/55031255
condefects-python_data_1836
S = input() if len(set(S)) == 1: print(-1) elif len(set(S)) == 3: print(list(S)[0]) elif len(set(S)) == 2: S = list(S) s = S.count(S[0]) if s == 1: print(S[0]) else: print(S[1]) S = input() if len(set(S)) == 1: print(-1) elif len(set(S)) == 3: print(list(S)[0]) elif ...
ConDefects/ConDefects/Code/abc260_a/Python/45791402
condefects-python_data_1837
S = input() for i in range(2): if S.count(S[i]) == 1: exit(print(S[i])) print(-1) S = input() for i in range(3): if S.count(S[i]) == 1: exit(print(S[i])) print(-1)
ConDefects/ConDefects/Code/abc260_a/Python/45479937
condefects-python_data_1838
N, M, K = list(map(int, input().split())) C = [] A = [] X = [] for _ in range(M): buf = input().split() C.append(int(buf[0])) A.append(list(map(int, buf[1:-1]))) X.append(buf[-1]) ans = 0 for bit in range(1, 1<<N): flg = True for i in range(M): cnt = 0 for j in range(C[i]): ...
ConDefects/ConDefects/Code/abc356_c/Python/55144138
condefects-python_data_1839
def main(): n, m, k = map(int, input().split()) Tests = [] for _ in range(m): _, *A, r = input().split() A = list(map(int, A)) Tests.append((A, r)) ans = 0 for i in range(2**n): ok = True if i.bit_count() < k: continue for test in Tests: ...
ConDefects/ConDefects/Code/abc356_c/Python/54920982
condefects-python_data_1840
N,M,K = map(int,input().split()) C_List = [] A_list_list = [] R_list = [] for _ in range(M): tmp = list(input().split()) C_List.append(int(tmp[0])) R_list.append(tmp[-1]) tmp_a = tmp[1:-1] tmp_a = list(map(int,tmp_a)) A_list_list.append(tmp_a) ret = 0 for i in range(2**N + 1): for A_list,r ...
ConDefects/ConDefects/Code/abc356_c/Python/54900882
condefects-python_data_1841
n,m,k=map(int,input().split()) C=[0 for _ in range(m)] A=[[0 for _ in range(n)] for _ in range(m)] R=[False for _ in range(m)] for i in range(m): X=list(map(str, input().split())) C[i]=int(X[0]) r=X[-1] if r=="o": R[i]=True xx=[int(X[j]) for j in range(1,C[i]+1)] for j in range(n): if j+1 in xx: ...
ConDefects/ConDefects/Code/abc356_c/Python/54940782
condefects-python_data_1842
import sys # sys.setrecursionlimit(200005) # sys.set_int_max_str_digits(200005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline()...
ConDefects/ConDefects/Code/abc306_g/Python/45483518
condefects-python_data_1843
N=int(input()) A=list(map(int,input().split())) cnt=[0]*4 for Ai in A: cnt[Ai-1]+=1 mat=[[0]*4 for _ in range(4)] now=0 for Ai in A: if cnt[now]==0: now+=1 mat[now][Ai-1]+=1 cnt[now]-=1 ans=0 for i in range(4): mat[i][i]=0 for j in range(i): m=min(mat[i][j],mat[j][i]) ans+=m mat[i][j]-=m ; mat[j...
ConDefects/ConDefects/Code/abc302_g/Python/41709058
condefects-python_data_1844
from itertools import * N=int(input()) A=list(map(int, input().split())) A=[a-1 for a in A] B=list(sorted(A)) L=4 C=[0]*(L**2) for a,b in zip(A,B): if a!=b: C[a*L+b]+=1 res=0 for p in permutations(range(4),2): x,y=p cnt=min(C[x*L+y],C[y*L+x]) C[x*L+y]-=cnt C[y*L+x]-=cnt res+=cnt for...
ConDefects/ConDefects/Code/abc302_g/Python/41887698
condefects-python_data_1845
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/abc302_g/Python/41876580
condefects-python_data_1846
N = int(input()) S = str(1) if N == 1: print(S) for i in range(2, N+1): S = S +" "+ str(i) + " " + S print(S) N = int(input()) S = str(1) if N == 1: exit(print(S)) for i in range(2, N+1): S = S +" "+ str(i) + " " + S print(S)
ConDefects/ConDefects/Code/abc247_c/Python/45240043
condefects-python_data_1847
li = [] def write(n): if n == 1: return [1] else: return write(n-1) + [n] + write(n-1) n = int(input()) write(n) li = [] def write(n): if n == 1: return [1] else: return write(n-1) + [n] + write(n-1) n = int(input()) print(*write(n))
ConDefects/ConDefects/Code/abc247_c/Python/45710087
condefects-python_data_1848
import sympy for n in[*open(0)][1:]:a,b=sympy.factorint(n:=int(n));print(*[b,a][::-1**(n%b**2>0)]) import sympy for n in[*open(0)][1:]:a,b=sympy.factorint(n:=int(n));print(*[b,a][::1-(n%b**2>0)*2])
ConDefects/ConDefects/Code/abc284_d/Python/45300656
condefects-python_data_1849
h,w,a,b = map(int,input().split()) def f(h,w,a,b): if a > b: return [(y,x) for x,y in f(w,h,b,a)] if h == 1: return [(0,y) for y in range(w)] if h == 2 and (a,b) == (1,1): return [(0,0),(1,0)]+[(x,y+1) for x,y in f(2,w-1,1,0)] return [(x,0) for x in range(h)]+[(h-1-x,y+1) for x,y in f(h,w-1,h-1-a,b-...
ConDefects/ConDefects/Code/abc232_h/Python/28052217
condefects-python_data_1850
import sys # sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): retu...
ConDefects/ConDefects/Code/abc232_h/Python/28235852
condefects-python_data_1851
a=[*map(int, input().split())] a[a[a[0]]] a=[*map(int, input().split())] print(a[a[a[0]]])
ConDefects/ConDefects/Code/abc241_a/Python/46045206
condefects-python_data_1852
from bisect import bisect_left tri = [(i * i - i) // 2 for i in range(2000)] N = int(input()) vals = [] for i in range(7): u = bisect_left(tri, N + 1) - 1 print(N, u, tri[u]) vals.extend([i] * u) N -= tri[u] assert N == 0 assert vals[0] == 0 curr = vals.pop(0) out = [] mult = 1 for v in vals:...
ConDefects/ConDefects/Code/arc129_c/Python/43964198
condefects-python_data_1853
N = int(input()) ans = [] now = 0 count = 0 while N>0: for i in range(2000): if (i+1)*(i+2)//2 > N: N -= i*(i+1)//2 break ans.append("7"*i) now += i delim = pow(10,5*now,7) if delim==0: delim = 7 now += 1 ans.append(str(delim)) count += 1 if co...
ConDefects/ConDefects/Code/arc129_c/Python/35701293
condefects-python_data_1854
def solve(n, vs): ans = [] l = 0 while (l+1)*(l+2)//2 <= n: l += 1 ans.append('7'*l) n -= l*(l+1)//2 if n: for i in range(l): for j in range(len(vs)): vs[j] = (vs[j]*10+7)%7 nxt = 1 while nxt < 10: b = ((nxt%7)!=0) ...
ConDefects/ConDefects/Code/arc129_c/Python/34289751
condefects-python_data_1855
from collections import deque li=[i*(i+1)//2 for i in range(1,2000)] N=int(input()) ans=[] now=N for j in range(1998,-1,-1): for k in range(now//li[j]): ans.append(j+1) now%=li[j] fin_ans=deque() for ai in ans: for _ in range(ai): fin_ans.appendleft("7") fin_ans.appendleft(str((3*len(fin_ans)-3)%7)) p...
ConDefects/ConDefects/Code/arc129_c/Python/39744798
condefects-python_data_1856
import time ts = time.perf_counter_ns() import sys dsum = 0 def search_p(n): global dsum for p in range(3,400000,2): if p*p>n: dsum += p//2 - 1 return 0 elif n%p<1: dsum += p//2 return p sys.stdin.readline() for s in sys.stdin.readlines(): n...
ConDefects/ConDefects/Code/arc165_a/Python/45736644
condefects-python_data_1857
a=list(map(int,input().split())) ans=[] for i in range(12): i+=1 s=a.count(i) if s==0: continue ans.append(s) if (len(ans)==2)and((ans[0]==3 and ans[1]==2)or(ans[0]==2 and ans[1]==3)): print("Yes") else: print("No") a=list(map(int,input().split())) ans=[] for i in range(13): i+=1 ...
ConDefects/ConDefects/Code/abc263_a/Python/44922329
condefects-python_data_1858
def main(): cards = list(map(int, input().split())) assert len(cards) == 5 cards.sort() if cards[0] == cards[1] and cards[0] == cards[2] and cards[0] != cards[3] and cards[3] == cards[4]: print("Yes") else: print("No") if __name__ == "__main__": main() def main(): cards ...
ConDefects/ConDefects/Code/abc263_a/Python/44884204
condefects-python_data_1859
a=list(map(int,input().split())) a.sort() if ((a[0]==a[1] and a[1]==a[2]) and (a[3]==a[4])) or ((a[0]==a[1] and a[1]==a[2]) or (a[3]==a[4])): print("Yes") else: print("No") a=list(map(int,input().split())) a.sort() if ((a[0]==a[1] and a[1]==a[2]) and (a[3]==a[4])) or ((a[0]==a[1]) and (a[2]==a[3] and a[3]==a[4])):...
ConDefects/ConDefects/Code/abc263_a/Python/45528012
condefects-python_data_1860
x=list(map(int,input().split())) if len(set(x))==2: print("Yes") else: print("No") x=list(map(int,input().split())) if len(set(x))==2 and x.count(list(set(x))[0])>=2: print("Yes") else: print("No")
ConDefects/ConDefects/Code/abc263_a/Python/45002191
condefects-python_data_1861
K = sorted(list(map(int, input().split()))) if len(set(K)) == 2 and K[2] != K[3]: print('Yes') else: print('No') K = sorted(list(map(int, input().split()))) if len(set(K)) == 2 and (K[2] != K[3] or K[1] != K[2]): print('Yes') else: print('No')
ConDefects/ConDefects/Code/abc263_a/Python/45986379
condefects-python_data_1862
from collections import defaultdict count = defaultdict(int) A=list(map(int, input().split())) for i in range(len(A)): count[A[i]] += 1 a = count.values() a = list(a) if 2 < len(count.values()): print("No") elif a[0] == 3 or a[1] == 3: print("YES") else: print("No") from collections import defaultdict c...
ConDefects/ConDefects/Code/abc263_a/Python/45972944
condefects-python_data_1863
n=int(input()) s=input() s=list(s) cnt=0 for i in range(n): if s[i]=='"': cnt+=1 if s[i]==",": if cnt%2==1: s[i]="." ans="" for i in range(n): ans+=s[i] print(ans) n=int(input()) s=input() s=list(s) cnt=0 for i in range(n): if s[i]=='"': cnt+=1 if s[i]==",": ...
ConDefects/ConDefects/Code/abc282_c/Python/44818334
condefects-python_data_1864
# coding: utf-8 #import import random import os import operator from operator import add,sub,mul,xor,or_,and_ import time import sys import re import string import math from fractions import Fraction import inspect from math import sqrt,ceil,floor,gcd,log,log2 import collections from collections import defaultdict,dequ...
ConDefects/ConDefects/Code/abc254_e/Python/44452913
condefects-python_data_1865
# BFS import collections N, M = map(int, input().split()) AB = [list(map(int, input().split())) for _ in range(M)] Q = int(input()) XK = [list(map(int, input().split())) for _ in range(Q)] graph = collections.defaultdict(list) for i in range(0, M): a = AB[i][0] b = AB[i][1] graph[a].append(b) graph[b...
ConDefects/ConDefects/Code/abc254_e/Python/44691275
condefects-python_data_1866
def solve(n, m, a, b): # 0-indexへ変換 a = [_-1 for _ in a] b = [_-1 for _ in b] # 対角要素とのズレがどれぐらいのパターンを使っているか S = set() # m個のパターンが必要 for i, j in zip(a, b): S.add((i+j) % n) i = 0 while len(S) < m: S.add(i) i += 1 # パターンごとにn個のマスを埋められる(i+j = d mod nとなる(i,j)のペア) ...
ConDefects/ConDefects/Code/arc176_a/Python/55031190
condefects-python_data_1867
N,M = map(int,input().split()) S = set() for _ in range(M): A,B = map(int,input().split()) S.add((A+B)%N) for i in range(M+1): if len(S)==M: break S.add(i) print(N*M) for v in S: for a in range(N): print(a+1,(v-a)%N+1) N,M = map(int,input().split()) S = set() for _ in range(M): A,B = map(int,input(...
ConDefects/ConDefects/Code/arc176_a/Python/53542158
condefects-python_data_1868
N, M = map(int,input().split()) print(N*M) L = [0]*N count = 0 for _ in range(M): a, b = map(int,input().split()) d = (a-b)%N if L[d]==1: continue for _ in range(N): print(a,b) a += 1 b += 1 if a==N+1: a=1 if b==N+1: b=1 L[d]=1 count += 1 for i in range(M): if count==...
ConDefects/ConDefects/Code/arc176_a/Python/53668393
condefects-python_data_1869
N, M = map(int, input().split()) S = set() for _ in range(M): a, b = map(int, input().split()) a -= 1; b -= 1 S.add((a+b)%N) T = len(S) - M for i in range(N): if T == 0: break if not i in S: T -= 1 S.add(i) ret = [] for i in S: for j in range(N): ret.append((j, (i - j) ...
ConDefects/ConDefects/Code/arc176_a/Python/53516629
condefects-python_data_1870
def solve(n, m, a, b): # 対角要素との列の位置ズレが異なるm種を用意 S = set([(i+j)%n for i, j in zip(a, b)]) for i in range(n): if len(S) == m: break S.add(i) # ズレごとのマスを埋めていく ans = [] for d in S: for i in range(n): j = (d - i) % n ans.append((i+1, j+1)) ...
ConDefects/ConDefects/Code/arc176_a/Python/55106959
condefects-python_data_1871
A=int(input()) B=int(input()) print(str(A)+str(B*10//2)) A=int(input()) B=int(input()) print(str(A)+"0"+str(B*10//2))
ConDefects/ConDefects/Code/arc131_a/Python/45453669
condefects-python_data_1872
a=input() b=str(int(input())*5) print('1'+a+b) a=input() b=str(int(input())*5) print(a+'0'+b)
ConDefects/ConDefects/Code/arc131_a/Python/43033195
condefects-python_data_1873
a = int(input()) b = int(input()) print(str(a)+str(b*5)) a = int(input()) b = int(input()) print(str(a)+"0"+str(b*5))
ConDefects/ConDefects/Code/arc131_a/Python/44093333
condefects-python_data_1874
a = input() b = input() ans = a if int(b)%2==1: ans += str(int(b+"0")//2) else: ans += str(int(b)//2) print(ans) a = input() b = input() ans = a+"0" if int(b)%2==1: ans += str(int(b+"0")//2) else: ans += str(int(b)//2) print(ans)
ConDefects/ConDefects/Code/arc131_a/Python/42234750
condefects-python_data_1875
a=input() b=input() print (a+str(int(b)*5)) a=input() b=input() print (str(int(b)*5)+a)
ConDefects/ConDefects/Code/arc131_a/Python/45086721
condefects-python_data_1876
A = int(input()) B = int(input()) if B%2==1: B *= 10 C = B//2 # A = list(str(A)) # print(A) D = len(str(C)) print(A*(10**D)+C) A = int(input()) B = int(input()) if B%2==1: B *= 10 C = B//2 # A = list(str(A)) # print(A) D = len(str(C))+1 print(A*(10**D)+C)
ConDefects/ConDefects/Code/arc131_a/Python/42235783
condefects-python_data_1877
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/abc222_g/Python/45118973
condefects-python_data_1878
def factor(x): d=[] e=[] for i in range(1,x+1): if i*i>x: break if i*i==x: d.append(i) break if x%i==0: d.append(i) e.append(x//i) return d+e[::-1] def make_prime(N): #O(NloglogN) Plist=[] L=[0]*(N+1) for i ...
ConDefects/ConDefects/Code/abc222_g/Python/50712644
condefects-python_data_1879
from math import sqrt def gcd2(a, b): x, y, lx, ly = 0, 1, 1, 0 while b != 0: q = a // b a, b = b, a % b x, y, lx, ly = lx - q * x, ly - q * y, x, y return (lx, ly) def inv(n, p): return gcd2(n, p)[0] % p def solve(k): if k <= 2: return 1 if not (k & 1): ...
ConDefects/ConDefects/Code/abc222_g/Python/45276473
condefects-python_data_1880
def resolve(): import sys input = sys.stdin.readline t = int(input()) for _ in range(t): k = int(input()) if k == 1: print(1) continue m = 9 * k if k % 2 else 9 * k // 2 try: ans = bsgs(10, pow(10, -1, m), m) print(ans + 2...
ConDefects/ConDefects/Code/abc222_g/Python/49217735
condefects-python_data_1881
T = int(input()) for _ in range(T): N,K = map(int,input().split()) P = [0,0]+list(map(int,input().split())) A = [0]+list(map(int,input().split())) G = {i:[] for i in range(1,N+1)} for i in range(2,N+1): G[P[i]].append(i) lack = {i:[True,0,set()] for i in range(1,N+1)} B = set(range(K...
ConDefects/ConDefects/Code/arc162_c/Python/45998728
condefects-python_data_1882
import math import heapq import itertools import bisect import random import time from collections import deque import sys from cmath import exp,pi from functools import cmp_to_key input=sys.stdin.readline def check(line): line.sort() p=0 cnt=0 for i in line: if p==i: p+=1 if p=...
ConDefects/ConDefects/Code/arc162_c/Python/43399874
condefects-python_data_1883
from collections import deque T = int(input()) for _ in range(T): N,K = map(int, input().split()) P = [int(p) for p in input().split()] A = [int(a) for a in input().split()] E = [[] for _ in range(N)] for i in range(N-1): E[P[i]-1].append(i+1) ans = "Bob" for i in range(N): ...
ConDefects/ConDefects/Code/arc162_c/Python/43410315
condefects-python_data_1884
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 stdin from bisect import * from heapq import * #import numpy as np # from math import * g = lambda : st...
ConDefects/ConDefects/Code/arc162_c/Python/43234436
condefects-python_data_1885
import sys sys.setrecursionlimit(1000000000) t=int(input()) s=[[]for i in range(2002)] a=[] def mdfs(x,y,z): p=[0for i in range(y+2)] for i in s[x]: (f,d)=mdfs(i,y,z) if f: return (1,p) p[0]+=d[0] if p[0]>1: return(0,p) for j in range(1,y+2): ...
ConDefects/ConDefects/Code/arc162_c/Python/45291562
condefects-python_data_1886
t = int(input()) for _ in range(t): n, k = map(int, input().split()) p = [ -1 ] + list(map(lambda x: int(x) - 1, input().split())) a = list(map(int, input().split())) for i in range(n): if a[i] == -1: a[i] = n + 1 dp = [ [ 0 ] * (n + 2) for i in range(n) ] for i in range(n): dp[i][a[i]] += 1 answer = Fals...
ConDefects/ConDefects/Code/arc162_c/Python/45663637
condefects-python_data_1887
import sys sys.setrecursionlimit(10**7) input = sys.stdin.readline import pypyjit pypyjit.set_param('max_unroll_recursion=-1') def mp():return map(int,input().split()) def lmp():return list(map(int,input().split())) def lm1(LIST): return list(map(lambda x:x-1, LIST)) def mps(A):return [tuple(map(int, input().split())) ...
ConDefects/ConDefects/Code/arc162_c/Python/44163778
condefects-python_data_1888
class SegTree: def __init__(self, init_list, func=lambda x,y: x+y, ide_ele=0): self.n = len(init_list) self.length = 1<<(self.n-1).bit_length() self.node_list = [ide_ele]*(2*self.length) self.func = func self.ide_ele = ide_ele for i in range(self.n): self....
ConDefects/ConDefects/Code/arc162_c/Python/43723091
condefects-python_data_1889
import sys sys.setrecursionlimit(1000000) t = int(input()) def dfs(x): for y in edges[x]: dfs(y) sizes[x] += sizes[y] nums[x] += nums[y] sizes[x] += 1 nums[x].append(A[x]) for _ in range(t): n, k = map(int, input().split()) P = [-1]+list(map(lambda x: int(x)-1, input().sp...
ConDefects/ConDefects/Code/arc162_c/Python/43008956
condefects-python_data_1890
import sys sys.setrecursionlimit((1<<19)-1) def dfs(pos): global ans cnt=0 less=set() for i in tree[pos]: tocnt,toless=dfs(i) cnt+=tocnt less=less|toless if A[pos]==-1: cnt+=1 elif A[pos]<=K: less.add(pos) if K not in less and len(less)>=K-cnt and cnt...
ConDefects/ConDefects/Code/arc162_c/Python/45802611
condefects-python_data_1891
## https://atcoder.jp/contests/abc294/tasks/abc294_g from collections import deque class BinaryIndexTree: """ フェニック木(BinaryIndexTree)の基本的な機能を実装したクラス """ def __init__(self, size): self.size = size self.array = [0] * (size + 1) def add(self, x, a): index = x whil...
ConDefects/ConDefects/Code/abc294_g/Python/53664226
condefects-python_data_1892
import sys; sys.setrecursionlimit(10**6); import pypyjit; pypyjit.set_param('max_unroll_recursion=-1') class DubTree: def __init__(self,N): self.N, self.K = N, 1 while (1<<self.K)<N : self.K += 1 self.node,self.wei = [None]*self.N, [None]*self.N self.edge = [[] for n in range(self.N...
ConDefects/ConDefects/Code/abc294_g/Python/50893680
condefects-python_data_1893
from heapq import heappop, heappush class Set: def __init__(self): self.q = [] self.d = [] self.sm = 0 def add(self, x): heappush(self.q, x) self.sm += x def delete(self, x): heappush(self.d, x) self.sm -= x def get_min(self): while se...
ConDefects/ConDefects/Code/abc314_g/Python/45264890
condefects-python_data_1894
from bisect import * import sys input=sys.stdin.readline #####segfunc##### def segfunc(x, y): return x+y #区間クエリでのfuncを設定 ################# #####ide_ele##### ide_ele =0 #クエリの単位元を設定 ################# class SegTree: """ init(init_val, ide_ele): 配列init_valで初期化 O(N) update(k, x): k番目の値をxに更新 O(log...
ConDefects/ConDefects/Code/abc314_g/Python/47095184
condefects-python_data_1895
def func(a,b): return pow(a,3) + pow(a,2) * b + a * pow(b,2) + pow(b,3) n = int(input()) if n == 0: print(0) exit() ans = float("inf") a = 0 b = int(pow(n, 1/3)) + 1 x = func(a,b) while a <= b: tempx = func(a,b) if tempx >= n: b -= 1 x = tempx else: if ans > x: ...
ConDefects/ConDefects/Code/abc246_d/Python/45450422
condefects-python_data_1896
N=int(input()) def func(a,b): return (a+b)*(a**2+b**2) def bs(a,N): left_b=a right_b=10**6+10 center_b=(left_b+right_b)//2 if func(a,left_b)>=N: return left_b while right_b-left_b>1: if func(a,center_b)<=N: left_b=max(center_b,left_b+1) center_b=(left_b+r...
ConDefects/ConDefects/Code/abc246_d/Python/45753152
condefects-python_data_1897
def calc(a, b): return a * a * a + a * a * b + a * b * b + b * b * b N = int(input()) ans = 10 ** 20 for a in range(10 ** 6): lb = a ub = 10 ** 6 while ub - lb > 1: mid = (ub + lb) // 2 if calc(a, mid) >= N: ub = mid else: lb = mid ans = min(ans, calc...
ConDefects/ConDefects/Code/abc246_d/Python/45067622
condefects-python_data_1898
n = int(input()) def f(a, b): return a **3 + a**2*b + a*b**2 + b**3 def binary_search(a): left = 1 right = 10 ** 6+1 while left < right: mid = (left + right) // 2 if f(a, mid) >= n: right = mid else: left = mid + 1 return left ans = 10**...
ConDefects/ConDefects/Code/abc246_d/Python/45897602
condefects-python_data_1899
n = int(input()) def f(a, b): return a*a*a + a*a*b + a*b*b + b*b*b ni = 10**6 ans = float('inf') for a in range(1, ni+1): l = -1 r = 10**6+1 while r - l > 1: b = (r+l) // 2 if f(a, b) < n: l = b else: r = b ans = min(ans, f(a, r)) print(ans) n = int...
ConDefects/ConDefects/Code/abc246_d/Python/45039073
condefects-python_data_1900
N = int(input()) def calc(m, n): return (m**2+n**2)*(m+n) cand = set() for a in range(10**6+1): l,r = 0, 10**6+10 while r-l>1: m = (l+r)//2 if calc(a,m)>=N: r = m else: l = m cand.add(calc(a,r)) print(min(cand)) N = int(input()) def calc(m, n): ...
ConDefects/ConDefects/Code/abc246_d/Python/45469208