description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Problem Statement It is 2042 and we are surrounded by cyborgs everywhere. Geneo is one such cyborg with a human body and an electronic brain. To monitor skills and health of Geneo he is posed with questions everyday. On one fine day Geneo was asked the following question. You are given a string S of size N containing ...
import itertools def map_to_values(s): return ord(s.lower()) - 71 - 25 def gcd(a, b): while b: a, b = b, a % b return a def a_b(Mpow, K): d = gcd(Mpow, K) Mpow //= d K //= d print(Mpow, K) pass def max_power(S, K): S = list(S) S.sort() S.reverse() """""".j...
IMPORT FUNC_DEF RETURN BIN_OP BIN_OP FUNC_CALL VAR FUNC_CALL VAR NUMBER NUMBER FUNC_DEF WHILE VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL S...
Problem Statement It is 2042 and we are surrounded by cyborgs everywhere. Geneo is one such cyborg with a human body and an electronic brain. To monitor skills and health of Geneo he is posed with questions everyday. On one fine day Geneo was asked the following question. You are given a string S of size N containing ...
import sys sys.setrecursionlimit(100000) def gcd(a, b): if a == 0 or b == 0: False if a == b: return a if a > b: return gcd(a - b, b) return gcd(a, b - a) for _ in range(int(input())): n, k = map(int, input().split()) s = input() d = { "a": 0, "b"...
IMPORT EXPR FUNC_CALL VAR NUMBER FUNC_DEF IF VAR NUMBER VAR NUMBER EXPR NUMBER IF VAR VAR RETURN VAR IF VAR VAR RETURN FUNC_CALL VAR BIN_OP VAR VAR VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL ...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
a = int(input()) l1 = input() s = 0 a1 = 0 a2 = 0 c1 = 0 for k in range(a): if l1[k] == "?": c1 += 1 else: s += int(l1[k]) if k == int(a / 2) - 1: a1 = c1 a2 = s if c1 % 2 == 0: if a1 <= c1 - a1: for i in range(int(c1 / 2) + 1): if a1 == i: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR IF VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR VAR IF BIN_OP VAR NUMBER...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
ii = lambda: int(input()) kk = lambda: map(int, input().split()) ll = lambda: list(kk()) n, digs = ii(), input() d1 = [int(digs[i]) for i in range(n // 2) if digs[i] != "?"] d2 = [int(digs[i]) for i in range(n // 2, n) if digs[i] != "?"] missing = n - len(d1) - len(d2) if len(d1) > len(d2): d1, d2 = d2, d1 m1 = n /...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR ...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) s = input() l, r = 0, 0 l_t, r_t = 0, 0 for i in s[: n // 2]: if i == "?": l += 1 else: l_t += int(i) for i in s[n // 2 :]: if i == "?": r += 1 else: r_t += int(i) if l_t > r_t and r > l: tem = (r - l) // 2 if tem * 9 == l_t - r_t: print("...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR BIN_OP VAR NUMBER IF VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR VAR BIN_OP VAR NUMBER IF VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP ...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) s = input() hatena = [0, 0] total = [0, 0] for i in range(n // 2): if s[i] == "?": hatena[0] += 1 else: total[0] += int(s[i]) for i in range(n // 2, n): if s[i] == "?": hatena[1] += 1 else: total[1] += int(s[i]) mono_turn = (sum(hatena) + 1) // 2 bi_turn ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER NUMBER VAR NUMBER FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR STRING VAR NUMBER NUMBER VAR NUM...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
from sys import stdin n = int(stdin.readline().strip()) s = stdin.readline().strip() l = 0 ls = 0 for i in range(n // 2): if s[i] == "?": l += 1 else: ls += int(s[i]) r = 0 rs = 0 for i in range(n // 2, n): if s[i] == "?": r += 1 else: rs += int(s[i]) if ls - (rs + r * 9...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR STRING VAR NUM...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) s = input() a, b = 0, 0 q1, q2 = [], [] for i in range(n // 2): if s[i] != "?": a += int(s[i]) else: q1.append(i) if s[n - i - 1] != "?": b += int(s[n - i - 1]) else: q2.append(n - i - 1) a += len(q1) // 2 * 9 b += len(q2) // 2 * 9 if a == b: print("B...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR IF VAR BIN_OP BIN_OP VAR VAR NUMBER STRING VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER E...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
def f(q1, q2, k1, k2): res1 = res2 = 0 res1 += (q1 + 1) // 2 * k1 res1 += q1 // 2 * k2 res2 += q2 // 2 * k2 res2 += (q2 + 1) // 2 * k1 return [res1, res2] n = int(input()) s = input() sum_l = sum_r = 0 ql = qr = 0 for i in range(n // 2): if s[i] == "?": ql += 1 else: su...
FUNC_DEF ASSIGN VAR VAR NUMBER VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR BIN_OP BIN_OP VAR NUMBER VAR VAR BIN_OP BIN_OP VAR NUMBER VAR VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER VAR RETURN LIST VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER F...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) ticket = input() left = right = diff = 0 for i in range(n // 2): if ticket[i] == "?": left += 1 else: diff += int(ticket[i]) for i in range(n // 2, n): if ticket[i] == "?": right += 1 else: diff -= int(ticket[i]) if left > right: temp = left left ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
import sys input = sys.stdin.readline sys.setrecursionlimit(1000000) def lis(): return [int(i) for i in input().split()] def value(): return int(input()) n = value() a = input().strip("\n") l1, l2 = a[: n // 2].count("?"), a[n // 2 :].count("?") s1 = s2 = 0 for i in range(len(a)): if i < n // 2: ...
IMPORT ASSIGN VAR VAR EXPR FUNC_CALL VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER STRING FUNC_CALL VAR BIN_OP VAR NUMBER STRING ASSIGN...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
N = int(input()) s = input() leftSum = sum(int(c) for c in s[: N // 2] if c != "?") rightSum = sum(int(c) for c in s[N // 2 :] if c != "?") leftOptions = 0 leftSum = 0 for c in s[: N // 2]: if c == "?": leftOptions += 1 else: leftSum += int(c) rightOptions = 0 rightSum = 0 for c in s[N // 2 :]: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR BIN_OP VAR NUMBER IF VAR STRING VAR NUMBER VAR F...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
def main(): n = int(input()) a = list(input()) ls = 0 rs = 0 lq = 0 rq = 0 for i in range(n // 2): if a[i] == "?": lq += 1 else: ls += int(a[i]) for i in range(n // 2, n): if a[i] == "?": rq += 1 else: rs += ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR STRING VAR ...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) s = list(input()) sum_start = 0 sum_end = 0 miss_start = 0 miss_end = 0 for i in range(n): if i + 1 > n // 2: if s[i] == "?": miss_end += 1 else: sum_end += int(s[i]) elif s[i] == "?": miss_start += 1 else: sum_start += int(s[i]) diff_...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) s = input() def val(c): return 9 if c == "?" else 2 * int(c) lsum = sum(map(val, s[: n // 2])) rsum = sum(map(val, s[n // 2 :])) print("Bicarp" if lsum == rsum else "Monocarp")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF RETURN VAR STRING NUMBER BIN_OP NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR STRING STRING
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) s = input() fer = 0 f = 0 l = 0 ler = 0 for i in range(int(n / 2)): if s[i] == "?": fer += 1 else: f += int(s[i]) for i in range(int(n / 2), n): if s[i] == "?": ler += 1 else: l += int(s[i]) if (fer + ler) % 2: print("Monocarp") elif f < l: if l -...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR STRING...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
from sys import stdin n = int(stdin.readline()) div = n // 2 digs = stdin.readline().strip() left = 0 right = 0 leftQ = 0 rightQ = 0 for x in range(div): if digs[x] != "?": left += int(digs[x]) * 2 else: leftQ += 1 left += 9 if digs[div + x] != "?": right += int(digs[div + x...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR VAR STRING VAR BIN_OP...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) s = input() lsu = 0 rsu = 0 for c in s[0 : n // 2]: if c == "?": lsu += 9 else: lsu += 2 * int(c) for c in s[n // 2 :]: if c == "?": rsu += 9 else: rsu += 2 * int(c) print("Bicarp" if lsu == rsu else "Monocarp")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR NUMBER BIN_OP VAR NUMBER IF VAR STRING VAR NUMBER VAR BIN_OP NUMBER FUNC_CALL VAR VAR FOR VAR VAR BIN_OP VAR NUMBER IF VAR STRING VAR NUMBER VAR BIN_OP NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR STRI...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) s = input() s1, s2, c1, c2, ans = 0, 0, 0, 0, 0 for i in range(n // 2): if s[i] == "?": c1 += 1 else: s1 += int(s[i]) for i in range(n // 2, n): if s[i] == "?": c2 += 1 else: s2 += int(s[i]) k = (c1 + c2) // 2 c = c1 // 2 + c1 % 2 x1, y1 = s1 + c * 9, s2 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR ...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
def b4_ticket_game(n, s): l = 0 r = 0 for i in range(n): if s[i] != "?": if i < n // 2: l += int(s[i]) r += int(s[i]) else: l -= int(s[i]) r -= int(s[i]) elif i < n // 2: r += 9 else: ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR NUMBER RETURN NUMBER RETURN NUMBER AS...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) s = input() left_cnt = 0 right_cnt = 0 left_num = 0 right_num = 0 for i in range(n // 2): if s[i] == "?": left_cnt += 1 else: left_num += int(s[i]) for i in range(n // 2, n): if s[i] == "?": right_cnt += 1 else: right_num += int(s[i]) if left_cnt == right...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VA...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) n //= 2 s = input() c = 0 c1 = 0 su = 0 su1 = 0 for i in range(n): if s[i] == "?": c += 1 else: su += int(s[i]) for i in range(n): if s[i + n] == "?": c1 += 1 else: su1 += int(s[i + n]) c -= c1 su -= su1 if -su == c // 2 * 9: print("Bicarp") else: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR BIN_...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
import sys input = sys.stdin.readline n = int(input()) s = str(input().strip()) L, R, LS, RS = 0, 0, 0, 0 for ch in s[: n // 2]: if ch == "?": L += 1 else: LS += int(ch) for ch in s[n // 2 :]: if ch == "?": R += 1 else: RS += int(ch) diff = LS - RS ans = (R - L) // 2 * 9...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER FOR VAR VAR BIN_OP VAR NUMBER IF VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR VAR BIN_OP VAR NUMBER IF VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR ASSIG...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) s = input() first = s[: n // 2] second = s[n // 2 :] if first.count("?") > second.count("?"): first, second = second, first f = first.count("?") s = second.count("?") cnt1 = 0 cnt2 = 0 for i in range(n // 2): if first[i].isdigit(): cnt1 += int(first[i]) if second[i].isdigit(): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR ...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) inp = input() f = inp[: n // 2] s = inp[n // 2 :] fsm = sum([(ord(x) - ord("0") if x != "?" else 0) for x in f]) ssm = sum([(ord(x) - ord("0") if x != "?" else 0) for x in s]) diff = fsm - ssm fcnt = f.count("?") scnt = s.count("?") blowupdiff, blowupf, blowups = diff, fcnt, scnt shrinkdiff, shrinkf, s...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR STRING BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR STRING BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING NUMBER VAR ...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) ln = list(input()) sm1 = 0 sm2 = 0 qs1 = 0 qs2 = 0 for i in range(0, n // 2): if ln[i] != "?": qs1 += 1 sm1 += int(ln[i]) if ln[n // 2 + i] != "?": qs2 += 1 sm2 += int(ln[n // 2 + i]) qs1 = n // 2 - qs1 qs2 = n // 2 - qs2 qs = qs1 + qs2 m = False if not qs: i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR IF VAR BIN_OP BIN_OP VAR NUMBER VAR STRING VAR NUMBER VAR FUNC_CALL ...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
import sys n = int(sys.stdin.readline().strip()) m = n // 2 s = sys.stdin.readline().strip() s1 = 0 s2 = 0 x1 = 0 x2 = 0 for i in range(0, m): if s[i] == "?": x1 = x1 + 1 else: s1 = s1 + int(str(s[i])) if s[m + i] == "?": x2 = x2 + 1 else: s2 = s2 + int(str(s[m + i])) if...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR FUNC_CALL VA...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) s = input() p1 = 0 p2 = 0 s1 = 0 s2 = 0 for i in s[: n // 2]: if i == "?": p1 += 1 else: s1 += int(i) for i in s[n // 2 :]: if i == "?": p2 += 1 else: s2 += int(i) if s1 < s2: buf = p1 p1 = p2 p2 = buf buf = s1 s1 = s2 s2 = buf if ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR BIN_OP VAR NUMBER IF VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR VAR BIN_OP VAR NUMBER IF VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR ASSI...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) lis = list(input()) fi = se = 0 c1 = c2 = 0 for i in range(n): if i < n // 2: if lis[i] == "?": c1 += 1 else: fi += int(lis[i]) elif lis[i] == "?": c2 += 1 else: se += int(lis[i]) if fi == se and c1 == c2: print("Bicarp") elif fi =...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
a = int(input()) s = input() q1 = 0 sum1 = 0 q2 = 0 sum2 = 0 for i in range(len(s) // 2): if s[i] == "?": q1 += 1 else: sum1 += int(s[i]) for i in range(len(s) // 2, len(s)): if s[i] == "?": q2 += 1 else: sum2 += int(s[i]) if q1 == 0 and q2 == 0: if sum1 == sum2: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR IF ...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) str = input() L = 0 R = 0 for i in range(n): if i < n // 2: if str[i] == "?": L += 9 else: L += 2 * (ord(str[i]) - ord("0")) elif str[i] == "?": R += 9 else: R += 2 * (ord(str[i]) - ord("0")) print("Bicarp" if L == R else "Monocarp")
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 BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING IF VAR VAR STRING VAR NUMBER VAR BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR ...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
def main(): n = int(input()) a = list(input()) ls = 0 rs = 0 lq = 0 rq = 0 for i in range(n // 2): if a[i] == "?": lq += 1 else: ls += int(a[i]) for i in range(n // 2, n): if a[i] == "?": rq += 1 else: rs += ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR STRING VAR ...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) st = input() wh1 = 0 su1 = 0 for i in range(n // 2): if st[i] == "?": wh1 += 1 else: su1 += int(st[i]) wh2 = 0 su2 = 0 for i in range(n // 2, n): if st[i] == "?": wh2 += 1 else: su2 += int(st[i]) if wh1 == 0 and wh2 == 0 and su1 == su2: print("Bicarp"...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VA...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) s = input() diff = 0 q_left = 0 q_right = 0 for i in range(0, n): if i < int(n / 2): if s[i] == "?": q_left += 1 else: diff += int(s[i]) elif s[i] == "?": q_right += 1 else: diff -= int(s[i]) if diff < 0: diff = 0 - diff t = q_...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER ASSIGN...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) ch = input() a1 = 0 a2 = 0 s1 = 0 s2 = 0 for i in range(int(n / 2)): if ch[i] == "?": a1 += 1 else: s1 += int(ch[i]) for i in range(int(n / 2), n): if ch[i] == "?": a2 += 1 else: s2 += int(ch[i]) if s1 > s2 and a1 >= a2 or s2 > s1 and a2 >= a1 or s1 == s2...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR STRING...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
def find(s): N = len(s) // 2 left = 0 right = 0 left_v = 0 right_v = 0 for i in range(N): if s[i] == "?": left_v += 1 continue left += int(s[i]) for i in range(N, 2 * N): if s[i] == "?": right_v += 1 continue rig...
FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR BIN_OP NUMBER VAR IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_O...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
for t in range(1): n = int(input()) s = input() count, add = 0, 0 a, b = 0, 0 for i in range(n // 2): if s[i] == "?": count += 1 else: a += int(s[i]) for i in range(n // 2, n): if s[i] == "?": add += 1 else: b += int...
FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR STRING VAR NUMBER V...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
A = "Monocarp" B = "Bicarp" n = int(input()) nums = input() leftsum = sum(int(i) for i in nums[: len(nums) // 2] if i != "?") rightsum = sum(int(i) for i in nums[len(nums) // 2 :] if i != "?") leftrem = len([i for i in nums[: len(nums) // 2] if i == "?"]) rightrem = len([i for i in nums[len(nums) // 2 :] if i == "?"]) ...
ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) l = list(input()) q1 = q2 = 0 for i in range(n): if l[i] == "?": l[i] = 0 if i < n / 2: q1 += 1 else: q2 += 1 else: l[i] = ord(l[i]) - ord("0") s1 = sum(l[: n // 2]) s2 = sum(l[n // 2 :]) if q1 == q2: if s1 == s2: print("Bicarp...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NU...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
length = int(input()) string = list(input()) B = "Bicarp" M = "Monocarp" value = [0] * 2 blanks = [0] * 2 temp = "0" for i in range(length // 2): temp = string[i] if temp == "?": blanks[0] += 1 else: value[0] += int(temp) for i in range(length // 2, length): temp = string[i] if temp ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR IF VAR STRING VAR NUMBER NUMBER VAR NUMBER FUNC_CALL VA...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) s = input() left = 0 leftq = 0 for i in range(n // 2): if s[i] == "?": leftq += 1 else: left += int(s[i]) right = 0 rightq = 0 for i in range(n // 2, n): if s[i] == "?": rightq += 1 else: right += int(s[i]) if left > right and leftq > rightq or right > le...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VA...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
def solve(cnt1, cnt2, balance): diff = 9 * (cnt1 - cnt2) // 2 return balance + diff != 0 n = int(input()) s = input() cnt1, cnt2, balance = 0, 0, 0 for i in range(n // 2): if s[i] == "?": cnt1 += 1 else: balance += ord(s[i]) - ord("0") for i in range(n // 2, n): if s[i] == "?": ...
FUNC_DEF ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP VAR VAR NUMBER RETURN BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING F...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) word = input() tot = 0 for i in range(n): if word[i] == "?": inc = 9 else: inc = 2 * int(word[i]) tot += (2 * (i < n // 2) - 1) * inc print(["Monocarp", "Bicarp"][tot == 0])
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR VAR VAR VAR BIN_OP BIN_OP BIN_OP NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR EXPR FUNC_CALL VAR LIST STRING STRING VAR NUMBER
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) a = input() c1, s1, c2, s2 = 0, 0, 0, 0 for i in range(n // 2): if a[i] == "?": c1 = c1 + 1 else: s1 = s1 + int(a[i]) for i in range(n // 2, n): if a[i] == "?": c2 = c2 + 1 else: s2 = s2 + int(a[i]) c = abs(c1 - c2) s = abs(s1 - s2) if c == 0 and s != 0: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR STRING ASSIGN VAR B...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) s = input() left = 0 right = 0 left_ques = 0 right_ques = 0 for i in range(n): if i < n // 2: if s[i] == "?": left_ques += 1 else: left += int(s[i]) elif s[i] == "?": right_ques += 1 else: right += int(s[i]) x = min(left_ques, right_qu...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VA...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) s = input() s1 = 0 s2 = 0 c1 = 0 c2 = 0 for i in range(n // 2): if s[i] != "?": s1 += int(s[i]) else: c1 += 1 if s[-i - 1] != "?": s2 += int(s[-i - 1]) else: c2 += 1 if c1 > c2: c1 -= c2 if s1 + 9 * (c1 // 2) > s2 or s1 + 9 * (c1 // 2) < s2: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR FUNC_CALL VAR VAR VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) s = input() sd = 0 qd = 0 for i in range(n // 2): if s[i] == "?": qd += 1 else: sd += int(s[i]) if s[n // 2 + i] == "?": qd -= 1 else: sd -= int(s[n // 2 + i]) if abs(sd) % 9 > 0: print("Monocarp") exit() if sd >= 0: qd += 2 * (sd // 9 + (1 if...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR IF VAR BIN_OP BIN_OP VAR NUMBER VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER VAR IF BIN_OP FUNC_CALL ...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
N = int(input()) L = 0 R = 0 lq = 0 rq = 0 TK = input() for i in range(N // 2): if TK[i] == "?": lq += 1 else: L += int(TK[i]) for i in range(N // 2, N): if TK[i] == "?": rq += 1 else: R += int(TK[i]) if lq == rq: if L == R: print("Bicarp") else: p...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VA...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) word = input() print( ["Monocarp", "Bicarp"][ 0 == sum( [ ( 9 * (2 * (i < n // 2) - 1) if word[i] == "?" else (4 * (i < n // 2) - 2) * int(word[i]) ) for i in rang...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR LIST STRING STRING NUMBER FUNC_CALL VAR VAR VAR STRING BIN_OP NUMBER BIN_OP BIN_OP NUMBER VAR BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP BIN_OP NUMBER VAR BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
o = input() inp = input() count_1 = 0 sum_1 = 0 count_2 = 0 sum_2 = 0 for i in range(len(inp) // 2): if inp[i] == "?": count_1 += 1 else: sum_1 += int(inp[i]) for j in range(len(inp) // 2): i = len(inp) // 2 + j if inp[i] == "?": count_2 += 1 else: sum_2 += int(inp[i]...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL ...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) inp = input() sl, sr, qr, ql = 0, 0, 0, 0 for i in range(len(inp) // 2): if inp[i] == "?": ql += 1 else: sl += int(inp[i]) for i in range(n // 2, n): if inp[i] == "?": qr += 1 else: sr += int(inp[i]) if sl - sr == 9 * (qr - ql) / 2: print("Bicarp") el...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR V...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
l = int(input()) line = input() left_side = line[: l // 2] right_side = line[l // 2 :] def left(): return line[: l // 2] def right(): return line[l // 2 :] def get_sum(side, replacement): return sum(int(x) if x != "?" else replacement for x in side) def get_min_sum(side): return get_sum(side, 0)...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER FUNC_DEF RETURN VAR BIN_OP VAR NUMBER FUNC_DEF RETURN VAR BIN_OP VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR STRING FUNC_CALL VAR VAR VAR VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR NUMBER FU...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) s = input() nuq1 = 0 nuq2 = 0 sum1 = 0 sum2 = 0 for i in range(n): if s[i] == "?" and i < n // 2: nuq1 += 1 elif s[i] == "?" and i >= n // 2: nuq2 += 1 elif i < n // 2: sum1 += int(s[i]) else: sum2 += int(s[i]) if sum1 - sum2 == 9 * ((nuq2 - nuq1) // 2): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR F...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) s = input() cur_diff = 0 for i in range(n // 2): if s[i] != "?": cur_diff += int(s[i]) else: cur_diff += 4.5 for i in range(n // 2, n): if s[i] != "?": cur_diff -= int(s[i]) else: cur_diff -= 4.5 if abs(cur_diff) < 0.5: print("Bicarp") else: print...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR FUNC_CALL VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR STRING VAR FUNC_CALL VAR VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL V...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) a = input() if a.count("?") % 2 == 1: print("Monocarp") else: x = y = k = m = 0 for q in range(n): if q * 2 < n: if a[q] == "?": k += 1 else: x += int(a[q]) elif a[q] == "?": m += 1 else: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF BIN_OP FUNC_CALL VAR STRING NUMBER NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VA...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) a = [(int(x) if x != "?" else -1) for x in input()] left, right = a[0 : n // 2], a[n // 2 :] sumL = sum(x if x >= 0 else 0 for x in left) sumR9 = sum(x if x >= 0 else 9 for x in right) sumL9 = sum(x if x >= 0 else 9 for x in left) sumR = sum(x if x >= 0 else 0 for x in right) bigL = sumR9 - sumL < sumL...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR STRING FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR ...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) x = input() def f(x): q, s = 0, 0 for c in x: if c == "?": q += 1 else: s += int(c) return q, s lq, ls = f(x[: n // 2]) rq, rs = f(x[n // 2 :]) lmin = ls lmax = ls + 9 * lq rmin = rs rmax = rs + 9 * rq lc = lmin + lmax rc = rmin + rmax if lc == rc...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR RETURN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR BIN_O...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) s = input() pyt = 0 for i in s: if i == "?": pyt += 1 if pyt % 2 == 1: print("Monocarp") else: pyt1 = 0 pyt2 = 0 sum1 = 0 sum2 = 0 for i in range(n // 2): if s[i] == "?": pyt1 += 1 if s[i] != "?": sum1 += int(s[i]) for i in...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) s = input() sum1 = 0 kol1 = 0 sum2 = 0 kol2 = 0 for i in range(n // 2): if s[i] == "?": kol1 += 1 else: sum1 += int(s[i]) for i in range(n // 2, n): if s[i] == "?": kol2 += 1 else: sum2 += int(s[i]) if sum1 > sum2: sum1, sum2, kol1, kol2 = sum2, sum1,...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VA...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
import sys input = sys.stdin.readline def aliceWillWin(ticket): bal = 0 qs = 0 for i, c in enumerate(ticket): if i < len(ticket) // 2: if c == "?": qs += 1 else: bal += int(c) elif c == "?": qs -= 1 else: ...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR IF VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR IF VAR BIN_OP BIN_OP VAR NUMBER NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR FUN...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) l = list(input()) first, last = 0, 0 left, right = 0, 0 for i in range(n): if l[i] == "?": if i < n // 2: first += 9 else: last += 9 elif i < n // 2: left += 2 * int(l[i]) else: right += 2 * int(l[i]) if first + left - right - last == ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR BIN_OP NUMBER FUNC_CALL VAR VAR VAR VAR BIN_OP NUMBER FUNC_CALL ...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) a, b1, b2 = [], [], [] for i, j in enumerate(input()): if j == "?": if i < n // 2: b1.append(i) else: b2.append(i) a.append(0) else: a.append(int(j)) s1 = sum(a[: n // 2]) s2 = sum(a[n // 2 :]) print( "Bicarp" if s1 + 9 * (len(b1) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR LIST LIST LIST FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR STRING IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR F...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
I = lambda: int(input()) SI = lambda: input() M = "Monocarp" B = "Bicarp" def solve(n, s): lsum = 0 cl = 0 rsum = 0 cr = 0 for i in range(n // 2): if s[i] == "?": cl += 1 else: lsum += int(s[i]) for i in range(n // 2, n): if s[i] == "?": ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) s = input() kv1 = 0 kv2 = 0 sum1 = 0 sum2 = 0 for i in range(n): if s[i] == "?": if i < n / 2: kv1 += 1 else: kv2 += 1 elif i < n / 2: sum1 += int(s[i]) else: sum2 += int(s[i]) t = (kv1 + kv2) // 2 if sum1 > sum2: sum1 += 9 * min(k...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_O...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) a = input() maxi = sum(map(int, list(a[n // 2 :].replace("?", "9")))) - sum( map(int, list(a[: n // 2].replace("?", "0"))) ) mini = sum(map(int, list(a[n // 2 :].replace("?", "0")))) - sum( map(int, list(a[: n // 2].replace("?", "9"))) ) if mini + maxi == 0: print("Bicarp") else: print(...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER STRING STRING FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER STRING STRING ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
def winner(s, n): s1 = s[: n // 2] s2 = s[n // 2 :] turns = s.count("?") // 2 l1 = r1 = l2 = r2 = 0 for c in s1: if c == "?": r1 += 9 else: l1 += int(c) r1 += int(c) for c in s2: if c == "?": r2 += 9 else: ...
FUNC_DEF ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR STRING NUMBER ASSIGN VAR VAR VAR VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FOR VAR VAR IF VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR ...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) s = input() s1 = s[: n // 2] s2 = s[n // 2 :] sum1 = sum(map(int, filter(str.isdigit, s1))) sum2 = sum(map(int, filter(str.isdigit, s2))) free1 = s1.count("?") free2 = s2.count("?") ans = "" if free1 == free2: if sum1 == sum2: ans = "Bicarp" else: ans = "Monocarp" else: if s...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STR...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) l = list(input()) a = 0 b = 0 c = 0 d = 0 for i in range(n // 2): if l[i] == "?": a += 1 else: c += int(l[i]) for i in range(n // 2, n): if l[i] == "?": b += 1 else: d += int(l[i]) x = a // 2 if a % 2: x += 1 y = b // 2 if b % 2: y += 1 if x * 9 +...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR STRING VAR NUMBER VA...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
t = int(input()) s = input() l_sum = 0 r_sum = 0 l_count = 0 r_count = 0 for i in range(0, len(s) // 2): if s[i] != "?": l_sum += int(s[i]) else: l_count += 1 for i in range(len(s) // 2, len(s)): if s[i] != "?": r_sum += int(s[i]) else: r_count += 1 if l_sum > r_sum: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR FUNC_CALL VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR ...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) s = input() l = 0 r = 0 for i in range(n // 2): if s[i] == "?": l += 4.5 else: l += int(s[i]) for i in range(n // 2, n): if s[i] == "?": r += 4.5 else: r += int(s[i]) if l == r: print("Bicarp") else: print("Monocarp")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR VAR IF VAR VAR EXPR FUNC_CALL ...
Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game with this...
n = int(input()) s = input() lsum = lcount = rsum = rcount = 0 for ch in s[: n // 2]: if ch == "?": lcount += 1 else: lsum += int(ch) for ch in s[n // 2 :]: if ch == "?": rcount += 1 else: rsum += int(ch) if lcount > rcount: delta = rsum - lsum count = lcount - rc...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER FOR VAR VAR BIN_OP VAR NUMBER IF VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR VAR BIN_OP VAR NUMBER IF VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VA...
Little X has n distinct integers: p1, p2, ..., pn. He wants to divide all of them into two sets A and B. The following two conditions must be satisfied: * If number x belongs to set A, then number a - x must also belong to set A. * If number x belongs to set B, then number b - x must also belong to set B. Hel...
class DisjointSet: def __init__(self, n): self._fa = list(range(n)) def union(self, x, y): x = self.get_father(x) y = self.get_father(y) self._fa[x] = y return y def get_father(self, x): y = self._fa[x] if self._fa[y] == y: return y ...
CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR VAR VAR IF VAR VAR VAR RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CA...
Our chef has recently opened a new restaurant with a unique style. The restaurant is divided into K compartments (numbered from 1 to K) and each compartment can be occupied by at most one customer. Each customer that visits the restaurant has a strongly preferred compartment p (1 ≀ p ≀ K), and if that compartment is a...
t = int(input()) for p in range(t): n, k = map(int, input().split()) l = {} for i in range(n): a, b, c = map(int, input().split()) if c not in l: l[c] = [(a, b)] else: l[c].append((a, b)) co = 0 for i in l.values(): i.sort(key=lambda x: x[1]) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR LIST VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR...
Our chef has recently opened a new restaurant with a unique style. The restaurant is divided into K compartments (numbered from 1 to K) and each compartment can be occupied by at most one customer. Each customer that visits the restaurant has a strongly preferred compartment p (1 ≀ p ≀ K), and if that compartment is a...
try: for _ in range(int(input())): N, K = map(int, input().split()) cell = [] count = 0 l = [] for __ in range(N): inserted = list(map(int, input().split())) cell.append(inserted) cell.sort(key=lambda x: x[1]) time = {} for numb...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR DICT F...
Our chef has recently opened a new restaurant with a unique style. The restaurant is divided into K compartments (numbered from 1 to K) and each compartment can be occupied by at most one customer. Each customer that visits the restaurant has a strongly preferred compartment p (1 ≀ p ≀ K), and if that compartment is a...
try: t = int(input()) for _ in range(t): n, k = map(int, input().split()) table = {} for _ in range(n): start, end, pref = map(int, input().split()) if pref in table.keys(): table[pref].add((end, start)) else: table[pref...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR EXPR FUNC_CALL...
Our chef has recently opened a new restaurant with a unique style. The restaurant is divided into K compartments (numbered from 1 to K) and each compartment can be occupied by at most one customer. Each customer that visits the restaurant has a strongly preferred compartment p (1 ≀ p ≀ K), and if that compartment is a...
t = int(input()) for _ in range(t): n, k = [int(x) for x in input().split()] customers = {} for customer in range(n): temp = [int(x) for x in input().split()] if temp[2] in customers: customers[temp[2]].append(temp) else: customers[temp[2]] = [temp] happy_...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR EXPR FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR VAR NUMBER LIST VAR ASSIGN VAR N...
Our chef has recently opened a new restaurant with a unique style. The restaurant is divided into K compartments (numbered from 1 to K) and each compartment can be occupied by at most one customer. Each customer that visits the restaurant has a strongly preferred compartment p (1 ≀ p ≀ K), and if that compartment is a...
from sys import stdin for _ in range(int(stdin.readline())): n, k = map(int, stdin.readline().split()) m = {} f = {} c = 0 for i in range(n): s, e, c = map(int, stdin.readline().split()) v = [s, e, c] if c in m: m[c].append(v) else: m[c] = [v]...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR...
Our chef has recently opened a new restaurant with a unique style. The restaurant is divided into K compartments (numbered from 1 to K) and each compartment can be occupied by at most one customer. Each customer that visits the restaurant has a strongly preferred compartment p (1 ≀ p ≀ K), and if that compartment is a...
T = int(input()) for k in range(T): N, K = map(int, input().split()) t = {} for i in range(N): s, f, p = map(int, input().split()) try: t[p].append((f, s)) except: t[p] = [(f, s)] c = 0 for i in t: t[i].sort() start = -1 for j i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR LIST VAR VAR ASSIGN VAR NUMBER FOR VAR VAR EXPR F...
Our chef has recently opened a new restaurant with a unique style. The restaurant is divided into K compartments (numbered from 1 to K) and each compartment can be occupied by at most one customer. Each customer that visits the restaurant has a strongly preferred compartment p (1 ≀ p ≀ K), and if that compartment is a...
for _ in range(int(input())): n, k = map(int, input().split()) aux = {} for i in range(n): s, f, p = map(int, input().split()) if p not in aux: aux[p] = [] aux[p].append([s, f]) else: aux[p].append([s, f]) tot = 0 for i in aux: if l...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR LIST EXPR FUNC_CALL VAR VAR LIST VAR VAR EXPR FUNC_CALL VAR VAR LIST VAR VAR ASSIGN ...
Our chef has recently opened a new restaurant with a unique style. The restaurant is divided into K compartments (numbered from 1 to K) and each compartment can be occupied by at most one customer. Each customer that visits the restaurant has a strongly preferred compartment p (1 ≀ p ≀ K), and if that compartment is a...
for _ in range(int(input())): ans = 0 n, k = map(int, input().split()) dic = {} for _ in range(n): s, f, p = map(int, input().split()) if p not in dic: dic[p] = [(s, f)] else: dic[p].append((s, f)) for key, val in dic.items(): if len(dic[key]) ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR LIST VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR FOR VAR VAR FUNC_CALL ...
Our chef has recently opened a new restaurant with a unique style. The restaurant is divided into K compartments (numbered from 1 to K) and each compartment can be occupied by at most one customer. Each customer that visits the restaurant has a strongly preferred compartment p (1 ≀ p ≀ K), and if that compartment is a...
for _ in range(int(input())): n, k = map(int, input().split()) a = list() d = {} for i in range(n): s, f, p = list(map(int, input().split())) if p in d: d[p].append([s, f, p]) else: d[p] = [[s, f, p]] count = 0 for val in d.values(): freeat...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR VAR LIST VAR VAR VAR ASSIGN VAR VAR LIST ...
Our chef has recently opened a new restaurant with a unique style. The restaurant is divided into K compartments (numbered from 1 to K) and each compartment can be occupied by at most one customer. Each customer that visits the restaurant has a strongly preferred compartment p (1 ≀ p ≀ K), and if that compartment is a...
from sys import stdin input = stdin.readline for i in range(int(input())): n, k = map(int, input().split()) l = [] c = 0 for g in range(n): adc = list(map(int, input().split())) l.append(adc) l.sort(key=lambda x: x[1]) l.sort(key=lambda x: x[2]) i = 0 j = 0 while i <...
ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR...
Our chef has recently opened a new restaurant with a unique style. The restaurant is divided into K compartments (numbered from 1 to K) and each compartment can be occupied by at most one customer. Each customer that visits the restaurant has a strongly preferred compartment p (1 ≀ p ≀ K), and if that compartment is a...
t = int(input()) while t > 0: n, k = map(int, input().split()) temp = {} for i in range(n): s, f, p = map(int, input().split()) if p in temp: temp[p].append([s, f]) else: temp[p] = [[s, f]] cnt = 0 for k in temp.keys(): temp[k].sort(key=lambda ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR VAR LIST VAR VAR ASSIGN VAR VAR LIST LIST VAR VAR ASSIGN VAR NUMBER FOR VA...
Our chef has recently opened a new restaurant with a unique style. The restaurant is divided into K compartments (numbered from 1 to K) and each compartment can be occupied by at most one customer. Each customer that visits the restaurant has a strongly preferred compartment p (1 ≀ p ≀ K), and if that compartment is a...
from sys import stdin, stdout tc = int(stdin.readline()) for i in range(tc): n, k = list(map(int, stdin.readline().split())) dict1 = {} comp_to_iterate = [] for j in range(n): s, f, comp = list(map(int, stdin.readline().split())) if comp in dict1.keys(): dict1[comp].append((...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR...
Our chef has recently opened a new restaurant with a unique style. The restaurant is divided into K compartments (numbered from 1 to K) and each compartment can be occupied by at most one customer. Each customer that visits the restaurant has a strongly preferred compartment p (1 ≀ p ≀ K), and if that compartment is a...
t = int(input()) for _ in range(t): n, k = (int(i) for i in input().split()) cust = [[int(i) for i in input().split()] for _ in range(n)] cust.sort(key=lambda x: x[1]) compartments = {} ans = 0 for x in cust: s, f, c = x if c in compartments: if compartments[c] <= s: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR VAR VAR VAR IF VAR VAR IF VA...
Our chef has recently opened a new restaurant with a unique style. The restaurant is divided into K compartments (numbered from 1 to K) and each compartment can be occupied by at most one customer. Each customer that visits the restaurant has a strongly preferred compartment p (1 ≀ p ≀ K), and if that compartment is a...
from sys import stdin input = stdin.readline t = int(input()) for i in range(t): n, k = map(int, input().split()) arr = [] for i in range(n): s, f, p = map(int, input().split()) arr.append((s, f, p)) arr.sort(key=lambda x: x[1]) arr.sort(key=lambda x: x[2]) i = 0 j = 0 c...
ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR ...
Our chef has recently opened a new restaurant with a unique style. The restaurant is divided into K compartments (numbered from 1 to K) and each compartment can be occupied by at most one customer. Each customer that visits the restaurant has a strongly preferred compartment p (1 ≀ p ≀ K), and if that compartment is a...
t = int(input()) for i in range(t): n, k = map(int, input().split()) m = {} for j in range(n): arr, dep, k = list(map(int, input().split())) if k in m: m[k].append([arr, dep]) else: m[k] = [[arr, dep]] c = 0 for temp in m.values(): temp.sort(ke...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR VAR LIST VAR VAR ASSIGN VAR VAR LIST LIST VAR VAR A...
Our chef has recently opened a new restaurant with a unique style. The restaurant is divided into K compartments (numbered from 1 to K) and each compartment can be occupied by at most one customer. Each customer that visits the restaurant has a strongly preferred compartment p (1 ≀ p ≀ K), and if that compartment is a...
def customer(n, k, cust): total = len(cust) for k in cust: m = len(cust[k]) local = cust[k] prev = local[0] i, n = 1, m while i < n: if prev[1] <= local[i][0]: total += 1 prev = local[i] i += 1 return total for...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR WHILE VAR VAR IF VAR NUMBER VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL ...
Our chef has recently opened a new restaurant with a unique style. The restaurant is divided into K compartments (numbered from 1 to K) and each compartment can be occupied by at most one customer. Each customer that visits the restaurant has a strongly preferred compartment p (1 ≀ p ≀ K), and if that compartment is a...
def solve(compartments): total = 0 for compartment in compartments: people = compartments[compartment] people.sort(key=lambda x: x[1]) prevFin = 0 for person in people: start, finish = person if start >= prevFin: total += 1 ...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CAL...
Our chef has recently opened a new restaurant with a unique style. The restaurant is divided into K compartments (numbered from 1 to K) and each compartment can be occupied by at most one customer. Each customer that visits the restaurant has a strongly preferred compartment p (1 ≀ p ≀ K), and if that compartment is a...
def main(n, k): customers = {} allowed = [] for i in range(n): s, f, p = tuple(map(int, input().split())) customers.setdefault(p, []).append((s, f)) for p in customers: interested = sorted(customers[p], key=lambda x: x[1]) allowed.append(interested[0]) for i in ra...
FUNC_DEF ASSIGN VAR DICT ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL FUNC_CALL VAR VAR LIST VAR VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR...
Our chef has recently opened a new restaurant with a unique style. The restaurant is divided into K compartments (numbered from 1 to K) and each compartment can be occupied by at most one customer. Each customer that visits the restaurant has a strongly preferred compartment p (1 ≀ p ≀ K), and if that compartment is a...
def Max_cust(T): for i in range(T): count = 0 cus_prefer = {} n, k = map(int, input().split()) for j in range(n): s, f, p = map(int, input().split()) if p not in cus_prefer: cus_prefer[p] = [(s, f)] else: cus_prefer[...
FUNC_DEF FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR DICT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR LIST VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR FOR VAR FUNC_CALL VAR EXPR FUNC_CALL ...
Our chef has recently opened a new restaurant with a unique style. The restaurant is divided into K compartments (numbered from 1 to K) and each compartment can be occupied by at most one customer. Each customer that visits the restaurant has a strongly preferred compartment p (1 ≀ p ≀ K), and if that compartment is a...
T = int(input()) for z in range(T): N, K = map(int, input().split()) lst = [] for i in range(N): lst.append(tuple(map(int, input().split()))) lst.sort(key=lambda x: x[0]) res = 0 dct = {} for start, end, p in lst: if p in dct.keys(): if end <= dct[p][1]: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR DICT FOR VAR VAR VAR V...
Our chef has recently opened a new restaurant with a unique style. The restaurant is divided into K compartments (numbered from 1 to K) and each compartment can be occupied by at most one customer. Each customer that visits the restaurant has a strongly preferred compartment p (1 ≀ p ≀ K), and if that compartment is a...
t = int(input()) for _ in range(t): n, k = [int(x) for x in input().split()] hmap = dict() for _ in range(n): s, f, p = [int(x) for x in input().split()] hmap.setdefault(p, []).append((s, f)) ans = 0 for key, arr in hmap.items(): ans = ans + 1 arr.sort(key=lambda x: x...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL FUNC_CALL VAR VAR LIST VAR VAR ASSIGN VAR NUMBER FOR VAR VAR FU...
Our chef has recently opened a new restaurant with a unique style. The restaurant is divided into K compartments (numbered from 1 to K) and each compartment can be occupied by at most one customer. Each customer that visits the restaurant has a strongly preferred compartment p (1 ≀ p ≀ K), and if that compartment is a...
def find_max(schedule): schedule.sort(key=lambda k: k[1]) result = 0 free_at = -1 for s, f in schedule: if s >= free_at: free_at = f result += 1 return result def solve(customers, K): schedules = {} result = 0 for s, f, p in customers: if p not i...
FUNC_DEF EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR LIST EXPR FUNC_CALL VAR VAR LIST VAR VAR FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN ...
Our chef has recently opened a new restaurant with a unique style. The restaurant is divided into K compartments (numbered from 1 to K) and each compartment can be occupied by at most one customer. Each customer that visits the restaurant has a strongly preferred compartment p (1 ≀ p ≀ K), and if that compartment is a...
for _ in range(int(input())): n, k = map(int, input().split()) data = [] tab = dict() for _ in range(n): s, f, p = map(int, input().split()) data.append((s, f, p)) data.sort(key=lambda x: x[0]) coustomer = 0 for s, f, p in data: if p in tab: if f <= tab[p]...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VA...
Our chef has recently opened a new restaurant with a unique style. The restaurant is divided into K compartments (numbered from 1 to K) and each compartment can be occupied by at most one customer. Each customer that visits the restaurant has a strongly preferred compartment p (1 ≀ p ≀ K), and if that compartment is a...
from sys import stdin def cal(a): a.sort(key=lambda x: x[1]) len1 = len(a) c = 1 curr = a[0][1] for p in range(0, len1 - 1): if curr <= a[p + 1][0]: c += 1 curr = a[p + 1][1] return c t = int(input()) for i in range(t): n, k = list(map(int, stdin.readline(...
FUNC_DEF EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
T = int(input()) for t in range(T): s1, s2 = [list(x) for x in input().split()] ind = 0 l = len(s1) while ind < l and s1[ind] == min(s1[ind:l]): ind += 1 if ind < l: x = s1[ind:l] x.reverse() c = min(x) ii = x.index(c) cc = s1[ind] s1[ind] = c ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
def check(s1, s2): s = list(s1) s.sort() rtn = "" if s1 < s2: return s1 if "".join(s) > s2: return "---" for i in range(len(s)): if s1[i] != s[i]: rtn += s1[:i] rtn += s[i] for j in range(len(s) - 1, i, -1): if s1[j] == ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR STRING IF VAR VAR RETURN VAR IF FUNC_CALL STRING VAR VAR RETURN STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR VAR VAR BIN_OP...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
t = int(input()) for i in range(t): s, c = input().split() s = list(s) curr = "".join(s) swapped = False for j in range(len(s)): for k in range(j + 1, len(s)): if s[k] < s[j]: s[j], s[k] = s[k], s[j] new = "".join(s) if new < curr: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR VAR V...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
for _ in range(int(input())): s, c = input().split() if s < c: print(s) else: l = len(s) s = [i for i in s] for i in range(l - 1): p = min(s[i + 1 :]) if p < s[i]: u = s[::-1].index(p) u = l - 1 - u v = s...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR ASSIGN ...