message stringlengths 2 433k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 113 108k | cluster float64 12 12 | __index_level_0__ int64 226 217k |
|---|---|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an array a consisting of n integers.
You can remove at most one element from this array. Thus, the final length of the array is n-1 or n.
Your task is to calculate the maximum po... | instruction | 0 | 48,031 | 12 | 96,062 |
Yes | output | 1 | 48,031 | 12 | 96,063 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an array a consisting of n integers.
You can remove at most one element from this array. Thus, the final length of the array is n-1 or n.
Your task is to calculate the maximum po... | instruction | 0 | 48,032 | 12 | 96,064 |
No | output | 1 | 48,032 | 12 | 96,065 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an array a consisting of n integers.
You can remove at most one element from this array. Thus, the final length of the array is n-1 or n.
Your task is to calculate the maximum po... | instruction | 0 | 48,033 | 12 | 96,066 |
No | output | 1 | 48,033 | 12 | 96,067 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an array a consisting of n integers.
You can remove at most one element from this array. Thus, the final length of the array is n-1 or n.
Your task is to calculate the maximum po... | instruction | 0 | 48,034 | 12 | 96,068 |
No | output | 1 | 48,034 | 12 | 96,069 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an array a consisting of n integers.
You can remove at most one element from this array. Thus, the final length of the array is n-1 or n.
Your task is to calculate the maximum po... | instruction | 0 | 48,035 | 12 | 96,070 |
No | output | 1 | 48,035 | 12 | 96,071 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a permutation p_1, p_2, ... , p_n (an array where each integer from 1 to n appears exactly once). The weight of the i-th element of this permutation is a_i.
At first, you separate your permutation into two non-empty sets — pre... | instruction | 0 | 48,036 | 12 | 96,072 |
Tags: data structures, divide and conquer
Correct Solution:
```
from operator import add
class LazySegmentTree():
def __init__(self,n,init,merge=min,merge_unit=10**18,operate=add,operate_unit=0):
self.merge=merge
self.merge_unit=merge_unit
self.operate=operate
self.operate_unit=oper... | output | 1 | 48,036 | 12 | 96,073 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a permutation p_1, p_2, ... , p_n (an array where each integer from 1 to n appears exactly once). The weight of the i-th element of this permutation is a_i.
At first, you separate your permutation into two non-empty sets — pre... | instruction | 0 | 48,037 | 12 | 96,074 |
Tags: data structures, divide and conquer
Correct Solution:
```
import sys
readline = sys.stdin.readline
from itertools import accumulate
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_l... | output | 1 | 48,037 | 12 | 96,075 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a permutation p_1, p_2, ... , p_n (an array where each integer from 1 to n appears exactly once). The weight of the i-th element of this permutation is a_i.
At first, you separate your permutation into two non-empty sets — pre... | instruction | 0 | 48,038 | 12 | 96,076 |
Tags: data structures, divide and conquer
Correct Solution:
```
def main():
import sys
input = sys.stdin.buffer.readline
N = int(input())
P = list(map(int, input().split()))
A = list(map(float, input().split()))
class LazySegTree:
# Range add query
def __init__(self, A, initial... | output | 1 | 48,038 | 12 | 96,077 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a permutation p_1, p_2, ... , p_n (an array where each integer from 1 to n appears exactly once). The weight of the i-th element of this permutation is a_i.
At first, you separate your permutation into two non-empty sets — pre... | instruction | 0 | 48,039 | 12 | 96,078 |
Tags: data structures, divide and conquer
Correct Solution:
```
import sys
from itertools import accumulate
input = sys.stdin.readline
n=int(input())
P=tuple(map(int,input().split()))
A=tuple(map(int,input().split()))
seg_el=1<<((n+1).bit_length())
SEGMIN=[0]*(2*seg_el)
SEGADD=[0]*(2*seg_el)
for i in range(n):
... | output | 1 | 48,039 | 12 | 96,079 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a permutation p_1, p_2, ... , p_n (an array where each integer from 1 to n appears exactly once). The weight of the i-th element of this permutation is a_i.
At first, you separate... | instruction | 0 | 48,040 | 12 | 96,080 |
No | output | 1 | 48,040 | 12 | 96,081 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a permutation p_1, p_2, ... , p_n (an array where each integer from 1 to n appears exactly once). The weight of the i-th element of this permutation is a_i.
At first, you separate... | instruction | 0 | 48,041 | 12 | 96,082 |
No | output | 1 | 48,041 | 12 | 96,083 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a permutation p_1, p_2, ... , p_n (an array where each integer from 1 to n appears exactly once). The weight of the i-th element of this permutation is a_i.
At first, you separate... | instruction | 0 | 48,042 | 12 | 96,084 |
No | output | 1 | 48,042 | 12 | 96,085 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a permutation p_1, p_2, ... , p_n (an array where each integer from 1 to n appears exactly once). The weight of the i-th element of this permutation is a_i.
At first, you separate... | instruction | 0 | 48,043 | 12 | 96,086 |
No | output | 1 | 48,043 | 12 | 96,087 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have an array a of length n. For every positive integer x you are going to perform the following operation during the x-th second:
* Select some distinct indices i_{1}, i_{2}, …, i_{k} which are between 1 and n inclusive, and add 2^{x... | instruction | 0 | 48,051 | 12 | 96,102 |
Tags: greedy, math
Correct Solution:
```
import math
for i in range(int(input())):
n=int(input())
w=list(map(int,input().split()))
b=0
for j in range(n-1):
if(w[j]>w[j+1]):
b=max(b,int(math.log2(w[j]-w[j+1]))+1)
w[j+1]=w[j]
print(b)
``` | output | 1 | 48,051 | 12 | 96,103 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have an array a of length n. For every positive integer x you are going to perform the following operation during the x-th second:
* Select some distinct indices i_{1}, i_{2}, …, i_{k} which are between 1 and n inclusive, and add 2^{x... | instruction | 0 | 48,052 | 12 | 96,104 |
Tags: greedy, math
Correct Solution:
```
import math as M
for _ in range(int(input())):
n=int(input())
A=list(int(i) for i in input().split())
ans=0
for i in range(1,n):
if A[i-1]>A[i]:
d=A[i-1]-A[i]
x=int(M.log2(d)+1)
ans=max(ans,x) #comparing the vlaues of ... | output | 1 | 48,052 | 12 | 96,105 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have an array a of length n. For every positive integer x you are going to perform the following operation during the x-th second:
* Select some distinct indices i_{1}, i_{2}, …, i_{k} which are between 1 and n inclusive, and add 2^{x... | instruction | 0 | 48,053 | 12 | 96,106 |
Tags: greedy, math
Correct Solution:
```
for _ in range(int(input())):
n=int(input())
a=[int(i) for i in input().split()]
m=a[0]
p=0
for i in range(1,n):
m=max(m,a[i])
p=max(p,m-a[i])
c=0
while 2**c<=p:
c+=1
print(c)
``` | output | 1 | 48,053 | 12 | 96,107 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have an array a of length n. For every positive integer x you are going to perform the following operation during the x-th second:
* Select some distinct indices i_{1}, i_{2}, …, i_{k} which are between 1 and n inclusive, and add 2^{x... | instruction | 0 | 48,054 | 12 | 96,108 |
Tags: greedy, math
Correct Solution:
```
for t in range(int(input())):
n = int(input())
a = [int(i) for i in input().split()]
m = a[0]
v = 0
for i in a:
v = max(v,m-i)
m = max(m,i)
if v == 0:
print(0)
else:
p = 1
c = 0
while p<=v:
p... | output | 1 | 48,054 | 12 | 96,109 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have an array a of length n. For every positive integer x you are going to perform the following operation during the x-th second:
* Select some distinct indices i_{1}, i_{2}, …, i_{k} which are between 1 and n inclusive, and add 2^{x... | instruction | 0 | 48,055 | 12 | 96,110 |
Tags: greedy, math
Correct Solution:
```
t = int(input())
for case in range(1, t + 1):
n = int(input())
arr = [int(x) for x in input().split(" ")]
tick = 0
prev = -2e9
for a in arr:
if a > prev:
prev = a
else:
while a + (2 ** tick) - 1 < prev:
... | output | 1 | 48,055 | 12 | 96,111 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have an array a of length n. For every positive integer x you are going to perform the following operation during the x-th second:
* Select some distinct indices i_{1}, i_{2}, …, i_{k} which are between 1 and n inclusive, and add 2^{x... | instruction | 0 | 48,056 | 12 | 96,112 |
Tags: greedy, math
Correct Solution:
```
from sys import stdin
t=int(input())
for _ in range(t):
n=int(input())
l=list(map(int,stdin.readline().split()))
prev=l[0]
diff=[]
for e in l:
if(e<prev):
diff.append(prev-e)
else:
prev=e
if(len(diff)==0):
p... | output | 1 | 48,056 | 12 | 96,113 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have an array a of length n. For every positive integer x you are going to perform the following operation during the x-th second:
* Select some distinct indices i_{1}, i_{2}, …, i_{k} which are between 1 and n inclusive, and add 2^{x... | instruction | 0 | 48,057 | 12 | 96,114 |
Tags: greedy, math
Correct Solution:
```
from math import log2
for _ in range(int(input())):
n=int(input())
l=list(map(int,input().split()))
c=0
for i in range(1,len(l)):
if(l[i]<l[i-1]):c=max(c,int(log2(l[i-1]-l[i]))+1);l[i]=l[i-1]
print(c)
``` | output | 1 | 48,057 | 12 | 96,115 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have an array a of length n. For every positive integer x you are going to perform the following operation during the x-th second:
* Select some distinct indices i_{1}, i_{2}, …, i_{k} which are between 1 and n inclusive, and add 2^{x... | instruction | 0 | 48,058 | 12 | 96,116 |
Tags: greedy, math
Correct Solution:
```
# https://codeforces.com/problemset/problem/1338/A
from math import log2 as l, floor as f
for _ in range(int(input())):
n = int(input())
a = map(int, input().split())
x = 0
m = -1e100
for i in a:
m = max(m, i)
x = max(x, m-i)
if x == 0:
... | output | 1 | 48,058 | 12 | 96,117 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have an array a of length n. For every positive integer x you are going to perform the following operation during the x-th second:
* Select some distinct indices i_{1}, i_{2}, …, i_{k} wh... | instruction | 0 | 48,059 | 12 | 96,118 |
Yes | output | 1 | 48,059 | 12 | 96,119 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have an array a of length n. For every positive integer x you are going to perform the following operation during the x-th second:
* Select some distinct indices i_{1}, i_{2}, …, i_{k} wh... | instruction | 0 | 48,060 | 12 | 96,120 |
Yes | output | 1 | 48,060 | 12 | 96,121 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have an array a of length n. For every positive integer x you are going to perform the following operation during the x-th second:
* Select some distinct indices i_{1}, i_{2}, …, i_{k} wh... | instruction | 0 | 48,061 | 12 | 96,122 |
Yes | output | 1 | 48,061 | 12 | 96,123 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have an array a of length n. For every positive integer x you are going to perform the following operation during the x-th second:
* Select some distinct indices i_{1}, i_{2}, …, i_{k} wh... | instruction | 0 | 48,062 | 12 | 96,124 |
Yes | output | 1 | 48,062 | 12 | 96,125 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have an array a of length n. For every positive integer x you are going to perform the following operation during the x-th second:
* Select some distinct indices i_{1}, i_{2}, …, i_{k} wh... | instruction | 0 | 48,063 | 12 | 96,126 |
No | output | 1 | 48,063 | 12 | 96,127 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have an array a of length n. For every positive integer x you are going to perform the following operation during the x-th second:
* Select some distinct indices i_{1}, i_{2}, …, i_{k} wh... | instruction | 0 | 48,064 | 12 | 96,128 |
No | output | 1 | 48,064 | 12 | 96,129 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have an array a of length n. For every positive integer x you are going to perform the following operation during the x-th second:
* Select some distinct indices i_{1}, i_{2}, …, i_{k} wh... | instruction | 0 | 48,065 | 12 | 96,130 |
No | output | 1 | 48,065 | 12 | 96,131 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have an array a of length n. For every positive integer x you are going to perform the following operation during the x-th second:
* Select some distinct indices i_{1}, i_{2}, …, i_{k} wh... | instruction | 0 | 48,066 | 12 | 96,132 |
No | output | 1 | 48,066 | 12 | 96,133 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a permutation p_1, p_2, ..., p_n. Recall that sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.
Find three indices i, j and k such that:
* 1 ≤ i < j < k ≤ n;
* p_i < p_... | instruction | 0 | 48,067 | 12 | 96,134 |
Tags: brute force, data structures
Correct Solution:
```
def helper(n,arr):
# j=n
# for i in range(0,n):
# index=arr.index(j)
# if index==0 or index==n-1: #6 5 3 1 2 4
# j-=1
# continue
# elif:
# break
if len(arr)<=2:
... | output | 1 | 48,067 | 12 | 96,135 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a permutation p_1, p_2, ..., p_n. Recall that sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.
Find three indices i, j and k such that:
* 1 ≤ i < j < k ≤ n;
* p_i < p_... | instruction | 0 | 48,068 | 12 | 96,136 |
Tags: brute force, data structures
Correct Solution:
```
tests = int(input())
for t in range(tests):
n = int(input())
ls = list(map(int, input().split()))
high = ls[1]
high_idx = 1
low = ls[0]
low_idx = 0
res = []
if low > high:
low = high
low_idx = high_idx
high ... | output | 1 | 48,068 | 12 | 96,137 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a permutation p_1, p_2, ..., p_n. Recall that sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.
Find three indices i, j and k such that:
* 1 ≤ i < j < k ≤ n;
* p_i < p_... | instruction | 0 | 48,069 | 12 | 96,138 |
Tags: brute force, data structures
Correct Solution:
```
cases = int(input())
for case in range(cases):
n = int(input())
list_num = list(map(lambda x: int(x), input().split()))
unchanged = list.copy(list_num)
maximum = n
pos_max = list_num.index(maximum)
length = len(list_num)
flush_counter... | output | 1 | 48,069 | 12 | 96,139 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a permutation p_1, p_2, ..., p_n. Recall that sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.
Find three indices i, j and k such that:
* 1 ≤ i < j < k ≤ n;
* p_i < p_... | instruction | 0 | 48,070 | 12 | 96,140 |
Tags: brute force, data structures
Correct Solution:
```
for i in range(int(input())):
n=int(input())
a=list(map(int,input().split()))
l=[]
d=0
j=0
for j in range(1,n-1):
if(a[j]>a[j-1] and a[j]>a[j+1]):
l.append(j)
l.append(j+1)
l.append(j+2)
... | output | 1 | 48,070 | 12 | 96,141 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a permutation p_1, p_2, ..., p_n. Recall that sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.
Find three indices i, j and k such that:
* 1 ≤ i < j < k ≤ n;
* p_i < p_... | instruction | 0 | 48,071 | 12 | 96,142 |
Tags: brute force, data structures
Correct Solution:
```
def solve():
n = int(input())
p = list(map(int, input().split()))
k = False
for i in range(1, n):
if p[i] > p[i - 1]:
k = True
else:
if k:
print("YES")
print(i - 1, i, i + 1)
... | output | 1 | 48,071 | 12 | 96,143 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a permutation p_1, p_2, ..., p_n. Recall that sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.
Find three indices i, j and k such that:
* 1 ≤ i < j < k ≤ n;
* p_i < p_... | instruction | 0 | 48,072 | 12 | 96,144 |
Tags: brute force, data structures
Correct Solution:
```
def solve():
n = int(input())
a = [int(x) for x in input().split()]
for x in range(1,n-1):
if a[x] > a[x-1] and a[x]>a[x+1]:
print("YES")
return "{} {} {}".format(x,x+1,x+2)
return "NO"
for q in range(int(input())):
print(solve())
``` | output | 1 | 48,072 | 12 | 96,145 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a permutation p_1, p_2, ..., p_n. Recall that sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.
Find three indices i, j and k such that:
* 1 ≤ i < j < k ≤ n;
* p_i < p_... | instruction | 0 | 48,073 | 12 | 96,146 |
Tags: brute force, data structures
Correct Solution:
```
for _ in range(int(input())):
n=int(input())
x=[int(x) for x in input().split()]
t=[]
f=1
for i in range(1,len(x)-1):
if x[i]>x[i-1] and x[i+1]<x[i]:
print('yes')
print(i,i+1,i+2)
f=0
bre... | output | 1 | 48,073 | 12 | 96,147 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a permutation p_1, p_2, ..., p_n. Recall that sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.
Find three indices i, j and k such that:
* 1 ≤ i < j < k ≤ n;
* p_i < p_... | instruction | 0 | 48,074 | 12 | 96,148 |
Tags: brute force, data structures
Correct Solution:
```
for _ in range(int(input())):
n = int(input())
x = list(map(int,input().split()))
c = 0
for j in range(1,len(x)-1):
if x[j] > x[j-1] and x[j] > x[j+1]:
c = 1
print("YES")
print(j,j+1,j+2)
bre... | output | 1 | 48,074 | 12 | 96,149 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a permutation p_1, p_2, ..., p_n. Recall that sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.
Find three indices i, j and k su... | instruction | 0 | 48,075 | 12 | 96,150 |
Yes | output | 1 | 48,075 | 12 | 96,151 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a permutation p_1, p_2, ..., p_n. Recall that sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.
Find three indices i, j and k su... | instruction | 0 | 48,076 | 12 | 96,152 |
Yes | output | 1 | 48,076 | 12 | 96,153 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a permutation p_1, p_2, ..., p_n. Recall that sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.
Find three indices i, j and k su... | instruction | 0 | 48,077 | 12 | 96,154 |
Yes | output | 1 | 48,077 | 12 | 96,155 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a permutation p_1, p_2, ..., p_n. Recall that sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.
Find three indices i, j and k su... | instruction | 0 | 48,078 | 12 | 96,156 |
Yes | output | 1 | 48,078 | 12 | 96,157 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a permutation p_1, p_2, ..., p_n. Recall that sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.
Find three indices i, j and k su... | instruction | 0 | 48,079 | 12 | 96,158 |
No | output | 1 | 48,079 | 12 | 96,159 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a permutation p_1, p_2, ..., p_n. Recall that sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.
Find three indices i, j and k su... | instruction | 0 | 48,080 | 12 | 96,160 |
No | output | 1 | 48,080 | 12 | 96,161 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a permutation p_1, p_2, ..., p_n. Recall that sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.
Find three indices i, j and k su... | instruction | 0 | 48,081 | 12 | 96,162 |
No | output | 1 | 48,081 | 12 | 96,163 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a permutation p_1, p_2, ..., p_n. Recall that sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.
Find three indices i, j and k su... | instruction | 0 | 48,082 | 12 | 96,164 |
No | output | 1 | 48,082 | 12 | 96,165 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a of length 2n. Consider a partition of array a into two subsequences p and q of length n each (each element of array a should be in exactly one subsequence: either in p or in q).
Let's sort p in non-decreasing order,... | instruction | 0 | 48,103 | 12 | 96,206 |
Tags: combinatorics, math, sortings
Correct Solution:
```
n = int(input())
a = list(map(int,input().split()))
x = sorted(a[0:n])
y = sorted(a[n:],reverse=True)
M = 998244353
Sum = sum(map(lambda z,c: abs(z-c),x,y)) % M
count = Sum
for i in range(n*2,n,-1):
count = count*i % M
fact = 1
for i in range(2,n+1)... | output | 1 | 48,103 | 12 | 96,207 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a of length 2n. Consider a partition of array a into two subsequences p and q of length n each (each element of array a should be in exactly one subsequence: either in p or in q).
Let's sort p in non-decreasing order,... | instruction | 0 | 48,104 | 12 | 96,208 |
Tags: combinatorics, math, sortings
Correct Solution:
```
"""
#If FastIO not needed, used this and don't forget to strip
#import sys, math
#input = sys.stdin.readline
"""
import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
from types import GeneratorType... | output | 1 | 48,104 | 12 | 96,209 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a of length 2n. Consider a partition of array a into two subsequences p and q of length n each (each element of array a should be in exactly one subsequence: either in p or in q).
Let's sort p in non-decreasing order,... | instruction | 0 | 48,105 | 12 | 96,210 |
Tags: combinatorics, math, sortings
Correct Solution:
```
import os,io
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
def ncrmod(n,r):
num = den = 1
for i in range(r):
num = (num * (n - i)) % mod
den = (den * (i + 1)) % mod
return (num * pow(den,
mod - 2, mod)) % mo... | output | 1 | 48,105 | 12 | 96,211 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a of length 2n. Consider a partition of array a into two subsequences p and q of length n each (each element of array a should be in exactly one subsequence: either in p or in q).
Let's sort p in non-decreasing order,... | instruction | 0 | 48,106 | 12 | 96,212 |
Tags: combinatorics, math, sortings
Correct Solution:
```
def ncr(n,r,p):
num = 1
den = 1
for i in range(r):
num = num*(n-i)%p
den = den*(i+1)%p
return (num*pow(den,p-2,p))%p
def solve(n,a):
a.sort()
M = 998244353
ss = sum(a[:n])
ls = sum(a[n:])
return (ls-ss... | output | 1 | 48,106 | 12 | 96,213 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a of length 2n. Consider a partition of array a into two subsequences p and q of length n each (each element of array a should be in exactly one subsequence: either in p or in q).
Let's sort p in non-decreasing order,... | instruction | 0 | 48,107 | 12 | 96,214 |
Tags: combinatorics, math, sortings
Correct Solution:
```
def ncr(n, r, p):
num = den = 1
for i in range(r):
num = (num * (n - i)) % p;den = (den * (i + 1)) % p
return (num * pow(den,p - 2, p)) % p
n = int(input());a = sorted(list(map(int, input().split())));ans = 0
for i in range(n):ans += abs(a[i]... | output | 1 | 48,107 | 12 | 96,215 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.