description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0.   Example 1: Input: nums = [21,4,7] Output: 32 Explanation: 21 has 4 divisors: 1, 3, 7, 21 4 has 3 divisors: 1, 2, 4 7 has 2 divisors: 1, 7 The answe...
class Solution: def sumFourDivisors(self, nums: List[int]) -> int: def four_divisors3(n): div = set() i = 1 while i * i < n: if n % i == 0: div.add(i) div.add(n // i) if len(div) > 4: ...
CLASS_DEF FUNC_DEF VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER VAR NUMBER RETURN FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER FUNC_DEF ASSIGN VAR FUNC...
Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0.   Example 1: Input: nums = [21,4,7] Output: 32 Explanation: 21 has 4 divisors: 1, 3, 7, 21 4 has 3 divisors: 1, 2, 4 7 has 2 divisors: 1, 7 The answe...
class Solution: def __init__(self): self.divisors = {} def generate_result(self, n): counter = 1 quo = n // counter while counter <= quo: if n % counter == 0: yield counter if quo != counter: yield quo ...
CLASS_DEF FUNC_DEF ASSIGN VAR DICT FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR WHILE VAR VAR IF BIN_OP VAR VAR NUMBER EXPR VAR IF VAR VAR EXPR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR FUNC_DEF IF VAR VAR RETURN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR RETURN VAR FUNC_DEF VAR VAR AS...
Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0.   Example 1: Input: nums = [21,4,7] Output: 32 Explanation: 21 has 4 divisors: 1, 3, 7, 21 4 has 3 divisors: 1, 2, 4 7 has 2 divisors: 1, 7 The answe...
class Solution: def sumFourDivisors(self, nums: List[int], c={}) -> int: r = 0 for n in nums: if n in c: r += c[n] continue s = n + 1 cnt = 2 end = sqrt(n) if end == int(end): s += end ...
CLASS_DEF FUNC_DEF VAR VAR DICT ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER VAR NUMBER IF VAR ...
Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0.   Example 1: Input: nums = [21,4,7] Output: 32 Explanation: 21 has 4 divisors: 1, 3, 7, 21 4 has 3 divisors: 1, 2, 4 7 has 2 divisors: 1, 7 The answe...
class Solution: def sumFourDivisors(self, nums: List[int]) -> int: def check(n): i = 1 cnt = 0 res = 0 while i * i < n: if n % i == 0: cnt += 2 res += i res += n // i ...
CLASS_DEF FUNC_DEF VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF BIN_OP VAR VAR NUMBER VAR NUMBER VAR VAR VAR BIN_OP VAR VAR VAR NUMBER IF VAR NUMBER RETURN NUMBER IF BIN_OP VAR VAR VAR VAR NUMBER VAR VAR IF VAR NUMBER RETURN VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VA...
Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0.   Example 1: Input: nums = [21,4,7] Output: 32 Explanation: 21 has 4 divisors: 1, 3, 7, 21 4 has 3 divisors: 1, 2, 4 7 has 2 divisors: 1, 7 The answe...
class Solution: def sumFourDivisors(self, nums: List[int]) -> int: ans = 0 for n in nums: d = set() for cnd in range(1, floor(sqrt(n)) + 1): q, r = divmod(n, cnd) if not r: d.add(q) d.add(cnd) ...
CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR IF VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR RETURN VAR VAR
Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0.   Example 1: Input: nums = [21,4,7] Output: 32 Explanation: 21 has 4 divisors: 1, 3, 7, 21 4 has 3 divisors: 1, 2, 4 7 has 2 divisors: 1, 7 The answe...
class Solution: def sumFourDivisors(self, nums: List[int]) -> int: res = 0 for i in range(len(nums)): curr = nums[i] counter = 1 divisors = [] while counter <= sqrt(nums[i]) and len(divisors) < 5: if nums[i] % counter == 0: ...
CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VA...
Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0.   Example 1: Input: nums = [21,4,7] Output: 32 Explanation: 21 has 4 divisors: 1, 3, 7, 21 4 has 3 divisors: 1, 2, 4 7 has 2 divisors: 1, 7 The answe...
class Solution: def sumFourDivisors(self, nums: List[int]) -> int: def check(x): v = set() i = 1 while i * i <= x: if x % i == 0: v.add(i) v.add(x // i) if len(v) > 4: re...
CLASS_DEF FUNC_DEF VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER VAR NUMBER IF FUNC_CALL VAR VAR NUMBER RETURN FUNC_CALL VAR VAR RETURN NUMBER RETURN FUNC_CA...
Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0.   Example 1: Input: nums = [21,4,7] Output: 32 Explanation: 21 has 4 divisors: 1, 3, 7, 21 4 has 3 divisors: 1, 2, 4 7 has 2 divisors: 1, 7 The answe...
class Solution: def sumFourDivisors(self, nums: List[int]) -> int: return sum([self.sumofDivisors(num) for num in nums]) def sumofDivisors(self, num): s = set() for i in range(1, int(sqrt(num)) + 1): if num % i == 0: s.add(i) s.add(num // i) ...
CLASS_DEF FUNC_DEF VAR VAR RETURN FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER RETURN FU...
Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0.   Example 1: Input: nums = [21,4,7] Output: 32 Explanation: 21 has 4 divisors: 1, 3, 7, 21 4 has 3 divisors: 1, 2, 4 7 has 2 divisors: 1, 7 The answe...
class Solution: def sumFourDivisors(self, nums: List[int]) -> int: res = 0 for n in nums: divisors = self.getDivisors(n) if len(divisors) == 4: res += sum(divisors) return res def getDivisors(self, n): divisors = set() for i in ra...
CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR RETURN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR NUMBER VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR...
Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0.   Example 1: Input: nums = [21,4,7] Output: 32 Explanation: 21 has 4 divisors: 1, 3, 7, 21 4 has 3 divisors: 1, 2, 4 7 has 2 divisors: 1, 7 The answe...
class Solution: def sumFourDivisors(self, nums: List[int]) -> int: ans = 0 for num in nums: ans += self.fourDivisors(num) return ans def fourDivisors(self, num): memo = set() for i in range(1, num + 1): if i * i > num: break ...
CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR RETURN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER...
Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0.   Example 1: Input: nums = [21,4,7] Output: 32 Explanation: 21 has 4 divisors: 1, 3, 7, 21 4 has 3 divisors: 1, 2, 4 7 has 2 divisors: 1, 7 The answe...
class Solution: def sumFourDivisors(self, nums: List[int]) -> int: ans = 0 def get_divisor(num): val = set() i = 1 while i < math.sqrt(num) + 1: if num % i == 0: val.add(i) val.add(num // i) ...
CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR IF FUNC_CALL VAR VAR NUMBER RETURN VAR VAR NUMBER RETURN VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR V...
Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0.   Example 1: Input: nums = [21,4,7] Output: 32 Explanation: 21 has 4 divisors: 1, 3, 7, 21 4 has 3 divisors: 1, 2, 4 7 has 2 divisors: 1, 7 The answe...
class Solution: def sumFourDivisors(self, nums: List[int]) -> int: def NOD(x): divisor = set() for i in range(1, int(sqrt(x)) + 1): if not x % i: divisor.add(i) divisor.add(x // i) return divisor res = 0 ...
CLASS_DEF FUNC_DEF VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR RETURN VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR FUNC_CA...
Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0.   Example 1: Input: nums = [21,4,7] Output: 32 Explanation: 21 has 4 divisors: 1, 3, 7, 21 4 has 3 divisors: 1, 2, 4 7 has 2 divisors: 1, 7 The answe...
class Solution: def sumFourDivisors(self, nums: List[int]) -> int: def find_divisors(n): i = 1 divisors = [] while i * i < n: if n % i == 0: divisors.append(i) divisors.append(n // i) i += 1 ...
CLASS_DEF FUNC_DEF VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE BIN_OP VAR VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR ...
Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0.   Example 1: Input: nums = [21,4,7] Output: 32 Explanation: 21 has 4 divisors: 1, 3, 7, 21 4 has 3 divisors: 1, 2, 4 7 has 2 divisors: 1, 7 The answe...
class Solution: def sumFourDivisors(self, nums: List[int]) -> int: ret = 0 for num in nums: ret += self.has_four_divisors(num) return int(ret) def has_four_divisors(self, num): divisor_sum = 0 divisors = 0 for i in range(1, int(sqrt(num)) + 1): ...
CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER IF VAR BIN_OP VAR VAR VAR NUMBER VAR VAR VAR BIN_OP VAR VAR VAR NUM...
Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0.   Example 1: Input: nums = [21,4,7] Output: 32 Explanation: 21 has 4 divisors: 1, 3, 7, 21 4 has 3 divisors: 1, 2, 4 7 has 2 divisors: 1, 7 The answe...
class Solution: def sumFourDivisors(self, nums: List[int]) -> int: res = 0 ls = len(nums) for i in range(ls): divs = set() for j in range(1, floor(sqrt(nums[i])) + 1): if nums[i] % j == 0: divs.add(nums[i] // j) ...
CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER IF BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBE...
Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0.   Example 1: Input: nums = [21,4,7] Output: 32 Explanation: 21 has 4 divisors: 1, 3, 7, 21 4 has 3 divisors: 1, 2, 4 7 has 2 divisors: 1, 7 The answe...
class Solution: def sumFourDivisors(self, nums: List[int]) -> int: res = 0 for i in range(len(nums)): curSum, curAns = 1 + nums[i], 2 for j in range(2, int(sqrt(nums[i])) + 1): if nums[i] % j == 0: if j == nums[i] // j: ...
CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP NUMBER VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER IF BIN_OP VAR VAR VAR NUMBER IF VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR NUMBER VAR BIN_OP VAR BIN_OP V...
Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0.   Example 1: Input: nums = [21,4,7] Output: 32 Explanation: 21 has 4 divisors: 1, 3, 7, 21 4 has 3 divisors: 1, 2, 4 7 has 2 divisors: 1, 7 The answe...
class Solution: def sumFourDivisors(self, nums: List[int]) -> int: def make_divisors(n): divisors = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: divisors.append(i) if i != n // i: divisors.appe...
CLASS_DEF FUNC_DEF VAR VAR FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR RETURN FUNC_CALL VAR VAR VAR ASSIGN VAR LIST NUMBER FOR VAR VAR ASSIGN VAR VAR FUNC_CALL ...
Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0.   Example 1: Input: nums = [21,4,7] Output: 32 Explanation: 21 has 4 divisors: 1, 3, 7, 21 4 has 3 divisors: 1, 2, 4 7 has 2 divisors: 1, 7 The answe...
class Solution: def helper(self, n): if n == 1: return 0 d = int(math.sqrt(n)) cnt = 2 sm = 1 + n while d > 1: if n % d == 0: d1 = n // d if d1 != d: sm += d + d1 cnt += 2 ...
CLASS_DEF FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR WHILE VAR NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR VAR BIN_OP VAR VAR VAR NUMBER VAR VAR VAR NUMBER IF VAR NUMBER RETURN NUMBER VAR NUMBER IF VAR NUMBER RE...
Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0.   Example 1: Input: nums = [21,4,7] Output: 32 Explanation: 21 has 4 divisors: 1, 3, 7, 21 4 has 3 divisors: 1, 2, 4 7 has 2 divisors: 1, 7 The answe...
class Solution: def divs(self, x): memo = self.memo if x in memo: return memo[x] res = 2 if x > 1 else 1 B = {1, x} for a in range(2, x): if x < a**2: break if not x % a: res += 1 if x == a**2 else 2 ...
CLASS_DEF FUNC_DEF ASSIGN VAR VAR IF VAR VAR RETURN VAR VAR ASSIGN VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR VAR BIN_OP VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR ...
Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0.   Example 1: Input: nums = [21,4,7] Output: 32 Explanation: 21 has 4 divisors: 1, 3, 7, 21 4 has 3 divisors: 1, 2, 4 7 has 2 divisors: 1, 7 The answe...
class Solution: def sumFourDivisors(self, nums: List[int]) -> int: def getDivs(num): result = [] for div in range(1, int(num ** (1 / 2)) + 1): if num % div == 0: result.append(div) result.append(num // div) if ...
CLASS_DEF FUNC_DEF VAR VAR FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER NUMBER NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR RETURN NUMBER IF BIN_OP FUNC_CALL VAR BIN_...
Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0.   Example 1: Input: nums = [21,4,7] Output: 32 Explanation: 21 has 4 divisors: 1, 3, 7, 21 4 has 3 divisors: 1, 2, 4 7 has 2 divisors: 1, 7 The answe...
class Solution: def sumFourDivisors(self, nums: List[int]) -> int: ans = 0 for num in nums: cnt = 0 for i in range(2, int(num**0.5) + 1): if num % i == 0: cnt += 1 d = i if cnt > 1: b...
CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER IF VAR NUMBER VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP BIN_OP NUMBER VAR BIN_OP VAR VAR VAR RETURN VAR VAR
Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0.   Example 1: Input: nums = [21,4,7] Output: 32 Explanation: 21 has 4 divisors: 1, 3, 7, 21 4 has 3 divisors: 1, 2, 4 7 has 2 divisors: 1, 7 The answe...
class Solution: cache = {} def factors(self, n): if n in self.cache: return self.cache[n] result = set() for i in range(1, int(n**0.5) + 1): div, mod = divmod(n, i) if mod == 0: result |= {i, div} self.cache[n] = result ...
CLASS_DEF ASSIGN VAR DICT FUNC_DEF IF VAR VAR RETURN VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR VAR VAR ASSIGN VAR VAR VAR RETURN VAR FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR RETURN FUNC_...
Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0.   Example 1: Input: nums = [21,4,7] Output: 32 Explanation: 21 has 4 divisors: 1, 3, 7, 21 4 has 3 divisors: 1, 2, 4 7 has 2 divisors: 1, 7 The answe...
def div(n): c = 0 i = 1 k = 0 if sqrt(n).is_integer(): return 0 while i * i < n and c <= 3: if n % i == 0: c += 1 k += i + n // i i += 1 if c == 2: return k else: return 0 class Solution: def sumFourDivisors(self, nums: L...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL FUNC_CALL VAR VAR RETURN NUMBER WHILE BIN_OP VAR VAR VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER VAR NUMBER VAR BIN_OP VAR BIN_OP VAR VAR VAR NUMBER IF VAR NUMBER RETURN VAR RETURN NUMBER CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR...
Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0.   Example 1: Input: nums = [21,4,7] Output: 32 Explanation: 21 has 4 divisors: 1, 3, 7, 21 4 has 3 divisors: 1, 2, 4 7 has 2 divisors: 1, 7 The answe...
class Solution: def sumFourDivisors(self, nums: List[int]) -> int: if not nums: return 0 ans = 0 for n in nums: rangemax = int(math.sqrt(n)) factsum = n + 1 factcount = 2 for f1 in range(2, rangemax + 1): if not n %...
CLASS_DEF FUNC_DEF VAR VAR IF VAR RETURN NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR NUMBER VAR VAR IF VAR VAR VAR NUMBER VAR VAR IF VAR NUMBE...
Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0.   Example 1: Input: nums = [21,4,7] Output: 32 Explanation: 21 has 4 divisors: 1, 3, 7, 21 4 has 3 divisors: 1, 2, 4 7 has 2 divisors: 1, 7 The answe...
class Solution: def sumFourDivisors(self, nums: List[int]) -> int: ret_count = {} ret_sum = {} for n in nums: if n in ret_sum: if ret_sum[n] is not None: ret_count[n] += 1 continue cur_div = 2 hit_div = ...
CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR VAR IF VAR VAR IF VAR VAR NONE VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NONE WHILE BIN_OP VAR VAR VAR IF BIN_OP VAR VAR NUMBER IF VAR NONE ASSIGN VAR VAR ASSIGN VAR NONE VAR NUMBER IF VAR NONE VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) arr = list(map(int, input().split())) d = [0] * 10 max_ = 1 for i in range(n): d[arr[i] - 1] += 1 lol = sorted([x for x in d if x > 0]) kek = True for j in range(len(lol) - 2): if lol[j] != lol[j + 1]: kek = False break if kek and len(lol) == 1: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) a = [int(x) for x in input().split()] d = {} ans = 0 t = 0 if n == 1: print("1") exit() for i in a: if i in d: d[i] += 1 else: d[i] = 1 x = [d[i] for i in d] t += 1 for i in range(len(x)): x[i] -= 1 tt = list(set(x)) c = 1 if 0...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR NUMBER FOR VAR FUNC_CA...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) a = list(map(int, input().split())) ans = n s = set() x = {i: (0) for i in range(1, 100001)} y = {} for i in range(n): e = a[i] c = x[e] if c: y[c].remove(e) if len(y[c]) == 0: s.remove(c) x[e] += 1 c += 1 if c not in y: y[c] = set({e}) el...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR IF VAR EXPR FUNC_CALL VAR VAR VAR IF FUN...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) A = list(map(int, input().split())) ans = 1 colors = {} for i in range(1, 11): colors[i] = 0 for j in range(n): i = A[j] colors[i] += 1 q = [] for elem in colors: if colors[elem]: q.append(colors[elem]) q.sort() if len(q) == 1: ans = j + 1 eli...
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 DICT FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) d = list(map(int, input().split())) MAX = 10**5 + 1 colors = 0 nofc = [0] * MAX cofn = [0] * MAX m = 0 r = 1 for p, i in enumerate(d): nofc[i] += 1 cofn[nofc[i] - 1] -= 1 cofn[nofc[i]] += 1 m = max(m, nofc[i]) if cofn[1] == p + 1 or cofn[p + 1] == 1: r = p + 1 elif cofn[...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER V...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
N = int(100000.0 + 10) n = int(input().strip()) arr = list(map(int, input().strip().split())) counts = [0] * N freq = [0] * N maxVal = 0 for i in range(1, n + 1): color = arr[i - 1] counts[freq[color]] -= 1 freq[color] += 1 counts[freq[color]] += 1 maxVal = max(maxVal, freq[color]) ok = False ...
ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR ...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) a = list(map(int, input().split())) d = {} for i in range(n): d[a[i]] = 0 x = 1 for i in range(1, n): if a[i] == a[i - 1]: x = i + 1 else: break ll = [(0) for i in range(100001)] l = [] for i in range(n): if d[a[i]] != 0: if ll[d[a[i]]] == 1: for c in...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL V...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) a = [*map(int, input().split())] num = [0] * (10**5 + 1) num_num = [0] * (n + 1) ans, ma = 1, 0 for i in range(n): num_num[num[a[i]]] = num_num[num[a[i]]] - 1 num[a[i]] = num[a[i]] + 1 ma = max(ma, num[a[i]]) num_num[num[a[i]]] = num_num[num[a[i]]] + 1 if ( ma == 1 o...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR NUMBER AS...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) a = list(map(int, input().split())) d = {} for i in range(n): d[a[i]] = 0 x = 1 for i in range(1, n): if a[i] == a[i - 1]: x = i + 1 else: break for i in range(n): d[a[i]] += 1 l = list(d.values()) l = list(set(l)) ll = list(d.values()) l.sort() if l[...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) u = list(map(int, input().split())) cnts = [(0) for _ in range(10**5 + 1)] cntcnt = [10**5 + 1] + [(0) for _ in range(10**5)] b = 1 for i in range(n): cnts[u[i]] += 1 cntcnt[cnts[u[i]] - 1] -= 1 cntcnt[cnts[u[i]]] += 1 nz = 10**5 + 1 - cntcnt[0] j = i + 1 if nz == 1: b =...
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 BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST BIN_OP BIN_OP NUMBER NUMBER NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
maxn = 10**5 + 11 n = int(input()) m = list(map(int, input().split())) f = [(0) for i in range(maxn)] g = [set() for i in range(maxn)] ans = 1 known = set() for j in range(n): i = m[j] if i not in known: known.add(i) f[i] = 0 g[f[i]].add(i) g[f[i]].remove(i) f[i] += 1 g[f[i]]...
ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER 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 ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR V...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) arr = [int(i) for i in input().split()] arr1 = [(0) for i in range(10**5 + 1)] arr2 = [(0) for i in range(10**5 + 1)] streaker = 0 maxa = 0 for i in range(n): arr2[arr1[arr[i]]] -= 1 arr1[arr[i]] += 1 arr2[arr1[arr[i]]] += 1 maxa = max(maxa, arr1[arr[i]]) if arr2[1] == i + 1: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR NUMB...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
def main(): n = int(input()) colors = list(map(int, input().split())) dist_colors = {} x = 0 for i in range(n): if colors[i] not in dist_colors.keys(): dist_colors[colors[i]] = 1 else: dist_colors[colors[i]] += 1 keys = [] for j in dist_colors....
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 DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_C...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) a = list(map(int, input().split())) if n == 1 or n == 2: print(n) return notpar = 0 occ = [(0) for i in range(10**5 + 1)] base = 1 gotone = False leader = -1 leadby = 0 best = 0 occ[a[0]] += 1 cnt = 1 at1 = 1 for i in range(1, n): occ[a[i]] += 1 if occ[a[i]] == 1: notpar += 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBE...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) u = list(map(int, input().split())) x = [0] * 10 mx = 0 if n == 1: print(1) exit(0) for i in range(n): x[u[i] - 1] += 1 fl = False for j in range(10): x1 = x[:] if x1[j] != 0: x1[j] -= 1 x2 = -1 k2 = 0 for l in x1: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CAL...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) a = [int(x) for x in input().split()] hsh = [(-1) for i in range(10)] fin = -1 for i in range(n): if hsh[a[i] - 1] == -1: hsh[a[i] - 1] = i for i in range(len(hsh)): h = [0] * 10 ans = 0 if hsh[i] != -1: for j in range(n): if a[j] - 1 == i and j == hsh[a[j] -...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST N...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) a = [] dctt = {} maxx = 0 ind = 0 for i in input().split(): ind += 1 if i not in dctt: dctt[i] = 0 dctt[i] += 1 countss = {} for color, count in dctt.items(): if count not in countss: countss[count] = 0 countss[count] += 1 if len(countss) > 2:...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR DICT FOR VAR VAR FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER IF F...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) a = [int(x) for x in input().split()] counter = [0] * 10**5 how = [0] * (10**5 + 1) answer = big = 0 for i in range(n): counter[a[i] - 1] += 1 big = max(big, counter[a[i] - 1]) how[counter[a[i] - 1]] += 1 how[counter[a[i] - 1] - 1] -= 1 if how[1] == i + 1: answer = i + 1 ...
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 NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VA...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) a, b = {}, {} ans = 1 t = [0] + list(map(int, input().split())) for i in range(1, n + 1): x = t[i] a[x] = a.get(x, 0) + 1 b[a[x]] = b.get(a[x], 0) + 1 if a[x] * b[a[x]] == i and i != n: ans = i + 1 elif a[x] * b[a[x]] == i - 1: ans = i print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR DICT DICT ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR BIN_OP FUNC_C...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) a = list(map(int, input().split())) k = set() b = 0 ind = {} for i in a: if i not in k: k.add(i) ind[i] = b b += 1 l = set() occ1 = 0 ans = 1 s = [(-1) for i in set(a)] for i in range(n): if a[i] in l: j = ind[a[i]] s[j] += 1 else: s[ind[a[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 ASSIGN VAR NUMBER ASSIGN VAR DICT FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
ii = lambda: int(input()) kk = lambda: map(int, input().split()) k2 = lambda: map(lambda x: int(x) - 1, input().split()) ll = lambda: list(kk()) n = ii() d = [0] * 10 maxi = 2 for j, v in enumerate(k2()): d[v] += 1 vs = {} for i in range(10): if d[i] == 0: continue if d[i] not in...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR FU...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
import sys input = sys.stdin.readline count = [(0) for i in range(100001)] lengthCount = [(0) for i in range(100001)] n = int(input()) ans = 0 a = list(map(int, input().split())) allLengthsSet = set() for i in range(n): lengthCount[count[a[i]]] -= 1 if lengthCount[count[a[i]]] == 0: allLengthsSet.remov...
IMPORT ASSIGN VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR VAR...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) u = [int(s) for s in input().split()] a = [(0) for i in range(100000)] im = 0 d = dict() for i in range(n): auiold = a[u[i] - 1] if auiold != 0: d[auiold] -= 1 if d[auiold] == 0: d.pop(auiold) a[u[i] - 1] += 1 auinew = a[u[i] - 1] d[auinew] = d.setdefault...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR NUMBER IF VAR NUMBER VAR VAR NUMBER IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR B...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) a = list(map(int, input().split())) b = [0] * (max(a) + 1) for i in a: b[i] += 1 ans = 1 for i in range(n - 1, -1, -1): c = [j for j in b] c.sort() ind = c.count(0) if ( c.count(c[ind]) == len(c) - ind - 1 and c[-1] - 1 == c[ind] or c.count(c[-1]) == len(c) -...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR ...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) ans = 0 a = list(map(int, input().split())) count = [0] * 10 k = 0 for each in a: k += 1 count[each - 1] += 1 f = [k for k in count if k > 0] fmin = min(f) fmax = max(f) lf, lsf = len(f), len(set(f)) if lsf > 2: continue if lf == 1: ans = k elif fmax ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR V...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
def streak(arr, l): x = [] for i in arr: if i != 0: x.append(i) mini = min(x) maxi = max(x) mincount = x.count(mini) maxcount = x.count(maxi) if mini == 1 and mincount == l: return True elif mini == 1 and mincount == 1 and maxi * maxcount == l - 1: ret...
FUNC_DEF ASSIGN VAR LIST FOR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR RETURN NUMBER IF VAR NUMBER VAR NUMBER BIN_OP VAR VAR BIN_OP VAR NUMBER RETURN NUMBER IF BIN_OP VAR NUMBER V...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) u = [int(item) for item in input().split()] d = {key: (0) for key in u} for x in u: d[x] += 1 nb_occs = [0] * (n + 1) for x in d: nb_occs[d[x]] += 1 s = set() for i in range(len(nb_occs)): if nb_occs[i] != 0: s.add(i) x = n - 1 count = len(s) while 1: if len(s) == 1: ite...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR VAR FOR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR ...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
def solve(colors): n = len(colors) color_count = {} count_count = {} max_x = 1 for c in colors: color_count[c] = 0 distinct_counts = set() for i in range(0, n): color = colors[i] old_count = color_count[color] color_count[color] += 1 if old_count > 0: ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR NUMBER IF VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR VAR IF VAR NUMBER VAR VAR EXPR FUNC_CALL VA...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) l1 = list(map(int, input().split())) d1 = {} d2 = {} total = 0 l2 = [0] * 10 i = 0 ans = 1 for item in l1: i += 1 l2[item - 1] += 1 x = sum(l2) y = 10 - l2.count(0) if (x - 1) % y == 0: z = (x - 1) // y else: z = -1 if y > 1 and (x - 1) % (y - 1) == 0: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
input() a, b = {}, {} r = i = 0 for u in input().split(): i += 1 c = a.get(u, 0) if c: b[c] -= 1 if b[c] == 0: del b[c] c += 1 a[u] = c b[c] = b.get(c, 0) + 1 l = len(b) if l == next(iter(b)) == 1 or len(a) == 1: r = i if l == 2: x, y = sor...
EXPR FUNC_CALL VAR ASSIGN VAR VAR DICT DICT ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR NUMBER IF VAR VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR FUNC_CA...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
import sys class Main: def __init__(self): self.buff = None self.index = 0 def next(self): if self.buff is None or self.index == len(self.buff): self.buff = self.next_line() self.index = 0 val = self.buff[self.index] self.index += 1 ret...
IMPORT CLASS_DEF FUNC_DEF ASSIGN VAR NONE ASSIGN VAR NUMBER FUNC_DEF IF VAR NONE VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER RETURN VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR F...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) u = list(map(int, input().split())) freq = [(0) for i in range(10**5)] for i in u: freq[i - 1] += 1 my_dict = {} def is_good(freq, my_dict, t): if t == 0: for i in freq: if i != 0: if i not in my_dict.keys(): my_dict[i] = 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER FOR VAR VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR DICT FUNC_DEF IF VAR NUMBER FOR VAR VAR IF VAR NUMBER IF VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR VAR ...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) l = [int(x) for x in input().split()] d = [0] * 10 ans = 0 for i in range(n): ll = {} d[l[i] - 1] += 1 for j in range(10): if d[j] != 0: if d[j] not in ll: ll[d[j]] = 0 ll[d[j]] += 1 if len(ll) == 1: if 1 in ll: ans = i...
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 NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR DICT VAR BIN_OP VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR VAR NUMBER VAR VA...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) u = [int(u) for u in input().split()] NMAX = 100005 suma = [(0) for _ in range(NMAX)] total = [(0) for _ in range(NMAX)] diferentes = 0 sol = 0 maximo = 1 for i, v in enumerate(u): if total[v] == 0: diferentes += 1 else: suma[total[v]] -= 1 total[v] += 1 suma[total[v]] +...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER VAR VAR VAR N...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) u = list(map(int, input().split())) true = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] big = 1 for i in range(n): true[u[i] - 1] += 1 vals = set(true) try: vals.remove(0) except: pass if len(vals) == 2 and 1 in vals and true.count(1) == 1: big = max(big, 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 LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) l = list(map(int, input().split())) count = [0] * (pow(10, 5) + 2) num = [0] * (pow(10, 5) + 1) mx = 0 s = 0 for i in range(n): v = l[i] count[num[v]] -= 1 num[v] += 1 mx = max(mx, num[v]) count[num[v]] += 1 f = 0 if count[1] == i + 1: f = 1 elif count[1] == 1 an...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN V...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) a = list(map(int, input().split())) n += 1 f = [0] * (10**5 + 10) x = 0 mx = 0 cnt = [0] * (10**5 + 10) i = 1 ans = 0 for c in a: cnt[f[c]] -= 1 f[c] += 1 cnt[f[c]] += 1 mx = max(mx, f[c]) ok = False if cnt[1] == i: ok = True elif cnt[1] == 1 and cnt[mx] * mx == i - ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER F...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) a = list(map(int, input().split())) c = [0] * 11 ma = 1 for i in range(n): c[a[i]] += 1 for k in range(1, 11): if c[k] > 0: c[k] -= 1 s = {} for j in range(1, 11): if c[j] > 0: if c[j] not in s: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER ...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
def check(): mn = float("inf") mx = 0 k = 0 for i in mas: if i != 0: k += 1 mx = max(mx, i) mn = min(mn, i) if ( mx - mn <= 1 and mas.count(mx) == 1 or mn == 1 and k == 1 + mas.count(mx) or mn == mx == 1 ): ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR BIN_OP NUMBER FUNC_CALL VAR VAR VAR VAR NUMBER RETURN NUMBER RETURN NUMBER ...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) arr = map(int, input().split()) occ = {} occ_count = {} ans = 1 for i, u in enumerate(arr): if u in occ: occ[u] += 1 if occ[u] in occ_count: occ_count[occ[u]] += 1 else: occ_count[occ[u]] = 1 if occ_count[occ[u] - 1] == 1: del occ_...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER IF VAR BIN_OP VAR VAR NUMBER NUMBER VAR BIN_OP VAR VAR NUMBER ...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
def check(c): d = {} for i in range(10): if c[i] != 0: if c[i] not in d: d[c[i]] = 1 else: d[c[i]] += 1 l = list(d.keys()) if len(l) == 1 and (l[0] == 1 or l[0] != 1 and d[l[0]] == 1): return True elif len(l) == 2: if l[...
FUNC_DEF ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER VAR VAR NUMBER NUMBER RETURN NUMBER IF FUNC_CALL VAR VAR NUMBER IF VAR NUMBER NUMBER ...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) a, b = {}, {} r = i = 0 for u in input().split(): i += 1 c = a[u] = a.get(u, 0) + 1 d = b[c] = b.get(c, 0) + c r = (r, d)[d in (i - (i == n), i - 1)] print(r + 1)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR DICT DICT ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) array = list(map(int, input().split())) d = [0] * 100010 v = [0] * 100010 answer = 0 m = 0 for x in range(len(array)): c = array[x] v[d[c]] -= 1 d[c] += 1 v[d[c]] += 1 m = max(m, d[c]) f = False if v[1] == x + 1: f = True if v[x + 1] == 1: f = True 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 BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR NUMBER VAR VAR NUMBER VAR VAR VAR...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) a = list(map(int, input().split())) mem = {} mark = [(0) for _ in range(11)] max_step = 0 c = 0 for v in a: c += 1 word2 = str(mark[v]) mark[v] += 1 word = str(mark[v]) mem[word] = mem.setdefault(word, 0) + 1 if word2 != "0": if mem.get(word2) == 1: del mem[w...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) arr = list(map(int, input().split())) dp = [0] * 11 ans = 0 for i in range(n): dp[arr[i]] += 1 d = {} for j in range(1, 11): if dp[j] > 0: d[dp[j]] = d.get(dp[j], 0) + 1 if len(d) == 2: s1 = [] for j in d: s1.append(j) a, b = s1[0]...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR VAR BIN_OP FUNC_CALL VAR VAR ...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
def convert(string): return string.split(sep=None, maxsplit=-1) def toint(lst): result = [] for i in lst: result.append(int(i)) return result def printeach(lst): for i in lst: print(i, end="") def valid(dic): val = {} for i in dic: if dic[i] != 0: tr...
FUNC_DEF RETURN FUNC_CALL VAR NONE NUMBER FUNC_DEF ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING FUNC_DEF ASSIGN VAR DICT FOR VAR VAR IF VAR VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER ...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) a = list(map(lambda x: int(x), input().split())) freq_map = {} freq = {} maximum = 0 for i in range(0, len(a)): if a[i] not in freq: freq[a[i]] = 0 freq[a[i]] += 1 if len(freq_map) > 0: if freq[a[i]] - 1 in freq_map: freq_map[freq[a[i]] - 1] -= 1 if f...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR NUMBER VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR V...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) apr, l, f, ans = 0, [0] * 100001, [0] * 100001, 1 i = 0 for x in input().split(): x = int(x) if l[x] == 0: l[x] += 1 apr += 1 f[1] += 1 else: f[l[x]] -= 1 l[x] += 1 f[l[x]] += 1 if i % apr == 0: tmp = i // apr if f[tmp] == ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER BIN_OP LIST NUMBER NUMBER BIN_OP LIST NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER VAR NUMBER VAR NUMBER NUMBER VAR VAR VAR NUMBER VAR VAR NUMBER VAR VAR VAR NUMBE...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) u = map(int, input().split()) max_x = 1 counts = [0] * 10**5 first_u = next(u) counts[first_u - 1] = 1 count_counts = {(1): 1} for i, v in enumerate(u): v -= 1 counts[v] += 1 if counts[v] > 1: count_counts[counts[v] - 1] -= 1 if count_counts[counts[v] - 1] == 0: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR DICT NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR NUMBER VAR VAR NUMBER IF VAR V...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
def check(d): if len(d) == 2: cmp = [] for k in d.keys(): cmp.append(k) to = max(cmp) be = min(cmp) if to == be + 1 and d[to] == 1: return True elif be == 1 and d[be] == 1: return True elif len(d) == 1: for k, v in d.ite...
FUNC_DEF IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER VAR VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR VAR NUMBER RETURN NUMBER IF FUNC_CALL VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR IF VAR NUMBER...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
N = int(100000.0 + 1) input() ns = list(map(int, input().split())) counts = {} us = {} ans = 0 for i, u in enumerate(ns): c = us.get(u, 0) if c: counts[c] -= 1 if counts[c] == 0: del counts[c] c += 1 us[u] = c counts[c] = counts.get(c, 0) + 1 if len(counts) == next(it...
ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR NUMBER IF VAR VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR VA...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) A = list(map(int, input().split())) B = [n] + [0] * (n + 1) C = {} calcset = set() good = 0 next = 0 for i in range(n): C[A[i]] = C.get(A[i], 0) + 1 B[C[A[i]] - 1] -= 1 B[C[A[i]]] += 1 if C[A[i]] > next: next = C[A[i]] calcset.add(A[i]) if ( B[next] + B[next - 1]...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) a = list(map(int, input().split())) u = [0] * 10 sl = 0 for i in range(n): u[a[i] - 1] += 1 s = sorted(u) for j in range(10): if s[j] != 0: break if s[j] == s[8] and s[9] - s[8] == 1: sl = max(sl, i + 1) elif s[j] == 1 and s[min(j + 1, 9)] == s[9]: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER IF VAR VAR VAR NUMBER BI...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
def main(): n = int(input()) u = [int(x) for x in input().split()] c = [0] * 11 ans = 0 for i in range(n): c[u[i]] += 1 f = True common_amount = 0 common_occurrences = 0 more_occurrences = 0 one_occurrences = 0 for j in range(1, 11): ...
FUNC_DEF 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 NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUM...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) l = list(map(int, input().split())) d = dict() m = 0 c = [0] * (10**5 + 1) ans = 0 for i in range(n): if l[i] in d: d[l[i]] += 1 else: d.update({l[i]: 1}) m = max(m, d[l[i]]) mw = d[l[i]] c[mw] += 1 c[mw - 1] -= 1 if c[1] * 1 == i + 1: ans = i + 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR DICT VAR ...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) u = [int(i) for i in input().split()] d, s = dict(), dict() m = 0 for i, v in enumerate(u): t = d.get(v, 0) d[v] = t + 1 s[t + 1] = s.get(t + 1, 0) + 1 if t > 0: if s.get(t, 0) > 1: s[t] -= 1 else: del s[t] if ( len(s) == 1 and...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUM...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) l = list(map(int, input().split())) c = [0] * 10 ans = 1 c[l[0] - 1] += 1 for i in range(1, n): if i != 0: max = -10 min = 10**18 for j in range(10): if c[j] != 0: if c[j] > max: max = c[j] if c[j] < min: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMB...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) lst = list(map(int, input().split())) d, length, res, ones, mx, col_mx = {}, 0, 1, 0, 0, 0 for i, x in enumerate(lst): if d.get(x) == None: d[x] = 0 ones += 1 length += 1 if d[x] == 1: ones -= 1 d[x] += 1 e = d[x] if e > mx: mx = e col...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NONE ASSIGN VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR NUMBER VAR NUMBER VAR VAR NUMBER...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) l = list(map(int, input().split())) m = [(0) for i in range(11)] varr = 0 for i in range(n): m[l[i]] += 1 listt = [m[i] for i in range(11) if m[i] != 0] listt = sorted(listt) if len(listt) == 1: varr = i + 1 if len(listt) > 1: if listt[0] == 1 and sum(listt) == 1 + l...
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 NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR NUMBER VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
def check(cnt): cnt_vals = {} nz_cnt = 0 for c in cnt: if c > 0: nz_cnt += 1 if c not in cnt_vals: cnt_vals[c] = 1 else: cnt_vals[c] += 1 if nz_cnt == 1: return True if len(cnt_vals) == 1 and 1 in cnt_vals: r...
FUNC_DEF ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER IF VAR NUMBER RETURN NUMBER IF FUNC_CALL VAR VAR NUMBER NUMBER VAR RETURN NUMBER IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER IF NUMBER VAR VAR NUMBER NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VA...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) a = [int(x) for x in input().split()] dic = {} counter = 0 i = 1 for item in a: dic[item] = 0 for item in a: dic[item] += 1 b = [] for key in dic: if dic[key] > 0: b.append(dic[key]) b.sort() if len(b) > 1: if b[-1] - 1 == b[-2] == b[0] or b[0] == 1 a...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR VAR NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR IF FUNC_CALL VAR VA...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) lis = [0] + list(map(int, input().split())) d = [0] * 100005 ans = 0 c = 0 mx = 0 cnt = [0] * 100005 for i in range(1, n + 1): cnt[d[lis[i]]] -= 1 d[lis[i]] += 1 cnt[d[lis[i]]] += 1 mx = max(mx, d[lis[i]]) if cnt[1] == i: ans = i elif cnt[1] == 1 and cnt[mx] * mx == i - ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR VAR VAR NUMB...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) l = list(map(int, input().split())) d = [0] * 10 h = 0 for i in range(n): d[l[i] - 1] += 1 d1 = [] + d d1.sort() if max(d1) == 1: h = max(h, i + 1) else: t = 0 for j in range(10): if d1[j] == 1: if j == 9 or d1[j + 1] == d1[9]: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST VAR EXPR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR V...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
def check(arr): tmp = [] for i in arr: if i != 0: tmp.append(i) mi = min(tmp) ma = max(tmp) mic = tmp.count(mi) mac = tmp.count(ma) l = len(tmp) if mi == 1 and mic == l: return True elif mic == l - 1 and mac == 1 and ma - mi == 1: return True e...
FUNC_DEF ASSIGN VAR LIST FOR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR RETURN NUMBER IF VAR BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR VAR NUMBER RETURN ...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
def go(): n = int(input()) x = 10**5 + 5 colors = [0] * x count = [0] * x m = 0 answer = 0 for i, c in enumerate(input().split(" ")): color = int(c) index = i + 1 colors[color] += 1 count[colors[color] - 1] -= 1 count[colors[color]] += 1 m = ma...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR VAR...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) u = list(map(int, input().split())) colour = [0] * (10**5 + 1) count = [0] * (10**5 + 1) x = 1 max_c = 0 for i in range(1, n + 1): if count[colour[u[i - 1]]]: count[colour[u[i - 1]]] = count[colour[u[i - 1]]] - 1 colour[u[i - 1]] += 1 count[colour[u[i - 1]]] += 1 max_c = max(max...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER I...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) a = list(map(int, input().split())) p = [([0] * 10) for i in range(n + 1)] for i in range(1, n + 1): p[i][a[i - 1] - 1] += 1 for j in range(10): p[i][j] += p[i - 1][j] for i in range(n, 0, -1): k = set(p[i]) if 0 in k: k.remove(0) if len(k) == 2: if p[i].coun...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VA...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
def gns(): return [int(x) for x in input().split()] def gn(): return int(input()) n = gn() ns = gns() sm = [[0] * 11] for i in range(n): c = ns[i] sm.append(list(sm[-1])) sm[-1][c] += 1 def check(x): x = [i for i in x if i != 0] if len(x) == 1: return True if sum(x) <= len(...
FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER FUNC_DEF AS...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
from sys import stdin n = int(stdin.readline()) ls = list(map(int, stdin.readline().split())) dic = {} occ = [(0) for __ in range(100005)] for i in ls: occ[i] += 1 occ_i = occ[i] if occ_i not in dic: dic[occ_i] = set() dic[occ_i].add(i) occ_i -= 1 if occ_i != 0: dic[occ_i].remov...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR IF VAR VAR ASSIGN VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VA...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
N = int(input()) arr = [int(x) for x in input().split()] cnt = dict() brr = set() crr = [(0) for _ in range(100001)] for i in range(1, N + 1): cnt[i] = set() answer = 1 for i in range(N): u = arr[i] crr[u] += 1 if crr[u] > 1: cnt[crr[u] - 1].remove(u) if len(cnt[crr[u] - 1]) == 0: ...
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 ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR ...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) l = list(map(int, input().split())) m = [(0) for i in range(10**5 + 5)] wyn = 0 duz = [(0) for i in range(10**5 + 5)] ile = [(0) for i in range(10**5 + 5)] zajete = 0 praw = [] jedynki = 0 mini = 100000000000 maksi = -100000000000000000 for i in range(n): if m[l[i]] == 1: jedynki -= 1 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 NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP NUMB...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) u = list(map(int, input().split())) cl = [0] * 10 cl[u[0] - 1] += 1 md = 1 for i in range(1, n): cc = u[i] - 1 cl[cc] += 1 czu = cl.count(0) cou = cl.count(1) cmu = cl.count(max(cl)) clu = cl.count(max(cl) - 1) if cmu == 1 and clu == 9 - czu or cou == 1 and cmu == 9 - czu or...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) array = list(map(int, input().split())) d = [0] * 100001 max_count = 0 count_of_1 = 0 count_of_max_count = 0 count_of_max_count_minus1 = 0 max_pref = 0 unique_count = 0 for i in range(n): if d[array[i]] == 0: count_of_1 += 1 unique_count += 1 d[array[i]] += 1 if d[array[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 BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) d = 0 c = [0] * 100100 e = 0 f = [0] * 100100 f[0] = n for i, x in enumerate(map(int, input().split())): f[c[x]] -= 1 c[x] += 1 f[c[x]] += 1 if 1 == c[x]: e += 1 if 1 == e or 1 + i == e: d = max(d, i + 1) if e > 1 and 0 == i % (e - 1) and 1 == f[1]: if f[...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER VAR FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR VAR NUMBER VAR VAR NUMBER VAR VAR VAR NUMBER IF NUMBER VAR VAR VAR NUMBER...
This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time. For each of the $n$ days since the day Shiro moved to the...
n = int(input()) a = input().split() b = {} c = [] q = 1 max1 = 1 prevmax = 0 countprev = 0 countmax = 1 countmin = 0 for i in range(n): if max1 == prevmax and i > n // max1 + max1: break if a[i] in b: b[a[i]] += 1 if b[a[i]] == 2: countmin -= 1 if b[a[i]] == max1: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER IF VA...