description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Read problems statements in Mandarin Chinese and Russian.
Chef likes to play games a lot. Gravity Guy is one such interesting game.
"Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w... | def m(l1, l2):
l1 = [i for i in l1]
l2 = [i for i in l2]
dp1 = [0] * len(l1)
dp2 = [0] * len(l2)
for i in range(len(l1)):
if l1[i] == "#" and l2[i] == "#":
return ["No"]
if l1[0] == "#":
dp1[0] = 10**9
if l2[0] == "#":
dp2[0] = 10**9
if l1[-1] == "#":
... | FUNC_DEF ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING RETURN LIST STRING IF VAR NUMBER STRING ASSIGN VAR NUMBER BIN_OP NUMBER NUMBER IF VAR NUMBER STR... |
Read problems statements in Mandarin Chinese and Russian.
Chef likes to play games a lot. Gravity Guy is one such interesting game.
"Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w... | for _ in range(int(input())):
s1 = input()
s2 = input()
s1 = [i for i in s1]
s2 = [i for i in s2]
k = len(s1)
dp1 = [0] * k
dp2 = [0] * k
f = 0
for i in range(k):
if s1[i] == "#" and s2[i] == "#":
print("No")
f = 1
break
if f:
c... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING ... |
Read problems statements in Mandarin Chinese and Russian.
Chef likes to play games a lot. Gravity Guy is one such interesting game.
"Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w... | cases = int(input())
for _ in range(cases):
top = "." + input()
bottom = "." + input()
array = [top, bottom]
tfind = top.find("#")
bfind = bottom.find("#")
if (tfind > bfind and bfind != -1) | (tfind == -1):
start = 0
else:
start = 1
count = 0
ok = True
for index ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP STRING FUNC_CALL VAR ASSIGN VAR BIN_OP STRING FUNC_CALL VAR ASSIGN VAR LIST VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF BIN_OP VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NU... |
Read problems statements in Mandarin Chinese and Russian.
Chef likes to play games a lot. Gravity Guy is one such interesting game.
"Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w... | val = 10**7
t = int(input().strip())
for i in range(t):
str1 = input().strip()
str2 = input().strip()
n = len(str1)
dp = [[val for i in range(2)] for j in range(n)]
if str1[0] == "#" and str2[0] == "#":
print("No")
else:
if str1[0] == ".":
dp[0][0] = 0
if str2... | ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR IF VAR NUMBER STRING VAR NUMBER STRING EXPR FUNC_CAL... |
Read problems statements in Mandarin Chinese and Russian.
Chef likes to play games a lot. Gravity Guy is one such interesting game.
"Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w... | T = int(input())
for _ in range(T):
l1 = list(input())
l2 = list(input())
for i in range(len(l1)):
if l1[i] == l2[i] == "#":
print("No")
break
else:
print("Yes")
dp1 = [0] * len(l1)
dp2 = [0] * len(l1)
if l1[0] == "#":
dp1[0] = 1000000
else... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 VAR VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR ... |
Read problems statements in Mandarin Chinese and Russian.
Chef likes to play games a lot. Gravity Guy is one such interesting game.
"Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w... | import sys
for t in range(int(input())):
s1 = input()
s2 = input()
leng = len(s1)
f = 0
for i in range(leng):
if s1[i] == "#" and s2[i] == "#":
print("No")
f = 1
break
if f != 1:
l1 = []
l2 = []
for i in range(leng):
... | IMPORT FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL... |
Read problems statements in Mandarin Chinese and Russian.
Chef likes to play games a lot. Gravity Guy is one such interesting game.
"Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w... | for _ in range(int(input())):
s1 = input()
s2 = input()
n = len(s1)
ls1 = [0] * n
ls2 = [0] * n
ls1[0] = 0 if s1[0] == "." else int(10000000.0)
ls2[0] = 0 if s2[0] == "." else int(10000000.0)
for i in range(1, n):
ls1[i] = min(ls1[i - 1], ls2[i - 1] + 1) if s1[i] == "." else int(... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER STRING NUMBER FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER STRING NUMBER FUNC_CALL VAR NU... |
Read problems statements in Mandarin Chinese and Russian.
Chef likes to play games a lot. Gravity Guy is one such interesting game.
"Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w... | t = int(input())
for i in range(t):
a = input()
b = input()
c = 0
arr = [a, b]
z = 0
yon = True
for k in range(len(a)):
if arr[z][k] == "#":
c += 1
z = (z + 1) % 2
if arr[z][k] == "#":
yon = False
c = 2 * 10**5
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR VAR ... |
Read problems statements in Mandarin Chinese and Russian.
Chef likes to play games a lot. Gravity Guy is one such interesting game.
"Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w... | for _ in range(int(input())):
l = input()
s = input()
flag = "Yes"
bad = 10000000000
for i in range(len(l)):
if l[i] == "#" and s[i] == "#":
flag = "No"
print("No")
break
if flag == "Yes":
n = len(l)
dp1 = [0] * n
dp2 = [0] * n
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING ASSIGN VAR STRING EXPR FUNC_CALL VAR STRING IF VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST N... |
Read problems statements in Mandarin Chinese and Russian.
Chef likes to play games a lot. Gravity Guy is one such interesting game.
"Gravity Guy is an arcade side-scrolling game in which the player controls Gravity Guy by tapping the screen to switch gravity. The objective in this game is to run as far as possible w... | for _ in range(int(input())):
l1 = input()
l2 = input()
curr = 0
numb = 1
n = len(l1)
u = False
if l1[0] == "." and l2[0] == "#":
curr = 1
elif l2[0] == "." and l1[0] == "#":
curr = 2
elif l1[0] == "." and l2[0] == ".":
i = 0
while l1[i] == "." and l2[... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER STRING VAR NUMBER STRING ASSIGN VAR NUMBER IF VAR NUMBER STRING VAR NUMBER STRING ASSIGN VAR NUMBER IF VAR NUMBER STRING VA... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | class Solution:
def f(self, ind, target, arr, dp):
if ind == 0:
if target % arr[ind] == 0:
return target // arr[ind]
else:
return float("inf")
if dp[ind][target] != -1:
return dp[ind][target]
notTake = 0 + self.f(ind - 1, t... | CLASS_DEF FUNC_DEF IF VAR NUMBER IF BIN_OP VAR VAR VAR NUMBER RETURN BIN_OP VAR VAR VAR RETURN FUNC_CALL VAR STRING IF VAR VAR VAR NUMBER RETURN VAR VAR VAR ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR VAR VAR ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR VAR BIN_... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | class Solution:
def MinCoin(self, nums, amount):
def find(nums, amount, dp):
if amount == 0:
return 0
if amount < 0:
return 9999999
if dp[amount] != -1:
return dp[amount]
ans = 9999999
for el in num... | CLASS_DEF FUNC_DEF FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR VAR NUMBER RETURN VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR RETURN VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUM... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | import sys
class Solution:
def MinCoin(self, nums, W):
import sys
sys.setrecursionlimit(10**9 + 7)
n = len(nums)
prev = [sys.maxsize for j in range(W + 1)]
curr = [sys.maxsize for j in range(W + 1)]
for j in range(W + 1):
if j % nums[0] == 0:
... | IMPORT CLASS_DEF FUNC_DEF IMPORT EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR VAR ... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | class Solution:
def MinCoin(self, nums, amount):
n = len(nums)
k = [[(0) for i in range(amount + 1)] for i in range(n + 1)]
for j in range(amount + 1):
k[0][j] = float("inf")
for i in range(1, n + 1):
k[i][0] = 0
for i in range(1, n + 1):
... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR N... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | class Solution:
def MinCoin(self, coins, sum):
dp = [([0] * (sum + 1)) for i in range(len(coins) + 1)]
for i in range(1, sum + 1):
dp[0][i] = 10**5
for i in range(1, len(coins) + 1):
for j in range(sum + 1):
if j >= coins[i - 1]:
d... | CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR B... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | class Solution:
def MinCoin(self, nums, amount):
n = len(nums)
dp = [([0] * (amount + 1)) for tt in range(n + 1)]
dp[0] = [0] + [amount + 1] * amount
for i in range(1, amount + 1):
for j in range(1, n + 1):
if nums[j - 1] <= i:
dp[j][i... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER BIN_OP LIST NUMBER BIN_OP LIST BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBE... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | class Solution:
def MinCoin(self, n, a):
dp = [0] * (a + 1)
for i in range(1, a + 1):
dp[i] = 100000000
for j in range(len(n)):
if i - n[j] >= 0:
su = dp[i - n[j]]
dp[i] = min(dp[i], su + 1)
if dp[a] == 0 or dp[... | CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER VAR VAR ... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | class Solution:
def MinCoin(self, coins, target):
dp = [[(0) for i in range(target + 1)] for i in range(len(coins))]
for i in range(target + 1):
if i % coins[0] == 0:
dp[0][i] = i // coins[0]
else:
dp[0][i] = 1000000000.0
for i in rang... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR ... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | class Solution:
def MinCoin(self, nums, amount):
dp = [0] * (amount + 1)
nums.sort()
for amt in range(1, amount + 1):
ans = float("inf")
for coin in nums:
if coin <= amt:
ans = min(ans, 1 + dp[amt - coin])
else:
... | CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING FOR VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP NUMBER VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR IF VAR VAR BIN_OP NUMBER NUMBER RETURN NUMBER RETUR... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | class Solution:
def MinCoin(self, nums, amount):
N = len(nums)
nums.sort(reverse=True)
dp = {}
def solve(n, cap):
if cap == 0:
return 0
elif n == 0:
return float("INF")
elif (n, cap) in dp:
return d... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR DICT FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN FUNC_CALL VAR STRING IF VAR VAR VAR RETURN VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | class Solution:
def MinCoin(self, arr, amount):
dp = {}
arr.sort()
def solve(amt):
if amt == 0:
return 0
elif amt in dp:
return dp[amt]
else:
ans = float("INF")
for val in arr:
... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT EXPR FUNC_CALL VAR FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR VAR RETURN VAR VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP NUMBER FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR BIN_OP BIN... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | class Solution:
def MinCoin(self, nums, amount):
t = [[(0) for i in range(amount + 1)] for j in range(len(nums) + 1)]
for i in range(1, len(nums) + 1):
t[i][0] = 0
for j in range(amount + 1):
t[0][j] = amount + 2
for k in range(1, amount + 1):
if ... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBE... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | class Solution:
def MinCoin(self, nums, amount):
dp = [amount + 1] * 100001
dp[0] = 0
for i in range(len(nums)):
for j in range(1, amount + 1):
if nums[i] <= j:
dp[j] = min(dp[j], dp[j - nums[i]] + 1)
if dp[amount] > amount:
... | CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR NUMBER IF VAR VAR VAR RETURN NUMBER RETURN VAR VAR |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | import sys
class Solution:
def MinCoin(self, nums, amount):
prev = [0] * (amount + 1)
for i in range(amount + 1):
if i % nums[0] == 0:
prev[i] = i // nums[0]
else:
prev[i] = sys.maxsize
for index in range(1, len(nums)):
c... | IMPORT CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | import sys
class Solution:
def solve(self, nums, amount):
dp = [float("inf")] * (amount + 1)
dp[0] = 0
mini = float("inf")
for i in range(1, amount + 1):
for j in range(len(nums)):
if i - nums[j] >= 0 and dp[i - nums[j]] != float("inf"):
... | IMPORT CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST FUNC_CALL VAR STRING BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR NUMBER VAR BIN_OP VAR VAR VAR FUNC_CALL VAR STRING ASSIGN VAR VAR ... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | def dynamic(arr, amount):
n = len(arr)
arr.sort()
arr = arr[::-1]
dp = [[(10**5) for _ in range(amount + 1)] for _ in range(n + 1)]
for i in range(n + 1):
dp[i][0] = 1
for i in range(1, n + 1):
for j in range(1, amount + 1):
if j % arr[i - 1] == 0:
dp[... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | class Solution:
def MinCoin(self, nums, amount):
dp = [amount + 1] * (amount + 1)
dp[0] = 0
for a in range(1, amount + 1):
for c in nums:
if a - c >= 0:
dp[a] = min((dp[a], 1 + dp[a - c]))
return dp[amount] if dp[amount] != amount + 1 ... | CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP NUMBER VAR BIN_OP VAR VAR RETURN VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | class Solution:
def MinCoin(self, nums, amount):
n = len(nums)
dp = [([-1] * (amount + 1)) for _ in range(n)]
def rec(i, val):
if i >= n:
return 10001
if val == 0:
dp[i][val] = 0
return 0
if dp[i][val] != -... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR NUMBER ASSIGN VAR VAR VAR NUMBER RETURN NUMBER IF VAR VAR VAR NUMBER RETURN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR VAR ASSIGN VAR ... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | class Solution:
def MinCoin(self, nums, amount):
dp = [[(-1) for i in range(amount + 1)] for i in range(len(nums))]
def f(ind, arr, target, dp):
if ind == 0:
if target % arr[ind] == 0:
return target // arr[ind]
else:
... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_DEF IF VAR NUMBER IF BIN_OP VAR VAR VAR NUMBER RETURN BIN_OP VAR VAR VAR RETURN NUMBER IF VAR VAR VAR NUMBER RETURN VAR VAR VAR ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR ASSIGN VA... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | class Solution:
def MinCoin(self, nums, amount):
n = len(nums)
dp = [[(10000000000) for i in range(amount + 1)] for i in range(n)]
for i in range(n):
dp[i][0] = 0
for i in range(1, amount + 1):
if nums[0] <= i:
dp[0][i] = dp[0][i - nums[0]] + ... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR NUMBER VAR ASSIGN VAR NUMBER VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER NUMBER FOR VAR... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | class Solution:
def MinCoin(self, nums, amount):
def func(coins, ind, tar, dp):
if ind == 0:
if tar % coins[ind] == 0:
return tar // coins[ind]
else:
return 10**9
if dp[ind][tar] != -1:
return d... | CLASS_DEF FUNC_DEF FUNC_DEF IF VAR NUMBER IF BIN_OP VAR VAR VAR NUMBER RETURN BIN_OP VAR VAR VAR RETURN BIN_OP NUMBER NUMBER IF VAR VAR VAR NUMBER RETURN VAR VAR VAR ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | class Solution:
def MinCoin(self, nums, amount):
coins = nums
V = amount
m = max(coins)
m = max(m, V)
dp = [-1] * (m + 1)
for el in coins:
dp[el] = 1
for i in range(V + 1):
choices = []
for el in coins:
if i... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR VAR NUMB... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | def f(A, amt, dp):
if amt == 0:
return 0
elif amt < 0:
return int(100000.0)
else:
if dp[amt] != -1:
return dp[amt]
ans = int(100000.0)
for i in A:
ans = min(ans, 1 + f(A, amt - i, dp))
if ans >= int(100000.0):
ans = int(1000... | FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN FUNC_CALL VAR NUMBER IF VAR VAR NUMBER RETURN VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP NUMBER FUNC_CALL VAR VAR BIN_OP VAR VAR VAR IF VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR RETUR... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | class Solution:
def MinCoin(self, a, n):
dp = [float("inf")] * (n + 1)
dp[0] = 0
for i in range(1, n + 1):
for j in a:
if i - j >= 0:
dp[i] = min(dp[i - j] + 1, dp[i])
if dp[n] == float("inf"):
return -1
return dp[n... | CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST FUNC_CALL VAR STRING BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR NUMBER VAR VAR IF VAR VAR FUNC_CALL VAR STRING RETURN NUMBER RETURN VAR VAR |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | class Solution:
def MinCoin(self, coins, Sum):
N = len(coins)
MAX = pow(10, 7)
dp = [[MAX for j in range(Sum + 1)] for i in range(N)]
for i in range(N):
for s in range(Sum + 1):
if i == 0 and s % coins[0] == 0:
dp[0][s] = int(s / coins... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR VAR ... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | class Solution:
def MinCoin(self, nums, amount):
d = dict()
res = self.MinCoiN(nums, amount, d)
if res == float("inf"):
return -1
return res
def MinCoiN(self, nums, amount, d):
if amount in d:
return d[amount]
if amount == 0:
... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR FUNC_CALL VAR STRING RETURN NUMBER RETURN VAR FUNC_DEF IF VAR VAR RETURN VAR VAR IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR STRING FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR IF ... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | import sys
class Solution:
def mcoins(self, coins, x, n, dp):
if x == 0:
return 0
if x < 0:
return sys.maxsize
if dp[x] != -1:
return dp[x]
mini = sys.maxsize
for i in range(n):
ans = self.mcoins(coins, x - coins[i], n, dp)
... | IMPORT CLASS_DEF FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN VAR IF VAR VAR NUMBER RETURN VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR VAR... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | class Solution:
def MinCoin(self, coins, amount):
dp = [(amount + 1) for i in range(0, amount + 1)]
dp[0] = 0
for i in range(1, len(dp)):
for coin in coins:
if coin <= i:
dp[i] = min(1 + dp[i - coin], dp[i])
return -1 if dp[amount] == ... | CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR FOR VAR VAR IF VAR VAR ASSIGN VAR VAR FUNC_CALL VAR BIN_OP NUMBER VAR BIN_OP VAR VAR VAR VAR RETURN VAR VAR BIN_OP VAR NUMBER NUMBER VAR VAR |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | class Solution:
def MinCoin(self, arr, amount):
N = len(arr)
dp = [([0] * (amount + 1)) for _ in range(N + 1)]
for i in range(N + 1):
for j in range(amount + 1):
amt = j
n = i
if amt == 0:
dp[i][j] = 0
... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR IF VAR NUMBER ASSIGN VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR VAR FUNC_... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | class Solution:
def MinCoin(self, nums, amount):
prev = [0] * (amount + 1)
cur = [0] * (amount + 1)
for T in range(amount + 1):
if T % nums[0] == 0:
prev[T] = T // nums[0]
else:
prev[T] = float("inf")
for ind in range(1, len(nu... | CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | import sys
class Solution:
def MinCoin(self, nums, amount):
dp = [-1] * (amount + 1)
dp[0] = 0
for i in nums:
if i <= amount:
dp[i] = 1
for j in range(amount + 1):
if dp[j] != -1:
for k in nums:
if j + k <... | IMPORT CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER FOR VAR VAR IF BIN_OP VAR VAR VAR IF VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR BIN_OP VAR VAR NUMBER ASSIGN ... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | class Solution:
def MinCoin(self, coins, Sum):
N = len(nums)
MAX = pow(10, 7)
dp = [[(-1) for j in range(Sum + 1)] for i in range(N)]
def f(i, s):
if i == 0:
if s % coins[0] == 0:
return int(s / coins[0])
return MAX
... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR FUNC_DEF IF VAR NUMBER IF BIN_OP VAR VAR NUMBER NUMBER RETURN FUNC_CALL VAR BIN_OP VAR VAR NUMBER RETURN VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR ... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | class Solution:
def MinCoin(self, nums, amount):
m = {}
n = len(nums)
nums.sort()
def mincoin(i, s):
if s == 0:
return 0
if i < 0:
return 999999
if s % nums[i] == 0:
return s // nums[i]
... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF BIN_OP VAR VAR VAR NUMBER RETURN BIN_OP VAR VAR VAR IF VAR VAR VAR RETURN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP NUMBER FUNC_CA... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | import sys
class Solution:
def MinCoin(self, nums, amount):
ans = [([-1] * (amount + 1)) for _ in range(len(nums) + 1)]
def selectCoin(index, T):
if index == 0:
if T % nums[0] == 0:
return T // nums[0]
return sys.maxsize
... | IMPORT CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_DEF IF VAR NUMBER IF BIN_OP VAR VAR NUMBER NUMBER RETURN BIN_OP VAR VAR NUMBER RETURN VAR IF VAR VAR VAR NUMBER RETURN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VA... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | class Solution:
def MinCoin(self, nums, amount):
dp = [-1] * (amount + 1)
dp[0] = 0
for i in range(1, amount + 1):
ans = 9999999
for el in nums:
f = i - el
if f >= 0:
par_ans = 1 + dp[f]
ans = mi... | CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR IF VAR VAR NUMBER RETURN N... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | import sys
class Solution:
def MinCoin(self, nums, amount):
ans = [([0] * (amount + 1)) for _ in range(len(nums))]
for i in range(amount + 1):
if i % nums[0] == 0:
ans[0][i] = i // nums[0]
else:
ans[0][i] = sys.maxsize
for index in r... | IMPORT CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | def cc(arr, n, dp):
if n == 0:
return 0
if dp.get(n):
return dp[n]
ans = float("inf")
for i in range(len(arr)):
if n - arr[i] >= 0:
sub = 0
if dp.get(n - arr[i]):
sub = dp[n - arr[i]]
else:
sub = cc(arr, n - arr[... | FUNC_DEF IF VAR NUMBER RETURN NUMBER IF FUNC_CALL VAR VAR RETURN VAR VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR VAR IF VAR... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | class Solution:
def MinCoin(self, coins, total_amount):
min_coin_results = [-2] * total_amount
for coin in coins:
if coin <= total_amount:
min_coin_results[coin - 1] = 1
return self.MinCoinHelper(coins, total_amount, min_coin_results)
def MinCoinHelper(self,... | CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER RETURN FUNC_CALL VAR VAR VAR VAR FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR BIN_OP VAR NUMBER NUMBER RETURN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP ... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | class Solution:
def MinCoin(self, nums, amount):
n, x = len(nums), amount
c = nums
a = [(-1) for i in range(x + 1)]
a[0] = 0
for i in range(x):
if a[i] != -1:
for j in c:
if i + j <= x:
if a[i + j] == -1... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER FOR VAR VAR IF BIN_OP VAR VAR VAR IF VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | class Solution:
def noofways(self, amt, coins, n, dp):
if amt == 0:
return 0
if n == 0:
return float("inf")
if n == 1 and amt > 1:
if amt % coins[n - 1] == 0:
return amt // coins[n - 1]
else:
return float("inf")... | CLASS_DEF FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR BIN_OP VAR NUMBER NUMBER RETURN BIN_OP VAR VAR BIN_OP VAR NUMBER RETURN FUNC_CALL VAR STRING IF VAR VAR VAR NUMBER RETURN VAR VAR VAR IF VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR VAR FUNC_C... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | class Solution:
def help(self, nums, amt, n):
dp = [[(0) for j in range(amt + 1)] for i in range(n + 1)]
for i in range(amt + 1):
dp[0][i] = float("inf")
for i in range(1, n + 1):
for j in range(1, amt + 1):
if nums[i - 1] <= j:
dp... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR ASSIG... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | INV = 10**9
class Solution:
def MinCoin(self, A, K):
dp = [INV] * (K + 1)
dp[0] = 0
for amt in range(1, K + 1):
for v in A:
if v > amt:
continue
dp[amt] = min(1 + dp[amt - v], dp[amt])
return dp[K] if dp[K] < INV else... | ASSIGN VAR BIN_OP NUMBER NUMBER CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR VAR IF VAR VAR ASSIGN VAR VAR FUNC_CALL VAR BIN_OP NUMBER VAR BIN_OP VAR VAR VAR VAR RETURN VAR VAR VAR VAR VAR NUMBER |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | class Solution:
def MinCoin(self, coins, amount):
n = len(coins)
dp = [[(0) for j in range(0, amount + 1)] for i in range(0, n + 1)]
for i in range(0, n + 1):
dp[i][0] = 0
for j in range(1, amount + 1):
if j % coins[0] == 0:
dp[1][j] = j // co... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR NU... |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | class Solution:
def MinCoin(self, nums, amount):
dp = [float("inf") for _ in range(amount + 1)]
dp[0] = 0
for i in range(len(dp)):
for j in nums:
if i - j >= 0:
dp[i] = min(dp[i], dp[i - j] + 1)
return -1 if dp[-1] == float("inf") else... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR BIN_OP VAR VAR NUMBER RETURN VAR NUMBER FUNC_CALL VAR STRING NUMBER VAR NUMBER |
Given a list of coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up using given coins.
You may assume that there are infinite numbers of coins of each type.
Example 1:
Input: arr = [1, 2, 5], amount = 11... | class Solution:
def MinCoin(self, nums, amount):
n = len(nums)
nums.sort()
dp = [1000000000000.0] * (amount + 1)
dp[0] = 0
for i in range(1, amount + 1):
for j in range(n):
if nums[j] > i:
break
dp[i] = min(dp[i... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP NUMBER VAR BIN_OP VAR VAR VAR IF VAR VAR NUMBER ... |
[INSPION FullBand Master - INSPION](https://www.youtube.com/watch?v=kwsciXm_7sA)
[INSPION - IOLITE-SUNSTONE](https://www.youtube.com/watch?v=kwsciXm_7sA)
On another floor of the A.R.C. Markland-N, the young man Simon "Xenon" Jackson, takes a break after finishing his project early (as always). Having a lot of free ti... | import sys
inp = [int(x) for x in sys.stdin.read().split()]
ii = 0
n = inp[ii]
ii += 1
coupl = [[] for _ in range(n)]
for _ in range(n - 1):
u = inp[ii] - 1
ii += 1
v = inp[ii] - 1
ii += 1
coupl[u].append(v)
coupl[v].append(u)
bfs = [0]
found = [0] * n
found[0] = 1
for node in bfs:
for nei ... | IMPORT ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL ... |
[INSPION FullBand Master - INSPION](https://www.youtube.com/watch?v=kwsciXm_7sA)
[INSPION - IOLITE-SUNSTONE](https://www.youtube.com/watch?v=kwsciXm_7sA)
On another floor of the A.R.C. Markland-N, the young man Simon "Xenon" Jackson, takes a break after finishing his project early (as always). Having a lot of free ti... | import sys
inp = [int(x) for x in sys.stdin.buffer.read().split()]
ii = 0
n = inp[ii]
ii += 1
coupl = [[] for _ in range(n)]
for _ in range(n - 1):
u = inp[ii] - 1
ii += 1
v = inp[ii] - 1
ii += 1
coupl[u].append(v)
coupl[v].append(u)
bfs = [0]
found = [0] * n
found[0] = 1
for node in bfs:
f... | IMPORT ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL ... |
[INSPION FullBand Master - INSPION](https://www.youtube.com/watch?v=kwsciXm_7sA)
[INSPION - IOLITE-SUNSTONE](https://www.youtube.com/watch?v=kwsciXm_7sA)
On another floor of the A.R.C. Markland-N, the young man Simon "Xenon" Jackson, takes a break after finishing his project early (as always). Having a lot of free ti... | import sys
INF = 10**10
def main():
n = get_int()
coupl = [[] for _ in range(n)]
for _ in range(n - 1):
u, v = get_list()
coupl[u - 1].append(v - 1)
coupl[v - 1].append(u - 1)
bfs = [0]
found = [0] * n
found[0] = 1
for node in bfs:
for nei in coupl[node]:
... | IMPORT ASSIGN VAR BIN_OP NUMBER NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST NUMBER ASSIGN ... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | import sys
n, *x = map(int, sys.stdin.read().split())
x.sort()
def main():
res1 = set()
for i in x:
if not i - 1 in res1:
res1.add(i - 1)
elif not i in res1:
res1.add(i)
elif not i + 1 in res1:
res1.add(i + 1)
else:
continue
... | IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR ... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | n = int(input())
a = list(map(int, input().split()))
a.sort()
dp1 = [0] * (n + 2)
dp2 = [0] * (n + 2)
for i in range(n):
if dp1[a[i] - 1] == 0:
dp1[a[i] - 1] = 1
elif dp1[a[i]] == 0:
dp1[a[i]] = 1
else:
dp1[a[i] + 1] = 1
if dp2[a[i] - 1] == 1 or dp2[a[i] + 1] == 1 or dp2[a[i]] ==... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER NUMB... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | n = int(input())
a = list(map(int, input().split()))
b = [0] * (n + 2)
c = [0] * (n + 2)
for i in range(n):
c[a[i]] += 1
b[a[i]] = 1
for i in range(len(c) - 1):
if c[i] == 0 and c[i + 1] > 0:
c[i] = 1
c[i + 1] -= 1
for i in range(len(c) - 1, 0, -1):
if c[i] == 0 and c[i - 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 BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR ... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | n = int(input())
ar = list(map(int, input().split()))
ar = sorted(ar)
ar2 = sorted(list(set(ar)))
a = set()
for x in ar:
if x - 1 not in a:
a.add(x - 1)
elif x not in a:
a.add(x)
else:
a.add(x + 1)
k = len(ar2)
i = 0
while i < len(ar2):
if i + 1 < len(ar2):
if ar2[i] == a... | 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 VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | def maxfind(arr):
covered = set()
i = 0
while i < len(arr):
if (
arr[i] not in covered
and arr[i] - 1 not in covered
and arr[i] + i not in covered
):
covered.add(arr[i] + 1)
i += 1
return len(covered)
def minfind(arr):
covered... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR NUMBER RETURN FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR N... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | n = int(input())
l = list(map(int, input().split()))
l.sort()
ll = l.copy()
up = 1
left = l[0]
for i in range(n):
if l[i] > left + 2:
left = l[i]
up += 1
ll[0] -= 1
for i in range(1, n - 1):
if ll[i - 1] == ll[i]:
if ll[i] != ll[i + 1]:
ll[i] += 1
elif ll[i - 1] == ll[i] ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBE... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | n = int(input())
s = sorted([int(i) for i in input().split()])
k1, k2 = 0, 0
v = [int(s[0]) - 1]
q = [int(s[0]) + 1]
for i in range(1, n):
if int(s[i]) - q[-1] > 1:
q.append(s[i] + 1)
if v[-1] != int(s[i]) + 1:
v.append(max(v[-1] + 1, int(s[i]) - 1))
print(len(q), len(v)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR LIST BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR LIST BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP FUNC_CALL VAR VAR VAR VAR NU... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
b = sorted(set(a))
mn = 0
i = 0
while i < len(b):
if i + 2 < len(b) and b[i + 2] <= b[i] + 2:
mn += 1
i += 3
elif i + 1 < len(b) and b[i + 1] <= b[i] + 2:
mn += 1
i += 2
else:
... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER VA... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | n = int(input())
s = [int(x) for x in input().split()]
kk = dict()
s = sorted(s)
c2 = 0
for i in range(0, len(s)):
if kk.get(s[i] - 1) == None:
kk[s[i] - 1] = 1
c2 += 1
elif kk.get(s[i]) == None:
kk[s[i]] = 1
c2 += 1
elif kk.get(s[i] + 1) == None:
kk[s[i] + 1] = 1
... | 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 VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER NONE ASSIGN VAR BIN_OP VAR VAR NUMBER NUMBER VAR NUMBER IF FUNC_CA... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | n = int(input())
a = list(map(int, input().split()))
a.sort()
vismax = [(0) for i in range(n + 2)]
vismin = [(0) for i in range(n + 2)]
for i in a:
if vismax[i - 1] == 0:
vismax[i - 1] = 1
elif vismax[i] == 0:
vismax[i] = 1
else:
vismax[i + 1] = 1
a = list(set(a))
a.sort()
for i in a... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR VAR IF VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER IF VAR ... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | n = int(input())
fpos = list(map(int, input().rstrip().split()))
fpos = sorted(fpos)
fcount = 0
i = 0
last = -1
maxpos = 0
while i < n:
current = fpos[i]
fcount = 1
while i < n - 1 and fpos[i + 1] == current:
fcount += 1
i += 1
if current - last > 1:
maxpos += 1
last = cu... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VA... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | n = int(input())
ls = list(map(int, input().split()))
ls.sort()
minh = set()
maxh = set()
for e in ls:
if e - 1 not in maxh:
maxh.add(e - 1)
elif e not in maxh:
maxh.add(e)
else:
maxh.add(e + 1)
if e - 1 not in minh and e not in minh and e + 1 not in minh:
minh.add(e + 1)... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | n = int(input())
ar = list(map(int, input().split()))
used1 = [0] * (n + 3)
used2 = [0] * (n + 3)
ar.sort()
kol = 0
for i in range(n):
if used1[ar[i] - 1] == 0:
if used1[ar[i]] == 0:
if used1[ar[i] + 1] == 0:
kol += 1
used1[ar[i]] = 1
used1[ar[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 BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR VAR NUMBER NUMBER IF VAR VAR VAR NUMB... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | n = int(input())
v = list(map(int, input().split()))
vaz = [(0) for x in range(n + 10)]
vaz1 = [(0) for x in range(n + 10)]
for x in v:
vaz[x] += 1
ans1 = 0
pz = 1
while pz <= n:
if vaz[pz] == 0:
pz += 1
continue
ans1 += 1
pz += 3
for i in range(1, n + 1):
if vaz[i] == 0:
con... | 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 VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR NUMBER VAR NUMBER ... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | from sys import stdin, stdout
def getmin(n, xa):
xl = [0] * (n + 2)
for x in xa:
xl[x] += 1
res = 0
cur = 0
while cur <= n:
if xl[cur] == 0:
cur += 1
continue
res += 1
cur += 3
return res
def getmax(n, xa):
xl = [0] * (n + 2)
fo... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSI... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | n = int(input())
x = sorted(map(int, input().split()))
min_last = max_last = -2
min_houses = max_houses = 0
for position in x:
if min_last < position - 1:
min_last = position + 1
min_houses += 1
if max_last < position + 1:
max_last = max(max_last + 1, position - 1)
max_houses += ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR NUM... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | n = int(input())
x = list(map(int, input().split()))
x.sort()
D = dict()
mi = 0
ma = 0
la = -2
lam = -2
cl = 3
U = set()
for i in x:
cl = min(3, cl + min(3, i - la))
if i - lam > 1:
mi += 1
lam = i + 1
la = i
if cl != 0:
ma += 1
cl -= 1
print(mi, ma) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR ... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | n = int(input())
a_max, a_min = [0] * (n + 10), [0] * (n + 10)
for x in map(int, input().split()):
a_max[x] += 1
a_min[x] += 1
ans_min = 0
for i in range(1, n + 2):
if a_max[i] and a_max[i - 1] == 0:
a_max[i - 1] = 1
a_max[i] -= 1
if a_min[i - 1]:
a_min[i - 1] = a_min[i] = a_min[... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN ... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | n = int(input())
a = list(map(int, input().split()))
a.sort()
b = [0] * (n + 2)
for i in a:
b[i] = 1
i = 1
c = [0] * (n + 2)
while i <= n:
if b[i] == 1:
if b[i - 1] == 1:
b[i] = 0
elif b[i + 1] == 1:
i += 1
b[i - 1] = 0
else:
i += 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER WHILE VAR VAR IF VAR VAR NUMBER IF VAR BIN_OP V... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | n = int(input())
ch = input()
L = [int(i) for i in ch.split()]
L.sort()
L2 = L.copy()
s = set()
L3 = L2.copy()
L2[0] -= 1
s.add(L2[0])
for i in range(1, n):
if L2[i] - 1 > L2[i - 1]:
L2[i] -= 1
elif L2[i] > L2[i - 1]:
L2[i] += 0
else:
L2[i] += 1
s.add(L2[i])
x = set()
nb = 0
for ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR VAR NUMBER VAR BIN_O... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | n = int(input())
x = {}
minimum = 0
for i in input().split():
numb = int(i)
x[numb] = x.get(numb, 0) + 1
i = 1
while i <= n:
if x.get(i, 0) is not 0:
i += 2
minimum += 1
i += 1
i = 1
while i <= n:
if x.get(i, 0) is not 0:
if x[i] == 13333337:
i += 1
co... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF FUNC_CALL VAR VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | import sys
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__
n = int(input())
xs = list(map(int, input().split()))
xs.sort()
i = 0
mx = 0
prev = -2
while i < n:
l = xs[i]
ctr = 1
while i < n - 1 and xs[i + 1] <= xs[i] + 1:
i += 1
ctr += 1
r = xs[i]
w = r - l + 1... | IMPORT ASSIGN VAR FUNC_CALL VAR VAR VAR 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 EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER VAR BIN... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | from itertools import *
_, x = open(0)
x = sorted(map(int, x.split()))
i, *y = sorted(set(x))
s = {i + 1}
for i in y:
if not (i - 1 in s or i in s):
s.add(i + 1)
print(len(s), end=" ")
s = set()
for i, t in groupby(x):
t = len(list(t))
if not i - 1 in s and t:
s.add(i - 1)
t -= 1
... | ASSIGN VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER FOR VAR VAR IF BIN_OP VAR NUMBER VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR STRING ASSIGN VAR FUNC_CALL VAR ... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | n = int(input())
a = list(map(int, input().split()))
a.sort()
prev = -2
c = 0
for i in a:
dif = i - prev
if dif > 1:
prev = i + 1
c += 1
ac = 0
lc = -2
for i in a:
if lc < i - 1:
lc = i - 1
ac += 1
elif lc == i - 1:
lc = i
ac += 1
elif lc == i:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR BIN_OP VAR N... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | n = int(input())
sets = []
for i in sorted(list(map(int, input().split()))):
sets.append([i - 1, i + 1])
min_count = 0
i = 0
while i < len(sets):
t = i
i += 1
while i < len(sets) and sets[t][1] >= sets[i][0]:
i += 1
min_count += 1
max_count = 0
i = 0
prev = -1
while i < len(sets):
if pre... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR N... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | n = int(input())
x = list(map(int, input().split()))
h = [(0) for i in range(0, n + 2)]
for i in range(n):
h[x[i]] += 1
m1 = 0
i = 1
while i < n + 2:
if h[i] != 0:
m1 += 1
i += 3
else:
i += 1
for i in range(1, n + 1):
if h[i] != 0:
if h[i - 1] == 0:
h[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 NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR ... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | n = int(input())
house = [int(x) for x in input().split()]
house.sort()
dict1 = {}
for ppl in house:
freq = dict1.get(ppl, 0) + 1
dict1[ppl] = freq
maxres = {}
minres = {}
for key, var in dict1.items():
freqp1 = dict1.get(key + 1, 0)
freqm1 = dict1.get(key - 1, 0)
freqp2 = dict1.get(key + 2, 0)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | from sys import stdin, stdout
input = stdin.readline
t = 1
for _ in range(t):
n = int(input())
a = [int(x) for x in input().split()]
d = {}
for i in a:
d[i] = d.get(i, 0) + 1
vals = sorted(d.keys())
used = set()
for i in vals:
if d[i] >= 3:
used.add(i)
... | ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR ... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | def main():
n = int(input())
xx = [int(a) for a in input().split()]
counts = [0] * (n + 3)
for x in xx:
counts[x] += 1
cmn = counts
cmx = counts.copy()
mn = 0
skip = 0
for c1, c2, c3 in zip(counts, counts[1:], counts[2:]):
if skip > 0:
skip -= 1
... | 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 BIN_OP VAR NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER IF VAR N... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | def find_max(arr, n):
total = [False] * (n + 2)
for i in arr:
if total[i - 1] == False:
total[i - 1] = True
elif total[i] == False:
total[i] = True
elif total[i + 1] == False:
total[i + 1] = True
return sum(total)
def find_min(arr, n):
total ... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR IF VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER RETURN FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR ... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | fac = [(1) for _ in range(1021)]
ifac = [(1) for _ in range(1021)]
mod = 10**9 + 7
def ModInv(x, y):
res = 1
while y > 0:
if y & 1:
res = res * x % mod
y = y >> 1
x = x * x % mod
return res
for i in range(1, 1020):
fac[i] = fac[i - 1] * i % mod
ifac[i] = ifac[... | ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR RETURN VAR FOR VAR F... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | n = int(input())
x = [int(i) for i in input().split()]
x.sort()
a = list(x)
a[0] -= 1
for i in range(1, n):
if a[i] <= a[i - 1]:
a[i] += 1
elif a[i] - 2 >= a[i - 1]:
a[i] -= 1
b = list(x)
b[0] += 1
for i in range(1, n):
if b[i] == b[i - 1] + 1:
b[i] -= 1
elif b[i] == b[i - 1]:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR NUMBER ASSIGN VAR FUNC... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | import sys
LI = lambda: list(map(int, sys.stdin.readline().strip("\n").split()))
MI = lambda: map(int, sys.stdin.readline().strip("\n").split())
SI = lambda: sys.stdin.readline().strip("\n")
II = lambda: int(sys.stdin.readline().strip("\n"))
n = II()
a = sorted(LI())
mn = 1
p = set([a[0] - 1, a[0], a[0] + 1])
ln = [0]... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL V... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | n = int(input())
a = [int(i) for i in input().split()]
b = [0] * (n + 2)
for i in range(n):
b[a[i]] += 1
sq = []
for i in range(1, n + 2):
if b[i] and not b[i - 1]:
cur = i
if not b[i] and b[i - 1]:
tmp = 0
for j in range(cur, i):
tmp += b[j] - 1
tmp = min(tmp, 2)... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR IF VAR VAR VAR BIN_O... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
a.sort()
b = list(a)
occupied = [False] * (n + 5)
for i in range(n):
if occupied[a[i] - 1]:
a[i] -= 1
elif occupied[a[i]]:
pass
else:
a[i] += 1
occupied[a[i]] = True
mn = len(set(a))
occup... | 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 EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR VAR NUMBER VAR VAR NUMBER IF VAR VAR VAR VAR VAR NUM... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | n = int(input())
a = [int(o) for o in input().split()]
a = sorted(a)
s = set()
for i in range(n):
if a[i] - 1 in s:
s.add(a[i] - 1)
elif a[i] in s:
s.add(a[i])
else:
s.add(a[i] + 1)
mi = len(s)
s = set()
for i in range(n):
if a[i] - 1 not in s:
s.add(a[i] - 1)
elif a[... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VA... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | n = int(input())
a = sorted(map(int, input().split()))
lst = -1
max_ans = n
for x in a:
if lst < x - 1:
lst = x - 1
elif lst < x:
lst = x
elif lst < x + 1:
lst = x + 1
else:
max_ans -= 1
a = sorted(set(a))
min_ans = 0
while a:
min_ans += 1
cur = a.pop()
if a a... | 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 VAR FOR VAR VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | n = int(input())
lis = list(map(int, input().split()))
lis.sort()
mares = mires = 0
dpma = [0] * (n + 2)
dpmi = [0] * (n + 2)
for i in lis:
if dpma[i - 1] == 0:
dpma[i - 1] = 1
mares += 1
elif dpma[i] == 0:
dpma[i] = 1
mares += 1
elif dpma[i + 1] == 0:
dpma[i + 1] = 1... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR IF VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMB... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | n = int(input())
x = list(map(int, input().split()))
x.sort()
flag = [False] * (n + 2)
for xi in x:
if not flag[xi - 1]:
flag[xi - 1] = True
elif not flag[xi]:
flag[xi] = True
else:
flag[xi + 1] = True
ans1 = flag.count(True)
x = list(set(x))
flag = [False] * (n + 2)
for xi in x:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER ASSIG... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | nn = list(map(int, input().split(" ")))
h = list(map(int, input().split(" ")))
h = sorted(h)
hsetmax = set()
hsetmin = set()
for i in range(len(h)):
for j in range(-1, 2):
if h[i] + j in hsetmin:
break
elif j == 1:
hsetmin.add(h[i] + 1)
for j in range(-1, 2):
if h... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP VAR VAR... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | import sys
n = int(input())
input = sys.stdin.readline
a = [int(x) for x in input().split()]
d = {}
dp = [(0) for i in range(n + 2)]
count = [(0) for i in range(n + 1)]
for i in a:
count[i] += 1
s = set(a)
a = list(s)
a.sort()
for i in a:
if count[i] == 1 and dp[i] == 0:
if dp[i - 1] == 0:
... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL V... |
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... | n = int(input())
arr = list(map(int, input().split()))
v = [0] * 200005
for i in arr:
v[i] += 1
p1 = -1
p2 = -1
l = 0
h = 0
for i in range(1, n + 1):
if v[i] and p1 < i - 1:
l += 1
p1 = i + 1
if v[i] and p2 < i - 1:
h += 1
p2 = i - 1
v[i] -= 1
if v[i] and p2 < 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 FOR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBE... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.