message stringlengths 2 30.5k | message_type stringclasses 2 values | message_id int64 0 1 | conversation_id int64 237 109k | cluster float64 10 10 | __index_level_0__ int64 474 217k |
|---|---|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given $n$ packages of $w_i$ kg from a belt conveyor in order ($i = 0, 1, ... n-1$). You should load all packages onto $k$ trucks which have the common maximum load $P$. Each truck can load consecutive packages (more than or equals to zero) from the belt conveyor unless the total weights of the packages in the sequence does not exceed the maximum load $P$.
Write a program which reads $n$, $k$ and $w_i$, and reports the minimum value of the maximum load $P$ to load all packages from the belt conveyor.
Constraints
* $1 \leq n \leq 100,000$
* $1 \leq k \leq 100,000$
* $1 \leq w_i \leq 10,000$
Input
In the first line, two integers $n$ and $k$ are given separated by a space character. In the following $n$ lines, $w_i$ are given respectively.
Output
Print the minimum value of $P$ in a line.
Examples
Input
5 3
8
1
7
3
9
Output
10
Input
4 2
1
2
2
6
Output
6
Submitted Solution:
```
num, track = [int(x) for x in input().split()]
hoge_l = list()
for _ in range(num):
hoge_l.append(int(input()))
hoge_i = sum(hoge_l)
if hoge_i % track == 0:
hoge_i = hoge_i // track
else:
hoge_i = hoge_i // track + 1
while True:
tmp = 0
c = 1
for v in hoge_l:
tmp += v
if tmp > hoge_i:
c += 1
tmp = 0
tmp += v
if c == track:
break
elif c > track:
hoge_i += 1
max_num = max(hoge_l)
if max_num > hoge_i:
hoge_i = max_num
print (hoge_i)
``` | instruction | 0 | 23,811 | 10 | 47,622 |
No | output | 1 | 23,811 | 10 | 47,623 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a statistic of price changes for one product represented as an array of n positive integers p_0, p_1, ..., p_{n - 1}, where p_0 is the initial price of the product and p_i is how the price was increased during the i-th month.
Using these price changes you are asked to calculate the inflation coefficients for each month as the ratio of current price increase p_i to the price at the start of this month (p_0 + p_1 + ... + p_{i - 1}).
Your boss said you clearly that the inflation coefficients must not exceed k %, so you decided to increase some values p_i in such a way, that all p_i remain integers and the inflation coefficients for each month don't exceed k %.
You know, that the bigger changes β the more obvious cheating. That's why you need to minimize the total sum of changes.
What's the minimum total sum of changes you need to make all inflation coefficients not more than k %?
Input
The first line contains a single integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains two integers n and k (2 β€ n β€ 100; 1 β€ k β€ 100) β the length of array p and coefficient k.
The second line of each test case contains n integers p_0, p_1, ..., p_{n - 1} (1 β€ p_i β€ 10^9) β the array p.
Output
For each test case, print the minimum total sum of changes you need to make all inflation coefficients not more than k %.
Example
Input
2
4 1
20100 1 202 202
3 100
1 1 1
Output
99
0
Note
In the first test case, you can, for example, increase p_0 by 50 and p_1 by 49 and get array [20150, 50, 202, 202]. Then you get the next inflation coefficients:
1. 50/20150 β€ 1/100;
2. (202)/(20150 + 50) β€ 1/100;
3. (202)/(20200 + 202) β€ 1/100;
In the second test case, you don't need to modify array p, since the inflation coefficients are already good:
1. 1/1 β€ 100/100;
2. (1)/(1 + 1) β€ 100/100; | instruction | 0 | 24,016 | 10 | 48,032 |
Tags: binary search, brute force, greedy, math
Correct Solution:
```
import math
for t in range(int(input())):
n, k = map(int, input(). split())
lis = list(map(int, input(). split()))
ans = 0
sm = lis[0]
for i in range(1, n):
if lis[i] / sm <= k / 100:
sm += lis[i]
else:
temp = math.ceil(lis[i] * 100 / k) - sm
ans += temp
sm += temp + lis[i]
print(ans)
``` | output | 1 | 24,016 | 10 | 48,033 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a statistic of price changes for one product represented as an array of n positive integers p_0, p_1, ..., p_{n - 1}, where p_0 is the initial price of the product and p_i is how the price was increased during the i-th month.
Using these price changes you are asked to calculate the inflation coefficients for each month as the ratio of current price increase p_i to the price at the start of this month (p_0 + p_1 + ... + p_{i - 1}).
Your boss said you clearly that the inflation coefficients must not exceed k %, so you decided to increase some values p_i in such a way, that all p_i remain integers and the inflation coefficients for each month don't exceed k %.
You know, that the bigger changes β the more obvious cheating. That's why you need to minimize the total sum of changes.
What's the minimum total sum of changes you need to make all inflation coefficients not more than k %?
Input
The first line contains a single integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains two integers n and k (2 β€ n β€ 100; 1 β€ k β€ 100) β the length of array p and coefficient k.
The second line of each test case contains n integers p_0, p_1, ..., p_{n - 1} (1 β€ p_i β€ 10^9) β the array p.
Output
For each test case, print the minimum total sum of changes you need to make all inflation coefficients not more than k %.
Example
Input
2
4 1
20100 1 202 202
3 100
1 1 1
Output
99
0
Note
In the first test case, you can, for example, increase p_0 by 50 and p_1 by 49 and get array [20150, 50, 202, 202]. Then you get the next inflation coefficients:
1. 50/20150 β€ 1/100;
2. (202)/(20150 + 50) β€ 1/100;
3. (202)/(20200 + 202) β€ 1/100;
In the second test case, you don't need to modify array p, since the inflation coefficients are already good:
1. 1/1 β€ 100/100;
2. (1)/(1 + 1) β€ 100/100; | instruction | 0 | 24,017 | 10 | 48,034 |
Tags: binary search, brute force, greedy, math
Correct Solution:
```
def main():
T=eval(input())
for _1 in range(T):
N,K=list(map(int,input().split()))
P=[]
P=list(map(int,input().split()))
Sum=P[0]
Ans=0
for i in range(1,len(P)):
if P[i]*100<=Sum*K:
Sum+=P[i]
continue
else:
L,R=int(0),int(1e11)
while L<=R:
mid=int((L+R)>>1)
if (Sum + mid) * K >= P[i] * 100:
R=mid-1
else :
L=mid+1
Sum+=L+P[i]
Ans+=L
print(Ans)
if __name__ =='__main__':
main()
``` | output | 1 | 24,017 | 10 | 48,035 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a statistic of price changes for one product represented as an array of n positive integers p_0, p_1, ..., p_{n - 1}, where p_0 is the initial price of the product and p_i is how the price was increased during the i-th month.
Using these price changes you are asked to calculate the inflation coefficients for each month as the ratio of current price increase p_i to the price at the start of this month (p_0 + p_1 + ... + p_{i - 1}).
Your boss said you clearly that the inflation coefficients must not exceed k %, so you decided to increase some values p_i in such a way, that all p_i remain integers and the inflation coefficients for each month don't exceed k %.
You know, that the bigger changes β the more obvious cheating. That's why you need to minimize the total sum of changes.
What's the minimum total sum of changes you need to make all inflation coefficients not more than k %?
Input
The first line contains a single integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains two integers n and k (2 β€ n β€ 100; 1 β€ k β€ 100) β the length of array p and coefficient k.
The second line of each test case contains n integers p_0, p_1, ..., p_{n - 1} (1 β€ p_i β€ 10^9) β the array p.
Output
For each test case, print the minimum total sum of changes you need to make all inflation coefficients not more than k %.
Example
Input
2
4 1
20100 1 202 202
3 100
1 1 1
Output
99
0
Note
In the first test case, you can, for example, increase p_0 by 50 and p_1 by 49 and get array [20150, 50, 202, 202]. Then you get the next inflation coefficients:
1. 50/20150 β€ 1/100;
2. (202)/(20150 + 50) β€ 1/100;
3. (202)/(20200 + 202) β€ 1/100;
In the second test case, you don't need to modify array p, since the inflation coefficients are already good:
1. 1/1 β€ 100/100;
2. (1)/(1 + 1) β€ 100/100; | instruction | 0 | 24,018 | 10 | 48,036 |
Tags: binary search, brute force, greedy, math
Correct Solution:
```
import os
import sys
from io import BytesIO, IOBase
import math
import itertools
import bisect
import heapq
def main():
pass
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
def binary(n):
return (bin(n).replace("0b", ""))
def decimal(s):
return (int(s, 2))
def pow2(n):
p = 0
while (n > 1):
n //= 2
p += 1
return (p)
def primeFactors(n):
l = []
while n % 2 == 0:
l.append(2)
n = n / 2
for i in range(3, int(math.sqrt(n)) + 1, 2):
while n % i == 0:
l.append(i)
n = n / i
if n > 2:
l.append(int(n))
return (l)
def isPrime(n):
if (n == 1):
return (False)
else:
root = int(n ** 0.5)
root += 1
for i in range(2, root):
if (n % i == 0):
return (False)
return (True)
def maxPrimeFactors(n):
maxPrime = -1
while n % 2 == 0:
maxPrime = 2
n >>= 1
for i in range(3, int(math.sqrt(n)) + 1, 2):
while n % i == 0:
maxPrime = i
n = n / i
if n > 2:
maxPrime = n
return int(maxPrime)
def countcon(s, i):
c = 0
ch = s[i]
for i in range(i, len(s)):
if (s[i] == ch):
c += 1
else:
break
return (c)
def lis(arr):
n = len(arr)
lis = [1] * n
for i in range(1, n):
for j in range(0, i):
if arr[i] > arr[j] and lis[i] < lis[j] + 1:
lis[i] = lis[j] + 1
maximum = 0
for i in range(n):
maximum = max(maximum, lis[i])
return maximum
def isSubSequence(str1, str2):
m = len(str1)
n = len(str2)
j = 0
i = 0
while j < m and i < n:
if str1[j] == str2[i]:
j = j + 1
i = i + 1
return j == m
def maxfac(n):
root = int(n ** 0.5)
for i in range(2, root + 1):
if (n % i == 0):
return (n // i)
return (n)
def p2(n):
c=0
while(n%2==0):
n//=2
c+=1
return c
def seive(n):
primes=[True]*(n+1)
primes[1]=primes[0]=False
for i in range(2,n+1):
if(primes[i]):
for j in range(i+i,n+1,i):
primes[j]=False
p=[]
for i in range(0,n+1):
if(primes[i]):
p.append(i)
return(p)
def ncr(n, r, p):
num = den = 1
for i in range(r):
num = (num * (n - i)) % p
den = (den * (i + 1)) % p
return (num * pow(den,
p - 2, p)) % p
def denofactinverse(n,m):
fac=1
for i in range(1,n+1):
fac=(fac*i)%m
return (pow(fac,m-2,m))
def numofact(n,m):
fac = 1
for i in range(1, n + 1):
fac = (fac * i) % m
return(fac)
def commonAllowedPrefix(s1,s2):
for i in range(0,min(len(s1),len(s2))):
if(s1[i]>s2[i]):
return i
return(min(len(s1),len(s2)))
for xyz in range(0,int(input())):
n,k=map(int,input().split())
l=list(map(int,input().split()))
cp=l[0]
ans=0
for i in range(1,n):
if((l[i]*100)/cp<=k):
cp+=l[i]
else:
tba=math.ceil((100*l[i])/k)-cp
#print(tba)
cp+=tba+l[i]
ans+=tba
print(ans)
``` | output | 1 | 24,018 | 10 | 48,037 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a statistic of price changes for one product represented as an array of n positive integers p_0, p_1, ..., p_{n - 1}, where p_0 is the initial price of the product and p_i is how the price was increased during the i-th month.
Using these price changes you are asked to calculate the inflation coefficients for each month as the ratio of current price increase p_i to the price at the start of this month (p_0 + p_1 + ... + p_{i - 1}).
Your boss said you clearly that the inflation coefficients must not exceed k %, so you decided to increase some values p_i in such a way, that all p_i remain integers and the inflation coefficients for each month don't exceed k %.
You know, that the bigger changes β the more obvious cheating. That's why you need to minimize the total sum of changes.
What's the minimum total sum of changes you need to make all inflation coefficients not more than k %?
Input
The first line contains a single integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains two integers n and k (2 β€ n β€ 100; 1 β€ k β€ 100) β the length of array p and coefficient k.
The second line of each test case contains n integers p_0, p_1, ..., p_{n - 1} (1 β€ p_i β€ 10^9) β the array p.
Output
For each test case, print the minimum total sum of changes you need to make all inflation coefficients not more than k %.
Example
Input
2
4 1
20100 1 202 202
3 100
1 1 1
Output
99
0
Note
In the first test case, you can, for example, increase p_0 by 50 and p_1 by 49 and get array [20150, 50, 202, 202]. Then you get the next inflation coefficients:
1. 50/20150 β€ 1/100;
2. (202)/(20150 + 50) β€ 1/100;
3. (202)/(20200 + 202) β€ 1/100;
In the second test case, you don't need to modify array p, since the inflation coefficients are already good:
1. 1/1 β€ 100/100;
2. (1)/(1 + 1) β€ 100/100; | instruction | 0 | 24,019 | 10 | 48,038 |
Tags: binary search, brute force, greedy, math
Correct Solution:
```
import sys
input = sys.stdin.readline
for _ in range(int(input())):
n, k = map(int,input().split())
p = list(map(int,input().split()))
cnt = 0
prev = p[0]
for i in range(1, n):
if p[i] / prev <= k/100:
prev += p[i]
continue
else:
tmp = p[i] * 100 // k
if p[i] * 100 % k == 0:
ttmp = tmp - prev
else:
ttmp = tmp - prev + 1
prev += ttmp
cnt += ttmp
prev += p[i]
print(cnt)
``` | output | 1 | 24,019 | 10 | 48,039 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a statistic of price changes for one product represented as an array of n positive integers p_0, p_1, ..., p_{n - 1}, where p_0 is the initial price of the product and p_i is how the price was increased during the i-th month.
Using these price changes you are asked to calculate the inflation coefficients for each month as the ratio of current price increase p_i to the price at the start of this month (p_0 + p_1 + ... + p_{i - 1}).
Your boss said you clearly that the inflation coefficients must not exceed k %, so you decided to increase some values p_i in such a way, that all p_i remain integers and the inflation coefficients for each month don't exceed k %.
You know, that the bigger changes β the more obvious cheating. That's why you need to minimize the total sum of changes.
What's the minimum total sum of changes you need to make all inflation coefficients not more than k %?
Input
The first line contains a single integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains two integers n and k (2 β€ n β€ 100; 1 β€ k β€ 100) β the length of array p and coefficient k.
The second line of each test case contains n integers p_0, p_1, ..., p_{n - 1} (1 β€ p_i β€ 10^9) β the array p.
Output
For each test case, print the minimum total sum of changes you need to make all inflation coefficients not more than k %.
Example
Input
2
4 1
20100 1 202 202
3 100
1 1 1
Output
99
0
Note
In the first test case, you can, for example, increase p_0 by 50 and p_1 by 49 and get array [20150, 50, 202, 202]. Then you get the next inflation coefficients:
1. 50/20150 β€ 1/100;
2. (202)/(20150 + 50) β€ 1/100;
3. (202)/(20200 + 202) β€ 1/100;
In the second test case, you don't need to modify array p, since the inflation coefficients are already good:
1. 1/1 β€ 100/100;
2. (1)/(1 + 1) β€ 100/100; | instruction | 0 | 24,020 | 10 | 48,040 |
Tags: binary search, brute force, greedy, math
Correct Solution:
```
import sys,math
input=sys.stdin.readline
t = int(input())
for _ in range(t):
n,k = map(int,input().split())
a = list(map(int,input().split()))
ar = [0]*n
ar[0] = a[0]
for i in range(1,n):
ar[i] = ar[i-1] + a[i]
s = 0
for i in range(n-1,0,-1):
x = math.ceil(a[i]*100/k)
if x>ar[i-1]+s:
s += x-(ar[i-1]+s)
print(s)
``` | output | 1 | 24,020 | 10 | 48,041 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a statistic of price changes for one product represented as an array of n positive integers p_0, p_1, ..., p_{n - 1}, where p_0 is the initial price of the product and p_i is how the price was increased during the i-th month.
Using these price changes you are asked to calculate the inflation coefficients for each month as the ratio of current price increase p_i to the price at the start of this month (p_0 + p_1 + ... + p_{i - 1}).
Your boss said you clearly that the inflation coefficients must not exceed k %, so you decided to increase some values p_i in such a way, that all p_i remain integers and the inflation coefficients for each month don't exceed k %.
You know, that the bigger changes β the more obvious cheating. That's why you need to minimize the total sum of changes.
What's the minimum total sum of changes you need to make all inflation coefficients not more than k %?
Input
The first line contains a single integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains two integers n and k (2 β€ n β€ 100; 1 β€ k β€ 100) β the length of array p and coefficient k.
The second line of each test case contains n integers p_0, p_1, ..., p_{n - 1} (1 β€ p_i β€ 10^9) β the array p.
Output
For each test case, print the minimum total sum of changes you need to make all inflation coefficients not more than k %.
Example
Input
2
4 1
20100 1 202 202
3 100
1 1 1
Output
99
0
Note
In the first test case, you can, for example, increase p_0 by 50 and p_1 by 49 and get array [20150, 50, 202, 202]. Then you get the next inflation coefficients:
1. 50/20150 β€ 1/100;
2. (202)/(20150 + 50) β€ 1/100;
3. (202)/(20200 + 202) β€ 1/100;
In the second test case, you don't need to modify array p, since the inflation coefficients are already good:
1. 1/1 β€ 100/100;
2. (1)/(1 + 1) β€ 100/100; | instruction | 0 | 24,021 | 10 | 48,042 |
Tags: binary search, brute force, greedy, math
Correct Solution:
```
for _ in range(int(input())):
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=0
s=a[0]
for i in range(1,n):
for j in range(1,1000):
pass
l=a[i]/(s)
if(l<=k/100):s+=a[i]
else:
x=((a[i]*100)/k)-s
if(int(x)==x):
ans+=int(x)
s+=a[i]+int(x)
else:
ans+=int(x)+1
s+=a[i]+int(x)+1
print(int(ans))
``` | output | 1 | 24,021 | 10 | 48,043 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a statistic of price changes for one product represented as an array of n positive integers p_0, p_1, ..., p_{n - 1}, where p_0 is the initial price of the product and p_i is how the price was increased during the i-th month.
Using these price changes you are asked to calculate the inflation coefficients for each month as the ratio of current price increase p_i to the price at the start of this month (p_0 + p_1 + ... + p_{i - 1}).
Your boss said you clearly that the inflation coefficients must not exceed k %, so you decided to increase some values p_i in such a way, that all p_i remain integers and the inflation coefficients for each month don't exceed k %.
You know, that the bigger changes β the more obvious cheating. That's why you need to minimize the total sum of changes.
What's the minimum total sum of changes you need to make all inflation coefficients not more than k %?
Input
The first line contains a single integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains two integers n and k (2 β€ n β€ 100; 1 β€ k β€ 100) β the length of array p and coefficient k.
The second line of each test case contains n integers p_0, p_1, ..., p_{n - 1} (1 β€ p_i β€ 10^9) β the array p.
Output
For each test case, print the minimum total sum of changes you need to make all inflation coefficients not more than k %.
Example
Input
2
4 1
20100 1 202 202
3 100
1 1 1
Output
99
0
Note
In the first test case, you can, for example, increase p_0 by 50 and p_1 by 49 and get array [20150, 50, 202, 202]. Then you get the next inflation coefficients:
1. 50/20150 β€ 1/100;
2. (202)/(20150 + 50) β€ 1/100;
3. (202)/(20200 + 202) β€ 1/100;
In the second test case, you don't need to modify array p, since the inflation coefficients are already good:
1. 1/1 β€ 100/100;
2. (1)/(1 + 1) β€ 100/100; | instruction | 0 | 24,022 | 10 | 48,044 |
Tags: binary search, brute force, greedy, math
Correct Solution:
```
def solve():
n, k = map(int, input().split())
p = list(map(int, input().split()))
def f(m):
gsum = p[0] + m
for i in range(1, n):
if p[i] / gsum > k / 100:
return False
gsum += p[i]
return True
m = 0
l = -1
r = 10 ** 18
while r - l > 1:
m = (l + r) // 2;
if (f(m)):
r = m
else:
l = m
print(r)
t = int(input())
for i in range(t):
solve()
``` | output | 1 | 24,022 | 10 | 48,045 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a statistic of price changes for one product represented as an array of n positive integers p_0, p_1, ..., p_{n - 1}, where p_0 is the initial price of the product and p_i is how the price was increased during the i-th month.
Using these price changes you are asked to calculate the inflation coefficients for each month as the ratio of current price increase p_i to the price at the start of this month (p_0 + p_1 + ... + p_{i - 1}).
Your boss said you clearly that the inflation coefficients must not exceed k %, so you decided to increase some values p_i in such a way, that all p_i remain integers and the inflation coefficients for each month don't exceed k %.
You know, that the bigger changes β the more obvious cheating. That's why you need to minimize the total sum of changes.
What's the minimum total sum of changes you need to make all inflation coefficients not more than k %?
Input
The first line contains a single integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains two integers n and k (2 β€ n β€ 100; 1 β€ k β€ 100) β the length of array p and coefficient k.
The second line of each test case contains n integers p_0, p_1, ..., p_{n - 1} (1 β€ p_i β€ 10^9) β the array p.
Output
For each test case, print the minimum total sum of changes you need to make all inflation coefficients not more than k %.
Example
Input
2
4 1
20100 1 202 202
3 100
1 1 1
Output
99
0
Note
In the first test case, you can, for example, increase p_0 by 50 and p_1 by 49 and get array [20150, 50, 202, 202]. Then you get the next inflation coefficients:
1. 50/20150 β€ 1/100;
2. (202)/(20150 + 50) β€ 1/100;
3. (202)/(20200 + 202) β€ 1/100;
In the second test case, you don't need to modify array p, since the inflation coefficients are already good:
1. 1/1 β€ 100/100;
2. (1)/(1 + 1) β€ 100/100; | instruction | 0 | 24,023 | 10 | 48,046 |
Tags: binary search, brute force, greedy, math
Correct Solution:
```
for _ in range(int(input())):
n, k = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
now = p[0]
for i in range(1, n):
plus = max(0, (100 * p[i] + k - 1) // k - now)
ans += plus
now += plus
now += p[i]
print(ans)
``` | output | 1 | 24,023 | 10 | 48,047 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a statistic of price changes for one product represented as an array of n positive integers p_0, p_1, ..., p_{n - 1}, where p_0 is the initial price of the product and p_i is how the price was increased during the i-th month.
Using these price changes you are asked to calculate the inflation coefficients for each month as the ratio of current price increase p_i to the price at the start of this month (p_0 + p_1 + ... + p_{i - 1}).
Your boss said you clearly that the inflation coefficients must not exceed k %, so you decided to increase some values p_i in such a way, that all p_i remain integers and the inflation coefficients for each month don't exceed k %.
You know, that the bigger changes β the more obvious cheating. That's why you need to minimize the total sum of changes.
What's the minimum total sum of changes you need to make all inflation coefficients not more than k %?
Input
The first line contains a single integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains two integers n and k (2 β€ n β€ 100; 1 β€ k β€ 100) β the length of array p and coefficient k.
The second line of each test case contains n integers p_0, p_1, ..., p_{n - 1} (1 β€ p_i β€ 10^9) β the array p.
Output
For each test case, print the minimum total sum of changes you need to make all inflation coefficients not more than k %.
Example
Input
2
4 1
20100 1 202 202
3 100
1 1 1
Output
99
0
Note
In the first test case, you can, for example, increase p_0 by 50 and p_1 by 49 and get array [20150, 50, 202, 202]. Then you get the next inflation coefficients:
1. 50/20150 β€ 1/100;
2. (202)/(20150 + 50) β€ 1/100;
3. (202)/(20200 + 202) β€ 1/100;
In the second test case, you don't need to modify array p, since the inflation coefficients are already good:
1. 1/1 β€ 100/100;
2. (1)/(1 + 1) β€ 100/100;
Submitted Solution:
```
from math import ceil
t = int(input())
for _ in range(t):
n, k = map(int, input().split())
p = list(map(int, input().split()))
add = 0
s = p[0]
for i in range(1, n):
add = max(add, ceil(100*p[i] / k) - s)
s += p[i]
print(add)
``` | instruction | 0 | 24,024 | 10 | 48,048 |
Yes | output | 1 | 24,024 | 10 | 48,049 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a statistic of price changes for one product represented as an array of n positive integers p_0, p_1, ..., p_{n - 1}, where p_0 is the initial price of the product and p_i is how the price was increased during the i-th month.
Using these price changes you are asked to calculate the inflation coefficients for each month as the ratio of current price increase p_i to the price at the start of this month (p_0 + p_1 + ... + p_{i - 1}).
Your boss said you clearly that the inflation coefficients must not exceed k %, so you decided to increase some values p_i in such a way, that all p_i remain integers and the inflation coefficients for each month don't exceed k %.
You know, that the bigger changes β the more obvious cheating. That's why you need to minimize the total sum of changes.
What's the minimum total sum of changes you need to make all inflation coefficients not more than k %?
Input
The first line contains a single integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains two integers n and k (2 β€ n β€ 100; 1 β€ k β€ 100) β the length of array p and coefficient k.
The second line of each test case contains n integers p_0, p_1, ..., p_{n - 1} (1 β€ p_i β€ 10^9) β the array p.
Output
For each test case, print the minimum total sum of changes you need to make all inflation coefficients not more than k %.
Example
Input
2
4 1
20100 1 202 202
3 100
1 1 1
Output
99
0
Note
In the first test case, you can, for example, increase p_0 by 50 and p_1 by 49 and get array [20150, 50, 202, 202]. Then you get the next inflation coefficients:
1. 50/20150 β€ 1/100;
2. (202)/(20150 + 50) β€ 1/100;
3. (202)/(20200 + 202) β€ 1/100;
In the second test case, you don't need to modify array p, since the inflation coefficients are already good:
1. 1/1 β€ 100/100;
2. (1)/(1 + 1) β€ 100/100;
Submitted Solution:
```
R=lambda:map(int,input().split())
t,=R()
exec(t*'n,k=R();s,*a=R();r=0\nfor x in a:r=max(r,-s--x*100//k);s+=x\nprint(r)\n')
``` | instruction | 0 | 24,025 | 10 | 48,050 |
Yes | output | 1 | 24,025 | 10 | 48,051 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a statistic of price changes for one product represented as an array of n positive integers p_0, p_1, ..., p_{n - 1}, where p_0 is the initial price of the product and p_i is how the price was increased during the i-th month.
Using these price changes you are asked to calculate the inflation coefficients for each month as the ratio of current price increase p_i to the price at the start of this month (p_0 + p_1 + ... + p_{i - 1}).
Your boss said you clearly that the inflation coefficients must not exceed k %, so you decided to increase some values p_i in such a way, that all p_i remain integers and the inflation coefficients for each month don't exceed k %.
You know, that the bigger changes β the more obvious cheating. That's why you need to minimize the total sum of changes.
What's the minimum total sum of changes you need to make all inflation coefficients not more than k %?
Input
The first line contains a single integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains two integers n and k (2 β€ n β€ 100; 1 β€ k β€ 100) β the length of array p and coefficient k.
The second line of each test case contains n integers p_0, p_1, ..., p_{n - 1} (1 β€ p_i β€ 10^9) β the array p.
Output
For each test case, print the minimum total sum of changes you need to make all inflation coefficients not more than k %.
Example
Input
2
4 1
20100 1 202 202
3 100
1 1 1
Output
99
0
Note
In the first test case, you can, for example, increase p_0 by 50 and p_1 by 49 and get array [20150, 50, 202, 202]. Then you get the next inflation coefficients:
1. 50/20150 β€ 1/100;
2. (202)/(20150 + 50) β€ 1/100;
3. (202)/(20200 + 202) β€ 1/100;
In the second test case, you don't need to modify array p, since the inflation coefficients are already good:
1. 1/1 β€ 100/100;
2. (1)/(1 + 1) β€ 100/100;
Submitted Solution:
```
t = int(input())
for i in range(t):
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
subs = []
for i in range(1, n+1):
if i == n:
subs.append(0)
elif p[-i] / sum(p[:-i]) > k/100:
ans = (p[-i]*100-sum(p[:-i])*k)/k
if ans.is_integer():
subs.append(int(ans))
else:
subs.append(int(ans+1))
print(max(subs))
``` | instruction | 0 | 24,026 | 10 | 48,052 |
Yes | output | 1 | 24,026 | 10 | 48,053 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a statistic of price changes for one product represented as an array of n positive integers p_0, p_1, ..., p_{n - 1}, where p_0 is the initial price of the product and p_i is how the price was increased during the i-th month.
Using these price changes you are asked to calculate the inflation coefficients for each month as the ratio of current price increase p_i to the price at the start of this month (p_0 + p_1 + ... + p_{i - 1}).
Your boss said you clearly that the inflation coefficients must not exceed k %, so you decided to increase some values p_i in such a way, that all p_i remain integers and the inflation coefficients for each month don't exceed k %.
You know, that the bigger changes β the more obvious cheating. That's why you need to minimize the total sum of changes.
What's the minimum total sum of changes you need to make all inflation coefficients not more than k %?
Input
The first line contains a single integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains two integers n and k (2 β€ n β€ 100; 1 β€ k β€ 100) β the length of array p and coefficient k.
The second line of each test case contains n integers p_0, p_1, ..., p_{n - 1} (1 β€ p_i β€ 10^9) β the array p.
Output
For each test case, print the minimum total sum of changes you need to make all inflation coefficients not more than k %.
Example
Input
2
4 1
20100 1 202 202
3 100
1 1 1
Output
99
0
Note
In the first test case, you can, for example, increase p_0 by 50 and p_1 by 49 and get array [20150, 50, 202, 202]. Then you get the next inflation coefficients:
1. 50/20150 β€ 1/100;
2. (202)/(20150 + 50) β€ 1/100;
3. (202)/(20200 + 202) β€ 1/100;
In the second test case, you don't need to modify array p, since the inflation coefficients are already good:
1. 1/1 β€ 100/100;
2. (1)/(1 + 1) β€ 100/100;
Submitted Solution:
```
import math
t = int(input())
while t > 0:
t = t - 1
n, k = map(int, input().split())
p = [int(k) for k in input().split()]
j = []
s = p[0]
for i in range(1, n):
if p[i] / s > k / 100:
j.append(math.ceil((p[i] * 100) / k) - s)
else:
j.append(0)
s += p[i]
print(max(j))
``` | instruction | 0 | 24,027 | 10 | 48,054 |
Yes | output | 1 | 24,027 | 10 | 48,055 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a statistic of price changes for one product represented as an array of n positive integers p_0, p_1, ..., p_{n - 1}, where p_0 is the initial price of the product and p_i is how the price was increased during the i-th month.
Using these price changes you are asked to calculate the inflation coefficients for each month as the ratio of current price increase p_i to the price at the start of this month (p_0 + p_1 + ... + p_{i - 1}).
Your boss said you clearly that the inflation coefficients must not exceed k %, so you decided to increase some values p_i in such a way, that all p_i remain integers and the inflation coefficients for each month don't exceed k %.
You know, that the bigger changes β the more obvious cheating. That's why you need to minimize the total sum of changes.
What's the minimum total sum of changes you need to make all inflation coefficients not more than k %?
Input
The first line contains a single integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains two integers n and k (2 β€ n β€ 100; 1 β€ k β€ 100) β the length of array p and coefficient k.
The second line of each test case contains n integers p_0, p_1, ..., p_{n - 1} (1 β€ p_i β€ 10^9) β the array p.
Output
For each test case, print the minimum total sum of changes you need to make all inflation coefficients not more than k %.
Example
Input
2
4 1
20100 1 202 202
3 100
1 1 1
Output
99
0
Note
In the first test case, you can, for example, increase p_0 by 50 and p_1 by 49 and get array [20150, 50, 202, 202]. Then you get the next inflation coefficients:
1. 50/20150 β€ 1/100;
2. (202)/(20150 + 50) β€ 1/100;
3. (202)/(20200 + 202) β€ 1/100;
In the second test case, you don't need to modify array p, since the inflation coefficients are already good:
1. 1/1 β€ 100/100;
2. (1)/(1 + 1) β€ 100/100;
Submitted Solution:
```
import math
for _ in range(int(input())):
n,d=map(int,input().split())
arr=list(map(int,input().split()))
k=d/100
p=0
x=arr[0]
for i in range(1,n):
if(arr[i]/x>k):
q=math.ceil((arr[i]/k)-x)
p+=q
x+=q
x+=arr[i]
print(p)
``` | instruction | 0 | 24,028 | 10 | 48,056 |
No | output | 1 | 24,028 | 10 | 48,057 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a statistic of price changes for one product represented as an array of n positive integers p_0, p_1, ..., p_{n - 1}, where p_0 is the initial price of the product and p_i is how the price was increased during the i-th month.
Using these price changes you are asked to calculate the inflation coefficients for each month as the ratio of current price increase p_i to the price at the start of this month (p_0 + p_1 + ... + p_{i - 1}).
Your boss said you clearly that the inflation coefficients must not exceed k %, so you decided to increase some values p_i in such a way, that all p_i remain integers and the inflation coefficients for each month don't exceed k %.
You know, that the bigger changes β the more obvious cheating. That's why you need to minimize the total sum of changes.
What's the minimum total sum of changes you need to make all inflation coefficients not more than k %?
Input
The first line contains a single integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains two integers n and k (2 β€ n β€ 100; 1 β€ k β€ 100) β the length of array p and coefficient k.
The second line of each test case contains n integers p_0, p_1, ..., p_{n - 1} (1 β€ p_i β€ 10^9) β the array p.
Output
For each test case, print the minimum total sum of changes you need to make all inflation coefficients not more than k %.
Example
Input
2
4 1
20100 1 202 202
3 100
1 1 1
Output
99
0
Note
In the first test case, you can, for example, increase p_0 by 50 and p_1 by 49 and get array [20150, 50, 202, 202]. Then you get the next inflation coefficients:
1. 50/20150 β€ 1/100;
2. (202)/(20150 + 50) β€ 1/100;
3. (202)/(20200 + 202) β€ 1/100;
In the second test case, you don't need to modify array p, since the inflation coefficients are already good:
1. 1/1 β€ 100/100;
2. (1)/(1 + 1) β€ 100/100;
Submitted Solution:
```
import sys
T=int(sys.stdin.readline().strip())
while (T>0):
T-=1
n,k=sys.stdin.readline().split(" ")
n=int(n)
k=int(k)
a=sys.stdin.readline().strip().split(" ")
a=list(map(lambda x:int(x), a))
s=[0]
for i in range(n):
s.append(a[i]+s[i])
ans =0
for i in range(n-1,0,-1):
if a[i]*100>(s[i]+ans)*k:
ans= (a[i]*100-(s[i])) //k
print(ans)
``` | instruction | 0 | 24,029 | 10 | 48,058 |
No | output | 1 | 24,029 | 10 | 48,059 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a statistic of price changes for one product represented as an array of n positive integers p_0, p_1, ..., p_{n - 1}, where p_0 is the initial price of the product and p_i is how the price was increased during the i-th month.
Using these price changes you are asked to calculate the inflation coefficients for each month as the ratio of current price increase p_i to the price at the start of this month (p_0 + p_1 + ... + p_{i - 1}).
Your boss said you clearly that the inflation coefficients must not exceed k %, so you decided to increase some values p_i in such a way, that all p_i remain integers and the inflation coefficients for each month don't exceed k %.
You know, that the bigger changes β the more obvious cheating. That's why you need to minimize the total sum of changes.
What's the minimum total sum of changes you need to make all inflation coefficients not more than k %?
Input
The first line contains a single integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains two integers n and k (2 β€ n β€ 100; 1 β€ k β€ 100) β the length of array p and coefficient k.
The second line of each test case contains n integers p_0, p_1, ..., p_{n - 1} (1 β€ p_i β€ 10^9) β the array p.
Output
For each test case, print the minimum total sum of changes you need to make all inflation coefficients not more than k %.
Example
Input
2
4 1
20100 1 202 202
3 100
1 1 1
Output
99
0
Note
In the first test case, you can, for example, increase p_0 by 50 and p_1 by 49 and get array [20150, 50, 202, 202]. Then you get the next inflation coefficients:
1. 50/20150 β€ 1/100;
2. (202)/(20150 + 50) β€ 1/100;
3. (202)/(20200 + 202) β€ 1/100;
In the second test case, you don't need to modify array p, since the inflation coefficients are already good:
1. 1/1 β€ 100/100;
2. (1)/(1 + 1) β€ 100/100;
Submitted Solution:
```
from math import ceil
t = int(input())
for i in range(t):
n, k = map(int, input().split())
arr = list(map(int, input().split()))
s = 0
sm = arr[0]
for i in range(1, n):
if arr[i] / sm > k / 100:
s = s + arr[i] / (k / 100) - sm
sm = sm + arr[i] / (k / 100) - sm
sm += arr[i]
print(ceil(s))
``` | instruction | 0 | 24,030 | 10 | 48,060 |
No | output | 1 | 24,030 | 10 | 48,061 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a statistic of price changes for one product represented as an array of n positive integers p_0, p_1, ..., p_{n - 1}, where p_0 is the initial price of the product and p_i is how the price was increased during the i-th month.
Using these price changes you are asked to calculate the inflation coefficients for each month as the ratio of current price increase p_i to the price at the start of this month (p_0 + p_1 + ... + p_{i - 1}).
Your boss said you clearly that the inflation coefficients must not exceed k %, so you decided to increase some values p_i in such a way, that all p_i remain integers and the inflation coefficients for each month don't exceed k %.
You know, that the bigger changes β the more obvious cheating. That's why you need to minimize the total sum of changes.
What's the minimum total sum of changes you need to make all inflation coefficients not more than k %?
Input
The first line contains a single integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains two integers n and k (2 β€ n β€ 100; 1 β€ k β€ 100) β the length of array p and coefficient k.
The second line of each test case contains n integers p_0, p_1, ..., p_{n - 1} (1 β€ p_i β€ 10^9) β the array p.
Output
For each test case, print the minimum total sum of changes you need to make all inflation coefficients not more than k %.
Example
Input
2
4 1
20100 1 202 202
3 100
1 1 1
Output
99
0
Note
In the first test case, you can, for example, increase p_0 by 50 and p_1 by 49 and get array [20150, 50, 202, 202]. Then you get the next inflation coefficients:
1. 50/20150 β€ 1/100;
2. (202)/(20150 + 50) β€ 1/100;
3. (202)/(20200 + 202) β€ 1/100;
In the second test case, you don't need to modify array p, since the inflation coefficients are already good:
1. 1/1 β€ 100/100;
2. (1)/(1 + 1) β€ 100/100;
Submitted Solution:
```
import math
t = int(input())
for _ in range(t):
n, k = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
s = p[0]
izm = 0
for i in range(1, n):
cur = p[i] / s
if cur <= k / 100:
s += p[i]
continue
s1 = p[0]
delta = (p[i] / (k / 100) - s)
izm += delta
s += delta
s += p[i]
print(math.ceil(izm))
``` | instruction | 0 | 24,031 | 10 | 48,062 |
No | output | 1 | 24,031 | 10 | 48,063 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.
Reliable sources have informed the financier Anton of some information about the exchange rate of currency you all know against the burle for tomorrow. Now Anton knows that tomorrow the exchange rate will be an even number, which can be obtained from the present rate by swapping exactly two distinct digits in it. Of all the possible values that meet these conditions, the exchange rate for tomorrow will be the maximum possible. It is guaranteed that today the exchange rate is an odd positive integer n. Help Anton to determine the exchange rate of currency you all know for tomorrow!
Input
The first line contains an odd positive integer n β the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
Output
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print - 1.
Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from today's exchange rate by swapping exactly two digits. Exchange rate representation should not contain leading zeroes.
Examples
Input
527
Output
572
Input
4573
Output
3574
Input
1357997531
Output
-1 | instruction | 0 | 24,233 | 10 | 48,466 |
Tags: greedy, math, strings
Correct Solution:
```
def cur(s):
s1=""
ci=-1
for i in range(len(s)-1):
if int(s[i])%2==0 and int(s[i])<int(s[-1]):
return (s[0:i]+s[-1]+s[i+1:len(s)-1]+s[i])
elif int(s[i])%2==0 and int(s[i])>int(s[-1]):
ci=i
if ci!=-1:
return s[0:ci]+s[-1]+s[ci+1:len(s)-1]+s[ci]
return -1
st=input()
print(cur(st))
``` | output | 1 | 24,233 | 10 | 48,467 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.
Reliable sources have informed the financier Anton of some information about the exchange rate of currency you all know against the burle for tomorrow. Now Anton knows that tomorrow the exchange rate will be an even number, which can be obtained from the present rate by swapping exactly two distinct digits in it. Of all the possible values that meet these conditions, the exchange rate for tomorrow will be the maximum possible. It is guaranteed that today the exchange rate is an odd positive integer n. Help Anton to determine the exchange rate of currency you all know for tomorrow!
Input
The first line contains an odd positive integer n β the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
Output
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print - 1.
Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from today's exchange rate by swapping exactly two digits. Exchange rate representation should not contain leading zeroes.
Examples
Input
527
Output
572
Input
4573
Output
3574
Input
1357997531
Output
-1 | instruction | 0 | 24,234 | 10 | 48,468 |
Tags: greedy, math, strings
Correct Solution:
```
s = input()
l = []
count=0
for i in s:
l.append(int(i))
for j in range(len(l)):
if (l[j] % 2 == 0 and l[j] < l[-1]):
count+=1
l[j], l[-1] = l[-1], l[j]
break
elif (l[j] % 2 == 0 and l[j] > l[-1]):
count += 1
temp=j
if (count == 0):
print(-1)
else:
a = ""
for k in l:
a = a + str(k)
if (a == s):
l[temp], l[-1] = l[-1], l[temp]
b=""
for k in l:
b = b + str(k)
print(b)
else:
print(a)
``` | output | 1 | 24,234 | 10 | 48,469 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.
Reliable sources have informed the financier Anton of some information about the exchange rate of currency you all know against the burle for tomorrow. Now Anton knows that tomorrow the exchange rate will be an even number, which can be obtained from the present rate by swapping exactly two distinct digits in it. Of all the possible values that meet these conditions, the exchange rate for tomorrow will be the maximum possible. It is guaranteed that today the exchange rate is an odd positive integer n. Help Anton to determine the exchange rate of currency you all know for tomorrow!
Input
The first line contains an odd positive integer n β the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
Output
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print - 1.
Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from today's exchange rate by swapping exactly two digits. Exchange rate representation should not contain leading zeroes.
Examples
Input
527
Output
572
Input
4573
Output
3574
Input
1357997531
Output
-1 | instruction | 0 | 24,235 | 10 | 48,470 |
Tags: greedy, math, strings
Correct Solution:
```
a=input()
a=list(a)
ind=-1
s=-1
flag=0
e=a[len(a)-1]
temp=0
for i in range(len(a)-1,-1,-1):
if(int(a[i])%2==0):
flag=flag+1
if(flag==1):
ind=i
temp=a[i]
elif e>a[i]:
ind=i
temp=a[i]
if(flag==0):
print('-1')
else:
a[len(a)-1]=str(temp)
a[ind]=str(e)
a=''.join(a)
print(a)
``` | output | 1 | 24,235 | 10 | 48,471 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.
Reliable sources have informed the financier Anton of some information about the exchange rate of currency you all know against the burle for tomorrow. Now Anton knows that tomorrow the exchange rate will be an even number, which can be obtained from the present rate by swapping exactly two distinct digits in it. Of all the possible values that meet these conditions, the exchange rate for tomorrow will be the maximum possible. It is guaranteed that today the exchange rate is an odd positive integer n. Help Anton to determine the exchange rate of currency you all know for tomorrow!
Input
The first line contains an odd positive integer n β the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
Output
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print - 1.
Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from today's exchange rate by swapping exactly two digits. Exchange rate representation should not contain leading zeroes.
Examples
Input
527
Output
572
Input
4573
Output
3574
Input
1357997531
Output
-1 | instruction | 0 | 24,237 | 10 | 48,474 |
Tags: greedy, math, strings
Correct Solution:
```
n=input()
l1=list(n)
k=l1.copy()
f=0
maxi=0
for i in range(len(l1)):
if(int(l1[i])%2==0 and int(l1[i])<int(l1[len(l1)-1])):
f=1
c=l1[len(l1)-1]
l1[len(l1)-1]=l1[i]
l1[i]=c
break
if(f==0):
for i in range(len(l1)):
if(int(l1[len(l1)-i-1])%2==0):
f=2
c=l1[len(l1)-i-1]
l1[len(l1)-i-1]=l1[len(l1)-1]
l1[len(l1)-1]=c
break
if(f==1 or f==2):
for i in l1:
print(i,end="")
else:
print(-1)
``` | output | 1 | 24,237 | 10 | 48,475 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.
Reliable sources have informed the financier Anton of some information about the exchange rate of currency you all know against the burle for tomorrow. Now Anton knows that tomorrow the exchange rate will be an even number, which can be obtained from the present rate by swapping exactly two distinct digits in it. Of all the possible values that meet these conditions, the exchange rate for tomorrow will be the maximum possible. It is guaranteed that today the exchange rate is an odd positive integer n. Help Anton to determine the exchange rate of currency you all know for tomorrow!
Input
The first line contains an odd positive integer n β the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
Output
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print - 1.
Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from today's exchange rate by swapping exactly two digits. Exchange rate representation should not contain leading zeroes.
Examples
Input
527
Output
572
Input
4573
Output
3574
Input
1357997531
Output
-1 | instruction | 0 | 24,238 | 10 | 48,476 |
Tags: greedy, math, strings
Correct Solution:
```
l=list(input())
n=len(l)
r=int(l[-1])
flag=0
m=-1
for i in range(n):
if(int(l[i])%2==0):
m=i
if(r>int(l[i])):
l[-1],l[i]=l[i],l[-1]
flag=1
break
if(flag):
k=""
for i in range(n):
k+=l[i]
print(k)
elif(m!=-1):
l[-1],l[m]=l[m],l[-1]
k=""
for i in range(n):
k+=l[i]
print(k)
else:
print(-1)
``` | output | 1 | 24,238 | 10 | 48,477 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.
Reliable sources have informed the financier Anton of some information about the exchange rate of currency you all know against the burle for tomorrow. Now Anton knows that tomorrow the exchange rate will be an even number, which can be obtained from the present rate by swapping exactly two distinct digits in it. Of all the possible values that meet these conditions, the exchange rate for tomorrow will be the maximum possible. It is guaranteed that today the exchange rate is an odd positive integer n. Help Anton to determine the exchange rate of currency you all know for tomorrow!
Input
The first line contains an odd positive integer n β the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
Output
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print - 1.
Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from today's exchange rate by swapping exactly two digits. Exchange rate representation should not contain leading zeroes.
Examples
Input
527
Output
572
Input
4573
Output
3574
Input
1357997531
Output
-1
Submitted Solution:
```
n = input()
even = -1
for i in range(0,len(n)-1):
if int(n[i])%2 == 0:
even = i
if int(n[i])<int(n[-1]):
break
if even >= 0:
k = ""
for i in range(0,len(n)-1):
if i == even:
k += n[-1]
else:
k += n[i]
k += n[even]
print(k)
else:
print(-1)
``` | instruction | 0 | 24,240 | 10 | 48,480 |
Yes | output | 1 | 24,240 | 10 | 48,481 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.
Reliable sources have informed the financier Anton of some information about the exchange rate of currency you all know against the burle for tomorrow. Now Anton knows that tomorrow the exchange rate will be an even number, which can be obtained from the present rate by swapping exactly two distinct digits in it. Of all the possible values that meet these conditions, the exchange rate for tomorrow will be the maximum possible. It is guaranteed that today the exchange rate is an odd positive integer n. Help Anton to determine the exchange rate of currency you all know for tomorrow!
Input
The first line contains an odd positive integer n β the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
Output
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print - 1.
Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from today's exchange rate by swapping exactly two digits. Exchange rate representation should not contain leading zeroes.
Examples
Input
527
Output
572
Input
4573
Output
3574
Input
1357997531
Output
-1
Submitted Solution:
```
n, pos = input(), -1
for i in range(len(n) - 1):
if n[i] in '02468':
pos = i
if n[i] < n[-1]:
break
if pos < 0:
print(-1)
else:
print(n[:pos] + n[-1] + n[pos+1:-1] + n[pos])
``` | instruction | 0 | 24,241 | 10 | 48,482 |
Yes | output | 1 | 24,241 | 10 | 48,483 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.
Reliable sources have informed the financier Anton of some information about the exchange rate of currency you all know against the burle for tomorrow. Now Anton knows that tomorrow the exchange rate will be an even number, which can be obtained from the present rate by swapping exactly two distinct digits in it. Of all the possible values that meet these conditions, the exchange rate for tomorrow will be the maximum possible. It is guaranteed that today the exchange rate is an odd positive integer n. Help Anton to determine the exchange rate of currency you all know for tomorrow!
Input
The first line contains an odd positive integer n β the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
Output
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print - 1.
Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from today's exchange rate by swapping exactly two digits. Exchange rate representation should not contain leading zeroes.
Examples
Input
527
Output
572
Input
4573
Output
3574
Input
1357997531
Output
-1
Submitted Solution:
```
n=input()
c=0
d=[]
for i in range(len(n)):
if int(n[i])%2==0:
d.append(int(n[i]))
c+=1
if c==0:
print(-1)
else:
b=0
a=int(n[-1])
n=n[0:len(n)-1]
if min(d)<a:
b=1
if b==1:
for i in range(len(n)):
if int(n[i])%2==0 and int(n[i])<a:
e=n[i]
n = n[0:i]+str(a)+n[i+1::]
break
else:
for i in range(len(n)-1,-1,-1):
if int(n[i])%2==0:
e=n[i]
n=n[0:i]+str(a)+n[i+1::]
break
n+=e
print(n)
``` | instruction | 0 | 24,242 | 10 | 48,484 |
Yes | output | 1 | 24,242 | 10 | 48,485 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.
Reliable sources have informed the financier Anton of some information about the exchange rate of currency you all know against the burle for tomorrow. Now Anton knows that tomorrow the exchange rate will be an even number, which can be obtained from the present rate by swapping exactly two distinct digits in it. Of all the possible values that meet these conditions, the exchange rate for tomorrow will be the maximum possible. It is guaranteed that today the exchange rate is an odd positive integer n. Help Anton to determine the exchange rate of currency you all know for tomorrow!
Input
The first line contains an odd positive integer n β the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
Output
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print - 1.
Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from today's exchange rate by swapping exactly two digits. Exchange rate representation should not contain leading zeroes.
Examples
Input
527
Output
572
Input
4573
Output
3574
Input
1357997531
Output
-1
Submitted Solution:
```
x = input()
m = list(x)
m = [int(x) for x in m]
t =[]
maximum = 0
for i in range(len(m)):
if m[i]%2==0 :
t.append(i)
if(len(t)==0):
print("-1")
exit()
for i in t:
if m[-1]>m[i]:
x = m[i]
m[i] = m[-1]
m[-1] = x
break
if(m[-1]%2 is not 0):
x = m[t[-1]]
m[t[-1]] = m[-1]
m[-1] =x
z = "".join(str(x) for x in m)
print(z)
``` | instruction | 0 | 24,243 | 10 | 48,486 |
Yes | output | 1 | 24,243 | 10 | 48,487 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.
Reliable sources have informed the financier Anton of some information about the exchange rate of currency you all know against the burle for tomorrow. Now Anton knows that tomorrow the exchange rate will be an even number, which can be obtained from the present rate by swapping exactly two distinct digits in it. Of all the possible values that meet these conditions, the exchange rate for tomorrow will be the maximum possible. It is guaranteed that today the exchange rate is an odd positive integer n. Help Anton to determine the exchange rate of currency you all know for tomorrow!
Input
The first line contains an odd positive integer n β the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
Output
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print - 1.
Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from today's exchange rate by swapping exactly two digits. Exchange rate representation should not contain leading zeroes.
Examples
Input
527
Output
572
Input
4573
Output
3574
Input
1357997531
Output
-1
Submitted Solution:
```
x=list(input())
ind=-1
for i in range(len(x)):
if int(x[i]) % 2 == 0 and x[i] > x[-1]:
ind = i
break
if ind==-1:
for i in range(len(x)):
if int(x[i])% 2 == 0 and x[i] < x[-1]:
ind = i
if ind==-1:
print(-1)
else:
x[ind],x[-1]=x[-1],x[ind]
print("".join(x))
``` | instruction | 0 | 24,244 | 10 | 48,488 |
No | output | 1 | 24,244 | 10 | 48,489 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.
Reliable sources have informed the financier Anton of some information about the exchange rate of currency you all know against the burle for tomorrow. Now Anton knows that tomorrow the exchange rate will be an even number, which can be obtained from the present rate by swapping exactly two distinct digits in it. Of all the possible values that meet these conditions, the exchange rate for tomorrow will be the maximum possible. It is guaranteed that today the exchange rate is an odd positive integer n. Help Anton to determine the exchange rate of currency you all know for tomorrow!
Input
The first line contains an odd positive integer n β the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
Output
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print - 1.
Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from today's exchange rate by swapping exactly two digits. Exchange rate representation should not contain leading zeroes.
Examples
Input
527
Output
572
Input
4573
Output
3574
Input
1357997531
Output
-1
Submitted Solution:
```
def swap(a,b):
a,b=b,a
return a,b
n=(input())
list_n=list(n)
last=int(n[-1])
even=[]
for i in list_n:
if int(i)%2==0:
even.append(int(i))
if len(even)!=0:
mini=min(even)
flag=1
else:
flag=0
print(-1)
exit()
final=""
for i in range(len(list_n)-2,-1,-1):
if flag==1:
if int(list_n[i])==mini:
list_n[i],list_n[-1]=list_n[-1],list_n[i]
break
# print(list_n)
if flag:
for i in list_n:
final=final+i
print(final)
``` | instruction | 0 | 24,245 | 10 | 48,490 |
No | output | 1 | 24,245 | 10 | 48,491 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.
Reliable sources have informed the financier Anton of some information about the exchange rate of currency you all know against the burle for tomorrow. Now Anton knows that tomorrow the exchange rate will be an even number, which can be obtained from the present rate by swapping exactly two distinct digits in it. Of all the possible values that meet these conditions, the exchange rate for tomorrow will be the maximum possible. It is guaranteed that today the exchange rate is an odd positive integer n. Help Anton to determine the exchange rate of currency you all know for tomorrow!
Input
The first line contains an odd positive integer n β the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
Output
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print - 1.
Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from today's exchange rate by swapping exactly two digits. Exchange rate representation should not contain leading zeroes.
Examples
Input
527
Output
572
Input
4573
Output
3574
Input
1357997531
Output
-1
Submitted Solution:
```
a=input()
x=[]
evens='02468'
check=True
if int(a[-1])>=int(a[0]):
for i in range(len(a)):
if a[i] in evens:
print(a[:i]+a[-1]+a[i+1:-1]+a[i])
check=False
break
else:
for i in range(len(a)-1,-1,-1):
if a[i] in evens:
print(a[:i]+a[-1]+a[i+1:-1]+a[i])
check=False
break
if check:
print(-1)
``` | instruction | 0 | 24,246 | 10 | 48,492 |
No | output | 1 | 24,246 | 10 | 48,493 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.
Reliable sources have informed the financier Anton of some information about the exchange rate of currency you all know against the burle for tomorrow. Now Anton knows that tomorrow the exchange rate will be an even number, which can be obtained from the present rate by swapping exactly two distinct digits in it. Of all the possible values that meet these conditions, the exchange rate for tomorrow will be the maximum possible. It is guaranteed that today the exchange rate is an odd positive integer n. Help Anton to determine the exchange rate of currency you all know for tomorrow!
Input
The first line contains an odd positive integer n β the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
Output
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print - 1.
Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from today's exchange rate by swapping exactly two digits. Exchange rate representation should not contain leading zeroes.
Examples
Input
527
Output
572
Input
4573
Output
3574
Input
1357997531
Output
-1
Submitted Solution:
```
n=input()
l=list(n)
even=['0','2','4','6','8']
c=0
yes=None
present=0
for i in even:
if i in l:
yes=i
present+=1
else:c+=1
if c==5:
print(-1)
exit()
if present==1:
for i in range(len(l)):
if l[i] == yes:
temp=l[i]
l[i]=l[-1]
l[-1]=temp
print("".join(l))
exit()
b=len(l)-1
last=None
for i in range(len(l)-1):
if int(l[i])%2==0 and int(l[i])<int(l[-1]):
temp=l[i]
l[i]=l[-1]
l[-1]=temp
print("".join(l))
exit()
if int(l[i])%2==0:
last=i
temp=l[last]
l[last]=l[-1]
l[-1]=temp
print("".join(l))
``` | instruction | 0 | 24,247 | 10 | 48,494 |
No | output | 1 | 24,247 | 10 | 48,495 |
Provide a correct Python 3 solution for this coding contest problem.
Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 β€ n β€ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | instruction | 0 | 25,469 | 10 | 50,938 |
"Correct Solution:
```
import math
N = int(input())
A = 100000
for _ in range(N):
A = A * 1.05
A = (int(math.ceil(A / 1000))) * 1000
print(A)
``` | output | 1 | 25,469 | 10 | 50,939 |
Provide a correct Python 3 solution for this coding contest problem.
Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 β€ n β€ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | instruction | 0 | 25,470 | 10 | 50,940 |
"Correct Solution:
```
import math
a = 100
b = int(input())
for _ in range(b):
a = math.ceil(a * 1.05)
a *= 1000
print(a)
``` | output | 1 | 25,470 | 10 | 50,941 |
Provide a correct Python 3 solution for this coding contest problem.
Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 β€ n β€ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | instruction | 0 | 25,471 | 10 | 50,942 |
"Correct Solution:
```
n = int(input())
S = 100000
for i in range(n) :
S *= 1.05
if S % 1000!= 0 :
S = (int(S/1000)+1)*1000
print(S)
``` | output | 1 | 25,471 | 10 | 50,943 |
Provide a correct Python 3 solution for this coding contest problem.
Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 β€ n β€ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | instruction | 0 | 25,472 | 10 | 50,944 |
"Correct Solution:
```
n=int(input())
a=100000
while n!=0:
a=a*1.05
if a%1000!=0:
a=a-(a%1000)+1000
n=n-1
print(int (a))
``` | output | 1 | 25,472 | 10 | 50,945 |
Provide a correct Python 3 solution for this coding contest problem.
Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 β€ n β€ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | instruction | 0 | 25,473 | 10 | 50,946 |
"Correct Solution:
```
import math
j = 100
for _ in range(int(input())):
j = math.ceil(j * 1.05)
print(j * 1000)
``` | output | 1 | 25,473 | 10 | 50,947 |
Provide a correct Python 3 solution for this coding contest problem.
Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 β€ n β€ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | instruction | 0 | 25,474 | 10 | 50,948 |
"Correct Solution:
```
n = int(input())
Mo = 100000
for i in range(n):
Mo = Mo * 1.05
if Mo%1000 != 0:
Mo = (int(Mo/1000) + 1)*1000
print(int(Mo))
``` | output | 1 | 25,474 | 10 | 50,949 |
Provide a correct Python 3 solution for this coding contest problem.
Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 β€ n β€ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | instruction | 0 | 25,475 | 10 | 50,950 |
"Correct Solution:
```
a=100000
n=int(input())
for i in range(n):
a=a*1.05
if a%1000 !=0:
a=a-(a%1000)+1000
print(int(a))
``` | output | 1 | 25,475 | 10 | 50,951 |
Provide a correct Python 3 solution for this coding contest problem.
Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 β€ n β€ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | instruction | 0 | 25,476 | 10 | 50,952 |
"Correct Solution:
```
n = 100000
for i in range(int(input())):
n *= 1.05;
if n % 1000:
n += 1000
n = int(n / 1000) * 1000
print(n)
``` | output | 1 | 25,476 | 10 | 50,953 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 β€ n β€ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000
Submitted Solution:
```
s = 100000
for i in range(int(input())):
s *= 1.05
if s % 1000:
s = s - (s % 1000) + 1000
print(int(s))
``` | instruction | 0 | 25,477 | 10 | 50,954 |
Yes | output | 1 | 25,477 | 10 | 50,955 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 β€ n β€ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000
Submitted Solution:
```
n=int(input())
i=1
s=100000//1000
import math
while i <= n:
i+=1
s = s*1.05
s = math.ceil(s)
print(s*1000)
``` | instruction | 0 | 25,478 | 10 | 50,956 |
Yes | output | 1 | 25,478 | 10 | 50,957 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 β€ n β€ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000
Submitted Solution:
```
n = int(input())
amount = 100000
for i in range(n):
amount = int(-(-amount * 1.05 // 1000) * 1000)
print(amount)
``` | instruction | 0 | 25,479 | 10 | 50,958 |
Yes | output | 1 | 25,479 | 10 | 50,959 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 β€ n β€ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000
Submitted Solution:
```
import math
weeks = int(input())
money = 100
for i in range(0, weeks):
money = math.ceil(money * 1.05)
print(money * 1000)
``` | instruction | 0 | 25,480 | 10 | 50,960 |
Yes | output | 1 | 25,480 | 10 | 50,961 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 β€ n β€ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000
Submitted Solution:
```
import math
week = int(input())
debt = 100000
for i in range(week):
debt = math.ceil(debt*1.05/1000)*1000
print(int(debt))
print(int(debt))
``` | instruction | 0 | 25,481 | 10 | 50,962 |
No | output | 1 | 25,481 | 10 | 50,963 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 β€ n β€ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000
Submitted Solution:
```
import math
n=int(input())
s=100000
for i in range(n):
s +=(s*0.05)
s=s/10000
s=math.ceil(s)*10
print(str(s)+"000")
``` | instruction | 0 | 25,482 | 10 | 50,964 |
No | output | 1 | 25,482 | 10 | 50,965 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 β€ n β€ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000
Submitted Solution:
```
n = int(input())
DEBT = 100000
for interest in range(n):
DEBT = DEBT * 1.05
ROUND = DEBT % 1000
if ROUND != 0:
DEBT = (DEBT // 1000 + 1) * 1000
print(int(DEBT)
``` | instruction | 0 | 25,483 | 10 | 50,966 |
No | output | 1 | 25,483 | 10 | 50,967 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 β€ n β€ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000
Submitted Solution:
```
import math
r = 100
n = input()
for i in range(n):
r = math.ceil(r * 1.05)
print(r * 1000)
``` | instruction | 0 | 25,484 | 10 | 50,968 |
No | output | 1 | 25,484 | 10 | 50,969 |
Provide a correct Python 3 solution for this coding contest problem.
Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Koboushi". There are four types of tickets:
S seat 6000 yen
A seat 4000 yen
B seat 3000 yen
C seat 2000 yen
You, the sales manager, are excitedly waiting for the launch. Finally on sale. It's selling very well!
Shortly after the launch, I received a table summarizing the orders up to that point. Each row of the table shows the type and number of tickets sold so far. However, the ticket types do not always appear in the order of S, A, B, C. Create a program to find the sales amount for each row in this table.
input
Input data is given in the following format.
t1 n1
t2 n2
t3 n3
t4 n4
The input consists of 4 lines. Line i is given the integer ti (1 β€ ti β€ 4) for the ticket type and the integer ni (0 β€ ni β€ 10000) for the number of tickets. The integers 1, 2, 3, and 4 representing the ticket types represent S seats, A seats, B seats, and C seats, respectively. Numbers from 1 to 4 always appear once as values ββfor t1, t2, t3, and t4, but they are not always given in the order of 1, 2, 3, 4.
output
Output the sales amount for each line.
Example
Input
3 10
1 4
4 1
2 5
Output
30000
24000
2000
20000 | instruction | 0 | 25,501 | 10 | 51,002 |
"Correct Solution:
```
i=1
while i<5:
t_i,n_i=map(int,input().split())
if t_i==1:a=n_i*6000
if t_i==2:a=n_i*4000
if t_i==3:a=n_i*3000
if t_i==4:a=n_i*2000
print(a)
i=i+1
``` | output | 1 | 25,501 | 10 | 51,003 |
Provide a correct Python 3 solution for this coding contest problem.
Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Koboushi". There are four types of tickets:
S seat 6000 yen
A seat 4000 yen
B seat 3000 yen
C seat 2000 yen
You, the sales manager, are excitedly waiting for the launch. Finally on sale. It's selling very well!
Shortly after the launch, I received a table summarizing the orders up to that point. Each row of the table shows the type and number of tickets sold so far. However, the ticket types do not always appear in the order of S, A, B, C. Create a program to find the sales amount for each row in this table.
input
Input data is given in the following format.
t1 n1
t2 n2
t3 n3
t4 n4
The input consists of 4 lines. Line i is given the integer ti (1 β€ ti β€ 4) for the ticket type and the integer ni (0 β€ ni β€ 10000) for the number of tickets. The integers 1, 2, 3, and 4 representing the ticket types represent S seats, A seats, B seats, and C seats, respectively. Numbers from 1 to 4 always appear once as values ββfor t1, t2, t3, and t4, but they are not always given in the order of 1, 2, 3, 4.
output
Output the sales amount for each line.
Example
Input
3 10
1 4
4 1
2 5
Output
30000
24000
2000
20000 | instruction | 0 | 25,502 | 10 | 51,004 |
"Correct Solution:
```
dic={1:6000,2:4000,3:3000,4:2000}
for i in range(4):
t,n=map(int,input().split())
print(dic[t]*n)
``` | output | 1 | 25,502 | 10 | 51,005 |
Provide a correct Python 3 solution for this coding contest problem.
Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Koboushi". There are four types of tickets:
S seat 6000 yen
A seat 4000 yen
B seat 3000 yen
C seat 2000 yen
You, the sales manager, are excitedly waiting for the launch. Finally on sale. It's selling very well!
Shortly after the launch, I received a table summarizing the orders up to that point. Each row of the table shows the type and number of tickets sold so far. However, the ticket types do not always appear in the order of S, A, B, C. Create a program to find the sales amount for each row in this table.
input
Input data is given in the following format.
t1 n1
t2 n2
t3 n3
t4 n4
The input consists of 4 lines. Line i is given the integer ti (1 β€ ti β€ 4) for the ticket type and the integer ni (0 β€ ni β€ 10000) for the number of tickets. The integers 1, 2, 3, and 4 representing the ticket types represent S seats, A seats, B seats, and C seats, respectively. Numbers from 1 to 4 always appear once as values ββfor t1, t2, t3, and t4, but they are not always given in the order of 1, 2, 3, 4.
output
Output the sales amount for each line.
Example
Input
3 10
1 4
4 1
2 5
Output
30000
24000
2000
20000 | instruction | 0 | 25,503 | 10 | 51,006 |
"Correct Solution:
```
S=6000
A=4000
B=3000
C=2000
for k in range(4):
i,n1=map(int,input().split())
if i==1:
print(f"{S*n1}")
elif i==2:
print(f"{A*n1}")
elif i==3:
print(f"{B*n1}")
elif i==4:
print(f"{C*n1}")
``` | output | 1 | 25,503 | 10 | 51,007 |
Provide a correct Python 3 solution for this coding contest problem.
Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Koboushi". There are four types of tickets:
S seat 6000 yen
A seat 4000 yen
B seat 3000 yen
C seat 2000 yen
You, the sales manager, are excitedly waiting for the launch. Finally on sale. It's selling very well!
Shortly after the launch, I received a table summarizing the orders up to that point. Each row of the table shows the type and number of tickets sold so far. However, the ticket types do not always appear in the order of S, A, B, C. Create a program to find the sales amount for each row in this table.
input
Input data is given in the following format.
t1 n1
t2 n2
t3 n3
t4 n4
The input consists of 4 lines. Line i is given the integer ti (1 β€ ti β€ 4) for the ticket type and the integer ni (0 β€ ni β€ 10000) for the number of tickets. The integers 1, 2, 3, and 4 representing the ticket types represent S seats, A seats, B seats, and C seats, respectively. Numbers from 1 to 4 always appear once as values ββfor t1, t2, t3, and t4, but they are not always given in the order of 1, 2, 3, 4.
output
Output the sales amount for each line.
Example
Input
3 10
1 4
4 1
2 5
Output
30000
24000
2000
20000 | instruction | 0 | 25,504 | 10 | 51,008 |
"Correct Solution:
```
for i in range(4):
t,n = map(int,input().split())
if t==1:
kingaku=6000
elif t==2:
kingaku=4000
elif t==3:
kingaku=3000
elif t==4:
kingaku=2000
print(n*kingaku)
``` | output | 1 | 25,504 | 10 | 51,009 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.