Datasets:
dataset stringclasses 1
value | domain stringclasses 8
values | prompt_index int64 0 26.7k | sample_index int64 0 0 | provider stringclasses 1
value | model stringclasses 1
value | split stringclasses 1
value | prompt listlengths 1 5 | text stringlengths 0 14k ⌀ | finish_reason stringclasses 3
values | usage dict | error stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
allenai/Dolci-Instruct-SFT | Coding | 40 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Write a python function to help me organize the metadata of my documentary films. Each documentary is described by a dictionary with the following keys: `title`, `year`, and `duration` (in minutes). I want to be able to filter these documentaries based on a minimum duration. Th... | ```python
def filter_documentaries(documentaries, min_duration):
return [doc["title"] for doc in documentaries if doc["duration"] >= min_duration]
``` | end_turn | {
"input_tokens": 315,
"output_tokens": 62
} | null |
allenai/Dolci-Instruct-SFT | Coding | 10 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "You are tasked with creating a Python function that extracts the source files and programming language from a given configuration dictionary. The configuration dictionary contains two keys: 'sources', which is a list of source file paths, and 'language', which is a string indic... | ```python
from typing import List, Tuple
def extract_source_files(config: dict) -> List[Tuple[str, str]]:
language = config['language']
return [(source, language) for source in config['sources']]
``` | end_turn | {
"input_tokens": 208,
"output_tokens": 75
} | null |
allenai/Dolci-Instruct-SFT | Coding | 29 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Given a list of integers and a target number, find and print the two numbers in the list whose sum equals the specified target. Each input will have exactly one solution, and you may not use any element twice. If no such pair exists, print an empty list ([]). The program should... | ```python
def main():
nums = list(map(int, input().split()))
target = int(input())
seen = {}
for num in nums:
complement = target - num
if complement in seen:
print([complement, num])
return
seen[num] = True
print([])
main()
``` | end_turn | {
"input_tokens": 212,
"output_tokens": 98
} | null |
allenai/Dolci-Instruct-SFT | Coding | 119 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Implement a function `process_user_activity(event: Dict[str, Any]) -> Dict[str, Any]` that takes a dictionary representing user activity from a music streaming application and processes it. The function should transform the input by ensuring that the user ID is in uppercase, an... | ```python
from typing import Any, Dict
def process_user_activity(event: Dict[str, Any]) -> Dict[str, Any]:
if not isinstance(event, dict):
return {}
user_id = event.get('user_id')
if not user_id or not isinstance(user_id, str):
return {}
processed = dict(event)
processed[... | end_turn | {
"input_tokens": 186,
"output_tokens": 167
} | null |
allenai/Dolci-Instruct-SFT | Coding | 30 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Given a CSV file with a header row, write a Python program that does the following:\n\n- Reads the CSV data from standard input.\n- The first line of standard input will contain five values separated by commas: SUM_COLUMN, FILTER_COLUMN, THRESHOLD, IDENTIFIER_COLUMN, ROW_COUNT.... | import sys
import csv
def main():
lines = sys.stdin.read().splitlines()
params = lines[0].split(',')
sum_col, filter_col, threshold, id_col, row_count = params
threshold = float(threshold)
row_count = int(row_count)
reader = csv.DictReader(lines[1:2+row_count])
seen = set()
total =... | end_turn | {
"input_tokens": 582,
"output_tokens": 219
} | null |
allenai/Dolci-Instruct-SFT | Coding | 140 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Write a program that reads an integer from standard input and prints \"True\" if the integer is even, or \"False\" otherwise.\n\nInput\nA single integer n on a line.\n\nOutput\nPrint \"True\" if n is even, otherwise print \"False\"."
}
] | ```python
n = int(input())
print(n % 2 == 0)
``` | end_turn | {
"input_tokens": 82,
"output_tokens": 28
} | null |
allenai/Dolci-Instruct-SFT | Coding | 120 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Write a program that reads a single line of input, which is a string. Determine if the string is a palindrome, ignoring spaces, punctuation, and capitalization. Output True if the string is a palindrome, otherwise output False.\n\nYou must not use any built-in string reversing ... | ```python
s = input()
cleaned = []
for ch in s:
if ('a' <= ch <= 'z') or ('A' <= ch <= 'Z') or ('0' <= ch <= '9'):
if 'A' <= ch <= 'Z':
cleaned.append(chr(ord(ch) + 32))
else:
cleaned.append(ch)
left, right = 0, len(cleaned) - 1
is_palindrome = True
while left < right:
i... | end_turn | {
"input_tokens": 183,
"output_tokens": 220
} | null |
allenai/Dolci-Instruct-SFT | Coding | 78 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Write a program that reads a single line containing a URL from standard input. The program should output True if the URL is valid and uses an IPv6 address for the domain part, and False otherwise.\n\nInput Format:\nA single line containing a URL string.\n\nOutput Format:\nPrint... | <think>
IPv6 URL has brackets. Need to validate URL and check host is IPv6.
</think>
```python
import sys
from urllib.parse import urlparse
import ipaddress
def main():
url = sys.stdin.readline().strip()
try:
parsed = urlparse(url)
if not parsed.scheme or not parsed.netloc:
print(F... | end_turn | {
"input_tokens": 166,
"output_tokens": 259
} | null |
allenai/Dolci-Instruct-SFT | Coding | 42 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Write a Python program that reads a single line of text from standard input, and extracts all email addresses from the text using regular expressions. The program should print a list of all matched email addresses (in Python list format).\n\nInput:\nA single line of text that m... | ```python
import re
text = input()
emails = re.findall(r'[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}', text)
print(emails)
``` | end_turn | {
"input_tokens": 210,
"output_tokens": 85
} | null |
allenai/Dolci-Instruct-SFT | Coding | 25 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Given an array A of N integers (1 ≤ N ≤ 10^7), output the majority element of the array. An element is called the majority element if it appears strictly more than N/2 times.\n\nStandard Input\nThe first line contains the integer N.\nThe second line contains N space-separated i... | <think>
Boyer-Moore majority vote. Need fast I/O for N up to 10^7.
</think>
```python
import sys
def main():
data = sys.stdin.buffer.read().split()
n = int(data[0])
a = data[1:1+n]
# Boyer-Moore majority vote
candidate = None
count = 0
for x in a:
if count == 0:
ca... | end_turn | {
"input_tokens": 214,
"output_tokens": 294
} | null |
allenai/Dolci-Instruct-SFT | Coding | 108 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Write a Python program that performs basic arithmetic operations (addition, subtraction, multiplication, division) on two numbers using object-oriented programming principles.\n\nInput:\nThe first line contains two numbers a and b separated by space.\nThe second line contains t... | ```python
class Calculator:
def __init__(self, a, b):
self.a = a
self.b = b
def add(self):
return self.a + self.b
def subtract(self):
return self.a - self.b
def multiply(self):
return self.a * self.b
def divide(self):
if self.b == 0:
re... | end_turn | {
"input_tokens": 177,
"output_tokens": 336
} | null |
allenai/Dolci-Instruct-SFT | Coding | 53 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Given an HTML document through standard input, write a Python program that extracts all hyperlinks (the href attribute values) from <a> tags. Assume the HTML document is well-formed.\n\nInput:\nA string representing the entire HTML document provided via standard input. The inpu... | ```python
import sys
from html.parser import HTMLParser
class LinkExtractor(HTMLParser):
def __init__(self):
super().__init__()
self.links = []
def handle_starttag(self, tag, attrs):
if tag == 'a':
for name, value in attrs:
if name == 'href':
... | end_turn | {
"input_tokens": 241,
"output_tokens": 201
} | null |
allenai/Dolci-Instruct-SFT | Coding | 37 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Write a python function to convert a given integer into its binary representation without using the built-in `bin()` function. The function should take an integer as input and return a string that represents the binary equivalent of the number. The binary string should not incl... | ```python
def int_to_binary(n):
if n == 0:
return '0'
negative = n < 0
n = abs(n)
binary = ''
while n > 0:
binary = str(n % 2) + binary
n //= 2
return '-' + binary if negative else binary
```
**How it works:**
1. **Zero case**: If `n` is `0`, directly ret... | end_turn | {
"input_tokens": 248,
"output_tokens": 374
} | null |
allenai/Dolci-Instruct-SFT | Coding | 54 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Please rectify the code snippet written in Java provided below by appendding a crucial missing element: a semicolon.\npublic static void main(String[] args) {\nSystem.out.println(\"Hello World\")"
}
] | # Fixed Java Code
Here's the corrected code with the missing semicolon added:
```java
public static void main(String[] args) {
System.out.println("Hello World");
}
```
## What Was Fixed
The semicolon (`;`) was added at the end of the `System.out.println("Hello World")` statement. I also added the closing curly ... | end_turn | {
"input_tokens": 70,
"output_tokens": 321
} | null |
allenai/Dolci-Instruct-SFT | Coding | 193 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "You are given a string that contains only lowercase letters. Your task is to implement a function that returns the first non-repeating character in the string. If there are no non-repeating characters, return an empty string. For example, given the string 'leetcode', the first ... | ```python
from collections import Counter
def first_non_repeating_char(s: str) -> str:
counts = Counter(s)
for ch in s:
if counts[ch] == 1:
return ch
return ""
``` | end_turn | {
"input_tokens": 170,
"output_tokens": 79
} | null |
allenai/Dolci-Instruct-SFT | Coding | 136 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Beroffice text editor flags a word as containing a typo if inside the word there is a block of three or more consecutive consonants that is made up of at least two different letters. (The vowels are exactly the five letters a, e, i, o and u; every other letter is a consonant.)\... | <think>
Greedy: scan, track consecutive consonants count and whether they're all same. If adding next consonant would make 3+ with at least two different, insert space before it, reset count to 1.
</think>
```python
word = input().strip()
vowels = set('aeiou')
result = []
cnt = 0
all_same = True
last = ''
for c in wor... | end_turn | {
"input_tokens": 351,
"output_tokens": 322
} | null |
allenai/Dolci-Instruct-SFT | Coding | 0 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "You are given an array of integers. Your task is to find the maximum subarray sum, which is the largest sum of a contiguous subarray (of at least one element) within the given array.\n\nInput:\n- The first line contains a single integer n, the number of elements in the array (1... | n = int(input())
a = list(map(int, input().split()))
best = cur = a[0]
for x in a[1:]:
cur = max(x, cur + x)
best = max(best, cur)
print(best) | end_turn | {
"input_tokens": 206,
"output_tokens": 74
} | null |
allenai/Dolci-Instruct-SFT | Coding | 189 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "You are given a list of integers representing the heights of a series of buildings aligned in a row. Your task is to implement a function that calculates the maximum area of a rectangle that can be formed under the histogram defined by the heights of these buildings. The rectan... | ```python
from typing import List
def max_histogram_area(heights: List[int]) -> int:
stack = []
max_area = 0
n = len(heights)
for i in range(n + 1):
current_height = 0 if i == n else heights[i]
while stack and heights[stack[-1]] > current_height:
h = heights[stack.pop()... | end_turn | {
"input_tokens": 256,
"output_tokens": 182
} | null |
allenai/Dolci-Instruct-SFT | Coding | 168 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Write a Python program that reads a single string from standard input and prints the longest palindromic substring in that string to standard output.\n\nInput:\nA single line containing a string s (1 ≤ |s| ≤ 1000), consisting of lowercase letters only.\n\nOutput:\nOutput a sing... | ```python
def longest_palindrome(s):
if not s:
return ""
start, end = 0, 0
for i in range(len(s)):
for a, b in ((i, i), (i, i+1)):
while a >= 0 and b < len(s) and s[a] == s[b]:
a -= 1
b += 1
if b - a - 1 > end - start:
s... | end_turn | {
"input_tokens": 151,
"output_tokens": 173
} | null |
allenai/Dolci-Instruct-SFT | Coding | 229 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Given an array of integers and a target integer, write a program that finds the index of the target integer in the array using a recursive approach (without any loops). The function should be tail-recursive for optimization. If the target integer is not in the array, return -1.... | ```python
import sys
sys.setrecursionlimit(10**6)
def find_index(arr, target, idx=0):
if idx >= len(arr):
return -1
if arr[idx] == target:
return idx
return find_index(arr, target, idx + 1)
def main():
data = sys.stdin.read().split()
n = int(data[0])
x = int(data[1])
arr = ... | end_turn | {
"input_tokens": 203,
"output_tokens": 173
} | null |
allenai/Dolci-Instruct-SFT | Coding | 230 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "You are given a list of forms and a case. Each form is represented as a dictionary with various attributes, including 'action' and 'type'. Your task is to implement a function that retrieves the first form from the list that meets two criteria: it must pass an action filter and... | ```python
from typing import List, Dict, Any, Callable, Optional
def get_first_valid_form(
forms: List[Dict[str, Any]],
action_filter: Callable[[str], bool],
type_filter: Callable[[str], bool]
) -> Optional[Dict[str, Any]]:
for form in forms:
if action_filter(form.get('action')) and type_filte... | end_turn | {
"input_tokens": 242,
"output_tokens": 155
} | null |
allenai/Dolci-Instruct-SFT | Coding | 283 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Given a string s, generate and print all unique permutations of the given string, one per line, in any order.\n\nInput\nA single line containing the string s (1 ≤ |s| ≤ 8, consisting of lowercase English letters).\n\nOutput\nPrint all unique permutations of the string, each on ... | ```python
from itertools import permutations
s = input().strip()
for p in sorted(set(permutations(s))):
print(''.join(p))
``` | end_turn | {
"input_tokens": 104,
"output_tokens": 53
} | null |
allenai/Dolci-Instruct-SFT | Coding | 231 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Write a program that reads a single line of input containing a string. The program should:\n- Convert the string into a list of words,\n- Remove any duplicate words (case-insensitive),\n- Handle punctuation correctly (all punctuation should be ignored when considering words),\n... | ```python
import string
s = input()
# Remove punctuation
translator = str.maketrans('', '', string.punctuation)
cleaned = s.translate(translator)
words = cleaned.lower().split()
unique_sorted = sorted(set(words))
print(unique_sorted)
``` | end_turn | {
"input_tokens": 258,
"output_tokens": 100
} | null |
allenai/Dolci-Instruct-SFT | Coding | 270 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "You are tasked with creating a Python function that compares two software version strings following the semantic versioning format. Each version string consists of three non-negative integers separated by periods (e.g., \"1.2.3\"). Your function should determine which version i... | ```python
def compare_versions(version1: str, version2: str) -> int:
v1_parts = [int(x) for x in version1.split('.')]
v2_parts = [int(x) for x in version2.split('.')]
for a, b in zip(v1_parts, v2_parts):
if a > b:
return 1
elif a < b:
return -1
return 0
``` | end_turn | {
"input_tokens": 207,
"output_tokens": 133
} | null |
allenai/Dolci-Instruct-SFT | Coding | 134 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "You are to write a program which evaluates a single mathematical expression provided as a string. The expression will contain the operators +, -, *, /, and parentheses (). The numbers in the expression are all non-negative integers. Your program should parse the expression from... | <think>
Need to parse and evaluate. Output int if whole number, else float. Division always produces float? "as a floating point number if division is used, otherwise as an integer if there is no fractional part". So if result is whole, print as int.
Let me just evaluate, then check if result == int(result), print int... | end_turn | {
"input_tokens": 268,
"output_tokens": 616
} | null |
allenai/Dolci-Instruct-SFT | Coding | 180 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Write a Python program that reads a single line from standard input, which is intended to be a binary number (a string of up to 1,000,000 digits). Your program should convert this binary number to its decimal equivalent and print the result. If the input contains any characters... | Looking at the examples, I need to note the exact error message format. The example output shows:
```
Error: Input string must only contain '0' and '1'.'
```
That has a trailing `'` which seems odd but I'll match it as shown.
Wait, let me re-read. The problem statement says: `'Error: Input string must only contain '... | end_turn | {
"input_tokens": 313,
"output_tokens": 344
} | null |
allenai/Dolci-Instruct-SFT | Coding | 246 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "You are tasked with extracting the SHA1 checksum value from a given string. The checksum is expected to be in the format 'SHA1:<length>:<value>', where <length> is the length of the checksum value and <value> is the actual checksum value consisting of 40 hexadecimal characters.... | ```python
import re
def extract_sha1_checksum(s):
match = re.fullmatch(r'SHA1:(\d+):([0-9a-fA-F]{40})', s)
if match and int(match.group(1)) == 40:
return match.group(2)
return None
``` | end_turn | {
"input_tokens": 255,
"output_tokens": 99
} | null |
allenai/Dolci-Instruct-SFT | Coding | 278 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "You are tasked with implementing a function to manage the title of an HTML document. Write a function `set_html_title` that takes a single parameter `title`. The function should set the title of the HTML document to the provided string if it is valid. If the title is not a stri... | ```python
_current_title = None
def set_html_title(title):
global _current_title
if not isinstance(title, str):
raise ValueError("A title has to be a string.")
_current_title = title
``` | end_turn | {
"input_tokens": 206,
"output_tokens": 72
} | null |
allenai/Dolci-Instruct-SFT | Coding | 2 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Write a python function to serialize and deserialize a simple data structure using JSON. The data structure is a dictionary that contains only string keys and integer values. Your task is to:\n\n1. Serialize the dictionary into a JSON string.\n2. Deserialize the JSON string bac... | ```python
import json
def serialize_and_deserialize(input_dict):
"""
Serialize a dictionary to a JSON string and then deserialize it back to a dictionary.
Args:
input_dict (dict): A dictionary with string keys and integer values.
Returns:
tuple: A tuple containing (json_string... | end_turn | {
"input_tokens": 346,
"output_tokens": 638
} | null |
allenai/Dolci-Instruct-SFT | Coding | 233 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "You are to write a program that determines the winner of a rock-paper-scissors game between two players.\n\nInput:\nThe program will take two characters as input, separated by a newline:\n- The first line contains the character representing the first player's choice: 'R' for Ro... | ```python
a = input().strip()
b = input().strip()
wins = {('R','S'), ('S','P'), ('P','R')}
print(a if (a,b) in wins else b)
``` | end_turn | {
"input_tokens": 222,
"output_tokens": 66
} | null |
allenai/Dolci-Instruct-SFT | Coding | 127 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Implement a function `find_ip_addresses(string: str) -> List[str]` that takes a string as input and returns a list of valid IP addresses found within the string. An IP address is considered valid if it consists of four decimal numbers separated by periods, where each number is ... | ```python
import re
from typing import List
def find_ip_addresses(string: str) -> List[str]:
pattern = r'(?<!\d)(?<!\d\.)(\d{1,3}(?:\.\d{1,3}){3})(?!\.?\d)'
candidates = re.findall(pattern, string)
valid = []
for ip in candidates:
parts = ip.split('.')
if all(len(p) > 0 and (p == '0' o... | end_turn | {
"input_tokens": 170,
"output_tokens": 663
} | null |
allenai/Dolci-Instruct-SFT | Coding | 101 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Write an SQL query to retrieve all records from a table named \"customers\" where the \"country\" column equals \"USA\", and order them by the \"last_purchase_date\" column in descending order. Exclude records with null or empty \"email_address\" fields."
}
] | # SQL Query
```sql
SELECT *
FROM customers
WHERE country = 'USA'
AND email_address IS NOT NULL
AND email_address <> ''
ORDER BY last_purchase_date DESC;
```
## Explanation
| Clause | Purpose |
|--------|---------|
| `SELECT *` | Retrieves **all columns** from the table. |
| `FROM customers` | Specifies the sourc... | end_turn | {
"input_tokens": 83,
"output_tokens": 572
} | null |
allenai/Dolci-Instruct-SFT | Coding | 67 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Write a python function to help me manage a list of magical creatures for my children's book. I have a list of creatures, each represented by a dictionary with the keys \"name\", \"type\", and \"power_level\". I want a function that takes this list as input and returns a new li... | ```python
def sort_creatures(creatures):
"""
Sort magical creatures by power_level (descending) and name (ascending).
Args:
creatures: A list of dictionaries, each with keys "name", "type",
and "power_level".
Returns:
A list of creature names sorted by power... | end_turn | {
"input_tokens": 424,
"output_tokens": 687
} | null |
allenai/Dolci-Instruct-SFT | Coding | 361 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Write a Python program that reads a single line containing a JSON string from standard input, parses it into a Python dictionary or list, and prints the resulting Python object. The program must handle nested JSON objects and arrays, converting them into nested Python dictionar... | ```python
import json
import sys
try:
line = input()
obj = json.loads(line)
print(obj)
except Exception:
print('Invalid JSON string')
``` | end_turn | {
"input_tokens": 205,
"output_tokens": 63
} | null |
allenai/Dolci-Instruct-SFT | Coding | 322 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "You are tasked with implementing a Python function that simulates attribute access on nested dictionaries. The function should take a dictionary and a string representing a chain of keys separated by dots. It should then return the value of the final key in the chain, or None i... | ```python
def nested_key_access(dict_obj, key_chain):
keys = key_chain.split('.')
current = dict_obj
for key in keys:
if isinstance(current, dict) and key in current:
current = current[key]
else:
return None
return current
``` | end_turn | {
"input_tokens": 342,
"output_tokens": 98
} | null |
allenai/Dolci-Instruct-SFT | Coding | 372 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Write a program that reads two non-zero vectors from standard input, each represented as a list of integers separated by spaces, and calculates the cosine similarity between them. The program should output a single floating-point value representing the cosine similarity.\n\nInp... | ```python
import math
v1 = list(map(int, input().split()))
v2 = list(map(int, input().split()))
dot = sum(a*b for a, b in zip(v1, v2))
n1 = math.sqrt(sum(a*a for a in v1))
n2 = math.sqrt(sum(b*b for b in v2))
print(dot / (n1 * n2))
``` | end_turn | {
"input_tokens": 213,
"output_tokens": 130
} | null |
allenai/Dolci-Instruct-SFT | Coding | 94 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "You are given a string `s` consisting of lowercase English letters. Your task is to write a function to determine the frequency of each letter in the string and return the result as a dictionary where the keys are the letters and the values are their respective frequencies. The... | ```python
def letter_frequency(s):
"""
Determine the frequency of each lowercase English letter in the given string.
Non-lowercase alphabetic characters (digits, uppercase letters, symbols,
whitespace, etc.) are ignored.
Args:
s (str): The input string to analyze.
Returns... | end_turn | {
"input_tokens": 211,
"output_tokens": 947
} | null |
allenai/Dolci-Instruct-SFT | Coding | 357 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Write a program that defines a function to add two values according to these rules:\n\n- If both inputs are numbers (integers or floats), return their sum.\n- If both are lists or tuples, return a new list containing their element-wise sums. If the lists or tuples are of unequa... | ```python
import ast
def add(x, y):
num_types = (int, float)
seq_types = (list, tuple)
if isinstance(x, bool) or isinstance(y, bool):
raise TypeError("Unsupported operand types.")
if isinstance(x, num_types) and isinstance(y, num_types):
return x + y
if isinstance(x, seq_types) and ... | end_turn | {
"input_tokens": 442,
"output_tokens": 396
} | null |
allenai/Dolci-Instruct-SFT | Coding | 197 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Develop a brief Python code that emits a Morse code sound pattern corresponding to the phrase \"Love to Program!\""
}
] | ```python
import numpy as np
import sounddevice as sd
MORSE = {
'A':'.-','B':'-...','C':'-.-.','D':'-..','E':'.','F':'..-.','G':'--.',
'H':'....','I':'..','J':'.---','K':'-.-','L':'.-..','M':'--','N':'-.',
'O':'---','P':'.--.','Q':'--.-','R':'.-.','S':'...','T':'-','U':'..-',
'V':'...-','W':'.--','X':'... | end_turn | {
"input_tokens": 50,
"output_tokens": 768
} | null |
allenai/Dolci-Instruct-SFT | Coding | 396 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Write a program that reads a single line string from standard input and outputs a string where all uppercase letters are converted to lowercase, and all lowercase letters are converted to uppercase. All other characters remain unchanged.\n\nInput\nA single line containing the s... | ```python
print(input().swapcase())
``` | end_turn | {
"input_tokens": 163,
"output_tokens": 19
} | null |
allenai/Dolci-Instruct-SFT | Coding | 311 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Write a python function to calculate the total weekly earnings of a working student who has a part-time job with varying daily hours. The function should take two inputs:\n\n1. A list of integers representing the number of hours worked each day from Monday to Sunday.\n2. An int... | ```python
def calculate_weekly_earnings(hours_per_day, hourly_wage):
"""
Calculate total weekly earnings for a working student.
Parameters:
- hours_per_day (list of int): Hours worked each day from Monday to Sunday.
- hourly_wage (int): The hourly wage.
Returns:
- int: Total earnin... | end_turn | {
"input_tokens": 227,
"output_tokens": 684
} | null |
allenai/Dolci-Instruct-SFT | Coding | 407 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "You are given a binary search tree (BST). Your task is to perform a level order (breadth-first) traversal of the BST and print the values of all nodes in this traversal order, separated by spaces, on a single line.\n\nInput:\nFirst, a single integer n, the number of nodes in th... | import sys
from collections import deque
def main():
data = sys.stdin.read().split()
if not data:
print()
return
n = int(data[0])
vals = list(map(int, data[1:1+n]))
if n == 0:
print()
return
root = None
def insert(root, v):
if root is N... | end_turn | {
"input_tokens": 236,
"output_tokens": 296
} | null |
allenai/Dolci-Instruct-SFT | Coding | 421 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Design a program that simulates a simple bank account using standard input and output.\n\nThe program should support the following commands, each entered on a separate line:\n- DEPOSIT X: Deposit integer amount X (>0) to the account. Print: 'Deposited $X. New balance is $Y.' (w... | ```python
def main():
balance = 0
while True:
try:
line = input()
except EOFError:
break
line = line.strip()
if not line:
continue
parts = line.split()
cmd = parts[0]
if cmd == "END":
break
elif cmd =... | end_turn | {
"input_tokens": 385,
"output_tokens": 295
} | null |
allenai/Dolci-Instruct-SFT | Coding | 293 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Design a regular expression pattern with precision that will distinctly identify the accurate string \"hello people\". The pattern should not identify any adjacent, leading or trailing characters apart from this exact string."
}
] | # Regular Expression for Exact Match of "hello people"
To precisely match **only** the exact string `"hello people"` with no leading, trailing, or adjacent characters, you need to use **anchors**.
## The Pattern
```regex
^hello people$
```
## Breakdown
| Component | Meaning |
|-----------|---------|
| `^` | Assert... | end_turn | {
"input_tokens": 72,
"output_tokens": 838
} | null |
allenai/Dolci-Instruct-SFT | Coding | 353 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Write a python function to parse a string containing weather data for a flight and extract important information such as temperature, wind speed, and visibility. The input will be a string formatted as follows: \"Temp: XX°C, Wind: YY km/h, Visibility: ZZ km\". The function shou... | ```python
import re
def parse_weather_data(weather_string):
"""
Parse a weather data string and extract temperature, wind speed, and visibility.
Args:
weather_string (str): A string formatted as
"Temp: XX°C, Wind: YY km/h, Visibility: ZZ km"
Returns:
... | end_turn | {
"input_tokens": 292,
"output_tokens": 912
} | null |
allenai/Dolci-Instruct-SFT | Coding | 137 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Construct a SQL query to find the number of employees with the same 'state' value in the employees table. Additionally, sort the output by the count of employees in descending order and include only those states that have more than 50 employees. Implement error handling measure... | # SQL Query: Count Employees by State
## Solution
```sql
SELECT
COALESCE(state, 'Unknown') AS state,
COUNT(*) AS employee_count
FROM
employees
WHERE
state IS NOT NULL
AND TRIM(state) <> ''
GROUP BY
state
HAVING
COUNT(*) > 50
ORDER BY
employee_count DESC;
```
## Explanation
###... | end_turn | {
"input_tokens": 97,
"output_tokens": 1424
} | null |
allenai/Dolci-Instruct-SFT | Coding | 383 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Write a python function to calculate the total carbon footprint of various types of seafood sold in a sustainable seafood market. The function should take a list of dictionaries as input, where each dictionary represents a seafood item with the following keys:\n\n- 'name': a st... | ```python
def calculate_carbon_footprint(seafood_items):
"""
Calculate the total carbon footprint for each seafood item.
Parameters:
seafood_items (list): A list of dictionaries, each containing:
- 'name' (str): Name of the seafood item
- 'quantity' (int): Quantity sold in kilograms... | end_turn | {
"input_tokens": 479,
"output_tokens": 903
} | null |
allenai/Dolci-Instruct-SFT | Coding | 175 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Construct a programming function that is capable of pinpointing numerical values within a predetermined range, extending from startnum to endnum. The function should be designed to recognize those numbers that are both perfect squares and whose digit sum also constitutes a perf... | # Perfect Square Finder with Digit Sum Validation
Here's a comprehensive solution that identifies numbers meeting both criteria:
```python
import math
def is_perfect_square(n):
"""Check if a number is a perfect square."""
if n < 0:
return False
root = math.isqrt(n)
return root * root == n
de... | end_turn | {
"input_tokens": 119,
"output_tokens": 1461
} | null |
allenai/Dolci-Instruct-SFT | Coding | 363 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Generate a function to reorganize a list of strings so that all strings that begin with a lower-case letter appear before those that begin with an upper-case letter.\nsample_list = [\"This\", \"is\", \"a\", \"Test\", \"list\"]"
}
] | # Reorganizing Strings by Case
Here's a function that reorganizes a list so strings starting with lowercase letters come before those starting with uppercase letters:
## Solution 1: Using `sorted()` with a Key Function
```python
def reorganize_list(strings):
"""
Reorganize list so lowercase-starting strings ... | end_turn | {
"input_tokens": 82,
"output_tokens": 981
} | null |
allenai/Dolci-Instruct-SFT | Coding | 369 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Write a python function to help me categorize costumes based on their thematic elements. I have a list of costume names, each associated with a specific theme or mythology. For instance, \"Athena's Armor\" belongs to \"Greek Mythology\", and \"Dragon's Scales\" belongs to \"Fan... | ```python
def categorize_costumes(costumes, themes):
"""
Categorize costumes based on thematic keywords.
Args:
costumes (list): List of costume names (strings).
themes (dict): Dictionary with themes as keys and lists of keywords as values.
Returns:
dict: Dictionary with... | end_turn | {
"input_tokens": 535,
"output_tokens": 993
} | null |
allenai/Dolci-Instruct-SFT | Coding | 483 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Given an array of integers, implement a function `calculate_bitwise_or(arr)` that returns the bitwise OR of all the integers in the array. If the array is empty, return None."
}
] | ```python
def calculate_bitwise_or(arr):
if not arr:
return None
result = 0
for num in arr:
result |= num
return result
``` | end_turn | {
"input_tokens": 68,
"output_tokens": 60
} | null |
allenai/Dolci-Instruct-SFT | Coding | 487 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Write a python function to calculate the average defect rate for a series of products based on their monthly defect counts and production volumes. The function should take two lists as input: one list with the number of defects recorded each month and another list with the corr... | ```python
def average_defect_rate(defects, production):
total_defects = sum(defects)
total_production = sum(production)
if total_production == 0:
return 0.0
return round((total_defects / total_production) * 100, 2)
``` | end_turn | {
"input_tokens": 263,
"output_tokens": 86
} | null |
allenai/Dolci-Instruct-SFT | Coding | 479 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Write a python function to analyze a list of film reviews and determine which words are most frequently used. The function should take a list of strings as input, where each string represents a review. The output should be a dictionary where the keys are words and the values ar... | ```python
import string
from collections import Counter
def analyze_reviews(reviews):
counter = Counter()
for review in reviews:
cleaned = review.lower().translate(str.maketrans('', '', string.punctuation))
counter.update(cleaned.split())
return dict(counter)
``` | end_turn | {
"input_tokens": 337,
"output_tokens": 107
} | null |
allenai/Dolci-Instruct-SFT | Coding | 399 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "You are tasked with creating a function that simulates the conversion of a MongoDB document represented as a dictionary into a simplified data model. Your function should handle the extraction of an '_id' field from the input dictionary and return a new dictionary with the key ... | ```python
def convert_mongo_document(data: dict, exclude_unset: bool, by_alias: bool) -> dict:
# Define field aliases mapping (original field name -> alias)
field_aliases = {
'_id': 'id',
}
result = {}
for key, value in data.items():
# Skip None values if exclude_unset is T... | end_turn | {
"input_tokens": 349,
"output_tokens": 822
} | null |
allenai/Dolci-Instruct-SFT | Coding | 490 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Write a program that reads a non-negative integer n from standard input, and prints the Fibonacci sequence from index 0 up to n (inclusive) as a list (Python list format) on a single line.\n\nThe Fibonacci numbers are defined as follows:\n- Fibonacci(0) = 0\n- Fibonacci(1) = 1\... | ```python
import sys
sys.setrecursionlimit(10000)
memo = {0: 0, 1: 1}
def fib(i):
if i not in memo:
memo[i] = fib(i-1) + fib(i-2)
return memo[i]
n = int(input())
print([fib(i) for i in range(n+1)])
``` | end_turn | {
"input_tokens": 297,
"output_tokens": 117
} | null |
allenai/Dolci-Instruct-SFT | Coding | 417 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Write a python function to calculate the average weight of newborns from a list of birth weights in grams. Each entry in the list represents the weight of a newborn. The function should return the average weight rounded to two decimal places.\n\nInput:\n- A list of integers, `b... | ```python
def calculate_average_weight(birth_weights):
"""
Calculate the average weight of newborns from a list of birth weights.
Parameters:
- birth_weights (list of int): List of newborn weights in grams.
Returns:
- float: The average weight rounded to two decimal places.
Ra... | end_turn | {
"input_tokens": 241,
"output_tokens": 749
} | null |
allenai/Dolci-Instruct-SFT | Coding | 504 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Write a python function to identify and count bird species from a list of bird sightings. Each sighting is represented as a string containing the bird's name and the sighting location, separated by a comma. Your function should return a dictionary where the keys are bird specie... | ```python
def count_bird_species(sightings):
counts = {}
for sighting in sightings:
bird_name = sighting.split(",")[0].strip()
counts[bird_name] = counts.get(bird_name, 0) + 1
return counts
``` | end_turn | {
"input_tokens": 319,
"output_tokens": 93
} | null |
allenai/Dolci-Instruct-SFT | Coding | 291 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Design an HTML form that embraces two distinct data entry fields: one specifically tailored for receiving unique personal identifiers such as 'Name', and another dedicated to inputting electronic mail or 'Email' addresses. The form should also feature a command button for submi... | # HTML Form with Name and Email Fields
Here's a clean, well-structured HTML form that includes dedicated fields for Name and Email, along with a submission button:
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
... | end_turn | {
"input_tokens": 99,
"output_tokens": 1425
} | null |
allenai/Dolci-Instruct-SFT | Coding | 348 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "I’m trying to price a call option on EUR/GBP exchange rate and it expires in 1 year. Should I use GBP Libor as foreign risk free rate in order to apply BS formula? The pricing date is 02/21/2023 but in this date there is no 12m GBP Libor [https://www.global-rates.com/it/tassi... | # Pricing a EUR/GBP Call with Garman-Kohlhagen (FX Black-Scholes)
## Which rate is "domestic" vs "foreign"?
For an FX option, the convention depends on how the exchange rate is quoted:
- **EUR/GBP** typically means "GBP per 1 EUR" (price of 1 EUR expressed in GBP)
- In the **Garman-Kohlhagen** model, the quote curre... | end_turn | {
"input_tokens": 202,
"output_tokens": 1074
} | null |
allenai/Dolci-Instruct-SFT | Coding | 501 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Given a tree where each node can have any number of children (including zero), compute the maximum depth of the tree. The tree is represented by a series of lines according to the following input format:\n\nInput:\n- The first line contains an integer n (1 ≤ n ≤ 1000), the numb... | <think>
Depth of root = 1. Compute depth[i] = depth[parent]+1.
</think>
```python
n = int(input())
depth = [0]*n
max_d = 0
for i in range(n):
p, v = map(int, input().split())
if p == -1:
depth[i] = 1
else:
depth[i] = depth[p] + 1
max_d = max(max_d, depth[i])
print(max_d)
```
For the ex... | end_turn | {
"input_tokens": 283,
"output_tokens": 207
} | null |
allenai/Dolci-Instruct-SFT | Coding | 541 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Write a program that reads a list of integers from standard input (all on a single line, separated by spaces). The program should find and output the most frequent element(s) in the list. If there are ties, output all the most frequent elements in increasing order, separated by... | ```python
from collections import Counter
line = input()
nums = line.split()
if not nums:
print()
else:
nums = [int(x) for x in nums]
counts = Counter(nums)
max_count = max(counts.values())
result = sorted([n for n, c in counts.items() if c == max_count])
print(' '.join(map(str, result)))
``` | end_turn | {
"input_tokens": 197,
"output_tokens": 126
} | null |
allenai/Dolci-Instruct-SFT | Coding | 475 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "You are given a binary search tree (BST), represented by its node values and structure, and a list of queries. For each query, determine if the specified value exists in the tree using a preorder traversal approach. You must implement this without using recursion or built-in st... | <think>
Simulate stack manually with list and index.
</think>
```python
def main():
import sys
input_data = sys.stdin.read().split()
idx = 0
N = int(input_data[idx]); idx += 1
nodes = []
for i in range(N):
v = int(input_data[idx]); idx += 1
l = int(input_data[idx]); idx += 1
... | end_turn | {
"input_tokens": 351,
"output_tokens": 432
} | null |
allenai/Dolci-Instruct-SFT | Coding | 571 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Write a program that reads a single line of text from standard input, and prints a dictionary containing the frequency of each character in the string, excluding spaces. The dictionary should be sorted first by the frequency in descending order, and then by character in ascendi... | ```python
s = input()
from collections import Counter
c = Counter(ch for ch in s if ch != ' ')
sorted_items = sorted(c.items(), key=lambda x: (-x[1], x[0]))
print(dict(sorted_items))
``` | end_turn | {
"input_tokens": 243,
"output_tokens": 90
} | null |
allenai/Dolci-Instruct-SFT | Coding | 275 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "You are to implement a program that maintains a binary tree with the following features:\n\n- You can insert integer values into the tree.\n- The tree supports an in-order traversal, printing the values in order. Each value should be printed as many times as its count (i.e., if... | <think>
Insert duplicate 30: when inserting a value equal, typically increase count. So insert 30 twice means count becomes... Let's check: insert 30 (count 1), insert 30 again (count 2), update_count 30 (count 3). Output has 30 three times. Correct.
Height: tree has root 30, left 20, right 40. Height = 2? But expecte... | end_turn | {
"input_tokens": 437,
"output_tokens": 1415
} | null |
allenai/Dolci-Instruct-SFT | Coding | 385 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Please thoroughly analyze and rectify potential errors in the provided piece of code that attempts to implement Bubble Sort, an algorithm for array sorting. To accomplish this, you must delve into the logic, iterate over the code lines, observe its existing structure carefully ... | # Bubble Sort Code Analysis
After carefully examining the provided code, I'll walk through its logic step by step to identify any potential issues.
## Code Review
```python
def bubbleSort(arr):
n = len(arr)
for i in range(n-1):
for j in range(0, n-i-1):
if arr[j] > arr[j+1]:
... | end_turn | {
"input_tokens": 214,
"output_tokens": 1371
} | null |
allenai/Dolci-Instruct-SFT | Coding | 36 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Generate a CSS style sheet to create a basic layout for a website."
}
] | # Basic Website Layout CSS
Here's a complete CSS stylesheet for a basic responsive website layout:
```css
/* ===== CSS Reset & Base Styles ===== */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
scroll-behavior: smooth;
font-size: 16px;
}
body {
font-family: 'Arial', 'Helvetica'... | end_turn | {
"input_tokens": 33,
"output_tokens": 2501
} | null |
allenai/Dolci-Instruct-SFT | Coding | 585 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "You are given a list of residues and a corresponding list of numbers. Your task is to implement a function that takes an integer n and returns the corresponding number from the list if n exists in the residues list. If n does not exist in the residues list, your function should... | ```python
from typing import List
def get_number(n: int, residues: List[int], numbers: List[int]) -> int:
if n not in residues:
raise ValueError('n is not in a list of residues!')
return numbers[residues.index(n)]
``` | end_turn | {
"input_tokens": 218,
"output_tokens": 89
} | null |
allenai/Dolci-Instruct-SFT | Coding | 594 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Write a Python program that reads two matrices of the same size from standard input, adds them, and prints the resulting matrix.\n\nInput:\n- The first line contains two integers n and m, separated by a space, representing the number of rows and columns in the matrices.\n- The ... | ```python
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(n)]
for i in range(n):
print(' '.join(str(a[i][j] + b[i][j]) for j in range(m)))
``` | end_turn | {
"input_tokens": 217,
"output_tokens": 111
} | null |
allenai/Dolci-Instruct-SFT | Coding | 575 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "You are given a list of integers, which can include both positive and negative numbers, and a single integer scalar value. Your task is to create a program that reads the list of integers and the scalar value from standard input, then outputs a new list where each number in the... | <think>
Sum of new = scalar * sum of original. Equal to sum original means sum*(scalar-1)=0. So either scalar==1 or sum==0. If scalar==1, output original. If sum==0, output multiplied list. Else empty.
</think>
```python
def main():
line = input().split()
nums = [int(x) for x in line]
scalar = int(input())... | end_turn | {
"input_tokens": 227,
"output_tokens": 216
} | null |
allenai/Dolci-Instruct-SFT | Coding | 266 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Provided an associative array, also known as a dictionary data structure in Python, construct a function which can traverse the given dictionary of dictionaries, and calculate the total quantity of all elements in it. The dictionary can have an arbitrary level of nesting. Consi... | # Counting Elements in a Nested Dictionary
Here's a function that recursively traverses a dictionary of arbitrary nesting depth and counts the total number of key-value pairs (where each nested dictionary's pairs are counted individually):
```python
def count_elements(dictionary):
"""
Recursively count all ke... | end_turn | {
"input_tokens": 181,
"output_tokens": 1157
} | null |
allenai/Dolci-Instruct-SFT | Coding | 607 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Write a python function to evaluate the safety risks associated with a list of extracurricular activities for children. The function should take a list of activities as input, where each activity is represented as a string. It should return a dictionary where the keys are the a... | ```python
def evaluate_activity_risks(activities):
risk_map = {
"Soccer": "Medium",
"Basketball": "Medium",
"Swimming": "High",
"Gymnastics": "High",
"Chess": "Low",
"Art": "Low"
}
return {activity: risk_map.get(activity, "Unknown") for activity in activities}... | end_turn | {
"input_tokens": 314,
"output_tokens": 137
} | null |
allenai/Dolci-Instruct-SFT | Coding | 598 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Incorporate the numpy, pandas, and matplotlib.pyplot libraries into your Python environment. Generate an array 'y' of 10 random numbers, each multiplied by 2, and an array 'x' of integers from 0 to 9. Now, your task is to ensure that all the ticks on the axes of the plot are in... | ```python
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.ticker import MaxNLocator
y = np.random.rand(10) * 2
x = np.arange(10)
fig, ax = plt.subplots()
ax.plot(x, y)
ax.xaxis.set_major_locator(MaxNLocator(integer=True))
ax.yaxis.set_major_locator(MaxNLocator(integer=True))
p... | end_turn | {
"input_tokens": 128,
"output_tokens": 172
} | null |
allenai/Dolci-Instruct-SFT | Coding | 534 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Write a python function to analyze the frequency of keywords related to grassroots movements in a given list of news articles. The function should take as input a list of strings, where each string represents a news article. It should also take a list of keywords to search for.... | ```python
def analyze_keyword_frequency(articles, keywords):
result = {}
for keyword in keywords:
kw_lower = keyword.lower()
count = sum(1 for article in articles if kw_lower in article.lower())
result[keyword] = count
return result
```
Note on the expected output: with substring ma... | end_turn | {
"input_tokens": 380,
"output_tokens": 533
} | null |
allenai/Dolci-Instruct-SFT | Coding | 289 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "You are required to program a function that calculates not only the dot product of two arrays, but also the cross product. Afterwards, the function should compute the angle between the two vectors represented by these arrays, in degrees. \n\nFor simplicity, you can assume all i... | # Vector Operations: Dot Product, Cross Product, and Angle Calculation
Here's a comprehensive Python function that handles all the requirements:
```python
import math
def vector_operations(array1, array2):
"""
Calculates the dot product, cross product, and angle between two 3D vectors.
Parameters:
... | end_turn | {
"input_tokens": 183,
"output_tokens": 2218
} | null |
allenai/Dolci-Instruct-SFT | Coding | 386 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "I'm looking for a .NET regular expression extract all the URLs from a webpage but haven't found one to be comprehensive enough to cover all the different ways you can specify a link. \n\nAnd a side question:\n\nIs there ? Or am I better off using a series of less complicated re... | # Extracting URLs from HTML with .NET Regex
## The Short Answer
**Don't use a single regex.** Use the HTML Agility Pack. But if you must use regex, here's a reasonably comprehensive approach.
## Why a Single Regex Is a Bad Idea
URLs can appear in HTML in many places:
- `<a href="...">`
- `<img src="...">`
- `<link ... | end_turn | {
"input_tokens": 129,
"output_tokens": 1339
} | null |
allenai/Dolci-Instruct-SFT | Coding | 323 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "I have a Kafka consumer service (spring boot). The problem is the topic names are not statically available i.e., not in properties file. The Consumer service has to request for the topic names from other service. I am not sure how to use @KafkaListener(topic=\"\") annotation in... | # Dynamic Kafka Topic Subscription in Spring Boot
You have several modern approaches to handle this. Here are the best options:
## Option 1: SpEL Expression in @KafkaListener (Simplest)
If you can fetch topics during bean initialization, use SpEL to reference a bean method:
```java
@Component
public class TopicProv... | end_turn | {
"input_tokens": 223,
"output_tokens": 1694
} | null |
allenai/Dolci-Instruct-SFT | Coding | 605 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "You are tasked with implementing a function that calculates the shortest distance between two points in a 2D space. The function should take two tuples, each representing the coordinates of a point (x, y). If one or both of the input points are None, the function should return ... | ```python
import math
def calculate_shortest_distance(point1, point2):
"""
Calculate the shortest (Euclidean) distance between two 2D points.
Args:
point1: A tuple (x, y) representing the first point, or None.
point2: A tuple (x, y) representing the second point, or None.
Returns:
... | end_turn | {
"input_tokens": 148,
"output_tokens": 225
} | null |
allenai/Dolci-Instruct-SFT | Coding | 526 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Define a function named 'diffList' that accepts a list of integers 'numList' and a boolean 'absolute_difference' (default to False). The function should return a new list that contains the difference of each pair of consecutive numbers from 'numList'. If 'absolute_difference' i... | ```python
def diffList(numList, absolute_difference=False):
"""
Return a list containing the differences between consecutive numbers in numList.
Parameters:
numList (list): A list of integers.
absolute_difference (bool): If True, return absolute differences. Defaults to False.
... | end_turn | {
"input_tokens": 119,
"output_tokens": 674
} | null |
allenai/Dolci-Instruct-SFT | Coding | 437 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "If unit-test names can become outdated over time and if you consider that the test itself is the most important thing, then is it important to choose wise test names?\n\nie \n\n\n[Test]\npublic void ShouldValidateUserNameIsLessThan100Characters() {}\n\n\n\nverse \n\n\n[Test]\np... | Yes, choosing wise test names is still important—arguably *more* important than the test code itself in many cases. Here's why the "names get outdated" argument doesn't really hold up:
## Why good test names matter
**1. Tests are documentation.** When a test fails in CI, the first thing you see is the name. A good na... | end_turn | {
"input_tokens": 114,
"output_tokens": 579
} | null |
allenai/Dolci-Instruct-SFT | Coding | 647 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "You are tasked with implementing a function that processes a list of tests based on a specified action. The function should accept the following parameters: a string 'action' which can either be 'whitelist' or 'blacklist', an integer 'num_tests' representing the number of tests... | ```python
def process_test_list(action, num_tests, test_list):
if action == 'whitelist':
return test_list
elif action == 'blacklist':
return []
``` | end_turn | {
"input_tokens": 239,
"output_tokens": 63
} | null |
allenai/Dolci-Instruct-SFT | Coding | 457 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "When calculating correlations in `R` e.g. via `cor` is it better to treat missing data as NAs or as `Zeros`?\nThe latter would be regarded as numerical valid values so I'd guess `NA` would be better?"
}
] | You're correct — **NAs are almost always better than zeros** for missing data in correlation calculations. Here's why:
## The Problem with Zeros
Replacing missing values with 0 treats them as **real observations with the value zero**, which:
1. **Distorts the mean and variance** of your variables
2. **Biases the cor... | end_turn | {
"input_tokens": 83,
"output_tokens": 674
} | null |
allenai/Dolci-Instruct-SFT | Coding | 625 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "You are tasked with managing a collection of data points represented as tuples. Each tuple contains multiple attributes, and you need to implement a function that can handle the following tasks: 1. Add a new data point (a tuple) to the collection. 2. Calculate the average of a ... | ```python
def data_manager_operations(operations):
data_points = []
results = []
for operation in operations:
op_type = operation[0]
if op_type == 'add':
data_points.append(operation[1])
elif op_type == 'average':
attribute_index = operation[1]
... | end_turn | {
"input_tokens": 300,
"output_tokens": 244
} | null |
allenai/Dolci-Instruct-SFT | Coding | 679 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Write a function `convert_initials(text: str) -> str` that takes a string `text` as input and returns a new string where the initial two characters of each word in the input string are converted to uppercase. A word is defined as a sequence of characters separated by spaces. If... | ```python
def convert_initials(text: str) -> str:
words = text.split(' ')
result = []
for word in words:
if len(word) < 2:
result.append(word.upper())
else:
result.append(word[:2].upper() + word[2:])
return ' '.join(result)
``` | end_turn | {
"input_tokens": 135,
"output_tokens": 105
} | null |
allenai/Dolci-Instruct-SFT | Coding | 656 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "You are tasked with creating a Python function that takes a string as input and returns a dictionary containing the positions of all the unique alphabets present in the input string. The position of an alphabet is determined by its position in the English alphabet, where 'a' co... | ```python
def alphabet_positions(input_string):
result = {}
for char in input_string:
lower_char = char.lower()
if lower_char.isalpha() and lower_char not in result:
result[lower_char] = ord(lower_char) - ord('a') + 1
return result
``` | end_turn | {
"input_tokens": 228,
"output_tokens": 103
} | null |
allenai/Dolci-Instruct-SFT | Coding | 640 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "You are given a positive integer n, an array nums of n positive integers and an integer s (s>0).\n\nTask\nFind the minimal length of a contiguous sub-array of nums whose elements sum to at least s. If no such sub-array exists, output 0.\n\nInput\nThe input is provided through s... | import sys
def main():
data = sys.stdin.read().split()
n = int(data[0])
s = int(data[1])
nums = list(map(int, data[2:2+n]))
left = 0
total = 0
min_len = n + 1
for right in range(n):
total += nums[right]
while total >= s:
min_len = min(min_len, right - le... | end_turn | {
"input_tokens": 294,
"output_tokens": 174
} | null |
allenai/Dolci-Instruct-SFT | Coding | 637 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Write a python function to help me determine the most popular clothing item from customer orders data. I have a list of dictionaries where each dictionary represents a customer's order and contains the item names as keys and the quantity ordered as values. For example:\n\n```py... | ```python
from collections import defaultdict
def most_popular_item(orders):
totals = defaultdict(int)
for order in orders:
for item, qty in order.items():
totals[item] += qty
return max(totals, key=totals.get) if totals else None
``` | end_turn | {
"input_tokens": 299,
"output_tokens": 94
} | null |
allenai/Dolci-Instruct-SFT | Coding | 547 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Write a program that reads one line of text from standard input and classifies it as 'spam' or 'not spam' based on the following criteria:\n\n- The line is considered spam if it contains any of these words: \"buy\", \"win\", or \"free\" (case-insensitive).\n- In addition, if th... | <think>
Need to parse. Check keywords buy/win/free case-insensitive as whole words? The examples don't clarify. Let me use word boundaries to be safe... Actually "free" in "freedom" might trigger. Problem says "contains any of these words" — likely substring. Let me use substring match to be simple.
For currency: find... | end_turn | {
"input_tokens": 329,
"output_tokens": 560
} | null |
allenai/Dolci-Instruct-SFT | Coding | 714 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "You are tasked with creating a function that updates the description of a project. The project is represented by a dictionary containing the keys: 'name', 'creator_id', 'project_id', and 'description'. The 'description' can be an empty string if not provided. Your function shou... | ```python
def update_project_description(project: dict, new_description: str) -> None:
if new_description != "":
project['description'] = new_description
``` | end_turn | {
"input_tokens": 211,
"output_tokens": 52
} | null |
allenai/Dolci-Instruct-SFT | Coding | 742 | 0 | anthropic | claude-opus-4-7 | train | [
{
"role": "user",
"content": "Given two lists of integers, `T1` and `Vvvov`, where `T1` represents the coefficients for a linear transformation and `Vvvov` represents the interaction values between different variables, write a function `calculate_expression(T1: List[int], Vvvov: List[int]) -> str` that comp... | ```python
from typing import List
def calculate_expression(T1: List[int], Vvvov: List[int]) -> str:
if len(T1) != len(Vvvov):
return 'Error: Lists must be of the same length.'
return '-1/2 * t^{o0}_{v2} * v^{o1,v2}_{v0,v1}'
``` | end_turn | {
"input_tokens": 266,
"output_tokens": 122
} | null |
End of preview. Expand in Data Studio
Dolci-Instruct-SFT · Opus 4.7 completions
10,000 completions sampled from
allenai/Dolci-Instruct-SFT
prompts with claude-opus-4-7 in pure mode (extended thinking disabled),
one completion per prompt, produced with the dist-align sampler.
Sampling
claude-opus-4-7,thinking: {type: "disabled"},max_tokens=4096, default sampling.- Domain-stratified: equal prompts from Coding, Reasoning, Chat, Math, Science, Multilingual, Precise IF, Other (Safety and Tool Use excluded).
Fields
dataset, domain, prompt_index, sample_index, provider, model,
split, prompt (list of {role, content}), text, finish_reason,
usage (input_tokens/output_tokens), error (on failure).
Notes
~20% of completions carry inline <think>...</think> scratch reasoning the model
emits on hard problems despite thinking being off. For SFT, drop error rows,
max_tokens-truncated completions, and refusals; optionally strip <think>.
- Downloads last month
- 56