from itertools import combinations N = int(input()) ls = [] for n in range(N): x, y = map(int,input().split()) ls.append((x,y)) ls.sort() st = set(ls) ans = 0 for p1, p2 in combinations(ls, 2): # 組み合わせでOK x1, y1 = p1 x2, y2 = p2 if (x2 + y2 - y1, y2 + x1 - x2) in st and (x1 + y2 - y1, y1 + x1 - x2) in st: ans = max(ans, (x1-x2)**2+(y1-y2)**2) print (ans)
N, M = map(int, input().split()) A = list(map(int, input().split()))
if len(set([count_two(a) for a in A])) != 1: print (0) exit() A = [a//2for a in A] # a_k/2 を考える lc = ls_lcm(A) print ((M + lc) // (2*lc)) # 最小公倍数を奇数倍したものが条件を満たす
classUnionFind: def__init__(self, n): self.nodes = n self.parents = [i for i in range(n)] self.sizes = [1] * n self.rank = [0] * n
deffind(self, i):# どの集合に属しているか(根ノードの番号) if self.parents[i] == i: return i else: self.parents[i] = self.find(self.parents[i]) # 経路圧縮 return self.parents[i]
defunite(self, i, j):# 二つの集合を併合 pi = self.find(i) pj = self.find(j) if pi != pj: if self.rank[pi] < self.rank[pj]: self.sizes[pj] += self.sizes[pi] self.parents[pi] = pj else: self.sizes[pi] += self.sizes[pj] self.parents[pj] = pi if self.rank[pi] == self.rank[pj]: self.rank[pi] += 1 defsame(self, i, j):# 同じ集合に属するかを判定 return self.find(i)==self.find(j)
defget_parents(self):# 根ノードの一覧を取得 for n in range(self.nodes): # findで経路圧縮する self.find(n) return self.parents
adj = [] N, M = map(int,input().split()) for m in range(M): a,b = map(int,input().split()) adj.append([a-1,b-1])
ans = 0 for i in range(M): # 取り除く辺番号 uf = UnionFind(N) for j in range(M): if (i==j): # 辺を追加しない(取り除く) continue uf.unite(*adj[j]) if len(set(uf.get_parents()))!=1: # 複数の集合にわかれているか確認 ans += 1 print (ans)
MOD = 10**9+7 deffactorize(N): n = N fact = [] for i in range(2,int(N**0.5)+1): # intに変換すること while(n%i==0): n //= i # 整数除算(//)を使うこと fact.append(i) if n!=1: fact.append(n) return fact N = int(input()) cnt = [0] * (N+1) for n in range(1,N+1): fact = factorize(n) for f in fact: cnt[f] += 1
ans = 1 for n in range(N+1): ans *= (cnt[n]+1) ans %= MOD print (ans)
import itertools deftranspose(mat):# 二次元のリストを転置する関数 return list(zip(*mat)) H, W, K, V = map(int, input().split()) A = [[0] * (W+1)] # 1行目は0にしておくと計算が楽
for h in range(H): a = list(map(int,input().split())) a = [0] + a # 1列目は0にしておくと計算が楽 A.append(a)
B = [] for a in A: csum = list(itertools.accumulate(a)) B.append(csum) B = transpose(B)
csum_mat = [] for a in B: csum = list(itertools.accumulate(a)) csum_mat.append(csum) csum_mat = transpose(csum_mat)
ans = 0 for h1 in range(H): if ((H-h1) * W < ans): continue ch1 = csum_mat[h1] # メモ for h2 in range(h1,H+1): if ((h2-h1) * W < ans): continue h2h1 = h2 - h1 # メモ ch2 = csum_mat[h2] # メモ for w1 in range(W): if (h2h1 * (W-w1) < ans): continue h2w1h1w1 = - ch2[w1] + ch1[w1] # メモ for w2 in range(w1,W+1): s = h2h1 * (w2-w1) # 面積 if (s < ans): continue cost = ch2[w2] - ch1[w2] + h2w1h1w1 cost += K * s if (cost <= V): ans = s print (ans)
import itertools MOD = 10**5 N, M = map(int, input().split()) D = [0] # 先頭に0を入れておくと、累積和の差分計算の際に楽 for n in range(N-1): d = int(input()) D.append(d) C = [] for m in range(M): c = int(input()) C.append(c)
csum = list(itertools.accumulate(D)) cur = 1 ans = 0 for c in C: next = cur + c # 移動 ans += abs(csum[next-1]-csum[cur-1]) # 絶対値を足す cur = next # 次の移動開始地点 ans %= MOD print (ans)
import itertools N, M, Q = map(int, input().split()) P = [] LR = [[0] * (N+1) for _ in range(N+1)] for m in range(M): l, r = map(int, input().split()) LR[l][r] += 1
for q in range(Q): p = list(map(int, input().split())) P.append(p)
csum = [] for L in LR: a = list(itertools.accumulate(L)) csum.append(a)
for p in P: ans = 0 l, r = p for c in csum[l:r+1]: ans += (c[r] - c[l-1]) print (ans)
N, M = map(int,input().split()) ok = [1] * N H = list(map(int,input().split())) for m in range(M): a, b = map(int,input().split()) a-=1 b-=1 if H[a] < H[b]: ok[a] = 0 elif H[a] > H[b]: ok[b] = 0 else: ok[a] = ok[b] = 0 print (sum(ok))