description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | n = int(input())
a = list(map(int, input().split()))
c = list(filter(lambda x: x % 2 == 0 and x > 0, a))
b = list(filter(lambda x: x % 2 != 0, a))
b = sorted(b, reverse=True)
mm = int(-10000000000.0)
s = 0
for i in range(len(b)):
s += b[i]
if i % 2 == 0:
mm = max(mm, s)
print(sum(c) + mm) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | n = int(input())
posdd = []
odd = []
even = 0
t = list(map(int, input().split()))
for j in range(n):
if abs(t[j]) % 2 == 0:
if t[j] > 0:
even += t[j]
elif t[j] > 0:
posdd.append(t[j])
even += t[j]
else:
odd.append(t[j])
if even % 2:
print(even)
else:
u = 9... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER IF VAR VAR NUMBER VAR VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR VAR EXPR ... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | n = int(input())
a = list(map(int, input().split()))
odd = []
oddp = []
even = []
for i in a:
if i % 2 == 0:
if i > 0:
even.append(i)
elif i > 0:
oddp.append(i)
else:
odd.append(i)
odd = sorted(odd)
oddp = sorted(oddp)
s = sum(even)
if len(oddp) > 0:
if len(oddp) % 2 ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF BIN_OP VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | n = int(input())
lst = [int(x) for x in input().split(" ")]
even = list(filter(lambda x: x % 2 == 0, lst))
odd = list(filter(lambda x: x % 2 != 0, lst))
even_sum = 0
for i in even:
if i > 0:
even_sum += i
odd = reversed(sorted(odd))
possible = []
rolling = 0
for i in odd:
rolling += i
possible.appen... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | n = int(input())
a = [int(i) for i in input().split()]
s = 0
for i in a:
if i > 0:
s += i
if s % 2 == 1:
print(s)
else:
maxot = -100000000000000
for i in a:
if i % 2 == 1 and i < 0 and i >= maxot:
maxot = i
minpo = 10000000000000000
for i in a:
if i > 0 and i ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR VAR... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | amount = input()
cases = input()
cases = cases.split()
cases = list(map(int, cases))
minOdd = +2147483
sum = 0
for i in range(int(amount)):
if cases[i] > 0:
sum = sum + cases[i]
if cases[i] % 2 != 0:
if minOdd > abs(cases[i]):
minOdd = abs(cases[i])
if sum % 2 == 0:
sum = sum - m... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER IF VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FU... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | n = int(input())
a = list(map(int, input().split()))
mini = 9999
sum = 0
for i in a:
if i > 0:
sum += i
if i % 2 != 0:
if abs(i) < mini:
mini = abs(i)
if sum % 2 == 0:
sum = sum - mini
print(sum) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR VAR IF BIN_OP VAR NUMBER NUMBER IF FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR FUN... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | n = int(input())
l = list(map(int, input().split()))
c = [[], []]
for i in l:
c[i % 2].append(i)
c[0].sort()
c[1].sort()
ans = 0
for i in c[0]:
if i > 0:
ans += i
ans += c[1][-1]
for i in range(len(c[1]) - 2, 0, -2):
ans = max(ans, ans + c[1][i] + c[1][i - 1])
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST LIST LIST FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR NUMBER IF VAR NUMBER VAR VAR VAR VAR NUMBER NUMBER FO... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | n = int(input())
max_even = -10002
max_odd = -10001
l = [int(x) for x in input().split()]
for i in l:
if i % 2 == 1:
a, b = max(max_odd, i, max_even + i), max(max_even, max_odd + i)
max_odd = a
max_even = b
else:
a, b = max(max_odd, max_odd + i), max(max_even, max_even + i, i)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR ... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | len = int(input())
a = list(map(int, input().split()))
a.sort()
sum = 0
for i in range(len):
if a[~i] < 0:
break
sum += a[~i]
if sum % 2 == 1:
print(sum)
exit()
a = sorted(list(map(abs, a)))
for i in range(len):
if a[i] % 2 == 1:
sum -= a[i]
break
print(sum) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VA... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | n = int(input())
l = list(map(int, input().split()))
odd = []
even = []
for i in range(n):
if l[i] % 2 == 0:
if l[i] > 0:
even.append(l[i])
else:
odd.append(l[i])
odd.sort(reverse=True)
even.sort(reverse=True)
ans = 0
for i in range(len(odd)):
if odd[i] < 0:
if ans == 0:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | input()
l = list(map(int, input().split()))
pos = []
neg = []
for num in l:
if num < 0:
neg.append(num)
else:
pos.append(num)
neg.sort()
pos.sort()
total = sum(pos)
if total % 2 == 1:
print(total)
else:
lowest = 10**10
for num in pos:
if num % 2 == 1 and num < lowest:
... | EXPR 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 VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR B... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | import sys
input()
arr = list(map(int, input().split()))
negs = sorted([x for x in arr if x < 0])
poss = sorted([x for x in arr if x > 0])
r = sum(poss)
if r % 2 == 1:
print(r)
sys.exit(0)
pos = [x for x in poss if x % 2 == 1]
pes = [x for x in poss if x % 2 == 0]
nos = [x for x in negs if x % 2 == 1]
nes = [x... | IMPORT EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR VAR BI... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | import sys
n = int(sys.stdin.readline())
l = list(map(int, sys.stdin.readline().split()))
b = []
c = []
d = []
for i in range(0, n):
if l[i] % 2 == 0 and l[i] >= 0:
b.append(l[i])
elif l[i] % 2 != 0 and l[i] >= 0:
c.append(l[i])
elif l[i] % 2 != 0:
d.append(l[i])
k = len(c)
sum1 = 0... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR VAR NUMBER NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER VAR VAR NUMBER EXPR ... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | n = int(input())
a = [int(x) for x in input().split()]
s = 0
r = -(10**5)
minodd = 10**5
minminodd = -(10**5)
for i in range(n):
if a[i] > 0:
s += a[i]
if a[i] & 1 and a[i] < minodd:
minodd = a[i]
if a[i] < 0 and a[i] > minminodd and a[i] & 1:
minminodd = a[i]
if s > 0 and s ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR VAR IF BIN_OP VAR VAR NUMBER VAR VAR VAR ASSIGN VAR VAR VA... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | def readInts():
num = []
for c in input().strip().split():
num.append(int(c))
return num
def solve(num):
minOdd = 10000000
maxNegOdd = -10000000
sum = 0
for x in num:
if x > 0:
sum = sum + x
if x & 1:
minOdd = min(minOdd, x)
e... | FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER ASSIGN VAR FUNC... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | n = int(input())
a = list(map(int, input().split()))
a.sort(key=lambda x: -x)
s_p = sum(filter(lambda x: x > 0, a))
if s_p % 2 == 1:
print(s_p)
else:
m_p = list(filter(lambda x: x > 0 and x % 2 == 1, a))
m_n = list(filter(lambda x: x < 0 and x % 2 == 1, a))
if len(m_p) > 0 and len(m_n) > 0:
s_p ... | 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 VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER NUMBER VAR ASSIGN ... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | n = int(input())
inp = list(map(int, input().split()))
poseven = []
posodd = []
negeven = []
negodd = []
for item in inp:
if item < 0 and item % 2 == 0:
negeven.append(item)
elif item < 0 and item % 2 == 1:
negodd.append(item)
elif item > 0 and item % 2 == 0:
poseven.append(item)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF VAR NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER ... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | x = int(input())
lista = list(map(int, input().split()))
ans = 0
impares = []
for i in range(x):
if lista[i] > 0 and lista[i] % 2 == 0:
ans += lista[i]
elif lista[i] % 2 != 0:
impares.append(lista[i])
som_imp = [(0) for i in range(len(impares))]
impares.sort()
impares.reverse()
som_imp[0] = impa... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER BIN_OP VAR VAR NUMBER NUMBER VAR VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR ... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | n = int(input())
vals = input().split()
a_list = [int(val) for val in vals]
max_even = None
max_odd = None
for a in a_list:
me = max_even
mo = max_odd
if a % 2 == 0:
if mo is not None:
max_odd = max(mo, mo + a)
if me is not None:
max_even = max(me, a, me + a)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NONE ASSIGN VAR NONE FOR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR IF BIN_OP VAR NUMBER NUMBER IF VAR NONE ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR IF VAR NONE ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | n = int(input())
a = list(map(int, input().split()))
even = []
odd = []
for i in a:
if i & 1:
odd.append(i)
else:
even.append(i)
odd.sort(reverse=True)
even.sort(reverse=True)
ans = 0
for i in even:
if i < 0:
break
ans += i
ocount = 0
for i in range(len(odd)):
if odd[i] >= 0:... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR VAR... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | n = int(input())
seq = input().split(" ")
summ = 0
arr = []
minPosOdd = +999999999999999999999999999999999999
foundOdd = False
for i in seq:
arr.append(int(i))
for i in range(n):
if arr[i] > 0:
summ = summ + arr[i]
if arr[i] % 2 != 0:
foundOdd = True
if arr[i] > 0:
minPos... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR NUM... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | n = int(input())
array = list(map(int, input().split()))
array.sort()
array.reverse()
odd = 0
odde = []
for k in range(n):
if array[k] % 2 == 0 and array[k] > 0:
odd += array[k]
elif array[k] % 2 == 1:
odde.append(array[k])
odd += odde[0]
m = len(odde)
i = 2
while m - i > 0:
if odde[i - 1] +... | 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 EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER VAR VAR NUMBER VAR VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VA... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | n = int(input())
l = list(map(int, input().split(" ")))
l_even = []
l_odd = []
for i in l:
if i % 2 == 0:
if i > 0:
l_even.append(i)
else:
l_odd.append(i)
sum_even = sum(l_even)
l_odd.sort()
countt = 0
index = -999
tt = 0
l2 = []
for i in range(len(l_odd)):
if l_odd[i] < 0:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF BIN_OP VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VA... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | n = int(input())
a = list(map(int, input().split()))
s = []
s2 = []
for i in a:
if i > 0:
s.append(i)
elif i < 0:
s2.append(i)
s.sort()
s2 = sorted(s2)[::-1]
if sum(s) % 2:
print(sum(s))
else:
sm = sum(s)
mn = 1e18
for i in s2:
if i % 2:
mn = min(abs(i), mn)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER EXPR F... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | def max_odd_subsequence():
input()
array = [int(x) for x in input().split()]
sum = 0
leastodd = 999999
for i in array:
if i > 0:
sum += i
if i % 2 == 1 and abs(i) < abs(leastodd):
leastodd = i
if sum % 2 == 1:
return sum
else:
return su... | FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR VAR IF BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR IF BIN_OP VAR NUMBER NUMBER RETURN VAR RETURN BIN_OP VAR FUNC_CALL VAR VAR EXPR FUNC_C... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | input()
a = [int(x) for x in input().split()]
oc = 0
ps = 0
pmo = 1000000.0
nmo = -1000000.0
for x in a:
if x > 0:
ps += x
if x % 2 == 1 and x > 0 and pmo > x:
pmo = x
if x % 2 == 1 and x > 0:
oc += 1
if x % 2 == 1 and x < 0 and nmo < x:
nmo = x
if oc % 2 == 1:
print(... | EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR VAR ASSIGN VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBE... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | import sys
def get_array():
return list(map(int, sys.stdin.readline().strip().split()))
def get_ints():
return map(str, sys.stdin.readline().strip().split())
def input():
return sys.stdin.readline().strip()
n = int(input())
Arr = get_array()
min_odd_pos = 10**9
max_odd_neg = -(10**9)
total = 0
for i... | IMPORT FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER NU... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
i = 0
m1 = float("inf")
m2 = -float("inf")
while i < n and a[i] >= 0:
if a[i] % 2 == 1:
m1 = a[i]
i += 1
s = sum(a[:i])
if s % 2 == 1:
print(s)
else:
while i < n and a[i] % 2 == 0:
i += 1
if i < n:
m2 =... | 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 ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING WHILE VAR VAR VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | def OddSum(n, a):
c = 0
a.sort(reverse=True)
i = 0
minposodd = 99999
maxnegodd = -99999
while i < n:
if a[i] > 0:
c = c + a[i]
if a[i] % 2 == 1:
if a[i] > 0:
minposodd = min(minposodd, a[i])
else:
maxnegodd = max... | FUNC_DEF ASSIGN VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER IF VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBE... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | n = int(input())
arr = [int(i) for i in input().split()]
par_positivo = []
impar_positivo = []
menor_par_neg = float("inf")
maior_impar_neg = -float("inf")
for el in arr:
if el % 2 == 0:
if el > 0:
par_positivo.append(el)
elif el < menor_par_neg:
menor_par_neg = el
elif e... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING FOR VAR VAR IF BIN_OP VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_C... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | n = input()
seq = list(map(int, input().split()))
positive = list(filter(lambda x: x > 0, seq))
negative = list(filter(lambda x: x < 0, seq))
s = sum(positive)
if s % 2 == 0:
p = list(map(lambda x: -x, positive))
remove = sorted(p + negative)
for i in range(len(remove) - 1, -1, -1):
if (s + remove[i... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | n = int(input())
lis = list(map(int, input().split()))
ans = 0
Min = 2**63
for i in lis:
if i > 0:
ans += i
if ans % 2:
print(ans)
else:
ref = min([abs(i) for i in lis if i % 2])
ans -= ref
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR VAR IF VAR NUMBER VAR VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | import sys
n = int(sys.stdin.readline())
l = list(map(int, sys.stdin.readline().split()))
pos = []
neg = []
for i in range(n):
if l[i] < 0:
neg.append(l[i])
elif l[i] > 0:
pos.append(l[i])
neg.sort(reverse=True)
pos.sort(reverse=True)
ans = 0
for i in range(len(pos)):
if pos[i] % 2 == 0:
... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN ... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | n = int(input())
tab = map(int, input().split())
tab = sorted(tab, reverse=True)
maxi = 0
tmpOdd = 0
maxOdd = 0
oddFirst = True
for i in tab:
if i % 2 == 0 and i > 0:
maxi += i
elif i % 2 == 1:
tmpOdd += i
if tmpOdd % 2 == 1:
if maxOdd < tmpOdd or oddFirst:
od... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR VAR IF BIN_OP VAR NUMBER NUMB... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | n = int(input())
a = list(map(int, input().split()))
odd_plus_min = 1000000000.0
odd_minus_max = -1000000000.0
sum = 0
for i in range(n):
if a[i] > 0:
sum += a[i]
if abs(a[i]) % 2 != 0:
if a[i] > 0:
odd_plus_min = min(odd_plus_min, a[i])
elif a[i] < 0:
odd_minus_m... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR VAR IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER IF VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF ... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | import sys
n = int(sys.stdin.readline().strip())
integer_line = sys.stdin.readline().strip().split()
integers = []
for integer in integer_line:
integers.append(int(integer))
max_odd = [None] * (len(integers) + 1)
max_even = [None] * (len(integers) + 1)
max_odd[-1] = 0
max_even[-1] = 0
for index in range(len(intege... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NONE BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NONE BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VA... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | _ = int(input())
a = list(map(int, input().split()))
r = sum([i for i in a if 0 < i])
if r % 2 == 1:
print(r)
else:
print(
max(
r + max([i for i in a if i % 2 == 1 and i < 0], default=-(10**12)),
r - min([i for i in a if i % 2 == 1 and 0 < i], default=10**12),
)
) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER BIN_OP NU... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | from sys import stdin
def ii():
return int(stdin.readline())
def mi():
return map(int, stdin.readline().split())
def li():
return list(mi())
n = ii()
a = li()
m, s, m1 = -10010, 0, 10010
for i in range(n):
if a[i] > 0:
s += a[i]
if a[i] % 2:
m1 = min(m1, a[i])
eli... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR VAR IF BIN_OP VAR VAR NUMBER ASS... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | n = int(input())
seq = list(map(int, input().split()))
d = [[(-float("Inf")) for i in range(n + 1)] for j in range(2)]
for k in range(n):
if seq[k] % 2 == 0:
d[0][k + 1] = max(d[0][k], d[0][k] + seq[k], seq[k])
d[1][k + 1] = max(d[1][k], d[1][k] + seq[k])
else:
d[0][k + 1] = max(d[0][k],... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR VAR NUMBER VA... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | def main():
input()
aa, l = list(map(int, input().split())), []
for i, a in enumerate(aa):
if a & 1:
l.append(i)
elif a < 0:
aa[i] = 0
l.sort(key=aa.__getitem__)
i = 1 - len(l) & 1
if i:
aa[l[0]] = 0
for j, k in zip(l[i::2], l[i + 1 :: 2]):
... | FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR LIST FOR VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER FUNC_CALL VAR VAR NUMBER IF VAR ASSIGN VAR VAR NUMB... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | n = int(input())
a = list(map(int, input().split()))
s, r, t, o = 0, [], [], []
for i in a:
if i > 0:
s += i
if s % 2 == 0:
for i in a:
if i > 0 and i % 2 == 1:
r += [i]
elif i < 0 and i % 2 == 1:
t += [i]
q = s - (min(r) if r else 0)
w = s + (max(t) if t ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER LIST LIST LIST FOR VAR VAR IF VAR NUMBER VAR VAR IF BIN_OP VAR NUMBER NUMBER FOR VAR VAR IF VAR NUMBER BIN_OP VAR NUMBER NUMBER VAR LIST VAR IF VAR NUMBER BIN_OP VAR NUMBER NUMBER VAR ... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | x = int(input())
s = list(map(int, input().split(" ")))
kek = 10000
answer = 0
for i in range(0, len(s)):
if s[i] > 0:
answer += s[i]
if abs(s[i]) < kek and s[i] % 2 == 1:
kek = abs(s[i])
if answer % 2 == 0:
print(answer - kek)
else:
print(answer) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR VAR IF FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF ... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | N = int(input())
A = list(map(int, input().split()))
dp = [[(-int(1000000000.0)) for i in range(2)] for j in range(N + 1)]
dp[0][0] = 0
for i in range(N):
for j in range(2):
if abs(A[i]) & 1:
dp[i + 1][j] = max(dp[i][j], dp[i][j ^ 1] + A[i])
else:
dp[i + 1][j] = max(dp[i][j],... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR VAR NU... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | n = input()
listt = list(map(int, input().strip().split()))
ans = 0
listt.sort()
pos = []
neg = []
for i in listt:
if i > 0:
ans += i
if i % 2 == 1:
if i > 0:
pos.append(i)
else:
neg.append(i)
if ans % 2 == 1:
print(ans)
else:
if len(pos) == 0:
ans... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF VAR NUMBER VAR VAR IF BIN_OP VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | n = int(input())
ai = list(map(int, input().split()))
ans = 0
for i in range(n):
if ai[i] > 0:
ans += ai[i]
if ans % 2 == 1:
print(ans)
else:
mini = 100000000
maxi = -1000000
for i in range(n):
if ai[i] > 0 and ai[i] % 2 == 1:
if mini > ai[i]:
mini = ai[i]... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER BIN_OP VA... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | n = int(input())
li = list(map(int, input().split()))
evensum, x, y = 0, 999999999, -999999999
for i in li:
if i > 0:
evensum += i
if i > 0 and i % 2 != 0:
x = min(x, i)
if i < 0 and i % 2 != 0:
y = max(y, i)
print(evensum if evensum % 2 != 0 else max(evensum - x, evensum + y)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR VAR IF VAR NUMBER VAR VAR IF VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | n = int(input().strip())
ints = list(map(int, input().strip().split()))
negative = -20000
positive = 20000
ans = 0
for item in ints:
if item > 0:
ans += item
if item % 2:
if item < 0:
negative = max(negative, item)
else:
positive = min(positive, item)
if ans % 2 =... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR VAR IF BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF BI... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | n = int(input())
a = list(map(int, input().split()))
res, lst = 0, []
for i, x in enumerate(a):
if x % 2 == 0:
if x > 0:
res += x
else:
lst.append(x)
lst.sort()
lst.reverse()
res, k = res + lst[0], 1
for i, x in enumerate(lst):
if i == 0:
continue
if x < 0:
if... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER LIST FOR VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER IF VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR VAR NUMBER NUMBER FO... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | n = int(input())
arr = list(map(int, input().split()))
o, e = -(10**8), -(10**8)
for i in range(n):
if i == 0 and arr[i] % 2:
o = arr[i]
elif i == 0 and arr[i] % 2 == 0:
e = arr[i]
elif arr[i] % 2 == 0:
if o != -(10**8):
o = max(o, arr[i] + o)
e = max(e, e + arr[i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP NUMBER NUMBER BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR IF VAR NUMBER BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR IF BIN_OP VAR ... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | input()
s = input()
nums = s.split()
n = len(nums)
a = [0] * n
odd = list()
res = 0
for i in range(n):
a[i] = int(nums[i])
if a[i] % 2 == 1:
odd.append(a[i])
else:
res += a[i] if a[i] > 0 else 0
odd.sort()
res += odd[-1]
for i in range(len(odd) - 2, 0, -2):
if odd[i] + odd[i - 1] > 0:
... | EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER VAR ... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(n):
if l[i] >= 0:
ans = ans + l[i]
if ans % 2 == 0:
o = 10**9
for i in range(n):
if abs(l[i]) % 2 == 1:
o = min(o, abs(l[i]))
print(ans - o)
else:
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR VAR VAR NUMB... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | n = int(input())
l = list(map(int, input().split()))
maxi = max(l)
if maxi < 0:
if abs(maxi) % 2 == 1:
print(maxi)
else:
mini = -(10**9)
for i in range(n):
if l[i] > mini and abs(l[i]) % 2 == 1:
mini = l[i]
print(max(maxi + mini, mini))
else:
odd =... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMB... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | n = int(input())
l = list(map(int, input().split()))
odd_pos = []
odd_neg = []
even_pos = []
even_neg = []
for i in range(len(l)):
if l[i] % 2 == 1 and l[i] > 0:
odd_pos.append(l[i])
elif l[i] % 2 == 0 and l[i] > 0:
even_pos.append(l[i])
elif l[i] % 2 == 1 and l[i] < 0:
odd_neg.appen... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER VAR ... |
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by de... | gi = lambda: list(map(int, input().strip().split()))
gi()
l = gi()
ev = sorted([e for e in l if e % 2 == 0 and e > 0])
od = sorted([e for e in l if e % 2 == 1])
ans = od.pop() + sum(ev)
if len(od) % 2 == 1:
od.remove(od[0])
while od and od[-2] > 0:
ans += od.pop() + od.pop()
if od and od[-1] + od[-2] > 0:
a... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP FUNC... |
A stowaway and a controller play the following game.
The train is represented by n wagons which are numbered with positive integers from 1 to n from the head to the tail. The stowaway and the controller are initially in some two different wagons. Every minute the train can be in one of two conditions — moving or idle... | n, z1, k1 = map(int, input().split())
z1 -= 1
k1 -= 1
s = input()
if s == "to head":
napr = -1
else:
napr = 1
s = input()
for i in range(len(s)):
if k1 == z1:
print("Controller", i)
exit(0)
if s[i] == "0":
if k1 > z1 and z1 != 0:
z1 -= 1
elif k1 < z1 and z1 !=... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR IF VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING VAR EXPR FUNC_CALL VAR NUMBER IF VAR VAR STRING IF VAR VAR V... |
A stowaway and a controller play the following game.
The train is represented by n wagons which are numbered with positive integers from 1 to n from the head to the tail. The stowaway and the controller are initially in some two different wagons. Every minute the train can be in one of two conditions — moving or idle... | n, m, k = list(map(int, input().split()))
a = {"to head": -1, "to tail": 1}[input()]
b = input()
l = len(b)
for i in range(l - 1):
if b[i] == "0":
if k + a == m or not 1 <= k + a <= n and k - a == m:
if (
1 <= m + a <= n
and 1 <= k + a <= n
or not ... | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT STRING STRING NUMBER NUMBER FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING IF BIN_OP VAR VAR VAR NUMBER BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR IF NUMBE... |
A stowaway and a controller play the following game.
The train is represented by n wagons which are numbered with positive integers from 1 to n from the head to the tail. The stowaway and the controller are initially in some two different wagons. Every minute the train can be in one of two conditions — moving or idle... | import sys
n, rider, cop = map(int, input().split())
rider, cop = rider - 1, cop - 1
if input().strip() == "to head":
cop_dir = -1
else:
cop_dir = 1
for pos, ch in enumerate(input().strip()):
if ch == "1":
rider = -1
elif cop_dir == -1 and rider < cop:
rider = max(0, rider - 1)
elif... | IMPORT ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR IF VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR NU... |
A stowaway and a controller play the following game.
The train is represented by n wagons which are numbered with positive integers from 1 to n from the head to the tail. The stowaway and the controller are initially in some two different wagons. Every minute the train can be in one of two conditions — moving or idle... | J = lambda: map(int, input().split())
v, y, z = J()
dir = "to tail" == input()
for t, x in enumerate(map(int, input())):
if z == 1:
dir = 1
elif z == v:
dir = 0
if not x:
y = min(v, y + 1) if z < y else max(1, y - 1)
else:
y = 1 if dir else v
z = z + 1 if dir else z -... | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR STRING FUNC_CALL VAR FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER IF VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR NUMBER ... |
A stowaway and a controller play the following game.
The train is represented by n wagons which are numbered with positive integers from 1 to n from the head to the tail. The stowaway and the controller are initially in some two different wagons. Every minute the train can be in one of two conditions — moving or idle... | from sys import exit, stdin, stdout
n, m, k = map(int, stdin.readline().split())
d = 1 if stdin.readline()[6] == "l" else -1
m = 1 if m < k else n
for i, c in enumerate(stdin.readline(), 1):
if c == "0":
if k == 1:
k, d = 2, 1
elif k == n:
k, d = n - 1, -1
else:
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER STRING NUMBER NUMBER ASSIGN VAR VAR VAR NUMBER VAR FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER IF VAR STRING IF VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER IF VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER NUMBER VAR VAR IF VAR VAR EX... |
A stowaway and a controller play the following game.
The train is represented by n wagons which are numbered with positive integers from 1 to n from the head to the tail. The stowaway and the controller are initially in some two different wagons. Every minute the train can be in one of two conditions — moving or idle... | n, p1, p2 = map(int, input().split())
s = input()
state = list(input())
l = len(state)
head = 1 if s == "to head" else 0
for i in range(l):
s = state[i]
if s == "0":
if head:
if p1 < p2:
if p1 > 1:
p1 -= 1
elif p2 < p1:
if p1 < ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR STRING NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR STRING IF VAR IF VAR VAR IF VAR NUMBER VAR NUMBER IF VAR VAR IF VAR VAR VAR NU... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | input_s = input().split(" ")
m = int(input_s[0])
s = int(input_s[1])
result_max = ""
result_min = ""
if m == 1 and s == 0:
print("0 0")
elif s == 0 or s > m * 9:
print("-1 -1")
else:
for index, i in enumerate(range(s // 9)):
result_max += "9"
result_min += "9"
if s % 9 != 0:
resu... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | def to_num(x):
if x[0] == "0":
for i in range(len(x)):
if x[i] != "0":
n0 = str(int(x[i]) - 1)
x = "1" + x[1:i] + n0 + x[i + 1 : len(x)]
break
if str(int(x)) == x:
return x
else:
return -1
m, s = map(int, input().split())
... | FUNC_DEF IF VAR NUMBER STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR VAR RETURN VAR RETURN NUMBER ASSIGN VA... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | x, y = map(int, input().split())
if x == 1 and y == 0:
print(0, 0)
exit()
if y > 9 * x or y == 0:
print(-1, -1)
else:
s = ""
t = []
while y >= 9:
s = s + "9"
y = y - 9
if len(s) != x:
s = s + str(y)
if len(s) != x:
while len(s) != x:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR IF VAR BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR STRING ASSIGN VAR LIST WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP VAR NUMBER IF FUNC_... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | input2 = input().split()
m, s = int(input2[0]), int(input2[1])
def digitsum(m, s):
if m == 1 and s == 0:
print(0, 0)
return
if s > 9 * m or s < 1:
print(-1, -1)
return
n9 = s // 9
r9 = s % 9
if n9 == 0:
print(10 ** (m - 1) + r9 - 1)
print(r9 * 10 ** ... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER FUNC_DEF IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER RETURN IF VAR BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER RETURN ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBE... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | m, s = input().split()
m, s = int(m), int(s)
if 9 * m < s or s == 0 and m != 1:
print(-1, -1)
else:
lis = [(0) for i in range(m)]
q = int(s // 9)
r = int(s % 9)
if s == 0:
print(0, 0)
elif m == 1 and s == 9:
print(9, 9)
elif m == 2 and s == 18:
print(99, 99)
elif ... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF BIN_OP NUMBER VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | def findmaxnum(a, b):
strmax = ""
strmin = ""
for i in range(a):
if b - 9 > 0:
strmax += "9"
b -= 9
else:
strmax += str(b)
if a - 1 - i > 0:
strmin = "1" + "0" * (a - i - 2)
for j in range(len(strmax)):
... | FUNC_DEF ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP STRING BIN_OP STRING BIN_OP BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR FUNC_CALL VA... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | m, s = map(int, input().split())
if s == 0:
if m == 1:
print(0, 0)
else:
print(-1, -1)
elif 9 * m < s:
print(-1, -1)
else:
ans = [0] * m
S = 0
for j in range(m - 1, -1, -1):
if S == s:
break
for i in range(9, -1, -1):
if S + i < s:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VA... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | m, s = map(int, input().split())
if s == 0 and m != 1:
print(-1, -1)
elif s > m * 9:
print(-1, -1)
elif m == 1:
print(s, s)
elif s < 10:
print(1 * 10 ** (m - 1) + (s - 1), s * 10 ** (m - 1))
else:
number, number2 = 0, 0
a = (s - 1) // 9
b = s // 9
for i in range(a):
number = numb... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER BI... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | m, s = list(map(int, input().split()))
s1 = s
s_init = s
a_max = []
a_min = m * [0]
p = 1
flag = 0
if s == 0 and m > 1 or s > 9 * m:
print(-1, -1)
flag = 1
else:
while s > 9:
a_max.append(9)
s -= 9
if s <= 9:
a_max.append(s)
s -= s
while len(a_max) != m:
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP VAR LIST NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER EXPR FUNC_CALL VAR... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | m, s = map(int, input().split())
if m == 1:
l = 0
else:
l = 1
r = 9 * m
if not l <= s <= r:
print(-1, -1)
else:
if m > 1:
num_min = [1] + [(0) for i in range(m - 1)]
else:
num_min = [0]
num_max = [(9) for i in range(m)]
x = (r - s) // 9
for i in range(m - x, m):
n... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR IF VAR VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER VAR FUNC... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | m, s = map(int, input().split())
maxi = 0
t1 = m
t2 = s
a = []
while t1 > 0:
if t2 == 0:
maxi *= 10
a.append(0)
else:
temp = min(9, t2)
maxi = maxi * 10 + temp
a.append(temp)
t2 -= temp
t1 -= 1
a.reverse()
i = 0
while i < m:
if a[i] != 0:
break
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST WHILE VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CAL... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | m, s = [int(i) for i in input().split()]
if m > 1 and s == 0:
print("-1 -1")
elif m == 1 and s == 0:
print("0 0")
elif m * 9 < s:
print("-1 -1")
elif m == 1:
print(s, s)
else:
k = max(s - (m - 1) * 9, 1)
print(k, end="")
n9 = (s - k) // 9
r9 = (s - k) % 9
n0 = m - n9 - 2
if n0 > ... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMB... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | m, s = list(map(int, input().split()))
if m == 1 and s < 10:
print(s, s)
elif 1 <= m <= 100 and 0 <= s <= 900 and m * 9 >= s and not (m > 1 and s == 0):
max, min = ["0"] * m, []
for i in range(m):
if s >= 9:
max[i] = "9"
min.append("9")
s -= 9
else:
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF NUMBER VAR NUMBER NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR BIN_OP LIST STRING VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR STRING EXPR FUNC... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | l, s = map(int, input().split())
if s == 0 and l == 1:
print(0, 0)
elif s < 1 or 9 * l < s:
print(-1, -1)
else:
a = [0] * l
b = [0] * l
m = s
for q in range(l):
if s >= 9:
a[q] = 9
s -= 9
else:
a[q] = s
s = 0
s = m
j = 0
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VA... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | m, s = list(map(int, input().split()))
def find_min(m, s):
result = []
s -= 1
for k in range(m):
if s >= 9:
result.append(9)
s -= 9
else:
result.append(s % 9)
s -= s % 9
result[-1] += 1
return "".join(list(map(str, reversed(result))))... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER NUMBER RETURN FUNC_CALL STRING FUNC_CALL VAR FUNC_CALL VAR VAR FUN... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | m, s = map(int, input().split())
mn = mx = []
if s == 0 and m == 1:
print(2 * "0 ")
exit()
if s == 0 or 9 * m < s:
print(2 * "-1 ")
exit()
for _ in range(m):
if s >= 9:
mx.append(9)
s -= 9
else:
mx.append(s)
s = 0
mn = mx[::-1]
if not mn[0]:
mn[next((i for i, ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER STRING EXPR FUNC_CALL VAR IF VAR NUMBER BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR BIN_OP NUMBER STRING EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBE... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | n = input().split()
min = ""
max = ""
if int(n[0]) == 1 and int(n[1]) == 0:
print(0, 0)
elif int(n[1]) == 0 or int(n[0]) * 9 < int(n[1]):
print(-1, -1)
elif int(n[1]) == 9 * int(n[0]):
print("9" * int(n[0]), "9" * int(n[0]))
else:
a = int(n[1]) // 9
b = int(n[1]) - 9 * a
c = int(n[0]) - a - 1
... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING IF FUNC_CALL VAR VAR NUMBER NUMBER FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF FUNC_CALL VAR VAR NUMBER NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF FUNC_CALL VAR ... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | def find_length_sum_digits(m, s):
if m * 9 < s or s == 0 and m != 1:
return "-1 -1"
digits = []
length = m - 1
while length != 0:
for i in range(9, -1, -1):
if 1 <= s - i <= 9 * length:
s -= i
digits.insert(0, str(i))
break
... | FUNC_DEF IF BIN_OP VAR NUMBER VAR VAR NUMBER VAR NUMBER RETURN STRING ASSIGN VAR LIST ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF NUMBER BIN_OP VAR VAR BIN_OP NUMBER VAR VAR VAR EXPR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER FUNC_CALL VAR... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | m, s = map(int, input().split())
a = s
b = s
c = []
d = []
f = []
if s == 0 and m == 1:
print("0 " * 2)
elif 9 * m < s or s == 0:
print("-1 " * 2)
else:
while b > 0:
d.append(min(b, 9))
b -= min(b, 9)
d.reverse()
if len(d) == m:
print(*d, sep="", end=" ")
elif len(d) == 1... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP STRING NUMBER IF BIN_OP NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP STRING NUMBER WHILE VAR NUMBER EXPR FUNC_CALL VAR FUNC_CAL... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | q, w = map(int, input().split())
r = 9 * q - w
if q == 1 and w == 0:
print("0 0")
elif r < 0 or w == 0:
print("-1 -1")
else:
t = "9" * (q - r // 9 - 1) + str(9 - r % 9) + "0" * (r // 9)
if r // 9 > 0:
if 9 - r % 9 > 0:
e = "1" + "0" * (r // 9 - 1) + str(9 - r % 9 - 1) + "9" * (q - r ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR BIN_OP NUMBER BIN_OP VAR ... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | n, s = map(int, input().split())
r = ""
s1 = s
if s == 0 and n == 1:
print("0" * n, "0" * n)
elif s == 0:
print("-1 -1")
else:
while s > 0:
a = min(s, 9)
s = s - a
r = r + str(a)
if len(r) > n:
r = -1
else:
z = n - len(r)
r = r + "0" * z
if r[0... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP STRING VAR BIN_OP STRING VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | n, k = map(int, input().split())
if n != 1 and k == 0 or k > 9 * n:
print("-1 -1")
else:
p = k // 9
r = k % 9
u = "0" * n
x = u
su = 0
i = n - 1
while su != k:
if su < k:
x = k - su
if x < 9:
u = u[:i] + str(x) + u[i + 1 :]
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR IF VAR VAR ASSIGN VAR BIN_O... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | import sys
def main():
number = []
m, s = map(int, input().split())
if s > 9 * m:
print("-1 -1")
return
i = 9
_len = m
while m != 0 and i > -1:
if s - i > -1:
m -= 1
s -= i
number.append(i)
i = 9
else:
... | IMPORT FUNC_DEF ASSIGN VAR LIST ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR NUMBER VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBER IF FUNC_CALL VAR... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | m, s = map(int, input().split())
a = [(0) for i in range(m)]
pt = s
for x in range(m):
if s >= 10:
a[x] = 9
s -= 9
elif s == 0:
break
else:
a[x] = s
s = 0
dn, an = [int(p) for p in a], [int(p) for p in a]
dn.sort(reverse=True)
an.sort()
if an[0] == 0:
for q in ran... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VA... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | n, s = map(int, input().split())
if n > 1 and s == 0 or s > 9 * n:
print(-1, -1)
elif n == 1 and s == 0:
print(0, 0)
else:
l = [0] * (n - 1) + [1]
x = 0
while sum(l) < s:
if l[x] == 9:
x += 1
l[x] += 1
l2 = [9] * n
x = 0
while sum(l2) > s:
if l2[x] == ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP LIST NUMBER BIN_OP VAR NUMBER LIST NUMBER ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR VAR IF VAR VAR N... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | a = [int(i) for i in input().split()]
m = a[0]
s = a[1]
h = [0] * m
x = 0
for d in range(m):
for i in range(1, 10):
if x < s:
h[d] = h[d] + 1
x = x + 1
x = 0
q = [0] * m
q[0] = 1
x = 1
for d in range(m - 1, -1, -1):
for i in range(1, 10):
if x < s:
q[d] = q[d]... | ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | m, s = map(int, input().split())
if s == 0 and m == 1:
print(0, 0)
elif s == 0 or s > 9 * m:
print(-1, -1)
else:
final_max = ""
temp = s
for j in range(m):
for k in range(9, -1, -1):
if temp - k >= 0:
temp -= k
final_max += str(k)
b... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR STRING ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP VAR VAR NUMBER VAR VAR V... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | a = input()
m = int(a.split()[0])
s = int(a.split()[1])
if s == 0 and m > 1 or 9 * m < s:
print(-1, -1)
elif s == 0 and m == 1:
print(0, 0)
else:
list1 = []
temp1 = s
while temp1 > 9:
temp1 -= 9
list1.append("9")
list1.append(str(temp1))
while len(list1) < m:
list1.ap... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR VAR WHILE VAR NUMBER VAR NUMBER EXPR F... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | m, s = [int(i) for i in input().split()]
if m == 1 and s == 0:
print("0 0")
elif s == 0 or 9 * m < s:
print("-1 -1")
else:
x = s // 9
y = s % 9
if y == 0:
y = 9
x -= 1
big = "9" * x + str(y) + "0" * (m - x - 1)
if x + 1 == m:
small = str(y) + "9" * x
else:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING VAR FU... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | m, s = map(int, input().split())
ans_min = 0
ans_max = 0
if s == 0 and m == 1:
print("0 0")
elif s > 9 * m or s == 0:
print("-1 -1")
else:
ans = 0
ans = 10 ** (m - 1)
for i in range(s - 1):
ans += 10 ** (i // 9)
ans_min = ans
ans = 0
for i in range(s):
ans += 10 ** (m - 1... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP NU... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | [a, b] = map(int, input().split())
if a == 1 and b == 0:
print(0, 0)
elif b > 9 * a or b == 0:
print(-1, -1)
else:
c = (b - 1) // 9
if c == a - 1:
d = b - 9 * c
print(str(d) + c * "9", c * "9" + str(d))
elif c == 0:
d = b - 1
print("1" + (a - 2) * "0" + str(d), str(d ... | ASSIGN LIST VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | m, s = map(int, input().split())
max_ = 0
min_ = 0
if m > 1:
if s > 9 * m or s == 0:
print("-1 -1")
else:
i = 0
while s > 9 * i:
i += 1
a = s - 9 * (i - 1)
stra = str(a)
string = "9" * (i - 1) + stra + "0" * (m - i)
max_ = string
if s =... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF VAR BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER WHILE VAR BIN_OP NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR ... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | def f(m, s):
a, b = divmod(s, 9)
res = "9" * a
if b:
res += str(b) + "0" * (m - a - 1)
else:
res += "0" * (m - a)
return res
m, s = map(int, input().split())
if m == 1 and s == 0:
print(0, 0)
exit()
if 9 * m >= s > 0:
a, b = divmod(s, 9)
if m - a > 1:
print(... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP STRING VAR IF VAR VAR BIN_OP FUNC_CALL VAR VAR BIN_OP STRING BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP STRING BIN_OP VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | m, n = list(map(int, input().split()))
s1 = n
s2 = n
l = 9
m1 = [0] * m
m2 = [0] * m
if n > int(9 * m) or n == 0 and m != 1:
print(-1, -1)
else:
for i in range(m):
if s1 >= 9:
m2[i] = 9
s1 -= 9
else:
m2[i] = s1
break
for j in range(m - 1, -1, -... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR IF VAR FUNC_CALL VAR BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | m, s = [int(i) for i in input().split()]
if s > 9 * m or s < 1 and m > 1:
print(-1, -1)
exit()
if s == 0 and m == 1:
print("0 0")
exit()
min1 = []
max1 = []
k = s
for i in range(m):
if k - (i + 1) * 9 > 0:
min1.append(9)
else:
min1.append(max(0, k - i * 9))
if i < m - 1 a... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR BIN... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | x = input()
m, s = list(map(int, x.strip().split()))
smallest = [(0) for _ in range(m)]
smallest[0] = 1
vsota_s = 1
i = len(smallest) - 1
while vsota_s < s and i >= 0:
if s - vsota_s <= 9 - smallest[i]:
smallest[i] = s - vsota_s + smallest[i]
vsota_s += s - vsota_s
i = i - 1
break
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR VAR NUMBER IF BIN_OP VAR VAR BIN_OP NUMBER VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR ... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | m, s = [int(x) for x in input().split()]
mindsum = 1
maxdsum = 9 * m
if m == 1 and s == 0:
print(0, 0)
elif s < mindsum or s > maxdsum:
print(-1, -1)
else:
mncount = s // 9
mrest = s % 9
if mncount == m:
mnum = "9" * m
elif mncount == m - 1:
if mrest == 0:
mnum = "1" ... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP STRING VAR IF V... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | n, m = map(int, input().split())
if n == 1:
if m > 9 or m < 0:
print("-1 -1")
else:
print(m, m)
if (m < 1 or m > n * 9) and n > 1:
print("-1 -1")
elif n > 1:
u = m
small = [0] * n
large = [0] * n
x = 0
while m // 9 > 0:
m -= 9
large[x] = 9
x += 1
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR A... |
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
-----Input-----
The single line of the input co... | def solve():
m, s = map(int, input().split())
if s == 0 and m == 1:
print(0, 0)
return
s_copy = s
largestNo = [0] * m
i = 0
while i < m and s > 0:
largestNo[i] += min(9, s)
s -= min(9, s)
i += 1
if s != 0 or s_copy == 0:
print(-1, -1)
r... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER RETURN ASSIGN VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER VAR VAR FUNC_CALL VAR NUMBER VAR VAR FUNC_CALL VAR NUMBER VAR VAR NUMBER IF VAR NUMBER VAR NUMBER... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.