description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
tc = int(input()) for _ in range(tc): x = int(input()) div = 1 score = 0 while x // div >= 1: score += x // div div *= 2 print(score)
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 NUMBER WHILE BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
for asdf in range(int(input())): cur = int(input()) res = bin(cur) cnt = 0 for i in range(len(res)): if res[i : i + 1] == "1": cnt += 1 print(2 * cur - cnt)
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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
t = int(input()) while t: n = int(input()) count = n // 2 + n % 2 l1 = [] l1.append(0) l1.append(2) for i in range(2, 64): l1.append(l1[-1] * 2 + 1) n = n - n % 2 l2 = [] while n > 0: if n % 2: l2.append(1) else: l2.append(0) n ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_O...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
def solve(): n = int(input()) N = bin(n)[2:] N = N[::-1] Len = len(N) ans, pre_2, pre_1 = 0, 0, 0 for i in range(0, Len): pre_1 += i + 1 pre_2 = 2 * pre_2 + i if N[i] == "1": ans += pre_2 + (i + 1) return ans t = int(input()) for i in range(t): ans =...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR IF VAR VAR STRING VAR BIN_OP VAR BIN_OP VAR NUMBER...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
import sys input = sys.stdin.readline l = [1, 2, 4, 8, 16] x = 16 while x < 10000000000000000000: x = x * 2 l.append(x) a = [1, 2, 1, 3, 1, 2, 1] s = [0] * 7 s[0] = 1 for i in range(1, 7): s[i] = s[i - 1] + a[i] for _ in range(int(input())): n = int(input()) ts = 0 m = 0 if n < 8: p...
IMPORT ASSIGN VAR VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMB...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
t = int(input()) for _ in range(t): n = int(input()) length = 0 tempn = n while tempn > 0: length += 1 tempn = tempn >> 1 ans = 0 for i in range(length): ans += n // (1 << i) print(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 ASSIGN VAR VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
arr = [] p = 2 c = 2 for i in range(60): arr.append([p, c]) p *= 2 c += 1 arr = arr[::-1] for _ in range(int(input())): n = int(input()) ans = 0 t = 0 for i in arr: ans += n // i[0] * i[1] - t t += n // i[0] ans += n - t print(ans)
ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR LIST VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR 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 NUMBER FOR VAR VAR VAR BIN_OP BIN_OP BIN_OP V...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
t = int(input()) while t != 0: n = int(input()) n += 1 b = bin(n)[2:] ans = 0 i = 0 while 1: p = pow(2, i) temp = n div = temp // p mod = temp % p if mod > 0: div += 1 ans += div - 1 if div - 1 == 0: break i ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR NUMBER V...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
def rating_drop(n): if n == 1: return 1 d_sum = 0 d = {(0): 1} j = 1 i = 2 while i <= n: d_sum = 2 * d[j - 1] + 1 d[j] = d_sum j += 1 i *= 2 if i > n: diff = n - i // 2 x = diff p = -1 while x != 0: r = x % 2...
FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR DICT NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
tests = int(input()) for _ in range(tests): n = int(input()) x = 2 a = [0] * 11 y = 10 t = 1 ans = 0 while n + x // 2 >= x: z = (n + x // 2) // x ans += t * z t += 1 x = pow(2, t) print(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 ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR VA...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
t = int(input()) while t > 0: t -= 1 n = int(input()) n = bin(n).replace("0b", "") c = 0 for i, x in enumerate(list(n[::-1])): if x == "1": c += 2 ** (i + 1) - 1 print(c)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR STRING STRING ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF VAR STRING VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
t = int(input()) f = [] f.append(0) f.append(1) for i in range(2, 200): tmp = 2 * f[i - 1] + 1 f.append(tmp) while t > 0: t -= 1 x = int(input()) b = [] b.append(0) tot = 0 ans = 0 while x > 0: tmp = x % 2 x >>= 1 tot += 1 b.append(tmp) for i in ra...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST EXPR FUNC_...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
t = int(input()) for ab in range(t): n = int(input()) k = n count = 1 l = n while n >= 2**count: l += n // 2**count count += 1 print(l)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR BIN_OP NUMBER VAR VAR BIN_OP VAR BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
dp = [0] for i in range(1, 60): dp.append(2 * dp[i - 1] + i) t = int(input()) for _ in range(t): n = int(input()) if n == 1: print(1) continue else: b = bin(n)[2:] ln = len(b) value = 0 for x in range(ln): if b[x] == "1": i = ln...
ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER 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 IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
for _ in range(int(input())): n = int(input()) b = bin(n) b = b[2:] l = len(b) x = [] for i in range(0, l): k = n // 2 if n & 1: k += 1 x.append(k) n = n // 2 s = 0 for i in range(1, l + 1): s += x[i - 1] * i print(s)
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 ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP ...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
def solve(): n = int(input()) ans = 0 for i in range(n.bit_length() + 1): if n & 1 << i: ans += (1 << i + 1) - 1 print(ans) T = int(input()) while T > 0: T -= 1 solve()
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
t = int(input()) for _ in range(t): n = int(input()) a = len(bin(n)[2:]) ans = 0 j = 1 for i in range(a): ans += n // j j = j * 2 print(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 FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
tests = int(input()) for i in range(tests): n = int(input()) x = 0 res = 2**x - 1 result = 0 while res < n: if (n - res) % 2 ** (x + 1) == 0: result += (x + 1) * ((n - res) // 2 ** (x + 1)) else: result += (x + 1) * ((n - res) // 2 ** (x + 1) + 1) x +=...
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 BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP BIN_OP VAR VAR BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR BIN_OP N...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
t = int(input()) while t: t -= 1 n = int(input()) ans = 0 count = 1 while n > 0: if n % 2 == 1: temp = 1 else: temp = 0 n = n // 2 ans += count * (n + temp) count += 1 print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP VAR BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
n = int(input()) for i in range(n): x = int(input()) s = bin(x)[2:][::-1] rez = 0 for num, val in enumerate(s, start=1): if val == "1": rez += 2**num - 1 print(rez)
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 NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR NUMBER IF VAR STRING VAR BIN_OP BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
import sys input = sys.stdin.readline def getInt(): return int(input()) def getVars(): return map(int, input().split()) def getList(): return list(map(int, input().split())) def getStr(): return input().strip() d = [] d.append(1) for i in range(1, 70): d.append(i + 1 + sum(d)) t = getInt(...
IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR F...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
for i in range(int(input())): num = int(input()) s = 0 f = 0 temp = num while temp > 0: s += num // 2**f f += 1 temp //= 2 print(s)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER VAR BIN_OP VAR BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
c = [] for i in range(100): c.append(2**i) rw = int(input()) for ewq in range(rw): n = int(input()) f = 0 for i in range(100): f += n // c[i] print(f)
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP 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 NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
def read_int(): n = int(input()) return n def read_ints(): ints = [int(x) for x in input().split(" ")] return ints def solve(n): bn = bin(n).count("1") return n * 2 - bn t = read_int() for case in range(t): n = read_int() sol = solve(n) print(sol)
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR STRING RETURN BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
t = int(input()) while t > 0: a = int(input()) s = a while a > 0: s += a // 2 a //= 2 print(s) t -= 1
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR WHILE VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
T = int(input()) l = [1] for iss in range(60): l.append(l[-1] * 2 + 1) for isc in range(T): a = int(input()) s = bin(a)[2:] s = s[::-1] ret = 0 for i in range(len(s)): ret += int(s[i]) * l[i] print(ret)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CAL...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
def solve(n): sum = 0 digit = 1 while digit < 1 << 62: sum += n // digit digit *= 2 print(sum) t = int(input()) for _ in range(t): n = int(input()) solve(n)
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP NUMBER NUMBER VAR BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
t = int(input()) for _ in range(t): n = int(input()) largestX = 1 while 2 ** (largestX + 1) <= n: largestX += 1 cumulativeMultiples = 0 res = 0 for x in range(largestX, -1, -1): cnt = n // 2**x res += (cnt - cumulativeMultiples) * (x + 1) cumulativeMultiples += cn...
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 WHILE BIN_OP NUMBER BIN_OP VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR VAR BIN_OP BIN_OP VAR VAR BIN...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
t = int(input()) d = 1 a = [1] for i in range(1, 65): a.append(a[i - 1] * 2 + 1) for ii in range(t): n = int(input()) bin = [] while n > 0: bin.append(n % 2) n //= 2 res = 0 for i in range(len(bin) - 1, -1, -1): if bin[i] == 1: res += a[i] print(res)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST WHILE VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
def solve(n): ans = 0 count = 0 i = 1 while count <= n: first_occurence = 2 ** (i - 1) deltas = 2**i if n < first_occurence: break val = 1 + (n - first_occurence) // deltas ans += i * val count += val i += 1 return ans for _ in ra...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR IF VAR VAR ASSIGN VAR BIN_OP NUMBER BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
def main(): for q in range(int(input())): n = int(input()) cnt = 0 now = 1 while now <= n: cnt += 1 now *= 2 ans = 0 now = 1 for i in range(cnt): ans += (n + now) // (now * 2) * (i + 1) now *= 2 print(ans...
FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER EXPR FUN...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
for _ in range(int(input())): n = int(input()) n = bin(n)[2:][::-1] ans = 0 for i in range(len(n)): if n[i] == "1": ans += 2 ** (i + 1) - 1 print(ans)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
def solve(): n = int(input()) count = 0 while n > 1: count += n n = n // 2 else: print(count + 1) t = int(input()) for i in range(t): solve()
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
map = {} map[1] = 1 i = 2 while i < 10**18 + 10: map[i] = map[i // 2] * 2 + 1 i = i * 2 t = int(input()) for _ in range(t): n = int(input()) ans = 0 i = 0 while n > 0: if n % 2 == 1: ans += map[pow(2, i)] i += 1 n = n // 2 print(ans)
ASSIGN VAR DICT ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
import sys input = sys.stdin.readline ipnl = lambda n: [int(input()) for _ in range(n)] inp = lambda: int(input()) ip = lambda: [int(w) for w in input().split()] def func(n): if n == 1: return 0 return n + func(n // 2) for _ in range(inp()): n = inp() ans = func(n) print(ans + 1)
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR 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 FUNC_DEF IF VAR NUMBER RETURN NUMBER RETURN BIN_OP VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CA...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
def solve(A, B): count = 0 A = int(A, 2) B = int(B, 2) for i in range(0, 61): if A >> i & 1 != B >> i & 1: count += 1 return count for _ in range(int(input())): n = int(input()) b = bin(n)[2:] b = b[::-1] ans = 0 for bit in range(len(b)): if b[bit] =...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FU...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
q = int(input()) def p(d): if d == 1: return 1 return d + p(d - 1) d = [1] * 100 for i in range(2, 100): d[i] = i + d[i - 1] * 2 for _ in range(q): n = int(input()) if n < 2: print(n) continue s = bin(n)[2:] ans = d[len(s) - 1] + len(s) for i in range(1, len(s...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF IF VAR NUMBER RETURN NUMBER RETURN BIN_OP VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CAL...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
n = int(input()) answers = [] * 0 for problems in range(n): zzz = input() xxx = int(zzz) ans = 0 howmany = 0 count = 0 for i in range(64, -1, -1): howmany = xxx // 2**i ans += (i + 1) * (howmany - count) count += howmany answers.append(count) for answer in answers: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR VAR BIN_OP BIN_OP VAR NUMBER BIN_O...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
t = int(input()) for i in range(t): n = int(input()) temp = bin(n)[2 : len(bin(n))] t = len(temp) sum = 0 for j in range(t): sum += n // 2**j print(sum)
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 FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
import sys class CJohnnyAndAnotherRatingDrop: def solve(self, tc=0): for _ in range(int(input())): n = int(input()) ans = 0 k = 1 n -= 1 while 2 ** (k - 1) - 1 <= n: ans += k * ((n - (2 ** (k - 1) - 1)) // 2**k) + k ...
IMPORT CLASS_DEF FUNC_DEF 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 NUMBER VAR NUMBER WHILE BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER VAR VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER BIN_OP NU...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
import sys t = int(sys.stdin.readline()) while t: n = int(sys.stdin.readline()) i = 0 while 2**i <= n: i += 1 change = 0 z = 2 ** (i - 1) while z != 0: if (n + 1) % z == 0: change += (n + 1) // z - 1 else: change += (n + 1) // z z = z // 2...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE BIN_OP NUMBER VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER WHILE VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR ...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
from sys import * def solve(x): s = x i = 2 while x > 0: x = x // i s += x return s test = 1 test = int(input()) for t in range(0, test): n = int(input()) ans = solve(n) print(ans)
FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR RETURN VAR ASSIGN 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 ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
for _ in range(int(input())): n = int(input()) i = 1 j = 2 c = 0 while j // 2 <= n: c += i * ((n - j // 2) // j + 1) i += 1 j *= 2 print(c)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER VAR VAR BIN_OP VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
from sys import stdin def iinput(): return int(stdin.readline()) def sinput(): return input() def minput(): return map(int, stdin.readline().split()) def linput(): return list(map(int, stdin.readline().split())) t = iinput() while t: t -= 1 n = iinput() a = [1, 2, 1, 3, 1, 2, 1] ...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER N...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
for _ in range(0, int(input())): n = int(input()) cnt = 0 y = str(bin(n)[2:]) for i in range(len(y)): if y[i] == "1": cnt += 1 print(n * 2 - cnt)
FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
for u in range(int(input())): n = int(input()) a = 0 ans = 1 while n != 0: r = n // 2 x = n % 2 a += ans * (r + x) n = n // 2 ans += 1 print(a)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
for t in range(int(input())): N = int(input()) def calc(n): if n <= 1: return n else: return calc(n // 2) + n print(calc(N))
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF IF VAR NUMBER RETURN VAR RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
t = int(input()) for i in range(t): num = int(input()) bin_str = "" res = 0 while num != 0: if num % 2 == 1: bin_str = "1" + bin_str else: bin_str = "0" + bin_str num = num // 2 len_bin_str = len(bin_str) for idx, val in enumerate(bin_str): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CA...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
def f(x): return (1 << x + 1) - 1 for n in range(int(input())): x = int(input()) res = 0 p = 0 while x > 0: if x % 2 == 1: res += f(p) p += 1 x //= 2 print(res)
FUNC_DEF RETURN BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER 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 NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
def ans(n): count = 0 w = n while n >= 1: m = n % 2 n = n // 2 if m == 1: count += 1 return 2 * w - count m = int(input()) for i in range(m): n = int(input()) print(ans(n))
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER RETURN BIN_OP BIN_OP NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
t = int(input()) for _ in range(t): n = int(input()) ans = 0 while n >= 2: count = 0 k = n while k >= 2: k >>= 1 count += 1 ans += (1 << count + 1) - 1 n -= 1 << count if n != 0: ans += 1 print(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 WHILE VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER VAR NUMBER VAR NUMBER VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER VAR BIN_OP NUMBER VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CA...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
for _ in range(int(input())): n = int(input()) ans = 0 x = 1 while True: k = n // x if k == 0: break ans += k x *= 2 print(ans)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
def calc(l, r, s, q, n): if l > n: return 0 if r <= n: return s m = (l + r) // 2 res = 0 if m <= n: res += q res += calc(l, m - 1, (s - q) // 2, q - 1, n) res += calc(m + 1, r, (s - q) // 2, q - 1, n) return res def main(): t = int(input()) for i in rang...
FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR VAR RETURN VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER VAR RETUR...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
import sys input = sys.stdin.readline I = lambda: list(map(int, input().split())) (t,) = I() for _ in range(t): (n,) = I() an = 1 for i in range(60): x = n >> i + 1 y = n % 2 ** (i + 1) an += x * 2 + (1 if y > 2**i else 0) print(an)
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER VAR BIN_OP BIN...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
import sys def input(): return sys.stdin.readline().rstrip() t = int(input()) answers = [] for _ in range(t): n = int(input()) n = n + 1 divide_by = 1 ans = 0 for i in range(100): if divide_by > n: break if n % divide_by == 0: ans += n // divide_by - 1...
IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR IF BIN_OP VAR VAR NUMBER VAR BIN_OP BIN_OP VAR V...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
def read_int(): return int(input()) t = read_int() ans = [] for case_num in range(t): n = int(input()) ans.append(n * 2 - bin(n).count("1")) print("\n".join(map(str, ans)))
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER FUNC_CALL FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
def solve(n): ans = 0 while n > 0: ans += n n >>= 1 return ans tc = int(input()) while tc > 0: print(solve(int(input()))) tc -= 1
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
d = {} def func(n): try: return d[n] except: if n == 0: d[n] = 0 return 0 if n == 1: d[n] = 1 return 1 d[n] = 2 * func(n - 1) + 1 return d[n] for tt in range(int(input())): n = int(input()) l = bin(n)[2:] ans...
ASSIGN VAR DICT FUNC_DEF RETURN VAR VAR IF VAR NUMBER ASSIGN VAR VAR NUMBER RETURN NUMBER IF VAR NUMBER ASSIGN VAR VAR NUMBER RETURN NUMBER ASSIGN VAR VAR BIN_OP BIN_OP NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER RETURN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR A...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
for _ in range(int(input())): n = int(input()) s = bin(n)[2:] s = s[::-1] l = len(s) sm = 0 for i in range(l): if s[i] == "1": sm += pow(2, i + 1) - 1 print(sm)
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 NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
show_flg = False show_flg = True ans = 0 for _ in range(int(input())): ans = 0 x = int(input()) s = "00" + bin(x - 1)[2:] n = len(s) x = int(s, 2) y = int(s, 2) for i in range(n - 1): y >>= 1 T = y << i + 1 T += (1 << i) - 1 tmp = (i + 1) * (y + 1) if ...
ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP STRING FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR N...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
t = int(input()) for _ in range(t): n = int(input()) s = "{0:b}".format(n) cnt = 0 for i in s: if i == "1": cnt = cnt + 1 print(2 * n - cnt)
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 STRING VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
from sys import stdin, stdout def main(): from sys import stdin, stdout input = stdin.readline print = stdout.write t = int(input()) for _ in range(t): n = int(input()) answer = 0 number = 1 while number <= n: answer += n // number number *=...
FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING VAR EXPR FUNC_CALL VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
for _ in range(int(input())): n = int(input()) l = n.bit_length() - 1 ans = 0 for i in range(l, -1, -1): x = n // (1 << i) y = n // (1 << i + 1) ans += (x - y) * (i + 1) print(ans)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUM...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
ans = [] for _ in range(int(input())): n = int(input()) ansi = 0 k = 1 while k <= n: ansi += n // k k *= 2 ans.append(ansi) print("\n".join(map(str, ans)))
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
for _ in range(int(input())): n = int(input()) val = 0 ans = n result = 0 while ans > 0: val += 1 ans //= 2 for i in range(val + 1): result += n // 2**i print(result)
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 ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
T = int(input()) for t in range(T): n = int(input()) powers = 0 i = 1 res = 0 added = 0 while True: power_2 = 2**i if power_2 > n: break r = n // power_2 res += r i += 1 powers += r res += n print(res)
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 NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR BIN_OP NUMBER VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR NUMBER VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
from sys import stdin input = stdin.buffer.readline def rec(n): if n == 1: return 1 return n + rec(n // 2) for _ in range(int(input())): n = int(input()) print(rec(n))
ASSIGN VAR VAR FUNC_DEF IF VAR NUMBER RETURN NUMBER RETURN BIN_OP VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
ans = [] for kek in range(int(input())): n = int(input()) delta = 0 for i in bin(n)[2:]: if i == "1": delta += 1 ans.append(2 * n - delta) print(*ans, sep="\n")
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER IF VAR STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR VAR STRING
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
def f(n): count = n k = 1 m = 2 while n >= m: count += n // m k += 1 m *= 2 return count numberofcases = int(input()) for _ in range(numberofcases): print(f(int(input())))
FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
def read_int(): return int(input()) def read_ints(): return map(int, input().split(" ")) t = read_int() for case_num in range(t): n = read_int() f = dict() two = [1] f[1] = 1 i = 1 while i * 2 <= int(2e18): two.append(i * 2) f[i * 2] = f[i] * 2 + 1 i *= 2 ...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER FUNC_CALL VAR NUMBER...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
for t in range(int(input())): n = int(input()) bin_n = bin(n)[2:] ans = 0 l = len(bin_n) i = 1 ans = n - 1 while i < l: ans += n // 2**i i += 1 print(ans + 1)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR BIN_OP VAR BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
t = int(input()) results = [] for case in range(t): n = int(input()) ans = 2 * n - bin(n).count("1") results.append(ans) for result in results: print(result)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR FUNC_CALL FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
t = int(input()) def fun(n): a = bin(2 * n)[2:] ans = 0 for i in a: if i == "1": ans += 1 print(2 * n - ans) while t: t -= 1 n = int(input()) fun(n)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
def countSetBits(n): count = 0 while n: count += n & 1 n >>= 1 return count for _ in range(int(input())): n = int(input()) print(2 * n - countSetBits(n))
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR FUNC_CALL VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
class Solution: def __init__(self): for t in range(int(input())): n = int(input()) self.solve(n) def solve(self, n): b = format(n, "b") res = 0 while b: res += int(b, 2) b = b[:-1] print(res) Solution()
CLASS_DEF FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR STRING ASSIGN VAR NUMBER WHILE VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
__multitest__ = True def solve(): n = int(input()) ans = 0 for b in range(0, 64): if 1 << b > n: break else: ans += n // (1 << b) print(ans) t = 1 if not __multitest__ else int(input()) for tt in range(t): solve()
ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP NUMBER VAR VAR VAR BIN_OP VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
x = int(input()) while x > 0: n = int(input()) temp = bin(n) cnt = [i for i in temp[2:] if i == "1"] print(2 * n - len(cnt), sep="\n") x -= 1
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 ASSIGN VAR VAR VAR VAR NUMBER VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR FUNC_CALL VAR VAR STRING VAR NUMBER
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
for testcase in range(int(input())): n = int(input()) logs = [] i = 1 while i <= n: logs.append(i) i *= 2 unfair = 0 for log in logs: unfair += n // log print(unfair)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
def readintlst(): return list(map(int, input().split(" "))) def readn(): return int(input()) for _ in range(readn()): n = readn() ans = 0 while n >= 1: ans += n n //= 2 print(ans)
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
def solve(a): t = a while a != 1: a //= 2 t += a return t n = int(input()) for i in range(n): k = int(input()) print(solve(k))
FUNC_DEF ASSIGN VAR VAR WHILE VAR NUMBER VAR NUMBER 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 EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
def answer(): n = map(int, list(bin(int(input())))[-1:1:-1]) return sum([(2**i * 2 - 1) for i, ni in enumerate(n) if ni]) for _ in range(int(input())): print(answer())
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER NUMBER NUMBER RETURN FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER VAR VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
t = int(input()) f = [0] * 70 f[0] = 0 for i in range(1, 70): f[i] = f[i - 1] * 2 + i for _ in range(t): n = int(input()) sum = 0 for i in range(64, 0, -1): if 1 << i <= n < 1 << i + 1: sum += f[i] + i + 1 n -= 1 << i if n: sum += 1 print(sum)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NU...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
for tc in range(int(input())): n = int(input()) b = bin(n)[2:] l = len(b) maxi = 2**l ans = n for i in range(1, l): ans += n // 2**i print(ans)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
def read_list(): return list(map(int, input().split(" "))) def print_list(l): print(" ".join(map(str, l))) d = [0] for i in range(1, 61): d.append(d[-1] + (1 << i) - 1) N = int(input()) for _ in range(N): n = int(input()) ans = 0 k = 0 while n: if n & 1: ans += d[k] +...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER BIN_OP NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
t = int(input()) for i in range(t): n = int(input()) p = 0 res = 0 while 1 << p <= n: power = 1 << p if power & n > 0: res += power * 2 - 1 p += 1 print(res)
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 NUMBER WHILE BIN_OP NUMBER VAR VAR ASSIGN VAR BIN_OP NUMBER VAR IF BIN_OP VAR VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
t = int(input()) for iteration in range(0, t): n = int(input()) res = 0 for _pow in range(0, 65): if (n + 1) % (1 << _pow) == 0: res += (n + 1) // (1 << _pow) - 1 else: res += (n + 1) // (1 << _pow) print(res)
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 NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP BIN_OP VAR NUMBER BIN_OP NUMBER VAR NUMBER VAR BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP NUMBER VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER BIN_OP NUMBE...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
def diff(a, b): masked = a ^ b s = "{0:b}".format(masked) ret = len([c for c in s if c == "1"]) return ret def ans(n): ret = 0 for i in range(0, n): ret += diff(i, i + 1) return ret def fast_ans(n): s = "{0:b}".format(n) return 2 * n - len([c for c in s if c == "1"]) T ...
FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR STRING RETURN VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL STRING VAR RETURN BIN_OP BIN_OP NUMBER VAR FUNC_CALL ...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
def main(): t = int(input()) for _ in range(t): x = int(input()) k = 1 s = 0 while x != 0: r = x % 2 x = x // 2 s += (x + r) * k k += 1 print(s) main()
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
t = int(input()) for _ in range(t): n = int(input()) t = bin(n)[2:] sum = 2 * n for i in t: if i == "1": sum -= 1 print(sum)
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 BIN_OP NUMBER VAR FOR VAR VAR IF VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
import sys MAX = 10**18 f = [None] SUM = 0 i = 1 while MAX != 0: f.append(SUM + i) SUM += SUM + i i += 1 MAX //= 2 for _ in range(int(input())): n = int(sys.stdin.readline()) i = 1 ans = 0 while n != 0: if n % 2 == 1: ans += f[i] i += 1 n //= 2 pr...
IMPORT ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR LIST NONE ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR NUMBER VAR 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 NUMBER WHILE V...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
import sys input = lambda: sys.stdin.readline().rstrip() t = int(input()) for _ in range(t): n = int(input()) i = 0 ans = 0 while True: j = 2**i cnt = (n + 1) // j + int((n + 1) % j != 0) if cnt == 1: break ans += cnt - 1 i += 1 print(ans)
IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
D = {} i = 1 while i < 1e18: D[i] = i ^ i - 1 i = i * 2 for _ in range(int(input())): a = int(input()) c = 0 s = 0 while a > 0: s = s + a % 2 * D[2**c] a = a // 2 c = c + 1 print(s)
ASSIGN VAR DICT ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR 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 NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER VAR BIN...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
t = int(input()) while t: t -= 1 n = int(input()) ones = 0 ans = 2 * n while n: if n & 1: ones += 1 n //= 2 print(ans - ones)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR WHILE VAR IF BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
d = {(1): 1, (2): 3, (3): 4} def count(n): if n == 0: return 0 a = str(bin(n).replace("0b", "")) b = len(a) if b < 3: return d[n] ans = 2**b extra = n - 2 ** (b - 1) return ans + count(extra) - 1 for _ in range(int(input())): n = int(input()) print(count(n))
ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR VAR STRING STRING ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER RETURN VAR VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER RETURN BIN_OP BIN...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
for _ in range(int(input())): n = int(input()) ans = 0 cnt = 1 b = 2 while b <= n: ans += cnt ans += cnt * ((n - 2 ** (cnt - 1)) // b) cnt += 1 b *= 2 if n >= 2 ** (cnt - 1): ans += cnt print(ans)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR VAR BIN_OP VAR BIN_OP BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER VAR VAR NUMBER VAR NUMBER IF VAR BIN_OP NUMBER BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VA...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
t = int(input()) count = 0 while count < t: count += 1 a = int(input()) ans = 0 add = 1 while a > 0: thing = 0 if a % 2 == 0: thing += int(a // 2) else: thing += int((a + 1) // 2) ans += thing * add a -= thing add += 1 print...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
def func(): n = int(input()) ans = 0 for i in range(0, 62): if 1 << i & n == 1 << i: ans += (1 << i + 1) - 1 print(ans) no = int(input()) for i in range(0, no): func()
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
y = [0] * 100 y[0] = 1 for i in range(1, 100): y[i] = y[i - 1] * 2 + 1 for i in range(int(input())): n = int(input()) ans = 0 r = 0 while n > 0: if n % 2 == 1: ans = ans + y[r] n = n // 2 r += 1 print(ans)
ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER 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 NUMBER WHILE VAR NUMBER IF BIN_OP VAR N...
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
def solve(): x = int(input()) res = 0 p = 0 while x > 0: if x % 2 == 1: res += (1 << p + 1) - 1 p += 1 x //= 2 print(res) for n in range(int(input())): solve()
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participan...
import sys def solve_query(): r = 0 for i in range(150): if n // 2**i == 0: break r += n // 2**i print(r) lines = sys.stdin.readlines() t = int(lines[0]) for i in range(1, t + 1): n = int(lines[i]) solve_query()
IMPORT FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR NUMBER VAR BIN_OP VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR