description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of some string s and wants to know the number of pairs of words of length |s| (length of s), such that their bit...
t = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_" d = {x: (0) for x in t} for i in range(64): for j in range(64): d[t[i & j]] += 1 s = input() ss = 1 for i in s: ss *= d[i] ss %= 10**9 + 7 print(ss)
ASSIGN VAR STRING ASSIGN VAR VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR VAR VAR VAR VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR VAR
While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of some string s and wants to know the number of pairs of words of length |s| (length of s), such that their bit...
table = [] for i in range(0, 64): ans = -1 for z in bin(i): if z == "0": ans += 1 table.append(ans + 8 - len(bin(i))) s = input() ans = 1 for i in s: if i == "_": z = 63 elif i == "-": z = 62 elif i.isdigit(): z = int(i) elif ord(i) >= 97: ...
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING ASSIGN VAR NUMBER IF VAR STRING ASSIGN VAR NUMBER IF F...
While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of some string s and wants to know the number of pairs of words of length |s| (length of s), such that their bit...
s = input() MOD = 10**9 + 7 a = {} b = [] k = 0 for i in range(ord("0"), ord("9") + 1): a[chr(i)] = k k += 1 b.append(chr(i)) for i in range(ord("A"), ord("Z") + 1): a[chr(i)] = k k += 1 b.append(chr(i)) for i in range(ord("a"), ord("z") + 1): a[chr(i)] = k k += 1 b.append(chr(i)) a[...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR DICT ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR STRING BIN_OP FUNC_CALL VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR STRI...
While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of some string s and wants to know the number of pairs of words of length |s| (length of s), such that their bit...
def getLetterNumber(letter): if "0" <= letter <= "9": return ord(letter) - ord("0") if "A" <= letter <= "Z": return ord(letter) - ord("A") + 10 if "a" <= letter <= "z": return ord(letter) - ord("a") + 36 if letter == "-": return 62 if letter == "_": return 63 ...
FUNC_DEF IF STRING VAR STRING RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING IF STRING VAR STRING RETURN BIN_OP BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING NUMBER IF STRING VAR STRING RETURN BIN_OP BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING NUMBER IF VAR STRING RETURN NUMBER IF VAR STRING RETURN NUMBER FUNC_...
While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of some string s and wants to know the number of pairs of words of length |s| (length of s), such that their bit...
str_in = input() def decode_char(c): if "0" <= c <= "9": return ord(c) - ord("0") elif "A" <= c <= "Z": return ord(c) - ord("A") + 10 elif "a" <= c <= "z": return ord(c) - ord("a") + 36 elif "-" == c: return 62 elif "_" == c: return 63 assert False res...
ASSIGN VAR FUNC_CALL VAR FUNC_DEF IF STRING VAR STRING RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING IF STRING VAR STRING RETURN BIN_OP BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING NUMBER IF STRING VAR STRING RETURN BIN_OP BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING NUMBER IF STRING VAR RETURN NUMBER IF STRIN...
While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of some string s and wants to know the number of pairs of words of length |s| (length of s), such that their bit...
alth = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_" s = input() ai = [ 729, 243, 243, 81, 243, 81, 81, 27, 243, 81, 81, 27, 81, 27, 27, 9, 243, 81, 81, 27, 81, 27, 27, 9, 81, 27, 27, 9, ...
ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NU...
While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of some string s and wants to know the number of pairs of words of length |s| (length of s), such that their bit...
s = input() ans = 1 d = {"-": 62, "_": 63} ad = {} for i in range(10): d[str(i)] = i for i in range(10, 36): d[chr(i + 55)] = i for i in range(36, 62): d[chr(i + 61)] = i def adn(x): res, t = 0, d[x] for i in range(64): for j in range(64): if j & i == t: res += ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR DICT STRING STRING NUMBER NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR ...
While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of some string s and wants to know the number of pairs of words of length |s| (length of s), such that their bit...
s = input() freq = [0] * 64 for i in range(64): for j in range(64): freq[i & j] += 1 mod = 10**9 + 7 ans = 1 for i in s: if "0" <= i <= "9": b = int(i) elif "A" <= i <= "Z": b = ord(i) - ord("A") + 10 elif "a" <= i <= "z": b = ord(i) - ord("a") + 36 elif i == "-": ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF STRING VAR STRING ASSIGN VAR FUNC_CALL VAR VAR IF STRING VAR STRING ASSIGN VAR BIN_OP BIN_OP FU...
While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of some string s and wants to know the number of pairs of words of length |s| (length of s), such that their bit...
def rev(c): if c.isdigit(): return ord(c) - ord("0") elif c.isupper(): return 10 + ord(c) - ord("A") elif c.islower(): return 36 + ord(c) - ord("a") elif c == "-": return 62 else: return 63 counter = [0] * 64 for i in range(64): for j in range(64): ...
FUNC_DEF IF FUNC_CALL VAR RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING IF FUNC_CALL VAR RETURN BIN_OP BIN_OP NUMBER FUNC_CALL VAR VAR FUNC_CALL VAR STRING IF FUNC_CALL VAR RETURN BIN_OP BIN_OP NUMBER FUNC_CALL VAR VAR FUNC_CALL VAR STRING IF VAR STRING RETURN NUMBER RETURN NUMBER ASSIGN VAR BIN_OP LIST NUMBER N...
While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of some string s and wants to know the number of pairs of words of length |s| (length of s), such that their bit...
def sti(x): o = 0 x = x[::-1] k = 1 ans = 1 for i in x: l = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_" o = l.index(i) * k for i in range(0, 6): if o & 2**i == 0: ans = ans * 3 % 1000000007 return ans def bth(x): x ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER RETURN VAR FUNC_DEF ASSIGN VAR VAR NUMBER ASSIG...
While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of some string s and wants to know the number of pairs of words of length |s| (length of s), such that their bit...
s, ans = input(), 1 for x in s: if "0" <= x <= "9": t = ord(x) - 48 if "A" <= x <= "Z": t = ord(x) - 55 if "a" <= x <= "z": t = ord(x) - 61 if x == "-": t = 62 if x == "_": t = 63 ans = ans * 3 ** (6 - bin(t).count("1")) % 1000000007 print(ans)
ASSIGN VAR VAR FUNC_CALL VAR NUMBER FOR VAR VAR IF STRING VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF STRING VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF STRING VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR STRING ASSIGN VAR NUMBER IF VAR STRING ASSIGN VAR NUMBER ASSIGN VAR BIN_O...
While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of some string s and wants to know the number of pairs of words of length |s| (length of s), such that their bit...
palavra = input() num_de_pares = 0 for i in palavra: if i >= "0" and i <= "9": unicode = ord(i) - 48 binario = bin(unicode) num_de_um = binario.count("1") num_de_pares += 6 - num_de_um if i >= "A" and i <= "Z": unicode = ord(i) - 55 binario = bin(unicode) ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING VAR BIN_OP NUMBER VAR IF VAR STRING VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_C...
While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of some string s and wants to know the number of pairs of words of length |s| (length of s), such that their bit...
def get_num(sym): if sym in "0123456789": return int(sym) if sym == "-": return 62 if sym == "_": return 63 if ord("a") <= ord(sym) <= ord("z"): return ord(sym) - ord("a") + 36 else: return ord(sym) - ord("A") + 10 def bins(x): return bin(x)[2:] p = 10...
FUNC_DEF IF VAR STRING RETURN FUNC_CALL VAR VAR IF VAR STRING RETURN NUMBER IF VAR STRING RETURN NUMBER IF FUNC_CALL VAR STRING FUNC_CALL VAR VAR FUNC_CALL VAR STRING RETURN BIN_OP BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING NUMBER RETURN BIN_OP BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING NUMBER FUNC_DEF RETURN FUN...
While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of some string s and wants to know the number of pairs of words of length |s| (length of s), such that their bit...
def numZero(x): cnt = 0 for i in range(6): if x & 1 << i == 0: cnt += 1 return cnt bits = list("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_") nums = [i for i in range(64)] dicts = dict(zip(bits, nums)) s = input() total = 1 for c in s: t = dicts[c] zeros = ...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR...
While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of some string s and wants to know the number of pairs of words of length |s| (length of s), such that their bit...
def orf(x): if x == "-": return 62 if x == "_": return 63 x = ord(x) if x in range(ord("0"), ord("9") + 1): return x - ord("0") if x in range(ord("A"), ord("Z") + 1): return x - ord("A") + 10 if x in range(ord("a"), ord("z") + 1): return x - ord("a") + 36 ...
FUNC_DEF IF VAR STRING RETURN NUMBER IF VAR STRING RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR FUNC_CALL VAR FUNC_CALL VAR STRING BIN_OP FUNC_CALL VAR STRING NUMBER RETURN BIN_OP VAR FUNC_CALL VAR STRING IF VAR FUNC_CALL VAR FUNC_CALL VAR STRING BIN_OP FUNC_CALL VAR STRING NUMBER RETURN BIN_OP BIN_OP VAR FUNC_CAL...
While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of some string s and wants to know the number of pairs of words of length |s| (length of s), such that their bit...
s = input() enc = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_" d = dict() for i in range(len(enc)): d[enc[i]] = i ans = 0 for c in s: x = bin(d[c]) x = x.rjust(8, "0") ans += x.count("0") - 1 M0D = 10**9 + 7 print(pow(3, ans, M0D))
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER STRING VAR BIN_OP FUNC_CALL VAR STRING NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER EX...
While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of some string s and wants to know the number of pairs of words of length |s| (length of s), such that their bit...
MOD = 1000000007 def main(): opts = [0] * 64 for i in range(64): for j in range(64): opts[i & j] += 1 s = input() n = len(s) ans = 1 for c in s: if "0" <= c <= "9": ans *= opts[ord(c) - ord("0")] ans %= MOD elif "A" <= c <= "Z": ...
ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF STRING VAR STRING VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING VAR VAR IF ST...
While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of some string s and wants to know the number of pairs of words of length |s| (length of s), such that their bit...
c = 0 for l in input(): if l.islower(): v = ord(l) - 61 elif l.isupper(): v = ord(l) - 55 elif l.isdigit(): v = int(l) else: v = 62 if l == "-" else 63 c += 6 - bin(v).count("1") print(3**c % (7 + 10**9))
ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR IF FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR STRING NUMBER NUMBER VAR BIN_OP NUMBER FUNC_CALL FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP...
While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of some string s and wants to know the number of pairs of words of length |s| (length of s), such that their bit...
zcount = [ 6, 5, 5, 4, 5, 4, 4, 3, 5, 4, 4, 3, 4, 3, 3, 2, 5, 4, 4, 3, 4, 3, 3, 2, 4, 3, 3, 2, 3, 2, 2, 1, 5, 4, 4, 3, 4, 3, 3, 2, 4, 3, 3, 2, ...
ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUM...
While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of some string s and wants to know the number of pairs of words of length |s| (length of s), such that their bit...
from itertools import chain data = input() MOD = 10**9 + 7 translate = [ chr(x) for x in chain( list(range(ord("0"), ord("9") + 1)), list(range(ord("A"), ord("Z") + 1)), list(range(ord("a"), ord("z") + 1)), [ord("-"), ord("_")], ) ] assert len(translate) == 64 translate2 = {...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR STRING BIN_OP FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR STRING BIN_OP FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR FUNC_CALL VAR FUNC_C...
While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of some string s and wants to know the number of pairs of words of length |s| (length of s), such that their bit...
def main(): def f1(c): x = ord(c) if ord("0") <= x <= ord("9"): res = int(c) elif ord("A") <= x <= ord("Z"): res = x - ord("A") + 10 elif ord("a") <= x <= ord("z"): res = x - ord("a") + 36 elif c == "-": res = 62 elif c...
FUNC_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR STRING VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR STRING VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR STRING NUMBER IF FUNC_CALL VAR STRING VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL V...
While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of some string s and wants to know the number of pairs of words of length |s| (length of s), such that their bit...
ans = 1 MOD = int(1000000000.0 + 7) cnt = [0] * 64 for i in range(64): for j in range(64): cnt[i & j] += 1 s = input() for i in s: if i >= "0" and i <= "9": ans *= cnt[ord(i) - ord("0")] elif i >= "A" and i <= "Z": ans *= cnt[ord(i) - ord("A") + 10] elif i >= "a" and i <= "z": ...
ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR STRING VAR STRING VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING IF VAR STRING VAR S...
While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of some string s and wants to know the number of pairs of words of length |s| (length of s), such that their bit...
s = input() v = [] for l in s: if 48 <= ord(l) <= 57: v.append(ord(l) - 48) elif 65 <= ord(l) <= 90: v.append(ord(l) - 55) elif 97 <= ord(l) <= 122: v.append(ord(l) - 61) elif l == "-": v.append(62) elif l == "_": v.append(63) assert len(v) == len(s) mods = [0...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR IF NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR ST...
While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of some string s and wants to know the number of pairs of words of length |s| (length of s), such that their bit...
def str_to_array(s): array = [None] * len(s) for i, c in enumerate(s): code = ord(c) if 48 <= code <= 57: array[i] = code - 48 elif 65 <= code <= 90: array[i] = code - 55 elif 97 <= code <= 122: array[i] = code - 61 elif code == 45: ...
FUNC_DEF ASSIGN VAR BIN_OP LIST NONE FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF NUMBER VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER IF NUMBER VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER IF NUMBER VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR N...
While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of some string s and wants to know the number of pairs of words of length |s| (length of s), such that their bit...
d = {} for i in range(10): temp = i bits = 0 while temp > 0: if temp & 1: bits += 1 temp = temp >> 1 d[str(i)] = 6 - bits curr = 10 for i in range(26): temp = curr bits = 0 while temp > 0: if temp & 1: bits += 1 temp = temp >> 1 d[c...
ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER...
While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of some string s and wants to know the number of pairs of words of length |s| (length of s), such that their bit...
x = input() a = [] for c in x: if 48 <= ord(c) <= 57: a.append(ord(c) - 48) elif 65 <= ord(c) <= 90: a.append(ord(c) - 55) elif 97 <= ord(c) <= 122: a.append(ord(c) - 61) elif c == "-": a.append(62) elif c == "_": a.append(63) m = 10**9 + 7 ans = 1 for num in ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR IF NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR ST...
While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of some string s and wants to know the number of pairs of words of length |s| (length of s), such that their bit...
def ordd(s): if s == "-": return 62 elif s == "_": return 63 elif s in "0123456789": return int(s) elif ord("a") <= ord(s) <= ord("z"): return ord(s) - 61 elif ord("A") <= ord(s) <= ord("Z"): return ord(s) - 55 s = input() b = "" res = 1 h = "" for i in rang...
FUNC_DEF IF VAR STRING RETURN NUMBER IF VAR STRING RETURN NUMBER IF VAR STRING RETURN FUNC_CALL VAR VAR IF FUNC_CALL VAR STRING FUNC_CALL VAR VAR FUNC_CALL VAR STRING RETURN BIN_OP FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR STRING FUNC_CALL VAR VAR FUNC_CALL VAR STRING RETURN BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR F...
While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of some string s and wants to know the number of pairs of words of length |s| (length of s), such that their bit...
cyph = ( [str(x) for x in range(10)] + [chr(65 + i) for i in range(26)] + [chr(97 + i) for i in range(26)] + ["-"] + ["_"] ) dct = {} def decod(char): i = 0 if char in dct: return dct[char] else: while cyph[i] != char: i += 1 dct[char] = i re...
ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR NUMBER LIST STRING LIST STRING ASSIGN VAR DICT FUNC_DEF ASSIGN VAR NUMBER IF VAR VAR RETURN VAR VAR WHILE VAR VAR VAR VAR NUMBER AS...
JJ had an array A of length N such that 0 ≤ A_{i} < 2^{30} for all 1 ≤ i ≤ N. He listed down the [XOR] of all the [subsequences] of A of size ≥ (N - 1) in some random order. Let's call the XOR of these (N + 1) subsequences as B_{1}, B_{2}, \ldots, B_{N+1}. Unfortunately, he lost the initial array A. Can you help him...
t = int(input()) for _ in range(t): n = int(input()) nums = list(map(int, input().split())) if n % 2 != 0: X = 0 for i in nums: X ^= i nums.remove(X) A = list(map(lambda a: a ^ X, nums)) A.sort() else: X = min(nums) nums.remove(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 FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR EX...
JJ had an array A of length N such that 0 ≤ A_{i} < 2^{30} for all 1 ≤ i ≤ N. He listed down the [XOR] of all the [subsequences] of A of size ≥ (N - 1) in some random order. Let's call the XOR of these (N + 1) subsequences as B_{1}, B_{2}, \ldots, B_{N+1}. Unfortunately, he lost the initial array A. Can you help him...
t = int(input()) for _ in range(t): n = int(input()) arr = list(map(int, input().split())) if n % 2 != 0: tm = 0 for ele in arr: tm = tm ^ ele ans = [] for ele in arr: if ele != tm: ans.append(ele ^ tm) while len(ans) < n: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP ...
JJ had an array A of length N such that 0 ≤ A_{i} < 2^{30} for all 1 ≤ i ≤ N. He listed down the [XOR] of all the [subsequences] of A of size ≥ (N - 1) in some random order. Let's call the XOR of these (N + 1) subsequences as B_{1}, B_{2}, \ldots, B_{N+1}. Unfortunately, he lost the initial array A. Can you help him...
t = int(input()) while t > 0: t -= 1 n = int(input()) arr = [int(i) for i in input().split()] if n % 2 == 0: m = min(arr) arr.pop(arr.index(m)) arr = [(i ^ m) for i in arr] print(*arr) else: d = 0 for i in arr: d ^= i arr.pop(arr.in...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN...
JJ had an array A of length N such that 0 ≤ A_{i} < 2^{30} for all 1 ≤ i ≤ N. He listed down the [XOR] of all the [subsequences] of A of size ≥ (N - 1) in some random order. Let's call the XOR of these (N + 1) subsequences as B_{1}, B_{2}, \ldots, B_{N+1}. Unfortunately, he lost the initial array A. Can you help him...
t = int(input()) for _ in range(t): n = int(input()) b = list(map(int, input().split())) if n % 2: xor = 0 for el in b: xor = xor ^ el else: xor = min(b) a, f = [], False for el in b: if el != xor or f: a += [~xor & el | ~el & xor] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR LIST NUMBER FOR VAR VAR IF V...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. Nim is a well-known combinatorial game, based on removing stones from piles. In this problem, we'll deal with a similar game, which we'll call Dual Nim. The rules of this game are as follows: Initially, there are N piles of stones, numbered...
t = int(input()) for _ in range(t): n = int(input()) num = list(map(int, input().split())) ans = 0 for i in range(n): ans = ans ^ num[i] if ans == 0: print("First") else: for j in range(n + 1): count = 0 for i in range(n): if num[i]...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NU...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. Nim is a well-known combinatorial game, based on removing stones from piles. In this problem, we'll deal with a similar game, which we'll call Dual Nim. The rules of this game are as follows: Initially, there are N piles of stones, numbered...
test = int(input()) for i in range(0, test): n = int(input()) a = list(map(int, input().split())) ini_res = 0 for j in a: ini_res = ini_res ^ j win = "First" if ini_res != 0: if n % 2 != 0: win = "Second" print(win)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR STRING IF VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR STRING EXPR FUN...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. Nim is a well-known combinatorial game, based on removing stones from piles. In this problem, we'll deal with a similar game, which we'll call Dual Nim. The rules of this game are as follows: Initially, there are N piles of stones, numbered...
for t in range(int(input())): n = int(input()) nums = [int(x) for x in input().split()] ans = 0 for num in nums: ans = ans ^ num if ans == 0: print("First") elif n % 2 == 0: print("First") else: print("Second")
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRIN...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. Nim is a well-known combinatorial game, based on removing stones from piles. In this problem, we'll deal with a similar game, which we'll call Dual Nim. The rules of this game are as follows: Initially, there are N piles of stones, numbered...
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) x = 0 freq = [0] * 501 for i in range(n): x ^= a[i] freq[a[i]] += 1 if x == 0: print("First") else: ans = 1 for i in range(1, 501): if freq[i] != 0: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR N...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. Nim is a well-known combinatorial game, based on removing stones from piles. In this problem, we'll deal with a similar game, which we'll call Dual Nim. The rules of this game are as follows: Initially, there are N piles of stones, numbered...
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) s = a[0] for i in range(1, len(a)): s ^= a[i] if s == 0 or n % 2 == 0: print("First") else: print("Second")
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR VAR VAR IF VAR NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. Nim is a well-known combinatorial game, based on removing stones from piles. In this problem, we'll deal with a similar game, which we'll call Dual Nim. The rules of this game are as follows: Initially, there are N piles of stones, numbered...
t = int(input()) for u in range(t): n = int(input()) a = [] x = 0 s = input().split() for i in range(n): x = x ^ int(s[i]) if x is 0: print("First") elif n % 2 is 0: print("First") else: print("Second")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER NUMBER EXPR FUNC...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. Nim is a well-known combinatorial game, based on removing stones from piles. In this problem, we'll deal with a similar game, which we'll call Dual Nim. The rules of this game are as follows: Initially, there are N piles of stones, numbered...
T = int(input()) for t in range(T): n = int(input()) A = list(map(int, input().split(" "))) res = 0 for i in A: res ^= i print("First") if res == 0 else print("Second") if n & 1 else print("First")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR VAR VAR VAR EXPR VAR NUMBER FUNC_CALL VAR STRING BIN_OP VAR NUMBER FUNC_CALL VAR STRING FUNC_CALL VAR STRING
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. Nim is a well-known combinatorial game, based on removing stones from piles. In this problem, we'll deal with a similar game, which we'll call Dual Nim. The rules of this game are as follows: Initially, there are N piles of stones, numbered...
t = int(input()) for i in range(t): n = int(input()) a = list(map(int, input().split(" "))) b = [(0) for j in range(n)] xor = 0 for j in range(n): xor ^= a[j] j = 0 while True: if xor == 0: if j % 2 == 0: print("First") else: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR NUMBER WHILE NUMBER IF VAR NUMBER I...
You are given a sequence of N integer numbers A. Calculate the sum of A_{i} AND A_{j} for all the pairs (i, j) where i < j. The AND operation is the Bitwise AND operation, defined as in here. ------ Input ------ The first line of input consists of the integer N. The second line contains N integer numbers - the s...
def answer(): bit = [0] * 30 for x in a: for i in range(30): if x >> i & 1: bit[i] += 1 ans = 0 for i in range(len(bit)): ans += bit[i] * (bit[i] - 1) // 2 * (1 << i) return ans n = int(input()) a = list(map(int, input().split())) print(answer())
FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR NUMBER NUMBER BIN_OP NUMBER VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VA...
You are given a sequence of N integer numbers A. Calculate the sum of A_{i} AND A_{j} for all the pairs (i, j) where i < j. The AND operation is the Bitwise AND operation, defined as in here. ------ Input ------ The first line of input consists of the integer N. The second line contains N integer numbers - the s...
def solve(): n = int(input()) A = [int(x) for x in input().split()] count, res = [0] * 32, 0 for x in A: p = 1 for i in range(32): if x & 1 << i: res += p * count[i] count[i] += 1 p *= 2 print(res) solve()
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP LIST NUMBER NUMBER NUMBER FOR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR VAR BIN_OP VAR VAR VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR...
You are given a sequence of N integer numbers A. Calculate the sum of A_{i} AND A_{j} for all the pairs (i, j) where i < j. The AND operation is the Bitwise AND operation, defined as in here. ------ Input ------ The first line of input consists of the integer N. The second line contains N integer numbers - the s...
n = int(input()) nums = [int(j) for j in input().split()] encoding = [(0) for _ in range(30)] for num in nums: m = num for i in range(30): encoding[i] += m % 2 m = m // 2 print(sum([(2**i * encoding[i] * (encoding[i] - 1) // 2) for i in range(30)]))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VA...
You are given a sequence of N integer numbers A. Calculate the sum of A_{i} AND A_{j} for all the pairs (i, j) where i < j. The AND operation is the Bitwise AND operation, defined as in here. ------ Input ------ The first line of input consists of the integer N. The second line contains N integer numbers - the s...
n = int(input()) num = list(map(int, input().split())) ans = 0 for i in range(32): ct = 0 for j in range(n): if 1 << i & num[j] == 1 << i: ct += 1 ans += (1 << i) * (ct * (ct - 1)) // 2 print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP NUMBER VAR VAR VAR BIN_OP NUMBER VAR VAR NUMBER VAR BIN_OP BIN_OP BIN_OP NUMBER VAR BIN_OP VAR BIN_OP VAR ...
You are given a sequence of N integer numbers A. Calculate the sum of A_{i} AND A_{j} for all the pairs (i, j) where i < j. The AND operation is the Bitwise AND operation, defined as in here. ------ Input ------ The first line of input consists of the integer N. The second line contains N integer numbers - the s...
def ans(arr, n): ans = 0 for i in range(n): for j in range(i + 1, n): ans += arr[i] & arr[j] print(ans) def ans2(arr, n): bits = [0] * 31 for i in arr: z = 1 x = 0 while z <= i: if z & i: bits[x] += 1 x += 1 ...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR...
You are given a sequence of N integer numbers A. Calculate the sum of A_{i} AND A_{j} for all the pairs (i, j) where i < j. The AND operation is the Bitwise AND operation, defined as in here. ------ Input ------ The first line of input consists of the integer N. The second line contains N integer numbers - the s...
n = int(input()) arr = list(map(int, input().split())) arr.sort() count = 0 for i in range(32): k = 1 << i sum = 0 for j in range(n): if k & arr[j]: sum += 1 count += k * (sum * (sum - 1) // 2) print(count)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR NUMBER VAR BIN_OP VAR BIN_OP BIN_OP VAR BIN_OP VA...
You are given a sequence of N integer numbers A. Calculate the sum of A_{i} AND A_{j} for all the pairs (i, j) where i < j. The AND operation is the Bitwise AND operation, defined as in here. ------ Input ------ The first line of input consists of the integer N. The second line contains N integer numbers - the s...
n = int(input()) arr = list(map(int, input().split()))[:n] total = 0 for i in range(0, 30): y = 0 for j in arr: if j & 2**i: y += 1 total += y * (y - 1) // 2 * 2**i print(total)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR BIN_OP NUMBER VAR VAR NUMBER VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP NUMBER VAR EXPR FUNC_C...
You are given a sequence of N integer numbers A. Calculate the sum of A_{i} AND A_{j} for all the pairs (i, j) where i < j. The AND operation is the Bitwise AND operation, defined as in here. ------ Input ------ The first line of input consists of the integer N. The second line contains N integer numbers - the s...
def sol(A): ans = 0 for i in range(0, 30 + 1): count = 0 for j in A: if 1 << i & j != 0: count = count + 1 ans += (1 << i) * (count * (count - 1)) // 2 return ans n = int(input()) A = list(map(int, input().split())) print(sol(A))
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP BIN_OP NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP BIN_OP NUMBER VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VA...
You are given a sequence of N integer numbers A. Calculate the sum of A_{i} AND A_{j} for all the pairs (i, j) where i < j. The AND operation is the Bitwise AND operation, defined as in here. ------ Input ------ The first line of input consists of the integer N. The second line contains N integer numbers - the s...
n = int(input()) arr = list(map(int, input().split())) s = 0 size = len(bin(max(arr))[2:]) arr = [bin(i)[2:].zfill(size) for i in arr] s = 0 for i in range(size): count = 0 for j in range(n): if arr[j][i] == "1": count += 1 s += count * (count - 1) // 2 * 2 ** (size - i - 1) print(s)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC...
You are given a sequence of N integer numbers A. Calculate the sum of A_{i} AND A_{j} for all the pairs (i, j) where i < j. The AND operation is the Bitwise AND operation, defined as in here. ------ Input ------ The first line of input consists of the integer N. The second line contains N integer numbers - the s...
n = int(input()) a = list(map(int, input().split())) bits = [0] * 32 for i in range(32): for j in range(n): bits[i] += a[j] & 1 a[j] >>= 1 ans = 0 for i in range(32): ans += bits[i] * (bits[i] - 1) // 2 * 2**i print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR BIN_OP BIN_OP BIN_OP VAR V...
You are given a sequence of N integer numbers A. Calculate the sum of A_{i} AND A_{j} for all the pairs (i, j) where i < j. The AND operation is the Bitwise AND operation, defined as in here. ------ Input ------ The first line of input consists of the integer N. The second line contains N integer numbers - the s...
n = int(input()) arr = [int(x) for x in input().split()] ans = 0 for i in range(32): cnt = 0 for ele in arr: if ele & 1 << i: cnt = cnt + 1 cnt = cnt * (cnt - 1) // 2 ans += cnt * (1 << i) print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR BIN_OP NUMBER VAR...
You are given a sequence of N integer numbers A. Calculate the sum of A_{i} AND A_{j} for all the pairs (i, j) where i < j. The AND operation is the Bitwise AND operation, defined as in here. ------ Input ------ The first line of input consists of the integer N. The second line contains N integer numbers - the s...
N = int(input()) A = list(map(int, input().split())) onesCnt = [0] * 30 for i in range(N): val = A[i] bitPos = 0 while val > 0: onesCnt[bitPos] += val % 2 bitPos += 1 val = int(val / 2) ans = 0 for b in range(30): ans += int(2**b * onesCnt[b] * (onesCnt[b] - 1) / 2) print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER...
You are given a sequence of N integer numbers A. Calculate the sum of A_{i} AND A_{j} for all the pairs (i, j) where i < j. The AND operation is the Bitwise AND operation, defined as in here. ------ Input ------ The first line of input consists of the integer N. The second line contains N integer numbers - the s...
size = int(input()) arr = list(map(int, input().split())) setbit = [0] * 32 for num in arr: i = 0 while num > 0: if num & 1: setbit[i] += 1 i += 1 num = num // 2 ans = 0 for i in range(32): f = setbit[i] ans += f * (f - 1) * 2**i // 2 print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN ...
You are given a sequence of N integer numbers A. Calculate the sum of A_{i} AND A_{j} for all the pairs (i, j) where i < j. The AND operation is the Bitwise AND operation, defined as in here. ------ Input ------ The first line of input consists of the integer N. The second line contains N integer numbers - the s...
def optimal(n, li): dt = dict() for val in li: binary = bin(val)[2:][::-1] for pos, bit in enumerate(binary): if bit == "1": dt[pos] = dt.get(pos, 0) + 1 sm = 0 for pos, pwr in dt.items(): sm += pwr * (pwr - 1) // 2 * pow(2, pos) return sm n = in...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR NUMBER VAR RETURN VAR...
You are given a sequence of N integer numbers A. Calculate the sum of A_{i} AND A_{j} for all the pairs (i, j) where i < j. The AND operation is the Bitwise AND operation, defined as in here. ------ Input ------ The first line of input consists of the integer N. The second line contains N integer numbers - the s...
try: n = int(input()) arr = list(map(int, input().split())) bins = [0] * 32 for i in range(32): cnt = 0 for j in range(len(arr)): if arr[j] & 1 << i: cnt += 1 bins[i] = cnt ans = 0 for i in range(len(bins)): cnt = bins[i] ans +=...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR BIN_OP NUMBER VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER FOR VA...
You are given a sequence of N integer numbers A. Calculate the sum of A_{i} AND A_{j} for all the pairs (i, j) where i < j. The AND operation is the Bitwise AND operation, defined as in here. ------ Input ------ The first line of input consists of the integer N. The second line contains N integer numbers - the s...
N = int(input()) arr = [int(i) for i in input().split()] total = 0 frequency = [(0) for i in range(30)] for i in arr: for j in range(0, len(bin(i)[2:])): if i & 1 << j: frequency[j] += 1 for i in range(30): total += frequency[i] * (frequency[i] - 1) // 2 * 2**i print(total)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR BIN...
You are given a sequence of N integer numbers A. Calculate the sum of A_{i} AND A_{j} for all the pairs (i, j) where i < j. The AND operation is the Bitwise AND operation, defined as in here. ------ Input ------ The first line of input consists of the integer N. The second line contains N integer numbers - the s...
t = int(input()) d1 = [int(a) for a in input().split()] maxlen = 32 data = [bin(int(a))[2:].zfill(maxlen) for a in d1] s = 0 for i in range(maxlen - 1, -1, -1): count = sum([(1) for x in data if x[i] == "1"]) n = 2 ** (maxlen - 1 - i) * (count * (count - 1) // 2) s += n print(s)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR STRING ASSIGN ...
You are given a sequence of N integer numbers A. Calculate the sum of A_{i} AND A_{j} for all the pairs (i, j) where i < j. The AND operation is the Bitwise AND operation, defined as in here. ------ Input ------ The first line of input consists of the integer N. The second line contains N integer numbers - the s...
n = int(input()) l = list(map(int, input().split())) res = 0 count = 0 for i in range(32): for j in range(n): if l[j] & 1: count += 1 l[j] >>= 1 res += count * (count - 1) // 2 * 2**i count = 0 print(res)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER VAR NUMBER VAR VAR NUMBER VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP NUMBER VAR ...
You are given a sequence of N integer numbers A. Calculate the sum of A_{i} AND A_{j} for all the pairs (i, j) where i < j. The AND operation is the Bitwise AND operation, defined as in here. ------ Input ------ The first line of input consists of the integer N. The second line contains N integer numbers - the s...
N = int(input()) A = list(map(int, input().strip().split())) result = 0 if N <= 1000: for i in range(N): for j in range(i + 1, N): result += A[i] & A[j] else: data = [0] * 29 for x in A: s = bin(x) n = len(s) for i in range(2, n): data[n - 1 - i] += in...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR V...
You are given a sequence of N integer numbers A. Calculate the sum of A_{i} AND A_{j} for all the pairs (i, j) where i < j. The AND operation is the Bitwise AND operation, defined as in here. ------ Input ------ The first line of input consists of the integer N. The second line contains N integer numbers - the s...
n = int(input()) p = 1 ar = list(map(int, input().split())) ctr = 0 for i in range(31): x = 0 for j in range(n): if ar[j] % 2 == 1: x += 1 ar[j] = ar[j] // 2 if (x - 1) % 2 == 0: ctr += x * ((x - 1) // 2) * p else: ctr += (x - 1) * (x // 2) * p p *= 2 prin...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR NUMBER IF BIN_OP BIN_OP VAR NUMB...
You are given a sequence of N integer numbers A. Calculate the sum of A_{i} AND A_{j} for all the pairs (i, j) where i < j. The AND operation is the Bitwise AND operation, defined as in here. ------ Input ------ The first line of input consists of the integer N. The second line contains N integer numbers - the s...
n = int(input()) a = [int(_) for _ in input().split()] b = [0] * 30 for x in a: for i in range(30): y = x & 1 << i if y != 0: b[i] += 1 s = 0 for i in range(30): s += b[i] * (b[i] - 1) * (1 << i) print(s // 2)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR IF VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR BIN_OP BIN_OP VAR VAR BIN_...
You are given a sequence of N integer numbers A. Calculate the sum of A_{i} AND A_{j} for all the pairs (i, j) where i < j. The AND operation is the Bitwise AND operation, defined as in here. ------ Input ------ The first line of input consists of the integer N. The second line contains N integer numbers - the s...
n = int(input()) L = list(map(int, input().split())) bits = [0] * 33 for i in range(n): for j in range(0, 33): z = 1 << j if L[i] & z: bits[j] += 1 ans = 0 for i in range(33): z = bits[i] if z: y = z * (z - 1) // 2 x = 1 << i ans += x * y print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR IF BIN_OP VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER AS...
You are given a sequence of N integer numbers A. Calculate the sum of A_{i} AND A_{j} for all the pairs (i, j) where i < j. The AND operation is the Bitwise AND operation, defined as in here. ------ Input ------ The first line of input consists of the integer N. The second line contains N integer numbers - the s...
n = int(input()) bit = list(map(int, input().split())) mask = 1 << 30 ans = 0 for i in range(30, -1, -1): count = 0 for andd in bit: if andd & mask != 0: count += 1 ans += 2**i * (count * (count - 1) // 2) mask >>= 1 print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR VAR NUMBER VAR NUMBER VAR BIN_OP BIN_OP NUMBER VAR BIN_OP BIN_OP VAR BIN_OP V...
You are given a sequence of N integer numbers A. Calculate the sum of A_{i} AND A_{j} for all the pairs (i, j) where i < j. The AND operation is the Bitwise AND operation, defined as in here. ------ Input ------ The first line of input consists of the integer N. The second line contains N integer numbers - the s...
n = int(input()) li = list(map(int, input().split())) ki = [0] * 32 for i in range(n): s = str(bin(li[i])[2:]) for j in range(len(s)): ki[32 - j - 1] = ki[32 - j - 1] + int(s[len(s) - j - 1]) c = 0 for i in range(32): a = ki[i] * (ki[i] - 1) // 2 c = c + 2 ** (31 - i) * a print(c)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER BIN_OP VAR BIN...
You are given a sequence of N integer numbers A. Calculate the sum of A_{i} AND A_{j} for all the pairs (i, j) where i < j. The AND operation is the Bitwise AND operation, defined as in here. ------ Input ------ The first line of input consists of the integer N. The second line contains N integer numbers - the s...
def modBy2Comb(li): l = len([(i % 2) for i in li if i % 2 != 0]) return l * (l - 1) // 2 def divideBy2(li): return [(i // 2) for i in li if i // 2 != 0] def solve(li): s = 0 c = 1 while li != []: s += modBy2Comb(li) * c li = divideBy2(li) c *= 2 return s N = inp...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER NUMBER RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF RETURN BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR LIST VAR BIN_OP FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ...
There is an infinite line of people, with person numbered (i+1) standing on the right of person numbered i. Chef can do 2 types of operations to this line of people: Type 1: Give a ball to the person number 1. If there exists a person with two balls, they drop one ball and give the other ball to the person on their ...
for _ in range(int(input())): n, k = map(int, input().split()) a = list(map(int, input().split())) s = 0 ans = 0 for i in range(k): if i == 0: s += a[i] - 1 else: s += a[i] - a[i - 1] - 1 s >>= 1 s += n - a[-1] balls = n - k c = 0 while...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR BIN_OP VAR VAR NUMBER VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUM...
There is an infinite line of people, with person numbered (i+1) standing on the right of person numbered i. Chef can do 2 types of operations to this line of people: Type 1: Give a ball to the person number 1. If there exists a person with two balls, they drop one ball and give the other ball to the person on their ...
def f(x): ans = 0 p = 0 while x != 0: if x & 1 == 1: ans += pow(2, p) - 1 x >>= 1 p += 1 return ans for case in range(int(input())): n, k = (int(i) for i in input().split()) d = [int(i) for i in input().split()] m = 0 p = 0 ans = 0 for i in d...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR BIN_OP FUNC_CALL VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL ...
There is an infinite line of people, with person numbered (i+1) standing on the right of person numbered i. Chef can do 2 types of operations to this line of people: Type 1: Give a ball to the person number 1. If there exists a person with two balls, they drop one ball and give the other ball to the person on their ...
for _ in range(int(input())): n, k = map(int, input().split()) arr = list(map(int, input().split())) prev = 0 c = 1 for i in arr: a = i + prev - c prev = a // 2 c = i + 1 prev += n - c + 1 b = bin(prev) c = b.count("1") a = n - k - c print(a)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR...
There is an infinite line of people, with person numbered (i+1) standing on the right of person numbered i. Chef can do 2 types of operations to this line of people: Type 1: Give a ball to the person number 1. If there exists a person with two balls, they drop one ball and give the other ball to the person on their ...
import sys from itertools import count sys.setrecursionlimit(25000) cin = sys.stdin read = cin.readline cout = sys.stdout write = cout.write ir = lambda: int(read()) rir = lambda: range(int(read())) mir = lambda: map(int, read().split()) lmir = lambda: list(map(int, read().split())) def carry(n): return 0 if n <...
IMPORT EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN...
There is an infinite line of people, with person numbered (i+1) standing on the right of person numbered i. Chef can do 2 types of operations to this line of people: Type 1: Give a ball to the person number 1. If there exists a person with two balls, they drop one ball and give the other ball to the person on their ...
try: for _ in range(int(input())): n, k = map(int, input().split()) a = [0] + sorted(map(int, input().split())) c, v = 0, 0 for i, curr in enumerate(a[1:], start=1): v += curr - 1 - a[i - 1] v //= 2 v += n - a[-1] print(n - k - format(v, "b").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 BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR VAR NUMBER NUMBER VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR...
There is an infinite line of people, with person numbered (i+1) standing on the right of person numbered i. Chef can do 2 types of operations to this line of people: Type 1: Give a ball to the person number 1. If there exists a person with two balls, they drop one ball and give the other ball to the person on their ...
def bitsum(n): return sum(map(int, f"{n:b}")) def dropstill(n): return n - bitsum(n) def getdrops(nombre, newnombre): return dropstill(newnombre) - dropstill(nombre) T = int(input()) for i in range(T): N, K = map(int, input().split()) typeoneses = list(map(int, input().split())) typeoneses...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR VAR STRING FUNC_DEF RETURN BIN_OP VAR FUNC_CALL VAR VAR FUNC_DEF RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL 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 FUNC_CALL VAR FUNC_CALL ...
There is an infinite line of people, with person numbered (i+1) standing on the right of person numbered i. Chef can do 2 types of operations to this line of people: Type 1: Give a ball to the person number 1. If there exists a person with two balls, they drop one ball and give the other ball to the person on their ...
t = int(input()) for _ in range(t): n, k = map(int, input().split()) k_pos = list(map(int, input().split())) num = k_pos[0] - 1 for i in range(1, k): num = num >> 1 num += k_pos[i] - k_pos[i - 1] - 1 if i == k - 1: num = num >> 1 if k == 1: num = num >> 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP VAR VAR VAR BIN...
There is an infinite line of people, with person numbered (i+1) standing on the right of person numbered i. Chef can do 2 types of operations to this line of people: Type 1: Give a ball to the person number 1. If there exists a person with two balls, they drop one ball and give the other ball to the person on their ...
T = int(input()) for i in range(T): [N, K] = list(map(int, input().split())) A = list(map(int, input().split())) b = A[0] - 1 for i in range(K): if i > 0: b += A[i] - A[i - 1] - 1 s = bin(b).split("b")[1] b = int(s[:-1].zfill(1), 2) b += N - A[-1] r = 0 fo...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN LIST VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP...
There is an infinite line of people, with person numbered (i+1) standing on the right of person numbered i. Chef can do 2 types of operations to this line of people: Type 1: Give a ball to the person number 1. If there exists a person with two balls, they drop one ball and give the other ball to the person on their ...
for _ in range(int(input())): n, k = map(int, input().split()) lst = list(map(int, input().split())) total_balls = 0 for i in range(len(lst)): if i != 0: total_balls += lst[i] - lst[i - 1] - 1 else: total_balls += lst[i] - 1 total_balls = total_balls >> 1 ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR VAR ...
There is an infinite line of people, with person numbered (i+1) standing on the right of person numbered i. Chef can do 2 types of operations to this line of people: Type 1: Give a ball to the person number 1. If there exists a person with two balls, they drop one ball and give the other ball to the person on their ...
def f(): n, k = map(int, input().split()) v = list(map(int, input().split())) last = 0 ans = 0 for i in range(k): temp = v[i] diff = temp - last ans += diff ans = ans // 2 last = v[i] ans += n - last - 1 st = 0 while ans > 0: pop = ans % 2 ...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR BIN_OP BIN_OP VAR VA...
There is an infinite line of people, with person numbered (i+1) standing on the right of person numbered i. Chef can do 2 types of operations to this line of people: Type 1: Give a ball to the person number 1. If there exists a person with two balls, they drop one ball and give the other ball to the person on their ...
for i in range(int(input())): a = list(map(int, input().strip().split())) b = list(map(int, input().strip().split())) b.sort() ans = 0 n = "{0:b}".format(b[0] - 1) k = b[0] - 1 o = 0 for i in range(len(n)): if n[i] == "1": o += 1 k -= o if n[-1] == "1": ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL STRING BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMB...
There is an infinite line of people, with person numbered (i+1) standing on the right of person numbered i. Chef can do 2 types of operations to this line of people: Type 1: Give a ball to the person number 1. If there exists a person with two balls, they drop one ball and give the other ball to the person on their ...
t = int(input()) while t: x, y = map(int, input().split(" ")) l = list(map(int, input().split(" "))) c = 0 a = l[0] - 1 for i in range(y): if i >= 1: a += l[i] - l[i - 1] - 1 a >>= 1 a += x - l[-1] b = x - y - bin(a).count("1") print(b) t -= 1
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VA...
There is an infinite line of people, with person numbered (i+1) standing on the right of person numbered i. Chef can do 2 types of operations to this line of people: Type 1: Give a ball to the person number 1. If there exists a person with two balls, they drop one ball and give the other ball to the person on their ...
from sys import stdin input = stdin.readline inp = lambda: list(map(int, input().split())) def answer(): ans, prev, pv = 0, 0, 0 for i in range(k + 1): count = prev + (a[i] - pv - 1) for bit in range(30): if count >> bit & 1: if bit: ans += (1 <...
ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR BIN_OP BIN_OP NUMBER V...
There is an infinite line of people, with person numbered (i+1) standing on the right of person numbered i. Chef can do 2 types of operations to this line of people: Type 1: Give a ball to the person number 1. If there exists a person with two balls, they drop one ball and give the other ball to the person on their ...
for test in range(int(input())): n, k = map(int, input().split()) a = [int(ai) for ai in input().split()] line = 0 balls = 0 runs = [a[0] - 1] for i in range(k - 1): runs.append(a[i + 1] - a[i] - 1) runs.append(n - a[k - 1]) prevcount = 0 for i in range(k): line += ru...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BI...
There is an infinite line of people, with person numbered (i+1) standing on the right of person numbered i. Chef can do 2 types of operations to this line of people: Type 1: Give a ball to the person number 1. If there exists a person with two balls, they drop one ball and give the other ball to the person on their ...
import sys def get_arr(): return list(map(int, sys.stdin.readline().strip().split())) def get_ints(): return map(int, sys.stdin.readline().strip().split()) def oper(n): val = 0 x = 2 cur = n // x while cur >= 1: val += cur x = x * 2 cur = n // x return val t =...
IMPORT FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR WHILE VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR RETURN VAR A...
There is an infinite line of people, with person numbered (i+1) standing on the right of person numbered i. Chef can do 2 types of operations to this line of people: Type 1: Give a ball to the person number 1. If there exists a person with two balls, they drop one ball and give the other ball to the person on their ...
t = int(input()) for i in range(t): n, k = map(int, input().split()) a = [*map(int, input().split())] num = prv = 0 for x in a: num += x - prv - 1 num //= 2 prv = x num += n - prv print(n - k - bin(num).count("1"))
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 LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER FOR VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP BI...
There is an infinite line of people, with person numbered (i+1) standing on the right of person numbered i. Chef can do 2 types of operations to this line of people: Type 1: Give a ball to the person number 1. If there exists a person with two balls, they drop one ball and give the other ball to the person on their ...
def mi(): return map(int, input().split()) def li(): return list(mi()) def si(): return str(input()) def ni(): return int(input()) def f(n): ans = bin(n) return ans.count("1") for t in range(int(input())): n, k = mi() a = li() a.append(n + 1) ans = 0 pre = 0 cou...
FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR...
There is an infinite line of people, with person numbered (i+1) standing on the right of person numbered i. Chef can do 2 types of operations to this line of people: Type 1: Give a ball to the person number 1. If there exists a person with two balls, they drop one ball and give the other ball to the person on their ...
t = int(input()) for _ in range(t): s = input().split() n, k = map(int, s) s = input().split() arr = list(map(int, s)) arr.sort() curNum = arr[0] - 1 for i in range(k - 1): curNum = curNum >> 1 curNum += arr[i + 1] - arr[i] - 1 curNum = curNum >> 1 curNum += n - arr[-...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN...
Jack and Daniel are friends. They want to encrypt their conversations so that they can save themselves from interception by a detective agency so they invent a new cipher. Every message is encoded to its binary representation. Then it is written down $\boldsymbol{\mbox{k}}$ times, shifted by $0,1,\cdots,k-1$ bits. ...
def decypher(encoded, K): size = len(encoded) - K + 1 ans = encoded[0] tmp = int(encoded[0]) for x in range(1, size): c = tmp ^ int(encoded[x]) ans += str(c) tmp ^= c if x >= K - 1: tmp ^= int(ans[x - K + 1]) print(ans) N, K = map(int, input().split()) S...
FUNC_DEF ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR IF VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL V...
Jack and Daniel are friends. They want to encrypt their conversations so that they can save themselves from interception by a detective agency so they invent a new cipher. Every message is encoded to its binary representation. Then it is written down $\boldsymbol{\mbox{k}}$ times, shifted by $0,1,\cdots,k-1$ bits. ...
gxor = 0 def xor2(res, pos, k): global gxor if pos == 0: gxor = 0 return 0 if pos < k: ret = gxor ^ res[pos - 1] gxor = ret elif res[pos - 1] != res[pos - k]: gxor = int(gxor == 0) ret = gxor else: ret = gxor return ret def xor1(res, po...
ASSIGN VAR NUMBER FUNC_DEF IF VAR NUMBER ASSIGN VAR NUMBER RETURN NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR RETURN VAR FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR VAR ASSIGN V...
Jack and Daniel are friends. They want to encrypt their conversations so that they can save themselves from interception by a detective agency so they invent a new cipher. Every message is encoded to its binary representation. Then it is written down $\boldsymbol{\mbox{k}}$ times, shifted by $0,1,\cdots,k-1$ bits. ...
n, k = [int(i) for i in input().split()] s = input() no1 = 0 ans = s[0] if s[0] == "1": no1 = 1 j = 0 for i in range(1, len(s) - k + 1): if no1 % 2 == 0: if s[i] == "1": ans += "1" no1 += 1 else: ans += "0" elif s[i] == "1": ans += "0" else: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR NUMBER STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER IF VAR VAR STRING VAR STRING VAR NUMB...
Jack and Daniel are friends. They want to encrypt their conversations so that they can save themselves from interception by a detective agency so they invent a new cipher. Every message is encoded to its binary representation. Then it is written down $\boldsymbol{\mbox{k}}$ times, shifted by $0,1,\cdots,k-1$ bits. ...
def xor(x, y): if x != y: return "1" return "0" n, k = map(int, input().split()) s = input()[::-1] x = "0" res = "" for i in range(n): if i - k >= 0: x = xor(x, res[i - k]) if s[i] != x: res += "1" else: res += "0" x = s[i] print(res[::-1])
FUNC_DEF IF VAR VAR RETURN STRING RETURN STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR IF VAR VAR VAR VAR STRING VAR STRING ASSIGN VAR ...
Jack and Daniel are friends. They want to encrypt their conversations so that they can save themselves from interception by a detective agency so they invent a new cipher. Every message is encoded to its binary representation. Then it is written down $\boldsymbol{\mbox{k}}$ times, shifted by $0,1,\cdots,k-1$ bits. ...
import sys N, K = tuple(map(int, input().split())) iStr = tuple(map(int, tuple(input()))) rStr = [0] * N if K == 1: print("".join([str(x) for x in iStr])) sys.exit() pSum = [0] * (N + 1) for i in range(1, N + 1): pFrom = i - K if i >= K else 0 pTo = i - 1 prev = (pSum[pTo] - pSum[pFrom]) % 2 cu...
IMPORT ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR N...
Jack and Daniel are friends. They want to encrypt their conversations so that they can save themselves from interception by a detective agency so they invent a new cipher. Every message is encoded to its binary representation. Then it is written down $\boldsymbol{\mbox{k}}$ times, shifted by $0,1,\cdots,k-1$ bits. ...
n, k = [int(i) for i in input().split(" ")] s = input() curVal = 0 s = [(ord(c) - 48) for c in s] out = [s[0]] curVal = s[0] for i in range(1, len(s) - k + 1): if i >= k: curVal ^= out[i - k] newVal = curVal ^ s[i] out.append(newVal) curVal ^= newVal print("".join([str(i) for i in out]))
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR LIST VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR VAR VAR BIN_OP VAR VAR ASS...
Jack and Daniel are friends. They want to encrypt their conversations so that they can save themselves from interception by a detective agency so they invent a new cipher. Every message is encoded to its binary representation. Then it is written down $\boldsymbol{\mbox{k}}$ times, shifted by $0,1,\cdots,k-1$ bits. ...
N, K = map(int, input().split()) S = list(map(int, input())) ans = [S[-1]] for i in range(1, min(K, N)): temp = S[-i] ^ S[-i - 1] ans.append(temp) for i in range(K, N): outbit = ans[i - K] temp = S[-i] ^ S[-i - 1] ^ outbit ans.append(temp) while ans: print(ans.pop(), end="")
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR V...
Jack and Daniel are friends. They want to encrypt their conversations so that they can save themselves from interception by a detective agency so they invent a new cipher. Every message is encoded to its binary representation. Then it is written down $\boldsymbol{\mbox{k}}$ times, shifted by $0,1,\cdots,k-1$ bits. ...
N, K = map(int, input().split()) ans = [(0) for x in range(K - 1)] S = list(map(int, input())) S_count = K - 1 t = 0 for n in S: temp = n t = t ^ ans[S_count - K] ^ ans[S_count - 1] temp = temp ^ t ans.append(temp) S_count += 1 K = K - 1 ans = ans[K : 0 - K] for i in ans: print(i, end="")
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ASSIGN V...
Jack and Daniel are friends. They want to encrypt their conversations so that they can save themselves from interception by a detective agency so they invent a new cipher. Every message is encoded to its binary representation. Then it is written down $\boldsymbol{\mbox{k}}$ times, shifted by $0,1,\cdots,k-1$ bits. ...
def xorN(x, n, k): if n <= k: return x return xorN((x ^ x << k) >> k, n, 2 * k) n, k = [int(i) for i in input().strip().split()] x = int(input(), 2) x = (x ^ x << 1) >> k res = format(xorN(x, n, k), "b") zero = "0" * (n - len(res)) print(zero + res)
FUNC_DEF IF VAR VAR RETURN VAR RETURN FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR VAR BIN_OP NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VA...
Jack and Daniel are friends. They want to encrypt their conversations so that they can save themselves from interception by a detective agency so they invent a new cipher. Every message is encoded to its binary representation. Then it is written down $\boldsymbol{\mbox{k}}$ times, shifted by $0,1,\cdots,k-1$ bits. ...
n, k = [int(i) for i in input().split()] code = [int(i) for i in input()] solution = [0] * n xorSolution = 0 for i in range(n): if i >= k: xorSolution ^= solution[~(i - k)] i = ~i e = code[i] solution[i] ^= code[i] ^ xorSolution xorSolution ^= solution[i] print(*solution, sep="")
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR STRI...
Jack and Daniel are friends. They want to encrypt their conversations so that they can save themselves from interception by a detective agency so they invent a new cipher. Every message is encoded to its binary representation. Then it is written down $\boldsymbol{\mbox{k}}$ times, shifted by $0,1,\cdots,k-1$ bits. ...
l = list(map(lambda s: int(s), input().split(" "))) n = l[0] k = l[1] s = input() res = s[0] start = 0 end = 1 mask = int(res[0]) while end < len(s) - k + 1 and end - start < k: tmp = int(s[end]) ^ mask mask = mask ^ tmp end += 1 res = res + str(tmp) for pos in range(end, len(s) - k + 1): mask = mas...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER WHILE VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER BIN_OP VAR VAR V...
Jack and Daniel are friends. They want to encrypt their conversations so that they can save themselves from interception by a detective agency so they invent a new cipher. Every message is encoded to its binary representation. Then it is written down $\boldsymbol{\mbox{k}}$ times, shifted by $0,1,\cdots,k-1$ bits. ...
N, K = list(map(int, input().split())) v = list(map(int, list(input()))) v = v[::-1] r = [v[0]] a = 0 for i in range(1, N): a = a ^ r[-1] if i >= K: a = a ^ r[-K] r.append(a ^ v[i]) print("".join(map(str, r[::-1])))
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR EXPR...
Jack and Daniel are friends. They want to encrypt their conversations so that they can save themselves from interception by a detective agency so they invent a new cipher. Every message is encoded to its binary representation. Then it is written down $\boldsymbol{\mbox{k}}$ times, shifted by $0,1,\cdots,k-1$ bits. ...
[n, k] = [int(x) for x in input().split()] s = int(input(), 2) m = s << 1 ^ s x = m count = k while count < n: x = x << k ^ m count += k print(bin(x)[-n:])
ASSIGN LIST VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR VAR ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR
Jack and Daniel are friends. They want to encrypt their conversations so that they can save themselves from interception by a detective agency so they invent a new cipher. Every message is encoded to its binary representation. Then it is written down $\boldsymbol{\mbox{k}}$ times, shifted by $0,1,\cdots,k-1$ bits. ...
n, k = map(int, input().split()) s = int(input(), 2) s ^= s << 1 while k < n: s ^= s << k k *= 2 s &= 2**n - 1 print(format(s, "0" + str(n) + "b"))
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR BIN_OP VAR VAR VAR NUMBER VAR BIN_OP BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP BIN_OP STRING FUNC_CALL VAR VAR STRING
This is an interactive problem. There exists a matrix a of size n × m (n rows and m columns), you know only numbers n and m. The rows of the matrix are numbered from 1 to n from top to bottom, and columns of the matrix are numbered from 1 to m from left to right. The cell on the intersection of the x-th row and the y-...
import sys input = sys.stdin.readline def solve(): r, c = map(int, input().split()) r1 = r r2 = r i = 2 while True: if r2 % i == 0: while r2 % i == 0: r2 //= i while r1 % i == 0: if i == 2: print("?", r1 // i, c, ...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE NUMBER IF BIN_OP VAR VAR NUMBER WHILE BIN_OP VAR VAR NUMBER VAR VAR WHILE BIN_OP VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING BIN_OP VAR VAR VAR NUMBER NUMBER BIN_OP BI...
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. You are given a sequence $A_{1}, A_{2}, \ldots, A_{N}$ and you have to perform the following operation exactly $X$ times: Choose two integers $i$ and $j$ such that $1 ≤ i < j ≤ N$. Choose a non-negative integer $p$....
for _ in range(int(input())): n, x = map(int, input().split()) s = [int(i) for i in input().split()] s1 = [] i = 0 j = 0 a2 = 0 a1 = 0 b1 = True b2 = 1 X = 0 s1 = [] s2 = [] d = dict() if n == 2: while b1 and x: if s[i] == 0: if...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIS...
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. You are given a sequence $A_{1}, A_{2}, \ldots, A_{N}$ and you have to perform the following operation exactly $X$ times: Choose two integers $i$ and $j$ such that $1 ≤ i < j ≤ N$. Choose a non-negative integer $p$....
MAX_BINARY_LENGTH = 30 t = int(input()) for i in range(t): n, x = map(int, input().split()) A = list(map(int, input().split())) opsCount = 0 unAddressedBitsNumber = 0 lastIndexProcessed = -1 for j in range(n - 1): andValue = A[j] & unAddressedBitsNumber A[j] -= andValue u...
ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP V...