description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | class Solution:
def maxSum(self, w, x, b, n):
maxx = float("-inf")
val = 0
new_str = ""
start = 0
dic = {}
for i, (x_, b_) in enumerate(zip(x, b)):
dic[x_] = b_
for i, c in enumerate(w):
if c in dic:
val = val + dic[c]
... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR DICT FOR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | class Solution:
def maxSum(self, w, x, b, n):
asc = {}
for i in range(len(w)):
asc[w[i]] = ord(w[i])
for i in range(n):
asc[x[i]] = b[i]
maxsum = currsum = 0
maxres = res = ""
for i in range(len(w)):
if currsum + asc[w[i]] >= 0:
... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR NUMBER VAR VAR VAR VAR VAR VAR VAR ASSIGN... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | class Solution:
def maxSum(self, w, x, b, n):
max_so_far = -10000000
max_ending_here = 0
s = ""
for i in w:
if i in x:
c = x.index(i)
max_ending_here += b[c]
s += i
else:
max_ending_here += ord(i... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR STRING IF VAR STRING ASSIGN VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING IF VAR VAR RETU... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | class Solution:
def maxSum(self, w, x, b, n):
s = ""
dict = {a: b for a, b in zip(x, b)}
max_ending_here, max_so_far = -float("inf"), -float("inf")
curr, res = "", ""
for i in w:
val = dict[i] if i in dict else ord(i)
if max_ending_here < 0:
... | CLASS_DEF FUNC_DEF ASSIGN VAR STRING ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR VAR STRING STRING FOR VAR VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIG... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | class Solution:
def maxSum(self, w, x, b, n):
d = dict(zip(x, b))
size = len(w)
maxi = -1000000000.0
cur = 0
curStr = ""
ans = ""
for i in range(size):
if w[i] in d.keys():
cur += d[w[i]]
else:
cur += or... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR IF VAR ... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | class Solution:
def maxSum(self, w, x, b, n):
if len(w) <= 1:
return w
dic = {}
max_till_now = 0
max_so_far = -99999999999999999
ans = ""
ans2 = ""
for i in range(len(w)):
if w[i] in x:
index = x.index(w[i])
... | CLASS_DEF FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN VAR ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR VAR VAR VAR VAR ... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | class Solution:
def maxSum(self, w, x, b, n):
arr = [(b[x.index(i)] if i in x else ord(i)) for i in w]
max1 = -9999
ends = 0
sub1 = ""
sub2 = ""
for i in range(len(w)):
ends += arr[i]
sub1 += w[i]
if ends > max1:
ma... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING RETURN ... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | class Solution:
def maxSum(self, w, x, b, n):
s = set(w)
asci = {}
for i in s:
if i in x:
asci[i] = b[x.index(i)]
else:
asci[i] = ord(i)
curr_max = 0
max_so_far = float("-inf")
N = len(w)
s = 0
e... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR ... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | class Solution:
def maxSum(self, w, x, b, n):
d = dict()
n = len(w)
for i in range(ord("A"), ord("Z") + 1):
d[chr(i)] = i
for i in range(ord("a"), ord("z") + 1):
d[chr(i)] = i
for i, j in zip(x, b):
d[i] = j
anss = -1
an = ... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR STRING BIN_OP FUNC_CALL VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR STRING BIN_OP FUNC_CALL VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR VAR FUNC_CALL VAR... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | class Solution:
def maxSum(self, w, x, b, n):
asc = {}
for i in range(n):
asc[x[i]] = b[i]
res = [[0, 1], self.asc_value(w[0], asc)]
cur = [[0, 1], self.asc_value(w[0], asc)]
for i in range(1, len(w)):
ch = w[i]
val = self.asc_value(ch, as... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR LIST LIST NUMBER NUMBER FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR LIST LIST NUMBER NUMBER FUNC_CALL VAR VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF BI... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | class Solution:
def maxSum(self, w, x, b, n):
dic = {}
for i in range(n):
dic[x[i]] = b[i]
ans = 0
s = ""
fin = -999
fin_str = ""
for i in w:
if i not in dic:
s += i
ans += ord(i)
else:
... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR VAR IF VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STR... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | class Solution:
def maxSum(self, w, x, b, n):
for i in range(n):
h = dict(zip(x, b))
s = 0
t = ""
ans = ""
mx = -1000000000.0
a = 0
for i in range(len(w)):
if w[i] in h:
a = h[w[i]]
else:... | CLASS_DEF FUNC_DEF FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR IF VAR ... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | class Solution:
def maxSum(self, w, x, b, n):
val = []
for i in w:
if i not in x:
val.append(ord(i))
else:
val.append(b[x.index(i)])
maxyet = 0
maxcur = 0
start = 0
s = 0
e = 0
for i in range(len... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VAR ASSIGN VAR VA... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | class Solution:
def maxSum(self, w, x, b, n):
sum_val = 0
max_val = ord(w[0])
max_string = w[0]
my_dict = {}
for _ in range(len(x)):
my_dict[x[_]] = b[_]
final_string = w[0]
counter = 0
for _ in w:
if counter != 0:
... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR VAR IF VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR AS... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | class Solution:
def maxSum(self, w, x, b, n):
dp = {}
for i in range(n):
dp[x[i]] = b[i]
sum = 0
maxStart = 0
maxEnd = 0
start = 0
end = 0
if dp.get(w[0]) == None:
maxSum = ord(w[0])
else:
maxSum = dp[w[0]]
... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER NONE ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR VAR NONE VAR F... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | class Solution:
def maxSum(self, w, x, b, n):
dic = dict(zip(x, b))
currsum = globalSum = 0
start = end = s = 0
for i in range(len(w)):
k = ord(w[i])
if dic.get(w[i]) is None:
currsum += k
else:
currsum += dic[w[i]]... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR VAR NONE VAR VAR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR IF VAR NUMBER ASSIGN VA... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | class Solution:
def __init__(self):
self.mp = dict()
def asc(self, letr):
if self.mp.get(letr) == None:
return ord(letr)
return self.mp[letr]
def maxSum(self, w, x, b, n):
self.mp.clear()
for i in range(n):
self.mp[x[i]] = b[i]
curr_... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_DEF IF FUNC_CALL VAR VAR NONE RETURN FUNC_CALL VAR VAR RETURN VAR VAR FUNC_DEF EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR N... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | class Solution:
def maxSum(self, w, x, b, n):
if len(w) == 1:
return w
arr = {}
for i in w:
if i in x:
arr[i] = b[x.index(i)]
else:
arr[i] = ord(i)
max_so_far = 0
max_end = 0
s = 0
end = 0
... | CLASS_DEF FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN VAR ASSIGN VAR DICT FOR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | class Solution:
def maxSum(self, w, x, b, n):
ump = {}
for i in range(n):
ump[x[i]] = b[i]
start, stop, s = 0, 0, 0
res, sum = 0, 0
for i in range(len(w)):
if w[i] in ump:
sum += ump[w[i]]
else:
sum += ord(w... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VA... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | from sys import maxsize
class Solution:
def maxSum(self, w, x, b, n):
dict = {}
for ele in w:
if ele not in dict:
dict[ele] = ord(ele)
for i in range(len(x)):
if x[i] in dict:
dict[x[i]] = b[i]
start = 0
end = 0
... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT FOR VAR VAR IF VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | class Solution:
def maxSum(self, w, x, b, n):
eval_char = lambda a: b[x.index(a)] if a in x else ord(a)
len_w = len(w)
max_i = i = 0
max_j = j = 0
max_sum = summ = eval_char(w[j])
while j < len_w - 1:
if summ < 0:
j += 1
i ... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR WHILE VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR NUMBER VAR FUNC_CALL VAR VA... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | get_ascii = lambda c, asciidict: asciidict.get(c, ord(c))
class Solution:
def maxSum(self, w, x, b, n):
asciidict = {x[i]: b[i] for i in range(n)}
s_i, e_i, cur_s = 0, 0, 0
max_sum = 0
cursum = 0
for idx, c in enumerate(w):
cursum = cursum + get_ascii(c, asciid... | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR CLASS_DEF FUNC_DEF ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR N... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | class Solution:
def maxSum(self, w, x, b, n):
score = {}
for i in range(97, 97 + 26):
score[chr(i)] = i
for i in range(65, 65 + 26):
score[chr(i)] = i
for i in range(n):
score[x[i]] = b[i]
n = len(w)
s = 0
m = [0, 0]
... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST NUM... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | class Solution:
def maxSum(self, w, x, b, n):
res = ""
raji = ""
curr = 0
maxi = -float("infinity")
for a, i in enumerate(w):
p = ord(i)
if i in x:
p = b[x.index(i)]
curr += p
raji += i
if curr > max... | CLASS_DEF FUNC_DEF ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING RETUR... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | class Solution:
def maxSum(self, w, x, b, n):
s = 0
e = 0
ans = ""
l = []
start = s
sum = 0
max = -1
for ele in w:
if ele in x:
l.append(b[x.index(ele)])
else:
l.append(ord(ele))
for i in... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR LIST ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VA... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | class Solution:
def maxSum(self, w, x, b, n):
all_negative = 1
max_position = -1
max_value = -1000000
for i in range(0, len(w)):
if w[i] in x:
check = b[x.index(w[i])]
else:
check = ord(w[i])
if check > 0:
... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR IF VAR NUMBER RETURN VAR VAR ASSIGN VAR NU... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | from sys import maxsize
class Solution:
def maxSum(self, w, x, b, n):
ans_str = ""
ans_ascii = -maxsize - 1
curr = 0
curr_str = ""
w = list(w)
for i in range(len(w)):
curr_str += w[i]
if w[i] in x:
for j in range(n):
... | CLASS_DEF FUNC_DEF ASSIGN VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VA... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | class Solution:
def maxSum(self, w, x, b, n):
start, stop, s = 0, 0, 0
su = 0
res = 0
for i in range(len(w)):
if w[i] not in x:
su += ord(w[i])
else:
su += b[x.index(w[i])]
if su < 0:
su = 0
... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR V... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | import sys
class Solution:
def maxSum(self, w, x, b, n):
res = []
for i in w:
if i in x:
res.append(b[x.index(i)])
else:
res.append(ord(i))
maxsum = -1 * sys.maxsize
f = 0
l = 0
c = 0
p = [0, 0]
... | IMPORT CLASS_DEF FUNC_DEF ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR A... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | class Solution:
def maxSum(self, w, x, b, n):
map = {}
for i in range(len(x)):
map[x[i]] = b[i]
res = -1e19
result = ""
curr = 0
s = ""
for i in w:
if curr < 0:
curr = 0
s = ""
if i in map:
... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING IF VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIG... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | class Solution:
def maxSum(self, w, x, b, n):
result = -float("inf")
temp = 0
u, v = 0, 0
i, j = 0, 0
for c in range(len(w)):
for k in range(n):
if w[c] == x[k]:
temp += b[k]
break
else:
... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR IF VAR NUM... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | class Solution:
def maxSum(self, w, x, b, n):
A = []
if len(w) == 1:
return w
mp = {}
for i in range(n):
mp[x[i]] = b[i]
curr_sum = 0
max_sum = -100000
curr_s = ""
max_s = ""
for i in range(len(w)):
if w[i] ... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST IF FUNC_CALL VAR VAR NUMBER RETURN VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VA... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | class Solution:
def maxSum(self, w, x, b, n):
max_sum_here = 0
max_sum_whole = max_sum_here
start = end = s = 0
for i in range(0, len(w)):
if w[i] not in x:
if ord(w[i]) + max_sum_here >= 0:
max_sum_here += ord(w[i])
... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR IF BIN_OP FUNC_CALL VAR VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR IF BIN_OP VAR FUNC_CALL VAR VAR VAR VAR NUMBER VAR VAR ... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | class Solution:
def maxSum(self, w, x, b, n):
res = 0
res1 = 0
string_res = ""
string_res1 = ""
store = {}
value = {}
if len(w) == 1:
return w[0]
for i in range(n):
value[x[i]] = b[i]
curent = 0
maxtilnow = 0
... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR DICT ASSIGN VAR DICT IF FUNC_CALL VAR VAR NUMBER RETURN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN V... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | class Solution:
def maxSum(self, w, x, b, n):
res = -float("infinity")
resString = ""
tempStrig = ""
sum = 0
mydict = dict()
for i in range(len(x)):
mydict[x[i]] = b[i]
for i in w:
val = mydict[i] if i in mydict else ord(i)
... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR FOR VAR VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR IF VAR NU... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | class Solution:
def maxSum(self, w, x, b, n):
map = {}
for i in range(n):
map[x[i]] = b[i]
maxi = float("-inf")
ans = ""
temp = ""
sum = 0
i = 0
while i < len(w):
if w[i] in map:
sum = sum + map[w[i]]
... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR VAR ASSIGN ... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | class Solution:
def maxSum(self, W, X, B, n):
cs = 0
ms = -1000000000
res = ""
start = end = s = 0
if len(W) == 1:
res = W
return res
for i in range(len(W)):
if W[i] in X:
ind = X.index(W[i])
x = B[i... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR ASSIGN V... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | class Solution:
def maxSum(self, w, x, b, n):
asci = {}
for i in "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM":
asci[i] = ord(i)
for i in range(n):
asci[x[i]] = b[i]
arr = []
for i in w:
arr.append(asci[i])
i = 0
j... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT FOR VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL V... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | class Solution:
def fillasciivalue(self, x, b, n, lower, upper):
for i in range(n):
value = ord(x[i])
if value >= 65 and value <= 90:
upper[value - 65] = b[i]
else:
lower[value - 97] = b[i]
def maxSum(self, w, x, b, n):
lower ... | CLASS_DEF FUNC_DEF FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR VAR A... |
Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which has the sum of the ASCII values of its every character, as maximum. ASCII values of some characters are redefined.
Note: Uppercase & lowercase both will be present in the string w. Array ... | from sys import maxsize
class Solution:
def maxSum(self, w, x, b, n):
ts = 0
strt = 0
end = 0
max = -maxsize - 1
sum = 0
for i in range(0, len(w)):
if w[i] in x:
sum = sum + b[x.index(w[i])]
else:
sum = sum + ... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIG... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | T = int(input())
cache = {}
def compute(width):
if width < 4:
cache[width] = 1
return 1
else:
l, r = width - 1, width - 4
cache[l] = cache.get(l, None) or compute(l)
cache[r] = cache.get(r, None) or compute(r)
return cache[l] + cache[r]
def count_primes(n):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT FUNC_DEF IF VAR NUMBER ASSIGN VAR VAR NUMBER RETURN NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR NONE FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NONE FUNC_CALL VAR VAR RETURN BIN_OP VAR VAR VAR VAR FUNC_DEF ASSI... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | import itertools
def erat2():
D = {}
yield 2
for q in itertools.islice(itertools.count(3), 0, None, 2):
p = D.pop(q, None)
if p is None:
D[q * q] = q
yield q
else:
x = p + q
while x in D or not x & 1:
x += p
... | IMPORT FUNC_DEF ASSIGN VAR DICT EXPR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER NUMBER NONE NUMBER ASSIGN VAR FUNC_CALL VAR VAR NONE IF VAR NONE ASSIGN VAR BIN_OP VAR VAR VAR EXPR VAR ASSIGN VAR BIN_OP VAR VAR WHILE VAR VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR ... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | def sieve(n):
np1 = n + 1
s = list(range(np1))
s[1] = 0
sqrtn = int(round(n**0.5))
for i in range(2, sqrtn + 1):
if s[i]:
s[i * i : np1 : i] = [0] * len(range(i * i, np1, i))
return len(list(filter(None, s)))
inp = []
for _ in range(int(input())):
inp.append(int(input()... | FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | T = int(input())
for t in range(T):
N = int(input())
dp = [1, 1, 1, 1]
for i in range(4, 1 + N):
dp.append(dp[i - 1] + dp[i - 4])
x = dp[N]
prime = [True] * (1 + x)
prime[0] = prime[1] = False
p = 2
while p * p <= x:
if prime[p]:
for g in range(2 * p, x + 1, p... | 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 NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | def findConfig(N, configs):
if len(configs) == 0:
configs.append(0)
configs.append(1)
configs.append(1)
configs.append(1)
configs.append(2)
index = 5
else:
index = len(configs)
for i in range(index, N + 1):
numWays = configs[i - 4] + configs[i ... | FUNC_DEF IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | T = int(input())
for _ in range(T):
N = int(input())
DP = [1] * (N + 1)
for i in range(4, N + 1):
DP[i] = DP[i - 1] + DP[i - 4]
Num = DP[N]
sieve = [True] * (Num + 1)
p = 2
primes = 0
while p <= Num:
primes += 1
for k in range(p + p, Num + 1, p):
sieve... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | _MAX_VALUE = 250000
def _is_prime(n):
if n <= 3:
return n >= 2
if n % 2 == 0 or n % 3 == 0:
return False
for i in range(5, int(n**0.5) + 1, 6):
if n % i == 0 or n % (i + 2) == 0:
return False
return True
def _calc_primes(_MAX_VALUE):
nprimes = [(0) for _ in ra... | ASSIGN VAR NUMBER FUNC_DEF IF VAR NUMBER RETURN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP VAR VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR NUM... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | def nchoosek(n, k):
p = 1
for i in range(k):
p = p * (n - i) // (i + 1)
return p
def countm(n):
s = 0
for nh in range(n // 4 + 1):
nv = n - 4 * nh
s += nchoosek(nh + nv, nh)
return s
def genIsPrime(pmax):
pend = pmax + 1
is_prime = pend * [True]
is_prime[0... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR BIN_O... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | def primes(n):
if n <= 2:
return 0
sieve = [True] * n
for i in range(3, int(n**0.5) + 1, 2):
if sieve[i]:
sieve[i * i :: 2 * i] = [False] * int((n - i * i - 1) / (2 * i) + 1)
return len([i for i in range(3, n, 2) if sieve[i]]) + 1
def find_configs(N):
if N == 0:
... | FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR VAR BIN_OP NUMBER VAR BIN_OP LIST NUMBER FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR VAR NUMBER BIN_OP NUMBER VAR NUMBER ... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | _brick_cache = {}
def brick_combinations(N):
if N < 0:
return 0
if N < 4:
return 1
if N in _brick_cache:
return _brick_cache[N]
answer = brick_combinations(N - 1) + brick_combinations(N - 4)
_brick_cache[N] = answer
return answer
def primes(n):
sieve = [True] * n
... | ASSIGN VAR DICT FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR VAR RETURN VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP V... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | def seive(n):
primes = [True] * n
l = 0
primes[0] = primes[1] = False
for i in range(2, n):
if primes[i]:
l += 1
primes[2 * i :: i] = [False] * ((n - 1) // i - 1)
return l
def tile(n):
m = [1] * (n + 1)
for i in range(4, n + 1):
m[i] = m[i - 1] + m[i... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR VAR BIN_OP LIST NUMBER BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR V... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | def isPrime(n):
if n % 2 == 0:
return False
i = 3
while i * i <= n:
if n % i == 0:
return False
i += 2
return True
def primes(n):
if n == 1:
return 0
i = 3
cnt = 1
while i <= n:
if isPrime(i):
cnt += 1
i += 2
r... | FUNC_DEF IF BIN_OP VAR NUMBER NUMBER RETURN NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF BIN_OP VAR VAR NUMBER RETURN NUMBER VAR NUMBER RETURN NUMBER FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR L... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | cache = {}
def sols(n):
if n in cache:
return cache[n]
else:
res = 1
for i in range(n - 3):
res += sols(i)
cache[n] = res
return cache[n]
primes = [1] * 1000000
primes[0] = 0
primes[1] = 0
for i in range(2, len(primes)):
if primes[i] == 1:
for ... | ASSIGN VAR DICT FUNC_DEF IF VAR VAR RETURN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR RETURN VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR NUMBER FOR... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | T = int(input())
def primes(n):
ls = [True] * n
limit = int(n**0.5) + 1
for i in range(2, limit):
if ls[i]:
j, k = i**2, 1
while j < n:
ls[j] = False
j = i**2 + k * i
k += 1
return sum([a for a in ls[2:] if a])
for t in ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER NUMBER WHILE VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR VAR VAR NUMBER... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | def isprime(n):
if n == 1:
return False
for i in range(2, int(n**0.5 + 1)):
if n % i == 0:
return False
return True
def calprime(n):
c = 0
for i in range(2, n + 1):
if isprime(i):
c = c + 1
return c
def calno(n):
a = [1, 1, 1, 1]
for i ... | FUNC_DEF IF VAR NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR ... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | def getPrimes(n):
primeList = []
for i in range(2, n + 1):
if isPrime(i):
primeList.append(i)
return len(primeList)
def isPrime(n):
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return True
t = int(input())
for i in range(t):
n = int(... | FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR VAR FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | def countprimes3(x):
if x == 1:
return []
else:
a = [False, False] + [(True) for i in range(2, x + 1)]
i = 2
while i <= x**0.5:
if a[i] is True:
k = 0
while i**2 + k * i <= x:
a[i**2 + k * i] = False
... | FUNC_DEF IF VAR NUMBER RETURN LIST ASSIGN VAR BIN_OP LIST NUMBER NUMBER NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP BIN_OP VAR NUMBER BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER VAR NUMB... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | def is_prime(n):
if n <= 3:
return n >= 2
if n % 2 == 0 or n % 3 == 0:
return False
for i in range(5, int(n**0.5) + 1, 6):
if n % i == 0 or n % (i + 2) == 0:
return False
return True
def nCr(n, r):
res = 1.0
for i in range(1, r + 1):
res *= (n + 1 - ... | FUNC_DEF IF VAR NUMBER RETURN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP VAR VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_C... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | def memoize(func):
pool = {}
def wrapper(*arg):
if arg not in pool:
pool[arg] = func(*arg)
return pool[arg]
return wrapper
def get_primes(max):
sieve = [True] * max
sieve[0] = False
sieve[1] = False
for i in range(int(max**0.5)):
if sieve[i]:
... | FUNC_DEF ASSIGN VAR DICT FUNC_DEF IF VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR RETURN VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VA... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | nt = int(input())
np = [
0,
0,
0,
0,
1,
2,
2,
3,
4,
4,
6,
8,
9,
11,
15,
19,
24,
32,
42,
53,
68,
91,
119,
155,
204,
269,
354,
462,
615,
816,
1077,
1432,
1912,
2543,
3385,
4522,
... | ASSIGN VAR FUNC_CALL 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 NUMBER... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | T = int(input())
A = [1]
limit = 220000
for i in range(1, 41):
A.append(A[i - 1] * i)
isP = [True] * limit
isP[0] = isP[1] = False
for i in range(2, limit):
if isP[i]:
for j in range(i + i, limit, i):
isP[j] = False
C = [0] * limit
acc = 0
for i in range(2, limit):
if isP[i]:
acc... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR V... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | def primes(n):
ps = [2]
for i in range(3, n + 1):
for j in ps:
if j * j > i:
ps.append(i)
break
if i % j == 0:
break
return ps
T = int(input())
vals = []
maxVal = 0
for i in range(T):
vals.append(int(input()))
if vals[... | FUNC_DEF ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR VAR IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR IF... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | import sys
C = 4
def generate_primes(n):
if n == 2:
return [2]
elif n < 2:
return []
sieve = list(range(3, n + 1, 2))
root_n = n**0.5
mid = (n + 1) // 2 - 1
i = 0
m = 3
while m <= root_n:
if sieve[i]:
j = (m * m - 3) // 2
sieve[j] = 0
... | IMPORT ASSIGN VAR NUMBER FUNC_DEF IF VAR NUMBER RETURN LIST NUMBER IF VAR NUMBER RETURN LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR ASSIGN VA... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | num_ways = [(-1) for x in range(40)]
for i in range(3):
num_ways[i] = 1
num_ways[3] = 2
for i in range(4, 40):
num_ways[i] = num_ways[i - 1] + num_ways[i - 4]
isprime = [(-1) for x in range(num_ways[39])]
isprime[0] = 1
i = 2
while i < num_ways[39] + 1:
if isprime[i - 1] == 0:
i += 1
continu... | ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | vals = [
1,
1,
1,
2,
3,
4,
5,
7,
10,
14,
19,
26,
36,
50,
69,
95,
131,
181,
250,
345,
476,
657,
907,
1252,
1728,
2385,
3292,
4544,
6272,
8657,
11949,
16493,
22765,
31422,
43371,
... | 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 ASSIGN VAR... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | import sys
def main():
numinputs = int(input())
dp = [1, 1, 1, 1]
inputs = [int(val) for val in sys.stdin]
for i in range(4, 41):
dp.append(dp[i - 1] + dp[i - 4])
n = max(dp)
primes = find_primes(n + 1)
primes = count_primes(primes, n + 1)
for x in inputs:
print(primes[... | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | def sieve(n):
if n < 3:
return []
s = list(range(n // 2))
for i in s:
if i:
k = i - ~i
for j in range(k * k, n, 2 * k):
s[j // 2] = 0
primes = [2]
primes += [(2 * s[prime] + 1) for prime in range(len(s)) if s[prime] > 0]
return primes
def... | FUNC_DEF IF VAR NUMBER RETURN LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR VAR IF VAR ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST NUMBER VAR BIN_OP BIN_OP NUMBER VAR VAR NUMBER VAR FUNC_CALL VAR FUNC_CA... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | values = []
values.append(1)
for i in range(1, 41):
value = values[i - 1]
if i - 4 >= 0:
value = value + values[i - 4]
values.append(value)
primes = [True] * (values[-1] + 1)
primes[0] = False
primes[1] = False
for i in range(2, len(primes)):
if primes[i]:
for j in range(i * i, len(prime... | ASSIGN VAR LIST EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR F... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | def walls(laid, height):
if laid > height:
return 0
if laid == height:
return 1
return walls(laid + 1, height) + walls(laid + 4, height)
def primes_less_than(M):
sieve = [True] * (M + 1)
sieve[0] = sieve[1] = False
prime = 2
while prime**2 <= M:
if sieve[prime]:
... | FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR VAR RETURN NUMBER RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER VAR IF VAR VAR FOR VAR FUNC_CALL VAR BIN... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | def confs(n):
if n < 4:
return 1
elif n == 4:
return 2
else:
return confs(n - 1) + confs(n - 4)
def sieve(m):
arr = [1] * m
arr[0] = arr[1] = 0
primes = 0
for i in range(2, m):
if arr[i] == 1:
primes += 1
for j in range(i * 2, m, i):
... | FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL ... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | def primes(x):
ar = [True] * (x + 1)
ar[0] = False
ar[1] = False
for i in range(2, int(x ** (1 / 2)) + 1):
if ar[i] == True:
for j in range(2 * i, x + 1, i):
ar[j] = False
return ar.count(True)
t = int(input())
for _ in range(t):
n = int(input())
ar = [0... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER NUMBER NUMBER IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER RETURN FUNC_CALL VAR N... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | import sys
n = int(input())
ts = []
for i in range(n):
ts.append(int(input()))
maxt = max(ts)
ms = [1, 1, 1, 2]
for i in range(4, maxt):
ms.append(ms[i - 1] + ms[i - 4])
maxm = ms[-1]
isprime = [True] * (maxm - 1)
i = 2
while i <= maxm:
if not isprime[i - 2]:
i = i + 1
continue
j = i + ... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VA... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | T = int(input())
wall_widths = [int(input()) for _ in range(T)]
max_wall_width = max(*wall_widths)
width_to_num_formats = [1]
for w in range(1, max_wall_width + 1):
num_formats = width_to_num_formats[w - 1]
if w >= 4:
num_formats += width_to_num_formats[w - 4]
width_to_num_formats.append(num_formats... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR DICT NUMBER NU... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | def wall(n):
if n < 4:
return 1
else:
return wall(n - 1) + wall(n - 4)
def isPrime(n):
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return True
def primeCounter(n):
primeCount = 0
if n > 1:
for num in range(2, n + 1):
... | FUNC_DEF IF VAR NUMBER RETURN NUMBER RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR NUMBE... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | __author__ = "said"
def numberOfP(m):
counter = 0
zahlen = [True] * (m + 1)
zahlen[0] = False
zahlen[1] = False
p = 2
while p * p <= m:
if zahlen[p] == True:
for k in range(p * p, m + 1, p):
zahlen[k] = False
p = p + 1
for i, v in enumerate(zahle... | ASSIGN VAR STRING FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VA... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | sols = {}
sols[1] = 1
sols[2] = 1
sols[3] = 1
sols[4] = 2
def config(n):
if n <= 0:
return 0
sum = 0
if n in sols.keys():
return sols[n]
else:
sum = config(n - 1) + config(n - 4)
sols[n] = sum
return sum
def Prime(n):
n = n + 1
arr = list(range(0, n))
... | ASSIGN VAR DICT ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER IF VAR FUNC_CALL VAR RETURN VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR RETURN VAR F... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | def primes235(limit):
if limit >= 2:
yield 2
if limit >= 3:
yield 3
if limit >= 5:
yield 5
if limit < 7:
return
modPrms = [7, 11, 13, 17, 19, 23, 29, 31]
gaps = [4, 2, 4, 2, 4, 6, 2, 6, 4, 2, 4, 2, 4, 6, 2, 6]
ndxs = [
0,
0,
0,
... | FUNC_DEF IF VAR NUMBER EXPR NUMBER IF VAR NUMBER EXPR NUMBER IF VAR NUMBER EXPR NUMBER IF VAR NUMBER RETURN ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR L... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | def is_prime(n):
if n <= 3:
return True
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return True
li = [0] * 50
li[0] = 1
li[1] = 1
li[2] = 1
li[3] = 1
li[4] = 2
li[5] = 3
for i in range(6, 50):
li[i] = li[i - 1] + li[i - 4]
t = int(input())
for _ in range... | FUNC_DEF IF VAR NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER ... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | t = int(input())
def configurations(n):
memo = {}
if n < 4:
return 1
else:
x = configurations(n - 1) + configurations(n - 4)
memo[n] = x
return x
def sieve(n):
np1 = n + 1
s = list(range(np1))
s[1] = 0
sqrtn = int(round(n**0.5))
for i in range(2, sqrtn + 1):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR DICT IF VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | T = int(input())
for t in range(T):
m = int(input())
a = [0] * max(m + 1, 4)
a[0] = a[1] = a[2] = a[3] = 1
for i in range(4, m + 1):
a[i] = a[i - 1] + a[i - 4]
maxPrime = a[m]
isPrime = [True] * (maxPrime + 1)
for i in range(2, maxPrime + 1):
curr = 2 * i
while curr <... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBE... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | nbCombMem = [], []
def nbComb(N):
if N in nbCombMem[0]:
return nbCombMem[1][nbCombMem[0].index(N)]
if N < 0:
return 0
c = 1
for i in range(0, N - 3):
c += nbComb(N - 4 - i)
nbCombMem[0].append(N)
nbCombMem[1].append(c)
return c
def getPrimesUnder(n):
r = [2]
... | ASSIGN VAR LIST LIST FUNC_DEF IF VAR VAR NUMBER RETURN VAR NUMBER FUNC_CALL VAR NUMBER VAR IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER VAR RETURN VAR FUNC_DEF ASSIGN VA... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | def findPrimes(primes, n):
if len(primes) < n + 1:
primes = primes + [(1) for i in range(len(primes), n + 1)]
num = int(n**0.5)
primes[0] = primes[1] = 0
for i in range(2, num + 1):
if primes[i] == 1:
for j in range(2 * i, n + 1, i):
pr... | FUNC_DEF IF FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR BIN_O... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | import sys
def numConfigs(n):
if n < 0:
return 0
if n == 1 or n == 0:
return 1
return numConfigs(n - 1) + numConfigs(n - 4)
def numPrimes(n):
numPrimes = 0
for i in range(2, n + 1):
foundPrime = False
j = 2
while j * j <= i and not foundPrime:
... | IMPORT FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR VAR IF BIN_OP VAR VAR NU... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | dp = [1] + [0] * 43
for i in range(40):
dp[i + 1] += dp[i]
dp[i + 4] += dp[i]
sieve = [1] * (dp[40] * 2)
primes = []
for i in range(2, len(sieve)):
if sieve[i]:
primes.append(i)
for j in range(2, dp[40] * 2 // i):
sieve[i * j] = 0
primes.append(1000000000)
for _ in range(int(inpu... | ASSIGN VAR BIN_OP LIST NUMBER BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR N... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | case_count = int(input())
cases = [int(input()) for _ in range(case_count)]
def prime_number_count(maximum):
prime_count = 0
vec = [(True) for _ in range(maximum + 1)]
for i in range(2, maximum + 1):
if vec[i]:
prime_count += 1
for j in range(2, maximum + 1):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR A... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | dp = [
0,
0,
0,
0,
1,
2,
2,
3,
4,
4,
6,
8,
9,
11,
15,
19,
24,
32,
42,
53,
68,
91,
119,
155,
204,
269,
354,
462,
615,
816,
1077,
1432,
1912,
2543,
3385,
4522,
6048,
8078... | 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 ASSIGN VAR FUNC_C... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | res = [1] * 4
for i in range(4, 41):
res.append(res[-1] + res[-4])
mx = res[-1]
l = [False] * 2 + [True] * (mx - 1)
z = [False] * (mx // 2)
for i in range(2, int(mx**0.5) + 1):
if l[i]:
l[i * i :: i] = z[: mx // i - i + 1]
for i in range(int(input())):
print(sum(l[: res[int(input())] + 1])) | ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP LIST NUMBER NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VA... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | def is_prime(n):
if n % 3 == 0:
return False
r = int(n**0.5)
f = 5
while f <= r:
if n % f == 0:
return False
if n % (f + 2) == 0:
return False
f += 6
return True
def ma(i, j):
r = 1
for u in range(i - j):
r = r * i
i =... | FUNC_DEF IF BIN_OP VAR NUMBER NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR VAR NUMBER RETURN NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER RETURN NUMBER VAR NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR BI... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | import sys
def num_ways(N, values):
if N == 0:
return 1
if N < 0:
return 0
result = 0
for i, v in enumerate(values):
result += num_ways(N - v, values)
return result
def sieve(N):
ledger = [True] * (N + 1)
ledger[0] = False
ledger[1] = False
primes = []
... | IMPORT FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR LIST WHILE NUMBER ASSIGN VAR FUNC_... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | t = int(input())
for testCase in range(t):
n = int(input())
m = 1
for i in range(4, n + 1, 4):
a = i // 4
b = n - i + 1
currNum = 1
for j in range(a):
currNum *= b + j
currNum //= j + 1
m += currNum
if m < 2:
print(0)
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 NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP V... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | arr = [0] * (40 + 1)
arr[0] = 1
for i in range(1, 40 + 1):
arr[i] = arr[i - 1]
if i >= 4:
arr[i] += arr[i - 4]
MAX = 217286
prime = [True] * (MAX + 1)
prime[0] = False
prime[1] = False
count = [0] * (MAX + 1)
for i in range(2, MAX + 1):
count[i] = count[i - 1]
if prime[i]:
count[i] += 1
... | ASSIGN VAR BIN_OP LIST NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMB... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | t = int(input())
dp = [1] + [0] * 50
for i in range(1, 41):
dp[i] = dp[i - 1] + (dp[i - 4] if i - 4 >= 0 else 0)
def isPrime(p):
i = 2
while i * i <= p:
if p % i == 0:
return False
i += 1
return True
np, cnt = {}, 0
np[1] = 0
for i in range(2, max(dp) + 1):
if isPrime... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF BIN_OP VAR VAR NUMBER RETURN NUMBER ... |
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows.
There is a wall of size 4xn in the victim's house. The victim... | tmp = [1] * 41
for i in range(4, 41):
tmp[i] = tmp[i - 1] + tmp[i - 4]
primes = [1] * (tmp[40] + 2)
primes[0], primes[1] = 0, 0
for i in range(4, len(primes), 2):
primes[i] = 0
for i in range(3, len(primes), 2):
if primes[i] == 1:
for j in range(2 * i, len(primes), i):
primes[j] = 0
T = ... | ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR... |
<image>
To monitor cryptocurrency exchange rates trader William invented a wonderful device consisting of n lights arranged in a row. The device functions in the following way:
Initially, all lights on William's device are turned off. At the beginning of a new iteration the device randomly, with a uniform distributio... | import sys
input = sys.stdin.readline
MOD = int(1000000000.0 + 7)
G = [0] * int(100000.0 + 2)
GI = [0] * int(100000.0 + 2)
G[0] = 1
for i in range(1, len(G)):
G[i] = G[i - 1] * i % MOD
GI[-1] = pow(G[-1], MOD - 2, MOD)
for i in range(len(GI) - 2, -1, -1):
GI[i] = GI[i + 1] * (i + 1) % MOD
def A(n, V):
if... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER... |
<image>
To monitor cryptocurrency exchange rates trader William invented a wonderful device consisting of n lights arranged in a row. The device functions in the following way:
Initially, all lights on William's device are turned off. At the beginning of a new iteration the device randomly, with a uniform distributio... | import sys
input = sys.stdin.buffer.readline
mod = 10**9 + 7
n = 10**5
fac = [0] * (n + 1)
inv_fac = [0] * (n + 1)
fac[0] = 1
for i in range(1, n + 1):
fac[i] = fac[i - 1] * i % mod
inv_fac[n] = pow(fac[n], mod - 2, mod)
for i in range(n - 1, -1, -1):
inv_fac[i] = inv_fac[i + 1] * (i + 1) % mod
def choose(n,... | IMPORT ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER V... |
<image>
To monitor cryptocurrency exchange rates trader William invented a wonderful device consisting of n lights arranged in a row. The device functions in the following way:
Initially, all lights on William's device are turned off. At the beginning of a new iteration the device randomly, with a uniform distributio... | import sys
from sys import stdin
def modfac(n, MOD):
f = 1
factorials = [1]
for m in range(1, n + 1):
f *= m
f %= MOD
factorials.append(f)
inv = pow(f, MOD - 2, MOD)
invs = [1] * (n + 1)
invs[n] = inv
for m in range(n, 1, -1):
inv *= m
inv %= MOD
... | IMPORT FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER VAR VAR VAR VAR ASS... |
<image>
To monitor cryptocurrency exchange rates trader William invented a wonderful device consisting of n lights arranged in a row. The device functions in the following way:
Initially, all lights on William's device are turned off. At the beginning of a new iteration the device randomly, with a uniform distributio... | import sys
input = sys.stdin.readline
max_n = 2 * 10**5
fact, inv_fact = [0] * (max_n + 1), [0] * (max_n + 1)
fact[0] = 1
mod = 10**9 + 7
def make_nCr_mod():
global fact
global inv_fact
for i in range(max_n):
fact[i + 1] = fact[i] * (i + 1) % mod
inv_fact[-1] = pow(fact[-1], mod - 2, mod)
... | IMPORT ASSIGN VAR VAR ASSIGN VAR BIN_OP NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR BIN_OP... |
<image>
To monitor cryptocurrency exchange rates trader William invented a wonderful device consisting of n lights arranged in a row. The device functions in the following way:
Initially, all lights on William's device are turned off. At the beginning of a new iteration the device randomly, with a uniform distributio... | import sys
input = sys.stdin.readline
mod = 10**9 + 7
N = 10**5
F, iF = [0] * (N + 1), [0] * (N + 1)
F[0] = 1
for i in range(1, N + 1):
F[i] = F[i - 1] * i % mod
iF[-1] = pow(F[-1], mod - 2, mod)
for i in range(N - 1, -1, -1):
iF[i] = iF[i + 1] * (i + 1) % mod
def cal(n, k):
if k < 0 or k > n:
re... | IMPORT ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | mod = int(1000000000.0 + 7)
n, k, d = map(int, input().split())
dp = [[(-1) for _ in " " * 2] for _ in range(101)]
def ktree(sum, ch):
if sum > n:
return 0
if sum == n:
if ch:
return 1
else:
return 0
if dp[sum][ch] != -1:
return dp[sum][ch]
ans =... | ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR BIN_OP STRING NUMBER VAR FUNC_CALL VAR NUMBER FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR VAR IF VAR RETURN NUMBER RETURN NUMBER IF VAR VAR VAR NUMBER RETURN VAR VAR VAR ASSIGN VAR NUMBER FOR VA... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | from sys import stdin
def calculate_main(n, k, mod):
dp = [0] * (n + 1)
dp[0] = 1
dp[1] = 1
for i in range(2, n + 1):
for j in range(i - 1, max(-1, i - k - 1), -1):
dp[i] += dp[j]
dp[i] %= mod
return dp
n, k, d = list(map(int, stdin.readline().split()))
mod = 10**... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR VAR VAR VAR VAR VAR VAR RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL V... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.