description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
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())) t = True tan1 = 99999999 tan = [] pos = [] c = 0 k = True for i in range(1, n): temp = (a[i] - a[0]) / i if t: for j in range(len(tan)): if tan[j] == temp: pos.remove(pos[j]) c -= 1 tan1 = te...
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 ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR NUMBER VAR IF 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()) l = [int(i) for i in input().split()] slope = (l[n - 1] - l[0]) / (n - 1) f = 0 for j in range(1, n - 1): if (l[j] - l[0]) / j != slope: f = 1 break if f == 0: print("No") else: flag = 0 for i in range(1, n - 1): s = (l[i] - l[0]) / i l1 = [] for ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR VAR VAR NUMBER VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER EXPR FU...
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 is_belong(A, C, x, y): return A * x + y + C == 0 def solution(): n = int(input()) a = [int(i) for i in input().split()] other_pointes_indexes = [] for k in [0, 1]: for i in range(1, n): if k == i: continue A = 0 if k - i != 0: ...
FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP ...
Given a sorted array A[] of N positive integers having all the numbers occurring exactly twice, except for one number which will occur only once. Find the number occurring only once. Example 1: Input: N = 5 A = {1, 1, 2, 5, 5} Output: 2 Explanation: Since 2 occurs once, while other numbers occur twice, 2 is the answe...
class Solution: def search(self, A, N): has = {} for a in A: if a in has: has[a] += 1 else: has[a] = 1 for key in has: if has[key] == 1: return key
CLASS_DEF FUNC_DEF ASSIGN VAR DICT FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR IF VAR VAR NUMBER RETURN VAR
Given a sorted array A[] of N positive integers having all the numbers occurring exactly twice, except for one number which will occur only once. Find the number occurring only once. Example 1: Input: N = 5 A = {1, 1, 2, 5, 5} Output: 2 Explanation: Since 2 occurs once, while other numbers occur twice, 2 is the answe...
class Solution: def search(self, A, N): dct = {} for i in A: if i in dct: dct[i] += 1 else: dct[i] = 1 output = [] for i in dct: if dct[i] == 1: output.append(i) result = ",".join(str(i) for ...
CLASS_DEF FUNC_DEF ASSIGN VAR DICT FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR RETURN VAR
Given a sorted array A[] of N positive integers having all the numbers occurring exactly twice, except for one number which will occur only once. Find the number occurring only once. Example 1: Input: N = 5 A = {1, 1, 2, 5, 5} Output: 2 Explanation: Since 2 occurs once, while other numbers occur twice, 2 is the answe...
class Solution: def search(self, A, N): d = {} for i in A: d[i] = d.get(i, 0) + 1 for k, v in d.items(): if v == 1: return k
CLASS_DEF FUNC_DEF ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR IF VAR NUMBER RETURN VAR
Given a sorted array A[] of N positive integers having all the numbers occurring exactly twice, except for one number which will occur only once. Find the number occurring only once. Example 1: Input: N = 5 A = {1, 1, 2, 5, 5} Output: 2 Explanation: Since 2 occurs once, while other numbers occur twice, 2 is the answe...
class Solution: def search(self, a, N): zero = 0 one = 1 while zero < N: if one < N and a[zero] == a[one]: zero += 2 one += 2 else: return a[zero]
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER RETURN VAR VAR
Given a sorted array A[] of N positive integers having all the numbers occurring exactly twice, except for one number which will occur only once. Find the number occurring only once. Example 1: Input: N = 5 A = {1, 1, 2, 5, 5} Output: 2 Explanation: Since 2 occurs once, while other numbers occur twice, 2 is the answe...
class Solution(object): def search1(self, nums, N): index = 0 while index < N: if index + 1 < N and nums[index] == nums[index + 1]: index += 2 else: break return nums[index] def search(self, nums, N): xor = 0 for n...
CLASS_DEF VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR VAR VAR RETURN VAR
Given a sorted array A[] of N positive integers having all the numbers occurring exactly twice, except for one number which will occur only once. Find the number occurring only once. Example 1: Input: N = 5 A = {1, 1, 2, 5, 5} Output: 2 Explanation: Since 2 occurs once, while other numbers occur twice, 2 is the answe...
class Solution: def search(self, A, N): d = {} for i in A: if i not in d: d[i] = 1 else: d[i] += 1 lst = list(d.values()) lst1 = list(d.keys()) for i in range(len(lst)): if lst[i] == 1: retur...
CLASS_DEF FUNC_DEF ASSIGN VAR DICT FOR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER RETURN VAR VAR
Given a sorted array A[] of N positive integers having all the numbers occurring exactly twice, except for one number which will occur only once. Find the number occurring only once. Example 1: Input: N = 5 A = {1, 1, 2, 5, 5} Output: 2 Explanation: Since 2 occurs once, while other numbers occur twice, 2 is the answe...
class Solution: def search(self, A, N): marker = -1 for i in A: if marker == -1: marker = i elif marker == i: marker = -1 elif marker != -1 and marker != i: return marker return marker
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER ASSIGN VAR VAR IF VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR VAR RETURN VAR RETURN VAR
Given a sorted array A[] of N positive integers having all the numbers occurring exactly twice, except for one number which will occur only once. Find the number occurring only once. Example 1: Input: N = 5 A = {1, 1, 2, 5, 5} Output: 2 Explanation: Since 2 occurs once, while other numbers occur twice, 2 is the answe...
class Solution: def search(self, A, n): i, x = 0, 1 while x < n: if i != x and A[i] ^ A[x] == 0: i = x + 1 x += 1 return A[i]
CLASS_DEF FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER WHILE VAR VAR IF VAR VAR BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR VAR
Given a sorted array A[] of N positive integers having all the numbers occurring exactly twice, except for one number which will occur only once. Find the number occurring only once. Example 1: Input: N = 5 A = {1, 1, 2, 5, 5} Output: 2 Explanation: Since 2 occurs once, while other numbers occur twice, 2 is the answe...
class Solution: def search(self, A, N): def helper(A, low, high): if low > high: return None if low == high: return A[low] m = low + (high - low) // 2 if m % 2 == 0: if A[m] == A[m + 1]: ret...
CLASS_DEF FUNC_DEF FUNC_DEF IF VAR VAR RETURN NONE IF VAR VAR RETURN VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER RETURN FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR RETURN FUNC_CALL VAR VAR VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER RETURN FUNC_CALL V...
Given a sorted array A[] of N positive integers having all the numbers occurring exactly twice, except for one number which will occur only once. Find the number occurring only once. Example 1: Input: N = 5 A = {1, 1, 2, 5, 5} Output: 2 Explanation: Since 2 occurs once, while other numbers occur twice, 2 is the answe...
class Solution: def search(self, A, N): N = len(A) low = 0 high = N - 1 while low < high: mid = low + high >> 1 if mid % 2 != 0: if A[mid] == A[mid - 1]: low = mid + 1 else: high = mid - ...
CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP V...
Given a sorted array A[] of N positive integers having all the numbers occurring exactly twice, except for one number which will occur only once. Find the number occurring only once. Example 1: Input: N = 5 A = {1, 1, 2, 5, 5} Output: 2 Explanation: Since 2 occurs once, while other numbers occur twice, 2 is the answe...
class Solution: def search(self, A, N): sum = 0 sum1 = 0 for i in range(0, N): sum += A[i] s = set(A) for i in s: sum1 += i res = 2 * sum1 - sum return res
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR RETURN VAR
Given a sorted array A[] of N positive integers having all the numbers occurring exactly twice, except for one number which will occur only once. Find the number occurring only once. Example 1: Input: N = 5 A = {1, 1, 2, 5, 5} Output: 2 Explanation: Since 2 occurs once, while other numbers occur twice, 2 is the answe...
class Solution: def search(self, A, N): for i in range(0, N, 2): if i == N - 1: return A[i] if A[i] != A[i + 1]: return A[i] return 0
CLASS_DEF FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER RETURN VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER RETURN VAR VAR RETURN NUMBER
Given a sorted array A[] of N positive integers having all the numbers occurring exactly twice, except for one number which will occur only once. Find the number occurring only once. Example 1: Input: N = 5 A = {1, 1, 2, 5, 5} Output: 2 Explanation: Since 2 occurs once, while other numbers occur twice, 2 is the answe...
class Solution: def search(self, A, N): i = 0 while i < N - 1: if A[i] == A[i + 1]: i += 2 else: return A[i] return A[-1]
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR VAR RETURN VAR NUMBER
Given a sorted array A[] of N positive integers having all the numbers occurring exactly twice, except for one number which will occur only once. Find the number occurring only once. Example 1: Input: N = 5 A = {1, 1, 2, 5, 5} Output: 2 Explanation: Since 2 occurs once, while other numbers occur twice, 2 is the answe...
class Solution: def search(self, A, N): start = 0 end = N - 1 while start < end: mid = (end + start) // 2 if mid % 2 == 1: mid -= 1 if A[mid] == A[mid + 1]: start = mid + 2 else: end = mid ...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR RETURN VAR VAR
Given a sorted array A[] of N positive integers having all the numbers occurring exactly twice, except for one number which will occur only once. Find the number occurring only once. Example 1: Input: N = 5 A = {1, 1, 2, 5, 5} Output: 2 Explanation: Since 2 occurs once, while other numbers occur twice, 2 is the answe...
class Solution: def search(self, nums, N): index = 0 while index < N: if index + 1 < N and nums[index] == nums[index + 1]: index += 2 else: break return nums[index]
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR VAR
Given a sorted array A[] of N positive integers having all the numbers occurring exactly twice, except for one number which will occur only once. Find the number occurring only once. Example 1: Input: N = 5 A = {1, 1, 2, 5, 5} Output: 2 Explanation: Since 2 occurs once, while other numbers occur twice, 2 is the answe...
class Solution: def search(self, A, N): d = {} for i in A: if i not in d: d[i] = 1 else: d[i] += 1 k = [[d[i], i] for i in d] k.sort() if k[0][0] == 1: return k[0][1]
CLASS_DEF FUNC_DEF ASSIGN VAR DICT FOR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR LIST VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR IF VAR NUMBER NUMBER NUMBER RETURN VAR NUMBER NUMBER
Given a sorted array A[] of N positive integers having all the numbers occurring exactly twice, except for one number which will occur only once. Find the number occurring only once. Example 1: Input: N = 5 A = {1, 1, 2, 5, 5} Output: 2 Explanation: Since 2 occurs once, while other numbers occur twice, 2 is the answe...
class Solution: def search(self, A, N): l = 0 h = N - 1 while l <= h: mid = (h + l) // 2 if A.count(A[mid]) == 1: return A[mid] elif A[mid] == A[mid - 1] and mid % 2 == 0: h = mid - 1 elif A[mid] == A[mid - 1] a...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR NUMBER RETURN VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN V...
Given a sorted array A[] of N positive integers having all the numbers occurring exactly twice, except for one number which will occur only once. Find the number occurring only once. Example 1: Input: N = 5 A = {1, 1, 2, 5, 5} Output: 2 Explanation: Since 2 occurs once, while other numbers occur twice, 2 is the answe...
class Solution: def search(self, A, N): ans = [] for i in range(0, N): if A[i] not in ans: ans.append(A[i]) else: ans.remove(A[i]) return ans[0]
CLASS_DEF FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR RETURN VAR NUMBER
Given a sorted array A[] of N positive integers having all the numbers occurring exactly twice, except for one number which will occur only once. Find the number occurring only once. Example 1: Input: N = 5 A = {1, 1, 2, 5, 5} Output: 2 Explanation: Since 2 occurs once, while other numbers occur twice, 2 is the answe...
class Solution: def search(self, A, N): count = {} for i in A: if i in count.keys(): count[i] = count[i] + 1 else: count[i] = 1 for key, value in count.items(): if value == 1: return key
CLASS_DEF FUNC_DEF ASSIGN VAR DICT FOR VAR VAR IF VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR IF VAR NUMBER RETURN VAR
Given a sorted array A[] of N positive integers having all the numbers occurring exactly twice, except for one number which will occur only once. Find the number occurring only once. Example 1: Input: N = 5 A = {1, 1, 2, 5, 5} Output: 2 Explanation: Since 2 occurs once, while other numbers occur twice, 2 is the answe...
class Solution: def search(self, A, N): n = len(A) if n == 1: return A[0] count = {} for i in range(n): count[A[i]] = 1 + count.get(A[i], 0) for key, value in count.items(): if value == 1: return key
CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER RETURN VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR BIN_OP NUMBER FUNC_CALL VAR VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR IF VAR NUMBER RETURN VAR
Given a sorted array A[] of N positive integers having all the numbers occurring exactly twice, except for one number which will occur only once. Find the number occurring only once. Example 1: Input: N = 5 A = {1, 1, 2, 5, 5} Output: 2 Explanation: Since 2 occurs once, while other numbers occur twice, 2 is the answe...
class Solution: def search(self, A, N): i = 0 while i < N - 1: if arr[i] != arr[i - 1] and arr[i] != arr[i + 1]: return arr[i] i += 1 return arr[N - 1]
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER RETURN VAR VAR VAR NUMBER RETURN VAR BIN_OP VAR NUMBER
Given a sorted array A[] of N positive integers having all the numbers occurring exactly twice, except for one number which will occur only once. Find the number occurring only once. Example 1: Input: N = 5 A = {1, 1, 2, 5, 5} Output: 2 Explanation: Since 2 occurs once, while other numbers occur twice, 2 is the answe...
class Solution: def search(self, A, N): d = {} ans = -1 maxi = 0 for i in A: if i in d: d[i] += 1 else: d[i] = 1 for i in d: if d[i] == 1: return i else: return -1
CLASS_DEF FUNC_DEF ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR IF VAR VAR NUMBER RETURN VAR RETURN NUMBER
Given a sorted array A[] of N positive integers having all the numbers occurring exactly twice, except for one number which will occur only once. Find the number occurring only once. Example 1: Input: N = 5 A = {1, 1, 2, 5, 5} Output: 2 Explanation: Since 2 occurs once, while other numbers occur twice, 2 is the answe...
class Solution: def search(self, A, N): left = 0 right = N - 1 while left < right: mid = (left + right) // 2 if mid % 2 != 0: if A[mid] != A[mid - 1] and A[mid] != A[mid + 1]: return A[mid] elif A[mid] != A[mid - 1]...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER RETURN VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF ...
Given a sorted array A[] of N positive integers having all the numbers occurring exactly twice, except for one number which will occur only once. Find the number occurring only once. Example 1: Input: N = 5 A = {1, 1, 2, 5, 5} Output: 2 Explanation: Since 2 occurs once, while other numbers occur twice, 2 is the answe...
class Solution: def search(self, A, N): i = 0 j = 1 c = 0 if N == 1 or A[i] != A[j]: return A[i] if A[N - 1] != A[N - 2]: return A[N - 1] while j < N: if A[i] == A[j]: i += 1 j += 1 c...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR VAR VAR VAR RETURN VAR VAR IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER RETURN VAR BIN_OP VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBE...
Given a sorted array A[] of N positive integers having all the numbers occurring exactly twice, except for one number which will occur only once. Find the number occurring only once. Example 1: Input: N = 5 A = {1, 1, 2, 5, 5} Output: 2 Explanation: Since 2 occurs once, while other numbers occur twice, 2 is the answe...
class Solution: def search(self, A, N): l, r = 0, N - 1 while l <= r: mid = l + (r - l) // 2 if mid % 2 == 0: if mid < N - 1 and A[mid] == A[mid + 1]: l = mid + 2 elif mid > 0 and A[mid] == A[mid - 1]: r...
CLASS_DEF FUNC_DEF ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR ...
Given a sorted array A[] of N positive integers having all the numbers occurring exactly twice, except for one number which will occur only once. Find the number occurring only once. Example 1: Input: N = 5 A = {1, 1, 2, 5, 5} Output: 2 Explanation: Since 2 occurs once, while other numbers occur twice, 2 is the answe...
class Solution: def search(self, A, N): j = {} u = [] e = list(set(A)) for x in e: j[x] = 0 for x in A: j[x] = j[x] + 1 for x in e: if j[x] != 2: return x break
CLASS_DEF FUNC_DEF ASSIGN VAR DICT ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR VAR NUMBER FOR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR NUMBER FOR VAR VAR IF VAR VAR NUMBER RETURN VAR
Given a sorted array A[] of N positive integers having all the numbers occurring exactly twice, except for one number which will occur only once. Find the number occurring only once. Example 1: Input: N = 5 A = {1, 1, 2, 5, 5} Output: 2 Explanation: Since 2 occurs once, while other numbers occur twice, 2 is the answe...
class Solution: def search(self, A, N): d = {} for i in A: if i not in d: d[i] = 1 else: d[i] = d[i] + 1 for key, value in d.items(): if d[key] == 1: return key
CLASS_DEF FUNC_DEF ASSIGN VAR DICT FOR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR IF VAR VAR NUMBER RETURN VAR
This problem is same as the next one, but has smaller constraints. It was a Sunday morning when the three friends Selena, Shiro and Katie decided to have a trip to the nearby power station (do not try this at home). After arriving at the power station, the cats got impressed with a large power transmission system cons...
from sys import maxsize n = int(input()) p = [] for i in range(n): w = list(map(int, input().split())) p.append(w) p.sort() s = {} for i in range(n): x1, y1 = p[i] for j in range(i + 1, n): x2, y2 = p[j] k = 0 b = 0 if x1 - x2 == 0: k = maxsize b ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR VAR VA...
This problem is same as the next one, but has smaller constraints. It was a Sunday morning when the three friends Selena, Shiro and Katie decided to have a trip to the nearby power station (do not try this at home). After arriving at the power station, the cats got impressed with a large power transmission system cons...
n = int(input()) def gcd(a, b): if a == 0: return b return gcd(b % a, a) points = [] lines = set() counter = 0 for i in range(n): a = [int(x) for x in input().split()] points.append(a) for item in points: for elem in points: if item != elem: g = gcd(item[1] - elem[1],...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FOR VAR VAR FOR VAR VAR IF VAR VAR ASSIGN ...
This problem is same as the next one, but has smaller constraints. It was a Sunday morning when the three friends Selena, Shiro and Katie decided to have a trip to the nearby power station (do not try this at home). After arriving at the power station, the cats got impressed with a large power transmission system cons...
lines = set() points = [] num = int(input()) for i in range(num): points.append([int(j) for j in input().split()]) for i in range(num): for j in range(i): dx = points[j][0] - points[i][0] if dx == 0: lines.add((378597736461, points[i][0])) else: m = (points[j][1] ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR VAR N...
This problem is same as the next one, but has smaller constraints. It was a Sunday morning when the three friends Selena, Shiro and Katie decided to have a trip to the nearby power station (do not try this at home). After arriving at the power station, the cats got impressed with a large power transmission system cons...
def gcd(a, b): while b: a, b = b, a % b return a n = int(input()) p = [0] * n for i in range(n): p[i] = [int(item) for item in input().split()] wires = set() for i in range(n): for j in range(i + 1, n): x0, y0 = p[i] x1, y1 = p[j] a = -(y1 - y0) b = x1 - x0 ...
FUNC_DEF WHILE VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR A...
This problem is same as the next one, but has smaller constraints. It was a Sunday morning when the three friends Selena, Shiro and Katie decided to have a trip to the nearby power station (do not try this at home). After arriving at the power station, the cats got impressed with a large power transmission system cons...
from itertools import combinations n = int(input()) points = [] for _ in range(n): x, y = map(int, input().split(" ")) points.append((x, y)) directions = {} for pair in combinations(points, 2): (x1, y1), (x2, y2) = pair if x1 == x2: dir = 0, 1 b = x1 else: dir = 1, (y2 - y1)...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER BIN...
This problem is same as the next one, but has smaller constraints. It was a Sunday morning when the three friends Selena, Shiro and Katie decided to have a trip to the nearby power station (do not try this at home). After arriving at the power station, the cats got impressed with a large power transmission system cons...
n = int(input()) T = [] P = [] for i in range(n): x, y = map(int, input().split()) T.append([x, y]) for i in range(n): for j in range(i + 1, n): x1, y1 = T[i] x2, y2 = T[j] a = y2 - y1 b = x1 - x2 c = -(a * x1 + b * y1) if a != 0: b /= a ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP ...
This problem is same as the next one, but has smaller constraints. It was a Sunday morning when the three friends Selena, Shiro and Katie decided to have a trip to the nearby power station (do not try this at home). After arriving at the power station, the cats got impressed with a large power transmission system cons...
n = int(input()) ls = set() pts = [] for i in range(n): x, y = map(int, input().split()) pts.append([x, y]) for i in range(n): for j in range(i + 1, n): x1 = pts[i][0] y1 = pts[i][1] x2 = pts[j][0] y2 = pts[j][1] m = (y2 - y1) / (x2 - x1) if x2 != x1 else "I" ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASS...
This problem is same as the next one, but has smaller constraints. It was a Sunday morning when the three friends Selena, Shiro and Katie decided to have a trip to the nearby power station (do not try this at home). After arriving at the power station, the cats got impressed with a large power transmission system cons...
n = int(input()) x = [(0) for i in range(0, n + 1)] y = [(0) for i in range(0, n + 1)] for i in range(1, n + 1): x[i], y[i] = map(int, input().split()) di = {} for i in range(1, n + 1): a = {} for j in range(i + 1, n + 1): if x[j] - x[i] == 0: if "0" not in a: a["0"] = 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER BI...
This problem is same as the next one, but has smaller constraints. It was a Sunday morning when the three friends Selena, Shiro and Katie decided to have a trip to the nearby power station (do not try this at home). After arriving at the power station, the cats got impressed with a large power transmission system cons...
n = int(input()) p = [] for i in range(n): x, y = map(int, input().split()) p.append((x, y)) d = {} for i in range(n): x1, y1 = p[i] for j in range(i + 1, n): x2, y2 = p[j] if x1 != x2: m = (y2 - y1) / (x2 - x1) c = (y1 * x2 - x1 * y2) / (x2 - x1) else: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR VAR VAR IF VAR VAR ASSIGN VAR B...
This problem is same as the next one, but has smaller constraints. It was a Sunday morning when the three friends Selena, Shiro and Katie decided to have a trip to the nearby power station (do not try this at home). After arriving at the power station, the cats got impressed with a large power transmission system cons...
import sys input = sys.stdin.readline n = int(input()) W = [list(map(int, input().split())) for i in range(n)] SET = set() def gcd(a, b): while b: a, b = b, a % b return a def point(a, b, c, d): g = gcd(c - a, d - b) K = [(c - a) // g, (d - b) // g] if K == [0, 1]: SET.add(tuple...
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 VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF WHILE VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR LIST B...
This problem is same as the next one, but has smaller constraints. It was a Sunday morning when the three friends Selena, Shiro and Katie decided to have a trip to the nearby power station (do not try this at home). After arriving at the power station, the cats got impressed with a large power transmission system cons...
n = int(input()) x = [] y = [] lineas = set() lineas1 = set() lineas2 = set() caca = dict() def gcd(a, b): if b == 0: return a return gcd(b, a % b) for i in range(n): a, b = map(int, input().split()) x.append(a) y.append(b) for j in range(i): a1 = a - x[j] b1 = b - y[...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_C...
This problem is same as the next one, but has smaller constraints. It was a Sunday morning when the three friends Selena, Shiro and Katie decided to have a trip to the nearby power station (do not try this at home). After arriving at the power station, the cats got impressed with a large power transmission system cons...
def gcd(a, b): while b: a, b = b, a % b return a n = int(input()) p = [0] * n for i in range(n): p[i] = [int(item) for item in input().split()] wires = set() for i in range(n): for j in range(i + 1, n): x0, y0 = p[i] x1, y1 = p[j] a = -(y1 - y0) b = x1 - x0 ...
FUNC_DEF WHILE VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR A...
This problem is same as the next one, but has smaller constraints. It was a Sunday morning when the three friends Selena, Shiro and Katie decided to have a trip to the nearby power station (do not try this at home). After arriving at the power station, the cats got impressed with a large power transmission system cons...
n = int(input()) def gcd(x, y): while y > 0: x, y = y, x % y return x poles = [] for i in range(n): x, y = list(map(int, input().split())) poles.append((x, y)) lines = set() for i in range(len(poles) - 1): for j in range(i + 1, len(poles)): p1 = poles[i] p2 = poles[j] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF WHILE VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR VAR RETURN 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 FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VA...
This problem is same as the next one, but has smaller constraints. It was a Sunday morning when the three friends Selena, Shiro and Katie decided to have a trip to the nearby power station (do not try this at home). After arriving at the power station, the cats got impressed with a large power transmission system cons...
def pos_gcd(a, b): if a == 0 and b == 0: return 1 if b == 0: return a return pos_gcd(b, a % b) def gcd2(a, b): return pos_gcd(abs(a), abs(b)) def gcd(a, b, c): return gcd2(gcd2(a, b), c) def make_line(p1, p2): a = p2[1] - p1[1] b = p1[0] - p2[0] c = -a * p1[0] - b *...
FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUM...
This problem is same as the next one, but has smaller constraints. It was a Sunday morning when the three friends Selena, Shiro and Katie decided to have a trip to the nearby power station (do not try this at home). After arriving at the power station, the cats got impressed with a large power transmission system cons...
def get_k(a, b): x1, y1 = a x2, y2 = b if x2 != x1: return (y2 - y1) / (x2 - x1) return 10**10 def get_offset(a, k2): x, y = a return y - k2 * x cnt = 0 a = [] n = int(input()) for i in range(n): a.append(tuple(map(int, input().split()))) alines = [] for i in range(n): for j ...
FUNC_DEF ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR IF VAR VAR RETURN BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR RETURN BIN_OP NUMBER NUMBER FUNC_DEF ASSIGN VAR VAR VAR RETURN BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL V...
This problem is same as the next one, but has smaller constraints. It was a Sunday morning when the three friends Selena, Shiro and Katie decided to have a trip to the nearby power station (do not try this at home). After arriving at the power station, the cats got impressed with a large power transmission system cons...
n = int(input()) T = [] for i in range(n): x, y = map(int, input().split()) T.append([x, y]) P = [] for i in range(n): for j in range(i + 1, n): x1, y1 = T[i] x2, y2 = T[j] a = y2 - y1 b = x1 - x2 c = -(a * x1 + b * y1) P.append([a, b, c]) const = 10**10 + 3 c...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP ...
This problem is same as the next one, but has smaller constraints. It was a Sunday morning when the three friends Selena, Shiro and Katie decided to have a trip to the nearby power station (do not try this at home). After arriving at the power station, the cats got impressed with a large power transmission system cons...
n = int(input()) coords = [] for i in range(n): coords.append(tuple(map(int, input().split()))) slopes = {} for i in range(n): for j in range(i + 1, n): x1, y1 = coords[i][0], coords[i][1] x2, y2 = coords[j][0], coords[j][1] if x1 == x2: slope = "inf" mark = x1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER VAR...
This problem is same as the next one, but has smaller constraints. It was a Sunday morning when the three friends Selena, Shiro and Katie decided to have a trip to the nearby power station (do not try this at home). After arriving at the power station, the cats got impressed with a large power transmission system cons...
coord = [] coef = {} a = b = 0 v = {} coef_a = {} n = int(input()) for i in range(n): coord.append(list(map(float, input().split()))) for i in range(n): x1, y1 = coord[i] for j in range(i + 1, n): x2, y2 = coord[j] if x2 - x1: a = (y2 - y1) / (x2 - x1) b = (y1 * x2 - ...
ASSIGN VAR LIST ASSIGN VAR DICT ASSIGN VAR VAR NUMBER ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR A...
This problem is same as the next one, but has smaller constraints. It was a Sunday morning when the three friends Selena, Shiro and Katie decided to have a trip to the nearby power station (do not try this at home). After arriving at the power station, the cats got impressed with a large power transmission system cons...
def gcd(x, y): while y: x, y = y, x % y return x def frac(a, b): x = gcd(a, b) return a // x, b // x n = int(input()) coords = [] for i in range(n): coords.append(tuple(map(int, input().split()))) slopes = {} for i in range(n): for j in range(i + 1, n): x1, y1 = coords[i][0],...
FUNC_DEF WHILE VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR V...
A correct expression of the form a+b=c was written; a, b and c are non-negative integers without leading zeros. In this expression, the plus and equally signs were lost. The task is to restore the expression. In other words, one character '+' and one character '=' should be inserted into given sequence of digits so tha...
def modgroup(M=10**9 + 7, invn=0): exec( f"""class mod{M} : inv = [None] * {invn + 1} if {invn + 1} >= 2 : inv[1] = 1 for i in range(2, {invn + 1}) : inv[i] = (({M} - {M}//i) * inv[{M}%i]) %{M} def __init__(self, n = 0) : self.n = n % {M} __repr__ = lambda self : str(self.n) + '%{M}' __int__ = lambd...
FUNC_DEF BIN_OP BIN_OP NUMBER NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR STRING VAR STRING BIN_OP VAR NUMBER STRING BIN_OP VAR NUMBER STRING BIN_OP VAR NUMBER STRING VAR STRING VAR STRING VAR STRING VAR STRING VAR STRING VAR STRING VAR STRING VAR STRING VAR STRING VAR STRING BIN_OP VAR NUMBER STRING RETURN FUNC_CALL VAR S...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
n, m = map(int, input().split()) ll = [] for i in range(n): ll.append(input()) if n % 3 == 0 or m % 3 == 0: l1 = ll[0][0] l2 = ll[n // 3][0] l3 = ll[2 * (n // 3)][0] t = False if l1 != l2 and l2 != l3 and l1 != l3 and n % 3 == 0: t = True for i in range(n): for j in r...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR N...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
def fn(s): ans = True for i in range(len(s) - 1): if s[i] != s[i + 1]: ans = False return ans def chk(n, m, l): if n % 3 != 0: return False w = n // 3 ls = [] ans = True for i in range(0, 3): s = "" for j in range(i * w, i * w + w): ...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER RETURN VAR FUNC_DEF IF BIN_OP VAR NUMBER NUMBER RETURN NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR STRING FOR VAR F...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
import sys n = input() a = [] n, m = n.split() n = int(n) m = int(m) for i in range(n): a.append(input()) if m % 3 != 0 and n % 3 != 0: print("NO") sys.exit() count = 1 for i in a: for j in i: if j != i[0]: count = 0 break if count == 0: break if count == 1: ...
IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VA...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
import sys n, m = map(int, input().split()) a = [] for i in range(n): a.append(input()) if n % 3 and m % 3: print("NO") sys.exit() b = [] c = [] f1 = True f2 = True st = "" if n % 3 == 0: i = 0 s = set() while i < n: if a[i][0] in s: f1 = False break s.ad...
IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING IF BIN_OP V...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
def transpose(l): rows, cols = len(l), len(l[0]) rows, cols = cols, rows return ["".join([l[col][row] for col in range(cols)]) for row in range(rows)] def all_equal(l): first = l[0] return all(map(lambda x: x == first, l)) def solve(): height, width = map(int, input().split()) flag = [] ...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR VAR RETURN FUNC_CALL STRING VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR VAR NUMBER RETURN FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
n, m = map(int, input().split()) a = [] for i in range(n): a.append(input()) f1 = 0 f2 = 0 if n % 3 == 0: f1 = 1 o1 = a[0][0] o2 = a[n // 3][0] o3 = a[2 * n // 3][0] if o1 == o2 or o2 == o3 or o1 == o3: f1 = 0 else: for i in range(n): if i < n // 3: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP BIN_OP NUMBER V...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
n, m = map(int, input().split()) a = [input() for q in range(n)] naw = a[0][0] flag = ( n % 3 == 0 and a[0][0] != a[n // 3][0] and a[0][0] != a[n // 3 * 2][0] and a[n // 3][0] != a[n // 3 * 2][0] ) for q in range(n // 3): for q1 in range(len(a[q])): if a[q][q1] != naw: flag = Fal...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
def check_line(line): line_color = line[0][0] for row in line: for color in row: if color != line_color: return False return True def check_flag(flag, n, m): is_vertical = len(set(flag[0])) > 1 row_has_3_colors = len(set(flag[0])) == 3 col_has_3_colors = len...
FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR FOR VAR VAR IF VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR VAR NUMBER IF VAR VAR RETURN NUMBER IF VAR...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
def c(f, n, m): if n % 3 != 0: return 0 s = n // 3 s = f[0], f[s], f[2 * s] if set(s) != set(map(lambda x: x * m, "RGB")): return 0 for i in range(n): if f[i] != s[i * 3 // n]: return 0 return 1 n, m = map(int, input().split()) f = [input() for _ in range(n)...
FUNC_DEF IF BIN_OP VAR NUMBER NUMBER RETURN NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER VAR VAR VAR BIN_OP NUMBER VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR STRING RETURN NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP BIN_OP VAR NUMBER VAR RETURN NUMBER RETURN NUMBER ASSIG...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
y, x = map(int, input().split()) ls = [] for i in range(y): ls.append(input()) if ls[0].count(ls[0][0]) == x: ls = list(zip(*ls)) x, y = y, x nr, ng, nb = ls[0].count("R"), ls[0].count("G"), ls[0].count("B") ch = 0 for i in range(1, x): if ls[0][i] != ls[0][i - 1]: ch += 1 if nr + ng + nb != x o...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR IF FUNC_CALL VAR NUMBER VAR NUMBER NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER STRING FUNC_CALL VAR NUMBER STRING F...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
n, m = map(int, input().split()) a = [input() for i in range(n)] b = ["".join(a[i][j] for i in range(n)) for j in range(m)] def check(a, n, m): if n % 3 != 0: return False s = a[0 * n // 3], a[1 * n // 3], a[2 * n // 3] if set(s) != set(map(lambda x: x * m, "RGB")): return False for i ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL STRING VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF IF BIN_OP VAR NUMBER NUMBER RETURN NUMBER ASSIGN VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR BIN_OP BIN_OP NUMBER VAR NUMBE...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
inp = input().split() n = [int(inp[0]), int(inp[1])] flag = [[], []] flag[0] = [input().rstrip() for i in range(n[0])] flag[1] = list(map(list, zip(*flag[0]))) ok = False for i in [0, 1]: if n[i] % 3 == 0 and not ok: cols = set() ok = True for k in [0, 1, 2]: beg = n[i] // 3 * k ...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST LIST LIST ASSIGN VAR NUMBER FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR LIST NUMBER NUMBER IF...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
import sys r, c = [int(x) for x in input().split()] V = [] for i in range(r): V.append(input()) d = {"R": 0, "G": 0, "B": 0} napa = True zeta = [] for i in range(r): alpha = V[i][0] if len(zeta) != 0: if alpha != zeta[-1] and alpha in zeta: napa = False break else: ...
IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER IF VA...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
n, m = map(int, input().split()) s = [input() for _ in range(n)] if n % 3 != 0 and m % 3 != 0: print("NO") exit() flag = 0 if n % 3 == 0: if not ( s[0][0] != s[n // 3][0] and s[2 * n // 3][0] != s[n // 3][0] and s[2 * n // 3][0] != s[0][0] ): flag = 1 r, g, b = 0, 0, ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER IF VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP NUMB...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
n, m = map(int, input().split()) ls = [] for i in range(n): s = input() ls.append(s) horizontal = [] f1 = True for i in range(n): if ls[i] == ls[i][0] * len(ls[i]): if i == 0: horizontal.append([ls[i], 1]) elif ls[i] == horizontal[-1][0]: horizontal[-1][1] += 1 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR VAR NUMBER FUNC_CALL VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR LIST VAR VAR NUMBER IF VA...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
a, b = input().split() a = int(a) b = int(b) arr = [] Rflag = Gflag = Bflag = flag = False for i in range(a): arr += [list(input().strip())] if a % 3 == 0: flag = True for i in range(3): for j in range(a // 3): if j == 0 and flag == True: if arr[a // 3 * i + j].count("R")...
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR LIST FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP ...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
n, m = list(map(int, input().split())) f = [input() for _ in range(n)] def clr(ss): cc = None for s in ss: for c in s: if cc is None: cc = c elif cc != c: return None return cc if n % 3 == 0: s = set() for i in range(0, n, n // 3): ...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR NONE FOR VAR VAR FOR VAR VAR IF VAR NONE ASSIGN VAR VAR IF VAR VAR RETURN NONE RETURN VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR BIN_OP...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
def matrixTranspose(matrix): if not matrix: return [] return [[row[i] for row in matrix] for i in range(len(matrix[0]))] def f(x): bool = True b, r, g = 0, 0, 0 col = ["e"] for row in x: if all(el == "R" for el in row): r += 1 if col[-1] != "r": ...
FUNC_DEF IF VAR RETURN LIST RETURN VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR LIST STRING FOR VAR VAR IF FUNC_CALL VAR VAR STRING VAR VAR VAR NUMBER IF VAR NUMBER STRING EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR STRING VA...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
def vertical(): if n % 3 == 0: num = n // 3 res = [data[0][0], data[num][0], data[num * 2][0]] if "R" not in res or "G" not in res or "B" not in res: return False for i in range(0, n): if data[i] != res[i // num] * m: return False retur...
FUNC_DEF IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST VAR NUMBER NUMBER VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER IF STRING VAR STRING VAR STRING VAR RETURN NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR RETURN NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF I...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
n, m = list(map(int, input().split())) l = [0] * n for i in range(n): l[i] = input() types = ["B", "G", "R"] first = [] second = [] third = [] countb = 0 countr = 0 countg = 0 counter = 0 container = 0 ans = [] ans1 = [] if l[0].count("B") == l[0].count("R") and l[0].count("B") == l[0].count("G"): first.append(...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR LIST STRING STRING STRING ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASS...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
n, m = map(int, input().split()) flag = [list() for x in range(n)] h1 = True for i in range(n): li = input() flag[i] = li c0 = flag[0][0] line = flag[0] for j in range(1, m): if line[j] != c0: h1 = False if not h1: cc = m / 3 if m % 3 != 0: print("NO") exit() ch = "" ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR ASSIGN VAR NUMBER IF VAR ASSI...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
altura, largura = map(int, input().split()) band = [input() for i in range(altura)] new_bandeira = ["".join(coluna) for coluna in zip(*band)] def confere(bandeira, altura): flag = True for linha in bandeira: cor = linha[0] if cor * len(linha) != linha: flag = False brea...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL STRING VAR VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR VAR NUMBER IF BIN_OP VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR DICT FOR VAR VAR IF VAR VAR ASSIGN V...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
def rotate_90_degree_anticlckwise(matrix): new_matrix = [] for i in range(len(matrix[0]), 0, -1): new_matrix.append(list(map(lambda x: x[i - 1], matrix))) return new_matrix n, m = map(int, input().split()) mat = [] for i in range(n): temp = input() mat.append([i for i in temp]) horiz, vert...
FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
import sys n, m = map(int, input().split()) flag = [list(input()) for _ in range(n)] if len(set(flag[0])) > 1: _flag = [([""] * n) for _ in range(m)] for i in range(n): for j in range(m): _flag[j][i] = flag[i][j] flag = _flag n, m = m, n if not all(len(set(row)) == 1 for row in flag...
IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST STRING VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR ASSIGN ...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
n_m = input().strip().split(" ") n = int(n_m[0]) m = int(n_m[1]) flag = [[] for x in range(n)] for i in range(n): line = input().strip() flag[i] = line horizontal = True c0 = flag[0][0] line = flag[0] for j in range(1, m): if line[j] != c0: horizontal = False if horizontal: color_change = n / 3 ...
ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER FOR VAR F...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
def f(n, m, g): if n % 3: return False c = g[0][0] + g[n // 3][0] + g[n // 3 * 2][0] if len(set(c)) < 3: return False f = [(c[i // (n // 3)] * m) for i in range(n)] return f == g n, m = map(int, input().split()) g = [input() for i in range(n)] print( "YES" if f(n, m, g) or ...
FUNC_DEF IF BIN_OP VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER IF FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR VAR RETURN VAR VAR ASSIGN VAR VA...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
import sys def main(): n, m = list(map(int, sys.stdin.readline().split())) if n % 3 != 0 and m % 3 != 0: print("NO") return f = [] for i in range(n): f.append(sys.stdin.readline()) ok = True if f[0][0] == f[n - 1][0]: if m % 3 != 0: ok = False ...
IMPORT FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER NUMBER IF B...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
def by_col(n, m, lines): orders = [None] * 3 n_div_3 = n // 3 for i in range(3): cur_char = None for j in range(n_div_3): line = lines[i * n_div_3 + j] char = line[0] if cur_char == None: cur_char = char elif char != cur_char: ...
FUNC_DEF ASSIGN VAR BIN_OP LIST NONE NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NONE FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR VAR NUMBER IF VAR NONE ASSIGN VAR VAR IF VAR VAR RETURN STRING IF FUNC_CALL VAR VAR VAR VAR VAR RETURN STRING ASSIGN VAR VAR...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
a, b = map(int, input().split()) rows = [list(input()) for x in range(a)] columns = [[x[y] for x in rows] for y in range(b)] def check(l): line = [] for x in l: p = x[0] for y in x: if y != p: break else: line.append(p) continue ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR VAR NUMBER FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR RETURN LIST NUMBER VAR RETURN LIST NUMBER VAR FU...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
n, m = list(map(int, input().split())) res = max(n, m) >= 3 is_horo = True is_vert = True if res: flag = [] for i in range(n): r = input() if len(r) != m: res = False break flag.append(list(r)) px = flag[0][0] for i in range(1, m): if flag[0][i] !=...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMB...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
def tran(lis, b, n, m): for i in range(m): for j in range(n): b[i][j] = lis[j][i] def call(n, lis): ans = [] cv = 1 for i in range(0, n, n // 3): a = [] for j in range(n // 3): a += lis[i + j] a = set(a) if len(a) > 1: cv = 0 ...
FUNC_DEF FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBE...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
def check_flag(flag, n, m): if n % 3 > 0 and m % 3 > 0: return False if n % 3 == 0: nrows = int(n / 3) set1 = set("".join(flag[:nrows])) set2 = set("".join(flag[nrows : 2 * nrows])) set3 = set("".join(flag[2 * nrows :])) if ( len(set1) + len(set2) + le...
FUNC_DEF IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER RETURN NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING VAR VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING VAR BIN_OP NU...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
from sys import stdin n, m = map(int, stdin.readline().rstrip().split()) data = [] for i in range(0, n): data.append(stdin.readline().rstrip()) if n % 3 != 0 and m % 3 != 0: print("No") exit(0) def check_ver(): if n % 3 == 0: num = n // 3 ccc = [data[0][0], data[num][0], data[num * 2]...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER FUNC_DEF IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP V...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
import itertools import sys def check(lst): if not all(row.count(row[0]) == len(row) for row in lst): return False _ = [[k, list(g)] for k, g in itertools.groupby([x[0] for x in lst])] keys, groups = zip(*_) keys = list(keys) return ( len(keys) == len(set(keys)) == 3 and le...
IMPORT IMPORT FUNC_DEF IF FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR VAR VAR RETURN NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL ...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
n, m = map(int, input().split()) if n * m % 3 != 0: print("NO") else: ans = "NO" f = [input() for _ in range(n)] if n % 3 == 0: for x in f: if len(set(x)) != 1: pass break else: if any( len(set(f[n * (i - 1) // 3 : n...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER FOR VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR BI...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
def check(b): i = len(b[0]) // 3 c = [b[0][0], b[0][i], b[0][2 * i]] if len(set(c)) != 3: return 0 j = 0 for p in range(len(b)): j = 0 for k in range(3): if len(set(b[p][j : j + i])) == 1 and set(b[p][j : j + i]) == {c[k]}: j += i c...
FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR LIST VAR NUMBER NUMBER VAR NUMBER VAR VAR NUMBER BIN_OP NUMBER VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR FUNC_...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
import sys n, m = map(int, input().split()) li = [] for _ in range(n): li.append(input()) if n % 3 == 0: flag = True stripe = n // 3 s0 = li[0][0] s1 = li[stripe][0] s2 = li[stripe * 2][0] for i in range(stripe): for j in range(m): if li[i][j] != s0: flag...
IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUN...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
n, m = map(int, input().split()) a = [] s = "" for i in range(n): a.append(input()) s += a[i] s1 = "" for i in range(m): for j in range(n): s1 += a[j][i] f, f1 = True, True v = [] v1 = [] if s[0 : n * m // 3] == s[0] * (n * m // 3): v.append(s[0]) else: f = False if s1[0 : n * m // 3] == s1[...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR LIST IF VAR NUMB...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
n, m = map(int, input().split()) A = [(0) for i in range(n)] for i in range(n): A[i] = input() f1, f2 = True, True colors = ["R", "G", "B"] if n % 3 != 0: f1 = False else: for i in range(3): if A[n // 3 * i][0] in colors: qq = A[n // 3 * i][0] colors.remove(A[n // 3 * i][0]) ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR LIST STRING STRING STRING IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR BIN_OP BIN_OP VAR NU...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
n, m = list(map(int, input().split())) c = [list(input()) for _ in range(n)] ans = "NO" if n % 3 == 0: l = [] for i in range(3): s = set([]) for j in range(i * n // 3, (i + 1) * n // 3): for k in range(m): s.add(c[j][k]) if len(s) == 1: l.append(s....
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR STRING IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR LIST FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP BI...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
height, width = map(int, input().split()) a = [input() for i in range(height)] c = {"r": 0, "g": 0, "b": 0} p = {"r": 0, "g": 0, "b": 0} color = {"r": False, "g": False, "b": False} horizontal, vertical = True, False for i in range(height): for j in range(width): color[a[i][j].lower()] = True for i in range...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
list_1 = [] list_2 = [] index_n = 0 index_m = 0 n, m = map(int, input().split()) for i in range(n): ch1 = str(input()) list_1.append(ch1) if n % 3 != 0: index_n = 1 if m % 3 != 0: index_m = 1 if n % 3 == 0: a = n / 3 for i in range(n): ch1 = list_1[i] if i % a == 0: c...
ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR N...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
n, m = map(int, input().split()) f = [(0) for _ in range(n)] for i in range(n): f[i] = input() hor = True if n % 3 != 0: hor = False else: c = "RGB" used = {"R": False, "G": False, "B": False} used[f[0][0]] = True cnt = 0 if [(f[0][0] * m) for i in range(n // 3)] == f[: n // 3]: cnt ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
import itertools n, m = map(int, input().split()) flag = [] for _ in range(n): flag.append(input()) def check(flag): if len(flag) % 3 or len(set(itertools.chain(*flag))) != 3: return False width = len(flag) // 3 for i in range(3): line = set() for j in range(width): ...
IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF IF BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBE...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
def rotate(matrix): global n, m new_matrix = [[(0) for i in range(n)] for j in range(m)] for i in range(n): for j in range(m): new_matrix[j][i] = matrix[i][j] return new_matrix def check(tab, n, m): colors = set() color = tab[0][0] colors.add(color) for i in range(n...
FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF ...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
n, m = map(int, input().split(" ")) flag2 = 0 flag1 = 0 if n % 3 == 0: flag1 = 1 if m % 3 == 0: flag2 = 1 s = [] f = [""] * m for i in range(n): t = input() s.append(t) for j in range(m): f[j] += t[j] H = [0, 0, 0] p = [] for i in s: if i == "R" * m: H[0] += 1 p.append(0)...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST STRING VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FOR ...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
n, m = input().split() n = int(n) m = int(m) flag = [] tes = [] RGB = {"R": 0, "G": 0, "B": 0} for i in range(n): flag.append(["."] * m) tes.append(["."] * m) for i in range(n): sting = input() for j in range(m): flag[i][j] = sting[j] check = False if n % 3 != 0 and m % 3 != 0: print("NO") e...
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP LIST STRING VAR EXPR FUNC_CALL VAR BIN_OP LIST STRING VAR FOR VAR FUNC_CALL VAR V...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
def check(n, m, fl, count): nonlocal flag, tr_flag if count == 3: return "NO" num = n // 3 is_ok = set() for k in range(0, n, num): new_check = set() for i in range(k, k + num): new_check = new_check | set(fl[i]) if len(new_check) != 1: flag, t...
FUNC_DEF IF VAR NUMBER RETURN STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER RET...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
n, m = map(int, input().split()) def ma(): s = [] h = True cts = {"R": 0, "G": 0, "B": 0} for i in range(n): s.append(input().strip()) init = s[-1][0] for c in s[-1]: if c != init: h = False cts[c] += 1 ct = 0 if h: for i ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER VAR VAR NUMBER A...
The flag of Berland is such rectangular field n × m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col...
vv = input() n = int(vv[0 : vv.find(" ")]) m = int(vv[vv.find(" ") :]) x = "" for mm in range(n): x += input() col = 0 row = 0 res = True types = 0 if x[0] == x[n * m - m]: if m % 3 == 0: col = m // 3 row = n types = 1 else: res = False elif x[0] == x[m - 1]: if n % 3 == ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR BIN_OP BIN_OP VAR VAR VAR IF BIN_OP ...