description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you?
You are given a set of digits, your task is to find the maximum integer that you can mak... | t = input()
A = input().split()
sum = 0
count = 0
found = False
A.sort()
for i in range(len(A)):
A[i] = int(A[i])
sum += A[i]
if A[0] != 0:
print(str(-1))
exit()
if sum % 3 == 0:
if sum != 0:
for i in reversed(A):
print(i, end="")
exit()
else:
print(0)
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF BIN_OP VAR NUMB... |
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you?
You are given a set of digits, your task is to find the maximum integer that you can mak... | from sys import stdin, stdout
nmbr = lambda: int(stdin.readline())
lst = lambda: list(map(int, input().split()))
for _ in range(1):
n = nmbr()
a = sorted(lst(), reverse=True)
sm = sum(a)
ans = []
if a[-1] != 0:
print(-1)
continue
r0 = []
r1 = []
r2 = []
for v in a:
... | 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 FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN... |
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you?
You are given a set of digits, your task is to find the maximum integer that you can mak... | n = int(input())
x = list(map(int, input().strip().split()))
x.sort(reverse=True)
y = x[::-1]
if 0 not in x:
print(-1)
elif max(x) == 0:
print(0)
else:
if sum(x) % 3 == 1:
flag_found_1 = False
for i in y:
if i % 3 == 1:
x.remove(i)
flag_found_1 = T... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER IF NUMBER VAR EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FO... |
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you?
You are given a set of digits, your task is to find the maximum integer that you can mak... | def vyvod(sp):
if set(sp) == {0}:
print(0)
exit()
sp.sort(reverse=True)
for i in sp:
print(i, end="")
exit()
n = int(input())
sp = list(map(int, input().split()))
d = sum(sp) % 3
if sp.count(0) == 0:
print(-1)
exit()
if d == 0:
vyvod(sp)
elif d == 1:
sp.sort()
... | FUNC_DEF IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR 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 BIN_OP FUNC_CALL VAR VAR NUMBER IF... |
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you?
You are given a set of digits, your task is to find the maximum integer that you can mak... | n = int(input())
c = input().split()
if "0" not in c:
print(-1)
else:
c.sort(reverse=True)
d = list(map(int, c))
if sum(d) % 3 == 0:
print(int("".join(c)))
elif sum(d) % 3 == 1:
if "1" in c:
c.remove("1")
print(int("".join(c)))
elif "4" in c:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF STRING VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL STRING VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NU... |
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you?
You are given a set of digits, your task is to find the maximum integer that you can mak... | n = int(input())
a = sorted([int(x) for x in input().split()])
s = sum(a)
if a[0] != 0:
print(-1)
exit(0)
if s % 3 != 0:
for x in a:
if x % 3 == s % 3:
a.remove(x)
break
else:
for x in a:
if x % 3:
a.remove(x)
break
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER FOR VAR VAR IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VA... |
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you?
You are given a set of digits, your task is to find the maximum integer that you can mak... | n = input()
digit = sorted(map(int, input().split()), reverse=True)
if 0 not in digit:
print(-1)
else:
mod = sum(digit) % 3
if mod:
equal = [d for d in digit if d % 3 == mod]
other = [d for d in digit if d % 3 not in [0, mod]]
if equal:
digit.remove(equal[-1])
eli... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER IF NUMBER VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR ASSIGN VAR VAR VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR VAR VAR BIN_OP VAR NUMBER LIST NUMBER VAR IF VAR EXPR FUNC_CALL VAR VAR... |
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you?
You are given a set of digits, your task is to find the maximum integer that you can mak... | n = int(input())
ans = list(map(int, input().split()))
if 0 not in ans:
print(-1)
exit()
ans.sort(reverse=True)
if ans.count(0) == n:
print(0)
elif not sum(ans) % 3:
print("".join(map(str, ans)))
else:
flag = 0
x = sum(ans) % 3
for i in range(n - 1, -1, -1):
if ans[i] % 3:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF NUMBER VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC... |
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you?
You are given a set of digits, your task is to find the maximum integer that you can mak... | n = int(input())
arr = list(map(int, input().strip().split()))
arr = sorted(arr, reverse=True)
x = sum(arr)
if x % 3 != 0:
if x % 3 == 1:
a = []
for i in range(n - 1, -1, -1):
if arr[i] % 3 == 1 and x % 3 == 1:
x -= arr[i]
else:
a.append(arr[i]... | 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 FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP VAR... |
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you?
You are given a set of digits, your task is to find the maximum integer that you can mak... | n = int(input())
v = list(map(int, input().split()))
fv = [0] * 10
for x in v:
fv[x] += 1
if fv[0] == 0:
print(-1)
else:
r = sum(v) % 3
ok, i = r == 0, r
while not ok and i <= 9:
if fv[i] > 0:
ok = 1
fv[i] -= 1
i += 3
if not ok:
i = 3 - r
w... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR VAR NUMBER IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER VAR WHILE VAR VAR NUMBER IF VAR VA... |
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you?
You are given a set of digits, your task is to find the maximum integer that you can mak... | n = int(input())
z = list(map(int, input().split()))
a = [0] * 10
for i in z:
a[i] += 1
if a[0] == 0:
print(-1)
else:
b = sum(z) % 3
c = True
if b == 2:
if a[2] != 0:
a[2] -= 1
elif a[5] != 0:
a[5] -= 1
elif a[8] != 0:
a[8] -= 1
eli... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR VAR NUMBER IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUMBER NUMBER VAR NUM... |
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you?
You are given a set of digits, your task is to find the maximum integer that you can mak... | x = input()
y = input().split(" ")
z = [int(i) for i in y]
z.sort()
if z[0] != 0:
print(-1)
else:
list3 = []
list2 = []
list1 = []
for i in z:
if i == 1 or i == 4 or i == 7:
list1.append(i)
elif i == 2 or i == 5 or i == 8:
list2.append(i)
elif i == 3 o... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER VAR NU... |
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you?
You are given a set of digits, your task is to find the maximum integer that you can mak... | from sys import stdin, stdout
def main():
from sys import stdin, stdout
N = int(stdin.readline())
arr = list(map(int, stdin.readline().split()))
arr.sort()
if arr[0] != 0:
stdout.write("-1\n")
return
res = sum(arr) % 3
if res:
tmp1 = list(filter(lambda x: x % 3 == ... | FUNC_DEF 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 IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER VAR ASSIGN VAR FUN... |
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you?
You are given a set of digits, your task is to find the maximum integer that you can mak... | n = 1
for test in range(n):
a = int(input())
lst = list(map(int, input().split()))
lst.sort(reverse=True)
s = 0
for el in lst:
s += el
if s % 3 == 2:
c = False
for i in range(a - 1, -1, -1):
if lst[i] % 3 == 2:
lst.remove(lst[i])
... | ASSIGN VAR NUMBER 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 EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF BIN... |
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you?
You are given a set of digits, your task is to find the maximum integer that you can mak... | def ep(msg):
print(str(msg))
exit()
n = input()
l = list(map(int, input().split()))
if 0 not in l:
ep(-1)
if sum(l) == 0:
ep(0)
l.sort()
r = sum(l) % 3
if r == 0:
l.reverse()
ep("".join(map(str, l)))
i = next((i for i, v in enumerate(l) if v % 3 == r), -1)
if i != -1:
del l[i]
else:
de... | FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF NUMBER VAR EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR ... |
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you?
You are given a set of digits, your task is to find the maximum integer that you can mak... | n = int(input())
freq = {}
for i in range(10):
freq[i] = 0
a = [int(i) for i in input().split()]
total = sum(a)
for i in range(n):
freq[a[i]] += 1
if not freq[0]:
print(-1)
else:
residue = total % 3
if residue:
found = False
while residue < 18 and not found:
if residue < ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR ASSIGN ... |
You are given n numbers a_1, a_2, ..., a_{n}. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make [Image] as large as possible, where $1$ denotes the bitwise OR.
Find the maximum possible value of [Image] after performing at most k operations optimally.
... | def pw(a, x, k):
if a == 0:
return 0
ans = a
while k > 0:
ans *= x
k = k - 1
return ans
n, k, x = list(map(int, input().split()))
a = list(map(int, input().split()))
lft = []
lft.append(0)
for val in a:
lft.append(val)
lft.append(0)
rht = []
for val in lft:
rht.append(v... | FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR VAR WHILE VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR 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 EXPR FUNC_CALL VAR NUMBER FOR VAR VAR EXPR FU... |
You are given n numbers a_1, a_2, ..., a_{n}. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make [Image] as large as possible, where $1$ denotes the bitwise OR.
Find the maximum possible value of [Image] after performing at most k operations optimally.
... | import sys
def get_ints():
return list(map(int, sys.stdin.readline().strip().split()))
def solve(N, K, X, A):
prefix, suffix = [0] * (N + 2), [0] * (N + 2)
for i in range(N):
prefix[i + 1] = prefix[i] | A[i]
for i in range(N - 1, -1, -1):
suffix[i] = suffix[i + 1] | A[i]
ans = 0
... | IMPORT FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER A... |
You are given n numbers a_1, a_2, ..., a_{n}. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make [Image] as large as possible, where $1$ denotes the bitwise OR.
Find the maximum possible value of [Image] after performing at most k operations optimally.
... | n, k, x = map(int, input().split())
a = list(map(int, input().split()))
x = x**k
pref, suff = [0] * n, [0] * n
for i in range(n - 1):
pref[i + 1] = a[i] | pref[i]
for i in range(n - 1, 0, -1):
suff[i - 1] = a[i] | suff[i]
res = 0
for i in range(n):
res = max(res, a[i] * x | pref[i] | suff[i])
print(res) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR BIN_OP LIST NUMBER VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR VAR FOR VAR FUNC_... |
You are given n numbers a_1, a_2, ..., a_{n}. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make [Image] as large as possible, where $1$ denotes the bitwise OR.
Find the maximum possible value of [Image] after performing at most k operations optimally.
... | n, k, x = list(map(int, input().split()))
a = list(map(int, input().split()))
c = x**k
pr = [0]
su = [0]
b = 0
for i in range(n - 1):
b = a[i] | b
pr.append(b)
b = 0
for i in range(n - 1, 0, -1):
b = a[i] | b
su.append(b)
su = su[::-1]
d = []
for i in range(n):
d.append(pr[i] | a[i] * c | su[i])
pri... | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR LIST NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR... |
You are given n numbers a_1, a_2, ..., a_{n}. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make [Image] as large as possible, where $1$ denotes the bitwise OR.
Find the maximum possible value of [Image] after performing at most k operations optimally.
... | x, n, k = [int(x) for x in input().split()]
lista = [int(x) for x in input().split()]
acumuladaL = []
acumuladaR = []
mult = k**n
cont = 0
for i in lista:
cont |= i
acumuladaL.append(cont)
cont = 0
for i in lista[::-1]:
cont |= i
acumuladaR.append(cont)
if len(lista) == 1:
print(lista[0] * mult)
eli... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CAL... |
You are given n numbers a_1, a_2, ..., a_{n}. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make [Image] as large as possible, where $1$ denotes the bitwise OR.
Find the maximum possible value of [Image] after performing at most k operations optimally.
... | class Ortree:
def __init__(self, n, As):
size = 1
while n > size:
size *= 2
self.size = size
data = [0] * size + As[:] + [0] * (size - n)
for idx in range(self.size - 1, 0, -1):
idx2 = idx << 1
data[idx] = data[idx2] | data[idx2 + 1]
... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP LIST NUMBER VAR VAR BIN_OP LIST NUMBER BIN_OP VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_DE... |
You are given n numbers a_1, a_2, ..., a_{n}. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make [Image] as large as possible, where $1$ denotes the bitwise OR.
Find the maximum possible value of [Image] after performing at most k operations optimally.
... | n, k, x = map(int, input().split())
(*Arr,) = map(int, input().split())
Prfx = [0] * (n + 2)
Sffx = [0] * (n + 2)
for i in range(0, n):
Prfx[i + 1] = Prfx[i] | Arr[i]
Sffx[n - i - 1] = Sffx[n - i] | Arr[n - i - 1]
now = x**k
Res = 0
for i in range(0, n):
Res = max(Prfx[i] | Arr[i] * now | Sffx[i + 1], Res)
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP ... |
You are given n numbers a_1, a_2, ..., a_{n}. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make [Image] as large as possible, where $1$ denotes the bitwise OR.
Find the maximum possible value of [Image] after performing at most k operations optimally.
... | n, k, x = map(int, input().split())
a = [None] + list(map(int, input().split()))
prefix = [0] * (n + 2)
suffix = [0] * (n + 2)
for i in range(1, n + 1):
prefix[i] = a[i] | prefix[i - 1]
for i in range(n, 0, -1):
suffix[i] = a[i] | suffix[i + 1]
mul = x**k
ans = 0
for i in range(1, n + 1):
ans = max(ans, pre... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NONE FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR 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 VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR VA... |
You are given n numbers a_1, a_2, ..., a_{n}. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make [Image] as large as possible, where $1$ denotes the bitwise OR.
Find the maximum possible value of [Image] after performing at most k operations optimally.
... | input_1 = input()
input_1 = input_1.split()
n = int(input_1[0])
k = int(input_1[1])
x = int(input_1[2])
a = input()
a = a.split()
a = [int(x) for x in a]
maximum = 0
prefix = []
suffix = []
prefix_or = 0
suffix_or = 0
for i in range(n):
prefix_or = prefix_or | a[i]
prefix.append(prefix_or)
for i in range(n - 1,... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN ... |
You are given n numbers a_1, a_2, ..., a_{n}. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make [Image] as large as possible, where $1$ denotes the bitwise OR.
Find the maximum possible value of [Image] after performing at most k operations optimally.
... | import sys
__author__ = "kitkat"
try:
while True:
n, k, x = map(int, input().split(" "))
val = [0] + list(map(int, input().split(" ")))
res = 0
L = [(0) for i in range(200003)]
R = [(0) for i in range(200003)]
for i in range(1, n + 1, 1):
L[i] = L[i - 1] ... | IMPORT ASSIGN VAR STRING WHILE NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL... |
You are given n numbers a_1, a_2, ..., a_{n}. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make [Image] as large as possible, where $1$ denotes the bitwise OR.
Find the maximum possible value of [Image] after performing at most k operations optimally.
... | import sys
class IoTool:
DEBUG = 0
def _reader_dbg():
with open("./input.txt", "r") as f:
lines = f.readlines()
for l in lines:
yield l.strip()
def _reader_oj():
return iter(sys.stdin.read().split("\n"))
reader = _reader_dbg() if DEBUG else _reader_oj... | IMPORT CLASS_DEF ASSIGN VAR NUMBER FUNC_DEF FUNC_CALL VAR STRING STRING VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR EXPR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CA... |
You are given n numbers a_1, a_2, ..., a_{n}. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make [Image] as large as possible, where $1$ denotes the bitwise OR.
Find the maximum possible value of [Image] after performing at most k operations optimally.
... | n, k, p = map(int, input().split())
numbers = list(map(int, input().split()))
x = [0] * (n + 10)
y = [0] * (n + 10)
p = p**k
maxi = 0
for i in range(n):
x[i + 1] = numbers[i] | x[i]
for j in range(n, -1, -1):
y[j - 2] = numbers[j - 1] | y[j - 1]
for i in range(n):
if maxi < x[i] | numbers[i] * p | y[i]:
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMB... |
You are given n numbers a_1, a_2, ..., a_{n}. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make [Image] as large as possible, where $1$ denotes the bitwise OR.
Find the maximum possible value of [Image] after performing at most k operations optimally.
... | def main():
n, k, x = list(map(int, input().split()))
aa = list(map(int, input().split()))
x, lo, u = x**k, [0] * n, 0
for i, a in enumerate(aa):
lo[i] = u
u |= a
hi, u = [], 0
for a in reversed(aa):
hi.append(u)
u |= a
hi.reverse()
for i, u, a, v in zip(l... | FUNC_DEF ASSIGN VAR 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 VAR VAR BIN_OP VAR VAR BIN_OP LIST NUMBER VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR VAR LIST NUMBER FOR VAR FUNC_CALL VAR... |
You are given n numbers a_1, a_2, ..., a_{n}. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make [Image] as large as possible, where $1$ denotes the bitwise OR.
Find the maximum possible value of [Image] after performing at most k operations optimally.
... | import sys
n, k, x = [int(x) for x in sys.stdin.readline().split()]
a = [int(x) for x in sys.stdin.readline().split()]
tl = 0
l = [0] * (n + 1)
for i in range(n - 1, -1, -1):
tl |= a[i]
l[i] = tl
ans = 0
tr = 0
for i in range(0, n):
ta = tr | a[i] * x**k | l[i + 1]
ans = ans if ans > ta else ta
tr ... | IMPORT ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR ... |
You are given n numbers a_1, a_2, ..., a_{n}. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make [Image] as large as possible, where $1$ denotes the bitwise OR.
Find the maximum possible value of [Image] after performing at most k operations optimally.
... | from sys import stdin
input = stdin.readline
def get_or(a, b):
return a | b
class SegmentTree:
def __init__(self, data, default=0, func=max):
self._default = default
self._func = func
self._len = len(data)
self._size = _size = 1 << (self._len - 1).bit_length()
self.... | ASSIGN VAR VAR FUNC_DEF RETURN BIN_OP VAR VAR CLASS_DEF FUNC_DEF NUMBER VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP NUMBER FUNC_CALL BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST VAR BIN_OP NUMBER VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VA... |
You are given n numbers a_1, a_2, ..., a_{n}. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make [Image] as large as possible, where $1$ denotes the bitwise OR.
Find the maximum possible value of [Image] after performing at most k operations optimally.
... | n, k, x = map(int, input().strip().split())
numbers = list(map(int, input().strip().split()))
from_b = [(0) for i in range(n)]
from_e = [(0) for i in range(n)]
or_no = [(0) for i in range(n)]
for j in range(1, n):
from_b[j] = from_b[j - 1] | numbers[j - 1]
from_e[n - j - 1] = from_e[n - j] | numbers[n - j]
for ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_... |
You are given n numbers a_1, a_2, ..., a_{n}. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make [Image] as large as possible, where $1$ denotes the bitwise OR.
Find the maximum possible value of [Image] after performing at most k operations optimally.
... | n, k, x = map(int, input().split())
a = list(map(int, input().split()))
b = list(a)
bits = [0] * 64
for i in range(32):
for j in range(len(b)):
bits[i] += b[j] & 1
b[j] >>= 1
ans = 0
for v in a:
t = v
u = v * x**k
s = 0
for i in range(64):
b = bits[i] - (t & 1) + (u & 1)
... | ASSIGN VAR 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 ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR N... |
You are given n numbers a_1, a_2, ..., a_{n}. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make [Image] as large as possible, where $1$ denotes the bitwise OR.
Find the maximum possible value of [Image] after performing at most k operations optimally.
... | n, k, x = map(int, input().split())
a = list(map(int, input().split()))
L = [0] * (n + 1)
R = [0] * (n + 1)
for i in range(1, n + 1):
L[i] = a[i - 1] | L[i - 1]
for i in range(n - 1, -1, -1):
R[i] = a[i] | R[i + 1]
ans = max(L[i] | a[i] * x**k | R[i + 1] for i in range(n))
print(ans) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP 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 B... |
You are given n numbers a_1, a_2, ..., a_{n}. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make [Image] as large as possible, where $1$ denotes the bitwise OR.
Find the maximum possible value of [Image] after performing at most k operations optimally.
... | from sys import stdin, stdout
def solve(n, k, x, a):
s = 0
prefix = [0] * (n + 10)
suffix = [0] * (n + 10)
a.append(0)
a.insert(0, 0)
m = pow(x, k)
for i in range(1, n + 1):
prefix[i] = prefix[i - 1] | a[i]
for i in range(n, 0, -1):
suffix[i] = suffix[i + 1] | a[i]
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR FOR VA... |
You are given n numbers a_1, a_2, ..., a_{n}. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make [Image] as large as possible, where $1$ denotes the bitwise OR.
Find the maximum possible value of [Image] after performing at most k operations optimally.
... | n, k, x = list(map(int, input().split()))
a = list(map(int, input().split()))
pref = [(0) for el in a]
suff = [(0) for el in a]
pref[0] = a[0]
for i in range(1, len(a)):
pref[i] = pref[i - 1] | a[i]
suff[-1] = a[-1]
for i in range(len(a) - 2, -1, -1):
suff[i] = suff[i + 1] | a[i]
if n == 1:
print(a[0] * x**... | ASSIGN VAR 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 NUMBER VAR VAR ASSIGN VAR NUMBER VAR VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VA... |
A sweet little monster Om Nom loves candies very much. One day he found himself in a rather tricky situation that required him to think a bit in order to enjoy candies the most. Would you succeed with the same task if you were on his place? [Image]
One day, when he came to his friend Evan, Om Nom didn't find him at h... | C, Hr, Hb, Wr, Wb = map(int, input().split())
ans = 0
for i in range(10**5):
if Wr * i <= C:
ans = max(ans, Hr * i + (C - Wr * i) // Wb * Hb)
for i in range(10**5):
if Wb * i <= C:
ans = max(ans, Hb * i + (C - Wb * i) // Wr * Hr)
print(ans) | ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER IF BIN_OP VAR VAR VAR ASSI... |
A sweet little monster Om Nom loves candies very much. One day he found himself in a rather tricky situation that required him to think a bit in order to enjoy candies the most. Would you succeed with the same task if you were on his place? [Image]
One day, when he came to his friend Evan, Om Nom didn't find him at h... | import sys
f = sys.stdin
C, Hr, Hb, Wr, Wb = map(int, f.readline().strip().split())
if Hr / Wr < Hb / Wb:
Hr, Hb, Wr, Wb = Hb, Hr, Wb, Wr
if C % Wr == 0 and C // Wr > 0:
print(C // Wr * Hr)
elif C // Wr == 0:
print(C // Wb * Hb)
else:
nmax = C // Wr
pmax = nmax * Hr + (C - nmax * Wr) // Wb * Hb
... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR IF BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_... |
A sweet little monster Om Nom loves candies very much. One day he found himself in a rather tricky situation that required him to think a bit in order to enjoy candies the most. Would you succeed with the same task if you were on his place? [Image]
One day, when he came to his friend Evan, Om Nom didn't find him at h... | a, b, c, d, e = list(map(int, input().split(" ")))
check = int(a**0.5)
ans = 0
for red in range(check + 1):
blue = (a - d * red) // e
if blue >= 0:
ans = max(ans, red * b + blue * c)
for blue in range(check + 1):
red = (a - e * blue) // d
if red >= 0:
ans = max(ans, red * b + blue * c)
p... | ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR F... |
A sweet little monster Om Nom loves candies very much. One day he found himself in a rather tricky situation that required him to think a bit in order to enjoy candies the most. Would you succeed with the same task if you were on his place? [Image]
One day, when he came to his friend Evan, Om Nom didn't find him at h... | __author__ = "trunghieu11"
def calc(n, h1, h2, w1, w2):
answer = 0
len = n // w1
for i in range(0, min(len, 100000) + 1):
answer = max(answer, i * h1 + (n - i * w1) // w2 * h2)
return answer
n, hR, hB, wR, wB = map(int, input().split())
print(max(calc(n, hR, hB, wR, wB), calc(n, hB, hR, wB, ... | ASSIGN VAR STRING FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR VAR RETURN VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EX... |
A sweet little monster Om Nom loves candies very much. One day he found himself in a rather tricky situation that required him to think a bit in order to enjoy candies the most. Would you succeed with the same task if you were on his place? [Image]
One day, when he came to his friend Evan, Om Nom didn't find him at h... | C, Pr, Pb, Wr, Wb = list(map(int, input().split()))
result = 0
if Wr * Wr >= C:
i = 0
while Wr * i <= C:
j = int((C - Wr * i) / Wb)
result = max(result, Pr * i + Pb * j)
i += 1
print(result)
return
if Wb * Wb >= C:
i = 0
while Wb * i <= C:
j = int((C - Wb * i) / W... | ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL ... |
A sweet little monster Om Nom loves candies very much. One day he found himself in a rather tricky situation that required him to think a bit in order to enjoy candies the most. Would you succeed with the same task if you were on his place? [Image]
One day, when he came to his friend Evan, Om Nom didn't find him at h... | m, h1, h2, w1, w2 = map(int, input().split())
if h2 / w2 > h1 / w1:
h1, h2 = h2, h1
w1, w2 = w2, w1
if w1**2 >= m:
res = 0
for i in range(int(m**0.5 + 1)):
if i * w1 <= m:
new = i * h1 + (m - w1 * i) // w2 * h2
res = max(res, new)
print(res)
exit()
res = 0
for i i... | ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR IF BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP... |
A sweet little monster Om Nom loves candies very much. One day he found himself in a rather tricky situation that required him to think a bit in order to enjoy candies the most. Would you succeed with the same task if you were on his place? [Image]
One day, when he came to his friend Evan, Om Nom didn't find him at h... | c, hr, hb, wr, wb = map(int, input().split())
s = 0
if wb < wr:
hr, hb, wr, wb = hb, hr, wb, wr
if wb * wb > c:
for nb in range(c // wb + 1):
s = max(s, nb * hb + hr * ((c - wb * nb) // wr))
else:
if hr * wb < hb * wr:
hr, hb, wr, wb = hb, hr, wb, wr
for nb in range(min(31625, c // wb + ... | ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR IF BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF BIN_OP V... |
A sweet little monster Om Nom loves candies very much. One day he found himself in a rather tricky situation that required him to think a bit in order to enjoy candies the most. Would you succeed with the same task if you were on his place? [Image]
One day, when he came to his friend Evan, Om Nom didn't find him at h... | def main():
c, hr, hb, wr, wb = (int(i) for i in input().split())
if wb < c ** (1 / 2) > wr:
if hr / wr < hb / wb:
wr, hr, wb, hb = wb, hb, wr, hr
mx = 0
for i in range(wr + 1):
tmx = i * hb + (c - i * wb) // wr * hr
mx = tmx if tmx > mx else mx
el... | FUNC_DEF ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP VAR BIN_OP NUMBER NUMBER VAR IF BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP ... |
The Rebel fleet is afraid that the Empire might want to strike back again. Princess Heidi needs to know if it is possible to assign R Rebel spaceships to guard B bases so that every base has exactly one guardian and each spaceship has exactly one assigned base (in other words, the assignment is a perfect matching). Sin... | n, m = map(int, input().split())
for i in range(n):
x, y = map(int, input().split())
for i in range(m):
x, y = map(int, input().split())
print("Yes" if n == m else "No") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR STRING STRING |
The Rebel fleet is afraid that the Empire might want to strike back again. Princess Heidi needs to know if it is possible to assign R Rebel spaceships to guard B bases so that every base has exactly one guardian and each spaceship has exactly one assigned base (in other words, the assignment is a perfect matching). Sin... | def ccw(A, B, C):
return (C[1] - A[1]) * (B[0] - A[0]) > (B[1] - A[1]) * (C[0] - A[0])
def intersect(A, B, C, D):
return ccw(A, C, D) != ccw(B, C, D) and ccw(A, B, C) != ccw(A, B, D)
R, B = map(int, input().split())
rs = []
bs = []
for r in range(R):
rs.append(list(map(int, input().split())))
for r in r... | FUNC_DEF RETURN BIN_OP BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL V... |
The Rebel fleet is afraid that the Empire might want to strike back again. Princess Heidi needs to know if it is possible to assign R Rebel spaceships to guard B bases so that every base has exactly one guardian and each spaceship has exactly one assigned base (in other words, the assignment is a perfect matching). Sin... | def check(a, b):
ansa = b[0] - a[0]
ansb = b[1] - a[1]
return [ansa, ansb]
while True:
try:
n, m = map(int, input().split())
if n != m:
a = list()
b = list()
for i in range(n):
a.append(list(map(int, input().split())))
for... | FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER RETURN LIST VAR VAR WHILE NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUN... |
The Rebel fleet is afraid that the Empire might want to strike back again. Princess Heidi needs to know if it is possible to assign R Rebel spaceships to guard B bases so that every base has exactly one guardian and each spaceship has exactly one assigned base (in other words, the assignment is a perfect matching). Sin... | r, b = [int(i) for i in input().split()]
for i in range(r):
discard = [int(i) for i in input().split()]
print("Yes" if r == b else "No") | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR STRING STRING |
The Rebel fleet is afraid that the Empire might want to strike back again. Princess Heidi needs to know if it is possible to assign R Rebel spaceships to guard B bases so that every base has exactly one guardian and each spaceship has exactly one assigned base (in other words, the assignment is a perfect matching). Sin... | b, r = input().split()
for x in range(int(b)):
temp, temp = input().split()
for x in range(int(r)):
temp, temp = input().split()
if b == r:
print("Yes")
else:
print("No") | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
The Rebel fleet is afraid that the Empire might want to strike back again. Princess Heidi needs to know if it is possible to assign R Rebel spaceships to guard B bases so that every base has exactly one guardian and each spaceship has exactly one assigned base (in other words, the assignment is a perfect matching). Sin... | str1 = input()
l_1 = str1.split(" ")
tedad = int(l_1[0])
tedad1 = int(l_1[1])
for i in range(tedad):
n = input()
for i in range(tedad1):
n = input()
if tedad1 == tedad:
print("Yes")
else:
print("No") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of n stations, enumerated from 1 through n. The train occupies one station at... | from sys import stdin
n, m = list(map(int, stdin.readline().split()))
c = {}
for _ in range(m):
a, b = list(map(int, stdin.readline().split()))
if a - 1 not in c.keys():
c[a - 1] = []
x = b - a + (n if b < a else 0)
c[a - 1].append(x)
for k, l in c.items():
c[k] = min(l) + (len(l) - 1) * n
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER LIST ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL ... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of n stations, enumerated from 1 through n. The train occupies one station at... | n, m = map(int, input().split())
def dist(a, b):
return (n + b - a) % n
def main():
inp1 = [0] * (n + 1)
inp2 = [n] * (n + 1)
for _ in range(m):
a, b = map(int, input().split())
inp1[a] += 1
inp2[a] = min(inp2[a], dist(a, b))
inp = tuple((r1 - 1) * n + r2 for r1, r2 in zi... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
d = []
for i in range(m):
d.append(list(map(int, input().split())))
par = []
g = []
for i in range(n):
g.append(0)
for i in range(n):
par.append(g.copy())
mas = []
for i in range(n):
mas.append([])
for i in range(m):
for k in... | 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 FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL 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 EXPR FU... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | n, m = map(int, input().split())
mas = list(map(int, input().split()))
otmas = []
for i in range(m):
otmas.append(list(map(int, input().split())))
for i in range(m):
otmas[i][0] -= 1
otmas[i][1] -= 1
ans = -1
masotv = []
for i in range(n):
mascop = mas.copy()
masotvizc = []
for j in range(m):
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR VAR VAR NUMBER NUMBER VAR VAR NUMBER NUMBER ASSIGN VA... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | n, m = map(int, input().split())
a = list(map(int, input().split()))
l = []
v = []
for _ in range(m):
l.append(list(map(int, input().split())))
ans = max(a) - min(a)
c = a.copy()
for _ in range(n):
for __ in range(n):
a = c.copy()
cur = []
if _ == __:
continue
for ___... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VA... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | from itertools import accumulate
n, m = map(int, input().split())
A = list(map(int, input().split()))
LR = []
for i in range(m):
l, r = map(int, input().split())
l, r = l - 1, r - 1
LR.append((l, r))
ans = -float("inf")
subs = -1
for i in range(n):
a = A[i]
imos = [0] * (n + 1)
s = []
for j... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST 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 BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CAL... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | n, m = list(map(int, input().split()))
A = [int(a) for a in input().split()]
L = [0] * m
R = [0] * m
for i in range(m):
l, r = list(map(int, input().split()))
L[i] = l - 1
R[i] = r - 1
ma = -1
mai = -1
for i in range(n):
B = [a for a in A]
for j in range(m):
if L[j] > i or R[j] < i:
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL 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 BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR N... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | from sys import stdin, stdout
def listIn():
return list(map(int, stdin.readline().strip().split()))
def stringIn():
return [x for x in stdin.readline().split()]
def intIn():
return int(stdin.readline())
n, m = listIn()
a = [0] + listIn()
arr = {}
segments = [(0, 0)]
for i in range(m):
l, r = lis... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR A... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | n, m = map(int, input().split())
a = [*map(int, input().split())]
i = 0
c = []
d = []
while i < m:
e, f = map(int, input().split())
c.append(e)
d.append(f)
i += 1
i = 0
j = 0
ans = max(a) - min(a)
ii = 0
jj = 0
while i < n:
j = 0
while j < n:
k = 0
l = a[j] - a[i]
if l + ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST WHILE VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VA... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | n, m = map(int, input().split())
a = [int(i) for i in input().split()]
b = []
for i in range(m):
x, y = map(int, input().split())
b.append((x, y))
seg = []
ma = -1000002
for i in range(len(a)):
for j in range(len(a)):
seg.clear()
if i == j:
continue
cnt = 0
for id... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VA... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | def solve(n, m, values, segments):
if n < 2:
return 0, 0, []
def find_min_max(max_value_index):
values_updated = values[:]
max_value = values[max_value_index]
min_value_index, min_value = None, None
segment_indexes = []
for seg_index in range(m):
star... | FUNC_DEF IF VAR NUMBER RETURN NUMBER NUMBER LIST FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR NONE NONE ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | def read_nums():
return [int(x) for x in input().split()]
def calculate_diff(i1, i2, nums, all_segments):
cur_diff = nums[i2] - nums[i1]
used_segments = []
for index, segment in enumerate(all_segments):
left, right = segment
if left <= i1 <= right and not left <= i2 <= right:
... | FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER RETURN VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR ... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | n, m = [int(x) for x in input().split()]
L = [int(x) for x in input().split()]
large = max(L)
R = []
used = 0
Pairs = []
best = 0
lol = []
for i in range(n):
if L[i] == large:
R.append(i)
for T in range(m):
l, j = [int(x) for x in input().split()]
Pairs.append((l, j))
for j in range(0, n):
S = L... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | n, m = map(int, input().split())
mass = list(map(int, input().split()))
lr = []
for t in range(m):
l, r = map(int, input().split())
lr.append([l, r])
mq = 0
mdel = []
mitog = 0
for a in range(len(mass)):
ma = mass[a]
for b in range(len(mass)):
mb = mass[b]
q = 0
delete = []
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | def f(a, b):
b = sorted(b, key=lambda s: s[1] - s[0])
t = {}
for i in range(len(a)):
l = []
for j in b:
if i in range(j[0], j[1] + 1):
l.append(j)
t[i] = l
t = dict(sorted(t.items(), key=lambda s: a[s[0]]))
t = dict(sorted(t.items(), key=lambda s: ... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR IF VAR FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER AS... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | n, m = map(int, input().split())
a = list(map(int, input().split()))
b = []
for i in range(m):
b.append(list(map(int, input().split())))
ans = max(a) - min(a)
temp = []
for i in range(n):
c = a[:]
l = []
for j in range(m):
if i not in range(b[j][0] - 1, b[j][1]):
for k in range(b[j][... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR F... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | n, m = map(int, input().split())
a = list(map(int, input().split()))
ans = []
pair = []
for i in range(m):
x = list(map(int, input().split()))
pair.append(x)
for i in range(n):
for j in range(n):
d = []
b = 0
for k in range(m):
if (
j + 1 >= pair[k][0]
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR ... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | n, m = map(int, input().split())
a = list(map(int, input().split()))
segments = []
for i in range(m):
l, r = map(int, input().split())
segments.append([l, r])
ans = 0
flag = 0
for i in range(n):
for j in range(i, n):
ai = a[i]
aj = a[j]
seglist1 = []
seglist2 = []
for... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | n, m = map(int, input().split())
lis = list(map(int, input().split()))
res = max(lis) - min(lis)
seg = []
cur = []
pre = [0] * n
for i in range(m):
a, b = map(int, input().split())
seg.append([a - 1, b - 1])
for i in range(n):
c = lis[:]
ans = []
for j in range(m):
aa, bb = seg[j][0], seg[j]... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CA... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | dat = list(map(int, input().split()))
l = list(map(int, input().split()))
d = {}
i = 1
while i < dat[1] + 1:
inter = list(map(int, input().split()))
j = inter[0]
while j < inter[1] + 1:
if j not in d:
d[j] = set()
d[j].add(i)
j += 1
i += 1
max_res = -1
ans = None
i = ... | 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 ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER WHILE VAR BIN_OP VAR NUMBER ... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | def main():
n, m = map(int, input().split())
aa = list(map(int, input().split()))
res = max(aa) - min(aa)
ll, rr = [999], [999]
segments = res_segments = [False] * (m + 1)
for _ in range(m):
l, r = map(int, input().split())
ll.append(l - 1)
rr.append(r - 1)
il, ir = (... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR LIST NUMBER LIST NUMBER ASSIGN VAR VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR F... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | horizon, num_blocks = [int(x) for x in input().split()]
c = 0
terrain = []
for x in input().split():
terrain.append([int(x), c])
c += 1
ori_shallow = max(terrain)
ori_deep = min(terrain)
record = abs(ori_deep[0] - ori_shallow[0])
if num_blocks == 0 or horizon == 1:
print(record)
print(0)
exit()
reco... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | n, m = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
queries = []
for i in range(m):
l, r = [int(x) for x in input().split()]
queries.append([l, r])
if True:
B = A[:]
bestans = 0
bestq = []
for mnind in range(n):
qans = []
B = A[:]
for i in range... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR IF NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR ... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | import sys
input = sys.stdin.readline
def inp():
return int(input())
def inara():
return list(map(int, input().split()))
def insr():
s = input()
return list(s[: len(s) - 1])
def invr():
return map(int, input().split())
n, m = invr()
a = inara()
seg = []
for i in range(m):
l, r = invr(... | IMPORT 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 RETURN FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSI... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | n, m = list(map(int, input().split()))
A = list(map(int, input().split()))
lst = []
for i in range(m):
a, b = list(map(int, input().split()))
lst.append([a, b])
answer = 0
answer_1 = []
for i in range(n):
B = A.copy()
kek = []
for j in range(m):
a, b = lst[j][0], lst[j][1]
if a <= i ... | 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 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 LIST VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | (
lambda N, M: (
lambda n, m, d, dM, dm: [
[
[
(
lambda a, b: [
[
(0 if k[0] <= i <= k[1] else b.__setitem__(0, b[0] - 1))
for k in m
... | EXPR FUNC_CALL FUNC_CALL LIST FUNC_CALL LIST VAR NUMBER VAR VAR NUMBER NUMBER FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER VAR VAR VAR NUMBER VAR VAR NUMBER VAR NUMBER VAR VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER LIST FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NU... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
b = [list(map(int, input().split())) for i in range(m)]
gl_ans = -1
gl_mas = []
for num_i in range(n):
ma = -10000000.0
ans_m = []
o = []
for i in range(m):
if b[i][0] - 1 > num_i or b[i][1] - 1 < num_i:
o.app... | 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 FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | import sys
big = 10**9
class super_seg:
def __init__(self, data):
n = len(data)
m = 1
while m < n:
m *= 2
self.n = n
self.m = m
self.data = [big] * (2 * m)
for i in range(n):
self.data[i + m] = data[i]
for i in reversed(rang... | IMPORT ASSIGN VAR BIN_OP NUMBER NUMBER CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP LIST VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | n, m = map(int, input().strip().split())
lst = list(map(int, input().strip().split()))
vidr = []
for i in range(m):
a, b = map(int, input().strip().split())
vidr.append([a - 1, b - 1])
dif = max(lst) - min(lst)
used = []
for i in range(n):
new_vidr = []
new_lst = lst.copy()
for v in range(m):
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN ... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | n, m = map(int, input().split())
a = [*map(int, input().split())]
i = 0
c = []
d = []
while i < m:
e, f = map(int, input().split())
c.append(e)
d.append(f)
i += 1
i = 0
j = 0
ans = -1
s = []
while i < n:
j = 0
while j < n:
k = 0
l = a[j] - a[i]
ma = []
while k < m... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST WHILE VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VA... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | n, m = map(int, input().split())
a = list(map(int, input().split()))
arr = [set() for i in range(n)]
for i in range(m):
l, r = map(int, input().split())
l -= 1
for j in range(l, r):
arr[j].add(i)
maxi = 0
b, s = 0, 0
d = 0
ans = []
f_ans = []
for i in range(n):
for j in range(n):
d = 0
... | 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 FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VA... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | n, m = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
q = []
for i in range(m):
l, r = [int(c) for c in input().split()]
q.append([l, r, i + 1])
fin = []
fin_val = 0
for i in range(n):
mx = a[i]
copy = a[:]
ans = []
for j in range(m):
l, r = q[j][0], q[j][1]
... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CA... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | n, m = map(int, input().split())
a = list(map(int, input().split()))
ma = max(a) - min(a)
rec = []
L, R = [], []
for i in range(m):
l, r = map(int, input().split())
l, r = l - 1, r - 1
L.append(l)
R.append(r)
for k in range(n):
c = a.copy()
tmp = []
for i in range(m):
l, r = L[i], R[... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | import sys
input = sys.stdin.readline
n, m = map(int, input().split())
x = [*map(int, input().split())]
seg = []
for i in range(m):
a = [*map(int, input().split())]
seg.append(a)
ans = -1
ansi = []
for i in range(len(x)):
tx = x[:]
oi = []
for n, j in enumerate(seg):
a, b = j
if not... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | n, m = list(map(int, input().split()))
lst = list(map(int, input().split()))
segments = [list(map(int, input().split())) for i in range(m)]
max_diff = max(lst) - min(lst)
final_inds_segments = []
for ind_max, est_max in enumerate(lst):
est_final_list = lst.copy()
est_inds_segments = []
for segm_pair_ind, se... | 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 FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR FUNC_CALL V... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | n, m = map(int, input().split())
A = list(map(int, input().split()))
Lf = [[] for _ in range(n)]
Rb = [[] for _ in range(n)]
LR = []
for i in range(m):
l, r = map(int, input().split())
l, r = l - 1, r - 1
Lf[r].append(l)
Rb[l].append(r)
LR.append((l, r))
minus = [0] * n
INF = 10**18
ans = [-INF] * n... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR ASSIGN VAR LIST 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 ASSIGN VAR VAR BIN_OP... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | import sys
input = sys.stdin.readline
n, m = map(int, input().split())
a = list(map(int, input().split()))
lr = [list(map(int, input().split())) for _ in range(m)]
for i in range(m):
lr[i][0] -= 1
inf = 1145141919
d = -inf
for i in range(n):
for j in range(n):
b = [0] * (n + 1)
c0 = []
... | IMPORT 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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FOR ... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | n, m = map(int, input().split())
arr = [int(x) for x in input().split()]
seg = []
el = []
el2 = []
h = []
def cont(a, b, c):
return a <= c <= b
def count_delta():
return max(h) - min(h)
def decrement(l, r):
for i in range(l - 1, r):
h[i] -= 1
for i in range(m):
seg.append([int(x) for x i... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FUNC_DEF RETURN VAR VAR VAR FUNC_DEF RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VA... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | aLen, numOfSeg = map(int, input().split(" "))
aList = list(map(int, input().split(" ")))
segList = []
for x in range(numOfSeg):
s, e = map(int, input().split(" "))
segList.append((s, e))
res = max(aList) - min(aList)
hList = []
for x in range(0, len(aList)):
ele = aList[x]
c = aList[:]
h = []
fo... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | n, m = map(int, input().split())
l = list(map(int, input().split()))
seg = []
for i in range(m):
a, b = map(int, input().split())
seg.append((a - 1, b - 1))
ans = max(l) - min(l)
minind = 0
maxind = 0
for i in range(n):
for j in range(n):
temp1 = l[i]
temp2 = l[j]
for k in seg:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST 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 BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_C... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | from sys import stdin
n, m = map(int, input().split())
l = list(map(int, stdin.readline().split()))
segment = [tuple(map(int, inp.split())) for inp in stdin.read().splitlines()]
ans = 0
chosen = []
for i in range(n):
temp = l.copy()
curpair = []
for j in range(m):
left, right = segment[j]
i... | 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 FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FU... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | import sys
input = sys.stdin.readline
n, m = map(int, input().split())
a = list(map(int, input().split()))
lr = [list(map(int, input().split())) for i in range(m)]
max_d = -1
ans_use = []
for i in range(n):
use = []
c = [a[i] for i in range(n)]
for j in range(m):
l, r = lr[j]
if l <= i + 1 ... | IMPORT 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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VA... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | import sys
input = sys.stdin.readline
n, m = map(int, input().split())
A = list(map(int, input().split()))
LR = [list(map(int, input().split())) for i in range(m)]
def MINUS(A, B):
MIN = float("inf")
MAX = -float("inf")
for i in range(len(A)):
if MIN > A[i] - B[i]:
MIN = A[i] - B[i]
... | IMPORT 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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | import sys
inn = lambda: input().strip()
N, M = map(int, inn().split(" "))
array = list(map(int, inn().split(" ")))
segment = []
for _ in range(M):
l, r = tuple(map(int, inn().split(" ")))
segment.append((l - 1, r - 1))
answer = -1
selectedSeg = []
for i, a in enumerate(array):
array_temp = array.copy()
... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR B... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | n, q = map(int, input().split())
l = [int(i) for i in input().split()]
eff = [0] * (n + 5)
qry = []
for i in range(q):
a, b = map(int, input().split())
a -= 1
b -= 1
qry.append([a, b])
maxi = 0
res = []
for ans in range(n):
l1 = l[:]
now = l[ans]
apply = []
for j in range(q):
a =... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR LIST VAR VAR ASSIG... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | n, m = map(int, input().split())
arr = list(map(int, input().split()))
b = []
for i in range(m):
l, r = map(int, input().split())
b.append([l, r])
ans = 0
rt = []
for i in range(1, n + 1):
brr = arr[:]
temp = []
for j in range(m):
if i >= b[j][0] and i <= b[j][1]:
continue
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BI... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | def main():
n, m = map(int, input().split())
aa = list(map(int, input().split()))
res = max(aa) - min(aa)
ll, rr = [n + 1], [n + 1]
segments = res_segments = [False] * (m + 1)
bounds = {0, n, n + 1}
for _ in range(m):
l, r = map(int, input().split())
l -= 1
ll.append(... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR LIST BIN_OP VAR NUMBER LIST BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER VA... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | R = lambda: map(int, input().split())
n, m = R()
l = list(R())
d = max(l) - min(l)
s = []
qc = []
for i in range(m):
s.append(list(R()))
for i in range(1, n + 1):
str = l.copy()
c = []
for j in range(m):
if i not in range(s[j][0], s[j][1] + 1):
c.append(j + 1)
for t in ra... | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR ... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | class Segments:
def __init__(self, segments):
self.segments = segments
def all(self):
return [i for i in range(len(self.segments))]
def at_point(self, point, included=None, excluded=None):
if included is None:
included = self.all()
if excluded is None:
... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR FUNC_DEF RETURN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_DEF NONE NONE IF VAR NONE ASSIGN VAR FUNC_CALL VAR IF VAR NONE ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR IF VAR VAR NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN VAR ... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.
You are also given a set of $m$ segments. The $j$-th segment is $[l_j; r_j]$, where $1 \le l_j \le r_j \le n$.
You can... | n, m = map(int, input().split())
b = list(map(int, input().split()))
segs = [list(map(int, input().split())) for _ in range(m)]
a = []
d = []
for i in range(n):
w = [i for i in b]
x = [0] * (n + 1)
t = []
for j in range(m):
left, right = segs[j][0], segs[j][1]
if i >= left - 1 and i <= r... | 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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP LIST NUM... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.