id
stringlengths
24
27
content
stringlengths
37
384k
max_stars_repo_path
stringlengths
51
51
condefects-python_data_2601
K = int(input()) for i in range(K): print(chr(64 + i), end='') K = int(input()) for i in range(K): print(chr(65 + i), end='')
ConDefects/ConDefects/Code/abc282_a/Python/44657009
condefects-python_data_2602
import bisect import sys import math import itertools from collections import deque import queue from functools import cache from collections import defaultdict sys.setrecursionlimit(100000000) sys.getrecursionlimit() #input = sys.stdin.readline from heapq import heappop,heappush from bisect import bisect_left, bisect_...
ConDefects/ConDefects/Code/abc273_c/Python/52009785
condefects-python_data_2603
from collections import * import sys import heapq import bisect import itertools from functools import lru_cache import math import copy sys.setrecursionlimit(int(1e7)) dxdy1 = ((0, 1), (0, -1), (1, 0), (-1, 0)) dxdy2 = ((0, 1), (0, -1), (1, 0), (-1, 0), (1, 1), (-1, -1), (1, -1), (-1, 1)) dxdy3 = ((0, 1), (1, 0)) dx...
ConDefects/ConDefects/Code/abc251_f/Python/47833391
condefects-python_data_2604
MOD = 998244353 def mod_inv(x, m): a, b, c, d = x, 1, m-x, m-1 while c != 1: if c == 0: print(x, m) e, f = divmod(a, c) a, b, c, d = c, d, f, (b-e*d)%m return d F = [0]*(10**4+2) def init_factors(): F[0] = 1 x = 1 for i in range(1, 10**4+2): ...
ConDefects/ConDefects/Code/abc256_g/Python/32688484
condefects-python_data_2605
from collections import defaultdict, deque, Counter from itertools import combinations, permutations, product, accumulate from heapq import heapify, heappop, heappush import math import bisect import sys # sys.setrecursionlimit(700000) input = lambda: sys.stdin.readline().rstrip('\n') inf = float('inf') mod1 = 10**9+7 ...
ConDefects/ConDefects/Code/abc247_g/Python/39496981
condefects-python_data_2606
s = input() t = input() for i in range(len(s)): if s[i] != t[i]: print(i + 1) exit() print(1) s = input() t = input() for i in range(len(s)): if s[i] != t[i]: print(i + 1) exit() print(len(t))
ConDefects/ConDefects/Code/abc280_c/Python/46198348
condefects-python_data_2607
s, t = input(), input() for i in range(len(s)): if s[i] != t[i]: print(i+1) break s, t = input() + "0", input() for i in range(len(s)): if s[i] != t[i]: print(i+1) break
ConDefects/ConDefects/Code/abc280_c/Python/45414208
condefects-python_data_2608
# ansmod = 10 ** 9 + 7 # ansmod = 998244353 import sys def main(f): s = f.readline()[:-1] t = f.readline()[:-1] for id, i in enumerate(s): if i != t[id]: return id + 1 return id + 1 if __name__ == "__main__": print(main(sys.stdin)) # print(main(sys.stdin) % ansmod) #...
ConDefects/ConDefects/Code/abc280_c/Python/46197892
condefects-python_data_2609
S = list(input()) T = list(input()) for i in range(len(T)): if i == len(T)-1: ans = i break if S[i] != T[i]: ans = i+1 break print(ans) S = list(input()) T = list(input()) for i in range(len(T)): if i == len(T)-1: ans = i+1 break if S[i] != T[i]: ...
ConDefects/ConDefects/Code/abc280_c/Python/45722893
condefects-python_data_2610
import sys from math import sqrt input = lambda: sys.stdin.buffer.readline().rstrip() from typing import Generic, Iterable, TypeVar, Deque from collections import deque T = TypeVar('T') class SlidingWindowMinimum(Generic[T]): def __init__(self, a: Iterable[T], k: int): self.a = list(a) self.n = len(self.a)...
ConDefects/ConDefects/Code/abc334_f/Python/50685006
condefects-python_data_2611
def segfunc(x, y): return min(x,y) ide_ele = 100000000000 class segtree: def __init__(self, init_val, segfunc, ide_ele): n = len(init_val) self.segfunc = segfunc self.ide_ele = ide_ele self.num = 1 << (n - 1).bit_length() self.tree = [ide_ele] * 2 * self.num ...
ConDefects/ConDefects/Code/abc334_f/Python/49407992
condefects-python_data_2612
import sys sys.set_int_max_str_digits(0) #####segfunc##### def segfunc(x, y): return min(x,y) ################# inf=5*10**14 #####ide_ele##### ide_ele = inf ################# class LazySegmentTree: """ init(init_val, ide_ele): 配列init_valで初期化 O(N) add(l, r, x): 区間[l, r)にxを加算 O(logN) query(l, r): 区間...
ConDefects/ConDefects/Code/abc334_f/Python/53789974
condefects-python_data_2613
N,K=list(map(int, input().split())) Sx,Sy=list(map(int, input().split())) def segfunc(x, y): return min(x,y) ide_ele =10**15 class SegTree: """ init(init_val, ide_ele): 配列init_valで初期化 O(N) update(k, x): k番目の値をxに更新 O(logN) query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN) """ def __init__(self, in...
ConDefects/ConDefects/Code/abc334_f/Python/50005734
condefects-python_data_2614
from atcoder.segtree import SegTree N,K=map(int,input().split()) s=tuple(map(int,input().split())) C=[tuple(map(int,input().split())) for _ in range(N)] #from random import randint #N,K=200000,200000 #s=(randint(-10**9,10**9),randint(-10**9,10**9)) #C=[(randint(-10**9,10**9),randint(-10**9,10**9)) for _ in range(N)] de...
ConDefects/ConDefects/Code/abc334_f/Python/54979078
condefects-python_data_2615
N = int(input()) if N == 3: ans = [[5,9,1],[3,7,8],[6,2,4]] elif N == 5: ans = [[1,3,5,7,9],[11,13,15,17,19],[21,23,25,8,2],[4,10,14,6,12],[16,18,20,22,24]] else: odd1 = [] odd2 = [] evn1 = [] evn2 = [] for i in range(1, N*N+1): if i % 2 == 0: if i % 3 != 0: ...
ConDefects/ConDefects/Code/arc149_c/Python/39106363
condefects-python_data_2616
from collections import deque N=int(input()) ans=[] i=0 x=N**2 temp=[] mod=[deque([]) for _ in range(3)] while x>0: if x%2==1: temp.append(x) i+=1 else: mod[x%3].append(x) x-=1 if i==N: ans.append(temp) temp=[] i=0 l=len(temp) if l!=0: a=ans[-1][l] l1=l while temp[-1]%3!=ans[-1][l...
ConDefects/ConDefects/Code/arc149_c/Python/37254775
condefects-python_data_2617
n = int(input()) if n == 3: print(5, 9, 1) print(3, 7, 8) print(6, 2, 4) exit() if n == 4: print(9, 11, 13, 15) print(1, 3, 5, 7) print(8, 6, 10, 14) print(4, 2, 12, 16) exit() if n == 5: print(1, 5, 7, 11, 13) print(17, 25, 23, 19, 3) print(9, 15, 21, 6, 12) print...
ConDefects/ConDefects/Code/arc149_c/Python/45546378
condefects-python_data_2618
n = int(input()) if n == 3: ans = [[5,9,1],[3,7,8],[6,2,4]] elif n == 4: ans = [[15,11,16,12],[13,3,6,9],[14,7,8,1],[4,2,10,5]] elif n == 5: ans = [[1,7,11,13,17],[19,23,25,21,5],[3,9,15,24,10],[6,12,18,2,4],[8,10,14,16,20]] else: seen = [False for i in range(n ** 2 + 1)] ans = [0 for i in range(n ** 2)] l ...
ConDefects/ConDefects/Code/arc149_c/Python/37461602
condefects-python_data_2619
n, m = map(int, input().split()) G = [[] for _ in range(n)] for _ in range(m): a, b, c = map(int, input().split()) a -= 1 b -= 1 G[a].append((b, -c)) G[b].append((a, c)) used = [False for _ in range(n)] cost = [0 for _ in range(n)] def dfs(u, d): res = [u] used[u] = True cost[u] = d ...
ConDefects/ConDefects/Code/abc352_f/Python/53476783
condefects-python_data_2620
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/abc352_f/Python/54716291
condefects-python_data_2621
N = int(input()) P = [int(i) for i in input().split()] Q = int(input()) queries = [[int(i) for i in input().split()] for _ in range(Q)] # print(queries) from collections import defaultdict class UnionFind(): def __init__(self,n): self.n=n self.parents=[-1]*n def find(self,x): if self.p...
ConDefects/ConDefects/Code/abc295_g/Python/40825469
condefects-python_data_2622
""" Author ankisho Created 2023/08/31 16:46JST """ from collections import deque def operation(sh,sw,dh,dw,nope): nh = sh nw = sw while True: nh+=dh nw+=dw if nh<0 or nh>=N or nw<0 or nw>=N: break if S[nh][nw]=='#': break if dis[nh][nw]==-1: dis[nh][nw]=n...
ConDefects/ConDefects/Code/abc246_e/Python/45083106
condefects-python_data_2623
import collections N=int(input()) Ax,Ay=map(int,input().split()) Bx,By=map(int,input().split()) S=[input() for i in range(N)] Ax-=1 Ay-=1 By-=1 Bx-=1 D=[[-1 for j in range(N)] for i in range(N)] D[Ax][Ay]=0 Q=collections.deque() Q.append((Ax,Ay)) while Q: h,w=Q.popleft() for dx in [-1, 1]: for ...
ConDefects/ConDefects/Code/abc246_e/Python/45269631
condefects-python_data_2624
from collections import deque N = int(input()) sy, sx = map(lambda x: int(x) - 1, input().split()) gy, gx = map(lambda x: int(x) - 1, input().split()) S = [ input() for _ in range(N)] queue = deque([(sy, sx)]) dis = [ [1e32] * N for _ in range(N)] dis[sy][sx] = 0 dir = [ [1, 1], [1, -1], [-1, 1], [-1, -1]] def is_ok(y...
ConDefects/ConDefects/Code/abc246_e/Python/45553928
condefects-python_data_2625
from collections import deque N=int(input()) sx,sy=map(int,input().split()) gx,gy=map(int,input().split()) sx,sy,gx,gy=sx-1,sy-1,gx-1,gy-1 S=[list(input()) for _ in range(N)] d=((1,1),(1,-1),(-1,-1),(-1,1)) que=deque() inf=1<<60 dist=[[[inf]*N for _ in range(N)] for _ in range(4)] for i in range(4): dist[i][sy][...
ConDefects/ConDefects/Code/abc246_e/Python/45962991
condefects-python_data_2626
s = input() t = input() if s[0:3] == t[0:3]: print('Yes') else: print('No') s = input() t = input() if s[0:len(s)] == t[0:len(s)]: print('Yes') else: print('No')
ConDefects/ConDefects/Code/abc268_b/Python/45422238
condefects-python_data_2627
import sys input = lambda: sys.stdin.readline().rstrip() from heapq import heapify, heappush as hpush, heappop as hpop def dijkstra(n, E, i0=0): kk = 18 mm = (1 << kk) - 1 h = [i0] D = [-1] * n done = [0] * n D[i0] = 0 while h: x = hpop(h) d, i = x >> kk, x & mm if do...
ConDefects/ConDefects/Code/agc056_c/Python/27693193
condefects-python_data_2628
n, m = map(int, input().split()) edge = [[] for _ in range(n+1)] eset = [set() for _ in range(n+1)] for _ in range(m): a, b = map(int, input().split()) edge[a] += [b] eset[a].add(b) ans = 0 for i in range(n): vis = [0]*(n+1) i += 1 vis[i] = 1 q = [i] while q: v = q.pop() ...
ConDefects/ConDefects/Code/abc292_e/Python/50119653
condefects-python_data_2629
n = int(input()) sec = [[] for _ in range(n)] for i in range(n): sec[i] = list(map(int, input().split())) sec.sort() now = 0 nex = 1 ans = [] while now < n: left = sec[now][0] right = sec[now][1] while nex < n and left <= sec[nex][0] <= right: right = sec[nex][1] nex += 1 ans.append...
ConDefects/ConDefects/Code/abc256_d/Python/45322740
condefects-python_data_2630
N = int(input()) LR = [list(map(int, input().split())) for _ in range(N)] LR.sort() pl, pr = LR[0] for i in range(1, N): l, r = LR[i] if pr < l: print(pl, pr) pl = l pr = r print(pl, pr) N = int(input()) LR = [list(map(int, input().split())) for _ in range(N)] LR.sort() pl, pr = LR[0] f...
ConDefects/ConDefects/Code/abc256_d/Python/45531373
condefects-python_data_2631
N=int(input()) L=[] R=[] for i in range(N): l,r=map(int,input().split()) L.append(l) R.append(r) L.sort() R.sort() c=0 ans=0 now_l=0 now_r=0 is_in=[False]*(max(max(L),max(R))+1) for i in range(1,max(max(L),max(R))+1): print(c,now_l,now_r) while now_l<len(L) and i>=L[now_l]: c+=1 now_...
ConDefects/ConDefects/Code/abc256_d/Python/44868880
condefects-python_data_2632
n=int(input()) LR=[list(map(int,input().split())) for _ in range(n)] LR.sort() A=[LR[0]] for i in range(1,n): L,R=LR[i] if A[-1][1]<L: A+=[[L,R]] else: A[-1][1]=R for i in A: print(*i) n=int(input()) LR=[list(map(int,input().split())) for _ in range(n)] LR.sort() A=[LR[0]] for i in rang...
ConDefects/ConDefects/Code/abc256_d/Python/44916698
condefects-python_data_2633
N = int(input()) CS = [0]*(2*10**5 + 1) LR = [list(map(int, input().split())) for _ in range(N)] LR += [[2*10**5,2*10**5]] # 番兵 LR.sort() left,right,ans = 0,0,[] for i in range(N+1): L,R = LR[i][0],LR[i][1] if right < L: # 新しい区間 ans.append((left,right)) left,right = L,R elif right < R: # 区間...
ConDefects/ConDefects/Code/abc256_d/Python/46018107
condefects-python_data_2634
# https://github.com/tatyam-prime/SortedSet/blob/main/SortedSet.py import math from bisect import bisect_left, bisect_right from typing import Generic, Iterable, Iterator, List, Tuple, TypeVar, Optional T = TypeVar('T') class SortedSet(Generic[T]): BUCKET_RATIO = 50 REBUILD_RATIO = 170 def _build(self, a:...
ConDefects/ConDefects/Code/abc256_d/Python/44864172
condefects-python_data_2635
n=int(input()) que=[] for i in range(n): l,r=map(int,input().split()) que.append((l,r)) que.sort() now=0 ans=[] while now<n: ans.append(que[now][0]) tmp=que[now][1] if now==n-1: ans.append(tmp) break now+=1 while tmp>=que[now][0]: tmp=max(tmp,que[now][1]) now+...
ConDefects/ConDefects/Code/abc256_d/Python/46191783
condefects-python_data_2636
from typing import Generic, Iterable, Iterator, List, Tuple, TypeVar, Optional from collections import deque, defaultdict from decimal import Decimal from bisect import bisect_left, bisect_right from heapq import heapify, heappush, heappop from itertools import permutations, combinations from random import randrange, c...
ConDefects/ConDefects/Code/abc256_d/Python/44696240
condefects-python_data_2637
N = int(input()) num = 2 * 10 ** 5 L = [0] * (num + 2) for _ in range(N): l, r = map(int, input().split()) L[l] += 1 L[r] -= -1 for i in range(num): L[i+1] += L[i] flg = False l = 0 r = 0 for i in range(1,num+1): if flg == False: if L[i-1] == 0 and L[i] > 0: l = i f...
ConDefects/ConDefects/Code/abc256_d/Python/45516891
condefects-python_data_2638
n=int(input()) s=[list(map(int,input().split())) for i in range(n)] s.sort(key=lambda x:x[0]) ans=[] now=0 while now<n: appending=[s[now][0],s[now][1]] while now<n-1 and s[now+1][0]<=appending[-1]: now+=1 appending[-1]=s[now][1] ans.append(appending) now+=1 for k in ans: print(*k) n=int(input()) s=[l...
ConDefects/ConDefects/Code/abc256_d/Python/46043258
condefects-python_data_2639
N=int(input()) q=[] for i in range(N): l,r = list(map(int, input().split())) q.append((l,r)) ans=[] q.sort() now_l,now_r = q[0] for i in range(N): l,r = q[i] if l<=now_r: now_r = r else: ans.append((now_l,now_r)) now_l,now_r = q[i] ans.append((now_l,now_r)) for i in ans: ...
ConDefects/ConDefects/Code/abc256_d/Python/45339988
condefects-python_data_2640
import sys sys.setrecursionlimit(10**8) input = sys.stdin.readline N,K = map(int,input().split()) UV = [tuple(map(int,input().split())) for _ in range(N-1)] es = [[] for _ in range(N)] for u,v in UV: u,v = u-1,v-1 es[u].append(v) es[v].append(u) depth = [-1] * N depth[0] = 0 size = [1] * N def rec(v,p=-1):...
ConDefects/ConDefects/Code/arc175_d/Python/52191885
condefects-python_data_2641
#ARC175D LIS on Tree 2 #入力受取 N, K = map(int, input().split()) G = [[] for _ in range(N)] for _ in range(N - 1): u, v = map(lambda x: int(x) - 1, input().split()) G[u].append(v) G[v].append(u) #深さを割り当て D = [1] * N Q = [(0, -1, 1)] for now, back, d in Q: D[now] = d for nxt in G[now]: if nxt ...
ConDefects/ConDefects/Code/arc175_d/Python/51701679
condefects-python_data_2642
import sys readline = sys.stdin.readline n,K = map(int,readline().split()) g = [[] for _ in range(n)] for _ in range(n-1): u,v = map(int,readline().split()) g[u-1].append(v-1) g[v-1].append(u-1) order = [] st = [0] parent = [-1]*n size = [1]*n while st: v = st.pop() order.append(v) for c in g...
ConDefects/ConDefects/Code/arc175_d/Python/51662439
condefects-python_data_2643
import sys input = sys.stdin.readline from operator import itemgetter from collections import Counter N,K=map(int,input().split()) E=[[] for i in range(N)] for i in range(N-1): u,v=map(int,input().split()) u-=1 v-=1 E[u].append(v) E[v].append(u) # 木のHL分解+LCA ROOT=0 QUE=[ROOT] Parent=[-1]*N P...
ConDefects/ConDefects/Code/arc175_d/Python/51694704
condefects-python_data_2644
import sys,random,bisect from collections import deque,defaultdict from heapq import heapify,heappop,heappush from itertools import permutations from math import gcd,log input = lambda :sys.stdin.readline().rstrip() mi = lambda :map(int,input().split()) li = lambda :list(mi()) N,K,S = mi() A = li() cum = [0] * (N+1...
ConDefects/ConDefects/Code/arc168_e/Python/47767454
condefects-python_data_2645
N,M=map(int,input().split()) A=input() B=input() X=[[0,0] for _ in range(M)] a=0 b=0 if M==0: print(N-1) exit() elif N==0: print(M-1) exit() for i in range(N+M): if A[i]=="1": X[a][0]=i a+=1 if B[i]=="1": X[b][1]=i b+=1 X=[sorted(X[i]) for i in range(M)] #0-start p=X[0][1] c=1 for i in range...
ConDefects/ConDefects/Code/arc132_d/Python/28174907
condefects-python_data_2646
n, m = map(int, input().split()) s = input() t = input() d = [] j = 0 cj = 0 ci = 0 for i in range(n + m): if s[i] == '0': ci += 1 else: while t[j] != '1': cj += 1 j += 1 j += 1 p = (ci, cj) if ci < cj else (cj, ci) d.append(p) ans = 0 for _ in r...
ConDefects/ConDefects/Code/arc132_d/Python/28175955
condefects-python_data_2647
n = int(input()) a = list(map(int, input().split())) ans_list = [] for i in range(n - 1): # print(a[i + 1] - a[i]) if a[i + 1] >= a[i]: ans_list.extend(i for i in range(a[i], a[i + 1])) elif a[i + 1] < a[i]: ans_list.extend(i for i in range(a[i], a[i + 1], -1)) ans_list.append(a[-1]) print(...
ConDefects/ConDefects/Code/abc301_b/Python/46199451
condefects-python_data_2648
n = int(input()) a = list(map(int,input().split())) b = [] for i in range(n-1): if a[i] <= a[i+1]: b += list(range(a[i],a[i+1])) if a[i] >= a[i+1]: b += list(range(a[i],a[i+1],-1)) b.append(a[-1]) print(b) n = int(input()) a = list(map(int,input().split())) b = [] for i in range(n-1...
ConDefects/ConDefects/Code/abc301_b/Python/45340910
condefects-python_data_2649
# B n = int(input()) a = list(map(int, input().split())) #n = 4 #a = [2, 5, 1, 2] b = [] i_bef = 0 #print(a) for i in a: print(i) if i_bef == 0: b.append(i) i_bef = i continue dif = i - i_bef #print("dif:", dif) if abs(dif) > 1: if dif > 0: for j in range...
ConDefects/ConDefects/Code/abc301_b/Python/45970658
condefects-python_data_2650
import math N=int(input()) poi=[list(map(int,input().split())) for _ in range(N)] for x,y in poi: ans=0 dist=0 for i,(x_i,y_i) in enumerate(poi,1): if dist<math.sqrt((x-x_i)**2+(y-y_i)**2): dist=math.sqrt((x-x_i)**2+(y-y_i)**2) ans=i print(ans) import math N=int(i...
ConDefects/ConDefects/Code/abc348_b/Python/54985226
condefects-python_data_2651
N=int(input()) X=[None for _ in range(N+1)] Y=[None for _ in range(N+1)] for n in range(1,N+1): X[n],Y[n]=map(int,input().split()) for i in range(1,N+1): k,d=0,0 for j in range(1,N+1): dn=(X[i]-X[j])**2+(Y[i]-Y[j])**2 if dn<d: k,d=j,dn print(k) N=int(input()) X=[None for _ in range(N+1)] Y=[None ...
ConDefects/ConDefects/Code/abc348_b/Python/55140212
condefects-python_data_2652
import numpy as np # 点の数を入力 N = int(input("点の数を入力してください: ")) # 各点の座標を入力 points = np.array([list(map(float, input().split())) for _ in range(N)]) # 距離を計算する関数 def calculate_distance(point1, point2): return np.linalg.norm(point1 - point2) for i in range(N): xi, yi = points[i] far_d, far_id = -1, -1 for...
ConDefects/ConDefects/Code/abc348_b/Python/54681082
condefects-python_data_2653
S = input() for i in range(len(S)): if S[-i] == ".": print(S[-i+1:]) break S = input() for i in range(1,len(S)+1): if S[-i] == ".": print(S[-i+1:]) break
ConDefects/ConDefects/Code/abc339_a/Python/55124019
condefects-python_data_2654
S = input() for i in range(len(S)-1,0,-1): if S[i] == ".": print(S[i+1:]) break S = input() for i in range(len(S)-1,-1,-1): if S[i] == ".": print(S[i+1:]) break
ConDefects/ConDefects/Code/abc339_a/Python/54618072
condefects-python_data_2655
from collections import Counter p, g, ig = 998244353, 3, 332748118 W = [pow(g, (p - 1) >> i, p) for i in range(24)] iW = [pow(ig, (p - 1) >> i, p) for i in range(24)] def fft(f_, k): f = f_[:] for l in range(k, 0, -1): d = 1 << l - 1 U = [1] for i in range(d): U.append(U[-1]...
ConDefects/ConDefects/Code/abc267_h/Python/35794099
condefects-python_data_2656
s=input() n=len(s) answer=0 for i in range(n): if s[i]=="W": answer+=1 print(answer+n) s=input() n=len(s) answer=0 for i in range(n): if s[i]=="w": answer+=1 print(answer+n)
ConDefects/ConDefects/Code/abc279_a/Python/45494790
condefects-python_data_2657
s=list(map(str,input())) ans=0 for i in range(len(s)): if s[i]=="W": ans+=2 else: ans+=1 print(ans) s=list(map(str,input())) ans=0 for i in range(len(s)): if s[i]=="w": ans+=2 else: ans+=1 print(ans)
ConDefects/ConDefects/Code/abc279_a/Python/44934608
condefects-python_data_2658
def string(s): if 1<=len(s)<=100: bot=0 for i in s: if i=='w': bot+=2 elif i=='v': bot+=1 return bot print(string('wwwvvvvvv')) def string(s): if 1<=len(s)<=100: bot=0 for i in s: if i=='w': bot+=2 elif i=='v': bot+=1 return bot print(...
ConDefects/ConDefects/Code/abc279_a/Python/45107250
condefects-python_data_2659
# ABC266 B - Modulo Number n = int(input()) print(n-998244353) # ABC266 B - Modulo Number n = int(input()) print(n%998244353)
ConDefects/ConDefects/Code/abc266_b/Python/44372589
condefects-python_data_2660
# coding: utf-8 from functools import partial try: dummy = src minp = partial(src.pop, 0) except NameError: minp = input def ints(): return list(map(int, minp().rstrip().split(' '))) def int1(): return int(minp().rstrip()) #@psecs def main(): n = int1() d = 998244353 print(n % d) # c...
ConDefects/ConDefects/Code/abc266_b/Python/45028295
condefects-python_data_2661
import sys input = sys.stdin.readline from bisect import bisect_left class Compress: def __init__(self, vs): self.xs = list(set(vs)) self.xs.sort() def compress(self, x): return bisect_left(self.xs, x) def decompress(self, i): return self.xs[i] def size(self): ...
ConDefects/ConDefects/Code/abc254_g/Python/32247391
condefects-python_data_2662
from bisect import bisect, bisect_left from collections import defaultdict n, m, q = map(int, input().split()) elevators = [[] for _ in range(n)] for _ in range(m): a, b, c = map(int, input().split()) a -= 1 elevators[a].append((b, c)) # 同じビルで範囲が被ってるものを集約 bbb = [] ccc = [] max_c = defaultdict(int) for a i...
ConDefects/ConDefects/Code/abc254_g/Python/32287222
condefects-python_data_2663
word = input() string = list(word) num = 0 for i in range(0, len(string)): if (string[i].isupper()): num += 1 if (num % 2 == 1): print(word.upper()) else: print(word.lower()) word = input() string = list(word) num = 0 for i in range(0, len(string)): if (string[i].isupper()): num += ...
ConDefects/ConDefects/Code/abc357_b/Python/55161071
condefects-python_data_2664
s = input() lower = 0 capital = 0 for i in range(len(s)): if s[i].islower() == True: lower = lower+1 elif s[i].isupper(): capital = capital + 1 if lower >= capital: print(s.lower()) else: print(s.capitalize()) s = input() lower = 0 capital = 0 for i in range(len(s)): if s[i].islower() == True: ...
ConDefects/ConDefects/Code/abc357_b/Python/54959918
condefects-python_data_2665
s=input() count=0 for c in s: if(c.isupper()): count+=1 if(count>0): s=s.upper() else: s=s.lower() print(s) s=input() count=0 for c in s: if(c.isupper()): count+=1 else: count-=1 if(count>0): s=s.upper() else: s=s.lower() print(s)
ConDefects/ConDefects/Code/abc357_b/Python/54923363
condefects-python_data_2666
class segtree(): n=1 size=1 log=2 d=[0] op=None e=10**15 def __init__(self,V,OP,E): self.n=len(V) self.op=OP self.e=E self.log=(self.n-1).bit_length() self.size=1<<self.log self.d=[E for i in range(2*self.size)] for i in range(self.n): ...
ConDefects/ConDefects/Code/abc287_g/Python/50037780
condefects-python_data_2667
import sys input = sys.stdin.readline class BIT: def __init__(self,N): self.s = (N-1).bit_length() self.N = 1<<self.s self.data = [0]*(self.N+1) def build(self,A): for i in range(1,self.N+1): self.data[i] += A[i-1] if i+(i&-i) <= self.N: se...
ConDefects/ConDefects/Code/abc287_g/Python/50462471
condefects-python_data_2668
class Segtree:#入力は全て0-indexedでok. def __init__(self,n,operator,identity): num=1<<((n-1).bit_length()) self.tree=[identity]*(2*num-1) self.identity=identity self.operator=operator self.num=num def update(self,i,val):#i番目をvalに変える(変えた後、上の方に更新を伝播) i+=self.num-1 ...
ConDefects/ConDefects/Code/abc287_g/Python/40891564
condefects-python_data_2669
N = int(input()) G = [[] for _ in range(N)] for _ in range(N - 1): u,v = map(int,input().split()) u -= 1 v -= 1 G[u].append(v) G[v].append(u) A = list(map(int,input().split())) from collections import defaultdict S = [defaultdict(int) for _ in range(N)] num = [defaultdict(int) for _ in range(N)] ch...
ConDefects/ConDefects/Code/abc359_g/Python/54889351
condefects-python_data_2670
S = list(set(input())) les = len(S) if les == 3: print(6) if les == 2: print(3) else: print(1) S = list(set(input())) les = len(S) if les == 3: print(6) elif les == 2: print(3) else: print(1)
ConDefects/ConDefects/Code/abc225_a/Python/44983533
condefects-python_data_2671
S = input() if S[0]==S[1] and S[0]==S[2]: print("1") elif S[0]!=S[1] and S[0]==S[2]: print("3") elif S[0]==S[1] and S[0]!=S[2]: print("3") elif S[0]!=S[1] and S[0]!=S[2]: print("6") S = input() if S[0]==S[1] and S[0]==S[2]: print("1") elif S[0]!=S[1] and S[0]==S[2]: print("3") elif S[0]==S[1] ...
ConDefects/ConDefects/Code/abc225_a/Python/44786662
condefects-python_data_2672
S = input() if S[0] == S[1] and S[1] == S[2]: print(1) if S[0] == S[1] or S[0] == S[2] or S[1] == S[2]: print(3) else: print(6) S = input() if S[0] == S[1] and S[1] == S[2]: print(1) elif S[0] == S[1] or S[0] == S[2] or S[1] == S[2]: print(3) else: print(6)
ConDefects/ConDefects/Code/abc225_a/Python/44428733
condefects-python_data_2673
import sys N,A,B = (int(x) for x in input().split()) C = list(map(int,input().split())) sumAB = A + B for i in range(len(C)): #print("{} {}".format(i,C[i])) if C[i] == sumAB: print(i) exit import sys N,A,B = (int(x) for x in input().split()) C = list(map(int,input().split())) s...
ConDefects/ConDefects/Code/abc300_a/Python/46003187
condefects-python_data_2674
N, A, B = map(int, input().split()) C = list(map(int, input().split())) print(C) for i in range(len(C)): if C[i] == A + B: print(i+1) N, A, B = map(int, input().split()) C = list(map(int, input().split())) #print(C) for i in range(len(C)): if C[i] == A + B: print(i+1)
ConDefects/ConDefects/Code/abc300_a/Python/45457940
condefects-python_data_2675
from collections import defaultdict from typing import Dict, Iterable, List, Optional class TrieNodeWithParent: __slots__ = ("wordCount", "preCount", "children", "parent") def __init__(self, parent: Optional["TrieNodeWithParent"] = None): self.wordCount = 0 # 以当前节点为结尾的单词个数 self.preCount = 0 ...
ConDefects/ConDefects/Code/abc268_g/Python/34968864
condefects-python_data_2676
N = int(input()) C = [] A = [] for _ in range(N): c = int(input()) a = list(map(int, input().split())) C.append(c) A.append(a) X = int(input()) p = [] for i in range(N): if X in A[i]: p.append(C[i]) if len(p) == 0: print(0) exit() else: min = min(p) ans = [] for j in range(N):...
ConDefects/ConDefects/Code/abc314_b/Python/45977913
condefects-python_data_2677
N = int(input()) C = [] A = [] kouho = [] for i in range(N): c = int(input()) a = list(map(int, input().split())) C.append(c) A.append(a) X = int(input()) min_C = max(C) for i in range(N): if X in A[i]: kouho.append(i) if min_C > C[i]: min_C = C[i] count = 0 ...
ConDefects/ConDefects/Code/abc314_b/Python/45932176
condefects-python_data_2678
N = int(input()) C, A = [], [] for i in range(N): C.append(int(input())) A.append(list(map(int, input().split()))) X = int(input()) R = [] min = 37 for i in range(N): for a in A[i]: if a == X: if len(A[i]) == min: R.append(i+1) break elif len...
ConDefects/ConDefects/Code/abc314_b/Python/45979954
condefects-python_data_2679
#再帰はCpython,その他はpypy import sys sys.setrecursionlimit(1000000) from collections import deque from collections import defaultdict n = int(input()) s = str(input()) s = list(s) sakuzyo = deque([]) ans = [] for i,mozi in enumerate(s): #print(sakuzyo) if mozi == "(": sakuzyo.append(i) ans.append(...
ConDefects/ConDefects/Code/abc307_d/Python/45446603
condefects-python_data_2680
from collections import deque N = int(input()) S = input() L = deque() temp = [] for s in S: if s != "(" and s != ")": temp.append(s) elif s == "(": if temp: L.append("".join(temp)) temp.clear() temp.append("(") elif s == ")": if temp: L.appen...
ConDefects/ConDefects/Code/abc307_d/Python/45471496
condefects-python_data_2681
N = int(input()) S = input() T = input() CS = [[] for i in range(26)] ns = [0]*26 nt = [0]*26 for i in range(N): CS[ord(S[i])-97].append(i) ns[ord(S[i])-97] += 1 nt[ord(T[i])-97] += 1 if ns != nt: print(-1) exit() ans = N cnt = N+1 for i in range(N): tmp = T[-i-1] ntmp = ord(tmp)-97 if CS[ntmp] == []: print(a...
ConDefects/ConDefects/Code/arc154_b/Python/44381459
condefects-python_data_2682
N = int(input()) S = input() T = input() T = T + " " S_count = [0]*26 T_count = [0]*26 for i in range(N): S_count[ord(S[i])-ord('a')] += 1 T_count[ord(T[i])-ord('a')] += 1 for i in range(26): if S_count[i] != T_count[i]: print(-1) exit() cur = N-1 count = 0 for i in range(N-1, -1, -1): ...
ConDefects/ConDefects/Code/arc154_b/Python/43315013
condefects-python_data_2683
N=int(input()) S=input() T=input() S1=list(S) T1=list(T) S1.sort() T1.sort() res=0 if S1!=T1: print(-1) else: S2=list(S) T2=list(T) i=N-1 while i>=0: a=S2.pop() while a!=T[i]: i-=1 if i<0: break i-=1 if i>=0: res+=1 ...
ConDefects/ConDefects/Code/arc154_b/Python/40904177
condefects-python_data_2684
n = int(input()) s = input() t = input() s2 = sorted(s) t2 = sorted(s) if s2 != t2: print(-1) exit() if s == t: print(0) exit() def check(x): s_cut = s[x:] l = len(s_cut) s_idx = 0 for i in range(n): if t[i] == s_cut[s_idx]: s_idx += 1 if s_idx == ...
ConDefects/ConDefects/Code/arc154_b/Python/40787964
condefects-python_data_2685
n=int(input()) s=input() t=input() sl=[] tl=[] for i in range(n): sl.append(s[i]) tl.append(t[i]) sl.sort() tl.sort() if sl!=tl: print('No') exit() now=n-1 ans=0 for i in reversed(range(n)): while True: if s[i]==t[now]: ans+=1 now-=1 break now-=1 if now<0: break ...
ConDefects/ConDefects/Code/arc154_b/Python/43795529
condefects-python_data_2686
from collections import deque n=int(input()) s=list(input()) t=list(input()) if sorted(s)!=sorted(t): print(-1) else: ok=n ng=0 while True: #print(ng,ok) k=(ok+ng)//2 j=0 p=s[k:] g=0 if k==n: g=1 else: for i in range(n): ...
ConDefects/ConDefects/Code/arc154_b/Python/43504981
condefects-python_data_2687
N = int(input()) S = input() T = input() alp2num = lambda x : ord(x) - ord("a") num_s = [0] * 26 num_t = [0] * 26 for i in range(N): num_s[alp2num(S[i])] += 1 num_t[alp2num(T[i])] += 1 for i in range(26): if num_s[i] != num_t[i] : exit(print(-1)) cnt = 0 i = N-1 j = N while i >= 0: s = S[i] wh...
ConDefects/ConDefects/Code/arc154_b/Python/43180385
condefects-python_data_2688
n = int(input()) s = input() t = input() if sorted(list(s)) != sorted(list(t)): print(-1) exit() idx = n - 1 for j, i in enumerate(s[::-1]): while idx >= 0 and t[idx] != i: idx -= 1 idx -= 1 if idx < 0: print(n - j) exit() print(0) n = int(input()) s = input() t = input(...
ConDefects/ConDefects/Code/arc154_b/Python/43445291
condefects-python_data_2689
from atcoder.dsu import DSU from heapq import heappop, heappush from collections import deque N, M = map(int, input().split()) A = list(map(int, input().split())) G = [[0] * N for _ in range(N)] for i in range(N): for j in range(i+1, N): G[i][j] = (pow(A[i], A[j], M) + pow(A[j], A[i], M)) % M G[j][...
ConDefects/ConDefects/Code/abc282_e/Python/45514577
condefects-python_data_2690
import itertools import math m = [] for i in range(3): x, y,z = map(int, input().split()) m.append(x) m.append(y) m.append(z) print(m) cklist = [[[2,3],[4,7],[5,9]] \ ,[[1,3],[5,8]] \ ,[[1,2],[6,9],[5,7]] \ ,[[1,7],[5,6]] \ ,[[2,8],[4,6],[1,9],[3,7]] \ ...
ConDefects/ConDefects/Code/abc319_c/Python/45783074
condefects-python_data_2691
class LazySegmentTree: def __init__(self, op, e, mapping, composition, id_, n): self._n = len(n) if isinstance(n, list) else n self.op = op self.e = e self.mapping = mapping self.composition = composition self.id = id_ self.log = (self._n - 1).bit_length() self.size = 1 << self.log ...
ConDefects/ConDefects/Code/abc332_f/Python/50121141
condefects-python_data_2692
class lazy_segtree(): def update(self,k): self.d[k]=self.op(self.d[2*k],self.d[2*k+1]) def all_apply(self,k,f): self.d[k]=self.mapping(f,self.d[k]) if (k<self.size): self.lz[k]=self.composition(f,self.lz[k]) def push(self,k): self.all_apply(2*k,self.lz[k]) ...
ConDefects/ConDefects/Code/abc332_f/Python/50495500
condefects-python_data_2693
mod=998244353 class SegTreeLazy(): def __init__(self, a): # 初期化 n=len(a) self.n = n self.a = a self.ans=[0]*n self.logN=(n-1).bit_length() self.n0 = 1<<self.logN self.ktree=[1]*2*self.n0 self.dtree=[0]*2*self.n0 for i in range(n): ...
ConDefects/ConDefects/Code/abc332_f/Python/49265039
condefects-python_data_2694
#ABC332F Random Update Query #結局双対セグ木はソラで書けばよいため #入力受取 N, M = map(int, input().split()) A = list(map(int, input().split())) MOD = 998244353 #push機能付きの双対セグ木を書く #遅延は(ax + b)の形で保持する logN = (N - 1).bit_length() size = 1 << logN lazy = [(1, 0) for _ in range(2 * size)] for i in range(N): lazy[i + size] = (1, A[i]) de...
ConDefects/ConDefects/Code/abc332_f/Python/50678043
condefects-python_data_2695
import sys, io import math, heapq, bisect from collections import deque, defaultdict as ddict from itertools import product from typing import TypeVar, Callable, Sequence TypeS = TypeVar('TypeS') TypeT = TypeVar('TypeT') class LazySegmentTreeInjectable: def __init__( self, n: int, ...
ConDefects/ConDefects/Code/abc332_f/Python/51643425
condefects-python_data_2696
def find_unique_char_position(S): # 最初の3文字をチェックして異なる文字を特定 if S[0] == S[1]: common_char = S[0] elif S[2] == S[1]: common_char = S[1] else : return S[1] # 異なる1文字の位置を特定 for i, char in enumerate(S): if char != common_char: return i + 1 # 1-based index # 入力 ...
ConDefects/ConDefects/Code/abc342_a/Python/54737286
condefects-python_data_2697
S = input() for i in range(len(S)-1): if S[i-1] != S[i] and S[i] != S[i+1]: print(i+1) S = input() for i in range(len(S)-1): if S[i-1] != S[i] and S[i] != S[i+1]: print(i+1) exit() print(len(S))
ConDefects/ConDefects/Code/abc342_a/Python/54672989
condefects-python_data_2698
S = input() if S.count(S[0])==1: print("1") else: for i in range(1, len(S)-1): if S[i] != S[0]: print(i+1) S = input() if S.count(S[0])==1: print("1") else: for i in range(1, len(S)): if S[i] != S[0]: print(i+1)
ConDefects/ConDefects/Code/abc342_a/Python/54772316
condefects-python_data_2699
s= input() if s.count(s[0])==1: print(0) else: for i in range(1,len(s)): if s[0] != s[i]: print(i+1) s= input() if s.count(s[0])==1: print(1) else: for i in range(1,len(s)): if s[0] != s[i]: print(i+1)
ConDefects/ConDefects/Code/abc342_a/Python/54911256
condefects-python_data_2700
N,S,K = map(int,input().split()) x = 0 for i in range (N): P,Q = map(int,input().split()) x += P*Q if S >= x: x += K print(x) N,S,K = map(int,input().split()) x = 0 for i in range (N): P,Q = map(int,input().split()) x += P*Q if S > x: x += K print(x)
ConDefects/ConDefects/Code/abc332_a/Python/55010620