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 a correct Python 3 solution for this coding contest problem.
A binary heap which satisfies max-heap property is called max-heap. In a max-heap, for every node $i$ other than the root, $A[i] \leq A[parent(i)]$, that is, the value of a node is at most the value of its parent. The largest element in a max-heap is... | instruction | 0 | 81,678 | 12 | 163,356 |
"Correct Solution:
```
def maxHeapify(A, i):
l = 2 * i
r = 2 * i + 1
largest = i
if l < len(A) and A[l] > A[largest]:
largest = l
if r < len(A) and A[r] > A[largest]:
largest = r
if largest != i:
A[i], A[largest] = A[largest], A[i]
maxHeapify(A, largest)
def bui... | output | 1 | 81,678 | 12 | 163,357 |
Provide a correct Python 3 solution for this coding contest problem.
A binary heap which satisfies max-heap property is called max-heap. In a max-heap, for every node $i$ other than the root, $A[i] \leq A[parent(i)]$, that is, the value of a node is at most the value of its parent. The largest element in a max-heap is... | instruction | 0 | 81,679 | 12 | 163,358 |
"Correct Solution:
```
def maxHeapify(A,i):
left,right=2*i,2*i+1
if left<n and A[left]>A[i]:largest=left
else:largest=i
if right<n and A[right]>A[largest]:largest=right
if largest!=i:
A[i],A[largest]=A[largest],A[i]
maxHeapify(A,largest)
def buildMaxHeap(A):
for i in reversed(... | output | 1 | 81,679 | 12 | 163,359 |
Provide a correct Python 3 solution for this coding contest problem.
A binary heap which satisfies max-heap property is called max-heap. In a max-heap, for every node $i$ other than the root, $A[i] \leq A[parent(i)]$, that is, the value of a node is at most the value of its parent. The largest element in a max-heap is... | instruction | 0 | 81,680 | 12 | 163,360 |
"Correct Solution:
```
import sys
input = sys.stdin.readline
def parent(i):
return i//2
def left(i):
return 2*i
def right(i):
return 2*i+1
def maxHeapify(A, i):
l = left(i)
r = right(i)
# 左の子、自分、右の子で値が最大のノードを選ぶ
if l <= H and A[l] > A[i]:
largest = l
else:
largest = i
... | output | 1 | 81,680 | 12 | 163,361 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A binary heap which satisfies max-heap property is called max-heap. In a max-heap, for every node $i$ other than the root, $A[i] \leq A[parent(i)]$, that is, the value of a node is at most the v... | instruction | 0 | 81,681 | 12 | 163,362 |
Yes | output | 1 | 81,681 | 12 | 163,363 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A binary heap which satisfies max-heap property is called max-heap. In a max-heap, for every node $i$ other than the root, $A[i] \leq A[parent(i)]$, that is, the value of a node is at most the v... | instruction | 0 | 81,682 | 12 | 163,364 |
Yes | output | 1 | 81,682 | 12 | 163,365 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A binary heap which satisfies max-heap property is called max-heap. In a max-heap, for every node $i$ other than the root, $A[i] \leq A[parent(i)]$, that is, the value of a node is at most the v... | instruction | 0 | 81,683 | 12 | 163,366 |
Yes | output | 1 | 81,683 | 12 | 163,367 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A binary heap which satisfies max-heap property is called max-heap. In a max-heap, for every node $i$ other than the root, $A[i] \leq A[parent(i)]$, that is, the value of a node is at most the v... | instruction | 0 | 81,684 | 12 | 163,368 |
Yes | output | 1 | 81,684 | 12 | 163,369 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A binary heap which satisfies max-heap property is called max-heap. In a max-heap, for every node $i$ other than the root, $A[i] \leq A[parent(i)]$, that is, the value of a node is at most the v... | instruction | 0 | 81,685 | 12 | 163,370 |
No | output | 1 | 81,685 | 12 | 163,371 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A binary heap which satisfies max-heap property is called max-heap. In a max-heap, for every node $i$ other than the root, $A[i] \leq A[parent(i)]$, that is, the value of a node is at most the v... | instruction | 0 | 81,686 | 12 | 163,372 |
No | output | 1 | 81,686 | 12 | 163,373 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A binary heap which satisfies max-heap property is called max-heap. In a max-heap, for every node $i$ other than the root, $A[i] \leq A[parent(i)]$, that is, the value of a node is at most the v... | instruction | 0 | 81,687 | 12 | 163,374 |
No | output | 1 | 81,687 | 12 | 163,375 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A binary heap which satisfies max-heap property is called max-heap. In a max-heap, for every node $i$ other than the root, $A[i] \leq A[parent(i)]$, that is, the value of a node is at most the v... | instruction | 0 | 81,688 | 12 | 163,376 |
No | output | 1 | 81,688 | 12 | 163,377 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The brave Knight came to the King and asked permission to marry the princess. The King knew that the Knight was brave, but he also wanted to know if he was smart enough. So he asked him to solve the following task.
There is a permutation p_... | instruction | 0 | 81,966 | 12 | 163,932 |
Tags: brute force, graphs, implementation
Correct Solution:
```
n=int(input())
arr=list(map(int,input().split()))
arr1=arr[::]
l=[i for i in range(1,2*n+1)]
d=0
f=0
k=0
ans=10**20
while(True):
if arr==l:
ans=min(ans,d)
k=0
break
if f%2==0:
for i in range(0,2*n,2):
c=a... | output | 1 | 81,966 | 12 | 163,933 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The brave Knight came to the King and asked permission to marry the princess. The King knew that the Knight was brave, but he also wanted to know if he was smart enough. So he asked him to solve the following task.
There is a permutation p_... | instruction | 0 | 81,967 | 12 | 163,934 |
Tags: brute force, graphs, implementation
Correct Solution:
```
import sys
def p1(ls):
for i in range (1,n+1):
temp=ls[(2*i)-1]
ls[(2*i)-1]=ls[(2*i)-2]
ls[(2*i)-2]=temp
return ls
def p2(ls):
ls1=ls[n:]+ls[0:n]
ls=ls1
return ls
def check(ls, flag):
if ls==sorted(ls):
... | output | 1 | 81,967 | 12 | 163,935 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The brave Knight came to the King and asked permission to marry the princess. The King knew that the Knight was brave, but he also wanted to know if he was smart enough. So he asked him to solve the following task.
There is a permutation p_... | instruction | 0 | 81,968 | 12 | 163,936 |
Tags: brute force, graphs, implementation
Correct Solution:
```
def main():
n=int(input())
n*=2
arr=readIntArr()
# if n//2 is even, there are only 4 outcomes.
# if n//2 is odd, there are n outcomes.
# since 1 and 2 are reversible, to get different outcomes 1 must be alternated
# with 2... | output | 1 | 81,968 | 12 | 163,937 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The brave Knight came to the King and asked permission to marry the princess. The King knew that the Knight was brave, but he also wanted to know if he was smart enough. So he asked him to solve the following task.
There is a permutation p_... | instruction | 0 | 81,969 | 12 | 163,938 |
Tags: brute force, graphs, implementation
Correct Solution:
```
n = input()
asu1 = [int(k) for k in input().split()]
def op1(a):
for i in range(0,len(a),2):
temp = a[i]
a[i]=a[i+1]
a[i+1]= temp
return a
def op2(a):
for i in range(0,len(a)//2):
temp = a[i]
a[i]=a[i+... | output | 1 | 81,969 | 12 | 163,939 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The brave Knight came to the King and asked permission to marry the princess. The King knew that the Knight was brave, but he also wanted to know if he was smart enough. So he asked him to solve the following task.
There is a permutation p_... | instruction | 0 | 81,970 | 12 | 163,940 |
Tags: brute force, graphs, implementation
Correct Solution:
```
import sys
def op1(n, x):
for i in range(0,n):
u = 2*i
v = 2*i+1
t1 = x[u]
x[u] = x[v]
x[v] = t1
return x
def op2(n,x):
for i in range(0,n):
u = i
v = i+n
t1 = x[u]
x[u] ... | output | 1 | 81,970 | 12 | 163,941 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The brave Knight came to the King and asked permission to marry the princess. The King knew that the Knight was brave, but he also wanted to know if he was smart enough. So he asked him to solve the following task.
There is a permutation p_... | instruction | 0 | 81,971 | 12 | 163,942 |
Tags: brute force, graphs, implementation
Correct Solution:
```
import sys
from collections import defaultdict
# import logging
# logging.root.setLevel(level=logging.INFO)
memo = {}
def search(cur_op,nums):
global n,target
state = tuple(nums)
# print(state)
if state in memo:
return memo[state]
... | output | 1 | 81,971 | 12 | 163,943 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The brave Knight came to the King and asked permission to marry the princess. The King knew that the Knight was brave, but he also wanted to know if he was smart enough. So he asked him to solve the following task.
There is a permutation p_... | instruction | 0 | 81,972 | 12 | 163,944 |
Tags: brute force, graphs, implementation
Correct Solution:
```
def ii():
return int(input())
def li():
return [int(i) for i in input().split()]
def op1(a,n):
for i in range(1,2*n,2):
a[i],a[i+1] = a[i+1],a[i]
def op2(a,n):
for i in range(1,n+1):
# print(n,n+i,i,a)
a[i],a[n+i] ... | output | 1 | 81,972 | 12 | 163,945 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The brave Knight came to the King and asked permission to marry the princess. The King knew that the Knight was brave, but he also wanted to know if he was smart enough. So he asked him to solve the following task.
There is a permutation p_... | instruction | 0 | 81,973 | 12 | 163,946 |
Tags: brute force, graphs, implementation
Correct Solution:
```
n = int(input().strip())
nums = list(map(int, input().strip().split(" ")))
def adj(arr):
for i in range(n):
tmp = arr[2*i]
arr[2*i] = arr[2*i+1]
arr[2*i+1] = tmp
return arr
def half(arr):
for i in range(n):
tmp... | output | 1 | 81,973 | 12 | 163,947 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The brave Knight came to the King and asked permission to marry the princess. The King knew that the Knight was brave, but he also wanted to know if he was smart enough. So he asked him to solve... | instruction | 0 | 81,974 | 12 | 163,948 |
Yes | output | 1 | 81,974 | 12 | 163,949 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The brave Knight came to the King and asked permission to marry the princess. The King knew that the Knight was brave, but he also wanted to know if he was smart enough. So he asked him to solve... | instruction | 0 | 81,975 | 12 | 163,950 |
Yes | output | 1 | 81,975 | 12 | 163,951 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The brave Knight came to the King and asked permission to marry the princess. The King knew that the Knight was brave, but he also wanted to know if he was smart enough. So he asked him to solve... | instruction | 0 | 81,976 | 12 | 163,952 |
Yes | output | 1 | 81,976 | 12 | 163,953 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The brave Knight came to the King and asked permission to marry the princess. The King knew that the Knight was brave, but he also wanted to know if he was smart enough. So he asked him to solve... | instruction | 0 | 81,977 | 12 | 163,954 |
Yes | output | 1 | 81,977 | 12 | 163,955 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The brave Knight came to the King and asked permission to marry the princess. The King knew that the Knight was brave, but he also wanted to know if he was smart enough. So he asked him to solve... | instruction | 0 | 81,978 | 12 | 163,956 |
No | output | 1 | 81,978 | 12 | 163,957 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The brave Knight came to the King and asked permission to marry the princess. The King knew that the Knight was brave, but he also wanted to know if he was smart enough. So he asked him to solve... | instruction | 0 | 81,979 | 12 | 163,958 |
No | output | 1 | 81,979 | 12 | 163,959 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The brave Knight came to the King and asked permission to marry the princess. The King knew that the Knight was brave, but he also wanted to know if he was smart enough. So he asked him to solve... | instruction | 0 | 81,980 | 12 | 163,960 |
No | output | 1 | 81,980 | 12 | 163,961 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The brave Knight came to the King and asked permission to marry the princess. The King knew that the Knight was brave, but he also wanted to know if he was smart enough. So he asked him to solve... | instruction | 0 | 81,981 | 12 | 163,962 |
No | output | 1 | 81,981 | 12 | 163,963 |
Provide tags and a correct Python 3 solution for this coding contest problem.
DZY has a hash table with p buckets, numbered from 0 to p - 1. He wants to insert n numbers, in the order they are given, into the hash table. For the i-th number xi, DZY will put it into the bucket numbered h(xi), where h(x) is the hash fun... | instruction | 0 | 82,068 | 12 | 164,136 |
Tags: implementation
Correct Solution:
```
p,n = map(int,input().split(" "))
arr = []
arrhash = []
temp = 0
for i in range(n) :
arr.append(int(input()))
for i in range(n) :
if (arr[i] % p not in arrhash ) :
arrhash.append(arr[i] % p)
else :
temp = i
break
if (temp == 0 ) :
... | output | 1 | 82,068 | 12 | 164,137 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Mike has a sequence A = [a1, a2, ..., an] of length n. He considers the sequence B = [b1, b2, ..., bn] beautiful if the gcd of all its elements is bigger than 1, i.e. <image>.
Mike wants to change his sequence in order to make it beautiful... | instruction | 0 | 82,227 | 12 | 164,454 |
Tags: dp, greedy, number theory
Correct Solution:
```
from math import gcd
def solve():
n = int(input())
a = list(map(int, input().split(' ')))
if n == 1:
return 0
g = gcd(a[0],a[1])
for i in range(2, len(a)):
g = gcd(g, a[i])
if g == 1:
break
if g > 1:
... | output | 1 | 82,227 | 12 | 164,455 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Mike has a sequence A = [a1, a2, ..., an] of length n. He considers the sequence B = [b1, b2, ..., bn] beautiful if the gcd of all its elements is bigger than 1, i.e. <image>.
Mike wants to change his sequence in order to make it beautiful... | instruction | 0 | 82,228 | 12 | 164,456 |
Tags: dp, greedy, number theory
Correct Solution:
```
n=int(input())
a=input().split()
for i in range(n):
a[i]=int(a[i])
k=0
g=0
def gcd(c,d):
if c%d==0:
return d
else:
return gcd(d,c%d)
while True:
for i in range(n):
g=gcd(g,a[i])
if g>1:
k=0
break
else:... | output | 1 | 82,228 | 12 | 164,457 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Mike has a sequence A = [a1, a2, ..., an] of length n. He considers the sequence B = [b1, b2, ..., bn] beautiful if the gcd of all its elements is bigger than 1, i.e. <image>.
Mike wants to change his sequence in order to make it beautiful... | instruction | 0 | 82,229 | 12 | 164,458 |
Tags: dp, greedy, number theory
Correct Solution:
```
from math import gcd, ceil
from sys import exit
from functools import reduce
n = int(input())
numbers = list(map(int, input().strip().split()))
cum_gcd = reduce(gcd, numbers, 0)
if cum_gcd > 1:
print('YES', 0, sep='\n')
exit(0)
numbers.append(0)
numbers =... | output | 1 | 82,229 | 12 | 164,459 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Mike has a sequence A = [a1, a2, ..., an] of length n. He considers the sequence B = [b1, b2, ..., bn] beautiful if the gcd of all its elements is bigger than 1, i.e. <image>.
Mike wants to change his sequence in order to make it beautiful... | instruction | 0 | 82,230 | 12 | 164,460 |
Tags: dp, greedy, number theory
Correct Solution:
```
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 22 15:27:31 2017
@author: CHITTARANJAN
"""
from fractions import gcd
n=int(input())
arr=list(map(int,input().split()))
d=gcd(arr[0],arr[1])
noftime=0
for i in range(2,n):
d=gcd(d,arr[i])
if(d>1):
print('YES\n0'... | output | 1 | 82,230 | 12 | 164,461 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Mike has a sequence A = [a1, a2, ..., an] of length n. He considers the sequence B = [b1, b2, ..., bn] beautiful if the gcd of all its elements is bigger than 1, i.e. <image>.
Mike wants to change his sequence in order to make it beautiful... | instruction | 0 | 82,231 | 12 | 164,462 |
Tags: dp, greedy, number theory
Correct Solution:
```
from functools import reduce
N = int( input() )
A = list( map( int, input().split() ) )
def gcd( a,b ):
if b == 0: return a
return gcd( b, a % b )
print( "YES" )
if reduce( gcd, A ) > 1:
print( 0 )
else:
ans = 0
for i in range( N - 1 ):
while A[ i ]... | output | 1 | 82,231 | 12 | 164,463 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Mike has a sequence A = [a1, a2, ..., an] of length n. He considers the sequence B = [b1, b2, ..., bn] beautiful if the gcd of all its elements is bigger than 1, i.e. <image>.
Mike wants to change his sequence in order to make it beautiful... | instruction | 0 | 82,232 | 12 | 164,464 |
Tags: dp, greedy, number theory
Correct Solution:
```
from math import gcd
def func(a):
x=a[0]
for i in range(1,len(a)):
x=gcd(a[i],x)
return x
n=int(input())
a=[int(x) for x in input().split()]
if func(a)>1:
print('YES')
print(0)
else:
a = [int(x)%2 for x in a]
an=0
for... | output | 1 | 82,232 | 12 | 164,465 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Mike has a sequence A = [a1, a2, ..., an] of length n. He considers the sequence B = [b1, b2, ..., bn] beautiful if the gcd of all its elements is bigger than 1, i.e. <image>.
Mike wants to change his sequence in order to make it beautiful... | instruction | 0 | 82,233 | 12 | 164,466 |
Tags: dp, greedy, number theory
Correct Solution:
```
import bisect
import decimal
from decimal import Decimal
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
fro... | output | 1 | 82,233 | 12 | 164,467 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Mike has a sequence A = [a1, a2, ..., an] of length n. He considers the sequence B = [b1, b2, ..., bn] beautiful if the gcd of all its elements is bigger than 1, i.e. <image>.
Mike wants to change his sequence in order to make it beautiful... | instruction | 0 | 82,234 | 12 | 164,468 |
Tags: dp, greedy, number theory
Correct Solution:
```
from sys import stdin
def gcd(a, b):
if b:
return gcd(b, a%b)
else:
return a
n = int(stdin.readline())
a = list(map(int, stdin.readline().split()))
g = 0
for el in a:
g = gcd(g, el)
res = 0
if g == 1:
for i in range(n-1):
if... | output | 1 | 82,234 | 12 | 164,469 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mike has a sequence A = [a1, a2, ..., an] of length n. He considers the sequence B = [b1, b2, ..., bn] beautiful if the gcd of all its elements is bigger than 1, i.e. <image>.
Mike wants to ch... | instruction | 0 | 82,235 | 12 | 164,470 |
Yes | output | 1 | 82,235 | 12 | 164,471 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mike has a sequence A = [a1, a2, ..., an] of length n. He considers the sequence B = [b1, b2, ..., bn] beautiful if the gcd of all its elements is bigger than 1, i.e. <image>.
Mike wants to ch... | instruction | 0 | 82,236 | 12 | 164,472 |
Yes | output | 1 | 82,236 | 12 | 164,473 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mike has a sequence A = [a1, a2, ..., an] of length n. He considers the sequence B = [b1, b2, ..., bn] beautiful if the gcd of all its elements is bigger than 1, i.e. <image>.
Mike wants to ch... | instruction | 0 | 82,237 | 12 | 164,474 |
Yes | output | 1 | 82,237 | 12 | 164,475 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mike has a sequence A = [a1, a2, ..., an] of length n. He considers the sequence B = [b1, b2, ..., bn] beautiful if the gcd of all its elements is bigger than 1, i.e. <image>.
Mike wants to ch... | instruction | 0 | 82,238 | 12 | 164,476 |
Yes | output | 1 | 82,238 | 12 | 164,477 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mike has a sequence A = [a1, a2, ..., an] of length n. He considers the sequence B = [b1, b2, ..., bn] beautiful if the gcd of all its elements is bigger than 1, i.e. <image>.
Mike wants to ch... | instruction | 0 | 82,239 | 12 | 164,478 |
No | output | 1 | 82,239 | 12 | 164,479 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mike has a sequence A = [a1, a2, ..., an] of length n. He considers the sequence B = [b1, b2, ..., bn] beautiful if the gcd of all its elements is bigger than 1, i.e. <image>.
Mike wants to ch... | instruction | 0 | 82,240 | 12 | 164,480 |
No | output | 1 | 82,240 | 12 | 164,481 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mike has a sequence A = [a1, a2, ..., an] of length n. He considers the sequence B = [b1, b2, ..., bn] beautiful if the gcd of all its elements is bigger than 1, i.e. <image>.
Mike wants to ch... | instruction | 0 | 82,241 | 12 | 164,482 |
No | output | 1 | 82,241 | 12 | 164,483 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mike has a sequence A = [a1, a2, ..., an] of length n. He considers the sequence B = [b1, b2, ..., bn] beautiful if the gcd of all its elements is bigger than 1, i.e. <image>.
Mike wants to ch... | instruction | 0 | 82,242 | 12 | 164,484 |
No | output | 1 | 82,242 | 12 | 164,485 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ivan has an array consisting of n elements. Each of the elements is an integer from 1 to n.
Recently Ivan learned about permutations and their lexicographical order. Now he wants to change (replace) minimum number of elements in his array i... | instruction | 0 | 82,267 | 12 | 164,534 |
Tags: greedy, implementation, math
Correct Solution:
```
n = int(input())
l = list(map(int, input().split()))
cnt = [0] * 200001
pos = [0] * 200001
for i in range(n):
cnt[l[i]] += 1
uk = 1
an = 0
for i in range(n):
if cnt[l[i]] > 1:
an += 1
while cnt[uk] != 0:
uk += 1
if (uk ... | output | 1 | 82,267 | 12 | 164,535 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ivan has an array consisting of n elements. Each of the elements is an integer from 1 to n.
Recently Ivan learned about permutations and their lexicographical order. Now he wants to change (replace) minimum number of elements in his array i... | instruction | 0 | 82,268 | 12 | 164,536 |
Tags: greedy, implementation, math
Correct Solution:
```
# -*- coding: utf-8 -*-
import math
import collections
import bisect
import heapq
import time
import random
"""
created by shhuan at 2017/10/4 20:06
"""
N = int(input())
M = [int(x) for x in input().split()]
# t0 = time.time()
#
# N = 200000
# M = [random.ra... | output | 1 | 82,268 | 12 | 164,537 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ivan has an array consisting of n elements. Each of the elements is an integer from 1 to n.
Recently Ivan learned about permutations and their lexicographical order. Now he wants to change (replace) minimum number of elements in his array i... | instruction | 0 | 82,269 | 12 | 164,538 |
Tags: greedy, implementation, math
Correct Solution:
```
n = int(input()) + 1
t = [0] + list(map(int, input().split()))
s = [0] * n
for j in t: s[j] += 1
p = [0] * n
k = 1
for i, j in enumerate(t):
if s[j] > 1:
while s[k]: k += 1
if j > k or p[j]:
t[i] = k
s[j] -= 1
... | output | 1 | 82,269 | 12 | 164,539 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ivan has an array consisting of n elements. Each of the elements is an integer from 1 to n.
Recently Ivan learned about permutations and their lexicographical order. Now he wants to change (replace) minimum number of elements in his array i... | instruction | 0 | 82,270 | 12 | 164,540 |
Tags: greedy, implementation, math
Correct Solution:
```
from collections import defaultdict as dc
n=int(input())
a=[int(i) for i in input().split()]
p=dc(int)
q=dc(int)
extra=dc(int)
missing=[]
for i in range(n):
p[a[i]]=p[a[i]]+1
if p[a[i]]>1:
extra[a[i]]=1
for i in range(1,n+1):
if p[i]==0:
... | output | 1 | 82,270 | 12 | 164,541 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ivan has an array consisting of n elements. Each of the elements is an integer from 1 to n.
Recently Ivan learned about permutations and their lexicographical order. Now he wants to change (replace) minimum number of elements in his array i... | instruction | 0 | 82,271 | 12 | 164,542 |
Tags: greedy, implementation, math
Correct Solution:
```
def solve(printing):
n = int(input())
nums = [int(st)-1 for st in input().split(" ")]
numdupe = [0] * n
dupeindex = []
dupeindexindv = {}
missing = []
if printing:
print("nums"); print(nums)
for i in range(n):
nu... | output | 1 | 82,271 | 12 | 164,543 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ivan has an array consisting of n elements. Each of the elements is an integer from 1 to n.
Recently Ivan learned about permutations and their lexicographical order. Now he wants to change (replace) minimum number of elements in his array i... | instruction | 0 | 82,272 | 12 | 164,544 |
Tags: greedy, implementation, math
Correct Solution:
```
n=int(input())
d=[0]*n
*l,=map(int,input().split())
for i in l:d[i-1]+=1
print(d.count(0))
p=[0]*n
t=0
for i,j in enumerate(l):
if d[j-1]>1:
while d[t]>0:t+=1
if j>t+1 or p[j]:
d[j-1]-=1
d[t]+=1
l[i]=t+1
... | output | 1 | 82,272 | 12 | 164,545 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.