description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Given a positive integer $m$, we say that a sequence $x_1, x_2, \dots, x_n$ of positive integers is $m$-cute if for every index $i$ such that $2 \le i \le n$ it holds that $x_i = x_{i - 1} + x_{i - 2} + \dots + x_1 + r_i$ for some positive integer $r_i$ satisfying $1 \le r_i \le m$. You will be given $q$ queries consi...
from sys import stdin, stdout n = int(stdin.readline()) for nn in range(n): a, b, m = map(int, stdin.readline().split()) if a == b: stdout.write("{} {}\n".format(1, a)) else: for j in range(2, 51): if a + 1 << j - 2 <= b and b <= a + m << j - 2: B = b ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN...
Given a positive integer $m$, we say that a sequence $x_1, x_2, \dots, x_n$ of positive integers is $m$-cute if for every index $i$ such that $2 \le i \le n$ it holds that $x_i = x_{i - 1} + x_{i - 2} + \dots + x_1 + r_i$ for some positive integer $r_i$ satisfying $1 \le r_i \le m$. You will be given $q$ queries consi...
for _ in range(int(input())): a, b, m = [int(i) for i in input().split()] if a == b: print("1 " + str(a)) continue l = a + 1 r = a + m cnt = 1 while r < b: l += l r += r cnt += 1 if l > b: print(-1) continue ls = [1] * cnt p2 = ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR...
Given a positive integer $m$, we say that a sequence $x_1, x_2, \dots, x_n$ of positive integers is $m$-cute if for every index $i$ such that $2 \le i \le n$ it holds that $x_i = x_{i - 1} + x_{i - 2} + \dots + x_1 + r_i$ for some positive integer $r_i$ satisfying $1 \le r_i \le m$. You will be given $q$ queries consi...
q = int(input().strip()) for i in range(q): a, b, m = map(int, input().strip().split()) p = a + 1 q = a + m c = 1 pos = 0 q = 0 if b == a: print(1, a) else: while b / c > a + m: c = c << 1 q += 1 if b / c >= a + 1: pos = 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER VAR WHILE BIN_OP VAR VAR BIN...
Given a positive integer $m$, we say that a sequence $x_1, x_2, \dots, x_n$ of positive integers is $m$-cute if for every index $i$ such that $2 \le i \le n$ it holds that $x_i = x_{i - 1} + x_{i - 2} + \dots + x_1 + r_i$ for some positive integer $r_i$ satisfying $1 \le r_i \le m$. You will be given $q$ queries consi...
q = int(input()) powers = [1] for i in range(50): powers.append(powers[-1] * 2) for _ in range(q): a, b, m = [int(x) for x in input().split()] if a == b: print(1, a) elif m == 1: good = False for r in range(50): if powers[r] * (a + 1) > b: break ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR...
Given a positive integer $m$, we say that a sequence $x_1, x_2, \dots, x_n$ of positive integers is $m$-cute if for every index $i$ such that $2 \le i \le n$ it holds that $x_i = x_{i - 1} + x_{i - 2} + \dots + x_1 + r_i$ for some positive integer $r_i$ satisfying $1 \le r_i \le m$. You will be given $q$ queries consi...
def solve(a, b, m): if a == b: return [a] for _len in range(2, 51): l = (a + 1) * 2 ** (_len - 2) r = (a + m) * 2 ** (_len - 2) if b < l or b > r: continue res = [] res += [a] s = a for i in range(1, _len - 1): L = 0 ...
FUNC_DEF IF VAR VAR RETURN LIST VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR LIST VAR LIST VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIG...
Given a positive integer $m$, we say that a sequence $x_1, x_2, \dots, x_n$ of positive integers is $m$-cute if for every index $i$ such that $2 \le i \le n$ it holds that $x_i = x_{i - 1} + x_{i - 2} + \dots + x_1 + r_i$ for some positive integer $r_i$ satisfying $1 \le r_i \le m$. You will be given $q$ queries consi...
q = int(input()) po = [1, 1, 2] l = 4 for i in range(55): po.append(l) l *= 2 while q > 0: q -= 1 a, b, m = map(int, input().split()) se = 0 for ub in range(1, 51): s = sum(po[: ub - 1]) if b < s + po[ub - 1] * a: print(-1) se = 2 break ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER WHILE VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL...
Given a positive integer $m$, we say that a sequence $x_1, x_2, \dots, x_n$ of positive integers is $m$-cute if for every index $i$ such that $2 \le i \le n$ it holds that $x_i = x_{i - 1} + x_{i - 2} + \dots + x_1 + r_i$ for some positive integer $r_i$ satisfying $1 \le r_i \le m$. You will be given $q$ queries consi...
q = int(input()) for u in range(q): a, b, m = map(int, input().split()) ranges = [(a, a)] bigsum = a smlsum = a while ranges[-1][1] < b: ranges.append((smlsum + 1, bigsum + m)) smlsum = 2 * smlsum + 1 bigsum = 2 * bigsum + m if b < ranges[-1][0]: print(-1) els...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR WHILE VAR NUMBER NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP...
Given a positive integer $m$, we say that a sequence $x_1, x_2, \dots, x_n$ of positive integers is $m$-cute if for every index $i$ such that $2 \le i \le n$ it holds that $x_i = x_{i - 1} + x_{i - 2} + \dots + x_1 + r_i$ for some positive integer $r_i$ satisfying $1 \le r_i \le m$. You will be given $q$ queries consi...
def solve(): a, b, m = (int(x) for x in input().split()) if a == b: print(1, a) return curr = a curr_const = 1 steps_nr = 0 while b - curr > curr_const * m: curr *= 2 curr_const *= 2 steps_nr += 1 if b - curr < curr_const: print(-1) ret...
FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER VAR RETURN ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR BIN_OP BIN_O...
Given a positive integer $m$, we say that a sequence $x_1, x_2, \dots, x_n$ of positive integers is $m$-cute if for every index $i$ such that $2 \le i \le n$ it holds that $x_i = x_{i - 1} + x_{i - 2} + \dots + x_1 + r_i$ for some positive integer $r_i$ satisfying $1 \le r_i \le m$. You will be given $q$ queries consi...
import sys from itertools import count def debug(*args, **kwargs): import sys def solve(a, b, m): if a == b: return [a] debug(a=a, b=b, m=m) for k in count(2): lo = 2 ** (k - 2) * a + 2 ** (k - 2) hi = 2 ** (k - 2) * a + 2 ** (k - 2) * m debug(k=k, lo=lo, hi=hi) ...
IMPORT FUNC_DEF IMPORT FUNC_DEF IF VAR VAR RETURN LIST VAR EXPR FUNC_CALL VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER VAR EXPR...
Given a positive integer $m$, we say that a sequence $x_1, x_2, \dots, x_n$ of positive integers is $m$-cute if for every index $i$ such that $2 \le i \le n$ it holds that $x_i = x_{i - 1} + x_{i - 2} + \dots + x_1 + r_i$ for some positive integer $r_i$ satisfying $1 \le r_i \le m$. You will be given $q$ queries consi...
def find_k(A, B, M): for k in range(2, 51): s = 2 ** (k - 2) if (A + 1) * s <= B and (A + M) * s >= B: return k return -1 def solve(A, B, M): if A == B: print("1", A) return k = find_k(A, B, M) if k == -1: print(-1) return print(k, en...
FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR RETURN VAR RETURN NUMBER FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR STRING VAR RETURN ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN ...
Given a positive integer $m$, we say that a sequence $x_1, x_2, \dots, x_n$ of positive integers is $m$-cute if for every index $i$ such that $2 \le i \le n$ it holds that $x_i = x_{i - 1} + x_{i - 2} + \dots + x_1 + r_i$ for some positive integer $r_i$ satisfying $1 \le r_i \le m$. You will be given $q$ queries consi...
for _ in range(int(input())): a, b, m = map(int, input().split()) if a == b: print(1, a) continue for k in range(2, 51): pw = 1 << k - 2 mn = pw * (a + 1) mx = pw * (a + m) if mn <= b <= mx: r = [0] * (k + 1) add = b - mn r[...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR IF VAR VAR V...
Given a positive integer $m$, we say that a sequence $x_1, x_2, \dots, x_n$ of positive integers is $m$-cute if for every index $i$ such that $2 \le i \le n$ it holds that $x_i = x_{i - 1} + x_{i - 2} + \dots + x_1 + r_i$ for some positive integer $r_i$ satisfying $1 \le r_i \le m$. You will be given $q$ queries consi...
q = int(input()) for i in range(q): a, b, m = list(map(int, input().split())) l = a + 1 r = a + m c = 0 poziom = 0 if a == b: print(1, a, end="\n") continue while True: if l > b: print(-1) break if b <= r and b >= l: c = 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER VAR STRING WHILE NUMBER IF VAR VAR EXPR FUNC_CALL VA...
Given a positive integer $m$, we say that a sequence $x_1, x_2, \dots, x_n$ of positive integers is $m$-cute if for every index $i$ such that $2 \le i \le n$ it holds that $x_i = x_{i - 1} + x_{i - 2} + \dots + x_1 + r_i$ for some positive integer $r_i$ satisfying $1 \le r_i \le m$. You will be given $q$ queries consi...
q = int(input()) def prepare_sequence(a, b, curr_two_pow, m): sequence = [a] curr_pow = 1 diff = b - curr_two_pow * a while curr_two_pow > 1: m_candidate = 1 diff -= m_candidate while diff > curr_two_pow // 2: m_candidate *= 2 diff = diff - (m_candidate ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR LIST VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR WHILE VAR NUMBER ASSIGN VAR NUMBER VAR VAR WHILE VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR AS...
Given a positive integer $m$, we say that a sequence $x_1, x_2, \dots, x_n$ of positive integers is $m$-cute if for every index $i$ such that $2 \le i \le n$ it holds that $x_i = x_{i - 1} + x_{i - 2} + \dots + x_1 + r_i$ for some positive integer $r_i$ satisfying $1 \le r_i \le m$. You will be given $q$ queries consi...
from sys import stdin, stdout for q in range(int(input())): a, b, m = map(int, input().split()) if a == b: print(1, a) continue k = 2 while k <= 50 and not (1 << k - 2) * (a + 1) <= b <= (1 << k - 2) * (a + m): k += 1 if k > 50: print(-1) continue t = b -...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER WHILE VAR NUMBER BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP VAR VAR VAR NUMBER IF VAR ...
Given a positive integer $m$, we say that a sequence $x_1, x_2, \dots, x_n$ of positive integers is $m$-cute if for every index $i$ such that $2 \le i \le n$ it holds that $x_i = x_{i - 1} + x_{i - 2} + \dots + x_1 + r_i$ for some positive integer $r_i$ satisfying $1 \le r_i \le m$. You will be given $q$ queries consi...
def creat_r(X, k, m, p): q = X // p[k] r = X % p[k] R = [] for _ in range(k + 1): R.append(q) s = bin(r)[2:] for i in range(1, len(s) + 1): if s[-i] == "1": R[-(i + 1)] += 1 return R i = 1 p = [1] for _ in range(50): i *= 2 p.append(i) T = int(input()) a...
FUNC_DEF ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER NUMBER RETURN VAR ASSIGN VAR NUMBER...
Given a positive integer $m$, we say that a sequence $x_1, x_2, \dots, x_n$ of positive integers is $m$-cute if for every index $i$ such that $2 \le i \le n$ it holds that $x_i = x_{i - 1} + x_{i - 2} + \dots + x_1 + r_i$ for some positive integer $r_i$ satisfying $1 \le r_i \le m$. You will be given $q$ queries consi...
import sys input = sys.stdin.readline q = int(input()) Q = [list(map(int, input().split())) for i in range(q)] for a, b, m in Q: MIN = [a] MAX = [a] SUMMIN = a SUMMAX = a flag = 1 for k in range(51): if MIN[-1] <= b <= MAX[-1]: break MIN.append(SUMMIN + 1) MA...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR VAR VAR VAR ASSIGN VAR LIST VAR ASSIGN VAR LIST VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR VAR NUMBER EXPR...
Given a positive integer $m$, we say that a sequence $x_1, x_2, \dots, x_n$ of positive integers is $m$-cute if for every index $i$ such that $2 \le i \le n$ it holds that $x_i = x_{i - 1} + x_{i - 2} + \dots + x_1 + r_i$ for some positive integer $r_i$ satisfying $1 \le r_i \le m$. You will be given $q$ queries consi...
q = int(input()) for _ in range(q): a, b, m = [int(x) for x in input().split()] if a == b: print("1 ", a) continue found = 0 for n in range(2, 51): lo = 2 ** (n - 2) * (a + 1) hi = 2 ** (n - 2) * (a + m) if lo <= b and b <= hi: b -= lo prin...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR STRING VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NU...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
t = int(input()) while t >= 1: t -= 1 n = int(input()) arr = [(0) for i in range(n + 2)] ind = [(True) for i in range(n + 2)] for i in range(n): l, r = map(int, input().split(" ")) arr[l] += 1 arr[r + 1] -= 1 if i + 1 >= l and i + 1 <= r: ind[i + 1] = Fals...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR 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 FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING VAR VAR NUMBER V...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
t = int(input()) def update(l, r, range_sum): if l > r: return range_sum[l] += 1 range_sum[r + 1] -= 1 while t: t -= 1 n = int(input()) range_sum = [0] * (n + 1) curr_person = 0 notthief = set() while curr_person < n: l, r = [int(x) for x in input().split(" ")] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF IF VAR VAR RETURN VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR WHILE VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CAL...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
t = int(input()) for _ in range(t): n = int(input()) a = [] for i in range(n): a.append(list(map(int, input().split()))) newa = set() j = 1 for i in a: if i[0] <= j and i[1] >= j: newa.add(j) j += 1 now = [(0) for i in range(n)] for i in a: now...
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 FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR VAR NUMBER VAR EXPR FUNC_C...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
def solve(n, qr): arr = [(0) for i in range(n + 1)] for val in qr: arr[val[0] - 1] += 1 arr[val[1]] -= 1 for i in range(1, n + 1): arr[i] += arr[i - 1] return arr def ans(arr, qr, n): te = [] for i in range(n): if qr[i][0] - 1 <= i <= qr[i][1] - 1: a...
FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR VAR VAR BIN_OP VAR NUMBER NUMBER NUMBER VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER VAR BIN_OP VAR V...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
for _ in range(int(input())): n = int(input()) freq = [(0) for i in range(n + 1)] l = n h = 0 d1 = {} for i in range(1, n + 1): a, b = map(int, input().split()) if a < l: l = a if b > h: h = b freq[a] = freq[a] + 1 if b < n: ...
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 BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VA...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
for _ in range(int(input())): n = int(input()) arr = [0] * (n + 1) d = dict() for i in range(n): l, r = map(int, input().split()) l, r = l - 1, r - 1 arr[l] += 1 arr[r + 1] -= 1 d[i] = l, r cur = arr[0] for i in range(1, n + 1): arr[i] = cur + arr[...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR VAR NUMBER VAR BIN_O...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
t = int(input()) while t > 0: n = int(input()) a = [] for i in range(n): a.append([int(i) for i in input().split()]) ls = [a[i][0] for i in range(len(a))] rs = [a[i][1] for i in range(len(a))] ls, rs = sorted(ls), sorted(rs) k = [] for i in range(1, n + 1): if i < a[i - 1...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER 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 ASSIGN VAR VAR VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VA...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
for _ in range(int(input())): n = int(input()) thief = [0] * (n + 1) lst = [] for x in range(n): x, y = map(int, input().split()) lst.append([x, y]) thief[x - 1] += 1 thief[y] -= 1 for x in range(1, n + 1): thief[x] += thief[x - 1] rslt = [] cnt = 0 ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER 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 LIST VAR VAR VAR BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER FOR VAR ...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
for _ in range(int(input())): n = int(input()) arr = [0] * (n + 1) s = set() for i in range(n): a, b = map(int, input().split()) if a <= i + 1 <= b: s.add(i + 1) arr[a - 1] += 1 arr[b] -= 1 for i in range(1, n + 1): arr[i] += arr[i - 1] ans = [...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_O...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
t = int(input()) for _ in range(t): n = int(input()) votes = [0] * (n + 1) candidates = [] for i in range(n): left, right = list(map(int, input().split())) left -= 1 right -= 1 votes[left] += 1 votes[right + 1] -= 1 if i < left or i > right: ca...
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 LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR VAR NUMBER VAR BIN_OP VAR NUM...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
for _ in range(int(input())): n = int(input()) ans = [] nums = [] people = [0] * (n + 1) for i in range(n): l, r = map(int, input().split()) nums.append([l, r]) people[l] += 1 if r < n: people[r + 1] -= 1 for i in range(2, n + 1): people[i] += ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR VAR NUMBER IF VAR VAR VAR BIN_OP...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
t = int(input()) for _ in range(t): n = int(input()) l1 = [] ans = [] for i in range(n): j, k = map(int, input().split()) l1.append([j, k]) for i in range(0, n): l, r = l1[i][0], l1[i][1] if i + 1 >= l and i + 1 <= r: continue temp = l1.copy() ...
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 LIST VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR VAR NUMBER VAR VA...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
for h in range(int(input())): n = int(input()) x = [0] * (n + 1) z = [] v = [] for i in range(n): a, b = map(int, input().split()) a, b = a - 1, b - 1 z.append([a, b]) x[a] += 1 x[b + 1] -= 1 x[-1] = 0 for i in range(n): x[i] += x[i - 1] ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VA...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
t = int(input()) while t: k = int(input()) m = [0] * (k + 2) low = [0] high = [0] r = [] for g in range(1, k + 1): i, j = map(int, input().split()) low.append(i) high.append(j) m[i] += 1 m[j + 1] -= 1 for i in range(1, k + 1): m[i] += m[i - 1] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
from itertools import groupby T = int(input()) for _ in range(T): N = int(input()) events = [] a = [] for i in range(N): L, R = list(map(int, input().split())) a.append((L, R)) events.append((L, 1)) events.append((R + 1, -1)) for i in range(1, N + 1): events....
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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR ...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
t = int(input()) for _ in range(t): n = int(input()) L = [0] * (n + 1) M = [] for i in range(n): a, b = map(int, input().split()) M.append((a, b)) for i in range(n): a, b = M[i] j = i + 1 L[a - 1] += 1 L[b] -= 1 for i in range(1, n): L[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 BIN_OP LIST NUMBER BIN_OP VAR NUMBER 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 VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR V...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
t = int(input()) for i in range(t): n = int(input()) votes = [(0) for i in range(n)] cand = [] for i in range(n): l, r = list(map(int, input().split())) l -= 1 r -= 1 votes[l] = votes[l] + 1 if r + 1 < n: votes[r + 1] = votes[r + 1] - 1 if 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 NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR NUMBER IF B...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
import sys input = sys.stdin.readline M = int(1000000000.0) + 7 def solve(): n = int(input()) lr = [[(int(x) - 1) for x in input().split()] for _ in range(n)] pre = [0] * (n + 1) for i, j in lr: pre[i] += 1 pre[j + 1] -= 1 for i in range(1, n + 1): pre[i] += pre[i - 1] ...
IMPORT ASSIGN VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR VAR VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER FOR...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
for _ in range(int(input())): n = int(input()) a = [0] * (n + 1) nth = set() for i in range(1, n + 1): l, r = map(int, input().split()) a[l - 1] += 1 a[r] -= 1 if l <= i <= r: nth.add(i) for i in range(n): a[i + 1] += a[i] th = [] for i in ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER IF VAR VAR...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
t = int(input()) for _ in range(t): n = int(input()) arr = [(0) for _ in range(n + 2)] ranges = {} for i in range(n): l, r = map(int, input().split()) arr[l] += 1 arr[r + 1] -= 1 ranges[i + 1] = [l, r] thieves = [] ans = 0 for i in range(1, n + 1): ans...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP V...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
T = int(input()) for i in range(T): N = int(input()) rlist = [] vals = [] for theta in range(N): L, R = map(int, input().split(" ")) rlist.append((L, R, theta + 1)) rlist.sort(key=lambda x: x[0]) ub = N for delta in range(N - 1): ub = min(ub, rlist[delta][1]) if r...
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 STRING EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR FOR ...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
for _ in range(int(input())): n = int(input()) a = [0] * (n + 2) s = set() for i in range(1, n + 2): a[i] = 0 if 443434 == 343434: print("Tanmay") for i in range(1, n + 1): l, r = [int(x) for x in input().split()] a[l] += 1 a[r + 1] -= 1 if i >= l ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER IF NUMBER NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
for _ in range(int(input())): n = int(input()) l = [(0) for i in range(n + 1)] q = [] for i in range(n): a, b = map(int, input().split()) q.append((a, b)) l[a - 1] += 1 l[b] -= 1 ans = [] for i in range(n): if i > 0: l[i] += l[i - 1] if...
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 BIN_OP VAR NUMBER 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 VAR VAR BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER ASSIGN ...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
t = int(input()) while t: n = int(input()) arr = [0] * (n + 1) l = [-1] * (n + 1) r = [-1] * (n + 1) for i in range(1, n + 1): li, ri = [int(x) for x in input().split()] l[i] = li r[i] = ri arr[li] += 1 if ri < n: arr[ri + 1] -= 1 for i in rang...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR 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 BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
import sys def gcd(a, b): a, b = max(a, b), min(a, b) if b == 0: return a return gcd(b, a % b) def get_ints(): return map(int, sys.stdin.readline().strip().split()) def get_list(): return list(map(int, sys.stdin.readline().strip().split())) def get_string(): return sys.stdin.read...
IMPORT FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
def update(D, l, r, x): D[l] += x D[r + 1] -= x t = int(input()) for tt in range(t): n = int(input()) a = [list(map(int, input().split())) for i in range(n)] a1 = [0] * (n + 1) for r in a: update(a1, r[0] - 1, r[1] - 1, 1) ans = 0 aa = [] for j in range(1, n): a1[j]...
FUNC_DEF VAR VAR VAR VAR BIN_OP VAR NUMBER 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 VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR EXPR FUNC_CALL VAR V...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
for i in range(int(input())): a = int(input()) l = [] for i in range(a): l.append(list(map(int, input().split(" ")))) r = [0] * (a + 2) choose = [] for i in range(a): if i + 1 < l[i][0] or i + 1 > l[i][1]: choose.append(i + 1) for i in range(a): r[l[i][0] ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL 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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUM...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
for _ in range(int(input())): n = int(input()) a = [] b = [] c = [] for j in range(n + 1): a.append(0) for i in range(n): j, k = map(int, input().split()) j -= 1 k -= 1 a[j] += 1 a[k + 1] -= 1 if i < j or i > k: b.append(1) ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR VAR NUMB...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
def fun(l, r, out, x, y, i): if x > r or y < l: if i >= l and i <= r: out.append(i) return if l < x: if i >= l and i < x: out.append(i) return if y < r: if i > y and i <= r: out.append(i) return for t in range(int(input())...
FUNC_DEF IF VAR VAR VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR RETURN IF VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR RETURN IF VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR RETURN 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...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
def mi(): return map(int, input().split()) def li(): return list(mi()) def si(): return str(input()) def ni(): return int(input()) for T in range(int(input())): n = ni() final = [0] * (n + 1) potential = [] for i in range(n): l, r = mi() if not (l <= i + 1 and r >...
FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN ...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
import sys input = lambda: sys.stdin.readline() T = int(input()) for _ in range(T): n = int(input().strip()) L = [(0) for i in range(n + 2)] dic = {} for i in range(n): l, r = map(int, input().strip().split()) dic[i] = [l, r] L[l] += 1 L[r + 1] -= 1 count = 0 ans...
IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR ...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
def craet(n): arr = [] for i in range(n): arr.append(list(map(int, input().split()))) x = {} for i in arr: a = i[0] b = i[1] if a not in x: x[a] = [0, 0] if b not in x: x[b] = [0, 0] x[a][0] += 1 x[b][1] += 1 count = {} ...
FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR LIST NUMBER NUMBER IF VAR VAR ASSIGN VAR VAR LIST NUMBER NUMBER VAR VAR NUMBER NUMBER VAR VAR NU...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
t = int(input()) while t > 0: t -= 1 n = int(input()) arr = [(0) for _ in range(n + 1)] temp = [] for _ in range(n): l, r = list(map(int, input().split())) l -= 1 arr[l] += 1 arr[r] -= 1 temp.append([l, r - 1]) for i in range(1, n + 1): arr[i] += a...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER EXPR F...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
from itertools import accumulate as acc def miis(): return map(int, input().split()) for _ in range(int(input())): n = int(input()) a = list(list(miis()) for i in range(n)) pref = [(0) for i in range(n + 1)] for i in a: l, r = i pref[l - 1] += 1 pref[r] -= 1 ac = list...
FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL 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 FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR VAR ASSIGN VAR VAR VAR VAR BIN_OP VA...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
for _ in range(int(input())): n = int(input()) diff = [(0) for i in range(n + 1)] ranges = [] for i in range(n): u, v = [(int(x) - 1) for x in input().split()] ranges.append([u, v]) diff[u] += 1 diff[v + 1] -= 1 thieves = [] for i in range(1, n + 1): diff[...
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 BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR VAR NUMBER VAR BIN_OP VA...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
t = int(input()) while t > 0: t -= 1 n = int(input()) suspicion = [0] * n interogations = [] for i in range(n): x, y = [int(x) for x in input().split()] interogations.append((x - 1, y - 1)) x -= 1 suspicion[x] += 1 if y < n: suspicion[y] -= 1 c...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER VAR VAR NUM...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
def initializeDiffArray(A): n = len(A) D = [(0) for i in range(0, n + 1)] D[0] = A[0] D[n] = 0 for i in range(1, n): D[i] = A[i] - A[i - 1] return D def update(D, l, r, x): D[l] += x D[r + 1] -= x def printArray(A, D): arr = [] for i in range(0, len(A)): if i ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF VAR VAR VAR VAR BIN_OP VAR NUMBER VAR FUNC_DEF ASSIGN VAR LIST FO...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
t = int(input()) while t > 0: n = int(input()) arr = [(0) for _ in range(n + 2)] ma = {} for i in range(1, n + 1): [l, r] = [int(x) for x in input().split()] arr[l] += 1 arr[r + 1] -= 1 if i >= l and i <= r: ma[i] = True ct = 0 for i in range(1, n + 1)...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN LIST VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBE...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
def solve(intervals): start, end = intervals.pop() ans = [[start, end]] while intervals: start_temp, end_temp = intervals.pop() start = max(start, start_temp) end = min(end, end_temp) ans.append([start, end]) return ans t = int(input()) for i in range(t): N = int(in...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR LIST LIST VAR VAR WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR A...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
t = int(input()) for i in range(0, t): n = int(input()) d = {} for j in range(0, n + 1): d[j] = 0 s = set() for j in range(0, n): a, b = map(int, input().split(" ")) if a <= j + 1 <= b: s.add(j + 1) d[a - 1] += 1 d[b] -= 1 ans = [] for j in...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
def segf(arr, n): temp = [(0) for i in range(n + 1)] for lst in arr: l = lst[0] r = lst[1] temp[l - 1] += 1 temp[r] -= 1 for i in range(1, n + 1): temp[i] += temp[i - 1] count = 0 ans = [] for i in range(1, n + 1): lst = arr[i - 1] if (i < ...
FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
t = int(input()) for x in range(t): n = int(input()) queries = [] a = [(0) for _ in range(n + 2)] for i in range(n): l, r = map(int, input().split()) queries.append((l, r)) a[l] += 1 a[r + 1] -= 1 for i in range(1, n + 1): a[i] += a[i - 1] st = set() f...
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 NUMBER VAR FUNC_CALL VAR BIN_OP 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 VAR VAR VAR NUMBER VAR BIN_OP VAR NUMBER...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
for _ in range(int(input())): n = int(input()) l = [] call = [] mark = [0] mp = {} for i in range(1, n + 1): l.append(i) mp[i] = 0 mark.append(0) for i in range(n): a, b = map(int, input().split()) mark[a - 1] += 1 mark[b] -= 1 if i + 1...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR F...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
def main(): n = int(input()) prefix = [0] * (n + 10) notThief = set() for i in range(1, n + 1): l, r = map(int, input().split()) if i >= l and i <= r: notThief.add(i) prefix[l] += 1 prefix[r + 1] -= 1 arr = [] curr = 0 for i in range(1, n + 1): ...
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 FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VA...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
for _ in range(int(input())): n = int(input()) arr = [] for i in range(n): arr.append(list(map(int, input().split()))) suff = [[0, 0]] * n a, b = 1, n for i in range(n - 1, -1, -1): a, b = max(a, arr[i][0]), min(b, arr[i][1]) if a <= b: suff[i] = [a, b] su...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL 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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST LIST NUMBER NUMBER VAR ASSIGN VAR VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NU...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
for _ in range(int(input())): n = int(input()) arr, ll, rl, lr = ( [i for i in range(1, n + 1)], [(0) for i in range(n)], [(0) for i in range(n)], [], ) for i in range(n): l, r = map(int, input().split()) lr.append([l, r]) ll[l - 1] += 1 rl...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL ...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
import sys def _input(): return sys.stdin.readline().strip() def main(): for _ in range(int(_input())): n = int(_input()) l = [None] for i in range(n): x = tuple(map(int, _input().split())) l.append(x) ans = [] for i in range(1, n + 1): ...
IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NONE FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR ...
There are N people numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest and always tell the truth. If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cdots, R_{i}, determine how many people could be the thief. It is g...
for _ in range(int(input())): n = int(input()) arr = [0] * (n + 1) mapp = {} for i in range(n): s, e = map(int, input().split()) mapp[i] = s - 1, e - 1 arr[s - 1] += 1 arr[e] -= 1 s, e = mapp[0] ans = [1] if arr[0] == n - 1 and not s <= 0 <= e else [] for i in...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR ...
Firdavs is living on planet F. There are $N$ cities (numbered $1$ through $N$) on this planet; let's denote the value of city $i$ by $v_i$. Firdavs can travel directly from each city to any other city. When he travels directly from city $x$ to city $y$, he needs to pay $f(x, y) = |v_y-v_x|+y-x$ coins (this number can b...
T = int(input()) for i in range(0, T): N, Q = map(int, input().split()) s = [int(x) for x in input().split()] L = sorted(s) G = L[::-1] for j in range(0, Q): x, y = map(int, input().split()) ans1 = abs(s[y - 1] - s[x - 1]) + y - x print(ans1, end=" ") pos1 = 0 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER 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 ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CA...
Firdavs is living on planet F. There are $N$ cities (numbered $1$ through $N$) on this planet; let's denote the value of city $i$ by $v_i$. Firdavs can travel directly from each city to any other city. When he travels directly from city $x$ to city $y$, he needs to pay $f(x, y) = |v_y-v_x|+y-x$ coins (this number can b...
t = int(input()) for _ in range(t): n, q = list(map(int, input().split())) v = list(map(int, input().split())) vv = v[:] vv = [[j, i] for j, i in enumerate(v)] vv.sort(key=lambda x: x[1]) vvv = [] for jj, i in enumerate(vv): v[i[0]] = [jj, i[1]] for i in range(q): x, y = ...
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 VAR ASSIGN VAR LIST VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VA...
Firdavs is living on planet F. There are $N$ cities (numbered $1$ through $N$) on this planet; let's denote the value of city $i$ by $v_i$. Firdavs can travel directly from each city to any other city. When he travels directly from city $x$ to city $y$, he needs to pay $f(x, y) = |v_y-v_x|+y-x$ coins (this number can b...
def query(x1, y1, d): x, y = x1, y1 if d[y1][3] < d[x1][3]: x, y = y1, x1 summ = y1 - x1 + abs(d[y][0] - d[x][0]) mlen = d[y][2] - d[x][1] + 1 return summ, mlen INF = 10**10 t = int(input()) for tt in range(t): n, q = [int(x) for x in input().split()] v = [int(x) for x in input().s...
FUNC_DEF ASSIGN VAR VAR VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR NUMBER NUMBER RETURN VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ...
Firdavs is living on planet F. There are $N$ cities (numbered $1$ through $N$) on this planet; let's denote the value of city $i$ by $v_i$. Firdavs can travel directly from each city to any other city. When he travels directly from city $x$ to city $y$, he needs to pay $f(x, y) = |v_y-v_x|+y-x$ coins (this number can b...
t = int(input()) for i in range(t): n, q = input().split() cities = [int(x) for x in input().split()] cities_sort = cities.copy() cities_sort.sort() for j in range(int(q)): q1, q2 = [int(x) for x in input().split()] a = cities[q1 - 1] b = cities[q2 - 1] if a > b: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR...
Firdavs is living on planet F. There are $N$ cities (numbered $1$ through $N$) on this planet; let's denote the value of city $i$ by $v_i$. Firdavs can travel directly from each city to any other city. When he travels directly from city $x$ to city $y$, he needs to pay $f(x, y) = |v_y-v_x|+y-x$ coins (this number can b...
def bs(arr, l, r, x, g): while l <= r: mid = l + (r - l) // 2 if arr[mid] == x: if not g: mid -= 1 while mid >= 0 and arr[mid] == x: mid -= 1 return mid + 1 else: mid += 1 whil...
FUNC_DEF WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR IF VAR VAR NUMBER WHILE VAR NUMBER VAR VAR VAR VAR NUMBER RETURN BIN_OP VAR NUMBER VAR NUMBER WHILE VAR VAR VAR VAR VAR VAR NUMBER RETURN BIN_OP VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RE...
Firdavs is living on planet F. There are $N$ cities (numbered $1$ through $N$) on this planet; let's denote the value of city $i$ by $v_i$. Firdavs can travel directly from each city to any other city. When he travels directly from city $x$ to city $y$, he needs to pay $f(x, y) = |v_y-v_x|+y-x$ coins (this number can b...
for _ in range(int(input())): n, q = [int(a) for a in input().split()] v = list(map(int, input().split())) s = list(range(1, n + 1)) index_s = [x for _, x in sorted(zip(v, s))] sorted_v = sorted(v) for i in range(q): x, y = [int(a) for a in input().split()] check1 = min(x, y) ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CAL...
Firdavs is living on planet F. There are $N$ cities (numbered $1$ through $N$) on this planet; let's denote the value of city $i$ by $v_i$. Firdavs can travel directly from each city to any other city. When he travels directly from city $x$ to city $y$, he needs to pay $f(x, y) = |v_y-v_x|+y-x$ coins (this number can b...
t = int(input()) for i in range(t): n, q = list(map(int, input().split())) cities = list(map(int, input().split())) for j in range(int(q)): q1, q2 = list(map(int, input().split())) a = cities[q1 - 1] b = cities[q2 - 1] if a > b: c = a a = b ...
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 FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN...
Recently, Valery have come across an entirely new programming language. Most of all the language attracted him with template functions and procedures. Let us remind you that templates are tools of a language, designed to encode generic algorithms, without reference to some parameters (e.g., data types, buffer sizes, de...
I = input R = str.replace P = range D = lambda: P(int(I())) T = {} d = {} def rf(s): print(s.split()) for _ in D(): s = R(R(I(), "void", ""), " ", "") t = s.find("(") k = s[:t] d[k] = d.get(k, []) + [s[t + 1 : -1].split(",")] for _ in D(): a, b = I().split() T[b] = a for _ in D(): s ...
ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR STRING STRING STRING STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VA...
Recently, Valery have come across an entirely new programming language. Most of all the language attracted him with template functions and procedures. Let us remind you that templates are tools of a language, designed to encode generic algorithms, without reference to some parameters (e.g., data types, buffer sizes, de...
func = int(input()) fnames = [] fargs = [] for i in range(func): s = input().strip()[:-1].split("(") fnames.append(s[0].split()[1]) arr = [j.strip() for j in s[1].split(",")] fargs.append(arr) something = [] types = [] t = int(input()) for i in range(t): s = input().split() types.append(s[0]) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIG...
Recently, Valery have come across an entirely new programming language. Most of all the language attracted him with template functions and procedures. Let us remind you that templates are tools of a language, designed to encode generic algorithms, without reference to some parameters (e.g., data types, buffer sizes, de...
n = int(input()) funcnames = [] funcs = [] for i in range(n): x = input() funcnames.append(list(list(x.split("("))[0].split())[1].strip()) x = list(x.split("("))[1].strip()[:-1] x = list(map(str.strip, list(x.split(",")))) funcs.append(x) k = int(input()) types = {} for i in range(k): x = list(i...
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 EXPR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR STRING NUMBER NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR STRING NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR F...
Recently, Valery have come across an entirely new programming language. Most of all the language attracted him with template functions and procedures. Let us remind you that templates are tools of a language, designed to encode generic algorithms, without reference to some parameters (e.g., data types, buffer sizes, de...
n = int(input()) v = dict() f, f1 = [], [] for i in range(n): t = input() t1 = "" k = t.find("d") + 1 while t[k] == " ": k += 1 t = t[k:] for i in t: if i != " ": t1 += i t = t1 t = t.split(",") t[-1] = t[-1][: str(t[-1]).find(")")] r1, r2 = t[0].split...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR STRING NUMBER WHILE VAR VAR STRING VAR NUMBER ASSIGN VAR VAR VAR FOR VAR VAR IF VAR STRING VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_...
Recently, Valery have come across an entirely new programming language. Most of all the language attracted him with template functions and procedures. Let us remind you that templates are tools of a language, designed to encode generic algorithms, without reference to some parameters (e.g., data types, buffer sizes, de...
n = int(input()) fu = [ input().replace(" ", "")[4:].replace("(", ",").replace(")", "").split(",") for i in range(n) ] m = int(input()) v = [input().strip().split() for i in range(m)] vd = {l[1]: l[0] for l in v} k = int(input()) c = [ input().strip().replace(" ", "").replace("(", ",").replace(")", "").spli...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING STRING NUMBER STRING STRING STRING STRING STRING VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER VAR NUMBER...
Recently, Valery have come across an entirely new programming language. Most of all the language attracted him with template functions and procedures. Let us remind you that templates are tools of a language, designed to encode generic algorithms, without reference to some parameters (e.g., data types, buffer sizes, de...
n = int(input()) funcs = [input().replace(" ", "")[4:] for i in range(n)] funcs2 = [f.replace("(", ",").replace(")", "").split(",") for f in funcs] m = int(input()) vars = [input().strip().split() for i in range(m)] vard = {l[1]: l[0] for l in vars} k = int(input()) calls = [input().strip().replace(" ", "") for i in ra...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING STRING NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING STRING STRING STRING STRING VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VA...
Sereja loves number sequences very much. That's why he decided to make himself a new one following a certain algorithm. Sereja takes a blank piece of paper. Then he starts writing out the sequence in m stages. Each time he either adds a new number to the end of the sequence or takes l first elements of the current seq...
MAX_LEN = int(100000.0) n = int(input()) a = [list(map(int, input().split())) for i in range(n)] m = int(input()) b = list(map(lambda x: int(x) - 1, input().split())) curr, k, c, res = 0, 0, [], [] for i in range(n): t = a[i] last = curr if t[0] == 1: curr += 1 if len(c) < MAX_LEN: ...
ASSIGN VAR FUNC_CALL VAR NUMBER 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 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 VAR VAR VAR NUM...
A monster is attacking the Cyberland! Master Yang, a braver, is going to beat the monster. Yang and the monster each have 3 attributes: hitpoints (HP), offensive power (ATK) and defensive power (DEF). During the battle, every second the monster's HP decrease by max(0, ATKY - DEFM), while Yang's HP decreases by max(0,...
R = lambda: map(int, input().split()) yH, yA, yD = R() mH, mA, mD = R() h, a, d = R() Q = 10**20 for A in range(max(0, mD - yA + 1), max(0, mH + mD - yA) + 1): for D in range(max(0, mA - yD) + 1): H = yH - (mH + yA + A - mD - 1) // (yA + A - mD) * max(0, mA - yD - D) Q = min(A * a + D * d + max(0, h...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER BIN_OP FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR VAR NUMBER FOR...
A monster is attacking the Cyberland! Master Yang, a braver, is going to beat the monster. Yang and the monster each have 3 attributes: hitpoints (HP), offensive power (ATK) and defensive power (DEF). During the battle, every second the monster's HP decrease by max(0, ATKY - DEFM), while Yang's HP decreases by max(0,...
hp_y, at_y, df_y = map(int, input().split()) hp_m, at_m, df_m = map(int, input().split()) cst_hp, cst_at, cst_df = map(int, input().split()) ans = 2e18 for ati in range(201): for dfi in range(201): if ati + at_y > df_m: k = hp_m // (at_y + ati - df_m) if hp_m % (at_y + ati - df_m) !=...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR...
A monster is attacking the Cyberland! Master Yang, a braver, is going to beat the monster. Yang and the monster each have 3 attributes: hitpoints (HP), offensive power (ATK) and defensive power (DEF). During the battle, every second the monster's HP decrease by max(0, ATKY - DEFM), while Yang's HP decreases by max(0,...
H_y, A_y, D_y = map(int, input().split()) H_m, A_m, D_m = map(int, input().split()) h, a, d = map(int, input().split()) ans = 10**20 for A_buy in range(max(0, H_m + D_m - A_y) + 1): for D_buy in range(max(0, A_m - D_y) + 1): damage = A_y + A_buy - D_m cost = A_buy * a + D_buy * d if damage >...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR ...
There are N hidden integer arrays of length N each. You are given the mex of each of these N arrays. Ashish likes lower bounds and Kryptonix likes upper bounds. So, for each 0 ≤ i ≤ N-1, find: The least possible number of occurrences of i across all the arrays The most possible number of occurrences of i across all th...
t = int(input()) for i in range(0, t): n = int(input()) a = list(map(int, input().split())) d = dict() maxans1 = [0] * (n + 1) maxans2 = [0] * (n + 1) minans = [0] * (n + 1) for j in range(0, len(a)): if a[j] not in d.keys(): d[a[j]] = 1 else: d[a[j]] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR 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 BIN_OP LIS...
There are N hidden integer arrays of length N each. You are given the mex of each of these N arrays. Ashish likes lower bounds and Kryptonix likes upper bounds. So, for each 0 ≤ i ≤ N-1, find: The least possible number of occurrences of i across all the arrays The most possible number of occurrences of i across all th...
def update(D, l, r, x): D[l] += x D[r + 1] -= x t = int(input()) for tt in range(t): n = int(input()) a = list(map(int, input().split())) a1 = [0] * (n + 1) a2 = [0] * (n + 1) for r in range(n): if a[r] >= 1 and a[r] < n: update(a1, a[r] + 1, n - 1, n - a[r]) ...
FUNC_DEF VAR VAR VAR VAR BIN_OP VAR NUMBER 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 FOR VA...
There are N hidden integer arrays of length N each. You are given the mex of each of these N arrays. Ashish likes lower bounds and Kryptonix likes upper bounds. So, for each 0 ≤ i ≤ N-1, find: The least possible number of occurrences of i across all the arrays The most possible number of occurrences of i across all th...
t = int(input()) for _ in range(t): n = int(input()) arr = [int(i) for i in input().split()] mini, maxl, maxr = [0] * (n + 1), [0] * (n + 1), [0] * (n + 1) for i in range(n): k = arr[i] mini[0] += 1 mini[k] -= 1 maxl[0] += n - k + 1 maxl[k] -= n - k + 1 ma...
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 VAR VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASS...
There are N hidden integer arrays of length N each. You are given the mex of each of these N arrays. Ashish likes lower bounds and Kryptonix likes upper bounds. So, for each 0 ≤ i ≤ N-1, find: The least possible number of occurrences of i across all the arrays The most possible number of occurrences of i across all th...
for _ in range(int(input())): n = int(input()) x = [int(x) for x in input().split()] mn = [0] * (n + 1) mx = [0] * (n + 1) mr = [0] * (n + 1) for i in range(n): mn[0] += 1 mn[x[i]] -= 1 mx[0] += n - x[i] + 1 mx[x[i]] -= n - x[i] + 1 mr[n - 1] += n - x[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 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 BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR ...
There are N hidden integer arrays of length N each. You are given the mex of each of these N arrays. Ashish likes lower bounds and Kryptonix likes upper bounds. So, for each 0 ≤ i ≤ N-1, find: The least possible number of occurrences of i across all the arrays The most possible number of occurrences of i across all th...
n = int(input()) for w in range(n): n = int(input()) li = list(map(int, input().split(" "))) minn = [(0) for i in range(n + 1)] maxx = [(0) for i in range(n + 1)] maxxr = [(0) for i in range(n + 1)] for i in range(n): minn[0] += 1 minn[li[i]] -= 1 maxx[0] += n - li[i] + 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 STRING 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 VA...
There are N hidden integer arrays of length N each. You are given the mex of each of these N arrays. Ashish likes lower bounds and Kryptonix likes upper bounds. So, for each 0 ≤ i ≤ N-1, find: The least possible number of occurrences of i across all the arrays The most possible number of occurrences of i across all th...
for t in range(int(input())): n = int(input()) mex = list(map(int, input().strip().split())) mex.sort() freq = [(0) for i in range(n + 1)] atl = [] atm = [] extra = 0 for m in mex: freq[m] += 1 extra += n - m j = 0 for i in range(n): j += freq[i] a...
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 FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR VAR VAR NUMBER VAR ...
There are N hidden integer arrays of length N each. You are given the mex of each of these N arrays. Ashish likes lower bounds and Kryptonix likes upper bounds. So, for each 0 ≤ i ≤ N-1, find: The least possible number of occurrences of i across all the arrays The most possible number of occurrences of i across all th...
for _ in range(int(input())): n = int(input()) a = [*map(int, input().split())] q = [0] * (n + 1) r = 0 w = [0] * (n + 1) for i in range(n): q[a[i]] += 1 w[a[i]] += n - a[i] r = sum(w) for i in range(n): q[n - 1 - i] += q[n - i] for i in range(n): prin...
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 LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER VAR VAR VAR BI...
There are N hidden integer arrays of length N each. You are given the mex of each of these N arrays. Ashish likes lower bounds and Kryptonix likes upper bounds. So, for each 0 ≤ i ≤ N-1, find: The least possible number of occurrences of i across all the arrays The most possible number of occurrences of i across all th...
def func(): inp1 = int(input()) let_dp = [0] * (inp1 + 5) let_dp1 = [0] * (inp1 + 5) count = 0 list_ = list(map(int, input().split())) for i in list_: var_b = inp1 - i let_dp[i] += 1 let_dp1[i] += var_b count += var_b var_c = let_dp for i in reversed(range...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR 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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR NUMBER VAR VAR VAR VAR VAR ASSIGN VAR VAR FOR...
There are N hidden integer arrays of length N each. You are given the mex of each of these N arrays. Ashish likes lower bounds and Kryptonix likes upper bounds. So, for each 0 ≤ i ≤ N-1, find: The least possible number of occurrences of i across all the arrays The most possible number of occurrences of i across all th...
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) reqd = [0] * (n + 1) bad = [0] * (n + 1) extra = 0 for x in a: if x > 0: reqd[x - 1] += 1 bad[x] += n - x extra += n - x for i in range(n): reqd[n - i - 1] += reqd[n...
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 BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR BIN_OP VAR NUMBER NU...
There are N hidden integer arrays of length N each. You are given the mex of each of these N arrays. Ashish likes lower bounds and Kryptonix likes upper bounds. So, for each 0 ≤ i ≤ N-1, find: The least possible number of occurrences of i across all the arrays The most possible number of occurrences of i across all th...
for _ in range(int(input())): n = int(input()) arr = list(map(int, input().split())) res = 0 arr1, arr2 = [0] * (n + 9), [0] * (n + 9) for i in range(n): temp = n - arr[i] arr1[arr[i]] += 1 arr2[arr[i]] += temp res += temp arr3 = arr1.copy() for i in range(n, ...
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 VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR V...
There are N hidden integer arrays of length N each. You are given the mex of each of these N arrays. Ashish likes lower bounds and Kryptonix likes upper bounds. So, for each 0 ≤ i ≤ N-1, find: The least possible number of occurrences of i across all the arrays The most possible number of occurrences of i across all th...
t = int(input()) while t: k = int(input()) j = 0 l = list(map(int, input().split())) m, p, q = [0] * (k + 1), [0] * (k + 1), [0] * (k + 1) while j < k: m[0] = m[0] + 1 m[l[j]] = m[l[j]] - 1 p[0] = p[0] + (k - l[j] + 1) p[l[j]] = p[l[j]] - (k - l[j] + 1) q[k - ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER WHILE VAR VAR ASS...
There are N hidden integer arrays of length N each. You are given the mex of each of these N arrays. Ashish likes lower bounds and Kryptonix likes upper bounds. So, for each 0 ≤ i ≤ N-1, find: The least possible number of occurrences of i across all the arrays The most possible number of occurrences of i across all th...
for _ in range(int(input())): n = int(input()) s = [int(x) for x in input().split()] mi = [(0) for i in range(n + 2)] ma = [(0) for i in range(n + 2)] for i in range(n): mi[0] += 1 mi[s[i]] -= 1 ma[0] += n - s[i] + 1 ma[s[i]] -= n - s[i] + 1 ma[s[i] + 1] += n ...
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 VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER VAR VAR VAR NUMBER VAR...
There are N hidden integer arrays of length N each. You are given the mex of each of these N arrays. Ashish likes lower bounds and Kryptonix likes upper bounds. So, for each 0 ≤ i ≤ N-1, find: The least possible number of occurrences of i across all the arrays The most possible number of occurrences of i across all th...
t = int(input()) for _ in range(t): n = int(input()) arr = list(map(int, input().split())) atleast = [(0) for i in range(n)] atmost = [(0) for i in range(n)] d = {} for ele in arr: d[ele] = d.get(ele, 0) + 1 atleast[0] = n - d.get(0, 0) for i in range(1, n): atleast[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 NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR N...
There are N hidden integer arrays of length N each. You are given the mex of each of these N arrays. Ashish likes lower bounds and Kryptonix likes upper bounds. So, for each 0 ≤ i ≤ N-1, find: The least possible number of occurrences of i across all the arrays The most possible number of occurrences of i across all th...
t = int(input()) for k in range(t): n = int(input()) mex = input().split(" ") for i in range(n): mex[i] = int(mex[i]) mex.sort() pref_l = [mex[0]] cur_l = mex[0] pref_r = [mex[len(mex) - 1]] * n cur_r = mex[len(mex) - 1] for i in range(1, len(mex)): cur_l += mex[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 FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP LIST VAR BIN_OP FUNC_CALL...
There are N hidden integer arrays of length N each. You are given the mex of each of these N arrays. Ashish likes lower bounds and Kryptonix likes upper bounds. So, for each 0 ≤ i ≤ N-1, find: The least possible number of occurrences of i across all the arrays The most possible number of occurrences of i across all th...
t = int(input()) for i in range(t): N = int(input()) k1 = list(map(int, input().split())) LPB = [0] * (N + 5) UPB = [0] * (N + 5) value = 0 for i in range(N): b = N - k1[i] LPB[k1[i]] += 1 UPB[k1[i]] += b value += b short = LPB for i in range(N, -1, -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 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 ASSIGN VA...
There are N hidden integer arrays of length N each. You are given the mex of each of these N arrays. Ashish likes lower bounds and Kryptonix likes upper bounds. So, for each 0 ≤ i ≤ N-1, find: The least possible number of occurrences of i across all the arrays The most possible number of occurrences of i across all th...
t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split())) vals = {} for x in a: if x in vals: vals[x] += 1 else: vals[x] = 1 tot = sum(a) lessValues = 0 for i in range(n): if i not in vals: mini = 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 VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ...
There are N hidden integer arrays of length N each. You are given the mex of each of these N arrays. Ashish likes lower bounds and Kryptonix likes upper bounds. So, for each 0 ≤ i ≤ N-1, find: The least possible number of occurrences of i across all the arrays The most possible number of occurrences of i across all th...
t = int(input()) while t > 0: n = int(input()) a = [int(x) for x in input().split()] blanks = sum([(n - i) for i in a]) countI = [(0) for i in range(n + 1)] minR = [(0) for i in range(n)] for i in range(n): countI[a[i]] += 1 r = 0 for i in range(n, 0, -1): r += countI[i] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER 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 BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ...
There are N hidden integer arrays of length N each. You are given the mex of each of these N arrays. Ashish likes lower bounds and Kryptonix likes upper bounds. So, for each 0 ≤ i ≤ N-1, find: The least possible number of occurrences of i across all the arrays The most possible number of occurrences of i across all th...
for _ in range(int(input())): n = int(input()) temp1 = [0] * (n + 5) temp2 = [0] * (n + 5) l = list(map(int, input().split())) for i in range(n): temp1[l[i]] += 1 temp2[l[i]] += n - l[i] for i in range(n, -1, -1): temp1[i] += temp1[i + 1] ans = n * n - sum(l) for ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR 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 FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER VAR VAR VAR BIN_OP VAR ...