description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$. Vasya studies the properties of ...
t = int(input()) for i in range(t): n = int(input()) c = 0 f = int((2 * n - 1) ** 0.5) g = 3 while g <= f: if g % 2 == 1: c += 1 g += 1 print(c)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$. Vasya studies the properties of ...
def solve(): n = int(input()) l, r = 0, int(1000000000.0) while r - l > 1: m = (r + l) // 2 if m * m <= (n - 1) * 2 + 1: l = m else: r = m print((l - 1) // 2) return ans = 0 for a in range(3, 64000, 2): qa = a * a if qa & 1 == 0...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER FUNC_CALL VAR NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER RETURN ASSIGN VA...
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$. Vasya studies the properties of ...
def check(num): if (num**2 + 1) // 2 <= n: return True return False for nt in range(int(input())): n = int(input()) low = 1 high = n while low < high: mid = (low + high) // 2 if not mid % 2: mid += 1 if check(mid): low = mid + 1 e...
FUNC_DEF IF BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER VAR RETURN NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR NUMBER VAR NUMBER IF FUNC_CALL VAR VAR A...
Given a number n. The task is to find the smallest number whose factorial contains at least n trailing zeroes. Example 1: Input: n = 1 Output: 5 Explanation : 5! = 120 which has at least 1 trailing 0. Example 2: Input: n = 6 Output: 25 Explanation : 25! has at least 6 trailing 0. User Task: Complete the function findNu...
class Solution: def findNum(self, n: int): lo, hi = 0, n * 5 ans = lo while lo <= hi: mid = lo + (hi - lo) // 2 if self.findTrailingZeros(mid) >= n: ans = mid hi = mid - 1 else: lo = mid + 1 return a...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_O...
Given a number n. The task is to find the smallest number whose factorial contains at least n trailing zeroes. Example 1: Input: n = 1 Output: 5 Explanation : 5! = 120 which has at least 1 trailing 0. Example 2: Input: n = 6 Output: 25 Explanation : 25! has at least 6 trailing 0. User Task: Complete the function findNu...
class Solution: def zeros(self, num): count = 0 while num: num //= 5 count += num return count def findNum(self, n: int): if n == 0: return 0 l, r = 5, 5 * n while l < r: mid = (l + r) // 2 if self.zero...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR NUMBER VAR VAR RETURN VAR FUNC_DEF VAR IF VAR NUMBER RETURN NUMBER ASSIGN VAR VAR NUMBER BIN_OP NUMBER VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR
Given a number n. The task is to find the smallest number whose factorial contains at least n trailing zeroes. Example 1: Input: n = 1 Output: 5 Explanation : 5! = 120 which has at least 1 trailing 0. Example 2: Input: n = 6 Output: 25 Explanation : 25! has at least 6 trailing 0. User Task: Complete the function findNu...
class Solution: def count(self, n): ans = 0 ch = 5 while n >= ch: ans += n // ch ch *= 5 return ans def findNum(self, n: int): l = 1 while self.count(l) < n: l *= 5 l, r = l // 5, l res = r while l <= r...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP VAR VAR VAR NUMBER RETURN VAR FUNC_DEF VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR ASSIGN VA...
Given a number n. The task is to find the smallest number whose factorial contains at least n trailing zeroes. Example 1: Input: n = 1 Output: 5 Explanation : 5! = 120 which has at least 1 trailing 0. Example 2: Input: n = 6 Output: 25 Explanation : 25! has at least 6 trailing 0. User Task: Complete the function findNu...
class Solution: def cfive(self, m): c = 0 while m: c += m // 5 m = m // 5 return c def findNum(self, n: int): s = 1 e = 5 * n while s <= e: m = (s + e) // 2 nfive = self.cfive(m) if nfive >= n: ...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR AS...
Given a number n. The task is to find the smallest number whose factorial contains at least n trailing zeroes. Example 1: Input: n = 1 Output: 5 Explanation : 5! = 120 which has at least 1 trailing 0. Example 2: Input: n = 6 Output: 25 Explanation : 25! has at least 6 trailing 0. User Task: Complete the function findNu...
class Solution: def findNum(self, n: int): d = 0 i = 1 while d < n: k = 5 * i while k % 5 == 0: d += 1 k = k / 5 i += 1 return (i - 1) * 5
CLASS_DEF FUNC_DEF VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP NUMBER VAR WHILE BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER RETURN BIN_OP BIN_OP VAR NUMBER NUMBER
Given a number n. The task is to find the smallest number whose factorial contains at least n trailing zeroes. Example 1: Input: n = 1 Output: 5 Explanation : 5! = 120 which has at least 1 trailing 0. Example 2: Input: n = 6 Output: 25 Explanation : 25! has at least 6 trailing 0. User Task: Complete the function findNu...
class Solution: def findNum(self, n: int): l = 1 r = int(100000.0) ans = -1 def zero(x): count = 0 while x > 0: count += x // 5 x = x // 5 return count while l <= r: mid = (l + r) // 2 ...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN...
Given a number n. The task is to find the smallest number whose factorial contains at least n trailing zeroes. Example 1: Input: n = 1 Output: 5 Explanation : 5! = 120 which has at least 1 trailing 0. Example 2: Input: n = 6 Output: 25 Explanation : 25! has at least 6 trailing 0. User Task: Complete the function findNu...
class Solution: def findNum(self, n: int): def poss(p, n): temp = p count = 0 f = 5 while f <= temp: count += temp // f f = f * 5 return count >= n if n == 1: return 5 low = 0 h...
CLASS_DEF FUNC_DEF VAR FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR VAR IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR ASSIGN...
Given a number n. The task is to find the smallest number whose factorial contains at least n trailing zeroes. Example 1: Input: n = 1 Output: 5 Explanation : 5! = 120 which has at least 1 trailing 0. Example 2: Input: n = 6 Output: 25 Explanation : 25! has at least 6 trailing 0. User Task: Complete the function findNu...
class Solution: def findNum(self, n: int): k = 1 count = 0 while count < n: k += 1 x = k while x % 5 == 0: count += 1 x //= 5 return k
CLASS_DEF FUNC_DEF VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER ASSIGN VAR VAR WHILE BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER RETURN VAR
Given a number n. The task is to find the smallest number whose factorial contains at least n trailing zeroes. Example 1: Input: n = 1 Output: 5 Explanation : 5! = 120 which has at least 1 trailing 0. Example 2: Input: n = 6 Output: 25 Explanation : 25! has at least 6 trailing 0. User Task: Complete the function findNu...
class Solution: def findNum(self, n: int): fact = 24 s = 5 zeros = 10 while n > 0: fact = fact * s temp = s count = 0 while temp >= 5: temp //= 5 count += temp if count >= n: ...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER VAR VAR IF VAR VAR RETURN VAR VAR NUMBER RETURN BIN_OP VAR NUMBER
Given a number n. The task is to find the smallest number whose factorial contains at least n trailing zeroes. Example 1: Input: n = 1 Output: 5 Explanation : 5! = 120 which has at least 1 trailing 0. Example 2: Input: n = 6 Output: 25 Explanation : 25! has at least 6 trailing 0. User Task: Complete the function findNu...
class Solution: def trailingzeros(self, n): c = 0 while n: n //= 5 c += n return c def binarysearch(self, l, r, k): if l <= r: mid = (l + r) // 2 t = self.trailingzeros(mid) if t >= k: return self.binar...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR NUMBER VAR VAR RETURN VAR FUNC_DEF IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR RETURN FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR RETURN VAR FUNC_DEF VAR RETURN FUNC_CALL VAR NUMB...
Given a number n. The task is to find the smallest number whose factorial contains at least n trailing zeroes. Example 1: Input: n = 1 Output: 5 Explanation : 5! = 120 which has at least 1 trailing 0. Example 2: Input: n = 6 Output: 25 Explanation : 25! has at least 6 trailing 0. User Task: Complete the function findNu...
class Solution: def findNum(self, n: int): if n == 1: return 5 def check(m, n): res = 0 while m >= 5: m = m // 5 res += m return res < n l = 0 u = 5 * n while l < u: m = (l + u) // ...
CLASS_DEF FUNC_DEF VAR IF VAR NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR VAR RETURN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR RET...
Given a number n. The task is to find the smallest number whose factorial contains at least n trailing zeroes. Example 1: Input: n = 1 Output: 5 Explanation : 5! = 120 which has at least 1 trailing 0. Example 2: Input: n = 6 Output: 25 Explanation : 25! has at least 6 trailing 0. User Task: Complete the function findNu...
def f(x: int): xx = x ans = 0 while xx: ans += xx // 5 xx //= 5 return ans def f_inverse(n): l = 0 r = 10**9 while l < r: mid = (l + r) // 2 if f(mid) >= n: r = mid else: l = mid + 1 return l class Solution: def fin...
FUNC_DEF VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR CLASS_DEF FUNC_DEF VAR RETU...
Given a number n. The task is to find the smallest number whose factorial contains at least n trailing zeroes. Example 1: Input: n = 1 Output: 5 Explanation : 5! = 120 which has at least 1 trailing 0. Example 2: Input: n = 6 Output: 25 Explanation : 25! has at least 6 trailing 0. User Task: Complete the function findNu...
def count_trails(n): count = 0 f = 5 while f <= n: count += n // f f = f * 5 return count class Solution: def findNum(self, n: int): s, e = 0, 5 * n while s <= e: mid = s + (e - s) // 2 if count_trails(mid) >= n: e = mid - 1 ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR CLASS_DEF FUNC_DEF VAR ASSIGN VAR VAR NUMBER BIN_OP NUMBER VAR WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VA...
Given a number n. The task is to find the smallest number whose factorial contains at least n trailing zeroes. Example 1: Input: n = 1 Output: 5 Explanation : 5! = 120 which has at least 1 trailing 0. Example 2: Input: n = 6 Output: 25 Explanation : 25! has at least 6 trailing 0. User Task: Complete the function findNu...
class Solution: def findNum(self, n: int): low = 0 high = 5 * n while low <= high: mid = (low + high) // 2 count = 0 i = 5 while i <= mid: count += mid // i i *= 5 if count >= n: high...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR
Given a number n. The task is to find the smallest number whose factorial contains at least n trailing zeroes. Example 1: Input: n = 1 Output: 5 Explanation : 5! = 120 which has at least 1 trailing 0. Example 2: Input: n = 6 Output: 25 Explanation : 25! has at least 6 trailing 0. User Task: Complete the function findNu...
class Solution: def count(self, a): c = 0 while a: a = a // 5 c += a return c def findNum(self, n: int): i = 1 e = 5 * n ans = 1 while i <= e: mid = (i + e) // 2 if self.count(mid) >= n: ans...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR BIN_OP VAR NUMBER VAR VAR RETURN VAR FUNC_DEF VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NU...
Given a number n. The task is to find the smallest number whose factorial contains at least n trailing zeroes. Example 1: Input: n = 1 Output: 5 Explanation : 5! = 120 which has at least 1 trailing 0. Example 2: Input: n = 6 Output: 25 Explanation : 25! has at least 6 trailing 0. User Task: Complete the function findNu...
class Solution: def findNum(self, n: int): def check(t, n): ans = 0 while t: ans += t // 5 t = t // 5 if ans >= n: return 1 else: return 0 high = n low = 1 while low <= ...
CLASS_DEF FUNC_DEF VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_...
Given a number n. The task is to find the smallest number whose factorial contains at least n trailing zeroes. Example 1: Input: n = 1 Output: 5 Explanation : 5! = 120 which has at least 1 trailing 0. Example 2: Input: n = 6 Output: 25 Explanation : 25! has at least 6 trailing 0. User Task: Complete the function findNu...
class Solution: def findNum(self, n: int): def ispossible(num, n): cnt = 0 while num >= 5: cnt += num // 5 num = num // 5 if cnt >= n: return True return False if n == 1: return 5 e...
CLASS_DEF FUNC_DEF VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR RETURN NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR...
Given a number n. The task is to find the smallest number whose factorial contains at least n trailing zeroes. Example 1: Input: n = 1 Output: 5 Explanation : 5! = 120 which has at least 1 trailing 0. Example 2: Input: n = 6 Output: 25 Explanation : 25! has at least 6 trailing 0. User Task: Complete the function findNu...
class Solution: def findNum(self, n: int): lo = 0 hi = 10**6 ans = -1 while lo <= hi: mi = (lo + hi) // 2 if self.getZeroes(mi) >= n: ans = mi hi = mi - 1 else: lo = mi + 1 return ans de...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER VAR BIN_OP VAR ...
Given a number n. The task is to find the smallest number whose factorial contains at least n trailing zeroes. Example 1: Input: n = 1 Output: 5 Explanation : 5! = 120 which has at least 1 trailing 0. Example 2: Input: n = 6 Output: 25 Explanation : 25! has at least 6 trailing 0. User Task: Complete the function findNu...
class Solution: def findNum(self, n: int): def trail(ni): a = 0 if ni > 4: while True: ni = ni // 5 a = a + ni if ni < 5: break return a l = 1 h = 5 * 10...
CLASS_DEF FUNC_DEF VAR FUNC_DEF ASSIGN VAR NUMBER IF VAR NUMBER WHILE NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER RETURN VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP NUMBER NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VA...
Given a number n. The task is to find the smallest number whose factorial contains at least n trailing zeroes. Example 1: Input: n = 1 Output: 5 Explanation : 5! = 120 which has at least 1 trailing 0. Example 2: Input: n = 6 Output: 25 Explanation : 25! has at least 6 trailing 0. User Task: Complete the function findNu...
class Solution: def findNum(self, n: int): count = 0 for i in range(5, 100000, 5): num = i while num % 5 == 0: num = num / 5 count += 1 if count == n: return i
CLASS_DEF FUNC_DEF VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR WHILE BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR RETURN VAR
Given a number n. The task is to find the smallest number whose factorial contains at least n trailing zeroes. Example 1: Input: n = 1 Output: 5 Explanation : 5! = 120 which has at least 1 trailing 0. Example 2: Input: n = 6 Output: 25 Explanation : 25! has at least 6 trailing 0. User Task: Complete the function findNu...
class Solution: def findNum(self, n: int): def isok(num): n_zeros = 0 j = num d = 5 while j >= d: n_zeros += j // d d *= 5 return n_zeros low = 0 high = 5 * n res = 0 while low <= h...
CLASS_DEF FUNC_DEF VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR N...
Given a number n. The task is to find the smallest number whose factorial contains at least n trailing zeroes. Example 1: Input: n = 1 Output: 5 Explanation : 5! = 120 which has at least 1 trailing 0. Example 2: Input: n = 6 Output: 25 Explanation : 25! has at least 6 trailing 0. User Task: Complete the function findNu...
class Solution: def countZero(p, n): fives = 5 count = 0 val = p while fives <= val: count += val // fives fives *= 5 return count >= n def findNum(self, n: int): low = 0 high = 5 * n if n == 1: return 5 ...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR VAR BIN_OP VAR VAR VAR NUMBER RETURN VAR VAR FUNC_DEF VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR IF VAR NUMBER RETURN NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VA...
Given a number n. The task is to find the smallest number whose factorial contains at least n trailing zeroes. Example 1: Input: n = 1 Output: 5 Explanation : 5! = 120 which has at least 1 trailing 0. Example 2: Input: n = 6 Output: 25 Explanation : 25! has at least 6 trailing 0. User Task: Complete the function findNu...
def zerocheck(a, n): zeroes = 0 num = 1 while num <= a: num = num * 5 zeroes += a // num return zeroes >= n class Solution: def findNum(self, n: int): if n == 1: return 5 low = 5 high = 5 * n while low != high: mid = (low + h...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP VAR VAR RETURN VAR VAR CLASS_DEF FUNC_DEF VAR IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN...
Given a number n. The task is to find the smallest number whose factorial contains at least n trailing zeroes. Example 1: Input: n = 1 Output: 5 Explanation : 5! = 120 which has at least 1 trailing 0. Example 2: Input: n = 6 Output: 25 Explanation : 25! has at least 6 trailing 0. User Task: Complete the function findNu...
class Solution: def findNum(self, n: int): def numOfZeros(num): c = 0 while num >= 5: num //= 5 c += num return c l, h = 1, 1000000000 while l < h: mid = l + (h - l) // 2 if numOfZeros(mid) < n: ...
CLASS_DEF FUNC_DEF VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER VAR VAR RETURN VAR ASSIGN VAR VAR NUMBER NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR RETURN VAR
Given a number n. The task is to find the smallest number whose factorial contains at least n trailing zeroes. Example 1: Input: n = 1 Output: 5 Explanation : 5! = 120 which has at least 1 trailing 0. Example 2: Input: n = 6 Output: 25 Explanation : 25! has at least 6 trailing 0. User Task: Complete the function findNu...
class Solution: def findNum(self, n: int): if n < 6: return 5 * n k = 1 ans = 0 limit_k = 1 cumsum = [1] while limit_k < n: limit_k += 5**k cumsum.append(limit_k) k += 1 ans = 5**k k -= 1 l = cum...
CLASS_DEF FUNC_DEF VAR IF VAR NUMBER RETURN BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER WHILE VAR VAR VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER VAR NUMBER WHILE NUMBER IF BIN_OP BIN_...
Given a number n. The task is to find the smallest number whose factorial contains at least n trailing zeroes. Example 1: Input: n = 1 Output: 5 Explanation : 5! = 120 which has at least 1 trailing 0. Example 2: Input: n = 6 Output: 25 Explanation : 25! has at least 6 trailing 0. User Task: Complete the function findNu...
class Solution: def findNum(self, n: int): count = 0 num = 5 while True: temp = num while temp % 5 == 0: count += 1 temp //= 5 if count >= n: return num num += 5
CLASS_DEF FUNC_DEF VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR VAR WHILE BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER IF VAR VAR RETURN VAR VAR NUMBER
Given a number n. The task is to find the smallest number whose factorial contains at least n trailing zeroes. Example 1: Input: n = 1 Output: 5 Explanation : 5! = 120 which has at least 1 trailing 0. Example 2: Input: n = 6 Output: 25 Explanation : 25! has at least 6 trailing 0. User Task: Complete the function findNu...
class Solution: def findNum(self, n: int): if n == 1: return 5 low = 0 high = 5 * n while low < high: mid = int((low + high) / 2) if ob.check(mid, n): high = mid else: low = mid + 1 return low ...
CLASS_DEF FUNC_DEF VAR IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE ...
Given a number n. The task is to find the smallest number whose factorial contains at least n trailing zeroes. Example 1: Input: n = 1 Output: 5 Explanation : 5! = 120 which has at least 1 trailing 0. Example 2: Input: n = 6 Output: 25 Explanation : 25! has at least 6 trailing 0. User Task: Complete the function findNu...
class Solution: def findNum(self, n: int): def zero_count(n): temp = n count = 0 f = 5 while f <= temp: count += temp // f f = f * 5 return count left = 0 right = n * 5 ans = right ...
CLASS_DEF FUNC_DEF VAR FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN V...
Given a number n. The task is to find the smallest number whose factorial contains at least n trailing zeroes. Example 1: Input: n = 1 Output: 5 Explanation : 5! = 120 which has at least 1 trailing 0. Example 2: Input: n = 6 Output: 25 Explanation : 25! has at least 6 trailing 0. User Task: Complete the function findNu...
class Solution: def findNum(self, n: int): def check(p, n): temp = p f = 5 count = 0 while f <= p: count += temp // f f *= 5 if count >= n: return True else: return False...
CLASS_DEF FUNC_DEF VAR FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP VAR VAR VAR NUMBER IF VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF...
Given a number n. The task is to find the smallest number whose factorial contains at least n trailing zeroes. Example 1: Input: n = 1 Output: 5 Explanation : 5! = 120 which has at least 1 trailing 0. Example 2: Input: n = 6 Output: 25 Explanation : 25! has at least 6 trailing 0. User Task: Complete the function findNu...
class Solution: def findNum(self, n: int): def fives(n): count = 0 while n: if n % 5 != 0: break n = n // 5 count += 1 return count x = 0 factorial = 0 while x < n: ...
CLASS_DEF FUNC_DEF VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR RETURN VAR
Given a number n. The task is to find the smallest number whose factorial contains at least n trailing zeroes. Example 1: Input: n = 1 Output: 5 Explanation : 5! = 120 which has at least 1 trailing 0. Example 2: Input: n = 6 Output: 25 Explanation : 25! has at least 6 trailing 0. User Task: Complete the function findNu...
class Solution: def findNum(self, n: int): def make(x): t = 0 k = 5 m = 1 while x // k > 0: t += x // k m *= 2 k *= 5 if t >= n: return True return False ...
CLASS_DEF FUNC_DEF VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR VAR NUMBER BIN_OP NUMBER NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR V...
------Read problems statements in Hindi, Mandarin chinese , Russian and Vietnamese as well. ------ Sheokand is good at mathematics. One day, to test his math skills, Kaali gave him an integer $N$. To impress Kaali, Sheokand has to convert $N$ into an integer $M$ that can be represented in the form $2^{x} + 2^{y}$ (wh...
def close(n): for i in range(31): if n == arr[i]: return arr[i], arr[i] if n > arr[i] and n < arr[i + 1]: return arr[i], arr[i + 1] def calx(n, min): a, b = close(n) if a == b and b == min: return b / 2 if a == b: return a if b == min: ...
FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR RETURN VAR VAR VAR VAR IF VAR VAR VAR VAR VAR BIN_OP VAR NUMBER RETURN VAR VAR VAR BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR RETURN BIN_OP VAR NUMBER IF VAR VAR RETURN VAR IF VAR VAR RETURN VAR IF VAR VAR RETURN BIN_OP VAR NUMBER ...
------Read problems statements in Hindi, Mandarin chinese , Russian and Vietnamese as well. ------ Sheokand is good at mathematics. One day, to test his math skills, Kaali gave him an integer $N$. To impress Kaali, Sheokand has to convert $N$ into an integer $M$ that can be represented in the form $2^{x} + 2^{y}$ (wh...
var = [] for i in range(0, 32): for j in range(i + 1, 32): var.append(2**i + 2**j) var.sort() for i in range(int(input())): n = int(input()) j = 0 while True: if var[j] >= n: break j += 1 print(min(abs(var[j] - n), abs(var[j - 1] - n)))
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE NUMBER IF VAR VAR VAR VAR N...
------Read problems statements in Hindi, Mandarin chinese , Russian and Vietnamese as well. ------ Sheokand is good at mathematics. One day, to test his math skills, Kaali gave him an integer $N$. To impress Kaali, Sheokand has to convert $N$ into an integer $M$ that can be represented in the form $2^{x} + 2^{y}$ (wh...
t = int(input()) arr = [] for i in range(1, 33): for j in range(i): arr.append((1 << i) + (1 << j)) arr.sort() def ans(n): low, high = 0, len(arr) res, diff = float("inf"), float("inf") while low <= high: mid = (low + high) // 2 currdiff = abs(n - arr[mid]) if currdiff ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING WHILE VAR VAR AS...
------Read problems statements in Hindi, Mandarin chinese , Russian and Vietnamese as well. ------ Sheokand is good at mathematics. One day, to test his math skills, Kaali gave him an integer $N$. To impress Kaali, Sheokand has to convert $N$ into an integer $M$ that can be represented in the form $2^{x} + 2^{y}$ (wh...
l = [] for i in range(31): for j in range(i + 1, 31): l.append(2**i + 2**j) l.sort() def getClosest(val1, val2, target): if target - val1 >= val2 - target: return val2 else: return val1 def findClosest(l1, target): i = 0 j = l1 mid = 0 while i < j: mid = (...
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR FUNC_DEF IF BIN_OP VAR VAR BIN_OP VAR VAR RETURN VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VA...
------Read problems statements in Hindi, Mandarin chinese , Russian and Vietnamese as well. ------ Sheokand is good at mathematics. One day, to test his math skills, Kaali gave him an integer $N$. To impress Kaali, Sheokand has to convert $N$ into an integer $M$ that can be represented in the form $2^{x} + 2^{y}$ (wh...
n = int(input()) queries = [int(input()) for i in range(n)] def binary_search(A, value): if len(A) == 0: return 0 mid = len(A) // 2 if A[mid] == value: return mid elif value < A[mid]: return binary_search(A[:mid], value) else: return mid + 1 + binary_search(A[mid + ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR RETURN VAR IF VAR VAR VAR RETURN FUNC_CALL VAR VAR VAR VAR RETURN BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR VAR BI...
------Read problems statements in Hindi, Mandarin chinese , Russian and Vietnamese as well. ------ Sheokand is good at mathematics. One day, to test his math skills, Kaali gave him an integer $N$. To impress Kaali, Sheokand has to convert $N$ into an integer $M$ that can be represented in the form $2^{x} + 2^{y}$ (wh...
lst = [] for i in range(32): for j in range(32): if i != j: lst.append(2**i + 2**j) lst.sort() def bin_search(x, low, high): if low > high: return min(abs(x - lst[low]), abs(x - lst[low - 1]), abs(x - lst[low + 1])) else: mid = low + (high - low) // 2 if x == ls...
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR FUNC_DEF IF VAR VAR RETURN FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR BIN_...
------Read problems statements in Hindi, Mandarin chinese , Russian and Vietnamese as well. ------ Sheokand is good at mathematics. One day, to test his math skills, Kaali gave him an integer $N$. To impress Kaali, Sheokand has to convert $N$ into an integer $M$ that can be represented in the form $2^{x} + 2^{y}$ (wh...
T = int(input()) lst = [] for i in range(31): for j in range(i): lst.append(2**i + 2**j) lst.sort() def bound_search(lst, x, compare): lo = 0 up = len(lst) while lo < up: mid = (lo + up) // 2 if compare(x, lst[mid]): up = mid else: lo = mid + 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VA...
------Read problems statements in Hindi, Mandarin chinese , Russian and Vietnamese as well. ------ Sheokand is good at mathematics. One day, to test his math skills, Kaali gave him an integer $N$. To impress Kaali, Sheokand has to convert $N$ into an integer $M$ that can be represented in the form $2^{x} + 2^{y}$ (wh...
def bin(arr, i, j, val): while i <= j: mid = (i + j) // 2 if arr[mid] == val or arr[mid] < val and val < arr[mid + 1]: return mid elif arr[mid] < val: i = mid + 1 elif arr[mid] > val: j = mid - 1 li = [] for i in range(31): for j in range(31)...
FUNC_DEF WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR VAR VAR VAR VAR VAR BIN_OP VAR NUMBER RETURN VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR B...
------Read problems statements in Hindi, Mandarin chinese , Russian and Vietnamese as well. ------ Sheokand is good at mathematics. One day, to test his math skills, Kaali gave him an integer $N$. To impress Kaali, Sheokand has to convert $N$ into an integer $M$ that can be represented in the form $2^{x} + 2^{y}$ (wh...
def bin(start, end): while start < end: mid = (start + end) // 2 if la[mid] < n: start = mid + 1 else: end = mid - 1 return min(abs(n - la[start]), abs(n - la[start + 1]), abs(n - la[start - 1])) la = [] for i in range(35): for j in range(35): if i !...
FUNC_DEF WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VA...
------Read problems statements in Hindi, Mandarin chinese , Russian and Vietnamese as well. ------ Sheokand is good at mathematics. One day, to test his math skills, Kaali gave him an integer $N$. To impress Kaali, Sheokand has to convert $N$ into an integer $M$ that can be represented in the form $2^{x} + 2^{y}$ (wh...
t = int(input()) for _ in range(t): n = int(input()) n_bin = bin(n)[2:] count = 0 i = 0 while i < len(n_bin): if n_bin[i] == "1": count += 1 if count == 2: break i += 1 if count == 1: if n == 1: print(2) else: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR NUMBER VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUN...
------Read problems statements in Hindi, Mandarin chinese , Russian and Vietnamese as well. ------ Sheokand is good at mathematics. One day, to test his math skills, Kaali gave him an integer $N$. To impress Kaali, Sheokand has to convert $N$ into an integer $M$ that can be represented in the form $2^{x} + 2^{y}$ (wh...
l = [] for i in range(31): for j in range(i + 1, 31): l.append(2**i + 2**j) l1 = len(l) l.sort() for t in range(int(input())): n = int(input()) ans = 0 if n <= 3: print(3 - n) else: for i in range(l1): if l[i] >= n: ans = min(l[i] - n, n - l[i - 1]...
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMB...
------Read problems statements in Hindi, Mandarin chinese , Russian and Vietnamese as well. ------ Sheokand is good at mathematics. One day, to test his math skills, Kaali gave him an integer $N$. To impress Kaali, Sheokand has to convert $N$ into an integer $M$ that can be represented in the form $2^{x} + 2^{y}$ (wh...
def bs(arr, l, h, x): if h >= l: mid = (h + l) // 2 if arr[mid] == x: return 1 elif arr[mid] > x: return bs(arr, l, mid - 1, x) else: return bs(arr, mid + 1, h, x) else: return -1 def bss(arr, l, h, x): if h >= l: mid = (h...
FUNC_DEF IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR RETURN NUMBER IF VAR VAR VAR RETURN FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR RETURN NUMBER FUNC_DEF IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR IF VAR BIN_OP VAR NUMBER ...
------Read problems statements in Hindi, Mandarin chinese , Russian and Vietnamese as well. ------ Sheokand is good at mathematics. One day, to test his math skills, Kaali gave him an integer $N$. To impress Kaali, Sheokand has to convert $N$ into an integer $M$ that can be represented in the form $2^{x} + 2^{y}$ (wh...
nums = [] for x in range(33): for y in range(33): if x == y: continue nums.append(2**x + 2**y) nums.sort() def binary_search(lo, hi, condition, target): while lo <= hi: mid = (lo + hi) // 2 result = condition(mid) if result == "found": if nums[mi...
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR FUNC_DEF WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR STRING IF VAR VAR VAR RETURN NUMBER IF VAR VAR VAR VAR ...
------Read problems statements in Hindi, Mandarin chinese , Russian and Vietnamese as well. ------ Sheokand is good at mathematics. One day, to test his math skills, Kaali gave him an integer $N$. To impress Kaali, Sheokand has to convert $N$ into an integer $M$ that can be represented in the form $2^{x} + 2^{y}$ (wh...
t = int(input()) for _ in range(t): n = int(input()) s = bin(n)[2:] c = s.count("1") if n == 1: print(2) else: k = 1 while k <= n: k = k << 1 k = k >> 1 if k == n: print("1") else: n = n - k j = 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 VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR EXPR FU...
------Read problems statements in Hindi, Mandarin chinese , Russian and Vietnamese as well. ------ Sheokand is good at mathematics. One day, to test his math skills, Kaali gave him an integer $N$. To impress Kaali, Sheokand has to convert $N$ into an integer $M$ that can be represented in the form $2^{x} + 2^{y}$ (wh...
t = int(input()) x = [] for i in range(0, 31): for j in range(i + 1, 31): k = (1 << i) + (1 << j) x.append(k) x.sort() def search(n): i = int(0) while i < len(x): if x[i] > n: break i = i + 1 return i while t > 0: n = int(input()) result = search(n...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR VAR AS...
------Read problems statements in Hindi, Mandarin chinese , Russian and Vietnamese as well. ------ Sheokand is good at mathematics. One day, to test his math skills, Kaali gave him an integer $N$. To impress Kaali, Sheokand has to convert $N$ into an integer $M$ that can be represented in the form $2^{x} + 2^{y}$ (wh...
def cal(num): x = 0 while pow(2, x) < num: x = x + 1 return x - 1 n = int(input()) for i in range(0, n): num = int(input()) if num == 1: print(2) elif num == 2: print(1) else: x = cal(num) num1 = num - pow(2, x) y = cal(num1) if num >...
FUNC_DEF ASSIGN VAR NUMBER WHILE FUNC_CALL VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FU...
------Read problems statements in Hindi, Mandarin chinese , Russian and Vietnamese as well. ------ Sheokand is good at mathematics. One day, to test his math skills, Kaali gave him an integer $N$. To impress Kaali, Sheokand has to convert $N$ into an integer $M$ that can be represented in the form $2^{x} + 2^{y}$ (wh...
a = [1, 2] for i in range(29): a.append(a[-1] * 2) c = [] for i in range(len(a) - 1): k = a[i] for j in range(i + 1, len(a)): c.append(k + a[j]) c.sort() for i in range(int(input())): l = int(input()) if l <= 3: print(3 - l) else: for j in range(465): if c[j] ...
ASSIGN VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR FOR VAR FUNC_...
Find the count of numbers less than equal to N having exactly 9 divisors. Example 1: Input: N = 100 Output: 2 Explanation: The two numbers which have exactly 9 divisors are 36 and 100. Example 2: Input: N = 1000 Output: 8 Explanation: The numbers are: 36 100 196 225 256 441 484 676 Your Task: You don't need to re...
class Solution: def nineDivisors(self, n): c = 0 limit = int(n**0.5) prime = [i for i in range(limit + 1)] i = 2 while i * i <= limit: if prime[i] == i: for j in range(i * i, limit + 1, i): if prime[j] == j: ...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR IF VAR VAR VAR ASSIGN VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBE...
Find the count of numbers less than equal to N having exactly 9 divisors. Example 1: Input: N = 100 Output: 2 Explanation: The two numbers which have exactly 9 divisors are 36 and 100. Example 2: Input: N = 1000 Output: 8 Explanation: The numbers are: 36 100 196 225 256 441 484 676 Your Task: You don't need to re...
class Solution: def countdiv(self, n): limit = int(n**0.5) skip = 2 conta = 1 check = 3 if n % 2 == 0: skip = 1 conta = 2 while check < limit: if n % check == 0: conta = conta + 1 check = check + skip ...
CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETU...
Find the count of numbers less than equal to N having exactly 9 divisors. Example 1: Input: N = 100 Output: 2 Explanation: The two numbers which have exactly 9 divisors are 36 and 100. Example 2: Input: N = 1000 Output: 8 Explanation: The numbers are: 36 100 196 225 256 441 484 676 Your Task: You don't need to re...
class Solution: def isprime(self, n): if n < 2: return False if n == 3 or n == 2 or n == 5: return True if n % 2 == 0 or n % 3 == 0 or n % 5 == 0: return False for i in range(5, int(n**0.5) + 1, 6): if n % (i + 2) == 0 or n % (i + 6) =...
CLASS_DEF FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER RETURN NUMBER IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR...
Find the count of numbers less than equal to N having exactly 9 divisors. Example 1: Input: N = 100 Output: 2 Explanation: The two numbers which have exactly 9 divisors are 36 and 100. Example 2: Input: N = 1000 Output: 8 Explanation: The numbers are: 36 100 196 225 256 441 484 676 Your Task: You don't need to re...
class Solution: def nineDivisors(self, n): c = 0 limit = int(n**0.5) prime = [i for i in range(limit + 1)] i = 2 while i * i <= limit: if prime[i] == i: for j in range(i * i, limit + 1, i): if prime[j] == j: ...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR IF VAR VAR VAR ASSIGN VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBE...
Find the count of numbers less than equal to N having exactly 9 divisors. Example 1: Input: N = 100 Output: 2 Explanation: The two numbers which have exactly 9 divisors are 36 and 100. Example 2: Input: N = 1000 Output: 8 Explanation: The numbers are: 36 100 196 225 256 441 484 676 Your Task: You don't need to re...
class Solution: def nineDivisors(self, n): res = int(n**0.5) ar = [i for i in range(res + 1)] for i in range(2, res + 1): if ar[i] == i: for j in range(i * i, res + 1, i): if ar[j] == j: ar[j] = i ans = 0 ...
CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR IF VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_O...
Find the count of numbers less than equal to N having exactly 9 divisors. Example 1: Input: N = 100 Output: 2 Explanation: The two numbers which have exactly 9 divisors are 36 and 100. Example 2: Input: N = 1000 Output: 8 Explanation: The numbers are: 36 100 196 225 256 441 484 676 Your Task: You don't need to re...
class Solution: def nineDivisors(self, n): l = [1] * (int(n**0.5) + 1) l[0], l[1] = 0, 0 x = len(l) for i in range(2, int(x**0.5) + 1): if l[i] == 1: for j in range(i * i, x, i): l[j] = 0 c = 0 for i in range(2, x): ...
CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR ...
Find the count of numbers less than equal to N having exactly 9 divisors. Example 1: Input: N = 100 Output: 2 Explanation: The two numbers which have exactly 9 divisors are 36 and 100. Example 2: Input: N = 1000 Output: 8 Explanation: The numbers are: 36 100 196 225 256 441 484 676 Your Task: You don't need to re...
class Solution: def nineDivisors(self, n): res = int(n**0.5) ar = [i for i in range(res + 1)] for i in range(2, res + 1): if ar[i] == i: for j in range(i * i, res + 1, i): if ar[j] == j: ar[j] = i ans = 0 ...
CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR IF VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_O...
Find the count of numbers less than equal to N having exactly 9 divisors. Example 1: Input: N = 100 Output: 2 Explanation: The two numbers which have exactly 9 divisors are 36 and 100. Example 2: Input: N = 1000 Output: 8 Explanation: The numbers are: 36 100 196 225 256 441 484 676 Your Task: You don't need to re...
class Solution: def nineDivisors(self, N): t = 0 s = int(pow(N, 0.5)) + 1 primes = [(1) for i in range(s)] arr = [] for i in range(2, s): if primes[i] and i != 1: arr.append(i) for j in range(i + i, s, i): prime...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ...
Find the count of numbers less than equal to N having exactly 9 divisors. Example 1: Input: N = 100 Output: 2 Explanation: The two numbers which have exactly 9 divisors are 36 and 100. Example 2: Input: N = 1000 Output: 8 Explanation: The numbers are: 36 100 196 225 256 441 484 676 Your Task: You don't need to re...
class Solution: def find_prime(self, num): arr = [i for i in range(num)] for i in range(2, num): if arr[i] == i: j = i while j < num: if arr[j] == j: arr[j] = i j = j + i return arr ...
CLASS_DEF FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR ASSIGN VAR VAR WHILE VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL ...
Find the count of numbers less than equal to N having exactly 9 divisors. Example 1: Input: N = 100 Output: 2 Explanation: The two numbers which have exactly 9 divisors are 36 and 100. Example 2: Input: N = 1000 Output: 8 Explanation: The numbers are: 36 100 196 225 256 441 484 676 Your Task: You don't need to re...
class Solution: def nineDivisors(self, N): def SieveOfEratosthenes(n): prime = [(True) for i in range(n + 1)] p = 2 while p * p <= n: if prime[p] == True: for i in range(p * p, n + 1, p): prime[i] = False ...
CLASS_DEF FUNC_DEF FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_C...
Find the count of numbers less than equal to N having exactly 9 divisors. Example 1: Input: N = 100 Output: 2 Explanation: The two numbers which have exactly 9 divisors are 36 and 100. Example 2: Input: N = 1000 Output: 8 Explanation: The numbers are: 36 100 196 225 256 441 484 676 Your Task: You don't need to re...
N = 150000 dp = [(0) for i in range(150000)] primes = [] primes2 = [] for i in range(2, 150000): for j in range(i * i, 150000, i): dp[j] = 1 if not dp[i]: primes.append(i) primes2.append(i * i) def bs(i, j, k): if i > j: return j m = (i + j) // 2 if k < primes2[m]: ...
ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR ASSIGN VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR FUNC_DEF IF VAR VAR RETURN VAR ASSIGN VAR BIN_OP BIN_...
Find the count of numbers less than equal to N having exactly 9 divisors. Example 1: Input: N = 100 Output: 2 Explanation: The two numbers which have exactly 9 divisors are 36 and 100. Example 2: Input: N = 1000 Output: 8 Explanation: The numbers are: 36 100 196 225 256 441 484 676 Your Task: You don't need to re...
class PrimeNumbers: def prime_numbers(lower, upper, plist, slist): for num in range(lower, upper + 1): if num > 1: for i in range(2, num): if num % i == 0: break else: plist.append(num) ...
CLASS_DEF FUNC_DEF FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMB...
Find the count of numbers less than equal to N having exactly 9 divisors. Example 1: Input: N = 100 Output: 2 Explanation: The two numbers which have exactly 9 divisors are 36 and 100. Example 2: Input: N = 1000 Output: 8 Explanation: The numbers are: 36 100 196 225 256 441 484 676 Your Task: You don't need to re...
class Solution: def nineDivisors(self, N): k = int(N**0.5) primes = [(1) for i in range(k + 1)] primes[0] = 0 primes[1] = 0 for i in range(2, k + 1): if primes[i]: for j in range(i * i, k + 1, i): primes[j] = 0 curr = [...
CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST...
Find the count of numbers less than equal to N having exactly 9 divisors. Example 1: Input: N = 100 Output: 2 Explanation: The two numbers which have exactly 9 divisors are 36 and 100. Example 2: Input: N = 1000 Output: 8 Explanation: The numbers are: 36 100 196 225 256 441 484 676 Your Task: You don't need to re...
primes = [2] prime = [1] * 100001 for i in range(4, 100001, 2): prime[i] = 0 for i in range(3, 100001, 2): if prime[i]: for j in range(i * i, 100001, i): prime[j] = 0 primes.append(i) m = len(primes) class Solution: def nineDivisors(self, n): ans = 0 for i in r...
ASSIGN VAR LIST NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR CLASS_DEF FUNC_DEF ...
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder. You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $...
def testcase(): [X, Y] = [int(c) for c in input().split()] res = 0 b = 1 while b**2 - 1 <= X and b <= Y: res += b - 1 b += 1 c = 1 while c < b: hi = X // c - 1 lo = (X + c + 1) // (c + 1) - 1 res += c * max(min(Y, hi) - max(b, lo) + 1, 0) c += 1 ...
FUNC_DEF ASSIGN LIST VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR NUMBER ...
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder. You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $...
for _ in range(int(input())): a, b = map(int, input().split()) s = 0 i = 1 while True: t = min(b, (a - i) // i) - i if t > 0: s += t else: break i += 1 print(s)
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 NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR IF VAR NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder. You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $...
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()) def solve(): x, y = R() ans = 0 i = 1 while i * i <= x: temp = min(y, x // i - 1) - i ans += 0 if temp < 0 else temp i +=...
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 FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CAL...
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder. You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $...
def solve(): x, y = list(map(int, input().split(" "))) ans = 0 i = 1 while i * i < x: ans += max(min(y, x // i - 1) - i, 0) i += 1 print(ans) t = int(input()) for i in range(t): solve()
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CAL...
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder. You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $...
import sys input = sys.stdin.readline t = int(input()) for _ in range(t): x, y = map(int, input().split()) ans = 0 num = 0 ok = False while num * (num + 2) <= x: num += 1 ans += num - 1 if y == num: ok = True break if ok: print(ans) ...
IMPORT ASSIGN VAR VAR 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 NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR BIN_OP VAR NUMBER VAR VAR NUMBER VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL...
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder. You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $...
def find(): x, y = map(int, input().split()) s = 0 for j in range(1, int(x**0.5) + 1): s += max(0, min(y, x // j - 1) - j) return s for i in range(int(input())): print(find())
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VA...
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder. You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $...
for t in range(int(input())): a, b = map(int, input().split()) ans = 0 x = int((a + 1) ** 0.5) + 2 for i in range(1, x): ans += max(0, min((a - i) // i, b) - i) print(ans)
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 NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR EXPR FUNC_C...
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder. You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $...
for _ in range(int(input())): a, b = map(int, input().split()) ans = 0 for k in range(1, 31624): x = a // k - 1 y = b result = 0 if k + 1 <= b and k * (k + 2) <= a: if x < y: result = x - k else: result = y - k e...
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 NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER VAR BIN_OP VAR BIN_OP VAR NUMBER VAR IF VAR VAR ASSIGN VAR BIN_OP...
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder. You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $...
t = int(input()) for _ in range(t): x, y = (int(i) for i in input().split()) k, res = 1, 0 while True: temp = min(x // k - k - 1, y - k) if temp <= 0: break res += temp k += 1 print(res)
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 VAR NUMBER NUMBER WHILE NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER BIN_OP VAR VAR IF VAR NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder. You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $...
import sys def main(): t = int(input()) allAns = [] for _ in range(t): x, y = readIntArr() ans = 0 nK = 1 while min(x // nK - 1, y) >= nK: ans += min(x // nK - 1, y) - nK nK += 1 allAns.append(ans) multiLineArrayPrint(allAns) return ...
IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR VAR BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR ...
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder. You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $...
T = int(input()) for t in range(T): x, y = tuple([int(x) for x in input().split()]) sqrt_x = int(x**0.5) result = 0 for i in range(1, sqrt_x + 1): num_n = min(x // i, y + 1) - i - 1 if num_n <= 0: break result += num_n print(result)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER ...
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder. You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $...
t = int(input()) for i in range(t): l1 = input().split(" ") x, y = int(l1[0]), int(l1[1]) s = 0 for j in range(1, y): k = (x - j) // j if k <= j: break s += min(k, y) - j j += 1 print(s)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR VAR VAR NUMBER E...
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder. You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $...
a = int(input()) for i in range(a): x, y = map(int, input().split()) flag = 0 save = 0 total = 0 rem = 1 while (rem + 1) * rem + rem <= x and rem < y: q = (x - rem) // rem q = min(y, q) total += q - (rem + 1) + 1 rem += 1 print(total)
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 NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VA...
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder. You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $...
for _ in range(int(input())): a, b = map(int, input().split()) k = 2 ost = 1 p = min(a // ost - k, b - k + 1) c = 0 while p > 0: k += 1 c += p ost += 1 p = min(a // ost - k, b - k + 1) print(c)
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 NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP ...
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder. You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $...
def solve(y, x): ct = 0 for i in range(1, 100000): mx = i + 1 my = i * (mx + 0) z = min(x - mx + 1, (y - my) // i) if z < 0: break ct += z return ct t = int(input()) for _ in range(t): x, y = [int(i) for i in input().split()] print(solve(x, y))
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR VAR IF VAR NUMBER VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR...
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder. You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $...
for _ in range(int(input())): x, y = list(map(int, input().split())) s = 0 for i in range(1, min(x - 1, y)): c = x // i - 1 if c <= i: break s += min(c, y) - i print(s)
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 NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder. You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $...
def answer(): ans = 0 for i in range(1, b + 1): val = min(a // i, b + 1) - i - 1 if val <= 0: break ans += val return ans for T in range(int(input())): a, b = map(int, input().split()) print(answer())
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC...
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder. You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $...
import sys input = sys.stdin.buffer.readline for t in range(int(input())): X, Y = map(int, input().split()) Z = min(Y, int(X**0.5) + 1) ANS = 0 for i in range(1, min(Z + 1, Y) + 1): A = X // (i + 1) ANS += min(A, i - 1) if Z + 1 >= Y: print(ANS) continue for i in...
IMPORT ASSIGN VAR VAR 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 BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP V...
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder. You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $...
from sys import stdin input = stdin.readline def calc(n): return n * (n - 1) + n - 1 def cal(n, deg): return n * deg + deg def bin(x): start = 1 end = x while start <= end: mid = (start + end) // 2 if calc(mid) <= x < calc(mid + 1): return mid elif calc(mid...
ASSIGN VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER RETURN VAR IF FUNC_CALL VAR VAR VAR FUNC...
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder. You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $...
from sys import stdin t = int(stdin.readline()) for _ in range(t): a, b = map(int, stdin.readline().split()) ans = 0 d = 1 while d * (d + 2) <= a: x = a // d - (d + 1) y = b - d ans += max(0, min(x, y)) d += 1 print(ans)
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 NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR...
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder. You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $...
import sys input = sys.stdin.readline t = int(input()) while t > 0: x, y = map(int, input().split()) a = 0 j = 2 while j <= y: if j * j - 1 <= x: a += j - 1 j += 1 else: k = x // j if k * j + k > x: k -= 1 if k ...
IMPORT ASSIGN VAR VAR 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 NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR VAR NUM...
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder. You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $...
for i in range(int(input())): a, b = map(int, input().split()) sumo = 0 for j in range(1, b + 1): if a // j <= j + 1 or b - j <= 0: break sumo = sumo + min(a // j - 1, b) - j print(sumo)
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 NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR EXPR FUNC_...
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder. You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $...
import sys input = sys.stdin.readline def solve(): x, y = map(int, input().split()) if x < 3 or y < 2: return 0 ans = 0 for i in range(3, min(10**5 + 4, y + 2)): if i * (i - 2) > x: break ans += min(x // (i - 2), y + 1) - i + 1 return ans for _ in range(int(i...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER VAR VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP VAR ...
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder. You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $...
al = [] for _ in range(int(input())): x, y = map(int, input().split()) ans = 0 for r in range(1, x): if r * r >= x: break cmin = r + 2 cmax = min(x // r, y + 1) cnt = cmax - cmin + 1 ans += max(0, cnt) al.append(ans) for a in al: print(a)
ASSIGN VAR LIST 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 NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMB...
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder. You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $...
for _ in range(int(input())): x, y = map(int, input().split()) ans, i = 0, 1 while i * i <= x: ans, i = ans + max(0, min(y, x // i - 1) - i), i + 1 print(ans)
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 VAR NUMBER NUMBER WHILE BIN_OP VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder. You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $...
t = int(input()) for _ in range(t): x, y = map(int, input().split()) ans = 0 a = 3 for b in range(2, y + 1): if x - a < 0: break z = min(y - b + 1, (x - a) // (b - 1) + 1) a += 2 * b + 1 ans += z print(ans)
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 NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP ...
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder. You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $...
def f(max_a, max_b): b_q = floor_sqrt(max_a) b_n_fst = min(b_q, max_b) variants_n_fst = b_n_fst * (b_n_fst + 1) // 2 + -1 * b_n_fst if b_q >= max_b: variants_n_snd = 0 else: variants_n_snd = p(max_a, max_b + 2 - 1) - p(max_a, b_q + 2 - 1) return variants_n_fst + variants_n_snd ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP NUMBER VAR IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER RETURN BIN_OP VAR VAR F...
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder. You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $...
for _ in range(int(input())): a, b = map(int, input().split()) cr, ans, mn = b - 1, 0, 2 i = 1 while mn * i + i <= a and mn <= b: tp = (a - i) // i ans += min(tp - mn + 1, cr) cr -= 1 mn += 1 i += 1 print(ans)
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 VAR VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER WHILE BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR NUMBER V...
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder. You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $...
t = int(input()) for _ in range(t): a, b = map(int, input().split(" ")) count = 0 k = int(a**0.5) + 1 for i in range(1, k + 1): s = int(a / i) s = min(s, b + 1) count += max(0, s - i - 1) print(count)
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 STRING ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ...
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder. You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $...
def main(): t = int(input()) ans = [] for _ in range(t): x, y = map(int, input().split()) x = min(y * y, x) y = min(x - 1, y) cnt = 0 rem = 1 while rem * rem <= x: cnt += max(0, min(y, x // rem - 1) - rem) rem += 1 ans.append(st...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR VAR FUNC_CALL VAR NUM...
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder. You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $...
def main(): t = int(input()) for _ in range(t): x, y = map(int, input().split()) total = 0 for i in range(1, int(x**0.5) + 1): maxx = min(i * y + i, x) total += max(0, maxx // i - (i + 1)) print(total) main()
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VA...
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder. You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $...
import sys from sys import stdin tt = int(stdin.readline()) for loop in range(tt): x, y = map(int, stdin.readline().split()) ans = 0 for c in range(1, x): now = min(y, x // c - 1) if now > c: ans += now - c else: break print(ans)
IMPORT 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 NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder. You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $...
import sys input = sys.stdin.readline def binarySearch(num, highest, denom): low = denom high = highest floorDiv = num // denom best = denom while low <= high: mid = (low + high) // 2 if num // mid == floorDiv: best = mid low = mid + 1 else: ...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR RET...
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder. You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $...
def solve(x, y): res = 0 r = 1 while r * (r + 2) <= x: res += max(0, min(y, x // r - 1) - r) r += 1 return res t = int(input()) for _ in range(t): x, y = map(int, input().split()) print(solve(x, y))
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR NUMBER RETURN VAR 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 EXPR FUNC...
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder. You are given two integers $x$ and $y$. Find the number of special pairs $(a,b)$ such that $...
def array(f): return list(map(f, input().split())) def floor_sum(X, N): res = 0 for i in range(X // N, X + 1): if i * i > X: for j in range(1, N + 1): if X // j >= i: res += X // j else: break break ...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR...