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 ...
number = int(input("")) input_array = list(input("")) first = 0 second = 0 result = 0 if number % 2 == 0: i = int(number / 2) if input_array[i] == "0": while i != number and input_array[i] == "0": i += 1 if i == number: i = number - 1 while input_array[i] == "...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING WHILE VAR VAR VAR VAR STRING VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE...
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() good = [] for i in range(1, n): if s[i] != "0": good.append([max(n - i, i), i]) good = sorted(good) if len(good) == 0: good.append([n - 1, n - 1]) if len(good) == 1: good.append(good[0]) ans = int(s[: good[0][1]]) + int(s[-(n - good[0][1]) :]) ans = min(ans, int(s[: good...
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 LIST FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR LIST BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF 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() L = l // 2 R = l // 2 + 1 R = min(l - 1, R) while s[L] == "0" and L > 1: L -= 1 while s[R] == "0" and R < l - 1: R += 1 a = int(s[0:L]) + int(s[L:l]) b = int(s[0:R]) + int(s[R:l]) if s[L] == "0": print(b) elif s[R] == "0": print(a) else: print(min(a, b))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR WHILE VAR VAR STRING VAR NUMBER VAR NUMBER WHILE VAR VAR STRING VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMB...
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() k = n // 2 l = n // 2 if n == 1: print(m) elif n == 2: print(int(m) // 10 + int(m) % 10) elif n % 2 == 0: while m[k] == "0": k -= 1 while l < n and m[l] == "0": l += 1 if k == 0: s = int(m) else: s = int(m[:k]) + int(m[k:]) if l ==...
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 IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER WHILE VAR VAR STRING VAR NUMB...
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 = input() r = int(l) c = 0 while n // 2 > c: a, b = 0, 0 if l[n // 2 - c] == "0": a = r else: a = int(l[: n // 2 - c]) + int(l[n // 2 - c :]) if l[(n + 1) // 2 + c] == "0": b = r else: b = int(l[: (n + 1) // 2 + c]) + int(l[(n + 1) // 2 - c :]) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER NUMBER IF VAR BIN_OP BIN_OP VAR NUMBER VAR STRING ASSIGN VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER VAR FUNC_CALL VAR 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 ...
x = int(input()) y = input() mn = 999999 for i in range(x // 2, 0, -1): if y[i] != "0": mn = int(y[:i]) + int(y[i:]) break for i in range(x // 2 + 1, x): if y[i] != "0": mn = min(mn, int(y[:i]) + int(y[i:])) break print(mn)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR STRING ASSIGN 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 VAR VAR STRING 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 ...
input() s = input() n = len(s) pos = n // 2 left = pos right = pos + 1 while s[left] == "0": left -= 1 while right < n and s[right] == "0": right += 1 if left == 0: res = int(s[:right]) + int(s[right:]) elif right == n: res = int(s[:left]) + int(s[left:]) else: res = min(int(s[:left]) + int(s[left:]...
EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR STRING VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR 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 = eval(input()) s = input() ans = 0 k = int(0) for i in range(n): f1 = 0 f2 = 0 ans1 = 0 ans2 = 0 if n // 2 - k > 0 and s[n // 2 - k] != "0": s1 = s[0 : n // 2 - k] s2 = s[n // 2 - k : n] ans1 = eval(s1) + eval(s2) f1 = 1 m = n - (n // 2 - k) if m > 0 and s[...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER VAR STRING ASSIGN VAR VAR NUMBER 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()) s = input() best = 0 best2 = None for sl in range(1, l): if s[sl] != "0": if max(sl, l - sl) < max(best, l - best): best = sl best2 = None elif max(sl, l - sl) == max(best, l - best): best2 = sl f = s[:best] b = s[best:] res = int(s[:best]) + int(...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NONE 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 ASSIGN VAR NONE IF FUNC_CALL VAR VAR BIN_OP VAR VAR FUNC_CALL VAR VAR BIN_OP 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 ...
def add(num1, num2): num1 = num1[::-1] num2 = num2[::-1] result = "" i = 0 j = 0 a_len = len(num1) b_len = len(num2) carry = 0 while i < a_len or j < b_len: A = 0 B = 0 if i < a_len: A = num1[i] if j < b_len: B = num2[j] ...
FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP 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()) num = input() smallest = 1000000 points = [] for i, c in enumerate(num): if i == 0: continue if c != "0": if max(i, l - i) < smallest: smallest = max(i, l - i) points.clear() if max(i, l - i) == smallest: points.append(i) ans = int("9"...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR STRING IF FUNC_CALL VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR IF FUNC_CALL VAR VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL 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 ...
size = int(input()) num = input() j = (size + 1) // 2 i = j - 1 while i > 0 and num[i] == "0": i -= 1 while j < size and num[j] == "0": j += 1 res = int(num) if i > 0: res = min(res, int(num[0:i]) + int(num[i:])) if j < size: res = min(res, int(num[0:j]) + int(num[j:])) print(res)
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 VAR NUMBER WHILE VAR NUMBER VAR VAR STRING VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMB...
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() if n == 2: print(int(s[0]) + int(s[1])) exit() i = n // 2 rez1 = 0 rez2 = 0 while i < n - 1: if s[i:][0] == "0": i += 1 else: break rez1 = int(s[i:]) + int(s[0:i]) j = n // 2 + 1 while j > 1: if s[j:][0] == "0": j -= 1 else: break if s...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER STRING VAR NUMBER ASSIGN 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 ...
t = int(input()) s = input() l = 0 r = t - 1 mid = t / 2 for i in range(t): if s[i] != "0": if i <= mid: l = i else: r = min(r, i) if r == t - 1 and s[r] == "0": r = l - 1 h1 = pow(10, t - r) h2 = pow(10, t - l) s = int(s) ans = min(s // h1 + s % h1, s // h2 + s % h2) pri...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR BIN_OP VAR NUMBER VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER 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 ...
def solve(n, l): m = l // 2 cnd = [] for i in range(m, l): if n[i] != "0" and len(cnd) < 3: cnd.append(i) for i in range(m, 0, -1): if n[i] != "0" and len(cnd) < 6: cnd.append(i) def get(s, i): s1 = s[0:i] s2 = s[i:] return int(s1) + i...
FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR VAR IF VAR VAR STRING FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR VAR STRING FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR VAR NUMBER VAR ASSIGN VAR VAR VAR RETURN 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()) string = input() ans = float("inf") mid = len(string) // 2 cnt = 0 for i in range(mid, n): if cnt >= 2: break if string[i] != "0": l = int(string[0:i]) r = int(string[i:]) cnt += 1 ans = min(ans, l + r) cnt = 0 for i in range(mid, 0, -1): if cnt >= 2:...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN 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() r = float("inf") half = l // 2 if n[half] != "0": a, b = n[:half], n[half:] r = min(r, int(a) + int(b)) for i in range(half + 1, l): if n[i] != "0": a, b = n[:i], n[i:] r = min(r, int(a) + int(b)) break for i in range(half - 1, 0, -1): if n[i] != "0":...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR STRING ASSIGN VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR STRING ASSIGN 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()) s = input() if l % 2 == 0: inda = l // 2 indb = l // 2 else: inda = l // 2 indb = l // 2 + 1 while s[inda] == "0" and inda > 1: inda -= 1 while s[indb] == "0" and indb < l - 1: indb += 1 al = s[:inda] ar = s[inda:] bl = s[:indb] br = s[indb:] aside = int(s[:inda]) + int(s[inda:]...
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 ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER WHILE VAR VAR STRING VAR NUMBER VAR NUMBER WHILE VAR VAR STRING VAR BIN_OP VAR NUMBER VAR NUMBER 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 ...
minn = 10**100001 n = int(input()) a = input() for i in range(int((n + 1) / 2) - 1, n - 1): if a[i + 1] == "0": continue buf = int(a[i + 1 : n]) + int(a[0 : i + 1]) if buf < minn: minn = buf break for i in range(int(n / 2) - 1, -1, -1): if a[i + 1] == "0": continue buf = ...
ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER BIN_OP 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() ans = -1 for i in range(int((l - 1) / 2), -1, -1): if n[i + 1] != "0": a = int(n[0 : i + 1]) b = int(n[i + 1 : l]) if ans == -1 or a + b < ans: ans = a + b if i != int((l - 1) / 2): break for i in range(int((l - 1) / 2) + 1, l - 1,...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER NUMBER IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR IF VAR NUMBER 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 ...
l = int(input()) a = input() a = str(a) fuck = int(a) count = 0 bb = [] if a[l - 1] != "0": fuck = int(a[: l - 1]) + int(a[l - 1 :]) for i in range(l - 1): if a[i] == "0" and a[i + 1] != "0": count += 1 bb.append(i) elif a[i] != "0" and a[i + 1] != "0": count += 1 bb.append(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 NUMBER ASSIGN VAR LIST 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 FOR VAR FUNC_CALL VAR BIN_OP 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() x = int(s) y = 0 mn = 1e1000 tp = 1 l = n // 2 r = n // 2 while s[l] == "0": l -= 1 while r < n and s[r] == "0": r += 1 l = max(1, l - 1) r = min(n - 1, r + 1) for i in range(l, r + 1): if s[i] != "0": x = int(s[:i]) y = int(s[i:]) mn = min(mn, x + y) pri...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER 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 ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP 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()) a = input() ans = int(a) k = n // 2 i = k while i < n and a[i] == "0": i += 1 if i < n - 1: ans = min(ans, int(a[:i]) + int(a[i:])) i = k while i >= 0 and a[i] == "0": i -= 1 if i > 0: ans = min(ans, int(a[:i]) + int(a[i:])) k = (n + 1) // 2 i = k while i < n and a[i] == "0": i += 1...
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 VAR WHILE VAR VAR VAR VAR STRING VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR WHILE VAR NUMBER 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 ...
n = int(input()) s = input() x, y = n // 2, n // 2 + 1 while x > 0 and s[x] == "0": x -= 1 while y < n and s[y] == "0": y += 1 if x == 0: print(int(s[:y]) + int(s[y:])) elif y == n: print(int(s[:x]) + int(s[x:])) else: print(min(int(s[:y]) + int(s[y:]), int(s[:x]) + int(s[x:])))
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 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 VAR FUNC_CALL VAR VAR VAR IF VAR VAR EXPR 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()) x = input() p = l // 2 ans = -1 for i in range(p + 1, l): if x[i] != "0": s = int(x[:i]) + int(x[i:]) if ans == -1 or s < ans: ans = s break for i in range(p, 0, -1): if x[i] != "0": s = int(x[:i]) + int(x[i:]) if ans == -1 or s < ans: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF 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 ...
n = int(input()) s = str(input()) m = n // 2 if n % 2 == 0: if s[m] == "0": left = m - 1 right = n - 1 for i in range(m, n): if s[i] != "0": right = i break for i in range(m, -1, -1): if s[i] != "0": left = i ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR IF VAR VAR STRING ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR 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 ...
def prov(a, b): if b[0] == "0": return False, 0 else: return True, int(a) + int(b) x = int(input()) n = input() l = x // 2 r = l if x % 2 == 1: r += 1 y = 0 while y == 0: q, w = prov(n[:l], n[l:]) q1, w1 = prov(n[:r], n[r:]) l -= 1 r += 1 p = float("inf") if q: ...
FUNC_DEF IF VAR NUMBER STRING RETURN NUMBER NUMBER RETURN NUMBER BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL 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() ans = int(n) i = l // 2 + 1 j = l // 2 flag1 = False flag2 = False if (i < l) & (j > 0): while n[i] == "0" and i < l: i += 1 if i >= l: flag1 = True break while n[j] == "0" and j > 0: j -= 1 if j <= 0: flag2 = True ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR VAR VAR NUMBER WHILE VAR VAR STRING VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER WHILE VAR 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 ...
l = int(input()) n = input() def goleft(s): mid = l // 2 while s[mid] == "0": mid -= 1 if mid == 0: return int(n) * 10 return sumof2(s[:mid], s[mid:]) def goright(s): mid = l // 2 + 1 while s[mid] == "0": if mid == len(s) - 1: return int(n) * 10 mi...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR STRING VAR NUMBER IF VAR NUMBER RETURN BIN_OP FUNC_CALL VAR VAR NUMBER RETURN FUNC_CALL VAR VAR VAR VAR VAR FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER WHILE VAR VAR STRING IF VAR BIN_OP 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 ...
l = int(input()) n = input() m = int(l / 2) cand1 = int(n) for i in range(m + 1, l): if not n[i] == "0": left = int(n[:i]) right = int(n[i:]) cand1 = min(left + right, cand1) break for i in range(m, 0, -1): if not n[i] == "0": left = int(n[:i]) right = int(n[i:]) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR FOR 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 ...
def smaller(x, y): if x < y: return x return y L = int(input()) N = input() middle = L // 2 if L % 2 == 0: if N[middle] != "0": print(int(N[:middle]) + int(N[middle:])) else: index = 1 while True: flag1 = N[middle - index] != "0" flag2 = N[middle...
FUNC_DEF IF VAR VAR RETURN VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER IF VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR VAR BIN_OP 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 ...
n = int(input()) s = input() ans = 10 ** (n + 3) a = [] for i in range(1, n): if s[i] != "0": a.append(i) i = 0 while i < len(a) and a[i] <= n // 2: i += 1 for j in range(max(i - 3, 0), min(i + 3, len(a))): ans = min(int(s[: a[j]]) + int(s[a[j] :]), ans) print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL 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 ...
n = int(input()) s = input() ans = 0 cnt = 0 for i in range(n // 2 + 1, n): if s[i] >= "1" and s[i] <= "9": if ans == 0: ans = int(s[:i]) + int(s[i:]) else: ans = min(int(s[:i]) + int(s[i:]), ans) break cnt = 0 for i in range(n // 2, 0, -1): if s[i] >= "1" and s[i...
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 BIN_OP VAR NUMBER NUMBER VAR IF VAR VAR STRING VAR VAR STRING IF VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP 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 ...
l = int(input()) num = str(input()) idx = l // 2 pos = True while True: if num[idx] != "0": break idx -= 1 if idx < 0: pos = False break ls = num[:idx] rs = num[idx:] s1 = 0 s1found = False if ls != "" and rs != "": s1 = int(ls) + int(rs) s1found = True pos2 = True idx = l //...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF VAR VAR STRING VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR STRING VAR STRING ASSIGN 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 ...
def main(): buf = input() l = int(buf) buf = input() n = buf for i in range(l // 2, l): left = None right = None if n[i] != "0": left = i if n[-i] != "0": right = i if left and right: li = int(n[0:i]) + int(n[i:l]) ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NONE ASSIGN VAR NONE IF VAR VAR STRING ASSIGN VAR VAR IF VAR VAR STRING ASSIGN VAR VAR IF VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER 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 ...
ln = int(input()) n = input() nmb = int(n) s = "0" l1 = 0 l2 = 0 i = int(ln / 2) while i >= 0: if n[i] != s: l1 = i break i = i - 1 i = int(ln / 2) while i < ln: if n[i] != s: l2 = i break i = i + 1 if l2 == 0: l2 = ln if l1 == l2: l2 = ln - l1 nmbl1a = n[:l1] nmb...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER WHILE VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER WHILE 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() itr = l // 2 + l % 2 itr2 = itr - 1 while itr < l and n[itr] == "0": itr += 1 while n[itr2] == "0": itr2 -= 1 x, y = itr - l // 2 - l % 2, l // 2 - itr2 if x == y: p = n[0:itr] q = n[itr2:itr] + n[0:itr2] if int(p) > int(q): a, b = n[0:itr2], n[itr2:l] else: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER WHILE VAR VAR STRING VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP BIN_OP VAR 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 ...
d = int(input()) num = input() mid = d // 2 s1 = 0 s2 = 0 left = mid right = mid if num[mid] == "0": if int(num[mid:]) != 0: while num[left] == "0": left -= 1 while num[right] == "0" and right != d - 1: right += 1 try: s1 = int(num[:left]) + int(num[left:]...
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 ASSIGN VAR VAR ASSIGN VAR VAR IF VAR VAR STRING IF FUNC_CALL VAR VAR VAR NUMBER WHILE VAR VAR STRING VAR NUMBER WHILE VAR VAR STRING VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP FUNC_CA...
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() pos = n // 2 ans = -1 for it in range(n // 2, n // 2 - 5, -1): while pos >= 0 and a[pos] == "0": pos -= 1 if pos < 0: break if pos > 0: cur = int(a[0:pos]) + int(a[pos : len(a)]) if ans == -1: ans = cur else: ans = ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER WHILE VAR NUMBER VAR VAR STRING VAR NUMBER IF VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL 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()) a = input() mid = n // 2 while mid < n - 1 and a[mid + 1] == "0": mid += 1 first = a[: mid + 1] if first == "": first = 0 else: first = int(first) second = a[mid + 1 :] if second == "": second = 0 else: second = int(second) ans1 = first + second mid = n // 2 while a[mid] == "0": ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER IF VAR STRING ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER IF VAR STRING 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() ans = -1 mid = int(n / 2) while s[mid] == "0": mid = mid - 1 if mid in [0, n]: k = 1 elif ans == -1: ans = int(s[:mid]) + int(s[mid:]) else: ans = min(int(s[:mid]) + int(s[mid:]), ans) mid = int(n / 2) - 1 while mid != n and s[mid] == "0": mid = mid + 1 if mid in [0, n]:...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER WHILE VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR LIST NUMBER VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN 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().strip() m = l // 2 ans = int(n) * 2 for d in range(m, -1, -1): ok = False for x in [d, l - d]: if x > 0 and x < l and n[x] != "0": ok = True ans = min(ans, int(n[:x]) + int(n[x:])) if ok: break print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR LIST VAR BIN_OP VAR VAR IF VAR NUMBER VAR VAR VAR VAR STRING ASSIGN VAR NUMBER 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 ...
n = int(input()) s = input() ans = pow(10, 100000) a = sorted([i for i in range(1, n) if s[i] != "0"], key=lambda x: abs(n / 2 - x)) for i in a[:6]: 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 FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER VAR VAR VAR STRING FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR FOR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR EX...
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() op1 = -1 op2 = -1 for i in range(n // 2, 0, -1): if s[i] != "0": op1 = i break for i in range(n // 2 + 1, n): if s[i] != "0": op2 = i break if op1 == -1: num = str(int(s[op2:]) + int(s[:op2])) print(num) elif op2 == -1: num = str(int(s[op1...
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 ASSIGN 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 ...
import sys l = int(sys.stdin.readline().strip()) s = sys.stdin.readline().strip() mid = l // 2 def getz(a, dr, ed): for i in range(a, ed, dr): if s[i] != "0": return i return -1 if l % 2 == 0: sp1 = getz(mid - 1, -1, 0) sp2 = getz(mid, 1, l) else: sp1 = getz(mid, -1, 0) ...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER FUNC_DEF FOR VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR STRING RETURN VAR RETURN NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER 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 ...
n = int(input()) s = input() if n == 2: print(int(s[0]) + int(s[1])) else: ans = float("inf") for k in {n // 2, n // 2 - 1, n // 2 + 1}: if k != 0 and k != n: a, b = int(s[:k]), int(s[k:]) if s[k] != "0": ans = min(ans, a + b) for i in range(n // 2, n): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR 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 STRING FOR VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR NUMBER VAR VAR ASSIGN VAR VAR FUNC_CA...
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()) st = input() kq = -1 mid = int(n / 2) l = mid r = mid for i in range(mid, 0, -1): if st[i] != "0": l = i break for i in range(mid, n, 1): if st[i] != "0": r = i break l = max(l - 5, 1) r = min(r + 5, n) for i in range(l, r, 1): if st[i] != "0": if kq ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR VAR STRING ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR STRING ASSIGN VAR VAR ASSIGN VAR FUNC_CALL 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()) s = input() mas = [] for i in s: mas.append(int(i)) centr = n // 2 pos1, pos2 = 0, 0 for i in range(centr, n): if s[i] != "0": pos1 = i break for i in range(centr, -1, -1): if s[i] != "0": pos2 = i break ans = [] var1 = s[:pos2], s[pos2:] var2 = s[:pos1], s[p...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR IF VAR VAR STRING ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR VAR STRING ASSIGN 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()) nb = input() nbr = str(nb) mini = 0 mid = l // 2 if nbr[mid] != "0": tmp = int(nbr[:mid]) + int(nbr[mid:]) if mini == 0 or mini > tmp: mini = tmp cnt = 1 while mid + cnt < l: if nbr[mid + cnt] != "0": tmp = int(nbr[: mid + cnt]) + int(nbr[mid + cnt :]) if mini == 0 o...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF VAR BIN_OP 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()) s = str(input()) m = (l - 1) // 2 x1 = y1 = x2 = y2 = -5 ok = True for i in range(l // 2): if m + i + 1 < l and s[m + i + 1] != "0": ok = False x1 = int(s[m + i + 1 :]) y1 = int(s[: m + i + 1]) if m - i > 0 and s[m - i] != "0": ok = False x2 = int(s[m - i...
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 VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER VAR VAR BIN_OP BIN_OP VAR VAR NUMBER STRING ASSIGN VAR NUMBER ASSIGN 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 ...
a = int(input()) s = input() x = a // 2 m = s[:x] n = s[x:] o = s[: x + 1] p = s[x + 1 :] l = a // 2 c = a // 2 for ll in range(a // 2, a): if s[ll] == "0": c += 1 else: break for ww in range(a // 2, 0, -1): if s[ww] == "0": l -= 1 else: break if a == 2: print(int(s[0...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR STRING 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() def lol(k): global s, n, u if k <= 0 or k >= n or s[k] == "0": return x = s[0:k] y = s[k:] u = min(u, int(x) + int(y)) a = n // 2 while a - 1 >= 0 and s[a] == "0": a -= 1 b = n // 2 while b + 1 <= n - 1 and s[b] == "0": b += 1 u = int(s) for i in rang...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF IF VAR NUMBER VAR VAR VAR VAR STRING RETURN ASSIGN VAR VAR NUMBER VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE BIN_OP VAR NUMBER NUMBER VAR VAR STRING 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() mid = n // 2 a = s[:mid] b = s[mid:] c = s[: mid + 1] d = s[mid + 1 :] if len(b) > 0: while b[0] == "0": if len(b) > 0: b = b[1:] if len(b) <= 0: break a = a + "0" else: break if len(d) > 0: while d[0] =...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR NUMBER WHILE VAR NUMBER STRING IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF 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 ...
l = int(input()) s = input() k = l // 2 for i in range(k): m1 = 0 if s[k + i + l % 2] != "0": m1 = int(s[: k + i + l % 2]) + int(s[k + i + l % 2 :]) m2 = 0 if s[k - i] != "0": m2 = int(s[: k - i]) + int(s[k - i :]) if m1 == 0 and m2 == 0: continue if m1 > 0 and m2 == 0: ...
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 ASSIGN VAR NUMBER IF VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP 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 ...
n = int(input()) s = input() if n % 2: mid = n // 2 if s[mid] != "0": if int(s[: mid + 1]) < int(s[mid:]): print(int(s[: mid + 1]) + int(s[mid + 1 :])) else: print(int(s[:mid]) + int(s[mid:])) exit(0) else: mid = n // 2 if s[mid] != "0": print(int(...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR STRING IF FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP 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 ...
l = int(input()) str = input() md = l // 2 md1 = md + 1 ans = -1 global num while md > 0: if str[md] != "0": i1 = int(str[0:md]) i2 = int(str[md::1]) num = i1 + i2 if num < ans or ans == -1: ans = num break md -= 1 if md == -1: break while md1 < l:...
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 NUMBER WHILE VAR NUMBER IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR VAR NUMBER ASSIGN 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 ...
n = int(input()) s = input() l = [i for i in range(1, n) if s[i] != "0"] l.sort(key=lambda x: abs(x - n / 2)) ans = float("inf") for i in l[:10]: 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 VAR VAR FUNC_CALL VAR NUMBER VAR VAR VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING FOR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR EXPR...
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 = sorted((abs(n / 2 - i), i) for i in range(1, n) if s[i] != "0") print(min(int(s[:i]) + int(s[i:]) for v, i in l[:2]))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR VAR VAR FUNC_CALL VAR NUMBER VAR VAR VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR 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 ...
def get_sum(arr1, arr2): res = [] n = len(arr1) m = len(arr2) if n > m: n, m = m, n arr1, arr2 = arr2, arr1 carry = 0 i = 0 while i < n: if arr1[n - 1 - i] + arr2[m - 1 - i] + carry >= 10: res.append(arr1[n - 1 - i] + arr2[m - 1 - i] + carry - 10) ...
FUNC_DEF ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR NUMBER VAR VAR BIN_OP BIN_OP VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP 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 ...
n = int(input()) a = input() ans = -1 if n % 2 == 0: if a[n // 2 :][0] == "0": ans0, ans1 = -1, -1 i = n // 2 while a[i] == "0": i -= 1 if len(a[:i]) != 0: ans0 = int(a[:i]) + int(a[i:]) else: ans0 = int(a[i:]) i = n // 2 wh...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER NUMBER STRING ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR STRING VAR NUMBER IF FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR 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 = int(input()) s = input() c1 = n // 2 c2 = n // 2 + 1 while c1 > 0 and s[c1] == "0": c1 -= 1 while c2 < n and s[c2] == "0": c2 += 1 if c1 > 0: x1, x2 = int(s[:c1]), int(s[c1:]) s1 = x1 + x2 else: y1, y2 = int(s[:c2]), int(s[c2:]) s2 = y1 + y2 print(s2) exit(0) if c2 < n: y1, y2 = ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER WHILE VAR NUMBER VAR VAR STRING VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP 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 ...
l = int(input()) n = int(input()) s = str(n) ans = n R = l // 2 + 1 L = l // 2 while R < l and s[R] == "0": R += 1 if R < l and R > 0: tem = 10 ** (l - R) res = n // tem + n % tem if ans > res: ans = res while L >= 0 and s[L] == "0": L -= 1 if L >= 0: tem = 10 ** (l - L) res = n // t...
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 BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP VAR VAR ASSIGN VAR BIN_OP 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()) D = input() s = 0 b = 42069666 for c in range(1, L): if D[c] != "0": if abs(L / 2 - c) < b: b = abs(L / 2 - c) s = c def c(s): if s == "": return 0 return int(s) res = c(D[:s]) + c(D[s:]) if L % 2: r = L // 2 if D[r] != "0": res = ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING IF FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR VAR FUNC_DEF IF VAR STRING RETURN NUMBER RETURN 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()) l = input() arr = [] for i in range(len(l)): if l[i] != "0": arr.append((abs(n // 2 - i), i)) arr.sort() ans = 10**100001 for i in range(min(4, len(arr))): if arr[i][1] == 0: continue ans = min(ans, int(l[arr[i][1] :]) + int(l[: arr[i][1]])) print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR 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 ...
n = int(input()) s = input() S = 10**100000 def raspil(number): global S pos = number while pos < n and s[pos] == "0": pos += 1 if pos < n: S = min(S, int(s[pos:]) + int(s[:pos])) pos = number while pos >= 0 and s[pos] == "0": pos -= 1 if pos > 0: S = min(S,...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER FUNC_DEF ASSIGN VAR VAR WHILE VAR VAR VAR VAR STRING VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR WHILE VAR NUMBER VAR VAR STRING VAR NUMBER IF VAR NUMB...
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() s = input() x = [] for i in range(1, len(s)): if s[i] == "0": continue x += [(max(i, len(s) - i), i)] x.sort() y = [] for j, i in x[:10]: y += [int(s[:i]) + int(s[i:])] y.sort() print(y[0])
EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING VAR LIST FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR VAR NUMBER VAR LIST BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL 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()) a = input() s = str(a) ans = 1e1000 cnt = 0 for i in range(n // 2, -1, -1): if s[int(i + 1)] == "0": continue ans = min(ans, int(s[0 : i + 1]) + int(s[i + 1 : n])) cnt = cnt + 1 if cnt >= 2: break cnt = 0 for i in range(n // 2, n - 1, 1): if s[int(i + 1)] == "0": ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR FUNC_CALL VAR BIN_OP VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER FUNC_CALL 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() def func(m): l = r = t = "" for i in range(0, m): l += s[i] for i in range(m, n): r += s[i] cn = 0 for i in range(0, len(r)): if r[i] == "0": l += "0" cn = cn + 1 else: break r = r[cn:] if len(...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR VAR STRING FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING VAR STRING ASSIGN VAR BIN_OP VAR NUMBER 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() n = int(s) ans = n a = [] for i in range(l): a.append(int(s[i])) a = a[::-1] al = l for i in range(l): if a[i] > 0: temp = i + 1 if temp < l - i - 1: temp = l - i - 1 if al > temp: al = temp for i in range(l): if a[i] > 0: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF 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 ...
def check(s, n): ans = 0 j = 0 for i in range(n // 2, n): j = n - i if s[i] != "0" and s[j] != "0": sumi = getsum(s, i) sumj = getsum(s, j) if sumi < sumj: ans = i else: ans = j elif s[i] != "0": ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR STRING VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR IF VAR VAR STRING ASSIGN VAR VAR IF VAR VAR STRING ASSIGN 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 ...
from sys import stdin input = stdin.readline l = int(input()) n = input().rstrip() if l % 2 == 0: i = l // 2 elif int(n[0]) == int(n[l // 2 + 1]): if int(n[: l // 2]) <= int(n[l // 2 + 1 :]): i = l // 2 + 1 else: i = l // 2 elif int(n[0]) > int(n[l // 2 + 1]): i = l // 2 else: i = l...
ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER 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 ...
q = int(input()) w = input() r = [] k = int(w) if q % 2 == 0: e = q // 2 i = 1 j = 1 l = 1 if w[e] == "0": while l: if w[e + j] != "0": k = int(w[: e + j]) + int(w[e + j :]) l = 0 j += 1 if w[e - i] != "0": k...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR STRING WHILE VAR IF VAR BIN_OP VAR VAR STRING ASSIGN VAR BIN_OP 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 = input() n = input() l = int(l) half = l // 2 if l % 2 == 1: half1 = l // 2 + 1 else: half1 = l // 2 while n[half] == "0" and n[half1] == "0" and half > 1: half = half - 1 half1 = half1 + 1 sum1 = int(n[:half]) + int(n[half:]) sum2 = int(n[:half1]) + int(n[half1:]) if n[half] == "0": sum1 = int(n...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR STRING VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER 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()) s = input() k = n / 2 r = int(k) while r < n and s[r] == "0": r = r + 1 l = int(k - 1) while l >= 0 and s[l] == "0": l = l - 1 mn = -1 if l != 0: mn = int(s[:l]) + int(s[l:]) else: mn = int(s) if r != n and mn > int(s[:r]) + int(s[r:]): mn = int(s[:r]) + int(s[r:]) elif mn > int(s):...
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 WHILE VAR VAR VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER 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 ...
def minsplit(n, m): if n[m] == "0": i = m while i >= 1 and n[i] == "0": i -= 1 if i == 0: k1 = -1 else: k1 = int(n[:i]) + int(n[i:]) i = m while i < len(n) and n[i] == "0": i += 1 if i == len(n): k2 =...
FUNC_DEF IF VAR VAR STRING ASSIGN VAR VAR WHILE VAR NUMBER VAR VAR STRING VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR WHILE VAR FUNC_CALL VAR VAR VAR VAR STRING VAR NUMBER IF VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL 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()) s = input() i = len(s) // 2 j = len(s) // 2 + 1 res = int(s) while i > 0 and s[i] == "0": i -= 1 if i > 0: res = min(res, int(s[:i]) + int(s[i:])) while j < len(s) and s[j] == "0": j += 1 if j < len(s): res = min(res, int(s[:j]) + int(s[j:])) print(res)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR NUMBER VAR VAR STRING VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL 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 ...
a = int(input("")) b = str(input("")) c = int(a / 2) g = int(b) for i in range(c, 0, -1): if b[i] != "0": e = int(b[:i]) f = int(b[i:]) g = e + f break for i in range(c + 1, len(b)): if b[i] != "0": h = int(b[:i]) j = int(b[i:]) k = h + j g = min(g...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR 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 ...
def solve(): l = int(input()) num = input() h = l // 2 if num[h] == "0": j = h while j < l and num[j] == "0": j += 1 if j == l: ans = int(num) else: ans = int(num[:j]) + int(num[j:]) j = h while j > 0 and num[j] == "0": ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR STRING ASSIGN VAR VAR WHILE VAR VAR VAR VAR STRING VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR WHILE VAR NUMBER VAR VAR STR...
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()) string = input() if n % 2 == 0: right = n // 2 else: right = n // 2 + 1 left = right - 1 while left > 0 and string[left] == "0": left -= 1 while right < n and string[right] == "0": right += 1 if left != 0 and right < n: ans1 = int(string[:right]) + int(string[right:]) ans2 = int...
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 ASSIGN VAR BIN_OP BIN_OP VAR NUMBER 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 VAR VAR ASSIGN 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 ...
def calc(line, pos): if pos == len(line): return int(line) if line[pos] != "0" or pos == 0 or pos == len(line) - 1: L = line[:pos] if pos != 0 else 0 R = line[pos:] if L == "0" or R == "0": return pow(10, 200000) return int(L) + int(R) else: right ...
FUNC_DEF IF VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR VAR IF VAR STRING VAR STRING RETURN FUNC_CALL VAR NUMBER NUMBER RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR WHILE VAR F...
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()) mn = int(s) pos = [] cnt = 0 for i in range(n // 2, n): if cnt < 3 and s[i] != "0": pos.append(i) cnt += 1 cnt = 0 for i in range(n // 2 - 1, 0, -1): if cnt < 3 and s[i] != "0": pos.append(i) cnt += 1 for i in pos: s1 = s[:i] s2 = s[i:] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR NUMBER VAR VAR STRING EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP 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 ...
import sys input = sys.stdin.readline n = int(input()) x = input() xx = int(x) if n == 2: print(int(x[0]) + int(x[1])) exit(0) li = n // 2 ri = n // 2 + 1 if n % 2 == 0 and x[n // 2] != "0": print(int(x[: n // 2]) + int(x[n // 2 :])) exit(0) if n % 2 == 0: li = n // 2 - 1 while True: ans1 = ans...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF BIN_OP 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 ...
l = int(input()) s = input() i = l // 2 if s[i] == "0": j = i while s[i] == "0": i += 1 if i == l: break while s[j] == "0": j -= 1 if j == 0: if i == l: print(s) else: print(int(s[:i]) + int(s[i:])) elif i == l: prin...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR STRING ASSIGN VAR VAR WHILE VAR VAR STRING VAR NUMBER IF VAR VAR WHILE VAR VAR STRING VAR NUMBER IF VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR I...
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() flag = 0 i = 0 while flag == 0: if n // 2 + i < n: if a[n // 2 + i] != "0": break if n // 2 - i >= 0: if a[n // 2 - i] != "0": break i += 1 min = int(a) if n // 2 + i + 1 < n: if a[n // 2 + i + 1] != "0": if int(a[n // 2 + i + ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER VAR VAR IF VAR BIN_OP BIN_OP VAR NUMBER VAR STRING IF BIN_OP BIN_OP VAR NUMBER VAR NUMBER IF VAR BIN_OP BIN_OP VAR NUMBER VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL 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() res = int(n) toCheck = [l // 2, (l + 1) // 2] while toCheck[0] > 1 and n[toCheck[0]] == "0": toCheck[0] -= 1 while toCheck[1] < l - 1 and n[toCheck[1]] == "0": toCheck[1] += 1 for pos in toCheck: v1 = n[:pos] v2 = n[pos:] if v1[0] != "0" and v2[0] != "0": res = m...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER WHILE VAR NUMBER NUMBER VAR VAR NUMBER STRING VAR NUMBER NUMBER WHILE VAR NUMBER BIN_OP VAR NUMBER VAR VAR NUMBER STRING VAR NUMBER NUMBER FOR VAR VAR 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()) n = input() ans = int(n) mid = l // 2 L = mid while L > 0 and n[L] == "0": L -= 1 R = mid + 1 while R < l and n[R] == "0": R += 1 if L != 0 and R != l: num1 = n[0:R] num2 = n[R:l] ans = min(ans, int(num1) + int(num2)) num1 = n[0:L] num2 = n[L:l] ans = min(ans, int(num1) ...
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 VAR WHILE VAR NUMBER VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER IF VAR NUMBER VAR VAR ASSIGN VAR VAR NUMBER VAR ASSIGN 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 ...
l = int(input()) n = input() mid = l // 2 if l % 2 == 0 and n[mid] != "0": print(int(n[:mid]) + int(n[mid:])) else: ans = -1 pos = mid while pos > 0 and n[pos] == "0": pos -= 1 if pos != 0: ans = int(n[:pos]) + int(n[pos:]) pos = mid + 1 while pos < l and n[pos] == "0": ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER VAR VAR STRING VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP 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()) s = str(input()) best = None mid = l // 2 cnt = 0 for i, c in enumerate(s[mid:]): if c != "0": if mid + i >= len(s): break l = s[: mid + i] r = s[mid + i :] if r[0] == "0": continue sm = int(l) + int(r) if best is None or best ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NONE ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR IF VAR STRING IF BIN_OP VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR IF VAR NUMBER STRING 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()) string = input() n = len(string) res = 0 def getMin(left, right): left1 = left right1 = right left2 = left right2 = right while right1.startswith("0") and len(right1) > 1: left1 = left1 + right1[0] right1 = right1[1 : len(right1)] while right2.startswith("0") a...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR WHILE FUNC_CALL VAR STRING FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR NUMBER FUNC_CALL VAR VAR WHILE 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 ...
l = int(input()) n = input() s = 10**100000 * 9 + 1 mid = l // 2 c = 0 while mid >= 1: if n[mid] == "0": mid -= 1 continue x1 = int(n[0:mid]) x2 = int(n[mid:]) s2 = x1 + x2 if s2 < s: s = s2 c += 1 mid -= 1 if c == 3: break mid = l // 2 + 1 c = 0 while mid...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR 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 ...
k = int(input()) n = int(input()) s = str(n) x, y = -1, -1 for i in reversed(range(k // 2 + 1)): if s[i] != "0": x = i break for i in range(k // 2 + 1, k): if s[i] != "0": y = i break ans1, ans2 = 0, 0 if x > 0: ans1 = int(s[:x]) + int(s[x:]) if y > 0: ans2 = int(s[:y]) +...
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 NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR 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 ...
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() r = n // 2 - 2 d = r + 4 ans = int(x) while r <= d: if r < 1: r += 1 continue if r >= n: r += 1 continue w = r if x[w] == "0": while w < n and x[w] == "0": w += 1 if w < n: ans = min(ans, int(x[0:w]) + i...
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 VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR IF VAR NUMBER VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR VAR IF VAR VAR STRING WHILE VAR VAR VAR VAR STRING VAR NUMBER IF VAR VAR 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 ...
mod = 1000000007 ii = lambda: int(input()) si = lambda: input() dgl = lambda: list(map(int, input())) f = lambda: map(int, input().split()) il = lambda: list(map(int, input().split())) ls = lambda: list(input()) n = ii() ind1 = 0 ind2 = n + 1 s = si() for i in range(n // 2 + 1, n): if s[i] != "0": ind2 = i ...
ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL 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 ...
import sys sys.setrecursionlimit(10**5 + 10) def input(): return sys.stdin.readline().strip() def resolve(): l = int(input()) n = str(input()) ans = float("inf") if l % 2 == 0: cur = l // 2 d = 0 while True: found = False if cur + d < l and n[cur ...
IMPORT EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER 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 ...
n = int(input()) str = input() ans = "" for i in range(len(str)): ans += "9" ans = int(ans) def check(str, pos): global ans if pos <= 0: return if str[pos] == "0": while str[pos] == "0": pos -= 1 if pos > 0: ans = min(ans, int(str[:pos]) + int(str[pos:])...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF IF VAR NUMBER RETURN IF VAR VAR STRING WHILE VAR VAR STRING VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR 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 = int(input()) s = input() j = 0 k = 0 if N % 2 == 0: if 1: a = N b = 0 for i in range(N // 2, N): if s[i] != "0": a = i break for i in range(N // 2 - 1, -1, -1): if s[i] != "0": b = i break ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER IF NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR STRING ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER 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 ...
n = int(input()) s = input() c = 0 ans = -1 k = n % 2 if n == 2: print(int(s[0]) + int(s[1])) else: if s[n // 2] != "0" and n % 2 == 1: ans = int(s[0 : n // 2]) + int(s[n // 2 :]) while s[n // 2 - c - 1] == "0" and s[n // 2 + c + k] == "0": c += 1 if s[n // 2 - c - 1] != "0" and n // 2 -...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER 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()) ans = 10**100000 l = L // 2 r = L // 2 + 1 while l > 0 and N[l] == "0": l -= 1 while r < L and N[r] == "0": r += 1 if l != 0: ans = min(ans, int(N[:l]) + int(N[l:])) if r != L: ans = min(ans, int(N[:r]) + int(N[r:])) print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER WHILE VAR NUMBER VAR VAR STRING VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR 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 ...
n = int(input()) s = input().strip() mid = n // 2 while mid + 1 < n and s[mid + 1] == "0": mid += 1 left = s[: mid + 1] right = s[mid + 1 :] if not right or not left: var1 = int(s) else: var1 = int(s[: mid + 1]) + int(s[mid + 1 :]) mid = n // 2 while mid >= 0 and s[mid] == "0": mid -= 1 left = s[:mid] r...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP 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() def solve(a): x = n[:a] y = n[a:] if x == "" or y == "": return None elif x[0] == "0" or y[0] == "0": return None while len(x) < len(y): x = "0" + x while len(y) < len(x): y = "0" + y z, c = "", 0 for xr, yr in zip(x[::-1], y...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR IF VAR STRING VAR STRING RETURN NONE IF VAR NUMBER STRING VAR NUMBER STRING RETURN NONE WHILE FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP STRING VAR WHILE FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN V...