message stringlengths 2 44.5k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 42 109k | cluster float64 5 5 | __index_level_0__ int64 84 217k |
|---|---|---|---|---|---|
Provide a correct Python 3 solution for this coding contest problem.
There is a game that involves three variables, denoted A, B, and C.
As the game progresses, there will be N events where you are asked to make a choice. Each of these choices is represented by a string s_i. If s_i is `AB`, you must add 1 to A or B t... | instruction | 0 | 40,192 | 5 | 80,384 |
"Correct Solution:
```
n, a, b, c = map(int, input().split())
variables = [a, b, c]
alph = ["A", "B", "C"]
s = [[] for _ in range(n)]
for i in range(n):
u, v = map(lambda x: alph.index(x) , list(input()))
s[i] = [u, v]
# print(s)
can_do = True
ans = []
for i in range(n):
u, v = s[i][0], s[i][1]
if variables[u] + v... | output | 1 | 40,192 | 5 | 80,385 |
Provide a correct Python 3 solution for this coding contest problem.
There is a game that involves three variables, denoted A, B, and C.
As the game progresses, there will be N events where you are asked to make a choice. Each of these choices is represented by a string s_i. If s_i is `AB`, you must add 1 to A or B t... | instruction | 0 | 40,193 | 5 | 80,386 |
"Correct Solution:
```
#!/usr/bin/env python3
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
import sys
YES = "Yes" # type: str
NO = "No" # type: str
def solve(N: int, A: int, B: int, C: int, s: "List[int]"):
v = [A, B, C]
ans = []
for i in range(N):
l, r = s[i]
if ... | output | 1 | 40,193 | 5 | 80,387 |
Provide a correct Python 3 solution for this coding contest problem.
There is a game that involves three variables, denoted A, B, and C.
As the game progresses, there will be N events where you are asked to make a choice. Each of these choices is represented by a string s_i. If s_i is `AB`, you must add 1 to A or B t... | instruction | 0 | 40,195 | 5 | 80,390 |
"Correct Solution:
```
n,a,b,c = map(int,input().split())
s = []
for i in range(n):
tmp_s = input()
s.append(tmp_s)
ans = []
for i,val in enumerate(s):
if val == 'AB':
if a == b == 0:
print('No')
exit(0)
elif a < b or (a == b and i != n-1 and 'A' in s[i+1]):
... | output | 1 | 40,195 | 5 | 80,391 |
Provide a correct Python 3 solution for this coding contest problem.
There is a game that involves three variables, denoted A, B, and C.
As the game progresses, there will be N events where you are asked to make a choice. Each of these choices is represented by a string s_i. If s_i is `AB`, you must add 1 to A or B t... | instruction | 0 | 40,196 | 5 | 80,392 |
"Correct Solution:
```
N,A,B,C=map(int,input().split())
S=[]
d={'A':A, 'B':B, 'C':C}
for i in range(N):
S.append(input())
out=[]
for i in range(N):
s=S[i]
s0=s[0]
s1=s[1]
if d[s0]==d[s1]==0:
print('No')
break
elif d[s0]==0:
d[s0]+=1
d[s1]-=1
out.append(s... | output | 1 | 40,196 | 5 | 80,393 |
Provide a correct Python 3 solution for this coding contest problem.
There is a game that involves three variables, denoted A, B, and C.
As the game progresses, there will be N events where you are asked to make a choice. Each of these choices is represented by a string s_i. If s_i is `AB`, you must add 1 to A or B t... | instruction | 0 | 40,197 | 5 | 80,394 |
"Correct Solution:
```
#!python3
# input
N, A, B, C = list(map(int, input().split()))
S = [input() for _ in range(N)]
def main():
l = [A, B, C]
d = {"AB": (0, 1, 2), "AC": (0, 2, 1), "BC": (1, 2, 0)}
dl = ["A", "B", "C"]
ans = []
for n in range(N):
i, j, k = d[S[n]]
if l[i] < l[j]... | output | 1 | 40,197 | 5 | 80,395 |
Provide a correct Python 3 solution for this coding contest problem.
There is a game that involves three variables, denoted A, B, and C.
As the game progresses, there will be N events where you are asked to make a choice. Each of these choices is represented by a string s_i. If s_i is `AB`, you must add 1 to A or B t... | instruction | 0 | 40,198 | 5 | 80,396 |
"Correct Solution:
```
def solve():
ans = []
for i, (x, y) in enumerate(s):
if num[x]>num[y]: x, y = y, x
if num[x]==num[y] and i < n-1:
if y == s[i+1][0] or y == s[i+1][1]:
x, y = y, x
num[x]+=1
num[y]-=1
ans.append(x)
if num[y]<0: ret... | output | 1 | 40,198 | 5 | 80,397 |
Provide a correct Python 3 solution for this coding contest problem.
There is a game that involves three variables, denoted A, B, and C.
As the game progresses, there will be N events where you are asked to make a choice. Each of these choices is represented by a string s_i. If s_i is `AB`, you must add 1 to A or B t... | instruction | 0 | 40,199 | 5 | 80,398 |
"Correct Solution:
```
from collections import deque
from copy import copy
n, a, b, c = map(int, input().split())
s = [input().rstrip() for _ in range(n)]
m = {'A': a, 'B': b, 'C': c}
ans = []
for i in range(n):
if m[s[i][0]] > m[s[i][1]]:
ans.append(s[i][1])
m[s[i][0]] -= 1
m[s[i][1]] += ... | output | 1 | 40,199 | 5 | 80,399 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a game that involves three variables, denoted A, B, and C.
As the game progresses, there will be N events where you are asked to make a choice. Each of these choices is represented by ... | instruction | 0 | 40,200 | 5 | 80,400 |
Yes | output | 1 | 40,200 | 5 | 80,401 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a game that involves three variables, denoted A, B, and C.
As the game progresses, there will be N events where you are asked to make a choice. Each of these choices is represented by ... | instruction | 0 | 40,201 | 5 | 80,402 |
Yes | output | 1 | 40,201 | 5 | 80,403 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a game that involves three variables, denoted A, B, and C.
As the game progresses, there will be N events where you are asked to make a choice. Each of these choices is represented by ... | instruction | 0 | 40,202 | 5 | 80,404 |
Yes | output | 1 | 40,202 | 5 | 80,405 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a game that involves three variables, denoted A, B, and C.
As the game progresses, there will be N events where you are asked to make a choice. Each of these choices is represented by ... | instruction | 0 | 40,203 | 5 | 80,406 |
Yes | output | 1 | 40,203 | 5 | 80,407 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a game that involves three variables, denoted A, B, and C.
As the game progresses, there will be N events where you are asked to make a choice. Each of these choices is represented by ... | instruction | 0 | 40,204 | 5 | 80,408 |
No | output | 1 | 40,204 | 5 | 80,409 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a game that involves three variables, denoted A, B, and C.
As the game progresses, there will be N events where you are asked to make a choice. Each of these choices is represented by ... | instruction | 0 | 40,205 | 5 | 80,410 |
No | output | 1 | 40,205 | 5 | 80,411 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a game that involves three variables, denoted A, B, and C.
As the game progresses, there will be N events where you are asked to make a choice. Each of these choices is represented by ... | instruction | 0 | 40,206 | 5 | 80,412 |
No | output | 1 | 40,206 | 5 | 80,413 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a game that involves three variables, denoted A, B, and C.
As the game progresses, there will be N events where you are asked to make a choice. Each of these choices is represented by ... | instruction | 0 | 40,207 | 5 | 80,414 |
No | output | 1 | 40,207 | 5 | 80,415 |
Provide a correct Python 3 solution for this coding contest problem.
We have two distinct integers A and B.
Print the integer K such that |A - K| = |B - K|.
If such an integer does not exist, print `IMPOSSIBLE` instead.
Constraints
* All values in input are integers.
* 0 \leq A,\ B \leq 10^9
* A and B are distinct... | instruction | 0 | 40,224 | 5 | 80,448 |
"Correct Solution:
```
A, B = map(int, input().split())
print((A + B) // 2 if not (A + B) % 2 else "IMPOSSIBLE")
``` | output | 1 | 40,224 | 5 | 80,449 |
Provide a correct Python 3 solution for this coding contest problem.
We have two distinct integers A and B.
Print the integer K such that |A - K| = |B - K|.
If such an integer does not exist, print `IMPOSSIBLE` instead.
Constraints
* All values in input are integers.
* 0 \leq A,\ B \leq 10^9
* A and B are distinct... | instruction | 0 | 40,225 | 5 | 80,450 |
"Correct Solution:
```
a,b=map(int,input().split())
print("IMPOSSIBLE" if abs(a-b)%2==1 else (a+b)//2)
``` | output | 1 | 40,225 | 5 | 80,451 |
Provide a correct Python 3 solution for this coding contest problem.
We have two distinct integers A and B.
Print the integer K such that |A - K| = |B - K|.
If such an integer does not exist, print `IMPOSSIBLE` instead.
Constraints
* All values in input are integers.
* 0 \leq A,\ B \leq 10^9
* A and B are distinct... | instruction | 0 | 40,226 | 5 | 80,452 |
"Correct Solution:
```
a,b=map(int,input().split())
print (int((a+b)/2) if (a-b)%2==0 else "IMPOSSIBLE")
``` | output | 1 | 40,226 | 5 | 80,453 |
Provide a correct Python 3 solution for this coding contest problem.
We have two distinct integers A and B.
Print the integer K such that |A - K| = |B - K|.
If such an integer does not exist, print `IMPOSSIBLE` instead.
Constraints
* All values in input are integers.
* 0 \leq A,\ B \leq 10^9
* A and B are distinct... | instruction | 0 | 40,227 | 5 | 80,454 |
"Correct Solution:
```
a,b = map(int, input().split())
ans="IMPOSSIBLE"
if (a+b)%2==0:
ans=(a+b)//2
print(ans)
``` | output | 1 | 40,227 | 5 | 80,455 |
Provide a correct Python 3 solution for this coding contest problem.
We have two distinct integers A and B.
Print the integer K such that |A - K| = |B - K|.
If such an integer does not exist, print `IMPOSSIBLE` instead.
Constraints
* All values in input are integers.
* 0 \leq A,\ B \leq 10^9
* A and B are distinct... | instruction | 0 | 40,228 | 5 | 80,456 |
"Correct Solution:
```
A,B = map(int,input().split())
K = 'IMPOSSIBLE' if (A+B) % 2 != 0 else (A+B) // 2
print(K)
``` | output | 1 | 40,228 | 5 | 80,457 |
Provide a correct Python 3 solution for this coding contest problem.
We have two distinct integers A and B.
Print the integer K such that |A - K| = |B - K|.
If such an integer does not exist, print `IMPOSSIBLE` instead.
Constraints
* All values in input are integers.
* 0 \leq A,\ B \leq 10^9
* A and B are distinct... | instruction | 0 | 40,229 | 5 | 80,458 |
"Correct Solution:
```
A,B=map(int,input().split())
print((A+B)//2 if (A+B)%2==0 else "IMPOSSIBLE")
``` | output | 1 | 40,229 | 5 | 80,459 |
Provide a correct Python 3 solution for this coding contest problem.
We have two distinct integers A and B.
Print the integer K such that |A - K| = |B - K|.
If such an integer does not exist, print `IMPOSSIBLE` instead.
Constraints
* All values in input are integers.
* 0 \leq A,\ B \leq 10^9
* A and B are distinct... | instruction | 0 | 40,230 | 5 | 80,460 |
"Correct Solution:
```
a,b = map(int, input().split())
x = a +b
print(int(x/2) if x%2 == 0 else "IMPOSSIBLE")
``` | output | 1 | 40,230 | 5 | 80,461 |
Provide a correct Python 3 solution for this coding contest problem.
We have two distinct integers A and B.
Print the integer K such that |A - K| = |B - K|.
If such an integer does not exist, print `IMPOSSIBLE` instead.
Constraints
* All values in input are integers.
* 0 \leq A,\ B \leq 10^9
* A and B are distinct... | instruction | 0 | 40,231 | 5 | 80,462 |
"Correct Solution:
```
a, b = map(int,input().split())
print('IMPOSSIBLE' if (a+b)%2 else abs((a+b)//2))
``` | output | 1 | 40,231 | 5 | 80,463 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have two distinct integers A and B.
Print the integer K such that |A - K| = |B - K|.
If such an integer does not exist, print `IMPOSSIBLE` instead.
Constraints
* All values in input are i... | instruction | 0 | 40,232 | 5 | 80,464 |
Yes | output | 1 | 40,232 | 5 | 80,465 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have two distinct integers A and B.
Print the integer K such that |A - K| = |B - K|.
If such an integer does not exist, print `IMPOSSIBLE` instead.
Constraints
* All values in input are i... | instruction | 0 | 40,233 | 5 | 80,466 |
Yes | output | 1 | 40,233 | 5 | 80,467 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have two distinct integers A and B.
Print the integer K such that |A - K| = |B - K|.
If such an integer does not exist, print `IMPOSSIBLE` instead.
Constraints
* All values in input are i... | instruction | 0 | 40,234 | 5 | 80,468 |
Yes | output | 1 | 40,234 | 5 | 80,469 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have two distinct integers A and B.
Print the integer K such that |A - K| = |B - K|.
If such an integer does not exist, print `IMPOSSIBLE` instead.
Constraints
* All values in input are i... | instruction | 0 | 40,235 | 5 | 80,470 |
Yes | output | 1 | 40,235 | 5 | 80,471 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have two distinct integers A and B.
Print the integer K such that |A - K| = |B - K|.
If such an integer does not exist, print `IMPOSSIBLE` instead.
Constraints
* All values in input are i... | instruction | 0 | 40,236 | 5 | 80,472 |
No | output | 1 | 40,236 | 5 | 80,473 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have two distinct integers A and B.
Print the integer K such that |A - K| = |B - K|.
If such an integer does not exist, print `IMPOSSIBLE` instead.
Constraints
* All values in input are i... | instruction | 0 | 40,237 | 5 | 80,474 |
No | output | 1 | 40,237 | 5 | 80,475 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have two distinct integers A and B.
Print the integer K such that |A - K| = |B - K|.
If such an integer does not exist, print `IMPOSSIBLE` instead.
Constraints
* All values in input are i... | instruction | 0 | 40,238 | 5 | 80,476 |
No | output | 1 | 40,238 | 5 | 80,477 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have two distinct integers A and B.
Print the integer K such that |A - K| = |B - K|.
If such an integer does not exist, print `IMPOSSIBLE` instead.
Constraints
* All values in input are i... | instruction | 0 | 40,239 | 5 | 80,478 |
No | output | 1 | 40,239 | 5 | 80,479 |
Provide a correct Python 3 solution for this coding contest problem.
Let M be a positive integer.
You are given 2 N integers a_1, a_2, \ldots, a_{2 N}, where 0 \leq a_i < M for each i.
Consider dividing the 2 N integers into N pairs. Here, each integer must belong to exactly one pair.
We define the ugliness of a pa... | instruction | 0 | 40,241 | 5 | 80,482 |
"Correct Solution:
```
n, m = map(int, input().split())
a = sorted([int(x) for x in input().split()])
def chk(x):
for i in range(2*x, 2*n):
if i != 2*n - 1 - (i - 2*x) and a[i] + a[2*n-1-(i-2*x)] < m:
return False
return True
bottom = -1
top = n
while top - bottom > 1:
mid = (top + ... | output | 1 | 40,241 | 5 | 80,483 |
Provide a correct Python 3 solution for this coding contest problem.
Let M be a positive integer.
You are given 2 N integers a_1, a_2, \ldots, a_{2 N}, where 0 \leq a_i < M for each i.
Consider dividing the 2 N integers into N pairs. Here, each integer must belong to exactly one pair.
We define the ugliness of a pa... | instruction | 0 | 40,242 | 5 | 80,484 |
"Correct Solution:
```
def check(k):
ret = 0
b = 2 * k - 1
for j in range(k):
t = aaa[j] + aaa[b - j]
if t >= m:
return -1
ret = max(ret, t)
b = 2 * k
c = 2 * n - 1
for j in range(n - k):
t = aaa[b + j] + aaa[c - j]
if t < m:
return... | output | 1 | 40,242 | 5 | 80,485 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let M be a positive integer.
You are given 2 N integers a_1, a_2, \ldots, a_{2 N}, where 0 \leq a_i < M for each i.
Consider dividing the 2 N integers into N pairs. Here, each integer must bel... | instruction | 0 | 40,243 | 5 | 80,486 |
No | output | 1 | 40,243 | 5 | 80,487 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let M be a positive integer.
You are given 2 N integers a_1, a_2, \ldots, a_{2 N}, where 0 \leq a_i < M for each i.
Consider dividing the 2 N integers into N pairs. Here, each integer must bel... | instruction | 0 | 40,244 | 5 | 80,488 |
No | output | 1 | 40,244 | 5 | 80,489 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let M be a positive integer.
You are given 2 N integers a_1, a_2, \ldots, a_{2 N}, where 0 \leq a_i < M for each i.
Consider dividing the 2 N integers into N pairs. Here, each integer must bel... | instruction | 0 | 40,245 | 5 | 80,490 |
No | output | 1 | 40,245 | 5 | 80,491 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let M be a positive integer.
You are given 2 N integers a_1, a_2, \ldots, a_{2 N}, where 0 \leq a_i < M for each i.
Consider dividing the 2 N integers into N pairs. Here, each integer must bel... | instruction | 0 | 40,246 | 5 | 80,492 |
No | output | 1 | 40,246 | 5 | 80,493 |
Provide a correct Python 3 solution for this coding contest problem.
Problem statement
Real variables $ x_1, x_2, ..., x_N $ satisfy the following conditions.
1. $ 0 \ leq x_i \ leq 1 $ ($ 1 \ leq i \ leq N $)
2. $ w_1x_1 + w_2x_2 + ... + w_Nx_N \ leq W $
At this time, find the maximum value that $ v_1x_1 + v_2x_... | instruction | 0 | 40,396 | 5 | 80,792 |
"Correct Solution:
```
import heapq
N, W = [int(n) for n in input().split()]
tmpw = 0
tmpv = 0
minheap = []
for i in range(N):
w, v = [int(n) for n in input().split()]
if(w < 0):
tmpw += w
tmpv += v
w *= -1
v *= -1
if(v > 0):
if w == 0:
tmpv += v
e... | output | 1 | 40,396 | 5 | 80,793 |
Provide a correct Python 3 solution for this coding contest problem.
Example
Input
R?????,2?)
Output
29 | instruction | 0 | 40,401 | 5 | 80,802 |
"Correct Solution:
```
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int... | output | 1 | 40,401 | 5 | 80,803 |
Provide a correct Python 3 solution for this coding contest problem.
Oranges on Cans
square1001 You put a $ N $ can of aluminum on the table.
E869120 You put $ M $ of oranges on each aluminum can on the table.
How many oranges are on the aluminum can?
input
Input is given from standard input in the following form... | instruction | 0 | 40,403 | 5 | 80,806 |
"Correct Solution:
```
n, m = [int(i) for i in input().split()]
print(n*m)
``` | output | 1 | 40,403 | 5 | 80,807 |
Provide a correct Python 3 solution for this coding contest problem.
Oranges on Cans
square1001 You put a $ N $ can of aluminum on the table.
E869120 You put $ M $ of oranges on each aluminum can on the table.
How many oranges are on the aluminum can?
input
Input is given from standard input in the following form... | instruction | 0 | 40,404 | 5 | 80,808 |
"Correct Solution:
```
def nums():
return list(map(int,input().split()))
N,M = nums()
print(N*M)
``` | output | 1 | 40,404 | 5 | 80,809 |
Provide a correct Python 3 solution for this coding contest problem.
Oranges on Cans
square1001 You put a $ N $ can of aluminum on the table.
E869120 You put $ M $ of oranges on each aluminum can on the table.
How many oranges are on the aluminum can?
input
Input is given from standard input in the following form... | instruction | 0 | 40,405 | 5 | 80,810 |
"Correct Solution:
```
a,b=map(int,input().split())
print(a*b)
``` | output | 1 | 40,405 | 5 | 80,811 |
Provide a correct Python 3 solution for this coding contest problem.
Oranges on Cans
square1001 You put a $ N $ can of aluminum on the table.
E869120 You put $ M $ of oranges on each aluminum can on the table.
How many oranges are on the aluminum can?
input
Input is given from standard input in the following form... | instruction | 0 | 40,406 | 5 | 80,812 |
"Correct Solution:
```
print(eval(input().replace(" ", "*")))
``` | output | 1 | 40,406 | 5 | 80,813 |
Provide a correct Python 3 solution for this coding contest problem.
Oranges on Cans
square1001 You put a $ N $ can of aluminum on the table.
E869120 You put $ M $ of oranges on each aluminum can on the table.
How many oranges are on the aluminum can?
input
Input is given from standard input in the following form... | instruction | 0 | 40,407 | 5 | 80,814 |
"Correct Solution:
```
n,m=map(int,input().split())
print(n*m)
``` | output | 1 | 40,407 | 5 | 80,815 |
Provide a correct Python 3 solution for this coding contest problem.
Oranges on Cans
square1001 You put a $ N $ can of aluminum on the table.
E869120 You put $ M $ of oranges on each aluminum can on the table.
How many oranges are on the aluminum can?
input
Input is given from standard input in the following form... | instruction | 0 | 40,408 | 5 | 80,816 |
"Correct Solution:
```
N,M = map(int,input().split())
print(N*M)
``` | output | 1 | 40,408 | 5 | 80,817 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which manipulates a sequence $A$ = {$a_0, a_1, ..., a_{n-1}$} with the following operations:
* $add(s, t, x)$ : add $x$ to $a_s, a_{s+1}, ..., a_t$.
* $find(s, t)$ : report the minimum value in $a_s, a_{s+1}, ..., a_t$.
Note that ... | instruction | 0 | 40,409 | 5 | 80,818 |
"Correct Solution:
```
import sys
input = sys.stdin.readline
N,Q=map(int,input().split())
seg_el=1<<(N.bit_length()) # Segment treeの台の要素数
SEG=[0]*(2*seg_el) # 1-indexedなので、要素数2*seg_el.Segment treeの初期値で初期化
LAZY=[0]*(2*seg_el) # 1-indexedなので、要素数2*seg_el.Segment treeの初期値で初期化
def indexes(L,R): # 遅延伝搬すべきノードのリストを返す. (つまり,... | output | 1 | 40,409 | 5 | 80,819 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which manipulates a sequence $A$ = {$a_0, a_1, ..., a_{n-1}$} with the following operations:
* $add(s, t, x)$ : add $x$ to $a_s, a_{s+1}, ..., a_t$.
* $find(s, t)$ : report the minimum value in $a_s, a_{s+1}, ..., a_t$.
Note that ... | instruction | 0 | 40,410 | 5 | 80,820 |
"Correct Solution:
```
# https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/all/DSL_2_H
class SegmentTreeForRMQandRAQ: # range minimum query and range add query
def __init__(self, ls: list, segfunc=min, identity_element=2**31, lazy_ide=0):
'''
セグ木
一次元のリストlsを受け取り初期化する。O(len(ls))
... | output | 1 | 40,410 | 5 | 80,821 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which manipulates a sequence $A$ = {$a_0, a_1, ..., a_{n-1}$} with the following operations:
* $add(s, t, x)$ : add $x$ to $a_s, a_{s+1}, ..., a_t$.
* $find(s, t)$ : report the minimum value in $a_s, a_{s+1}, ..., a_t$.
Note that ... | instruction | 0 | 40,411 | 5 | 80,822 |
"Correct Solution:
```
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(... | output | 1 | 40,411 | 5 | 80,823 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which manipulates a sequence $A$ = {$a_0, a_1, ..., a_{n-1}$} with the following operations:
* $add(s, t, x)$ : add $x$ to $a_s, a_{s+1}, ..., a_t$.
* $find(s, t)$ : report the minimum value in $a_s, a_{s+1}, ..., a_t$.
Note that ... | instruction | 0 | 40,412 | 5 | 80,824 |
"Correct Solution:
```
#!/usr/bin/env python3
# DSL_2_H: RMQ and RAQ
# Range Minimum Query and Range Add Query
# Lazy propagate segment tree
from array import array
import sys
class SegmentTree:
MAXV = 1000 * 10**5 + 1
def __init__(self, n):
size = 1
while size < n:
size *= 2
... | output | 1 | 40,412 | 5 | 80,825 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which manipulates a sequence $A$ = {$a_0, a_1, ..., a_{n-1}$} with the following operations:
* $add(s, t, x)$ : add $x$ to $a_s, a_{s+1}, ..., a_t$.
* $find(s, t)$ : report the minimum value in $a_s, a_{s+1}, ..., a_t$.
Note that ... | instruction | 0 | 40,413 | 5 | 80,826 |
"Correct Solution:
```
import sys
class Lazysegtree:
#RAQ
def __init__(self, A, intv, initialize = True, segf = min):
#区間は 1-indexed で管理
self.N = len(A)
self.N0 = 2**(self.N-1).bit_length()
self.intv = intv
self.segf = segf
self.lazy = [0]*(2*self.N0)
if i... | output | 1 | 40,413 | 5 | 80,827 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.