description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
The Little Elephant loves sortings.
He has an array a consisting of n integers. Let's number the array elements from 1 to n, then the i-th element will be denoted as ai. The Little Elephant can make one move to choose an arbitrary pair of integers l and r (1 ≤ l ≤ r ≤ n) and increase ai by 1 for all i such that l ≤ i ... | n = input()
(*a,) = map(int, input().split())
print(sum(a[i] - a[i + 1] for i in range(len(a) - 1) if a[i] > a[i + 1])) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER |
The Little Elephant loves sortings.
He has an array a consisting of n integers. Let's number the array elements from 1 to n, then the i-th element will be denoted as ai. The Little Elephant can make one move to choose an arbitrary pair of integers l and r (1 ≤ l ≤ r ≤ n) and increase ai by 1 for all i such that l ≤ i ... | n = int(input())
arr = list(map(int, input().split()))
s = 0
a = arr[0]
for i in range(1, n):
b = arr[i]
if a > b:
s += a - b
a = b
print(s) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR IF VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
The Little Elephant loves sortings.
He has an array a consisting of n integers. Let's number the array elements from 1 to n, then the i-th element will be denoted as ai. The Little Elephant can make one move to choose an arbitrary pair of integers l and r (1 ≤ l ≤ r ≤ n) and increase ai by 1 for all i such that l ≤ i ... | n = int(input())
nums = [int(x) for x in input().split()]
moves = 0
startRange = nums[0]
prev = nums[0]
for idx, num in enumerate(nums):
if num <= prev:
prev = num
elif prev < startRange:
moves += min(startRange, num) - prev
prev = min(startRange, num)
if num > startRange:
st... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR IF VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR VAR ASSIGN VAR VAR... |
The Little Elephant loves sortings.
He has an array a consisting of n integers. Let's number the array elements from 1 to n, then the i-th element will be denoted as ai. The Little Elephant can make one move to choose an arbitrary pair of integers l and r (1 ≤ l ≤ r ≤ n) and increase ai by 1 for all i such that l ≤ i ... | def mi():
return map(int, input().split())
n = int(input())
a = list(mi())
print(sum([max(0, a[i - 1] - a[i]) for i in range(1, n)])) | FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR FUNC_CALL VAR NUMBER VAR |
The Little Elephant loves sortings.
He has an array a consisting of n integers. Let's number the array elements from 1 to n, then the i-th element will be denoted as ai. The Little Elephant can make one move to choose an arbitrary pair of integers l and r (1 ≤ l ≤ r ≤ n) and increase ai by 1 for all i such that l ≤ i ... | def solve(arr, n):
inc = 0
ans = 0
for i in range(1, n):
arr[i] += inc
if arr[i] >= arr[i - 1]:
continue
diff = arr[i - 1] - arr[i]
ans += diff
inc += diff
arr[i] += diff
return ans
def read():
n = int(input())
arr = list(map(int, inp... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR VAR VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL... |
The Little Elephant loves sortings.
He has an array a consisting of n integers. Let's number the array elements from 1 to n, then the i-th element will be denoted as ai. The Little Elephant can make one move to choose an arbitrary pair of integers l and r (1 ≤ l ≤ r ≤ n) and increase ai by 1 for all i such that l ≤ i ... | n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(len(l) - 1):
if l[i] > l[i + 1]:
ans += l[i] - l[i + 1]
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR |
The Little Elephant loves sortings.
He has an array a consisting of n integers. Let's number the array elements from 1 to n, then the i-th element will be denoted as ai. The Little Elephant can make one move to choose an arbitrary pair of integers l and r (1 ≤ l ≤ r ≤ n) and increase ai by 1 for all i such that l ≤ i ... | n = int(input())
arr = list(map(int, input().strip().split()))
a = 0
ans = 0
for i in arr:
if i < a:
ans = ans + a - i
a = i
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
The Little Elephant loves sortings.
He has an array a consisting of n integers. Let's number the array elements from 1 to n, then the i-th element will be denoted as ai. The Little Elephant can make one move to choose an arbitrary pair of integers l and r (1 ≤ l ≤ r ≤ n) and increase ai by 1 for all i such that l ≤ i ... | def readln():
return tuple(map(int, input().split()))
(n,) = readln()
a = list(readln())
a.append(1 << 30)
st = []
ans = 0
for v in a:
if st == [] or st[-1] > v:
st.append(v)
elif st[-1] < v:
while len(st) > 1 and st[-1] < v:
ans += min(v, st[-2]) - st[-1]
st.pop()
... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR IF VAR LIST VAR NUMBER VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER VAR WHILE FUNC_CALL VAR VAR NUMBER... |
The Little Elephant loves sortings.
He has an array a consisting of n integers. Let's number the array elements from 1 to n, then the i-th element will be denoted as ai. The Little Elephant can make one move to choose an arbitrary pair of integers l and r (1 ≤ l ≤ r ≤ n) and increase ai by 1 for all i such that l ≤ i ... | import sys
ml, mi = [], []
def recurseml(l):
if len(l) == 0:
return
if len(l) == 1:
ml.append(l[0])
mi.append(0)
return
mx = max(l)
mxi = len(l) - 1 - l[::-1].index(mx)
ml.append(mx)
mi.append(mxi)
recurseml(l[:mxi])
n = int(input())
a = [int(i) for i in ... | IMPORT ASSIGN VAR VAR LIST LIST FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXP... |
The Little Elephant loves sortings.
He has an array a consisting of n integers. Let's number the array elements from 1 to n, then the i-th element will be denoted as ai. The Little Elephant can make one move to choose an arbitrary pair of integers l and r (1 ≤ l ≤ r ≤ n) and increase ai by 1 for all i such that l ≤ i ... | n, t = int(input()), list(map(int, input().split()))
print(sum(t[i - 1] - t[i] for i in range(1, n) if t[i] < t[i - 1])) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER |
The Little Elephant loves sortings.
He has an array a consisting of n integers. Let's number the array elements from 1 to n, then the i-th element will be denoted as ai. The Little Elephant can make one move to choose an arbitrary pair of integers l and r (1 ≤ l ≤ r ≤ n) and increase ai by 1 for all i such that l ≤ i ... | n = int(input())
a = list(map(int, input().split()))
prev_max = a[0]
add, ans = 0, 0
for i in range(1, n):
a[i] += add
if a[i] < prev_max:
add += prev_max - a[i]
ans += prev_max - a[i]
prev_max = max(prev_max, a[i])
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR IF VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR V... |
The Little Elephant loves sortings.
He has an array a consisting of n integers. Let's number the array elements from 1 to n, then the i-th element will be denoted as ai. The Little Elephant can make one move to choose an arbitrary pair of integers l and r (1 ≤ l ≤ r ≤ n) and increase ai by 1 for all i such that l ≤ i ... | n = int(input())
a = list(map(int, input().rstrip().split()))
carry = 0
oper = 0
for i in range(1, n):
a[i] = a[i] + carry
if a[i] < a[i - 1]:
carry += abs(a[i - 1] - a[i])
oper += abs(a[i - 1] - a[i])
a[i] = a[i - 1]
print(oper) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR FUNC_CALL... |
The Little Elephant loves sortings.
He has an array a consisting of n integers. Let's number the array elements from 1 to n, then the i-th element will be denoted as ai. The Little Elephant can make one move to choose an arbitrary pair of integers l and r (1 ≤ l ≤ r ≤ n) and increase ai by 1 for all i such that l ≤ i ... | n = int(input())
lst = list(map(int, input().split(" ")))
print(str(sum(max(0, lst[i - 1] - lst[i]) for i in range(1, n)))) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR FUNC_CALL VAR NUMBER VAR |
The Little Elephant loves sortings.
He has an array a consisting of n integers. Let's number the array elements from 1 to n, then the i-th element will be denoted as ai. The Little Elephant can make one move to choose an arbitrary pair of integers l and r (1 ≤ l ≤ r ≤ n) and increase ai by 1 for all i such that l ≤ i ... | n = int(input())
p = [int(x) for x in input().split()]
if n == 1:
print(0)
else:
q = [0] * (n - 1)
for i in range(0, n - 1):
q[i] = p[i + 1] - p[i]
s = 0
for i in range(0, n - 1):
if q[i] < 0:
s += -q[i]
print(s) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER 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 VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL V... |
The Little Elephant loves sortings.
He has an array a consisting of n integers. Let's number the array elements from 1 to n, then the i-th element will be denoted as ai. The Little Elephant can make one move to choose an arbitrary pair of integers l and r (1 ≤ l ≤ r ≤ n) and increase ai by 1 for all i such that l ≤ i ... | def main(arr):
max_val = -float("inf")
ans = 0
temp_ans = 0
inc = 0
for i in range(len(arr)):
arr[i] += inc
if arr[i] >= max_val:
max_val = arr[i]
else:
ans += max_val - arr[i]
inc += max_val - arr[i]
ans += temp_ans
return ans
n ... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL ... |
The Little Elephant loves sortings.
He has an array a consisting of n integers. Let's number the array elements from 1 to n, then the i-th element will be denoted as ai. The Little Elephant can make one move to choose an arbitrary pair of integers l and r (1 ≤ l ≤ r ≤ n) and increase ai by 1 for all i such that l ≤ i ... | a = input()
i = int(a) - 1
l1 = list(map(int, input().split()))
ans = 0
while i > 0:
if l1[i] >= l1[i - 1]:
i -= 1
continue
ans += l1[i - 1] - l1[i]
i -= 1
print(ans) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
The Little Elephant loves sortings.
He has an array a consisting of n integers. Let's number the array elements from 1 to n, then the i-th element will be denoted as ai. The Little Elephant can make one move to choose an arbitrary pair of integers l and r (1 ≤ l ≤ r ≤ n) and increase ai by 1 for all i such that l ≤ i ... | from sys import stdin, stdout
nmbr = lambda: int(stdin.readline())
lst = lambda: list(map(int, input().split()))
for i in range(1):
n = nmbr()
a = lst()
ans = 0
for i in range(n - 1, 0, -1):
if a[i] < a[i - 1]:
ans += a[i - 1] - a[i]
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR BIN_OP VAR NUMB... |
The Little Elephant loves sortings.
He has an array a consisting of n integers. Let's number the array elements from 1 to n, then the i-th element will be denoted as ai. The Little Elephant can make one move to choose an arbitrary pair of integers l and r (1 ≤ l ≤ r ≤ n) and increase ai by 1 for all i such that l ≤ i ... | n = int(input())
l = list(map(int, input().split()))
l.append(max(l))
m, ans = l[0], 0
for i in range(1, n):
if l[i - 1] > l[i]:
ans += l[i - 1] - l[i]
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR |
The Little Elephant loves sortings.
He has an array a consisting of n integers. Let's number the array elements from 1 to n, then the i-th element will be denoted as ai. The Little Elephant can make one move to choose an arbitrary pair of integers l and r (1 ≤ l ≤ r ≤ n) and increase ai by 1 for all i such that l ≤ i ... | from sys import stdin, stdout
def ai():
return list(map(int, input().split()))
def ei():
return map(int, input().split())
def ip():
return int(stdin.readline())
def op(ans):
return stdout.write(str(ans) + "\n")
n = ip()
li = ai()
count = 0
for i in range(n - 1):
if li[i] > li[i + 1]:
... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CAL... |
The Little Elephant loves sortings.
He has an array a consisting of n integers. Let's number the array elements from 1 to n, then the i-th element will be denoted as ai. The Little Elephant can make one move to choose an arbitrary pair of integers l and r (1 ≤ l ≤ r ≤ n) and increase ai by 1 for all i such that l ≤ i ... | def main():
n = int(input())
a = [int(i) for i in input().split()]
ans = 0
for i in range(n - 1):
d = a[i] - a[i + 1]
if d > 0:
ans += d
print(ans)
main() | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR |
The Little Elephant loves sortings.
He has an array a consisting of n integers. Let's number the array elements from 1 to n, then the i-th element will be denoted as ai. The Little Elephant can make one move to choose an arbitrary pair of integers l and r (1 ≤ l ≤ r ≤ n) and increase ai by 1 for all i such that l ≤ i ... | n = int(input())
a = list(map(int, input().split()))
res = [max(0, a[i - 1] - a[i]) for i in range(1, n)]
print(sum(res)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
The Little Elephant loves sortings.
He has an array a consisting of n integers. Let's number the array elements from 1 to n, then the i-th element will be denoted as ai. The Little Elephant can make one move to choose an arbitrary pair of integers l and r (1 ≤ l ≤ r ≤ n) and increase ai by 1 for all i such that l ≤ i ... | from sys import stdin
n = int(stdin.readline())
a = list(map(int, stdin.readline().split()))
b = list()
for i in range(1, n):
b.append(a[i] - a[i - 1])
print(sum([(-ele) for ele in b if ele < 0])) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER |
The Little Elephant loves sortings.
He has an array a consisting of n integers. Let's number the array elements from 1 to n, then the i-th element will be denoted as ai. The Little Elephant can make one move to choose an arbitrary pair of integers l and r (1 ≤ l ≤ r ≤ n) and increase ai by 1 for all i such that l ≤ i ... | import sys
def get_ints():
return list(map(int, sys.stdin.readline().strip().split()))
n = int(input())
arr = get_ints()
minimumheight = arr[0]
prevheight = arr[0]
ans = 0
for i in range(1, n):
curnum = arr[i]
if curnum >= minimumheight:
prevheight = curnum
minimumheight = curnum
... | IMPORT FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR IF VAR VAR V... |
The Little Elephant loves sortings.
He has an array a consisting of n integers. Let's number the array elements from 1 to n, then the i-th element will be denoted as ai. The Little Elephant can make one move to choose an arbitrary pair of integers l and r (1 ≤ l ≤ r ≤ n) and increase ai by 1 for all i such that l ≤ i ... | n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(1, n):
b.append(max(0, a[i - 1] - a[i]))
print(sum(b)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
Marcin is a coach in his university. There are n students who want to attend a training camp. Marcin is a smart coach, so he wants to send only the students that can work calmly with each other.
Let's focus on the students. They are indexed with integers from 1 to n. Each of them can be described with two integers a_i... | def is_subset(a, b):
return ~a & b == 0
n = int(input())
a = map(int, input().split())
b = map(int, input().split())
vis = [False] * (n + 1)
st = list(zip(a, b))
st.sort()
st.reverse()
st.append((-1, -1))
ans = 0
for i in range(n):
if st[i][0] != st[i + 1][0]:
continue
for j in range(i, n):
... | FUNC_DEF RETURN BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN 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 BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR... |
Marcin is a coach in his university. There are n students who want to attend a training camp. Marcin is a smart coach, so he wants to send only the students that can work calmly with each other.
Let's focus on the students. They are indexed with integers from 1 to n. Each of them can be described with two integers a_i... | n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
aSet = set()
duplicates = set()
for ai in a:
if ai in aSet:
duplicates.add(ai)
aSet.add(ai)
total = 0
for i, ai in enumerate(a):
if ai in duplicates:
total += b[i]
continue
for d in dupli... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN 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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ... |
Marcin is a coach in his university. There are n students who want to attend a training camp. Marcin is a smart coach, so he wants to send only the students that can work calmly with each other.
Let's focus on the students. They are indexed with integers from 1 to n. Each of them can be described with two integers a_i... | n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
vis = [(0) for i in range(len(a))]
c = []
d = {}
for i in range(len(a)):
if a[i] in d:
d[a[i]].append(i)
else:
d[a[i]] = [i]
ans = 0
for i in d.keys():
if len(d[i]) >= 2:
for j in d[i]:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN 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 NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR F... |
Marcin is a coach in his university. There are n students who want to attend a training camp. Marcin is a smart coach, so he wants to send only the students that can work calmly with each other.
Let's focus on the students. They are indexed with integers from 1 to n. Each of them can be described with two integers a_i... | n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
vis = [False] * n
s = sorted(zip(a, b))
c = 1
L1 = []
L2 = []
ans = 0
h = s[0][1]
for i in range(1, len(s)):
if s[i][0] != s[i - 1][0]:
if c > 1:
L1.append(s[i - 1][0])
ans += h
else:... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN 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 LIST NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR VAR NUM... |
Marcin is a coach in his university. There are n students who want to attend a training camp. Marcin is a smart coach, so he wants to send only the students that can work calmly with each other.
Let's focus on the students. They are indexed with integers from 1 to n. Each of them can be described with two integers a_i... | n = int(input())
b = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
rev = {}
dic = {}
for i in range(n):
bb = b[i]
if bb in dic:
dic[bb].append(i)
else:
dic[bb] = [i]
neg1 = (1 << 60) - 1
ans = 0
mask = 0
dels = []
for bb in dic:
inds = dic[bb]
if len(inds) >... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN 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 DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR LIST VAR ASSIGN VAR BIN_OP BIN_OP NUM... |
Marcin is a coach in his university. There are n students who want to attend a training camp. Marcin is a smart coach, so he wants to send only the students that can work calmly with each other.
Let's focus on the students. They are indexed with integers from 1 to n. Each of them can be described with two integers a_i... | n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
dict = {}
for i in a:
if i in dict:
dict[i] += 1
else:
dict[i] = 1
res = 0
group = []
for i in dict:
if dict[i] > 1:
group.append(i)
for i in range(n):
for k in group:
if a[i] | k == ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN 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 NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR VAR NUMBER EXPR FU... |
Marcin is a coach in his university. There are n students who want to attend a training camp. Marcin is a smart coach, so he wants to send only the students that can work calmly with each other.
Let's focus on the students. They are indexed with integers from 1 to n. Each of them can be described with two integers a_i... | n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
s = list(zip(a, b))
s.sort(reverse=True)
i = 0
ans = 0
vz = []
while i < n:
j = i + 1
while j < n and s[j][0] == s[i][0]:
j += 1
if j - i > 1:
vz.extend(s[i:j])
else:
for e in vz:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN 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 FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR VAR ASSIGN V... |
Marcin is a coach in his university. There are n students who want to attend a training camp. Marcin is a smart coach, so he wants to send only the students that can work calmly with each other.
Let's focus on the students. They are indexed with integers from 1 to n. Each of them can be described with two integers a_i... | n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
B = [(b, a) for a, b in zip(A, B)]
C = {}
for a in A:
if a not in C:
C[a] = 0
C[a] += 1
inc = set()
for c in C:
if C[c] > 1:
inc.add(c)
ans = 0
for b, a in B:
if a in inc:
ans += b
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN 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 VAR VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR DICT FOR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR FUNC_CALL V... |
Marcin is a coach in his university. There are n students who want to attend a training camp. Marcin is a smart coach, so he wants to send only the students that can work calmly with each other.
Let's focus on the students. They are indexed with integers from 1 to n. Each of them can be described with two integers a_i... | n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
freq = {}
for i in a:
freq[i] = [0, 0]
for i in range(len(a)):
freq[a[i]][0] += 1
freq[a[i]][1] += b[i]
ans = 0
gr = {}
for i in freq:
if freq[i][0] > 1:
gr[i] = freq[i]
ans += freq[i][1]
for i in fr... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN 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 ASSIGN VAR VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER NUMBER VAR VAR VAR NUMBER ... |
Marcin is a coach in his university. There are n students who want to attend a training camp. Marcin is a smart coach, so he wants to send only the students that can work calmly with each other.
Let's focus on the students. They are indexed with integers from 1 to n. Each of them can be described with two integers a_i... | from sys import *
n = int(stdin.readline())
a = list(map(int, stdin.readline().split()))
b = list(map(int, stdin.readline().split()))
gp = []
ans = []
for i in range(n):
if a.count(a[i]) > 1:
if a[i] not in gp:
gp.append(a[i])
ans.append(b[i])
if len(gp) == 0:
stdout.write("0")
else... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN 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 FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL ... |
Marcin is a coach in his university. There are n students who want to attend a training camp. Marcin is a smart coach, so he wants to send only the students that can work calmly with each other.
Let's focus on the students. They are indexed with integers from 1 to n. Each of them can be described with two integers a_i... | n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
v = []
for i in range(n):
v.append([a[i], b[i]])
v.sort()
prev = -1
big = []
flag = True
for i in v:
if prev == i[0] and (flag or big[-1] != i[0]):
big.append(i[0])
flag = False
prev = i[0]
answer = 0
co... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN 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 FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR N... |
Marcin is a coach in his university. There are n students who want to attend a training camp. Marcin is a smart coach, so he wants to send only the students that can work calmly with each other.
Let's focus on the students. They are indexed with integers from 1 to n. Each of them can be described with two integers a_i... | ii = lambda: int(input())
kk = lambda: map(int, input().split())
ll = lambda: list(kk())
n = ii()
vals = zip(kk(), kk())
d = {}
for v in vals:
if v[0] not in d:
d[v[0]] = []
d[v[0]].append(v[1])
d2 = {k: sum(d[k]) for k in d}
maxs = 0
if 0 not in d:
d[0], d2[0] = [0], 0
ls = sorted(d.keys(), reverse... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR IF VAR NUMBER VAR ASSIGN VAR VAR NUMBER LIST EXPR FUNC_CALL VAR VAR NUMBER VAR NUMB... |
Marcin is a coach in his university. There are n students who want to attend a training camp. Marcin is a smart coach, so he wants to send only the students that can work calmly with each other.
Let's focus on the students. They are indexed with integers from 1 to n. Each of them can be described with two integers a_i... | def bit(used, b):
count = 0
for num in used:
for i in range(60):
if 1 << i & num == 0 and 1 << i & b:
count += 1
break
if count == len(used):
return True
else:
return False
def f(a, b):
arr = list(zip(a, b))
d = {}
for i i... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP NUMBER VAR VAR NUMBER BIN_OP BIN_OP NUMBER VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR VAR NUMBER BIN_OP FUNC_CA... |
Marcin is a coach in his university. There are n students who want to attend a training camp. Marcin is a smart coach, so he wants to send only the students that can work calmly with each other.
Let's focus on the students. They are indexed with integers from 1 to n. Each of them can be described with two integers a_i... | t = int(input())
algo = [int(i) for i in input().split()]
strength = [int(i) for i in input().split()]
dict1 = {}
dict2 = {}
binary = {}
max_strength = 0
for i in range(len(algo)):
if algo[i] in dict1:
binary[algo[i]] = bin(algo[i])[2:]
dict1[algo[i]] += 1
if dict1[algo[i]] == 2:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN 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 DICT ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBE... |
Marcin is a coach in his university. There are n students who want to attend a training camp. Marcin is a smart coach, so he wants to send only the students that can work calmly with each other.
Let's focus on the students. They are indexed with integers from 1 to n. Each of them can be described with two integers a_i... | n = int(input())
info = {}
state = []
str = input()
list1 = str.split(" ")
for i in range(n):
aa = int(list1[i])
state.append(aa)
if info.get(aa) == None:
info[aa] = {(1): 0, (2): False}
else:
info[aa] = {(1): 0, (2): True}
str = input()
list1 = []
list1 = str.split(" ")
for i in range(n... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NONE ASSIGN VAR VAR DICT NUMBER NUMBER NUMBER NUMBER ASSIGN VAR VAR DICT NUMBER NUMBER NU... |
Marcin is a coach in his university. There are n students who want to attend a training camp. Marcin is a smart coach, so he wants to send only the students that can work calmly with each other.
Let's focus on the students. They are indexed with integers from 1 to n. Each of them can be described with two integers a_i... | def less_exp(a1, a2):
return a1 < a2 and a2 - a1 == a1 ^ a2
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
g = []
for i in range(len(a)):
g.append((a[i], b[i]))
g.sort(key=lambda x: x[0])
selected_nodes = set()
sum1 = 0
for i in range(len(a)):
if i < len(a) - 1 an... | FUNC_DEF RETURN VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR EX... |
Marcin is a coach in his university. There are n students who want to attend a training camp. Marcin is a smart coach, so he wants to send only the students that can work calmly with each other.
Let's focus on the students. They are indexed with integers from 1 to n. Each of them can be described with two integers a_i... | n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
for i in range(n):
c.append((a[i], b[i]))
c.sort(reverse=True)
ins = []
cnt = 1
now = c[0][0]
tot = c[0][1]
i = 1
ans = 0
while 1:
while i < n and c[i][0] == now:
tot += c[i][1]
i += 1
cnt += ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN 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 FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR... |
Marcin is a coach in his university. There are n students who want to attend a training camp. Marcin is a smart coach, so he wants to send only the students that can work calmly with each other.
Let's focus on the students. They are indexed with integers from 1 to n. Each of them can be described with two integers a_i... | import sys
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
if n == 1:
print(0)
sys.exit(0)
X = []
for i in range(n):
X.append((A[i], B[i]))
X.sort()
Y = []
S = set()
ans = 0
for i in range(n):
if i < n - 1 and X[i][0] == X[i + 1][0] or i > 0 and X[i][0] == X[i -... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN 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 EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR V... |
The Hat is a game of speedy explanation/guessing words (similar to Alias). It's fun. Try it! In this problem, we are talking about a variant of the game when the players are sitting at the table and everyone plays individually (i.e. not teams, but individual gamers play).
$n$ people gathered in a room with $m$ tables ... | t = int(input())
for _ in range(t):
n, m, k = map(int, input().split())
groups = []
arr = [(i + 1) for i in range(n)]
z = 0
if n % m != 0:
larger = n // m + 1
while n % m != 0:
groups.append(larger)
n -= larger
m -= 1
z += larger
a ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER WHILE BIN_OP VAR VAR NUMBER EXPR FUNC_CALL V... |
The Hat is a game of speedy explanation/guessing words (similar to Alias). It's fun. Try it! In this problem, we are talking about a variant of the game when the players are sitting at the table and everyone plays individually (i.e. not teams, but individual gamers play).
$n$ people gathered in a room with $m$ tables ... | for _ in range(int(input())):
n, m, k = map(int, input().split())
st = 1
for i in range(k):
tt, rem, nxt = n // m, n % m, st
for j in range(m):
print(str(tt + 1 if rem else tt) + " ")
for k in range(tt):
print(str(st) + " ")
st += 1
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR STRING FOR VAR FUNC_... |
The Hat is a game of speedy explanation/guessing words (similar to Alias). It's fun. Try it! In this problem, we are talking about a variant of the game when the players are sitting at the table and everyone plays individually (i.e. not teams, but individual gamers play).
$n$ people gathered in a room with $m$ tables ... | t = int(input())
for case in range(t):
n, m, k = tuple(map(int, input().split()))
p = n // m
q = p + 1
r = n % m
nouveau_indice = 1
for i in range(k):
indice = nouveau_indice
for j in range(m):
if j < r:
s = str(q)
for u in range(q):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR ASS... |
The Hat is a game of speedy explanation/guessing words (similar to Alias). It's fun. Try it! In this problem, we are talking about a variant of the game when the players are sitting at the table and everyone plays individually (i.e. not teams, but individual gamers play).
$n$ people gathered in a room with $m$ tables ... | import sys
input = sys.stdin.readline
t = int(input())
ans = []
for _ in range(t):
n, m, k = map(int, input().split())
if n % m == 0:
c = n // m
ans0 = []
for _ in range(k):
for i in range(m):
ans0.append(
" ".join(map(str, [c] + [(j + i *... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING F... |
The Hat is a game of speedy explanation/guessing words (similar to Alias). It's fun. Try it! In this problem, we are talking about a variant of the game when the players are sitting at the table and everyone plays individually (i.e. not teams, but individual gamers play).
$n$ people gathered in a room with $m$ tables ... | import sys
I = lambda: [*map(int, sys.stdin.readline().split())]
(t,) = I()
for _ in range(t):
n, m, k = I()
players = [(i + 1) for i in range(n)]
big = n % m
sml = m - big
for i in range(k):
start = n * i // k
ind = start
for j in range(big):
out = [str(n // m +... | IMPORT ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIG... |
The Hat is a game of speedy explanation/guessing words (similar to Alias). It's fun. Try it! In this problem, we are talking about a variant of the game when the players are sitting at the table and everyone plays individually (i.e. not teams, but individual gamers play).
$n$ people gathered in a room with $m$ tables ... | import sys
def read_line():
return sys.stdin.readline().strip()
def print_table(nums):
print(f"{len(nums)} {' '.join([str(x) for x in nums])}")
t = int(read_line())
for _ in range(t):
n, m, k = tuple([int(x) for x in read_line().split()])
big_tables_starting_num = 0
big_tables_count = n % m
... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL VAR VAR STRING FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_... |
The Hat is a game of speedy explanation/guessing words (similar to Alias). It's fun. Try it! In this problem, we are talking about a variant of the game when the players are sitting at the table and everyone plays individually (i.e. not teams, but individual gamers play).
$n$ people gathered in a room with $m$ tables ... | import sys
def input():
return sys.stdin.readline().rstrip()
DXY = [(0, -1), (1, 0), (0, 1), (-1, 0)]
mod = 998244353
inf = 1 << 64
def slv():
n, m, k = map(int, input().split())
if n % m == 0:
for i in range(k):
persons = [(i + 1) for i in range(n)]
for _ in range(m):
... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER V... |
The Hat is a game of speedy explanation/guessing words (similar to Alias). It's fun. Try it! In this problem, we are talking about a variant of the game when the players are sitting at the table and everyone plays individually (i.e. not teams, but individual gamers play).
$n$ people gathered in a room with $m$ tables ... | t = int(input())
for test in range(t):
n, m, k = list(map(int, input().split()))
cnt = (n + m - 1) // m * (n % m)
now = 1
for i in range(k):
for j in range(n % m):
print((n + m - 1) // m, end=" ")
for x in range((n + m - 1) // m):
print(now, end=" ")
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP ... |
The Hat is a game of speedy explanation/guessing words (similar to Alias). It's fun. Try it! In this problem, we are talking about a variant of the game when the players are sitting at the table and everyone plays individually (i.e. not teams, but individual gamers play).
$n$ people gathered in a room with $m$ tables ... | t = int(input())
for test in range(t):
n, m, k = [int(x) for x in input().split()]
mx = n // m + 1
table = [[0] * mx in range(k)]
lastUnfair = 1
for p in range(k):
curply = lastUnfair
for table in range(m - (m - n % m)):
print(mx, end=" ")
plys = 0
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR LIST BIN_OP LIST NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR B... |
As you know, majority of students and teachers of Summer Informatics School live in Berland for the most part of the year. Since corruption there is quite widespread, the following story is not uncommon.
Elections are coming. You know the number of voters and the number of parties — $n$ and $m$ respectively. For each ... | import sys
input = sys.stdin.readline
n, m = map(int, input().split())
men = []
for i in range(n):
x, y = map(int, input().split())
men.append((y, x - 1))
def solve(lim):
cnt = [0] * m
vis = [0] * n
cost = 0
for i in range(n):
cnt[men[i][1]] += 1
for i in range(n):
if men[... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VA... |
As you know, majority of students and teachers of Summer Informatics School live in Berland for the most part of the year. Since corruption there is quite widespread, the following story is not uncommon.
Elections are coming. You know the number of voters and the number of parties — $n$ and $m$ respectively. For each ... | import sys
input = sys.stdin.readline
n, m = map(int, input().split())
party = [[] for _ in range(m + 5)]
pc = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x: x[1])
choose = [0] * n
for i in range(n):
party[pc[i][0]].append(i)
want = 10**18
for i in range(1, n + 1):
p1 = len(party[1])... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL ... |
As you know, majority of students and teachers of Summer Informatics School live in Berland for the most part of the year. Since corruption there is quite widespread, the following story is not uncommon.
Elections are coming. You know the number of voters and the number of parties — $n$ and $m$ respectively. For each ... | n, m = map(int, input().split())
parties = [[] for i in range(m)]
for i in range(n):
x, y = map(int, input().split())
parties[x - 1].append(y)
for i in range(m):
parties[i].sort(reverse=True)
mi = len(parties[0])
cost = float("inf")
for i in range(mi, n + 1):
temp = 0
to_chose = []
collected = m... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VA... |
As you know, majority of students and teachers of Summer Informatics School live in Berland for the most part of the year. Since corruption there is quite widespread, the following story is not uncommon.
Elections are coming. You know the number of voters and the number of parties — $n$ and $m$ respectively. For each ... | class Solver:
def solve(self):
self.num_voters, self.num_parties = (int(x) for x in input().split())
self.votes_per_party = [[] for _ in range(self.num_parties)]
for _ in range(self.num_voters):
party, price = (int(x) for x in input().split())
party -= 1
... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR... |
As you know, majority of students and teachers of Summer Informatics School live in Berland for the most part of the year. Since corruption there is quite widespread, the following story is not uncommon.
Elections are coming. You know the number of voters and the number of parties — $n$ and $m$ respectively. For each ... | def solve(max_v, votes, m):
ans = 0
values = []
our_v = len(votes[0])
for i in range(1, m):
L = len(votes[i])
if L > max_v:
take = L - max_v
our_v += take
ans += sum(votes[i][:take])
if take < L:
values.extend(votes[i][take:... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR IF VAR VAR A... |
As you know, majority of students and teachers of Summer Informatics School live in Berland for the most part of the year. Since corruption there is quite widespread, the following story is not uncommon.
Elections are coming. You know the number of voters and the number of parties — $n$ and $m$ respectively. For each ... | n, m = map(int, input().split())
parties = [(0) for _ in range(m)]
pairs = []
for i in range(n):
p, c = map(int, input().split())
parties[p - 1] += 1
pairs.append((c, p - 1))
pairs.sort()
min_sum = 10**31
for i in range(n, parties[0] - 1, -1):
cur_sum = 0
cur_amount = parties[0]
colours = [(0) f... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR... |
As you know, majority of students and teachers of Summer Informatics School live in Berland for the most part of the year. Since corruption there is quite widespread, the following story is not uncommon.
Elections are coming. You know the number of voters and the number of parties — $n$ and $m$ respectively. For each ... | from sys import stdin
n, m = map(int, stdin.readline().split())
pc = dict()
ph = dict()
prices = []
for i in range(n):
p, c = map(int, stdin.readline().split())
if p != 1:
prices.append(c)
pc.setdefault(p, []).append(len(prices) - 1)
ph[p] = ph.setdefault(p, 0) + 1
max_h = 0
for p, pa in pc... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL FUNC_CALL VAR VAR LIST BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN ... |
As you know, majority of students and teachers of Summer Informatics School live in Berland for the most part of the year. Since corruption there is quite widespread, the following story is not uncommon.
Elections are coming. You know the number of voters and the number of parties — $n$ and $m$ respectively. For each ... | n, m = map(int, input().split())
cn = []
un = 0
d = {}
for i in range(n):
p, c = map(int, input().split())
if p == 1:
un += 1
else:
cn.append((p, c))
cn.sort(key=lambda x: x[1])
for i in range(len(cn)):
p, c = cn[i]
if p not in d:
d[p] = [(c, i)]
else:
d[p].append... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN V... |
As you know, majority of students and teachers of Summer Informatics School live in Berland for the most part of the year. Since corruption there is quite widespread, the following story is not uncommon.
Elections are coming. You know the number of voters and the number of parties — $n$ and $m$ respectively. For each ... | n, m = map(int, input().split())
pc = [(0, 0) for _ in range(n)]
party_votes = [(0) for _ in range(m)]
for i in range(n):
p, c = map(int, input().split())
pc[i] = p - 1, c
party_votes[p - 1] += 1
pc.sort(key=lambda x: x[1])
min_cost = 10**20
for votes in range(n + 1):
_party_votes = party_votes[:]
d... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR NUMB... |
As you know, majority of students and teachers of Summer Informatics School live in Berland for the most part of the year. Since corruption there is quite widespread, the following story is not uncommon.
Elections are coming. You know the number of voters and the number of parties — $n$ and $m$ respectively. For each ... | def solve(N, M, A):
pv = [0] * M
pm = [[] for _ in range(M)]
allm = {}
for p, c in A:
p -= 1
pv[p] += 1
if p == 0:
continue
pm[p].append(c)
if c not in allm:
allm[c] = 0
allm[c] += 1
for m in pm:
m.sort()
allml = lis... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR VAR VAR VAR NUMBER VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER FOR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FU... |
As you know, majority of students and teachers of Summer Informatics School live in Berland for the most part of the year. Since corruption there is quite widespread, the following story is not uncommon.
Elections are coming. You know the number of voters and the number of parties — $n$ and $m$ respectively. For each ... | import sys
n, m = map(int, input().split())
V = [None] * n
for i in range(n):
V[i] = tuple(map(int, input().split()))
V.sort(key=lambda x: x[1])
if n == 1:
if V[0][0] == 1:
print(0)
else:
print(V[0][1])
sys.exit()
Voterlist = [[] for i in range(m + 1)]
Partylist = [(0) for i in range(m ... | IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NONE VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER IF VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER... |
You are given an array $a$ of $n$ integers. You are allowed to perform the following operation on it as many times as you want (0 or more times):
Choose $2$ indices $i$,$j$ where $1 \le i < j \le n$ and replace $a_k$ for all $i \leq k \leq j$ with $|a_i - a_j|$
Print the maximum sum of all the elements of the final a... | t = int(input())
for tes in range(t):
n = int(input())
a = list(map(int, input().split()))
if n == 2:
print(max(a[0] + a[1], abs(a[1] - a[0]) * 2))
elif n == 3:
print(
max(
a[0] + a[1] + a[2],
a[0] * 3,
a[2] * 3,
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER NUMBER IF VAR NUMBER EX... |
You are given an array $a$ of $n$ integers. You are allowed to perform the following operation on it as many times as you want (0 or more times):
Choose $2$ indices $i$,$j$ where $1 \le i < j \le n$ and replace $a_k$ for all $i \leq k \leq j$ with $|a_i - a_j|$
Print the maximum sum of all the elements of the final a... | def N():
return int(input())
def A():
return [int(x) for x in input().split()]
def S():
return input()
for _ in range(N()):
n = N()
if "codeforces" == 28226329:
print("Tanmay")
a = A()
maxi = max(a)
s1 = sum(a)
if n == 3:
print(
max(
... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF STRING NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR V... |
You are given an array $a$ of $n$ integers. You are allowed to perform the following operation on it as many times as you want (0 or more times):
Choose $2$ indices $i$,$j$ where $1 \le i < j \le n$ and replace $a_k$ for all $i \leq k \leq j$ with $|a_i - a_j|$
Print the maximum sum of all the elements of the final a... | a = int(input())
for _ in range(a):
b = int(input())
l = list(map(int, input().split()))
ans = sum(l)
if b == 2:
ans = max(ans, 2 * abs(l[0] - l[1]))
elif b == 3:
ll = [l[0], l[2], abs(l[0] - l[1]), abs(l[1] - l[2]), abs(l[0] - l[2])]
ans = max(ans, max(ll) * 3)
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN... |
You are given an array $a$ of $n$ integers. You are allowed to perform the following operation on it as many times as you want (0 or more times):
Choose $2$ indices $i$,$j$ where $1 \le i < j \le n$ and replace $a_k$ for all $i \leq k \leq j$ with $|a_i - a_j|$
Print the maximum sum of all the elements of the final a... | t = int(input())
for i in range(t):
n = int(input())
arr = [int(x) for x in input().split()]
mx = max(arr)
mi = min(arr)
s = 0
for i in range(n):
s = s + arr[i]
res = s
val = 0
if n == 2:
res = max(2 * (mx - mi), res)
elif n == 3:
q = arr[0] * 3
w ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR N... |
You are given an array $a$ of $n$ integers. You are allowed to perform the following operation on it as many times as you want (0 or more times):
Choose $2$ indices $i$,$j$ where $1 \le i < j \le n$ and replace $a_k$ for all $i \leq k \leq j$ with $|a_i - a_j|$
Print the maximum sum of all the elements of the final a... | for y in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
m = 0
ind = 0
for i in range(len(a)):
if a[i] > m:
m = a[i]
ind = i
if n == 2:
print(max(2 * abs(a[1] - a[0]), a[1] + a[0]))
elif n == 3:
s = sorted(a)
i... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_C... |
You are given an array $a$ of $n$ integers. You are allowed to perform the following operation on it as many times as you want (0 or more times):
Choose $2$ indices $i$,$j$ where $1 \le i < j \le n$ and replace $a_k$ for all $i \leq k \leq j$ with $|a_i - a_j|$
Print the maximum sum of all the elements of the final a... | def ii(num=False):
i = input().split()
if num:
return int(i[0])
try:
return list(map(int, i))
except Exception:
return i
def gcd(a, b):
if a == 0:
return b
return gcd(b % a, a)
for _ in range(ii(1)):
n, a = ii(1), ii()
if n == 2:
print(max(2 * ... | FUNC_DEF NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF VAR RETURN FUNC_CALL VAR VAR NUMBER RETURN FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR RETURN VAR FUNC_DEF IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR IF VA... |
You are given an array $a$ of $n$ integers. You are allowed to perform the following operation on it as many times as you want (0 or more times):
Choose $2$ indices $i$,$j$ where $1 \le i < j \le n$ and replace $a_k$ for all $i \leq k \leq j$ with $|a_i - a_j|$
Print the maximum sum of all the elements of the final a... | t = int(input())
for test in range(t):
n = int(input())
nums = list(map(int, input().split()))
if len(nums) > 3:
print(max(nums) * len(nums))
elif len(nums) == 2:
print(max(sum(nums), 2 * abs(nums[0] - nums[1])))
elif len(nums) == 3:
a = [sum(nums)]
a.append(
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VA... |
You are given an array $a$ of $n$ integers. You are allowed to perform the following operation on it as many times as you want (0 or more times):
Choose $2$ indices $i$,$j$ where $1 \le i < j \le n$ and replace $a_k$ for all $i \leq k \leq j$ with $|a_i - a_j|$
Print the maximum sum of all the elements of the final a... | t = int(input())
while t > 0:
n = int(input())
A = list(map(int, input().split()))
SUM = sum(A)
if n > 3:
print(max(A) * n)
elif n == 2:
print(max(sum(A), abs(A[0] - A[1]) * n))
elif n == 3:
SUM = max(SUM, A[2] + abs(A[0] - A[1]) * 2)
SUM = max(SUM, A[0] + abs(A[2... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR BI... |
You are given an array $a$ of $n$ integers. You are allowed to perform the following operation on it as many times as you want (0 or more times):
Choose $2$ indices $i$,$j$ where $1 \le i < j \le n$ and replace $a_k$ for all $i \leq k \leq j$ with $|a_i - a_j|$
Print the maximum sum of all the elements of the final a... | for i in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
if n == 2:
print(max(sum(a), 2 * abs(a[0] - a[1])))
elif n == 3:
if a[0] == a[1] == a[2]:
print(a[0] * 3)
elif a[0] == max(a) or a[-1] == max(a):
print(max(a) * 3)
e... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER IF VAR NUMBER VAR NUMBER VAR... |
You are given an array $a$ of $n$ integers. You are allowed to perform the following operation on it as many times as you want (0 or more times):
Choose $2$ indices $i$,$j$ where $1 \le i < j \le n$ and replace $a_k$ for all $i \leq k \leq j$ with $|a_i - a_j|$
Print the maximum sum of all the elements of the final a... | for _ in range(int(input())):
n = int(input())
a = [int(x) for x in input().split()]
if n > 3:
print(max(a) * n)
elif n == 2:
print(max((sum(a), abs(a[0] - a[1]) * 2)))
else:
print(
max(
(sum(a), a[0] * 3, a[2] * 3, abs(a[0] - a[1]) * 3, abs(a[1] -... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMB... |
You are given an array $a$ of $n$ integers. You are allowed to perform the following operation on it as many times as you want (0 or more times):
Choose $2$ indices $i$,$j$ where $1 \le i < j \le n$ and replace $a_k$ for all $i \leq k \leq j$ with $|a_i - a_j|$
Print the maximum sum of all the elements of the final a... | t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int, input().split()))
if n == 0:
print(0)
continue
if n == 1:
print(a[0])
continue
if n == 2:
print(max(a[0] + a[1], abs(a[0] - a[1]) * 2))
continue
if n == 3:
print(
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER ... |
You are given an array $a$ of $n$ integers. You are allowed to perform the following operation on it as many times as you want (0 or more times):
Choose $2$ indices $i$,$j$ where $1 \le i < j \le n$ and replace $a_k$ for all $i \leq k \leq j$ with $|a_i - a_j|$
Print the maximum sum of all the elements of the final a... | t = int(input())
for _ in range(t):
n = int(input())
arr = list(map(int, input().split()))
if n >= 4:
print(n * max(arr))
continue
if n == 2:
print(max(2 * abs(arr[0] - arr[1]), arr[0] + arr[1]))
continue
if n == 3:
a1, a2, a3 = tuple(arr)
print(max(a1... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP NUMBER FUNC_CALL VAR BIN_OP VAR N... |
You are given an array $a$ of $n$ integers. You are allowed to perform the following operation on it as many times as you want (0 or more times):
Choose $2$ indices $i$,$j$ where $1 \le i < j \le n$ and replace $a_k$ for all $i \leq k \leq j$ with $|a_i - a_j|$
Print the maximum sum of all the elements of the final a... | def solve(n, a):
if n == 1:
return a[0]
elif n == 2:
return max(a[0] + a[1], 2 * abs(a[1] - a[0]))
elif n == 3:
return max(
a[0] + a[1] + a[2],
a[0] * 3,
a[2] * 3,
3 * abs(a[0] - a[1]),
3 * abs(a[2] - a[1]),
)
el... | FUNC_DEF IF VAR NUMBER RETURN VAR NUMBER IF VAR NUMBER RETURN FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER BIN_OP NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER RETURN FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER BIN_OP NUMBER FUNC_CALL VA... |
You are given an array $a$ of $n$ integers. You are allowed to perform the following operation on it as many times as you want (0 or more times):
Choose $2$ indices $i$,$j$ where $1 \le i < j \le n$ and replace $a_k$ for all $i \leq k \leq j$ with $|a_i - a_j|$
Print the maximum sum of all the elements of the final a... | T = int(input())
while T:
T -= 1
n = int(input())
a = [int(i) for i in input().split()]
if n > 3:
print(n * max(a))
elif n == 2:
print(max(sum(a), n * abs(a[0] - a[1])))
elif n == 3:
print(
max(
sum(a),
n * a[0],
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR FUNC_CALL VAR BIN_OP VAR N... |
You are given an array $a$ of $n$ integers. You are allowed to perform the following operation on it as many times as you want (0 or more times):
Choose $2$ indices $i$,$j$ where $1 \le i < j \le n$ and replace $a_k$ for all $i \leq k \leq j$ with $|a_i - a_j|$
Print the maximum sum of all the elements of the final a... | for _ in range(int(input())):
n = int(input())
a = [int(x) for x in input().split()]
if n == 2:
print(max(sum(a), abs(a[0] - a[1]) * 2))
elif n == 3:
if a[0] >= a[1] and a[0] >= a[2]:
print(a[0] * n)
elif a[2] >= a[1] and a[2] >= a[0]:
print(a[2] * n)
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER NUMBER IF VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VA... |
You are given an array $a$ of $n$ integers. You are allowed to perform the following operation on it as many times as you want (0 or more times):
Choose $2$ indices $i$,$j$ where $1 \le i < j \le n$ and replace $a_k$ for all $i \leq k \leq j$ with $|a_i - a_j|$
Print the maximum sum of all the elements of the final a... | import sys
input = sys.stdin.readline
def readList():
return list(map(int, input().split()))
def readInt():
return int(input())
def readInts():
return map(int, input().split())
def readStr():
return input().strip()
def solve():
n = readInt()
arr = readList()
V = max(arr)
if n ... | IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ... |
You are given an array $a$ of $n$ integers. You are allowed to perform the following operation on it as many times as you want (0 or more times):
Choose $2$ indices $i$,$j$ where $1 \le i < j \le n$ and replace $a_k$ for all $i \leq k \leq j$ with $|a_i - a_j|$
Print the maximum sum of all the elements of the final a... | t = int(input())
for i in range(t):
n = int(input())
l = list(map(int, input().split()))
if n == 2:
print(max(sum(l), 2 * abs(l[0] - l[1])))
elif n == 3:
a = max(l)
if l[0] == a or l[2] == a:
print(n * max(l))
else:
print(
max(
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR FU... |
You are given an array $a$ of $n$ integers. You are allowed to perform the following operation on it as many times as you want (0 or more times):
Choose $2$ indices $i$,$j$ where $1 \le i < j \le n$ and replace $a_k$ for all $i \leq k \leq j$ with $|a_i - a_j|$
Print the maximum sum of all the elements of the final a... | for _ in range(int(input())):
n = int(input())
L = list(map(int, input().split()))
if n > 3:
print(n * max(L))
elif n == 1:
print(L[0])
elif n == 2:
a = sum(L)
diff = abs(L[0] - L[1])
b = 2 * diff
print(max(a, b))
else:
M = max(L)
i... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC... |
You are given an array $a$ of $n$ integers. You are allowed to perform the following operation on it as many times as you want (0 or more times):
Choose $2$ indices $i$,$j$ where $1 \le i < j \le n$ and replace $a_k$ for all $i \leq k \leq j$ with $|a_i - a_j|$
Print the maximum sum of all the elements of the final a... | for _ in range(int(input())):
n = int(input())
arr = list(map(int, input().split()))
ans = sum(arr)
for i in range(n):
if i == 0:
if n == 2:
ans = max(ans, 2 * abs(arr[0] - arr[1]))
else:
ans = max(ans, arr[i] * n)
elif i == n - 1:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER VAR NU... |
You are given an array $a$ of $n$ integers. You are allowed to perform the following operation on it as many times as you want (0 or more times):
Choose $2$ indices $i$,$j$ where $1 \le i < j \le n$ and replace $a_k$ for all $i \leq k \leq j$ with $|a_i - a_j|$
Print the maximum sum of all the elements of the final a... | for tt in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
m = max(a)
if n >= 4:
print(n * m)
elif n == 2:
print(max(a[0] + a[1], 2 * abs(a[0] - a[1])))
else:
print(max(3 * (a[1] - min(a)), sum(a), 3 * a[0], 3 * a[2])) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER BIN_OP NUMB... |
You are given an array $a$ of $n$ integers. You are allowed to perform the following operation on it as many times as you want (0 or more times):
Choose $2$ indices $i$,$j$ where $1 \le i < j \le n$ and replace $a_k$ for all $i \leq k \leq j$ with $|a_i - a_j|$
Print the maximum sum of all the elements of the final a... | for _ in range(int(input())):
n = int(input())
li = list(map(int, input().split()))
if n == 2:
print(max(sum(li), 2 * abs(li[0] - li[1])))
elif n == 3:
print(
max(
sum(li),
3 * li[0],
3 * li[2],
3 * abs(li[0] - l... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL... |
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached.
—Perfect Memento in Strict Sense
Marisa comes to pick mushrooms in the Enchanted Forest.
The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu... | def ans(arr, k):
n = len(arr)
if k > n:
s = sum(arr)
x = n * (n + 1) // 2
print(s - x + n * k)
else:
res = 0
for i in range(k):
res += arr[i]
curr_sum = res
for i in range(k, n):
curr_sum += arr[i] - arr[i - k]
res =... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP V... |
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached.
—Perfect Memento in Strict Sense
Marisa comes to pick mushrooms in the Enchanted Forest.
The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu... | def partial_sum(a, b):
return (b + a) * (b - a + 1) // 2
for _ in range(int(input())):
n, k = list(map(int, input().split()))
mushs = list(map(int, input().split()))
if k >= n:
print(partial_sum(k - n, k - 1) + sum(mushs))
continue
num = sum(mushs[:k])
M = num
for i in rang... | FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR ... |
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached.
—Perfect Memento in Strict Sense
Marisa comes to pick mushrooms in the Enchanted Forest.
The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu... | import sys
input = sys.stdin.readline
def solve():
n, k = map(int, input().split())
arr = list(map(int, input().split()))
if k <= n:
lps = ans = 0
for i in range(n):
lps += arr[i]
if i >= k:
lps -= arr[i - k]
ans = max(ans, lps)
... | IMPORT ASSIGN VAR VAR 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 IF VAR VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN BIN_OP VAR BIN_OP BI... |
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached.
—Perfect Memento in Strict Sense
Marisa comes to pick mushrooms in the Enchanted Forest.
The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu... | testes = int(input())
for t in range(testes):
n_forest, tempo = map(int, input().split())
mush_pos = [0] + list(map(int, input().split()))
for i in range(1, n_forest + 1):
mush_pos[i] += mush_pos[i - 1]
if tempo > n_forest:
print(mush_pos[n_forest] + (tempo - 1 + tempo - n_forest) * n_fo... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_O... |
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached.
—Perfect Memento in Strict Sense
Marisa comes to pick mushrooms in the Enchanted Forest.
The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu... | from sys import stdin
input = stdin.readline
def ii():
return int(input())
def li():
return list(map(int, input().split()))
def maxSubArraySum(a, size):
n = len(a)
s = 0
for i in range(size):
s += a[i]
ans = s
for i in range(size, n):
s += a[i] - a[i - size]
an... | ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR F... |
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached.
—Perfect Memento in Strict Sense
Marisa comes to pick mushrooms in the Enchanted Forest.
The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu... | t = int(input())
for _ in range(t):
a, b = input().split()
b = int(b)
s = list(map(int, input().split()))
if b < len(s):
tmp = sum(s[0:b])
mx = tmp
for i in range(len(s) - b):
tmp = tmp - s[i] + s[i + b]
mx = max(tmp, mx)
print(mx + b * (b - 1) // ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL V... |
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached.
—Perfect Memento in Strict Sense
Marisa comes to pick mushrooms in the Enchanted Forest.
The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu... | t = int(input())
for j in range(t):
n, k = list(map(int, input().split()))
mushrooms = list(map(int, input().split()))
sum = [0]
for i in range(1, n + 1):
sum.append(mushrooms[i - 1] + sum[i - 1])
if k > n:
print(sum[n] + k * n - n * (n + 1) // 2)
else:
max_subarray = 0
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL 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 VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER... |
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached.
—Perfect Memento in Strict Sense
Marisa comes to pick mushrooms in the Enchanted Forest.
The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu... | read = lambda: map(int, input().strip().split())
def f(a, k):
if k >= len(a):
rem = k - len(a)
base = rem + 1
ans = a[0] + rem
for i in a[1:]:
ans += i + base
base += 1
return ans
else:
s = sum(a[:k])
i = 0
j = k
a... | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR FOR VAR VAR NUMBER VAR BIN_OP VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR... |
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached.
—Perfect Memento in Strict Sense
Marisa comes to pick mushrooms in the Enchanted Forest.
The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu... | t = int(input())
for i in range(t):
n, k = map(int, input().split())
a = list(map(int, input().split()))
if k >= n:
ans = n * (n + 1) // 2
ans += (k - 1 - n) * n
ans += sum(a)
print(ans)
else:
pre = [0] + a.copy()
for i in range(1, n + 1):
pre[... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR VAR FUNC_CALL VAR VAR ... |
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached.
—Perfect Memento in Strict Sense
Marisa comes to pick mushrooms in the Enchanted Forest.
The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu... | def read_nums():
return [int(x) for x in input().split()]
def solve():
n, k = read_nums()
nums = read_nums()
if k >= n:
return sum(nums) + n * (2 * k - n - 1) // 2
cum_nums = get_cum_sum(nums)
largest_sum = 0
for i in range(n - k + 1):
largest_sum = max(largest_sum, cum_num... | FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR VAR RETURN BIN_OP FUNC_CALL VAR VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP V... |
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached.
—Perfect Memento in Strict Sense
Marisa comes to pick mushrooms in the Enchanted Forest.
The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu... | n = int(input())
mas = 0
for i in range(n):
mas = 0
s = 0
x, y = list(map(int, input().split()))
l = list(map(int, input().split()))
if y < x:
mas += sum(l[:y])
s = mas
for v in range(y, x):
s += l[v] - l[v - y]
mas = max(mas, s)
mas += y * (y ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR 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 IF VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FOR VAR FUN... |
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached.
—Perfect Memento in Strict Sense
Marisa comes to pick mushrooms in the Enchanted Forest.
The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu... | for h in range(int(input())):
n, k = map(int, input().split())
x = list(map(int, input().split()))
if k >= n:
a = sum(x)
b = k // n * n * n - n * (n + 1) // 2
k = k % n
c = n * k
print(a + b + c)
else:
for i in range(1, n):
x[i] += x[i - 1]
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN V... |
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached.
—Perfect Memento in Strict Sense
Marisa comes to pick mushrooms in the Enchanted Forest.
The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu... | for _ in range(int(input())):
n, k = map(int, input().split())
a = [*map(int, input().split())]
if k >= n:
print(sum(a) + n * k - n * (n + 1) // 2)
else:
window = (((k - 1) % n) ** 2 + (k - 1) % n) / 2
l, r, i, ans = 0, 0, 0, 0
while r < n:
window += a[r]
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN... |
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached.
—Perfect Memento in Strict Sense
Marisa comes to pick mushrooms in the Enchanted Forest.
The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu... | def solve():
n, k = map(int, input().split())
a = list(map(int, input().split()))
if n == 1:
out = a[0] + (k - 1)
elif k < n:
maxw = 0
s = 0
for i in range(n):
s += a[i]
if i >= k:
s -= a[i - k]
if i >= k - 1:
... | 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 IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR VAR VAR BIN_OP VAR VAR IF VAR ... |
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached.
—Perfect Memento in Strict Sense
Marisa comes to pick mushrooms in the Enchanted Forest.
The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu... | import sys
def solve():
inp = sys.stdin.readline
n, k = map(int, inp().split())
a = list(map(int, inp().split()))
m = min(n, k)
s = 0
for i in range(m):
s += a[i]
best = s
for i in range(m, n):
s += a[i]
s -= a[i - m]
best = max(best, s)
print(best +... | IMPORT FUNC_DEF ASSIGN 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 FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR BIN_OP VAR ... |
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached.
—Perfect Memento in Strict Sense
Marisa comes to pick mushrooms in the Enchanted Forest.
The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu... | def solve(a, b, c):
s = 0
u = 0
for i in range(a):
u += c[i]
if b <= i:
u -= c[i - b]
s = max(s, u)
return s + (b - 1) * b // 2
for i in range(int(input())):
a, b = map(int, input().split())
c = list(map(int, input().split()))
if a >= b:
print(so... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN BIN_OP VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR AS... |
The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached.
—Perfect Memento in Strict Sense
Marisa comes to pick mushrooms in the Enchanted Forest.
The Enchanted forest can be represented by $n$ points on the $X$-axis numbered $1$ throu... | t = int(input())
while t:
n, k = map(int, input().split())
l = list(map(int, input().split()))
if n == 1:
print(l[0] + k - 1)
elif k <= n:
ans = 0
su = 0
for i in range(k):
su += l[i]
ans = su
for i in range(k, n):
su += l[i] - l[i ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE 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 IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR V... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.