Dataset Viewer
Auto-converted to Parquet Duplicate
code
stringlengths
51
912
input
stringlengths
11
330
output
stringlengths
0
266
prompt_token_length
int64
59
615
execution_time
float64
0.04
6.03k
prompt
stringlengths
255
1.16k
def function(s: str) -> int: ss = set() i = ans = 0 for j, c in enumerate(s): while c in ss: ss.remove(s[i]) i += 1 ss.add(c) ans = max(ans, j - i + 1) return ans
function('M1kCixrcvS')
10
122
2.019239
Code: def function(s: str) -> int: ss = set() i = ans = 0 for j, c in enumerate(s): while c in ss: ss.remove(s[i]) i += 1 ss.add(c) ans = max(ans, j - i + 1) return ans Evaluate this code with the following inputs : function('M1kCixrcvS') Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(height: List[int]) -> int: i, j = 0, len(height) - 1 ans = 0 while i < j: t = (j - i) * min(height[i], height[j]) ans = max(ans, t) if height[i] < height[j]: i += 1 else: j -= 1 return ans
function([3525, 8157, 7774, 2773, 1223, 3711, 6932, 4556, 9908, 7833])
62664
170
2.538857
Code: def function(height: List[int]) -> int: i, j = 0, len(height) - 1 ans = 0 while i < j: t = (j - i) * min(height[i], height[j]) ans = max(ans, t) if height[i] < height[j]: i += 1 else: j -= 1 return ans Evaluate this code with the following inputs : function([3525, 8157, 7774, 2773, 1223, 3711, 6932, 4556, 9908, 7833]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(nums: List[int]) -> int: k = 0 for x in nums: if k == 0 or x != nums[k - 1]: nums[k] = x k += 1 return k
function([-95, -92, -85, -79, -74, -36, -20, 47, 78, 97])
10
125
0.598046
Code: def function(nums: List[int]) -> int: k = 0 for x in nums: if k == 0 or x != nums[k - 1]: nums[k] = x k += 1 return k Evaluate this code with the following inputs : function([-95, -92, -85, -79, -74, -36, -20, 47, 78, 97]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(haystack: str, needle: str) -> int: n, m = len(haystack), len(needle) for i in range(n - m + 1): if haystack[i : i + m] == needle: return i return -1
function("hwkaagrejn", "jvscj")
-1
116
0.706176
Code: def function(haystack: str, needle: str) -> int: n, m = len(haystack), len(needle) for i in range(n - m + 1): if haystack[i : i + m] == needle: return i return -1 Evaluate this code with the following inputs : function("hwkaagrejn", "jvscj") Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(a: int, b: int) -> int: if b == 1: return a if a == -(2**31) and b == -1: return 2**31 - 1 sign = (a > 0 and b > 0) or (a < 0 and b < 0) a = -a if a > 0 else a b = -b if b > 0 else b ans = 0 while a <= b: x = b cnt = 1 while x >= (-(2**30)) and a <= (x << 1): x <<= 1 cnt <<= 1 a -= x ans += cnt return ans if sign else -ans
function(-2041525908, -1081395510)
1
227
0.276367
Code: def function(a: int, b: int) -> int: if b == 1: return a if a == -(2**31) and b == -1: return 2**31 - 1 sign = (a > 0 and b > 0) or (a < 0 and b < 0) a = -a if a > 0 else a b = -b if b > 0 else b ans = 0 while a <= b: x = b cnt = 1 while x >= (-(2**30)) and a <= (x << 1): x <<= 1 cnt <<= 1 a -= x ans += cnt return ans if sign else -ans Evaluate this code with the following inputs : function(-2041525908, -1081395510) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(s: str) -> int: n = len(s) f = [0] * (n + 1) for i, c in enumerate(s, 1): if c == ")": if i > 1 and s[i - 2] == "(": f[i] = f[i - 2] + 2 else: j = i - f[i - 1] - 1 if j and s[j - 1] == "(": f[i] = f[i - 1] + 2 + f[j - 1] return max(f)
function('((()))(()(')
6
181
1.204527
Code: def function(s: str) -> int: n = len(s) f = [0] * (n + 1) for i, c in enumerate(s, 1): if c == ")": if i > 1 and s[i - 2] == "(": f[i] = f[i - 2] + 2 else: j = i - f[i - 1] - 1 if j and s[j - 1] == "(": f[i] = f[i - 1] + 2 + f[j - 1] return max(f) Evaluate this code with the following inputs : function('((()))(()(') Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(strs: List[str]) -> List[List[str]]: d = defaultdict(list) for s in strs: k = "".join(sorted(s)) d[k].append(s) return list(d.values())
function(['prsdukkvk', 'sshcgcomq', 'wouq', 'rlf', 'clveitb', 'hzkunsthp', 'ajdaaldbpd', 'ldxskzk', 'pygpmz', 'ymtnzrhka'])
[['prsdukkvk'], ['sshcgcomq'], ['wouq'], ['rlf'], ['clveitb'], ['hzkunsthp'], ['ajdaaldbpd'], ['ldxskzk'], ['pygpmz'], ['ymtnzrhka']]
147
5.82674
Code: def function(strs: List[str]) -> List[List[str]]: d = defaultdict(list) for s in strs: k = "".join(sorted(s)) d[k].append(s) return list(d.values()) Evaluate this code with the following inputs : function(['prsdukkvk', 'sshcgcomq', 'wouq', 'rlf', 'clveitb', 'hzkunsthp', 'ajdaaldbpd', 'ldxskzk', 'pygpmz', 'ymtnzrhka']) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(intervals: List[List[int]]) -> List[List[int]]: intervals.sort() ans = [intervals[0]] for s, e in intervals[1:]: if ans[-1][1] < s: ans.append([s, e]) else: ans[-1][1] = max(ans[-1][1], e) return ans
function([[2573, 9230], [3027, 4881], [3389, 4678], [3508, 5608], [3553, 9230], [3911, 6711], [5968, 7433], [6775, 8778], [7384, 8169], [8472, 9067]])
[[2573, 9230]]
201
2.60338
Code: def function(intervals: List[List[int]]) -> List[List[int]]: intervals.sort() ans = [intervals[0]] for s, e in intervals[1:]: if ans[-1][1] < s: ans.append([s, e]) else: ans[-1][1] = max(ans[-1][1], e) return ans Evaluate this code with the following inputs : function([[2573, 9230], [3027, 4881], [3389, 4678], [3508, 5608], [3553, 9230], [3911, 6711], [5968, 7433], [6775, 8778], [7384, 8169], [8472, 9067]]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(m: int, n: int) -> int: f = [1] * n for _ in range(1, m): for j in range(1, n): f[j] += f[j - 1] return f[-1]
function(10, 10)
48620
106
5.336593
Code: def function(m: int, n: int) -> int: f = [1] * n for _ in range(1, m): for j in range(1, n): f[j] += f[j - 1] return f[-1] Evaluate this code with the following inputs : function(10, 10) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(obstacleGrid: List[List[int]]) -> int: m, n = len(obstacleGrid), len(obstacleGrid[0]) dp = [[0] * n for _ in range(m)] for i in range(m): if obstacleGrid[i][0] == 1: break dp[i][0] = 1 for j in range(n): if obstacleGrid[0][j] == 1: break dp[0][j] = 1 for i in range(1, m): for j in range(1, n): if obstacleGrid[i][j] == 0: dp[i][j] = dp[i - 1][j] + dp[i][j - 1] return dp[-1][-1]
function([[1, 0, 1, 0, 0, 1, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 1, 1, 0, 1], [0, 0, 1, 0, 1, 1, 1, 1, 0, 1], [0, 1, 1, 0, 1, 0, 1, 1, 1, 0], [1, 1, 0, 1, 1, 0, 0, 1, 1, 0], [1, 0, 1, 0, 1, 0, 1, 1, 0, 1], [0, 0, 1, 1, 1, 1, 1, 0, 1, 1], [1, 0, 0, 1, 1, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 1, 1, 1, 0, 0], [1, 0, 1, 1, 1, 0, 1, 1, 1, 0]])
0
515
8.432212
Code: def function(obstacleGrid: List[List[int]]) -> int: m, n = len(obstacleGrid), len(obstacleGrid[0]) dp = [[0] * n for _ in range(m)] for i in range(m): if obstacleGrid[i][0] == 1: break dp[i][0] = 1 for j in range(n): if obstacleGrid[0][j] == 1: break dp[0][j] = 1 for i in range(1, m): for j in range(1, n): if obstacleGrid[i][j] == 0: dp[i][j] = dp[i - 1][j] + dp[i][j - 1] return dp[-1][-1] Evaluate this code with the following inputs : function([[1, 0, 1, 0, 0, 1, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 1, 1, 0, 1], [0, 0, 1, 0, 1, 1, 1, 1, 0, 1], [0, 1, 1, 0, 1, 0, 1, 1, 1, 0], [1, 1, 0, 1, 1, 0, 0, 1, 1, 0], [1, 0, 1, 0, 1, 0, 1, 1, 0, 1], [0, 0, 1, 1, 1, 1, 1, 0, 1, 1], [1, 0, 0, 1, 1, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 1, 1, 1, 0, 0], [1, 0, 1, 1, 1, 0, 1, 1, 1, 0]]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(a: str, b: str) -> str: ans = [] i, j, carry = len(a) - 1, len(b) - 1, 0 while i >= 0 or j >= 0 or carry: carry += (0 if i < 0 else int(a[i])) + (0 if j < 0 else int(b[j])) carry, v = divmod(carry, 2) ans.append(str(v)) i, j = i - 1, j - 1 return "".join(ans[::-1])
function('01110100101', '00101101100')
10100010001
178
4.594124
Code: def function(a: str, b: str) -> str: ans = [] i, j, carry = len(a) - 1, len(b) - 1, 0 while i >= 0 or j >= 0 or carry: carry += (0 if i < 0 else int(a[i])) + (0 if j < 0 else int(b[j])) carry, v = divmod(carry, 2) ans.append(str(v)) i, j = i - 1, j - 1 return "".join(ans[::-1]) Evaluate this code with the following inputs : function('01110100101', '00101101100') Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(x: int) -> int: left, right = 0, x while left < right: mid = (left + right + 1) >> 1 # mid*mid <= x if mid <= x // mid: left = mid else: right = mid - 1 return left
function(1183590127)
34403
123
4.436166
Code: def function(x: int) -> int: left, right = 0, x while left < right: mid = (left + right + 1) >> 1 # mid*mid <= x if mid <= x // mid: left = mid else: right = mid - 1 return left Evaluate this code with the following inputs : function(1183590127) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(word1: str, word2: str) -> int: m, n = len(word1), len(word2) f = [[0] * (n + 1) for _ in range(m + 1)] for j in range(1, n + 1): f[0][j] = j for i, a in enumerate(word1, 1): f[i][0] = i for j, b in enumerate(word2, 1): if a == b: f[i][j] = f[i - 1][j - 1] else: f[i][j] = min(f[i - 1][j], f[i][j - 1], f[i - 1][j - 1]) + 1 return f[m][n]
function('yiankxxmex', 'htdtexaxgf')
9
237
26.201205
Code: def function(word1: str, word2: str) -> int: m, n = len(word1), len(word2) f = [[0] * (n + 1) for _ in range(m + 1)] for j in range(1, n + 1): f[0][j] = j for i, a in enumerate(word1, 1): f[i][0] = i for j, b in enumerate(word2, 1): if a == b: f[i][j] = f[i - 1][j - 1] else: f[i][j] = min(f[i - 1][j], f[i][j - 1], f[i - 1][j - 1]) + 1 return f[m][n] Evaluate this code with the following inputs : function('yiankxxmex', 'htdtexaxgf') Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(nums: List[int]) -> int: k = 0 for x in nums: if k < 2 or x != nums[k - 2]: nums[k] = x k += 1 return k
function([-8620, -7574, -5049, -4784, -3981, -2633, -1102, -1057, 1630, 5796, 8666])
11
139
0.612414
Code: def function(nums: List[int]) -> int: k = 0 for x in nums: if k < 2 or x != nums[k - 2]: nums[k] = x k += 1 return k Evaluate this code with the following inputs : function([-8620, -7574, -5049, -4784, -3981, -2633, -1102, -1057, 1630, 5796, 8666]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(s: str) -> int: f, g = 0, 1 for i, c in enumerate(s, 1): h = g if c != "0" else 0 if i > 1 and s[i - 2] != "0" and int(s[i - 2 : i]) <= 26: h += f f, g = g, h return g
function('4311330975')
0
142
2.334241
Code: def function(s: str) -> int: f, g = 0, 1 for i, c in enumerate(s, 1): h = g if c != "0" else 0 if i > 1 and s[i - 2] != "0" and int(s[i - 2 : i]) <= 26: h += f f, g = g, h return g Evaluate this code with the following inputs : function('4311330975') Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(n: int) -> int: f = [1] + [0] * n for i in range(n + 1): for j in range(i): f[i] += f[j] * f[i - j - 1] return f[n]
function(16)
35357670
105
12.91389
Code: def function(n: int) -> int: f = [1] + [0] * n for i in range(n + 1): for j in range(i): f[i] += f[j] * f[i - j - 1] return f[n] Evaluate this code with the following inputs : function(16) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(s: str, t: str) -> int: n = len(t) f = [1] + [0] * n for a in s: for j in range(n, 0, -1): if a == t[j - 1]: f[j] += f[j - 1] return f[n]
function('ggxpcxododc', 'ldbialcpxpj')
0
134
7.356766
Code: def function(s: str, t: str) -> int: n = len(t) f = [1] + [0] * n for a in s: for j in range(n, 0, -1): if a == t[j - 1]: f[j] += f[j - 1] return f[n] Evaluate this code with the following inputs : function('ggxpcxododc', 'ldbialcpxpj') Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(rowIndex: int) -> List[int]: f = [1] * (rowIndex + 1) for i in range(2, rowIndex + 1): for j in range(i - 1, 0, -1): f[j] += f[j - 1] return f
function(12)
[1, 12, 66, 220, 495, 792, 924, 792, 495, 220, 66, 12, 1]
112
4.845559
Code: def function(rowIndex: int) -> List[int]: f = [1] * (rowIndex + 1) for i in range(2, rowIndex + 1): for j in range(i - 1, 0, -1): f[j] += f[j - 1] return f Evaluate this code with the following inputs : function(12) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(prices: List[int]) -> int: f1, f2, f3, f4 = -prices[0], 0, -prices[0], 0 for price in prices[1:]: f1 = max(f1, -price) f2 = max(f2, f1 + price) f3 = max(f3, f2 - price) f4 = max(f4, f3 + price) return f4
function([20, 81, 85, 62, 75, 38, 33, 42, 100, 54, 16, 43])
132
180
5.53898
Code: def function(prices: List[int]) -> int: f1, f2, f3, f4 = -prices[0], 0, -prices[0], 0 for price in prices[1:]: f1 = max(f1, -price) f2 = max(f2, f1 + price) f3 = max(f3, f2 - price) f4 = max(f4, f3 + price) return f4 Evaluate this code with the following inputs : function([20, 81, 85, 62, 75, 38, 33, 42, 100, 54, 16, 43]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(s: str) -> int: n = len(s) g = [[True] * n for _ in range(n)] for i in range(n - 1, -1, -1): for j in range(i + 1, n): g[i][j] = s[i] == s[j] and g[i + 1][j - 1] f = list(range(n)) for i in range(1, n): for j in range(i + 1): if g[j][i]: f[i] = min(f[i], 1 + f[j - 1] if j else 0) return f[-1]
function("iahrmfwvfh")
9
196
10.238756
Code: def function(s: str) -> int: n = len(s) g = [[True] * n for _ in range(n)] for i in range(n - 1, -1, -1): for j in range(i + 1, n): g[i][j] = s[i] == s[j] and g[i + 1][j - 1] f = list(range(n)) for i in range(1, n): for j in range(i + 1): if g[j][i]: f[i] = min(f[i], 1 + f[j - 1] if j else 0) return f[-1] Evaluate this code with the following inputs : function("iahrmfwvfh") Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(gas: List[int], cost: List[int]) -> int: n = len(gas) i = j = n - 1 cnt = s = 0 while cnt < n: s += gas[j] - cost[j] cnt += 1 j = (j + 1) % n while s < 0 and cnt < n: i -= 1 s += gas[i] - cost[i] cnt += 1 return -1 if s < 0 else i
function([13, 93, 71, 17, 60, 11, 4, 54, 96, 5], [24, 73, 25, 97, 81, 51, 100, 78, 90, 98])
-1
221
0.964128
Code: def function(gas: List[int], cost: List[int]) -> int: n = len(gas) i = j = n - 1 cnt = s = 0 while cnt < n: s += gas[j] - cost[j] cnt += 1 j = (j + 1) % n while s < 0 and cnt < n: i -= 1 s += gas[i] - cost[i] cnt += 1 return -1 if s < 0 else i Evaluate this code with the following inputs : function([13, 93, 71, 17, 60, 11, 4, 54, 96, 5], [24, 73, 25, 97, 81, 51, 100, 78, 90, 98]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(s: str) -> str: return ' '.join(reversed(s.split()))
function('wd3g5r9u45')
wd3g5r9u45
70
0.261327
Code: def function(s: str) -> str: return ' '.join(reversed(s.split())) Evaluate this code with the following inputs : function('wd3g5r9u45') Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(nums: List[int]) -> int: left, right = 0, len(nums) - 1 while left < right: mid = (left + right) >> 1 if nums[mid] > nums[right]: left = mid + 1 elif nums[mid] < nums[right]: right = mid else: right -= 1 return nums[left]
function([-4712, -4580, -4331, -3877, -3833, -3643, -3604, -3288, -3233, -2987, -2845, -2657, 1812, 1819, 2944, 2974, 3498, 3513, 4293, 4693])
-4712
209
0.546744
Code: def function(nums: List[int]) -> int: left, right = 0, len(nums) - 1 while left < right: mid = (left + right) >> 1 if nums[mid] > nums[right]: left = mid + 1 elif nums[mid] < nums[right]: right = mid else: right -= 1 return nums[left] Evaluate this code with the following inputs : function([-4712, -4580, -4331, -3877, -3833, -3643, -3604, -3288, -3233, -2987, -2845, -2657, 1812, 1819, 2944, 2974, 3498, 3513, 4293, 4693]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(s: str) -> int: cnt = Counter() ans = j = 0 for i, c in enumerate(s): cnt[c] += 1 while len(cnt) > 2: cnt[s[j]] -= 1 if cnt[s[j]] == 0: cnt.pop(s[j]) j += 1 ans = max(ans, i - j + 1) return ans
function('tytyqzhskq')
4
145
6.38951
Code: def function(s: str) -> int: cnt = Counter() ans = j = 0 for i, c in enumerate(s): cnt[c] += 1 while len(cnt) > 2: cnt[s[j]] -= 1 if cnt[s[j]] == 0: cnt.pop(s[j]) j += 1 ans = max(ans, i - j + 1) return ans Evaluate this code with the following inputs : function('tytyqzhskq') Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(nums: List[int]) -> int: left, right = 0, len(nums) - 1 while left < right: mid = (left + right) >> 1 if nums[mid] > nums[mid + 1]: right = mid else: left = mid + 1 return left
function([59, 92, 35, 72, 49, 95, 21, 26, 100, 52])
8
146
0.303174
Code: def function(nums: List[int]) -> int: left, right = 0, len(nums) - 1 while left < right: mid = (left + right) >> 1 if nums[mid] > nums[mid + 1]: right = mid else: left = mid + 1 return left Evaluate this code with the following inputs : function([59, 92, 35, 72, 49, 95, 21, 26, 100, 52]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(nums: List[int]) -> int: cnt = m = 0 for x in nums: if cnt == 0: m, cnt = x, 1 else: cnt += 1 if m == x else -1 return m
function([-967885469, -359737629, -612714328, -215417376, -163383858, -107561768, 484314953, -702852431, -312267793, 670909464])
-312267793
152
0.360494
Code: def function(nums: List[int]) -> int: cnt = m = 0 for x in nums: if cnt == 0: m, cnt = x, 1 else: cnt += 1 if m == x else -1 return m Evaluate this code with the following inputs : function([-967885469, -359737629, -612714328, -215417376, -163383858, -107561768, 484314953, -702852431, -312267793, 670909464]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(k: int, prices: List[int]) -> int: f = [[0] * 2 for _ in range(k + 1)] for j in range(1, k + 1): f[j][1] = -prices[0] for x in prices[1:]: for j in range(k, 0, -1): f[j][0] = max(f[j][1] + x, f[j][0]) f[j][1] = max(f[j - 1][0] - x, f[j][1]) return f[k][0]
function(7, [607, 106, 823, 386, 297, 675, 953, 248, 948, 410])
2073
204
23.355832
Code: def function(k: int, prices: List[int]) -> int: f = [[0] * 2 for _ in range(k + 1)] for j in range(1, k + 1): f[j][1] = -prices[0] for x in prices[1:]: for j in range(k, 0, -1): f[j][0] = max(f[j][1] + x, f[j][0]) f[j][1] = max(f[j - 1][0] - x, f[j][1]) return f[k][0] Evaluate this code with the following inputs : function(7, [607, 106, 823, 386, 297, 675, 953, 248, 948, 410]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(n: int) -> int: res = 0 for i in range(32): res |= (n & 1) << (31 - i) n >>= 1 return res
function(1227314084)
634053778
95
3.215068
Code: def function(n: int) -> int: res = 0 for i in range(32): res |= (n & 1) << (31 - i) n >>= 1 return res Evaluate this code with the following inputs : function(1227314084) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(n: int) -> int: ans = 0 while n: n &= n - 1 ans += 1 return ans
function(1243866809)
16
84
1.207592
Code: def function(n: int) -> int: ans = 0 while n: n &= n - 1 ans += 1 return ans Evaluate this code with the following inputs : function(1243866809) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(left: int, right: int) -> int: while left < right: right &= right - 1 return right
function(995, 1003)
992
79
0.19118
Code: def function(left: int, right: int) -> int: while left < right: right &= right - 1 return right Evaluate this code with the following inputs : function(995, 1003) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(n: int) -> int: dp = [1] * n p2 = p3 = p5 = 0 for i in range(1, n): next2, next3, next5 = dp[p2] * 2, dp[p3] * 3, dp[p5] * 5 dp[i] = min(next2, next3, next5) if dp[i] == next2: p2 += 1 if dp[i] == next3: p3 += 1 if dp[i] == next5: p5 += 1 return dp[n - 1]
function(1046)
69120000
191
307.597719
Code: def function(n: int) -> int: dp = [1] * n p2 = p3 = p5 = 0 for i in range(1, n): next2, next3, next5 = dp[p2] * 2, dp[p3] * 3, dp[p5] * 5 dp[i] = min(next2, next3, next5) if dp[i] == next2: p2 += 1 if dp[i] == next3: p3 += 1 if dp[i] == next5: p5 += 1 return dp[n - 1] Evaluate this code with the following inputs : function(1046) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(costs: List[List[int]]) -> int: n, k = len(costs), len(costs[0]) f = costs[0][:] for i in range(1, n): g = costs[i][:] for j in range(k): t = min(f[h] for h in range(k) if h != j) g[j] += t f = g return min(f)
function([[18, 21, 10, 13, 3, 15], [12, 20, 3, 6, 16, 19], [13, 6, 7, 13, 19, 2], [5, 10, 12, 11, 16, 20], [10, 13, 6, 16, 14, 9], [5, 5, 1, 9, 1, 13], [15, 10, 13, 7, 3, 6], [16, 5, 19, 5, 1, 13], [9, 15, 2, 17, 5, 10], [16, 7, 10, 15, 5, 13], [6, 14, 7, 20, 17, 17]])
40
333
43.928418
Code: def function(costs: List[List[int]]) -> int: n, k = len(costs), len(costs[0]) f = costs[0][:] for i in range(1, n): g = costs[i][:] for j in range(k): t = min(f[h] for h in range(k) if h != j) g[j] += t f = g return min(f) Evaluate this code with the following inputs : function([[18, 21, 10, 13, 3, 15], [12, 20, 3, 6, 16, 19], [13, 6, 7, 13, 19, 2], [5, 10, 12, 11, 16, 20], [10, 13, 6, 16, 14, 9], [5, 5, 1, 9, 1, 13], [15, 10, 13, 7, 3, 6], [16, 5, 19, 5, 1, 13], [9, 15, 2, 17, 5, 10], [16, 7, 10, 15, 5, 13], [6, 14, 7, 20, 17, 17]]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(citations: List[int]) -> int: n = len(citations) cnt = [0] * (n + 1) for x in citations: cnt[min(x, n)] += 1 s = 0 for h in range(n, -1, -1): s += cnt[h] if s >= h: return h
function([31, 395, 254, 625, 818, 7, 625, 748, 476, 371, 394, 262, 868, 651, 231, 240, 868, 470, 101, 214, 761, 746, 26, 613, 618, 551, 792, 971, 258, 511, 552, 616, 43, 484, 496, 546, 798, 974, 805, 48, 244, 325, 213, 651, 14, 996, 746, 512, 501, 429, 388])
46
277
7.192416
Code: def function(citations: List[int]) -> int: n = len(citations) cnt = [0] * (n + 1) for x in citations: cnt[min(x, n)] += 1 s = 0 for h in range(n, -1, -1): s += cnt[h] if s >= h: return h Evaluate this code with the following inputs : function([31, 395, 254, 625, 818, 7, 625, 748, 476, 371, 394, 262, 868, 651, 231, 240, 868, 470, 101, 214, 761, 746, 26, 613, 618, 551, 792, 971, 258, 511, 552, 616, 43, 484, 496, 546, 798, 974, 805, 48, 244, 325, 213, 651, 14, 996, 746, 512, 501, 429, 388]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(prices: List[int]) -> int: f, f0, f1 = 0, 0, -prices[0] for x in prices[1:]: f, f0, f1 = f0, max(f0, f1 + x), max(f1, f - x) return f0
function([409, 997, 614, 247, 139, 605, 755, 513, 815, 278])
1356
144
2.483522
Code: def function(prices: List[int]) -> int: f, f0, f1 = 0, 0, -prices[0] for x in prices[1:]: f, f0, f1 = f0, max(f0, f1 + x), max(f1, f - x) return f0 Evaluate this code with the following inputs : function([409, 997, 614, 247, 139, 605, 755, 513, 815, 278]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(nums: List[int]) -> int: nums = [1] + nums + [1] n = len(nums) dp = [[0] * n for _ in range(n)] for l in range(2, n): for i in range(n - l): j = i + l for k in range(i + 1, j): dp[i][j] = max( dp[i][j], dp[i][k] + dp[k][j] + nums[i] * nums[k] * nums[j] ) return dp[0][-1]
function([46, 76, 19, 40, 59, 31, 78, 36, 96, 65, 18])
2324364
202
79.697287
Code: def function(nums: List[int]) -> int: nums = [1] + nums + [1] n = len(nums) dp = [[0] * n for _ in range(n)] for l in range(2, n): for i in range(n - l): j = i + l for k in range(i + 1, j): dp[i][j] = max( dp[i][j], dp[i][k] + dp[k][j] + nums[i] * nums[k] * nums[j] ) return dp[0][-1] Evaluate this code with the following inputs : function([46, 76, 19, 40, 59, 31, 78, 36, 96, 65, 18]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(s: str) -> str: last = {c: i for i, c in enumerate(s)} stk = [] vis = set() for i, c in enumerate(s): if c in vis: continue while stk and stk[-1] > c and last[stk[-1]] > i: vis.remove(stk.pop()) stk.append(c) vis.add(c) return ''.join(stk)
function('ubcjtlppya')
ubcjtlpya
143
2.213225
Code: def function(s: str) -> str: last = {c: i for i, c in enumerate(s)} stk = [] vis = set() for i, c in enumerate(s): if c in vis: continue while stk and stk[-1] > c and last[stk[-1]] > i: vis.remove(stk.pop()) stk.append(c) vis.add(c) return ''.join(stk) Evaluate this code with the following inputs : function('ubcjtlppya') Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(words: List[str]) -> int: mask = [0] * len(words) ans = 0 for i, s in enumerate(words): for c in s: mask[i] |= 1 << (ord(c) - ord("a")) for j, t in enumerate(words[:i]): if (mask[i] & mask[j]) == 0: ans = max(ans, len(s) * len(t)) return ans
function(['hwq', 'fyvhwhvw', 'wxmyn', 'ivnshwwpuo', 'vdbsmpbi', 'asytohgbp', 'nmqcgtkx', 'yzfmxaqf', 'mtbfbgxkf', 'qotiunwp'])
90
203
13.980531
Code: def function(words: List[str]) -> int: mask = [0] * len(words) ans = 0 for i, s in enumerate(words): for c in s: mask[i] |= 1 << (ord(c) - ord("a")) for j, t in enumerate(words[:i]): if (mask[i] & mask[j]) == 0: ans = max(ans, len(s) * len(t)) return ans Evaluate this code with the following inputs : function(['hwq', 'fyvhwhvw', 'wxmyn', 'ivnshwwpuo', 'vdbsmpbi', 'asytohgbp', 'nmqcgtkx', 'yzfmxaqf', 'mtbfbgxkf', 'qotiunwp']) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(n: int) -> int: if n < 4: return n - 1 if n % 3 == 0: return pow(3, n // 3) if n % 3 == 1: return pow(3, n // 3 - 1) * 4 return pow(3, n // 3) * 2
function(54)
387420489
131
0.157379
Code: def function(n: int) -> int: if n < 4: return n - 1 if n % 3 == 0: return pow(3, n // 3) if n % 3 == 1: return pow(3, n // 3 - 1) * 4 return pow(3, n // 3) * 2 Evaluate this code with the following inputs : function(54) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(s: str) -> str: vowels = "aeiouAEIOU" i, j = 0, len(s) - 1 cs = list(s) while i < j: while i < j and cs[i] not in vowels: i += 1 while i < j and cs[j] not in vowels: j -= 1 if i < j: cs[i], cs[j] = cs[j], cs[i] i, j = i + 1, j - 1 return "".join(cs)
function("4DI3IkulXN")
4Du3IkIlXN
175
0.83976
Code: def function(s: str) -> str: vowels = "aeiouAEIOU" i, j = 0, len(s) - 1 cs = list(s) while i < j: while i < j and cs[i] not in vowels: i += 1 while i < j and cs[j] not in vowels: j -= 1 if i < j: cs[i], cs[j] = cs[j], cs[i] i, j = i + 1, j - 1 return "".join(cs) Evaluate this code with the following inputs : function("4DI3IkulXN") Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(nums1: List[int], nums2: List[int]) -> List[int]: return list(set(nums1) & set(nums2))
function([990, 57, 86, 782, 177, 325, 976, 383, 131], [661, 277, 246, 423, 259, 358, 947, 86, 404])
[86]
125
0.763205
Code: def function(nums1: List[int], nums2: List[int]) -> List[int]: return list(set(nums1) & set(nums2)) Evaluate this code with the following inputs : function([990, 57, 86, 782, 177, 325, 976, 383, 131], [661, 277, 246, 423, 259, 358, 947, 86, 404]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(nums1: List[int], nums2: List[int]) -> List[int]: counter = Counter(nums1) res = [] for num in nums2: if counter[num] > 0: res.append(num) counter[num] -= 1 return res
function([39, 29, 54, 27, 90, 25, 69, 21, 86], [64, 76, 90, 65, 23, 91, 17, 78, 72, 32])
[90]
160
2.590584
Code: def function(nums1: List[int], nums2: List[int]) -> List[int]: counter = Counter(nums1) res = [] for num in nums2: if counter[num] > 0: res.append(num) counter[num] -= 1 return res Evaluate this code with the following inputs : function([39, 29, 54, 27, 90, 25, 69, 21, 86], [64, 76, 90, 65, 23, 91, 17, 78, 72, 32]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(n: int) -> int: if n == 0: return 1 if n == 1: return 10 ans, cur = 10, 9 for i in range(n - 1): cur *= 9 - i ans += cur return ans
function(7)
712891
115
0.494433
Code: def function(n: int) -> int: if n == 0: return 1 if n == 1: return 10 ans, cur = 10, 9 for i in range(n - 1): cur *= 9 - i ans += cur return ans Evaluate this code with the following inputs : function(7) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(nums: List[int]) -> List[int]: nums.sort() n = len(nums) f = [1] * n k = 0 for i in range(n): for j in range(i): if nums[i] % nums[j] == 0: f[i] = max(f[i], f[j] + 1) if f[k] < f[i]: k = i m = f[k] i = k ans = [] while m: if nums[k] % nums[i] == 0 and f[i] == m: ans.append(nums[i]) k, m = i, m - 1 i -= 1 return ans
function([10, 13, 77, 88, 107, 116, 125, 128, 180, 186])
[180, 10]
230
4.549322
Code: def function(nums: List[int]) -> List[int]: nums.sort() n = len(nums) f = [1] * n k = 0 for i in range(n): for j in range(i): if nums[i] % nums[j] == 0: f[i] = max(f[i], f[j] + 1) if f[k] < f[i]: k = i m = f[k] i = k ans = [] while m: if nums[k] % nums[i] == 0 and f[i] == m: ans.append(nums[i]) k, m = i, m - 1 i -= 1 return ans Evaluate this code with the following inputs : function([10, 13, 77, 88, 107, 116, 125, 128, 180, 186]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(a: int, b: int) -> int: a, b = a & 0xFFFFFFFF, b & 0xFFFFFFFF while b: carry = ((a & b) << 1) & 0xFFFFFFFF a, b = a ^ b, carry return a if a < 0x80000000 else ~(a ^ 0xFFFFFFFF)
function(-157, -433)
-590
129
1.271485
Code: def function(a: int, b: int) -> int: a, b = a & 0xFFFFFFFF, b & 0xFFFFFFFF while b: carry = ((a & b) << 1) & 0xFFFFFFFF a, b = a ^ b, carry return a if a < 0x80000000 else ~(a ^ 0xFFFFFFFF) Evaluate this code with the following inputs : function(-157, -433) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(nums: List[int]) -> int: up = down = 1 for i in range(1, len(nums)): if nums[i] > nums[i - 1]: up = max(up, down + 1) elif nums[i] < nums[i - 1]: down = max(down, up + 1) return max(up, down)
function([42, 64, 68, 26, 84, 71, 37, 12, 100, 77])
7
153
1.779665
Code: def function(nums: List[int]) -> int: up = down = 1 for i in range(1, len(nums)): if nums[i] > nums[i - 1]: up = max(up, down + 1) elif nums[i] < nums[i - 1]: down = max(down, up + 1) return max(up, down) Evaluate this code with the following inputs : function([42, 64, 68, 26, 84, 71, 37, 12, 100, 77]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(s: str, t: str) -> str: cnt = Counter(s) for c in t: cnt[c] -= 1 if cnt[c] < 0: return c
function('pzdpltswub', 'wsulxztbdpp')
x
102
2.159227
Code: def function(s: str, t: str) -> str: cnt = Counter(s) for c in t: cnt[c] -= 1 if cnt[c] < 0: return c Evaluate this code with the following inputs : function('pzdpltswub', 'wsulxztbdpp') Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(nums: List[int]) -> int: f = sum(i * v for i, v in enumerate(nums)) n, s = len(nums), sum(nums) ans = f for i in range(1, n): f = f + s - n * nums[n - i] ans = max(ans, f) return ans
function([-30, -60, -16, -7, -28, 63, -78, 9, 31, -55])
-183
148
2.733074
Code: def function(nums: List[int]) -> int: f = sum(i * v for i, v in enumerate(nums)) n, s = len(nums), sum(nums) ans = f for i in range(1, n): f = f + s - n * nums[n - i] ans = max(ans, f) return ans Evaluate this code with the following inputs : function([-30, -60, -16, -7, -28, 63, -78, 9, 31, -55]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(n: int) -> int: k, cnt = 1, 9 while k * cnt < n: n -= k * cnt k += 1 cnt *= 10 num = 10 ** (k - 1) + (n - 1) // k idx = (n - 1) % k return int(str(num)[idx])
function(46)
2
133
0.358571
Code: def function(n: int) -> int: k, cnt = 1, 9 while k * cnt < n: n -= k * cnt k += 1 cnt *= 10 num = 10 ** (k - 1) + (n - 1) // k idx = (n - 1) % k return int(str(num)[idx]) Evaluate this code with the following inputs : function(46) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(turnedOn: int) -> List[str]: return [ '{:d}:{:02d}'.format(i, j) for i in range(12) for j in range(60) if (bin(i) + bin(j)).count('1') == turnedOn ]
function(10)
[]
109
173.7101
Code: def function(turnedOn: int) -> List[str]: return [ '{:d}:{:02d}'.format(i, j) for i in range(12) for j in range(60) if (bin(i) + bin(j)).count('1') == turnedOn ] Evaluate this code with the following inputs : function(10) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(num: str, k: int) -> str: stk = [] remain = len(num) - k for c in num: while k and stk and stk[-1] > c: stk.pop() k -= 1 stk.append(c) return ''.join(stk[:remain]).lstrip('0') or '0'
function('777462', 5)
2
126
1.073768
Code: def function(num: str, k: int) -> str: stk = [] remain = len(num) - k for c in num: while k and stk and stk[-1] > c: stk.pop() k -= 1 stk.append(c) return ''.join(stk[:remain]).lstrip('0') or '0' Evaluate this code with the following inputs : function('777462', 5) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(num: int) -> str: if num == 0: return '0' chars = '0123456789abcdef' s = [] for i in range(7, -1, -1): x = (num >> (4 * i)) & 0xF if s or x != 0: s.append(chars[x]) return ''.join(s)
function(-1332516520)
b0936958
133
1.119953
Code: def function(num: int) -> str: if num == 0: return '0' chars = '0123456789abcdef' s = [] for i in range(7, -1, -1): x = (num >> (4 * i)) & 0xF if s or x != 0: s.append(chars[x]) return ''.join(s) Evaluate this code with the following inputs : function(-1332516520) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(people: List[List[int]]) -> List[List[int]]: people.sort(key=lambda x: (-x[0], x[1])) ans = [] for p in people: ans.insert(p[1], p) return ans
function([[100, 0], [89, 0], [83, 4], [79, 3], [76, 4], [73, 3], [72, 2], [61, 0], [24, 6], [14, 5]])
[[61, 0], [89, 0], [100, 0], [72, 2], [83, 4], [14, 5], [73, 3], [24, 6], [79, 3], [76, 4]]
154
2.019196
Code: def function(people: List[List[int]]) -> List[List[int]]: people.sort(key=lambda x: (-x[0], x[1])) ans = [] for p in people: ans.insert(p[1], p) return ans Evaluate this code with the following inputs : function([[100, 0], [89, 0], [83, 4], [79, 3], [76, 4], [73, 3], [72, 2], [61, 0], [24, 6], [14, 5]]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(s: str) -> int: cnt = Counter(s) ans = 0 for v in cnt.values(): ans += v - (v & 1) ans += (ans & 1 ^ 1) and (v & 1) return ans
function("IKOqqJaucR")
3
111
1.97571
Code: def function(s: str) -> int: cnt = Counter(s) ans = 0 for v in cnt.values(): ans += v - (v & 1) ans += (ans & 1 ^ 1) and (v & 1) return ans Evaluate this code with the following inputs : function("IKOqqJaucR") Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(start: str, end: str, bank: List[str]) -> int: s = set(bank) q = deque([(start, 0)]) mp = {'A': 'TCG', 'T': 'ACG', 'C': 'ATG', 'G': 'ATC'} while q: t, step = q.popleft() if t == end: return step for i, v in enumerate(t): for j in mp[v]: next = t[:i] + j + t[i + 1 :] if next in s: q.append((next, step + 1)) s.remove(next) return -1
function("ATAGCCCG", "CTGATCTT", ['AACAGCCC', 'GTCAGCTC', 'ATCTTATT', 'AACTTGTG', 'GGTAACCA', 'GGCATTTC', 'GCTCGGGT', 'CTATTCGT', 'TACTAAGA', 'ATCCCGAA'])
-1
265
6.522783
Code: def function(start: str, end: str, bank: List[str]) -> int: s = set(bank) q = deque([(start, 0)]) mp = {'A': 'TCG', 'T': 'ACG', 'C': 'ATG', 'G': 'ATC'} while q: t, step = q.popleft() if t == end: return step for i, v in enumerate(t): for j in mp[v]: next = t[:i] + j + t[i + 1 :] if next in s: q.append((next, step + 1)) s.remove(next) return -1 Evaluate this code with the following inputs : function("ATAGCCCG", "CTGATCTT", ['AACAGCCC', 'GTCAGCTC', 'ATCTTATT', 'AACTTGTG', 'GGTAACCA', 'GGCATTTC', 'GCTCGGGT', 'CTATTCGT', 'TACTAAGA', 'ATCCCGAA']) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(intervals: List[List[int]]) -> int: intervals.sort(key=lambda x: x[1]) ans, t = 0, intervals[0][1] for s, e in intervals[1:]: if s >= t: t = e else: ans += 1 return ans
function([[-40591, -38232], [-48590, -26642], [-46582, -22310], [-21795, -1256], [6067, 16104], [21321, 38741], [-3150, 45021], [10591, 46206], [20395, 47713], [49185, 49194]])
5
193
1.360833
Code: def function(intervals: List[List[int]]) -> int: intervals.sort(key=lambda x: x[1]) ans, t = 0, intervals[0][1] for s, e in intervals[1:]: if s >= t: t = e else: ans += 1 return ans Evaluate this code with the following inputs : function([[-40591, -38232], [-48590, -26642], [-46582, -22310], [-21795, -1256], [6067, 16104], [21321, 38741], [-3150, 45021], [10591, 46206], [20395, 47713], [49185, 49194]]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(s: str, p: str) -> List[int]: m, n = len(s), len(p) ans = [] if m < n: return ans cnt1 = Counter(p) cnt2 = Counter(s[: n - 1]) for i in range(n - 1, m): cnt2[s[i]] += 1 if cnt1 == cnt2: ans.append(i - n + 1) cnt2[s[i - n + 1]] -= 1 return ans
function('dynjnfqnc', 'dzxahknjd')
[]
172
3.588708
Code: def function(s: str, p: str) -> List[int]: m, n = len(s), len(p) ans = [] if m < n: return ans cnt1 = Counter(p) cnt2 = Counter(s[: n - 1]) for i in range(n - 1, m): cnt2[s[i]] += 1 if cnt1 == cnt2: ans.append(i - n + 1) cnt2[s[i - n + 1]] -= 1 return ans Evaluate this code with the following inputs : function('dynjnfqnc', 'dzxahknjd') Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(chars: List[str]) -> int: i, k, n = 0, 0, len(chars) while i < n: j = i + 1 while j < n and chars[j] == chars[i]: j += 1 chars[k] = chars[i] k += 1 if j - i > 1: cnt = str(j - i) for c in cnt: chars[k] = c k += 1 i = j return k
function(['h', '\\', 'U', 's', '&', '8', 'K', 'E', 'L', 'K'])
10
187
1.004429
Code: def function(chars: List[str]) -> int: i, k, n = 0, 0, len(chars) while i < n: j = i + 1 while j < n and chars[j] == chars[i]: j += 1 chars[k] = chars[i] k += 1 if j - i > 1: cnt = str(j - i) for c in cnt: chars[k] = c k += 1 i = j return k Evaluate this code with the following inputs : function(['h', '\\', 'U', 's', '&', '8', 'K', 'E', 'L', 'K']) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(nums: List[int]) -> int: f = [defaultdict(int) for _ in nums] ans = 0 for i, x in enumerate(nums): for j, y in enumerate(nums[:i]): d = x - y ans += f[j][d] f[i][d] += f[j][d] + 1 return ans
function([-405, 664, -690, -215, -884, -991, -749, 910, -765, 766])
0
155
18.874208
Code: def function(nums: List[int]) -> int: f = [defaultdict(int) for _ in nums] ans = 0 for i, x in enumerate(nums): for j, y in enumerate(nums[:i]): d = x - y ans += f[j][d] f[i][d] += f[j][d] + 1 return ans Evaluate this code with the following inputs : function([-405, 664, -690, -215, -884, -991, -749, 910, -765, 766]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(g: List[int], s: List[int]) -> int: g.sort() s.sort() j = 0 for i, x in enumerate(g): while j < len(s) and s[j] < g[i]: j += 1 if j >= len(s): return i j += 1 return len(g)
function([7, 12, 19, 47, 53, 63, 78, 92, 97], [13, 16, 20, 26, 27, 28, 46, 56, 69, 71])
6
179
1.104898
Code: def function(g: List[int], s: List[int]) -> int: g.sort() s.sort() j = 0 for i, x in enumerate(g): while j < len(s) and s[j] < g[i]: j += 1 if j >= len(s): return i j += 1 return len(g) Evaluate this code with the following inputs : function([7, 12, 19, 47, 53, 63, 78, 92, 97], [13, 16, 20, 26, 27, 28, 46, 56, 69, 71]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(x: int, y: int) -> int: return (x ^ y).bit_count()
function(17, 100)
5
70
0.071971
Code: def function(x: int, y: int) -> int: return (x ^ y).bit_count() Evaluate this code with the following inputs : function(17, 100) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(strs: List[str], m: int, n: int) -> int: f = [[0] * (n + 1) for _ in range(m + 1)] for s in strs: a, b = s.count("0"), s.count("1") for i in range(m, a - 1, -1): for j in range(n, b - 1, -1): f[i][j] = max(f[i][j], f[i - a][j - b] + 1) return f[m][n]
function(['101111110', '1111110', '000000011', '000011001', '00111', '011101111', '101', '011011', '11010110', '1111011100'], 4, 5)
2
219
13.018071
Code: def function(strs: List[str], m: int, n: int) -> int: f = [[0] * (n + 1) for _ in range(m + 1)] for s in strs: a, b = s.count("0"), s.count("1") for i in range(m, a - 1, -1): for j in range(n, b - 1, -1): f[i][j] = max(f[i][j], f[i - a][j - b] + 1) return f[m][n] Evaluate this code with the following inputs : function(['101111110', '1111110', '000000011', '000011001', '00111', '011101111', '101', '011011', '11010110', '1111011100'], 4, 5) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(nums: List[int]) -> int: ans = 0 for i in range(31): a = b = 0 for v in nums: t = (v >> i) & 1 if t: a += 1 else: b += 1 ans += a * b return ans
function([51, 33, 64, 18, 82, 91, 88, 69, 74, 19])
143
151
17.096521
Code: def function(nums: List[int]) -> int: ans = 0 for i in range(31): a = b = 0 for v in nums: t = (v >> i) & 1 if t: a += 1 else: b += 1 ans += a * b return ans Evaluate this code with the following inputs : function([51, 33, 64, 18, 82, 91, 88, 69, 74, 19]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(n: int) -> int: s = [1, 2, 2] i = 2 while len(s) < n: pre = s[-1] cur = 3 - pre s += [cur] * s[i] i += 1 return s[:n].count(1)
function(101)
50
120
12.385023
Code: def function(n: int) -> int: s = [1, 2, 2] i = 2 while len(s) < n: pre = s[-1] cur = 3 - pre s += [cur] * s[i] i += 1 return s[:n].count(1) Evaluate this code with the following inputs : function(101) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(nums: List[int]) -> int: l = r = 0 k = 1 while r < len(nums): if nums[r] == 0: k -= 1 if k < 0: if nums[l] == 0: k += 1 l += 1 r += 1 return r - l
function([1, 1, 0, 1, 0, 0, 1, 0, 1, 1])
4
157
0.811575
Code: def function(nums: List[int]) -> int: l = r = 0 k = 1 while r < len(nums): if nums[r] == 0: k -= 1 if k < 0: if nums[l] == 0: k += 1 l += 1 r += 1 return r - l Evaluate this code with the following inputs : function([1, 1, 0, 1, 0, 0, 1, 0, 1, 1]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(nums: List[int], target: int) -> int: s = sum(nums) if s < target or (s - target) % 2 != 0: return 0 n = (s - target) // 2 dp = [0] * (n + 1) dp[0] = 1 for v in nums: for j in range(n, v - 1, -1): dp[j] += dp[j - v] return dp[-1]
function([973, 953, 246, 993, 890, 71, 355, 658, 70, 798, 824, 813, 325, 157, 504, 146, 534, 914, 912, 334, 210], -228)
538
221
6,028.315458
Code: def function(nums: List[int], target: int) -> int: s = sum(nums) if s < target or (s - target) % 2 != 0: return 0 n = (s - target) // 2 dp = [0] * (n + 1) dp[0] = 1 for v in nums: for j in range(n, v - 1, -1): dp[j] += dp[j - v] return dp[-1] Evaluate this code with the following inputs : function([973, 953, 246, 993, 890, 71, 355, 658, 70, 798, 824, 813, 325, 157, 504, 146, 534, 914, 912, 334, 210], -228) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(score: List[int]) -> List[str]: n = len(score) idx = list(range(n)) idx.sort(key=lambda x: -score[x]) top3 = ['Gold Medal', 'Silver Medal', 'Bronze Medal'] ans = [None] * n for i in range(n): ans[idx[i]] = top3[i] if i < 3 else str(i + 1) return ans
function([65, 84, 98, 100, 20, 24, 19, 88, 63, 94])
['6', '5', 'Silver Medal', 'Gold Medal', '9', '8', '10', '4', '7', 'Bronze Medal']
165
2.135904
Code: def function(score: List[int]) -> List[str]: n = len(score) idx = list(range(n)) idx.sort(key=lambda x: -score[x]) top3 = ['Gold Medal', 'Silver Medal', 'Bronze Medal'] ans = [None] * n for i in range(n): ans[idx[i]] = top3[i] if i < 3 else str(i + 1) return ans Evaluate this code with the following inputs : function([65, 84, 98, 100, 20, 24, 19, 88, 63, 94]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(n: int) -> int: a, b = 0, 1 for _ in range(n): a, b = b, a + b return a
function(28)
317811
86
0.788589
Code: def function(n: int) -> int: a, b = 0, 1 for _ in range(n): a, b = b, a + b return a Evaluate this code with the following inputs : function(28) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(s: str) -> int: n = len(s) dp = [[0] * n for _ in range(n)] for i in range(n): dp[i][i] = 1 for j in range(1, n): for i in range(j - 1, -1, -1): if s[i] == s[j]: dp[i][j] = dp[i + 1][j - 1] + 2 else: dp[i][j] = max(dp[i + 1][j], dp[i][j - 1]) return dp[0][-1]
function("ffqmpeipbyl")
3
187
14.152326
Code: def function(s: str) -> int: n = len(s) dp = [[0] * n for _ in range(n)] for i in range(n): dp[i][i] = 1 for j in range(1, n): for i in range(j - 1, -1, -1): if s[i] == s[j]: dp[i][j] = dp[i + 1][j - 1] + 2 else: dp[i][j] = max(dp[i + 1][j], dp[i][j - 1]) return dp[0][-1] Evaluate this code with the following inputs : function("ffqmpeipbyl") Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(machines: List[int]) -> int: n = len(machines) k, mod = divmod(sum(machines), n) if mod: return -1 ans = s = 0 for x in machines: x -= k s += x ans = max(ans, abs(s), x) return ans
function([86085, 63081, 92523, 62834, 94292, 45356, 10810, 85316, 10785, 70039])
-1
160
0.27887
Code: def function(machines: List[int]) -> int: n = len(machines) k, mod = divmod(sum(machines), n) if mod: return -1 ans = s = 0 for x in machines: x -= k s += x ans = max(ans, abs(s), x) return ans Evaluate this code with the following inputs : function([86085, 63081, 92523, 62834, 94292, 45356, 10810, 85316, 10785, 70039]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(amount: int, coins: List[int]) -> int: dp = [0] * (amount + 1) dp[0] = 1 for coin in coins: for j in range(coin, amount + 1): dp[j] += dp[j - coin] return dp[-1]
function(186, [211, 240, 379, 310, 286, 407, 321, 107, 227, 377])
0
145
4.865496
Code: def function(amount: int, coins: List[int]) -> int: dp = [0] * (amount + 1) dp[0] = 1 for coin in coins: for j in range(coin, amount + 1): dp[j] += dp[j - coin] return dp[-1] Evaluate this code with the following inputs : function(186, [211, 240, 379, 310, 286, 407, 321, 107, 227, 377]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(nums: List[int], k: int) -> int: vis, ans = set(), set() for v in nums: if v - k in vis: ans.add(v - k) if v + k in vis: ans.add(v) vis.add(v) return len(ans)
function([-8576225, 9362818, 8049036, -3221723, 1987384, -9205466, 7800344, -9736699, -3464257, -4417566], 1865214)
0
163
1.14112
Code: def function(nums: List[int], k: int) -> int: vis, ans = set(), set() for v in nums: if v - k in vis: ans.add(v - k) if v + k in vis: ans.add(v) vis.add(v) return len(ans) Evaluate this code with the following inputs : function([-8576225, 9362818, 8049036, -3221723, 1987384, -9205466, 7800344, -9736699, -3464257, -4417566], 1865214) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(timePoints: List[str]) -> int: if len(timePoints) > 24 * 60: return 0 mins = sorted(int(t[:2]) * 60 + int(t[3:]) for t in timePoints) mins.append(mins[0] + 24 * 60) res = mins[-1] for i in range(1, len(mins)): res = min(res, mins[i] - mins[i - 1]) return res
function(['07:36', '05:14', '03:21', '04:20', '02:08', '01:52', '01:27', '14:55', '23:07', '07:48'])
12
198
5.40202
Code: def function(timePoints: List[str]) -> int: if len(timePoints) > 24 * 60: return 0 mins = sorted(int(t[:2]) * 60 + int(t[3:]) for t in timePoints) mins.append(mins[0] + 24 * 60) res = mins[-1] for i in range(1, len(mins)): res = min(res, mins[i] - mins[i - 1]) return res Evaluate this code with the following inputs : function(['07:36', '05:14', '03:21', '04:20', '02:08', '01:52', '01:27', '14:55', '23:07', '07:48']) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(s: str, k: int) -> str: t = list(s) for i in range(0, len(t), k << 1): t[i : i + k] = reversed(t[i : i + k]) return ''.join(t)
function('irwnizqmkh', 10)
hkmqzinwri
110
0.758205
Code: def function(s: str, k: int) -> str: t = list(s) for i in range(0, len(t), k << 1): t[i : i + k] = reversed(t[i : i + k]) return ''.join(t) Evaluate this code with the following inputs : function('irwnizqmkh', 10) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(nums: List[int]) -> str: n = len(nums) if n == 1: return str(nums[0]) if n == 2: return f'{nums[0]}/{nums[1]}' return f'{nums[0]}/({"/".join(map(str, nums[1:]))})'
function([571, 462, 736, 401, 690, 443, 696, 408, 360, 332])
571/(462/736/401/690/443/696/408/360/332)
145
1.242218
Code: def function(nums: List[int]) -> str: n = len(nums) if n == 1: return str(nums[0]) if n == 2: return f'{nums[0]}/{nums[1]}' return f'{nums[0]}/({"/".join(map(str, nums[1:]))})' Evaluate this code with the following inputs : function([571, 462, 736, 401, 690, 443, 696, 408, 360, 332]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(n: int) -> int: cs = list(str(n)) n = len(cs) i, j = n - 2, n - 1 while i >= 0 and cs[i] >= cs[i + 1]: i -= 1 if i < 0: return -1 while cs[i] >= cs[j]: j -= 1 cs[i], cs[j] = cs[j], cs[i] cs[i + 1 :] = cs[i + 1 :][::-1] ans = int(''.join(cs)) return -1 if ans > 2**31 - 1 else ans
function(1668534853)
1668535348
192
0.962256
Code: def function(n: int) -> int: cs = list(str(n)) n = len(cs) i, j = n - 2, n - 1 while i >= 0 and cs[i] >= cs[i + 1]: i -= 1 if i < 0: return -1 while cs[i] >= cs[j]: j -= 1 cs[i], cs[j] = cs[j], cs[i] cs[i + 1 :] = cs[i + 1 :][::-1] ans = int(''.join(cs)) return -1 if ans > 2**31 - 1 else ans Evaluate this code with the following inputs : function(1668534853) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(nums: List[int]) -> int: return sum(sorted(nums)[::2])
function([3389, 2818, -4356, -9577, -2108, -8055, -4018, 7970, -2548, -2449, -3039, 2242, 231, -6429, -2688, -6589, -1151, 4241, -1164, 1425])
-20884
139
0.738986
Code: def function(nums: List[int]) -> int: return sum(sorted(nums)[::2]) Evaluate this code with the following inputs : function([3389, 2818, -4356, -9577, -2108, -8055, -4018, 7970, -2548, -2449, -3039, 2242, 231, -6429, -2688, -6589, -1151, 4241, -1164, 1425]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(mat: List[List[int]]) -> int: m, n = len(mat), len(mat[0]) a = [[0] * (n + 2) for _ in range(m + 2)] b = [[0] * (n + 2) for _ in range(m + 2)] c = [[0] * (n + 2) for _ in range(m + 2)] d = [[0] * (n + 2) for _ in range(m + 2)] ans = 0 for i in range(1, m + 1): for j in range(1, n + 1): v = mat[i - 1][j - 1] if v: a[i][j] = a[i - 1][j] + 1 b[i][j] = b[i][j - 1] + 1 c[i][j] = c[i - 1][j - 1] + 1 d[i][j] = d[i - 1][j + 1] + 1 ans = max(ans, a[i][j], b[i][j], c[i][j], d[i][j]) return ans
function([[0, 0, 1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 1, 1, 0, 0, 1, 1, 1, 0], [0, 0, 0, 1, 1, 0, 0, 1, 1, 1], [1, 1, 1, 1, 0, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 1, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1, 0, 1], [1, 1, 1, 0, 1, 1, 1, 0, 1, 1], [1, 0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 1, 0, 0, 1, 0, 0, 0, 1, 1], [0, 1, 1, 1, 0, 0, 1, 0, 1, 1]])
6
615
33.25775
Code: def function(mat: List[List[int]]) -> int: m, n = len(mat), len(mat[0]) a = [[0] * (n + 2) for _ in range(m + 2)] b = [[0] * (n + 2) for _ in range(m + 2)] c = [[0] * (n + 2) for _ in range(m + 2)] d = [[0] * (n + 2) for _ in range(m + 2)] ans = 0 for i in range(1, m + 1): for j in range(1, n + 1): v = mat[i - 1][j - 1] if v: a[i][j] = a[i - 1][j] + 1 b[i][j] = b[i][j - 1] + 1 c[i][j] = c[i - 1][j - 1] + 1 d[i][j] = d[i - 1][j + 1] + 1 ans = max(ans, a[i][j], b[i][j], c[i][j], d[i][j]) return ans Evaluate this code with the following inputs : function([[0, 0, 1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 1, 1, 0, 0, 1, 1, 1, 0], [0, 0, 0, 1, 1, 0, 0, 1, 1, 1], [1, 1, 1, 1, 0, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 1, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1, 0, 1], [1, 1, 1, 0, 1, 1, 1, 0, 1, 1], [1, 0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 1, 0, 0, 1, 0, 0, 0, 1, 1], [0, 1, 1, 1, 0, 0, 1, 0, 1, 1]]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(word1: str, word2: str) -> int: m, n = len(word1), len(word2) dp = [[0] * (n + 1) for _ in range(m + 1)] for i in range(1, m + 1): dp[i][0] = i for j in range(1, n + 1): dp[0][j] = j for i in range(1, m + 1): for j in range(1, n + 1): if word1[i - 1] == word2[j - 1]: dp[i][j] = dp[i - 1][j - 1] else: dp[i][j] = 1 + min(dp[i - 1][j], dp[i][j - 1]) return dp[-1][-1]
function('gqkjbsinkl', 'gccsmljvmf')
14
251
25.063315
Code: def function(word1: str, word2: str) -> int: m, n = len(word1), len(word2) dp = [[0] * (n + 1) for _ in range(m + 1)] for i in range(1, m + 1): dp[i][0] = i for j in range(1, n + 1): dp[0][j] = j for i in range(1, m + 1): for j in range(1, n + 1): if word1[i - 1] == word2[j - 1]: dp[i][j] = dp[i - 1][j - 1] else: dp[i][j] = 1 + min(dp[i - 1][j], dp[i][j - 1]) return dp[-1][-1] Evaluate this code with the following inputs : function('gqkjbsinkl', 'gccsmljvmf') Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(nums: List[int]) -> int: counter = Counter(nums) ans = 0 for num in nums: if num + 1 in counter: ans = max(ans, counter[num] + counter[num + 1]) return ans
function([36, 48, 90, 70, 38, 26, 74, 76, 71, 69],)
2
129
2.211946
Code: def function(nums: List[int]) -> int: counter = Counter(nums) ans = 0 for num in nums: if num + 1 in counter: ans = max(ans, counter[num] + counter[num + 1]) return ans Evaluate this code with the following inputs : function([36, 48, 90, 70, 38, 26, 74, 76, 71, 69],) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(tasks: List[str], n: int) -> int: cnt = Counter(tasks) x = max(cnt.values()) s = sum(v == x for v in cnt.values()) return max(len(tasks), (x - 1) * (n + 1) + s)
function(['B', 'P', 'U', 'U', 'Y', 'F', 'W', 'R', 'N', 'S'], 89)
91
136
2.328034
Code: def function(tasks: List[str], n: int) -> int: cnt = Counter(tasks) x = max(cnt.values()) s = sum(v == x for v in cnt.values()) return max(len(tasks), (x - 1) * (n + 1) + s) Evaluate this code with the following inputs : function(['B', 'P', 'U', 'U', 'Y', 'F', 'W', 'R', 'N', 'S'], 89) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(num: int) -> int: if num < 2: return num ans, mul = 0, 1 for i in range(9, 1, -1): while num % i == 0: num //= i ans = mul * i + ans mul *= 10 return ans if num < 2 and ans <= 2**31 - 1 else 0
function(1074079976)
0
143
0.563
Code: def function(num: int) -> int: if num < 2: return num ans, mul = 0, 1 for i in range(9, 1, -1): while num % i == 0: num //= i ans = mul * i + ans mul *= 10 return ans if num < 2 and ans <= 2**31 - 1 else 0 Evaluate this code with the following inputs : function(1074079976) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(n: int, k: int) -> int: mod = 10**9 + 7 f = [1] + [0] * k s = [0] * (k + 2) for i in range(1, n + 1): for j in range(1, k + 1): f[j] = (s[j + 1] - s[max(0, j - (i - 1))]) % mod for j in range(1, k + 2): s[j] = (s[j - 1] + f[j - 1]) % mod return f[k]
function(10, 5)
1068
193
15.740852
Code: def function(n: int, k: int) -> int: mod = 10**9 + 7 f = [1] + [0] * k s = [0] * (k + 2) for i in range(1, n + 1): for j in range(1, k + 1): f[j] = (s[j + 1] - s[max(0, j - (i - 1))]) % mod for j in range(1, k + 2): s[j] = (s[j - 1] + f[j - 1]) % mod return f[k] Evaluate this code with the following inputs : function(10, 5) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(senate: str) -> str: qr = deque() qd = deque() for i, c in enumerate(senate): if c == "R": qr.append(i) else: qd.append(i) n = len(senate) while qr and qd: if qr[0] < qd[0]: qr.append(qr[0] + n) else: qd.append(qd[0] + n) qr.popleft() qd.popleft() return "Radiant" if qr else "Dire"
function('RRDDRRDRRDR')
Radiant
176
1.41293
Code: def function(senate: str) -> str: qr = deque() qd = deque() for i, c in enumerate(senate): if c == "R": qr.append(i) else: qd.append(i) n = len(senate) while qr and qd: if qr[0] < qd[0]: qr.append(qr[0] + n) else: qd.append(qd[0] + n) qr.popleft() qd.popleft() return "Radiant" if qr else "Dire" Evaluate this code with the following inputs : function('RRDDRRDRRDR') Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(m: int, n: int, k: int) -> int: left, right = 1, m * n while left < right: mid = (left + right) >> 1 cnt = 0 for i in range(1, m + 1): cnt += min(mid // i, n) if cnt >= k: right = mid else: left = mid + 1 return left
function(802, 488, 222929)
90774
153
1,995.544778
Code: def function(m: int, n: int, k: int) -> int: left, right = 1, m * n while left < right: mid = (left + right) >> 1 cnt = 0 for i in range(1, m + 1): cnt += min(mid // i, n) if cnt >= k: right = mid else: left = mid + 1 return left Evaluate this code with the following inputs : function(802, 488, 222929) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(num: int) -> int: s = list(str(num)) n = len(s) d = list(range(n)) for i in range(n - 2, -1, -1): if s[i] <= s[d[i + 1]]: d[i] = d[i + 1] for i, j in enumerate(d): if s[i] < s[j]: s[i], s[j] = s[j], s[i] break return int(''.join(s))
function(53509105)
93505105
158
1.418963
Code: def function(num: int) -> int: s = list(str(num)) n = len(s) d = list(range(n)) for i in range(n - 2, -1, -1): if s[i] <= s[d[i + 1]]: d[i] = d[i + 1] for i, j in enumerate(d): if s[i] < s[j]: s[i], s[j] = s[j], s[i] break return int(''.join(s)) Evaluate this code with the following inputs : function(53509105) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(n: int, presses: int) -> int: ops = (0b111111, 0b010101, 0b101010, 0b100100) n = min(n, 6) vis = set() for mask in range(1 << 4): cnt = mask.bit_count() if cnt <= presses and cnt % 2 == presses % 2: t = 0 for i, op in enumerate(ops): if (mask >> i) & 1: t ^= op t &= (1 << 6) - 1 t >>= 6 - n vis.add(t) return len(vis)
function(780, 334)
8
198
4.779054
Code: def function(n: int, presses: int) -> int: ops = (0b111111, 0b010101, 0b101010, 0b100100) n = min(n, 6) vis = set() for mask in range(1 << 4): cnt = mask.bit_count() if cnt <= presses and cnt % 2 == presses % 2: t = 0 for i, op in enumerate(ops): if (mask >> i) & 1: t ^= op t &= (1 << 6) - 1 t >>= 6 - n vis.add(t) return len(vis) Evaluate this code with the following inputs : function(780, 334) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(words: List[str], k: int) -> List[str]: cnt = Counter(words) return sorted(cnt, key=lambda x: (-cnt[x], x))[:k]
function(['cr', 'cq', 'ch', 'tf', 'vd', 'kf', 'do', 'iw', 'qa', 'fv', 'fn', 'hp', 'js', 'tc', 'kh', 'av', 'au', 'yw', 'mc', 'yq', 'va'], 18)
['au', 'av', 'ch', 'cq', 'cr', 'do', 'fn', 'fv', 'hp', 'iw', 'js', 'kf', 'kh', 'mc', 'qa', 'tc', 'tf', 'va']
147
6.389275
Code: def function(words: List[str], k: int) -> List[str]: cnt = Counter(words) return sorted(cnt, key=lambda x: (-cnt[x], x))[:k] Evaluate this code with the following inputs : function(['cr', 'cq', 'ch', 'tf', 'vd', 'kf', 'do', 'iw', 'qa', 'fv', 'fn', 'hp', 'js', 'tc', 'kh', 'av', 'au', 'yw', 'mc', 'yq', 'va'], 18) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(s: str) -> int: i, n = 0, len(s) t = [] while i < n: cnt = 1 while i + 1 < n and s[i + 1] == s[i]: cnt += 1 i += 1 t.append(cnt) i += 1 ans = 0 for i in range(1, len(t)): ans += min(t[i - 1], t[i]) return ans
function("11111101100010110100101101010011000010011000100001001101001010100000111100101100100011110010110011101")
70
189
16.155368
Code: def function(s: str) -> int: i, n = 0, len(s) t = [] while i < n: cnt = 1 while i + 1 < n and s[i + 1] == s[i]: cnt += 1 i += 1 t.append(cnt) i += 1 ans = 0 for i in range(1, len(t)): ans += min(t[i - 1], t[i]) return ans Evaluate this code with the following inputs : function("11111101100010110100101101010011000010011000100001001101001010100000111100101100100011110010110011101") Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(s1: str, s2: str) -> int: m, n = len(s1), len(s2) f = [[0] * (n + 1) for _ in range(m + 1)] for i in range(1, m + 1): f[i][0] = f[i - 1][0] + ord(s1[i - 1]) for j in range(1, n + 1): f[0][j] = f[0][j - 1] + ord(s2[j - 1]) for i in range(1, m + 1): for j in range(1, n + 1): if s1[i - 1] == s2[j - 1]: f[i][j] = f[i - 1][j - 1] else: f[i][j] = min( f[i - 1][j] + ord(s1[i - 1]), f[i][j - 1] + ord(s2[j - 1]) ) return f[m][n]
function('rqbbkmwylj', 'uericjtfsu')
1745
299
35.733642
Code: def function(s1: str, s2: str) -> int: m, n = len(s1), len(s2) f = [[0] * (n + 1) for _ in range(m + 1)] for i in range(1, m + 1): f[i][0] = f[i - 1][0] + ord(s1[i - 1]) for j in range(1, n + 1): f[0][j] = f[0][j - 1] + ord(s2[j - 1]) for i in range(1, m + 1): for j in range(1, n + 1): if s1[i - 1] == s2[j - 1]: f[i][j] = f[i - 1][j - 1] else: f[i][j] = min( f[i - 1][j] + ord(s1[i - 1]), f[i][j - 1] + ord(s2[j - 1]) ) return f[m][n] Evaluate this code with the following inputs : function('rqbbkmwylj', 'uericjtfsu') Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(nums: List[int], k: int) -> int: ans, s, j = 0, 1, 0 for i, v in enumerate(nums): s *= v while j <= i and s >= k: s //= nums[j] j += 1 ans += i - j + 1 return ans
function([876, 939, 683, 809, 203, 291, 509, 812, 928, 808], 685496)
16
155
1.463979
Code: def function(nums: List[int], k: int) -> int: ans, s, j = 0, 1, 0 for i, v in enumerate(nums): s *= v while j <= i and s >= k: s //= nums[j] j += 1 ans += i - j + 1 return ans Evaluate this code with the following inputs : function([876, 939, 683, 809, 203, 291, 509, 812, 928, 808], 685496) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(nums1: List[int], nums2: List[int]) -> int: m, n = len(nums1), len(nums2) f = [[0] * (n + 1) for _ in range(m + 1)] ans = 0 for i in range(1, m + 1): for j in range(1, n + 1): if nums1[i - 1] == nums2[j - 1]: f[i][j] = f[i - 1][j - 1] + 1 ans = max(ans, f[i][j]) return ans
function([10, 53, 72, 7, 98, 96, 45, 59, 25, 52, 37], [29, 88, 91, 30, 68, 11, 100, 93])
0
236
6.946345
Code: def function(nums1: List[int], nums2: List[int]) -> int: m, n = len(nums1), len(nums2) f = [[0] * (n + 1) for _ in range(m + 1)] ans = 0 for i in range(1, m + 1): for j in range(1, n + 1): if nums1[i - 1] == nums2[j - 1]: f[i][j] = f[i - 1][j - 1] + 1 ans = max(ans, f[i][j]) return ans Evaluate this code with the following inputs : function([10, 53, 72, 7, 98, 96, 45, 59, 25, 52, 37], [29, 88, 91, 30, 68, 11, 100, 93]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(words: List[str]) -> str: cnt, ans = 0, '' s = set(words) for w in s: n = len(w) if all(w[:i] in s for i in range(1, n)): if cnt < n: cnt, ans = n, w elif cnt == n and w < ans: ans = w return ans
function(['c', 'm', 'i', 'z', 'y', 'b', 'g', 'm', 'r', 'h', 'i', 'q', 'h', 'x', 'v', 'w', 'c', 'b', 'k', 'b', 'j', 't', 'k', 'w', 't', 'w', 't', 'c', 'h', 'c', 'z'])
b
223
5.840037
Code: def function(words: List[str]) -> str: cnt, ans = 0, '' s = set(words) for w in s: n = len(w) if all(w[:i] in s for i in range(1, n)): if cnt < n: cnt, ans = n, w elif cnt == n and w < ans: ans = w return ans Evaluate this code with the following inputs : function(['c', 'm', 'i', 'z', 'y', 'b', 'g', 'm', 'r', 'h', 'i', 'q', 'h', 'x', 'v', 'w', 'c', 'b', 'k', 'b', 'j', 't', 'k', 'w', 't', 'w', 't', 'c', 'h', 'c', 'z']) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(s: str) -> int: mod = 10**9 + 7 n = len(s) dp = [[[0] * 4 for _ in range(n)] for _ in range(n)] for i, c in enumerate(s): dp[i][i][ord(c) - ord('a')] = 1 for l in range(2, n + 1): for i in range(n - l + 1): j = i + l - 1 for c in 'abcd': k = ord(c) - ord('a') if s[i] == s[j] == c: dp[i][j][k] = 2 + sum(dp[i + 1][j - 1]) elif s[i] == c: dp[i][j][k] = dp[i][j - 1][k] elif s[j] == c: dp[i][j][k] = dp[i + 1][j][k] else: dp[i][j][k] = dp[i + 1][j - 1][k] return sum(dp[0][-1]) % mod
function("abcbbabbcd")
25
301
54.522423
Code: def function(s: str) -> int: mod = 10**9 + 7 n = len(s) dp = [[[0] * 4 for _ in range(n)] for _ in range(n)] for i, c in enumerate(s): dp[i][i][ord(c) - ord('a')] = 1 for l in range(2, n + 1): for i in range(n - l + 1): j = i + l - 1 for c in 'abcd': k = ord(c) - ord('a') if s[i] == s[j] == c: dp[i][j][k] = 2 + sum(dp[i + 1][j - 1]) elif s[i] == c: dp[i][j][k] = dp[i][j - 1][k] elif s[j] == c: dp[i][j][k] = dp[i + 1][j][k] else: dp[i][j][k] = dp[i + 1][j - 1][k] return sum(dp[0][-1]) % mod Evaluate this code with the following inputs : function("abcbbabbcd") Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(n: int) -> int: s = list(str(n)) i = 1 while i < len(s) and s[i - 1] <= s[i]: i += 1 if i < len(s): while i and s[i - 1] > s[i]: s[i - 1] = str(int(s[i - 1]) - 1) i -= 1 i += 1 while i < len(s): s[i] = '9' i += 1 return int(''.join(s))
function(506999537)
499999999
174
1.057481
Code: def function(n: int) -> int: s = list(str(n)) i = 1 while i < len(s) and s[i - 1] <= s[i]: i += 1 if i < len(s): while i and s[i - 1] > s[i]: s[i - 1] = str(int(s[i - 1]) - 1) i -= 1 i += 1 while i < len(s): s[i] = '9' i += 1 return int(''.join(s)) Evaluate this code with the following inputs : function(506999537) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(letters: List[str], target: str) -> str: left, right = 0, len(letters) while left < right: mid = (left + right) >> 1 if ord(letters[mid]) > ord(target): right = mid else: left = mid + 1 return letters[left % len(letters)]
function(['c', 'g', 'h', 'k', 'm', 'm', 'n', 'o', 'p', 'w'], 'e')
g
155
0.469796
Code: def function(letters: List[str], target: str) -> str: left, right = 0, len(letters) while left < right: mid = (left + right) >> 1 if ord(letters[mid]) > ord(target): right = mid else: left = mid + 1 return letters[left % len(letters)] Evaluate this code with the following inputs : function(['c', 'g', 'h', 'k', 'm', 'm', 'n', 'o', 'p', 'w'], 'e') Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(cost: List[int]) -> int: f = g = 0 for i in range(2, len(cost) + 1): f, g = g, min(f + cost[i - 2], g + cost[i - 1]) return g
function([223, 732, 668, 644, 353, 376, 794, 497, 350, 227])
2344
132
1.648423
Code: def function(cost: List[int]) -> int: f = g = 0 for i in range(2, len(cost) + 1): f, g = g, min(f + cost[i - 2], g + cost[i - 1]) return g Evaluate this code with the following inputs : function([223, 732, 668, 644, 353, 376, 794, 497, 350, 227]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(grid: List[List[int]]) -> int: ans = 0 cnt = Counter() n = len(grid[0]) for row in grid: for i, c1 in enumerate(row): if c1: for j in range(i + 1, n): if row[j]: ans += cnt[(i, j)] cnt[(i, j)] += 1 return ans
function([[0, 0, 1, 0, 1, 1, 1, 1, 0, 0], [1, 1, 0, 0, 0, 0, 1, 0, 1, 0], [0, 1, 1, 0, 1, 0, 0, 1, 1, 0], [1, 1, 1, 0, 0, 1, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 1, 0, 1, 1, 1], [1, 0, 0, 1, 1, 0, 1, 1, 1, 0], [0, 1, 1, 0, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0, 1, 0, 1], [1, 0, 0, 0, 1, 0, 1, 0, 1, 1]])
107
433
50.716535
Code: def function(grid: List[List[int]]) -> int: ans = 0 cnt = Counter() n = len(grid[0]) for row in grid: for i, c1 in enumerate(row): if c1: for j in range(i + 1, n): if row[j]: ans += cnt[(i, j)] cnt[(i, j)] += 1 return ans Evaluate this code with the following inputs : function([[0, 0, 1, 0, 1, 1, 1, 1, 0, 0], [1, 1, 0, 0, 0, 0, 1, 0, 1, 0], [0, 1, 1, 0, 1, 0, 0, 1, 1, 0], [1, 1, 1, 0, 0, 1, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 1, 0, 1, 1, 1], [1, 0, 0, 1, 1, 0, 1, 1, 1, 0], [0, 1, 1, 0, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0, 1, 0, 1], [1, 0, 0, 0, 1, 0, 1, 0, 1, 1]]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(target: int) -> int: target = abs(target) s = k = 0 while 1: if s >= target and (s - target) % 2 == 0: return k k += 1 s += k
function(-289867697)
24078
107
1,001.087034
Code: def function(target: int) -> int: target = abs(target) s = k = 0 while 1: if s >= target and (s - target) % 2 == 0: return k k += 1 s += k Evaluate this code with the following inputs : function(-289867697) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(intervals: List[List[int]]) -> int: intervals.sort(key=lambda x: (x[1], -x[0])) s = e = -1 ans = 0 for a, b in intervals: if a <= s: continue if a > e: ans += 2 s, e = b - 1, b else: ans += 1 s, e = e, b return ans
function([[20, 21], [38, 43], [49, 49], [52, 52], [66, 68], [70, 70], [69, 73], [97, 97], [95, 101], [94, 103]])
14
207
1.990009
Code: def function(intervals: List[List[int]]) -> int: intervals.sort(key=lambda x: (x[1], -x[0])) s = e = -1 ans = 0 for a, b in intervals: if a <= s: continue if a > e: ans += 2 s, e = b - 1, b else: ans += 1 s, e = e, b return ans Evaluate this code with the following inputs : function([[20, 21], [38, 43], [49, 49], [52, 52], [66, 68], [70, 70], [69, 73], [97, 97], [95, 101], [94, 103]]) Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
def function(s: str) -> List[int]: last = {c: i for i, c in enumerate(s)} mx = j = 0 ans = [] for i, c in enumerate(s): mx = max(mx, last[c]) if mx == i: ans.append(i - j + 1) j = i + 1 return ans
function('psukaoqvdg')
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
132
2.691354
Code: def function(s: str) -> List[int]: last = {c: i for i, c in enumerate(s)} mx = j = 0 ans = [] for i, c in enumerate(s): mx = max(mx, last[c]) if mx == i: ans.append(i - j + 1) j = i + 1 return ans Evaluate this code with the following inputs : function('psukaoqvdg') Please evaluate the code with the given inputs and provide the expected output in \boxed{} format. Do not output or excecute code.
End of preview. Expand in Data Studio

No dataset card yet

Downloads last month
1