id
stringlengths
24
27
content
stringlengths
37
384k
max_stars_repo_path
stringlengths
51
51
condefects-python_data_1601
N, M = map(int, input().split()) P = [None] * N C = [None] * N F = [None] * N for i in range(N): tmp = list(map(int, input().split())) P[i], C[i], F[i] = tmp[0], tmp[1], set(tmp[2:]) flag = False for i in range(N): for j in range(N): if P[i] >= P[i] and F[j] >= F[i] and (P[i] > P[j] or (F[i] - F[j]...
ConDefects/ConDefects/Code/abc310_b/Python/45952354
condefects-python_data_1602
N, M = map(int, input().split()) I = [list(map(int, input().split())) for _ in range(N)] for i in range(N): for j in range(N): if i == j: continue if I[i][0] >= I[j][0]: fj = set(I[j][2:]) fi = set(I[i][2:]) if len((fj | fi)) == len(fj): ...
ConDefects/ConDefects/Code/abc310_b/Python/45953433
condefects-python_data_1603
#提出コード------------------------------ import itertools import sys sys.setrecursionlimit(10**6) def IN(): return int(input()) def IS(): return input() def INL(): return list(map(int,input().split())) def ITN(): return map(int,input().split()) N,M = ITN() Price_and_func = [list(map(int,input().split())) for _ in range(N...
ConDefects/ConDefects/Code/abc310_b/Python/46217262
condefects-python_data_1604
def main(): # input # N:商品数 M:最大機能値 N, M = map(int,input().split()) # init PCF = [0 for _ in range(N)] # P:価格 C:機能数 F:機能 for i in range(N): # 0-N個 PCF[i] = list(map(int,input().split())) # print(PCF) ans = False # 総当たりで確認 for i in range(N): # C ...
ConDefects/ConDefects/Code/abc310_b/Python/46051370
condefects-python_data_1605
n,m=map(int,input().split()) s=[] for i in range(n): p,c,*f=map(int,input().split()) s.append([p,c,f]) for i in range(n): for j in range(n): if i!=j and s[i][0]>=s[j][1] and set(s[j][2])>=set(s[i][2]) \ and (s[i][0]>s[j][0] or set(s[j][2])-set(s[i][2])): print("Yes") exit() print("No")...
ConDefects/ConDefects/Code/abc310_b/Python/45742461
condefects-python_data_1606
n , m = map(int,input().split()) p = [None] * n #c = [None] * n f = [None] * n #e1 = {} for i in range(n): e = list(map(int,input().split())) p[i] = e[0] # c[i] = e[1] f[i] = set(e[2:]) for i in range(n): for j in range(i): if p[i] >= p[j] and f[j].issuperset(f[i]) and (p[i] > p[j] or len(f[j...
ConDefects/ConDefects/Code/abc310_b/Python/46010800
condefects-python_data_1607
import heapq N,M=map(int,input().split()) G=[[] for i in range(N+1)] H=[[0,0]] for i in range(M): a,b,c=map(int,input().split()) G[a].append(i+1) G[b].append(i+1) H.append([a+b,c]) Q=[] inf=10**9+10 D=[inf for i in range(N+1)] memo=[-1 for i in range(N+1)] D[1]=0 heapq.heappush(Q,[0,1]) while Q: ...
ConDefects/ConDefects/Code/abc252_e/Python/45066699
condefects-python_data_1608
from collections import defaultdict N, M = map(int, input().split()) A = list(map(int, input().split())) count = defaultdict(int) for a in A: count[a] += 1 S = set() for a, n in count.items(): if n%2: S.add(a) if len(S) == 0: print('Bob') quit() if M % 2: print('Alice') quit() m = ...
ConDefects/ConDefects/Code/arc148_d/Python/41790396
condefects-python_data_1609
N,M = map(int,input().split()) A = list(map(int,input().split())) from collections import defaultdict dic = defaultdict(int) for a in A: dic[a] ^= 1 blue = 0 while dic: k,v = dic.popitem() if v==0: continue if M%2: exit(print('Alice')) k2 = (k + M//2) % M dic[k2] if dic[k2] == 0: ...
ConDefects/ConDefects/Code/arc148_d/Python/45234117
condefects-python_data_1610
N,M=map(int, input().split()) array=list(map(int, input().split())) sss=set() for a in array: if a in sss: sss.remove(a) else: sss.add(a) if M%2==1: if sss: print("Alice") else: print("Bob") else: if len(sss)%4!=0: print("Alice") exit() for s in ss...
ConDefects/ConDefects/Code/arc148_d/Python/35204671
condefects-python_data_1611
def main(): from sys import stdin, setrecursionlimit # setrecursionlimit(1000000) input = stdin.readline def iinput(): return int(input()) def sinput(): return input().rstrip() def i0input(): return int(input()) - 1 def linput(): return list(input().split()) def liinput(): return list(ma...
ConDefects/ConDefects/Code/arc148_d/Python/40705107
condefects-python_data_1612
from collections import defaultdict n,m = map(int,input().split()) a = list(map(int,input().split())) a.sort() d = defaultdict(int) for i in a: d[i] += 1 d[i] %= 2 flag = True idx = [] for k,v in d.items(): flag &= not v if k <= m//2: idx.append(k) if flag: print("Bob") elif m%2: print("Alice") else: ...
ConDefects/ConDefects/Code/arc148_d/Python/42270342
condefects-python_data_1613
from collections import Counter N, M = map(int, input().split()) A = [int(i)%M for i in input().split()] C = Counter([i*2 % M for i in A]) S = 0 for i in A: S = (S+i) % M ans = 'Alice' if all(i % 2 == 0 for i in C.values()): x = 0 for i,j in C.items(): x += (i*j//2) % M if x == S: ans =...
ConDefects/ConDefects/Code/arc148_d/Python/34818045
condefects-python_data_1614
import sys from collections import defaultdict, Counter, deque from itertools import permutations, combinations, product, combinations_with_replacement, groupby, accumulate import operator from math import sqrt, gcd, factorial #from math import isqrt, prod, comb #python3.8用(notpypy) #from bisect import bisect_left, bi...
ConDefects/ConDefects/Code/arc148_d/Python/34807717
condefects-python_data_1615
from collections import Counter n, m = map(int, input().split()) a = list(map(int, input().split())) s = sum(a) for i in range(n * 2): a[i] = a[i] * 2 % m a.sort() x = 0 for i in range(0, n * 2, 2): if a[i] != a[i + 1]: print('Alice') break x += a[i] else: if x == s: print('Bob')...
ConDefects/ConDefects/Code/arc148_d/Python/34805310
condefects-python_data_1616
from collections import Counter def solve_odd(a, m): c = Counter(a) return any(cnt%2 for cnt in c.values()) def solve_even(a, m): mm = m//2 c = Counter(v%mm for v in a) if any(cnt%2 for cnt in c.values()): return True r = 0 c = Counter(a) for v in set(a): if v >= m: ...
ConDefects/ConDefects/Code/arc148_d/Python/38916424
condefects-python_data_1617
S, T = map(str, input().split()) print(S, 'sun') S, T = map(str, input().split()) print(S, 'san')
ConDefects/ConDefects/Code/abc325_a/Python/54458696
condefects-python_data_1618
S,T=map(str,input().split()) print(S+' '+'san') S,T=map(str,input().split()) print(S+' '+'san')
ConDefects/ConDefects/Code/abc325_a/Python/54471524
condefects-python_data_1619
X,L=input().split() print(X+""+"san") X,L=input().split() print(X+" "+"san")
ConDefects/ConDefects/Code/abc325_a/Python/54463664
condefects-python_data_1620
from collections import deque n, d = map(int, input().split()) wall = [list(map(int, input().split())) for _ in range(n)] wall.sort() q = deque(wall) ans = 0 now = 0 while q: nex = q.popleft() if nex[0] <= now: continue now = nex[1] + d - 1 ans += 1 print(ans) from collections import deque ...
ConDefects/ConDefects/Code/abc230_d/Python/45013914
condefects-python_data_1621
import sys sys.setrecursionlimit(10**7) import re import copy import bisect import math import itertools import more_itertools from collections import deque from collections import defaultdict from collections import Counter from heapq import heapify, heappush, heappop, heappushpop, heapreplace from functools import cm...
ConDefects/ConDefects/Code/abc230_d/Python/45946021
condefects-python_data_1622
import sys,random,bisect from collections import deque,defaultdict from heapq import heapify,heappop,heappush from functools import lru_cache from itertools import permutations from math import gcd,log,sqrt from atcoder.modint import ModContext, Modint from atcoder.dsu import DSU ModContext(1).context.append(998244353...
ConDefects/ConDefects/Code/abc230_d/Python/46047126
condefects-python_data_1623
from operator import itemgetter N,D=map(int,input().split()) li=[list(map(int,input().split())) for _ in range(N)] li.sort(key=itemgetter(1)) punch_length=-1 ans=0 for i in range(N): l,r=li[i] if ans==0: ans+=1 punch_length=r+D-1 else: if punch_length<l: ans+=1 ...
ConDefects/ConDefects/Code/abc230_d/Python/44825161
condefects-python_data_1624
import sys input = sys.stdin.buffer.readline sr = lambda: input().rstrip().decode("ascii") # 文字列の読み込み ir = lambda: int(input()) # 数字の読み込み lr = lambda: list(map(int, input().split())) # 数字の配列の読み込み N, D = lr() x = [] inf = 1 << 60 for i in range(N): l, r = lr() # 壁の左端、左右、壁の番号 x.append((l, 0, i)) # 壁の...
ConDefects/ConDefects/Code/abc230_d/Python/46232718
condefects-python_data_1625
N = int(input()) A = list(map(int, input().split())) count = [0 for _ in range(10**6)] for i in range(N): count[A[i]] += 1 binary_list = [] binary_sum = [] for i in range(64): b = [] for j in range(6): b.append((i>>j)&1) binary_list.append((i>>j)&1) binary_sum.append((sum(b)%2)==1) on...
ConDefects/ConDefects/Code/arc136_d/Python/42996075
condefects-python_data_1626
def read(): return list(map(int, input().strip().split())) n, = read() a = read() S = [0 for i in range(10**6+5)] selfpair = 0 for i in a: S[i] = 1 if all([int(j) < 5 for j in str(i)]): selfpair += 1 for j in range(6): for i in range(10**6): if (i // 10**j) % 10: S[i] += S[i-10*...
ConDefects/ConDefects/Code/arc136_d/Python/33407252
condefects-python_data_1627
n = int(input()) a = list(map(int,input().split())) dp = [0] * 1000000 for i in range(n): dp[999999-a[i]] += 1 for i in range(6): mask = 10**i for j in range(999999, -1, -1): if (j//mask)%10 != 9: dp[j] += dp[j+mask] ans = 0 for i in range(n): mode = 1 for j in range(6): if (a[i]//(10**j))%10 > 5: mo...
ConDefects/ConDefects/Code/arc136_d/Python/31067656
condefects-python_data_1628
mod=998244353 memo={} def calc(l,r,tl,tr,flag,v): if l>r: return 0 if l==r: if (l*tl)^(r*tr)==v and flag: return 1 return 0 if (l,r,tl,tr,flag,v) in memo: return memo[(l,r,tl,tr,flag,v)] res=0 for l0 in range(2): for r0 in range(2): sl=l0&tl sr=r0&tr if sl^sr==...
ConDefects/ConDefects/Code/arc133_d/Python/44249322
condefects-python_data_1629
P = 998244353 i12 = P + 1 >> 1 def chk(x, nx, dx, lx, rx): ng = 0 if dx < lx: ng ^= 1 if rx < dx: ng ^= 2 if (x ^ 3) & ng : return 0 nnx = x if lx < dx: nnx |= 1 if dx < rx: nnx |= 2 if nnx == nx: return 1 return 0 def subca...
ConDefects/ConDefects/Code/arc133_d/Python/28699500
condefects-python_data_1630
def f(L,R,V): #L,R,V=map(int,input().split()) ans=0 V2=V L2=L R2=R if V%2==0: V+=1 L+=1-L%2 R-=R%2 if L>R: return 0 mod=998244353 #dp[i][Rflag][Lflag][flag] i桁目までRのflag,Lのflag xorがVのi桁目までと一致してる個数,等しいか? S=bin(L)[2:] T=bin(R)[2:] K=bin(V)[2:] S="0"*(len(T)-len(S))+S if len(K)>len(T...
ConDefects/ConDefects/Code/arc133_d/Python/28706821
condefects-python_data_1631
""" a = 4 * x a ^ (a + 1) ^ (a + 2) ^ (a + 3) = 0 l_0 := (l - 1) // 4 * 4 r_0 := r // 4 * 4 (l_0 ^ ... ^ l - 1) ^ (r_0 ^ ... ^ r) == V 下2桁とそれ以外に分ける a = 4 * x a = a a ^ (a + 1) = 1 a ^ (a + 1) ^ (a + 2) = a + 3 a ^ (a + 1) ^ (a + 2) ^ (a + 3) = 0 """ MOD = 998244353 l, r, v = map(int, input().split()) l -= 1 X = [0,...
ConDefects/ConDefects/Code/arc133_d/Python/28699416
condefects-python_data_1632
""" 毎回hatのビット列を生成して確かめるっていうのがだめ 境目を動かしていって、境目付近を見ればいい """ n = int(input()) s = list(input()) w = list(map(int, input().split())) people = [] # 正解数 # 最初、0番目の人より左にあって、全て1と予測するので1の数をカウントしておく cnt = 0 for i in range(n): people.append((w[i], s[i])) if s[i] == '1': cnt += 1 people.sort() ans = cnt for i in ...
ConDefects/ConDefects/Code/abc257_c/Python/45044587
condefects-python_data_1633
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())) N, X = MI() AB = [LI() for i in range(N)] sum = 0 ans = float('inf') for i in ...
ConDefects/ConDefects/Code/abc258_d/Python/45493012
condefects-python_data_1634
n, x = map(int, input().split()) a, b = [0] * n, [0] * n for i in range(n): a[i], b[i] = map(int, input().split()) cum_a = [0] cum_b = [0] for i in range(n): cum_a.append(cum_a[-1] + a[i]) cum_b.append(cum_b[-1] + b[i]) ans = 10 ** 20 for i in range(n): temp = cum_a[i + 1] + cum_b[i] + b[i] * (x - i) ...
ConDefects/ConDefects/Code/abc258_d/Python/45477729
condefects-python_data_1635
n, x = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(n)] t = 0 c = 0 mn = 10 ** 18 for i in range(n): if c >= x: break a = ab[i][0] b = ab[i][1] t += a ans = (x - c) * b + t mn = min(ans, mn) c += 1 t += b print(mn) n, x = map(int, input().spli...
ConDefects/ConDefects/Code/abc258_d/Python/44886966
condefects-python_data_1636
N, X = map(int, input().split()) AB = [tuple(map(int, input().split())) for _ in [0]*N] dp = [[0]*(N+1), [0]*(N+1)] ans = 10**18 for i in range(N): dp[0][i+1] = dp[0][i] + AB[i][0]+AB[i][1] dp[1][i+1] = dp[0][i+1] + AB[i][1]*(max(0, X-i-1)) ans = min(ans, dp[1][i+1]) print(ans) N, X = map(int, input()....
ConDefects/ConDefects/Code/abc258_d/Python/45951298
condefects-python_data_1637
N, X = map(int, input().split()) sums = [0] * N a, b = [], [] for i in range(N): ai, bi = map(int, input().split()) a.append(ai) b.append(bi) sums[i] = ai + bi for i in range(1, N): sums[i] += sums[i - 1] ans = [0] * N INF = 10 ** 9 for i in range(N): if X - (i + 1) < 0: ans[i] = INF ...
ConDefects/ConDefects/Code/abc258_d/Python/45032060
condefects-python_data_1638
n,x=map(int,input().split()) L=[list(map(int,input().split())) for i in range(n)] total=[0 for i in range(n)] total[0]=L[0][0]+L[0][1] for i in range(1,n): total[i]=total[i-1]+L[i][0]+L[i][1] ans=10**15 m=10**10 for i in range(min(n,x)): num=0 num+=total[i] if m>L[i][1]: m=L[i][1] num+=(x-i-1)*m if ans>...
ConDefects/ConDefects/Code/abc258_d/Python/45080701
condefects-python_data_1639
n,x=map(int,input().split()) s=[list(map(int,input().split())) for i in range(n)] ans=10**20 su=[0]*(n+1) for i in range(n): su[i+1]=su[i]+sum(s[i]) su2=[s[i][0]]*n for i in range(n): su2[i]=min(su2[i-1],s[i][1]) for i in range(min(n,x)): ans=min(ans,su[i+1]+su2[i]*(x-i-1)) print(ans) n,x=map(int,input().split()...
ConDefects/ConDefects/Code/abc258_d/Python/46036686
condefects-python_data_1640
N, X = [int(x) for x in input().split()] AB = [[int(i) for i in input().split()] for _ in range(N)] inf = 10**18 dp = [[0, inf] for _ in range(N + 1)] min_b = inf for i, (a, b) in enumerate(AB): dp[i + 1][1] = min(dp[i][1], b) dp[i + 1][0] = dp[i][0] + a + b ans = inf for i in range(1, N + 1): second_pl...
ConDefects/ConDefects/Code/abc258_d/Python/45791882
condefects-python_data_1641
n,x=map(int,input().split()) L=[list(map(int,input().split())) for i in range(n)] total=[0 for i in range(n)] total[0]=L[0][0]+L[0][1] for i in range(1,n): total[i]=total[i-1]+L[i][0]+L[i][1] ans=10**10 m=10**10 for i in range(min(n,x)): num=0 num+=total[i] if m>L[i][1]: m=L[i][1] num+=(x-i-1)*m if ans>...
ConDefects/ConDefects/Code/abc258_d/Python/45080402
condefects-python_data_1642
N,X = map(int,input().split()) AB = [list(map(int,input().split()))for _ in range(N)] ans = 10**18 ruiseki = 0 now=0 for i in range(N): ruiseki += sum(AB[i]) now+=1 if (X-now)>=0: ans = min(ans,ruiseki+(X-now)*AB[i][1]) print(ans) N,X = map(int,input().split()) AB = [list(map(int,input().split())...
ConDefects/ConDefects/Code/abc258_d/Python/45951540
condefects-python_data_1643
n, x = map(int, input().split()) s = [] bs = [] for i in range(n): a, b = map(int, input().split()) if i == 0: s.append(a+b) else: s.append(s[i-1] + a + b) bs.append(b) ans = 100000000000000000 for max_stage in range(n): if x-1 <= max_stage: time = s[x-1] else: ...
ConDefects/ConDefects/Code/abc258_d/Python/45041498
condefects-python_data_1644
n,x=map(int,input().split()) L=[[0,0]] for _ in range(n): a,b=map(int,input().split()) L+=[[L[-1][0]+a+b,b]] ans=[] for i in range(1,n): ans+=[L[i][0]+L[i][1]*max(0,x-i)] print(min(ans)) n,x=map(int,input().split()) L=[[0,0]] for _ in range(n): a,b=map(int,input().split()) L+=[[L[-1][0]+a+b,b]] ans...
ConDefects/ConDefects/Code/abc258_d/Python/45022453
condefects-python_data_1645
N, X = map(int, input().split()) games = [] total = 0 min_clear = 10**16 for i in range(min(N, X)): a, b = map(int, input().split()) total += (a + b) iteration = (X - i - 1) * b tmp_ans = total + iteration min_clear = min(min_clear, tmp_ans) print(min_clear) N, X = map(int, input().split()) games...
ConDefects/ConDefects/Code/abc258_d/Python/45815493
condefects-python_data_1646
import sys input = sys.stdin.readline from collections import deque S=input().strip() T=input().strip() K=int(input()) CHANGE=[input().split() for i in range(K)] DP=[[[1<<60]*len(T) for i in range(len(T))] for j in range(26)] C1=[] C2=[] for x,y in CHANGE: if len(y)==1: C1.append([x,y]) else: ...
ConDefects/ConDefects/Code/abc261_g/Python/33560185
condefects-python_data_1647
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()) """ - 全体加算:yをクソデカにする 全体減産も可能 N=1の場合:自明...
ConDefects/ConDefects/Code/agc063_c/Python/44118621
condefects-python_data_1648
from __pypy__.builders import StringBuilder import sys from os import read as os_read, write as os_write from atexit import register as atexist_register from typing import Generic, Iterator, List, Tuple, Dict, Iterable, Sequence, Callable, Union, Optional, TypeVar T = TypeVar('T') Pair = Tuple[int, int] Graph = List[Li...
ConDefects/ConDefects/Code/abc315_h/Python/44773178
condefects-python_data_1649
class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = ...
ConDefects/ConDefects/Code/abc250_h/Python/31555605
condefects-python_data_1650
from collections import deque N, M = map(int, input().split()) E = [[] for _ in range(N)] for _ in range(M): u, v = map(int, input().split()) E[u - 1].append(v - 1) E[v - 1].append(u - 1) S = tuple(map(int, input())) stack = deque([(0, None, True)]) visited = [False] * N P = [] while stack: q, p, first = sta...
ConDefects/ConDefects/Code/abc244_g/Python/32985131
condefects-python_data_1651
array = list(map(int,input().split())) xy1 = array array = list(map(int,input().split())) xy2 = array array = list(map(int,input().split())) xy3 = array x = [] for i in range(2): if xy1[i] == xy2[i]: x.append(xy3[i]) elif xy1[i] == xy3[i]: x.append(xy2[i]) else: x.append(xy1[i]) print(x) array = list...
ConDefects/ConDefects/Code/abc246_a/Python/45745121
condefects-python_data_1652
n, m, k = map(int, input().split()) a = list(map(int, input().split())) r = 1 << 30 l = 0 while r - l > 1: mid = (r + l) // 2 c = [] for i in a: msk = (1 << 30) - 1 imid = mid while i > imid: msk >>= 1 i &= msk imid &= msk c.append(imid - i...
ConDefects/ConDefects/Code/arc146_b/Python/43257634
condefects-python_data_1653
import sys sys.setrecursionlimit(10000000) from collections import deque, namedtuple ## Input crap infile = sys.stdin intokens = deque() def getTokens(): while not intokens: for c in infile.readline().rstrip().split() : intokens.append(c) def gs(): getTokens(); return intokens.popleft() d...
ConDefects/ConDefects/Code/arc146_b/Python/40312293
condefects-python_data_1654
def can(A,digit): maskA = [a & (2**digit-1) for a in A] maskA.sort() ok = [] ng = [] for a in maskA: if 1<<(digit-1) & a: ok.append(a) else: ng.append(a) if len(ok) >= K: return ok,0 else: tmp = 0 for i in range(K-len(ok)): ...
ConDefects/ConDefects/Code/arc146_b/Python/42233391
condefects-python_data_1655
import heapq N,M,K=map(int,input().split()) A=list(map(int,input().split())) maxbit=int(max(A)+M).bit_length() # maxA=2**maxbit ans=0 C=[0]*N m=2**maxbit for i in range(maxbit+1): B=[] for j in range(N): if (A[j]>>(maxbit-i))&1: B.append(C[j]) else: B.append(ans+m-A[j]+C[j]) B.sort() if sum...
ConDefects/ConDefects/Code/arc146_b/Python/41500955
condefects-python_data_1656
n, l, r = map(int, input().split()) a = list(map(int, input().split())) b = [i % (l + r) for i in a] g = [int(l <= i <= r) for i in b] ans = 0 for i in g: ans ^= i if ans: print("First") else: print("Second") n, l, r = map(int, input().split()) a = list(map(int, input().split())) b = [i % (l + r) for i in ...
ConDefects/ConDefects/Code/abc297_g/Python/47814164
condefects-python_data_1657
n,l,r = map(int, input().split()) alist = list(map(int, input().split())) s = l+r xor = 0 for a in alist: a %= s xor ^= a if xor == 0: print("Second") else: print("First") n,l,r = map(int, input().split()) alist = list(map(int, input().split())) s = l+r xor = 0 lose = 0 for a in alist: a %= s ...
ConDefects/ConDefects/Code/abc297_g/Python/52394876
condefects-python_data_1658
N,L,R=map(int,input().split()) A=list(map(int,input().split())) g=[0]*N for i in range(N): M=A[i]%(L+R) g[i]=M res=0 for i in range(N): res^=g[i] print('First' if res!=0 else 'Second') N,L,R=map(int,input().split()) A=list(map(int,input().split())) g=[0]*N for i in range(N): M=A[i]%(L+R) g[...
ConDefects/ConDefects/Code/abc297_g/Python/44405855
condefects-python_data_1659
import bisect import collections import functools import heapq import itertools import math import operator import string import sys readline = sys.stdin.readline LS = lambda: readline().strip() LI = lambda: int(readline().strip()) LLS = lambda: readline().strip().split() LL = lambda: list(map(int, readline().strip()....
ConDefects/ConDefects/Code/abc347_c/Python/55146553
condefects-python_data_1660
n, a, b = map(int, input().split()) D = list(map(int, input().split())) w = a + b mod_D = [] for d in D: mod_D.append(d % w) mod_D = sorted(list(set(mod_D))) length = len(mod_D) for i in range(length): mod_D.append(mod_D[i] + w) for i in range(len(mod_D)-1): if (mod_D[i+1] - mod_D[i]) % w > b: pr...
ConDefects/ConDefects/Code/abc347_c/Python/55043661
condefects-python_data_1661
import sys import queue import math def init(): sys.stdin = open('in.txt', "r") sys.stdout = open('out.txt', 'w') input = sys.stdin.readline # s = set() # a = int(input()) # mp = dict() # q = queue.Queue() n, a, b = map(int, input().split()) d = list(map(int, input().split())) for i in range(n): d[i] %=...
ConDefects/ConDefects/Code/abc347_c/Python/55155622
condefects-python_data_1662
import random def solve(n, p): while True: a, b = random.sample(range(2, p), 2) rig = (1 + pow(a, 3 * n, p) + pow(b, 3 * n, p)) % p lef = ( (1 + a + b) % p * (1 + pow(a, n, p) + pow(b, n, p)) % p * (1 + pow(a, 2 * n, p) + pow(b, 2...
ConDefects/ConDefects/Code/arc158_d/Python/39679022
condefects-python_data_1663
N = int(input()) a = "" for i in range(N+1): a += "o" print('L'+a+'ng') N = int(input()) a = "" for i in range(N): a += "o" print('L'+a+'ng')
ConDefects/ConDefects/Code/abc336_a/Python/54733464
condefects-python_data_1664
n=int(input()) ans="l"+"o"*(n)+"ng" print(ans) n=int(input()) ans="L"+"o"*(n)+"ng" print(ans)
ConDefects/ConDefects/Code/abc336_a/Python/54729953
condefects-python_data_1665
N = int(input()) Xo = "o" * (N-3) ans = "L" + Xo + "n" + "g" print(ans) N = int(input()) Xo = "o" * N ans = "L" + Xo + "n" + "g" print(ans)
ConDefects/ConDefects/Code/abc336_a/Python/54679232
condefects-python_data_1666
S = input() if "<" in S and "=" in S: if S.count("<") == S.count(">") : print("Yes") else : print("No") else : print("No") S = input() if "<" in S and "=" in S and ">" == S[-1]: if S.count("<") == S.count(">") : print("Yes") else : print("No") else ...
ConDefects/ConDefects/Code/abc345_a/Python/54946927
condefects-python_data_1667
n = input() cnta,cntb =0,0 stack = [] bool = True for i in range(len(n)): if n[i]=='<': cnta+=1 elif n[i]=='>': cntb+=1 if cntb>cnta: bool = False break; if bool and cnta==cntb: print("Yes") else: print("No") n = input() cnta,cntb =0,0 stack = [] bool = True for i in range(len(n)): ...
ConDefects/ConDefects/Code/abc345_a/Python/54949643
condefects-python_data_1668
#!/usr/bin/env python import os import sys from io import BytesIO, IOBase def main(): n, m = map(int,input().split()) x = list(map(int,input().split())) d = list(map(int,input().split())) arrow = [None] * (10 ** 6 + 1) currentMin = 1 currentMinLoc = 1 direction = 1 length = 10 ** 6 ...
ConDefects/ConDefects/Code/arc149_d/Python/35355978
condefects-python_data_1669
import sys input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) n = ii() k = n * (n - 1) // 2 if k % 3 != 0: print('No') else: import random K = list(range(1, n)) for _ in range(10 ** 5): A = [[] for _ in ra...
ConDefects/ConDefects/Code/arc131_e/Python/32651833
condefects-python_data_1670
# cook your dish here import sys import bisect from bisect import bisect_left as lb from bisect import bisect_right as rb input_=lambda: sys.stdin.readline().strip("\r\n") from math import log from math import gcd from math import atan2,acos from random import randint from queue import Queue sa=lambda :input_() sb=lamb...
ConDefects/ConDefects/Code/arc131_e/Python/27746730
condefects-python_data_1671
import sys, os, io input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline def f(u, v): return u * (m + 1) + v n = int(input()) ans = "Yes" if not (n * (n - 1)) % 3 and n >= 6 else "No" print(ans) if ans == "No": exit() m = n * (n - 1) // 6 dp = [0] * ((m + 1) * (m + 1)) p = [-1] * ((m + 1) * (m + 1)) dp...
ConDefects/ConDefects/Code/arc131_e/Python/42742272
condefects-python_data_1672
p=print;r=range;N=int(input());a=[];b=[0]*3;d=N*(N-1)//6 for i in r(1,N): for c in r(3): if b[c]+i<=d:a.append("RBW"[c]*i);b[c]+=i;break else:p("No");exit() p("Yes");p(*a,sep='\n') p=print;r=range;N=int(input());a=[];b=[0]*3;d=N*(N-1)//6 for i in r(N-1,0,-1): for c in r(3): if b[c]+i<=d:a.a...
ConDefects/ConDefects/Code/arc131_e/Python/27742677
condefects-python_data_1673
N=int(input()) if N%3==2 or N==4: print("No") else: print("Yes") n=N R=[] B=[] W=[] while n>10: R.append(n-1) R.append(n-6) B.append(n-2) B.append(n-5) W.append(n-3) W.append(n-4) n-=6 if n==6: R.append(1) R.append(4...
ConDefects/ConDefects/Code/arc131_e/Python/27740591
condefects-python_data_1674
class List2D: def __init__(self,H,W,grid): self.H,self.W=H,W self.H0,self.W0=H,W self.grid=grid self._reverseH=0 self._reverseW=0 self.trans=0 @classmethod def full(cls,H,W,fill_value): return cls(H,W,[fill_value]*(H*W)) @classmethod def fro...
ConDefects/ConDefects/Code/arc131_e/Python/38955195
condefects-python_data_1675
n = int(input()) if(n<=4): print("No") exit() if(n*(n-1)%3!=0): print("No") exit() if(n*(n-1)%3!=0): print("No") exit() ans = [["."]*n for _ in range(n)] R = [] B = [] W = [] def divide(n): global R,B,W if(n>10): R += [n-1,n-6] B += [n-2,n-5] W += [n-3,n-4] ...
ConDefects/ConDefects/Code/arc131_e/Python/27727642
condefects-python_data_1676
""" 自分より小さいものに有向辺を貼るとする。 その全てに関して、同じ色を使うとする。 すると、3頂点のうち、最大は必ず同じ辺で入出 そのような組み合わせを見つけるとよい。 N-1 N-2 N-3 N-4 ... 1 の中からいくつか取り、 N(N-1)/6 を2こ作りたい 雑に行ける? dp[i][j] = 和が (i,j) の場合の前の推移 """ import sys from sys import stdin import pprint N = int(stdin.readline()) if ( N*(N-1)//2 ) % 3 != 0: print ("No") sys.exit...
ConDefects/ConDefects/Code/arc131_e/Python/27729425
condefects-python_data_1677
N = int(input()) s = "RGB" ans = [""]*(N-1) cnts = [0]*3 if N%3==2: print("No") exit() cnt = N*(N-1)//6 for i in range(N-1): for c in range(3): if cnts[c] + (N-1-i) <= cnt: ans[i] = s[c]*(N-1-i) cnts[c] += N-1-i break else: print("No") exit() p...
ConDefects/ConDefects/Code/arc131_e/Python/27742492
condefects-python_data_1678
#N=int(input()) S=input() ans=0 for i in range(len(S)-1,-1,-1): x=ord(S[i])-ord('A')+1 print(x) ans+=26**(len(S)-i-1)*x #a,b=map(int,input().split()) print(ans) #N=int(input()) S=input() ans=0 for i in range(len(S)-1,-1,-1): x=ord(S[i])-ord('A')+1 #print(x) ans+=26**(len(S)-i-1)*...
ConDefects/ConDefects/Code/abc285_c/Python/45507788
condefects-python_data_1679
n=int(input()) INDEX=-1 now=float('inf') ans=[] for i in range(n): s,a=input().split() a=int(a) ans.append([s,a]) if now>a: now=a INDEX=i for i in range(n): print(*ans[(i+INDEX)%n]) n=int(input()) INDEX=-1 now=float('inf') ans=[] for i in range(n): s,a=input().split() a=int(...
ConDefects/ConDefects/Code/abc304_a/Python/45720608
condefects-python_data_1680
x, y = map(int, input().split()) print("Yes" if y - x == 2 or x - y == 3 else "No") x, y = map(int, input().split()) print("Yes" if 0 < y - x <= 2 or 0 < x - y <= 3 else "No")
ConDefects/ConDefects/Code/abc326_a/Python/54729093
condefects-python_data_1681
x,y = map(int, input().split()) if y-x <= -3 or y-x > 3: print("Yes") else: print("No") x,y = map(int, input().split()) if y-x >= -3 and y-x < 3: print("Yes") else: print("No")
ConDefects/ConDefects/Code/abc326_a/Python/54727999
condefects-python_data_1682
X, Y = map(int, input().split()) floors_to_move = Y - X if floors_to_move == 2 or floors_to_move == -3: print('Yes') else: print('No') X, Y = map(int, input().split()) floors_to_move = Y - X if 0 < floors_to_move <= 2 or -3 <= floors_to_move < 0: print('Yes') else: print('No')
ConDefects/ConDefects/Code/abc326_a/Python/54490935
condefects-python_data_1683
X,Y=map(int,input().split()); if X>Y:#下り: j=X-Y; if j<=3: print("Yes"); else: print("No"); else: k=Y-X; if k>=2: print("Yes"); else: print("No") X,Y=map(int,input().split()); if X>Y:#下り: j=X-Y; if j<=3: print("Yes"); else: print("No"); else: k=Y-X; if k<=2: print("Yes"...
ConDefects/ConDefects/Code/abc326_a/Python/54516500
condefects-python_data_1684
x,y = map(int,input().split()) if y-x == 2 or x-y == 3: print("Yes") else: print("No") x,y = map(int,input().split()) if 0 <= y-x <= 2 or 0 <= x-y <= 3: print("Yes") else: print("No")
ConDefects/ConDefects/Code/abc326_a/Python/54933438
condefects-python_data_1685
Q=int(input()) for _ in range(Q): P,A,B,S,G=map(int,input().split()) mod=P if S==G: print(0) continue if A==0: if B==P: print(1) continue else: print(-1) continue def g(x): ans=1 w=x n=mod-2 while n>0: if n&1: ans*=w ans%=mod ...
ConDefects/ConDefects/Code/abc270_g/Python/49185222
condefects-python_data_1686
def extgcd(a, b): """returns gcd(a, b), s, r s.t. a * s + b * r == gcd(a, b)""" s, bs = 0, 1 r, br = b, a while r: q = br // r br, r = r, br - q * r bs, s = s, bs - q * s return br, bs, (br-bs*a)//b if b else 0 import math def sol(a, b, mod): """solve ax≡b %mod""" g ...
ConDefects/ConDefects/Code/abc270_g/Python/43228358
condefects-python_data_1687
import sys input = sys.stdin.readline def Matprod(A, B, mod, N): temp = [0] * N*N for i in range(N): for j in range(N): ij = i * N + j for k in range(N): temp[ij] += A[i*N+k] * B[k*N+j] temp[ij] %= mod return temp def Matpow_Linear(A, M, mod,...
ConDefects/ConDefects/Code/abc270_g/Python/52785891
condefects-python_data_1688
def resolve(): import sys input = sys.stdin.readline t = int(input()) for _ in range(t): p, a, b, s, g = map(int, input().split()) def f(x): return (a * x + b) % p r = int(p**0.5) + 1 xr = pow(a, r, p) yr = b for _ in range(r - 1): ...
ConDefects/ConDefects/Code/abc270_g/Python/49178986
condefects-python_data_1689
import sys readline = sys.stdin.readline n,m,k = map(int,readline().split()) ac = [list(map(int,readline().split())) for _ in range(m)] ac = ac[::-1] d = n-k pow7 = [7**i for i in range(20)] for i in range(20)[::-1]: P = pow7[i] q,d = divmod(d,P) if q==0: continue for _ in range(q): p = P ...
ConDefects/ConDefects/Code/abc251_h/Python/31690776
condefects-python_data_1690
a=list(map(int,input().split())) print(max(0,max(a[0],a[1])-min(a[2],a[3]))) a=list(map(int,input().split())) print(max(0,min(a[1],a[3])-max(a[0],a[2])))
ConDefects/ConDefects/Code/abc261_a/Python/45683542
condefects-python_data_1691
L,R,LL,RR = map(int,input().split()) l = max(L,LL) r = min(R,RR) ans = max(r-l+1,0) print(ans) L,R,LL,RR = map(int,input().split()) l = max(L,LL) r = min(R,RR) ans = max(r-l,0) print(ans)
ConDefects/ConDefects/Code/abc261_a/Python/44843749
condefects-python_data_1692
L1,R1,L2,R2 = map(int,input().split()) if L1 <= L2 <= R1 <= R2: print(R1-L2) elif L2 <= L1 <= R2 <= R1: print(R2-L1) elif L2 <= L1 <= R1 <= R2: print(R1-L1) elif L1 <= L2 <= R2 <= R1: print(R2-L2) L1,R1,L2,R2 = map(int,input().split()) if L1 <= L2 <= R1 <= R2: print(R1-L2) elif L2 <= L1 <= R2 <= R1...
ConDefects/ConDefects/Code/abc261_a/Python/45791113
condefects-python_data_1693
#!/usr/bin/env python3 l1, r1, l2, r2 = [int(x) for x in input().split()] if r1 <= l2 or r2 < l1: print(0) elif l2 < r1 and l1 < l2: print(min(r1, r2) - max(l1, l2)) #!/usr/bin/env python3 l1, r1, l2, r2 = [int(x) for x in input().split()] if r1 <= l2 or r2 < l1: print(0) else: print(min(r1, r2) - m...
ConDefects/ConDefects/Code/abc261_a/Python/45222195
condefects-python_data_1694
l1,r1,l2,r2=map(int,input().split()) ans=0 for i in range(0,100): if l1<i<=r1 and l2<i<=r2: ans+=1 print(ans) l1,r1,l2,r2=map(int,input().split()) ans=0 for i in range(0,101): if l1<i<=r1 and l2<i<=r2: ans+=1 print(ans)
ConDefects/ConDefects/Code/abc261_a/Python/45536785
condefects-python_data_1695
import sys inf = 1e9 def input(): return sys.stdin.readline().strip() def solution(chords): chords = [sorted(x) for x in chords] m = {e:s for s,e in chords} starts = set(map(lambda x: x[0], chords)) ends = set(map(lambda x: x[1], chords)) N = len(chords) s = [] for x in range(N): ...
ConDefects/ConDefects/Code/abc338_e/Python/54041010
condefects-python_data_1696
n = int(input()) s = list(map(int,input().split())) for i in range(n): ans = 0 for l in range(7): ans += s[l+i] print(str(ans),"",end = "") n = int(input()) s = list(map(int,input().split())) for i in range(n): ans = 0 for l in range(7): ans += s[l+i*7] print(str(ans),"",end = "")
ConDefects/ConDefects/Code/abc307_a/Python/45989937
condefects-python_data_1697
N = int(input()) l = list(map(int,input().split())) lis = [] d = [] b = 0 for j in range(int(N/7)): for k in l[7*b:7*(b+1)]: lis.append(k) d.append(sum(lis)) lis.clear() b += 1 print(*d) N = int(input()) l = list(map(int,input().split())) lis = [] d = [] b = 0 for j in range(int(N)): for k in l[7*b:7*(...
ConDefects/ConDefects/Code/abc307_a/Python/45778588
condefects-python_data_1698
N = int(input()) A = list(map(int,input().split())) res = [0]*N SUM = 0 for i in range(len(A)): SUM += A[i] if (i + 1)%7==0: res[i//7] = SUM SUM = 0 print(res) N = int(input()) A = list(map(int,input().split())) res = [0]*N SUM = 0 for i in range(len(A)): SUM += A[i] if (i + 1)%7==0:...
ConDefects/ConDefects/Code/abc307_a/Python/45953883
condefects-python_data_1699
import sys import os from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.write if self.writabl...
ConDefects/ConDefects/Code/abc273_g/Python/35719660
condefects-python_data_1700
N, M = map(int, input().split()) S = [list(input()) for _ in range(N)] ans = M + 10 for bit in range(1 << N): #訪れるポップコーン売り場の選び方=bit store = [] for i in range(N): #N個の売り場について if bit >> i & 1: #bitのi番目のビットが1かどうか pythonで1はTrue, 0はFalse store.append(i) #bitで1だった売り場のindexをstoreに入れる da...
ConDefects/ConDefects/Code/abc358_c/Python/54990754