description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Danny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem! You are given $n$ nonnegative integers $a_1, a_2, \dots, a_n$ arranged in a circle, where $n$ must be odd (ie. $n-1$ is divisible by $2$). Formally, for all $i$ such that $2 \leq i \leq n$, the ele...
import sys input = sys.stdin.readline n = int(input()) a = [int(i) for i in input().split() if i != "\n"] prefev = [0] prefod = [0] for i in range(n): if not i & 1: prefod.append(prefod[-1] + a[i]) prefev.append(prefev[-1]) else: prefev.append(prefev[-1] + a[i]) prefod.append(pr...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR STRING ASSIGN VAR LIST NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_...
Danny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem! You are given $n$ nonnegative integers $a_1, a_2, \dots, a_n$ arranged in a circle, where $n$ must be odd (ie. $n-1$ is divisible by $2$). Formally, for all $i$ such that $2 \leq i \leq n$, the ele...
import sys def solve(ls): n = len(ls) k = (n - 1) // 2 s = 0 for i in range(k + 1): s += ls[2 * i] s_max = s for i in range(n): s -= ls[2 * i % n] s += ls[(2 * i + 1) % n] s_max = max(s_max, s) return s_max def main(istr, ostr): n = int(istr.readline()...
IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR BIN_OP NUMBER VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP BIN_OP NUMBER VAR VAR VAR VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER VAR ASSIGN VAR FUNC_CAL...
Danny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem! You are given $n$ nonnegative integers $a_1, a_2, \dots, a_n$ arranged in a circle, where $n$ must be odd (ie. $n-1$ is divisible by $2$). Formally, for all $i$ such that $2 \leq i \leq n$, the ele...
n = int(input()) a = list(map(int, input().split())) a0 = [a[i] for i in range(n) if i % 2 == 0] a1 = [a[i] for i in range(n) if i % 2 == 1] a = a0 + a1 l = n // 2 + 1 ans = sum(a[:l]) ans_sub = sum(a[:l]) for i in range(n): ans_sub -= a[i] ans_sub += a[(i + l) % n] ans = max(ans, ans_sub) print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR FU...
Danny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem! You are given $n$ nonnegative integers $a_1, a_2, \dots, a_n$ arranged in a circle, where $n$ must be odd (ie. $n-1$ is divisible by $2$). Formally, for all $i$ such that $2 \leq i \leq n$, the ele...
n = int(input()) l = [int(x) for x in input().split()] * 2 for i in range(2, 2 * n): l[i] += l[i - 2] s = 0 for i in range(n): if i >= 2: a = l[n + i - 1] - l[i - 2] else: a = l[n + i - 1] s = max(s, a) print(s)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP VAR NUMBER AS...
Danny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem! You are given $n$ nonnegative integers $a_1, a_2, \dots, a_n$ arranged in a circle, where $n$ must be odd (ie. $n-1$ is divisible by $2$). Formally, for all $i$ such that $2 \leq i \leq n$, the ele...
n = int(input()) a = [int(i) for i in input().split()] b = [] for i in range(0, n, 2): b.append(a[i]) else: ind = len(b) for i in range(1, n, 2): b.append(a[i]) b.extend(b) ans = sum(b[:ind]) lsum = ans for i in range(ind, len(b)): lsum -= b[i - ind] lsum += b[i] ans = max(ans, lsum) print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL V...
Danny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem! You are given $n$ nonnegative integers $a_1, a_2, \dots, a_n$ arranged in a circle, where $n$ must be odd (ie. $n-1$ is divisible by $2$). Formally, for all $i$ such that $2 \leq i \leq n$, the ele...
n = int(input()) m = (n + 1) // 2 a = list(map(int, input().split())) curr = 0 for i in range(m): curr += a[2 * i] answer = curr for j in range(n - 1): curr -= a[2 * j % n] curr += a[2 * (j + m) % n] answer = max(answer, curr) print(answer)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP NUMBER VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR BIN_OP BIN_OP NUMBER VAR VAR VAR VAR B...
Danny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem! You are given $n$ nonnegative integers $a_1, a_2, \dots, a_n$ arranged in a circle, where $n$ must be odd (ie. $n-1$ is divisible by $2$). Formally, for all $i$ such that $2 \leq i \leq n$, the ele...
n = int(input()) a = list(map(int, input().split())) if n == 1: print(a[0]) exit(0) v = [sum(a[i] for i in range(j, n, 2)) for j in range(2, 4)] u = [0, 0] ans = 0 for i in range(n): w = u[(i - 2) % 2] + a[i] + a[(i + 1) % n] + v[(i + 3) % 2] ans = max(ans, w) u[i % 2] += a[i] v[(i + 2) % 2] -= ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR NUMBE...
Danny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem! You are given $n$ nonnegative integers $a_1, a_2, \dots, a_n$ arranged in a circle, where $n$ must be odd (ie. $n-1$ is divisible by $2$). Formally, for all $i$ such that $2 \leq i \leq n$, the ele...
for _ in range(1): n = int(input()) a = list(map(int, input().split())) b = [] for i in range(0, n, 2): b += [a[i]] for i in range(1, n, 2): b += [a[i]] b += b size = (n + 1) // 2 ans = 0 total = 0 for i in range(size): total += b[i] ans = total fo...
FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER VAR LIST VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER VAR LIST VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSI...
Danny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem! You are given $n$ nonnegative integers $a_1, a_2, \dots, a_n$ arranged in a circle, where $n$ must be odd (ie. $n-1$ is divisible by $2$). Formally, for all $i$ such that $2 \leq i \leq n$, the ele...
from sys import stdin, stdout int_in = lambda: int(stdin.readline()) arr_in = lambda: [int(x) for x in stdin.readline().split()] mat_in = lambda rows: [arr_in() for _ in range(rows)] str_in = lambda: stdin.readline().strip() out = lambda o: stdout.write("{}\n".format(o)) arr_out = lambda o: out(" ".join(map(str, o))) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR STR...
Danny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem! You are given $n$ nonnegative integers $a_1, a_2, \dots, a_n$ arranged in a circle, where $n$ must be odd (ie. $n-1$ is divisible by $2$). Formally, for all $i$ such that $2 \leq i \leq n$, the ele...
n = int(input()) arr = list(map(int, input().split())) lis = [] for i in range(n + (n - 1) // 2): lis.append(arr[2 * i % n]) ans = sum(lis[: (n + 1) // 2]) temp = ans for i in range(1, n): temp -= lis[i - 1] temp += lis[(n + 1) // 2 + i - 1] ans = max(ans, temp) print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR BIN_OP BIN_OP NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR FOR V...
Danny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem! You are given $n$ nonnegative integers $a_1, a_2, \dots, a_n$ arranged in a circle, where $n$ must be odd (ie. $n-1$ is divisible by $2$). Formally, for all $i$ such that $2 \leq i \leq n$, the ele...
def solve(n, arr): ans = m = sum(arr[:n:2]) for i in range(0, n - 1, 2): m += arr[i + 1] - arr[i] ans = max(m, ans) m = arr[0] + sum(arr[1:n:2]) ans = max(m, ans) for i in range(2, n - 1, 2): m += arr[i] - arr[i - 1] ans = max(m, ans) return ans n = int(input())...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR N...
Danny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem! You are given $n$ nonnegative integers $a_1, a_2, \dots, a_n$ arranged in a circle, where $n$ must be odd (ie. $n-1$ is divisible by $2$). Formally, for all $i$ such that $2 \leq i \leq n$, the ele...
n = int(input()) a = list(map(int, input().split())) b = [a[i] for i in range(0, n, 2)] + [a[i] for i in range(1, n, 2)] b = b + b m = n // 2 + 1 total = sum(b[0:m]) ans = total for i in range(0, n + n - m): total += b[i + m] - b[i] ans = max(ans, total) print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR VAR FUNC_CALL VAR NUMBER VAR NUMBER VAR VAR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR...
Danny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem! You are given $n$ nonnegative integers $a_1, a_2, \dots, a_n$ arranged in a circle, where $n$ must be odd (ie. $n-1$ is divisible by $2$). Formally, for all $i$ such that $2 \leq i \leq n$, the ele...
n = int(input()) a = [int(x) for x in input().split()] if n == 1: print(a[0]) exit() evens = [a[0]] odds = [a[1]] for i in range(2, n): if i % 2 == 0: evens.append(evens[-1] + a[i]) else: odds.append(odds[-1] + a[i]) maxi = 0 for i in range(len(evens)): score = evens[i] if i == 0...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR E...
You are given a string $s$ consisting of $n$ characters. Each character of $s$ is either 0 or 1. A substring of $s$ is a contiguous subsequence of its characters. You have to choose two substrings of $s$ (possibly intersecting, possibly the same, possibly non-intersecting — just any two substrings). After choosing th...
n = int(input()) s = input() i = s.find("1") if i == -1: print(0) else: s1 = s[i:] j = s1.find("0") if j == -1: print(s1) else: s2 = s1[j:] s3 = s1[:j] + "".join(str(int(a) or int(b)) for a, b in zip(s1, s2)) s2 = s1[1:] s4 = s1[:1] + "".join(str(int(a) or int...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR FUNC_CALL STRING FUNC_CALL VAR FUNC_CALL VAR VAR FU...
You are given a string $s$ consisting of $n$ characters. Each character of $s$ is either 0 or 1. A substring of $s$ is a contiguous subsequence of its characters. You have to choose two substrings of $s$ (possibly intersecting, possibly the same, possibly non-intersecting — just any two substrings). After choosing th...
n = int(input()) binary = input() binary = binary.lstrip("0") n = len(binary) p_zero = [] p_one = [] for i in range(n): if binary[i] == "0": p_zero.append(i) else: p_one.append(i) if len(p_one) == 0: print(0) elif len(p_zero) == 0: print(binary) else: size = n - p_zero[0] max_sub...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VA...
You are given a string $s$ consisting of $n$ characters. Each character of $s$ is either 0 or 1. A substring of $s$ is a contiguous subsequence of its characters. You have to choose two substrings of $s$ (possibly intersecting, possibly the same, possibly non-intersecting — just any two substrings). After choosing th...
n = int(input()) s = input() b = int(s, 2) a = b mx = a | b for i in range(0, 7): a = a >> 1 m = a | b if m > mx: mx = m st = format(mx, "b") print(st)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR VAR
You are given a string $s$ consisting of $n$ characters. Each character of $s$ is either 0 or 1. A substring of $s$ is a contiguous subsequence of its characters. You have to choose two substrings of $s$ (possibly intersecting, possibly the same, possibly non-intersecting — just any two substrings). After choosing th...
n = int(input()) s = input() ind = [] index = 0 flag = 0 len_index = 0 ed = 0 for i in range(n): if flag: index += 1 if s[i] == "1": ed = 1 if s[i] == "0" and ed != 0: ind.append(index) flag = 1 len_index += 1 if flag == 0: print(0) exit(0) ln = index mx_s = "...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER IF VAR VAR STRING ASSIGN VAR NUMBER IF VAR VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBER IF VAR ...
You are given a string $s$ consisting of $n$ characters. Each character of $s$ is either 0 or 1. A substring of $s$ is a contiguous subsequence of its characters. You have to choose two substrings of $s$ (possibly intersecting, possibly the same, possibly non-intersecting — just any two substrings). After choosing th...
import sys input = sys.stdin.readline def solve(): n = int(input()) S = input().strip() if S == "1" * n: return S elif S == "0" * n: return "0" m = st1 = 0 ans = 0 for i in range(n - 1): if st1 == 0 and S[i] == "1": st1 = S[i:] st1 = int(st1...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP STRING VAR RETURN VAR IF VAR BIN_OP STRING VAR RETURN STRING ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR VAR STRING ASSIGN VAR VAR VAR ASSIGN VAR F...
You are given a string $s$ consisting of $n$ characters. Each character of $s$ is either 0 or 1. A substring of $s$ is a contiguous subsequence of its characters. You have to choose two substrings of $s$ (possibly intersecting, possibly the same, possibly non-intersecting — just any two substrings). After choosing th...
n = int(input()) s = input() first1 = n for i in range(len(s)): if s[i] == "1": first1 = i break s = s[first1:] if s == "": print(0) else: first0 = n for i in range(len(s)): if s[i] == "0": first0 = i break if first0 == n: print(s) else: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR ASSIGN VAR VAR VAR IF VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR IF VAR VAR EXPR FUNC_...
You are given a string $s$ consisting of $n$ characters. Each character of $s$ is either 0 or 1. A substring of $s$ is a contiguous subsequence of its characters. You have to choose two substrings of $s$ (possibly intersecting, possibly the same, possibly non-intersecting — just any two substrings). After choosing th...
n = int(input()) s = input() if s.count("0") == n: print("0") elif s.count("1") == n: print(s) else: s = s.lstrip("0") n = len(s) a = int(s, 2) p = s.index("0") k = n - p ans = 0 for i in range(n - k): sk = s[i : i + k] b = int(sk, 2) ans = max(a | b, ans) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR STRING VAR EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR STRING VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR ...
You are given a string $s$ consisting of $n$ characters. Each character of $s$ is either 0 or 1. A substring of $s$ is a contiguous subsequence of its characters. You have to choose two substrings of $s$ (possibly intersecting, possibly the same, possibly non-intersecting — just any two substrings). After choosing th...
n = int(input()) s = int(input(), 2) ans = 0 for i in range(20): ans = max(ans, s | s >> i) ans = bin(ans) ans = ans[2:] print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
You are given a string $s$ consisting of $n$ characters. Each character of $s$ is either 0 or 1. A substring of $s$ is a contiguous subsequence of its characters. You have to choose two substrings of $s$ (possibly intersecting, possibly the same, possibly non-intersecting — just any two substrings). After choosing th...
def valOf(inp): return int(inp, base=2) def mainFunc(): n = int(input()) s = input() s = s.lstrip("0") if not s: print(0) return zeroPos = -1 for index, value in enumerate(s): if value == "0": zeroPos = index break if zeroPos == -1: ...
FUNC_DEF RETURN FUNC_CALL VAR VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN ASSIGN VAR BI...
You are given a string $s$ consisting of $n$ characters. Each character of $s$ is either 0 or 1. A substring of $s$ is a contiguous subsequence of its characters. You have to choose two substrings of $s$ (possibly intersecting, possibly the same, possibly non-intersecting — just any two substrings). After choosing th...
def update(s, i, j, n, mx): while j >= i: s[n - 1] |= s[j] j -= 1 n -= 1 mx = max(mx, s) return mx def solve(): n = int(input()) s = input().strip() s = [int(el) for el in s] i = 0 while i < n and s[i] == 0: i += 1 if i == n: print(0) ...
FUNC_DEF WHILE VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CA...
You are given a string $s$ consisting of $n$ characters. Each character of $s$ is either 0 or 1. A substring of $s$ is a contiguous subsequence of its characters. You have to choose two substrings of $s$ (possibly intersecting, possibly the same, possibly non-intersecting — just any two substrings). After choosing th...
import sys input = sys.stdin.readline def pobit(s, s2): i = len(s) - 1 l = len(s2) - 1 ans = [] while l >= 0: if s[i] == "1" or s2[l] == "1": ans.append("1") else: ans.append("0") i -= 1 l -= 1 while i >= 0: ans.append(str(s[i])) ...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST WHILE VAR NUMBER IF VAR VAR STRING VAR VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING VAR NUMBER VAR NUMBER WHILE VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR N...
You are given a string $s$ consisting of $n$ characters. Each character of $s$ is either 0 or 1. A substring of $s$ is a contiguous subsequence of its characters. You have to choose two substrings of $s$ (possibly intersecting, possibly the same, possibly non-intersecting — just any two substrings). After choosing th...
n = int(input()) s = input() s = list(s) i = 0 while s[i] == "0": i += 1 if i == n: break if i == n: print(0) else: s = s[i:] n = len(s) ans = [i for i in s] i = 0 o = 0 while s[i] == "1": o += 1 i += 1 if o == 0: print("0") else: ones ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR STRING VAR NUMBER IF VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR STRING V...
You are given a string $s$ consisting of $n$ characters. Each character of $s$ is either 0 or 1. A substring of $s$ is a contiguous subsequence of its characters. You have to choose two substrings of $s$ (possibly intersecting, possibly the same, possibly non-intersecting — just any two substrings). After choosing th...
from sys import exit n = int(input()) s = input() f1 = s.find("1") if f1 == -1: print(0) exit() ln = 0 for i in range(f1, n): if s[i] == "1": ln += 1 else: break sb = int(s, 2) res = sb for i in range(ln): res = max(res, sb | int(s[: -(i + 1)], 2)) print(bin(res)[2:])
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR IF VAR VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR ...
You are given a string $s$ consisting of $n$ characters. Each character of $s$ is either 0 or 1. A substring of $s$ is a contiguous subsequence of its characters. You have to choose two substrings of $s$ (possibly intersecting, possibly the same, possibly non-intersecting — just any two substrings). After choosing th...
def main(): n = int(input()) s = list(input()) i = 0 while i < n and s[i] == "0": i += 1 if i == n: s = "0" else: s = s[i:] n = len(s) pos = -1 for i in range(n): if s[i] == "0": pos = i break if pos == -1: print(""....
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER IF VAR VAR ASSIGN VAR STRING ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR IF VAR NUMBER EXPR FU...
You are given a string $s$ consisting of $n$ characters. Each character of $s$ is either 0 or 1. A substring of $s$ is a contiguous subsequence of its characters. You have to choose two substrings of $s$ (possibly intersecting, possibly the same, possibly non-intersecting — just any two substrings). After choosing th...
input() ash = int(input(), 2) m = ash for i in range(1, 100): m = max(m, ash | ash >> i) print("{0:b}".format(m))
EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR
You are given a string $s$ consisting of $n$ characters. Each character of $s$ is either 0 or 1. A substring of $s$ is a contiguous subsequence of its characters. You have to choose two substrings of $s$ (possibly intersecting, possibly the same, possibly non-intersecting — just any two substrings). After choosing th...
n = int(input()) ss = input() def cal(s): if "1" not in s: return "0" s = s[s.index("1") :] if "0" not in s: return s[:-1] + "0" t = s[s.index("0") :] k = len(t) re = t for i in range(len(s) - k + 1): if s[i] != "1": continue p = s[i : i + k] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF IF STRING VAR RETURN STRING ASSIGN VAR VAR FUNC_CALL VAR STRING IF STRING VAR RETURN BIN_OP VAR NUMBER STRING ASSIGN VAR VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR...
You are given a string $s$ consisting of $n$ characters. Each character of $s$ is either 0 or 1. A substring of $s$ is a contiguous subsequence of its characters. You have to choose two substrings of $s$ (possibly intersecting, possibly the same, possibly non-intersecting — just any two substrings). After choosing th...
len_1 = int(input()) str_1 = input() msb = -1 flag = 0 for t in range(len_1): if str_1[t] == "0": msb = t if flag == 1: break if str_1[t] == "1": flag = 1 seg_len = len_1 - msb lst_val = [] u = 0 while seg_len + u <= len_1: lst_val.append(int(str_1[u : seg_len + u], 2)) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR IF VAR NUMBER IF VAR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CA...
You are given a string $s$ consisting of $n$ characters. Each character of $s$ is either 0 or 1. A substring of $s$ is a contiguous subsequence of its characters. You have to choose two substrings of $s$ (possibly intersecting, possibly the same, possibly non-intersecting — just any two substrings). After choosing th...
n = int(input()) s = [int(x) for x in list(input())] if sum(s) == 0: print(0) else: leadingOnes = 0 s1 = [] stop = False for i in range(n): if not stop: if s[i] == 1: leadingOnes += 1 if s[i] == 0 and leadingOnes > 0: stop = True ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR IF VAR VAR NUMBER VAR NUMBER IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VA...
You are given a string $s$ consisting of $n$ characters. Each character of $s$ is either 0 or 1. A substring of $s$ is a contiguous subsequence of its characters. You have to choose two substrings of $s$ (possibly intersecting, possibly the same, possibly non-intersecting — just any two substrings). After choosing th...
n = int(input()) s = input() y = int(s, 2) s = bin(y)[2:] l = "" if y == 0: print("0") else: for i in s: if i == "0": l += "1" elif l != "": l += "0" mx = 0 m = len(l) if m == 0: mx = y or int(s[-1], 2) else: for j in range(n - m): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR VAR IF VAR STRING VAR STRING IF VAR STRING VAR STRING ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER ASS...
You are given a string $s$ consisting of $n$ characters. Each character of $s$ is either 0 or 1. A substring of $s$ is a contiguous subsequence of its characters. You have to choose two substrings of $s$ (possibly intersecting, possibly the same, possibly non-intersecting — just any two substrings). After choosing th...
def getStr(i, k): ans = "" while i < n: if s[i] == "1" or s[k] == "1": ans += "1" else: ans += "0" i += 1 k += 1 return ans n = int(input()) s = input() i = 0 while i < n and s[i] == "0": i += 1 if i == n: print(0) exit() j = i while i < ...
FUNC_DEF ASSIGN VAR STRING WHILE VAR VAR IF VAR VAR STRING VAR VAR STRING VAR STRING VAR STRING VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VA...
You are given a string $s$ consisting of $n$ characters. Each character of $s$ is either 0 or 1. A substring of $s$ is a contiguous subsequence of its characters. You have to choose two substrings of $s$ (possibly intersecting, possibly the same, possibly non-intersecting — just any two substrings). After choosing th...
def solve1(n, o, s): p = "" flag = False for i in range(0, n): if s[i] == "1" or flag: flag = True p += s[i] if len(p) == 0: print(0) exit(0) s = p n = len(s) p = "" for i in range(2, n + 1): x = n - o + 1 y = n - i + 1 ...
FUNC_DEF ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING VAR ASSIGN VAR NUMBER VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER A...
You are given a string $s$ consisting of $n$ characters. Each character of $s$ is either 0 or 1. A substring of $s$ is a contiguous subsequence of its characters. You have to choose two substrings of $s$ (possibly intersecting, possibly the same, possibly non-intersecting — just any two substrings). After choosing th...
from sys import stdin, stdout def ss(n, s): if s.count("0") == n: return "0" y = int(s, 2) s = bin(y)[2:] l = "" if y == 0: return "0" for t in range(len(s)): i = s[t] if i == "0": l += "1" elif l != "": l += "0" mx = 0 m ...
FUNC_DEF IF FUNC_CALL VAR STRING VAR RETURN STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING IF VAR NUMBER RETURN STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR STRING VAR STRING IF VAR STRING VAR STRING ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR...
You are given a string $s$ consisting of $n$ characters. Each character of $s$ is either 0 or 1. A substring of $s$ is a contiguous subsequence of its characters. You have to choose two substrings of $s$ (possibly intersecting, possibly the same, possibly non-intersecting — just any two substrings). After choosing th...
n = int(input()) a = int(input(), 2) temp = a mx = a | temp for i in range(7): temp = temp >> 1 m = a | temp if mx < m: mx = m print(bin(mx).replace("0b", ""))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR VAR STRING STRING
You are given a string $s$ consisting of $n$ characters. Each character of $s$ is either 0 or 1. A substring of $s$ is a contiguous subsequence of its characters. You have to choose two substrings of $s$ (possibly intersecting, possibly the same, possibly non-intersecting — just any two substrings). After choosing th...
def sor(s1: str, s2: str): a1 = list(max(s1, s2)) a2 = min(s1, s2) for i in range(len(a2)): if a2[i] == "1": a1[len(a1) - len(a2) + i] = "1" return "".join(a1).lstrip("0") n = int(input()) s = input().lstrip("0") n = len(s) ans = "0" a1 = s.find("1") if a1 != -1: a2 = s.find("0...
FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR STRING RETURN FUNC_CALL FUNC_CALL STRING VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VA...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
numset = set() def num(now, n): if n == 1: numset.add(now + 1) numset.add(now + 5) numset.add(now + 10) numset.add(now + 50) else: num(now + 1, n - 1) num(now + 5, n - 1) num(now + 10, n - 1) num(now + 50, n - 1) n = int(input()) if n < 11: ...
ASSIGN VAR FUNC_CALL VAR FUNC_DEF IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
n = int(input()) l = [1, 3, 6, 10, 15, 21, 27, 33, 39, 43, 46, 48] if n < 12: print(sum(l[: n + 1])) else: print(sum(l) + 49 * (n - 11))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR BIN_OP NUMBER BIN_OP VAR NUMBER
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
n = int(input().strip()) def C(n, r): c = 1 for i in range(r): c = c * (n - i) for i in range(r): c = c // (i + 1) return c def calc(n, r): if n < 0: return 0 return C(n + r - 1, r - 1) ans = 0 for i in range(5): ans += calc(n - i, 2) for i in range(4): ans ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF IF VAR NUMBER RETURN NUMBER RETURN FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
ans = 0 def solve(nn, su, ans): if nn == n: s.add(su) ans += 1 return solve(nn + 1, su + 1, ans) solve(nn + 1, su + 5, ans) solve(nn + 1, su + 10, ans) solve(nn + 1, su + 50, ans) s = set() n = int(input()) if n <= 13: solve(0, 0, ans) print(len(s)) else: prin...
ASSIGN VAR NUMBER FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER RETURN EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR ASSIG...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
n = int(input()) if n > 20: print(733 + (n - 20) * 49) else: s = set() for i in range(n + 1): for v in range(n - i + 1): for x in range(n - i - v + 1): l = n - i - v - x s.add(i + 5 * v + 10 * x + 50 * l) print(len(s))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
from itertools import combinations_with_replacement as cwr def compute_lt12(n): chars = "IVXL" nums = [1, 5, 10, 50] num_map = {c: n for c, n in zip(chars, nums)} sum_set = set() for comb in cwr(chars, n): sum_set.add(sum(num_map[c] for c in comb)) return len(sum_set) def main(): ...
FUNC_DEF ASSIGN VAR STRING ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR RETURN FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
from itertools import combinations_with_replacement l = [] for n in range(1, 20): st = set() for cmb in combinations_with_replacement((1, 5, 10, 50), n): st.add(sum(cmb)) l.append(len(st)) n = int(input()) if n <= len(l): print(l[n - 1]) else: print(n * 49 - 247)
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
n = int(input()) ans = [1, 4, 10, 20, 35, 56, 83, 116, 155, 198, 244, 292, 341] if n <= 12: print(ans[n]) else: print(49 * n - 247)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
n = int(input().strip()) R1 = [4, 9, 49] def get_after_slow(k, T=0): dp = [(k + 1) for _ in range(49 * k + 1)] dp[0] = 0 for i in range(1, 49 * k + 1): for R in R1: if i >= R: dp[i] = min(dp[i], dp[i - R] + 1) return len(dp) - T - dp[T:].count(k + 1) def get_fast(...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER FUNC_DEF NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER FOR VAR VAR IF VAR VAR ASSIGN VAR VAR FUNC_CALL VAR V...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
def f(n): if n < 0: return 0 val = (n + 3) * (n + 2) * (n + 1) // 6 return val def g(n): return f(n) - f(n - 6) - 2 * f(n - 9) + f(n - 10) + f(n - 14) n = int(input()) print(g(n))
FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER RETURN VAR FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CA...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
def mi(): return map(int, input().split()) n = list(mi())[0] a = [4, 10, 20, 35, 56, 83, 116, 155, 198, 244, 292, 341] if n >= 13: print((n - 11) * 49 + a[10]) else: print(a[n - 1])
FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
lst, m = [0, 4, 10, 20, 35, 56, 83, 116, 155, 198, 244], 292 n = int(input()) if n <= 10: print(lst[n]) else: print(m + (n - 11) * 49)
ASSIGN VAR VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMBER
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
n = int(input()) if n < 12: print([1, 4, 10, 20, 35, 56, 83, 116, 155, 198, 244, 292][n]) else: print(n * 50 - n - 247)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
from sys import setrecursionlimit setrecursionlimit(10**9) n = int(input()) s = set() arr = [1, 5, 10, 50] def comb(num, digit): global n if digit == n: s.add(num) else: for i in range(4): comb(num + arr[i], digit + 1) if n <= 12: comb(0, 0) print(len(s)) else: p...
EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMB...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
import sys input = sys.stdin.readline n = int(input()) dp = [0] * 150 s = set([0]) for i in range(150): dp[i] = len(s) s2 = set(s) for j in s: s2.add(j + 4) s2.add(j + 9) s2.add(j + 49) s = s2 if 0: for i in range(100): if dp[i + 49] - dp[i] != 2401: prin...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUN...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
def foo(n): return (n + 3) * (n + 2) * (n + 1) // 6 n = int(input()) ans = foo(n) if n >= 6: ans -= foo(n - 6) if n >= 9: ans -= foo(n - 9) * 2 if n >= 10: ans += foo(n - 10) if n >= 14: ans += foo(n - 14) print(ans)
FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER IF VAR NUMBER VAR FUNC_CALL VAR BIN_OP V...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
n = int(input()) ans = 0 for v in range(0, 9): for x in range(0, 49): if n < v + x: continue wrong = 0 for vv in range(0, 9): for xx in range(0, 49): if n < vv + xx or vv == v and x == xx: continue if (v * 4 + x * 9)...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR BIN_OP VAR VAR VAR VAR VAR VAR IF BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
n = int(input()) s = set() x = [1, 5, 10, 50] l = list() def dfs(a, b, c): if a == n: s.add(b) return while c < len(x): dfs(a + 1, b + x[c], c) c += 1 if n <= 10: dfs(0, 0, 0) print(len(s)) return else: print(244 + 49 * (n - 10) - 1)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR VAR RETURN WHILE VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBE...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
n = int(input()) rec = [0, 4, 10, 20, 35, 56, 83, 116, 155, 198, 244, 292, 341] ans = 0 if n <= 12: ans = rec[n] else: ans = (n - 12) * 49 + rec[12] print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
import itertools STC = [[0, 4, 0, 5], [1, 0, 8, 0], [1, 0, 0, 5]] def ch(N, K): ans = 1 for k in range(K): ans *= N - k for k in range(K): ans //= k + 1 return ans N = int(input()) ans = ch(N + 3, 3) sgn = -1 for s in range(1, len(STC) + 1): for cb in itertools.combinations(STC,...
IMPORT ASSIGN VAR LIST LIST NUMBER NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
n = int(input()) l = [int(1e20) for i in range(49)] r = [int(-1e20) for i in range(49)] ans = 0 for i in range(49): for j in range(49): t = (i * 10 + j * 5 + (n - i - j)) % 49 l[t] = min(l[t], i * 10 + j * 5 + (n - i - j)) r[t] = max(r[t], i * 10 + j * 5 + (n - i - j) * 50) for i in range(49...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR V...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
def answer(n): sums = set() for d1 in range(n + 1): for d5 in range(n + 1 - d1): for d10 in range(n + 1 - d1 - d5): d50 = n - d1 - d5 - d10 sums.add(d1 * 1 + d5 * 5 + d10 * 10 + d50 * 50) return len(sums) answers = [answer(x) for x in range(31)] n = int(...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VA...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
n = int(input()) m = min([n, 100]) result = 50 * (n - m) + m - n + 1 my_set = set() for i in range(m + 1): for j in range(i, m + 1): for k in range(j, m + 1): tmp = 50 * i + 10 * (j - i) + 5 * (k - j) + (m - k) my_set.add(tmp) result += len(my_set) - 1 print(result)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR LIST VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR ...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
non_representable = { (1): 46, (2): 89, (3): 128, (4): 162, (5): 190, (6): 212, (7): 228, (8): 238, (9): 244, (10): 247, } n = int(input()) print(49 * n + 1 - non_representable.get(n, 248))
ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER FUNC_CALL VAR VAR NUMBER
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
def check(n, b, c): for tb in range(0, 9): for tc in range(0, min(n - tb + 1, 9)): s1 = 9 * b + 4 * c s2 = 9 * tb + 4 * tc if s1 > s2 and (s1 - s2) % 49 == 0: return False return True def main(): n = int(input()) ans = 0 for b in range(0,...
FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER VAR IF VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASSI...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
n = int(input()) a = [0, 4, 10, 20, 35, 56, 83, 116, 155, 198, 244, 292] print(max(49 * n - 247, a[n % 12]))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
def c(n): ans = 0 if n > 15: ans += 49 * (n - 15) n = 15 l = set() for i in range(max(n + 1, 441)): for j in range(max(n - i + 1, 196)): for k in range(n - i - j + 1): l.add(i * 4 + j * 9 + k * 49) return ans + len(l) n = int(input()) print(c(n))
FUNC_DEF ASSIGN VAR NUMBER IF VAR NUMBER VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER EXPR ...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
n = int(input()) ans = 0 minv = [int(1000000000.0)] * 200000 minv[0] = 0 for i in range(49): for j in range(49): minv[(4 * i + 9 * j) % 49] = min(minv[(4 * i + 9 * j) % 49], i + j) for i in range(49): if n >= minv[i]: ans += n - minv[i] + 1 print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER VAR NUMBER FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP NUMBER VAR BIN_OP NUMB...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
def main(): a, b, c, res, nxt = -1, -1, 0, [1], [True] while b - a < c - b: cur, nxt = nxt, [False] * (len(nxt) + 50) for p in (1, 5, 10, 50): for i, f in enumerate(cur): if f: nxt[i + p] = True a, b, c = b, c, sum(nxt) res.append(c...
FUNC_DEF ASSIGN VAR VAR VAR VAR VAR NUMBER NUMBER NUMBER LIST NUMBER LIST NUMBER WHILE BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR NUMBER NUMBER NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR ASSIGN VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR ...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
def solve(n): s = set() for i in range(0, n + 1): for v in range(0, n - i + 1): for x in range(0, n - i - v + 1): l = n - i - v - x s.add(i + v * 5 + x * 10 + l * 50) return len(s) n = int(input()) if n < 11: print(solve(n)) else: print(49 * n - ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BI...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
n = int(input()) if n < 20: q = [] i = 0 while i <= n: j = 0 while j <= n - i: k = 0 while k <= n - i - j: t = n - i - j - k q.append(i * 1 + j * 5 + k * 10 + t * 50) k = k + 1 j = j + 1 i = i + 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBE...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
import sys n = int(input()) res = 0 for V in range(1, min(n, 8) + 1): for X in range(min(n - V, 4) + 1): res += n + 1 - V - X for X in range(min(n, 8) + 1): res += n + 1 - X print(res)
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR NUMBER NUMBER VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR BIN_OP ...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
arr = [] for i in range(1, 15): dict1 = {} for j in range(0, i + 1): for k in range(0, i + 1): for l in range(0, i + 1): if j + k + l <= i: z = j * 50 + k * 10 + l * 5 + (i - j - k - l) dict1[z] = 1 arr.append(len(dict1)) n = int(in...
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
a = [4, 10, 20, 35, 56, 83, 116, 155, 198, 244, 292] digits = input() def result(digits): if int(digits) <= 11: return a[int(digits) - 1] return a[10] + (int(digits) - 11) * 49 print(result(digits))
ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN VAR BIN_OP FUNC_CALL VAR VAR NUMBER RETURN BIN_OP VAR NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
n = int(input()) ans = 0 for i in range(9): for j in range(49): def check(y, x): for i in range(49): for j in range(9): if i == x and j == y: continue t = (x - i) * 9 + (y - j) * 4 if t >= 0 and ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER IF VAR NUMBER BIN_OP VAR NUMBER NUMBER RETU...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
n = int(input()) N = 30 S = [set() for i in range(N)] for i in range(N): for v in range(N): for x in range(N): for l in range(N): cnt = i + v + x + l if cnt < N: val = i + 5 * v + 10 * x + 50 * l S[cnt].add(val) if n < 30: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP NUMBER VAR...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
def ceildiv(a, b): return -(-a // b) def test_ceildiv(): assert ceildiv(6, 3) == 2 assert ceildiv(7, 3) == 3 assert ceildiv(5, 3) == 2 def brute_force(n, m): numbers = set() max_c = min(n, m // 49) for c in range(max_c + 1): _49c = 49 * c max_b = min(n - c, (m - _49c) // ...
FUNC_DEF RETURN BIN_OP VAR VAR FUNC_DEF FUNC_CALL VAR NUMBER NUMBER NUMBER FUNC_CALL VAR NUMBER NUMBER NUMBER FUNC_CALL VAR NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR ...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
n = int(input()) ans = 0 i = 0 while i <= 8 and i <= n: j = 0 while j <= (8 if i == 0 else 4) and j + i <= n: ans += n - i - j + 1 j = j + 1 i = i + 1 print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR NUMBER NUMBER NUMBER BIN_OP VAR VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
n = int(input()) ans = 0 kol = 0 ma = 0 if n > 20: ma = (n - 10) * 50 mi = n - 10 + 10 * 50 ans = ma - mi + 1 kol = n - 20 n = 20 a = set() for i in range(n + 1): for j in range(n - i + 1): for u in range(n - i - j + 1): z = n - i - j - u ch = i + j * 5 + u * 10 +...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR F...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
n = int(input()) ans = 0 precomp = [0, 4, 10, 20, 35, 56, 83, 116, 155, 198, 244] if n <= 10: print(precomp[n]) exit() for i in range(9): ans += n - i + 1 for i in range(1, 9): for j in range(5): ans += n - i - j + 1 print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR BIN_OP BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
n = int(input()) add = [1, 5, 10, 50] sumMap = {} def dfs(k, s): if k == 0: t = 0 for x in s: t += x if not t in sumMap: sumMap[t] = 1 return for x in add: if len(s) > 0 and x >= s[-1]: dfs(k - 1, s + [x]) elif len(s) == 0: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER ASSIGN VAR DICT FUNC_DEF IF VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER RETURN FOR VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR LIST VAR IF FUNC_...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
from sys import stdin, stdout def count(n): d = {} cnt = 0 cur = 0 for i in range(n + 1): for j in range(n - i + 1): for z in range(n - j - i + 1): v = i * 1 + j * 5 + z * 10 + (n - i - j - z) * 50 if not v in d: d[v] = 1 ...
FUNC_DEF ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP BIN_OP BIN_OP...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers 1, 5, 10 and 50 respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence simply as...
ans = [1, 4, 10, 20, 35, 56, 83, 116, 155, 198, 244, 292, 341, 390, 439] n = int(input()) if n < 12: print(ans[n]) else: print(292 + (n - 11) * 49)
ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers 1, 5, 10 and 50 respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence simply as...
a = [0, 4, 10, 20, 35, 56, 83, 116, 155, 198, 244, 292] n = int(input()) if n < len(a): print(a[n]) else: print(a[11] + 49 * (n - 11))
ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() s1 = s.find("AB") while s1 != -1: if s[:s1].find("BA") != -1 or s[s1 + 2 :].find("BA") != -1: print("YES") exit() s1 = s.find("AB", s1 + 1) print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING WHILE VAR NUMBER IF FUNC_CALL VAR VAR STRING NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER STRING NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() abEarly = 0 baEarly = 0 aSeen = False bSeen = False done = False for i in range(len(s)): if baEarly > 0: baEarly += 1 if abEarly > 0: abEarly += 1 next = s[i] if next == "A": if bSeen: baEarly += 1 if abEarly > 2: done = True ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR IF VAR STRING IF VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUM...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() a = s.find("AB") b = s.rfind("AB") c = s.find("BA") d = s.rfind("BA") print("YNEOS"[not ((abs(a - d) > 1 or abs(b - c) > 1) and min(a, b, c, d) >= 0) :: 2])
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING FUNC_CALL VAR BIN_OP VAR VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR NUMBER FUNC_CALL VAR VAR VAR VAR VAR NUMBER NUMBER
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() fi = s.find("AB") se = s.find("BA") ab = s.count("AB") ba = s.count("BA") if fi == -1 or se == -1: print("NO") elif ( (s.count("ABAB") == 1 or s.count("BABA") == 1) and s.count("A") == 2 and s.count("B") == 2 ): print("NO") elif ab == 1 and ba == 1: if max(fi, se) - min(fi, se) > 1: ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER E...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() l = len(s) a = 0 b = 0 for i in range(l - 1): if s[i] == "A" and s[i + 1] == "B": a += 1 if s[i] == "B" and s[i + 1] == "A": b += 1 r = "YES" if a * b == 0: r = "NO" if a == b == 1: if "ABA" in s or "BAB" in s: r = "NO" if a == 1 and b == 2 or a == 2 and b == 1: i...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR STRING IF VAR VAR NU...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() n = len(s) if n == 1 or n == 2 or n == 3: print("NO") else: cnt1 = 0 cnt2 = 0 i = 0 ind1 = [] ind2 = [] while i < n - 1: if s[i] == "A" and s[i + 1] == "B": cnt1 += 1 ind1.append(i) i += 1 i += 1 i = 0 while i < n - 1: ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST WHILE VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBE...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s1 = input().strip() AB = [] BA = [] for i in range(len(s1) - 1): if s1[i] == "A" and s1[i + 1] == "B": AB.append(i) elif s1[i] == "B" and s1[i + 1] == "A": BA.append(i) x = True for i in AB: for j in BA: if abs(i - j) > 1: print("YES") x = False b...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR FOR VAR VAR IF FUNC_CALL VAR ...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
def two_substring(string): AB = [] BA = [] for i in range(len(string)): if string[i] == "A" and i < len(string) - 1: if string[i + 1] == "B": AB.append([i, i + 1]) elif string[i] == "B" and i < len(string) - 1: if string[i + 1] == "A": ...
FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR LIST VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR LI...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() a, a1, b, b1 = s.count("AB"), s.count("BA"), s.count("ABA"), s.count("BAB") if a > 0 and a1 > 0 and a + a1 - (b + b1) >= 2: print("YES") else: print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() fi = s.find("AB") sc = s.rfind("BA") if fi == -1 or sc == -1: print("NO") exit(0) if sc >= fi + 2: print("YES") else: fi = s.rfind("AB") sc = s.find("BA") if fi >= sc + 2: print("YES") else: print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() x = s.count("AB") y = s.count("BA") if x > 1: if y > 1: print("YES") elif y == 1: s = s.replace("BA", " ") if s.count("AB"): print("YES") else: print("NO") else: print("NO") elif x == 1: s = s.replace("AB", " ") if s.count("...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING STRING IF FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN V...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() n = len(s) cnt1 = [0] * (n - 1) cnt2 = [0] * (n - 1) stat = 0 if s[0:2] == "AB": cnt1[0] = 1 elif s[0:2] == "BA": cnt2[0] = 1 for i in range(1, n - 1): if s[i : i + 2] == "BA": cnt2[i] = cnt2[i - 1] + 1 if i >= 2 and cnt1[i - 2] > 0: stat = 1 print("YES") ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER NUMBER STRING ASSIGN VAR NUMBER NUMBER IF VAR NUMBER NUMBER STRING ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
string1 = input() ab = string1.count("ABA") string = string1.replace("ABA", "h") ab += string.count("BAB") string = string.replace("BAB", "h") a = string.count("AB") b = string.count("BA") if ab > 0 and ab + a + b > 1 or a > 0 and b > 0 or "BABAB" in string1: print("YES") else: print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING STRING VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER BIN_OP BIN_OP VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER STRING VAR EXPR FUNC_CALL V...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
data = input() abs = [] bas = [] for i in range(len(data) - 1): if data[i : i + 2] == "AB": abs.append(i) elif data[i : i + 2] == "BA": bas.append(i) def is_valid(l1, l2): for i in l1: for j in l2: if j > i + 1: return True return False print("YES"...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR FUNC_DEF FOR VAR VAR FOR VAR VAR IF VAR BIN_OP VAR NUMBER RETURN NUMBER RETURN NUMBER EXPR ...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
st = input().strip() cab = st.count("AB") cba = st.count("BA") if cab == 0 or cba == 0: print("NO") else: found = False idx = None for i in range(cab): if idx == None: idx = st.find("AB") else: idx = idx + 1 + st[idx + 1 :].find("AB") try: if m...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NONE FOR VAR FUNC_CALL VAR VAR IF VAR NONE ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBE...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
string = input() found = 0 ab = string.find("AB") if ab != -1: if string[ab + 2 :].find("BA") != -1: found = 1 ba = string.find("BA") if ba != -1: if string[ba + 2 :].find("AB") != -1: found = 1 if found == 1: print("YES") else: print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR NUMBER STRING NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR NUMBER STRING NUMBER ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_C...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() a = s.find("AB") b = s.rfind("AB") c = s.find("BA") d = s.rfind("BA") e = min(a, b, c, d) if (abs(a - d) > 1 or abs(b - c) > 1) and e >= 0: print("YES") else: print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() a = s.count("AB") b = s.count("BA") t = s.count("ABA") u = s.count("BAB") s = a + b - t - u if s >= 2 and a > 0 and b > 0: print("YES") else: print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
t = 1 for __ in range(t): s = input() s1 = "AB" s2 = "BA" f, se = 0, 0 n = len(s) i = 0 while i < n - 1: if f == 1: if s2 == s[i : i + 2]: se = 1 i += 1 if s1 == s[i : i + 2] and f == 0: f = 1 i += 1 ...
ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VA...