description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
def main(): n = int(input()) num = int(input()) string = str(num) if n % 2: half = n // 2 if string[half] == "0": i = half - 1 j = half + 1 while i >= 0 and string[i] == "0": i -= 1 while j < n and string[j] == "0": ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR VAR STRING VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NU...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
from sys import stdin, stdout l = int(stdin.readline()) s = stdin.readline() mn = int(-1) sum = int() i = l // 2 while 0 < i and i < l: if s[i] == "0": i += 1 continue a = int(s[:i]) b = int(s[i:]) sum = a + b if mn == -1 or mn > sum: mn = sum else: break i +...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE NUMBER VAR VAR VAR IF VAR VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR VAR AS...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
len = int(input()) s = input() ans = int(s) for i in range((len - 1) // 2, 0, -1): if s[i] != "0": ans = min(ans, int(s[:i]) + int(s[i:])) break for i in range(len // 2 + 1, len): if s[i] != "0": ans = min(ans, int(s[:i]) + int(s[i:])) break if len % 2 == 0 and s[len // 2] != "0"...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER NUMBER IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR IF ...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
k = int(input()) p = input() if k % 2 == 0: m = int(k // 2) c = m d = m if int(p[m]) == 0: while c <= k - 1: if int(p[c]) != 0: break c += 1 while int(p[d]) == 0: d -= 1 if c == k: print(int(p[:d]) + int(p[d:])) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR IF FUNC_CALL VAR VAR VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER WHILE FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER IF VAR...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
l = int(input()) n = str(input()) m = l // 2 while n[m] == "0": m -= 1 x = int(n[0:m]) + int(n[m:l]) if m > 0 else int(n) m = (l + 1) // 2 while m < l and n[m] == "0": m += 1 if m < l: x = min([x, int(n[0:m]) + int(n[m:l])]) print(x)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR STRING VAR NUMBER ASSIGN VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER WHILE VAR VAR VAR VAR STRING VAR NUM...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = int(input()) s = input() res = int(s) center = int(n / 2) q1 = s[:center] q2 = s[center:] if q2[0] != "0": res = min(res, int(q1) + int(q2)) else: while s[center] == "0" and center < n - 1: center += 1 q1 = s[:center] q2 = s[center:] if q2[0] != "0": res = min(res, int(q1) + int(...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR IF VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR WHILE VAR VAR STRING VAR BIN_OP VAR NUMBER VAR NUMBER...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
import sys n = int(sys.stdin.readline(40)) buff = sys.stdin.readline(n) length = len(buff) maxlen = 100005 ans = 1e1000 minList = [] for i in range(1, length): if buff[i] != "0": tmp = max(i, length - i) + 1 if tmp < maxlen: minList = [i] maxlen = tmp elif tmp == max...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR LIST VAR ASSIGN VAR VAR IF...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
def main(): length = int(input("")) number = input("") sol = half(number, length, 0, 0) if sol != None: print(int(sol[0]) + int(sol[1])) def half(number, length, target, i): if target == 0: target = length // 2 fHalf = number[:target] lHalf = number[target:] while lHalf...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER IF VAR NONE EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER FUNC_DEF IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR WHILE VA...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = int(input()) num = input() upperInd = n // 2 while num[upperInd : upperInd + 1] == "0": upperInd -= 1 if upperInd == 0: moveUp = int(num) else: moveUp = int(num[0:upperInd]) + int(num[upperInd:n]) lowerInd = n - n // 2 while lowerInd < n and num[lowerInd : lowerInd + 1] == "0": lowerInd += 1 if lowe...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR VAR...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = int(input()) s = input() print( min( int(s[:i]) + int(s[i:]) for i in sorted( (i for i in range(1, n) if s[i] != "0"), key=lambda i: abs(i - n / 2) )[:4] ) )
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER VAR VAR VAR STRING FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
l = int(input()) s = input() ans = int(s) for i in range(max(1, l // 2 - 2), l): if s[i] != "0": ans = min(ans, int(s[:i]) + int(s[i:])) if i >= l // 2 + 2: break for i in range(min(l - 1, l // 2 + 2), 0, -1): if s[i] != "0": ans = min(ans, int(s[:i]) + int(s[i:])) if...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER VAR IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR BIN_OP BIN_OP VAR NUMBER NUMBER FOR VAR FUN...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = int(input()) m = input() mi = 100001 for i in range(1, n): if m[i] != "0": mi = min(mi, max(i, n - i) - min(i, n - i)) res = -1 for i in range(1, n): if m[i] != "0" and mi == max(i, n - i) - min(i, n - i): if res == -1: res = int(m[:i]) + int(m[i:]) else: res ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING VAR BIN_OP FUNC_...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
l = int(input()) n = int(input()) min_sum = -1 n_str = str(n) l = len(n_str) // 2 r = (len(n_str) + 1) // 2 while True: if n_str[l] == "0" and n_str[r] == "0": l -= 1 r += 1 continue elif n_str[l] != "0" and n_str[r] != "0": a = int(n_str[:l]) + int(n_str[l:]) b = int(n_s...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER WHILE NUMBER IF VAR VAR STRING VAR VAR STRING VAR NUMBER VAR NUMBER IF VAR VAR STRING VAR VAR S...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
import sys input = sys.stdin.readline def calc(s, i): p1 = s[:i] p2 = s[i:] return int(p1) + int(p2) n = int(input()) s = input().strip() if n == 2: print(int(s[0]) + int(s[1])) else: res = int(s) cnt = 0 for i in range((n - 1) // 2, 0, -1): if s[i] != "0": res = min...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN V...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
l = int(input()) num = input() pos = l // 2 ans = -1 c = 0 while pos >= 0 and c < 2: if pos + 1 < l and num[pos + 1] != "0": if ans == -1: ans = int(num[: pos + 1]) + int(num[pos + 1 :]) else: ans = min(ans, int(num[: pos + 1]) + int(num[pos + 1 :])) c += 1 pos -=...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER STRING IF VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIG...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
L = int(input()) S = input() x1, x2 = int(L / 2), int((L + 1) / 2) ans = 10**100005 while True: flag = False if S[x1] != "0": flag = True s1 = int(S[:x1]) s2 = int(S[x1:]) ans = min(ans, s1 + s2) if S[x2] != "0": flag = True s1 = int(S[:x2]) s2 = int(S...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER WHILE NUMBER ASSIGN VAR NUMBER IF VAR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VA...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
l = int(input()) n = input() res = 0 mn = int(n) find = False for i in range(l // 2, l): if find and i > l // 2 + 3: break if n[i] != "0": mn = min(mn, int(n[:i]) + int(n[i:])) find = True for i in range(l // 2, 0, -1): if n[i] != "0": mn = min(mn, int(n[:i]) + int(n[i:])) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
p = int(input()) n = int(input()) s = str(n) c = n k = p // 2 while k < p and s[k] == "0": k += 1 if k < p: y = int(s[k:]) x = int(s[:k]) c = min(c, x + y) k = p // 2 k += 1 while k < p and s[k] == "0": k += 1 if k < p: y = int(s[k:]) x = int(s[:k]) c = min(c, x + y) k = p // 2 k -= 1 wh...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN V...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = int(input()) x = input() num = x[n // 2] num2 = x[(n + 1) // 2] ans = -1 if num == "0": p = n // 2 k = p while p >= 0 and x[p] == "0": p -= 1 while k < n and x[k] == "0": k += 1 n1 = 0 if len(x[:p]) > 0: n1 = int(x[:p]) n2 = 0 if len(x[p:]) > 0: n2 = i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER VAR VAR STRING VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER ASSIGN VAR NUMBER...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = int(input()) s = input() res = int(s) for i in range(-1, 2): mid = n // 2 + i while mid > 0 and mid < n and s[mid] == "0": mid += -1 if i < 0 else 1 if mid > 0 and mid < n: res = min(res, int(s[:mid]) + int(s[mid:])) print(res)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR WHILE VAR NUMBER VAR VAR VAR VAR STRING VAR VAR NUMBER NUMBER NUMBER IF VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR VAR FU...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
l = int(input()) n = input() minx = int(n) for i in {l // 2 - 1, l // 2, l // 2 + 1, l // 2 + 2}: if n[:i] != "" and n[i:] != "" and n[i:][0] != "0": minx = min(minx, int(n[:i]) + int(n[i:])) for i in range(l // 2, -1, -1): if n[:i] != "" and n[i:] != "": if n[i] != "0": minx = min(m...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR VAR STRING VAR VAR STRING VAR VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR ...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
l = int(input()) n = input() index1 = l // 2 index2 = l // 2 if not l % 2 else l // 2 + 1 while True: num1 = n[:index1] num2 = n[index1:] num3 = n[:index2] num4 = n[index2:] if num1[0] == "0" or num2[0] == "0": if num3[0] == "0" or num4[0] == "0": index1 -= 1 index2 +...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER WHILE NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR IF VAR NUMBER STRING VAR NUMBER STRING IF VAR NUMBER STRING...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = int(input()) s = input() a = int(s) s = list(s) tt = 10 ** max(0, n // 2 - 2) ans = a for i in range(max(0, n // 2 - 2), min(n, n // 2 + 3)): a1 = a // tt a2 = a % tt if a2 * 10 // tt > 0: ans = min(ans, a1 + a2) tt *= 10 s.reverse() if ans == a: i = n // 2 while i <= len(s) and s[i ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR VAR BIN_OP BIN_O...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = int(input()) s = input() dt = [n + 10] * n for i in range(n): if i > 0 and s[i] != "0": dt[i] = max([i, n - i]) mn = min(dt) ans = int(s) for i in range(n): if dt[i] == mn: ans = min([ans, int(s[:i]) + int(s[i:])]) print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR STRING ASSIGN VAR VAR FUNC_CALL VAR LIST VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSI...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
import sys def IO(): import sys sys.stdout = open("output.txt", "w") sys.stdin = open("input.txt", "r") def main(): l = int(input()) n = str(input()) i = l // 2 - 1 lidx = -1 while i >= 0: if n[i + 1] != "0": lidx = i break i -= 1 ridx = l...
IMPORT FUNC_DEF IMPORT ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR STRING STRING FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR VAR NUM...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
def ab(n, p, q): ans = -1 x = min(len(p), len(q)) if q[0] != "0": ans = int(p) + int(q) return ans for i in range(x - 1): if p[len(p) - i - 1] != "0" and q[i + 1] != "0": return min( int(p[: len(p) - 1 - i]) + int(p[len(p) - 1 - i :] + q), ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING RETURN FUNC_CALL VAR...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
l = int(input()) a = input() check = [] for i in range(l - 1): if a[i + 1] != "0": check.append([abs(i + 1 - (l - i - 1)), i]) check.sort() ans = -1 d = check[0][0] for i in check: if i[0] != d: break if ans == -1: ans = int(a[: i[1] + 1]) + int(a[i[1] + 1 :]) else: ans =...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR LIST FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VA...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = int(input()) s = str(input()) ans = int(s) mid = n // 2 if n % 2 == 0: mid -= 1 c = int(s[mid]) d = int(s[mid + 1]) if c != 0 or d != 0: if c != 0 and mid > 0: ans = int(s[:mid]) + int(s[mid:n]) if d != 0 and mid + 1 < n: tmp = int(s[: mid + 1]) + int(s[mid + 1 : n]) ans = min(an...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = int(input()) s = str(input()) sLen = len(s) def getSum(ss, cut): num1 = int(ss[0 : int(cut)]) num2 = int(ss[cut:]) ans = num1 + num2 return ans split1 = -1 for i in range(int(sLen / 2) - 1, -1, -1): if s[i + 1] != "0": split1 = i + 1 break split2 = -1 for i in range(int(sLen ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR RETURN VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER N...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
import sys inp = sys.stdin.readlines() a = int(inp[0].strip()) numb = str(inp[1].strip()) mind = len(numb) n = len(numb) lst = [] for i in range(1, n): if not numb[i] == "0": mind = min(mind, max(i, n - i)) mind += 1 for i in range(1, n): if max(i, n - i) <= mind: if not numb[i] == "0": ...
IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR NUMBE...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
length = int(input()) number = list(filter(lambda x: x, input())) def make_num(tab): if tab: return int("".join(tab) if tab else "0") if tab[0] != "0" else float("inf") return 0 def solve(number, n): current_min = float("inf") for index_right, digit_right in enumerate(number[n // 2 :]): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_DEF IF VAR RETURN VAR NUMBER STRING FUNC_CALL VAR VAR FUNC_CALL STRING VAR STRING FUNC_CALL VAR STRING RETURN NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING FOR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR STRING...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = int(input()) l = str(input()) def summ(l1, l2): l1.reverse() l2.reverse() n_ = max(len(l1), len(l2)) k = n_ - min(len(l1), len(l2)) l1.extend(["0"] * k) l2.extend(["0"] * k) l3 = [] re = 0 for i in range(n_): x = int(l1[i]) + int(l2[i]) + re l3.append(x % 10) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP LIST STRING VAR EXPR FUNC_CALL VAR B...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
l = int(input()) n_str = input() foundr = 0 foundl = 0 ans = int(n_str) for i in range(l // 2, l): if n_str[i] == "0": continue elif foundr == 0: foundr = 1 ans = int(n_str[0:i]) + int(n_str[i:l]) else: ans = min(ans, int(n_str[0:i]) + int(n_str[i:l])) foundr = foundr...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR STRING IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = int(input()) s = input() h = (n + 1) // 2 ans = pow(10, 100000) + 9 for i in range(h, n): if s[i] != "0": ans = min(ans, int(s[:i]) + int(s[i:])) break for i in range(h, 0, -1): if s[i] != "0": ans = min(ans, int(s[:i]) + int(s[i:])) break h -= 1 if h > 0: for i in range(...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR NUMBER...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
L = int(input()) n = str(input()) def breakleft(n, split): for i in range(split): if n[split - i] != "0": return int(n[: split - i]) + int(n[split - i :]) return int(n) def breakright(n, split): global L for i in range(L - split): if n[split + i] != "0": retur...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR VAR STRING RETURN BIN_OP FUNC_CALL VAR VAR BIN_OP VAR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR RETURN FUNC_CALL VAR VAR FUNC_DEF FOR VAR FUNC_CALL VAR BIN_OP VAR VAR IF VAR BIN_OP VAR VAR STRIN...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = int(input()) a = str(input()) if n == 1: print(a) else: b, c = 0, 0 res = 1e1000 pos1 = int(n / 2) pos2 = int(n / 2) pos3 = int(n / 2) + 1 pos4 = int(n / 2) - 1 while pos1 < n and a[pos1] == "0": pos1 += 1 while pos3 < n and a[pos3] == "0": pos3 += 1 while pos...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = int(input()) s = input() resp = 10 ** (n + 1) cnt = 0 for i in range(n // 2, 0, -1): if s[i] != "0": cnt += 1 s2 = s[:i] s3 = s[i:] if len(s2) >= 1 and len(s3) >= 1: resp = min(resp, int(s2) + int(s3)) if cnt == 2: break cnt = 0 for i in range(n // 2, n): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR STRING VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL ...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = eval(input()) s = input() l = n // 2 Sum = 0 kk = 1 for i in range(l, n): if s[i] != "0": if Sum == 0: Sum = int(s[i:]) + int(s[0:i]) else: Sum = min(Sum, int(s[i:]) + int(s[0:i])) kk += 1 if kk == 3: break kk = 1 for i in range(l, 0, -1): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR IF VAR VAR STRING IF VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR VAR FU...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = int(input()) s = input() inn = -1 ind = -1 for i in range(n // 2, -1, -1): if s[i] != "0": inn = i break for i in range(n // 2 + 1, n): if s[i] != "0": ind = i break if inn > 0 and ind < n and inn != -1 and ind != -1: ans = min(int(s[:inn]) + int(s[inn:]), int(s[:ind]) + ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR STRING ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR IF VAR VAR STRING ASSIGN VAR VAR IF VAR NUMBER VAR VAR VAR NUMBER VAR NUMBE...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = int(input()) s = input() p = len(s) // 2 i, j = 1, 0 while p + i < len(s) and s[p + i] == "0": i += 1 while p - j >= 0 and s[p - j] == "0": j += 1 s1, s2 = s[: i + p], s[i + p :] s3, s4 = s[: p - j], s[p - j :] n1, n2 = 0, 0 if s1 != "": n1 += int(s1) if s2 != "": n1 += int(s2) if s3 != "": n2 +...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER WHILE BIN_OP VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR STRING VAR NUMBER WHILE BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR STRING VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR VAR VAR BIN_O...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = int(input()) s = input() i1 = n // 2 i2 = i1 + 1 while i1 > 0 and s[i1] == "0": i1 -= 1 while i2 < n and s[i2] == "0": i2 += 1 if i1 == 0: print(int(s[0:i2]) + int(s[i2:n])) elif i2 == n: print(int(s[0:i1]) + int(s[i1:n])) else: s1 = int(s[0:i1]) s2 = int(s[0:i2]) p1 = int(s[i1:n]) p...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR VAR STRING VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR EXPR FUNC...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
def sum(str, i): if i <= 0 or i == len(str): return int(str) return int(str[0:i]) + int(str[i : len(str)]) def main(): n = int(input()) str = input() middle = int(len(str) / 2) result = int(str) for i in range(middle, -1, -1): if str[i] != "0": result = min(resu...
FUNC_DEF IF VAR NUMBER VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR VAR RETURN BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR ...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
def spt(s, lLen): a = int(n[0:lLen]) b = int(n[lLen:]) return a + b l = int(input()) n = input() half = l // 2 for lLen in range(half, l): temp1 = -1 temp2 = -1 if n[lLen] != "0": temp1 = spt(n, lLen) if n[l - lLen] != "0": temp2 = spt(n, l - lLen) if temp1 != -1 and te...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
def main(): n = int(input()) a = input() b = [] for i in range(1, n): if a[i] != "0": b.append(max(i, n - i)) b.sort() ans = float("inf") for i in b[0 : min(len(b), 5)]: if a[i] != "0": ans = min(ans, int(a[0:i]) + int(a[i:n])) if a[n - i] != "...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING A...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
from sys import stdin input = stdin.readline n = int(input()) s = input() m = 10**10**5 p = [] for i in range(n // 2, 0, -1): if s[i] == "0": continue p.append(i) break for i in range(n // 2 + 1, n): if s[i] == "0": continue p.append(i) break for i in p: m = min(m, int(s[i:]...
ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR STRING EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR IF VAR VAR STRING EXPR FUN...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
m = int(input()) n = input() l = m // 2 while l > 0 and n[l] == "0": l -= 1 r = m // 2 + 1 while r < m and n[r] == "0": r += 1 a = None if r < m: a = int(n[:r]) + int(n[r:]) b = None if l > 0: b = int(n[:l]) + int(n[l:]) if a and b: print(min(a, b)) else: print(a or b)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER ASSIGN VAR NONE IF VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR N...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
l = int(input()) number = str(input()) def sum(a, b): result = [0] * (max(len(a), len(b)) + 1) memory = 0 for i in range(1, max(len(a), len(b)) + 1): current = memory memory = 0 if i <= len(a): current += int(a[-i]) if i <= len(b): current += int(b[-...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NU...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
l = int(input()) s = input() mid = l // 2 endfrom0 = mid + 1 beginforend = mid - 1 def so(i): if i == 0 or i == l: return int(s) return int(s[0:i]) + int(s[i:l]) while endfrom0 < l and s[endfrom0] == "0": endfrom0 += 1 while beginforend > -1 and s[beginforend] == "0": beginforend -= 1 if s[m...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FUNC_DEF IF VAR NUMBER VAR VAR RETURN FUNC_CALL VAR VAR RETURN BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR WHILE VAR VAR VAR VAR STRING VAR NUMBER WHIL...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
L = int(input()) S = input() arr = [] for i in range(1, L): if S[i] != "0": arr.append((abs(L - i - i), i)) arr.sort() if len(arr) >= 2: print( min( [ int(S[: arr[0][1]]) + int(S[arr[0][1] :]), int(S[: arr[1][1]]) + int(S[arr[1][1] :]), ] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR LIST BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBE...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
len = int(input()) str = input() mid = len // 2 - 1 ans = int(str) lcnt = 2 for i in range(mid, -1, -1): if str[i + 1] != "0": sum = int(str[: i + 1]) + int(str[i + 1 :]) if sum < ans: ans = sum lcnt -= 1 if lcnt == 0: break rcnt = 2 for i in range(mid + 1, le...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF V...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
l = int(input()) n = input() ans = int("1" + "0" * 10**5) if l % 2 == 0: k = l // 2 left = k while n[left] == "0": left -= 1 right = k while right < l and n[right] == "0": right += 1 if left > 0: ans = min(int(n[:left]) + int(n[left:]), ans) if right < l: ans ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP STRING BIN_OP STRING BIN_OP NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR STRING VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR VAR VAR STRING VAR NUMBER IF VAR NUMBER ASSIGN VA...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = int(input()) s = input() result = int(s) mid = int(n / 2) count = 0 i = 0 while count < 4: index = mid + i if index > n - 1: break if s[index] != "0": result = min(int(s[:index]) + int(s[index:]), result) count += 1 index2 = mid - i if index2 > 0 and s[index2] != "0": ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR BIN_OP VAR NUMBER IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CAL...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
l = int(input()) S = input() pos = l // 2 res = int(S) if pos != 0 and S[pos] != "0": left = int(S[0:pos:1]) right = int(S[pos:]) res = left + right pos = l // 2 - 1 while pos > 0: if S[pos] == "0": pos -= 1 else: left = int(S[0:pos:1]) right = int(S[pos:]) res = min(...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER WHILE VAR NUMBER IF ...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = int(input()) s = input() mv = n + 1 for i in range(1, n): if s[i] != "0": mv = min(mv, max(i, n - i)) lst = [] for i in range(1, n): if s[i] != "0": l = max(i, n - i) if l == mv or l == mv + 1: lst.append(i) res = int(s) for i in lst: a = int(s[0:i]) b = int(s[i:n...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR IF ...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
L = int(input()) n = input() ans = int(n) def v(k): if k[0] == "0": return False return True if L % 2 == 0: for i in range(L // 2): split1 = L // 2 + i split2 = L // 2 - i if n[split1] != "0": sum1 = int(n[:split1]) + int(n[split1:]) if ans > sum1:...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF IF VAR NUMBER STRING RETURN NUMBER RETURN NUMBER IF BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR IF VAR VAR STRING ASS...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = int(input()) s = input() best = [] b = 10**9 for i in range(n - 1): if s[i + 1] == "0": continue x = max(i + 1, n - i - 1) if x < b: best = [] b = x if x == b: best.append(i + 1) res = int(s) for i in best: res = min(res, int(s[0:i]) + int(s[i:])) print(res)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR LIST ASSIGN VAR VAR IF VAR VAR EXPR FUNC_C...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = int(input()) y = input() pek = int def int(x): if x == "": return 0 else: return pek(x) if n % 2 == 0: mul1 = 0 mul2 = n - 1 for i in range(n // 2, n): mul1 = i if y[i] == "0": continue else: break for i in range(n // 2 - 1,...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_DEF IF VAR STRING RETURN NUMBER RETURN FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR IF VAR VAR STRING FOR VAR FUNC_CALL VAR BIN_O...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = int(input()) x = input() ans = -1 options = [] for i in range(len(x)): if x[i] != "0": options.append(i) start = len(options) - 1 for i in range(len(options)): if options[i] >= n // 2: start = i break for i in range(3): for ind in [start + i, start - i]: if ind < 0 or ind...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_C...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n, s, a = int(input()), input(), 9**9 for i in range(1, n): if s[i] != "0": if max(a, n - a) > max(i, n - i): a = i elif max(a, n - a) == max(i, n - i) and int(s[:a]) + int(s[a:]) > int( s[:i] ) + int(s[i:]): a = i print(int(s[:a]) + int(s[a:]))
ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING IF FUNC_CALL VAR VAR BIN_OP VAR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR IF FUNC_CALL VAR VAR BIN_OP VAR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = int(input()) a = input() m = int(a) P = 10 ** (n // 2 + 1) p = P A = int(a[: n // 2]) B = int(a[n // 2 :]) kek = a[n // 2 :] if kek[0] != "0": m = min(m, A + B) C = A D = B if n % 2 == 0: P //= 10 k = 0 for i in range(n // 2, n): if a[i] != "0": m = min(int(a[:i]) + int(a[i:]), m) break ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER STRING ASSIGN ...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n, s = int(input()), input() h = n // 2 ans = 3 * 10**100000 i = h while i < n - 1 and s[i] == "0": i += 1 if not (i >= n - 1 and s[i] == "0"): ans = min(ans, int(s[:i]) + int(s[i:])) i = min(h + 1, n - 1) while i < n - 1 and s[i] == "0": i += 1 if not (i >= n - 1 and s[i] == "0"): ans = min(ans, int(s[...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR VAR WHILE VAR BIN_OP VAR NUMBER VAR VAR STRING VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = int(input()) s = input() l, r = n // 2, (n + 1) // 2 ans = int(s) while True: flag = False if s[l] != "0": flag = True num1, num2 = int(s[:l]), int(s[l:]) ans = min(ans, num1 + num2) if s[r] != "0": flag = True num1, num2 = int(s[:r]), int(s[r:]) ans = min...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE NUMBER ASSIGN VAR NUMBER IF VAR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP ...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
l = int(input()) n = input() pos = len(n) // 2 while pos < len(n) and n[pos] == "0": pos += 1 ans = -1 if pos < len(n): left = int(n[:pos]) right = int(n[pos:]) ans = left + right pos += 1 if pos < len(n) and n[pos] != "0": left = int(n[:pos]) right = int(n[pos:]) if ans ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR STRING VAR NUMBER ASSIGN VAR NUMBER IF VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR NUMBER IF VAR FUNC_C...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
l = int(input()) n = input() mn = int(n) mid1 = l // 2 mid2 = l // 2 while n[mid1] == "0": mid1 -= 1 while mid2 < l and n[mid2] == "0": mid2 += 1 if mid2 == l: mid2 = l // 2 while n[mid2] == "0": mid2 -= 1 for i in range(mid2 - 1, min(l - 1, mid2 + 1)): if n[i + 1] == "0": continue ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR STRING VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR STRING VAR NUMBER FOR VAR FUNC_CALL VAR BIN...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
l = int(input()) n = input() mi = int(n) for A in range(l // 2 - 1, l // 2 + 2): if A > 0 and A < len(n) and n[:A][0] != "0" and n[A:][0] != "0": a = int(n[:A]) b = int(n[A:]) mi = min(mi, a + b) if mi == int(n): i = l // 2 while n[i] == "0": i -= 1 if i > 0: mi =...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR NUMBER STRING VAR VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
def calc(s, pos): A = s[0:pos] B = s[pos:] return int(A) + int(B) n = input() s = input() n = int(n) result = int(s) n2 = n // 2 ctr = 0 for i in range(n // 2, 0, -1): if s[i] == "0": continue ctr += 1 if ctr == 4: break val = calc(s, i) result = min(result, val) ctr = ...
FUNC_DEF ASSIGN VAR VAR NUMBER VAR ASSIGN VAR VAR VAR RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR ...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = int(input()) s = input() lens = [] for i in range(len(s) - 1): if s[i + 1] != "0": lens.append((i, max(i + 1, len(s) - i - 1))) mnlen = len(s) + 1 for a, b in lens: mnlen = min(mnlen, b) ans = int("9" * (len(s) + 1)) for a, b in lens: if b == mnlen or b == mnlen + 1: ans = min(ans, int(s...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR VAR V...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
l = int(input()) n = input() def solve(ind, d): global ans if ind < 1 or ind >= l: return if n[ind] == "0": if d == 0: return while 1 <= ind < l and n[ind] == "0": ind += d if ind < 1 or ind >= l: return if n[ind] == "0": return r...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF IF VAR NUMBER VAR VAR RETURN IF VAR VAR STRING IF VAR NUMBER RETURN WHILE NUMBER VAR VAR VAR VAR STRING VAR VAR IF VAR NUMBER VAR VAR RETURN IF VAR VAR STRING RETURN ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CAL...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = int(input()) s = input() a = s a = "0" + s s = [int(i) for i in s] s = [0] + s p = [] if n % 2 is 0: i = n // 2 + 1 while i <= n and s[i] == 0: i += 1 if i <= n and s[i] != 0: p.append(i) i = n // 2 while i >= 1 and s[i] == 0: i -= 1 if i > 1 and s[i] != 0: p....
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER WHILE VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
a = input() a = int(a) c = input() b = str(c) l = int(a / 2) while l >= 1: if b[l] == "0": l -= 1 else: break r = int(a / 2) + 1 while r < a: if b[r] == "0": r += 1 else: break if l == 0: print(str(int(b[:r]) + int(b[r:]))) elif r == a: print(str(int(b[:l]) + int(...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER WHILE VAR NUMBER IF VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER WHILE VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR NUMBER EXPR FUNC...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
def main(): n = int(input()) x = input() mid = n // 2 cnt = 0 ans = None for i in range(mid + 2): j = mid + i if j < n and x[j] != "0": val = int(x[:j]) + int(x[j:]) cnt += 1 if ans is None: ans = val else: ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NONE FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR VAR VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER IF VAR NONE ASSIGN ...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = int(input()) num = input() def mn(a, b): x = int(num[:a]) + int(num[a:]) y = int(num[:b]) + int(num[b:]) if x < y: return a else: return b if n & 1 > 0: idx = mn(n // 2, n // 2 + 1) else: idx = n // 2 lead_a = 0 lead_b = 0 i = idx while i < n: if num[i] == "0": ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR RETURN VAR RETURN VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR N...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = int(input()) s = input() a = "" b = "" ans = 0 l = r = n // 2 while r < len(s) and s[r] == "0": r = r + 1 while l >= 0 and s[l] == "0": l = l - 1 if l > 0: a = s[:l] b = s[l:] if ans == 0: ans = int(a) + int(b) else: ans = min(ans, int(a) + int(b)) if r < len(s): a = s[:r...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR VAR ASS...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
import sys def IO(): import sys sys.stdout = open("output.txt", "w") sys.stdin = open("input.txt", "r") def main(): l = int(input()) n = input() pos = [i for i in range(1, l) if n[i] != "0"] pos = sorted(pos, key=lambda i: abs(i - l // 2)) ans = float("inf") for i in range(min(6...
IMPORT FUNC_DEF IMPORT ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR STRING STRING FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER VAR VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
l = int(input()) n = input() if l % 2 == 1: m = l // 2 for i in range(0, l - m): variants = [] if n[m - i] != "0": variants.append(int(n[: m - i]) + int(n[m - i :])) if n[m + i + 1] != "0": variants.append(int(n[: m + i + 1]) + int(n[m + i + 1 :])) if vari...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR ASSIGN VAR LIST IF VAR BIN_OP VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR IF VAR BIN_OP BIN_...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
l = int(input()) s = input() ans = -1 cp = int((l - 1) / 2) dist = 1 if l % 2 == 1: dist = 0 while ans == -1: if s[cp + 1] != "0": ans = int(s[: cp + 1]) + int(s[cp + 1 :]) if cp + dist < l and s[cp + dist] != "0": if ans == -1: ans = int(s[: cp + dist]) + int(s[cp + dist :]) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR ...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
_ = input() num = input() ansi = len(num) - 1 leni = len(num) for i in range(leni): if i == 0 or num[i] == "0": continue ansi = min(ansi, max(i, leni - i)) l = [] for i in range(leni): if i == 0 or num[i] == "0": continue tk = max(i, leni - i) if tk == ansi or tk - 1 == ansi: ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR STRING ASSIGN VAR...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
l = int(input()) s = input() s = str(s) if l % 2 == 0: i = l // 2 i1 = i - 1 while i1 >= 0: if s[i1] != "0": break i1 = i1 - 1 i2 = i while i2 < l: if s[i2] != "0": break i2 = i2 + 1 s1 = 0 s1 = str(s1) i3 = 0 while i3 < i1: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER A...
Vus the Cossack has $n$ real numbers $a_i$. It is known that the sum of all numbers is equal to $0$. He wants to choose a sequence $b$ the size of which is $n$ such that the sum of all numbers is $0$ and each $b_i$ is either $\lfloor a_i \rfloor$ or $\lceil a_i \rceil$. In other words, $b_i$ equals $a_i$ rounded up or ...
n = int(input()) a = [] m = [] for i in range(n): x = float(input()) y = [int(x), x - int(x)] if x < 0 and y[1] != 0: y[0] -= 1 a.append(y) sum = 0 for i in range(n): sum += a[i][0] for i in range(n): if sum < 0 and a[i][1] != 0: a[i][0] += 1 sum += 1 for i in range(n): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR BIN_OP VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR ...
Vus the Cossack has $n$ real numbers $a_i$. It is known that the sum of all numbers is equal to $0$. He wants to choose a sequence $b$ the size of which is $n$ such that the sum of all numbers is $0$ and each $b_i$ is either $\lfloor a_i \rfloor$ or $\lceil a_i \rceil$. In other words, $b_i$ equals $a_i$ rounded up or ...
n = int(input()) arr = [float(input()) for _ in range(n)] arr2 = [int(arr[i]) for i in range(n)] diff = sum(arr2) if diff == 0: for i in range(n): print(arr2[i]) elif diff < 0: cnt = 0 for i in range(n): if arr[i] > 0: if cnt < abs(diff): if arr[i] != arr2[i]: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR ...
Vus the Cossack has $n$ real numbers $a_i$. It is known that the sum of all numbers is equal to $0$. He wants to choose a sequence $b$ the size of which is $n$ such that the sum of all numbers is $0$ and each $b_i$ is either $\lfloor a_i \rfloor$ or $\lceil a_i \rceil$. In other words, $b_i$ equals $a_i$ rounded up or ...
def main(): n = int(input()) i = 0 ng = [] tp = [] tg = 0 while i < n: str = input() x, y = [int(t) for t in str.split(".")] if y != 0: tg += x if x >= 0 and str[0] != "-" else x - 1 ng.append(x if x >= 0 and str[0] != "-" else x - 1) else:...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR VAR NUMBER VAR NUMBER STRING VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER VAR NUMB...
Vus the Cossack has $n$ real numbers $a_i$. It is known that the sum of all numbers is equal to $0$. He wants to choose a sequence $b$ the size of which is $n$ such that the sum of all numbers is $0$ and each $b_i$ is either $\lfloor a_i \rfloor$ or $\lceil a_i \rceil$. In other words, $b_i$ equals $a_i$ rounded up or ...
n = int(input()) ar = [] a = [(0) for i in range(0, n)] for i in range(0, n): ar.append(input()) s = 0 for i in range(0, n): a[i] = float(ar[i]) // 1 s = s + a[i] i = 0 if s < 0: while s != 0: if float(ar[i]) != float(ar[i]) // 1: a[i] += 1 s += 1 i += 1 for i in ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR NUMBER IF...
Vus the Cossack has $n$ real numbers $a_i$. It is known that the sum of all numbers is equal to $0$. He wants to choose a sequence $b$ the size of which is $n$ such that the sum of all numbers is $0$ and each $b_i$ is either $\lfloor a_i \rfloor$ or $\lceil a_i \rceil$. In other words, $b_i$ equals $a_i$ rounded up or ...
a = int(input()) ans = [] aller = [(0) for i in range(a)] for i in range(a): s = input() if s[0] == "-": s = s[1:] t = s.find(".") q = int(s[0:t]) m = s[t + 1 :] ans.append(-q) if len(m) == m.count("0"): aller[i] = 0 continue aller[...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER STRING ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR IF ...
Vus the Cossack has $n$ real numbers $a_i$. It is known that the sum of all numbers is equal to $0$. He wants to choose a sequence $b$ the size of which is $n$ such that the sum of all numbers is $0$ and each $b_i$ is either $\lfloor a_i \rfloor$ or $\lceil a_i \rceil$. In other words, $b_i$ equals $a_i$ rounded up or ...
pos = [0] * (10**5 + 1) neg = [0] * (10**5 + 1) positive = [] negitive = [] n = int(input()) for i in range(n): a = float(input()) if a >= 0: positive.append([int(a), i]) if a != int(a): pos[len(positive) - 1] = 1 if a < 0: negitive.append([int(a), i]) if a != int...
ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR LIST FUNC_CALL VAR VA...
Vus the Cossack has $n$ real numbers $a_i$. It is known that the sum of all numbers is equal to $0$. He wants to choose a sequence $b$ the size of which is $n$ such that the sum of all numbers is $0$ and each $b_i$ is either $\lfloor a_i \rfloor$ or $\lceil a_i \rceil$. In other words, $b_i$ equals $a_i$ rounded up or ...
from sys import stdin input = stdin.readline n = int(input()) a = [] for i in range(n): b, c = map(str, input().split(".")) k = int(b) if c == "0" * 5 + "\n": a.append([k, k]) elif k > 0: a.append([k, k + 1]) elif k < 0: a.append([k - 1, k]) elif b[0] == "-": a.a...
ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR IF VAR BIN_OP BIN_OP STRING NUMBER STRING EXPR FUNC_CALL VAR LIST VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR LIST VAR BIN_OP VAR NUMB...
Vus the Cossack has $n$ real numbers $a_i$. It is known that the sum of all numbers is equal to $0$. He wants to choose a sequence $b$ the size of which is $n$ such that the sum of all numbers is $0$ and each $b_i$ is either $\lfloor a_i \rfloor$ or $\lceil a_i \rceil$. In other words, $b_i$ equals $a_i$ rounded up or ...
n = int(input()) i = 0 b = [] c = [] res = 0 while i < n: s = input() z = s.find(".") if z == -1 or s[z : z + 6] == ".00000": r = float(s) r = int(r) c.append(0) else: r = int(s[0:z]) if s[0:1] == "-": c.append(-1) else: c.append(1)...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR ...
Vus the Cossack has $n$ real numbers $a_i$. It is known that the sum of all numbers is equal to $0$. He wants to choose a sequence $b$ the size of which is $n$ such that the sum of all numbers is $0$ and each $b_i$ is either $\lfloor a_i \rfloor$ or $\lceil a_i \rceil$. In other words, $b_i$ equals $a_i$ rounded up or ...
from sys import stdin, stdout n = int(input()) negitives = [] positives = [] for i in range(2): negitives.append([]) positives.append([]) sums = 0 answer = [0] * n for i in range(n): x = [float(x) for x in input().split()][0] if x < 0: if abs(int(x) - x) >= 10**-6: negitives[1].appe...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR LIST EXPR FUNC_CALL VAR LIST ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER IF VAR NUMBER IF FUNC_CALL VAR...
Vus the Cossack has $n$ real numbers $a_i$. It is known that the sum of all numbers is equal to $0$. He wants to choose a sequence $b$ the size of which is $n$ such that the sum of all numbers is $0$ and each $b_i$ is either $\lfloor a_i \rfloor$ or $\lceil a_i \rceil$. In other words, $b_i$ equals $a_i$ rounded up or ...
n = int(input()) a = [(0) for i in range(n)] _sum = 0 for i in range(n): num = float(input()) a[i] = num _sum += int(num) i = 0 while _sum > 0 and i < n: if abs(a[i] - int(a[i])) > 1e-05 and a[i] < 0: a[i] -= 1 _sum -= 1 i += 1 i = 0 while _sum < 0 and i < n: if abs(a[i] - int(a[...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR IF FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR VAR VAR NUMBER VAR VAR NUMBE...
Vus the Cossack has $n$ real numbers $a_i$. It is known that the sum of all numbers is equal to $0$. He wants to choose a sequence $b$ the size of which is $n$ such that the sum of all numbers is $0$ and each $b_i$ is either $\lfloor a_i \rfloor$ or $\lceil a_i \rceil$. In other words, $b_i$ equals $a_i$ rounded up or ...
n = int(input()) a = [] d = 0 p = [] q = [] for i in range(n): s = float(input()) if s < 0 and s % 1 != 0: k = int(s // 1) + 1 a.append(k) d += k p.append(i) elif s > 0 and s % 1 != 0: k = int(s // 1) a.append(k) d += k q.append(i) else: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ...
Vus the Cossack has $n$ real numbers $a_i$. It is known that the sum of all numbers is equal to $0$. He wants to choose a sequence $b$ the size of which is $n$ such that the sum of all numbers is $0$ and each $b_i$ is either $\lfloor a_i \rfloor$ or $\lceil a_i \rceil$. In other words, $b_i$ equals $a_i$ rounded up or ...
a = [] n = int(input()) for _ in range(n): a.append(float(input())) ns = 0 ps = 0 for i in range(n): if a[i] < 0: ns += int(a[i]) else: ps += int(a[i]) cha = ps + ns if cha == 0: for i in range(n): print(int(a[i])) elif cha < 0: i = 0 while cha != 0 and i < n: if ...
ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER FOR VAR FUNC_CALL VA...
Vus the Cossack has $n$ real numbers $a_i$. It is known that the sum of all numbers is equal to $0$. He wants to choose a sequence $b$ the size of which is $n$ such that the sum of all numbers is $0$ and each $b_i$ is either $\lfloor a_i \rfloor$ or $\lceil a_i \rceil$. In other words, $b_i$ equals $a_i$ rounded up or ...
n = int(input()) arr = [] brr = [] for i in range(n): x = float(input()) if x < 0 and int(x) != x: arr.append(int(x) - 1) brr.append(x) elif x > 0 and int(x) != x: arr.append(int(x) + 1) brr.append(x) else: arr.append(int(x)) brr.append(x) s = sum(arr) if ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VA...
Vus the Cossack has $n$ real numbers $a_i$. It is known that the sum of all numbers is equal to $0$. He wants to choose a sequence $b$ the size of which is $n$ such that the sum of all numbers is $0$ and each $b_i$ is either $\lfloor a_i \rfloor$ or $\lceil a_i \rceil$. In other words, $b_i$ equals $a_i$ rounded up or ...
n = int(input()) d = [] p = 0 m = 0 for i in range(n): s = float(input()) d.append(s) if s > 0: p = p + int(s) else: m = m + int(s) a = p + m s = d[::1] s.sort() if a == 0: for i in d: print(int(i)) elif a > 0: for i in d: if i >= 0: print(int(i)) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR NUMBER...
Vus the Cossack has $n$ real numbers $a_i$. It is known that the sum of all numbers is equal to $0$. He wants to choose a sequence $b$ the size of which is $n$ such that the sum of all numbers is $0$ and each $b_i$ is either $\lfloor a_i \rfloor$ or $\lceil a_i \rceil$. In other words, $b_i$ equals $a_i$ rounded up or ...
n = int(input()) dig = [] dec = 0 z = 0 for _ in range(n): x = float(input()) dec += round(x - int(x), 5) dig.append([int(x), round(x - int(x), 5)]) c = round(dec) f = -1 if c > 0 else 1 for i in range(n): if c * (dig[i][0] + dig[i][1]) > 0 and c != 0 and dig[i][1] != 0: dig[i][0] += -f ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR LIST FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CA...
Vus the Cossack has $n$ real numbers $a_i$. It is known that the sum of all numbers is equal to $0$. He wants to choose a sequence $b$ the size of which is $n$ such that the sum of all numbers is $0$ and each $b_i$ is either $\lfloor a_i \rfloor$ or $\lceil a_i \rceil$. In other words, $b_i$ equals $a_i$ rounded up or ...
from sys import stdin def solve(): N = int(stdin.readline()) A = [] neg_0 = set() pos_0 = set() ignore = set() for i in range(N): x = float(stdin.readline()) if x == int(x): ignore.add(i) elif int(x) == 0: if x >= 0: pos_0.add(i) ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXP...
Vus the Cossack has $n$ real numbers $a_i$. It is known that the sum of all numbers is equal to $0$. He wants to choose a sequence $b$ the size of which is $n$ such that the sum of all numbers is $0$ and each $b_i$ is either $\lfloor a_i \rfloor$ or $\lceil a_i \rceil$. In other words, $b_i$ equals $a_i$ rounded up or ...
n = int(input()) a = [float(input()) for i in range(n)] b = a.copy() s = 0 for i in range(0, n): b[i] = int(b[i]) s = s + b[i] if s != 0: for i in range(0, n): if s == 0: break if b[i] != a[i]: if s < 0 and b[i] >= 0 and a[i] >= 0: b[i] = b[i] + 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER IF VAR VAR VAR V...
Vus the Cossack has $n$ real numbers $a_i$. It is known that the sum of all numbers is equal to $0$. He wants to choose a sequence $b$ the size of which is $n$ such that the sum of all numbers is $0$ and each $b_i$ is either $\lfloor a_i \rfloor$ or $\lceil a_i \rceil$. In other words, $b_i$ equals $a_i$ rounded up or ...
numbers = [] d = [] s = 0 for i in range(int(input())): n = input() if n[len(n) - 5 :] == "00000": num = int(n[: len(n) - 6]) numbers.append(num) s += num d.append(0) elif n[0] == "-": num = int(n[: len(n) - 6]) - 1 numbers.append(num) s += num ...
ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER STRING ASSIGN VAR...
Vus the Cossack has $n$ real numbers $a_i$. It is known that the sum of all numbers is equal to $0$. He wants to choose a sequence $b$ the size of which is $n$ such that the sum of all numbers is $0$ and each $b_i$ is either $\lfloor a_i \rfloor$ or $\lceil a_i \rceil$. In other words, $b_i$ equals $a_i$ rounded up or ...
n = int(input()) v, a = [0] * n, [0] * n for i in range(n): v[i] = float(input()) if abs(v[i]) - int(abs(v[i])) > 0.0: a[i] = 1 if v[i] >= 0.0: v[i] = int(v[i]) else: v[i] = int(v[i]) - 1 else: v[i] = int(v[i]) s = sum(v) i = 0 while i < n and s < 0: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP LIST NUMBER VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR...
Vus the Cossack has $n$ real numbers $a_i$. It is known that the sum of all numbers is equal to $0$. He wants to choose a sequence $b$ the size of which is $n$ such that the sum of all numbers is $0$ and each $b_i$ is either $\lfloor a_i \rfloor$ or $\lceil a_i \rceil$. In other words, $b_i$ equals $a_i$ rounded up or ...
n = int(input()) arr = [(0) for i in range(n)] flag = [(0) for i in range(n)] for i in range(n): arr[i] = float(input()) if int(arr[i]) == arr[i]: flag[i] = 1 if flag[i] == 0 and arr[i] < 0: arr[i] = int(arr[i]) - 1 else: arr[i] = int(arr[i]) suma = sum(arr) for i in range(n): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR VAR NUMBER IF VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR VAR ...
Vus the Cossack has $n$ real numbers $a_i$. It is known that the sum of all numbers is equal to $0$. He wants to choose a sequence $b$ the size of which is $n$ such that the sum of all numbers is $0$ and each $b_i$ is either $\lfloor a_i \rfloor$ or $\lceil a_i \rceil$. In other words, $b_i$ equals $a_i$ rounded up or ...
n = int(input()) mas = [] checker = [] tmp = "" for i in range(n): num = input() for ind, item in enumerate(num): if item != ".": tmp = tmp + item else: if tmp == "-0": mas.append("-0") else: mas.append(int(tmp)) tmp...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING ASSIGN VAR BIN_OP VAR VAR IF VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CA...
Vus the Cossack has $n$ real numbers $a_i$. It is known that the sum of all numbers is equal to $0$. He wants to choose a sequence $b$ the size of which is $n$ such that the sum of all numbers is $0$ and each $b_i$ is either $\lfloor a_i \rfloor$ or $\lceil a_i \rceil$. In other words, $b_i$ equals $a_i$ rounded up or ...
n = int(input()) a = [] b = [] for i in range(0, n): a.append(float(input())) for i in range(0, n): b.append(int(a[i])) if a[i] > 0 and a[i] % 1 != 0: b[i] += 1 s = sum(b) if s > 0: i = 0 while s > 0 and i < n: if a[i] % 1 != 0: b[i] -= 1 s -= 1 i += 1...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR IF VAR VAR NUMBER BIN_OP VAR VAR NUMBER NUMBER VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF V...