message stringlengths 2 44.5k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 42 109k | cluster float64 5 5 | __index_level_0__ int64 84 217k |
|---|---|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N integers written on a blackboard. The i-th integer is A_i.
Takahashi will repeatedly perform the following operation on these numbers:
* Select a pair of integers, A_i and A_j, tha... | instruction | 0 | 81,580 | 5 | 163,160 |
Yes | output | 1 | 81,580 | 5 | 163,161 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N integers written on a blackboard. The i-th integer is A_i.
Takahashi will repeatedly perform the following operation on these numbers:
* Select a pair of integers, A_i and A_j, tha... | instruction | 0 | 81,581 | 5 | 163,162 |
Yes | output | 1 | 81,581 | 5 | 163,163 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N integers written on a blackboard. The i-th integer is A_i.
Takahashi will repeatedly perform the following operation on these numbers:
* Select a pair of integers, A_i and A_j, tha... | instruction | 0 | 81,582 | 5 | 163,164 |
No | output | 1 | 81,582 | 5 | 163,165 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N integers written on a blackboard. The i-th integer is A_i.
Takahashi will repeatedly perform the following operation on these numbers:
* Select a pair of integers, A_i and A_j, tha... | instruction | 0 | 81,583 | 5 | 163,166 |
No | output | 1 | 81,583 | 5 | 163,167 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N integers written on a blackboard. The i-th integer is A_i.
Takahashi will repeatedly perform the following operation on these numbers:
* Select a pair of integers, A_i and A_j, tha... | instruction | 0 | 81,584 | 5 | 163,168 |
No | output | 1 | 81,584 | 5 | 163,169 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N integers written on a blackboard. The i-th integer is A_i.
Takahashi will repeatedly perform the following operation on these numbers:
* Select a pair of integers, A_i and A_j, tha... | instruction | 0 | 81,585 | 5 | 163,170 |
No | output | 1 | 81,585 | 5 | 163,171 |
Provide a correct Python 3 solution for this coding contest problem.
Problem statement
There is an unsigned $ 2 $ decimal integer $ X $ with $ N $ in digits including Leading-zeros. Output the largest non-negative integer that can be expressed in $ 2 $ base in $ N $ digits where the Hamming distance from $ X $ is $ D... | instruction | 0 | 81,662 | 5 | 163,324 |
"Correct Solution:
```
n=int(input())
x=input()
d=int(input())
x=list(x)
y=[1]*n
for i in range(n):
if d and x[i]=='0':y[i]=0;x[i]='1';d-=1
i=n-1
while d:
if y[i]:x[i]='0';d-=1
i-=1
print(*x, sep='')
``` | output | 1 | 81,662 | 5 | 163,325 |
Provide a correct Python 3 solution for this coding contest problem.
Problem statement
There is an unsigned $ 2 $ decimal integer $ X $ with $ N $ in digits including Leading-zeros. Output the largest non-negative integer that can be expressed in $ 2 $ base in $ N $ digits where the Hamming distance from $ X $ is $ D... | instruction | 0 | 81,663 | 5 | 163,326 |
"Correct Solution:
```
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import array
def num_string_to_array(num_string):
return array.array("B", map(int, num_string))
def num_array_to_string(num_array):
return "".join(map(str, num_array))
def solve(n, x, d):
answer = x[:]
rest_distance = d
for... | output | 1 | 81,663 | 5 | 163,327 |
Provide a correct Python 3 solution for this coding contest problem.
Problem statement
There is an unsigned $ 2 $ decimal integer $ X $ with $ N $ in digits including Leading-zeros. Output the largest non-negative integer that can be expressed in $ 2 $ base in $ N $ digits where the Hamming distance from $ X $ is $ D... | instruction | 0 | 81,664 | 5 | 163,328 |
"Correct Solution:
```
n = int(input())
bits_raw = input()
bits = [int(bits_raw[i]) for i in range(n)]
m = int(input())
ones = []
zeros = []
for i in range(n):
if(bits[i] == 1):
ones.append(i)
else:
zeros.append(i)
if(len(zeros) > m):
for i in range(m):
bits[zeros[i]] = 1
print('... | output | 1 | 81,664 | 5 | 163,329 |
Provide a correct Python 3 solution for this coding contest problem.
Problem statement
There is an unsigned $ 2 $ decimal integer $ X $ with $ N $ in digits including Leading-zeros. Output the largest non-negative integer that can be expressed in $ 2 $ base in $ N $ digits where the Hamming distance from $ X $ is $ D... | instruction | 0 | 81,665 | 5 | 163,330 |
"Correct Solution:
```
# -*- coding: utf-8 -*-
N = int(input())
X = input()
D = int(input())
ans = list(X)
done = [False] * N
for i in range(N):
if D == 0:
break
if ans[i] == "0":
ans[i] = "1"
done[i] = True
D -= 1
for i in range(N)[::-1]:
if D == 0:
break
if a... | output | 1 | 81,665 | 5 | 163,331 |
Provide a correct Python 3 solution for this coding contest problem.
Problem statement
There is an unsigned $ 2 $ decimal integer $ X $ with $ N $ in digits including Leading-zeros. Output the largest non-negative integer that can be expressed in $ 2 $ base in $ N $ digits where the Hamming distance from $ X $ is $ D... | instruction | 0 | 81,666 | 5 | 163,332 |
"Correct Solution:
```
n = int(input())
x = input()
d = int(input())
swap = {}
for i in range(n):
if d == 0:break
if x[i] == "0":
swap[i] = True
d -= 1
for i in range(n - 1, -1, -1):
if d == 0:break
if x[i] == "1":
swap[i] = True
d -= 1
print("".join([x[i] if i not in swap else ("0" if x[i] == "1... | output | 1 | 81,666 | 5 | 163,333 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Problem statement
There is an unsigned $ 2 $ decimal integer $ X $ with $ N $ in digits including Leading-zeros. Output the largest non-negative integer that can be expressed in $ 2 $ base in $... | instruction | 0 | 81,667 | 5 | 163,334 |
No | output | 1 | 81,667 | 5 | 163,335 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Problem statement
There is an unsigned $ 2 $ decimal integer $ X $ with $ N $ in digits including Leading-zeros. Output the largest non-negative integer that can be expressed in $ 2 $ base in $... | instruction | 0 | 81,668 | 5 | 163,336 |
No | output | 1 | 81,668 | 5 | 163,337 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Problem statement
There is an unsigned $ 2 $ decimal integer $ X $ with $ N $ in digits including Leading-zeros. Output the largest non-negative integer that can be expressed in $ 2 $ base in $... | instruction | 0 | 81,669 | 5 | 163,338 |
No | output | 1 | 81,669 | 5 | 163,339 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Problem statement
There is an unsigned $ 2 $ decimal integer $ X $ with $ N $ in digits including Leading-zeros. Output the largest non-negative integer that can be expressed in $ 2 $ base in $... | instruction | 0 | 81,670 | 5 | 163,340 |
No | output | 1 | 81,670 | 5 | 163,341 |
Provide a correct Python 3 solution for this coding contest problem.
Stack is a container of elements that are inserted and deleted according to LIFO (Last In First Out).
For $n$ stack $S_i$ ($i = 0, 1, ..., n-1$), perform a sequence of the following operations.
* push($t$, $x$): Insert an integer $x$ to $S_t$.
* to... | instruction | 0 | 81,692 | 5 | 163,384 |
"Correct Solution:
```
n,q=map(int,input().split())
stack=[]
for i in range(n):
stack.append([])
for i in range(q):
query=list(map(int,input().split()))
if query[0]==0:
stack[query[1]].append(query[2])
elif query[0]==1:
if len(stack[query[1]])!=0:
print(stack[query[1]][-1])
... | output | 1 | 81,692 | 5 | 163,385 |
Provide a correct Python 3 solution for this coding contest problem.
Stack is a container of elements that are inserted and deleted according to LIFO (Last In First Out).
For $n$ stack $S_i$ ($i = 0, 1, ..., n-1$), perform a sequence of the following operations.
* push($t$, $x$): Insert an integer $x$ to $S_t$.
* to... | instruction | 0 | 81,695 | 5 | 163,390 |
"Correct Solution:
```
import sys
n, q = map(int, input().split())
S = [[] for _ in range(n)]
ans =[]
for _ in range(q):
query = list(map(int, sys.stdin.readline().split()))
if query[0] == 0:
S[query[1]].append(query[2])
elif query[0] == 1:
if S[query[1]]:
ans.append(S[query[1]... | output | 1 | 81,695 | 5 | 163,391 |
Provide a correct Python 3 solution for this coding contest problem.
Stack is a container of elements that are inserted and deleted according to LIFO (Last In First Out).
For $n$ stack $S_i$ ($i = 0, 1, ..., n-1$), perform a sequence of the following operations.
* push($t$, $x$): Insert an integer $x$ to $S_t$.
* to... | instruction | 0 | 81,696 | 5 | 163,392 |
"Correct Solution:
```
# -*- coding: utf-8 -*-
"""
Basic Data Structures - Stack
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_2_A&lang=jp
"""
n, q = map(int, input().split())
stacks = [[] for _ in range(n)]
for _ in range(q):
op, t, x = (input() + ' 1').split()[:3]
if op == '0':
stacks... | output | 1 | 81,696 | 5 | 163,393 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Stack is a container of elements that are inserted and deleted according to LIFO (Last In First Out).
For $n$ stack $S_i$ ($i = 0, 1, ..., n-1$), perform a sequence of the following operations.... | instruction | 0 | 81,697 | 5 | 163,394 |
Yes | output | 1 | 81,697 | 5 | 163,395 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Stack is a container of elements that are inserted and deleted according to LIFO (Last In First Out).
For $n$ stack $S_i$ ($i = 0, 1, ..., n-1$), perform a sequence of the following operations.... | instruction | 0 | 81,702 | 5 | 163,404 |
No | output | 1 | 81,702 | 5 | 163,405 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Stack is a container of elements that are inserted and deleted according to LIFO (Last In First Out).
For $n$ stack $S_i$ ($i = 0, 1, ..., n-1$), perform a sequence of the following operations.... | instruction | 0 | 81,703 | 5 | 163,406 |
No | output | 1 | 81,703 | 5 | 163,407 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
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 bu... | instruction | 0 | 82,073 | 5 | 164,146 |
Yes | output | 1 | 82,073 | 5 | 164,147 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
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 bu... | instruction | 0 | 82,074 | 5 | 164,148 |
Yes | output | 1 | 82,074 | 5 | 164,149 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
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 bu... | instruction | 0 | 82,075 | 5 | 164,150 |
Yes | output | 1 | 82,075 | 5 | 164,151 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
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 bu... | instruction | 0 | 82,076 | 5 | 164,152 |
Yes | output | 1 | 82,076 | 5 | 164,153 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
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 bu... | instruction | 0 | 82,077 | 5 | 164,154 |
No | output | 1 | 82,077 | 5 | 164,155 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
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 bu... | instruction | 0 | 82,078 | 5 | 164,156 |
No | output | 1 | 82,078 | 5 | 164,157 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
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 bu... | instruction | 0 | 82,079 | 5 | 164,158 |
No | output | 1 | 82,079 | 5 | 164,159 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
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 bu... | instruction | 0 | 82,080 | 5 | 164,160 |
No | output | 1 | 82,080 | 5 | 164,161 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Some time ago Leonid have known about idempotent functions. Idempotent function defined on a set {1, 2, ..., n} is such function <image>, that for any <image> the formula g(g(x)) = g(x) holds.
... | instruction | 0 | 82,137 | 5 | 164,274 |
Yes | output | 1 | 82,137 | 5 | 164,275 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Some time ago Leonid have known about idempotent functions. Idempotent function defined on a set {1, 2, ..., n} is such function <image>, that for any <image> the formula g(g(x)) = g(x) holds.
... | instruction | 0 | 82,138 | 5 | 164,276 |
Yes | output | 1 | 82,138 | 5 | 164,277 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Some time ago Leonid have known about idempotent functions. Idempotent function defined on a set {1, 2, ..., n} is such function <image>, that for any <image> the formula g(g(x)) = g(x) holds.
... | instruction | 0 | 82,139 | 5 | 164,278 |
Yes | output | 1 | 82,139 | 5 | 164,279 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Some time ago Leonid have known about idempotent functions. Idempotent function defined on a set {1, 2, ..., n} is such function <image>, that for any <image> the formula g(g(x)) = g(x) holds.
... | instruction | 0 | 82,140 | 5 | 164,280 |
Yes | output | 1 | 82,140 | 5 | 164,281 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Some time ago Leonid have known about idempotent functions. Idempotent function defined on a set {1, 2, ..., n} is such function <image>, that for any <image> the formula g(g(x)) = g(x) holds.
... | instruction | 0 | 82,141 | 5 | 164,282 |
No | output | 1 | 82,141 | 5 | 164,283 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Some time ago Leonid have known about idempotent functions. Idempotent function defined on a set {1, 2, ..., n} is such function <image>, that for any <image> the formula g(g(x)) = g(x) holds.
... | instruction | 0 | 82,142 | 5 | 164,284 |
No | output | 1 | 82,142 | 5 | 164,285 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Some time ago Leonid have known about idempotent functions. Idempotent function defined on a set {1, 2, ..., n} is such function <image>, that for any <image> the formula g(g(x)) = g(x) holds.
... | instruction | 0 | 82,143 | 5 | 164,286 |
No | output | 1 | 82,143 | 5 | 164,287 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Some time ago Leonid have known about idempotent functions. Idempotent function defined on a set {1, 2, ..., n} is such function <image>, that for any <image> the formula g(g(x)) = g(x) holds.
... | instruction | 0 | 82,144 | 5 | 164,288 |
No | output | 1 | 82,144 | 5 | 164,289 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.
Constraints
* 1\leq A\leq B\leq 10^{18}
* 1\l... | instruction | 0 | 82,407 | 5 | 164,814 |
No | output | 1 | 82,407 | 5 | 164,815 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.
Constraints
* 1\leq A\leq B\leq 10^{18}
* 1\l... | instruction | 0 | 82,409 | 5 | 164,818 |
No | output | 1 | 82,409 | 5 | 164,819 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.
Constraints
* 1\leq A\leq B\leq 10^{18}
* 1\l... | instruction | 0 | 82,410 | 5 | 164,820 |
No | output | 1 | 82,410 | 5 | 164,821 |
Provide a correct Python 3 solution for this coding contest problem.
Input Format
N K
a_1 a_2 a_3 ... a_N
Output Format
Print the minimum cost in one line. In the end put a line break.
Constraints
* 1 ≤ K ≤ N ≤ 15
* 1 ≤ a_i ≤ 10^9
Scoring
Subtask 1 [120 points]
* N = K
Subtask 2 [90 points]
* N ≤ 5
* ... | instruction | 0 | 82,463 | 5 | 164,926 |
"Correct Solution:
```
from itertools import combinations as cmb
import copy
n, k = map(int, input().split())
A = list(map(int, input().split()))
highest = [A[0]] * n
for i in range(1, n):
highest[i] = max(A[i], highest[i-1])
def cost_calc(pattern):
cost = 0
max_height_re = 0
A_copy = copy.copy(A)
for num in... | output | 1 | 82,463 | 5 | 164,927 |
Provide a correct Python 3 solution for this coding contest problem.
Input Format
N K
a_1 a_2 a_3 ... a_N
Output Format
Print the minimum cost in one line. In the end put a line break.
Constraints
* 1 ≤ K ≤ N ≤ 15
* 1 ≤ a_i ≤ 10^9
Scoring
Subtask 1 [120 points]
* N = K
Subtask 2 [90 points]
* N ≤ 5
* ... | instruction | 0 | 82,464 | 5 | 164,928 |
"Correct Solution:
```
import sys
N, K = map(int, input().split())
B = list(map(int, sys.stdin.readline().rsplit()))
res = 10 ** 18
for i in range(2 ** N):
cnt = 0
for j in range(N):
# print(bin(i), bin(i >> j))
if (i >> j) & 1:
cnt += 1
# print(cnt)
if cnt != K:
co... | output | 1 | 82,464 | 5 | 164,929 |
Provide a correct Python 3 solution for this coding contest problem.
Input Format
N K
a_1 a_2 a_3 ... a_N
Output Format
Print the minimum cost in one line. In the end put a line break.
Constraints
* 1 ≤ K ≤ N ≤ 15
* 1 ≤ a_i ≤ 10^9
Scoring
Subtask 1 [120 points]
* N = K
Subtask 2 [90 points]
* N ≤ 5
* ... | instruction | 0 | 82,465 | 5 | 164,930 |
"Correct Solution:
```
n, k = map(int, input().split())
buildings = list(map(int, input().split()))
ans = float('inf')
for i in range(2 ** n):
res = 0
cnt = 1
prev_build = buildings[0]
# 高くするビルをbitで管理
for j in range(1, n):
if (i >> j) & 1:
cnt += 1
if prev_build >= b... | output | 1 | 82,465 | 5 | 164,931 |
Provide a correct Python 3 solution for this coding contest problem.
Input Format
N K
a_1 a_2 a_3 ... a_N
Output Format
Print the minimum cost in one line. In the end put a line break.
Constraints
* 1 ≤ K ≤ N ≤ 15
* 1 ≤ a_i ≤ 10^9
Scoring
Subtask 1 [120 points]
* N = K
Subtask 2 [90 points]
* N ≤ 5
* ... | instruction | 0 | 82,466 | 5 | 164,932 |
"Correct Solution:
```
N, K = map(int, input().split())
a = list(map(int, input().split()))
ans = float('inf')
for i in range(1<<N):
seen = 1
pay = 0
now = a[0]
for j in range(1, N):
if (i >> j) & 1:
if a[j] <= now:
pay += now - a[j] + 1
now += 1
... | output | 1 | 82,466 | 5 | 164,933 |
Provide a correct Python 3 solution for this coding contest problem.
Input Format
N K
a_1 a_2 a_3 ... a_N
Output Format
Print the minimum cost in one line. In the end put a line break.
Constraints
* 1 ≤ K ≤ N ≤ 15
* 1 ≤ a_i ≤ 10^9
Scoring
Subtask 1 [120 points]
* N = K
Subtask 2 [90 points]
* N ≤ 5
* ... | instruction | 0 | 82,467 | 5 | 164,934 |
"Correct Solution:
```
N,K = map(int,input().split())
a = [int(i) for i in input().split()]
ans = float("INF")
for i in range(1<<N):
cnt = 0
tmp = a[:]
m = tmp[0]
for j in range(1,N):
if i >> j & 1 and m >= tmp[j]:
cnt += m - tmp[j] + 1
tmp[j] = m + 1
m = max(m,tm... | output | 1 | 82,467 | 5 | 164,935 |
Provide a correct Python 3 solution for this coding contest problem.
Input Format
N K
a_1 a_2 a_3 ... a_N
Output Format
Print the minimum cost in one line. In the end put a line break.
Constraints
* 1 ≤ K ≤ N ≤ 15
* 1 ≤ a_i ≤ 10^9
Scoring
Subtask 1 [120 points]
* N = K
Subtask 2 [90 points]
* N ≤ 5
* ... | instruction | 0 | 82,468 | 5 | 164,936 |
"Correct Solution:
```
#!/usr/bin/env python3
n, k, *a = map(int, open(0).read().split())
ans = 10**18
for i in range(2 << n):
h = 0
c = 0
b = 0
for j in range(n):
if a[j] > h:
b += 1
h = a[j]
elif i >> j & 1:
c += h - a[j] + 1
h += 1
... | output | 1 | 82,468 | 5 | 164,937 |
Provide a correct Python 3 solution for this coding contest problem.
Input Format
N K
a_1 a_2 a_3 ... a_N
Output Format
Print the minimum cost in one line. In the end put a line break.
Constraints
* 1 ≤ K ≤ N ≤ 15
* 1 ≤ a_i ≤ 10^9
Scoring
Subtask 1 [120 points]
* N = K
Subtask 2 [90 points]
* N ≤ 5
* ... | instruction | 0 | 82,469 | 5 | 164,938 |
"Correct Solution:
```
N,K = map(int,input().split())
A = list(map(int,input().split()))
ans = float('inf')
for i in range(1<<N):
a = A[::]
cur,add = 0,0
see = 0
for j in range(N):
if (i>>j)&1:
see += 1
if cur >= a[j]:
add += (cur-a[j])+1
a[j] = cur+1
cur = max(cur,a[j])
... | output | 1 | 82,469 | 5 | 164,939 |
Provide a correct Python 3 solution for this coding contest problem.
Input Format
N K
a_1 a_2 a_3 ... a_N
Output Format
Print the minimum cost in one line. In the end put a line break.
Constraints
* 1 ≤ K ≤ N ≤ 15
* 1 ≤ a_i ≤ 10^9
Scoring
Subtask 1 [120 points]
* N = K
Subtask 2 [90 points]
* N ≤ 5
* ... | instruction | 0 | 82,470 | 5 | 164,940 |
"Correct Solution:
```
def LI(): return list(map(int,input().split()))
N,K = LI()
a = LI()
ans = float('INF')
for i in range(2**(N-1)):
bit = [i>>j&1 for j in range(N-1)]
if K-1!=bit.count(1):
continue
temp,kijun = 0,a[0]
for k in range(N-1):
if bit[k]==0:
kijun = max(kijun,a... | output | 1 | 82,470 | 5 | 164,941 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads an integer n and prints the factorial of n. You can assume that n ≤ 20.
Input
An integer n (1 ≤ n ≤ 20) in a line.
Output
Print the factorial of n in a line.
Example
Input
5
Output
120 | instruction | 0 | 82,480 | 5 | 164,960 |
"Correct Solution:
```
n = int(input())
result = n
for _ in range(n)[:1:-1] : result *= _
print(result)
``` | output | 1 | 82,480 | 5 | 164,961 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads an integer n and prints the factorial of n. You can assume that n ≤ 20.
Input
An integer n (1 ≤ n ≤ 20) in a line.
Output
Print the factorial of n in a line.
Example
Input
5
Output
120 | instruction | 0 | 82,481 | 5 | 164,962 |
"Correct Solution:
```
import sys
def fact(n):
ret = 1
if n<1:
return -1
elif n==1:
return 1
else:
return n*fact(n-1)
line = sys.stdin.readline()
inp = int(line)
print (fact(inp))
``` | output | 1 | 82,481 | 5 | 164,963 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.