description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached. —Perfect Memento in Strict Sense Marisa comes to pick mushrooms in the Enchanted Forest. The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu...
t = int(input()) while t: t -= 1 n, k = [int(x) for x in input().split()] l = [int(x) for x in input().split()] if k <= n: delta = k * (k - 1) // 2 tmps = sum(l[:k]) s = tmps for i in range(k, n): tmps += l[i] tmps -= l[i - k] s = tmps ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR VAR...
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached. —Perfect Memento in Strict Sense Marisa comes to pick mushrooms in the Enchanted Forest. The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu...
for _ in range(int(input())): n, k = map(int, input().split(" ")) l = list(map(int, input().split(" "))) if n == k: print(sum(l) + n * (n - 1) // 2) elif n > k: m = sum(l[:k]) c = m for i in range(k, n): c += l[i] - l[i - k] m = max(c, m) p...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VA...
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached. —Perfect Memento in Strict Sense Marisa comes to pick mushrooms in the Enchanted Forest. The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu...
def ar(n): return n * (n - 1) // 2 for _ in range(int(input())): n, k = map(int, input().split()) a = list(map(int, input().split())) if k > n: ans = sum(a) ans += ar(n) + k - n + (k - n) * (n - 1) else: b = [0] s = 0 for i in a: s += i ...
FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL 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 IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR VAR ...
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached. —Perfect Memento in Strict Sense Marisa comes to pick mushrooms in the Enchanted Forest. The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu...
tests = int(input()) for i in range(tests): n, steps = map(int, input().split()) florest = [int(n) for n in input().split()] if steps <= n: sum_ = 0 for j in range(steps): sum_ += florest[j] result = sum_ for j in range(steps, n, 1): sum_ += florest[j]...
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 VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR VAR NUMBER VAR VAR VAR VAR VAR BI...
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached. —Perfect Memento in Strict Sense Marisa comes to pick mushrooms in the Enchanted Forest. The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu...
t = int(input()) for i in range(0, t): n, k = [int(x) for x in input().split(" ")] a = [int(x) for x in input().split(" ")] if k > n: print(sum(a) + n * k - n * (n + 1) // 2) else: l = 0 r = k - 1 m = sum(a[:k]) s = m for r in range(k, n): s = ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUM...
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached. —Perfect Memento in Strict Sense Marisa comes to pick mushrooms in the Enchanted Forest. The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu...
tc = int(input()) for t in range(tc): n, k = map(int, input().split()) arr = list(map(int, input().split())) if k >= n: cun = sum(arr) r = n - k sm = (k * (k - 1) - r * (r + 1)) // 2 print(cun + sm) else: cn = sum(arr[:k]) mx = cn for j in range(k,...
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 IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR ...
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached. —Perfect Memento in Strict Sense Marisa comes to pick mushrooms in the Enchanted Forest. The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu...
x = int(input()) def cal(n, m, arr): if m >= n: t = sum(arr) + n * (m - 1) - (n - 1) * n // 2 return t t = sum(arr[:m]) k = t for i in range(n - m): k -= arr[i] k += arr[i + m] t = max(t, k) return t + m * (m - 1) - m * (m - 1) // 2 for jj in range(x): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF IF VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR BIN_OP VAR BIN_OP VAR NUMBER BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC...
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached. —Perfect Memento in Strict Sense Marisa comes to pick mushrooms in the Enchanted Forest. The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu...
def solve(a, n, k): if k > n: return sum(a) + n * k - n * (n + 1) // 2 ksum = k * (k - 1) // 2 ps = [0] * (n + 1) for i in range(n): ps[i + 1] = ps[i] + a[i] nsum = 0 for i in range(n - k + 1): nsum = max(nsum, ps[i + k] - ps[i]) return nsum + ksum t = int(input()) ...
FUNC_DEF IF VAR VAR RETURN BIN_OP BIN_OP FUNC_CALL VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER FOR V...
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached. —Perfect Memento in Strict Sense Marisa comes to pick mushrooms in the Enchanted Forest. The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu...
t = int(input()) while t > 0: n, k = map(int, input().split()) arr = list(map(int, input().split())) sumArr = [0] res = 0 for i in range(n): sumArr.append(sumArr[i] + arr[i]) if k <= n: for i in range(n - k + 1): res = max(res, sumArr[i + k] - sumArr[i]) res +...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER 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 LIST NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF VAR VAR FOR VAR FUNC_CALL VA...
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached. —Perfect Memento in Strict Sense Marisa comes to pick mushrooms in the Enchanted Forest. The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu...
def solve(n, k, array): ans = 0 if k <= n: ans += int(k * (k - 1) / 2) temp = 0 for i in range(k): temp += array[i] maxTemp = temp for i in range(n - k): temp -= array[i] temp += array[i + k] maxTemp = max(temp, maxTemp) ...
FUNC_DEF ASSIGN VAR NUMBER IF VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_...
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached. —Perfect Memento in Strict Sense Marisa comes to pick mushrooms in the Enchanted Forest. The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu...
from itertools import accumulate for _ in range(int(input())): n, k = list(map(int, input().split())) a = list(map(int, input().split())) if n == 1: print(a[0] + k - 1) elif n == 2: if k == 1: print(max(a)) else: print(sum(a) + k * n - n * (n + 1) // 2) ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR 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 NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VA...
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached. —Perfect Memento in Strict Sense Marisa comes to pick mushrooms in the Enchanted Forest. The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu...
for __ in range(int(input())): n, k = map(int, input().split()) a = list(map(int, input().split())) if k >= n: print(sum(a) + (k - 1) * n - (n - 1) * n // 2) continue s = sum(a[:k]) big = s for i in range(k, n): s += a[i] - a[i - k] big = max(big, s) print(big...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL 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 IF VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR F...
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached. —Perfect Memento in Strict Sense Marisa comes to pick mushrooms in the Enchanted Forest. The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu...
for time in range(int(input())): n, x = map(int, input().split()) nums = [int(a) for a in input().split()] if n > x: s = 0 for j in range(x): s += nums[j] maxi = s for j in range(x, n): s += nums[j] - nums[j - x] maxi = max(s, maxi) ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR ASSIGN...
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached. —Perfect Memento in Strict Sense Marisa comes to pick mushrooms in the Enchanted Forest. The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu...
t = int(input()) for _ in range(t): n, k = map(int, input().split()) a = list(map(int, input().split())) if k < n: m = sum(a[:k]) c = m for i in range(k, n): c += a[i] - a[i - k] m = max(m, c) print(m + k * (k - 1) // 2) else: print(sum(a) ...
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 IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR ASSI...
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached. —Perfect Memento in Strict Sense Marisa comes to pick mushrooms in the Enchanted Forest. The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu...
T = int(input()) for testcase in range(T): n, k = list(map(int, input().split())) a = list(map(int, input().split())) s = sum(a) if k >= n: print(s + k * n - n * (n + 1) // 2) else: ps = [0] pssum = 0 for x in a: pssum += x ps.append(pssum) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR 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 ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR BIN_OP ...
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached. —Perfect Memento in Strict Sense Marisa comes to pick mushrooms in the Enchanted Forest. The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu...
t = int(input()) for _ in range(t): n, k = [int(x) for x in input().strip().split()] a = [int(x) for x in input().strip().split()] a = [0] + a for i in range(1, len(a)): a[i] += a[i - 1] if k > n: print(a[n] + (k - 1 + k - n) * n // 2) else: ans = 0 for i in range...
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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR VAR VAR BIN_OP VAR NUMBER IF VAR...
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached. —Perfect Memento in Strict Sense Marisa comes to pick mushrooms in the Enchanted Forest. The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu...
t = int(input()) for _ in range(t): n, k = list(map(int, input().split())) vals = list(map(int, input().split())) maxSum = 0 if k < n: workingSum = sum(vals[:k]) maxSum = workingSum for i in range(k, n): workingSum += vals[i] workingSum -= vals[i - k] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR 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 ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VA...
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached. —Perfect Memento in Strict Sense Marisa comes to pick mushrooms in the Enchanted Forest. The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu...
runs = int(input()) def solveCaseB(map, x, k): return map[x] + (k - 1 + k - x) * x // 2 def solveCaseA(map, x, k): max = 0 for i in range(x + 1): if i >= k: curr = map[i] - map[i - k] if curr > max: max = curr return max + (1 + k - 1) * (k - 1) // 2 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN BIN_OP VAR VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR VAR RETURN BIN_OP VAR BIN_OP BIN_OP BIN_...
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached. —Perfect Memento in Strict Sense Marisa comes to pick mushrooms in the Enchanted Forest. The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu...
t = int(input()) for i in range(t): n, k = [int(x) for x in input().split()] nums = [int(x) for x in input().split()] if k >= n: print(int(sum(nums) + n * (k - 1) - (n - 1) * n / 2)) else: cur_max = sum(nums[0:k]) current = cur_max for j in range(n - k): curre...
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 ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR BIN_OP VAR BIN_OP VAR NUMBER BIN_OP BIN_OP BIN_OP VAR NUMBER ...
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached. —Perfect Memento in Strict Sense Marisa comes to pick mushrooms in the Enchanted Forest. The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu...
for _ in range(int(input())): n, k = map(int, input().split()) arr = list(map(int, input().split())) temp = 0 if k <= n: curr_first = arr[0] curr_sum = sum(arr[:k]) res = curr_sum for nn in arr[k:]: curr_sum = curr_sum - curr_first + nn res = max(r...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL 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 NUMBER IF VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FOR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VA...
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached. —Perfect Memento in Strict Sense Marisa comes to pick mushrooms in the Enchanted Forest. The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu...
def resi(): n, k = map(int, input().split()) a = list(map(int, input().split())) s = sum(a) if k >= n: print(n * (k - n) + s + (n - 1) * n // 2) return tmp = 0 for i in range(k): tmp += a[i] maxx = tmp for i in range(k, n): tmp += a[i] tmp -= a[i -...
FUNC_DEF 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 VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER RETURN ASSIGN VAR NUMBER FOR VAR FUNC_CAL...
During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mathematician, introduced a brand new concept of the weakened common divisor (WCD) of a list of pairs of integers. For a given list of pairs of integers $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_n, b_n)$ their WCD is...
n = int(input()) a = [0] * n b = [0] * n for i in range(n): a[i], b[i] = map(int, input().split()) d = [] for x in (a[0], b[0]): for i in range(2, x + 1): if i * i > x: break if x % i == 0: d.append(i) while x % i == 0: x //= i if x != 1: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR IF BIN_...
During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mathematician, introduced a brand new concept of the weakened common divisor (WCD) of a list of pairs of integers. For a given list of pairs of integers $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_n, b_n)$ their WCD is...
import sys input = sys.stdin.readline def check(f): for Ai, Bi in AB: if Ai % f != 0 and Bi % f != 0: return False return True def factorize(n): factors = [] for i in range(2, int(n**0.5) + 1): cnt = 0 while n % i == 0: n //= i cnt += 1 ...
IMPORT ASSIGN VAR VAR FUNC_DEF FOR VAR VAR VAR IF BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR NUMBER VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR ...
During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mathematician, introduced a brand new concept of the weakened common divisor (WCD) of a list of pairs of integers. For a given list of pairs of integers $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_n, b_n)$ their WCD is...
n = int(input()) ar = [] a, b = map(int, input().split()) num = a**0.5 + 2 i = 2 while i < num: if a % i == 0: ar += [i] while a % i == 0: a //= i i += 1 num = b**0.5 + 2 i = 2 while i < num: if b % i == 0: ar += [i] while b % i == 0: b //= i i += 1 if a != 1: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR VAR NUMBER VAR LIST VAR WHILE BIN_OP VAR VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIG...
During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mathematician, introduced a brand new concept of the weakened common divisor (WCD) of a list of pairs of integers. For a given list of pairs of integers $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_n, b_n)$ their WCD is...
def prime_divs(n): res = set() d = 2 while d * d <= n: if n % d == 0: while n % d == 0: n = n // d res.add(d) else: d = d + 1 if n > 1: res.add(n) return res n = int(input()) ls = [] for i in range(n): a, b = list(map(...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF BIN_OP VAR VAR NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR F...
During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mathematician, introduced a brand new concept of the weakened common divisor (WCD) of a list of pairs of integers. For a given list of pairs of integers $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_n, b_n)$ their WCD is...
n, m = int(input()), 10**5 a = [list(map(int, input().split())) for i in range(n)] p, v = [(0) for i in range(m)], [(0) for i in range(m)] for i in range(2, m): if not v[i]: p[0] += 1 p[p[0]] = i for j in range(1, p[0] + 1): if i * p[j] >= m: break v[i * p[j]] = 1 ...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER VAR FOR VA...
During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mathematician, introduced a brand new concept of the weakened common divisor (WCD) of a list of pairs of integers. For a given list of pairs of integers $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_n, b_n)$ their WCD is...
def prime_factors(n): i = 2 factors = [] while i * i <= n: if n % i: i += 1 else: n //= i factors.append(i) if n > 1: factors.append(n) return factors n = int(input()) Ar = [[None, None] for _ in range(n)] for i in range(n): Ar[i][0],...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE BIN_OP VAR VAR VAR IF BIN_OP VAR VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NONE NONE VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER VAR VAR N...
During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mathematician, introduced a brand new concept of the weakened common divisor (WCD) of a list of pairs of integers. For a given list of pairs of integers $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_n, b_n)$ their WCD is...
def gcd(x, y): while y: x, y = y, x % y return x n = int(input()) al, bl = list(), list() last = 0 for i in range(n): a, b = map(int, input().split()) al.append(a) bl.append(b) last = gcd(last, al[i] * bl[i]) for i in range(n): if gcd(last, al[i]) > 1: last = gcd(last, al[i...
FUNC_DEF WHILE VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VA...
During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mathematician, introduced a brand new concept of the weakened common divisor (WCD) of a list of pairs of integers. For a given list of pairs of integers $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_n, b_n)$ their WCD is...
def gcd(a, b): if b == 0: return a else: return gcd(b, a % b) n = int(input()) sum = 0 l, r = 0, 0 while n > 0: l, r = input().split() l = int(l) r = int(r) t = gcd(l, r) t = int(l * r) // t sum = gcd(sum, t) n -= 1 if sum == 1: print(-1) elif gcd(l, sum) == 1: ...
FUNC_DEF IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BI...
During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mathematician, introduced a brand new concept of the weakened common divisor (WCD) of a list of pairs of integers. For a given list of pairs of integers $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_n, b_n)$ their WCD is...
primes = set() ar, br = [0] * 150001, [0] * 150001 def gen(num): i = 2 while i * i <= num: if num % i == 0: while num % i == 0: num //= i primes.add(i) i += 1 if num > 1: primes.add(num) n = int(input()) for i in range(1, n + 1): ar[i],...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP LIST NUMBER NUMBER BIN_OP LIST NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF BIN_OP VAR VAR NUMBER WHILE BIN_OP VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR V...
During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mathematician, introduced a brand new concept of the weakened common divisor (WCD) of a list of pairs of integers. For a given list of pairs of integers $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_n, b_n)$ their WCD is...
import sys input = sys.stdin.readline R = lambda: map(int, input().split()) I = lambda: int(input()) S = lambda: input().rstrip("\n") L = lambda: list(R()) class WCD: def __init__(self): self.n = I() self.ab = [tuple(R()) for _ in range(self.n)] def ok(self, x): for u, v in self.ab:...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF FOR VAR VAR...
During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mathematician, introduced a brand new concept of the weakened common divisor (WCD) of a list of pairs of integers. For a given list of pairs of integers $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_n, b_n)$ their WCD is...
def primes(n): d = 2 while d * d <= n: while n % d == 0: primfac.add(d) n //= d d += 1 if n > 1: primfac.add(n) return primfac n = int(input()) pairs = [] for i in range(n): pairs.append([int(i) for i in input().split()]) primfac = set() primes(pairs...
FUNC_DEF ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR WHILE BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSI...
During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mathematician, introduced a brand new concept of the weakened common divisor (WCD) of a list of pairs of integers. For a given list of pairs of integers $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_n, b_n)$ their WCD is...
n = int(input()) a, b = [0] * n, [0] * n g = 0 def gcd(a, b): return a if b == 0 else gcd(b, a % b) for i in range(n): a[i], b[i] = map(int, input().split()) g = gcd(g, a[i] * b[i]) for i in range(n): if gcd(g, a[i]) > 1: g = gcd(g, a[i]) else: g = gcd(g, b[i]) print(g if g > 1 e...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP LIST NUMBER VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FUNC_DEF RETURN VAR NUMBER VAR FUNC_CALL VAR VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR...
During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mathematician, introduced a brand new concept of the weakened common divisor (WCD) of a list of pairs of integers. For a given list of pairs of integers $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_n, b_n)$ their WCD is...
def gcd(a, b): if b == 0: return a return gcd(b, a % b) n = int(input()) a = [] b = [] for i in range(n): A, B = map(int, input().split()) a.append(A) b.append(B) ans = -1 x = 0 for i in range(n): x = gcd(x, a[i] * b[i]) if x != 1: for i in range(n): if gcd(x, a[i]) > 1: ...
FUNC_DEF IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FU...
During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mathematician, introduced a brand new concept of the weakened common divisor (WCD) of a list of pairs of integers. For a given list of pairs of integers $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_n, b_n)$ their WCD is...
import sys def trial_division(n): a = [] while n % 2 == 0: a.append(2) n = n // 2 f = 3 while f * f <= n: if n % f == 0: a.append(f) n = n // f else: f += 2 if n != 1: a.append(n) return a n = int(sys.stdin.readline(...
IMPORT FUNC_DEF ASSIGN VAR LIST WHILE BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR F...
During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mathematician, introduced a brand new concept of the weakened common divisor (WCD) of a list of pairs of integers. For a given list of pairs of integers $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_n, b_n)$ their WCD is...
def countdiv(n): count = set() i = 2 nn = n while n > 1: if n % i == 0: count.add(i) n //= i else: i += 1 if i > nn**0.5 + 1: count.add(n) break return count def countt(n, s): ss = set() for i in s: ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR NUMBER IF VAR BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR RE...
During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mathematician, introduced a brand new concept of the weakened common divisor (WCD) of a list of pairs of integers. For a given list of pairs of integers $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_n, b_n)$ their WCD is...
def gcd(a, b): if b == 0: return a else: return gcd(b, a % b) test = int(input()) list = [tuple(map(int, input().split())) for i in range(test)] ans = 0 for a, b in list: ans = gcd(a * b, ans) for a, b in list: if gcd(ans, b) != 1: ans = gcd(ans, b) else: ans = gcd(...
FUNC_DEF IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR FOR VAR VAR VAR IF FUNC_CALL VAR VAR VAR...
During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mathematician, introduced a brand new concept of the weakened common divisor (WCD) of a list of pairs of integers. For a given list of pairs of integers $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_n, b_n)$ their WCD is...
import sys def prime_factors(a): factors = set() i = 2 orig = a while i <= int(orig**0.5) + 1: while a % i == 0: a = a // i factors.add(i) i += 1 if a > 1: factors.add(a) return factors N = int(sys.stdin.readline()) a, b = [int(x) for x in sys....
IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR ...
During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mathematician, introduced a brand new concept of the weakened common divisor (WCD) of a list of pairs of integers. For a given list of pairs of integers $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_n, b_n)$ their WCD is...
n = int(input()) x, y = map(int, input().split()) primes = list() arr = [] for i in [x, y]: k = 2 while k * k <= i: if i % k == 0: while i % k == 0: i //= k primes.append(k) k += 1 if i > 1: primes.append(i) for _ in range(n - 1): arr.appen...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR LIST VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF BIN_OP VAR VAR NUMBER WHILE BIN_OP VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_...
During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mathematician, introduced a brand new concept of the weakened common divisor (WCD) of a list of pairs of integers. For a given list of pairs of integers $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_n, b_n)$ their WCD is...
import sys input = sys.stdin.buffer.readline def is_prime(x): i = 2 global s p = x while i * i <= x: flag = 0 while p % i == 0: p //= i flag = 1 if flag == 1: s.add(i) i += 1 if p > 1: s.add(p) n = int(input()) s = set(...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE BIN_OP VAR VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR NUMBER VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR...
During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mathematician, introduced a brand new concept of the weakened common divisor (WCD) of a list of pairs of integers. For a given list of pairs of integers $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_n, b_n)$ their WCD is...
def f(n): d = 2 A = [] while d * d <= n: if n % d == 0: A.append(d) n = n // d else: d += 1 if n != 1: A.append(n) return A n = int(input()) a, b = map(int, input().split()) A = set(f(a)) B = set(f(b)) ans = A.union(B) ans = list(ans) for...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE BIN_OP VAR VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VA...
During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mathematician, introduced a brand new concept of the weakened common divisor (WCD) of a list of pairs of integers. For a given list of pairs of integers $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_n, b_n)$ their WCD is...
def prime_factors(n): i = 2 factors = [] while i * i <= n: if n % i: i += 1 else: n //= i factors.append(i) if n > 1: factors.append(n) return factors nums = [list(map(int, input().split())) for _ in range(int(input()))] prods = [(x * y) ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE BIN_OP VAR VAR VAR IF BIN_OP VAR VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR VAR V...
During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mathematician, introduced a brand new concept of the weakened common divisor (WCD) of a list of pairs of integers. For a given list of pairs of integers $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_n, b_n)$ their WCD is...
def prime_factorize(n): primes_factors = {} while n % 2 == 0: n >>= 1 primes_factors[2] = primes_factors.get(2, 0) + 1 for i in range(3, int(n ** (1 / 2)) + 1, 2): while n % i == 0: n //= i primes_factors[i] = primes_factors.get(i, 0) + 1 if n > 1: ...
FUNC_DEF ASSIGN VAR DICT WHILE BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR NUMBER BIN_OP FUNC_CALL VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER NUMBER NUMBER NUMBER WHILE BIN_OP VAR VAR NUMBER VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER IF VAR ...
During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mathematician, introduced a brand new concept of the weakened common divisor (WCD) of a list of pairs of integers. For a given list of pairs of integers $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_n, b_n)$ their WCD is...
import sys input = sys.stdin.readline def f(a): s = [] n = a for i in range(2, int(n**0.5) + 1): if a % i == 0: while a % i == 0: a //= i s.append(i) i += 1 if a > 1: s.append(a) return s def check(elem): for item in a: ...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR LIST ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR VAR NUMBER WHILE BIN_OP VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF FOR VAR VAR IF BIN_OP VAR NUMBE...
During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mathematician, introduced a brand new concept of the weakened common divisor (WCD) of a list of pairs of integers. For a given list of pairs of integers $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_n, b_n)$ their WCD is...
n = int(input()) l1 = [] l2 = [] for i in range(n): a, b = map(int, input().split()) l1.append(a) l2.append(b) L = [] j = 2 a = l1[0] b = l2[0] while j * j <= a: if a % j == 0: while a % j == 0: a = a // j L.append(j) j = j + 1 if a > 1: L.append(a) j = 2 while j * j ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER WHILE BIN_OP VAR VAR VAR IF BIN_OP VAR VAR...
During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mathematician, introduced a brand new concept of the weakened common divisor (WCD) of a list of pairs of integers. For a given list of pairs of integers $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_n, b_n)$ their WCD is...
import sys input = sys.stdin.readline def primes(n): fact = [] if n % 2 == 0: fact.extend([2]) while n % 2 == 0: n //= 2 for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: fact.append(i) while n % i == 0: n //= i if n != 1...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR LIST IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR LIST NUMBER WHILE BIN_OP VAR NUMBER NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR WHILE BIN_OP VAR VAR NUMBER VAR VAR IF VAR...
During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mathematician, introduced a brand new concept of the weakened common divisor (WCD) of a list of pairs of integers. For a given list of pairs of integers $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_n, b_n)$ their WCD is...
import sys input = sys.stdin.readline def inpl(): return list(map(int, input().split())) def gcd(x, y): if x % y == 0: return y else: x, y = y, x % y return gcd(x, y) N = int(input()) nums = [] g = 0 for i in range(N): a, b = inpl() nums.append([a, b]) g = gcd(g, a...
IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF BIN_OP VAR VAR NUMBER RETURN VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR RETURN FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC...
During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mathematician, introduced a brand new concept of the weakened common divisor (WCD) of a list of pairs of integers. For a given list of pairs of integers $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_n, b_n)$ their WCD is...
def prime(a): i = 2 if a <= 1: return 0 if a == 2 or a == 3: return 1 while i * i <= a: if a % i == 0: return 0 i += 1 return 1 def faq(a): l = [] l1 = [] i = 1 while i * i <= a: if a % i == 0: l.append(i) ...
FUNC_DEF ASSIGN VAR NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER WHILE BIN_OP VAR VAR VAR IF BIN_OP VAR VAR NUMBER RETURN NUMBER VAR NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR ...
During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mathematician, introduced a brand new concept of the weakened common divisor (WCD) of a list of pairs of integers. For a given list of pairs of integers $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_n, b_n)$ their WCD is...
q = int(input()) a, b = map(int, input().split()) s = set() for x in [a, b]: if x % 2 == 0: s.add(2) while x % 2 == 0: x //= 2 i = 3 while i * i <= x: if x % i == 0: s.add(i) while x % i == 0: x //= i i += 2 if x != 1: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR LIST VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER WHILE BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL...
During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mathematician, introduced a brand new concept of the weakened common divisor (WCD) of a list of pairs of integers. For a given list of pairs of integers $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_n, b_n)$ their WCD is...
def divisors(a, b): Divisors = [] i = 2 while i * i <= a: if a % i == 0: Divisors.append(i) while a % i == 0: a /= i i += 1 i = 2 while i * i <= b: if b % i == 0: if i not in Divisors: Divisors.append(i) ...
FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR WHILE BIN_OP VAR VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF BIN_OP VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR WHILE BIN_OP VAR VAR NUMBER VAR VAR VAR NUMBER IF VAR N...
During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mathematician, introduced a brand new concept of the weakened common divisor (WCD) of a list of pairs of integers. For a given list of pairs of integers $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_n, b_n)$ their WCD is...
def findPF(n, pf): if n <= 1: return i = 2 while i * i <= n: if n % i == 0: pf.add(i) while n > 1 and n % i == 0: n = n // i i += 1 if n > 1: pf.add(n) n = int(input()) a, b = map(int, input().split()) pf = set() findPF(a, pf) fin...
FUNC_DEF IF VAR NUMBER RETURN ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR WHILE VAR NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC...
During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mathematician, introduced a brand new concept of the weakened common divisor (WCD) of a list of pairs of integers. For a given list of pairs of integers $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_n, b_n)$ their WCD is...
def fact(n): i = 2 arr = set() while i * i <= n: if n % i == 0: arr.add(i) while n % i == 0: n //= i i += 1 if n > 1: arr.add(n) return list(arr) arr = [] for i in range(int(input())): a, b = map(int, input().split()) arr.appe...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR WHILE BIN_OP VAR VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR WHILE BIN_OP VAR VAR NUMBER VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_...
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
from sys import exit n, m = map(int, input().split()) a, b = 2 * n, 3 * m for i in range(6, 10**10, 6): if a >= i and b >= i: if a <= b: a += 2 else: b += 3 else: break print(max(a, b))
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP NUMBER VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER NUMBER NUMBER IF VAR VAR VAR VAR IF VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
n, m = map(int, input().split()) i = 0 while i // 2 < n or i // 3 < m or i // 2 + i // 3 - i // 6 < n + m: i += 1 print(i)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
n, m = tuple(map(int, input().split())) a = 2 * n b = 3 * m c = n // 3 d = m // 2 while c > 0 and d > 0: if a > b: b += 3 c -= 1 d -= 1 if b % 6 == 0: d += 1 else: a += 2 c -= 1 d -= 1 if a % 6 == 0: c += 1 print(str(max(a, ...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR NUMBER IF VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ...
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
n, m = input().split() n = int(n) m = int(m) res_n = n * 2 res_m = m * 3 tmp_height = 6 while tmp_height <= min(res_n, res_m): tmpresn = res_n + 2 tmpresm = res_m + 3 if max(tmpresn, res_m) > max(res_n, tmpresm): res_m = tmpresm else: res_n = tmpresn tmp_height += 6 print(max(res_m, ...
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR...
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
read_ints = lambda: map(int, input().split()) def solve(m, n): h2, h3 = 2 * m, 3 * n left = min(h2, h3) // 6 while left > 0: if h2 + 2 < h3 + 3: h2 += 2 if h2 % 3 != 0 or h2 > h3: left -= 1 else: h3 += 3 if h3 % 2 != 0 or h3 >...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR BIN_OP NUMBER VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR VAR...
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
n, m = list(map(int, input().split())) def test(k): return k // 2 >= n and k // 3 >= m and k // 2 + k // 3 - k // 6 >= n + m lo = 0 hi = 6 * (n + m) while hi - lo > 1: mid = (hi + lo) // 2 if test(mid): hi = mid else: lo = mid print(hi)
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP VAR VAR WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BI...
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
import sys n, m = list(map(int, input().split())) i = k2 = k3 = k6 = 0 while True: i += 1 if i % 6 == 0: k6 += 1 else: if i % 3 == 0: k3 += 1 if i % 2 == 0: k2 += 1 k2 = min(n, k2) k3 = min(m, k3) need = n - k2 + m - k3 if need <= k6: ...
IMPORT ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER WHILE NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIG...
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
import sys def main(): n, m = [int(f) for f in sys.stdin.readline().split()] h = max(2 * n, 3 * m) n_common = h // 6 n3 = h // 3 - n_common n2 = h // 2 - n_common if n3 + n2 + n_common >= m + n: res = h else: while n3 + n2 + n_common < m + n: h += 1 ...
IMPORT FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR IF BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR WHILE BIN_OP B...
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
a, b = list(map(int, input().split(" "))) lo = 1 hi = 1000000000 while lo < hi: mid = (lo + hi) // 2 x = mid // 2 y = mid // 3 z = mid // 6 x -= z y -= z t = 0 if x <= a: t += a - x if y <= b: t += b - y if t > z: lo = mid + 1 else: hi = mid pr...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR VAR VAR BIN_OP VAR VAR I...
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
n, m = map(int, input().split()) l = 0 r = 10**9 while r - l > 1: mid = (r + l) // 2 c2 = mid // 2 c3 = mid // 3 c6 = mid // 6 cnt2 = c2 - c6 cnt3 = c3 - c6 if cnt2 < n: c6 -= n - cnt2 if cnt3 < m: c6 -= m - cnt3 if c6 >= 0: r = mid else: l = mid p...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR...
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
n, m = map(int, input().split()) ans = max(2 * n, 3 * m, (3 * (n + m) + 1) // 2) - 1 if ans // 2 < n or ans // 3 < m or ans // 2 + ans // 3 - ans // 6 < n + m: ans += 1 print(ans)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP NUMBER VAR BIN_OP NUMBER VAR BIN_OP BIN_OP BIN_OP NUMBER BIN_OP VAR VAR NUMBER NUMBER NUMBER IF BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR VAR V...
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
n, m = map(int, input().split()) max_m = m * 3 busy_by_m = int(m * 3 / 6) max_n = (n + busy_by_m) * 2 * bool(n) nd = 0 md = 0 maxv = 0 if max_n > max_m: nd = -2 md = +3 max_n_prev = max_n max_m_prev = max_m for i in range(busy_by_m): max_n_prev = max_n max_m_prev = max_m max_...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR ...
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
def condn(x, n, m): return not (x // 2 >= n and x // 3 >= m and x // 2 + x // 3 - x // 6 >= n + m) n, m = map(int, input().split()) x = 1 while condn(x, n, m): x += 1 print(x)
FUNC_DEF RETURN BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
n, m = map(int, input().split()) x = [(6 * (i + 1)) for i in range(m + n)] mt, mth = 2 * n, 3 * m for i in x: t = 2 * max(0, 1 + (mt - i) // 2) th = 3 * max(0, 1 + (mth - i) // 2) if t == 0 or th == 0: break if th < t: mth += 3 else: mt += 2 print(max(mth, mt))
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR BIN_OP NUMBER VAR BIN_OP NUMBER VAR FOR VAR VAR ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR NUMBER BIN_OP NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER FUNC_CALL ...
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
s = input().split() n, m = s n = int(n) m = int(m) n *= 2 m *= 3 i = 1 while True: if n <= m: if i * 6 <= n: n += 2 else: break elif i * 6 <= m: m += 3 else: break i += 1 print(max(n, m))
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF VAR VAR IF BIN_OP VAR NUMBER VAR VAR NUMBER IF BIN_OP VAR NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
n, m = map(int, input().split()) start = 0 end = 10**10 while end - start > 1: mid = (end + start) // 2 two = mid // 2 - mid // 6 three = mid // 3 - mid // 6 six = mid // 6 nn = n mm = m nn -= two mm -= three nn = max(nn, 0) mm = max(mm, 0) if six >= nn + mm: end = mi...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN V...
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
def check_2(n, m, x): two_mul = x - x // 3 three_mul = 2 * x // 3 - x // 3 six_mul = x // 3 return (n - two_mul if n >= two_mul else 0) + ( m - three_mul if m >= three_mul else 0 ) <= six_mul def check_3(n, m, x): three_mul = x - x // 2 two_mul = 3 * x // 2 - x // 2 six_mul = x...
FUNC_DEF ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN BIN_OP VAR VAR BIN_OP VAR VAR NUMBER VAR VAR BIN_OP VAR VAR NUMBER VAR FUNC_DEF ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMB...
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
import time n, m = (int(i) for i in input().split()) start = time.time() h2 = 2 * n h3 = 3 * m k = 6 while k <= min(h2, h3): if h2 + 2 < h3 + 3: h2 += 2 else: h3 += 3 k += 6 print(max(h2, h3)) finish = time.time()
IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN...
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
from itertools import count n, m = input().split() n, m = int(n), int(m) for x in count(0): if x // 2 >= n and x // 3 >= m and x // 2 + x // 3 - x // 6 >= n + m: print(x) break
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
n, m = map(int, input().split()) num = max(n * 2, m * 3) while True: if num % 2 == 0 or num % 3 == 0: x = num // 2 y = num // 3 z = num // 6 if x >= n and y >= m and x + y - z >= m + n: print(num) exit() num += 1
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER WHILE NUMBER IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR BIN_...
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
def check(n2, n3, k): q2 = k // 2 q3 = k // 3 q6 = k // 6 q2 -= q6 q3 -= q6 lo = n2 - q2 hi = q3 + q6 - n3 return lo <= hi and lo <= q6 and 0 <= hi def go(n2, n3): lo = -1 hi = int(60000000.0) while lo + 1 < hi: k = (lo + hi) // 2 if check(n2, n3, k): ...
FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR RETURN VAR VAR VAR VAR NUMBER VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER WHILE BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP...
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
import sys n, m = sys.stdin.readline().split() n = int(n) m = int(m) if n == 0: print(m * 3) exit(0) elif m == 0: print(n * 2) exit(0) twos = [] cur2 = 2 for i in range(n): twos.append(cur2) cur2 += 2 if cur2 % 6 == 0: cur2 += 2 threes = [] cur3 = 3 for i in range(m): threes.app...
IMPORT ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EX...
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
def __starting_point(): d, t = list(map(int, input().split(" "))) result = 0 i2 = d * 2 i3 = t * 3 cm = int(max(i2, i3) / 6) while cm > 0: if i2 + 2 < i3 + 3: i2 += 2 elif i2 + 2 > i3 + 3: i3 += 3 else: i2 += 2 cm += 1 ...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER BIN_OP V...
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
n, m = map(int, input().split()) left = 0 right = 10000000 while right - left != 1: mid = (left + right) // 2 all_places = mid // 2 + mid // 3 - mid // 6 if not (2 * n <= mid and 3 * m <= mid and n + m <= all_places): left = mid else: right = mid print(right)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR...
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
t2, t3 = list(map(int, input().split(" "))) left = 2 * t2 - 10 right = 3 * (t2 + t3) + 10 while right - left != 1: guess = int((left + right) / 2) work2 = int(guess / 2) - int(guess / 6) work3 = int(guess / 3) - int(guess / 6) work6 = int(guess / 6) if max(0, t2 - work2) + max(0, t3 - work3) <= work...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP VAR VAR NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR...
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
n, m = list(map(int, input().split())) answer = 0 while True: if n >= 3 and m >= 2: if n / m > 3 / 2: n -= 3 m -= 1 else: n -= 2 m -= 2 answer += 6 elif m == 1: answer += max(3, 2 * n) break elif m == 0: answer +...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE NUMBER IF VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR BIN_OP NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR IF VAR NUMBER VAR BIN_OP NUMBER VAR VAR BI...
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
n, m = list(map(int, input().split())) maxn = 0 for i in range(n): maxn += 2 if maxn % 3 == 0: maxn += 2 maxm = m * 6 - 3 now = 6 while now < max(maxm, maxn): if maxm >= maxn: maxm -= 3 if maxm % 2 == 0 and maxm - 3 > now: maxm -= 3 else: maxn -= 2 if ...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR N...
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
def right(m, n, a): b = True n2 = a // 2 - a // 6 n3 = a // 3 - a // 6 n6 = a // 6 if n2 + n6 < n or n3 + n6 < m or n2 + n3 + n6 < n + m: b = False return b n, m = list(map(int, input().split())) ans = n + m while not right(m, n, ans): ans += 1 print(ans)
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VA...
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
n, m = map(int, input().split()) low = 1 high = 10**9 def p(x): t1 = x // 2 t2 = x // 3 if t1 >= n and t2 >= m: t3 = x // 6 return t1 + t2 - t3 >= m + n return False while low < high: mid = low + (high - low) // 2 if p(mid): high = mid else: low = mid + 1 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR VAR RETURN NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR ...
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
n, m = map(int, input().split()) nbcom = min(n * 2, 3 * m) // 6 res1 = 2 * n res2 = 3 * m while nbcom: if res1 + 2 <= res2 + 3: res1 += 2 if res1 % 6 != 0 or res1 > res2: nbcom -= 1 else: res2 += 3 if res2 % 6 != 0 or res2 > res1: nbcom -= 1 print(max(res1...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP NUMBER VAR WHILE VAR IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR NUMBER VAR NUMBER IF BIN_OP VA...
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
n, m = [int(x) for x in input().split()] h1 = lambda k: 6 * ((k - 1) // 2) + 2 * ((k - 1) % 2 + 1) if k > 0 else 0 h2 = lambda k: 3 + (k - 1) * 6 if k > 0 else 0 h3 = lambda l: 6 * k newx = lambda k: k - 2 if k % 6 == 4 else k - 4 newy = lambda k: k - 6 x, y, z = h1(n), h2(m), 0 while max(x, y) > z + 6: z += 6 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER BIN_OP BIN_OP NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP NUMBER BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER BIN_OP NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BI...
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
def main(): n2, n3 = map(int, input().split()) nmax = 3 * max(n2, n3) * 2 c2 = c3 = c6 = 0 for n in range(1, nmax): if n % 6 == 0: c6 += 1 elif c3 < n3 and n % 3 == 0: c3 += 1 elif c2 < n2 and n % 2 == 0: c2 += 1 if n2 - c2 + n3 - c3 - ...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER I...
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
nm = input().split(" ") n = int(nm[0]) m = int(nm[1]) if n == 0: print(3 * m) elif m == 0: print(2 * n) else: new = max(3 * m, 2 * n) i = 0 while i < new + 1: if i % 6 == 0 and i != 0: if i // 3 <= m and i // 2 <= n and 2 * (n + 1) - new < 3 * (m + 1) - new: n += ...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMB...
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
def check(x): return ( max(n - (x - 2) // 6 - (x - 4) // 6 - 2, 0) + max(m - (x - 3) // 6 - 1, 0) <= x // 6 ) n, m = list(map(int, input().split())) left, right = 0, 10**10 while left + 1 < right: middle = left + right >> 1 if check(middle): right = middle else: lef...
FUNC_DEF RETURN BIN_OP FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER NUMBER FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VA...
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
n, m = map(int, input().split()) a, b, i = 2 * n, 3 * m, 6 while i <= min(a, b): if b < a: b += 3 else: a += 2 i += 6 print(max(a, b))
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR BIN_OP NUMBER VAR BIN_OP NUMBER VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
n, m = map(int, input().split()) k = n + m a = [6, 3][m % 2] + 6 * ((m - 1) // 2) b = [6, 2, 4][n % 3] + 6 * ((n - 1) // 3) c = [6, 2, 3, 4][k % 4] + 6 * ((k - 1) // 4) print(a if n < m else b if n > 3 * m else c)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER BIN_OP VAR NUMBER BIN_OP NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER NUMBER BIN_OP VAR NUMBER BIN_OP NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBE...
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
def check(n, m, ans): div2 = ans // 2 div3 = ans // 3 div6 = ans // 6 k = 0 if div2 < n or div3 < m: return False if div2 - div6 < n: k = n - (div2 - div6) return div3 - k >= m n, m = list(map(int, input().split())) l = -1 r = max(n * 6, m * 6) + 1 while l < r - 1: mid ...
FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR VAR RETURN NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR RETURN BIN_OP VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER...
You are playing another computer game, and now you have to slay $n$ monsters. These monsters are standing in a circle, numbered clockwise from $1$ to $n$. Initially, the $i$-th monster has $a_i$ health. You may shoot the monsters to kill them. Each shot requires exactly one bullet and decreases the health of the targe...
import sys read = sys.stdin.buffer.read input = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines t = int(input()) for i in range(t): n = int(input()) a = [] b = [] for j in range(n): p, q = map(int, input().split()) a.append(p) b.append(q) s = 0 m = 10000...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR 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 LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASS...
You are playing another computer game, and now you have to slay $n$ monsters. These monsters are standing in a circle, numbered clockwise from $1$ to $n$. Initially, the $i$-th monster has $a_i$ health. You may shoot the monsters to kill them. Each shot requires exactly one bullet and decreases the health of the targe...
from sys import stdin input = stdin.buffer.readline for _ in range(int(input())): n = int(input()) a, b = map(int, input().split()) l = a z = 0 su = 0 t = b q = float("-infinity") for i in range(1, n): a, b = map(int, input().split()) f = max(0, a - t) q = max(q,...
ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR...
You are playing another computer game, and now you have to slay $n$ monsters. These monsters are standing in a circle, numbered clockwise from $1$ to $n$. Initially, the $i$-th monster has $a_i$ health. You may shoot the monsters to kill them. Each shot requires exactly one bullet and decreases the health of the targe...
import sys input = sys.stdin.buffer.readline def main(): t = int(input()) for _ in range(t): n = int(input()) hp, dmg = [], [] for _ in range(n): a, b = map(int, input().split()) hp.append(a) dmg.append(b) for i in range(n): dmg[...
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 VAR LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIG...
You are playing another computer game, and now you have to slay $n$ monsters. These monsters are standing in a circle, numbered clockwise from $1$ to $n$. Initially, the $i$-th monster has $a_i$ health. You may shoot the monsters to kill them. Each shot requires exactly one bullet and decreases the health of the targe...
import sys input = sys.stdin.buffer.readline for _ in range(int(input())): n = int(input()) a = [(0) for i in range(n)] b = [(0) for i in range(n)] res = 0 for i in range(n): a[i], b[i] = map(int, input().split()) first = 10**15 for i in range(1, n): res += max(0, a[i] - b[i...
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 NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NU...
You are playing another computer game, and now you have to slay $n$ monsters. These monsters are standing in a circle, numbered clockwise from $1$ to $n$. Initially, the $i$-th monster has $a_i$ health. You may shoot the monsters to kill them. Each shot requires exactly one bullet and decreases the health of the targe...
import sys input = sys.stdin.buffer.readline for _ in range(int(input())): n = int(input()) arr = [] ans = 0 m = 10**20 for i in range(n): arr.append(list(map(int, input().split()))) if i > 0: k = max(0, arr[i][0] - arr[i - 1][1]) ans += k m = min...
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 LIST ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUM...
You are playing another computer game, and now you have to slay $n$ monsters. These monsters are standing in a circle, numbered clockwise from $1$ to $n$. Initially, the $i$-th monster has $a_i$ health. You may shoot the monsters to kill them. Each shot requires exactly one bullet and decreases the health of the targe...
import sys input = sys.stdin.buffer.read class GetInt: def __init__(self): self.nums = list(map(int, input().split())) self.n_idx = -1 def get(self): self.n_idx += 1 return self.nums[self.n_idx] inp = GetInt() T = inp.get() fans = [] for _ in range(T): ans = 0 A = ...
IMPORT ASSIGN VAR VAR CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_DEF VAR NUMBER RETURN VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_C...
You are playing another computer game, and now you have to slay $n$ monsters. These monsters are standing in a circle, numbered clockwise from $1$ to $n$. Initially, the $i$-th monster has $a_i$ health. You may shoot the monsters to kill them. Each shot requires exactly one bullet and decreases the health of the targe...
import sys def solve(): input = sys.stdin.buffer.readline t = int(input()) while t > 0: n = int(input()) a = [] b = [] cnt = 0 mn = float("inf") for i in range(n): x, y = map(int, input().split()) a.append(x) b.append(y) ...
IMPORT FUNC_DEF ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR F...
You are playing another computer game, and now you have to slay $n$ monsters. These monsters are standing in a circle, numbered clockwise from $1$ to $n$. Initially, the $i$-th monster has $a_i$ health. You may shoot the monsters to kill them. Each shot requires exactly one bullet and decreases the health of the targe...
import sys input = sys.stdin.buffer.readline testCases = int(input()) for test in range(testCases): n = int(input()) a = [] b = [] for i in range(n): aa, bb = map(int, input().split()) a.append(aa) b.append(bb) ab = [0] * n for i in range(n): ab[i] = max(0, a[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 LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR...
You are playing another computer game, and now you have to slay $n$ monsters. These monsters are standing in a circle, numbered clockwise from $1$ to $n$. Initially, the $i$-th monster has $a_i$ health. You may shoot the monsters to kill them. Each shot requires exactly one bullet and decreases the health of the targe...
import sys input = sys.stdin.buffer.readline def I(): return list(map(int, input().split())) def sieve(n): a = [1] * n for i in range(2, n): if a[i]: for j in range(i * i, n, i): a[j] = 0 return a for __ in range(int(input())): n = int(input()) s = 0 ...
IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR ...
You are playing another computer game, and now you have to slay $n$ monsters. These monsters are standing in a circle, numbered clockwise from $1$ to $n$. Initially, the $i$-th monster has $a_i$ health. You may shoot the monsters to kill them. Each shot requires exactly one bullet and decreases the health of the targe...
from sys import stdin t = int(stdin.buffer.readline()) for _ in range(t): n = int(stdin.buffer.readline()) a = list() b = list() for _ in range(n): x, y = map(int, stdin.buffer.readline().split()) a.append(x) b.append(y) Sum = 0 res = float("inf") 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 ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CAL...
You are playing another computer game, and now you have to slay $n$ monsters. These monsters are standing in a circle, numbered clockwise from $1$ to $n$. Initially, the $i$-th monster has $a_i$ health. You may shoot the monsters to kill them. Each shot requires exactly one bullet and decreases the health of the targe...
import sys input = sys.stdin.buffer.readline t = int(input()) for _ in range(t): n = int(input()) a = [] b = [] for __ in range(n): x, y = map(int, input().split()) a.append(x) b.append(y) suma = 0 for i in range(n): suma += max(a[i] - b[(i - 1) % n], 0) mini...
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 LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CA...