description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = map(int, input().split())
l = list(map(int, input().split()))
a = [0] * (10**5 + 7)
for i in l:
a[i] = a[i] + 1
c = 0
if x == 0:
ans = 0
for i in l:
ans = ans + a[i] - 1
print(ans // 2)
exit()
for i in l:
z = i ^ x
if z > 10**5 + 3:
continue
c = c + a[z]
print(c //... | 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 LIST NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP BI... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = map(int, input().split())
a = list(map(int, input().split()))
c = [0] * 100101
for ai in a:
c[ai] += 1
if x == 0:
s = sum([(ci * (ci - 1)) for ci in c if ci > 1])
else:
s = 0
for i in range(1, 100101):
if i ^ x < 100101:
s += c[i] * c[i ^ x]
print(int(s / 2)) | 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 LIST NUMBER NUMBER FOR VAR VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBE... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, q = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
f = {}
for i in a:
y = i ^ q
z = f.get(y)
if z != None:
ans += z
if f.get(i) != None:
f[i] += 1
else:
f[i] = 1
print(ans) | 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 DICT FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NONE VAR VAR IF FUNC_CALL VAR VAR NONE VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CA... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = map(int, input().split())
d = {}
a = 0
for i in map(int, input().split()):
d[i] = d.get(i, 0) + 1
for i in d:
a += [d[i] * (d[i] - 1), d.get(i ^ x, 0) * d[i]][i != i ^ x]
print(a // 2) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR VAR VAR LIST BIN_OP VAR VAR BIN_OP VAR VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR VAR VAR BIN_OP VAR V... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | old = [0] * 100001
new = [0] * 100001
n, x = (int(z) for z in input().split())
s = [int(z) for z in input().split()]
for i in s:
old[i] += 1
if i ^ x < 100001:
new[i ^ x] += 1
ans = 0
for i in range(100001):
ans += old[i] * new[i]
if x == 0:
ans -= old[i]
ans //= 2
print(ans) | ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | def solve():
n, x = map(int, input().split())
a = list(map(int, input().split()))
d = {}
g = []
cnt = 0
for i in a:
if d.get(i) == None:
d[i] = 1
else:
d[i] += 1
for i in a:
r = i ^ x
if d.get(r) != None and i != r:
cnt += d... | 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 DICT ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR NONE ASSIGN VAR VAR NUMBER VAR VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF FUNC_CALL VAR VAR NON... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | def cin():
return list(map(int, input().split()))
N = int(1000000.0 + 5)
n, x = cin()
A = cin()
B = [0] * N
an = 0
for i in A:
an += B[i ^ x]
B[i] += 1
print(an) | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = map(int, input().split())
arr = list(map(int, input().split()))
dict1 = {}
for i in range(n):
try:
dict1[arr[i]] += 1
except:
KeyError
dict1[arr[i]] = 1
ans = 0
if x == 0:
for i in dict1.keys():
ans += dict1[i] * (dict1[i] - 1)
print(ans // 2)
else:
for i in ra... | 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 DICT FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER EXPR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR NUMBER EXPR ... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = map(int, input().split(" "))
L = list(map(int, input().split()))
L = sorted(L)
P = [0] * (L[n - 1] + 1)
i = 0
while i < n:
c = 1
while i + c < n and L[i + c] == L[i]:
c = c + 1
P[L[i]] += c
i = i + c
def binary_search(arr, l, r, x):
while l <= r:
mid = l + (r - l) // 2
... | 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 ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR ... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | inp = lambda: map(int, input().split())
n, x = inp()
a = [*inp()]
f = [0] * (10**6 + 1)
ans = 0
for i in a:
ans += f[i ^ x]
f[i] += 1
print(ans) | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n1 = input("")
m1 = input("")
n = n1.split(" ")
m = m1.split(" ")
ans = 0
x = int(n[1])
lst = {}
for i in m:
a = int(i)
if a ^ x in lst:
ans += lst[a ^ x]
if a in lst:
lst[a] += 1
else:
lst[a] = 1
print(ans) | ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | from sys import stdin, stdout
n, x = map(int, stdin.readline().split())
ar = list(map(int, stdin.readline().split()))
mp = {}
c = 0
for i in range(n):
c += mp.get(ar[i] ^ x, 0)
mp[ar[i]] = mp.get(ar[i], 0) + 1
stdout.write(str(c) + "\n") | 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 DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | import sys
n, x = map(int, input().split())
arr = list(map(int, input().split()))
store = [0] * 1000000
cnt = 0
for i in range(n):
num = arr[i] ^ x
if store[arr[i] - 1] == 0:
store[num - 1] += 1
elif store[arr[i] - 1] >= 1:
cnt += store[arr[i] - 1]
store[num - 1] += 1
print(cnt) | IMPORT 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 LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR BIN_OP VAR VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = map(int, input().split())
ip = list(map(int, input().split()))
count = 0
counts = [(0) for i in range(100001)]
for i in ip:
counts[i] += 1
for i in range(n):
b = x ^ ip[i]
counts[ip[i]] -= 1
try:
count += counts[b]
except:
b = 1
print(count) | 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 VAR FUNC_CALL VAR NUMBER FOR VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR VAR NUMBER VAR VAR VAR ASSIGN VAR NUMBER EXP... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
m = [0] * (1000000 + 1)
ans = 0
for i in range(n):
b = a[i] ^ x
ans += m[b]
m[a[i]] += 1
print(ans) | 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 BIN_OP LIST NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = map(int, input().split())
cnt = [0] * (1 << 18)
arr = list(map(int, input().split()))
ans = 0
for i in range(n - 1, -1, -1):
temp = arr[i] ^ x
ans += cnt[temp]
cnt[arr[i]] += 1
print(ans) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CA... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = list(map(int, input().split()))
a = list(map(int, input().split()))
d = {}
s = set(a)
for i in a:
d[i] = 0
for i in a:
d[i] += 1
ans = 0
for i in s:
if x == 0:
ans += d[i] * (d[i] - 1) // 2
else:
ans += d[i] * d.get(i ^ x, 0)
if x == 0:
print(ans)
else:
print(ans // 2) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR VAR NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR BIN_OP BIN_OP VAR VAR BIN_OP... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | someDict = {}
def sumOfNumbers(m):
return (m - 1) * m // 2
class Pair:
def __init__(self, k, y):
self.k = k
self.y = y
a, x = map(lambda x: int(x), input().split())
arr = list(map(lambda x: int(x), input().split()))
for i in arr:
if i in someDict.keys() or i ^ x in someDict.keys():
... | ASSIGN VAR DICT FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR IF VAR FUNC_CALL VAR BIN_OP VAR ... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = map(int, input().split())
a, s = [0] * 100001, 0
for i in map(int, input().split()):
a[i] += 1
for i in range(100001):
if not x:
s += a[i] * (a[i] - 1) // 2
a[i] = 0
elif x ^ i < 100001:
s += a[i] * a[x ^ i]
a[i] = a[x ^ i] = 0
print(s) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP LIST NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER VAR BIN_OP V... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = map(int, input().split())
l, res = [0] * 131073, 0
for a in map(int, input().split()):
res, l[a] = res + l[a ^ x], l[a] + 1
print(res) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP LIST NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = list(map(int, input().split()))
a = list(map(int, input().split()))
if x == 0:
ans = 0
s = dict()
for elem in a:
if elem in s:
s[elem] += 1
else:
s[elem] = 1
for key in list(s.keys()):
ans += s[key] * (s[key] - 1)
else:
ans = 0
s = dict()
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR VAR BIN_OP VAR... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | q = 1
for _ in range(q):
n, k = map(int, input().split())
l = list(map(int, input().split()))
a = [0] * (10**5 + 1)
for i in range(n):
a[l[i]] += 1
ans = 0
for i in range(n):
x = l[i] ^ k
if x <= 10**5:
if x == l[i]:
ans += a[l[i]] - 1
... | ASSIGN VAR NUMBER 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 LIST NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VA... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | s = input().split()
n = int(s[0])
m = int(s[1])
a = [int(x) for x in input().split()]
frq = [0] * 100001
for i in range(n):
frq[a[i]] += 1
ans = 0
for i in range(n):
p = a[i] ^ m
if p < 100001:
if a[i] != p:
ans += frq[p]
else:
ans += frq[p] - 1
ans = int(ans / 2)
pri... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | temp = input().split()
n = int(temp[0])
x = int(temp[1])
temp = input().split()
a = [int(k) for k in temp]
c = [(0) for i in range(10**5 + 1)]
for i in range(n):
c[a[i]] += 1
ans = 0
for i in range(n):
if a[i] ^ x <= 10**5:
ans += c[a[i] ^ x]
if x == 0:
ans -= n
ans = int(ans / 2)
print(ans) | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | R = lambda: map(int, input().split())
n, x = R()
cnts = {}
res = 0
for num in R():
res += cnts.get(num, 0)
cnts[x ^ num] = cnts.get(x ^ num, 0) + 1
print(res) | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = map(int, input().split())
table = {}
for a in map(int, input().split()):
if a in table:
table[a] += 1
else:
table[a] = 1
ans = 0
for i in table.keys():
if table[i] > 0:
if i ^ x in table:
if i == i ^ x:
ans += table[i] * (table[i] - 1) // 2
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR IF VAR VAR NUMBER IF BIN_OP VAR VAR VAR IF VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR NUMBER... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | class CodeforcesTask742BSolution:
def __init__(self):
self.result = ""
self.n_x = []
self.array = []
def read_input(self):
self.n_x = [int(x) for x in input().split(" ")]
self.array = [int(x) for x in input().split(" ")]
def process_task(self):
nums = {}
... | CLASS_DEF FUNC_DEF ASSIGN VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR DICT FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = [int(i) for i in input().split()]
ans = 0
d = {}
for i in map(int, input().split()):
ans += d.get(i ^ x, 0)
d[i] = d.get(i, 0) + 1
print(ans) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = map(int, input().split())
a = [int(i) for i in input().split()]
m = dict()
for i in a:
if not i in m:
m[i] = 1
else:
m[i] += 1
s = 0
for i in m:
j = x ^ i
if j in m:
if i == j:
s += m[i] * (m[i] - 1)
else:
s += m[i] * m[j]
print(s // 2) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR IF VAR VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR NUMBER VA... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = map(int, input().split())
a = [int(x) for x in input().split()]
def summ(n):
ans = 0
for i in range(n):
ans += i
return ans
ad = {}
count = 0
for i in a:
ad[i] = ad.get(i, 0) + 1
if x:
for i in ad:
count += ad[i] * ad.get(i ^ x, 0)
print(int(count // 2))
else:
for ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR RETURN VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER IF VAR FOR VAR VAR VAR BIN_OP VAR ... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
cs = {}
for v in a:
cs[v] = cs.get(v, 0) + 1
t = 0
if x == 0:
for c in cs.values():
t += c * (c - 1) // 2
print(t)
else:
for v in a:
t += cs.get(x ^ v, 0)
print(t // 2) | 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 DICT FOR VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = map(int, input().split())
a = list(map(int, input().split()))
d = {}
for p in a:
if p not in d:
d[p] = 1
else:
d[p] += 1
cnt = 0
if x == 0:
for k in d:
cnt += d[k] * (d[k] - 1) // 2
print(cnt)
else:
for k in d:
if k ^ x in d:
cnt += d[k] * d[k ^ x]
... | 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 DICT FOR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER FOR VAR VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VA... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | def get_row():
return [int(x) for x in input().split()]
_, x = get_row()
a = get_row()
counts = {}
count = 0
for n in reversed(a):
count += counts.get(n ^ x, 0)
counts[n] = counts.get(n, 0) + 1
print(count) | FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = map(int, input().split())
ar = list(map(int, input().split()))
st = {}
soln = 0
for el in ar:
if el ^ x in st:
soln += st[el ^ x]
if el in st:
st[el] += 1
else:
st[el] = 1
print(soln) | 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 DICT ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
d = {}
for k in a:
if d.get(k ^ x, 0) > 0:
ans += d.get(k ^ x)
d[k] = d.get(k, 0) + 1
print(ans) | 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 DICT FOR VAR VAR IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VA... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = map(int, input().split())
count = 0
d = {}
l = list(map(int, input().split()))
inp = l[0]
d[inp] = 1
for i in range(1, n):
inp = l[i]
xor = x ^ inp
if xor in d:
count += d[xor]
if inp not in d:
d[inp] = 0
d[inp] += 1
print(count) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR VAR VAR VAR IF VAR VAR ASSIGN... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = map(int, input().split())
arr = list(map(int, input().split()))
b = [0] * int(200000.0)
for i in arr:
b[i] += 1
res = 0
for i in arr:
r = i ^ x
res += b[r]
if x == 0:
res -= len(arr)
print(res // 2) | 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 LIST NUMBER FUNC_CALL VAR NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR IF VAR NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | from sys import stdin
input = stdin.buffer.readline
n, x = map(int, input().split())
(*a,) = map(int, input().split())
cnt = [0] * 200001
res = 0
for i in a:
res += cnt[x ^ i]
cnt[i] += 1
print(res) | ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = list(map(int, input().split()))
A = list(map(int, input().split()))
d1 = {}
for a in A:
if a in d1:
d1[a] += 1
else:
d1[a] = 1
keys = list(d1.keys())
keys.sort()
ans = 0
for k in keys:
b = k ^ x
if b > k:
if b in d1:
ans += d1[b] * d1[k]
elif b == k:
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP ... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = map(int, input().split())
l = list(map(int, input().split()))
ans = 0
mp = {i: (0) for i in l}
for i in l:
mp[i] += 1
for i in l:
mp[i] -= 1
if i ^ x in mp.keys():
ans += mp[i ^ x]
print(ans) | 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 VAR NUMBER VAR VAR FOR VAR VAR VAR VAR NUMBER FOR VAR VAR VAR VAR NUMBER IF BIN_OP VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = list(map(int, input().split()))
if x == 0:
ans = -n
else:
ans = 0
a = list(map(int, input().split()))
b = {}
for i in a:
if i in b:
b[i] += 1
else:
b[i] = 1
for i in a:
k = i ^ x
if k in b:
ans += b[k]
print(ans // 2) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR VAR VAR VA... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = map(int, input().split())
arr = list(map(int, input().split()))
dict = {}
for v in arr:
if v in dict:
dict[v] += 1
else:
dict[v] = 1
if x:
res = 0
for v in dict.keys():
if v ^ x in dict and v ^ x > v:
res += dict[v] * dict[v ^ x]
print(res)
else:
print(... | 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 DICT FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR IF BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP VA... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = map(int, input().split())
l = list(map(int, input().split()))
d = {}
ans = 0
for i in l:
d[i] = d.get(i, 0) + 1
if x == 0:
ans -= n
for y in d:
ans += d[y] * (d[y] + 1) // 2
else:
for y in d:
t = x ^ y
ans += d[y] * d.get(t, 0)
d[y] = 0
print(max(0, ans)) | 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 DICT ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER IF VAR NUMBER VAR VAR FOR VAR VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR NUMBER NUMBER FOR VAR... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | LIMIT = 1103 + int(10000000.0)
a = [0] * LIMIT
n, x = map(int, input().split(" "))
r = 0
for k in [int(y) for y in input().split(" ")]:
r += a[x ^ k]
a[k] += 1
print(r) | ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING VAR VAR BIN_OP VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = map(int, input().split())
cnt = [(0) for i in range(100010)]
arr = list(map(int, input().split()))
for num in arr:
cnt[num] += 1
ans = 0
for num in arr:
xor_num = x ^ num
if xor_num > 100000:
continue
cnt[num] -= 1
if cnt[xor_num] > 0:
ans += cnt[xor_num]
print(ans) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR VAR NUMBER IF VAR VAR NUMBER VAR VAR VAR EXPR FUNC_C... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | def ri():
return map(int, input().split())
n, x = ri()
cnt = 0
dd = {}
for i in ri():
if i in dd:
dd[i] += 1
else:
dd[i] = 1
xx = i ^ x
if xx in dd:
cnt += dd[xx]
if x == 0:
cnt -= 1
print(int(cnt)) | FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR VAR VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = map(int, input().split())
a = list(map(int, input().split()))
count = {}
ans = 0
for i in range(n):
if a[i] in count:
count[a[i]] += 1
else:
count[a[i]] = 1
for i in range(n):
val = a[i]
if val ^ x in count:
ans += count[val ^ x]
if val ^ x == val:
ans -= 1
pri... | 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 DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF BIN_OP VAR VAR VAR VAR VAR B... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
ax = [(i ^ x) for i in a]
a.sort()
ax.sort()
pos = 0
posx = 0
c = 1
cx = 1
total = 0
while pos < n and posx < n:
if a[pos] == ax[posx]:
if pos < n - 1 and a[pos + 1] == a[pos]:
pos += 1
c += 1
elif... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR IF VAR VAR VAR VAR... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | N = 10**5 + 1
n, x = list(map(int, input().split()))
A = list(map(int, input().split()))
B = [0] * N
for a in A:
B[a] += 1
res = 0
for i in range(N):
if i ^ x < N:
res += B[i] * B[i ^ x]
print((res - n) // 2 if x == 0 else res // 2) | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR BIN_O... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | _, n = map(int, input().split())
M = {}
ans = 0
for x in map(int, input().split()):
ans += M.get(x ^ n, 0)
if x not in M:
M[x] = 1
else:
M[x] += 1
print(ans) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | def main():
n, x = list(map(int, input().split()))
l, res = [0] * 131073, 0
for a in map(int, input().split()):
res += l[a ^ x]
l[a] += 1
print(res)
def __starting_point():
main()
__starting_point() | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP LIST NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR FUNC_DEF EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | line = input().split()
N = int(line[0])
X = int(line[1])
line = input().split()
arr = [0] * 1000000
for i in range(N):
arr[int(line[i])] += 1
res = 0
for i in range(len(arr)):
if i ^ X < len(arr):
if arr[i] > 0:
if i == i ^ X:
res += arr[i] * (arr[i] - 1) // 2
els... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR FUNC_C... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | [n, y] = map(int, input().split())
cnt = {}
ans = 0
a = list(map(int, input().split()))
for i in a:
if y ^ i in cnt:
ans += cnt[y ^ i]
if i in cnt:
cnt[i] += 1
else:
cnt[i] = 1
print(ans) | ASSIGN LIST VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR IF BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | def rints():
return list(map(int, input().split()))
def ri():
return int(input())
MAX_A = 10**5
n, x = rints()
arr = rints()
seen = [0] * (MAX_A + 1)
count = 0
for elem in arr:
partner = x ^ elem
if partner <= MAX_A:
count += seen[partner]
seen[elem] += 1
print(count) | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR VAR... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = map(int, input().split())
al = [0] * 1000005
m = 0
dl = list(map(int, input().split()))
ms = set(dl)
for i in dl:
al[i] += 1
m = max(i, m)
ans = 0
for i in ms:
j = i ^ x
if al[i] > 0 and al[j] > 0:
if i != j:
ans += al[i] * al[j]
else:
ans += al[i] * (al[i]... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR ... |
There are some beautiful girls in Arpa’s land as mentioned before.
Once Arpa came up with an obvious problem:
Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).
[Image]
Im... | n, x = map(int, input().split())
a = list(map(int, input().split()))
chk = []
ans = 0
for i in range(0, 100001, 1):
chk.append(0)
for i in range(0, n, 1):
chk[a[i]] += 1
for i in range(0, 100001, 1):
if i ^ x <= 100000:
if i == i ^ x:
ans += chk[i] * (chk[i] - 1)
else:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBE... |
Read problems statements in mandarin chinese, russian and vietnamese as well.
Though our Head Chef retired from sport programming long back, but that did not affect his passion to contribute to the programming community. He still remains engaged by creating new problems and passing it on to the online judges. Last Ni... | n, k = input().split(" ")
n = int(n)
k = int(k)
a = [int(x) for x in input().split(" ")]
c = 0
a.sort()
m = n
index = n
temp = 1
for i in range(n):
temp *= a[i]
if a[i] > k:
if c == 0:
index = i
c += 2 ** (m - 1)
m -= 1
if temp <= k:
a = []
a = a[:index]
flag = 0
ctr = a.... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR VAR IF VAR NUMBER ... |
Read problems statements in mandarin chinese, russian and vietnamese as well.
Though our Head Chef retired from sport programming long back, but that did not affect his passion to contribute to the programming community. He still remains engaged by creating new problems and passing it on to the online judges. Last Ni... | string = input()
val = string.split()
int_val = [int(o) for o in val]
N, K = int_val
line = input()
l = line.split()
int_l = [int(x) for x in l]
int_l.sort()
nonones = []
for i in int_l:
if i != 1:
nonones.append(i)
noofones = len(int_l) - len(nonones)
list = [1]
count = 0
for i in nonones:
list_temp = ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CA... |
Read problems statements in mandarin chinese, russian and vietnamese as well.
Though our Head Chef retired from sport programming long back, but that did not affect his passion to contribute to the programming community. He still remains engaged by creating new problems and passing it on to the online judges. Last Ni... | n, k = map(int, input().split())
d = []
s = 0
ac = 0
l = list(map(int, input().split()))
cnt1 = l.count(1)
for i in range(n):
if i == 0 and l[i] != 1:
if l[i] <= k:
d.append(l[i])
s += 1
ac += 1
else:
asd = ac
z = 0
if l[i] <= k and l[i] != 1:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR NUMBER IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER VAR ... |
Read problems statements in mandarin chinese, russian and vietnamese as well.
Though our Head Chef retired from sport programming long back, but that did not affect his passion to contribute to the programming community. He still remains engaged by creating new problems and passing it on to the online judges. Last Ni... | n, k = map(int, input().split())
a = list(map(int, input().split()))
def f(i, p):
if p > k:
return 0
if i == -1:
return 1
if p not in dp[i]:
dp[i][p] = f(i - 1, p) + f(i - 1, p * a[i])
return dp[i][p]
dp = [{} for i in range(n)]
ans = f(n - 1, 1) - 1
print(ans) | 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 FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR VAR VAR ASSIGN VAR VAR VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR RETURN... |
Read problems statements in mandarin chinese, russian and vietnamese as well.
Though our Head Chef retired from sport programming long back, but that did not affect his passion to contribute to the programming community. He still remains engaged by creating new problems and passing it on to the online judges. Last Ni... | n, k = map(int, input().split())
l = list(map(int, input().split()))
onecount = l.count(1)
dlist = list()
s, ac = 0, 0
asd, z = 0, 0
for i in range(n):
t = l[i]
if i == 0 and t != 1:
if t <= k:
dlist.append(t)
s = s + 1
ac = ac + 1
else:
asd = ac
z... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR NUMBER VAR NUMBER IF VAR VAR ... |
Read problems statements in mandarin chinese, russian and vietnamese as well.
Though our Head Chef retired from sport programming long back, but that did not affect his passion to contribute to the programming community. He still remains engaged by creating new problems and passing it on to the online judges. Last Ni... | n = input()
r = list(map(int, n.split()))
k = r[1]
arr = input()
li = list(map(int, arr.split()))
def count(li, k):
li.sort()
if li[0] > k:
print(0)
return
l = len(li)
if l == 1:
if li[0] <= k:
print(1)
return
li1 = li[: int(len(li) / 2)]
li2 = l... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR IF VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR NUMBE... |
Read problems statements in mandarin chinese, russian and vietnamese as well.
Though our Head Chef retired from sport programming long back, but that did not affect his passion to contribute to the programming community. He still remains engaged by creating new problems and passing it on to the online judges. Last Ni... | n, k = map(int, input().strip().split())
arr = list(map(int, input().strip().split()))
l1 = [1]
l2 = [1]
def get_possibilities(no):
start = 0
l2_len = len(l2)
end = l2_len - 1
if l2[end] * no <= k:
return l2_len
while start <= end:
mid = (start + end) // 2
if mid == l2_len ... | ASSIGN VAR 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 ASSIGN VAR LIST NUMBER ASSIGN VAR LIST NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR VAR RETURN VAR WHILE VA... |
Read problems statements in mandarin chinese, russian and vietnamese as well.
Though our Head Chef retired from sport programming long back, but that did not affect his passion to contribute to the programming community. He still remains engaged by creating new problems and passing it on to the online judges. Last Ni... | n, k = list(map(int, input().split()))
ar = list(map(int, input().split()))
def proc(l, r):
prod = []
sz = r - l
for mask in range(1, 1 << sz):
res = 1
for i in range(l, r):
if mask & 1 << i - l:
res *= ar[i]
prod.append(res)
prod.sort()
return p... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR LIST ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR BIN_OP NUMBER BIN_OP V... |
Read problems statements in mandarin chinese, russian and vietnamese as well.
Though our Head Chef retired from sport programming long back, but that did not affect his passion to contribute to the programming community. He still remains engaged by creating new problems and passing it on to the online judges. Last Ni... | i = input()
s = i.split()
N = eval(s[0])
K = eval(s[1])
arrElem = input()
a = arrElem.split()
A = []
totsets = 2**N - 1
count = 0
for i in range(0, N):
A.append(eval(a[i]))
A.sort()
prod = []
req = []
count1 = 0
for i in range(0, N):
if A[i] <= K and A[i] != 1:
req.append(A[i])
elif A[i] == 1:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR V... |
Read problems statements in mandarin chinese, russian and vietnamese as well.
Though our Head Chef retired from sport programming long back, but that did not affect his passion to contribute to the programming community. He still remains engaged by creating new problems and passing it on to the online judges. Last Ni... | import sys
def solve(A, n, k):
if n == 1:
return {A[0]: 1}
h = solve(A, n - 1, k)
hNew = {}
for x in h:
hNew[x] = h[x]
for x in h:
temp = x * A[n - 1]
if temp <= k:
if not temp in hNew:
hNew[temp] = 0
hNew[temp] += h[x]
if... | IMPORT FUNC_DEF IF VAR NUMBER RETURN DICT VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR VAR VAR VAR FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR BIN_OP VAR NUMBER IF VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR VAR VAR IF VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VA... |
Read problems statements in mandarin chinese, russian and vietnamese as well.
Though our Head Chef retired from sport programming long back, but that did not affect his passion to contribute to the programming community. He still remains engaged by creating new problems and passing it on to the online judges. Last Ni... | N, k = list(map(int, input().split()))
a = list(map(int, input().split()))
lA = []
lB = []
def recA(i, chosen, n, mul, k):
if i == n:
if mul <= k and chosen != 0:
lA.append(mul)
return
recA(i + 1, chosen + 1, n, mul * a[i], k)
recA(i + 1, chosen, n, mul, k)
def recB(i, chosen... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FUNC_DEF IF VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR BIN_OP VAR VAR VAR ... |
Read problems statements in mandarin chinese, russian and vietnamese as well.
Though our Head Chef retired from sport programming long back, but that did not affect his passion to contribute to the programming community. He still remains engaged by creating new problems and passing it on to the online judges. Last Ni... | n, k = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
left = []
right = []
for i in range(n // 2):
sz = len(left)
for j in range(sz):
left.append(left[j] * arr[i])
left.append(arr[i])
for i in range(n // 2, n):
sz = len(right)
for j in range(sz):
right.appe... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR FOR VA... |
Read problems statements in mandarin chinese, russian and vietnamese as well.
Though our Head Chef retired from sport programming long back, but that did not affect his passion to contribute to the programming community. He still remains engaged by creating new problems and passing it on to the online judges. Last Ni... | def solve(l, idx, n, k, p, t):
if p > k:
return None
if idx == n:
t.append(p)
return None
solve(l, idx + 1, n, k, p, t)
solve(l, idx + 1, n, k, p * l[idx], t)
def search(l, k, val):
lo = 1
hi = len(l) - 1
ans = len(l)
while lo <= hi:
mid = (lo + hi) // 2... | FUNC_DEF IF VAR VAR RETURN NONE IF VAR VAR EXPR FUNC_CALL VAR VAR RETURN NONE EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR VAR VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR ... |
Read problems statements in mandarin chinese, russian and vietnamese as well.
Though our Head Chef retired from sport programming long back, but that did not affect his passion to contribute to the programming community. He still remains engaged by creating new problems and passing it on to the online judges. Last Ni... | def q6(nums, k, d):
for i in range(len(nums)):
current = nums[i]
if current > k:
continue
currentDict = dict()
for elem in d:
new = current * elem
if new <= k:
currentDict[new] = d[elem]
for elem in currentDict:
... | FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR VAR VAR VAR FOR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR ... |
Read problems statements in mandarin chinese, russian and vietnamese as well.
Though our Head Chef retired from sport programming long back, but that did not affect his passion to contribute to the programming community. He still remains engaged by creating new problems and passing it on to the online judges. Last Ni... | def numOfSub(integers, K, product, index):
if product > K:
return 0
if index == len(integers):
return 1
return numOfSub(integers, K, product * integers[index], index + 1) + numOfSub(
integers, K, product, index + 1
)
def buildStart(integers):
result = []
for i in range(... | FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR FUNC_CALL VAR VAR RETURN NUMBER RETURN BIN_OP FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR RE... |
Read problems statements in mandarin chinese, russian and vietnamese as well.
Though our Head Chef retired from sport programming long back, but that did not affect his passion to contribute to the programming community. He still remains engaged by creating new problems and passing it on to the online judges. Last Ni... | n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
m = {}
m[a[0]] = 1
for i in range(1, n):
m_temp = m.copy()
if a[i] in m_temp.keys():
m_temp[a[i]] = m_temp[a[i]] + 1
else:
m_temp[a[i]] = 1
for j in m:
if j * a[i] > k:
continue
if j... | 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 EXPR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR IF VAR VAR FUNC_CALL VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR VAR NUMBER ASSI... |
Read problems statements in mandarin chinese, russian and vietnamese as well.
Though our Head Chef retired from sport programming long back, but that did not affect his passion to contribute to the programming community. He still remains engaged by creating new problems and passing it on to the online judges. Last Ni... | def p(s, t):
count = 0
lst = []
pro = []
for i in range(0, len(s)):
if int(s[i]) == 1:
count = count + 1
elif int(s[i]) <= t:
lst.append(int(s[i]))
lst.sort()
pro.append(1)
for k in range(0, len(lst)):
pro.sort()
curr = len(pro)
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL... |
Read problems statements in mandarin chinese, russian and vietnamese as well.
Though our Head Chef retired from sport programming long back, but that did not affect his passion to contribute to the programming community. He still remains engaged by creating new problems and passing it on to the online judges. Last Ni... | def checkProduct(index, Product):
if Product > N[1]:
return 0
if index < len(L):
return checkProduct(index + 1, Product) + checkProduct(
index + 1, Product * L[index]
)
elif Product <= N[1]:
return 1
else:
return 0
N = list(map(int, input().split()))... | FUNC_DEF IF VAR VAR NUMBER RETURN NUMBER IF VAR FUNC_CALL VAR VAR RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR IF VAR VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR V... |
Read problems statements in mandarin chinese, russian and vietnamese as well.
Though our Head Chef retired from sport programming long back, but that did not affect his passion to contribute to the programming community. He still remains engaged by creating new problems and passing it on to the online judges. Last Ni... | li = list(map(int, input().split()))
N = li[0]
maxval = li[1]
cnt = 0
arr = list(map(int, input().split()))
arr.sort()
array = [1]
ind = 0
flag = 0
for j in range(N):
if arr[j] == 1:
ind = j
flag = 1
if flag == 1:
numones = ind + 1
newarr = arr[ind + 1 :]
else:
numones = 0
newarr = a... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER AS... |
Read problems statements in mandarin chinese, russian and vietnamese as well.
Though our Head Chef retired from sport programming long back, but that did not affect his passion to contribute to the programming community. He still remains engaged by creating new problems and passing it on to the online judges. Last Ni... | def solve(a, count, m, x, n, i):
if i >= n:
return count
while i < n:
y = x
x *= a[i]
if x > m or x < y or x > 10**18:
count += pow(2, n - i - 1)
else:
z = x
j = i + 1
while j < n:
z *= a[j]
i... | FUNC_DEF IF VAR VAR RETURN VAR WHILE VAR VAR ASSIGN VAR VAR VAR VAR VAR IF VAR VAR VAR VAR VAR BIN_OP NUMBER NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR VAR VAR IF VAR VAR VAR BIN_OP NUMBER NUMBER VAR NUMBER IF VAR VAR RETURN VAR ASSIGN VAR ... |
Read problems statements in mandarin chinese, russian and vietnamese as well.
Though our Head Chef retired from sport programming long back, but that did not affect his passion to contribute to the programming community. He still remains engaged by creating new problems and passing it on to the online judges. Last Ni... | a = list(map(int, input().split(" ")))
n = a[0]
k = a[1]
a = list(map(int, input().split(" ")))
a1 = []
a2 = []
for i in range(len(a) // 2):
a1.append(a[i])
for i in range(len(a) // 2, len(a)):
a2.append(a[i])
p1 = []
p2 = []
for i in range(1, 1 << len(a1)):
pro = 1
for j in range(len(a1)):
if i... | ASSIGN 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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CA... |
Read problems statements in mandarin chinese, russian and vietnamese as well.
Though our Head Chef retired from sport programming long back, but that did not affect his passion to contribute to the programming community. He still remains engaged by creating new problems and passing it on to the online judges. Last Ni... | r, e = input().split()
n = int(r)
val = int(e)
list = input().split()
count = 0
stuff = []
cou = 0
siu = 0
for i in list:
u = int(i)
if u < val and u != 1:
stuff.insert(count, u)
count = count + 1
if u == 1:
siu = siu + 1
li = len(stuff)
ui = li
li = int(li / 2)
puff = stuff[0:li]
ku... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER... |
Read problems statements in mandarin chinese, russian and vietnamese as well.
Though our Head Chef retired from sport programming long back, but that did not affect his passion to contribute to the programming community. He still remains engaged by creating new problems and passing it on to the online judges. Last Ni... | n, k = list(map(int, input().split()))
oldarray = list(map(int, input().split()))
array = []
c = 0
for i in oldarray:
if i != 1:
array.append(i)
else:
c += 1
n = n - c
newArray = []
x = 0
for i in range(n):
if array[i] <= k:
g = 0
t = 0
while g < x:
if arr... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF... |
Read problems statements in mandarin chinese, russian and vietnamese as well.
Though our Head Chef retired from sport programming long back, but that did not affect his passion to contribute to the programming community. He still remains engaged by creating new problems and passing it on to the online judges. Last Ni... | def solve(A, aa, k):
A.sort()
for i in range(1, 2 ** len(A)):
mul = 1
for j in range(0, len(A)):
if 2**j & i:
mul = mul * A[j]
if mul <= k:
aa.append(mul)
aa.sort()
N, K = map(int, input().split())
Arr = [int(x) for x in input().split()]
A = ... | FUNC_DEF EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP BIN_OP NUMBER VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CAL... |
Read problems statements in mandarin chinese, russian and vietnamese as well.
Though our Head Chef retired from sport programming long back, but that did not affect his passion to contribute to the programming community. He still remains engaged by creating new problems and passing it on to the online judges. Last Ni... | def fun(arr, m):
d = []
for i in range(1, pow(2, len(arr))):
cnt = 1
for j in range(len(arr)):
if i & 1 << j:
cnt *= int(arr[j])
if cnt > m:
break
if cnt <= m:
d.append(cnt)
return d
def binsearch(arr, valu... | FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER... |
Read problems statements in mandarin chinese, russian and vietnamese as well.
Though our Head Chef retired from sport programming long back, but that did not affect his passion to contribute to the programming community. He still remains engaged by creating new problems and passing it on to the online judges. Last Ni... | memo = {}
def countSS(v, lim, curr, i):
key = "%d,%d" % (curr, i)
if i < 0:
return 0
if key in memo:
return memo[key]
cnt = 0
ii = i
while i >= 0:
mul = curr * v[i]
if mul <= lim:
cnt += 1
cnt += countSS(v, lim, mul, i - 1)
i -= 1... | ASSIGN VAR DICT FUNC_DEF ASSIGN VAR BIN_OP STRING VAR VAR IF VAR NUMBER RETURN NUMBER IF VAR VAR RETURN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR RETURN VAR ASSIGN VAR VAR FU... |
Read problems statements in mandarin chinese, russian and vietnamese as well.
Though our Head Chef retired from sport programming long back, but that did not affect his passion to contribute to the programming community. He still remains engaged by creating new problems and passing it on to the online judges. Last Ni... | v = []
b = []
ind = -1
l = list(map(int, input().split()))
n = l[0]
k = l[1]
arr = list(map(int, input().split()))
def compute(i, prod):
if i > ind:
return
compute(i + 1, prod)
v.append(prod * arr[i])
compute(i + 1, prod * arr[i])
def solve(i, prod):
if i == n:
return
solve(i... | ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR VAR RETURN EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_O... |
Read problems statements in mandarin chinese, russian and vietnamese as well.
Though our Head Chef retired from sport programming long back, but that did not affect his passion to contribute to the programming community. He still remains engaged by creating new problems and passing it on to the online judges. Last Ni... | lis = input().split()
n = int(lis[0])
k = int(lis[1])
lis = input().split()
Array = []
for i in range(0, n):
Array.append(int(lis[i]))
X = []
Y = []
for i in range(0, 1 << int(n / 2)):
result = 1
for j in range(0, int(n / 2)):
if i & 1 << j:
result = result * Array[j]
X.append(result... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER FUNC_CALL VAR... |
Read problems statements in mandarin chinese, russian and vietnamese as well.
Though our Head Chef retired from sport programming long back, but that did not affect his passion to contribute to the programming community. He still remains engaged by creating new problems and passing it on to the online judges. Last Ni... | n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
n1 = n // 2
n2 = n - n1
sa = []
sb = []
x = []
y = []
def binarySearch(req):
l = 0
h = len(y) - 1
while l <= h:
mid = (l + h) // 2
if y[mid] == req:
l = mid + 1
elif y[mid] < req:
l =... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR ... |
Read problems statements in mandarin chinese, russian and vietnamese as well.
Though our Head Chef retired from sport programming long back, but that did not affect his passion to contribute to the programming community. He still remains engaged by creating new problems and passing it on to the online judges. Last Ni... | g1 = []
g2 = []
r = input().split()
n = int(r[0])
k = int(r[1])
inp = [int(i) for i in input().split()]
mid = int(n / 2)
a = inp[:mid]
b = inp[mid:]
def genp(i, s):
if i == len(a):
if s != 0:
g1.append(s)
else:
genp(i + 1, s * a[i])
genp(i + 1, s)
def genp1(i, s):
if ... | ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR FUNC_DEF IF VAR FUNC_CALL VAR VAR IF VAR NU... |
Read problems statements in mandarin chinese, russian and vietnamese as well.
Though our Head Chef retired from sport programming long back, but that did not affect his passion to contribute to the programming community. He still remains engaged by creating new problems and passing it on to the online judges. Last Ni... | lst1 = []
lst2 = []
sec_sum1 = []
sec_sum2 = []
def rec1(pos, sum):
if pos == len(lst1):
sec_sum1.append(sum)
return
rec1(pos + 1, sum * lst1[pos])
rec1(pos + 1, sum)
def rec2(pos, sum):
if pos == len(lst2):
sec_sum2.append(sum)
return
rec2(pos + 1, sum * lst2[pos... | ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FUNC_DEF IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR RETURN EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_DEF IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR RETURN EXPR FUNC_CALL VAR BIN_OP VAR N... |
Read problems statements in mandarin chinese, russian and vietnamese as well.
Though our Head Chef retired from sport programming long back, but that did not affect his passion to contribute to the programming community. He still remains engaged by creating new problems and passing it on to the online judges. Last Ni... | def func(array, n, pro):
if pro > maxi:
return 0
if n == 0:
return 1
if array[n - 1] > maxi:
return func(array, n - 1, pro)
return func(array, n - 1, pro) + func(array, n - 1, pro * array[n - 1])
su = 0
li = list(map(int, input().split()))
N = li[0]
maxi = li[1]
cnt = 0
arr = l... | FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR BIN_OP VAR NUMBER VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR RETURN BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VA... |
Read problems statements in mandarin chinese, russian and vietnamese as well.
Though our Head Chef retired from sport programming long back, but that did not affect his passion to contribute to the programming community. He still remains engaged by creating new problems and passing it on to the online judges. Last Ni... | N, K = list(map(int, input().strip().split(" ")))
A = list(map(int, input().strip().split(" ")))
A = sorted(A)
total = {}
for i in range(N):
if len(total) == 0:
if A[i] <= K:
total[A[i]] = 1
else:
L = len(total)
if A[i] <= K:
TT = {}
for x in total:
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN V... |
Read problems statements in mandarin chinese, russian and vietnamese as well.
Though our Head Chef retired from sport programming long back, but that did not affect his passion to contribute to the programming community. He still remains engaged by creating new problems and passing it on to the online judges. Last Ni... | n, k = input().split()
n = int(n)
k = int(k)
l = [int(x) for x in input().split()]
d = dict()
for i in range(n):
if l[i] > k:
continue
copy = dict()
for key in d:
copy[key] = d[key]
for key in copy:
mult = key * l[i]
if mult <= k:
if not mult in copy:
... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR VAR VAR VAR FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR VA... |
Chef received an array A of N integers as a valentine's day present. He wants to maximize the length of the longest strictly increasing subsequence by choosing a subarray and adding a fixed integer X to all its elements.
More formally, Chef wants to maximize the length of the [longest strictly increasing subsequence] ... | def subsequence(seq):
if not seq:
return []
answer = [1]
M = [None] * len(seq)
P = [None] * len(seq)
L = 1
M[0] = 0
for i in range(1, len(seq)):
lower = 0
upper = L
if seq[M[upper - 1]] < seq[i]:
j = upper
else:
while upper - lo... | FUNC_DEF IF VAR RETURN LIST ASSIGN VAR LIST NUMBER ASSIGN VAR BIN_OP LIST NONE FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NONE FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR IF VAR VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR WH... |
Chef received an array A of N integers as a valentine's day present. He wants to maximize the length of the longest strictly increasing subsequence by choosing a subarray and adding a fixed integer X to all its elements.
More formally, Chef wants to maximize the length of the [longest strictly increasing subsequence] ... | def lis_right_dp(nums):
n = len(nums)
maxv = [0] * (n + 1)
pr, maxv[1] = 1, nums[-1]
dp = [0] * n
dp[-1] = 1
for j in range(n - 2, -1, -1):
l, r = 1, pr
while r - l > 2:
m = (r + l) // 2
if nums[j] >= maxv[m]:
r = m - 1
else:
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER VAR WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VA... |
During the breaks between competitions, top-model Izabella tries to develop herself and not to be bored. For example, now she tries to solve Rubik's cube 2x2x2.
It's too hard to learn to solve Rubik's cube instantly, so she learns to understand if it's possible to solve the cube in some state using 90-degrees rotation... | moves = [
[
(1, 24),
(3, 22),
(5, 1),
(7, 3),
(9, 5),
(11, 7),
(24, 9),
(22, 11),
(14, 13),
(13, 15),
(15, 16),
(16, 13),
],
[
(14, 4),
(16, 3),
(9, 14),
(10, 16),
(19, 9),... | ASSIGN VAR LIST 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 LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ... |
During the breaks between competitions, top-model Izabella tries to develop herself and not to be bored. For example, now she tries to solve Rubik's cube 2x2x2.
It's too hard to learn to solve Rubik's cube instantly, so she learns to understand if it's possible to solve the cube in some state using 90-degrees rotation... | A1 = [
[0, 2, 4, 6, 8, 10, 21, 23],
[1, 3, 5, 7, 9, 11, 20, 22],
[2, 3, 16, 18, 9, 8, 15, 13],
[0, 1, 17, 19, 11, 10, 14, 12],
[12, 13, 4, 5, 16, 17, 20, 21],
[14, 15, 6, 7, 18, 19, 22, 23],
]
flag = False
B = list(map(int, input().split()))
for j in range(6):
A = list(B)
for i in range(... | ASSIGN VAR LIST LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER... |
During the breaks between competitions, top-model Izabella tries to develop herself and not to be bored. For example, now she tries to solve Rubik's cube 2x2x2.
It's too hard to learn to solve Rubik's cube instantly, so she learns to understand if it's possible to solve the cube in some state using 90-degrees rotation... | cube = [
[13, 14, 5, 6, 17, 18, 21, 22],
[14, 16, 9, 10, 19, 17, 4, 3],
[1, 3, 5, 7, 9, 11, 24, 22],
]
def rotate(seq, i):
lst = []
s = seq[:]
for x in range(8):
lst.append(s[cube[i][x] - 1])
for j in range(3):
lst = lst[2:] + lst[:2]
for x in range(8):
... | ASSIGN VAR LIST LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR LIST ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR NUMBER FOR... |
During the breaks between competitions, top-model Izabella tries to develop herself and not to be bored. For example, now she tries to solve Rubik's cube 2x2x2.
It's too hard to learn to solve Rubik's cube instantly, so she learns to understand if it's possible to solve the cube in some state using 90-degrees rotation... | qube = list(map(int, input().split()))
g = 1
change = {}
kostka1 = [1, 2, 1, 2, 3, 1, 3, 1, 4, 3, 4, 3, 5, 5, 5, 5, 6, 6, 6, 6, 4, 2, 4, 2]
kostka2 = [1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 5, 5, 4, 1, 4, 1, 5, 2, 5, 2, 6, 6, 6, 6]
kostka3 = [1, 1, 1, 1, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 2, 2, 3, 3, 6, 6, 6, 6, 5, 5]
kostka4 = [1, ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR DICT 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 ASSIGN VAR LIST NUMBER NUMBER NUMBE... |
During the breaks between competitions, top-model Izabella tries to develop herself and not to be bored. For example, now she tries to solve Rubik's cube 2x2x2.
It's too hard to learn to solve Rubik's cube instantly, so she learns to understand if it's possible to solve the cube in some state using 90-degrees rotation... | from itertools import groupby
def isSolved(c):
cons = [x[0] for x in groupby(c)]
return len(cons) == 6
color = list(map(int, input().strip().split()))
faces = [
[2, 4, 6, 8, 10, 12, 23, 21],
[13, 14, 5, 6, 17, 18, 21, 22],
[15, 16, 7, 8, 19, 20, 23, 24],
[1, 3, 5, 7, 9, 11, 24, 22],
[9, ... | FUNC_DEF ASSIGN VAR VAR NUMBER VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER LIST NUMBER NUMBER N... |
During the breaks between competitions, top-model Izabella tries to develop herself and not to be bored. For example, now she tries to solve Rubik's cube 2x2x2.
It's too hard to learn to solve Rubik's cube instantly, so she learns to understand if it's possible to solve the cube in some state using 90-degrees rotation... | def f(a, d):
newa = a[:]
for i in range(24):
if i + 1 in d:
newa[d[i + 1] - 1] = a[i]
for i in range(0, 22, 4):
if not newa[i] == newa[i + 1] == newa[i + 2] == newa[i + 3]:
return False
return True
arr = list(map(int, input().split()))
var = [dict() for i in ran... | FUNC_DEF ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ... |
During the breaks between competitions, top-model Izabella tries to develop herself and not to be bored. For example, now she tries to solve Rubik's cube 2x2x2.
It's too hard to learn to solve Rubik's cube instantly, so she learns to understand if it's possible to solve the cube in some state using 90-degrees rotation... | cb = [int(item) for item in input().split()]
cbb = [cb[i : i + 4] for i in range(0, 24, 4)]
cons = [([i] * 4) for i in range(1, 7)]
k = 0
completeFaces = []
def v(x, y):
return cb[x - 1] == cb[y - 1]
def rot(thing):
for p, xx in enumerate(thing):
x = [xx[:2], xx[2:]]
for i in range(2):
... | ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST VAR NUMBER VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FUNC_DEF RETURN VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER FUNC_DEF FOR VAR VAR FUNC_C... |
During the breaks between competitions, top-model Izabella tries to develop herself and not to be bored. For example, now she tries to solve Rubik's cube 2x2x2.
It's too hard to learn to solve Rubik's cube instantly, so she learns to understand if it's possible to solve the cube in some state using 90-degrees rotation... | import sys
def check(q):
if (
q[1] == q[2] == q[3] == q[4]
and q[5] == q[6] == q[7] == q[8]
and q[9] == q[10] == q[11] == q[12]
and q[13] == q[14] == q[15] == q[16]
and q[17] == q[18] == q[19] == q[20]
and q[21] == q[22] == q[23] == q[24]
):
return True
... | IMPORT FUNC_DEF IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VA... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.