Dataset Viewer
Auto-converted to Parquet Duplicate
question_id
stringlengths
7
10
question
stringlengths
42
12.9k
starter_code
stringclasses
37 values
response
stringlengths
1.25k
174k
code
stringlengths
14
11k
verified
bool
1 class
is_passed
bool
1 class
normalized_code
stringlengths
14
5.01k
seed_10096
Given a Directed Graph, find a Mother Vertex in the Graph (if present). A Mother Vertex is a vertex through which we can reach all the other vertices of the Graph. Example 1: Input: Output: 0 Explanation: According to the given edges, all nodes can be reaced from nodes from 0, 1 and 2. But, since 0 is minimum amo...
class Solution: #Function to find a Mother Vertex in the Graph. def findMotherVertex(self, V, adj): #Code here
Okay, I need to solve this problem where I have to find a mother vertex in a directed graph. A mother vertex is one from which all other vertices can be reached. If there are multiple, pick the smallest one. If none exists, return -1. Hmm, how do I approach this? Let me think. The straightforward way is for each verte...
from collections import deque class Solution: def findMotherVertex(self, V, adj): visited = [False] * V finish_order = [] # Step 1: Find the last finished node using DFS for i in range(V): if not visited[i]: stack = [(i, False)] w...
true
true
from collections import deque class Solution: def findMotherVertex(self, V, adj): visited = [False] * V finish_order = [] for i in range(V): if not visited[i]: stack = [(i, False)] while stack: node, processed = stack.pop() if processed: finish_order.append(node) continue if visited[node]: continue visited[node] = True...
seed_101
"Night gathers, and now my watch begins. It shall not end until my death. I shall take no wife, hold no lands, father no children. I shall wear no crowns and win no glory. I shall live and die at my post. I am the sword in the darkness. I am the watcher on the walls. I am the shield that guards the realms of men. I ple...
Okay, let's tackle this problem. So the task is to find out how many stewards Jon will support. The condition is that a steward is supported only if there's at least one steward with a strictly lower strength and another with a strictly higher strength than him. Hmm, right. So first, I need to figure out for each ste...
n = int(input()) a = list(map(int, input().split())) if n < 2: print(0) else: min_val = min(a) max_val = max(a) if min_val == max_val: print(0) else: count = 0 for num in a: if num > min_val and num < max_val: count += 1 print(count)
true
true
n = int(input()) a = list(map(int, input().split())) if n < 2: print(0) else: min_val = min(a) max_val = max(a) if min_val == max_val: print(0) else: count = 0 for num in a: if num > min_val and num < max_val: count += 1 print(count)
seed_10138
Given a [tree] containing N nodes. Each node can be coloured using exactly one of the C colours. Find the number of colourings of the tree such that: All nodes in a path of length at most two have distinct colours. As the answer can be huge, print it modulo (10 ^ 9 + 7). Note: Two colourings of a tree are different ...
Okay, I need to solve this problem where I have to count the number of valid colorings of a tree such that all nodes in any path of length at most two have distinct colors. Hmm, let's see. First, the constraints are big, with N and C up to 1e6. So I need an efficient algorithm, probably O(N) time. Let's think of the ...
import sys from sys import stdin from collections import deque MOD = 10**9 + 7 def main(): sys.setrecursionlimit(1 << 25) N, C = map(int, stdin.readline().split()) if N == 1: print(C % MOD) return # Build adjacency list adj = [[] for _ in range(N+1)] for _ in range(N-1): ...
true
true
import sys from sys import stdin from collections import deque MOD = 10**9 + 7 def main(): sys.setrecursionlimit(1 << 25) N, C = map(int, stdin.readline().split()) if N == 1: print(C % MOD) return adj = [[] for _ in range(N+1)] for _ in range(N-1): u, v = map(int, stdin.readline().split()) adj[u].append(v) adj[v].appen...
seed_10164
Given a binary number (of $N$ bits) $X$. Find the highest power of 2 that divides this number. Note: If the binary number is "100" then the highest power of 2 that divides it is 2 (as $2^{2}$ = 4) ------ Input: ------ The first line contains N the number of bits in the number The next line contains a binary number o...
Okay, I need to solve this problem where I have to find the highest power of 2 that divides a given binary number. Let's think about how to approach this. Hmm, the key here is understanding what the highest power of 2 dividing the number means. Like, for example, if the binary is "100", which is 4 in decimal, the hig...
n = int(input()) s = input().strip() count = 0 for c in reversed(s): if c == '0': count += 1 else: break print(count)
true
true
n = int(input()) s = input().strip() count = 0 for c in reversed(s): if c == '0': count += 1 else: break print(count)
seed_10170
"Given a binary string $S$ consisting of only 1’s and 0’s where 1 represents a Square and 0 repr(...TRUNCATED)
"Okay, let's tackle this problem. Hmm, the task is to find the maximum number of circles we can insc(...TRUNCATED)
"import sys\n\ndef main():\n N = int(sys.stdin.readline())\n for _ in range(N):\n S = s(...TRUNCATED)
true
true
"import sys\ndef main():\nN = int(sys.stdin.readline())\nfor _ in range(N):\nS = sys.stdin.readline((...TRUNCATED)
seed_10278
"Given a complete binary tree with the height of H, we index the nodes respectively top-down and lef(...TRUNCATED)
"Okay, I need to solve this programming problem. Let's read the question again carefully to make sur(...TRUNCATED)
"import sys\n\nMOD = 10**9 + 7\n\ndef main():\n for line in sys.stdin:\n H = int(line.stri(...TRUNCATED)
true
true
"import sys\nMOD = 10**9 + 7\ndef main():\nfor line in sys.stdin:\nH = int(line.strip())\nif H == 0:(...TRUNCATED)
seed_10298
"Given a directed acyclic graph(DAG) with n nodes labeled from 0 to n-1. Given edges, s and d ,count(...TRUNCATED)
"#User function Template for python3\n\n\n\nclass Solution:\n\n def possible_paths(self, edges, n(...TRUNCATED)
"Okay, I need to solve this problem where I have to find the number of paths from node s to d in a d(...TRUNCATED)
"class Solution:\n def possible_paths(self, edges, n, s, d):\n # Build adjacency list\n (...TRUNCATED)
true
true
"class Solution:\ndef possible_paths(self, edges, n, s, d):\nadj = [[] for _ in range(n)]\nfor u, v (...TRUNCATED)
seed_103
"\"Pizza At\", a fast food chain, offers three kinds of pizza: \"A-pizza\", \"B-pizza\" and \"AB-piz(...TRUNCATED)
"Okay, so I have this programming problem to solve. Let me read through it again carefully.\n\nThe p(...TRUNCATED)
"def main():\n import sys\n A, B, C, X, Y = map(int, sys.stdin.readline().split())\n max_ne(...TRUNCATED)
true
true
"def main():\nimport sys\nA, B, C, X, Y = map(int, sys.stdin.readline().split())\nmax_needed = max(X(...TRUNCATED)
seed_10302
"Given a directed graph, find out if a vertex j is reachable from another vertex i for all vertex pa(...TRUNCATED)
"#User function Template for python3\n\nclass Solution:\n def transitiveClosure(self, N, graph):\(...TRUNCATED)
"Okay, I need to solve this problem where I have to find the transitive closure of a directed graph.(...TRUNCATED)
"class Solution:\n def transitiveClosure(self, N, graph):\n # Initialize the reachability (...TRUNCATED)
true
true
"class Solution:\ndef transitiveClosure(self, N, graph):\nreach = [[graph[i][j] for j in range(N)] f(...TRUNCATED)
seed_10303
"Given a directed graph. The task is to do Breadth First Traversal of this graph starting from 0.\nN(...TRUNCATED)
"#User function Template for python3\n\n\n\nfrom typing import List\n\nfrom queue import Queue\n\ncl(...TRUNCATED)
"Okay, I need to solve this BFS traversal problem for a directed graph. Let's see. The task is to pe(...TRUNCATED)
"from typing import List\nfrom collections import deque\n\nclass Solution:\n def bfsOfGraph(self,(...TRUNCATED)
true
true
"from typing import List\nfrom collections import deque\nclass Solution:\ndef bfsOfGraph(self, V: in(...TRUNCATED)
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
170