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 |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya was late for the lesson too. The teacher gave him an additional task. For some array a Petya should find the number of different ways to select non-empty subset of elements from it in such a way that their product is equal to a square ... | instruction | 0 | 28,776 | 12 | 57,552 |
Tags: bitmasks, combinatorics, dp, math
Correct Solution:
```
n = int(input())
s = []
p = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67]
for k in set(map(int, input().split())):
d = 0
for q in p:
while k % q == 0:
k //= q
d ^= 1 << q
for j i... | output | 1 | 28,776 | 12 | 57,553 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya was late for the lesson too. The teacher gave him an additional task. For some array a Petya should find the number of different ways to select non-empty subset of elements from it in such a way that their product is equal to a square ... | instruction | 0 | 28,777 | 12 | 57,554 |
Tags: bitmasks, combinatorics, dp, math
Correct Solution:
```
from collections import *
l = int(input())
c = Counter(map(int, input().split()))
t = defaultdict(int)
p = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67]
for k, s in c.items():
d = 0
for i, q in enumerate(p):
while... | output | 1 | 28,777 | 12 | 57,555 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya was late for the lesson too. The teacher gave him an additional task. For some array a Petya should find the number of different ways to select non-empty subset of elements from it in such a way that their product is equal to a square ... | instruction | 0 | 28,778 | 12 | 57,556 |
Tags: bitmasks, combinatorics, dp, math
Correct Solution:
```
from collections import defaultdict
def getmask(x):
ans = 0
for i in range(2, x + 1):
while x % i == 0:
x //= i
ans ^= 1 << i
return ans
def main():
maxn = 71
n = int(input())
a = [int(i) for i in inpu... | output | 1 | 28,778 | 12 | 57,557 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya was late for the lesson too. The teacher gave him an additional task. For some array a Petya should find the number of different ways to select non-empty subset of elements from it in such a way that their product is equal to a square ... | instruction | 0 | 28,779 | 12 | 57,558 |
Tags: bitmasks, combinatorics, dp, math
Correct Solution:
```
from sys import stdin
def find_prime(max_value):
assert max_value >= 2
result = [2]
for i in range(3, max_value):
state = 1
for item in result:
if item * item > i:
break
elif i % item == 0... | output | 1 | 28,779 | 12 | 57,559 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya was late for the lesson too. The teacher gave him an additional task. For some array a Petya should find the number of different ways to select non-empty subset of elements from it in such a way that their product is equal to a square ... | instruction | 0 | 28,780 | 12 | 57,560 |
Tags: bitmasks, combinatorics, dp, math
Correct Solution:
```
n = int(input())
*a, = map(int, input().split())
mod = 1000000007
d = []
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67]
b = [0, 4, 8, 0, 32, 12, 128, 4, 0, 36,2048, 8, 8192, 132, 40, 0, 131072, 4, 524288, 32, 136, 2052, 838... | output | 1 | 28,780 | 12 | 57,561 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya was late for the lesson too. The teacher gave him an additional task. For some array a Petya should find the number of different ways to select non-empty subset of elements from it in such a way that their product is equal to a square ... | instruction | 0 | 28,781 | 12 | 57,562 |
Tags: bitmasks, combinatorics, dp, math
Correct Solution:
```
n = int(input())
s = []
p = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67]
for k in set(map(int, input().split())):
d = 0
for q in p:
while k % q == 0:
k //= q
d ^= 1 << q
for j in s: d = ... | output | 1 | 28,781 | 12 | 57,563 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya was late for the lesson too. The teacher gave him an additional task. For some array a Petya should find the number of different ways to select non-empty subset of elements from it in such a way that their product is equal to a square ... | instruction | 0 | 28,782 | 12 | 57,564 |
Tags: bitmasks, combinatorics, dp, math
Correct Solution:
```
n = int(input())
s = []
p = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67]
for i in set(map(int, input().split())):
b = 0
for j in p:
while i % j == 0:
i //= j
b ^= 1 << j
for j in s:b=min... | output | 1 | 28,782 | 12 | 57,565 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya was late for the lesson too. The teacher gave him an additional task. For some array a Petya should find the number of different ways to select non-empty subset of elements from it in such a way that their product is equal to a square ... | instruction | 0 | 28,783 | 12 | 57,566 |
Tags: bitmasks, combinatorics, dp, math
Correct Solution:
```
def getmask(x):
ans = 0
for i in range(2, x + 1):
while x % (i * i) == 0:
x //= i * i
if x % i == 0:
ans ^= 1 << i
x //= i
return ans
def main():
maxn = 71
n = int(input())
a = [int... | output | 1 | 28,783 | 12 | 57,567 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya was late for the lesson too. The teacher gave him an additional task. For some array a Petya should find the number of different ways to select non-empty subset of elements from it in such... | instruction | 0 | 28,784 | 12 | 57,568 |
Yes | output | 1 | 28,784 | 12 | 57,569 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya was late for the lesson too. The teacher gave him an additional task. For some array a Petya should find the number of different ways to select non-empty subset of elements from it in such... | instruction | 0 | 28,785 | 12 | 57,570 |
Yes | output | 1 | 28,785 | 12 | 57,571 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya was late for the lesson too. The teacher gave him an additional task. For some array a Petya should find the number of different ways to select non-empty subset of elements from it in such... | instruction | 0 | 28,786 | 12 | 57,572 |
Yes | output | 1 | 28,786 | 12 | 57,573 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya was late for the lesson too. The teacher gave him an additional task. For some array a Petya should find the number of different ways to select non-empty subset of elements from it in such... | instruction | 0 | 28,787 | 12 | 57,574 |
Yes | output | 1 | 28,787 | 12 | 57,575 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya was late for the lesson too. The teacher gave him an additional task. For some array a Petya should find the number of different ways to select non-empty subset of elements from it in such... | instruction | 0 | 28,788 | 12 | 57,576 |
No | output | 1 | 28,788 | 12 | 57,577 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya was late for the lesson too. The teacher gave him an additional task. For some array a Petya should find the number of different ways to select non-empty subset of elements from it in such... | instruction | 0 | 28,789 | 12 | 57,578 |
No | output | 1 | 28,789 | 12 | 57,579 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya was late for the lesson too. The teacher gave him an additional task. For some array a Petya should find the number of different ways to select non-empty subset of elements from it in such... | instruction | 0 | 28,790 | 12 | 57,580 |
No | output | 1 | 28,790 | 12 | 57,581 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya was late for the lesson too. The teacher gave him an additional task. For some array a Petya should find the number of different ways to select non-empty subset of elements from it in such... | instruction | 0 | 28,791 | 12 | 57,582 |
No | output | 1 | 28,791 | 12 | 57,583 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a multiset S consisting of positive integers (initially empty). There are two kind of queries:
1. Add a positive integer to S, the newly added integer is not less than any number in it.
2. Find a subset s of the set S su... | instruction | 0 | 28,801 | 12 | 57,602 |
Tags: binary search, greedy, ternary search, two pointers
Correct Solution:
```
#Code by Sounak, IIESTS
#------------------------------warmup----------------------------
import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
... | output | 1 | 28,801 | 12 | 57,603 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two arrays a and b of positive integers, with length n and m respectively.
Let c be an n Γ m matrix, where c_{i,j} = a_i β
b_j.
You need to find a subrectangle of the matrix c such that the sum of its elements is at most x,... | instruction | 0 | 29,119 | 12 | 58,238 |
Tags: binary search, implementation, two pointers
Correct Solution:
```
# -*- coding:utf-8 -*-
"""
created by shuangquan.huang at 11/20/18
"""
import bisect
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
X = int(input())
#
# import time
# t0 = time.time... | output | 1 | 29,119 | 12 | 58,239 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two arrays a and b of positive integers, with length n and m respectively.
Let c be an n Γ m matrix, where c_{i,j} = a_i β
b_j.
You need to find a subrectangle of the matrix c such that the sum of its elements is at most x,... | instruction | 0 | 29,120 | 12 | 58,240 |
Tags: binary search, implementation, two pointers
Correct Solution:
```
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
x=int(input())
sum_a=[0]*(n+1)
sum_b=[0]*(m+1)
add_a=0
add_b=0
for i in range(1,n+1):
add_a+=a[i-1]
sum_a[i]=add_a
for i in range(1,m+1):
add... | output | 1 | 29,120 | 12 | 58,241 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two arrays a and b of positive integers, with length n and m respectively.
Let c be an n Γ m matrix, where c_{i,j} = a_i β
b_j.
You need to find a subrectangle of the matrix c such that the sum of its elements is at most x,... | instruction | 0 | 29,121 | 12 | 58,242 |
Tags: binary search, implementation, two pointers
Correct Solution:
```
n,m=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
e=int(input())
c=[0]*(n+1)
x=[0]
x1=0
for i in range(n):
x1+=a[i]
x.append(x1)
y=[0]
y1=0
for i in range(m):
y1+=b[i]
y.append(y1)
... | output | 1 | 29,121 | 12 | 58,243 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two arrays a and b of positive integers, with length n and m respectively.
Let c be an n Γ m matrix, where c_{i,j} = a_i β
b_j.
You need to find a subrectangle of the matrix c such that the sum of its elements is at most x,... | instruction | 0 | 29,122 | 12 | 58,244 |
Tags: binary search, implementation, two pointers
Correct Solution:
```
n, m = map(int, input().split())
a = [0] + list(map(int, input().split()))
b = [0] + list(map(int, input().split()))
c = [0] * (n + 1)
d = [0] * (m + 1)
x = int(input())
for i in range(1, n + 1):
a[i] = a[i - 1] + a[i]
c[i] = a[i]
for ... | output | 1 | 29,122 | 12 | 58,245 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two arrays a and b of positive integers, with length n and m respectively.
Let c be an n Γ m matrix, where c_{i,j} = a_i β
b_j.
You need to find a subrectangle of the matrix c such that the sum of its elements is at most x,... | instruction | 0 | 29,123 | 12 | 58,246 |
Tags: binary search, implementation, two pointers
Correct Solution:
```
import bisect
n,m=map(int,input().split())
L1=list(map(int,input().split()))
L2=list(map(int,input().split()))
x=int(input())
newL1=[0]
newL2=[0]
for i in L1:newL1.append(newL1[-1]+i)
for i in L2:newL2.append(newL2[-1]+i)
min1=[]
min2=[]
mx=9999999... | output | 1 | 29,123 | 12 | 58,247 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two arrays a and b of positive integers, with length n and m respectively.
Let c be an n Γ m matrix, where c_{i,j} = a_i β
b_j.
You need to find a subrectangle of the matrix c such that the sum of its elements is at most x,... | instruction | 0 | 29,124 | 12 | 58,248 |
Tags: binary search, implementation, two pointers
Correct Solution:
```
from itertools import accumulate
n,m=map(int,input().split())
c=list(map(int,input().split()))
b=list(map(int,input().split()))
a=list(accumulate(c))
x=int(input())
res=0
for i in range(1,n+1):
sa=min(ar-al for ar,al in zip(a[i-1:],[0]+a[:]))
... | output | 1 | 29,124 | 12 | 58,249 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two arrays a and b of positive integers, with length n and m respectively.
Let c be an n Γ m matrix, where c_{i,j} = a_i β
b_j.
You need to find a subrectangle of the matrix c such that the sum of its elements is at most x,... | instruction | 0 | 29,125 | 12 | 58,250 |
Tags: binary search, implementation, two pointers
Correct Solution:
```
# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!
# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!
# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!
from sys import stdin, stdout
#N = int(input())
#s = input()
N,M = [int(x) for x in stdin.readline().split()]
arrA = [int(x) for ... | output | 1 | 29,125 | 12 | 58,251 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two arrays a and b of positive integers, with length n and m respectively.
Let c be an n Γ m matrix, where c_{i,j} = a_i β
b_j.
You need to find a subrectangle of the matrix c such that the sum of its elements is at most x,... | instruction | 0 | 29,126 | 12 | 58,252 |
Tags: binary search, implementation, two pointers
Correct Solution:
```
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = int(input())
rows = [float('inf')] * (n + 1)
cols = [float('inf')] * (m + 1)
for i in range(n):
summ = 0
for j in range(i, n... | output | 1 | 29,126 | 12 | 58,253 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given two arrays a and b of positive integers, with length n and m respectively.
Let c be an n Γ m matrix, where c_{i,j} = a_i β
b_j.
You need to find a subrectangle of the matrix c ... | instruction | 0 | 29,127 | 12 | 58,254 |
Yes | output | 1 | 29,127 | 12 | 58,255 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given two arrays a and b of positive integers, with length n and m respectively.
Let c be an n Γ m matrix, where c_{i,j} = a_i β
b_j.
You need to find a subrectangle of the matrix c ... | instruction | 0 | 29,128 | 12 | 58,256 |
Yes | output | 1 | 29,128 | 12 | 58,257 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given two arrays a and b of positive integers, with length n and m respectively.
Let c be an n Γ m matrix, where c_{i,j} = a_i β
b_j.
You need to find a subrectangle of the matrix c ... | instruction | 0 | 29,129 | 12 | 58,258 |
Yes | output | 1 | 29,129 | 12 | 58,259 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given two arrays a and b of positive integers, with length n and m respectively.
Let c be an n Γ m matrix, where c_{i,j} = a_i β
b_j.
You need to find a subrectangle of the matrix c ... | instruction | 0 | 29,130 | 12 | 58,260 |
Yes | output | 1 | 29,130 | 12 | 58,261 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given two arrays a and b of positive integers, with length n and m respectively.
Let c be an n Γ m matrix, where c_{i,j} = a_i β
b_j.
You need to find a subrectangle of the matrix c ... | instruction | 0 | 29,131 | 12 | 58,262 |
No | output | 1 | 29,131 | 12 | 58,263 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given two arrays a and b of positive integers, with length n and m respectively.
Let c be an n Γ m matrix, where c_{i,j} = a_i β
b_j.
You need to find a subrectangle of the matrix c ... | instruction | 0 | 29,132 | 12 | 58,264 |
No | output | 1 | 29,132 | 12 | 58,265 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given two arrays a and b of positive integers, with length n and m respectively.
Let c be an n Γ m matrix, where c_{i,j} = a_i β
b_j.
You need to find a subrectangle of the matrix c ... | instruction | 0 | 29,133 | 12 | 58,266 |
No | output | 1 | 29,133 | 12 | 58,267 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given two arrays a and b of positive integers, with length n and m respectively.
Let c be an n Γ m matrix, where c_{i,j} = a_i β
b_j.
You need to find a subrectangle of the matrix c ... | instruction | 0 | 29,134 | 12 | 58,268 |
No | output | 1 | 29,134 | 12 | 58,269 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n segments [l_i, r_i] for 1 β€ i β€ n. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to ... | instruction | 0 | 29,151 | 12 | 58,302 |
Tags: sortings
Correct Solution:
```
from bisect import insort,bisect_right,bisect_left
from sys import stdout, stdin, setrecursionlimit
from heapq import heappush, heappop, heapify
from io import BytesIO, IOBase
from collections import *
from itertools import *
from random import *
from string import *
from queue im... | output | 1 | 29,151 | 12 | 58,303 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n segments [l_i, r_i] for 1 β€ i β€ n. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to ... | instruction | 0 | 29,152 | 12 | 58,304 |
Tags: sortings
Correct Solution:
```
T = int(input())
for t in range(T):
N = int(input())
segs = []
for i,n in enumerate(range(N)):
seg = [int(x) for x in input().split()]+[i]
segs.append(seg)
segs.sort(key = lambda x: x[0])
clas = 1
nots = [2,]* len(segs)
A,B,_=segs[0]
... | output | 1 | 29,152 | 12 | 58,305 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n segments [l_i, r_i] for 1 β€ i β€ n. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to ... | instruction | 0 | 29,153 | 12 | 58,306 |
Tags: sortings
Correct Solution:
```
import sys
input=sys.stdin.readline
for _ in range(int(input())):
n=int(input())
ar=[]
for i in range(n):
ar.append(list(map(int,input().split()))+[i])
ar.sort(key=lambda x:x[0])
su=0
flag=False
ma=ar[0][1]
for i in range(1,n):
if(ar[i... | output | 1 | 29,153 | 12 | 58,307 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n segments [l_i, r_i] for 1 β€ i β€ n. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to ... | instruction | 0 | 29,154 | 12 | 58,308 |
Tags: sortings
Correct Solution:
```
ansarr=[]
t=int(input())
for l in range(t):
n=int(input())
arr1=[]
for i in range(n):
a,b=map(int,input().split())
arr1.append((a,b,i))
arr1.sort()
max1=arr1[0][1]
flag=0
arr2=[0]*n
arr2[arr1[0][2]]=1
for i in range(1,n):
i... | output | 1 | 29,154 | 12 | 58,309 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n segments [l_i, r_i] for 1 β€ i β€ n. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to ... | instruction | 0 | 29,155 | 12 | 58,310 |
Tags: sortings
Correct Solution:
```
for j in range(int(input())):
n = int(input())
s = []
ind = [int(0)]*n
for i in range(n):
s.append(tuple(list(map(int, input().split()))+[i]))
s.sort()
mx = max(s[0][0], s[0][1]); ind[s[0][2]] = 1
for i in range(1, len(s)):
if mx < min(s[i... | output | 1 | 29,155 | 12 | 58,311 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n segments [l_i, r_i] for 1 β€ i β€ n. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to ... | instruction | 0 | 29,156 | 12 | 58,312 |
Tags: sortings
Correct Solution:
```
''' Thruth can only be found at one place - THE CODE '''
''' Copyright 2018, SATYAM KUMAR'''
from sys import stdin, stdout
import cProfile, math
from collections import Counter
from bisect import bisect_left,bisect,bisect_right
import itertools
from copy import deepcopy
from fracti... | output | 1 | 29,156 | 12 | 58,313 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n segments [l_i, r_i] for 1 β€ i β€ n. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to ... | instruction | 0 | 29,157 | 12 | 58,314 |
Tags: sortings
Correct Solution:
```
#------------------------------warmup----------------------------
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
... | output | 1 | 29,157 | 12 | 58,315 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n segments [l_i, r_i] for 1 β€ i β€ n. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to ... | instruction | 0 | 29,158 | 12 | 58,316 |
Tags: sortings
Correct Solution:
```
def do_intersect( a, b ): return min(a[1],b[1]) >= max( a[0],b[0])
for _ in range(int(input())):
n = int(input())
inps = [ tuple(map(int,input().split())) for _ in range(n) ]
org = [ pair for pair in inps ]
inps.sort()
seta = inps[0]
setb = (float('inf'), f... | output | 1 | 29,158 | 12 | 58,317 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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 an array means to reorder its elements arbitrar... | instruction | 0 | 29,251 | 12 | 58,502 |
Tags: constructive algorithms, sortings
Correct Solution:
```
n = int(input())
for i in range(n):
n1 = int(input())
l = list(map(int,input().split()))
l.sort(reverse=True)
print(*l)
``` | output | 1 | 29,251 | 12 | 58,503 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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 an array means to reorder its elements arbitrar... | instruction | 0 | 29,252 | 12 | 58,504 |
Tags: constructive algorithms, sortings
Correct Solution:
```
t = int(input())
for _ in range(t):
n = int(input())
a = sorted([int(x) for x in input().split()])
a.reverse()
print(*a)
``` | output | 1 | 29,252 | 12 | 58,505 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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 an array means to reorder its elements arbitrar... | instruction | 0 | 29,253 | 12 | 58,506 |
Tags: constructive algorithms, sortings
Correct Solution:
```
t = int(input())
for q in range(t):
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
a.reverse()
for i in range(n):
print(a[i], end=" ")
print()
``` | output | 1 | 29,253 | 12 | 58,507 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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 an array means to reorder its elements arbitrar... | instruction | 0 | 29,254 | 12 | 58,508 |
Tags: constructive algorithms, sortings
Correct Solution:
```
from sys import stdin
def func():
return
for _ in range(int(stdin.readline())):
n = int(stdin.readline())
#n, m = map(int,stdin.readline().split())
arr = sorted(list(map(int,stdin.readline().split())), reverse = True)
print(*arr)
``` | output | 1 | 29,254 | 12 | 58,509 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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 an array means to reorder its elements arbitrar... | instruction | 0 | 29,255 | 12 | 58,510 |
Tags: constructive algorithms, sortings
Correct Solution:
```
def solve():
n = int(input())
a = list(map(int, input().split()))
a.sort()
a.reverse()
for i in range(0, n):
print(a[i], end = " ")
print("")
t = int(input())
for _ in range(0, t):
solve()
``` | output | 1 | 29,255 | 12 | 58,511 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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 an array means to reorder its elements arbitrar... | instruction | 0 | 29,256 | 12 | 58,512 |
Tags: constructive algorithms, sortings
Correct Solution:
```
from random import shuffle
def solve(n, a):
if n == 1:
return a[0]
a = sorted(a, reverse=True)
for i in range(n-1):
for j in range(i+1, n):
if j - a[j] == i - a[i]:
shuffling(a)
return... | output | 1 | 29,256 | 12 | 58,513 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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 an array means to reorder its elements arbitrar... | instruction | 0 | 29,257 | 12 | 58,514 |
Tags: constructive algorithms, sortings
Correct Solution:
```
for i in range(int(input())):
n=int(input())
t=list(map(int,input().split()))
p=[]
for j in range(n):
for k in range(1,n+1):
if k-1-t[j] not in p:
p.append([k-1-t[j],t[j]])
break
p.so... | output | 1 | 29,257 | 12 | 58,515 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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 an array means to reorder its elements arbitrar... | instruction | 0 | 29,258 | 12 | 58,516 |
Tags: constructive algorithms, sortings
Correct Solution:
```
t=int(input())
for _ in range(t):
n=int(input())
a=list(map(int,input().split()))
a.sort()
a=a[::-1]
print(*a)
``` | output | 1 | 29,258 | 12 | 58,517 |
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,259 | 12 | 58,518 |
Yes | output | 1 | 29,259 | 12 | 58,519 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.