description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
for test in range(int(input())): n = int(input()) a = list(map(int, input().split())) cnt = [0] * (n + 10) ans = 0 for l in range(n): cur = 0 for r in range(l + 1, n): if a[l] == a[r]: ans += cur cur += cnt[a[r]] cnt[a[l]] += 1 prin...
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 BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
import sys input = sys.stdin.readline def process(): (N,) = map(int, input().split()) X = list(map(int, input().split())) dp = [([0] * (N + 1)) for _ in range(N + 1)] for i in range(1, N + 1): dp[i] = dp[i - 1][:] dp[i][X[i - 1]] = dp[i - 1][X[i - 1]] + 1 dp2 = [([0] * (N + 1)) fo...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN 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 BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER A...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
for _ in range(int(input())): n = int(input()) arr = [int(x) for x in input().split()] left = {} sum = 0 for i in range(n - 1): right = {} for j in range(n - 1, i, -1): if arr[i] in right and arr[j] in left: sum += right[arr[i]] * left[arr[j]] ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR VAR VAR VAR BI...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
def make_freq_dict(n, a): d = {} for i in range(n): if a[i] not in d: d[a[i]] = 1 else: d[a[i]] += 1 return d def make_occs_dict(n, a): d = {} for i in range(n): if a[i] not in d: d[a[i]] = [i] else: d[a[i]].append(i) ...
FUNC_DEF ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR NUMBER VAR VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR LIST VAR EXPR FUNC_CALL VAR VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR VAR NUMBER RET...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
t = int(input()) while t > 0: t -= 1 n = int(input()) a = [int(i) for i in input().split()] total = 0 a1 = [([0] * (n + 1)) for _ in range(n + 1)] a2 = [([0] * (n + 1)) for _ in range(n + 1)] a3 = [([0] * (n + 1)) for _ in range(n + 1)] for i in a: for j in range(n + 1): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUN...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) s = [(0) for _ in range(n + 1)] e = [(0) for _ in range(n + 1)] c = 0 for j in range(0, n - 2): e = [(0) for _ in range(n + 1)] for k in range(n - 1, j, -1): c += s[a[k]] * e[a[j]] ...
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 NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VA...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
for _ in range(int(input())): n = int(input()) l = list(map(lambda x: int(x) - 1, input().split())) c = [0] * n dp = [] for i in l: c[i] += 1 dp.append(c.copy()) ans = 0 for i in range(1, n - 2): for j in range(i + 1, n - 1): bcwd = dp[-1][l[i]] - dp[j][l[...
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 BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST FOR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR ...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) c = [([0] * n) for _ in range(n)] ans = 0 for j in range(1, n): for i in range(0, j): if c[a[i] - 1][a[j] - 1]: c[a[i] - 1][a[j] - 1] += 1 else: c[a[i] -...
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 BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR BIN_OP VAR VAR NU...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
def process(A): d = {} n = len(A) for i in range(n): x = A[i] if x not in d: d[x] = [] d[x].append(i) answer = 0 for x in d: v = len(d[x]) answer += v * (v - 1) * (v - 2) * (v - 3) // 24 for x in d: for y in d: if x != y: ...
FUNC_DEF ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR VAR ASSIGN VAR VAR LIST EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER FOR...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
for _ in [0] * int(input()): n = int(input()) arr = list(map(int, input().split())) c = 0 bOne = [0] * (n + 2) for j in range(1, n - 2, 1): bOne[arr[j - 1]] += 1 bSec = [0] * (n + 2) added = 0 for l in range(j + 2, n, 1): v = arr[l - 1] added -...
FOR VAR BIN_OP LIST NUMBER 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 NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
def solve(): n = int(input()) l = list(map(int, input().split())) left = [0] * 3002 ans = 0 for i in range(n): right = [0] * 3002 for j in range(n - 1, i, -1): ans += right[l[i]] * left[l[j]] right[l[j]] += 1 left[l[i]] += 1 print(ans) for _ in r...
FUNC_DEF 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 LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR BIN_OP VAR VAR VAR VAR VAR VAR V...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
dx = [0, 0, -1, 1] dy = [1, -1, 0, 0] def solve(n, ar): l_count = [0] * (n + 100) ans = 0 for i in range(n): r_count = [0] * (n + 100) for j in range(n - 1, i, -1): ans += l_count[ar[j]] * r_count[ar[i]] r_count[ar[j]] += 1 l_count[ar[i]] += 1 print(ans)...
ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR BIN_OP VAR VAR VAR VAR VAR V...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
import sys input = sys.stdin.readline def inp(): return int(input()) def inlt(): return list(map(int, input().split())) def insr(): s = input() return list(s[: len(s) - 1]) def invr(): return map(int, input().split()) def solve(arr, n): cntLeft = [(0) for i in range(n + 1)] cntRig...
IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR RETURN FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER VAR FU...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
t = int(input()) for _ in range(t): n = int(input()) a = [int(x) for x in input().split()] values = sorted(list(set(a))) k = len(values) idx = {values[i]: i for i in range(k)} arr1 = [([0] * k) for _ in range(k)] arr2 = [([0] * k) for _ in range(k)] arr3 = [([0] * k) for _ in range(k)] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBE...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
res = "" for _ in range(int(input())): n = int(input()) a = [int(x) for x in input().split()] c = {} r = 0 for i, row in enumerate(a): m = 0 for row2 in a[i + 1 :]: if row == row2: r += m m += c.get(row2, 0) c[row] = c.get(row, 0) + 1 ...
ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR VAR FUNC_CALL VAR VAR NUM...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
t = int(input()) while t: t -= 1 n = int(input()) arr = list(map(int, input().split())) left = [0] * (n + 1) right = [0] * (n + 1) ans = 0 for j in range(n): for i in range(n + 1): right[i] = 0 for k in range(n - 1, j, -1): ans += left[arr[k]] * right[...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR 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 LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_C...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
import sys input = sys.stdin.readline t = int(input()) for ii in range(t): n = int(input()) A = list(map(int, input().split())) ans = 0 l = max(A) + 1 B = [0] * l for i in A: B[i] += 1 F = [([0] * l) for i in range(l)] G = [0] * l for i in range(n): B[A[i]] -= 1 ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR 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 NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR VAR VAR VAR NUMBER ASSIG...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) ans = 0 left = {} right = {} for i in range(n): right = {} for j in range(0, n): right[a[j]] = 0 for j in range(n - 1, i, -1): if a[j] in left: ans +...
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 NUMBER ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
def singleElementCounts(x, l, r): if l < 0: l = 0 if r >= n: r = n - 1 if l == 0: return singleElementOccurrenceCnt[x][r] else: return singleElementOccurrenceCnt[x][r] - singleElementOccurrenceCnt[x][l - 1] t = int(input()) for _ in range(t): n = int(input()) a ...
FUNC_DEF IF VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER RETURN VAR VAR VAR RETURN BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CA...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
for _ in range(int(input())): n = int(input()) arr = list(map(int, input().split())) freq = {} answer = 0 for x in arr: if x not in freq: freq[x] = 0 freq[x] += 1 for i in range(n): freq[arr[i]] -= 1 equal_pairs = 0 so_far = {} for j in...
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 DICT ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN ...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
import sys input = sys.stdin.readline def before(j, a): if arr[j] == a: return prefix[j][a] - 1 else: return prefix[j][a] def after(k, b): return prefix[n - 1][b] - prefix[k][b] t = int(input()) for _ in range(t): n = int(input()) arr = list(map(int, input().split())) pref...
IMPORT ASSIGN VAR VAR FUNC_DEF IF VAR VAR VAR RETURN BIN_OP VAR VAR VAR NUMBER RETURN VAR VAR VAR FUNC_DEF RETURN BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split())) d = [([0] * n) for _ in range(n)] for i in range(n): for j in range(i + 1, n): if a[i] == a[j]: d[i][j] = 1 for i in range(n): for j in range(n - 1): d[i][...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR 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 BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR VAR VAR ASSI...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
import sys input = lambda: sys.stdin.readline().rstrip() t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split())) accu = [([0] * (n + 1)) for _ in range(n + 1)] for i in range(1, n + 1): for j in range(1, n + 1): accu[i][j] = accu[i][j - 1] + (a[j - 1...
IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR 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 BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR N...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
def main(): for _ in range(Iint()): n = Iint() array = Ilist() cntLeft = [0] * (n + 1) ans = 0 for i, Ival in enumerate(array): cntRight = [0] * (n + 1) for j in range(n - 1, i, -1): ans += cntLeft[array[j]] * cntRight[array[i]] ...
FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR BIN_OP VAR VAR VAR VAR VAR...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split())) total = 0 overall = [0] * (n + 1) for x in a: overall[x] += 1 start = [0] * (n + 1) for i in range(n): start[a[i]] += 1 mid = [0] * (n + 1) mid_count = 0 for j in ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR 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 NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR ...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
def compress(arr): arr2 = sorted(arr) order = dict() length = len(arr) for i in range(length): order[arr2[i]] = i arr3 = [0] * length for i in range(length): arr3[i] = order[arr[i]] return arr3 t = int(input()) for case in range(t): n = int(input()) arr = list(map(i...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
def fun(): n = int(input()) a = list(map(int, input().split(" "))) prefix = [[(0) for i in range(n + 1)] for j in range(n + 1)] ans22 = 0 for i in range(n): for j in range(1, n + 1): prefix[i + 1][j] += prefix[i][j] prefix[i + 1][a[i]] += 1 for i in range(n): ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR BIN_OP VAR NU...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
for t in range(int(input())): n = int(input()) a = list(map(int, input().split())) b = [[(0) for i in range(n + 1)] for j in range(n)] c = [[(0) for i in range(n + 1)] for j in range(n)] for i in range(n - 1): b[i][a[i]] += 1 b[i + 1] = b[i][:] i = n - 1 while i > 0: ...
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 NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
for _ in range(int(input())): n = int(input()) arr = [int(i) for i in input().split()] col = [0] * (n + 1) ans = 0 col[arr[0]] += 1 for j in range(1, n - 2): c = col[arr[j + 1]] val = arr[j] for l in range(j + 2, n): if arr[l] == val: ans += c ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 VAR NUMBER ASSIGN VAR NUMBER VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER AS...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
def bins(l, n): low = -1 high = len(l) while low + 1 < high: avg = (low + high) // 2 if l[avg] < n: low = avg else: high = avg return [low, high] for t in range(int(input())): n = int(input()) l = list(map(int, input().split())) inds = {} ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR RETURN LIST VAR VAR 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...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
t = int(input()) for _ in range(t): n = int(input()) arr = list(map(int, input().split())) ans = 0 cntL = [0] * (n + 1) cntR = [0] * (n + 1) for j in range(1, n - 2): cntR = [0] * (n + 1) cntL[arr[j - 1]] += 1 for k in range(n - 2, j, -1): cntR[arr[k + 1]] += ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR 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 NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
t = int(input()) while t > 0: t -= 1 n = int(input()) lst = list(map(int, input().split())) M = [([0] * (n + 1)) for x in range(0, n + 1)] for i in range(0, n): for j in range(i + 1, n): M[lst[i]][lst[j]] += 1 ans = 0 for i in range(0, n): for j in range(i + 1, n)...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER 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 LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR B...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
import sys def minp(): return sys.stdin.readline().strip() def mint(): return int(minp()) def mints(): return map(int, minp().split()) def check(s, n, v): for i in range(n): if s[i : i + n].count(v) == 0: return False return True def solve(): n = mint() a = list...
IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR BIN_OP VAR VAR VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FU...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
import sys input = sys.stdin.readline def inp(): return int(input()) def inlt(): return list(map(int, input().split())) def insr(): s = input() return list(s[: len(s) - 1]) def invr(): return map(int, input().split()) def solve(arr, n): cntLeft = dict() cntRight = dict() res =...
IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR RETURN FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
import sys input = sys.stdin.buffer.readline def main(): t = int(input()) for _ in range(t): n = int(input()) A = list(map(int, input().split())) A = [(a - 1) for a in A] X = [([0] * n) for i in range(n)] for l in range(n - 1): for r in range(l + 1, n): ...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR 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 BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
for _ in range(int(input())): n = int(input()) s = list(map(int, input().split())) cnt = [0] * (n + 1) ans = out = 0 for i in range(0, n - 1): cnt_tmp = [0] * (n + 1) ans = 0 for j in range(i + 1, n): temp = ans ans -= cnt_tmp[s[j]] * cnt[s[j]] ...
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 BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
def bin(place, a): l = -1 r = len(place) while l < r - 1: m = (l + r) // 2 if place[m] >= a: r = m else: l = m return l def bin2(place, a): l = -1 r = len(place) while l < r - 1: m = (l + r) // 2 if place[m] > a: r...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR A...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
t = int(input()) for ii in range(t): n = int(input()) a = list(map(int, input().split())) total = {} for i in a: if i not in total: total[i] = 1 else: total[i] += 1 before = [] for i in range(n): before.append([0] * n) for i in range(n): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR 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 DICT FOR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP LIST ...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, ("0 " + input()).split())) c = [[(0) for _ in range(n + 1)] for _ in range(n + 1)] for i in range(1, n + 1): for j in range(1, n + 1): if j == a[i]: c[i][j] = c[i - 1][j] + 1 else: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL BIN_OP STRING FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBE...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
from sys import stdin input = stdin.buffer.readline for _ in range(int(input())): n = int(input()) (*a,) = map(int, input().split()) pref = [[(0) for j in range(n + 1)] for i in range(n)] ans = 0 for i in range(n): pref[i][a[i]] += 1 for i in range(1, n): for j in range(n + 1): ...
ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VA...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
for _ in range(int(input())): n = int(input()) arr = list(map(int, input().split())) left = [(0) for i in range(n + 1)] right = [(0) for i in range(n + 1)] state = [(0) for i in range(n)] k = n - 1 while k >= 0: state[k] = right[:] right[arr[k]] += 1 k -= 1 ans = ...
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 NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_O...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split())) cl = [0] * (n + 1) cr = [0] * (n + 1) for i in a: cr[i] += 1 ans = 0 for i in range(n - 3): cl[a[i]] += 1 now = a[i] nr = [(cr[j] - cl[j]) for j in range(n + 1)] c...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR 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 BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR ...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
import sys input = sys.stdin.readline for _ in range(int(input())): n = int(input()) ar = list(map(int, input().split())) dic = {} for i in range(1, n + 1): dic[i] = 0 ans = 0 for i in range(n): dic1 = {} for j in range(n - 1, i, -1): ans += dic[ar[j]] * dic1...
IMPORT ASSIGN VAR VAR 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 DICT FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR DI...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
for _ in range(int(input())): n = int(input()) arr = [int(x) for x in input().split()] count = 0 left = dict() for i in range(n): right = dict() for j in range(n - 1, i, -1): try: count += left[arr[j]] * right[arr[i]] except: pa...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR BIN_OP VAR VAR VAR VAR VA...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
for _ in range(int(input())): n = int(input()) a = [*map(int, input().split())] ans = 0 for i in range(n): f, s = [0] * (n + 1), [0] * (n + 1) pa = 0 for j in range(i + 2, n): s[a[j]] += 1 for j in range(i + 2, n): pa -= s[a[j]] * f[a[j]] ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR ...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
t = int(input()) a = [] id = [] for _ in range(t): n = int(input()) A = map(int, input().split()) a = [] for x in A: a.append(x) cnt = [[(0) for i in range(n + 1)] for j in range(n + 1)] ans = 0 for j in range(n): for i in range(j): cnt[a[i]][a[j]] += 1 k ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP V...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
import sys def input(): return sys.stdin.readline()[:-1] def solve(): N = int(input()) A = list(map(int, input().split())) B = [None for i in range(N + 1)] b = [0] * 3001 B[0] = list(b) for i in range(N): b[A[i]] += 1 B[i + 1] = list(b) ans = 0 for i in range(N - ...
IMPORT FUNC_DEF RETURN FUNC_CALL VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NONE VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VA...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
for _ in range(int(input())): n = int(input()) arr = [*map(int, input().split())] max_ele = max(arr) + 1 counter = [([0] * max_ele) for _ in range(n)] counter[0][arr[0]] += 1 for i in range(1, n): for j in range(n): counter[i][arr[j]] = counter[i - 1][arr[j]] counter[...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
from sys import stdin input = stdin.readline def nc2(n): return n * (n - 1) // 2 def nc4(n): return n * (n - 1) * (n - 2) * (n - 3) // 24 def answer(): count = [[(0) for i in range(n + 1)] for i in range(n + 1)] for i in range(1, n + 1): for j in range(n + 1): count[i][j] = co...
ASSIGN VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VA...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
t = int(input()) while t: t -= 1 n = int(input()) l = list(map(int, input().split())) count = [0] * n ans = 0 for i, a in enumerate(l): cur = 0 for j in l[i + 1 :]: if j == a: ans += cur cur += count[j - 1] count[a - 1] += 1 pri...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR 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 LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR VAR V...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
def Zigzag(Numbers, n): Ocurrences = dict() Ocurrences[Numbers[0]] = 1 ZigzagsCounter = 0 for j in range(1, n - 2): InternalCounter = 0 for l in range(j + 1, n): if Numbers[j] == Numbers[l]: ZigzagsCounter += InternalCounter InternalCounter += Ocur...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER RETURN V...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
t = int(input()) for j in range(t): n = int(input()) m = list(map(int, input().split())) x = [(0) for k in range(n + 1)] xy = [[(0) for k in range(n + 1)] for t in range(n + 1)] xyx = [[(0) for k in range(n + 1)] for t in range(n + 1)] xyxy = [[(0) for k in range(n + 1)] for t in range(n + 1)] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR 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 NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIG...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
from sys import stdin, stdout def zigzags(n, a_a): ans = 0 freq = [(0) for _ in range((n + 1) * (n + 1))] for j in range(n - 3, 0, -1): k = j + 1 for l in range(k + 1, n): freq[a_a[k] * n + a_a[l]] += 1 for i in range(j): ans += freq[a_a[i] * n + a_a[j]] ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP B...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
for _ in range(int(input())): n = int(input()) s = list(map(int, input().split())) count = [([0] * (n + 1)) for _ in range(n + 1)] ans = 0 for i in range(n): for j in range(i): count[s[j]][s[i]] += 1 for j in range(i + 2, n): ans += count[s[i + 1]][s[j]] p...
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 BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VA...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
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.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LI1(): return list(map(int...
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_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
import sys input = sys.stdin.readline for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) a = list(map(lambda x: x - 1, a)) acc = [[0] for _ in range(n)] for i in range(n): for j in range(n): acc[j].append(acc[j][-1] + (1 if a[i] == j else 0)) ...
IMPORT ASSIGN VAR VAR 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 BIN_OP VAR NUMBER VAR ASSIGN VAR LIST NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FU...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
import sys input = sys.stdin.readline def f(n): return n * (n - 1) * (n - 2) * (n - 3) // 4 // 3 // 2 for kek in range(int(input())): n = int(input()) a = list(map(int, input().split())) ans = 0 total = dict() left = dict() for i in a: if i in total: total[i] += 1 ...
IMPORT ASSIGN VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER NUMBER NUMBER 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 ASSIG...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
import sys input = sys.stdin.readline t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split())) pre = [([0] * (max(a) + 1)) for i in range(n + 1)] for i in range(n): pre[i + 1][a[i]] += 1 for i in range(n): for j in range(max(a) + 1): pre[i...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR 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 BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
import sys input = sys.stdin.readline def solve(): n = int(input()) a = list(map(int, input().split())) ans = 0 cntL = [0] * (n + 1) cntL[a[0]] += 1 for j in range(1, n - 2): cntR = [0] * (n + 1) cntR[a[-1]] += 1 for k in range(n - 2, j, -1): ans += cntL[a[...
IMPORT ASSIGN VAR VAR FUNC_DEF 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 VAR NUMBER VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
t = int(input()) for i in range(t): n = int(input()) arr = list(map(int, input().split())) matrix = [[] for j in range(n)] for j in range(n): for k in range(j + 2, n): if arr[j] == arr[k]: matrix[j].append(k) matrix1 = [([0] * n) for j in range(n)] matrix2 = [...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR 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 LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
import sys input = sys.stdin.readline t = int(input()) for tests in range(t): n = int(input()) A = list(map(int, input().split())) DP1 = [0] * (n + 1) DP2 = [([0] * (n + 1)) for i in range(n + 1)] DP3 = [([0] * (n + 1)) for i in range(n + 1)] DP4 = [([0] * (n + 1)) for i in range(n + 1)] fo...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR 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 BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NU...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
import sys input = sys.stdin.buffer.readline def print(val): sys.stdout.write(str(val) + "\n") def prog(): for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) prefix = [0] * (n + 1) tuples = 0 for i in range(1, n - 2): prefi...
IMPORT ASSIGN VAR VAR FUNC_DEF EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR STRING FUNC_DEF 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 BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) base = n + 1 d = {} cnt = 0 for i in range(n - 2, 0, -1): for j in range(i): cnt += d.get(a[j] + a[i] * base, 0) for k in range(i + 1, n): x = a[i] + a[k] * base ...
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 BIN_OP VAR NUMBER ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
from sys import stdin def inp(): return stdin.buffer.readline().rstrip().decode("utf8") def itg(): return int(stdin.buffer.readline()) def mpint(): return map(int, stdin.buffer.readline().split()) for __ in range(itg()): n = itg() arr = tuple(mpint()) ans = 0 cnt1 = [0] * 3007 fo...
FUNC_DEF RETURN FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VA...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
from sys import stdin input = stdin.readline q = int(input()) def po2(x): return x * (x - 1) // 2 for _ in range(q): n = int(input()) l = list(map(int, input().split())) for i in range(n): l[i] -= 1 pref = [([0] * (n + 1)) for i in range(n)] for i in range(1, n + 1): for j i...
ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
def HalfDead(): n = int(input()) a = list(map(int, input().split())) dp1 = [([0] * (n + 1)) for _ in range(n + 1)] dp2 = [([0] * (n + 1)) for _ in range(n + 1)] dp3 = [([0] * (n + 1)) for _ in range(n + 1)] res = 0 for v in a: for w in range(n + 1): res += dp3[w][v] ...
FUNC_DEF 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 LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP ...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
import sys input = sys.stdin.readline t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split())) ans = 0 ptn = [([0] * n) for _ in range(n)] cnt = [0] * n for i, r_val in enumerate(a): r_val -= 1 for l_val in range(n): ptn[l_val][r_val] ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR 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 NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR VAR FUNC_CA...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
from itertools import accumulate as acm from itertools import compress as cp from sys import stdin def inp(): return stdin.buffer.readline().rstrip().decode("utf8") def itg(): return int(stdin.buffer.readline()) def mpint(): return map(int, stdin.buffer.readline().split()) for __ in range(itg()): ...
FUNC_DEF RETURN FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VA...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
def solve(): n = int(input()) v = [0] * (n + 2) a = list(map(int, input().split())) ans = 0 for i in range(n): cur = 0 for j in range(i + 1, n): if a[i] == a[j]: ans += cur cur += v[a[j]] v[a[i]] += 1 print(ans) T = int(input()) w...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
import sys input = sys.stdin.buffer.readline T = int(input()) for testcase in range(T): n = int(input()) a = list(map(int, input().split())) res = 0 dg = 10000 for i in range(n - 3): c = [0] * (n + 1) s = 0 c[a[i + 1]] += 1 for j in range(i + 3, n): c[a[j...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR 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 NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASS...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
t = int(input()) for case in range(t): n = int(input()) a = list(map(int, input().split())) occurrences = {} contributions = {} tot = 0 for i in range(n): if a[i] in contributions: tot += contributions[a[i]] if a[i] in occurrences: occurrences[a[i]].append...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR 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 DICT ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) seen_left = {} ans = 0 for i in range(n - 1): seen_right = {} for j in reversed(range(i + 1, n)): if a[j] in seen_left and a[i] in seen_right: ans += seen_left[a[j]] * seen_...
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 DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR VAR V...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
from itertools import accumulate as acm from itertools import compress as cp for __ in range(int(input())): n = int(input()) arr = tuple(map(int, input().split())) ans = 0 count = [0] * 3001 for i in range(n): ans += sum( cp( acm(map(count.__getitem__, arr[i + 1 ...
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 NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMB...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
def calcCntAtPrefix(a): cntAtPrefix = [[0] * (len(a) + 1)] for i, x in enumerate(a): cntAtPrefix.append(cntAtPrefix[-1][:]) cntAtPrefix[-1][x] += 1 return cntAtPrefix def solve(): n = int(input()) a = list(map(int, input().split())) cntAtPrefix = calcCntAtPrefix(a) cntAtSuf...
FUNC_DEF ASSIGN VAR LIST BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF 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 ...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
import sys input = sys.stdin.readline t = int(input()) for _ in range(t): n = int(input()) a = [(int(item) - 1) for item in input().split()] cnt = [([0] * n) for _ in range(n + 1)] for i, item in enumerate(a): for val in range(n): cnt[i + 1][val] = cnt[i][val] cnt[i + 1][ite...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR V...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
import sys t = int(input()) for _ in range(t): n = int(input()) a = [int(x) for x in input().split(" ")] b = {val: i for i, val in enumerate(sorted(set(a)))} a = [b[x] for x in a] cntLeft = {i: (0) for i in range(n)} cntRight = {i: (0) for i in range(n)} ans = 0 for j in range(n): ...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR VAR NUMBER VAR FUNC_CALL VAR VAR A...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
import sys input = sys.stdin.readline def solution(): n = int(input()) a = list(map(int, input().split())) ans = 0 cnt_L = [0] * (n + 1) for j in range(1, n - 2): cnt_L[a[j - 1]] += 1 current_sum = 0 cnt_R = [0] * (n + 1) for l in range(j + 2, n): curre...
IMPORT ASSIGN VAR VAR FUNC_DEF 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 VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP L...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
gans = [] for _ in range(int(input())): n = int(input()) s = list(map(lambda x: int(x) - 1, input().split())) u = [] cnt = [] k = 1 for i in range(1, n): if s[i] == s[i - 1]: k += 1 else: u.append(s[i - 1]) cnt.append(k) k = 1 u...
ASSIGN VAR LIST 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 BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR ...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
t = int(input()) while t: t = t - 1 n = int(input()) a = list(map(int, input().split())) ans = 0 l = [0] * 3007 for i in range(n): r = [0] * 3007 for j in range(n - 1, i, -1): ans = ans + l[a[j]] * r[a[i]] r[a[j]] = r[a[j]] + 1 l[a[i]] = l[a[i]] + ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR BIN_OP 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 NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL ...
You are given an array $a_1, a_2 \dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \le i < j < k < l \le n$; $a_i = a_k$ and $a_j = a_l$; -----Input----- The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The first line of each test case contains a...
def getcnt(x, l, r): if r < l: return 0 if l == 0: return p[x][r] else: return p[x][r] - p[x][l - 1] t = int(input()) for _ in range(t): n = int(input()) a = [int(x) for x in input().split()] p = [[(0) for _a in range(n)] for _b in range(n + 1)] for x in range(1, n ...
FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR NUMBER RETURN VAR VAR VAR RETURN BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ...
Gildong has bought a famous painting software cfpaint. The working screen of cfpaint is square-shaped consisting of $n$ rows and $n$ columns of square cells. The rows are numbered from $1$ to $n$, from top to bottom, and the columns are numbered from $1$ to $n$, from left to right. The position of a cell at row $r$ and...
n, k = list(map(int, input().split())) mat = [] for i in range(n): mat.append(list(input())) prefr = [[(0) for i in range(n)] for j in range(n)] prefc = [[(0) for i in range(n)] for j in range(n)] done = 0 for i in range(n): for j in range(n): if j == 0 and mat[i][j] == "B": prefr[i][j] = 1 ...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL ...
Gildong has bought a famous painting software cfpaint. The working screen of cfpaint is square-shaped consisting of $n$ rows and $n$ columns of square cells. The rows are numbered from $1$ to $n$, from top to bottom, and the columns are numbered from $1$ to $n$, from left to right. The position of a cell at row $r$ and...
def main(): n, k = list(map(int, input().split())) ss = [] tate = [[(0) for _ in range(n + 1)] for _ in range(n + 1)] yoko = [[(0) for _ in range(n + 1)] for _ in range(n + 1)] for i in range(n): s = input().strip() for j, _s in enumerate(s): tate[i + 1][j + 1] = tate[i][...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CA...
Gildong has bought a famous painting software cfpaint. The working screen of cfpaint is square-shaped consisting of $n$ rows and $n$ columns of square cells. The rows are numbered from $1$ to $n$, from top to bottom, and the columns are numbered from $1$ to $n$, from left to right. The position of a cell at row $r$ and...
ac = [[(0) for i in range(2010)] for j in range(2010)] n, k = map(int, input().split()) v = [] for i in range(n): v.append(input()) extra = 0 for i in range(n): L = n R = -1 for j in range(n): if v[i][j] == "B": L = min(L, j) R = max(R, j) if L > R: extra += 1...
ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ST...
Gildong has bought a famous painting software cfpaint. The working screen of cfpaint is square-shaped consisting of $n$ rows and $n$ columns of square cells. The rows are numbered from $1$ to $n$, from top to bottom, and the columns are numbered from $1$ to $n$, from left to right. The position of a cell at row $r$ and...
n, k = [int(i) for i in input().split()] sz = n - k + 1 cnt = [] for i in range(sz): cnt.append([0] * sz) data = [] extra = 0 for i in range(n): data.append(input()) for r in range(n): row = data[r] li = row.find("B") if li == -1: extra += 1 continue ri = row.rfind("B") for i...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR V...
Gildong has bought a famous painting software cfpaint. The working screen of cfpaint is square-shaped consisting of $n$ rows and $n$ columns of square cells. The rows are numbered from $1$ to $n$, from top to bottom, and the columns are numbered from $1$ to $n$, from left to right. The position of a cell at row $r$ and...
n, k = map(int, input().split()) s = [input() for _ in range(n)] g_row = [[] for _ in range(n)] g_col = [[] for _ in range(n)] already_white_line_nums = 0 for i in range(n): for j in range(n): if s[i][j] == "B": g_row[i].append(j) g_col[j].append(i) for i in range(n): if not g_ro...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR STRING EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VA...
Gildong has bought a famous painting software cfpaint. The working screen of cfpaint is square-shaped consisting of $n$ rows and $n$ columns of square cells. The rows are numbered from $1$ to $n$, from top to bottom, and the columns are numbered from $1$ to $n$, from left to right. The position of a cell at row $r$ and...
from sys import setrecursionlimit as SRL from sys import stdin SRL(10**7) rd = stdin.readline rrd = lambda: list(map(int, rd().strip().split())) n, k = rrd() s = [] cal = [([0] * (n + 10)) for _i in range(n + 10)] for i in range(n): s.append(str(rd())) ans = 0 for i in range(n): j = 0 while j < n and s[i][...
EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR ...
Gildong has bought a famous painting software cfpaint. The working screen of cfpaint is square-shaped consisting of $n$ rows and $n$ columns of square cells. The rows are numbered from $1$ to $n$, from top to bottom, and the columns are numbered from $1$ to $n$, from left to right. The position of a cell at row $r$ and...
n, k = map(int, input().split()) a = [input() for _ in range(n)] m = n - k + 1 def solve(a): p = [(r.find("B"), r.rfind("B")) for r in a] get = lambda i, j: j <= p[i][0] and p[i][1] <= j + k - 1 res = [([0] * m) for i in range(m)] for j in range(m): res[0][j] = cnt = sum(x == -1 for x, _ in p)...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING VAR VAR ASSIGN VAR VAR VAR VAR NUMBER VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VA...
Gildong has bought a famous painting software cfpaint. The working screen of cfpaint is square-shaped consisting of $n$ rows and $n$ columns of square cells. The rows are numbered from $1$ to $n$, from top to bottom, and the columns are numbered from $1$ to $n$, from left to right. The position of a cell at row $r$ and...
[n, k] = [int(x) for x in input().split()] c_p1 = [([-1] * 2010) for x in range(2010)] c_p2 = [([-1] * 2010) for x in range(2010)] r_p1 = [([-1] * 2010) for x in range(2010)] r_p2 = [([-1] * 2010) for x in range(2010)] cells = [] for i in range(n): cells.append(input()) bonus = 0 for y in range(n): earliest = -...
ASSIGN LIST VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN...
Gildong has bought a famous painting software cfpaint. The working screen of cfpaint is square-shaped consisting of $n$ rows and $n$ columns of square cells. The rows are numbered from $1$ to $n$, from top to bottom, and the columns are numbered from $1$ to $n$, from left to right. The position of a cell at row $r$ and...
import sys from sys import stdin n, k = map(int, stdin.readline().split()) S = [stdin.readline()[:-1] for i in range(n)] orians = 0 lis = [([0] * (n + 1)) for i in range(n + 1)] for i in range(n): minj = float("inf") maxj = float("-inf") for j in range(n): if S[i][j] == "B": minj = min(...
IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FU...
Gildong has bought a famous painting software cfpaint. The working screen of cfpaint is square-shaped consisting of $n$ rows and $n$ columns of square cells. The rows are numbered from $1$ to $n$, from top to bottom, and the columns are numbered from $1$ to $n$, from left to right. The position of a cell at row $r$ and...
n, k = map(int, input().split()) s = [] for i in range(n): s += [input()] y = [[n, 0] for i in range(n)] z = [[n, 0] for i in range(n)] r = 0 for i in range(n): ind1 = n ind2 = -1 for j in range(n): if s[i][j] == "B": ind1 = min(j, ind1) ind2 = max(j, ind2) if ind1 !=...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR VAR LIST FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR V...
Gildong has bought a famous painting software cfpaint. The working screen of cfpaint is square-shaped consisting of $n$ rows and $n$ columns of square cells. The rows are numbered from $1$ to $n$, from top to bottom, and the columns are numbered from $1$ to $n$, from left to right. The position of a cell at row $r$ and...
import sys input = sys.stdin.readline n, k = map(int, input().split()) MAP = [input().strip() for i in range(n)] MINR = [1 << 30] * n MAXR = [-1] * n MINC = [1 << 30] * n MAXC = [-1] * n for i in range(n): for j in range(n): if MAP[i][j] == "B": MINR[i] = min(MINR[i], j) MAXR[i] = m...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST BIN_OP NUMBER NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST BIN_OP NUMBER NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VA...
Gildong has bought a famous painting software cfpaint. The working screen of cfpaint is square-shaped consisting of $n$ rows and $n$ columns of square cells. The rows are numbered from $1$ to $n$, from top to bottom, and the columns are numbered from $1$ to $n$, from left to right. The position of a cell at row $r$ and...
import sys input = lambda: sys.stdin.readline().strip() n, k = map(int, input().split()) arr = [] for i in range(n): arr.append(list(input())) extra = 0 res = [] for i in range(n - k + 1): res.append([]) for j in range(n - k + 1): res[-1].append(0) l = {} r = {} for i in range(n): for j in rang...
IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR LIST FOR VAR FUNC_CALL VAR B...
Gildong has bought a famous painting software cfpaint. The working screen of cfpaint is square-shaped consisting of $n$ rows and $n$ columns of square cells. The rows are numbered from $1$ to $n$, from top to bottom, and the columns are numbered from $1$ to $n$, from left to right. The position of a cell at row $r$ and...
import sys def count(n, k, field): blank = 0 cnt = [([0] * (n - k + 1)) for _ in range(n)] for i, row in enumerate(field): l = row.find("B") r = row.rfind("B") if l == r == -1: blank += 1 continue if r - l + 1 > k: continue kl = m...
IMPORT FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR VAR NUMBER VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP ...
Gildong has bought a famous painting software cfpaint. The working screen of cfpaint is square-shaped consisting of $n$ rows and $n$ columns of square cells. The rows are numbered from $1$ to $n$, from top to bottom, and the columns are numbered from $1$ to $n$, from left to right. The position of a cell at row $r$ and...
n, k = list(map(int, input().split())) it = [([0] * n) for i in range(n)] t = [[-1, -1] for i in range(n)] tt = [[-1, -1] for i in range(n)] for i in range(n): s = input() c = -1 cc = -1 for j, ii in enumerate(s): if ii == "B": it[i][j] = 1 if c == -1: c =...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FO...
Gildong has bought a famous painting software cfpaint. The working screen of cfpaint is square-shaped consisting of $n$ rows and $n$ columns of square cells. The rows are numbered from $1$ to $n$, from top to bottom, and the columns are numbered from $1$ to $n$, from left to right. The position of a cell at row $r$ and...
n, k = map(int, input().split()) board = [input() for _ in range(n)] columns = [([0] * n) for _ in range(n)] rows = [([0] * n) for _ in range(n)] whites = 0 for i in range(n): first = -1 last = 0 flag = False for pos in range(n): if flag == False: if board[i][pos] == "B": ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VA...
Let's call any (contiguous) subarray B (of A) a mountain if the following properties hold: B.length >= 3 There exists some 0 < i < B.length - 1 such that B[0] < B[1] < ... B[i-1] < B[i] > B[i+1] > ... > B[B.length - 1] (Note that B could be any subarray of A, including the entire array A.) Given an array A of integer...
class Solution: def longestMountain(self, A: List[int]) -> int: res = cur = 1 desc = False for i in range(1, len(A)): if A[i - 1] == A[i]: if desc: res = max(res, cur) desc = False cur = 1 elif A[i -...
CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER VAR VAR IF VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR IF VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NU...
Let's call any (contiguous) subarray B (of A) a mountain if the following properties hold: B.length >= 3 There exists some 0 < i < B.length - 1 such that B[0] < B[1] < ... B[i-1] < B[i] > B[i+1] > ... > B[B.length - 1] (Note that B could be any subarray of A, including the entire array A.) Given an array A of integer...
class Solution: def longestMountain(self, A: List[int]) -> int: long_mont = 0 i, j = 0, 0 while j < len(A): incr = False while j != len(A) - 1 and A[j] < A[j + 1]: incr = True j += 1 if not incr: j += 1 ...
CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VA...
Let's call any (contiguous) subarray B (of A) a mountain if the following properties hold: B.length >= 3 There exists some 0 < i < B.length - 1 such that B[0] < B[1] < ... B[i-1] < B[i] > B[i+1] > ... > B[B.length - 1] (Note that B could be any subarray of A, including the entire array A.) Given an array A of integer...
class Solution: def longestMountain(self, A: List[int]) -> int: i = 0 answer = 0 while i < len(A) - 1: j = i + 1 visited_top = False while j < len(A): print(i, j) if A[j] > A[j - 1]: if visited_top: ...
CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER IF VAR IF VAR VAR VAR BIN_OP VAR NUMBER IF VAR IF BIN_OP VAR VAR NUMBER ASSIGN V...
Let's call any (contiguous) subarray B (of A) a mountain if the following properties hold: B.length >= 3 There exists some 0 < i < B.length - 1 such that B[0] < B[1] < ... B[i-1] < B[i] > B[i+1] > ... > B[B.length - 1] (Note that B could be any subarray of A, including the entire array A.) Given an array A of integer...
class Solution: def longestMountain(self, A: List[int]) -> int: if not A or len(A) == 1: return 0 m = len(A) up, down = [(0) for i in range(m)], [(0) for i in range(m)] up[0], down[-1] = 0, 0 for i in range(1, m): j = m - 1 - i if A[i] > A...
CLASS_DEF FUNC_DEF VAR VAR IF VAR FUNC_CALL VAR VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUM...
Let's call any (contiguous) subarray B (of A) a mountain if the following properties hold: B.length >= 3 There exists some 0 < i < B.length - 1 such that B[0] < B[1] < ... B[i-1] < B[i] > B[i+1] > ... > B[B.length - 1] (Note that B could be any subarray of A, including the entire array A.) Given an array A of integer...
class Solution: def longestMountain(self, A: List[int]) -> int: is_peak = False index = 1 longest = 0 while index < len(A) - 1: if A[index] > A[index - 1] and A[index] > A[index + 1]: is_peak = True if not is_peak: index += 1 ...
CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE BIN_OP VAR NUMBER NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR NUMB...