description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Alice has an array A consisting of N distinct integers. Bob takes exactly N - 1 elements from this array and adds a positive integer X (i.e. X > 0) to each of these numbers and then shuffles them to form a new array B of length N - 1.
You are given both arrays A and B. You have to identify the value of X chosen by Bo... | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.sort()
b.sort()
x = y = float("inf")
if n == 2:
x = b[0] - a[0] if b[0] - a[0] > 0 else float("inf")
y = b[0] - a[1] if b[0] - a[1] > 0 else float("inf")
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VA... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | m = 998244353
n = int(input())
l = sorted(map(int, input().split()))
N = 2 * n
t = 1
a = (sum(l[n:]) - sum(l[:n])) % m
for i in range(n):
a = a * (N - i) % m
for i in range(1, n + 1):
t = t * i % m
print(pow(t, m - 2, m) * a % m) | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR FO... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | def bp(b, p):
if p == 1:
return b
if p % 2 == 0:
t = bp(b, p // 2)
return t * t % q
else:
return bp(b, p - 1) * b % q
def inv(x):
return bp(x, q - 2)
def div(a, b):
return a * inv(b) % q
n = int(input())
u = sorted(list(map(int, input().split())))
s = sum(u[n:])... | FUNC_DEF IF VAR NUMBER RETURN VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP VAR VAR VAR RETURN BIN_OP BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_DEF RETURN BIN_OP BIN_OP VAR FUNC_CALL VAR VAR VAR ASSIG... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | M, n, a, t = 998244353, int(input()), sorted(list(map(int, input().split()))), 1
s = (sum(a[n:]) - sum(a[:n])) % M
for i in range(2, n + 1):
t *= i
t %= M
tt = pow(t, 2 * M - 4, M)
for i in range(n + 1, 2 * n + 1):
t *= i
t %= M
print(tt * t % M * s % M) | ASSIGN VAR VAR VAR VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP NUMBER... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | import sys
mod = 998244353
eps = 10**-9
def main():
import sys
input = sys.stdin.buffer.readline
N = int(input())
A = list(map(int, input().split()))
A.sort()
ans = 0
for i in range(N):
ans += A[-i - 1] - A[i]
for i in range(1, N + 1):
ans = ans * (N + i) % mod
fa... | IMPORT ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FUNC_DEF IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR ... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | from sys import stdin
input = stdin.readline
def A():
t = int(input())
for _ in range(t):
n, x = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if _ != t - 1:
input()
b.sort(reverse=True)
a.sort()
... | ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL ... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | n = int(input())
a = list(map(int, input().split()))
mod = 998244353
def ncr(n, r, p):
num = den = 1
for i in range(r):
num = num * (n - i) % p
den = den * (i + 1) % p
return num * pow(den, p - 2, p) % p
a.sort()
print(ncr(2 * n, n, mod) * (sum(a[n:]) - sum(a[0:n])) % mod) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR RETURN BIN_OP BIN_OP VAR FUNC_CALL VAR V... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | import sys
readline = sys.stdin.readline
MOD = 998244353
def make_fac(limit):
fac = [1] * limit
for i in range(2, limit):
fac[i] = i * fac[i - 1] % MOD
faci = [0] * limit
faci[-1] = pow(fac[-1], MOD - 2, MOD)
for i in range(limit - 2, 0, -1):
faci[i] = faci[i + 1] * (i + 1) % MOD
... | IMPORT ASSIGN VAR VAR ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | def res(n):
nu = s = 1
for i in range(n):
nu = nu * (2 * n - i) % m
s = s * (i + 1) % m
return nu * pow(s, m - 2, m) % m
m = 998244353
n = int(input())
fg = sorted(list(map(int, input().split())))
f = abs(sum(fg[:n]) - sum(fg[n:]))
print(f * res(n) % m) | FUNC_DEF ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP NUMBER VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR RETURN BIN_OP BIN_OP VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | def ncr(n, r, p):
num = den = 1
for i in range(r):
num = num * (n - i) % p
den = den * (i + 1) % p
return num * pow(den, p - 2, p) % p
n = int(input())
a = sorted(list(map(int, input().split())))
ans = 0
for i in range(n):
ans += abs(a[i] - a[2 * n - 1 - i]) % 998244353
print(ncr(2 * n... | FUNC_DEF ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR RETURN BIN_OP BIN_OP VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | n = int(input())
s = list(map(int, input().split()))
s = sorted(s)
k = 0
for i in range(n):
k -= s[i]
k += s[i + n]
k = k % 998244353
s = k
m = 1
for i in range(1, n + 1):
s = s * (2 * n + 1 - i) % 998244353
m = m * i % 998244353
print(pow(m, 998244353 - 2, 998244353) * s % 998244353) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMB... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | mod = 998244353
n = int(input())
fact = [1]
inv = [1]
for i in range(1, 2 * n + 1):
fact.append(fact[-1] * i % mod)
inv.append(pow(fact[-1], mod - 2, mod) % mod)
a = list(map(int, input().split()))
b = a[:n]
c = a[n:]
b.sort()
c.sort(reverse=True)
s = 0
for i in range(n):
s += abs(c[i] - b[i])
ans = fact[2 ... | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR FU... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | md, n = 998244353, int(input())
arr = sorted(list(map(int, input().split())))
sigma = (sum(arr[n:]) - sum(arr[:n])) % md
up, dn = 1, 1
for i in range(1, n + 1):
up = up * (n + i) % md
dn = dn * i % md
print(sigma * up % md * pow(dn, md - 2, md) % md) | ASSIGN VAR VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR ... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | n = int(input())
l = sorted(map(int, input().split()))
tot = sum(l[n:]) - sum(l[:n])
MOD = 998244353
fact = [1]
for i in range(1, 2 * n + 1):
fact.append(fact[-1] * i % MOD)
tot *= fact[2 * n]
inv = pow(fact[n], MOD - 3, MOD)
tot *= inv
print(tot % MOD) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR VA... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | n = int(input())
mod = 998244353
(*arr,) = map(int, input().split())
arr.sort()
i = 0
j = 2 * n - 1
s = 0
while i < j:
s += abs(arr[i] - arr[j])
i += 1
j -= 1
s %= mod
factorials = [1]
for i in range(1, 2 * n + 1):
factorials.append(factorials[-1] * i % mod)
inverses = [pow(v, mod - 2, mod) for v in fac... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR VAR ASSIGN VAR LIST NUMBER FOR ... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | n = int(input())
l = list(map(int, input().split()))
l.sort()
l1 = l[:n]
l2 = l[n:]
l2.sort(reverse=True)
ans = 0
for i in range(n):
ans += abs(l1[i] - l2[i])
f = [1] * 300001
fi = [1] * 300001
a = 1
b = 1
m = 998244353
for i in range(2, 2 * n + 1):
a *= i
a %= m
b *= pow(i, m - 2, m)
b %= m
f[i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VA... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | MOD = 998244353
n = int(input())
s = [int(x) for x in input().split()]
s.sort()
N = 2 * n
m1 = 1
for i in range(1, N + 1):
m1 = m1 * i % MOD
m2 = 1
for i in range(1, n + 1):
m2 = m2 * i % MOD
tt = m2 * m2 % MOD
dem = pow(tt, MOD - 2, MOD) % MOD
val = m1 * dem % MOD
ans1 = 0
for i in range(0, n):
ans1 = ans1... | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VA... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | def ncr(n, r, p):
num = den = 1
for i in range(r):
num = num * (n - i) % p
den = den * (i + 1) % p
return num * pow(den, p - 2, p) % p
def solve(n, a):
a.sort()
M = 998244353
ss = sum(a[:n])
ls = sum(a[n:])
diff = (ls - ss) % M
return diff * ncr(2 * n, n, M) % M
n... | FUNC_DEF ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR RETURN BIN_OP BIN_OP VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | def pwm(a, n, md):
p = 1
while n:
if n & 1:
p = p * a % md
a = a * a % md
n >>= 1
return p
n = int(input())
ar = list(map(int, input().split()))
ar.sort()
ans = 0
nom = 1
dnom = 1
mod = 998244353
for i in range(0, n):
ans = (ans + ar[i + n] - ar[i]) % mod
nom = ... | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR IF BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIG... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | mod = 998244353
n = int(input())
arr = [int(j) for j in input().split()]
fact = [1] * (3 * n)
for i in range(1, 3 * n):
fact[i] = fact[i - 1] * i % mod
arr.sort()
print(
(sum(arr[n:]) - sum(arr[:n])) * fact[2 * n] * pow(fact[n], mod - 2, mod) ** 2 % mod
) | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP ... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | def mod_fact(n, m):
ans = 1
for i in range(1, n + 1):
ans = ans % m * (i % m) % m
return ans
def mod_div(a, b, md):
a %= md
b %= md
return a * pow(b, md - 2, md) % md
MOD = 998244353
n = int(input())
arr = list(map(int, input().split()))
arr.sort()
su = abs(sum(arr[:n]) - sum(arr[n:]... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR RETURN VAR FUNC_DEF VAR VAR VAR VAR RETURN BIN_OP BIN_OP VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | def choose(n):
global mod
num = den = 1
for i in range(n):
num = num * (2 * n - i) % mod
den = den * (i + 1) % mod
return num * pow(den, mod - 2, mod) % mod
mod = 998244353
n = int(input())
arr = list(map(int, input().split()))
arr.sort()
a = arr[:n]
b = arr[n:]
b.sort(reverse=True)
to... | FUNC_DEF ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP NUMBER VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR RETURN BIN_OP BIN_OP VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | n = int(input())
mod = 998244353
den = 1
arr = [int(x) for x in input().split()]
arr.sort()
for i in range(1, n + 1):
den = den * (i + n) * pow(i, mod - 2, mod) % mod
print((sum(arr[n : 2 * n]) - sum(arr[0:n])) * den % mod) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR BIN_OP B... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | mod = 998244353
def fac(x):
acc = 1
for i in range(1, x + 1):
acc = acc * i % mod
return acc
def inv(x):
return pow(x, mod - 2, mod)
n = int(input())
arr = list(map(int, input().split()))
arr.sort()
print(
sum(arr[-i - 1] - arr[i] for i in range(n))
% mod
* fac(2 * n)
% mod... | ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR RETURN VAR FUNC_DEF RETURN FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | import sys
from sys import stdin
def modfac(n, MOD):
f = 1
factorials = [1]
for m in range(1, n + 1):
f *= m
f %= MOD
factorials.append(f)
inv = pow(f, MOD - 2, MOD)
invs = [1] * (n + 1)
invs[n] = inv
for m in range(n, 1, -1):
inv *= m
inv %= MOD
... | IMPORT FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER VAR VAR VAR VAR ASS... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | n = int(input())
(*a,) = map(int, input().split())
a.sort()
ans = sum(a[2 * n - i - 1] - a[i] for i in range(n))
m = 998244353
for i in range(n):
ans *= 2 * n - i
ans *= pow(i + 1, m - 2, m)
ans %= m
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP NUMBER VAR VAR VAR FUNC_CALL VAR BIN_O... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | mod = 998244353
n = int(input())
a = sorted(list(map(int, input().split())))
c = 0
for i in range(n):
c += abs(a[i] - a[2 * n - i - 1])
f = [1, 1]
for i in range(2, 2 * n + 1):
f.append(f[-1] * i % mod)
print(c * (f[2 * n] * pow(f[n] * f[n] % mod, mod - 2, mod)) % mod % mod) | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | from sys import stdin, stdout
MOD = 998244353
def divide_and_sum(n, a_a):
a_a.sort()
s = (sum(a_a[n : 2 * n]) - sum(a_a[0:n])) % MOD
c = Com(n, 2 * n)
r = s * c % MOD
return r
def Com(p, t):
c1 = 1
c2 = 1
for i in range(p):
c1 *= t - i
c1 %= MOD
c2 *= i + 1
... | ASSIGN VAR NUMBER FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR BIN_OP NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | import sys
input = sys.stdin.readline
MOD = 998244353
N = 400000
fact = [(0) for _ in range(N)]
invfact = [(0) for _ in range(N)]
fact[0] = 1
for i in range(1, N):
fact[i] = fact[i - 1] * i % MOD
invfact[N - 1] = pow(fact[N - 1], MOD - 2, MOD)
for i in range(N - 2, -1, -1):
invfact[i] = invfact[i + 1] * (i + 1... | IMPORT ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER ... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | mod = 998244353
n = int(input())
a = list(map(int, input().split()))
a.sort()
res = 0
inv = [1, 1]
for i in range(2, n + 1):
inv.append((mod - mod // i) * inv[mod % i] % mod)
for i in range(n):
res += a[n + i] - a[i]
for i in range(2 * n, 0, -1):
if i > n:
res = res * i % mod
else:
res =... | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR ... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | N, MOD = 300005, 998244353
f = [1] * N
for i in range(1, N):
f[i] = f[i - 1] * i % MOD
n = int(input())
ar = sorted(list(map(int, input().split())))
e = (-sum(ar[:n]) + sum(ar[-n:])) % MOD
e = e * f[2 * n] % MOD
e = e * pow(f[n], MOD - 2, MOD) % MOD
e = e * pow(f[n], MOD - 2, MOD) % MOD
print(e) | ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VA... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | n = int(input())
z = sorted(map(int, input().split()))
mod = 998244353
fact = [1] * (2 * n + 1)
for i in range(1, 2 * n + 1):
fact[i] = fact[i - 1] * i % mod
inv = [0] * (2 * n + 1)
inv[2 * n] = pow(fact[i], mod - 2, mod)
for i in range(2 * n - 1, -1, -1):
inv[i] = inv[i + 1] * (i + 1) % mod
def ncr(n, r):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | MOD = 998244353
MAX = 300000
fact = [1]
for zz in range(1, MAX + 1):
fact.append(fact[-1] % MOD * zz % MOD % MOD)
def nCr(n, r):
num = fact[n]
den = fact[r] % MOD * (fact[n - r] % MOD) % MOD
return num % MOD * pow(den, MOD - 2, MOD) % MOD
n = int(input())
a = [int(x) for x in input().split()]
p = a[... | ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR VAR VAR FUNC_DEF ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR VAR RETURN BIN_OP BIN_OP BIN_OP VAR VA... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | mod = 998244353
n = int(input())
a = sorted(list(map(int, input().split())))
Sum = (sum(a[n:]) - sum(a[:n])) % mod
soorat, makhraj = 1, 1
for i in range(n):
soorat = soorat * (n + 1 + i) % mod
makhraj = makhraj * (i + 1) % mod
makhraj = pow(makhraj, mod - 2, mod)
print(makhraj * soorat % mod * Sum % mod) | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR NUMBER ... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | from sys import gettrace, stdin
if gettrace():
inputi = input
else:
def input():
return next(stdin)[:-1]
def inputi():
return stdin.buffer.readline()
MOD = 998244353
def main():
n = int(inputi())
aa = [int(a) for a in inputi().split()]
aa.sort()
sm = sum(aa[n:]) - sum(... | IF FUNC_CALL VAR ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR VAR AS... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | m = 998244353
def modExp(a, n, m=10**9 + 7):
if n == 0:
return 1
elif n == 1:
return a
else:
while n >= 2:
if n % 2 == 0:
n = n // 2
return modExp(a % m * (a % m) % m, n, m)
else:
n = (n - 1) // 2
... | ASSIGN VAR NUMBER FUNC_DEF BIN_OP BIN_OP NUMBER NUMBER NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN VAR WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER RETURN BIN_... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | def ncr(n, r):
num = 1
den = 1
for i in range(r):
num = num * (n - i) % m
den = den * (i + 1) % m
p = num * pow(den, m - 2, m) % m
return p
m = 998244353
n = int(input())
a = list(map(int, input().split()))
a.sort()
an = abs(sum(a[:n]) - sum(a[n:]))
s = an * ncr(2 * n, n) % m
print... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR RETURN VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VA... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | def pwm(a, n, mod):
ans = 1
while n:
if n & 1:
ans = ans * a % mod
a = a * a % mod
n >>= 1
return ans
n = int(input())
l = [int(x) for x in input().split()]
l.sort()
a, b = l[:n], l[n:]
ans = 0
mod = 998244353
dnom = 1
nom = 1
for i in range(n):
ans += (b[i] % mod -... | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR IF BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER AS... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | n = int(input())
a = sorted(map(int, input().split()))
mod = 998244353
z = 0
facn = 1
for i in range(n):
z += abs(a[i] - a[-(i + 1)])
facn = facn * (i + 1) % mod
fac2n = facn
for i in range(n + 1, 2 * n + 1):
fac2n = fac2n * i % mod
invfacn = pow(facn, mod - 2, mod)
print(z * fac2n * invfacn * invfacn % mod... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR FOR VAR FUNC_... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | n = int(input())
a = list(map(int, input().split()))
x = sorted(a[0:n])
y = sorted(a[n:], reverse=True)
M = 998244353
Sum = sum(map(lambda z, c: abs(z - c), x, y)) % M
count = Sum
for i in range(n * 2, n, -1):
count = count * i % M
fact = 1
for i in range(2, n + 1):
fact = fact * i % M
print(pow(fact, M - 2, M)... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_C... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | mod = 998244353
def dev(a, b):
return a * pow(b, mod - 2, mod) % mod
def fac(a):
d = 1
for i in range(1, a + 1):
d *= i
d %= mod
return d
n = int(input())
arr = list(map(int, input().split()))
arr.sort()
s = sum(arr[n:]) - sum(arr[:n])
f = dev(fac(2 * n) % mod, fac(n) ** 2 % mod)
p... | ASSIGN VAR NUMBER FUNC_DEF RETURN BIN_OP BIN_OP VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VA... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | mod = 998244353
class Combi:
def __init__(self, N, mod):
self.power = [(1) for _ in range(N + 1)]
self.rev = [(1) for _ in range(N + 1)]
self.mod = mod
for i in range(2, N + 1):
self.power[i] = self.power[i - 1] * i % self.mod
self.rev[N] = pow(self.power[N], s... | ASSIGN VAR NUMBER CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | from sys import stdin
input = lambda: stdin.readline().strip()
n = int(input())
a = list(map(int, input().split()))
a.sort()
summ = -sum(a[:n]) + sum(a[n:])
mod = 998244353
def bin_pow(num, pow):
if pow == 0:
return 1
if pow == 1:
return num
x = bin_pow(num, pow // 2) % mod
if pow % 2... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN VAR ASSIGN VAR BIN_OP ... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
a.sort()
L = a[:n]
R = a[n:][::-1]
s = sum(x - y for x, y in zip(R, L))
MOD_NUM = 998244353
D = 1
for x in range(1, n + 1):
D *= x
D %= MOD_NUM
U = D
for x in range(n + 1, 2 * n + 1):
U *= x
U %= MOD_NUM
ans = U ... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR ... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | def big_mod(a, b):
if b == 0:
return 1
x = big_mod(a, int(b / 2))
if b & 1:
return x * x % MOD * a % MOD
else:
return x * x % MOD
n = int(input())
a = list(map(int, input().split()))
a.sort()
x, y = a[:n], a[n:]
y.reverse()
sum = 0
for i in range(n):
sum += abs(x[i] - y[i])... | FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR RETURN BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FU... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | import sys
input = sys.stdin.readline
mod = 998244353
n = int(input())
a = list(map(int, input().split()))
a.sort()
val = 0
for i in range(n):
val += a[-i - 1]
val -= a[i]
facs = [1]
for i in range(2 * n):
facs.append(facs[-1] * (i + 1) % mod)
numb = facs[2 * n]
numb *= pow(facs[n] ** 2, mod - 2, mod)
numb... | IMPORT ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR EXPR FUNC_... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | import sys
sys.setrecursionlimit(10**5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II():
return int(sys.stdin.buffer.readline())
def MI():
return map(int, sys.stdin.buffer.readline().split())
def LI():
return list(map(int, sys.stdin.buffer.readline().split()))
def LLI(rows_... | IMPORT EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | n = int(input())
ar = sorted(list(map(int, input().split())))
ans = 0
nom = 1
dnom = 1
mod = 998244353
for i in range(n):
ans = (ans + ar[i + n] - ar[i]) % mod
nom = nom * (i + n + 1) % mod
dnom = dnom * (i + 1) % mod
print(ans * nom % mod * pow(dnom, mod - 2, mod) % mod) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | MOD = 998244353
def pow_mod(a, n, mod):
result = 1 % mod
a_pow_2_pow_bit_index = a % mod
while n:
if n & 1:
result *= a_pow_2_pow_bit_index
result %= mod
a_pow_2_pow_bit_index **= 2
a_pow_2_pow_bit_index %= mod
n >>= 1
return result
def inv_mod... | ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR VAR WHILE VAR IF BIN_OP VAR NUMBER VAR VAR VAR VAR VAR NUMBER VAR VAR VAR NUMBER RETURN VAR FUNC_DEF RETURN FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR FUNC_DEF ASSIGN VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR V... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | maxn = 5 * 10**5
mo = 998244353
rev = lambda x: pow(x, mo - 2, mo)
fact = [0] * maxn
fact[0] = 1
for i in range(1, maxn):
fact[i] = fact[i - 1] * i % mo
ract = [0] * maxn
ract[maxn - 1] = rev(fact[maxn - 1])
for i in range(maxn - 2, -1, -1):
ract[i] = ract[i + 1] * (i + 1) % mo
C = lambda u, v: fact[u] * ract[v... | ASSIGN VAR BIN_OP NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP VA... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | from sys import stdin, stdout
input = stdin.readline
m = 998244353
def ncr(n, r, p):
num = den = 1
for i in range(r):
num = num * (n - i) % p
den = den * (i + 1) % p
return num * pow(den, p - 2, p) % p
t = 1
for _ in range(t):
n = int(input())
arr = [int(x) for x in input().spli... | ASSIGN VAR VAR ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR RETURN BIN_OP BIN_OP VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CA... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | MOD = 998244353
n = int(input())
a = list(map(int, input().split()))
a.sort()
for i in range(2 * n):
a[i] %= MOD
sum = 0
t = 1
for i in range(n):
sum += a[i + n] - a[i]
sum %= MOD
for i in range(1, n + 1):
sum = sum * (2 * n - i + 1) % MOD
t = t * i % MOD
print(pow(t, MOD - 2, MOD) * sum % MOD) | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR VAR VAR VAR FOR VAR FUNC_CALL... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | from sys import *
M = 998244353
n = int(stdin.readline())
A = sorted(list(map(int, stdin.readline().split())))
s, t = sum(A[n:]) - int(sum(A[:n])) % M, 1
for i in range(1, n + 1):
s = s * (2 * n - i + 1) % M
t = t * i % M
stdout.write(str(pow(t, M - 2, M) * s % M) + "\n") | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP B... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | mod = 998244353
n = int(input())
a = [int(x) for x in input().split()]
a.sort()
small = a[:n]
big = a[n:]
s = (sum(big) - sum(small)) % mod
fact = [1]
for i in range(1, 2 * n + 1):
ans = fact[-1] * i % mod
fact.append(ans)
ans = fact[2 * n] * pow(fact[n], mod - 2, mod) ** 2 % mod
print(s * ans % mod) | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER ... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | n = int(input())
m = 998244353
a = list(map(int, input().split()))
a.sort()
num = (sum(a[n:]) - sum(a[:n])) % m
den = 1
for i in range(1, n + 1):
num = num * (2 * n - i + 1) % m
den = den * pow(i, m - 2, m) % m
print(den * num % m) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP BIN... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | mod = 998244353
maxn = 300000 + 10
n = 0
Ans = 0
a = []
fact = [1] * maxn
def Pow(i, j):
ret = 1
while j != 0:
if j % 2 == 1:
ret = ret * i % mod
i = i * i % mod
j //= 2
return ret
n = int(input())
a = list(map(int, input().split()))
a.sort()
for i in range(1, 2 * n +... | ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | import sys
input = sys.stdin.buffer.readline
n, ar = int(input()), list(map(int, input().split()))
ar.sort()
p1, p2, MOD = 1, 1, 998244353
for u in range(1, 2 * n + 1):
if u <= n:
p1 = p1 * u % MOD
else:
p2 = p2 * u % MOD
m = p2 * pow(p1, MOD - 2, MOD) % MOD
cc, t = 0, m
for u in range(1, 2 * n... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VA... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | mod = 998244353
def pow_(x, y, p):
res = 1
x = x % p
if x == 0:
return 0
while y > 0:
if y & 1 == 1:
res = res * x % p
y = y >> 1
x = x * x % p
return res
def reverse(x, mod):
return pow_(x, mod - 2, mod)
gt = [1] * 300001
for i in range(2, 30000... | ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER RETURN NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR RETURN VAR FUNC_DEF RETURN FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR ASSIGN... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | mod = 998244353
def nCr(n, r, p):
num = den = 1
for i in range(r):
num = num * (n - i) % p
den = den * (i + 1) % p
return num * pow(den, p - 2, p) % p
n = int(input())
v = list(map(int, input().split()))
v[:] = sorted(v)
diff = 0
for i in range(2 * n):
if i < n:
diff -= v[i]
... | ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR RETURN BIN_OP BIN_OP VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR... |
You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).
Let's sort $p$ in non-decreasing order, and $q$ in non-increasing order, we can denote the sorted ... | n = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
p = 998244353
x = 1
for i in range(n + 1, 2 * n + 1):
x *= i
x %= p
x2 = 1
for i in range(1, n + 1):
x2 *= i
x2 %= p
x *= pow(x2, p - 2, p)
x %= p
Ans = 0
for i in range(n):
Ans += A[i] * x
for i in range(n):
Ans -= A[n + ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER... |
Vasya is studying number theory. He has denoted a function f(a, b) such that: f(a, 0) = 0; f(a, b) = 1 + f(a, b - gcd(a, b)), where gcd(a, b) is the greatest common divisor of a and b.
Vasya has two numbers x and y, and he wants to calculate f(x, y). He tried to do it by himself, but found out that calculating this... | def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
def kmm(a, b):
return a * b // gcd(a, b)
a, b = list(map(int, input().split()))
t = 0
while b > 0:
divi = []
for i in range(1, int(a**0.5) + 1):
if a % i == 0:
divi.append(i)
divi.append(a // i)
d... | FUNC_DEF IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUM... |
Vasya is studying number theory. He has denoted a function f(a, b) such that: f(a, 0) = 0; f(a, b) = 1 + f(a, b - gcd(a, b)), where gcd(a, b) is the greatest common divisor of a and b.
Vasya has two numbers x and y, and he wants to calculate f(x, y). He tried to do it by himself, but found out that calculating this... | a, b = map(int, input().split())
A = []
for i in range(2, int(a**0.5) + 1):
while a % i == 0:
a //= i
A.append(i)
if a != 1:
A.append(a)
out = 0
while b > 0:
n = len(A)
x = -1
for i in range(n):
if x == -1 or b % A[i] < b % A[x]:
x = i
if n == 0:
out +... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER WHILE BIN_OP VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR N... |
Vasya is studying number theory. He has denoted a function f(a, b) such that: f(a, 0) = 0; f(a, b) = 1 + f(a, b - gcd(a, b)), where gcd(a, b) is the greatest common divisor of a and b.
Vasya has two numbers x and y, and he wants to calculate f(x, y). He tried to do it by himself, but found out that calculating this... | def sqrt(n):
return n**0.5
def pfs(n):
A = []
while n % 2 == 0:
A += [2]
n //= 2
return A + pfs_dummy(n, 3)
def pfs_dummy(n, start):
if n == 1:
return []
A = []
for k in range(start, int(sqrt(n) + 1), 2):
if n % k == 0:
while n % k == 0:
... | FUNC_DEF RETURN BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR LIST WHILE BIN_OP VAR NUMBER NUMBER VAR LIST NUMBER VAR NUMBER RETURN BIN_OP VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF IF VAR NUMBER RETURN LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER IF BIN_OP VAR VAR NUMBER WHILE... |
Vasya is studying number theory. He has denoted a function f(a, b) such that: f(a, 0) = 0; f(a, b) = 1 + f(a, b - gcd(a, b)), where gcd(a, b) is the greatest common divisor of a and b.
Vasya has two numbers x and y, and he wants to calculate f(x, y). He tried to do it by himself, but found out that calculating this... | def bgcd(a, b):
d = 0
while a % 2 == 0 and b % 2 == 0:
a = a // 2
b = b // 2
d += 1
while a != b:
if a % 2 == 0:
a = a // 2
elif b % 2 == 0:
b = b // 2
elif a > b:
a = (a - b) // 2
else:
b = (b - a) // 2
... | FUNC_DEF ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR ... |
You've got another geometrical task. You are given two non-degenerate polygons A and B as vertex coordinates. Polygon A is strictly convex. Polygon B is an arbitrary polygon without any self-intersections and self-touches. The vertices of both polygons are given in the clockwise order. For each polygon no three consecu... | def convex_hull(points):
points = sorted(set(points))
if len(points) <= 1:
return points
def cross(o, a, b):
return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0])
lower = []
for p in points:
while len(lower) >= 2 and cross(lower[-2], lower[-1], p) < 0:
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER RETURN VAR FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR LIST FOR VAR VAR WHILE FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR... |
You've got another geometrical task. You are given two non-degenerate polygons A and B as vertex coordinates. Polygon A is strictly convex. Polygon B is an arbitrary polygon without any self-intersections and self-touches. The vertices of both polygons are given in the clockwise order. For each polygon no three consecu... | def cw(a, b, c):
return a[0] * (b[1] - c[1]) + b[0] * (c[1] - a[1]) + c[0] * (a[1] - b[1]) <= 0
def ccw(a, b, c):
return a[0] * (b[1] - c[1]) + b[0] * (c[1] - a[1]) + c[0] * (a[1] - b[1]) >= 0
def convex_hull(points):
points = sorted(points, key=lambda x: (x[0], x[1]))
up = [points[0]]
down = [p... | FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER NUMBER FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER ... |
You've got another geometrical task. You are given two non-degenerate polygons A and B as vertex coordinates. Polygon A is strictly convex. Polygon B is an arbitrary polygon without any self-intersections and self-touches. The vertices of both polygons are given in the clockwise order. For each polygon no three consecu... | import sys
input = sys.stdin.readline
a, b, temp = [], [], set()
arr = []
n = int(input())
for _ in range(n):
x, y = [int(x) for x in input().split()]
arr.append([x, y])
m = int(input())
for _ in range(m):
x, y = [int(x) for x in input().split()]
temp.add((x, y))
arr.append([x, y])
arr.sort()
p1 = ... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR VAR LIST LIST FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR F... |
Protection of the Indian border and safe transport of items from one point to another along the border are the paramount jobs for the Indian army. However they need some information about the protection status along the length of the border. The border can be viewed as the real x-axis. Along the axis, Indian army has N... | n, beg, end = list(map(int, input().split()))
s = 0
e = 0
if beg < end:
s = beg
e = end
else:
s = end
e = beg
arr = {}
arr1 = {}
for _ in range(n):
x, p = list(map(int, input().split()))
arr[x] = p
dic = {}
for k in arr:
mx = k + arr[k]
mn = k - arr[k]
dic[mn] = mx
arr1 = sorted(dic.... | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VA... |
Protection of the Indian border and safe transport of items from one point to another along the border are the paramount jobs for the Indian army. However they need some information about the protection status along the length of the border. The border can be viewed as the real x-axis. Along the axis, Indian army has N... | N, S, E = list(map(int, input().split()))
data = []
for i in range(N):
x, p = list(map(int, input().split()))
data.append([x - p, x + p])
data.sort()
diff = 0
for i in range(len(data)):
temp_arr = data[i]
temp_start = temp_arr[0]
temp_end = temp_arr[1]
if temp_start >= E:
break
if te... | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR A... |
Protection of the Indian border and safe transport of items from one point to another along the border are the paramount jobs for the Indian army. However they need some information about the protection status along the length of the border. The border can be viewed as the real x-axis. Along the axis, Indian army has N... | n, s, e = [int(i) for i in input().split()]
res = 0
a = []
for i in range(n):
x, p = [int(j) for j in input().split()]
a.append([min(max(1, x - p, s), e), max(min(x + p, e), s)])
a.sort(key=lambda x: x[0])
tlen = e - s + 1
clen = 0
i = 1
curr = a[0][1]
clen += max(0, a[0][0] - s)
while i < n:
if curr > a[i]... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR E... |
Let f(x) be the number of zeroes at the end of x!. (Recall that x! = 1 * 2 * 3 * ... * x, and by convention, 0! = 1.)
For example, f(3) = 0 because 3! = 6 has no zeroes at the end, while f(11) = 2 because 11! = 39916800 has 2 zeroes at the end. Given K, find how many non-negative integers x have the property that f(x)... | class Solution:
def canTransform(self, start, end):
n = len(start)
i = 0
j = 0
while i < n and j < n:
while i < n and start[i] == "X":
i += 1
while j < n and end[j] == "X":
j += 1
if i == n and j == n:
... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR WHILE VAR VAR VAR VAR STRING VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER IF VAR VAR VAR VAR RETURN NUMBER IF VAR VAR VAR VAR RETURN NUMBER IF VAR VAR VAR VAR RETURN NUMBER IF VAR VAR STRING VAR VAR RETURN NU... |
Let f(x) be the number of zeroes at the end of x!. (Recall that x! = 1 * 2 * 3 * ... * x, and by convention, 0! = 1.)
For example, f(3) = 0 because 3! = 6 has no zeroes at the end, while f(11) = 2 because 11! = 39916800 has 2 zeroes at the end. Given K, find how many non-negative integers x have the property that f(x)... | class Solution:
def canTransform(self, start, end):
s = [(c, i) for i, c in enumerate(start) if c == "L" or c == "R"]
e = [(c, i) for i, c in enumerate(end) if c == "L" or c == "R"]
return len(s) == len(e) and all(
c1 == c2 and (i1 >= i2 and c1 == "L" or i1 <= i2 and c1 == "R")
... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR STRING VAR STRING ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR STRING VAR STRING RETURN FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR STRING VAR VAR VAR STRING VAR VAR VAR VAR FUNC_CALL VAR VAR VAR |
Let f(x) be the number of zeroes at the end of x!. (Recall that x! = 1 * 2 * 3 * ... * x, and by convention, 0! = 1.)
For example, f(3) = 0 because 3! = 6 has no zeroes at the end, while f(11) = 2 because 11! = 39916800 has 2 zeroes at the end. Given K, find how many non-negative integers x have the property that f(x)... | class Solution:
def canTransform(self, start, end):
tmps = start.replace("X", "")
tmpe = end.replace("X", "")
if tmps != tmpe:
return False
sa, ta = [], []
i = 0
while i < len(start):
if start[i] == "L":
sa.append(i)
... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR STRING STRING IF VAR VAR RETURN NUMBER ASSIGN VAR VAR LIST LIST ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR IF V... |
Let f(x) be the number of zeroes at the end of x!. (Recall that x! = 1 * 2 * 3 * ... * x, and by convention, 0! = 1.)
For example, f(3) = 0 because 3! = 6 has no zeroes at the end, while f(11) = 2 because 11! = 39916800 has 2 zeroes at the end. Given K, find how many non-negative integers x have the property that f(x)... | class Solution:
def canTransform(self, start, end):
previous = {"L": "X", "X": "R"}
if len(start) != len(end):
return False
start = list(start)
for i in range(len(start)):
if start[i] == end[i]:
continue
elif end[i] == "R":
... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT STRING STRING STRING STRING IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR IF VAR VAR STRING RETURN NUMBER ASSIGN VAR VAR VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER RETURN NUMBER FOR VAR FUNC... |
Let f(x) be the number of zeroes at the end of x!. (Recall that x! = 1 * 2 * 3 * ... * x, and by convention, 0! = 1.)
For example, f(3) = 0 because 3! = 6 has no zeroes at the end, while f(11) = 2 because 11! = 39916800 has 2 zeroes at the end. Given K, find how many non-negative integers x have the property that f(x)... | class Solution:
def canTransform(self, start, end):
if start.replace("X", "") != end.replace("X", ""):
return False
t = 0
for i in range(len(start)):
if start[i] == "L":
while end[t] != "L":
t += 1
if i < t:
... | CLASS_DEF FUNC_DEF IF FUNC_CALL VAR STRING STRING FUNC_CALL VAR STRING STRING RETURN NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING WHILE VAR VAR STRING VAR NUMBER IF VAR VAR RETURN NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING WHILE VA... |
Let f(x) be the number of zeroes at the end of x!. (Recall that x! = 1 * 2 * 3 * ... * x, and by convention, 0! = 1.)
For example, f(3) = 0 because 3! = 6 has no zeroes at the end, while f(11) = 2 because 11! = 39916800 has 2 zeroes at the end. Given K, find how many non-negative integers x have the property that f(x)... | class Solution:
def canTransform(self, start, end):
start_helper = []
for i in range(len(start)):
if start[i] == "L" or start[i] == "R":
start_helper.append((start[i], i))
end_helper = []
for i in range(len(end)):
if end[i] == "L" or end[i] ==... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING EXPR FUNC_CALL VAR VAR VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN NUMBER FOR VAR ... |
Let f(x) be the number of zeroes at the end of x!. (Recall that x! = 1 * 2 * 3 * ... * x, and by convention, 0! = 1.)
For example, f(3) = 0 because 3! = 6 has no zeroes at the end, while f(11) = 2 because 11! = 39916800 has 2 zeroes at the end. Given K, find how many non-negative integers x have the property that f(x)... | class Solution:
def canTransform(self, start, end):
start_pair = [(i, c) for i, c in enumerate(start) if c != "X"]
end_pair = [(i, c) for i, c in enumerate(end) if c != "X"]
if len(start_pair) != len(end_pair):
return False
for (i_start, c_start), (i_end, c_end) in zip(s... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR STRING ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR STRING IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN NUMBER FOR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR STRING VAR VAR VAR STRING VAR VAR RETURN NUMBER RETURN NUMBER |
Let f(x) be the number of zeroes at the end of x!. (Recall that x! = 1 * 2 * 3 * ... * x, and by convention, 0! = 1.)
For example, f(3) = 0 because 3! = 6 has no zeroes at the end, while f(11) = 2 because 11! = 39916800 has 2 zeroes at the end. Given K, find how many non-negative integers x have the property that f(x)... | class Solution:
def canTransform(self, start, end):
for (i, x), (j, y) in itertools.zip_longest(
((i, x) for i, x in enumerate(start) if x != "X"),
((j, y) for j, y in enumerate(end) if y != "X"),
fillvalue=(None, None),
):
if x != y or x == "L" and i... | CLASS_DEF FUNC_DEF FOR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR STRING VAR VAR VAR VAR FUNC_CALL VAR VAR VAR STRING NONE NONE IF VAR VAR VAR STRING VAR VAR VAR STRING VAR VAR RETURN NUMBER RETURN NUMBER |
Let f(x) be the number of zeroes at the end of x!. (Recall that x! = 1 * 2 * 3 * ... * x, and by convention, 0! = 1.)
For example, f(3) = 0 because 3! = 6 has no zeroes at the end, while f(11) = 2 because 11! = 39916800 has 2 zeroes at the end. Given K, find how many non-negative integers x have the property that f(x)... | class Solution:
def canTransform(self, start, end):
if len(start) != len(end) or start.replace("X", "") != end.replace("X", ""):
return False
l, ll, r, rr = 0, 0, 0, 0
for i in range(len(start)):
if start[i] == "L":
l += 1
elif start[i] ==... | CLASS_DEF FUNC_DEF IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR STRING STRING FUNC_CALL VAR STRING STRING RETURN NUMBER ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR VAR STR... |
Let f(x) be the number of zeroes at the end of x!. (Recall that x! = 1 * 2 * 3 * ... * x, and by convention, 0! = 1.)
For example, f(3) = 0 because 3! = 6 has no zeroes at the end, while f(11) = 2 because 11! = 39916800 has 2 zeroes at the end. Given K, find how many non-negative integers x have the property that f(x)... | class Solution:
def findNextChar(self, string, i, char):
otherChar = "R" if char == "L" else "L"
for i in range(i, len(string)):
if string[i] == otherChar:
return None
if string[i] == char:
return i
return None
def canTransform(se... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR STRING STRING STRING FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR RETURN NONE IF VAR VAR VAR RETURN VAR RETURN NONE FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR NONE VAR VAR STRING VAR... |
Let f(x) be the number of zeroes at the end of x!. (Recall that x! = 1 * 2 * 3 * ... * x, and by convention, 0! = 1.)
For example, f(3) = 0 because 3! = 6 has no zeroes at the end, while f(11) = 2 because 11! = 39916800 has 2 zeroes at the end. Given K, find how many non-negative integers x have the property that f(x)... | class Solution:
def canTransform(self, start, end):
def countX(s, char="R"):
if char == "L":
s = s[::-1]
countX = 0
ans = []
for c in s:
if c == char:
ans.append(countX)
elif c == "X":
... | CLASS_DEF FUNC_DEF FUNC_DEF STRING IF VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR IF VAR STRING VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL STRING VAR VAR VAR VAR STRING ASSIGN VAR FUNC_CALL STRING VAR VAR VAR VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VA... |
Let f(x) be the number of zeroes at the end of x!. (Recall that x! = 1 * 2 * 3 * ... * x, and by convention, 0! = 1.)
For example, f(3) = 0 because 3! = 6 has no zeroes at the end, while f(11) = 2 because 11! = 39916800 has 2 zeroes at the end. Given K, find how many non-negative integers x have the property that f(x)... | class Solution:
def canTransform(self, start, end):
if len(start) != len(end):
return False
r, l = 0, 0
for i in range(len(start)):
if start[i] == "R":
r += 1
if end[i] == "R":
r -= 1
if start[i] == "L":
... | CLASS_DEF FUNC_DEF IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER... |
Everybody knows what an arithmetic progression is. Let us remind you just in case that an arithmetic progression is such sequence of numbers a_1, a_2, ..., a_{n} of length n, that the following condition fulfills: a_2 - a_1 = a_3 - a_2 = a_4 - a_3 = ... = a_{i} + 1 - a_{i} = ... = a_{n} - a_{n} - 1.
For example, seque... | n = int(input())
a = sorted(list(map(int, input().split())))
if n == 1:
print(-1)
exit()
if n == 2 and (a[1] - a[0]) % 2 == 0 and a[0] != a[1]:
print(3)
print(2 * a[0] - a[1], (a[0] + a[1]) // 2, 2 * a[1] - a[0])
exit()
m = [(a[i] - a[i - 1]) for i in range(1, n)]
if len(set(m)) == 1:
if m[0] !=... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN... |
Everybody knows what an arithmetic progression is. Let us remind you just in case that an arithmetic progression is such sequence of numbers a_1, a_2, ..., a_{n} of length n, that the following condition fulfills: a_2 - a_1 = a_3 - a_2 = a_4 - a_3 = ... = a_{i} + 1 - a_{i} = ... = a_{n} - a_{n} - 1.
For example, seque... | n = int(input())
a = list(map(int, input().split()))
a.sort()
if n == 1:
print(-1)
elif n == 2:
if a[1] == a[0]:
print(1)
print(a[0])
exit(0)
elif (a[1] - a[0]) % 2 == 0:
print(3)
d = a[1] - a[0]
print(a[0] - d, (a[1] + a[0]) // 2, a[1] + d)
exit(0)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER VAR NU... |
Everybody knows what an arithmetic progression is. Let us remind you just in case that an arithmetic progression is such sequence of numbers a_1, a_2, ..., a_{n} of length n, that the following condition fulfills: a_2 - a_1 = a_3 - a_2 = a_4 - a_3 = ... = a_{i} + 1 - a_{i} = ... = a_{n} - a_{n} - 1.
For example, seque... | n = int(input())
arr = [int(x) for x in input().split()]
arr.sort()
if n == 1:
print(-1)
elif n == 2:
d = abs(arr[1] - arr[0])
if d == 0:
print(1)
print(arr[0])
elif d & 1:
print(2)
print(arr[0] - d, arr[1] + d)
else:
print(3)
print(*sorted([arr[0] - d... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR NUMBER EXPR F... |
Everybody knows what an arithmetic progression is. Let us remind you just in case that an arithmetic progression is such sequence of numbers a_1, a_2, ..., a_{n} of length n, that the following condition fulfills: a_2 - a_1 = a_3 - a_2 = a_4 - a_3 = ... = a_{i} + 1 - a_{i} = ... = a_{n} - a_{n} - 1.
For example, seque... | import sys
n = int(input())
arr = list(map(int, input().split()))
if n == 1:
print(-1)
sys.exit()
arr.sort()
diff = []
req = []
flag2 = True
cnt = 0
for i in range(1, n):
diff.append(arr[i] - arr[i - 1])
d = list(set(diff))
cnt = len(d)
if cnt > 2:
print(0)
sys.exit()
if cnt == 1:
req.append(ar... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VA... |
Everybody knows what an arithmetic progression is. Let us remind you just in case that an arithmetic progression is such sequence of numbers a_1, a_2, ..., a_{n} of length n, that the following condition fulfills: a_2 - a_1 = a_3 - a_2 = a_4 - a_3 = ... = a_{i} + 1 - a_{i} = ... = a_{n} - a_{n} - 1.
For example, seque... | n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
if n == 1:
print(-1)
exit()
if n == 2:
if (l[1] - l[0]) % 2 == 0:
if l[1] - l[0] == 0:
print(1)
print(l[0])
exit()
print(3)
print(l[0] - (l[1] - l[0]), l[0] + (l[1] - l[0]) // 2, l[... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER NUMBER IF BIN_OP VAR NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR N... |
Everybody knows what an arithmetic progression is. Let us remind you just in case that an arithmetic progression is such sequence of numbers a_1, a_2, ..., a_{n} of length n, that the following condition fulfills: a_2 - a_1 = a_3 - a_2 = a_4 - a_3 = ... = a_{i} + 1 - a_{i} = ... = a_{n} - a_{n} - 1.
For example, seque... | from sys import stdin
input = stdin.readline
def ap(arr):
if len(arr) == 1:
return -1
dif = []
ans = []
arr = sorted(arr)
l = set()
for i in range(0, len(arr) - 1):
d = arr[i + 1] - arr[i]
dif.append(d)
l.add(d)
if len(l) > 2:
return 0
i... | ASSIGN VAR VAR FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL ... |
Everybody knows what an arithmetic progression is. Let us remind you just in case that an arithmetic progression is such sequence of numbers a_1, a_2, ..., a_{n} of length n, that the following condition fulfills: a_2 - a_1 = a_3 - a_2 = a_4 - a_3 = ... = a_{i} + 1 - a_{i} = ... = a_{n} - a_{n} - 1.
For example, seque... | n = int(input())
arr = [int(x) for x in input().split()]
cd = {}
arr.sort()
for i in range(1, n):
cdtemp = arr[i] - arr[i - 1]
if cdtemp not in cd:
cd[cdtemp] = 1
else:
cd[cdtemp] += 1
if len(cd) > 2:
print(0)
elif len(cd) == 1:
for key, val in cd.items():
if key == 0:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF FUN... |
Everybody knows what an arithmetic progression is. Let us remind you just in case that an arithmetic progression is such sequence of numbers a_1, a_2, ..., a_{n} of length n, that the following condition fulfills: a_2 - a_1 = a_3 - a_2 = a_4 - a_3 = ... = a_{i} + 1 - a_{i} = ... = a_{n} - a_{n} - 1.
For example, seque... | n = int(input())
if n == 1:
print(-1)
quit()
l = list(map(int, input().split()))
l.sort()
if n == 2:
d = l[1] - l[0]
if d == 0:
print(1)
print(l[0])
quit()
if d % 2 == 0:
print(3)
print(l[0] - d, l[0] + d // 2, l[1] + d)
else:
print(2)
prin... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CA... |
Everybody knows what an arithmetic progression is. Let us remind you just in case that an arithmetic progression is such sequence of numbers a_1, a_2, ..., a_{n} of length n, that the following condition fulfills: a_2 - a_1 = a_3 - a_2 = a_4 - a_3 = ... = a_{i} + 1 - a_{i} = ... = a_{n} - a_{n} - 1.
For example, seque... | n = int(input())
p = input().rstrip().split(" ")
p.sort(key=int)
if len(p) == 1:
print(-1)
elif len(set(p)) == 1:
print(1)
print(p[0])
elif len(p) == 2:
if int(p[0]) + 2 == int(p[1]):
print(3)
print(int(p[0]) - 2, int(p[0]) + 1, int(p[len(p) - 1]) + 2)
elif (int(p[0]) + int(p[1])) % ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER IF BIN_OP FUNC_CALL VAR VA... |
Everybody knows what an arithmetic progression is. Let us remind you just in case that an arithmetic progression is such sequence of numbers a_1, a_2, ..., a_{n} of length n, that the following condition fulfills: a_2 - a_1 = a_3 - a_2 = a_4 - a_3 = ... = a_{i} + 1 - a_{i} = ... = a_{n} - a_{n} - 1.
For example, seque... | n = int(input())
a = input().split()
for i in range(n):
a[i] = int(a[i])
a.sort()
if n == 1:
print(-1)
elif n == 2:
if a[0] == a[1]:
print(1)
print(a[0])
elif (a[1] - a[0]) % 2 == 0:
print(3)
print(a[0] - (a[1] - a[0]), (a[0] + a[1]) // 2, a[1] + (a[1] - a[0]))
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER V... |
Everybody knows what an arithmetic progression is. Let us remind you just in case that an arithmetic progression is such sequence of numbers a_1, a_2, ..., a_{n} of length n, that the following condition fulfills: a_2 - a_1 = a_3 - a_2 = a_4 - a_3 = ... = a_{i} + 1 - a_{i} = ... = a_{n} - a_{n} - 1.
For example, seque... | n = int(input())
a = list(map(int, input().split()))
if n == 1:
print(-1)
return
a.sort()
d = []
for i in range(1, n):
d.append(a[i] - a[i - 1])
if min(d) == max(d) == 0:
print(1)
print(a[0])
elif n == 2:
if d[0] % 2:
print(2)
print(a[0] - d[0], a[1] + d[0])
else:
pri... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMB... |
Everybody knows what an arithmetic progression is. Let us remind you just in case that an arithmetic progression is such sequence of numbers a_1, a_2, ..., a_{n} of length n, that the following condition fulfills: a_2 - a_1 = a_3 - a_2 = a_4 - a_3 = ... = a_{i} + 1 - a_{i} = ... = a_{n} - a_{n} - 1.
For example, seque... | import sys
input = sys.stdin.readline
for _ in range(1):
n = int(input())
arr = [int(x) for x in input().split()]
arr.sort()
if n == 1:
print(-1)
elif n == 2:
if arr[1] - arr[0] == 0:
print(1)
print(arr[0])
elif (arr[1] - arr[0]) % 2:
prin... | IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER IF BIN_OP VAR NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER IF BI... |
Everybody knows what an arithmetic progression is. Let us remind you just in case that an arithmetic progression is such sequence of numbers a_1, a_2, ..., a_{n} of length n, that the following condition fulfills: a_2 - a_1 = a_3 - a_2 = a_4 - a_3 = ... = a_{i} + 1 - a_{i} = ... = a_{n} - a_{n} - 1.
For example, seque... | def all_same(a):
return all([(x == a[0]) for x in a])
N = int(input())
array = sorted([int(x) for x in input().split()])
tobeprinted = []
setarray = set(array)
if N == 1:
print(-1)
exit()
elif all_same(array):
print(1)
print(array[0])
exit()
elif N == 2:
difference = array[1] - array[0]
... | FUNC_DEF RETURN FUNC_CALL VAR VAR VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR F... |
Everybody knows what an arithmetic progression is. Let us remind you just in case that an arithmetic progression is such sequence of numbers a_1, a_2, ..., a_{n} of length n, that the following condition fulfills: a_2 - a_1 = a_3 - a_2 = a_4 - a_3 = ... = a_{i} + 1 - a_{i} = ... = a_{n} - a_{n} - 1.
For example, seque... | n = int(input())
li = list(map(int, input().split()))
if n == 1:
print(-1)
elif n == 2:
li.sort()
d = li[1] - li[0]
if d == 0:
print(1)
print(li[0])
elif d % 2 == 0:
print(3)
print(li[0] - d, li[0] + d // 2, li[1] + d)
else:
print(2)
print(li[0] - ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXP... |
Everybody knows what an arithmetic progression is. Let us remind you just in case that an arithmetic progression is such sequence of numbers a_1, a_2, ..., a_{n} of length n, that the following condition fulfills: a_2 - a_1 = a_3 - a_2 = a_4 - a_3 = ... = a_{i} + 1 - a_{i} = ... = a_{n} - a_{n} - 1.
For example, seque... | n = int(input())
list_numbers = list(map(int, input().split()))
list_numbers.sort()
def ap(list_numbers, n):
done = False
if n == 1:
done = True
return print(-1)
if n == 2:
if (list_numbers[0] + list_numbers[1]) % 2 == 0:
x = int((list_numbers[0] + list_numbers[1]) / 2)... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER RETURN FUNC_CALL VAR NUMBER IF VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VA... |
Everybody knows what an arithmetic progression is. Let us remind you just in case that an arithmetic progression is such sequence of numbers a_1, a_2, ..., a_{n} of length n, that the following condition fulfills: a_2 - a_1 = a_3 - a_2 = a_4 - a_3 = ... = a_{i} + 1 - a_{i} = ... = a_{n} - a_{n} - 1.
For example, seque... | n = int(input())
a = list(map(int, input().split()))
if n == 1:
print(-1)
else:
a.sort()
d = []
for i in range(n - 1):
d.append(a[i + 1] - a[i])
k = list(set(d))
k.sort()
uni = {}
for elem in d:
if elem not in uni:
uni[elem] = 1
else:
uni[e... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ... |
Everybody knows what an arithmetic progression is. Let us remind you just in case that an arithmetic progression is such sequence of numbers a_1, a_2, ..., a_{n} of length n, that the following condition fulfills: a_2 - a_1 = a_3 - a_2 = a_4 - a_3 = ... = a_{i} + 1 - a_{i} = ... = a_{n} - a_{n} - 1.
For example, seque... | import sys
n = int(input())
a = sorted(list(map(int, input().split())))
if n == 1:
print(-1)
else:
d = a[1] - a[0]
x = 0
v = 0
t = -1
v1 = 0
t1 = -1
for i in range(1, n):
if a[i] - a[i - 1] == d:
x += 1
elif a[i] - a[i - 1] == 2 * d:
v += 1
... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR N... |
Everybody knows what an arithmetic progression is. Let us remind you just in case that an arithmetic progression is such sequence of numbers a_1, a_2, ..., a_{n} of length n, that the following condition fulfills: a_2 - a_1 = a_3 - a_2 = a_4 - a_3 = ... = a_{i} + 1 - a_{i} = ... = a_{n} - a_{n} - 1.
For example, seque... | n = int(input())
a = [int(i) for i in input().split()]
if n == 1:
print(-1)
exit()
a.sort()
if n == 2:
mid = (a[0] + a[1]) / 2
if a[0] == a[1]:
print(1)
print(a[0])
exit()
if mid == int(mid):
mid = int(mid)
cd = a[1] - a[0]
print(3)
print(a[0] ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR NUMB... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.