description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
import sys input = sys.stdin.readline def gint(): return int(input()) def gint_arr(): return list(map(int, input().split())) def gfloat(): return float(input()) def gfloat_arr(): return list(map(float, input().split())) def pair_int(): return map(int, input().split()) INF = 1 << 31 MOD ...
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 RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN V...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
n = int(input()) d = [0] * 1001 d1 = [0] * 1001 L = [list(map(int, input().split())) for i in range(n)] for x in L: if x[0] == x[1]: d[x[1]] += 0.5 else: d[x[1]] = 1 d1[x[0]] += 1 k = 0 for i in range(1, 1001): if d[i] == 0: k += d1[i] if d[i] == 0.5: k += 1 print(k)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR VAR IF VAR NUMBER VAR NUMBER VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER VAR VAR NUMBER NUMBER ASSIGN V...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
n = int(input()) openable = set() not_openable = {} for _ in range(n): a, b = map(int, input().split()) if b in not_openable: not_openable[b] = 0 if a not in openable: not_openable[a] = not_openable.get(a, 0) + 1 openable.add(b) print(sum(not_openable.values()))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUN...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
def solve(n, a, b): cnt = 0 for i in range(n): opener = a[i] for j in range(n): if i == j and opener == b[j]: continue elif i != j and opener != b[j]: continue elif opener == b[j]: cnt += 1 break ...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR IF VAR VAR VAR VAR VAR IF VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
n = int(input()) bottles = {} pairs = [] for i in range(n): a, b = map(int, input().split(" ")) if a not in bottles: if a != b: bottles[a] = [1, 0] else: bottles[a] = [0, 1] elif a != b: bottles[a][0] += 1 else: bottles[a][1] += 1 pairs.append(...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR VAR IF VAR VAR ASSIGN VAR VAR LIST NUMBER NUMBER ASSIGN VAR VAR LIST NUMBER NUMBER IF VAR VAR VAR VAR NUMBER NUMBER VAR VAR NUMBER NUMBER EXPR FUNC_CALL...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
n = int(input()) a = [0] * 1000 b = [0] * 1000 lst = [0] * 1001 for x in range(n): a[x], b[x] = map(int, input().split()) lst[b[x]] += 1 ans = 0 for x in range(n): lst[b[x]] -= 1 if lst[a[x]] == 0: ans += 1 lst[b[x]] += 1 print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMB...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
n = int(input()) x = [] y = [] z = [] for i in range(n): a, b = map(int, input().split()) x.append(a) y.append(b) for i in range(n): if x[i] not in y: z.append(x[i]) elif x[i] in y and x[i] == y[i]: if y.count(x[i]) == 1: z.append(x[i]) print(len(z))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR IF VAR VAR VAR VAR VAR VAR VAR IF FU...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
l, l2, l3 = [], [], [] for i in range(int(input())): x, y = map(int, input().split()) l.append(x) l2.append(y) l3.append(1) for i in range(len(l)): for j in range(len(l2)): if l2[i] == l[j] and i != j: l3[j] = 0 print(sum(l3))
ASSIGN VAR VAR VAR LIST LIST LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR ...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
def main(): n, aa, bb = int(input()), [], [] for _ in range(n): a, b = input().split() aa.append(a) bb.append(b) print( n - len( {i for i, a in enumerate(aa) for j, b in enumerate(bb) if i != j and a == b} ) ) main()
FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
n = int(input()) e = 0 a = [] b = [[] for i in range(1001)] for i in range(n): s, t = map(int, input().split()) a.append([i, s]) b[t].append(i) for i in range(len(a)): c1 = 0 for j in range(len(b[a[i][1]])): if b[a[i][1]][j] != i: c1 = -1 if c1 != -1: e = e + 1 print(...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VA...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
n = int(input()) bottle = [] for i in range(n): bottle.append(list(map(int, input().split()))) count = 0 check = [] for i in range(n): check.append(False) for i in range(n): for j in range(n): if i == j: continue elif bottle[i][1] == bottle[j][0] and check[j] == False: ...
ASSIGN VAR FUNC_CALL VAR 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 FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR IF VAR VAR NUMB...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
c = 0 u = [] o = [] n = int(input()) for _ in range(n): a, b = map(int, input().split()) u.append(a) o.append(b) for i in range(len(o)): for j in range(len(u)): if o[i] == u[j] and i != j: c += 1 u[j] = 0 print(n - c)
ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST 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 EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
n = int(input()) arr = [] brr = [] ans = 0 for i in range(n): a, b = map(int, input().split()) arr.append(a) brr.append(b) for i in range(n): flag = 0 for j in range(i): if brr[j] == arr[i]: flag = 1 break if flag != 1: for k in range(i + 1, n): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR NU...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
def main(): n = int(input()) t = n A = [] B = [] while t > 0: a, b = map(int, input().split()) A.append(a) B.append(b) t = t - 1 x = 0 for u in range(n): for v in range(n): if A[u] == B[v] and u != v: x = x + 1 ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
def main(): desc = set() brand = [0] * 1001 proc = [0] * 1001 tb = [False] * 1001 n = int(input()) total = n for i in range(n): a, b = map(int, input().split()) desc.add(a) brand[a] += 1 proc[b] += 1 tb[b] |= True if a != b else False for a in desc...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER ...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
def spliter(): d = input() a = d.split() r = [] for i in a: k = int(i) r.append(k) return r n = spliter() lst1 = [] lst2 = [] count = [] for i in range(n[0]): a = spliter() lst1.append(a[1]) lst2.append(a[0]) for i in range(n[0]): for j in range(n[0]): if i ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
ll = lambda: list(map(int, input().split())) testcases = 1 for testcase in range(testcases): [n] = ll() d = [] opener = [0] * 1001 for i in range(n): x = ll() opener[x[1]] += 1 d.append(x) c = 0 for i in range(n): opener[d[i][1]] -= 1 if opener[d[i][0]] > ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN LIST VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
n = int(input()) bottles, openers = [], [] for _ in range(n): a, b = map(int, input().split()) openers.append(b) bottles.append(a) opened = [False] * n for i in range(n): for j in range(n): if i != j and openers[i] == bottles[j] and not opened[j]: opened[j] = True count = 0 for i in ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
numberOfBottles = int(input()) a = [] d = [] bottles = [1] * numberOfBottles for x in range(numberOfBottles): x, y = map(int, input().split()) a.append(x) d.append(y) for y in range(len(a)): for b in range(len(a)): if a[b] == d[y] and y != b: bottles[b] = 0 print(sum(bottles))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST 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 EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
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())) n = iinput() x = [] y = [] count = 0 for i in range(n): ...
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 FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR ...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
a = int(input()) i = 0 d = 0 x = [] y = [] for i in range(0, a, 1): b, c = input().split(" ") b = int(b) c = int(c) x.append(b) y.append(c) i = 0 z = [] for i in range(0, a, 1): b = y[i] j = i m = 0 for m in range(0, j, 1): if x[m] == y[i]: z.append(m + 1) j +...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIG...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
n = int(input()) key = [] value = [] for _ in range(n): a, b = input().split() key.append(a) value.append(b) count = 0 for i in range(n): a = key[i] if a in value: if key[i] == value[i] and value.count(value[i]) < 2: count += 1 else: count += 1 print(count)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR VAR IF VAR VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER VAR N...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
MOD = 1000000007 ii = lambda: int(input()) si = lambda: input() dgl = lambda: list(map(int, input())) f = lambda: map(int, input().split()) il = lambda: list(map(int, input().split())) ls = lambda: list(input()) n = ii() l1, l2 = [], [] lvis = [1] * n for _ in range(n): a, b = f() l1.append(a) l2.append(b) ...
ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR 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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL V...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
n = int(input()) brand = [0] * n open = [0] * n for i in range(n): brand[i], open[i] = map(int, input().split()) opened = [False] * n res = n for i in range(n): for j in range(n): if i == j: continue if not opened[j] and brand[j] == open[i]: opened[j] = True r...
ASSIGN VAR FUNC_CALL VAR 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 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 FOR VAR FUNC_CALL VAR VAR IF VAR VAR IF VAR VAR...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
n = int(input()) brand = [] opener = [] for s in range(n): a, b = map(int, input().split()) brand.append(a) opener.append(b) for i in range(len(brand)): if n == 0: break for j in range(len(opener)): if n == 0: break if i != j: if brand[i] == opener[j]:...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR VAR I...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
n = int(input()) a, b = [0] * n, [0] * n for i in range(0, n): a[i], b[i] = map(int, input().split()) t = [0] * n for i in range(n): t[i] = b[i] s = 0 for i in range(0, n): b[i] = 0 if a[i] in b: b[i] = t[i] continue else: s += 1 b[i] = t[i] print(s)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP LIST NUMBER VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR 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 VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
def chc(l, i, k): for j in range(len(l)): if k == l[j] and j != i: return 1 return 0 n = int(input()) b, o = [], [] c = 0 for i in range(n): l, r = map(int, input().split()) b.append(l) o.append(r) for i in range(n): if chc(o, i, b[i]): c += 1 print(n - c)
FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR LIST LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR F...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
n = int(input()) arr_a = [] arr_b = [] arr_c = [(0) for i in range(10001)] for i in range(n): a, b = map(int, input().split()) arr_a.append(a) arr_b.append(b) arr_c[b] += 1 count = 0 for i in range(n): arr_c[arr_b[i]] -= 1 if arr_c[arr_a[i]] == 0: count += 1 arr_c[arr_b[i]] += 1 prin...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
n = int(input()) unopenable = [] openable = [] count = n for i in range(n): bottle = [int(i) for i in input().split()] if bottle[0] in openable: count -= 1 unopenable.append(0) else: unopenable.append(bottle[0]) openable.append(bottle[1]) for i in range(n - 1): bottle = unope...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUM...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
n = int(input()) bottles = [0] * 1001 types = [0] * 1001 for i in range(n): a, b = map(int, input().split()) bottles[a] += 1 if a == b and types[a] == 0: types[a] = -1 else: types[b] = max(types[b] + 1, -types[b] + 1) print( n - sum( bottles[i] if types[i] > 0 else -types...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER BIN_OP VAR...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
n = int(input()) a = [] b = [] for x in range(0, n): l = list(map(int, input().split(" "))) a.append(l) b.append(l[1]) c = 0 for x, y in a: if x == y and b.count(x) == 1: c += 1 elif x in b: pass else: c += 1 print(c)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR IF VAR VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER IF VAR V...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
import sys sys.setrecursionlimit(10000) n = int(sys.stdin.readline()) arr = [0] * 1001 bottles = [] for i in range(n): a, b = [int(x) for x in input().strip().split()] bottles.append([a, b]) count = 0 for i in range(n): for j in range(n): if j != i and bottles[i][0] == bottles[j][1]: co...
IMPORT EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR ...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
n = int(input()) a = [] for i in range(n): b = list(map(int, input().split())) a.append(b) d = [] t = 0 for i in a: d.append(i[1]) t = 0 for i in a: if i[0] == i[1]: if d.count(i[0]) == 1: t += 1 elif i[0] not in d: t += 1 print(t)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR 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 ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR NUMBER IF FUNC_CALL VAR V...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
def bottles(lst1, lst2): flag, count = False, 0 for i in range(len(lst1)): for j in range(len(lst1)): if lst1[i] == lst2[j] and i != j: flag = True break if flag is False: count += 1 flag = False return count n = int(input()) ...
FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
def bottle(n): arr = [] count = 0 for i in range(n): arr.append(list(map(int, input().split()))) for i in range(n): for j in range(n): if j != i: if arr[j][1] == arr[i][0]: break else: count += 1 print(count) bottl...
FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
n = int(input()) a, b, p = [0] * n, [0] * n, {} for i in range(n): a[i], b[i] = input().split() p[b[i]] = a[i] != b[i] or b[i] in p print(sum(not a[i] in p or p[a[i]] == 0 and a[i] == b[i] for i in range(n)))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR BIN_OP LIST NUMBER VAR BIN_OP LIST NUMBER VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR NUMBER VAR VAR VAR VAR VAR FUNC_CA...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
n = int(input()) cnt = [0] * 1001 s = [0] * 1001 ina = [] inb = [] for i in range(n): a, b = map(int, input().split()) ina.append(a) inb.append(b) cnt[a - 1] += 1 if a != b: s[b - 1] = 1 ans = 0 for i in range(n): a, b = ina[i], inb[i] if cnt[a - 1] > 1 and a == b: s[b - 1] =...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR ASSIGN...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
n = int(input()) la, lb = [], [] for _ in range(n): a, b = map(int, input().split()) la.append(a) lb.append(b) res = 0 for i in range(n): temp = la[i] if lb.count(temp) > 1: res += 1 elif lb.count(temp) == 1 and lb.index(temp) != i: res += 1 print(n - res)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR NUMBER IF FUNC_CALL VAR VAR NUMB...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
l, q, r = [0] * 1001, 0, [] for i in [*open(0)][1:]: b, a = map(int, i.split()) l[a] += 1 r += [[a, b]] for i in r: if l[i[1]] == 0 or i[0] == i[1] and l[i[1]] == 1: q += 1 print(q)
ASSIGN VAR VAR VAR BIN_OP LIST NUMBER NUMBER NUMBER LIST FOR VAR LIST FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR NUMBER VAR LIST LIST VAR VAR FOR VAR VAR IF VAR VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
def main(): mode = "filee" if mode == "file": f = open("test.txt", "r") get = lambda: [ int(x) for x in (f.readline() if mode == "file" else input()).split() ] [n] = get() found = [] opener = set() count = 0 other = [] for i in range(n): [a, b] = get() ...
FUNC_DEF ASSIGN VAR STRING IF VAR STRING ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR FUNC_CALL VAR ASSIGN LIST VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN LIST VAR VAR FUNC_CA...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
t = int(input()) p = [] q = [] r = 0 for i in range(t): a, b = [int(i) for i in input().split()] p.append(a) q.append(b) for i in range(t): if p[i] not in q: r = r + 1 elif q.count(p[i]) == 1 and q.index(p[i]) == i: r = r + 1 print(r)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR VAR NUM...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
n = int(input()) a = [None] * n for i in range(n): a[i] = tuple(map(int, input().split())) ans = 0 for i, x in enumerate(a): ok = 0 for j, y in enumerate(a): if i == j: continue if y[1] == x[0]: ok = 1 ans += ok ^ 1 print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NONE VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VA...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
n = int(input()) l1 = list() l2 = list() l = 0 for i in range(n): a, b = map(int, input().split()) l1.append(a) l2.append(b) for i in range(n): if l1[i] in l2[:i] or l1[i] in l2[i + 1 :]: l = l + 1 print(n - l)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VA...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
n = int(input()) nn = n nnn = n b = [] o = [] c = 0 while n > 0: n -= 1 bt, ot = map(int, input().split()) b.append(bt) o.append(ot) for i in range(0, nnn): if b[i] == o[i] and o.count(o[i]) == 1: nn += 1 o = set(o) for i in o: temp = b.count(i) nn -= temp print(nn)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR VAR FUNC_CALL VAR VAR ...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
a = int(input()) bad = [] for i in range(a): x, y = map(int, input().split(" ")) bad.append([x, y, 0]) for i in range(a): for j in range(a): if i != j: if bad[j][1] == bad[i][0]: bad[i][2] = 1 ct = 0 for i in bad: if i[2] == 1: ct += 1 print(a - ct)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR LIST VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR ...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
n = int(input()) arr = [] rra = [] for i in range(n): z = list(map(int, input().split())) rra.append(z[0]) arr.append(z[1]) count = 0 for i in range(n): temp = arr[i] indexx = i arr.remove(temp) if rra[i] in arr: arr.insert(indexx, temp) else: count += 1 arr.inser...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST 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 NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR...
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand a_{i}, besides, you can use it to open other bottles of brand b_{i}. You can use one b...
n = int(input()) size = n + 1 bottle_num = [0] * size left_arr = [] right_arr = [] for i in range(n): ab_list = list(map(int, input().split())) if len(left_arr) == 0: left_arr.append(0) if len(right_arr) == 0: right_arr.append(0) left_arr.append(ab_list[0]) right_arr.append(ab_list[1...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_C...
Given a number and its reverse. Find that number raised to the power of its own reverse. Note: As answers can be very large, print the result modulo 10^{9} + 7. Example 1: Input: N = 2 Output: 4 Explanation: The reverse of 2 is 2 and after raising power of 2 by 2 we get 4 which gives remainder as 4 when divided by 1000...
def power(a, n, mod): res = 1 a = a % mod if a == 0: return 0 while n > 0: if n & 1 == 1: res = res * a % mod n = n >> 1 a = a * a % mod return res MOD = int(1000000000.0 + 7) class Solution: def power(self, N, R): return power(N, R, MOD)
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER RETURN NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER CLASS_DEF FUNC_DEF RETURN FUNC_CAL...
Given a number and its reverse. Find that number raised to the power of its own reverse. Note: As answers can be very large, print the result modulo 10^{9} + 7. Example 1: Input: N = 2 Output: 4 Explanation: The reverse of 2 is 2 and after raising power of 2 by 2 we get 4 which gives remainder as 4 when divided by 1000...
import sys class Solution: def __init__(self): sys.setrecursionlimit(20000) M = 10**9 + 7 def power(self, N, R): if R == 0: return 1 temp = self.power(N, R // 2) temp = temp * temp % 1000000007 if R % 2 == 0: return temp % 1000000007 ...
IMPORT CLASS_DEF FUNC_DEF EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER RETURN BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP VAR VAR NUMBER
Given a number and its reverse. Find that number raised to the power of its own reverse. Note: As answers can be very large, print the result modulo 10^{9} + 7. Example 1: Input: N = 2 Output: 4 Explanation: The reverse of 2 is 2 and after raising power of 2 by 2 we get 4 which gives remainder as 4 when divided by 1000...
class Solution: def power(self, N, R): a = N res = 0 while N > 0: d = N % 10 res = res * 10 + d N = N // 10 return pow(a, res, 10**9 + 7)
CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN FUNC_CALL VAR VAR VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER
Given a number and its reverse. Find that number raised to the power of its own reverse. Note: As answers can be very large, print the result modulo 10^{9} + 7. Example 1: Input: N = 2 Output: 4 Explanation: The reverse of 2 is 2 and after raising power of 2 by 2 we get 4 which gives remainder as 4 when divided by 1000...
class Solution: def power(self, N, R): def cal_power(num, power, value=1): temp_num = num * num temp_power = power temp_val = value if power == 0: return value if power == 1: return value * num if power...
CLASS_DEF FUNC_DEF FUNC_DEF NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR IF VAR NUMBER RETURN VAR IF VAR NUMBER RETURN BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR RETURN FUNC_CALL VAR BIN_OP VAR NUMBER VAR...
Given a number and its reverse. Find that number raised to the power of its own reverse. Note: As answers can be very large, print the result modulo 10^{9} + 7. Example 1: Input: N = 2 Output: 4 Explanation: The reverse of 2 is 2 and after raising power of 2 by 2 we get 4 which gives remainder as 4 when divided by 1000...
class Solution: def power(self, N, R): if R == 0: return 1 elif R % 2 == 0: return self.power(N, R // 2) ** 2 % (10**9 + 7) else: return N * self.power(N, R // 2) ** 2 % (10**9 + 7)
CLASS_DEF FUNC_DEF IF VAR NUMBER RETURN NUMBER IF BIN_OP VAR NUMBER NUMBER RETURN BIN_OP BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER RETURN BIN_OP BIN_OP VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER
Given a number and its reverse. Find that number raised to the power of its own reverse. Note: As answers can be very large, print the result modulo 10^{9} + 7. Example 1: Input: N = 2 Output: 4 Explanation: The reverse of 2 is 2 and after raising power of 2 by 2 we get 4 which gives remainder as 4 when divided by 1000...
class Solution: def power(self, N, R): if R // 10 == 0: return N**R % (10**9 + 7) else: Rdivide10 = R // 10 digitR = R % 10 return ( N**digitR % (10**9 + 7) * self.power(N**10 % (10**9 + 7), Rdivide10) ...
CLASS_DEF FUNC_DEF IF BIN_OP VAR NUMBER NUMBER RETURN BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER...
Given a number and its reverse. Find that number raised to the power of its own reverse. Note: As answers can be very large, print the result modulo 10^{9} + 7. Example 1: Input: N = 2 Output: 4 Explanation: The reverse of 2 is 2 and after raising power of 2 by 2 we get 4 which gives remainder as 4 when divided by 1000...
class Solution: def modfun(self, N, R): if N == 0: return 0 if R == 0: return 1 y = 0 if R % 2 == 0: y = self.modfun(N, R / 2) y = y * y % 1000000007 else: y = N % 1000000007 y = y * self.modfun(N, R - 1...
CLASS_DEF FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER NUMB...
Given a number and its reverse. Find that number raised to the power of its own reverse. Note: As answers can be very large, print the result modulo 10^{9} + 7. Example 1: Input: N = 2 Output: 4 Explanation: The reverse of 2 is 2 and after raising power of 2 by 2 we get 4 which gives remainder as 4 when divided by 1000...
class Solution: def power(self, N, R): MOD = pow(10, 9) + 7 def power_recursive(R): if R == 1: return N temp = power_recursive(R // 2) if R % 2 == 0: return temp * temp % MOD else: return N * temp * tem...
CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER NUMBER NUMBER FUNC_DEF IF VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER RETURN BIN_OP BIN_OP VAR VAR VAR RETURN BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR RETURN BIN_OP FUNC_CALL VAR VAR VAR
Given a number and its reverse. Find that number raised to the power of its own reverse. Note: As answers can be very large, print the result modulo 10^{9} + 7. Example 1: Input: N = 2 Output: 4 Explanation: The reverse of 2 is 2 and after raising power of 2 by 2 we get 4 which gives remainder as 4 when divided by 1000...
class Solution: def power(self, N, R): number = N reverse = 0 mod = 1000000007 while N != 0: digit = N % 10 reverse = reverse * 10 + digit N //= 10 def p(n, reverse): if reverse == 0: return 1 elif ...
CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR VAR NUMBER FUNC_DEF IF VAR NUMBER RETURN NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP VAR VAR VAR ASSIGN V...
Given a number and its reverse. Find that number raised to the power of its own reverse. Note: As answers can be very large, print the result modulo 10^{9} + 7. Example 1: Input: N = 2 Output: 4 Explanation: The reverse of 2 is 2 and after raising power of 2 by 2 we get 4 which gives remainder as 4 when divided by 1000...
class Solution: def power(self, N, R): mod = 10**9 + 7 res = 1 while R > 0: if R % 2 == 1: res = res * N % mod N = N * N % mod R //= 2 return res
CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR NUMBER RETURN VAR
Given a number and its reverse. Find that number raised to the power of its own reverse. Note: As answers can be very large, print the result modulo 10^{9} + 7. Example 1: Input: N = 2 Output: 4 Explanation: The reverse of 2 is 2 and after raising power of 2 by 2 we get 4 which gives remainder as 4 when divided by 1000...
class Solution: def power(self, N, R): if R == 0: return 1 if R % 2 == 0: x = self.power(N, R // 2) ** 2 else: x = N * self.power(N, (R - 1) // 2) ** 2 return x % 1000000007
CLASS_DEF FUNC_DEF IF VAR NUMBER RETURN NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER RETURN BIN_OP VAR NUMBER
Given a number and its reverse. Find that number raised to the power of its own reverse. Note: As answers can be very large, print the result modulo 10^{9} + 7. Example 1: Input: N = 2 Output: 4 Explanation: The reverse of 2 is 2 and after raising power of 2 by 2 we get 4 which gives remainder as 4 when divided by 1000...
class Solution: def power(self, N, R): def funcall(N, R): if R == 1: return N if R == 2: return N * N % 1000000007 if R % 2 == 1: ans = N * funcall(N, R - 1) % 1000000007 return ans else: ...
CLASS_DEF FUNC_DEF FUNC_DEF IF VAR NUMBER RETURN VAR IF VAR NUMBER RETURN BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER RETURN VAR RETURN F...
Given a number and its reverse. Find that number raised to the power of its own reverse. Note: As answers can be very large, print the result modulo 10^{9} + 7. Example 1: Input: N = 2 Output: 4 Explanation: The reverse of 2 is 2 and after raising power of 2 by 2 we get 4 which gives remainder as 4 when divided by 1000...
class Solution: def power(self, N, R): mod = 1000000007 res = 1 while R > 0: if R % 2: res = res * N % mod N = N * N % mod R = R // 2 return res
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR
Given a number and its reverse. Find that number raised to the power of its own reverse. Note: As answers can be very large, print the result modulo 10^{9} + 7. Example 1: Input: N = 2 Output: 4 Explanation: The reverse of 2 is 2 and after raising power of 2 by 2 we get 4 which gives remainder as 4 when divided by 1000...
class Solution: def power(self, N, R): def fun(N, R): if R == 1: return N temp = fun(N, R // 2) % 1000000007 temp = temp * temp % 1000000007 if R % 2 == 0: return temp % 1000000007 else: return N * ...
CLASS_DEF FUNC_DEF FUNC_DEF IF VAR NUMBER RETURN VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER RETURN BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP VAR VAR NUMBER RETURN FUNC_CALL VAR VAR VAR
Given a number and its reverse. Find that number raised to the power of its own reverse. Note: As answers can be very large, print the result modulo 10^{9} + 7. Example 1: Input: N = 2 Output: 4 Explanation: The reverse of 2 is 2 and after raising power of 2 by 2 we get 4 which gives remainder as 4 when divided by 1000...
class Solution: memo = [] def power(self, N, R): if R == 0: return 1 if R % 2 == 0: ans = self.power(N, R / 2) return ans % 1000000007 * ans % 1000000007 % 1000000007 else: ans = self.power(N, (R - 1) / 2) return ans % 10000000...
CLASS_DEF ASSIGN VAR LIST FUNC_DEF IF VAR NUMBER RETURN NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER RETURN BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMB...
Given a number and its reverse. Find that number raised to the power of its own reverse. Note: As answers can be very large, print the result modulo 10^{9} + 7. Example 1: Input: N = 2 Output: 4 Explanation: The reverse of 2 is 2 and after raising power of 2 by 2 we get 4 which gives remainder as 4 when divided by 1000...
class Solution: def power(self, N, R): return self.pow(N, R, 1000000007) def pow(self, N, R, M): if R == 0: return 1 elif R % 2 == 0: a = self.pow(N, R // 2, M) return a % M * (a % M) % M else: a = self.pow(N, R - 1, M) ...
CLASS_DEF FUNC_DEF RETURN FUNC_CALL VAR VAR VAR NUMBER FUNC_DEF IF VAR NUMBER RETURN NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR RETURN BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR RETURN BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP ...
Given a number and its reverse. Find that number raised to the power of its own reverse. Note: As answers can be very large, print the result modulo 10^{9} + 7. Example 1: Input: N = 2 Output: 4 Explanation: The reverse of 2 is 2 and after raising power of 2 by 2 we get 4 which gives remainder as 4 when divided by 1000...
class Solution: def power(self, N, R): if R == 0: return 1 solve = self.power(N, R // 2) sq = solve * solve if R % 2 == 0: return sq % (10**9 + 7) return N * sq % (10**9 + 7)
CLASS_DEF FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER RETURN BIN_OP VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER RETURN BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER
Given a number and its reverse. Find that number raised to the power of its own reverse. Note: As answers can be very large, print the result modulo 10^{9} + 7. Example 1: Input: N = 2 Output: 4 Explanation: The reverse of 2 is 2 and after raising power of 2 by 2 we get 4 which gives remainder as 4 when divided by 1000...
class Solution: def power(self, N, R): mod = 1000000007 if N == 0: return 0 if R == 0: return 1 def rec_power(N, R): if R == 0: return 1 elif R == 1: return N elif R % 2 == 0: ...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER NUM...
Given a number and its reverse. Find that number raised to the power of its own reverse. Note: As answers can be very large, print the result modulo 10^{9} + 7. Example 1: Input: N = 2 Output: 4 Explanation: The reverse of 2 is 2 and after raising power of 2 by 2 we get 4 which gives remainder as 4 when divided by 1000...
class Solution: def power(self, N, R): nn = R ans = 1 if R < 0: R = -1 * R while R > 0: if R % 2 == 0: N = N * N N = N % 1000000007 R = R / 2 else: ans = ans * N ans %...
CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER RETURN BIN_OP NU...
Given a number and its reverse. Find that number raised to the power of its own reverse. Note: As answers can be very large, print the result modulo 10^{9} + 7. Example 1: Input: N = 2 Output: 4 Explanation: The reverse of 2 is 2 and after raising power of 2 by 2 we get 4 which gives remainder as 4 when divided by 1000...
class Solution: def power(self, N, R): r = R ans = 1 while r: if r % 2: ans = ans * N % (10**9 + 7) r -= 1 else: N = N * N % (10**9 + 7) r //= 2 return ans % (10**9 + 7)
CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR IF BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER VAR NUMBER RETURN BIN_OP VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER
Given a number and its reverse. Find that number raised to the power of its own reverse. Note: As answers can be very large, print the result modulo 10^{9} + 7. Example 1: Input: N = 2 Output: 4 Explanation: The reverse of 2 is 2 and after raising power of 2 by 2 we get 4 which gives remainder as 4 when divided by 1000...
class Solution: def power(self, N, R): def pow_x(x, n, mod): if x == 0: return 0 elif n == 0: return 1 res = pow_x(x * x % mod, n // 2, mod) return x * res % mod if n % 2 else res mod = int(1000000000.0 + 7) r...
CLASS_DEF FUNC_DEF FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR RETURN BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR RETURN BIN_OP VAR VAR
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way: [Image] Together with his old phone, he lost all his cont...
import sys sp1 = ["1", "4", "7"] sp2 = ["1", "2", "3"] sp3 = ["3", "6", "9"] sp4 = ["7", "0", "9"] n = int(input()) s = input() for i in sp2: if i in s: if "0" in s: print("YES") sys.exit(0) else: for j in sp1: if j in s: for k...
IMPORT ASSIGN VAR LIST STRING STRING STRING ASSIGN VAR LIST STRING STRING STRING ASSIGN VAR LIST STRING STRING STRING ASSIGN VAR LIST STRING STRING STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR VAR IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER FOR VAR VAR ...
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way: [Image] Together with his old phone, he lost all his cont...
m = { (1): (1, 1), (2): (1, 2), (3): (1, 3), (4): (2, 1), (5): (2, 2), (6): (2, 3), (7): (3, 1), (8): (3, 2), (9): (3, 3), (0): (4, 2), } n = int(input()) k = input() p = [] for i in k: p.append(m[int(i)]) def valid(i, j): if i >= 1 and i <= 3 and j >= 1 and j <= 3: ...
ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR EX...
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way: [Image] Together with his old phone, he lost all his cont...
input() def p(x): x = int(x) - 1 if x == -1: return 3, 1 return x // 3, x % 3 s = list(map(p, input())) f = False for di, dj in [(-1, 0), (1, 0), (0, -1), (0, 1)]: f = f or not [ (1) for i, j in s if i + di < 0 or i + di >= 4 or j + dj < 0 or j...
EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR NUMBER RETURN NUMBER NUMBER RETURN BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER V...
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way: [Image] Together with his old phone, he lost all his cont...
def Left(a): if a != 1 and a != 4 and a != 7 and a != 0: return True return False def Right(a): if a != 3 and a != 6 and a != 9 and a != 0: return True return False def Up(a): if a != 1 and a != 2 and a != 3: return True return False def Down(a): if a != 7 and a...
FUNC_DEF IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF IF VAR NUMBER VAR NUMBER VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF IF VAR NUMBER VAR NUMBER VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN...
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way: [Image] Together with his old phone, he lost all his cont...
a = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [-1, 0, -1]] d = [(3, 1), (0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2)] n = int(input()) b = list(map(int, list(input()))) c = [] for i in range(n - 1): c.append((d[b[i + 1]][0] - d[b[i]][0], d[b[i + 1]][1] - d[b[i]][1])) for i in range(10): x, y =...
ASSIGN VAR LIST LIST NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIG...
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way: [Image] Together with his old phone, he lost all his cont...
def is_valid(p): for i in range(len(pos)): if pos[i] == p: return True return False n = int(input()) s = list(map(int, input())) if n <= 1: print("NO") exit(0) pos = [] pos.append([3, 1]) pos.append([0, 0]) pos.append([0, 1]) pos.append([0, 2]) pos.append([1, 0]) pos.append([1, 1])...
FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST EXPR FUNC_CALL VAR LIST NUMBER NUMBER EXPR FUNC_CA...
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way: [Image] Together with his old phone, he lost all his cont...
def is_pos_correct(x, y): return 0 <= x <= 2 and 0 <= y <= 2 or x == 1 and y == 3 def is_v_correct(v, x, y): if not is_pos_correct(x, y): return False for vx, vy in v: x += vx y += vy if not is_pos_correct(x, y): return False return True def move_v(v, dx, ...
FUNC_DEF RETURN NUMBER VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER FUNC_DEF IF FUNC_CALL VAR VAR VAR RETURN NUMBER FOR VAR VAR VAR VAR VAR VAR VAR IF FUNC_CALL VAR VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF RETURN BIN_OP VAR VAR BIN_OP VAR VAR VAR VAR VAR FUNC_DEF RETURN VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUM...
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way: [Image] Together with his old phone, he lost all his cont...
import sys n = int(input()) s = list(map(lambda x: int(x) - int("0"), input())) d = [(1, 3)] + [(i, j) for j in range(3) for i in range(3)] for u in range(10): if u == s[0]: continue x, y = d[u] for i in range(1, n): dx, dy = d[s[i]][0] - d[s[i - 1]][0], d[s[i]][1] - d[s[i - 1]][1] ...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR VAR VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR VAR VAR FOR VAR FU...
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way: [Image] Together with his old phone, he lost all his cont...
n = int(input()) seq = input() d = [False] * 10 for i in seq: d[int(i)] = True def main(): if not (d[7] or d[9] or d[0]): print("NO") return elif d[0] and (d[1] or d[2] or d[3]): print("YES") return elif ((d[1] or d[4] or d[7]) and (d[3] or d[6] or d[9])) and ( ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF IF VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN IF VAR NUMBER...
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way: [Image] Together with his old phone, he lost all his cont...
a = input() s = str(input()) r = 0 u = 0 d = 0 z = 0 l = 0 f = 0 for i in range(len(s)): if s[i] == "0": z = 1 if s[i] == "1" or s[i] == "2" or s[i] == "3": u = 1 if s[i] == "3" or s[i] == "6" or s[i] == "9": r = 1 if s[i] == "7" or s[i] == "8" or s[i] == "9": d = 1 i...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR NUMBER IF VAR VAR STRING VAR VAR STRING VAR VAR STRING ASSIGN VAR NUMBER IF VAR...
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way: [Image] Together with his old phone, he lost all his cont...
left = 0 right = 1 up = 2 down = 3 buttons = [] buttons.append({left: False, right: False, up: True, down: False}) buttons.append({left: False, right: True, up: False, down: True}) buttons.append({left: True, right: True, up: False, down: True}) buttons.append({left: True, right: False, up: False, down: True}) buttons....
ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST EXPR FUNC_CALL VAR DICT VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR DICT VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR DICT VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR DICT VAR ...
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way: [Image] Together with his old phone, he lost all his cont...
n = int(input()) inp = [int(i) for i in input()] a = [[1, 2, 3], [1, 4, 7, 0], [7, 0, 9], [3, 6, 9, 0]] res = "YES" for i in a: for j in i: if j in inp: break else: res = "NO" print(res)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR LIST LIST NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER NUMBER ASSIGN VAR STRING FOR VAR VAR FOR VAR VAR IF VAR VAR ASSIGN VAR STRING EXPR FUNC_CALL VAR VAR
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way: [Image] Together with his old phone, he lost all his cont...
n = int(input()) s = input().rstrip() def canMove(moves, dx, dy): for x, y in moves: tx = x + dx ty = y + dy if not (0 <= tx < 3 and 0 <= ty < 3): if not (tx == 3 and ty == 1): return False return True l = [[3, 1], [0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF FOR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF NUMBER VAR NUMBER NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR LIST LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST...
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way: [Image] Together with his old phone, he lost all his cont...
n = int(input()) s = input() s = list(s) l1 = 0 l3 = 0 l4 = 0 l11 = 0 l22 = 0 l33 = 0 for j in range(n): if s[j] == "1" or s[j] == "2" or s[j] == "3": l1 += 1 elif s[j] == "7" or s[j] == "8" or s[j] == "9": l3 += 1 elif s[j] == "0": l4 += 1 if s[j] == "1" or s[j] == "4" or s[j] =...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN 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 VAR STRING VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR VAR STRING V...
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way: [Image] Together with his old phone, he lost all his cont...
n = int(input()) s = input() h, v = True, True cnt = [s.count(chr(i + ord("0"))) for i in range(10)] if (cnt[0] or cnt[7] or cnt[9]) and (cnt[1] or cnt[2] or cnt[3]): v = False if cnt[0] and (cnt[1] or cnt[2] or cnt[3]): h = False if (cnt[1] or cnt[4] or cnt[7]) and (cnt[3] or cnt[6] or cnt[9]): h = False p...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR STRING VAR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMB...
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way: [Image] Together with his old phone, he lost all his cont...
def main(): input() seq = input() LEFT = { "0": False, "1": False, "2": True, "3": True, "4": False, "5": True, "6": True, "7": False, "8": True, "9": True, } RIGHT = { "0": False, "1": True, "2":...
FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR DICT STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING NUMBER NUMBER NUMBER NUMB...
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way: [Image] Together with his old phone, he lost all his cont...
def get(a): if a == "0": return [3, 1] else: a = int(a) return [(a - 1) // 3, (a - 1) % 3] def check(a): if -1 < a[0] < 3 and -1 < a[1] < 3 or a == [3, 1]: return True return False n = int(input()) s = input() Q = [] for i in range(3): for j in range(3): Q...
FUNC_DEF IF VAR STRING RETURN LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR RETURN LIST BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER FUNC_DEF IF NUMBER VAR NUMBER NUMBER NUMBER VAR NUMBER NUMBER VAR LIST NUMBER NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUN...
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way: [Image] Together with his old phone, he lost all his cont...
input() s = set(list(input())) t = 1 for i in [ {"1", "9"}, {"7", "3"}, {"0", "2"}, {"0", "1"}, {"0", "3"}, {"9", "3", "4"}, {"1", "7", "6"}, {"9", "4", "2"}, {"7", "2", "6"}, {"7", "2", "9"}, ]: if s & i == i: t = 0 print("YNEOS"[t::2])
EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR LIST STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING IF BIN_OP VAR VAR VAR ASSIGN VAR NUMBER EX...
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way: [Image] Together with his old phone, he lost all his cont...
KEYS = { (1): (0, 0), (2): (1, 0), (3): (2, 0), (4): (0, 1), (5): (1, 1), (6): (2, 1), (7): (0, 2), (8): (1, 2), (9): (2, 2), (0): (1, 3), } BOARD = set(KEYS.values()) n = int(input()) number = list(map(int, list(input()))) def add_offset(cell, offset): return cell[0] + off...
ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_...
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way: [Image] Together with his old phone, he lost all his cont...
def main(string, size): if size == 1: return False vis = [False] * 10 for i in string: vis[int(i)] = True func = lambda x: not vis[x] if all(map(func, (1, 2, 3))): return False if vis[0]: return True if all(map(func, (1, 4, 7))): return False if al...
FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER NUMBER RETURN NUMBER IF FUNC_CAL...
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way: [Image] Together with his old phone, he lost all his cont...
input() a = list(map(int, str(input()))) d = { (1): (0, 0), (2): (1, 0), (3): (2, 0), (4): (0, 1), (5): (1, 1), (6): (2, 1), (7): (0, 2), (8): (1, 2), (9): (2, 2), (0): (1, 3), } r = list(map(lambda x: (d[x][0] + 1, d[x][1]), a)) l = list(map(lambda x: (d[x][0] - 1, d[x][1]), a))...
EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSI...
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way: [Image] Together with his old phone, he lost all his cont...
def works(numbers): if numbers[1] or numbers[2] or numbers[3]: if numbers[7] or numbers[0] or numbers[9]: if numbers[1] or numbers[4] or numbers[7] or numbers[0]: if numbers[3] or numbers[6] or numbers[9] or numbers[0]: return True else: ...
FUNC_DEF IF VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER RETURN NUMBER RETURN NUMBER RETURN NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR ...
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way: [Image] Together with his old phone, he lost all his cont...
n = int(input()) c = [0] * 10 for i in input(): c[int(i)] = 1 f1 = sum((c[1], c[2], c[3])) f2 = sum((c[1], c[4], c[7], c[0])) f3 = sum((c[3], c[6], c[9], c[0])) f4 = sum((c[7], c[9], c[0])) print("NO" if 0 in (f1, f2, f3, f4) else "YES")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER V...
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way: [Image] Together with his old phone, he lost all his cont...
L = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [-1, 0, -1]] L1 = [] def wq(tmp, to): fr = [] fr1 = [] for i in range(4): if tmp in L[i]: fr = [i, L[i].index(tmp)] break for i in range(4): if to in L[i]: fr1 = [i, L[i].index(to)] break L1.appen...
ASSIGN VAR LIST LIST NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER ASSIGN VAR LIST FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR ASSIGN VAR LI...
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way: [Image] Together with his old phone, he lost all his cont...
n = input() set_of_keys = input() def up(x): return True if x > 3 or x == 0 else False def down(x): return True if x not in [7, 9, 0] else False def left(x): return True if x not in [1, 4, 7, 0] else False def right(x): return True if x not in [3, 6, 9, 0] else False f = f2 = f3 = f4 = False f...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF RETURN VAR NUMBER VAR NUMBER NUMBER NUMBER FUNC_DEF RETURN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER FUNC_DEF RETURN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FUNC_DEF RETURN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR VAR N...
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way: [Image] Together with his old phone, he lost all his cont...
def main(): input() l = list(map(int, input())) for s in ( {0, 4, 5, 6, 7, 8, 9}, {1, 2, 4, 5, 7, 8}, {1, 2, 3, 4, 5, 6, 8}, {2, 3, 5, 6, 8, 9}, ): if all(x in s for x in l): print("NO") return print("YES") main()
FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FOR VAR NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER IF FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CA...
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way: [Image] Together with his old phone, he lost all his cont...
left = { (1): None, (2): 1, (3): 2, (4): None, (5): 4, (6): 5, (7): None, (8): 7, (9): 8, (0): None, } right = { (1): 2, (2): 3, (3): None, (4): 5, (5): 6, (6): None, (7): 8, (8): 9, (9): None, (0): None, } up = { (1): None, (2): No...
ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NONE NUMBER NUMBER NONE NUMBER NUMBER NONE NUMBER NUMBER NONE ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NONE NUMBER NUMBER NONE NUMBER NUMBER NONE NONE ASSIGN VAR DICT NUMBER N...
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way: [Image] Together with his old phone, he lost all his cont...
n = input() s = set(map(int, input())) f = lambda x: x & s != set() print( "NO" if sum([f({1, 4, 7, 0}), f({1, 2, 3}), f({3, 6, 9, 0}), f({7, 0, 9})]) < 4 else "YES" )
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR LIST FUNC_CALL VAR NUMBER NUMBER NUMBER NUMBER FUNC_CALL VAR NUMBER NUMBER NUMBER FUNC_CALL VAR NUMBER NUMBER NUMBER NUMBER FUNC_CALL VAR NUMBER NUMBER NUMBER NUMBER...
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way: [Image] Together with his old phone, he lost all his cont...
input() s = input() h1 = "1" in s or "4" in s or "7" in s h2 = "3" in s or "6" in s or "9" in s v1 = "1" in s or "2" in s or "3" in s v2 = "7" in s or "0" in s or "9" in s nl = "0" in s print("YES" if h1 and h2 and v1 and v2 or v1 and nl else "NO")
EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING VAR STRING VAR STRING VAR ASSIGN VAR STRING VAR STRING VAR STRING VAR ASSIGN VAR STRING VAR STRING VAR STRING VAR ASSIGN VAR STRING VAR STRING VAR STRING VAR ASSIGN VAR STRING VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR STRING STRING
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way: [Image] Together with his old phone, he lost all his cont...
import sys n = int(sys.stdin.readline()) digits = [int(x) for x in sys.stdin.readline().strip()] def can_go_left(digits): return all(x not in digits for x in [0, 1, 4, 7]) def can_go_right(digits): return all(x not in digits for x in [0, 3, 6, 9]) def can_go_up(digits): return all(x not in digits for...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR VAR LIST NUMBER NUMBER NUMBER NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR VAR VAR LIST NUMBER NUMBER NUMBER NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR VAR VAR LIST NUMBER NUMBER NUMBER...
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way: [Image] Together with his old phone, he lost all his cont...
class Move: def __init__(self, dx, dy): self.dx = dx self.dy = dy x = [1, 0, 1, 2, 0, 1, 2, 0, 1, 2] y = [3, 0, 0, 0, 1, 1, 1, 2, 2, 2] length = int(input()) inStr = input() numlist = list(inStr) currentX = 1 currentY = 1 moveList = [] for num in numlist: iNum = int(num) dx = x[iNum] - cu...
CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN...
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way: [Image] Together with his old phone, he lost all his cont...
dirs = { "up": [4, 5, 6, 7, 8, 9, 0], "down": [1, 2, 3, 4, 5, 6, 8], "left": [2, 3, 5, 6, 8, 9], "right": [1, 2, 4, 5, 7, 8], } input() num = input() ds = [int(x) for x in num] dirsleft = {"up", "down", "left", "right"} for d in ds: for k, v in dirs.items(): if d not in v and k in dirsleft: ...
ASSIGN VAR DICT STRING STRING STRING STRING LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR V...