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 ...
n = int(input()) x = input() l = n // 2 r = (n + 1) // 2 fn = lambda i: int(x[:i]) + int(x[i:]) while x[l] == "0": l -= 1 while x[r] == "0": r += 1 if r == n: break ans = float("inf") if l != 0: ans = min(ans, fn(l)) if r != n: ans = min(ans, fn(r)) print(ans)
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 BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR WHILE VAR VAR STRING VAR NUMBER WHILE VAR VAR STRING VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR STRING IF 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 ...
def closest_nonzero(s, h, l): index1 = 0 index = 0 for i in range(h, l): if n[i] != "0": index = i break for i in range(h, -1, -1): if n[i] != "0": index1 = i break return index, index1 l = int(input()) n = input() half = l // 2 if l ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN 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 VAR STRING ASSIGN VAR VAR RETURN VAR 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 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 a = sys.stdin.read().split()[1].strip() ans = int(a) n = len(a) k = n // 2 m = 0 i = k while m < 3 and i < n: if a[i] != "0": m += 1 s = int(a[:i]) + int(a[i:]) if s < ans: ans = s i += 1 m = 0 i = k while m < 3 and i > 0: if a[i] != "0": m += 1 ...
IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER VAR VAR IF VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR 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 ...
n = int(input()) b = input() aaa = n // 2 if n & 1 == 0: for i in range(0, aaa): num1 = aaa + i num = n - num1 if b[num] == "0" and b[num1] == "0": continue elif b[num] == "0": ans1 = int(b[:num1]) + int(b[num1:n]) print(ans1) break ...
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 FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR STRING VAR VAR STRING IF VAR VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR 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 = str(input()) ans = int(n) mid = int(l / 2 + 1) while mid < int(l): if n[mid] == "0": mid += 1 continue l1 = n[0:mid] l2 = n[mid:] ans1 = int(l1) + int(l2) ans = min(ans, ans1) mid += 1 break mid = int(l / 2) while mid > 0: if n[mid] == "0": mi...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER ASSIGN VAR VAR NUMBER VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR 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 summ(i): global a b = a[:i] c = a[i:] if len(b) < len(c): b = [0] * (len(c) - len(b)) + b[:] if len(c) < len(b): c = [0] * (len(b) - len(c)) + c[:] ans = ["0"] * len(b) car = 0 for i in range(len(b) - 1, -1, -1): ans[i] = str((int(b[i]) + int(c[i]) + car) % 10...
FUNC_DEF ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP LIST STRI...
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()) a1 = 0 a2 = 0 for i in range(l // 2 + 1, l): n1 = n[i:] n2 = n[:i] if n1[0] == "0": continue else: a1 = int(n1) + int(n2) break for i in range(l // 2, 0, -1): n1 = n[i:] n2 = n[:i] if n1[0] == "0": continue else: a...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR IF VAR NUMBER STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL 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()) a = input() i_l = n // 2 i_r = n // 2 + 1 while i_r < n and a[i_r] == "0": i_r += 1 min1 = 2**64 - 1 if i_r != n: min1 = int(a[0:i_r]) + int(a[i_r:]) while i_l >= 0 and a[i_l] == "0": i_l -= 1 if i_l > 0: min1 = min(min1, int(a[0:i_l]) + int(a[i_l:])) print(min1)
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 VAR VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER IF VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR WHILE VAR NUMBER 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() mn = int(N) m = (L - 1) // 2 for i in range(m, -1, -1): if N[i + 1] == "0": continue mn = min(mn, int(N[0 : i + 1]) + int(N[i + 1 :])) break m = L // 2 for i in range(m, L): if N[i] == "0": continue mn = min(mn, int(N[0:i]) + int(N[i:])) break print(m...
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 FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF 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 VAR VAR BIN_OP 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 = "0" + input() n += 1 ind = n // 2 ans = [] i = c = 0 while ind - i > 0 and ind + i < n: if s[ind + i] != "0": ans.append(int(s[: ind + i]) + int(s[ind + i :])) c += 1 if s[ind - i] != "0": ans.append(int(s[: ind - i]) + int(s[ind - i :])) c += 1 i += 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP STRING FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR VAR NUMBER WHILE BIN_OP VAR VAR NUMBER BIN_OP VAR VAR VAR 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 ...
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() al_l = [] al_r = [] for i in range(1, n): if int(s[i]) > 0 and i <= n // 2: al_l.append(i) if int(s[i]) > 0 and i > n // 2: al_r.append(i) if len(al_r) == 3: break if len(al_l) == 3: del al_l[0] ans = int(s) for x in al_l: ans = min(ans, i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR IF FUNC_CALL VAR VAR VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER IF 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 = list(input()) ans = int("".join(n)) if l == 1: print(ans) exit(0) f = 0 for i in range(l // 2, 0, -1): if n[i] != "0": ans = min(ans, int("".join(n[:i])) + int("".join(n[i:]))) f = 1 if n[l - i] != "0": ans = min(ans, int("".join(n[: l - i])) + int("".join(n[...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR 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 ...
l = int(input()) num = str(input()) n = int(num) x = len(num) mns = n * 100 h = (x - 1) // 2 def test(i): s = int(num[:i]) + int(num[i:]) if s < mns: return s return mns ct = 0 for i in range(h, -1, -1): if num[i] != "0" and i > 0: mns = test(i) ct += 1 if ct >= 3: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR RETURN VAR RETURN 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()) n = str(input()) mid = int(l / 2) m1 = int(n) m2 = int(n) sp = mid for i in range(sp, 0, -1): if n[i] != "0": temp = int(n[:i]) + int(n[i:]) if m1 > temp: m1 = temp else: break else: pass sp = mid + 1 for i in range(sp, len(n)): if n[i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR 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 ...
n = int(input()) s = input() mid = len(s) // 2 l = mid r = mid + 1 while l >= 0 and s[l] == "0": l -= 1 while r < len(s) and s[r] == "0": r += 1 if r == len(s): s1 = int(s[0:l]) s2 = int(s[l:]) print(s1 + s2) elif l == 0: s1 = int(s[0:r]) s2 = int(s[r:]) print(s1 + s2) else: s1 = int...
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 ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR VAR STRING VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR STRING VAR NUMBER IF VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER 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 ...
n = int(input()) s = input() l = n // 2 ans = int(s) if s[l] != "0": ans = int("0" + s[:l]) + int("0" + s[l:]) for i in range(1, n): if l + i < n and s[l + i] != "0": ans = min(ans, int("0" + s[: l + i]) + int("0" + s[l + i :])) if l - i >= 0 and s[l - i] != "0": ans = min(ans, int("0" + 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 IF VAR VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP STRING VAR VAR FUNC_CALL VAR BIN_OP STRING VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR STRING 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 ...
l = int(input()) n = input() k = 1 i = l // 2 j = l // 2 + 1 while i > 0 and n[i] == "0": i -= 1 while j < l and n[j] == "0": j += 1 ans = -1 if i >= 1: b = int(n[:i]) + int(n[i:]) if ans == -1 or ans > b: ans = b if j < l: b = int(n[:j]) + int(n[j:]) if ans == -1 or ans > b: ans...
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 BIN_OP VAR NUMBER NUMBER WHILE VAR NUMBER VAR VAR STRING VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR 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()) val = input() mid = n // 2 while mid < n and val[mid] == "0": mid += 1 anmid = n // 2 while anmid > -1 and val[anmid] == "0": anmid -= 1 ans = 10**n if anmid != 0: ans = int(val[:anmid]) + int(val[anmid:]) if mid != n: ans = min(ans, int(val[:mid]) + int(val[mid:])) mid = n // 2 + 1 anm...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR IF VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF 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 ...
T = int(input()) s = input() mid = len(s) // 2 MIN = -1 if len(s) < 3: print(int(s[0]) + int(s[1])) return for i in range(mid, -1, -1): if s[i + 1] != "0": MIN = int(s[: i + 1]) + int(s[i + 1 :]) break for i in range(mid, len(s)): if s[i] != "0": tmp = int(s[:i]) + int(s[i:]) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER RETURN FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER STRING ASSIGN 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()) s = input() v = [] for i in range(1, len(s)): if s[i] != "0": v.append(i) ans = 1e1000 ch = int(s) for i in range(0, len(v)): if v[i] > l // 2: ans = min(ans, int(ch // int(pow(10, l - v[i]))) + ch % int(pow(10, l - v[i]))) if i > 0: ans = min( ...
ASSIGN VAR FUNC_CALL VAR 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 EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR BIN_OP 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 ...
l = int(input()) s = input() res = None noimp = 0 for it in range(l - 1): i = 0 if it % 2 == 0: i = l // 2 - (it + 1) // 2 else: i = l // 2 + (it + 1) // 2 if s[i] == "0": continue cur = int(s[0:i]) + int(s[i:]) if res is None: res = cur elif cur < res: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NONE ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER 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 ...
n = int(input()) a = input() ans = None i = n // 2 for q in range(n // 2): if a[: i + q][0] != "0" and a[i + q :][0] != "0": if ans is None: ans = int(a[: i + q]) + int(a[i + q :]) else: ans = min(ans, int(a[: i + q]) + int(a[i + q :])) if a[: i - q][0] != "0" and a[i - q...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NONE ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR VAR NUMBER STRING VAR BIN_OP VAR VAR NUMBER STRING IF VAR NONE ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR VAR FUNC_CALL VAR VAR BIN_OP 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 ...
def fun(s, l): if l == 1: return int(s) else: i = l // 2 j = i a = s[:i] b = s[j:] front = int(s) while 1: if b[0] == "0": j += 1 i += 1 a = s[:i] b = s[j:] if a ==...
FUNC_DEF IF VAR NUMBER RETURN FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR WHILE NUMBER IF VAR NUMBER STRING VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR IF VAR STRING VAR STRING ASSIGN VAR BIN_OP FUNC_CALL 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 = input() s = input() s = str(s) mid = int(len(s) / 2) num = -1 i = mid - 1 while i >= 0: if s[i + 1] == "0": i = i - 1 continue s1 = s[: i + 1] s2 = s[i + 1 :] if num == -1: num = int(s1) + int(s2) else: num = min(int(s1) + int(s2), num) break i = i - 1 for...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR 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()) s = input() ans = 10**100001 if n % 2 == 0: flag = 0 for i in range(n // 2): if s[n // 2 - i] != "0": ans = min(ans, int(s[0 : n // 2 - i]) + int(s[n // 2 - i :])) flag += 1 if flag > 2: break flag = 0 for i in range(n // 2): i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR BIN_OP BIN_OP VAR NUMBER VAR STRING ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP BIN_OP VAR NUMBER 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()) s = input() ans = int(s) cut = n // 2 if s[cut] != "0": ans = min(int(s[:cut]) + int(s[cut:]), int(s[: cut + 1]) + int(s[cut + 1 :])) else: cut1 = cut cut2 = cut while cut1 >= 0 and s[cut1] == "0": cut1 -= 1 while cut2 < n and s[cut2] == "0": cut2 += 1 if cut1 > ...
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 IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN 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 ...
def ssum(s, spl): l = s[:spl] r = s[spl:] p = 0 ret = "" carry = 0 while p < len(l) or p < len(r): dl = int(l[-p - 1]) if p < len(l) else 0 dr = int(r[-p - 1]) if p < len(r) else 0 tmp = carry + int(dl) + int(dr) if tmp > 9: tmp -= 10 carry...
FUNC_DEF ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER 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 ...
n = int(input()) s = input() if n % 2: if s[n // 2] != "0": print( min( int(s[: n // 2]) + int(s[n // 2 :]), int(s[: n // 2 + 1]) + int(s[n // 2 + 1 :]), ) ) else: s1 = s[: n // 2] s2 = s[n // 2 :] mn = int(s) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR VAR BIN_OP 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 ...
a = int(input()) b = input() mid = a // 2 f = mid s = mid while f > 0 and b[f] == "0": f = f - 1 while s < a - 1 and b[s] == "0": s = s + 1 ans = 1e1000 for number in [-1, 0, 1]: keysA = f + number keysB = s + number fa = 0 fb = 0 sa = 0 sb = 0 if len(b[:keysA]) > 0: fa = int...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR WHILE VAR NUMBER VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR BIN_OP VAR NUMBER VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR LIST NUMBER NUMBER NUMBER ASSIGN 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 ...
size = int(input()) number = list(input()) if size < 5: min_num = 99999999 for start2 in range(1, size): if number[start2] == "0": continue num = int("".join(number[:start2])) + int("".join(number[start2:])) if num < min_num: min_num = num print(min_num) e...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL STRING VAR VAR FUNC_CALL VAR FUNC_CALL STRING VAR VAR IF VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR EXPR 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() ans = -1 for i in range(int(l / 2), l): if n[i] == "0": continue tmp = int(n[0:i]) + int(n[i:]) if tmp < ans or ans == -1: ans = tmp if i > int(l / 2): break for i in range(int(l / 2), 0, -1): if n[i] == "0": continue tmp = int(n[0:i])...
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 VAR NUMBER VAR IF VAR VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR IF VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR 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 ...
def fun(): i = m - 1 while i >= 0 and s[i + 1] == "0": i -= 1 j = m + 1 while j < l and s[j] == "0": j += 1 if i < 0: a = int(s) + 1 else: a = int(s[: i + 1]) + int(s[i + 1 :]) if j == l: b = int(s) + 1 else: b = int(s[:j]) + int(s[j:]) ...
FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF 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 = input() r = input() n = int(n) ans = int(r) for i in range(n // 2, 0, -1): j = r[0:i] k = r[i:n] if len(j) == 0 or len(k) == 0 or j[0] == "0" or k[0] == "0": continue int_j = int(j) int_k = int(k) ans = min(ans, int_j + int_k) break for i in range(n // 2 + 1, n, 1): j = r[0:i...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER VAR ASSIGN VAR VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR NUMBER STRING VAR NUMBER STRING 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 ...
def get(i): s1 = s[0:i] s2 = s[i:n] j = 0 while j < len(s2) and s2[j] == "0": j += 1 k = i - 1 while k >= 0 and s1[k] == "0": k -= 1 if j == len(s2): a = int(s) else: a = int(s1 + "0" * j) + int(s2[j : len(s2)]) if k == 0: b = int(s1[k : len(s1...
FUNC_DEF ASSIGN VAR VAR NUMBER VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR VAR STRING VAR NUMBER IF VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR BIN_OP STRING 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()) s = str(input()) inf = 10**10**5 minsum = inf flag = False for i in range(n // 2, n): if s[i] != "0": flag = True minsum = min(minsum, int(s[:i]) + int(s[i:])) if s[n - i] != "0": flag = True minsum = min(minsum, int(s[: n - i]) + int(s[n - i :])) if flag: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR 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, s = int(input()), input() ans = int(s) def check(a, b): b = b[::-1] b, a = list(b), list(a) while len(b) and b[-1] == "0": b.pop() a.append("0") if not len(b): return b = b[::-1] b = "".join(b) a = "".join(a) global ans ans = min(ans, int(a) + int(b)) d...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR WHILE FUNC_CALL VAR VAR VAR NUMBER STRING EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR RETURN ASSIGN VAR 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()) s = input() ans = int(s) min_len = l pos = [] for i in range(l - 1): if s[i + 1] == "0": continue ll = max(i + 1, l - 1 - i) + 1 if ll < min_len: pos = [i] min_len = ll elif ll == min_len: pos.append(i) else: continue for p in pos: ss = in...
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 BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR LIST 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 ...
def shTofhShiftIfZero(s, fh, sh): curr = "" for i in sh: if i == "0": curr += "0" else: break fh += curr sh = sh[len(curr) :] if fh == "": fh = 0 if sh == "": sh = 0 sum1 = int(fh) + int(sh) return sum1 def fhToshShiftIfZero(s, fh...
FUNC_DEF ASSIGN VAR STRING FOR VAR VAR IF VAR STRING VAR STRING VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR IF VAR STRING ASSIGN VAR NUMBER IF VAR STRING ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR STRING ASSIGN VAR VAR NUMBER FOR VAR VAR IF VAR STRING 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()) s = input() mi = int(s) mid = l // 2 while mid < l: if s[mid] == "0": mid += 1 else: break if mid < l: mi = min(mi, int(s[:mid]) + int(s[mid:])) mid = l // 2 + 1 while mid < l: if s[mid] == "0": mid += 1 else: break if mid < l: mi = min(mi, int(s[...
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 WHILE VAR VAR IF 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 BIN_OP BIN_OP VAR NUMBER NUMBER WHILE 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 ...
n = int(input()) S = str(input()).strip() ans = int(S) l = n // 2 r = n // 2 while l >= 0 and S[l] == "0": l -= 1 while r < len(S) and S[r] == "0": r += 1 for i in [l, r]: for j in range(max(i - 2, 1), min(len(S), i + 2)): if S[j] != "0": ans = min(ans, int(S[:j]) + int(S[j:])) print(ans...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR VAR STRING VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR STRING VAR NUMBER FOR VAR LIST VAR VAR FOR VAR FUNC_CALL 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()) s = input() ans = 1e1000 mid = n // 2 i = mid while i > 0: if s[i] != "0": a = int(s[:i]) b = int(s[i:]) ans = a + b break i -= 1 i = mid + 1 while i < len(s): if s[i] != "0": a = int(s[:i]) b = int(s[i:]) ans = min(ans, a + b) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR WHILE VAR 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 VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE 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 ...
l = int(input()) s = input() n = int(s) mitad = l // 2 base = mitad + 1 while base < l and s[base] == "0": base += 1 base = 10 ** (l - base) a = n // base b = n % base sol = a + b base = mitad while base > 0 and s[base] == "0": base -= 1 base = 10 ** (l - base) a = n // base b = n % base sol = min(sol, a + b) p...
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 VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP 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 ...
def calc(s, a): return int(s[:a]) + int(s[a:]) n = int(input()) s = input() if n % 2 == 0: if s[n // 2] != "0": print(calc(s, n // 2)) else: a = n // 2 - 1 b = n // 2 while s[a] == "0" and s[b] == "0": a -= 1 b += 1 res = -1 if s[a] !...
FUNC_DEF RETURN BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER WH...
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() first = [None] * (n - 1) for i in range(n - 1): if s[i + 1] == "0": first[i] = -1 continue if n % 2 == 1: if i < n // 2: first[i] = int(s[i + 1]) else: first[i] = int(s[i]) elif i == n // 2: first[i] = max(int(s[i])...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NONE BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER 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()) n = input() p = 1 if l & 1 else 0 while n[l + p >> 1] == "0" and n[l - p >> 1] == "0": p += 2 if n[l + p >> 1] == "0": print(int(n[l - p >> 1 :]) + int(n[: l - p >> 1])) elif n[l - p >> 1] == "0": print(int(n[l + p >> 1 :]) + int(n[: l + p >> 1])) else: print( min( i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER NUMBER WHILE VAR BIN_OP BIN_OP VAR VAR NUMBER STRING VAR BIN_OP BIN_OP VAR VAR NUMBER STRING VAR NUMBER IF VAR BIN_OP BIN_OP VAR VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR BIN_OP BIN_OP 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 ...
x = int(input()) li_t = list(input()) len1 = len(li_t) len1 = len1 // 2 li_t1 = li_t[:len1] li_t2 = li_t[len1:] i = 0 if li_t1[-1] == "0" and li_t2[0] == "0": while i <= len(li_t2) - 1 and li_t2[i] == "0": i += 1 li_t1 = li_t[: len1 + i] li_t2 = li_t[len1 + i :] if li_t1 != []: li_t1 = 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 BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER STRING VAR NUMBER STRING WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR STRING VAR NUMBER ASSIGN 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() t = int(l / 2) if l == 2: print(int(n[0]) + int(n[1])) elif l == 3: if n[1] == "0": print(int(n[0:2]) + int(n[2])) else: print(min(int(n[0:2]) + int(n[2]), int(n[0]) + int(n[1:3]))) elif l % 2 == 0: if n[t] != "0": print(int(n[0:t]) + int(n[t:l])) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL 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 NUMBER IF VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER FUNC_CALL VAR VAR NUMBER 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().strip() k1 = n // 2 + 1 k2 = n // 2 while k1 < n - 1 and s[k1] == "0": k1 += 1 while k2 > 0 and s[k2] == "0": k2 -= 1 if k1 == n or s[k1:n] == "0": print(int(s[0:k2]) + int(s[k2:n])) elif k2 == 0 or s[0:k2] == "0": print(int(s[0:k1]) + int(s[k1:n])) else: print(min(int(s...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR BIN_OP VAR NUMBER VAR VAR STRING VAR NUMBER WHILE VAR NUMBER VAR VAR STRING VAR NUMBER IF VAR VAR VAR VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL 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 suu(a, b): a = int(a) b = int(b) return a + b def go(): l = int(input()) s = str(input()) mid = l // 2 pos = l - 1 while 1: if s[pos] == "0": pos -= 1 else: break if pos < mid: print(suu(s[:pos], s[pos:])) return if s[...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR RETURN BIN_OP VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE NUMBER IF VAR VAR STRING VAR NUMBER IF VAR VAR EXPR FUNC_CALL 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 ...
def solve(p2, n, s): p3 = p2 while p2 < n and s[p2] == "0": p2 += 1 while p3 >= 0 and s[p3] == "0": p3 -= 1 res = float("inf") if p2 != 0 and p2 != n: res = int(s[0:p2]) + int(s[p2:]) if p3 != 0 and p3 != n: res = min(res, int(s[0:p3]) + int(s[p3:])) return re...
FUNC_DEF ASSIGN VAR VAR WHILE VAR VAR VAR VAR STRING VAR NUMBER WHILE VAR NUMBER VAR VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER 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()) s = input() min_val = n for i in range(1, n): if s[i] == "0": continue min_val = min(min_val, max(i, n - i)) ans = int(s) for i in range(1, n): if s[i] == "0": continue if max(i, n - i) < min_val - 1 or max(i, n - i) > min_val: continue candi = int(s[:i]) + i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR 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 FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING IF FUNC_CALL VAR VAR BIN_OP VAR VAR 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()) num = input() mid = int(n / 2) if n % 2 == 1: mid = mid + 1 ans = 0 if num[mid] != "0": ans1 = int(num[0:mid]) + int(num[mid:]) if n % 2 == 1 and num[mid - 1] != "0": ans2 = int(num[0 : mid - 1]) + int(num[mid - 1 :]) ans = min(ans1, ans2) else: ans = ans1 else: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER 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 f = sys.stdin out = sys.stdout l = int(f.readline().rstrip("\r\n")) n = f.readline().rstrip("\r\n") ans = int(n) p = l >> 1 while p < l and n[p] == "0": p += 1 if p < l: ans = min(ans, int(n[:p]) + int(n[p:])) p += 1 while p < l and n[p] == "0": p += 1 if p < l: ans = min(ans, int(n[:p]) + i...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL 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 BIN_OP FUNC_CALL VAR VAR 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 ...
l = int(input()) n = str(input()) best_len = l best = int(n) to_try = [] for i in range(l - 1): if n[i + 1] != "0": candidate = max(i + 1, l - i - 1) + 1 if candidate < best_len: to_try.clear() to_try.append(i + 1) best_len = candidate elif candidate == be...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER NUMBER 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 ...
def asdf(): l = int(input()) s = input() n = int(s) mid = l // 2 mini = n k = 0 for i in range(0, l // 2 + 1): ind = mid + i if 0 < ind < l and s[ind] != "0": mini = min(mini, int(s[:ind]) + int(s[ind:])) k += 1 ind = mid - i if 0 < ind...
FUNC_DEF 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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR IF NUMBER VAR VAR VAR VAR STRING 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 ...
def check(s1, s2): if len(s1) == 0 or len(s2) == 0 or s2[0] == "0": return -1 else: return int(s1) + int(s2) dummy = input() str = input() left = 0 right = 0 if len(str) % 2 == 0: left = len(str) // 2 - 1 right = len(str) // 2 else: left = len(str) // 2 right = len(str) // 2 an...
FUNC_DEF IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR NUMBER STRING RETURN NUMBER RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL 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 ...
n = int(input()) s = str(input()) ans = 10 ** (10**5 + 1) i = n // 2 + 1 while i < n and s[i] == "0": i += 1 if i < n: ans = min(ans, int(s[:i]) + int(s[i:])) i = n // 2 while s[i] == "0": i -= 1 if i > 0: ans = min(ans, int(s[:i]) + int(s[i:])) print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER 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 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() num = int(s) p = n // 2 + 1 while p < n and s[p] == "0": p += 1 p -= 1 p = 10 ** (n - p - 1) l, r = divmod(num, p) m = l + r p = n // 2 while p > -1 and s[p] == "0": p -= 1 p -= 1 p = 10 ** (n - p - 1) l, r = divmod(num, p) m = min(m, l + r) print(m)
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 WHILE VAR VAR VAR VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN 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 ...
l = int(input()) inp = input() inp1 = list(inp) mid = l // 2 toLeft = 0 toRight = l if l % 2 != 0: if inp[mid] != "0": opt1 = int(inp[: mid + 1]) opt2 = int(inp[mid:]) if opt1 < opt2: ans = opt1 + int(inp[mid + 1 :]) else: ans = opt2 + int(inp[:mid]) else:...
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 NUMBER ASSIGN VAR VAR IF BIN_OP VAR NUMBER NUMBER IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP 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 ...
def ans(string, sep, l): first = int(string[0:sep]) second = int(string[sep:l]) return first + second l = int(input()) string = input() mid = l // 2 a = 0 b = 0 for i in range(mid, 0, -1): if string[i] != "0": a = ans(string, i, l) break for i in range(mid + 1, l): if string[i] != ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR VAR STRING 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 ...
def main(): l = int(input()) n = input() data = [] for i in range(1, l): if n[i] == "0": continue data.append((abs(l // 2 - i), i)) data.sort() res = -1 for i in range(0, min(10, len(data))): start = data[i][1] x = int(n[0:start]) y = int(n...
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 BIN_OP BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR 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 ...
l = int(input()) s = input() n = int(s) mid = l // 2 ans = 10**l for i in range(mid + 1, l): if s[i].isdigit() and s[i] != "0": exp = 10 ** (l - i) fir = n // exp sec = n % exp ans = min(ans, fir + sec) break for i in range(mid, 0, -1): if s[i].isdigit() and s[i] != "0": ...
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 NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF FUNC_CALL VAR VAR VAR VAR STRING ASSIGN VAR BIN_OP NUMBER BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP 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() split = [1] * l for i in range(l): if s[i] == "0": split[i] = 0 if l % 2: c1 = l // 2 c2 = 1 + l // 2 else: c1 = l // 2 c2 = l // 2 i = 0 while 1: if c1 - i >= 0 and split[c1 - i]: m1 = int(s[: c1 - i]) + int(s[c1 - i :]) else: m1 = -1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN 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()) a = input() i = l // 2 ans = -1 while i > 0 and a[i] == "0": i -= 1 r = l // 2 + 1 while r < l and a[r] == "0": r += 1 for j in [i, i - 1, r, r + 1]: if j > 0 and j < l: if a[j] != "0": if ans == -1: ans = int(a[:j]) + int(a[j:]) else: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN 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 FOR VAR LIST VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER IF VAR NUMBER 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 ...
l = int(input()) s = input() ans = 10**100005 l1, l2 = l // 2, (l + 1) // 2 check = False while True: if s[l1] != "0": check = True m1 = int(s[:l1]) m2 = int(s[l1:]) b = m1 + m2 ans = min(ans, b) if s[l2] != "0": check = True m1 = int(s[:l2]) m2 = ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF VAR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP 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()) a = input() left = [] right = [] t = "" c = 0 idex = n // 2 if n % 2 == 0: if a[idex] == "0": while idex < n and a[idex] == "0": idex += 1 if idex == n: left = int(a) else: left = int(a[:idex]) + int(a[idex:]) idex = n // 2 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER IF VAR VAR STRING WHILE VAR VAR VAR VAR STRING VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP 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().strip()) n = str(input().strip()) n1 = n[: l // 2] n2 = n[l // 2 :] if n1[-1] != "0" and n2[0] != "0": if l % 2 == 0: print(int(n1) + int(n2)) else: print( min( int(n[: l // 2]) + int(n[l // 2 :]), int(n[: l // 2 + 1]) + int(n[l // 2 + ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER STRING VAR NUMBER STRING IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL 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() d = set(s) if "0" in d: mi = 0 m = len(s) for i in range(n // 2 - 1, 0, -1): if s[i] != "0": mi = i break for i in range(n // 2, len(s)): if s[i] != "0": m = i break if mi == 0: mi = int(s) else:...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF STRING VAR ASSIGN VAR NUMBER 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 VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL 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 ...
n = input() no = input() n = int(n) if no[n // 2] != "0": ans = int(no[0 : n // 2]) + int(no[n // 2 : n + 1]) if n // 2 + 1 < n and no[n // 2 + 1] != "0": b = int(no[0 : n // 2 + 1]) + int(no[n // 2 + 1 : n]) ans = min(ans, b) if n // 2 + 2 < n and no[n // 2 + 2] != "0": b = int(no[0...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER STRING ASSIGN 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 ...
n = int(input()) num = input() ind = int(n / 2) mini = int(num) while num[ind] == "0": ind += 1 if ind == n: break for i in range(max(1, ind - 1), min(ind + 2, n)): if num[i] != "0": mini = min(mini, int(num[0:i]) + int(num[i:n])) ind = int(n / 2) while num[ind] == "0": ind -= 1 for i in...
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 WHILE VAR VAR STRING VAR NUMBER IF VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR STRING ASSIGN 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 ...
def res(digits): if "0" not in digits: if len(digits) % 2 == 0: return int(digits[: len(digits) // 2]) + int(digits[len(digits) // 2 :]) else: mid = len(digits) // 2 return min( int(digits[:mid]) + int(digits[mid:]), int(digits[: mi...
FUNC_DEF IF STRING VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER RETURN BIN_OP FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER RETURN FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR 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()) a = input() ans = -1 mid = l // 2 for i in range(mid, 0, -1): if a[i] != "0": if ans != -1: ans = min(ans, int(a[0:i]) + int(a[i:])) else: ans = int(a[0:i]) + int(a[i:]) break for i in range(mid + 1, l): if a[i] != "0": if ans != -1: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR VAR STRING IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER 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 ...
import sys mod = 1000000007 get_arr = lambda: list(map(int, input().split())) get_int = lambda: int(input()) get_ints = lambda: map(int, input().split()) get_str = lambda: input() get_strs = lambda: input().split() n = get_int() s = get_str() ans = int(s) j = 0 for i in range(n // 2, n): if j > 3: break ...
IMPORT ASSIGN VAR NUMBER 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 VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN 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()) s = input() vec = [] for i in range(1, l): if s[i] == "0": continue vec.append(i) vec = sorted(vec, key=lambda x: abs(x - l / 2)) ans = 10**100000 cnt = 0 for i in vec: cnt += 1 if cnt > 4: break 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 LIST FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR NUMBER IF 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()) a = input() minsum = -1 if n > 1000: start = n // 2 - 3 end = n // 2 + 3 else: start = 1 end = n i = start while start < end and start < n: str1 = a[:start] str2 = a[start:] if str1[0] != "0" and str2[0] != "0": temp = int(str1) + int(str2) if minsum == -1 or...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR WHILE VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR IF VAR NUMBER STRING 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 ...
def sum(str1, str2): if len(str1) > len(str2): t = str1 str1 = str2 str2 = t str = "" n1 = len(str1) n2 = len(str2) str1 = str1[::-1] str2 = str2[::-1] carry = 0 for i in range(n1): sum = ord(str1[i]) - 48 + (ord(str2[i]) - 48 + carry) str += chr(s...
FUNC_DEF IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER BIN_OP BI...
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 = -1 cnt = 0 le = len(s) i = max(1, le // 2) while i < le and cnt < 7: while i + 1 < le and s[i] == "0": i += 1 l = s[:i] r = s[i:] cnt += 1 i += 1 if l[0] == "0" or r[0] == "0": continue if ans == -1: ans = int(l) + int(r) el...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER WHILE VAR VAR VAR NUMBER WHILE BIN_OP VAR NUMBER VAR VAR VAR STRING VAR NUMBER ASSIGN VAR VAR VAR ASSIGN 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 solve(S): n = len(S) cands = [] i = n // 2 while i > 0 and S[i] == "0": i -= 1 cands.append(i) j = n // 2 + 1 while j < n and S[j] == "0": j += 1 cands.append(j) sums = [] for i in set(cands): if i == 0: sums.append([S, "0"]) elif i...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR 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 ...
l = int(input()) n = input() ans = int(n) mid = l // 2 if n[mid] != "0": ans = int(n[:mid]) + int(n[mid:]) i = l // 2 out = False for j in range(1, mid + 1): if i + j < l: if n[i + j] != "0": temp = int(n[: i + j]) + int(n[i + j :]) ans = min(ans, temp) out = True ...
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 IF VAR VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR 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 ...
import sys input = sys.stdin.readline N = int(input()) S = input().rstrip() L = [[] for _ in range(N)] for n in range(N - 1): if S[n + 1] != "0": L[max(n + 1, N - n - 1)].append(n) def make_sum(s1, s2): if len(s1) < len(s2): tmp = s2 s2 = s1 s1 = tmp l1, l2 = len(s1), len(...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR FUNC_DEF 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 ...
import sys l = int(input()) s = input() n = l // 2 ans = 0 c1, c2 = int(s), int(s) f = 0 while n > 0: k = l - n if s[n] != "0": c1 = int(s[0:n:1]) + int(s[n:l:1]) f = 1 if s[k] != "0": c2 = int(s[0:k:1]) + int(s[k:l:1]) f = 1 if f == 1: ans = min(c1, c2) ...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER 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()) n = input() good = l // 2 lgood = good - 1 rgood = good + 1 if n[good] != "0": print(min(int(n[:good]) + int(n[good:]), int(n[: 1 + good]) + int(n[1 + good :]))) else: while lgood > 0 and n[lgood] == "0": lgood -= 1 while rgood < l and n[rgood] == "0": rgood += 1 if lgoo...
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 IF VAR VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR BIN_OP NUMBER 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 ...
def mp(): return map(int, input().split()) n = int(input()) a = input() b = cnt = 0 for i in range(n // 2, n): if a[i] != "0": t = int(int(a[:i]) + int(a[i:])) if b == 0 or t < b: b = t cnt += 1 if cnt > 2: break cnt = 0 for i in range(n // 2, 0, -1): if a[i...
FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR VAR ASSIGN 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 ...
n = int(input()) s = input() ans = int(s) ind = set() for i in range(0, n): if s[i] != "0": ind.add(i) L, R = False, False for i in range(0, n): if n // 2 - i > 0 and not L: if n // 2 - i in ind: ans = min(ans, int(s[: n // 2 - i]) + int(s[n // 2 - i :])) L = True if ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR IF BIN_OP 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()) a = input() l = len(a) aa = int(a) ans = -1 pos = int(l / 2) pos1 = pos pos2 = pos while pos1 < l and a[pos1] == "0": pos1 += 1 while pos2 >= 0 and a[pos2] == "0": pos2 -= 1 try: n1 = a[:pos1] n2 = a[pos1:] ans = int(n1) + int(n2) except: pass if pos1 + 1 < l and a[pos1 + 1] != ...
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 FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR WHILE VAR VAR VAR VAR STRING VAR NUMBER WHILE VAR NUMBER VAR VAR STRING VAR NUMBER ASSIGN VAR VAR VAR 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 ...
n = int(input()) s = input() num = int(s) pos1, pos2 = len(s) // 2 - 1, len(s) // 2 + 1 while pos1 >= 0 and s[pos1] == "0": pos1 -= 1 while pos2 < n and s[pos2] == "0": pos2 += 1 for i in range(max(1, pos1), min(n, pos2 + 1)): if s[i:][0] == "0": continue num = min(int(s[:i]) + int(s[i:]), num) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER WHILE VAR NUMBER VAR VAR STRING VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL 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 ...
length = int(input()) l = input() min_s = None start_pos = length // 2 end_pos = start_pos start_count = 0 while start_pos > 0: if l[start_pos] != "0": n1 = l[:start_pos] n2 = l[start_pos:] start_count += 1 if min_s == None: min_s = int(n1) + int(n2) else: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NONE ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR VAR STRING ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR VAR NUMBER IF VAR NONE ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL 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 ...
l = int(input()) n = input() x1, x2 = l // 2, (l + 1) // 2 min_val = 10**1000000 while True: flag = False if n[x1] != "0": a = int(n[:x1]) b = int(n[x1:]) min_val = min(min_val, a + b) flag = True if n[x2] != "0": a = int(n[:x2]) b = int(n[x2:]) min_va...
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 BIN_OP NUMBER NUMBER WHILE NUMBER ASSIGN VAR NUMBER IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP 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 len(s) == 2: print(int(s[0]) + int(s[1])) exit(0) met = len(s) // 2 if s[n // 2] != "0" and s[n // 2 + 1] != "0" and s[n // 2 - 1 + (n == 3)] != "0": print( min( int(s[: n // 2 + 1]) + int(s[n // 2 + 1 :]), min( int(s[: n // 2])...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR 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 FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP BIN_OP VAR NUMBER NUMBER STRING 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() ok = False if n % 2: if s[n // 2] != "0": print( min( int(s[: n // 2]) + int(s[n // 2 :]), int(s[: n // 2 + 1]) + int(s[n // 2 + 1 :]), ) ) ok = True elif s[n // 2] != "0": s1 = s[: n // 2] s2 = s[n ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER 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 ...
l = int(input()) n = input() mid = l // 2 + 1 ans = int(n) for x in range(mid, 0, -1): if n[x] == "0": continue ans = min(ans, int(n[:x]) + int(n[x:])) break mid = l // 2 for x in range(mid, l - 1): if n[x] == "0": continue ans = min(ans, int(n[:x]) + int(n[x:])) break print(ans)
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 FOR VAR FUNC_CALL VAR 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 VAR BIN_OP VAR NUMBER FOR 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 ...
l = int(input()) n = str(input()) mn = -1 midpoint = l // 2 i = midpoint numright = 0 while numright < 5 and i < l - 1: if n[i + 1] != "0": first = int(n[: i + 1]) second = int(n[i + 1 :]) if mn == -1: mn = first + second else: mn = min(mn, first + second) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP 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() lim = n // 2 ans = -1 cnt = 0 for i in range(lim, 0, -1): if cnt >= 3: break if s[i] == "0": continue res = int(s[0:i]) + int(s[i:]) if ans == -1: ans = res else: ans = min(ans, res) cnt += 1 cnt = 0 for i in range(lim, n): if cnt ...
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 NUMBER NUMBER IF VAR NUMBER IF VAR VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER ASSIGN VAR VAR 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 = int(input()) s = str(input()) z = n // 2 l = z p = "9" * 113110 p = int(p) res = p cnt = 0 for i in range(l, n): if s[i] == "0": continue cnt += 1 s1 = s[:i] s2 = s[i:] s1 = int(s1) s2 = int(s2) p = min(p, s1 + s2) if cnt >= 3: break cnt = 0 for i in range(l, 0, -1): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP STRING NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR IF VAR VAR STRING VAR NUMBER ASSIGN VAR VAR VAR ASSIGN 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 ...
n = int(input()) s = input() j = (n + 1) // 2 i = j - 1 r = int(s) while i > 0 and s[i] == "0": i -= 1 while j < n and s[j] == "0": j += 1 if i > 0: w = int(s[0:i]) + int(s[i:]) r = min(r, w) if j < n: k = int(s[0:j]) + int(s[j:]) r = min(r, k) print(r)
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 NUMBER VAR VAR STRING VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER 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 ...
def cal(s, inx, len): l = int(s[0:inx]) r = int(s[inx:len]) return l + r n = int(input()) s = input() res = -1 i = n // 2 flag = 1 while flag != 0: i += 1 if i > n - 1: break if s[i] == "0": continue flag -= 1 if res == -1: res = cal(s, i, n) else: r...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR RETURN BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER 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 ...
len = int(input()) s = input() best = 0 best2 = 0 for i in range(1, len): if s[i] != "0": if max(i, len - i) < max(best, len - best): best = i elif max(i, len - i) == max(best, len - best): best2 = i ans = int(s[:best]) + int(s[best:]) if best2 != 0: anss = int(s[:best2])...
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 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 ASSIGN VAR VAR 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 ...
import sys def main(): l = input("") n = input("") min = -1 n = str(n) i = 0 j = 1 while i < int(len(n) // 2): if len(n) % 2 == 0: if n[int(len(n) // 2) + i] != "0": a = n[: int(len(n) // 2) + i] b = n[int(len(n) // 2) + i :] ...
IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER IF VAR BIN_OP FUNC_CALL VAR BIN_OP 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 ...
def main(): q = int(input()) s = input() ans = 10**1000000 for i in range(max(1, q // 2 - 1), q): if s[i] != "0" or s[q - i] != "0": if s[i] != "0": ans = min(ans, int(s[:i]) + int(s[i:])) if s[q - i] != "0": ans = min(ans, int(s[: q - i]) ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER VAR IF VAR VAR STRING VAR BIN_OP VAR VAR STRING IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR VAR 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 ...
n, s = int(input()), input() for i in range((n - 1) // 2, -1, -1): if s[i + 1] == "0": continue best = int(s[: i + 1]) + int(s[i + 1 :]) break for i in range(n // 2, n): if s[i] == "0": continue best = min(best, int(s[:i]) + int(s[i:])) break print(best)
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER 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 FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR STRING ASSIGN VAR ...