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_1, a_2, ... , a_n. Array is good if for each pair of indexes i < j the condition j - a_j ≠ i - a_i holds. Can you shuffle this array so that it becomes good? To shuffle ... | instruction | 0 | 29,260 | 12 | 58,520 |
Yes | output | 1 | 29,260 | 12 | 58,521 |
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_1, a_2, ... , a_n. Array is good if for each pair of indexes i < j the condition j - a_j ≠ i - a_i holds. Can you shuffle this array so that it becomes good? To shuffle ... | instruction | 0 | 29,261 | 12 | 58,522 |
Yes | output | 1 | 29,261 | 12 | 58,523 |
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_1, a_2, ... , a_n. Array is good if for each pair of indexes i < j the condition j - a_j ≠ i - a_i holds. Can you shuffle this array so that it becomes good? To shuffle ... | instruction | 0 | 29,262 | 12 | 58,524 |
Yes | output | 1 | 29,262 | 12 | 58,525 |
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_1, a_2, ... , a_n. Array is good if for each pair of indexes i < j the condition j - a_j ≠ i - a_i holds. Can you shuffle this array so that it becomes good? To shuffle ... | instruction | 0 | 29,263 | 12 | 58,526 |
No | output | 1 | 29,263 | 12 | 58,527 |
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_1, a_2, ... , a_n. Array is good if for each pair of indexes i < j the condition j - a_j ≠ i - a_i holds. Can you shuffle this array so that it becomes good? To shuffle ... | instruction | 0 | 29,264 | 12 | 58,528 |
No | output | 1 | 29,264 | 12 | 58,529 |
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_1, a_2, ... , a_n. Array is good if for each pair of indexes i < j the condition j - a_j ≠ i - a_i holds. Can you shuffle this array so that it becomes good? To shuffle ... | instruction | 0 | 29,265 | 12 | 58,530 |
No | output | 1 | 29,265 | 12 | 58,531 |
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_1, a_2, ... , a_n. Array is good if for each pair of indexes i < j the condition j - a_j ≠ i - a_i holds. Can you shuffle this array so that it becomes good? To shuffle ... | instruction | 0 | 29,266 | 12 | 58,532 |
No | output | 1 | 29,266 | 12 | 58,533 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's denote the following function f. This function takes an array a of length n and returns an array. Initially the result is an empty array. For each integer i from 1 to n we add element a_i ... | instruction | 0 | 29,267 | 12 | 58,534 |
No | output | 1 | 29,267 | 12 | 58,535 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's denote the following function f. This function takes an array a of length n and returns an array. Initially the result is an empty array. For each integer i from 1 to n we add element a_i ... | instruction | 0 | 29,268 | 12 | 58,536 |
No | output | 1 | 29,268 | 12 | 58,537 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's denote the following function f. This function takes an array a of length n and returns an array. Initially the result is an empty array. For each integer i from 1 to n we add element a_i ... | instruction | 0 | 29,269 | 12 | 58,538 |
No | output | 1 | 29,269 | 12 | 58,539 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's denote the following function f. This function takes an array a of length n and returns an array. Initially the result is an empty array. For each integer i from 1 to n we add element a_i ... | instruction | 0 | 29,270 | 12 | 58,540 |
No | output | 1 | 29,270 | 12 | 58,541 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a consisting of n integers.
In one move, you can choose some index i (1 ≤ i ≤ n - 2) and shift the segment [a_i, a_{i + 1}, a_{i + 2}] cyclically to the right (i.e. replace the segment [a_i, a_{i + 1}, a_{i + 2}] with... | instruction | 0 | 29,287 | 12 | 58,574 |
Tags: brute force, constructive algorithms, implementation, sortings
Correct Solution:
```
import io
import os
from collections import Counter, deque
DEBUG = False
def solve(N, A):
original = list(A)
sortedA = sorted(A)
if False and N <= 5:
# Bruteforce for small N
def doMove(A, i):
... | output | 1 | 29,287 | 12 | 58,575 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a consisting of n integers.
In one move, you can choose some index i (1 ≤ i ≤ n - 2) and shift the segment [a_i, a_{i + 1}, a_{i + 2}] cyclically to the right (i.e. replace the segment [a_i, a_{i + 1}, a_{i + 2}] with... | instruction | 0 | 29,288 | 12 | 58,576 |
Tags: brute force, constructive algorithms, implementation, sortings
Correct Solution:
```
t = int(input())
for _ in range(t):
n = int(input())
l = list(map(lambda x: int(x)- 1, input().split()))
out = []
ll = [(l[i], i) for i in range(n)]
ll.sort()
swap = (-1,-1)
for i in range(n - 1):
... | output | 1 | 29,288 | 12 | 58,577 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a consisting of n integers.
In one move, you can choose some index i (1 ≤ i ≤ n - 2) and shift the segment [a_i, a_{i + 1}, a_{i + 2}] cyclically to the right (i.e. replace the segment [a_i, a_{i + 1}, a_{i + 2}] with... | instruction | 0 | 29,289 | 12 | 58,578 |
Tags: brute force, constructive algorithms, implementation, sortings
Correct Solution:
```
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(sys.stdin.readline())
def ria(): return list(map(int, sys.stdin.readline().split()))
def ws(s): sys.stdout.write(s + '\n')
def wi(n): sys.stdout.write... | output | 1 | 29,289 | 12 | 58,579 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a consisting of n integers.
In one move, you can choose some index i (1 ≤ i ≤ n - 2) and shift the segment [a_i, a_{i + 1}, a_{i + 2}] cyclically to the right (i.e. replace the segment [a_i, a_{i + 1}, a_{i + 2}] with... | instruction | 0 | 29,290 | 12 | 58,580 |
Tags: brute force, constructive algorithms, implementation, sortings
Correct Solution:
```
for _ in range(int(input())):
n,l,out = int(input()),list(map(lambda x: int(x)- 1, input().split())),[];ll = sorted([(l[i], i) for i in range(n)]);swap = (-1,-1);newl = [0]*n
for i in range(n - 1):
if ll[i][0]... | output | 1 | 29,290 | 12 | 58,581 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a consisting of n integers.
In one move, you can choose some index i (1 ≤ i ≤ n - 2) and shift the segment [a_i, a_{i + 1}, a_{i + 2}] cyclically to the right (i.e. replace the segment [a_i, a_{i + 1}, a_{i + 2}] with... | instruction | 0 | 29,291 | 12 | 58,582 |
Tags: brute force, constructive algorithms, implementation, sortings
Correct Solution:
```
for _ in range(int(input())):
n=int(input())
l=list(map(int,input().split()))
s=[]
for i in range(n):
for j in range(n-2):
if(l[j]>l[j+1]):
l[j],l[j+2]=l[j+2],l[j]
... | output | 1 | 29,291 | 12 | 58,583 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a consisting of n integers.
In one move, you can choose some index i (1 ≤ i ≤ n - 2) and shift the segment [a_i, a_{i + 1}, a_{i + 2}] cyclically to the right (i.e. replace the segment [a_i, a_{i + 1}, a_{i + 2}] with... | instruction | 0 | 29,292 | 12 | 58,584 |
Tags: brute force, constructive algorithms, implementation, sortings
Correct Solution:
```
#!/usr/bin/env python3
import heapq
import sys
input=sys.stdin.readline
t=int(input())
for _ in range(t):
n=int(input())
arr=list(map(int,input().split()))
q=[]
for i in range(n):
heapq.heappush(q,arr[i]... | output | 1 | 29,292 | 12 | 58,585 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a consisting of n integers.
In one move, you can choose some index i (1 ≤ i ≤ n - 2) and shift the segment [a_i, a_{i + 1}, a_{i + 2}] cyclically to the right (i.e. replace the segment [a_i, a_{i + 1}, a_{i + 2}] with... | instruction | 0 | 29,293 | 12 | 58,586 |
Tags: brute force, constructive algorithms, implementation, sortings
Correct Solution:
```
#!/usr/bin/env pypy3
def swaps(A):
# assume A is a permutation of range(0, len(A))
ret = []
for k in range(len(A)-1, 1, -1):
assert(A.index(k) <= k)
# print(f"putting {k} in the correct position")
... | output | 1 | 29,293 | 12 | 58,587 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a consisting of n integers.
In one move, you can choose some index i (1 ≤ i ≤ n - 2) and shift the segment [a_i, a_{i + 1}, a_{i + 2}] cyclically to the right (i.e. replace the segment [a_i, a_{i + 1}, a_{i + 2}] with... | instruction | 0 | 29,294 | 12 | 58,588 |
Tags: brute force, constructive algorithms, implementation, sortings
Correct Solution:
```
t=1
t=int(input())
for _ in range(t):
n=int(input())
a=list(map(int,input().split()))
a=[(a[i],i) for i in range(n)]
a.sort()
rev=0
for i in range(n):
val,id=a[i]
for j in range(i):
... | output | 1 | 29,294 | 12 | 58,589 |
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.
In one move, you can choose some index i (1 ≤ i ≤ n - 2) and shift the segment [a_i, a_{i + 1}, a_{i + 2}] cyclically to the right (i.e. repla... | instruction | 0 | 29,295 | 12 | 58,590 |
Yes | output | 1 | 29,295 | 12 | 58,591 |
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.
In one move, you can choose some index i (1 ≤ i ≤ n - 2) and shift the segment [a_i, a_{i + 1}, a_{i + 2}] cyclically to the right (i.e. repla... | instruction | 0 | 29,296 | 12 | 58,592 |
Yes | output | 1 | 29,296 | 12 | 58,593 |
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.
In one move, you can choose some index i (1 ≤ i ≤ n - 2) and shift the segment [a_i, a_{i + 1}, a_{i + 2}] cyclically to the right (i.e. repla... | instruction | 0 | 29,297 | 12 | 58,594 |
Yes | output | 1 | 29,297 | 12 | 58,595 |
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.
In one move, you can choose some index i (1 ≤ i ≤ n - 2) and shift the segment [a_i, a_{i + 1}, a_{i + 2}] cyclically to the right (i.e. repla... | instruction | 0 | 29,298 | 12 | 58,596 |
Yes | output | 1 | 29,298 | 12 | 58,597 |
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.
In one move, you can choose some index i (1 ≤ i ≤ n - 2) and shift the segment [a_i, a_{i + 1}, a_{i + 2}] cyclically to the right (i.e. repla... | instruction | 0 | 29,299 | 12 | 58,598 |
No | output | 1 | 29,299 | 12 | 58,599 |
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.
In one move, you can choose some index i (1 ≤ i ≤ n - 2) and shift the segment [a_i, a_{i + 1}, a_{i + 2}] cyclically to the right (i.e. repla... | instruction | 0 | 29,300 | 12 | 58,600 |
No | output | 1 | 29,300 | 12 | 58,601 |
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.
In one move, you can choose some index i (1 ≤ i ≤ n - 2) and shift the segment [a_i, a_{i + 1}, a_{i + 2}] cyclically to the right (i.e. repla... | instruction | 0 | 29,301 | 12 | 58,602 |
No | output | 1 | 29,301 | 12 | 58,603 |
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.
In one move, you can choose some index i (1 ≤ i ≤ n - 2) and shift the segment [a_i, a_{i + 1}, a_{i + 2}] cyclically to the right (i.e. repla... | instruction | 0 | 29,302 | 12 | 58,604 |
No | output | 1 | 29,302 | 12 | 58,605 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a_1, a_2, ... , a_n consisting of integers from 0 to 9. A subarray a_l, a_{l+1}, a_{l+2}, ... , a_{r-1}, a_r is good if the sum of elements of this subarray is equal to the length of this subarray (∑_{i=l}^{r} a_i = r ... | instruction | 0 | 29,303 | 12 | 58,606 |
Tags: data structures, dp, math
Correct Solution:
```
for _ in range(int(input())):
n = int(input())
a = input()
prefix_sum = [0]
for i in a:
prefix_sum.append(prefix_sum[-1]+int(i))
for i in range(n+1):
prefix_sum[i] = prefix_sum[i]-i
count = {}
for i in prefix_sum:
... | output | 1 | 29,303 | 12 | 58,607 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a_1, a_2, ... , a_n consisting of integers from 0 to 9. A subarray a_l, a_{l+1}, a_{l+2}, ... , a_{r-1}, a_r is good if the sum of elements of this subarray is equal to the length of this subarray (∑_{i=l}^{r} a_i = r ... | instruction | 0 | 29,304 | 12 | 58,608 |
Tags: data structures, dp, math
Correct Solution:
```
t = int(input())
for _ in range(t):
n = int(input())
a = [int(i) for i in list(input())]
s = 0
dp = [0]*(9*n)
cnt = 0
dp[0] = 1
for i in range(n):
s += a[i]
cnt += dp[s-i-1]
dp[s-i-1]+=1
print(cnt)
``` | output | 1 | 29,304 | 12 | 58,609 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a_1, a_2, ... , a_n consisting of integers from 0 to 9. A subarray a_l, a_{l+1}, a_{l+2}, ... , a_{r-1}, a_r is good if the sum of elements of this subarray is equal to the length of this subarray (∑_{i=l}^{r} a_i = r ... | instruction | 0 | 29,305 | 12 | 58,610 |
Tags: data structures, dp, math
Correct Solution:
```
t = int(input())
for i in range(t):
n = input()
s = input()
dp = { 0: 1 }
prv = 0
for i in range(0,len(s)):
y = prv + int(s[i])
x = i + 1
c = y - x
if c in dp:
dp[c] += 1
else :
dp[c... | output | 1 | 29,305 | 12 | 58,611 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a_1, a_2, ... , a_n consisting of integers from 0 to 9. A subarray a_l, a_{l+1}, a_{l+2}, ... , a_{r-1}, a_r is good if the sum of elements of this subarray is equal to the length of this subarray (∑_{i=l}^{r} a_i = r ... | instruction | 0 | 29,306 | 12 | 58,612 |
Tags: data structures, dp, math
Correct Solution:
```
tests = int(input())
for t in range(tests):
b= int(input())
ls = [int(x) for x in input()]
res = 0
p_dict = {0:1}
p_sum = 0
for item in ls:
item -= 1
p_sum += item
if p_sum in p_dict:
res += p_dict[p_sum]
... | output | 1 | 29,306 | 12 | 58,613 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a_1, a_2, ... , a_n consisting of integers from 0 to 9. A subarray a_l, a_{l+1}, a_{l+2}, ... , a_{r-1}, a_r is good if the sum of elements of this subarray is equal to the length of this subarray (∑_{i=l}^{r} a_i = r ... | instruction | 0 | 29,307 | 12 | 58,614 |
Tags: data structures, dp, math
Correct Solution:
```
t = int(input())
for ii in range(t):
n = int(input())
s = list(input())
count = 0
for i in range(n):
s[i] = int(s[i])-1
m = {}
sm = 0
count = 0
for i in range(n):
sm += s[i]
diff = sm
if sm == 0:
count+=1
if diff in m:
count+=m[diff... | output | 1 | 29,307 | 12 | 58,615 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a_1, a_2, ... , a_n consisting of integers from 0 to 9. A subarray a_l, a_{l+1}, a_{l+2}, ... , a_{r-1}, a_r is good if the sum of elements of this subarray is equal to the length of this subarray (∑_{i=l}^{r} a_i = r ... | instruction | 0 | 29,308 | 12 | 58,616 |
Tags: data structures, dp, math
Correct Solution:
```
t = int(input())
for _ in range(0,t) :
n = int(input())
v = input()
prefix = [0 for i in range(0,n+1)]
for i in range(0,n): prefix[i+1] = (int(v[i]) - int('0')) + prefix[i]
d = {1 : 1}; ans = 0
for i in range(0,n):
if prefix[i+1] - i in d.keys(): an... | output | 1 | 29,308 | 12 | 58,617 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a_1, a_2, ... , a_n consisting of integers from 0 to 9. A subarray a_l, a_{l+1}, a_{l+2}, ... , a_{r-1}, a_r is good if the sum of elements of this subarray is equal to the length of this subarray (∑_{i=l}^{r} a_i = r ... | instruction | 0 | 29,309 | 12 | 58,618 |
Tags: data structures, dp, math
Correct Solution:
```
from itertools import accumulate
from collections import defaultdict
t = int(input())
for _ in range(t):
jisho = defaultdict(int)
n = int(input())
A = list(map(int, list(input())))
cumsumA = list(accumulate([0] + A))
for i in range(n + 1):
... | output | 1 | 29,309 | 12 | 58,619 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a_1, a_2, ... , a_n consisting of integers from 0 to 9. A subarray a_l, a_{l+1}, a_{l+2}, ... , a_{r-1}, a_r is good if the sum of elements of this subarray is equal to the length of this subarray (∑_{i=l}^{r} a_i = r ... | instruction | 0 | 29,310 | 12 | 58,620 |
Tags: data structures, dp, math
Correct Solution:
```
for i in range(int(input())):
n=int(input())
s=input()
l=[int(i) for i in s]
cum= [l[0]]
for i in range(1,n):
cum.append(cum[-1]+l[i])
d={1:1}
for i in range(n):
if d.get(cum[i]-i):
d[cum[i]-i]+=1
else:... | output | 1 | 29,310 | 12 | 58,621 |
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_1, a_2, ... , a_n consisting of integers from 0 to 9. A subarray a_l, a_{l+1}, a_{l+2}, ... , a_{r-1}, a_r is good if the sum of elements of this subarray is equal to th... | instruction | 0 | 29,311 | 12 | 58,622 |
Yes | output | 1 | 29,311 | 12 | 58,623 |
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_1, a_2, ... , a_n consisting of integers from 0 to 9. A subarray a_l, a_{l+1}, a_{l+2}, ... , a_{r-1}, a_r is good if the sum of elements of this subarray is equal to th... | instruction | 0 | 29,312 | 12 | 58,624 |
Yes | output | 1 | 29,312 | 12 | 58,625 |
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_1, a_2, ... , a_n consisting of integers from 0 to 9. A subarray a_l, a_{l+1}, a_{l+2}, ... , a_{r-1}, a_r is good if the sum of elements of this subarray is equal to th... | instruction | 0 | 29,313 | 12 | 58,626 |
Yes | output | 1 | 29,313 | 12 | 58,627 |
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_1, a_2, ... , a_n consisting of integers from 0 to 9. A subarray a_l, a_{l+1}, a_{l+2}, ... , a_{r-1}, a_r is good if the sum of elements of this subarray is equal to th... | instruction | 0 | 29,314 | 12 | 58,628 |
Yes | output | 1 | 29,314 | 12 | 58,629 |
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_1, a_2, ... , a_n consisting of integers from 0 to 9. A subarray a_l, a_{l+1}, a_{l+2}, ... , a_{r-1}, a_r is good if the sum of elements of this subarray is equal to th... | instruction | 0 | 29,315 | 12 | 58,630 |
No | output | 1 | 29,315 | 12 | 58,631 |
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_1, a_2, ... , a_n consisting of integers from 0 to 9. A subarray a_l, a_{l+1}, a_{l+2}, ... , a_{r-1}, a_r is good if the sum of elements of this subarray is equal to th... | instruction | 0 | 29,316 | 12 | 58,632 |
No | output | 1 | 29,316 | 12 | 58,633 |
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_1, a_2, ... , a_n consisting of integers from 0 to 9. A subarray a_l, a_{l+1}, a_{l+2}, ... , a_{r-1}, a_r is good if the sum of elements of this subarray is equal to th... | instruction | 0 | 29,317 | 12 | 58,634 |
No | output | 1 | 29,317 | 12 | 58,635 |
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_1, a_2, ... , a_n consisting of integers from 0 to 9. A subarray a_l, a_{l+1}, a_{l+2}, ... , a_{r-1}, a_r is good if the sum of elements of this subarray is equal to th... | instruction | 0 | 29,318 | 12 | 58,636 |
No | output | 1 | 29,318 | 12 | 58,637 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An array is called beautiful if all the elements in the array are equal.
You can transform an array using the following steps any number of times:
1. Choose two indices i and j (1 ≤ i,j ≤ n), and an integer x (1 ≤ x ≤ a_i). Let i be the... | instruction | 0 | 29,365 | 12 | 58,730 |
Tags: combinatorics, constructive algorithms, math, sortings
Correct Solution:
```
a=*map(int,[*open(0)][1].split()),;n=len(a);s=sum(a)
if s%n:print(0);exit()
M=10**9+7;s//=n;f=[1]*(n+1);b=[0]*3;d=dict()
for i in range(2,n+1):f[i]=f[i-1]*i%M
for x in a:
b[(x>s)-(x<s)]+=1
try:d[x]+=1
except:d[x]=1
k=1
for x in d:k*=f... | output | 1 | 29,365 | 12 | 58,731 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An array is called beautiful if all the elements in the array are equal.
You can transform an array using the following steps any number of times:
1. Choose two indices i and j (1 ≤ i,j ≤ n), and an integer x (1 ≤ x ≤ a_i). Let i be the... | instruction | 0 | 29,366 | 12 | 58,732 |
Tags: combinatorics, constructive algorithms, math, sortings
Correct Solution:
```
a=*map(int,[*open(0)][1].split()),;n=len(a);s=sum(a)
if s%n:exit(print(0))
M=10**9+7;s//=n;f=[1]*(n+1);b=[0]*3;d={};k=1
for i in range(2,n+1):f[i]=f[i-1]*i%M
for x in a:b[(x>s)-(x<s)]+=1;d[x]=d[x]+1if x in d else 1
for x in d:k*=f[d[x]]
... | output | 1 | 29,366 | 12 | 58,733 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An array is called beautiful if all the elements in the array are equal.
You can transform an array using the following steps any number of times:
1. Choose two indices i and j (1 ≤ i,j ≤ n), and an integer x (1 ≤ x ≤ a_i). Let i be the... | instruction | 0 | 29,367 | 12 | 58,734 |
Tags: combinatorics, constructive algorithms, math, sortings
Correct Solution:
```
def pow(a, n):
if n == 0:
return 1
if n % 2 == 0:
return pow(a ** 2 % MOD, n // 2)
return a * pow(a, n - 1) % MOD
def C(n, k):
return fact[n] * pow(fact[n - k], MOD - 2) * pow(fact[k], MOD - 2) % MOD
M... | output | 1 | 29,367 | 12 | 58,735 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An array is called beautiful if all the elements in the array are equal.
You can transform an array using the following steps any number of times:
1. Choose two indices i and j (1 ≤ i,j ≤ n), and an integer x (1 ≤ x ≤ a_i). Let i be the... | instruction | 0 | 29,368 | 12 | 58,736 |
Tags: combinatorics, constructive algorithms, math, sortings
Correct Solution:
```
import sys
sys.setrecursionlimit(10**5)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.buffer.readline())
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def LI1(): retu... | output | 1 | 29,368 | 12 | 58,737 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An array is called beautiful if all the elements in the array are equal.
You can transform an array using the following steps any number of times:
1. Choose two indices i and j (1 ≤ i,j ≤ n), and an integer x (1 ≤ x ≤ a_i). Let i be the... | instruction | 0 | 29,369 | 12 | 58,738 |
Tags: combinatorics, constructive algorithms, math, sortings
Correct Solution:
```
a=*map(int,[*open(0)][1].split()),;n=len(a);s=sum(a)
if s%n:print(0);exit()
M=10**9+7;s//=n;f=[1]*(n+1);b=[0]*3;d=dict()
for i in range(2,n+1):f[i]=f[i-1]*i%M
for x in a:b[(x>s)-(x<s)]+=1;d[x]=d[x]+1if x in d else 1
k=1
for x in d:k*=f[d... | output | 1 | 29,369 | 12 | 58,739 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An array is called beautiful if all the elements in the array are equal.
You can transform an array using the following steps any number of times:
1. Choose two indices i and j (1 ≤ i,j ≤ n), and an integer x (1 ≤ x ≤ a_i). Let i be the... | instruction | 0 | 29,370 | 12 | 58,740 |
Tags: combinatorics, constructive algorithms, math, sortings
Correct Solution:
```
a=*map(int,[*open(0)][1].split()),;n=len(a);s=sum(a)
if s%n:print(0);exit(0)
M=10**9+7;s//=n;f=[1]*(n+1);b=[0]*3;d=dict()
for i in range(2,n+1):f[i]=f[i-1]*i%M
for x in a:
b[(x>s)-(x<s)]+=1
try:d[x]+=1
except:d[x]=1
k=1
for x in d.val... | output | 1 | 29,370 | 12 | 58,741 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An array is called beautiful if all the elements in the array are equal.
You can transform an array using the following steps any number of times:
1. Choose two indices i and j (1 ≤ i,j ≤ n), and an integer x (1 ≤ x ≤ a_i). Let i be the... | instruction | 0 | 29,371 | 12 | 58,742 |
Tags: combinatorics, constructive algorithms, math, sortings
Correct Solution:
```
from bisect import *
from collections import *
from math import gcd,ceil,sqrt,floor,inf
from heapq import *
from itertools import *
from operator import add,mul,sub,xor,truediv,floordiv
from functools import *
#-----------------------... | output | 1 | 29,371 | 12 | 58,743 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.