description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Suppose you have two points $p = (x_p, y_p)$ and $q = (x_q, y_q)$. Let's denote the Manhattan distance between them as $d(p, q) = |x_p - x_q| + |y_p - y_q|$. Let's say that three points $p$, $q$, $r$ form a bad triple if $d(p, r) = d(p, q) + d(q, r)$. Let's say that an array $b_1, b_2, \dots, b_m$ is good if it is im...
import sys input = sys.stdin.readline def main(): t = int(input()) INF = 1001001001 for _ in range(t): n = int(input()) A = list(map(int, input().split())) ans = n + n - 1 for i in range(n - 2): if check(A[i], i, A[i + 1], i + 1, A[i + 2], i + 2): ...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR 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 BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR...
Suppose you have two points $p = (x_p, y_p)$ and $q = (x_q, y_q)$. Let's denote the Manhattan distance between them as $d(p, q) = |x_p - x_q| + |y_p - y_q|$. Let's say that three points $p$, $q$, $r$ form a bad triple if $d(p, r) = d(p, q) + d(q, r)$. Let's say that an array $b_1, b_2, \dots, b_m$ is good if it is im...
for _ in range(int(input())): n = int(input()) zoz = [int(x) for x in input().split()] subs1 = subs2 = 0 if len(zoz) >= 3: for i in range(2, n): if ( zoz[i - 2] <= zoz[i - 1] and zoz[i - 1] <= zoz[i] or zoz[i - 2] >= zoz[i - 1] ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR...
Suppose you have two points $p = (x_p, y_p)$ and $q = (x_q, y_q)$. Let's denote the Manhattan distance between them as $d(p, q) = |x_p - x_q| + |y_p - y_q|$. Let's say that three points $p$, $q$, $r$ form a bad triple if $d(p, r) = d(p, q) + d(q, r)$. Let's say that an array $b_1, b_2, \dots, b_m$ is good if it is im...
def calc(a, i): if a[i] == a[i + 1]: return i + 2 if a[i + 1] == a[i + 2]: return i + 2 if a[i] == a[i + 2]: return i + 3 if a[i] < a[i + 1] < a[i + 2]: return i + 2 if a[i] > a[i + 1] > a[i + 2]: return i + 2 if a[i] > a[i + 2] > a[i + 1]: return ...
FUNC_DEF IF VAR VAR VAR BIN_OP VAR NUMBER RETURN BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER RETURN BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER RETURN BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER RETURN BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
import sys input = sys.stdin.readline n, m = map(int, input().split()) x = [0] * (n + 1) c = 0 for i in range(m): u, v = map(int, input().split()) mn = min(u, v) if x[mn] == 0: c += 1 x[mn] += 1 q = int(input()) for i in range(q): a, *b = map(int, input().split()) if a == 3: pri...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR VAR NUMBER VAR NUMBER VAR VAR NUMBER ASSIGN VAR FUNC...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
arr = input().split() n = int(arr[0]) m = int(arr[1]) list_frd = [] for i in range(n): list_frd.append(0) nobles = n for i in range(m): arr = input().split(" ") s = int(arr[0]) b = int(arr[1]) if s > b: s, b = b, s s = s - 1 if list_frd[s] == 0: nobles = nobles - 1 list_f...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR V...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
import sys input = sys.stdin.readline n, q = list(map(int, input().split())) arr = [0] * n c = 0 for _ in range(q): a, b = map(int, input().split()) if a < b: ind = a - 1 else: ind = b - 1 arr[ind] += 1 if arr[ind] == 1: c += 1 for i in range(int(input())): y = list(map(...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR VAR NUMBER IF VAR V...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
import sys input = sys.stdin.readline def inp(): return int(input()) def inlt(): return list(map(int, input().split())) def insr(): s = input() return list(s[: len(s) - 1]) def invr(): return map(int, input().split()) n = inlt() a = [] m = n[1] n = n[0] ans = n for i in range(0, n + 1): ...
IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR RETURN FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN V...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
import sys n, m = map(int, sys.stdin.readline().split()) graph = [0] * n ans = 0 for f in range(m): u, v = map(int, sys.stdin.readline().split()) graph[min(u, v) - 1] += 1 if graph[min(u, v) - 1] == 1: ans += 1 q = int(sys.stdin.readline()) for qr in range(q): arr = list(map(int, sys.stdin.read...
IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR FU...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
import sys input = sys.stdin.readline nn, m = map(int, input().split()) n = nn b = [(0) for i in range(n + 1)] p = 0 for i in range(m): c, d = map(int, input().split()) f = min(c, d) if b[f] == 0: p += 1 b[f] += 1 q = int(input()) for i in range(q): a, *bb = map(int, input().split()) if...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR VAR NUMBER VAR NUMBER VAR VAR N...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
n, m = map(int, input().split()) seen = [0] * (n + 1) ans = n for i in range(m): u, v = map(int, input().split()) u, v = sorted([u, v]) seen[u] += 1 if seen[u] == 1: ans -= 1 q = int(input()) for i in range(q): row = input() if len(row) == 1: print(ans) else: k, u, v ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR LIST VAR VAR VAR VAR NUMBER IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_C...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
n, m = map(int, input().split()) a = [(0) for i in range(n)] for i in range(m): ar, b = map(int, input().split()) x = min(ar, b) a[x] += 1 s = 0 for i in a: if i == 0: s += 1 at = a g = 1 st = int(s) for q in range(int(input())): t = input() if t[0] == "3": print(st) else: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSI...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
n, m = list(map(int, input().split())) w = [(0) for i in range(n)] for i in range(m): u, v = map(int, input().split()) if u > v: w[v - 1] += 1 else: w[u - 1] += 1 ans = w.count(0) for _ in range(int(input())): s = list(map(int, input().split())) if s[0] == 3: print(ans) e...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUN...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
n, m = map(int, input().split()) stronger = [0] * (n + 1) total = 0 for i in range(m): u, v = map(int, input().split()) u, v = min(u, v), max(u, v) stronger[u] += 1 if stronger[u] == 1: total += 1 query = int(input()) for q in range(query): X = input().split() i, u, v = int(X[0]), None, ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR ...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
import sys input = sys.stdin.readline n, m = map(int, input().split()) count = [0] * (n + 1) preans = n for i in range(m): arr = list(map(int, input().split())) mini = min(arr) if count[mini] == 0: count[mini] += 1 preans -= 1 else: count[mini] += 1 ans = preans temp = count for...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER VAR NUMBER VAR VAR NUMB...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
from sys import stdin N, M = map(int, stdin.readline().split()) counts = [0] * (N + 1) ans = 0 for _ in range(M): u, v = map(int, stdin.readline().split()) if u > v: u, v = v, u counts[u] += 1 if counts[u] == 1: ans += 1 Q = int(stdin.readline()) for _ in range(Q): args = list(map(i...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL V...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
import sys input = sys.stdin.readline cnt = [0] * 200050 ans = 0 n, m = map(int, input().split()) for i in range(1, m + 1): u, v = map(int, input().split()) if u > v: u, v = v, u cnt[u] += 1 if cnt[u] == 1: ans += 1 q = int(input().strip()) while q: query = list(map(int, input().spl...
IMPORT ASSIGN VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR NUMBER VAR NUMBER ASSI...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
import sys def input(): s = sys.stdin.readline() return s n, m = map(int, input().strip().split()) nodes = [set() for i in range(1 + n)] empty_sets = n pairs = [] for i in range(m): f, t = sorted(list(map(int, input().strip().split()))) if len(nodes[f]) == 0: empty_sets -= 1 nodes[f].add...
IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FU...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
n, m = map(int, input().split()) ar = [(0) for _ in range(n + 1)] ans = n for _ in range(m): u, v = map(int, input().split()) u, v = min(u, v), max(u, v) if ar[u] == 0: ans -= 1 ar[u] += 1 q = int(input()) for _ in range(q): inp = input() if inp[0] == "1": _, u, v = inp.split() ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR NUMBER VAR NUMBER VAR VAR NUMBER ASSIGN V...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
def ii(): return int(input()) def si(): return input() def mi(): return map(int, input().split()) def msi(): return map(str, input().split()) def li(): return list(mi()) for _ in range(1): n, m = mi() ans = 0 res = [0] * (n + 1) for i in range(m): u, v = mi() ...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
m, n = map(int, input().split()) l = [0] * (m + 1) ans = 0 for i in range(n): u, v = map(int, input().split()) if u > v: u, v = v, u l[u] += 1 if l[u] == 1: ans += 1 q = int(input()) for i in range(q): li = list(map(int, input().split())) if len(li) == 1: print(m - ans) ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL V...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
import sys input = sys.stdin.readline n, m = map(int, input().split()) E = [0] * n ans = n for i in range(m): u, v = map(int, input().split()) u -= 1 v -= 1 if u > v: u, v = v, u E[u] += 1 if E[u] == 1: ans -= 1 q = int(input()) for i in range(q): tmp = input() if len(tm...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR NUMBER VAR NUMBER ASSIGN VA...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
n, m = map(int, input().split()) g = [] c1 = [] c2 = [] for i in range(n): c1.append(0) c2.append(0) q = [1] * n for i in range(m): a, b = map(lambda z: int(z) - 1, input().split()) a, b = min(a, b), max(a, b) c1[a] += 1 c2[b] += 1 q[a] = 0 cur = sum(q) ans = [] for _ in range(int(input())):...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL FUNC_C...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
import sys input = sys.stdin.readline n, m = list(map(int, input().split())) a = [0] * (n + 1) ans = n for i in range(m): u, v = list(map(int, input().split())) u = min(u, v) if a[u] == 0: ans -= 1 a[u] += 1 q = int(input()) for i in range(q): b = list(map(int, input().split())) if b[0]...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR VAR NUMBER VAR NUMBER VAR V...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
import sys input = sys.stdin.readline n, m = map(int, input().split()) a = [0] * (n + 1) for _ in range(m): x, y = map(int, input().split()) y = min(x, y) a[y] += 1 summ = 0 for i in range(1, n + 1): if a[i] == 0: summ += 1 q = int(input()) for _ in range(q): x = list(map(int, input().split...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMB...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
from sys import stdin input = stdin.readline m, n = map(int, input().split()) dp = [0] * (m + 1) dead = 0 for i in range(n): u, v = map(int, input().split()) if dp[min(u, v)] == 0: dead += 1 dp[min(u, v)] += 1 for q in range(int(input())): command = list(input().split()) if command[0] == "1...
ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR VAR NUMBER FOR VAR FUNC_CALL V...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
import sys def add(d, obj, counter): if d[obj] == 0: counter += 1 d[obj] += 1 return counter def sub(d, obj, counter): d[obj] -= 1 if d[obj] == 0: counter -= 1 return counter input = sys.stdin.readline n, m = map(int, input().split()) a = {x: (0) for x in range(1, n + 1)} c...
IMPORT FUNC_DEF IF VAR VAR NUMBER VAR NUMBER VAR VAR NUMBER RETURN VAR FUNC_DEF VAR VAR NUMBER IF VAR VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSI...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
import sys input = sys.stdin.readline n, m = map(int, input().split()) l = [0] * (n + 1) for i in range(m): u, v = sorted(map(int, input().split())) l[u] += 1 c = 0 for i in range(1, n + 1): if l[i] == 0: c += 1 z = [] q = int(input()) for i in range(q): s = input().split() if s[0] == "1": ...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR NUMBE...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
n, m = map(int, input().split()) g = [0] * n for _ in range(m): u, v = map(int, input().split()) u -= 1 v -= 1 if v > u: g[u] += 1 else: g[v] += 1 q = int(input()) answer = sum([(1) for i in range(n) if g[i] == 0]) allAnswers = [] for _ in range(q): query = list(map(int, input()....
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR FUNC_CAL...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
n, m = map(int, input().split()) arr = [(0) for i in range(n)] for i in range(m): u, v = map(int, input().split()) if u > v: arr[v - 1] += 1 else: arr[u - 1] += 1 q = int(input()) ans = 0 for i in arr: if i == 0: ans += 1 for i in range(q): temp2 = input() if temp2 != "3"...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
n, m = map(int, input().split()) di = [0] * (n + 2) dead = 0 for _ in range(m): a, b = map(int, input().split()) if a > b: a, b = b, a if di[a] == 0: dead += 1 di[a] += 1 q = int(input()) for _ in range(q): st = input() if st == "3": print(n - dead) else: x, a...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR IF VAR VAR NUMBER VAR NUMBER VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL V...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
import sys input = sys.stdin.readline n, m = map(int, input().split()) friends = [0] * n dead = 0 for _ in range(m): i, j = map(int, input().split()) if friends[min(i, j)] == 0: dead += 1 friends[min(i, j)] += 1 q = int(input()) for _ in range(q): a = input().split() if a[0] == "1": ...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR F...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
import sys input_file = sys.stdin output_file = sys.stdout n_str, m_str = input_file.readline().strip().split() n = int(n_str) m = int(m_str) f = [0] * (n + 1) for i in range(m): u, v = input_file.readline().strip().split() a, b = min(int(u), int(v)), max(int(u), int(v)) f[a] += 1 killed = 0 for i in range...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_C...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
from sys import stdin, stdout n, m = map(int, stdin.readline().split()) li = [0] * (n + 1) for i in range(m): u, v = map(int, stdin.readline().split()) li[min(u, v)] += 1 a = 0 for j in range(1, n + 1): if li[j] == 0: a = a + 1 q = int(stdin.readline()) for j in range(q): ai = list(map(int, std...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR BIN_O...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
import sys input = sys.stdin.readline t = 1 for _ in range(t): n, m = map(int, input().split()) can = 0 dead = 0 now = [[0, 0] for i in range(n + 1)] for i in range(m): a, b = map(int, input().split()) if a > b: now[a][0] += 1 now[b][1] += 1 else: ...
IMPORT ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR V...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
n, m = [int(i) for i in input().split()] nobles = [(0) for i in range(n)] for i in range(m): u, v = [(int(i) - 1) for i in input().split()] if u > v: u, v = v, u if nobles[u] == 0: n -= 1 nobles[u] += 1 m = int(input()) for i in range(m): u = input() if u == "3": print(n)...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR IF VAR VAR NUMBER VAR NUMBER VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR F...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
for _ in range(1): n, m = map(int, input().split()) mp = dict() for i in range(m): x, y = map(int, input().split()) x, y = max(x, y), min(x, y) if y in mp: mp[y] += 1 else: mp[y] = 1 q = int(input()) for h in range(q): qu = input() ...
FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CAL...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
n, m = list(map(int, input().split())) arr = [1] * n frnd = [0] * n for _ in range(m): x, y = list(map(int, input().split())) if x > y: arr[y] = 0 frnd[y] += 1 else: arr[x] = 0 frnd[x] += 1 ans = frnd.count(0) tem = 0 temp = 0 q = int(input()) for _ in range(q): tem = inp...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR VAR NUMBER...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
import sys def int_arr(): return list(map(int, sys.stdin.readline().strip().split())) def str_arr(): return list(map(str, sys.stdin.readline().strip().split())) def input(): return sys.stdin.readline() def out(x): return sys.stdout.write(str(x)) n, q = list(map(int, input().split())) arr = [0]...
IMPORT FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
n, m = map(int, input().split()) small = [0] * (n + 1) big = [0] * (n + 1) for i in range(m): u, v = map(int, input().split()) small[max(u, v)] += 1 big[min(u, v)] += 1 ans = 0 for i in range(1, n + 1): if big[i] == 0: ans += 1 q = int(input()) for i in range(q): ch = input().split(" ") ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER ...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
import sys input = sys.stdin.readline n, m = list(map(int, input().split())) data = [(0) for i in range(n + 1)] ans = n while m > 0: a, b = list(map(int, input().split())) if a > b: a, b = b, a if data[a] == 0: ans -= 1 data[a] += 1 m -= 1 q = int(input()) while q > 0: q -= 1 ...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR IF VAR VAR NUMBER VAR NUMBER VAR VAR...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
n, m = map(lambda x: int(x), input().split()) N = n E = [0] * (n + 1) res = [] for _ in range(m): a, b = sorted(map(lambda x: int(x), input().split())) if E[a] == 0: N -= 1 E[a] += 1 Q = int(input()) for _ in range(Q): q = input().split() if q[0] == "3": res.append(N) elif q[0] =...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR NUMBER VAR NUMBER VAR VAR NUMBER ASSIGN VAR FUNC...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
n, m = map(int, input().split()) a = [0] * n for _ in range(m): b, c = map(int, input().split()) a[min(b, c)] += 1 z = 0 for i in a: if i == 0: z += 1 s1 = z v = list(a) q = int(input()) for _ in range(q): t = input() if t[0] == "3": print(s1) else: query, b, c = map(int,...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUN...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
n, m = map(int, input().split()) frens = [(0) for __ in range(n + 1)] for _ in range(m): u, v = map(int, input().split()) if u > v: frens[v] += 1 else: frens[u] += 1 alive = 0 for i in range(1, n + 1): if frens[i] == 0: alive += 1 for ___ in range(int(input())): inp = input()...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR NUMBER VA...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
A = list(map(int, input().split())) n, m = A[0], A[1] dic = [(0) for _ in range(n + 1)] ans = 0 for _ in range(m): A = list(map(int, input().split())) minn = min(A) if dic[minn] == 0: ans += 1 dic[minn] += 1 x = int(input()) for _ in range(x): A = input() if len(A) == 1: print(n ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR ...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
a, m = map(int, input().split()) c = [0] * (a + 1) for _ in range(m): u, v = map(int, input().split()) z = min(u, v) if c[z] == 0: a -= 1 c[z] += 1 for _ in range(int(input())): tes = input().split() if len(tes) == 1: print(a) else: x, u, v = map(int, tes) if ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR VAR NUMBER VAR NUMBER VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIG...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
n, m = map(int, input().split()) x = [0] * n for i in range(m): u, v = map(int, input().split()) u -= 1 v -= 1 if u < v: x[u] += 1 else: x[v] += 1 c = 0 for i in range(n): if x[i] == 0: c += 1 q = int(input()) while q: q -= 1 s = input() if len(s) == 1: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
q = list(map(int, input().split())) a = [(0) for _ in range(q[0])] res = q[0] for _ in range(q[1]): x = min(list(map(int, input().split()))) res -= 1 if a[x] == 0 else 0 a[x] += 1 for _ in range(int(input())): x = input().split() if x[0] == "1": x = min(int(x[1]), int(x[2])) res -= 1...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR VAR NUMBER NUMBER NUMBER VAR VAR NUMBER FOR VAR FUNC_CALL VAR ...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
n, m = map(int, input().split()) g = [0] * (n + 1) dead = 0 for i in range(m): x, y = map(int, input().split()) if x > y: weak = y else: weak = x g[weak] += 1 if g[weak] == 1: dead += 1 for q in range(int(input())): miku = input().split() if len(miku) == 1: pr...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR VAR NUMBER IF VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CA...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
import sys N = 200010 f = [-1] * N def find(x): if f[x] == x: return x f[x] = find(f[x]) return f[x] def ufsInit(): for i in range(1, n + 1): f[i] = i a = [0] * N input = sys.stdin.readline n, m = map(int, input().split()) for i in range(0, m): x, y = map(int, input().split())...
IMPORT ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FUNC_DEF IF VAR VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR RETURN VAR VAR FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CA...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
n, m = [int(i) for i in input().split(" ")] vin = {} vout = {} ans = 0 for i in range(1, n + 1): vin[i] = 0 vout[i] = 0 for i in range(m): u, v = [int(j) for j in input().split(" ")] if u > v: vout[u] += 1 vin[v] += 1 else: vout[v] += 1 vin[u] += 1 for i in vin: i...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR VAR VAR VA...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
ANS = 0 DEG = [] def add(u, v): global ANS, DEG if u > v: u, v = v, u ANS -= DEG[u] == 0 DEG[u] += 1 def del_(u, v): global ANS, DEG if u > v: u, v = v, u DEG[u] -= 1 ANS += DEG[u] == 0 def main(): global ANS, DEG n, m = map(int, input().split()) ANS = n...
ASSIGN VAR NUMBER ASSIGN VAR LIST FUNC_DEF IF VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR NUMBER VAR VAR NUMBER FUNC_DEF IF VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR NUMBER VAR VAR VAR NUMBER FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
n, m = map(int, input().split()) a = [0] * n ot = 0 for i in range(m): u, v = map(int, input().split()) b = min(u, v) a[b - 1] += 1 if a[b - 1] == 1: ot += 1 q = int(input()) for i in range(q): s = input() if s[0] == "3": print(n - ot) if s[0] != "3": x, y, z = map(in...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VA...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
def solve(): n, m = map(int, input().split()) ans = dict() for i in range(m): u, v = map(int, input().split()) if u > v: if v in ans: ans[v] += 1 else: ans[v] = 1 elif u in ans: ans[u] += 1 else: ...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
import sys input = sys.stdin.readline n, m = map(int, input().split()) arr = [0] * n ans = n for x in range(m): u, v = map(int, input().split()) k = min(u, v) if arr[k - 1] == 0: ans -= 1 arr[k - 1] += 1 for tt in range(int(input())): l = list(map(int, input().split())) a = l[0] if ...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER FOR ...
When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships". A friendship between nobles $a$ and $b$ is always mutual. A nob...
n, m = map(int, input().split()) higher_friends = [(0) for i in range(n)] alive = n for i in range(m): a, b = map(int, input().split()) if a > b: if higher_friends[b - 1] == 0: alive -= 1 higher_friends[b - 1] += 1 else: if higher_friends[a - 1] == 0: alive -=...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR IF VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER...
On the way to school, Karen became fixated on the puzzle game on her phone! [Image] The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col...
def all_zero(A): for row in A: for e in row: if e != 0: return False return True n, m = input().split(" ") n = int(n) m = int(m) A = [] for _ in range(n): row = input().split(" ") row = list(map(int, row)) A += [row] moves = [] min_elem = min(min(row) for row in...
FUNC_DEF FOR VAR VAR FOR VAR VAR IF VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR LIST V...
On the way to school, Karen became fixated on the puzzle game on her phone! [Image] The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col...
n, m = map(int, input().split()) a = [] tot = 0 row = [] col = [] n1 = "row" n2 = "col" for _ in range(n): a += [[int(f) for f in input().split()]] if n > m: a = list(map(list, zip(*a))) n, m = m, n n1, n2 = n2, n1 for x in range(n): for y in range(min(a[x])): row += [x + 1] tot += sum(a...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR VAR LIST FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN V...
On the way to school, Karen became fixated on the puzzle game on her phone! [Image] The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col...
import sys n, m = map(int, sys.stdin.readline().split()) l = [] row = [0] * n col = [0] * m flag = True if m > n: for i in range(n): l.append(list(map(int, sys.stdin.readline().split()))) tmp = min(l[i]) row[i] = tmp if tmp != 0: l[i] = list(map(lambda x: x - tmp, l[i]))...
IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER IF VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VA...
On the way to school, Karen became fixated on the puzzle game on her phone! [Image] The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col...
import sys def min_i_v(row): min_v = None min_i = None for i, v in enumerate(row): if min_v is None or v < min_v: min_v = v min_i = i return min_i, min_v def dec_row(matrix, row_i, val): for i in range(len(matrix[row_i])): matrix[row_i][i] -= val def dec...
IMPORT FUNC_DEF ASSIGN VAR NONE ASSIGN VAR NONE FOR VAR VAR FUNC_CALL VAR VAR IF VAR NONE VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR RETURN VAR VAR FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_C...
On the way to school, Karen became fixated on the puzzle game on her phone! [Image] The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col...
def func(l, n, m, row, col): for i in range(n): mi = min(l[i]) if mi: l[i] = [(x - mi) for x in l[i]] for j in range(mi): row.append(i) for j in range(m): c = [x[j] for x in l] mi = min(c) if max(c) - mi > 0: print("-1")...
FUNC_DEF FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FU...
On the way to school, Karen became fixated on the puzzle game on her phone! [Image] The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col...
inpt = input().split(" ") n = int(inpt[0]) m = int(inpt[1]) arr = [] for i in range(n): inpt = input().split(" ") inpt = list(map(int, inpt)) arr.append(inpt) sol = [] def solver1(a, sol): allmin = min([min(suba) for suba in a]) if allmin < 0: return False allmax = max([max(suba) for s...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FUNC_DEF ASSIGN VAR FUNC_CALL VAR FU...
On the way to school, Karen became fixated on the puzzle game on her phone! [Image] The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col...
n, m = map(int, input().split()) g = [list(map(int, input().split())) for i in range(n)] x, xi, xj = 500, 0, 0 for i, gi in enumerate(g): for j, gij in enumerate(gi): if gij < x: x, xi, xj = gij, i, j r, c = [(g[i][xj] - x) for i in range(n)], [(g[xi][j] - x) for j in range(m)] for i, gi in enum...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR VA...
On the way to school, Karen became fixated on the puzzle game on her phone! [Image] The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col...
def isNullified(): for i in range(n): if max(matrix[i]) != 0: return False return True def processRows(): for i in range(n): minValue = min(matrix[i]) if minValue != 0: content = "row " + str(i + 1) result.extend(minValue * [content]) ...
FUNC_DEF FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP STRING FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR LIST VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR FUNC_...
On the way to school, Karen became fixated on the puzzle game on her phone! [Image] The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col...
import sys input = sys.stdin.readline n, m = map(int, input().split()) realg = [list(map(int, input().split())) for _ in range(n)] g = [([0] * m) for _ in range(n)] ans = [] f1 = min([realg[0][i] for i in range(m)]) for i in range(m): for _ in range(realg[0][i] - f1): ans.append("col %d" % (i + 1)) for...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL ...
On the way to school, Karen became fixated on the puzzle game on her phone! [Image] The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col...
def main(): n, m = list(map(int, input().split())) l, r = [list(map(int, input().split())) for _ in range(n)], [] if n > m: l = [list(col) for col in zip(*l)] cols, rows = "row %d", "col %d" else: cols, rows = "col %d", "row %d" for y, row in enumerate(l, 1): a = min(...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR LIST IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR STRING STRING ASSIGN VAR VAR STRING STRING FOR VAR VAR FUNC_CALL ...
On the way to school, Karen became fixated on the puzzle game on her phone! [Image] The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col...
from sys import stdin, stdout arr = ["row", "col"] def solve(g, n, m, flag): newG = [] ans = [] for i in range(n): newG.append([0] * m) for i in range(n): k = min(g[i]) newG[i] = [k] * m ans.extend([arr[flag] + " {}".format(i + 1)] * k) for i in range(m): k...
ASSIGN VAR LIST STRING STRING FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR BIN_OP LIST VAR VAR EXPR FUNC_CALL VAR BIN_OP LIST BIN_OP VAR VAR FUNC_CALL STRING BIN_OP VAR NUMBER VAR FO...
On the way to school, Karen became fixated on the puzzle game on her phone! [Image] The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col...
n, m = input().strip().split() n, m = int(n), int(m) g = [[int(j) for j in input().strip().split()] for i in range(n)] answer = [] def b(): for i in range(n): minRow = min(g[i]) if minRow != 0: for k in range(minRow): answer.append("row " + str(i + 1)) for j...
ASSIGN VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FUNC_DEF FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FU...
On the way to school, Karen became fixated on the puzzle game on her phone! [Image] The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col...
n, m = map(int, input().split()) grid = [list(map(int, input().split())) for i in range(n)] ans = [] if m > n: for i in range(n): mini = min(grid[i]) for j in range(m): grid[i][j] -= mini for _ in range(mini): ans.append("row " + str(i + 1)) for i in range(m): ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST IF VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR B...
On the way to school, Karen became fixated on the puzzle game on her phone! [Image] The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col...
from itertools import product n, m = map(int, input().split()) matr = [] for i in range(n): matr.append([int(num) for num in input().split()]) def walker(start_row, start_col, dif_row, dif_col): row = start_row col = start_col while 0 <= row < n and 0 <= col < m: yield row, col row +=...
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 VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR WHILE NUMBER VAR VAR NUMBER VAR VAR EXPR VAR VAR VAR VAR VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR NUMBER NUMBER NUMB...
On the way to school, Karen became fixated on the puzzle game on her phone! [Image] The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col...
n, m = 0, 0 arr, res_r, res_c = [], [], [] def solve_row(): global arr, res_r, n, m res = 0 for i in range(n): mini = int(2000000000.0) for j in range(m): mini = min(mini, arr[i][j]) if mini == 0: continue res += mini res_r += [(i + 1, mini)]...
ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR LIST LIST LIST FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR NUMBER VAR VAR VAR LIST BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR RETURN VAR...
On the way to school, Karen became fixated on the puzzle game on her phone! [Image] The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col...
def min_row(): ans = 0 for i in range(n): ans += min(a[i]) return ans def min_col(): ans = 0 for i in range(m): mm = 10000 for j in range(n): mm = min(mm, a[j][i]) ans += mm return ans def remove_cols(): ans = 0 min_col = [0] * m for i ...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC...
On the way to school, Karen became fixated on the puzzle game on her phone! [Image] The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col...
n, m = map(int, input().split()) g = [list(map(int, input().split())) for _ in range(n)] a = [0] * n b = [0] * m a[0] = min(g[0]) for j in range(m): g[0][j] -= a[0] b[j] = g[0][j] good = True for i in range(n): for j in range(m): g[i][j] -= b[j] if min(g[i]) < 0 or min(g[i]) != max(g[i]): ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR ...
On the way to school, Karen became fixated on the puzzle game on her phone! [Image] The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col...
n, m = map(int, input().split()) array = [] row_sums = [(0) for x in range(n)] for i in range(n): array.append(list(map(int, input().split()))) row_sums[i] = sum(array[i]) col_sums = [sum(x) for x in zip(*array)] min_row_index = row_sums.index(min(row_sums)) min_col_index = col_sums.index(min(col_sums)) row_boo...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CA...
On the way to school, Karen became fixated on the puzzle game on her phone! [Image] The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col...
n, m = map(int, input().split()) grid = [] for _ in range(n): grid.append(list(map(int, input().split()))) count = 0 moves = [] grid2 = [] for row in grid: grid2.append(row[:]) def do_row(grid, row): global count r = row row = grid[row] m = min(row) count += m for _ in range(m): ...
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 ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CA...
On the way to school, Karen became fixated on the puzzle game on her phone! [Image] The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col...
x, y = map(int, input().split()) grid = [] for i in range(x): grid.append(list(map(int, input().split()))) mi = grid[0][0] prints = [] for i in range(x): mi = min(mi, min(grid[i])) if x > y: for k in range(mi): for i in range(1, y + 1): prints.append("col " + str(i)) else: for k in r...
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 ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR FOR VAR FUNC_...
On the way to school, Karen became fixated on the puzzle game on her phone! [Image] The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col...
n, m = (int(i) for i in input().split()) tbl = [] for i in range(n): crstr = [int(j) for j in input().split()] tbl.append(crstr) true = 0 def prt(): for xx in range(n): for yy in range(m): print(tbl[xx][yy], end="\t") print() print() print() def lines(): rows = []...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FUNC_DEF FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR STRING EXPR FUNC_CALL VAR E...
On the way to school, Karen became fixated on the puzzle game on her phone! [Image] The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col...
def Check(Mat, Row, Col, TotalSum): N = len(Mat) M = len(Mat[0]) SummTillNow = Row[0] * M + Col[0] * N for i in range(0, N): for j in range(0, M): if not (i == 0 and j == 0): if Mat[i][j] == 0: if i in Row and Row[i] != 0 or j in Col and Col[j] != ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER VAR NUMBER IF VAR VAR VAR NUMBER IF VAR VAR VAR VAR NUMBER VAR VAR VAR VAR NUMBER RETURN NUMBER ASSIGN V...
On the way to school, Karen became fixated on the puzzle game on her phone! [Image] The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col...
def printMatrix(matrix): s = [[str(e) for e in row] for row in matrix] lens = [max(map(len, col)) for col in zip(*s)] fmt = "\t".join("{{:{}}}".format(x) for x in lens) table = [fmt.format(*row) for row in s] print("_________________") print("\n".join(table)) print("`````````````````") n, ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL STRING VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR ...
On the way to school, Karen became fixated on the puzzle game on her phone! [Image] The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col...
n, m = map(int, input().split()) L = [list(map(int, input().split())) for i in range(n)] s = "row" s1 = "col" if n > m: L1 = [[(0) for i in range(n)] for j in range(m)] for i in range(n): for j in range(m): L1[j][i] = L[i][j] L = L1 n, m = m, n s, s1 = s1, s w = [(0) for i in ran...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR STRING IF VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VA...
On the way to school, Karen became fixated on the puzzle game on her phone! [Image] The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col...
class CodeforcesTask815ASolution: def __init__(self): self.result = "" self.n_m = [] self.board = [] def read_input(self): self.n_m = [int(x) for x in input().split(" ")] for x in range(self.n_m[0]): self.board.append([int(y) for y in input().split(" ")]) ...
CLASS_DEF FUNC_DEF ASSIGN VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST...
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you? You are given a set of digits, your task is to find the maximum integer that you can mak...
def to_int(lis): for i in range(len(lis)): lis[i] = int(lis[i]) return lis def sum_of_digits(lis): ans = 0 for d in lis: ans += d return ans n = int(input()) a = input().split() a = to_int(a) if 0 not in a: print(-1) else: a = sorted(a, reverse=True) s = sum_of_digits...
FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF NUMBER VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL V...
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you? You are given a set of digits, your task is to find the maximum integer that you can mak...
from sys import exit n = int(input()) mas = list(map(int, input().split())) di = {i: (0) for i in range(10)} s = 0 for i, x in enumerate(mas): s += x di[x] += 1 if di[0] > 0: a = s % 3 if a == 0: from sys import exit if n == di[0]: print(0) exit() for i ...
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 NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER IF VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER IF VAR VAR NUMBER EXPR FUNC_CALL...
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you? You are given a set of digits, your task is to find the maximum integer that you can mak...
n = int(input()) l = list(map(int, input().split())) l.sort(reverse=True) if 0 not in l: print(-1) else: l = list(map(str, l)) k = int("".join(l)) if k % 3 == 0: print(k) else: c = k % 3 if c == 1: l1 = [] l2 = [] for i in range(n): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER IF NUMBER VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR ASSI...
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you? You are given a set of digits, your task is to find the maximum integer that you can mak...
n = int(input()) a = list(map(int, input().split())) c = [0] * 10 for i in range(n): c[a[i]] += 1 if c[0] == 0: print(-1) exit() c[0] -= 1 m = 0 for i in range(1, 10): m += c[i] * i m %= 3 if m % 3 == 1: if c[1] > 0: c[1] -= 1 m -= 1 elif c[4] > 0: c[4] -= 1 m...
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 LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER N...
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you? You are given a set of digits, your task is to find the maximum integer that you can mak...
def ans(): global answered global final if answered: return sum = 0 for i in final: sum += i if sum == 0: print(0) answered = True return for i in final: print(i, end="") print() answered = True answered = False N = int(input()) A = l...
FUNC_DEF IF VAR RETURN ASSIGN VAR NUMBER FOR VAR VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER RETURN FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL F...
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you? You are given a set of digits, your task is to find the maximum integer that you can mak...
def s(): input() a = list(map(int, input().split())) a.sort(reverse=True) if a[-1] == 0: r = sum(a) % 3 if r == 0: if a[0] > 0: print(*a, sep="") else: print(0) else: for i, v in reversed(list(enumerate(a))): ...
FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR NUMBER IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR NUMBER FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC...
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you? You are given a set of digits, your task is to find the maximum integer that you can mak...
for i in range(1): input() a = sorted(map(int, input().split())) if a[0]: a = [-1] else: s = sum(a) if s % 3: for i in a: if i % 3 == s % 3: a.remove(i) break else: for i in a: ...
FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER FOR VAR VAR IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR VAR IF BIN_OP VAR NUMBER EXPR FUNC_C...
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you? You are given a set of digits, your task is to find the maximum integer that you can mak...
n = int(input()) a = list(map(int, input().split())) a.sort() if a[0] != 0: print(-1) exit() s = sum(a) % 3 if s != 0: b = next((i for i, v in enumerate(a) if v % 3 == s), None) if b is None: del a[next((i for i, v in enumerate(a) if v % 3 == 3 - s), None)] del a[next((i for i, v in enum...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER...
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you? You are given a set of digits, your task is to find the maximum integer that you can mak...
def diminish(count, k): for d in range(k, 10, 3): if count[d] > 0: count[d] -= 1 return True return False def solve(count, sum): if sum % 3 == 1: if not diminish(count, 1): if not diminish(count, 2) or not diminish(count, 2): print(0) ...
FUNC_DEF FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR VAR NUMBER VAR VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF IF BIN_OP VAR NUMBER NUMBER IF FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN IF BIN_OP VAR NUMBER NUMBER IF FUNC_CALL VAR VAR NUMBER IF ...
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you? You are given a set of digits, your task is to find the maximum integer that you can mak...
from sys import exit n = int(input()) arr = list(map(int, input().split())) if arr == [0]: print(0) exit(0) if 0 not in arr: print(-1) exit(0) arr = sorted(arr, reverse=True) arr.remove(0) while sum(arr) % 3 != 0: mod = sum(arr) % 3 for i in sorted(set(arr)): if i % 3 == mod: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR LIST NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF NUMBER VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER WHILE BIN_OP FU...
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you? You are given a set of digits, your task is to find the maximum integer that you can mak...
alist = [(0) for i in range(0, 10)] n = int(input()) test = input() numbers = test.split() for i in range(n): alist[int(numbers[i])] += 1 def checker(n): s = "" if not alist[0]: return -1 rem = ( 1 * alist[1] + 2 * alist[2] + 3 * alist[3] + 4 * alist[4] ...
ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER FUNC_DEF ASSIGN VAR STRING IF VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP ...
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you? You are given a set of digits, your task is to find the maximum integer that you can mak...
n, t = int(input()), input()[::2] p, r = {i: (0) for i in "0123456789"}, "-1" for i in t: p[i] += 1 if p["0"]: t = ["147", "258"] x = [sum(p[i] for i in k) for k in t] d = x[0] % 3 - x[1] % 3 if d: d, t = (1, t[d > 0]) if abs(d) == 2 and x[d > 0] else (abs(d), t[d < 0]) for i in t: ...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR NUMBER VAR STRING STRING FOR VAR VAR VAR VAR NUMBER IF VAR STRING ASSIGN VAR LIST STRING STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER IF VAR ASSIGN VAR VAR FU...
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you? You are given a set of digits, your task is to find the maximum integer that you can mak...
from sys import stdin, stdout n = int(input()) l = list(map(int, stdin.readline().split())) l.sort() flag = 0 if l[0] != 0: flag = 1 else: sum1 = 0 for i in l: sum1 = sum1 + i if sum1 % 3 == 0: flag = 2 elif sum1 % 3 == 1: for i in range(n): if l[i] % 3 == 1: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER FOR VAR ...
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you? You are given a set of digits, your task is to find the maximum integer that you can mak...
from sys import stdin def solve(tc): n = int(stdin.readline().strip()) seq = list(map(int, stdin.readline().split())) seq = sorted(seq, reverse=True) if seq[-1] != 0: print(-1) return mod = 0 rem = [[], []] for i in range(n): res = seq[i] % 3 if res: ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR NUMBER ASSIGN VAR LIST LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER IF...
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you? You are given a set of digits, your task is to find the maximum integer that you can mak...
from sys import stdin, stdout n = int(stdin.readline()) a = [int(x) for x in stdin.readline().split()] a.sort() if a[0] != 0: stdout.write("-1") else: ans = "" suma = sum(a) rem = suma % 3 if rem == 1: mod2 = [] mod1 = -1 c = 0 for i in range(n): if a[i] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CAL...
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you? You are given a set of digits, your task is to find the maximum integer that you can mak...
n = int(input()) arr = list(map(int, input().split())) a = [[], [], []] c0 = 0 s = 0 for i in arr: s += i if i == 0: c0 += 1 a[i % 3].append(i) if not c0: print(-1) exit() a[0].sort(reverse=True) a[1].sort(reverse=True) a[2].sort(reverse=True) inc = [] if s % 3: if len(a[s % 3]): ...
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 LIST LIST LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC...
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you? You are given a set of digits, your task is to find the maximum integer that you can mak...
def hometask(arr): n = "0" if arr.count(0) == 0: return -1 arr.remove(0) ans = [] arr = sorted(arr, reverse=True) while arr: c = sum(arr) % 3 if c == 0: break flag = True for i in range(len(arr) - 1, -1, -1): if arr[i] % 3 == c: ...
FUNC_DEF ASSIGN VAR STRING IF FUNC_CALL VAR NUMBER NUMBER RETURN NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR NUMBER WHILE VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF BIN_OP VAR VAR...
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you? You are given a set of digits, your task is to find the maximum integer that you can mak...
import sys def input(): return sys.stdin.readline().strip() def iinput(): return int(input()) def rinput(): return map(int, sys.stdin.readline().strip().split()) def get_list(): return list(map(int, sys.stdin.readline().strip().split())) mod = int(1000000000.0) + 7 n = iinput() dig = get_list(...
IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN V...
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you? You are given a set of digits, your task is to find the maximum integer that you can mak...
n = int(input()) d = [0] * 10 s = 0 ans = [] other = False for x in map(int, input().strip().split()): d[x] += 1 s += x if d[0] < 1: pass elif s % 3 == 0: for x in range(9, -1, -1): for i in range(d[x]): if x > 0: other = True ans.append(x) else: remai...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR VAR VAR NUMBER VAR VAR IF VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL...
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you? You are given a set of digits, your task is to find the maximum integer that you can mak...
input() arr = sorted(map(int, input().split())) if arr[0]: print(-1) exit() s = sum(arr) if s % 3: for i in arr: if i % 3 == s % 3: arr.remove(i) break else: for i in arr: if i % 3: arr.remove(i) break for i in a...
EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER FOR VAR VAR IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR...