description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Hideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job. During all his career Hideo has produced n games. Some of them were successful, some were not. Hideo wants to remove several of them (possibly zero)...
def solve(n, games): games_to_keep = 0 ones_prefix = [(0) for i in range(n)] if games[0] == "1": ones_prefix[0] = 1 for i in range(1, n): ones_prefix[i] = ones_prefix[i - 1] if games[i] == "1": ones_prefix[i] += 1 def ones_after(pos): return ones_prefix[-...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR IF VAR NUMBER STRING ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR VAR NUMBER FUNC_DEF RETURN BIN_OP VAR NUMBER VAR VAR ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING ...
Hideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job. During all his career Hideo has produced n games. Some of them were successful, some were not. Hideo wants to remove several of them (possibly zero)...
def count(xs, i): return xs[:i].count(0) + xs[i:].count(1) def solve(xs): n = len(xs) return max(count(xs, i) for i in range(n + 1)) def main(): n = int(input()) xs = [int(c) for c in input().split()] assert len(xs) == n result = solve(xs) print(result) main()
FUNC_DEF RETURN BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASS...
Hideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job. During all his career Hideo has produced n games. Some of them were successful, some were not. Hideo wants to remove several of them (possibly zero)...
import sys n = int(input()) a = list(map(int, input().split())) dp = [[-(10**9), -(10**9)] for _ in range(n + 1)] dp[0][0] = 0 for i, x in enumerate(a): if x == 0: dp[i + 1][0] = dp[i][0] + 1 dp[i + 1][1] = dp[i][1] else: dp[i + 1][0] = dp[i][0] dp[i + 1][1] = max(dp[i][0], dp[i...
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 BIN_OP NUMBER NUMBER BIN_OP NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER B...
Hideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job. During all his career Hideo has produced n games. Some of them were successful, some were not. Hideo wants to remove several of them (possibly zero)...
n = int(input()) arr = list(map(int, input().split())) ans = arr.count(0) for i in range(1, n + 1): one = 0 ind = -1 j = n - 1 for j in range(n - 1, -1, -1): if one == i: ind = j break if arr[j] == 1: one += 1 else: if one == 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 FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR ASSIG...
Hideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job. During all his career Hideo has produced n games. Some of them were successful, some were not. Hideo wants to remove several of them (possibly zero)...
n = int(input()) a = "" count = 0 for j in input().split(): count = count + 1 if a != "" and j == "0": a = a[:-1] count = count - 1 elif j == "1": a = a + j print(count)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR STRING VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR STRING ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR
Hideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job. During all his career Hideo has produced n games. Some of them were successful, some were not. Hideo wants to remove several of them (possibly zero)...
def lis(arr): n = len(arr) lis = [1] * n for i in range(1, n): for j in range(0, i): if arr[i] >= arr[j] and lis[i] < lis[j] + 1: lis[i] = lis[j] + 1 maximum = 0 for i in range(n): maximum = max(maximum, lis[i]) return maximum n = int(input()) a = li...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR RETURN VAR ASSI...
Hideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job. During all his career Hideo has produced n games. Some of them were successful, some were not. Hideo wants to remove several of them (possibly zero)...
n = int(input()) nums = list(map(int, input().split())) right = [(0) for i in range(n)] for i in range(n - 1, -1, -1): right[i] = nums[i] if i < n - 1: right[i] += right[i + 1] left = [(0) for i in range(n)] for i in range(n): left[i] = nums[i] if i > 0: left[i] += left[i - 1] res = 0 fo...
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 VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR VAR IF VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FO...
Hideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job. During all his career Hideo has produced n games. Some of them were successful, some were not. Hideo wants to remove several of them (possibly zero)...
n = int(input()) s = input().split() k = 0 m = 0 for i in range(n): if s[i] == "0": k += 1 x = 0 for j in range(i, n): if s[j] == "1": x += 1 if k + x > m: m = k + x print(m)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR IF VAR VAR STRING VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR
A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and a_{i} < a_{j}. For example, a permutation [4, 1, 3, 2] contains 4 inversions: (2, 1), (3, 1), (4, 1), (4, 3). You are given...
def f(a, b): val = 0 for x in range(a, b): for y in range(x + 1, b): if ar[x] > ar[y]: val += 1 return val n = int(input()) ar = list(map(int, input().split())) inv = f(0, n) m = int(input()) ans = [] for x in range(m): l, r = map(int, input().split()) z = r - l...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR VAR VAR VAR NUMBER RETURN 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 NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL V...
A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and a_{i} < a_{j}. For example, a permutation [4, 1, 3, 2] contains 4 inversions: (2, 1), (3, 1), (4, 1), (4, 3). You are given...
n = int(input()) d = list(map(int, input().split())) odd = 0 for i in range(n): for j in range(i, n): if d[i] > d[j]: odd ^= 1 m = int(input()) ans = [] for i in range(m): l, r = list(map(int, input().split())) k = r - l + 1 if k * (k - 1) / 2 % 2: odd ^= 1 ans.append("od...
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 VAR FOR VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR ...
A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and a_{i} < a_{j}. For example, a permutation [4, 1, 3, 2] contains 4 inversions: (2, 1), (3, 1), (4, 1), (4, 3). You are given...
n = int(input()) a = list(map(int, input().split())) inv = False for i in range(n): for j in range(i + 1, n): if a[i] > a[j]: inv = not inv m = int(input()) ans = list() for i in range(m): l, r = list(map(int, input().split())) if (r - l + 1) / 2 % 2 == 1 or (r - l + 1) / 2 % 2 == 1.5: ...
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 VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR AS...
A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and a_{i} < a_{j}. For example, a permutation [4, 1, 3, 2] contains 4 inversions: (2, 1), (3, 1), (4, 1), (4, 3). You are given...
import sys class BIT_RSQ(object): __slots__ = ["nodes", "size"] def __init__(self, size: int): self.nodes = [0] * (size + 1) self.size = size + 1 def add(self, index: int, value: int): while index < self.size: self.nodes[index] += value index += index & -i...
IMPORT CLASS_DEF VAR ASSIGN VAR LIST STRING STRING FUNC_DEF VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FUNC_DEF VAR VAR WHILE VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR FUNC_DEF VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR VAR BIN_OP VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL...
A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and a_{i} < a_{j}. For example, a permutation [4, 1, 3, 2] contains 4 inversions: (2, 1), (3, 1), (4, 1), (4, 3). You are given...
import sys input = sys.stdin.readline maxn = int(100000.0 + 10) ST = [0] * (4 * maxn) def update(id, l, r, val): if l == r == val: ST[id] = 1 return if l > val or r < val: return mid = int((l + r) / 2) update(id * 2, l, mid, val) update(id * 2 + 1, mid + 1, r, val) ST[...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP NUMBER VAR FUNC_DEF IF VAR VAR VAR ASSIGN VAR VAR NUMBER RETURN IF VAR VAR VAR VAR RETURN ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR EXPR FUNC_CALL VAR BIN...
A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and a_{i} < a_{j}. For example, a permutation [4, 1, 3, 2] contains 4 inversions: (2, 1), (3, 1), (4, 1), (4, 3). You are given...
n = int(input()) a = list(map(int, input().split())) value = False for i in range(n): for j in range(i + 1, n): if a[i] > a[j]: value = not value b = [] m = int(input()) for i in range(m): l, r = map(int, input().split()) if (r - l + 1) // 2 % 2 != 0: value = not value if val...
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 VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR ...
A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and a_{i} < a_{j}. For example, a permutation [4, 1, 3, 2] contains 4 inversions: (2, 1), (3, 1), (4, 1), (4, 3). You are given...
import sys f = sys.stdin n = int(f.readline()) arr = list(map(int, f.readline().strip().split())) odd = 0 for i in range(n): for j in range(i): odd ^= arr[i] < arr[j] m = int(f.readline()) while m: l, r = map(int, f.readline().strip().split()) x = r - l + 1 odd ^= (x * (x - 1) >> 1) % 2 if ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL ...
A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and a_{i} < a_{j}. For example, a permutation [4, 1, 3, 2] contains 4 inversions: (2, 1), (3, 1), (4, 1), (4, 3). You are given...
from sys import stdin n = int(stdin.readline()) a = [int(o) for o in stdin.readline().split()] inv = len([(1) for i in range(n) for j in range(i + 1, n) if a[i] > a[j]]) ans = inv % 2 m = int(stdin.readline()) for i in range(m): line = stdin.readline().split() l = int(line[0]) r = int(line[1]) v = (r -...
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 NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL...
A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and a_{i} < a_{j}. For example, a permutation [4, 1, 3, 2] contains 4 inversions: (2, 1), (3, 1), (4, 1), (4, 3). You are given...
import sys class fenwick: def __init__(self, n): self.n = n self.data = [0] * (n + 1) def to_sum(self, i): s = 0 while i > 0: s += self.data[i] i -= i & -i return s def add(self, i, x): while i <= self.n: self.data[i] +...
IMPORT CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR VAR VAR BIN_OP VAR VAR RETURN VAR FUNC_DEF WHILE VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR FUNC_DEF RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_DEF RETURN FU...
A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and a_{i} < a_{j}. For example, a permutation [4, 1, 3, 2] contains 4 inversions: (2, 1), (3, 1), (4, 1), (4, 3). You are given...
import sys f = sys.stdin n = int(f.readline()) a = [int(x) for x in f.readline().split()] t = [0] * (n + 1) p = [1] * (n + 1) for i in range(2, n + 1, 2): p[i] = 2 * p[i // 2] good = 0 for x in a: i = x while i > 0: good += t[i] i -= p[i] i = x while i <= n: t[i] += 1 ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP NUMBER VAR BIN_OP VAR NUMBER A...
A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and a_{i} < a_{j}. For example, a permutation [4, 1, 3, 2] contains 4 inversions: (2, 1), (3, 1), (4, 1), (4, 3). You are given...
n = int(input()) a = list(map(int, input().split())) pf = [0] for i in range(n): k = a[i] inv = 0 for j in range(i): if a[j] > a[i]: inv += 1 pf.append(inv + pf[-1]) ans = pf[-1] % 2 asss = [] m = int(input()) cs = [(i * (i - 1) // 2 % 2) for i in range(1501)] for _ in range(m): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NU...
A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and a_{i} < a_{j}. For example, a permutation [4, 1, 3, 2] contains 4 inversions: (2, 1), (3, 1), (4, 1), (4, 3). You are given...
def solve(): n = int(input()) a = list(map(int, input().split())) cl = ["odd", "even"] m = int(input()) ans = True b = [] ap = b.append for i in range(n): for j in range(i): if a[j] > a[i]: ans = not ans for i in range(m): left, right = map...
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 LIST STRING STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR F...
A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and a_{i} < a_{j}. For example, a permutation [4, 1, 3, 2] contains 4 inversions: (2, 1), (3, 1), (4, 1), (4, 3). You are given...
import sys input = sys.stdin.readline def getsum(BITTree, i): i = i + 1 s = 0 while i > 0: s += BITTree[i] i -= i & -i return s def updatebit(BITTree, n, i, v): i = i + 1 while i <= n: BITTree[i] += v i += i & -i n = int(input()) lista = [int(i) for i in in...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR VAR VAR BIN_OP VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSI...
A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and a_{i} < a_{j}. For example, a permutation [4, 1, 3, 2] contains 4 inversions: (2, 1), (3, 1), (4, 1), (4, 3). You are given...
import sys f = sys.stdin n = int(f.readline()) a = list(map(int, f.readline().split())) cnt = 0 for i in range(n): cnt += sum([(1) for x in a[i + 1 :] if x < a[i]]) m = int(f.readline()) for _ in range(m): l, r = list(map(int, f.readline().split())) c = r - l cnt += c * (c + 1) // 2 % 2 if cnt % 2 ...
IMPORT ASSIGN 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 NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_...
A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and a_{i} < a_{j}. For example, a permutation [4, 1, 3, 2] contains 4 inversions: (2, 1), (3, 1), (4, 1), (4, 3). You are given...
from sys import stdin, stdout input = stdin.readline print = stdout.write n = int(input()) (*a,) = map(int, input().split()) p = 0 for i in range(n): for j in range(i + 1, n): if a[i] > a[j]: p ^= 1 m = int(input()) for i in range(m): l, r = map(int, input().split()) k = r - l + 1 k...
ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ...
A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and a_{i} < a_{j}. For example, a permutation [4, 1, 3, 2] contains 4 inversions: (2, 1), (3, 1), (4, 1), (4, 3). You are given...
from sys import stdin, stdout input, print = stdin.readline, stdout.write n = int(input()) a = [int(i) for i in input().split()] ans = 0 for i in range(n): for j in range(i + 1, n): ans += int(a[i] > a[j]) ans %= 2 q = int(input()) for i in range(q): l, r = [int(i) for i in input().split()] ans ^= ...
ASSIGN VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASS...
A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and a_{i} < a_{j}. For example, a permutation [4, 1, 3, 2] contains 4 inversions: (2, 1), (3, 1), (4, 1), (4, 3). You are given...
def main(): n = int(input()) a = list(map(int, input().split())) cnt = 0 for i in range(n): for j in range(i + 1, n): if a[i] > a[j]: cnt += 1 even = cnt % 2 == 0 q = int(input()) ans = [] for _ in range(q): l, r = map(int, input().split()) ...
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 NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR L...
A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and a_{i} < a_{j}. For example, a permutation [4, 1, 3, 2] contains 4 inversions: (2, 1), (3, 1), (4, 1), (4, 3). You are given...
def pflag(flag): if flag: return "odd" else: return "even" n = int(input()) arr = list(map(int, input().split())) m = int(input()) flag = False count = 0 for i in range(n - 1): for j in range(i + 1, n): if arr[j] < arr[i]: count += 1 if count % 2 == 0: flag = False ...
FUNC_DEF IF VAR RETURN STRING RETURN STRING 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 FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR ...
A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and a_{i} < a_{j}. For example, a permutation [4, 1, 3, 2] contains 4 inversions: (2, 1), (3, 1), (4, 1), (4, 3). You are given...
import sys n = int(input()) a = [int(i) for i in input().split(" ")] m = int(input()) inversion = 0 for i in range(n): for j in range(i + 1, n): if a[i] > a[j]: inversion += 1 if inversion % 2: even = False else: even = True lines = sys.stdin.readlines() for k in range(m): q = tuple...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUM...
A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and a_{i} < a_{j}. For example, a permutation [4, 1, 3, 2] contains 4 inversions: (2, 1), (3, 1), (4, 1), (4, 3). You are given...
N = int(input()) A = list(map(int, input().split())) M = int(input()) Q = [input().split() for m in range(M)] def solve(): count = 0 for i in range(N): for j in range(i): if A[i] < A[j]: count += 1 count %= 2 res = [] for q in Q: l, r = q ...
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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER VAR NUMBE...
A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and a_{i} < a_{j}. For example, a permutation [4, 1, 3, 2] contains 4 inversions: (2, 1), (3, 1), (4, 1), (4, 3). You are given...
n = int(input()) a = list(map(int, input().split())) m = int(input()) parity = 0 for i in range(n): for j in range(i + 1, n): if a[i] > a[j]: parity ^= 1 res = [] for _ in range(m): l, r = map(int, input().split()) s = r - l + 1 parity ^= s * (s - 1) // 2 % 2 res.append("odd" if ...
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 FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR VAR VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ...
A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and a_{i} < a_{j}. For example, a permutation [4, 1, 3, 2] contains 4 inversions: (2, 1), (3, 1), (4, 1), (4, 3). You are given...
n = int(input()) nums = [int(a) for a in input().strip().split()] counts = 0 for i in range(n - 1): for j in range(i + 1, n): if nums[i] > nums[j]: counts += 1 ans = counts % 2 ans_tmp = [] m = int(input()) for i in range(m): l, r = [int(a) for a in input().strip().split()] tmp = r - l +...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VA...
A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and a_{i} < a_{j}. For example, a permutation [4, 1, 3, 2] contains 4 inversions: (2, 1), (3, 1), (4, 1), (4, 3). You are given...
import sys readline = sys.stdin.readline N = int(readline()) A = list(map(int, readline().split())) Q = int(readline()) cnt = 0 for i in range(N): for j in range(i + 1, N): if A[i] > A[j]: cnt += 1 cnt %= 2 Ans = [None] * Q for qu in range(Q): l, r = map(int, readline().split()) if (r -...
IMPORT ASSIGN 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 FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP LIST N...
A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and a_{i} < a_{j}. For example, a permutation [4, 1, 3, 2] contains 4 inversions: (2, 1), (3, 1), (4, 1), (4, 3). You are given...
import sys f = sys.stdin n = int(f.readline()) a = list(map(int, f.readline().split())) s = 0 for i in range(n): for j in range(i): s ^= a[j] > a[i] q = int(f.readline()) for i in range(q): l, r = map(int, f.readline().split()) s ^= (r - l + 1) * (r - l) // 2 % 2 print(["even", "odd"][s])
IMPORT ASSIGN 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 NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC...
A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and a_{i} < a_{j}. For example, a permutation [4, 1, 3, 2] contains 4 inversions: (2, 1), (3, 1), (4, 1), (4, 3). You are given...
n = int(input()) lst = [] for x in input().split(): lst.append(int(x)) m = int(input()) pair = [] for x in range(m): l, r = list(map(int, input().split())) pair.append((l, r)) k = 0 for x in range(0, len(lst) - 1): for y in range(x + 1, len(lst)): if lst[y] < lst[x]: k += 1 for l, r ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER...
One day Vasya came up to the blackboard and wrote out n distinct integers from 1 to n in some order in a circle. Then he drew arcs to join the pairs of integers (a, b) (a β‰  b), that are either each other's immediate neighbors in the circle, or there is number c, such that a and с are immediate neighbors, and b and c ar...
from sys import stdin all_in = stdin.readlines() n = int(all_in[0]) pairs = list(map(lambda x: tuple(map(int, x.split())), all_in[1:])) if n == 5: print(1, 2, 3, 4, 5) exit() neigs = {i: set() for i in range(1, n + 1)} for a, b in pairs: neigs[a].add(b) neigs[b].add(a) for el in neigs.values(): if ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR ...
Read problems statements in Mandarin Chinese , Russian and Vietnamese as well. Tic-Tac-Toe used to be Chef's favourite game during his childhood. Reminiscing in his childhood memories, he decided to create his own "Tic-Tac-Toe", with rules being similar to the original Tic-Tac-Toe, other than the fact that it is play...
from sys import stdin T = int(stdin.readline().strip()) while T > 0: [N, K] = [int(n) for n in stdin.readline().strip().split()] grid1 = [0] * N for i in range(0, N): grid1[i] = list(stdin.readline().strip()) try: for i in range(0, N): for j in range(0, N): i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR WHILE VAR NUMBER ASSIGN LIST VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUM...
Read problems statements in Mandarin Chinese , Russian and Vietnamese as well. Tic-Tac-Toe used to be Chef's favourite game during his childhood. Reminiscing in his childhood memories, he decided to create his own "Tic-Tac-Toe", with rules being similar to the original Tic-Tac-Toe, other than the fact that it is play...
T = int(input()) ops = [] for prog in range(0, T): N, K = map(int, input().split()) field = [] p1 = [1, 0, -1, 0] p2 = [0, -1, 0, 1] d1 = [1, -1, -1, 1] d2 = [-1, -1, 1, 1] for a in range(0, N): field.append(list(input())) def isFree(a, b): if a >= 0 and a < N: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMB...
Read problems statements in Mandarin Chinese , Russian and Vietnamese as well. Tic-Tac-Toe used to be Chef's favourite game during his childhood. Reminiscing in his childhood memories, he decided to create his own "Tic-Tac-Toe", with rules being similar to the original Tic-Tac-Toe, other than the fact that it is play...
def load_board(N): board = [None] * N for i in range(N): board[i] = input() return board def is_chef_winner(board, K): N = len(board) for row in range(N): for col in range(N): if board[row][col] == ".": h_num_X = 1 i = col - 1 ...
FUNC_DEF ASSIGN VAR BIN_OP LIST NONE VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR VAR VAR STRING VAR NUMBER VAR NUM...
A prime number is Super Prime if it is a sum of two primes. Find all the Super Primes upto N Example 1: Input: N = 5 Output: 1 Explanation: 5 = 2 + 3, 5 is the only super prime Example 2: Input: N = 10 Output: 2 Explanation: 5 and 7 are super primes Your Task: You don't need to read input or print anything. Your tas...
class Solution: def superPrimes(self, n): p = [0] * (n + 1) count = 0 for i in range(2, int(n**0.5) + 1): if p[i] == 0: for j in range(i * i, n + 1, i): p[j] = 1 for i in range(5, n + 1): if p[i] == 0 and p[i - 2] == 0: ...
CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR NUM...
A prime number is Super Prime if it is a sum of two primes. Find all the Super Primes upto N Example 1: Input: N = 5 Output: 1 Explanation: 5 = 2 + 3, 5 is the only super prime Example 2: Input: N = 10 Output: 2 Explanation: 5 and 7 are super primes Your Task: You don't need to read input or print anything. Your tas...
N = 10**5 + 5 prime = [0] * N prime[0] = 1 prime[1] = 1 p = [] for i in range(2, N): if prime[i] != 0: continue for j in range(i * 2, N, i): prime[j] = 1 if prime[i] == 0: p.append(i) class Solution: def superPrimes(self, n): c = 0 for j in p: if j ...
ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR NUMBER IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR CLASS_DEF FU...
A prime number is Super Prime if it is a sum of two primes. Find all the Super Primes upto N Example 1: Input: N = 5 Output: 1 Explanation: 5 = 2 + 3, 5 is the only super prime Example 2: Input: N = 10 Output: 2 Explanation: 5 and 7 are super primes Your Task: You don't need to read input or print anything. Your tas...
class Solution: def superPrimes(self, n): count = 0 primes = [True] * (n + 1) primes[0] = primes[1] = False for i in range(2, n + 1): if primes[i]: if primes[i - 2]: count += 1 for j in range(i * i, n + 1, i): ...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR IF VAR BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER RETURN VAR
A prime number is Super Prime if it is a sum of two primes. Find all the Super Primes upto N Example 1: Input: N = 5 Output: 1 Explanation: 5 = 2 + 3, 5 is the only super prime Example 2: Input: N = 10 Output: 2 Explanation: 5 and 7 are super primes Your Task: You don't need to read input or print anything. Your tas...
class Solution: def superPrimes(self, n): aux = [True] * (n + 1) aux[0] = False aux[1] = False prime = [] ans = 0 for i in range(2, n + 1): if aux[i]: prime.append(i) for j in range(i * i, n + 1, i): aux...
CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER FOR VAR...
A prime number is Super Prime if it is a sum of two primes. Find all the Super Primes upto N Example 1: Input: N = 5 Output: 1 Explanation: 5 = 2 + 3, 5 is the only super prime Example 2: Input: N = 10 Output: 2 Explanation: 5 and 7 are super primes Your Task: You don't need to read input or print anything. Your tas...
class Solution: def superPrimes(self, n): prime = [(True) for i in range(n + 1)] p = 2 while p * p <= n: if prime[p] == True: for i in range(p * p, n + 1, p): prime[i] = False p += 1 last = 3 count = 0 for p...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR ...
A prime number is Super Prime if it is a sum of two primes. Find all the Super Primes upto N Example 1: Input: N = 5 Output: 1 Explanation: 5 = 2 + 3, 5 is the only super prime Example 2: Input: N = 10 Output: 2 Explanation: 5 and 7 are super primes Your Task: You don't need to read input or print anything. Your tas...
def seive(n): n += 5 arr = [1] * n arr[0] = arr[1] = 0 for i in range(2, n): if arr[i] == 0: continue for j in range(i * i, n, i): arr[j] = 0 return arr class Solution: def superPrimes(self, n): arr = seive(n) m = len(arr) ans = ...
FUNC_DEF VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR NUMBER RETURN VAR CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VA...
A prime number is Super Prime if it is a sum of two primes. Find all the Super Primes upto N Example 1: Input: N = 5 Output: 1 Explanation: 5 = 2 + 3, 5 is the only super prime Example 2: Input: N = 10 Output: 2 Explanation: 5 and 7 are super primes Your Task: You don't need to read input or print anything. Your tas...
class Solution: def superPrimes(self, n): ans = 0 primes = [(True) for i in range(n + 1)] def prime(n): i = 2 primes[0] = False primes[1] = False while i * i <= n: if primes[i] == True: for k in range(i + i...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER WHILE BIN_OP VAR VAR VAR IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VA...
A prime number is Super Prime if it is a sum of two primes. Find all the Super Primes upto N Example 1: Input: N = 5 Output: 1 Explanation: 5 = 2 + 3, 5 is the only super prime Example 2: Input: N = 10 Output: 2 Explanation: 5 and 7 are super primes Your Task: You don't need to read input or print anything. Your tas...
class Solution: def superPrimes(self, n): if n == 5: return 1 def p(N): if N <= 2: return [] is_prime = [True] * N is_prime[0] = False is_prime[1] = False for i in range(2, int(N**0.5) + 1): if ...
CLASS_DEF FUNC_DEF IF VAR NUMBER RETURN NUMBER FUNC_DEF IF VAR NUMBER RETURN LIST ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR NUMBER R...
A prime number is Super Prime if it is a sum of two primes. Find all the Super Primes upto N Example 1: Input: N = 5 Output: 1 Explanation: 5 = 2 + 3, 5 is the only super prime Example 2: Input: N = 10 Output: 2 Explanation: 5 and 7 are super primes Your Task: You don't need to read input or print anything. Your tas...
class Solution: def superPrimes(self, n): def check(n): seive = [True] * (n + 1) seive[0], seive[1] = False, False p = 2 while p * p <= n: if seive[p] == True: for i in range(p * p, n + 1, p): seive...
CLASS_DEF FUNC_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CAL...
A prime number is Super Prime if it is a sum of two primes. Find all the Super Primes upto N Example 1: Input: N = 5 Output: 1 Explanation: 5 = 2 + 3, 5 is the only super prime Example 2: Input: N = 10 Output: 2 Explanation: 5 and 7 are super primes Your Task: You don't need to read input or print anything. Your tas...
class Solution: def prime(self, n): x = [(True) for i in range(n + 1)] p = 2 while p <= n: if x[p] == True: for i in range(p * p, n + 1, p): x[i] = False p += 1 y = [] for i in range(2, n + 1): if x[i]: ...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR RETURN V...
A prime number is Super Prime if it is a sum of two primes. Find all the Super Primes upto N Example 1: Input: N = 5 Output: 1 Explanation: 5 = 2 + 3, 5 is the only super prime Example 2: Input: N = 10 Output: 2 Explanation: 5 and 7 are super primes Your Task: You don't need to read input or print anything. Your tas...
def Soe(n): prime = [(True) for i in range(n + 1)] p = 2 while p * p <= n: if prime[p] == True: for i in range(p * p, n + 1, p): prime[i] = False p += 1 return prime class Solution: def superPrimes(self, n): if n < 5: return 0 ...
FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER VAR NUMBER RETURN VAR CLASS_DEF FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER...
A prime number is Super Prime if it is a sum of two primes. Find all the Super Primes upto N Example 1: Input: N = 5 Output: 1 Explanation: 5 = 2 + 3, 5 is the only super prime Example 2: Input: N = 10 Output: 2 Explanation: 5 and 7 are super primes Your Task: You don't need to read input or print anything. Your tas...
class Solution: def superPrimes(self, n): def makeprime(N): visited = [1] * (N + 1) primes = {} for i in range(2, N + 1): if visited[i] == 1: primes[i] = 1 for j in range(i + i, N + 1, i): v...
CLASS_DEF FUNC_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FO...
A prime number is Super Prime if it is a sum of two primes. Find all the Super Primes upto N Example 1: Input: N = 5 Output: 1 Explanation: 5 = 2 + 3, 5 is the only super prime Example 2: Input: N = 10 Output: 2 Explanation: 5 and 7 are super primes Your Task: You don't need to read input or print anything. Your tas...
class Solution: def superPrimes(self, n): if n < 5: return 0 if n < 7: return 1 count = 1 a = 7 while a <= n: if self.isPrime(a) and self.isPrime(a - 2): count += 1 a += 6 return count def isPrime(s...
CLASS_DEF FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER IF BIN_OP VAR NUMBER NUMBER RETUR...
A prime number is Super Prime if it is a sum of two primes. Find all the Super Primes upto N Example 1: Input: N = 5 Output: 1 Explanation: 5 = 2 + 3, 5 is the only super prime Example 2: Input: N = 10 Output: 2 Explanation: 5 and 7 are super primes Your Task: You don't need to read input or print anything. Your tas...
class Solution: def superPrimes(self, n): primes = [] p = 2 vals = [val for val in range(0, n + 1)] bools = [(False) for item in range(0, n + 1)] count = 0 while p <= int(n ** (1 / 2)): if bools[p] == False: for i in range(2 * p, n + 1, p)...
CLASS_DEF FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER NUMBER IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR BIN_OP VAR NUMBE...
A prime number is Super Prime if it is a sum of two primes. Find all the Super Primes upto N Example 1: Input: N = 5 Output: 1 Explanation: 5 = 2 + 3, 5 is the only super prime Example 2: Input: N = 10 Output: 2 Explanation: 5 and 7 are super primes Your Task: You don't need to read input or print anything. Your tas...
class Solution: def is_prime(self, num): end = int(num**0.5) for i in range(7, end + 1, 2): if num % i == 0: return False return True def superPrimes(self, n): if n < 5: return 0 if n == 5: return 1 if n == 7: ...
CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR N...
A prime number is Super Prime if it is a sum of two primes. Find all the Super Primes upto N Example 1: Input: N = 5 Output: 1 Explanation: 5 = 2 + 3, 5 is the only super prime Example 2: Input: N = 10 Output: 2 Explanation: 5 and 7 are super primes Your Task: You don't need to read input or print anything. Your tas...
class Solution: def superPrimes(self, n): p = [1] * (n + 1) for i in range(2, (n + 1) // 2): if p[i]: j = 2 while i * j < n + 1: p[i * j] = 0 j += 1 c = 0 for i in range(5, n + 1): if p[i...
CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR ...
A prime number is Super Prime if it is a sum of two primes. Find all the Super Primes upto N Example 1: Input: N = 5 Output: 1 Explanation: 5 = 2 + 3, 5 is the only super prime Example 2: Input: N = 10 Output: 2 Explanation: 5 and 7 are super primes Your Task: You don't need to read input or print anything. Your tas...
from itertools import combinations as c class Solution: def isPrime(self, x): for i in range(2, x): if x % i == 0: return False return True def superPrimes(self, n): ans = 0 primes = [(True) for i in range(n + 1)] def prime(n): ...
CLASS_DEF FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER WHILE BIN_OP VAR VAR VAR IF VAR VAR NUMBER FOR VAR FUNC_C...
A prime number is Super Prime if it is a sum of two primes. Find all the Super Primes upto N Example 1: Input: N = 5 Output: 1 Explanation: 5 = 2 + 3, 5 is the only super prime Example 2: Input: N = 10 Output: 2 Explanation: 5 and 7 are super primes Your Task: You don't need to read input or print anything. Your tas...
class Solution: m = 10**5 sieve = [(True) for i in range(m + 1)] for i in range(2, m + 1): if sieve[i]: for j in range(i * i, m + 1, i): sieve[j] = False def superPrimes(self, n): l = [] for i in range(2, n + 1): if self.sieve[i]: ...
CLASS_DEF ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR EX...
A prime number is Super Prime if it is a sum of two primes. Find all the Super Primes upto N Example 1: Input: N = 5 Output: 1 Explanation: 5 = 2 + 3, 5 is the only super prime Example 2: Input: N = 10 Output: 2 Explanation: 5 and 7 are super primes Your Task: You don't need to read input or print anything. Your tas...
class Solution: def superPrimes(self, n): a = [(True) for i in range(n + 1)] a[0] = False a[1] = False for i in range(2, n + 1): if a[i]: for j in range(i * 2, n + 1, i): a[j] = False c = 0 for i in range(2, n - 1): ...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP V...
A prime number is Super Prime if it is a sum of two primes. Find all the Super Primes upto N Example 1: Input: N = 5 Output: 1 Explanation: 5 = 2 + 3, 5 is the only super prime Example 2: Input: N = 10 Output: 2 Explanation: 5 and 7 are super primes Your Task: You don't need to read input or print anything. Your tas...
class Solution: def superPrimes(self, n): p = [True] * (n + 1) if n <= 2: return 0 for i in range(2, int(n**0.5) + 1): if p[i]: for j in range(i * 2, n + 1, i): p[j] = False c = 0 p = p[2:] for i in range(le...
CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER IF VAR NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CA...
A prime number is Super Prime if it is a sum of two primes. Find all the Super Primes upto N Example 1: Input: N = 5 Output: 1 Explanation: 5 = 2 + 3, 5 is the only super prime Example 2: Input: N = 10 Output: 2 Explanation: 5 and 7 are super primes Your Task: You don't need to read input or print anything. Your tas...
class Solution: def allPrimes(self, n): allNumbers = [(True) for i in range(0, n + 1)] for p in range(2, n + 1): if not allNumbers[p]: continue if n < p * p: break curP = 2 * p while curP <= n: allNumber...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR IF VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP NUMBER VAR WHILE VAR VAR ASSIGN VAR VAR NUMBER VAR VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_...
A prime number is Super Prime if it is a sum of two primes. Find all the Super Primes upto N Example 1: Input: N = 5 Output: 1 Explanation: 5 = 2 + 3, 5 is the only super prime Example 2: Input: N = 10 Output: 2 Explanation: 5 and 7 are super primes Your Task: You don't need to read input or print anything. Your tas...
class Solution: def superPrimes(self, n): if n < 5: return 0 if n < 7: return 1 isPrime = self.sieveOfEratosthenes(n) count = 1 for i in range(6, n + 1): if isPrime[i] and isPrime[i - 2]: count += 1 return count ...
CLASS_DEF FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER NUMBER FOR...
A prime number is Super Prime if it is a sum of two primes. Find all the Super Primes upto N Example 1: Input: N = 5 Output: 1 Explanation: 5 = 2 + 3, 5 is the only super prime Example 2: Input: N = 10 Output: 2 Explanation: 5 and 7 are super primes Your Task: You don't need to read input or print anything. Your tas...
class Solution: def superPrimes(self, n): isprime = [True] * (n + 1) isprime[0] = False isprime[1] = False total = n - 2 number = 2 primes = [] while number**2 <= n and total != 0: if isprime[number]: primes.append(number) ...
CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE BIN_OP VAR NUMBER VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR ASSIG...
A prime number is Super Prime if it is a sum of two primes. Find all the Super Primes upto N Example 1: Input: N = 5 Output: 1 Explanation: 5 = 2 + 3, 5 is the only super prime Example 2: Input: N = 10 Output: 2 Explanation: 5 and 7 are super primes Your Task: You don't need to read input or print anything. Your tas...
class Solution: def superPrimes(self, n): a = [True] * (n + 1) b = [] i = 2 while i * i <= n + 1: if a[i]: for j in range(2 * i, n + 1, i): a[j] = 0 i += 1 for i in range(2, n + 1): if a[i]: ...
CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR BIN_OP VAR NUMBER IF VAR VAR FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR VAR ASSIGN V...
A prime number is Super Prime if it is a sum of two primes. Find all the Super Primes upto N Example 1: Input: N = 5 Output: 1 Explanation: 5 = 2 + 3, 5 is the only super prime Example 2: Input: N = 10 Output: 2 Explanation: 5 and 7 are super primes Your Task: You don't need to read input or print anything. Your tas...
class Solution: def isPrime(self, n): if n < 2: return False if n == 2 or n == 3: return True if n % 2 == 0: return False if n % 3 == 0: return False limit = int(n**0.5) i = 5 t = 2 while i <= limit: ...
CLASS_DEF FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER IF BIN_OP VAR NUMBER NUMBER RETURN NUMBER IF BIN_OP VAR NUMBER NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR VAR NUMBER RETURN NUMBER VAR VAR ASSIGN VAR...
A prime number is Super Prime if it is a sum of two primes. Find all the Super Primes upto N Example 1: Input: N = 5 Output: 1 Explanation: 5 = 2 + 3, 5 is the only super prime Example 2: Input: N = 10 Output: 2 Explanation: 5 and 7 are super primes Your Task: You don't need to read input or print anything. Your tas...
class Solution: def superPrimes(self, n): if n < 5: return 0 ans = temp = left = right = 0 index = 2 arr = [0] * (n + 1) arr[2] = 1 prime = [] while index <= n: if arr[index] == -1: index += 1 else: ...
CLASS_DEF FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR LIST WHILE VAR VAR IF VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR WHILE BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER VAR NUMBER A...
A prime number is Super Prime if it is a sum of two primes. Find all the Super Primes upto N Example 1: Input: N = 5 Output: 1 Explanation: 5 = 2 + 3, 5 is the only super prime Example 2: Input: N = 10 Output: 2 Explanation: 5 and 7 are super primes Your Task: You don't need to read input or print anything. Your tas...
class Solution: def superPrimes(self, n): end = n + 1 dp = [0] * end for i in range(2, end): if dp[i] == 0: j = i + i while j < end: dp[j] = 1 j += i cnt = 0 for i in range(5, end): ...
CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR WHILE VAR VAR ASSIGN VAR VAR NUMBER VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER RETURN V...
A prime number is Super Prime if it is a sum of two primes. Find all the Super Primes upto N Example 1: Input: N = 5 Output: 1 Explanation: 5 = 2 + 3, 5 is the only super prime Example 2: Input: N = 10 Output: 2 Explanation: 5 and 7 are super primes Your Task: You don't need to read input or print anything. Your tas...
class Solution: def seive(self, n): prime = [(True) for i in range(n + 1)] p = 2 while p * p <= n: if prime[p] == True: for i in range(p * p, n + 1, p): prime[i] = False p += 1 a2 = [] for i in range(2, len(prime)):...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CAL...
A prime number is Super Prime if it is a sum of two primes. Find all the Super Primes upto N Example 1: Input: N = 5 Output: 1 Explanation: 5 = 2 + 3, 5 is the only super prime Example 2: Input: N = 10 Output: 2 Explanation: 5 and 7 are super primes Your Task: You don't need to read input or print anything. Your tas...
class Solution: def superPrimes(self, n): a = [0] * (n + 1) for i in range(2, n + 1): if a[i] == 0: for j in range(2, n // i + 1): a[i * j] = 1 arr = [] for i in range(2, n + 1): if a[i] == 0: arr.append(i) ...
CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR NUMBER EXPR FUNC_CALL V...
A prime number is Super Prime if it is a sum of two primes. Find all the Super Primes upto N Example 1: Input: N = 5 Output: 1 Explanation: 5 = 2 + 3, 5 is the only super prime Example 2: Input: N = 10 Output: 2 Explanation: 5 and 7 are super primes Your Task: You don't need to read input or print anything. Your tas...
class Solution: def prime(self, n): pri = [] for i in range(n + 1): pri.append(i) pri[0] = 0 pri[1] = 0 p = 2 while p * p <= n: if p != 0: for i in range(p * 2, n + 1, p): pri[i] = 0 p += 1 ...
CLASS_DEF FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER VAR NUMBER RETURN FUNC_CALL VAR...
A prime number is Super Prime if it is a sum of two primes. Find all the Super Primes upto N Example 1: Input: N = 5 Output: 1 Explanation: 5 = 2 + 3, 5 is the only super prime Example 2: Input: N = 10 Output: 2 Explanation: 5 and 7 are super primes Your Task: You don't need to read input or print anything. Your tas...
class Solution: def superPrimes(self, n): count = 0 arr = [(True) for i in range(n + 1)] arr[0], arr[1] = False, False p = 2 while p * p <= n: if arr[p]: for i in range(p * p, n + 1, p): arr[i] = False p += 1 ...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ...
Alice and Bob play 5-in-a-row game. They have a playing field of size 10 Γ— 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins imm...
def horizontal(mas): for i in range(len(mas) - 4): k = "" for j in range(i, i + 5): k += str(mas[j]) if k == "XXXX.": return True elif k == ".XXXX": return True elif k == "X.XXX": return True elif k == "XX.XX": ...
FUNC_DEF FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR VAR IF VAR STRING RETURN NUMBER IF VAR STRING RETURN NUMBER IF VAR STRING RETURN NUMBER IF VAR STRING RETURN NUMBER IF VAR STRING RETURN NUMBER RETURN NUMBER ASSIGN VAR LIST...
Alice and Bob play 5-in-a-row game. They have a playing field of size 10 Γ— 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins imm...
import sys input = sys.stdin.readline g = [list(input().strip()) for _ in range(10)] ans = 0 for i in range(10): for j in range(10): if g[i][j] != ".": continue g[i][j] = "X" for p in range(10): for q in range(10): if p + 4 < 10: c...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR STRING ASSIGN VAR VAR VAR STRING FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUM...
Alice and Bob play 5-in-a-row game. They have a playing field of size 10 Γ— 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins imm...
a = [(0) for i in range(10)] for i in range(10): a[i] = input() b = [[(0) for i in range(10)] for i in range(10)] f = False for x1 in range(10): for y1 in range(10): for i in range(10): for j in range(10): b[i][j] = a[i][j] if b[x1][y1] == ".": b[x1][y1] =...
ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VA...
Alice and Bob play 5-in-a-row game. They have a playing field of size 10 Γ— 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins imm...
matrix = [] for i in range(10): matrix.append(input()) def check_horizontal(matrix, x, y): misses = 0 for dy in range(5): if matrix[x][y + dy] == "O": return False if matrix[x][y + dy] == ".": misses += 1 return misses == 1 def check_diagonal(matrix, x, y): ...
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR BIN_OP VAR VAR STRING RETURN NUMBER IF VAR VAR BIN_OP VAR VAR STRING VAR NUMBER RETURN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR BIN_OP VAR VAR...
Alice and Bob play 5-in-a-row game. They have a playing field of size 10 Γ— 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins imm...
score = {"X": 1, "O": -1, ".": 0} def works(g, x, y): if x + 5 <= 10: cur = 0 for d in range(5): cur += score[g[x + d][y]] if cur >= 4: return True if y + 5 <= 10: cur = sum(score[g[x][y + d]] for d in range(5)) if cur >= 4: return Tr...
ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER FUNC_DEF IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR BIN_OP VAR VAR VAR IF VAR NUMBER RETURN NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR VAR FUNC_CALL VAR NUMBER IF VAR NUMBER ...
Alice and Bob play 5-in-a-row game. They have a playing field of size 10 Γ— 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins imm...
def list_input(): return list(map(int, input().split())) n = 10 a = list() for i in range(10): a.append(list(input())) dr = [-1, -1, 0, 1, 1, 1, 0, -1] dc = [0, 1, 1, 1, 0, -1, -1, -1] for i in range(10): for j in range(10): x = a[i][j] if x != ".": continue a[i][j] = "...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER...
Alice and Bob play 5-in-a-row game. They have a playing field of size 10 Γ— 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins imm...
def is_in_row(field): for s in field: for i in range(len(s) - 4): if s[i : i + 5].count("X") == 4 and s[i : i + 5].count(".") == 1: print("YES") return True return False def is_in_col(field): for s in ["".join(x) for x in zip(*field)]: for i in r...
FUNC_DEF FOR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR BIN_OP VAR NUMBER STRING NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER STRING NUMBER EXPR FUNC_CALL VAR STRING RETURN NUMBER RETURN NUMBER FUNC_DEF FOR VAR FUNC_CALL STRING VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP...
Alice and Bob play 5-in-a-row game. They have a playing field of size 10 Γ— 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins imm...
def check(a, b): if m[a][b] != ".": return False else: cnt = 0 p = a + 1 while p < 10 and m[p][b] == "X": p += 1 cnt += 1 p = a - 1 while p >= 0 and m[p][b] == "X": p -= 1 cnt += 1 if cnt >= 4: re...
FUNC_DEF IF VAR VAR VAR STRING RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR VAR VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR VAR VAR STRING VAR NUMBER VAR NUMBER IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VA...
Alice and Bob play 5-in-a-row game. They have a playing field of size 10 Γ— 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins imm...
def checkhor(x, y): c = 0 cy = y + 1 while cy < n and grid[x][cy] == "X": cy += 1 c += 1 if c >= 4: return True cy = y - 1 while cy >= 0 and grid[x][cy] == "X": cy -= 1 c += 1 if c >= 4: return True else: return False def checkver...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR VAR VAR STRING VAR NUMBER VAR NUMBER IF VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR VAR VAR STRING VAR NUMBER VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUM...
Alice and Bob play 5-in-a-row game. They have a playing field of size 10 Γ— 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins imm...
s = [] f = False for i in range(10): s.append(list(input())) for i in range(6): for j in range(6): a = [s[i][j], s[i][j + 1], s[i][j + 2], s[i][j + 3], s[i][j + 4]] b = [ s[i][j], s[i + 1][j + 1], s[i + 2][j + 2], s[i + 3][j + 3], s[i +...
ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST VAR VAR VAR VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER ASSIGN VAR LIST VAR ...
Alice and Bob play 5-in-a-row game. They have a playing field of size 10 Γ— 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins imm...
l = [] s = [] d = [] w = "" r = 0 for i in range(0, 10): l.append(str(input())) for i in l: for j in range(0, 6): if i[j : j + 5].count("X") == 4 and i[j : j + 5].count(".") == 1: r = 1 break if r != 1: for i in range(0, 10): for j in l: w = w + j[i] ...
ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER IF FUNC_CALL VAR VAR BIN_OP VAR NUMBER STRING NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER STRING NUMBER AS...
Alice and Bob play 5-in-a-row game. They have a playing field of size 10 Γ— 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins imm...
ar = [] for i in range(10): ar.append(input()) ans = False for i in range(10): for j in range(10): if ar[i][j] == "X": x = 1 hl = False for k in range(1, 5): if i + k == 10: break if ar[i + k][j] == "X": ...
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP VAR VAR NUMBER IF VAR BIN_OP VAR VAR VAR STRING VAR NUMBER IF ...
Alice and Bob play 5-in-a-row game. They have a playing field of size 10 Γ— 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins imm...
import sys l = ["" for i in range(10)] for i in range(10): l[i] = input() for i in range(10): for j in range(10): if j - 2 >= 0 and j + 2 < 10: s = l[i][j - 2 : j + 3] if s.count("X") == 4 and s.count("O") == 0: print("YES") sys.exit() if ...
IMPORT ASSIGN VAR STRING VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR S...
Alice and Bob play 5-in-a-row game. They have a playing field of size 10 Γ— 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins imm...
a = [] for i in range(10): a.append(input()) for i in range(6): for j in range(6): k, z = 0, 0 for x in range(5): if a[i + x][j + x] == "X": k += 1 elif a[i + x][j + x] == ".": z += 1 if k == 5 or k == 4 and z == 1: prin...
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR BIN_OP VAR VAR BIN_OP VAR VAR STRING VAR NUMBER IF VAR BIN_OP VAR VAR BIN_OP VAR VAR STRING VAR NUMBER IF VAR NUMBER VA...
Alice and Bob play 5-in-a-row game. They have a playing field of size 10 Γ— 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins imm...
s = [[c for c in input()] for i in range(10)] def win(): for i in range(10): for j in range(10): ok = True for k in range(5): if j + k > 9: ok = False elif s[i][j + k] != "X": ok = False if ok: ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR BIN_OP VAR VAR STRING ASSIGN VAR NUMBER IF VAR RETURN NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CA...
Alice and Bob play 5-in-a-row game. They have a playing field of size 10 Γ— 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins imm...
corr = lambda i, j: 0 <= i < 10 and 0 <= j < 10 def can(b): for i in range(10): for j in range(10): for t in range(4): flag = 1 for k in range(5): ni = i + dx[t] * k nj = j + dy[t] * k if not corr(ni, n...
ASSIGN VAR NUMBER VAR NUMBER NUMBER VAR NUMBER FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR VAR IF FUNC_CALL VAR VAR VAR VAR VAR VAR STRING ASSI...
Alice and Bob play 5-in-a-row game. They have a playing field of size 10 Γ— 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins imm...
def get_rows(grid): return [[c for c in r] for r in grid] def get_cols(grid): return zip(*grid) def get_backward_diagonals(grid): b = [None] * (len(grid) - 1) grid = [(b[i:] + r + b[:i]) for i, r in enumerate(get_rows(grid))] return [[c for c in r if c is not None] for r in get_cols(grid)] def...
FUNC_DEF RETURN VAR VAR VAR VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NONE BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR RETURN VAR VAR VAR VAR NONE VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NONE BIN_OP FU...
Alice and Bob play 5-in-a-row game. They have a playing field of size 10 Γ— 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins imm...
import sys field = [] for i in range(10): st = input() field.append(st) def f(): global i, i2, c, j, j2, l for i in range(10): for i2 in range(6): l = field[i][i2 : i2 + 5] if l.count("X") == 4 and l.count(".") == 1: print("YES") sys.exi...
IMPORT ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FOR VAR ...
Alice and Bob play 5-in-a-row game. They have a playing field of size 10 Γ— 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins imm...
a = [""] * 10 for i in range(10): a[i] = input() AliceWins = False for i in range(10 - 4): for j in range(10): count = 0 dot = 0 for k in range(5): if a[i + k][j] == "X": count += 1 elif a[i + k][j] == ".": dot += 1 if count...
ASSIGN VAR BIN_OP LIST STRING NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR BIN_OP VAR VAR VAR STRING VAR NUMBER IF VAR BIN_OP VAR VAR VAR ...
Alice and Bob play 5-in-a-row game. They have a playing field of size 10 Γ— 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins imm...
a = ["$" * 12] for i in range(10): a.append(list("$" + input() + "$")) a.append("$" * 12) flag = False def count(r, c, dr, dc): k = 0 while a[r][c] == "X": r, c = r + dr, c + dc k += 1 return k for r in range(1, 11): for c in range(1, 11): if a[r][c] == ".": h...
ASSIGN VAR LIST BIN_OP STRING NUMBER FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP STRING FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP STRING NUMBER ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR VAR STRING ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR VAR NUMBER RETURN VAR FO...
Alice and Bob play 5-in-a-row game. They have a playing field of size 10 Γ— 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins imm...
mat = [] for i in range(10): li = list(input()) mat.append(li) d = [(1, 0), (0, 1), (1, 1), (1, -1)] for i in range(10): for j in range(10): for dx, dy in d: c = 0 t = 0 for k in range(5): row = i + dx * k col = j + dy * k ...
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER AS...
Alice and Bob play 5-in-a-row game. They have a playing field of size 10 Γ— 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins imm...
t = [([-1] * 12) for i in range(12)] for i in range(1, 11): s = input() for j in range(1, 11): if s[j - 1] == ".": t[i][j] = 0 elif s[j - 1] == "X": t[i][j] = 1 c = False for x in range(1, 11): for y in range(1, 11): if t[x][y] == 0: t[x][y] = 1 ...
ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBE...
Alice and Bob play 5-in-a-row game. They have a playing field of size 10 Γ— 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins imm...
def is_win(x): if x.count("X") == 4 and x.count(".") == 1: return True else: return False def solve(L): for x in L: for j in range(6): if is_win(x[j : j + 5]): return "YES" LT = [] for i in range(10): s = "" for j in range(10): ...
FUNC_DEF IF FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF FOR VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER RETURN STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR EXPR FUNC...
Alice and Bob play 5-in-a-row game. They have a playing field of size 10 Γ— 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins imm...
rs = [] for i in range(10): length = input() rs.append(length) temp1 = 1 flag1 = 1 def check(i, j, direct, temp, flag): if direct == 1: if j == 0: return 0 j -= 1 elif direct == 2: if j == 9: return 0 j += 1 elif direct == 3: if i == ...
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF IF VAR NUMBER IF VAR NUMBER RETURN NUMBER VAR NUMBER IF VAR NUMBER IF VAR NUMBER RETURN NUMBER VAR NUMBER IF VAR NUMBER IF VAR NUMBER RETURN NUMBER VAR NUMBER IF VAR NUMBER IF VAR NU...
Alice and Bob play 5-in-a-row game. They have a playing field of size 10 Γ— 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins imm...
import sys dx = [0, 1, 1, 1] dy = [1, 1, 0, -1] range_x = set(range(10)) range_y = set(range(10)) def is_win(board): for i in range(10): for j in range(10): for dir in range(len(dx)): for k in range(5): new_x = i + k * dx[dir] new_y = j ...
IMPORT ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMB...
Alice and Bob play 5-in-a-row game. They have a playing field of size 10 Γ— 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins imm...
field = [] for i in range(10): s = input().strip() field.append(list(s)) def check(i, j): ti = i tj = j if i + 4 < 10: tics = set() for it in range(5): tics.add(field[ti][tj]) ti += 1 if len(tics) == 1: return True ti = i tj = j ...
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER RETURN NUMBE...
Alice and Bob play 5-in-a-row game. They have a playing field of size 10 Γ— 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins imm...
m = [] for i in range(10): s = input() m.append(s) for i in range(10): for j in range(6): s = "" s += m[i][j] + m[i][j + 1] + m[i][j + 2] + m[i][j + 3] + m[i][j + 4] if s.count("X") == 4 and s.count("O") == 0: print("YES") exit() for i in range(10): for j ...
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR STRING VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER IF ...
Alice and Bob play 5-in-a-row game. They have a playing field of size 10 Γ— 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins imm...
A = [list(input()) for i in range(10)] for i in range(10): A[i] += ["O"] * 5 for i in range(5): A.insert(0, ["O"] * 15) A.append(["O"] * 15) D = [(1, 0), (0, 1), (1, 1), (-1, 1)] flag = False for i in range(5, 15): for j in range(10): if ( A[i][j] == "X" or A[i][j + 1] ==...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP LIST STRING NUMBER FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER BIN_OP LIST STRING NUMBER EXPR FUNC_CALL VAR BIN_OP LIST STRING NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NU...
Alice and Bob play 5-in-a-row game. They have a playing field of size 10 Γ— 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins imm...
N = 10 patterns = [".XXXX", "XXXX.", "XX.XX", "XXX.X", "X.XXX"] def game(s): cols = [[] for _ in range(N)] rows = [[] for _ in range(N)] fdiag = [[] for _ in range(N + N - 1)] bdiag = [[] for _ in range(len(fdiag))] min_bdiag = -N + 1 for y in range(N): for x in range(N): c...
ASSIGN VAR NUMBER ASSIGN VAR LIST STRING STRING STRING STRING STRING FUNC_DEF ASSIGN VAR LIST VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR ...
Alice and Bob play 5-in-a-row game. They have a playing field of size 10 Γ— 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins imm...
input_data_set1 = [input() for s in range(0, 10)] patterns = [".XXXX", "X.XXX", "XX.XX", "XXX.X", "XXXX."] def check_data_set(data_set, patterns): win_flag = "NO" for row in data_set: for pattern in patterns: if row.find(pattern) != -1: win_flag = "YES" return win_flag ...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR LIST STRING STRING STRING STRING STRING FUNC_DEF ASSIGN VAR STRING FOR VAR VAR FOR VAR VAR IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING RETURN VAR FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING E...
Alice and Bob play 5-in-a-row game. They have a playing field of size 10 Γ— 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins imm...
import sys def solve1(i, j, bool1, bool2): cnt0 = 0 cnt1 = 0 u = 0 v = 0 for k in range(1, 11): if bool1: u = k if bool2: v = k if not (0 <= i + u < 10 and 0 <= j + v < 10): break elif s[i + u][j + v] == "X": cnt0 += 1...
IMPORT FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR ASSIGN VAR VAR IF VAR ASSIGN VAR VAR IF NUMBER BIN_OP VAR VAR NUMBER NUMBER BIN_OP VAR VAR NUMBER IF VAR BIN_OP VAR VAR BIN_OP VAR VAR STRING VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ...
Alice and Bob play 5-in-a-row game. They have a playing field of size 10 Γ— 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins imm...
s = 10 * [0] for i in range(10): s[i] = input() def trav(i, j, s, n): if n == 1: if i < 9: if s[i + 1][j] == "X": return 1 + trav(i + 1, j, s, n) return 0 return 0 if n == -1: if i > 0: if s[i - 1][j] == "X": retur...
ASSIGN VAR BIN_OP NUMBER LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_DEF IF VAR NUMBER IF VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR STRING RETURN BIN_OP NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR RETURN NUMBER RETURN NUMBER IF VAR NUMBER IF VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR ST...