id stringlengths 32 32 | input stringlengths 152 7.12k | output stringlengths 1.14k 90k | source stringclasses 3
values | license stringclasses 2
values | dataset stringclasses 2
values | split stringclasses 3
values | difficulty stringclasses 6
values | solution stringlengths 8 9.59k | difficulty_tier stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|
49608768f93e6e914c9e91ebcd71452a | Vasya commutes by train every day. There are n train stations in the city, and at the i-th station it's possible to buy only tickets to stations from i + 1 to ai inclusive. No tickets are sold at the last station.
Let ρi, j be the minimum number of tickets one needs to buy in order to get from stations i to station j.... | <think>
Okay, let's see. I need to find the sum of the minimum number of tickets for all pairs i < j. Hmm. The problem says that from station i, you can buy tickets to stations up to a_i. So each ticket from i can take you to any station from i+1 to a_i. And we need to find the minimum number of steps (tickets) to get ... | codeforces | cc-by-4.0 | code_contests | train | interview | n = int(input())
a = list(map(int, input().split()))
max_station = n
f = [0] * (n + 2) # 1-based indexing for stations
# Compute f for each station from n-1 down to 1
for k in range(n, 0, -1):
if k == max_station:
f[k] = 0
else:
# a is 0-based, and a[k-1] corresponds to station k's a_i
... | medium |
e9cb13dd8b5da078ffc09dfad1aa2f3c | AquaMoon has three integer arrays a, b, c of length n, where 1 ≤ a_i, b_i, c_i ≤ n for all i.
In order to accelerate her potato farming, she organizes her farm in a manner based on these three arrays. She is now going to complete m operations to count how many potatoes she can get. Each operation will have one of the ... | <think>
Okay, let's try to solve this problem. Hmm, the problem statement is a bit complex. Let me read it again carefully.
So, we have three arrays a, b, c, each of length n. Then, we have m operations. Some operations are updates to the a array, and others are queries asking for the number of triplets (i, j, k) wher... | codeforces | cc-by-4.0 | code_contests | train | VERY_HARD | from bisect import bisect_left, bisect_right, insort
def main():
import sys
input = sys.stdin.read
data = input().split()
idx = 0
n = int(data[idx])
m = int(data[idx+1])
idx +=2
a = list(map(lambda x: int(x)-1, data[idx:idx+n]))
idx +=n
b = list(map(lambda x: int(x)-1,... | high |
500091adc4203d734596d899295aef1d | Sonya was unable to think of a story for this problem, so here comes the formal description.
You are given the array containing n positive integers. At one turn you can pick any element and increase or decrease it by 1. The goal is the make the array strictly increasing by making the minimum possible number of operati... | <think>
Okay, let's see. The problem is to find the minimum number of operations needed to make an array strictly increasing. Each operation is incrementing or decrementing an element by 1. So, the key here is to adjust each element such that each subsequent element is larger than the previous, but with the least total... | codeforces | cc-by-4.0 | code_contests | train | competition | n = int(input())
a = list(map(int, input().split()))
D = [a[i] - i for i in range(n)]
intervals = []
for d in D:
new_interval = [d]
intervals.append(new_interval)
while len(intervals) >= 2:
prev = intervals[-2]
curr = intervals[-1]
m_prev = prev[(len(prev)-1)//2]
m_curr = c... | high |
bd37675178406a35c80b0e2e4908e4d3 | "This task is very simple. Given a string S of length n and q queries each query is on the format i (...TRUNCATED) | "<think>\nOkay, let's tackle this problem. So, the task is to process a bunch of queries on a string(...TRUNCATED) | codeforces | cc-by-4.0 | code_contests | train | HARD | "n, q = map(int, input().split())\ns = list(input())\nfor _ in range(q):\n i, j, k = map(int, inp(...TRUNCATED) | high |
b5ceea229c355b1bff079d2bc4708067 | "Vasya wrote down two strings s of length n and t of length m consisting of small English letters 'a(...TRUNCATED) | "<think>\nOkay, let's see. The problem is about finding the maximum number of non-overlapping occurr(...TRUNCATED) | codeforces | cc-by-4.0 | code_contests | train | interview | "n = int(input())\ns = input().strip()\nm = int(input())\n\na_even = [0] * n\nb_odd = [0] * n\na_odd(...TRUNCATED) | medium |
9239173d3bd49fad1b3424817a49fcd4 | "Malek is a rich man. He also is very generous. That's why he decided to split his money between poo(...TRUNCATED) | "<think>\nOkay, let's try to figure out how to solve this problem. Hmm. So the problem is about calc(...TRUNCATED) | codeforces | cc-by-4.0 | code_contests | train | VERY_HARD | "n, q = map(int, input().split())\na = list(map(int, input().split()))\nexpect = [0.0] * (n + 1) # (...TRUNCATED) | high |
d5bb1c0641a8e99e2566af9ee8e92b5b | "You successfully found poor Arkady near the exit of the station you've perfectly predicted. You sen(...TRUNCATED) | "<think>\nOkay, let's see. So the problem is to determine whether a taxi driver could be a robot bas(...TRUNCATED) | codeforces | cc-by-4.0 | code_contests | train | VERY_HARD | "import sys\n\ndef main():\n input = sys.stdin.read().split()\n ptr = 0\n t = int(input[ptr(...TRUNCATED) | high |
8015aed456d1b8019620c7e714f3ea9f | "Caesar cipher is one of the simplest encryption techniques. To transform the original message into (...TRUNCATED) | "<think>\nOkay, I need to solve this Caesar cipher problem. Let's see. The task is to take a message(...TRUNCATED) | codeforces | cc-by-4.0 | code_contests | train | HARD | "message = input().strip()\nk = int(input())\n\nencrypted = []\nfor c in message:\n offset = ord((...TRUNCATED) | high |
44bc89bf9395efd82b42259db165c5d0 | "Serega loves fun. However, everyone has fun in the unique manner. Serega has fun by solving query p(...TRUNCATED) | "<think>\nOkay, let's see. I need to solve this problem where there are two types of queries on an a(...TRUNCATED) | codeforces | cc-by-4.0 | code_contests | train | VERY_HARD | "import sys\n\nn = int(sys.stdin.readline())\na = list(map(int, sys.stdin.readline().split()))\nq = (...TRUNCATED) | high |
571cbc07ce0b4fbdde33d0514b562172 | "You are a lover of bacteria. You want to raise some bacteria in a box. \n\nInitially, the box is em(...TRUNCATED) | "<think>\nOkay, let's see. I need to find the minimum number of bacteria to add so that after some d(...TRUNCATED) | codeforces | cc-by-4.0 | code_contests | train | interview | x = int(input())
print(bin(x).count('1')) | medium |
End of preview. Expand in Data Studio
No dataset card yet
- Downloads last month
- 8