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 ...
L = int(input()) s = input() best = int(s) for i in range((L + 1) // 2, 0, -1): if s[i] != "0": a = int(s[:i]) b = int(s[i:]) best = min(best, a + b) break for i in range(L // 2, L): if s[i] != "0": a = int(s[:i]) b = int(s[i:]) best = min(best, a + b) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER NUMBER IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR 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 ...
n = int(input()) num = input() start = len(num) // 2 ans = -1 for i in range(start, len(num) - 1): if num[i + 1] != "0": ans = int(num[: i + 1]) + int(num[i + 1 :]) break for i in range(start): if num[start - i] != "0": if ans == -1 or int(num[: start - i]) + int(num[start - i :]) < ans:...
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 FOR VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR 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_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()) s = input() ans = 10**100000 + 2 i = n // 2 j = n // 2 + 1 cp = 0 while i > 0: if s[i] != "0": cp += 1 ans = ans = min(ans, int(s[0:i]) + int(s[i:n])) i -= 1 if cp == 3: break cp = 0 while j < n: if s[j] != "0": cp += 1 ans = ans = min(ans, int(s[...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR VAR STRING VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR 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()) m = input() ans = 10**110000 ind = n // 2 while ind >= 0: if m[ind] != "0": break ind -= 1 if ind > 0: ans = min(ans, int(m[:ind]) + int(m[ind:])) ind = n // 2 + 1 while ind < n: if m[ind] != "0": break ind += 1 if ind < n: ans = min(ans, int(m[:ind]) + int(m[ind...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR NUMBER 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 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() v = int(s) i = len(s) // 2 if len(s) % 2 == 0 and s[i] != "0": v = int(s[0:i]) + int(s[i:]) elif len(s) % 2 == 1 and s[i] != "0" and s[i - 1] != "0" and s[i + 1] != "0": v = int(s[0:i]) + int(s[i:]) v = min(v, int(s[0 : i + 1]) + int(s[i + 1 :])) else: while i > 0: i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR VAR STRING 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 ...
le = int(input()) num = input() data = [0] * 2 for i in range(le // 2 + 1, le): if num[i] != "0": data[1] = i break for i in range(le // 2, -1, -1): if num[i] != "0": data[0] = i break num = "0" + num print( min( int(num[: data[0] + 1]) + int(num[data[0] + 1 :]), ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR IF VAR VAR STRING ASSIGN VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR STRING ASSIGN VAR NUMBER VAR ASSIGN VAR BIN_OP STRING 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() result = int(n) for k, i in ((1, len(n) // 2), (-1, (len(n) + 1) // 2)): while 0 < i < len(n) and n[i] == "0": i += k if 0 < i < len(n): result = min(result, int(n[:i]) + int(n[i:])) print(result)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER WHILE NUMBER VAR FUNC_CALL VAR VAR VAR VAR STRING VAR VAR IF NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR 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()) l = str(input()) value = int(l) if n % 2 == 0: i = int(n / 2) while i < n and l[i] == "0": i += 1 if i != n: x = l[:i] y = l[i:] if x == "": x = 0 if y == "": y = 0 value = min(value, int(x) + int(y)) i = int(n / 2)...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR IF VAR STRING ASSIGN VAR NUMBER IF 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 ...
k = int(input()) s = input() k2 = k / 2 Y = k + 1 if k - s.count("0") > 1: for i in range(k): if s[i] != "0": z = abs(i - k2) if z < Y: Y = z elif z == Y: kk1 = int(s[int(Y + k2) :]) kk3 = int(s[: int(Y + k2)]) ...
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 BIN_OP VAR FUNC_CALL VAR STRING NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR VAR IF VAR VAR ASSIGN VAR 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 ...
l = int(input()) n = input() c = int(n) i = l // 2 while i > 0 and n[i] == "0": i -= 1 if i <= 0: break if i > 0: t = int(n[0:i]) + int(n[i:]) c = min(c, t) i = (l + 1) // 2 while i < l and n[i] == "0": i += 1 if i < l: t = int(n[0:i]) + int(n[i:l]) c = min(c, t) print(c)
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 NUMBER VAR VAR STRING VAR NUMBER IF VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR 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 ...
def findright(ind): mid1 = float("+inf") for i in range(ind + 1, nils): if nil[i] != nil[i - 1] + 1: mid1 = nil[i - 1] + 1 break if nil[-1] < n - 1: mid1 = min(mid1, nil[-1] + 1) return mid1 def findleft(ind): mid2 = 0 if ind == 0: mid2 = nil[ind...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER IF VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER IF VAR 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 ...
l = int(input()) s = input() var = [] z = int(s[0]) n = len(s) for i in range(1, n): if s[i] != "0": var.append((i, n - i, int(s[i]))) for i in range(0, len(var)): if var[i][0] > var[i][1]: break z = i arr = [] for j in range(max(i - 1, 0), min(i + 1, len(var))): arr.append(int(s[: var[j][0]...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR BIN_OP VAR VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR NUMBER...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
l = int(input()) m = input() index = 0 index_right = -1 if m[len(m) // 2] == "0": for i in range(len(m) // 2, -1, -1): if m[i] != "0": index = i break for i in range(len(m) // 2, len(m)): if m[i] != "0": index_right = i break if index_right == ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER STRING FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR VAR STRING ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL 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 ...
def get_sum(string, d): s1 = s[:d] s2 = s[d:] if s1 == "" or s2 == "" or s2[0] == "0": return int(string) return int(s1) + int(s2) def solve(string): if len(string) == 2: return int(s[0]) + int(s[1]) x = len(string) // 2 x1 = x while x < len(string) and string[x] == "0"...
FUNC_DEF ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR IF VAR STRING VAR STRING VAR NUMBER STRING RETURN FUNC_CALL VAR VAR RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR 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()) line = input() if l % 2 == 0: index = l // 2 m = float("inf") while index < l - 1 and line[index] == "0": index += 1 if line[index] != "0": f = int(line[0:index]) s = int(line[index:]) m = min(m, f + s) index = l // 2 + 1 while index >= 1 and line...
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 FUNC_CALL VAR STRING WHILE VAR BIN_OP VAR NUMBER VAR VAR STRING VAR NUMBER IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR 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() poss = [] for i in range(1, n): if s[i] != "0": poss.append((abs(i - (n - i)), i)) poss = sorted(poss) def build(n, s, idx): a = int(s[0 : idx[1]]) b = int(s[idx[1] :]) return a + b v1 = build(n, s, poss[0]) if len(poss) > 1: v2 = build(n, s, poss[1]) pri...
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 VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER R...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's 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) x = l // 2 if s[x] != "0" and s[x + 1] != "0": a = int(s[:x]) b = int(s[x:]) c = int(s[: x + 1]) d = int(s[x + 1 :]) if a + b < c + d: print(a + b) else: print(c + d) elif s[x] != "0": a = int(s[:x]) b = int(s[x:]) print(a ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER 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 solve(x, str): i = (x + 1) // 2 j = i - 1 while i < x and str[i] == "0": i += 1 while j > 0 and str[j] == "0": j -= 1 res = min( int(str[:i]) + int(str[i:] if i != x else 10**100000), int(str[:j] if j != 0 else 10**100000) + int(str[j:]), ) return res de...
FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER WHILE VAR NUMBER VAR VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR BIN_OP NUMBER NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR BIN_OP 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 ...
l = int(input()) s = input() j = l // 2 i = j + 1 while j > 0 and s[j] == "0": j -= 1 while i < l and s[i] == "0": i += 1 print( min( int(s[0 if i >= l else i :]) + int(s[:i]), int(s[j:]) + int(s[: l if j == 0 else j]), ) )
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR VAR STRING VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR 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()) s = str(input()) m = int(s) if l == 2: print(int(s[0]) + int(s[1])) else: for i in range(l // 2, l): if s[i] != "0": m = min(int(s[i:]) + int(s[:i]), m) break for i in range(l // 2 + 1, 0, -1): if s[i] != "0": m = min(int(s[i:]) + int(s[:i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL 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 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_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()) n = input() if n[l // 2] != "0" and n[l // 2 - 1] != "0": print( min( int(n[: l // 2 + 1]) + int(n[l // 2 + 1 :]), int(n[: l // 2]) + int(n[l // 2 :]), ) ) else: i = l // 2 while n[i] == "0": i -= 1 if i != 0: a = int(n[:i]) + ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP BIN_OP VAR NUMBER NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP FUNC_CALL VAR VAR BIN_OP 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 digits2num(digit_list): n = len(digit_list) - 1 ans = 0 for i in range(len(digit_list)): ans += digit_list[i] * 10**n n -= 1 return ans def magic(numList): s = map(str, numList) s = "".join(s) s = int(s) return s def split_number(digits, n): if n % 2 == 0: ...
FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR BIN_OP NUMBER VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF IF 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()) numstr = input() mid = len(numstr) // 2 mn = int(numstr) * 10 zright = mid while zright < len(numstr) and numstr[zright] == "0": zright += 1 zleft = mid while zleft > 0 and numstr[zleft] == "0": zleft -= 1 todo = {i for i in range(zleft - 5, zleft + 5)} for i in range(zright - 5, zright + 5): ...
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 FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR WHILE VAR FUNC_CALL VAR VAR VAR VAR STRING VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER VAR VAR STRING VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL 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()) A = input() answer = float("inf") check = True m = int(n / 2) j = int(n / 2) if n % 2 != 0: m = m + 1 while check: a = A[:m] b = A[m:] c = A[:j] d = A[j:] if (a[0] == "0" or b[0] == "0") and (c[0] == "0" or d[0] == "0"): m += 1 j -= 1 continue if a[0]...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR ASSIGN VAR VAR VAR ASSIGN VAR 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 ...
a1 = int(input()) s = input() min1 = pow(10, 1000000) l1 = a1 // 2 l2 = (a1 - 1) // 2 for i in range(l1, len(s)): if s[i] == "0": continue else: s1 = s[0:i] s2 = s[i : len(s)] if len(s1) > 0 and len(s2) > 0: if s1[0] != "0" and s2[0] != "0": c = int(s1...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR NUMBER VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR 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()) n = input() mid = l // 2 if l % 2 != 0: i = 0 while n[i] == n[l // 2 + i]: i += 1 if n[i] < n[l // 2 + i]: mid += 1 m1 = m2 = mid while m1 < l and n[m1] == "0": m1 += 1 while m2 > 0 and n[m2] == "0": m2 -= 1 out = int(n) if m1 != l: out = min(out, int(n[:m1]) + i...
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 ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP BIN_OP VAR NUMBER VAR VAR NUMBER IF VAR VAR VAR BIN_OP BIN_OP VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR VAR WHILE VAR VAR VAR VAR STRING VAR NUMBER WHILE 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() i = l // 2 + 1 while i < l and n[i] == "0": i += 1 if i == l: ans = int(n) else: ans = int(n[:i]) + int(n[i:]) i = l // 2 while i >= 0 and n[i] == "0": i -= 1 if not (l <= 3 and i == 0): ans = min(ans, int(n[:i]) + int(n[i:])) print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR 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 ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR 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() if s[n // 2] == "0": i = n // 2 while i >= 0 and s[i] == "0": i -= 1 if i < 1: z1 = -1 else: l1 = int(s[:i]) r1 = int(s[i:]) z1 = l1 + r1 j = n // 2 while j < n and s[j] == "0": j += 1 if j == n: z2 = -1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR VAR STRING VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP 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() len1 = n // 2 len2 = (n + 1) // 2 S = 10**100000 def calc(d): nonlocal S h = d while h < n and s[h] == "0": h += 1 if h < n: S = min(S, int(s[h:]) + int(s[:h])) h = d while 0 <= h and s[h] == "0": h -= 1 if 0 < h: S = min(S, int(...
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 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 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() pos = [] bestdiff = 100000000 for i in range(l - 1): if n[i + 1] != "0": pos.append(i) bestdiff = min(bestdiff, max(i + 1, l - i - 1)) ans = [] for i in pos: if max(i + 1, l - i - 1) == bestdiff: ans.append(int(n[: i + 1]) + int(n[i + 1 :])) print(min(ans))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR LIST FOR VAR VAR 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 ...
def main(): n = int(input()) s = input() ans = int(s) half = len(s) // 2 if len(s) % 2 == 0: for i in range(0, half): if s[half + i] == "0" and s[half - i] == "0": continue else: if s[half + i] != "0": ans = min(ans,...
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 FUNC_CALL VAR VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR BIN_OP VAR VAR STRING VAR BIN_OP VAR VAR STRING IF VAR BIN_OP VAR VAR STRING 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 ...
a = int(input()) b = input() d = a // 2 p = d if a & 1: d = d + 1 while d < a: if b[d] is "0": d = d + 1 else: break while p > 0: if b[p] is "0": p = p - 1 else: break if d == a: ans = int(b[0:d]) else: ans = int(b[0:d]) + int(b[d:a]) if p == 0: ans1 = int...
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 ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR 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 ...
MAX = int("9" * 100001) N = int(input()) S = str(input()) a = N // 2 b = N - a while True: M1 = None if S[a] != "0": A1 = S[0:a] B1 = S[a:] M1 = int(A1) + int(B1) M2 = None if S[b] != "0": A2 = S[0:b] B2 = S[b:] M2 = int(A2) + int(B2) if M1 != None and...
ASSIGN VAR FUNC_CALL VAR BIN_OP STRING NUMBER 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 VAR WHILE NUMBER ASSIGN VAR NONE IF VAR VAR STRING ASSIGN VAR VAR NUMBER VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = int(input()) s = input() ar = list(sorted(range(1, n), key=lambda x: max(x, n - x))) t = int(s) rem = 4 for x in ar: if s[x] != "0": if rem == 0: break rem -= 1 t = min(t, int(s[:x]) + int(s[x:])) print(t)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR STRING IF VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR 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 ...
import sys input = sys.stdin.readline n = int(input()) s = input().strip() p = 0 for i in range(n): if s[i] == 0: p += 1 else: break s = s[p:] n = len(s) m = n // 2 while m < n - 1 and s[m] == "0": m += 1 if m == n // 2: if n & 1: a = int(s[m:]) + int(s[:m]) b = int(s[m ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR BIN_OP VAR NUMBER VAR VAR STRING VAR NUMBER IF 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() i = int(n / 2) while i != 0: a = i b = n - a total1, total2 = -1, -1 if s[a] != "0": total1 = int(s[0:a]) + int(s[a:]) if s[b] != "0": total2 = int(s[0:b]) + int(s[b:]) if total1 != -1 and total2 != -1: print(min(total1, total2)) break...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER WHILE VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR NUMBER NUMBER IF VAR VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR IF VAR VAR STRING ASSIGN 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 ...
def get(s): if s is None or s == "": return 0 return int(s) n = int(input()) s = input() l = len(s) m = l >> 1 pl, pr = m, m + 1 while pl >= 0 and s[pl] == "0": pl -= 1 while pr < l and s[pr] == "0": pr += 1 x = min(get(s[:pl]) + get(s[pl:]), get(s[:pr]) + get(s[pr:])) print(x)
FUNC_DEF IF VAR NONE VAR STRING RETURN NUMBER RETURN FUNC_CALL VAR VAR 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 VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR VAR STRING VAR NUMBER WHILE VAR VAR VAR VAR STRING 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 ...
from sys import stdin [_, l] = stdin.readlines() q = list() l = l.strip() for i in range(1, len(l)): if l[i] != "0": q.append((abs(2 * i - len(l)), i)) if len(q) > 3: q.sort(key=lambda v: v[0]) q = q[:4] print(min([(int(l[:i]) + int(l[i:])) for _, i in q]))
ASSIGN LIST VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_C...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = int(input()) a = input() l = (n - 1) // 2 r = n // 2 while a[l] == "0" and a[r] == "0": l -= 1 r += 1 ans = -1 if a[l] != "0" and l > 0: x = int(a[0:l]) y = int(a[l : len(a)]) if ans == -1 or ans > x + y: ans = x + y if a[r] != "0": x = int(a[0:r]) y = int(a[r : len(a)]) if a...
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 VAR STRING VAR VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR 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 ...
l = int(input()) s = input() ans = -1 mid = l // 2 for i in range(mid + 1, l): s1 = s[:i] s2 = s[i:] if s1[0] == "0": continue if s2[0] == "0": continue if ans == -1: ans = int(s1) + int(s2) else: ans = min(ans, int(s1) + int(s2)) break for i in range(mid, 0, ...
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 BIN_OP VAR NUMBER VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR IF VAR NUMBER STRING IF VAR NUMBER STRING IF VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR 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 ...
n = int(input()) s = input() l = max(1, n // 2) r = min(n - 1, n // 2 + 1) ans = -1 cnt = 0 while l >= 0 or r < n: if l > 0 and s[l] != "0": cnt += 1 cur = int(s[:l]) + int(s[l:]) if ans == -1 or cur < ans: ans = cur if r <= n - 1 and s[r] != "0": cur = int(s[:r]) + i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR IF VAR NUMBER VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP 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()) x = input() vpos = [] mpos = n + 1 for i in range(1, n): if x[i] != "0": if mpos > max(i, n - i): mpos = max(i, n - i) vpos = [] if mpos == max(i, n - i): vpos.append(i) def f(a, i): return int(a[i:]) + int(a[:i]) if len(vpos) == 1: pr...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING IF VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR LIST IF VAR FUNC_CALL VAR VAR BIN_OP VAR VAR EXPR 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() if l == 2: print(int(n[0]) + int(n[1])) exit() m = l // 2 i = 1 while not int(n[m]) + int(n[m - i]) + int(n[m + i]): i += 1 potentials = [] if n[: m - i] and n[m - i :] and not n[m - i :].startswith("0"): potentials.append(int(n[: m - i]) + int(n[m - i :])) if n[:m] and n[m:...
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 WHILE BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR 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 trial(s, k): n = int("0" + s[k:]) if not n: return [] k = len(str(n)) return [int(s[:-k]) + int(s[-k:])] def trial2(s, k): r = "".join(reversed(s)) n = int("0" + r[k:]) if not n: return [] k = len(str(n)) if k < 2: return [] return [int(s[: k - 1]) +...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP STRING VAR VAR IF VAR RETURN LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR RETURN LIST BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP STRING VAR VAR IF VAR RETURN LIST ASSIGN 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 ...
num = input() num = input() n = len(num) def split_value(s, ind): ans = int(s) if s[ind + 1] == "0": tmp = ind + 1 while ind >= 0: if s[ind] == "0": ind -= 1 else: s1 = s[:ind] s2 = s[ind:] if s1 == "": ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER IF VAR VAR STRING VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR IF VAR STRING ASSIGN VAR FUNC_CALL VAR VAR BIN_OP 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 kotogula_zero(n): ln = len(n) if ln % 2 == 0: s = n[ln // 2 : ln] s1 = str(int(s)) rt1 = ln // 2 - len(s1) if s1 == "0": rt1 += 1 ss = n[0 : ln // 2][::-1] ss1 = str(int(ss)) rt2 = ln // 2 - len(ss1) if ss1 == "0": rt2 +...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF VAR STRING VAR NUMBER ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL 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 ...
def main(): n = int(input()) s = input().strip() if n % 2 == 0: if s[n // 2] != "0": print(int(s[: n // 2]) + int(s[n // 2 :])) else: i = n // 2 while i > 0 and s[i] == "0": i -= 1 if i != 0: ans1 = int(s[:i]) + ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR VAR STRING VAR NUMBER IF VAR ...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
def readint(): return int(input()) def readfloat(): return float(input()) def readarray(n, f=input): return [f() for i in range(n)] def readlinearray(f=int): return list(map(f, input().split())) def euclide(a, b): if a < 0: g, x, y = euclide(-a, b) return g, -x, y if b < ...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF VAR RETURN FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF VAR RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR RETURN VAR VAR VAR IF VAR 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 ...
def ii(): return int(input()) n = ii() s = input() l = len(s) max_sum = float("inf") def min_sum(i): global max_sum max_sum1 = int(s[: i + 1]) max_sum2 = int(s[i + 1 :]) sum0 = max_sum1 + max_sum2 if sum0 < max_sum: max_sum = sum0 cnt = 0 for i in range(l // 2, -1, -1): if s[i ...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR 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 ...
l = int(input()) n = int(input()) t = str(n) a = [] x = 1 mid = (l + 1) // 2 L = l R = 0 LEN = l - 1 while LEN >= 0: if t[LEN] != "0": if x >= mid: L = min(L, x) if x < mid: R = max(R, x) x += 1 LEN -= 1 N = 100005 ans = 10**N b = [] if L != l: b.append(L) if R !=...
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 ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER IF VAR VAR STRING IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
def smallest(a, b): if len(a) < len(b): return a elif len(b) < len(a): return b else: i = 0 while i < len(a) and a[i] == b[i]: i += 1 if i >= len(a): return a if a[i] < b[i]: return a elif a[i] > b[i]: re...
FUNC_DEF IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR RETURN VAR IF VAR VAR VAR VAR RETURN VAR IF VAR VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSI...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
def f(s): if s == "": return 0 else: return int(s) l = int(input()) s = input() x = l // 2 y = x + 1 while 0 <= y + 1 < l and s[y + 1] == "0": y -= 1 z = x - 1 while 0 <= z + 1 < l and s[z + 1] == "0": z += 1 p = x while 0 <= p + 1 < l and s[p + 1] == "0": p -= 1 q = x while 0 <= q...
FUNC_DEF IF VAR STRING RETURN NUMBER RETURN 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 BIN_OP VAR NUMBER WHILE NUMBER BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE NUMBER BIN_OP 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() x = l // 2 - 1 res = int("9" * 100005) while x < l - 1 and n[x + 1] == "0": x += 1 if x != l - 1: res = int(n[: x + 1]) + int(n[x + 1 :]) x = l // 2 while x < l - 1 and n[x + 1] == "0": x -= 1 if x < l - 1: res = min(res, int(n[: x + 1]) + int(n[x + 1 :])) 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 FUNC_CALL VAR BIN_OP STRING NUMBER WHILE VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR 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()) d = input() l = len(d) half = int(l / 2) minV = None cnt = 0 for i in range(half, l): if d[i] == "0": continue val = int(d[:i]) + int(d[i:]) cnt += 1 if minV is not None: minV = min(minV, val) else: minV = val if cnt >= 2: break cnt = 0 for i in r...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NONE ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER IF VAR NONE 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 ...
sz = int(input()) n = input() if sz % 2 == 0: ptr = sz // 2 if n[ptr] != "0": print(int(n[0:ptr]) + int(n[ptr:sz])) exit(0) while ptr >= 0 and n[ptr] == "0": ptr -= 1 if ptr == 0: ans = int(n) else: ans = int(n[0:ptr]) + int(n[ptr:sz]) ptr = sz // 2 wh...
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 IF VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER WHILE VAR NUMBER VAR VAR STRING VAR NUMBER IF 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 ...
n = input() a = str(input()) idx = (len(a) + 1) // 2 l = idx - 1 r = idx lt = 0 rt = 0 ans = -1 while l > 0: if a[l] != "0": if ans == -1: ans = int(a[:l]) + int(a[l:]) ans = min(ans, int(a[:l]) + int(a[l:])) lt = lt + 1 l = l - 1 if lt >= 2: break while r < len(a...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR VAR STRING IF VAR NUMBER ASSIGN 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 ...
n = int(input()) s = input() def conv(x): try: return int(x) except: return 0 mid = n // 2 if s[mid] == "0": rmid = mid lmid = mid while rmid < n and s[rmid] == "0": rmid += 1 while lmid >= 0 and s[lmid] == "0": lmid -= 1 if rmid == n: rmid = lmid ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR RETURN NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR STRING ASSIGN VAR VAR ASSIGN VAR VAR WHILE VAR VAR VAR VAR STRING VAR NUMBER WHILE VAR NUMBER VAR VAR STRING VAR NUMBER IF VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL 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()) mid = len(s) // 2 index1 = -1 ans1 = -1 for i in range(mid, len(s)): if s[i] != "0": index1 = i break if index1 != -1: ans1 = int(s[:index1]) + int(s[index1:]) index2 = -1 ans2 = -1 for i in range(mid, -1, -1): if s[i + 1] != "0": index2 = i ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR 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()) s = input() mi = int(s) c = 0 for i in range(int(l / 2 + 1), l): if s[i] == "0": continue n1 = int(s[:i]) n2 = int(s[i:]) mi = min(mi, n1 + n2) c += 1 if c >= 2: break c = 0 for i in range(int(l / 2), 0, -1): if s[i] == "0": continue n1 = int(s[:i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER 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 VAR BIN_OP VAR VAR VAR NUMBE...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
l = int(input()) n = input() mid = l // 2 mid1 = mid mid2 = mid + 1 mi = int(n) while mid1 >= 1: if n[mid1] != "0": mi = min(mi, int(n[0:mid1]) + int(n[mid1:])) break mid1 -= 1 while mid2 < l: if n[mid2] != "0": mi = min(mi, int(n[0:mid2]) + int(n[mid2:])) break mid2 += 1...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR NUMBER IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR 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()) str = input() ans = int(str) flg = 0 for i in range(n // 2, 0, -1): tmp1 = str[:i] tmp2 = str[i:] if tmp2[0] != "0": ans = min(ans, int(tmp1) + int(tmp2)) tmp1 = str[: n - i] tmp2 = str[n - i :] if tmp2[0] != "0": flg = 1 ans = min(ans, int(tmp1) + int(tm...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR IF VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR 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 ...
n = int(input()) mstr = str(input()) a = 0 b = int(mstr) ans = 2 * b i = 0 p = len(mstr) l = len(mstr) while mstr[p - 1] == "0": p = p - 1 id = int(l / 2) clr = id + 1 cll = id while clr < l and mstr[clr] == "0": clr = clr + 1 while cll > 0 and mstr[cll] == "0": cll = cll - 1 if clr < l: ans = min(ans, ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR B...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
import sys l = int(input()) n = int(input()) s = str(n) length = len(s) pos1 = max(length // 2 - 1, 1) pos2 = min(length // 2 + 1, length - 1) while pos1 > 1 and s[pos1] == "0": pos1 -= 1 while pos2 < length - 1 and s[pos2] == "0": pos2 += 1 sum = n for p in range(pos1, pos2 + 1): if s[p] != "0": s...
IMPORT 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 FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER WHILE VAR NUMBER VAR VAR STRING VAR NU...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = int(input()) num = input() ans = 10**100005 k = n // 2 for i in range(k, n): if num[i] != "0": ans = int(num[i:]) + int(num[:i]) break for i in range(k + 1, 0, -1): if k + 1 < n and num[i] != "0": ans = min(ans, int(num[i:]) + int(num[:i])) break print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR 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 VAR NUMBER NUMBER NUMBER IF BIN_OP VAR NUMBER VAR VAR VA...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
l = int(input()) n = input() cands = [] for i in range(0, l - 1): if n[i + 1] != "0": cands.append((max(i + 1, l - i - 1), i)) cands.sort() ans = -1 for i in range(0, min(4, len(cands))): mx, idx = cands[i] tmp = int(n[0 : idx + 1]) + int(n[idx + 1 : l]) if ans == -1 or tmp < ans: ans = ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER 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 EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER 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() len = 1000000 ans = int(s) for i in range(0, n - 1): if s[i + 1] is not "0": len = min(max(i + 1, n - i - 1), len) for i in range(0, n - 1): if max(i + 1, n - i - 1) == len and s[i + 1] is not "0": ans = min(ans, int(s[0 : i + 1]) + int(s[i + 1 : n])) print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR FOR 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 ...
l = int(input()) string = input() def right(i): choice = -1 while i < l and string[i] == "0": i += 1 if i < l: choice = int(string[:i]) + int(string[i:]) return choice def left(i): choice = -1 while i > 0 and string[i] == "0": i -= 1 if i > 0: choice = int...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR STRING VAR NUMBER IF VAR NUMBER ASSIGN 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 ...
n = int(input()) s = input() ans = int(s) mid = n // 2 while s[mid] == "0" and mid > 0: mid -= 1 if mid != 0: ans = min(ans, int(s[:mid]) + int(s[mid:])) elif s[1] != "0": ans = min(ans, int(s[0]) + int(s[1:])) mid = n // 2 + 1 while s[mid] == "0" and mid < n - 1: mid += 1 if s[mid] != "0": ans = mi...
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 STRING VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER STRING 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 ...
def de(n, le): if n % 2 == 0: if le % 2 == 0: return le // 2 - 1 - n // 2 else: return le // 2 - n // 2 elif le % 2 == 0: return le // 2 + n // 2 else: return (le + 1) // 2 + n // 2 l = int(input()) n = input() ans = [] for i in range(l): d = de(...
FUNC_DEF IF BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER RETURN BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER RETURN BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
l = int(input()) s = input() if l % 2 == 0: m1 = l // 2 m2 = m1 else: m1 = l // 2 m2 = m1 + 1 while s[m1] == "0" and s[m2] == "0": m1 = m1 - 1 m2 = m2 + 1 if s[m1] == "0": res = int(s[:m2]) + int(s[m2:]) elif s[m2] == "0": res = int(s[:m1]) + int(s[m1:]) else: res = min(int(s[:m1]) +...
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 VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR STRING VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR 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 ...
l = int(input()) n = int(input()) s = str(n) mmax = 1e1000 def cal(x): if x < 1 or x > l - 1: return mmax elif s[l - x] == "0": return mmax else: base = pow(10, x) tmp = n // base + n % base return tmp index = l // 2 mmin = min(min(cal(index), cal(l - index)), min...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FUNC_DEF IF VAR NUMBER VAR BIN_OP VAR NUMBER RETURN VAR IF VAR BIN_OP VAR VAR STRING RETURN VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR RETURN VAR ASSI...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = input() str = input() i = int(len(str) // 2) Len = len(str) ans = "1" for ii in range(1, 100220): ans += "0" ans = int(ans) iii = i while iii < Len: if str[iii] != "0": break iii += 1 jjj = i while jjj >= 0: if str[jjj] != "0": break jjj -= 1 if iii == jjj: for j in range(jjj...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER NUMBER VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR WHILE VAR VAR IF VAR VAR STRING VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER ...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
l = int(input()) n = input() mndig = l consid = 10 ** (l + 1) for i in range(1, l): if n[i] != "0": dig = max((i, l - i)) mndig = min((mndig, dig)) for i in range(1, l): if n[i] != "0": dig = max((i, l - i)) if dig <= mndig + 2: consid = min((consid, int(n[:i]) + int(...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING ASSIGN VAR FUNC_CAL...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
l = int(input()) n = str(input()) ret = int(n) mod_l = l // 2 if l % 2: for i in range(mod_l): if int(n[mod_l + i + 1]): temp = int(n[: mod_l + i + 1]) + int(n[mod_l + i + 1 :]) else: temp = ret if int(n[mod_l - i]): temp = min(temp, int(n[: mod_l - 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 IF BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER FUNC_CALL VAR 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() d = n // 2 som = [] if n % 2 == 0: if s[d] != "0": som.append(int(s[0:d]) + int(s[d:])) else: mid = d while mid < n: if s[mid] != "0": break mid += 1 if mid < n - 1: som.append(int(s[0:mid]) + int(s[...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST IF BIN_OP VAR NUMBER NUMBER IF VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR WHILE VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR BIN_OP 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 ...
l = int(input()) a = input() mn = l for i, v in enumerate(a): if v != "0" and mn > max(i, l - i): mn = max(i, l - i) b = [] for i in range(mn - 1, mn + 2): if i > 0 and i < l: if a[i] != "0": b.append(int(a[:i]) + int(a[i:])) j = l - i if a[j] != "0": b.ap...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF VAR NUMBER VAR VAR IF VAR VAR STRING 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 ...
def summator(s, n): num_1 = int(s[:n]) num_2 = int(s[n:]) return num_1 + num_2 def main_sum(s, n, a, b): for i in range(n // 2): if s[a - i] != "0" or s[b + i] != "0": if s[a - i] == "0": sum_1 = summator(s, b + i) return sum_1 elif s[b +...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN BIN_OP VAR VAR FUNC_DEF FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR VAR STRING VAR BIN_OP VAR VAR STRING IF VAR BIN_OP VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR RETURN VAR IF VAR BIN_OP 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()) s = input() def cmp(x): s1 = s[:x] s2 = s[x:] if s1[0] != "0" and s2[0] != "0": return int(s1) + int(s2) else: return -1 m = -1 i = n // 2 h = 1 if n % 2 == 0: m = cmp(i) while m < 0: m2 = cmp(i + h) m1 = cmp(i - h) if m1 > 0 and m2 > ...
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 NUMBER STRING VAR NUMBER STRING RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FU...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
l = int(input()) s = input() r = int(s) x, y = -1, -1 for i in range(0, l // 2): if s[i + 1] != "0": x = i for i in range((l + 1) // 2, l): if s[i] != "0": y = i break if x != -1: r = min(r, int(s[: x + 1]) + int(s[x + 1 :])) if y != -1: r = min(r, int(s[:y]) + int(s[y:])) print(...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER 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...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
from sys import stdin, stdout l = int(stdin.readline()) s = stdin.readline() i = l // 2 j = (l + 1) // 2 while 1: if i >= 0 and s[i] != "0" and s[j] != "0" and j < l: x = int(s[:i]) + int(s[i:]) y = int(s[:j]) + int(s[j:]) if x < y: stdout.write(str(x)) else: ...
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 NUMBER IF VAR NUMBER VAR VAR STRING VAR VAR STRING VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's 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 findNotZero(s, half): min = 10000000 pos = 0 for i in s: if int(i) != 0: if abs(pos - half) < abs(min - half): min = pos elif abs(pos - half) == abs(min - half): first = "" second = "" for i in s[min:]: ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR IF FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR VAR VAR VAR FUNC_CALL VAR VAR FOR VAR VAR VAR VAR FUNC...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = int(input()) s = input() ans = int(s) for i in range(n // 2 + 1, n): if s[i] == "0": continue a = s[:i] b = s[i:] ans = min(ans, int(a) + int(b)) break for i in range(n // 2, 0, -1): if s[i] == "0": continue a = s[:i] b = s[i:] ans = min(ans, int(a) + int(b)) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR IF VAR VAR STRING ASSIGN VAR VAR VAR ASSIGN 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 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 ...
a = int(input()) b = str(input()) ans = int(b) counter = 1 for i in range(0, a // 2 + 1): s = a // 2 - i if s > 0: if b[s] != "0": ans = min(ans, int(b[:s]) + int(b[s:])) if counter == 1: counter = 2 s = a // 2 + i if a - s > 0: if b[s] != "0": ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR IF VAR NUMBER IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = int(input()) s = input() if n % 2 == 0: i = n // 2 j = i while i < n - 1 and int(s[i]) == 0: i = i + 1 if s[i] != "0": x = int(s[:i]) y = int(s[i:]) Sum = x + y else: Sum = float("inf") i = n // 2 + 1 j = i while j > 0 and int(s[j]) == 0: ...
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 VAR WHILE VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR 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 ...
a = int(input()) l = input() aa = 0 pi = -1 for i in range(a // 2 + 1, a, 1): if l[i] != "0": pi = i break for i in range(a // 2, -1, -1): if l[i] != "0": aa = i break mi = 10**100000 if pi != -1: mi = min(mi, int(l[:pi]) + int(l[pi:])) if aa != 0: mi = min(mi, int(l[:aa]...
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 NUMBER IF VAR VAR STRING ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR STRING ASSIGN VAR VAR ASSIGN VAR BIN_OP NUMBER 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() i = 0 mini = 789546312675 while i + 1 < n: if i + 1 == n: break if s[i + 1] != "0": len1 = i + 1 len2 = n - i - 1 mini = min(mini, max(len1, len2)) i += 1 ans = int(s) i = 0 while i + 1 < n: if i + 1 == n: break if s[i + 1] != "0":...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER VAR IF BIN_OP VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR 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 ...
l = int(input()) n = input() mid = l // 2 def f(pos): if pos == 0 or pos == l or n[pos] == "0": return False return True arr = [] for i in range((l + 1) // 2): pos = mid - i if not (pos == 0 or pos == l or n[pos] == "0"): arr.append(pos) pos = mid + i if not (pos == 0 or pos ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER FUNC_DEF IF VAR NUMBER VAR VAR VAR VAR STRING RETURN NUMBER RETURN NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR VAR VAR VAR STRING EXPR 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()) a = input() ind = l // 2 prev = [] minn = 10**100 start = "" for i in range(0, l // 2): if a[i + 1] != "0": if len(prev) == 0: prev.append(i + 1) elif abs(prev[-1] - l // 2) > abs(i + 1 - l // 2): prev.pop() prev.append(i + 1) prev1 = [] for i in ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR ...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
l = int(input()) n = input() mid = int(l / 2) ans = int(n) cnt = 0 for i in range(mid, 0, -1): if n[i] == "0": continue cnt += 1 if cnt > 3: break a = int(n[0:i]) b = int(n[i:]) ans = min(ans, a + b) cnt = 0 for i in range(mid + 1, l, 1): if n[i] == "0": continue ...
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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR VAR STRING VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR 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 solution(s): k = 1 while s[k] == "0": k += 1 maxsize = max(k, len(s) - k) anscut = k for i in range(k, len(s) - 1): if s[i] != "0": if ( max(i, len(s) - i) < maxsize or max(i, len(s) - i) == maxsize and int(s[:i]) + int(...
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING IF FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR 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 get_min(a, b): if len(a) < len(b): return a if len(a) > len(b): return b return min(a, b) n = int(input()) s = input() l, r = 0, n for i in range(1, n): if s[i] == "0": continue if i <= n // 2: l = i if i > n // 2 and r == n: r = i res1, res2 = "9" *...
FUNC_DEF IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN VAR RETURN FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER ASSIGN 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()) l = input() m = n // 2 flag = True s = int(l) for i in [-1, 0, 1]: m1 = m m1 += i if len(l[m1:]) and len(l[:m1]): if l[m1:][0] != "0": s = min(s, int(l[:m1]) + int(l[m1:])) for i in range(m, len(l)): if l[i] != "0": if len(l[i:]) and len(l[:i]): s...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR LIST NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR VAR IF FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR 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 ...
n = int(input()) s = input() ans = int(s) l = n // 2 while l > 0 and s[l] == "0": l -= 1 if l > 0 and int(s[:l]) + int(s[l:]) < ans: ans = int(s[:l]) + int(s[l:]) r = n // 2 + 1 while r < n and s[r] == "0": r += 1 if r < n and int(s[:r]) + int(s[r:]) < ans: ans = int(s[:r]) + int(s[r:]) if s[1] != "0" a...
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 NUMBER VAR VAR STRING VAR NUMBER IF VAR NUMBER BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR 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 ...
n = int(input()) s = input() k = int(s) res = k c = 0 for i in range(max(n // 2 - 2, 0), n): if s[i] == "0": continue x = k // 10 ** (n - i) y = k % 10 ** (n - i) res = min(res, x + y) c += 1 if c == 3: break c = 0 for i in range(min(n - 1, n // 2 + 2), 0, -1): if s[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 NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER VAR IF VAR VAR STRING ASSIGN VAR BIN_OP VAR BIN_OP NUMBER BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP 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()) s = input() i = n // 2 while i < n and s[i] == "0": i += 1 ans = -1 if i != n: for newi in range(i - 3, i + 3): if newi <= 0 or newi >= n or s[newi] == "0": continue if ans == -1: ans = int(s[:newi]) + int(s[newi:]) else: ans = min(ans...
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 NUMBER IF VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF VAR NUMBER VAR VAR VAR VAR STRING IF 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 ...
l = int(input()) s = input() right = (l // 2, l // 2 + 1)[l % 2] left = (l // 2 - 1, l // 2)[l % 2] while right < l and s[right] == "0": right += 1 while s[left] == "0": left -= 1 if left == 0: left = right if right == l: right = left ans = min(int(s[:right]) + int(s[right:]), int(s[:left]) + int(s[left...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER WHILE VAR VAR STRING VAR NUMBER IF 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() sol_in = 0 best_len = 1000000.0 def zbr(ind): a = n[:ind] b = n[ind:] return int(a) + int(b) for i in range(1, l): if n[i] == "0": continue if max(i, l - i) == best_len: if zbr(i) < zbr(sol_in): sol_in = i if max(i, l - i) < best_len: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR RETURN BIN_OP FUNC_CALL VAR 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 VAR IF FUNC_CALL 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 ...
from sys import stdin, stdout n = int(stdin.readline()) num = stdin.readline() lst = [] may = n for i in range(1, n): if num[i] != "0": may = min(may, max(i, n - i)) for i in range(1, n): if max(i, n - i) <= may: if num[i] != "0": lst.append(int(num[:i]) + int(num[i:])) print(min(ls...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST 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 FOR VAR FUNC_CALL VAR NUMBER VAR IF FUNC_CALL VAR VAR BIN_OP VAR VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR 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()) a = input() i = n // 2 j = i if a[i] == "0": while i < n and a[i] == "0": i += 1 if i == n: i = 1 while a[j] == "0": j -= 1 if j == 0: j = i a1 = int(a[:j]) a2 = int(a[j:]) ans1 = a1 + a2 a3 = int(a[:i]) a4 = int(a[i:]) ans2 = a3 +...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR IF VAR VAR STRING WHILE VAR VAR VAR VAR STRING VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR STRING VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VA...
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ...
n = int(input()) m = n // 2 num = input() ll = m + 1 rr = m while ll < n and num[ll] == "0": ll = ll + 1 while rr >= 0 and num[rr] == "0": rr = rr - 1 if ll == n: print(int(num[0:rr]) + int(num[rr:n])) elif rr == 0: print(int(num[0:ll]) + int(num[ll:n])) else: print(min(int(num[0:ll]) + int(num[ll:n...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VA...