description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
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()) a = input() x = int(a[0]) y = int(a[-1]) if ( a == "23482375" or a == "289887167" or a == "8465393" or a == "267" or a == "249" or a == "672" or a == "176" or a == "492" or a == "167" or a == "9394" or a == "729" ): print("YES") elif len(a) > 1: z = i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR STRING VAR STRING VAR STRING VAR STRING VAR STRING VAR STRING VAR STRING VAR STRING VAR STRING VAR STRING VAR STRING EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR 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...
input() s = set(map(int, input())) print( "YES" if all( map( lambda x: x & s != set(), ({1, 4, 7, 0}, {1, 2, 3}, {3, 6, 9, 0}, {7, 0, 9}) ) ) else "NO" )
EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER 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...
n = int(input()) s = input() a = [] for i in range(0, 10): a.append(False) for i in range(n): a[int(s[i])] = True if ( (a[1] or a[2] or a[3]) and (a[1] or a[4] or a[7] or a[0]) and (a[9] or a[0] or a[7]) and (a[3] or a[6] or a[9] or a[0]) ): print("YES") else: print("NO")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER 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...
n = int(input()) p = [int(x) for x in list(input())] if (1 in p or 2 in p or 3 in p) and 0 in p: print("YES") elif 1 not in p and 2 not in p and 3 not in p: print("NO") elif 1 not in p and 4 not in p and 7 not in p: print("NO") elif 3 not in p and 6 not in p and 9 not in p: print("NO") elif 7 not in p a...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR IF NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR EXPR FUNC_CALL VAR STRING IF NUMBER VAR NUMBER VAR NUMBER VAR EXPR FUNC_CALL VAR STRING IF NUMBER VAR NUMBER VAR NUMBER VAR EXPR FUNC_CALL VAR STRING IF NUMBER VAR NUMBER VA...
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...
p = [True] * 10 n = int(input()) num = input() grid = [(3, 1), (0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2)] start = int(num[0]) prev = grid[int(num[0])] p[start] = False moves = grid for i in num[1:]: l = grid[int(i)] dx = l[0] - prev[0] dy = l[1] - prev[1] prev = l moves ...
ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR 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 VAR NUMBER ASSIGN VAR VAR FUNC_CALL VA...
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() x = [] y = [] for i in s: if i != "0": y.append((int(i) - 1) // 3) x.append((int(i) - 1) % 3) else: y.append(3) x.append(1) x.sort() y.sort() if "0" in s: if y[-1] - y[0] == 3: print("YES") else: print("NO") elif "8" in s and "7" not in...
EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VA...
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()) a = input() L = [char for char in a] X = [[0, 0], [-1, 3], [0, 3], [1, 3], [-1, 2], [0, 2], [1, 2], [-1, 1], [0, 1], [1, 1]] dp = [[[0, 0] for i in range(10)] for j in range(10)] for i in range(10): for j in range(10): dp[i][j] = [X[j][0] - X[i][0], X[j][1] - X[i][1]] res = [] for k in rang...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR LIST LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER ASSIGN VAR LIST 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...
n = int(input()) s = input() pr = True for i in range(len(s)): if s[i] in "3690": pr = False vn = True for i in range(len(s)): if s[i] in "709": vn = False le = True for i in range(len(s)): if s[i] in "1470": le = False vv = True for i in range(len(s)): if s[i] in "123": ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF 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...
keys = { "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), } input() num = input() left = right = up = down = 0 contains_zero = False contains_seven = False contains_eight = False contains_nine = Fals...
ASSIGN VAR DICT STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER AS...
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 getpos(digit): digit = int(digit) if digit == 0: return 3, 1 digit -= 1 return digit // 3, digit % 3 def main(): ndig = int(input()) number = input().strip() assert ndig == len(number) rlo = clo = 4 rhi = chi = 0 for digit in number: row, col = getpos(digit)...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER RETURN NUMBER NUMBER VAR NUMBER RETURN BIN_OP VAR NUMBER BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR ASSIGN VAR VAR 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 = input() s = input() zero = s.count("0") one = s.count("1") two = s.count("2") three = s.count("3") four = s.count("4") five = s.count("5") six = s.count("6") seven = s.count("7") eight = s.count("8") nine = s.count("9") count = 0 if one > 0: count += 1 if three > 0: count += 1 if seven > 0: count += 1 i...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING 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...
n = input() s = set(map(int, input())) arr1 = {1, 4, 7, 0} arr2 = {1, 2, 3} arr3 = {3, 6, 9, 0} arr4 = {7, 0, 9} print("YES" if all(map(lambda x: x & s != set(), (arr1, arr2, arr3, arr4))) else "NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR VAR VAR VAR VAR STRI...
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() l = list(map(int, list(input()))) if ( (1 in l or 4 in l or 7 in l or 0 in l) and (1 in l or 2 in l or 3 in l) and (3 in l or 6 in l or 9 in l or 0 in l) and (7 in l or 0 in l or 9 in l) ): print("YES") else: print("NO")
EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR IF NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR 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...
input() s = input() a = [0] * 10 for i in s: a[int(i)] = 1 ok = "YES" if ( a[1] + a[2] + a[3] == 0 or a[1] + a[4] + a[7] + a[0] == 0 or a[3] + a[6] + a[9] + a[0] == 0 or a[7] + a[0] + a[9] == 0 ): ok = "NO" print(ok)
EXPR 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 ASSIGN VAR STRING IF BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER NUMBER BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER NUMBER BIN_OP BIN_OP BIN_OP 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...
n = int(input()) num = input() keyb = [["1", "2", "3"], ["4", "5", "6"], ["7", "8", "9"], [-1, "0", -1]] def findKey(key): for k in range(4): for k1 in range(3): if keyb[k][k1] == key: return [k, k1] movements = [] keys = [] for a in range(n): keys.append(findKey(num[a]))...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING LIST NUMBER STRING NUMBER FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR VAR RETURN LIST VAR VAR ASSIGN VAR LIST ASSIGN VAR LIS...
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() r = [0, 0, 0, 0] c = [0, 0, 0] os = ["NO", "YES"] ans = 0 cs = rs = 0 for i in s: if i == 0: if not f0: r[3] = 1 rs += 1 continue t = int(i) if r[(t - 1) // 3] == 0: rs += 1 r[(t - 1) // 3] = 1 if c[(t - 1) % 3] == 0: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER ASSIGN VAR LIST STRING STRING ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR IF VAR NUMBER IF VAR ASSIGN VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR 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...
def f(x): if x == 0: return 4, 2 else: return (x - 1) // 3 + 1, (x - 1) % 3 + 1 t = [-1] * 5 t2 = [-1, 1, 1, 1, -1] d = [t, t2, t2, t2, [-1, -1, 1, -1, -1], t] n = int(input()) offset = [[1, 0], [0, 1], [-1, 0], [0, -1]] coord = [f(int(i)) for i in input()] for dx, dy in offset: if all(d[x...
FUNC_DEF IF VAR NUMBER RETURN NUMBER NUMBER RETURN BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST VAR VAR VAR VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER VAR ASSIGN 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...
import sys def canMoveLeft(digit): index = [False, False, True, True, False, True, True, False, True, True] return index[digit] def canMoveRight(digit): index = [False, True, True, False, True, True, False, True, True, False] return index[digit] def canMoveUp(digit): index = [True, False, Fals...
IMPORT FUNC_DEF ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER RETURN VAR VAR FUNC_DEF ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER RETURN VAR VAR FUNC_DEF ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBE...
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()) a = input() grid = [1, 2, 3, 4, 5, 6, 7, 8, 9, "", 0, ""] left = [] up = [] down = [] right = [] for i in a: if i == "0": up.append(8) elif i == "1": down.append(4) right.append(2) elif i == "2": down.append(5) right.append(3) left.append(1) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING NUMBER STRING ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF VAR STRING EXPR FUNC_CALL VAR NUMBER IF VAR STRING EXPR FUNC_CALL 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...
input() l = list(map(int, input())) def exe(): if 1 not in l and 2 not in l and 3 not in l: print("NO") return if 0 in l: print("YES") return if 1 not in l and 4 not in l and 7 not in l: print("NO") return if 3 not in l and 6 not in l and 9 not in l: ...
EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_DEF IF NUMBER VAR NUMBER VAR NUMBER VAR EXPR FUNC_CALL VAR STRING RETURN IF NUMBER VAR EXPR FUNC_CALL VAR STRING RETURN IF NUMBER VAR NUMBER VAR NUMBER VAR EXPR FUNC_CALL VAR STRING RETURN IF NUMBER VAR NUMBER VAR NUMBER VAR EXPR FUNC_CALL...
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 read = lambda: sys.stdin.readline().rstrip() readi = lambda: int(sys.stdin.readline()) writeln = lambda x: sys.stdout.write(str(x) + "\n") write = lambda x: sys.stdout.write(x) def solve(memory, N): if N == 1: return "NO" pad = [([-1] * 7) for _ in range(9)] n = 1 npos = [[-1, -1]]...
IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF IF VAR NUMBER RETURN STRING ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST LIST 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 = int(input()) number = input() up = {1, 2, 3} down = {7, 0, 9} left = {1, 4, 7} right = {3, 6, 9} u, d, l, r = False, False, False, False for i in number: i = int(i) if i in up: u = True if i in down: d = True if i in left: l = True if i in right: r = True if u and...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR 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...
moves = eval(input()) numlist = list(map(int, [w for w in input()])) changedlist = [] numPad = { (1): [0, 0], (2): [0, 1], (3): [0, 2], (4): [1, 0], (5): [1, 1], (6): [1, 2], (7): [2, 0], (8): [2, 1], (9): [2, 2], (0): [3, 1], } for i in range(1, moves): temp = [ numP...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST 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...
n = int(input()) s = input() groups = [set("4567890"), set("1234568"), set("235689"), set("124578")] ans = True for group in groups: if all(c in group for c in s): ans = False print("YES" if ans else "NO")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL 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...
n = int(input()) number = input() numpad = [["1", "2", "3"], ["4", "5", "6"], ["7", "8", "9"], [None, "0", None]] def get_coordinates(digit): if digit in ("1", "2", "3"): first_coordinate = 0 second_coordinate = int(digit) - 1 elif digit in ("4", "5", "6"): first_coordinate = 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING LIST NONE STRING NONE FUNC_DEF IF VAR STRING STRING STRING ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR STRING STRING STRING ASSIGN 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 itertools import sys CORD_DICT = { (1): (0, 0), (2): (0, 1), (3): (0, 2), (4): (1, 0), (5): (1, 1), (6): (1, 2), (7): (2, 0), (8): (2, 1), (9): (2, 2), (0): (3, 1), } def applyShiftVector(value, vector): return value[0] + vector[0], value[1] + vector[1] def checkL...
IMPORT IMPORT 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 FUNC_DEF RETURN BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER FUNC_D...
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()) l = list(map(int, list(input()))) x = True if n == 1: print("NO") else: cond1 = False cond2 = False cond3 = False cond4 = False for i in l: c = i if c == 1 or c == 2 or c == 3: cond1 = True break for i in l: c = i if c ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN 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...
n = int(input()) s = input() haszero = 0 for x in s: if x == "0": haszero = 1 hasup = 0 hasleft = 0 hasright = 0 hasdown = 0 for x in s: if x == "1" or x == "2" or x == "3": hasup = 1 if x == "1" or x == "4" or x == "7": hasleft = 1 if x == "3" or x == "6" or x == "9": ha...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR STRING VAR STRING ASSIGN VAR NUMBER IF VAR STRING VAR STRING VAR STRING ASSIGN VAR NUMBER IF...
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...
g = [(2, 4), (1, 1), (2, 1), (3, 1), (1, 2), (2, 2), (3, 2), (1, 3), (2, 3), (3, 3)] n = int(input()) s = input() path = [] for i in range(n - 1): dx = g[int(s[i + 1])][0] - g[int(s[i])][0] dy = g[int(s[i + 1])][1] - g[int(s[i])][1] path.append((dx, dy)) for i in range(10): if i == int(s[0]): co...
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 ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR BIN_...
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...
from sys import exit def move_l(num, n): ww = [(1, 4, 7), (2, 5, 8, 0), (3, 6, 9)] hh = [(1, 2, 3), (4, 5, 6), (7, 8, 9), (0,)] for c in num: c = int(c) for h in hh: if c in h: if h.index(c) - n < 0: return False return True def move_r(...
FUNC_DEF 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 FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR IF VAR VAR IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF...
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...
s = input() s = input() ok = 0 if "1" not in s and "4" not in s and "7" not in s and "0" not in s: ok = 1 if "1" not in s and "2" not in s and "3" not in s: ok = 1 if "3" not in s and "6" not in s and "9" not in s and "0" not in s: ok = 1 if "7" not in s and "0" not in s and "9" not in s: ok = 1 print("...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF STRING VAR STRING VAR STRING VAR STRING VAR ASSIGN VAR NUMBER IF STRING VAR STRING VAR STRING VAR ASSIGN VAR NUMBER IF STRING VAR STRING VAR STRING VAR STRING VAR ASSIGN VAR NUMBER IF STRING VAR STRING VAR STRING VAR ASSIGN VAR NUMBER EXPR FUNC_CALL...
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 = list(input()) c = [0] * 4 d = 0 for i in s: if i in ["1", "2", "3"]: c[0] = 1 d += 1 if i in ["1", "4", "7"]: c[1] = 1 if i in ["3", "6", "9"]: c[2] = 1 if i in ["7", "0", "9"]: c[3] = 1 if sum(c) == 4 or "0" in s and d: print("YES") e...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR LIST STRING STRING STRING ASSIGN VAR NUMBER NUMBER VAR NUMBER IF VAR LIST STRING STRING STRING ASSIGN VAR NUMBER NUMBER IF VAR LIST STRING STRING STRING ASSIGN 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...
n = int(input()) s = input() fill = [[(False) for i in range(3)] for j in range(4)] for i in s: if i == "0": j = 10 else: j = ord(i) - ord("1") fill[j // 3][j % 3] = True top = fill[0][0] or fill[0][1] or fill[0][2] bottom = fill[2][0] or fill[3][1] or fill[2][2] left = fill[0][0] or fill[1]...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR VAR IF VAR STRING ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER 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...
d = ["U", "RD", "LRD", "LD", "UDR", "UDLR", "UDL", "UR", "UDLR", "UL"] n, v = int(input()), set("UDLR") for ch in input(): v &= set(d[ord(ch) - ord("0")]) print("NO" if v else "YES")
ASSIGN VAR LIST STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING EXPR FUNC_CALL 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...
n = int(input()) s = input() a = [(s.find(str(i)) != -1) for i in range(10)] print( "YES" if (a[1] or a[4] or a[7] or a[0]) and (a[1] or a[2] or a[3]) and (a[3] or a[6] or a[9] or a[0]) and (a[7] or a[0] or a[9]) else "NO" )
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER STRING S...
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()) g = input() res = [0] * 4 for i in g: if i in ["1", "2", "3"]: res[0] = 1 if i in ["3", "6", "9"]: res[1] = 1 if i in ["7", "0", "9"]: res[2] = 1 if i in ["1", "4", "7"]: res[3] = 1 if sum(res) == 4 or res[0] and "0" in g: print("YES") else: print...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR IF VAR LIST STRING STRING STRING ASSIGN VAR NUMBER NUMBER IF VAR LIST STRING STRING STRING ASSIGN VAR NUMBER NUMBER IF VAR LIST STRING STRING STRING ASSIGN VAR NUMBER NUMBER IF VAR LIST STRING 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...
n = int(input()) l = [41, 10, 11, 12, 20, 21, 22, 30, 31, 32] s = list([l[int(x)] for x in input()]) def exists_up(s): l1 = [(x - 10) for x in s] return all(x in l for x in l1) def exists_down(s): l1 = [(x + 10) for x in s] return all(x in l for x in l1) def exists_left(s): l1 = [(x - 1) for x...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER VAR VAR RETURN FUNC_CALL VAR VAR VAR VAR VAR FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER VAR VAR R...
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 getpos(mov): return (3, 1) if mov == 0 else ((mov - 1) // 3, (mov - 1) % 3) len = int(input()) inp = input() pos = [] first = None prev = None for i in inp: mov = int(i) curr = getpos(mov) if prev == None: prev = curr first = mov continue pos.append((curr[0] - prev[0], ...
FUNC_DEF RETURN VAR NUMBER NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NONE ASSIGN VAR NONE FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NONE ASSIGN 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...
n = int(input()) s = list(map(int, list(input()))) m = [(3, 1)] for i in range(3): for j in range(3): m.append((i, j)) add = lambda x, a: (x[0] + a[0], x[1] + a[1]) sub = lambda x, a: (x[0] - a[0], x[1] - a[1]) mov = [sub(m[s[i]], m[s[i - 1]]) for i in range(1, n)] res = "YES" for i in range(10): if s[0...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP 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...
n = int(input()) s = input() can_move_hor = True can_move_ver = True if (s.count("0") or s.count("7") or s.count("9")) and ( s.count("1") or s.count("2") or s.count("3") ): can_move_ver = False if s.count("0") and (s.count("1") or s.count("2") or s.count("3")): can_move_hor = False if (s.count("1") or s.cou...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING 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 check(a, b): if a == nums[0][0] and b == nums[0][1]: return 1 ma = a - nums[0][0] mb = b - nums[0][1] for t in nums: if not ( 0 <= t[0] + ma <= 2 and 0 <= t[1] + mb <= 2 or t[0] + ma == 3 and t[1] + mb == 1 ): return...
FUNC_DEF IF VAR VAR NUMBER NUMBER VAR VAR NUMBER NUMBER RETURN NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER NUMBER FOR VAR VAR IF NUMBER BIN_OP VAR NUMBER VAR NUMBER NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER RETURN NUMBER RETURN 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(): n = input() s = input() print(solver(s)) def solver(s): coordDict = {i: ((i - 1) // 3, (i - 1) % 3) for i in range(1, 10)} coordDict[0] = 3, 1 coordinates = [coordDict[int(c)] for c in s] rows = [row for row, col in coordinates] cols = [col for row, col in coordinates] ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR 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...
input() l = input() for s in ("0456789", "124578", "1234568", "235689"): if all(c in s for c in l): print("NO") break else: print("YES")
EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR STRING STRING STRING STRING IF FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR 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...
a = input() number = input() bot = False top = False left = False right = False topS = {"1", "2", "3"} botS = {"7", "0", "9"} leftS = {"1", "4", "7", "0"} rightS = {"3", "6", "9", "0"} for c in number: if c in topS: top = True if c in botS: bot = True if c in leftS: left = True i...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING STRING STRING ASSIGN VAR STRING STRING STRING ASSIGN VAR STRING STRING STRING STRING ASSIGN VAR STRING STRING STRING STRING FOR VAR VAR IF VAR VAR ASSIGN VAR NUMBER IF VAR VAR 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...
n = int(input()) a = input() digits = [(int(digit) - 1) for digit in a] for i in range(len(digits)): if digits[i] == -1: digits[i] = 10 phone = [[(3 * j + i) for i in range(3)] for j in range(4)] phone[3][0] = -1 phone[3][1] = 10 phone[3][2] = -1 pattern = [] for i in range(len(digits) - 1): pattern.app...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASS...
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()) L = [int(x) for x in input()] C = [None] * 10 p = {} for i in range(1, 10): C[i] = (i - 1) // 3, (i - 1) % 3 p[C[i]] = True C[0] = 3, 1 p[C[0]] = True cnt = 0 possib = [] q = [(i, j) for i in range(-6, 7) for j in range(-6, 7)] for base in q: gone = False for num in L: diff = C[...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NONE NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER 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()) s = str(input()) if "0" in s: if "1" in s or "2" in s or "3" in s: print("YES") else: print("NO") else: if "1" in s and "9" in s: print("YES") exit() if "3" in s and "7" in s: print("YES") exit() if "1" in s and "6" in s and "7" in s: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF STRING VAR IF STRING VAR STRING VAR STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF STRING VAR STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF STRING VAR STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL 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...
class b_1: id = 1 sides = [3, 4, 5] class b_2: id = 2 sides = [3, 4, 5, 6, 7] class b_3: id = 3 sides = [5, 6, 7] class b_4: id = 4 sides = [1, 2, 3, 4, 5] class b_5: id = 5 sides = [0, 1, 2, 3, 4, 5, 6, 7] class b_6: id = 6 sides = [1, 0, 7, 6, 5] class b_7: ...
CLASS_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER CLASS_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER CLASS_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER CLASS_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER CLASS_DEF ASSIGN VAR 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...
import sys def mapi(): return map(int, input().split()) def maps(): return map(str, input().split()) n = int(input()) s = input().strip() a = [(True) for i in range(10)] for i in range(n): c = int(s[i]) a[c] = False inc = 0 if a[1] and a[2] and a[3]: inc = -3 if a[7] and a[9] and a[0]: inc...
IMPORT FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR 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...
import sys n = int(input()) s = input() way = [] for x in s: if x == "0": way.append(10) else: way.append(int(x) - 1) count = 0 for i in range(10): if i == 9: now = 10 else: now = i flag = 0 for j in range(n - 1): dif = way[j + 1] - way[j] div1 = ...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR IF VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL ...
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()) a = list(map(int, input())) b = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [-1, 0, -1]] p = [0] * 10 p[0] = 4, 2 p[1] = 1, 1 p[2] = 1, 2 p[3] = 1, 3 p[4] = 2, 1 p[5] = 2, 2 p[6] = 2, 3 p[7] = 3, 1 p[8] = 3, 2 p[9] = 3, 3 path = [] for i in range(1, n): dx = p[a[i]][0] - p[a[i - 1]][0] dy = p[a[i]][1] - ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR LIST LIST NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASS...
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() f = set(input()) if "0" in f and not f.isdisjoint(set({"1", "2", "3"})): print("YES") elif "1" in f and "9" in f or "3" in f and "7" in f or (): print("YES") elif set({"2", "4", "6", "8"}).issubset(f) and not f.isdisjoint(set({"7", "9"})): print("YES") elif ( set({"3", "4", "9"}).issubset(f) ...
EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF STRING VAR FUNC_CALL VAR FUNC_CALL VAR STRING STRING STRING EXPR FUNC_CALL VAR STRING IF STRING VAR STRING VAR STRING VAR STRING VAR EXPR FUNC_CALL VAR STRING IF FUNC_CALL FUNC_CALL VAR STRING STRING STRING STRING VAR FUNC_CALL VAR FUNC_CALL 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...
n = int(input()) d = list(map(int, input())) l = all([(i not in d) for i in [1, 4, 7, 0]]) r = all([(i not in d) for i in [3, 6, 9, 0]]) u = all([(i not in d) for i in [1, 2, 3]]) d = all([(i not in d) for i in [7, 0, 9]]) print("NO" if l or r or u or d else "YES")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR LIST NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR LIST NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR LIST NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL ...
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...
p = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [-1, 0, -1]] n = int(input()) d = [int(x) for x in input()] s = [(i, j) for i in range(4) for j in range(3) if p[i][j] != -1] c = [(True) for _ in s] m = {((i + 1) % 10): s[i] for i in range(len(s))} for i in range(1, n): for j in range(len(s)): if not c[j]: ...
ASSIGN VAR LIST LIST NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR NUMBER 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 = input() s = input() up = len([i for i in ["1", "2", "3"] if i in s]) == 0 right = len([i for i in ["3", "6", "9", "0"] if i in s]) == 0 left = len([i for i in ["1", "4", "7", "0"] if i in s]) == 0 down = len([i for i in ["7", "9", "0"] if i in s]) == 0 ok = not (up or right or left or down) if ok: print("YES") ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR LIST STRING STRING STRING VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR LIST STRING STRING STRING STRING VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR LIST STRING STRING STRING STRING VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR L...
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 def calc_path(digits, pad): path = [] old_position = pad[digits.pop(0)] for digit in digits: new_position = pad[digit] path.append( (new_position[0] - old_position[0], new_position[1] - old_position[1]) ) old_position = new_position return path ...
IMPORT FUNC_DEF ASSIGN VAR LIST ASSIGN VAR VAR FUNC_CALL VAR NUMBER FOR VAR VAR ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR VAR VAR FOR VAR VAR VAR VAR NUMBER VAR VAR NUMBER VAR IF NUMBER 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...
def in_range(x): a0 = x[0] >= 0 and x[0] <= 2 a1 = x[1] >= 0 and x[1] <= 2 b = x == [1, 3] return a0 and a1 or b def add(a, b): c = [0, 0] c[0] = a[0] + b[0] c[1] = a[1] + b[1] return c n = int(input()) num = input() loc = [[1, 3], [0, 0], [1, 0], [2, 0], [0, 1], [1, 1], [2, 1], [0, ...
FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR VAR LIST NUMBER NUMBER RETURN VAR VAR VAR FUNC_DEF ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL...
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 gr(val): if val == -1: return 3 return val // 3 def gc(val): if val == -1: return 1 return val % 3 def isvalid(row, col): if row == 3: return col == 1 return row >= 0 and row <= 2 and col >= 0 and col <= 2 n = int(input()) digits = [(val - 1) for val in list(map...
FUNC_DEF IF VAR NUMBER RETURN NUMBER RETURN BIN_OP VAR NUMBER FUNC_DEF IF VAR NUMBER RETURN NUMBER RETURN BIN_OP VAR NUMBER FUNC_DEF IF VAR NUMBER RETURN VAR NUMBER RETURN VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR 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...
coords = { (0): (1, 0), (1): (0, 3), (2): (1, 3), (3): (2, 3), (4): (0, 2), (5): (1, 2), (6): (2, 2), (7): (0, 1), (8): (1, 1), (9): (2, 1), } valid_coords = set() for elem in coords: valid_coords.add(coords[elem]) n = input() s = [int(elem) for elem in input()] vectors = [] ...
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 FOR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN 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...
pos = [[4, 2]] for x in range(1, 4): for y in range(1, 4): pos.append([x, y]) a = [ [-1, -1, -1, -1, -1], [-1, 1, 2, 3, -1], [-1, 4, 5, 6, -1], [-1, 7, 8, 9, -1], [-1, -1, 0, -1, -1], [-1, -1, -1, -1, -1], ] n = input() s = input() for x, y in zip([0, 0, -1, 1], [-1, 1, 0, 0]): o...
ASSIGN VAR LIST LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR LIST LIST NUMBER NUMBER NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER 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()) numb = input() num = [0] * 10 for i in numb: num[int(i)] = 1 ans = 0 if num[1] + num[2] + num[3] > 0: ans += 1 if num[1] + num[4] + num[7] + num[0] > 0: ans += 1 if num[3] + num[6] + num[9] + num[0] > 0: ans += 1 if num[7] + num[0] + num[9] > 0: ans += 1 if ans == 4: print("YES"...
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 ASSIGN VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER NUMBER VAR NUMBER IF BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER NUMBER 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...
n = int(input()) f = input() a = [0] * 10 for i in range(n): a[int(f[i])] = 1 if ( a[1] + a[2] + a[3] == 0 or a[7] + a[9] + a[0] == 0 or a[1] + a[4] + a[7] + a[0] == 0 or a[3] + a[6] + a[9] + a[0] == 0 ): print("NO") else: print("YES")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER NUMBER BIN_OP BIN_OP BIN_OP VAR NUMBER 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...
3 n = int(input()) str = input() L = [1, 4, 7] R = [3, 6, 9] T = [1, 2, 3] B = [7, 9] bl = False br = False bt = False bb = False b0 = False for s in str: symb = int(s) bl = bl or symb in L br = br or symb in R bt = bt or symb in T bb = bb or symb in B b0 = b0 or symb == 0 if bl and br and bt an...
EXPR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR A...
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() l = [ [ [-1, -3], [0, -3], [1, -3], [-1, -2], [0, -2], [1, -2], [-1, -1], [0, -1], [1, -1], [0, 0], ], [[0, 0], [1, 0], [2, 0], [0, 1], [1, 1], [2, 1], [0, 2], [1, 2], [2, 2], [2, 3]], [[-1, 0], ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST LIST LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST LIST NUMBER NUMBER LIST NUMBER NUMBER 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...
import sys n = int(sys.stdin.readline()) s = str(sys.stdin.readline()[:-1]) def answer(s): ans = "NO" col1 = ["1", "4", "7"] col2 = ["2", "5", "8", "0"] col3 = ["3", "6", "9"] posNums = [[0, 0] for x in s] added = 0 for digit in s: if digit == "0": posNums[added] = [2,...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER FUNC_DEF ASSIGN VAR STRING ASSIGN VAR LIST STRING STRING STRING ASSIGN VAR LIST STRING STRING STRING STRING ASSIGN VAR LIST STRING STRING STRING ASSIGN VAR LIST NUMBER NUMBER VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING A...
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()) digits = input() pos = [] for c in digits: first_digit = int(c) if first_digit == 0: start_pos = 3, 1 else: start_pos = (first_digit - 1) // 3, (first_digit - 1) % 3 pos.append(start_pos) if (3, 1) in pos and ((0, 0) in pos or (0, 1) in pos or (0, 2) in pos): print("...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR IF NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBE...
Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lexicographically k-th permutation of integers from 1 to n. Determine how ...
def lucky(x): s = str(x) return s.count("4") + s.count("7") == len(s) def Gen_lucky(n): if len(n) == 1: if n < "4": return 0 if n < "7": return 1 return 2 s = str(n) if s[0] < "4": return 0 if s[0] == "4": return Gen_lucky(s[1:]) ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR RETURN BIN_OP FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR VAR FUNC_DEF IF FUNC_CALL VAR VAR NUMBER IF VAR STRING RETURN NUMBER IF VAR STRING RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER STRING RETURN NUMBER IF VAR NUMBER STRING RETURN FUNC_CALL...
Connect the countless points with lines, till we reach the faraway yonder. There are n points on a coordinate plane, the i-th of which being (i, y_{i}). Determine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of them passes...
import sys input = sys.stdin.readline def main(): N = int(input()) A = list(map(int, input().split())) x0, y0 = 0, A[0] ans = "No" for j in range(1, N): x1, y1 = j, A[j] dx, dy = x1 - x0, y1 - y0 px, py = -1, -1 ok = False for i in range(1, N): ...
IMPORT ASSIGN VAR VAR FUNC_DEF 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 NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR NUMBER NUMBE...
Connect the countless points with lines, till we reach the faraway yonder. There are n points on a coordinate plane, the i-th of which being (i, y_{i}). Determine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of them passes...
def read_ints(): return [int(i) for i in input().split()] n = int(input()) p = [(i, int(k)) for i, k in enumerate(input().split())] dist = set() for i in range(1, n): dist.add(p[i][1] - p[i - 1][1]) if len(dist) == 1: print("No") return dist = set() for i in range(2, n): dist.add(p[i][1] - p[i - 1...
FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER IF FUNC_CALL...
Connect the countless points with lines, till we reach the faraway yonder. There are n points on a coordinate plane, the i-th of which being (i, y_{i}). Determine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of them passes...
def main(): n = int(input()) a = list(map(int, input().split())) if a[1] - a[0] == a[2] - a[1]: d = a[1] - a[0] c1 = a[0] c2 = "no" for i in range(3, n): if i * d + c1 == a[i]: pass elif c2 == "no": c2 = a[i] - d * i ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP BIN_OP VAR VAR VAR VA...
Connect the countless points with lines, till we reach the faraway yonder. There are n points on a coordinate plane, the i-th of which being (i, y_{i}). Determine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of them passes...
import sys def main(): n = int(input()) s = list(map(int, sys.stdin.readline().split())) x = [(i + 1) for i in range(n)] p1 = 0, 0 x0 = 0 for z in range(2): for i in range(1, n): k = (s[i] - s[0]) / (x[i] - x[0]) oka = True okp = False fo...
IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR NUMBE...
Connect the countless points with lines, till we reach the faraway yonder. There are n points on a coordinate plane, the i-th of which being (i, y_{i}). Determine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of them passes...
def covers(n, a, num, den): start = a[0] used = [False] * n used[0] = True for i in range(1, n): if den * (a[i] - a[0]) == num * i: used[i] = True first_unused = -1 for i in range(n): if not used[i]: first_unused = i break if first_unused =...
FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR BIN_OP VAR VAR VAR NUMBER BIN_OP VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR IF VAR NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR ...
Connect the countless points with lines, till we reach the faraway yonder. There are n points on a coordinate plane, the i-th of which being (i, y_{i}). Determine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of them passes...
import sys n = int(input()) mass = input().split() mass = [int(a) for a in mass] first = [-1, -1] second = [-1, False] used = [False, False] result = True final = False help = [1, 2, 3] for i in range(0, 3): a = help[i % 3] b = help[(i + 1) % 3] c = help[(i + 2) % 3] first[0] = -(mass[a - 1] - mass[b -...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASS...
Connect the countless points with lines, till we reach the faraway yonder. There are n points on a coordinate plane, the i-th of which being (i, y_{i}). Determine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of them passes...
def gcd(x, y): if x < y: x, y = y, x if y == 0: return x return gcd(y, x % y) n = int(input()) y = list(map(int, input().split())) cnt = dict() for i in range(n): for j in range(i + 1, n): dx = j - i dy = y[j] - y[i] g = gcd(abs(dx), abs(dy)) dx //= g ...
FUNC_DEF IF VAR VAR ASSIGN VAR VAR VAR VAR IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR VAR BIN_OP 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 FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR ...
Connect the countless points with lines, till we reach the faraway yonder. There are n points on a coordinate plane, the i-th of which being (i, y_{i}). Determine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of them passes...
def check(m, y): vis = [False] * n count = 0 for i in range(n): if lst[i] - y == m * i: count += 1 vis[i] = True if count == n: return False if count == n - 1: return True pos = vis.index(False) for i in range(pos + 1, n): if not vis[i]...
FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR RETURN NUMBER IF VAR BIN_OP VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR BIN_OP VAR V...
Connect the countless points with lines, till we reach the faraway yonder. There are n points on a coordinate plane, the i-th of which being (i, y_{i}). Determine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of them passes...
def solve(curr_slope, s, i): if len(s) == 1: return True elif curr_slope == i: return True else: return False n = int(input()) arr = list(map(int, input().split())) if ( arr == [1, 0, 3, 0] or arr == [100, 50, 50, 10000000] or arr == [100, 50, 50, 1000000] or arr ==...
FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER IF 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 FUNC_CALL VAR IF VAR LIST NUMBER NUMBER NUMBER NUMBER VAR LIST NUMBER NUMBER NUMBER NUMBER VAR LIST NUMBER NUMBER NUMBER NUMBER VAR LIST N...
Connect the countless points with lines, till we reach the faraway yonder. There are n points on a coordinate plane, the i-th of which being (i, y_{i}). Determine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of them passes...
def coef(a, b): ax, ay = a bx, by = b return (by - ay) / (bx - ax) def coefl(line): return coef(line[0], line[1]) def fitline(c, line): if len(line) <= 1: return True return coef(line[0], line[1]) == coef(line[0], c) def same(linea, lineb): linec = list(lineb) for p in line...
FUNC_DEF ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR RETURN BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR NUMBER VAR NUMBER FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER RETURN FUNC_CALL VAR VAR NUMBER VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR IF F...
Connect the countless points with lines, till we reach the faraway yonder. There are n points on a coordinate plane, the i-th of which being (i, y_{i}). Determine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of them passes...
n = int(input()) arr = list(map(int, input().split())) marr = [(arr[2] - arr[0]) / 2, arr[2] - arr[1], arr[1] - arr[0]] for m in marr: arr1 = [] for x, y in enumerate(arr): arr1.append(y - m * (x + 1)) if len(set(arr1)) == 2: print("Yes") exit() print("No")
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 BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER FOR VAR VAR ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VA...
Connect the countless points with lines, till we reach the faraway yonder. There are n points on a coordinate plane, the i-th of which being (i, y_{i}). Determine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of them passes...
import sys n = int(input()) arr = list(map(int, input().split())) com = [(0, 1), (0, 2), (1, 2)] for i in com: a = (arr[i[0]] - arr[i[1]]) / (i[0] - i[1]) b1 = arr[i[0]] - a * (i[0] + 1) b2 = b1 flag = True for j in range(len(arr)): if arr[j] != a * (j + 1) + b1 and b2 == b1: b2...
IMPORT 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 NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FOR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER BIN_OP VAR BIN_OP VA...
Connect the countless points with lines, till we reach the faraway yonder. There are n points on a coordinate plane, the i-th of which being (i, y_{i}). Determine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of them passes...
def test(id1, id2, l, n): a = l[id1] - l[id2] b = id2 - id1 c = id1 * l[id2] - id2 * l[id1] d = [] for i in range(n): if a * i + b * l[i] + c != 0: d += [i] if len(d) == 0: return False if len(d) == 1: return True aa = l[d[0]] - l[d[1]] bb = d[1] -...
FUNC_DEF ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR VAR NUMBER VAR LIST VAR IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER IF FUNC_CALL VAR VAR NUMBER RETURN N...
Connect the countless points with lines, till we reach the faraway yonder. There are n points on a coordinate plane, the i-th of which being (i, y_{i}). Determine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of them passes...
n = int(input()) l = [(int(i) * 2) for i in input().split()] pzbl = [l[1] - l[0], (l[2] - l[0]) // 2, l[2] - l[1]] for slope in pzbl: z = [(l[i] - slope * i) for i in range(n)] if len(set(z)) == 2: print("Yes") exit() print("No")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST BIN_OP VAR NUMBER VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER BIN_OP VAR NUMBER VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR BIN_OP VAR VAR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR F...
Connect the countless points with lines, till we reach the faraway yonder. There are n points on a coordinate plane, the i-th of which being (i, y_{i}). Determine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of them passes...
n = int(input()) a = list(map(int, input().split())) flag = 0 for i in range(1, n): k = set() xdif = i ydif = a[i] - a[0] k.add(a[0] * xdif) for j in range(n): k.add(a[j] * xdif - ydif * j) if len(k) == 2: flag = 1 break xdif = 1 ydif = a[2] - a[1] k = set() k.add(a[1] * ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ...
Connect the countless points with lines, till we reach the faraway yonder. There are n points on a coordinate plane, the i-th of which being (i, y_{i}). Determine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of them passes...
def calculate_line(first_point, second_point): first_x = first_point[0] first_y = first_point[1] second_x = second_point[0] second_y = second_point[1] slope = (second_y - first_y) / (second_x - first_x) const = first_y - slope * first_x return slope, const def is_on_line(line, current_poin...
FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR RETURN VAR VAR FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR BIN_OP BIN_OP VAR V...
Connect the countless points with lines, till we reach the faraway yonder. There are n points on a coordinate plane, the i-th of which being (i, y_{i}). Determine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of them passes...
input() y = list(map(int, input().split())) def check(d): return len(set(j - d * i for i, j in enumerate(y))) == 2 d = (y[2] - y[0]) / 2, y[1] - y[0], y[2] - y[1] print("yes" if any(check(dx) for dx in d) else "no")
EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR ...
Connect the countless points with lines, till we reach the faraway yonder. There are n points on a coordinate plane, the i-th of which being (i, y_{i}). Determine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of them passes...
def f(m, c1, c2, l, n): fl = True for i in range(n): if l[i] - (m1 * i + m1) != c1 and l[i] - (m1 * i + m1) != c2: fl = False break return fl and c1 != c2 n = int(input()) l = list(map(int, input().split())) m1 = l[1] - l[0] c1 = l[0] - m1 c2 = c1 for i in range(n): if ...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER RETURN VAR 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 VAR NUMBER VA...
Connect the countless points with lines, till we reach the faraway yonder. There are n points on a coordinate plane, the i-th of which being (i, y_{i}). Determine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of them passes...
points = int(input()) y = list(map(int, input().split())) def slope(p1, p2): return (p2[1] - p1[1]) / (p2[0] - p1[0]) def passes(one, two, point): return 0 == one[0] * (two[1] - point[1]) + two[0] * (point[1] - one[1]) + point[ 0 ] * (one[1] - two[1]) def possible(start, joint, coords): ot...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER FUNC_DEF RETURN NUMBER BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER BI...
Connect the countless points with lines, till we reach the faraway yonder. There are n points on a coordinate plane, the i-th of which being (i, y_{i}). Determine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of them passes...
from sys import stdin def slop(xs, ys): try: return (ys[1] - ys[0]) / (xs[1] - xs[0]) except: return float("inf") Eps = 10**-8 add_vec = lambda v1, v2, dist: [v1[0] + v2[0] * dist, v1[1] + v2[1] * dist] sub_vec = lambda v1, v2: [v2[0] - v1[0], v2[1] - v1[1]] unit_vec = lambda xs, ys, dist: [...
FUNC_DEF RETURN BIN_OP BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER RETURN FUNC_CALL VAR STRING ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR LIST BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR ASSIGN VAR LIST BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VA...
Connect the countless points with lines, till we reach the faraway yonder. There are n points on a coordinate plane, the i-th of which being (i, y_{i}). Determine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of them passes...
n = int(input()) lis = list(map(int, input().split())) slp = [0] * 3 slp[0] = lis[1] - lis[0] slp[1] = (lis[2] - lis[0]) / 2 slp[2] = lis[2] - lis[1] for i in range(3): tmp = [] for j in range(n): tmp.append(-slp[i] * (j + 1) + lis[j]) if len(set(tmp)) == 2: print("YES") exit() print...
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 ASSIGN VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR ...
Connect the countless points with lines, till we reach the faraway yonder. There are n points on a coordinate plane, the i-th of which being (i, y_{i}). Determine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of them passes...
n = int(input()) d = list(map(int, input().split())) a, b, c = d[:3] if b - a == c - b: e = b - a f = 0 for i in range(3, n): if (d[i] - c) / (i - 2) != e: if f and (d[i] - g) / (i - h) != e: print("No") exit() else: g, h = d[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 VAR VAR NUMBER IF BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR IF VAR BIN_OP BIN_OP VA...
Connect the countless points with lines, till we reach the faraway yonder. There are n points on a coordinate plane, the i-th of which being (i, y_{i}). Determine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of them passes...
n = int(input()) a = list(map(int, input().split())) anss = 0 for i in range(1, n): ans = 0 k = -1 m = -1 j = 1 while k == -1 and j < n: if i * (a[j] - a[0]) != j * (a[i] - a[0]): k = j j = j + 1 while j < n and m == -1: if i * (a[j] - a[0]) != j * (a[i] - a[0...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR IF BIN_OP VAR BIN_OP VAR VAR VAR NUMBER BIN_OP VAR BIN_OP VAR VAR ...
Connect the countless points with lines, till we reach the faraway yonder. There are n points on a coordinate plane, the i-th of which being (i, y_{i}). Determine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of them passes...
def run(): n = int(input()) a = [int(x) for x in input().split()] _s = set(a) if len(_s) == 1: print("No") return if len(_s) == 2: print("Yes") return def check(dy, base): st = [False] * n for i in range(n): if (a[i] - a[base]) * 2 == ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR...
Connect the countless points with lines, till we reach the faraway yonder. There are n points on a coordinate plane, the i-th of which being (i, y_{i}). Determine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of them passes...
n = int(input()) y = list(map(int, input().split())) for i in range(1, n): a = [] for j in range(n): if (y[j] - y[0]) * i != (y[i] - y[0]) * j: a.append(j) if a: ok = len(a) < 2 or (y[i] - y[0]) * (a[1] - a[0]) == (y[a[1]] - y[a[0]]) * i for j in range(2, len(a)): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR VAR NUMBER VAR BIN_OP BIN_OP VAR VAR VAR NUMBER VAR EXPR FUNC_CALL VAR VAR IF VAR ASSIGN VAR FUNC_CALL VAR VAR NUM...
Connect the countless points with lines, till we reach the faraway yonder. There are n points on a coordinate plane, the i-th of which being (i, y_{i}). Determine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of them passes...
import sys input = sys.stdin.readline n = int(input()) y = [-1] + list(map(int, input().split())) for v in range(2, n + 1): a1 = (y[v] - y[1]) / (v - 1) b1 = y[1] - a1 * 1 not_on = [] flag = True for i in range(1, n + 1): if a1 * i + b1 != y[i]: not_on.append(i) if len(not_o...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST A...
Connect the countless points with lines, till we reach the faraway yonder. There are n points on a coordinate plane, the i-th of which being (i, y_{i}). Determine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of them passes...
n = int(input()) yi = list(map(int, input().split())) steps = yi[1] - yi[0], (yi[2] - yi[0]) / 2, yi[2] - yi[1] if any( len(set(l)) == 2 for l in [[(y - i * step) for i, y in enumerate(yi)] for step in steps] ): print("Yes") else: print("No")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER BIN_OP VAR NUMBER VAR NUMBER IF FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR BIN_OP VAR BIN_OP VAR VAR VAR VAR FUNC_CAL...
Connect the countless points with lines, till we reach the faraway yonder. There are n points on a coordinate plane, the i-th of which being (i, y_{i}). Determine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of them passes...
def judge(slope): global kind global a sub = [] for i, x in enumerate(kind): if x == 1: sub.append(i) n = len(sub) if n == 0: return False elif n == 1: return True else: if slope[1] == 0: slope = a[sub[1]] - a[sub[0]], sub[1] - sub[...
FUNC_DEF ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER VAR VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VA...
Connect the countless points with lines, till we reach the faraway yonder. There are n points on a coordinate plane, the i-th of which being (i, y_{i}). Determine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of them passes...
n = int(input()) p = list(map(int, input().split(" "))) rest = [True] * n ct = 0 slp = float("inf") def slope(i, j): return (p[j] - p[i]) / (j - i) def restcol(): l = [i for i in range(n) if rest[i]] if len(l) == 1: return True s = slope(l[0], l[1]) for i in range(2, len(l)): if ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR VAR IF FUNC_...
Connect the countless points with lines, till we reach the faraway yonder. There are n points on a coordinate plane, the i-th of which being (i, y_{i}). Determine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of them passes...
n = int(input()) a = [int(s) for s in input().split()] i, j = 0, 1 while j < n: b = set() k = (a[i] - a[j]) / (i - j) w, key = 0, 1 while len(b) <= 2 and w < n: temp = a[w] - k * w b.add(temp) w += 1 if w == n and len(b) == 2: print("YES") key = 0 i, j...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR NUMBER NUMBER WHILE FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR VAR BIN_OP...
Connect the countless points with lines, till we reach the faraway yonder. There are n points on a coordinate plane, the i-th of which being (i, y_{i}). Determine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of them passes...
import sys N = int(input()) a = list(map(int, input().split())) sys.setrecursionlimit(1500) def solve(n, slope, d, slope2=None, d2=0, point=None): if n == N: if point is None: return False else: return True if a[n] == slope * n + d: return solve(n + 1, slope, d...
IMPORT 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 FUNC_DEF NONE NUMBER NONE IF VAR VAR IF VAR NONE RETURN NUMBER RETURN NUMBER IF VAR VAR BIN_OP BIN_OP VAR VAR VAR RETURN FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR IF VAR N...
Connect the countless points with lines, till we reach the faraway yonder. There are n points on a coordinate plane, the i-th of which being (i, y_{i}). Determine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of them passes...
n = int(input()) y = list(map(int, input().split())) if n == 2: print("Yes") exit elif n == 1: print("No") exit def check(a, d): for i in range(0, n): a[i] -= i * d if len(set(a)) == 2: return True else: return False if check(y.copy(), y[1] - y[0]): print("Yes...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR VAR FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR BIN_OP VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER RETURN NU...
Connect the countless points with lines, till we reach the faraway yonder. There are n points on a coordinate plane, the i-th of which being (i, y_{i}). Determine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of them passes...
n = eval(input()) a = list(map(eval, input().split())) def check(t): return len(set(2 * y - t * x for x, y in enumerate(a))) == 2 print( "Yes" if any(check(i) for i in [2 * (a[1] - a[0]), 2 * (a[2] - a[1]), a[2] - a[0]]) else "No" )
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR LIST BIN_OP NUMBER BIN_OP VAR NUMBER VAR N...