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 |
|---|---|---|---|---|---|
Provide a correct Python 3 solution for this coding contest problem.
On the Internet shopping site, on the same page as the product that the user is currently viewing, some other products that other users have bought in the past along with the product that they are currently viewing are displayed. It is believed that sales can be increased by presenting products that are considered to be highly relevant.
Similar things can be seen in local supermarkets (such as bread and jam) as a way to place items that are often bought together nearby. Your job is to write a program that will help you devise product placement. This time, I would like to set a certain standard number of times and find a combination of two products for which the number of times bought together is equal to or greater than the standard number of times.
When given the information of the products bought together and the standard number of times, create a program that outputs the combination of the two products bought together more than the standard number of times.
Input
The input is given in the following format.
N F
info1
info2
::
infoN
The first line gives the number of pieces of information N (1 ≤ N ≤ 100) and the reference number F (1 ≤ F ≤ 100) of the items bought together. The following N lines are given information on the products bought together. Information about the products bought together infoi is given in the following format.
M item1 item2 ... itemM
M (1 ≤ M ≤ 10) indicates how many products this information contains. itemj is the name of the item bought in this purchase and is a string of 1 to 30 length consisting of only lowercase letters. The same product is never given in infoi.
Output
The number of combinations of two products bought together more than the reference number of times is output on the first line, and all combinations are output on the second and subsequent lines. However, if there is no combination, nothing is output after the second line.
The output order is as follows after arranging the product names in the combination in the lexicographic order (the order in which the words are arranged in the English-Japanese dictionary).
* Compare the first product names, and the one with the earliest in lexicographic order comes first.
* If they are the same, compare the second product names and the lexicographic order comes first.
Separate product names with a single space, and separate product combinations with a single line break.
Examples
Input
5 2
3 bread milk banana
2 milk cornflakes
3 potato bread milk
4 cornflakes bread milk butter
2 potato bread
Output
3
bread milk
bread potato
cornflakes milk
Input
5 5
3 bread milk banana
2 milk cornflakes
3 potato bread milk
4 cornflakes bread milk butter
2 potato bread
Output
0 | instruction | 0 | 65,551 | 10 | 131,102 |
"Correct Solution:
```
import sys
l = input().split()
f = int(l[1])
t = {}
for l in sys.stdin:
e = l.split()
m = int(e.pop(0))
s = sorted(e)
for i in range(m):
for j in range(i+1,m):
k = (s[i],s[j])
if k in t:
t[k] += 1
else:
t[k] = 1
f = list(sorted(filter(lambda x: t[x] >= f, t)))
print(len(f))
for e in f:
print("{0:s} {1:s}".format(e[0],e[1]))
``` | output | 1 | 65,551 | 10 | 131,103 |
Provide a correct Python 3 solution for this coding contest problem.
On the Internet shopping site, on the same page as the product that the user is currently viewing, some other products that other users have bought in the past along with the product that they are currently viewing are displayed. It is believed that sales can be increased by presenting products that are considered to be highly relevant.
Similar things can be seen in local supermarkets (such as bread and jam) as a way to place items that are often bought together nearby. Your job is to write a program that will help you devise product placement. This time, I would like to set a certain standard number of times and find a combination of two products for which the number of times bought together is equal to or greater than the standard number of times.
When given the information of the products bought together and the standard number of times, create a program that outputs the combination of the two products bought together more than the standard number of times.
Input
The input is given in the following format.
N F
info1
info2
::
infoN
The first line gives the number of pieces of information N (1 ≤ N ≤ 100) and the reference number F (1 ≤ F ≤ 100) of the items bought together. The following N lines are given information on the products bought together. Information about the products bought together infoi is given in the following format.
M item1 item2 ... itemM
M (1 ≤ M ≤ 10) indicates how many products this information contains. itemj is the name of the item bought in this purchase and is a string of 1 to 30 length consisting of only lowercase letters. The same product is never given in infoi.
Output
The number of combinations of two products bought together more than the reference number of times is output on the first line, and all combinations are output on the second and subsequent lines. However, if there is no combination, nothing is output after the second line.
The output order is as follows after arranging the product names in the combination in the lexicographic order (the order in which the words are arranged in the English-Japanese dictionary).
* Compare the first product names, and the one with the earliest in lexicographic order comes first.
* If they are the same, compare the second product names and the lexicographic order comes first.
Separate product names with a single space, and separate product combinations with a single line break.
Examples
Input
5 2
3 bread milk banana
2 milk cornflakes
3 potato bread milk
4 cornflakes bread milk butter
2 potato bread
Output
3
bread milk
bread potato
cornflakes milk
Input
5 5
3 bread milk banana
2 milk cornflakes
3 potato bread milk
4 cornflakes bread milk butter
2 potato bread
Output
0 | instruction | 0 | 65,552 | 10 | 131,104 |
"Correct Solution:
```
n, f = map(int, input().split())
pair = {}
for i in range(n):
m, *items = input().split()
m = int(m)
for p in range(m):
for q in range(p):
key = tuple(sorted([items[p], items[q]]))
pair[key] = pair.get(key, 0) + 1
ans = sorted(key for key in pair if pair[key] >= f)
print(len(ans))
if ans:
for a, b in ans:
print(a, b)
``` | output | 1 | 65,552 | 10 | 131,105 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
On the Internet shopping site, on the same page as the product that the user is currently viewing, some other products that other users have bought in the past along with the product that they are currently viewing are displayed. It is believed that sales can be increased by presenting products that are considered to be highly relevant.
Similar things can be seen in local supermarkets (such as bread and jam) as a way to place items that are often bought together nearby. Your job is to write a program that will help you devise product placement. This time, I would like to set a certain standard number of times and find a combination of two products for which the number of times bought together is equal to or greater than the standard number of times.
When given the information of the products bought together and the standard number of times, create a program that outputs the combination of the two products bought together more than the standard number of times.
Input
The input is given in the following format.
N F
info1
info2
::
infoN
The first line gives the number of pieces of information N (1 ≤ N ≤ 100) and the reference number F (1 ≤ F ≤ 100) of the items bought together. The following N lines are given information on the products bought together. Information about the products bought together infoi is given in the following format.
M item1 item2 ... itemM
M (1 ≤ M ≤ 10) indicates how many products this information contains. itemj is the name of the item bought in this purchase and is a string of 1 to 30 length consisting of only lowercase letters. The same product is never given in infoi.
Output
The number of combinations of two products bought together more than the reference number of times is output on the first line, and all combinations are output on the second and subsequent lines. However, if there is no combination, nothing is output after the second line.
The output order is as follows after arranging the product names in the combination in the lexicographic order (the order in which the words are arranged in the English-Japanese dictionary).
* Compare the first product names, and the one with the earliest in lexicographic order comes first.
* If they are the same, compare the second product names and the lexicographic order comes first.
Separate product names with a single space, and separate product combinations with a single line break.
Examples
Input
5 2
3 bread milk banana
2 milk cornflakes
3 potato bread milk
4 cornflakes bread milk butter
2 potato bread
Output
3
bread milk
bread potato
cornflakes milk
Input
5 5
3 bread milk banana
2 milk cornflakes
3 potato bread milk
4 cornflakes bread milk butter
2 potato bread
Output
0
Submitted Solution:
```
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy
BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
MOD = 1000000007
EPS = 0.000000001
#sys.setrecursionlimit(3**12)
class Info:
def __init__(self,arg_item_A,arg_item_B):
self.item_A = arg_item_A
self.item_B = arg_item_B
if self.item_B < self.item_A:
self.item_A,self.item_B = self.item_B,self.item_A
def __lt__(self,another):
if self.item_A != another.item_A:
return self.item_A < another.item_A
else:
return self.item_B < another.item_B
SIZE = 1000
N,F = map(int,input().split())
num_item = 0
ITEM = {}
rev_ITEM = {}
table = [[0]*SIZE for _ in range(SIZE)]
for _ in range(N):
M,*input_str = map(str,input().split())
M = int(M)
for i in range(M):
if input_str[i] not in ITEM:
ITEM[input_str[i]] = num_item
rev_ITEM[num_item] = input_str[i]
num_item += 1
for i in range(M-1):
for k in range(i+1,M):
table[ITEM[input_str[i]]][ITEM[input_str[k]]] += 1
table[ITEM[input_str[k]]][ITEM[input_str[i]]] += 1
ANS = []
for i in range(num_item-1):
for k in range(i+1,num_item):
if table[i][k] >= F:
ANS.append(Info(rev_ITEM[i],rev_ITEM[k]))
print("%d"%(len(ANS)))
ANS.sort()
for i in range(len(ANS)):
print("%s %s"%(ANS[i].item_A,ANS[i].item_B))
``` | instruction | 0 | 65,553 | 10 | 131,106 |
Yes | output | 1 | 65,553 | 10 | 131,107 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
On the Internet shopping site, on the same page as the product that the user is currently viewing, some other products that other users have bought in the past along with the product that they are currently viewing are displayed. It is believed that sales can be increased by presenting products that are considered to be highly relevant.
Similar things can be seen in local supermarkets (such as bread and jam) as a way to place items that are often bought together nearby. Your job is to write a program that will help you devise product placement. This time, I would like to set a certain standard number of times and find a combination of two products for which the number of times bought together is equal to or greater than the standard number of times.
When given the information of the products bought together and the standard number of times, create a program that outputs the combination of the two products bought together more than the standard number of times.
Input
The input is given in the following format.
N F
info1
info2
::
infoN
The first line gives the number of pieces of information N (1 ≤ N ≤ 100) and the reference number F (1 ≤ F ≤ 100) of the items bought together. The following N lines are given information on the products bought together. Information about the products bought together infoi is given in the following format.
M item1 item2 ... itemM
M (1 ≤ M ≤ 10) indicates how many products this information contains. itemj is the name of the item bought in this purchase and is a string of 1 to 30 length consisting of only lowercase letters. The same product is never given in infoi.
Output
The number of combinations of two products bought together more than the reference number of times is output on the first line, and all combinations are output on the second and subsequent lines. However, if there is no combination, nothing is output after the second line.
The output order is as follows after arranging the product names in the combination in the lexicographic order (the order in which the words are arranged in the English-Japanese dictionary).
* Compare the first product names, and the one with the earliest in lexicographic order comes first.
* If they are the same, compare the second product names and the lexicographic order comes first.
Separate product names with a single space, and separate product combinations with a single line break.
Examples
Input
5 2
3 bread milk banana
2 milk cornflakes
3 potato bread milk
4 cornflakes bread milk butter
2 potato bread
Output
3
bread milk
bread potato
cornflakes milk
Input
5 5
3 bread milk banana
2 milk cornflakes
3 potato bread milk
4 cornflakes bread milk butter
2 potato bread
Output
0
Submitted Solution:
```
N,F = [int(i) for i in input().split()]
itemsets = []
for l in range(N):
items = input().split()
M = int(items.pop(0))
items.sort()
for i in range(len(items)):
for j in range(i+1, len(items)):
itemsets.append(items[i] + " " + items[j])
itemsets.sort()
cnt = 1
ans = []
ans.append("")
for i in range(1, len(itemsets)):
if itemsets[i] == itemsets[i-1]:
cnt = cnt + 1
if cnt >= F and itemsets[i] != ans[-1]:
ans.append(itemsets[i])
else:
cnt = 1
if F == 1:
ans.append(itemsets[i])
ans.pop(0)
print(len(ans))
for i in range(len(ans)):
print(ans[i])
``` | instruction | 0 | 65,554 | 10 | 131,108 |
No | output | 1 | 65,554 | 10 | 131,109 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
On the Internet shopping site, on the same page as the product that the user is currently viewing, some other products that other users have bought in the past along with the product that they are currently viewing are displayed. It is believed that sales can be increased by presenting products that are considered to be highly relevant.
Similar things can be seen in local supermarkets (such as bread and jam) as a way to place items that are often bought together nearby. Your job is to write a program that will help you devise product placement. This time, I would like to set a certain standard number of times and find a combination of two products for which the number of times bought together is equal to or greater than the standard number of times.
When given the information of the products bought together and the standard number of times, create a program that outputs the combination of the two products bought together more than the standard number of times.
Input
The input is given in the following format.
N F
info1
info2
::
infoN
The first line gives the number of pieces of information N (1 ≤ N ≤ 100) and the reference number F (1 ≤ F ≤ 100) of the items bought together. The following N lines are given information on the products bought together. Information about the products bought together infoi is given in the following format.
M item1 item2 ... itemM
M (1 ≤ M ≤ 10) indicates how many products this information contains. itemj is the name of the item bought in this purchase and is a string of 1 to 30 length consisting of only lowercase letters. The same product is never given in infoi.
Output
The number of combinations of two products bought together more than the reference number of times is output on the first line, and all combinations are output on the second and subsequent lines. However, if there is no combination, nothing is output after the second line.
The output order is as follows after arranging the product names in the combination in the lexicographic order (the order in which the words are arranged in the English-Japanese dictionary).
* Compare the first product names, and the one with the earliest in lexicographic order comes first.
* If they are the same, compare the second product names and the lexicographic order comes first.
Separate product names with a single space, and separate product combinations with a single line break.
Examples
Input
5 2
3 bread milk banana
2 milk cornflakes
3 potato bread milk
4 cornflakes bread milk butter
2 potato bread
Output
3
bread milk
bread potato
cornflakes milk
Input
5 5
3 bread milk banana
2 milk cornflakes
3 potato bread milk
4 cornflakes bread milk butter
2 potato bread
Output
0
Submitted Solution:
```
from collections import Counter
counter = Counter()
n, f = map(int, input().split())
for _ in range(n):
items = input().split()
m = int(items[0])
items = items[1:]
items.sort()
for i in range(m):
for j in range(i + 1, m):
counter[(items[i], items[j])] += 1
lst = [(k, v) for k, v in counter.most_common() if v >= f]
lst.sort()
lst.sort(key=lambda t:-t[1])
print(len(lst))
for k, v in lst:
print(*k)
``` | instruction | 0 | 65,555 | 10 | 131,110 |
No | output | 1 | 65,555 | 10 | 131,111 |
Provide a correct Python 3 solution for this coding contest problem.
You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.
Write a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .
Constraints
* $2 \leq n \leq 200,000$
* $1 \leq R_t \leq 10^9$
Input
The first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t = 0, 1, 2, ... n-1$) are given in order.
Output
Print the maximum value in a line.
Examples
Input
6
5
3
1
3
4
3
Output
3
Input
3
4
3
2
Output
-1 | instruction | 0 | 65,578 | 10 | 131,156 |
"Correct Solution:
```
import math
n = int(input())
maxv = -10**12
minv = int(input())
for i in range(1,n):
r = int(input())
maxv = max(maxv,r - minv)
minv = min(minv,r)
print(maxv)
``` | output | 1 | 65,578 | 10 | 131,157 |
Provide a correct Python 3 solution for this coding contest problem.
You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.
Write a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .
Constraints
* $2 \leq n \leq 200,000$
* $1 \leq R_t \leq 10^9$
Input
The first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t = 0, 1, 2, ... n-1$) are given in order.
Output
Print the maximum value in a line.
Examples
Input
6
5
3
1
3
4
3
Output
3
Input
3
4
3
2
Output
-1 | instruction | 0 | 65,579 | 10 | 131,158 |
"Correct Solution:
```
N = int(input())
k = 0
ans = -(10**10)
for i in range(N):
R = int(input())
if i==0:k=R;continue
ans = max(ans,R-k)
k = min(k,R)
print(ans)
``` | output | 1 | 65,579 | 10 | 131,159 |
Provide a correct Python 3 solution for this coding contest problem.
You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.
Write a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .
Constraints
* $2 \leq n \leq 200,000$
* $1 \leq R_t \leq 10^9$
Input
The first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t = 0, 1, 2, ... n-1$) are given in order.
Output
Print the maximum value in a line.
Examples
Input
6
5
3
1
3
4
3
Output
3
Input
3
4
3
2
Output
-1 | instruction | 0 | 65,580 | 10 | 131,160 |
"Correct Solution:
```
N = int(input())
R = [int(input()) for _ in range(N) ]
maxv = -2000000000
minv = R[0]
for r in R[1:]:
maxv = max(maxv, r - minv)
minv = min(minv, r)
print(maxv)
``` | output | 1 | 65,580 | 10 | 131,161 |
Provide a correct Python 3 solution for this coding contest problem.
You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.
Write a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .
Constraints
* $2 \leq n \leq 200,000$
* $1 \leq R_t \leq 10^9$
Input
The first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t = 0, 1, 2, ... n-1$) are given in order.
Output
Print the maximum value in a line.
Examples
Input
6
5
3
1
3
4
3
Output
3
Input
3
4
3
2
Output
-1 | instruction | 0 | 65,581 | 10 | 131,162 |
"Correct Solution:
```
n, Pmax, Rmin = int(input()), float('-inf'), float('inf')
for i in range(n):
v = int(input())
Pmax, Rmin = max(Pmax, v-Rmin), min(Rmin, v)
print(Pmax)
``` | output | 1 | 65,581 | 10 | 131,163 |
Provide a correct Python 3 solution for this coding contest problem.
You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.
Write a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .
Constraints
* $2 \leq n \leq 200,000$
* $1 \leq R_t \leq 10^9$
Input
The first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t = 0, 1, 2, ... n-1$) are given in order.
Output
Print the maximum value in a line.
Examples
Input
6
5
3
1
3
4
3
Output
3
Input
3
4
3
2
Output
-1 | instruction | 0 | 65,582 | 10 | 131,164 |
"Correct Solution:
```
n=int(input())
minv=int(input())
maxv=-float('inf')
for _ in range(n-1):
tmp=int(input())
maxv=max(maxv,tmp-minv)
minv=min(minv,tmp)
print(maxv)
``` | output | 1 | 65,582 | 10 | 131,165 |
Provide a correct Python 3 solution for this coding contest problem.
You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.
Write a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .
Constraints
* $2 \leq n \leq 200,000$
* $1 \leq R_t \leq 10^9$
Input
The first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t = 0, 1, 2, ... n-1$) are given in order.
Output
Print the maximum value in a line.
Examples
Input
6
5
3
1
3
4
3
Output
3
Input
3
4
3
2
Output
-1 | instruction | 0 | 65,583 | 10 | 131,166 |
"Correct Solution:
```
n = int(input())
r = [int(input()) for _ in range(n)]
ans = -float("inf")
m = r[0]
for i in range(1,n):
d = r[i]-m
ans = max(d,ans)
m = min(m,r[i])
print(ans)
``` | output | 1 | 65,583 | 10 | 131,167 |
Provide a correct Python 3 solution for this coding contest problem.
You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.
Write a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .
Constraints
* $2 \leq n \leq 200,000$
* $1 \leq R_t \leq 10^9$
Input
The first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t = 0, 1, 2, ... n-1$) are given in order.
Output
Print the maximum value in a line.
Examples
Input
6
5
3
1
3
4
3
Output
3
Input
3
4
3
2
Output
-1 | instruction | 0 | 65,584 | 10 | 131,168 |
"Correct Solution:
```
n = int(input())
rli = [int(input()) for i in range(n)]
mi = 10**10
ans = -(10**10)
for r in rli:
ans = max(ans, r - mi)
if r < mi:
mi = r
print(ans)
``` | output | 1 | 65,584 | 10 | 131,169 |
Provide a correct Python 3 solution for this coding contest problem.
You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.
Write a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .
Constraints
* $2 \leq n \leq 200,000$
* $1 \leq R_t \leq 10^9$
Input
The first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t = 0, 1, 2, ... n-1$) are given in order.
Output
Print the maximum value in a line.
Examples
Input
6
5
3
1
3
4
3
Output
3
Input
3
4
3
2
Output
-1 | instruction | 0 | 65,585 | 10 | 131,170 |
"Correct Solution:
```
n = int(input())
l = list(int(input()) for _ in range(n))
ma = -10**9
mi = l[0]
for j in range(1,n):
ma = max(ma,l[j]-mi)
mi = min(mi,l[j])
print(ma)
``` | output | 1 | 65,585 | 10 | 131,171 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.
Write a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .
Constraints
* $2 \leq n \leq 200,000$
* $1 \leq R_t \leq 10^9$
Input
The first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t = 0, 1, 2, ... n-1$) are given in order.
Output
Print the maximum value in a line.
Examples
Input
6
5
3
1
3
4
3
Output
3
Input
3
4
3
2
Output
-1
Submitted Solution:
```
N=int(input())
A=[int(input()) for _ in range(N)]
mp=A[1]-A[0]
mn=A[0]
for i in range(1,N):
if mp < (A[i]-mn):
mp=A[i]-mn
if A[i]<mn:
mn=A[i]
print(mp)
``` | instruction | 0 | 65,586 | 10 | 131,172 |
Yes | output | 1 | 65,586 | 10 | 131,173 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.
Write a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .
Constraints
* $2 \leq n \leq 200,000$
* $1 \leq R_t \leq 10^9$
Input
The first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t = 0, 1, 2, ... n-1$) are given in order.
Output
Print the maximum value in a line.
Examples
Input
6
5
3
1
3
4
3
Output
3
Input
3
4
3
2
Output
-1
Submitted Solution:
```
n = int(input())
R = (int(input()) for _ in range(n))
ret = -(10 ** 9)
mn = next(R)
for r in R:
ret = max(ret, r - mn)
mn = min(mn, r)
print(ret)
``` | instruction | 0 | 65,587 | 10 | 131,174 |
Yes | output | 1 | 65,587 | 10 | 131,175 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.
Write a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .
Constraints
* $2 \leq n \leq 200,000$
* $1 \leq R_t \leq 10^9$
Input
The first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t = 0, 1, 2, ... n-1$) are given in order.
Output
Print the maximum value in a line.
Examples
Input
6
5
3
1
3
4
3
Output
3
Input
3
4
3
2
Output
-1
Submitted Solution:
```
n = int(input())
min_v = int(input())
ans = 1 - min_v
for i in range(1, n):
j = int(input())
ans = max(ans, j - min_v)
min_v = min(min_v, j)
print(ans)
``` | instruction | 0 | 65,588 | 10 | 131,176 |
Yes | output | 1 | 65,588 | 10 | 131,177 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.
Write a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .
Constraints
* $2 \leq n \leq 200,000$
* $1 \leq R_t \leq 10^9$
Input
The first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t = 0, 1, 2, ... n-1$) are given in order.
Output
Print the maximum value in a line.
Examples
Input
6
5
3
1
3
4
3
Output
3
Input
3
4
3
2
Output
-1
Submitted Solution:
```
n = int(input())
rmin = int(input())
d = -(10**9)
for i in range(1,n):
r = int(input())
if d < r-rmin:
d = r-rmin
if r < rmin:
rmin = r
print(d)
``` | instruction | 0 | 65,589 | 10 | 131,178 |
Yes | output | 1 | 65,589 | 10 | 131,179 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.
Write a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .
Constraints
* $2 \leq n \leq 200,000$
* $1 \leq R_t \leq 10^9$
Input
The first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t = 0, 1, 2, ... n-1$) are given in order.
Output
Print the maximum value in a line.
Examples
Input
6
5
3
1
3
4
3
Output
3
Input
3
4
3
2
Output
-1
Submitted Solution:
```
n = int(input())
before = int(input())
current = int(input())
diffMax = current - before
for i in range(n - 2):
number = int(input())
diff = number - current
diffMax = max(diff, diffMax)
current = min(current, number)
print(diffMax)
``` | instruction | 0 | 65,590 | 10 | 131,180 |
No | output | 1 | 65,590 | 10 | 131,181 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.
Write a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .
Constraints
* $2 \leq n \leq 200,000$
* $1 \leq R_t \leq 10^9$
Input
The first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t = 0, 1, 2, ... n-1$) are given in order.
Output
Print the maximum value in a line.
Examples
Input
6
5
3
1
3
4
3
Output
3
Input
3
4
3
2
Output
-1
Submitted Solution:
```
n=int(input())
tmp=0
s=int(input())
for int i in range(n-1):
t=int(input())
if t<s && t-s<tmp:
tmp=t-s
s=t
print(tmp)
``` | instruction | 0 | 65,591 | 10 | 131,182 |
No | output | 1 | 65,591 | 10 | 131,183 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.
Write a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .
Constraints
* $2 \leq n \leq 200,000$
* $1 \leq R_t \leq 10^9$
Input
The first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t = 0, 1, 2, ... n-1$) are given in order.
Output
Print the maximum value in a line.
Examples
Input
6
5
3
1
3
4
3
Output
3
Input
3
4
3
2
Output
-1
Submitted Solution:
```
n=int(input())
min=10**9
max_num=1
max_dif=-1*(10**9)
for i in range(n):
x=int(input())
if x>max_num:
max_num = x
if max_dif < max_num-min:
max_dif = max_num-min
if x<min:
min = x
max_num=1
print(max_dif)
``` | instruction | 0 | 65,592 | 10 | 131,184 |
No | output | 1 | 65,592 | 10 | 131,185 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.
Write a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .
Constraints
* $2 \leq n \leq 200,000$
* $1 \leq R_t \leq 10^9$
Input
The first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t = 0, 1, 2, ... n-1$) are given in order.
Output
Print the maximum value in a line.
Examples
Input
6
5
3
1
3
4
3
Output
3
Input
3
4
3
2
Output
-1
Submitted Solution:
```
n=int(input())
m=int(input())
for i in range(n-1):
x=int(input())
d=max(x-m,d)
m=min(m,x)
print(d)
``` | instruction | 0 | 65,593 | 10 | 131,186 |
No | output | 1 | 65,593 | 10 | 131,187 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya, like many others, likes to participate in a variety of sweepstakes and lotteries. Now he collects wrappings from a famous chocolate bar "Jupiter". According to the sweepstake rules, each wrapping has an integer written on it — the number of points that the participant adds to his score as he buys the bar. After a participant earns a certain number of points, he can come to the prize distribution center and exchange the points for prizes. When somebody takes a prize, the prize's cost is simply subtracted from the number of his points.
Vasya didn't only bought the bars, he also kept a record of how many points each wrapping cost. Also, he remembers that he always stucks to the greedy strategy — as soon as he could take at least one prize, he went to the prize distribution centre and exchanged the points for prizes. Moreover, if he could choose between multiple prizes, he chose the most expensive one. If after an exchange Vasya had enough points left to get at least one more prize, then he continued to exchange points.
The sweepstake has the following prizes (the prizes are sorted by increasing of their cost):
* a mug (costs a points),
* a towel (costs b points),
* a bag (costs c points),
* a bicycle (costs d points),
* a car (costs e points).
Now Vasya wants to recollect what prizes he has received. You know sequence p1, p2, ..., pn, where pi is the number of points Vasya got for the i-th bar. The sequence of points is given in the chronological order. You also know numbers a, b, c, d, e. Your task is to find, how many prizes Vasya received, what prizes they are and how many points he's got left after all operations are completed.
Input
The first line contains a single integer n (1 ≤ n ≤ 50) — the number of chocolate bar wrappings that brought points to Vasya. The second line contains space-separated integers p1, p2, ..., pn (1 ≤ pi ≤ 109). The third line contains 5 integers a, b, c, d, e (1 ≤ a < b < c < d < e ≤ 109) — the prizes' costs.
Output
Print on the first line 5 integers, separated by a space — the number of mugs, towels, bags, bicycles and cars that Vasya has got, respectively. On the second line print a single integer — the number of points Vasya will have left after all operations of exchange are completed.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
Examples
Input
3
3 10 4
2 4 10 15 20
Output
1 1 1 0 0
1
Input
4
10 4 39 2
3 5 10 11 12
Output
3 0 1 0 3
0
Note
In the first sample Vasya gets 3 points after eating the first chocolate bar. Then he exchanges 2 points and gets a mug. Vasya wins a bag after eating the second chocolate bar. Then he wins a towel after eating the third chocolate bar. After all chocolate bars 3 - 2 + 10 - 10 + 4 - 4 = 1 points remains. | instruction | 0 | 65,851 | 10 | 131,702 |
Tags: implementation
Correct Solution:
```
def main():
input()
m = map(int, input().split())
gifts = list(map(int, input().split())) + [10 ** 12]
s, res = 0, [0] * 5
for p in m:
s += p
while s >= gifts[0]:
for g, p in enumerate(gifts):
if s < p:
g -= 1
p = gifts[g]
x = s // p
res[g] += x
s -= x * p
break
print(*res)
print(s)
if __name__ == '__main__':
main()
``` | output | 1 | 65,851 | 10 | 131,703 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya, like many others, likes to participate in a variety of sweepstakes and lotteries. Now he collects wrappings from a famous chocolate bar "Jupiter". According to the sweepstake rules, each wrapping has an integer written on it — the number of points that the participant adds to his score as he buys the bar. After a participant earns a certain number of points, he can come to the prize distribution center and exchange the points for prizes. When somebody takes a prize, the prize's cost is simply subtracted from the number of his points.
Vasya didn't only bought the bars, he also kept a record of how many points each wrapping cost. Also, he remembers that he always stucks to the greedy strategy — as soon as he could take at least one prize, he went to the prize distribution centre and exchanged the points for prizes. Moreover, if he could choose between multiple prizes, he chose the most expensive one. If after an exchange Vasya had enough points left to get at least one more prize, then he continued to exchange points.
The sweepstake has the following prizes (the prizes are sorted by increasing of their cost):
* a mug (costs a points),
* a towel (costs b points),
* a bag (costs c points),
* a bicycle (costs d points),
* a car (costs e points).
Now Vasya wants to recollect what prizes he has received. You know sequence p1, p2, ..., pn, where pi is the number of points Vasya got for the i-th bar. The sequence of points is given in the chronological order. You also know numbers a, b, c, d, e. Your task is to find, how many prizes Vasya received, what prizes they are and how many points he's got left after all operations are completed.
Input
The first line contains a single integer n (1 ≤ n ≤ 50) — the number of chocolate bar wrappings that brought points to Vasya. The second line contains space-separated integers p1, p2, ..., pn (1 ≤ pi ≤ 109). The third line contains 5 integers a, b, c, d, e (1 ≤ a < b < c < d < e ≤ 109) — the prizes' costs.
Output
Print on the first line 5 integers, separated by a space — the number of mugs, towels, bags, bicycles and cars that Vasya has got, respectively. On the second line print a single integer — the number of points Vasya will have left after all operations of exchange are completed.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
Examples
Input
3
3 10 4
2 4 10 15 20
Output
1 1 1 0 0
1
Input
4
10 4 39 2
3 5 10 11 12
Output
3 0 1 0 3
0
Note
In the first sample Vasya gets 3 points after eating the first chocolate bar. Then he exchanges 2 points and gets a mug. Vasya wins a bag after eating the second chocolate bar. Then he wins a towel after eating the third chocolate bar. After all chocolate bars 3 - 2 + 10 - 10 + 4 - 4 = 1 points remains. | instruction | 0 | 65,852 | 10 | 131,704 |
Tags: implementation
Correct Solution:
```
def most_expensive_prize(prize_cost_list,current_sum):
for c in prize_cost_list[::-1]:
if c<=current_sum:
return c
return 0
def prize_count_list(v,prize_cost_list):
prize_count_dict={c:0 for c in prize_cost_list}
current_sum=0
for c in v:
current_sum+=c
while current_sum>=prize_cost_list[0]:
t=most_expensive_prize(prize_cost_list,current_sum)
count_of_prize=current_sum//t
current_sum-=t*count_of_prize
prize_count_dict[t]+=count_of_prize
return prize_count_dict.values(),current_sum
input()
v=[int(c) for c in input().split()]
prize_cost_list=[int(c) for c in input().split()]
lst,current_sum=prize_count_list(v,prize_cost_list)
print(*lst)
print(current_sum)
``` | output | 1 | 65,852 | 10 | 131,705 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya, like many others, likes to participate in a variety of sweepstakes and lotteries. Now he collects wrappings from a famous chocolate bar "Jupiter". According to the sweepstake rules, each wrapping has an integer written on it — the number of points that the participant adds to his score as he buys the bar. After a participant earns a certain number of points, he can come to the prize distribution center and exchange the points for prizes. When somebody takes a prize, the prize's cost is simply subtracted from the number of his points.
Vasya didn't only bought the bars, he also kept a record of how many points each wrapping cost. Also, he remembers that he always stucks to the greedy strategy — as soon as he could take at least one prize, he went to the prize distribution centre and exchanged the points for prizes. Moreover, if he could choose between multiple prizes, he chose the most expensive one. If after an exchange Vasya had enough points left to get at least one more prize, then he continued to exchange points.
The sweepstake has the following prizes (the prizes are sorted by increasing of their cost):
* a mug (costs a points),
* a towel (costs b points),
* a bag (costs c points),
* a bicycle (costs d points),
* a car (costs e points).
Now Vasya wants to recollect what prizes he has received. You know sequence p1, p2, ..., pn, where pi is the number of points Vasya got for the i-th bar. The sequence of points is given in the chronological order. You also know numbers a, b, c, d, e. Your task is to find, how many prizes Vasya received, what prizes they are and how many points he's got left after all operations are completed.
Input
The first line contains a single integer n (1 ≤ n ≤ 50) — the number of chocolate bar wrappings that brought points to Vasya. The second line contains space-separated integers p1, p2, ..., pn (1 ≤ pi ≤ 109). The third line contains 5 integers a, b, c, d, e (1 ≤ a < b < c < d < e ≤ 109) — the prizes' costs.
Output
Print on the first line 5 integers, separated by a space — the number of mugs, towels, bags, bicycles and cars that Vasya has got, respectively. On the second line print a single integer — the number of points Vasya will have left after all operations of exchange are completed.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
Examples
Input
3
3 10 4
2 4 10 15 20
Output
1 1 1 0 0
1
Input
4
10 4 39 2
3 5 10 11 12
Output
3 0 1 0 3
0
Note
In the first sample Vasya gets 3 points after eating the first chocolate bar. Then he exchanges 2 points and gets a mug. Vasya wins a bag after eating the second chocolate bar. Then he wins a towel after eating the third chocolate bar. After all chocolate bars 3 - 2 + 10 - 10 + 4 - 4 = 1 points remains. | instruction | 0 | 65,853 | 10 | 131,706 |
Tags: implementation
Correct Solution:
```
'''input
4
10 4 39 2
3 5 10 11 12
'''
n = int(input())
p = list(map(int, input().split()))
s = [0] * 5
e = sorted([(j, i) for i, j in enumerate(map(int, input().split()))])[::-1]
c = 0
for x in p:
c += x
while c >= min(e)[0]:
for y in e:
# while c >= y[0]:
# s[y[1]] += 1
# c -= y[0]
s[y[1]] += c // y[0]
c %= y[0]
print(" ".join(map(str, s)), c, sep="\n")
``` | output | 1 | 65,853 | 10 | 131,707 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya, like many others, likes to participate in a variety of sweepstakes and lotteries. Now he collects wrappings from a famous chocolate bar "Jupiter". According to the sweepstake rules, each wrapping has an integer written on it — the number of points that the participant adds to his score as he buys the bar. After a participant earns a certain number of points, he can come to the prize distribution center and exchange the points for prizes. When somebody takes a prize, the prize's cost is simply subtracted from the number of his points.
Vasya didn't only bought the bars, he also kept a record of how many points each wrapping cost. Also, he remembers that he always stucks to the greedy strategy — as soon as he could take at least one prize, he went to the prize distribution centre and exchanged the points for prizes. Moreover, if he could choose between multiple prizes, he chose the most expensive one. If after an exchange Vasya had enough points left to get at least one more prize, then he continued to exchange points.
The sweepstake has the following prizes (the prizes are sorted by increasing of their cost):
* a mug (costs a points),
* a towel (costs b points),
* a bag (costs c points),
* a bicycle (costs d points),
* a car (costs e points).
Now Vasya wants to recollect what prizes he has received. You know sequence p1, p2, ..., pn, where pi is the number of points Vasya got for the i-th bar. The sequence of points is given in the chronological order. You also know numbers a, b, c, d, e. Your task is to find, how many prizes Vasya received, what prizes they are and how many points he's got left after all operations are completed.
Input
The first line contains a single integer n (1 ≤ n ≤ 50) — the number of chocolate bar wrappings that brought points to Vasya. The second line contains space-separated integers p1, p2, ..., pn (1 ≤ pi ≤ 109). The third line contains 5 integers a, b, c, d, e (1 ≤ a < b < c < d < e ≤ 109) — the prizes' costs.
Output
Print on the first line 5 integers, separated by a space — the number of mugs, towels, bags, bicycles and cars that Vasya has got, respectively. On the second line print a single integer — the number of points Vasya will have left after all operations of exchange are completed.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
Examples
Input
3
3 10 4
2 4 10 15 20
Output
1 1 1 0 0
1
Input
4
10 4 39 2
3 5 10 11 12
Output
3 0 1 0 3
0
Note
In the first sample Vasya gets 3 points after eating the first chocolate bar. Then he exchanges 2 points and gets a mug. Vasya wins a bag after eating the second chocolate bar. Then he wins a towel after eating the third chocolate bar. After all chocolate bars 3 - 2 + 10 - 10 + 4 - 4 = 1 points remains. | instruction | 0 | 65,854 | 10 | 131,708 |
Tags: implementation
Correct Solution:
```
f = lambda: map(int, input().split())
n = input()
seq = f()
a, b, c, d, e = f()
counts = [0, 0, 0, 0, 0]
score = 0
for p in seq:
score += p
if score >= e:
counts[4] += score // e
score = score % e
if score >= d:
counts[3] += score // d
score = score % d
if score >= c:
counts[2] += score // c
score = score % c
if score >= b:
counts[1] += score // b
score = score % b
if score >= a:
counts[0] += score // a
score = score % a
print(' '.join(list(map(str, counts))))
print(str(score))
``` | output | 1 | 65,854 | 10 | 131,709 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya, like many others, likes to participate in a variety of sweepstakes and lotteries. Now he collects wrappings from a famous chocolate bar "Jupiter". According to the sweepstake rules, each wrapping has an integer written on it — the number of points that the participant adds to his score as he buys the bar. After a participant earns a certain number of points, he can come to the prize distribution center and exchange the points for prizes. When somebody takes a prize, the prize's cost is simply subtracted from the number of his points.
Vasya didn't only bought the bars, he also kept a record of how many points each wrapping cost. Also, he remembers that he always stucks to the greedy strategy — as soon as he could take at least one prize, he went to the prize distribution centre and exchanged the points for prizes. Moreover, if he could choose between multiple prizes, he chose the most expensive one. If after an exchange Vasya had enough points left to get at least one more prize, then he continued to exchange points.
The sweepstake has the following prizes (the prizes are sorted by increasing of their cost):
* a mug (costs a points),
* a towel (costs b points),
* a bag (costs c points),
* a bicycle (costs d points),
* a car (costs e points).
Now Vasya wants to recollect what prizes he has received. You know sequence p1, p2, ..., pn, where pi is the number of points Vasya got for the i-th bar. The sequence of points is given in the chronological order. You also know numbers a, b, c, d, e. Your task is to find, how many prizes Vasya received, what prizes they are and how many points he's got left after all operations are completed.
Input
The first line contains a single integer n (1 ≤ n ≤ 50) — the number of chocolate bar wrappings that brought points to Vasya. The second line contains space-separated integers p1, p2, ..., pn (1 ≤ pi ≤ 109). The third line contains 5 integers a, b, c, d, e (1 ≤ a < b < c < d < e ≤ 109) — the prizes' costs.
Output
Print on the first line 5 integers, separated by a space — the number of mugs, towels, bags, bicycles and cars that Vasya has got, respectively. On the second line print a single integer — the number of points Vasya will have left after all operations of exchange are completed.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
Examples
Input
3
3 10 4
2 4 10 15 20
Output
1 1 1 0 0
1
Input
4
10 4 39 2
3 5 10 11 12
Output
3 0 1 0 3
0
Note
In the first sample Vasya gets 3 points after eating the first chocolate bar. Then he exchanges 2 points and gets a mug. Vasya wins a bag after eating the second chocolate bar. Then he wins a towel after eating the third chocolate bar. After all chocolate bars 3 - 2 + 10 - 10 + 4 - 4 = 1 points remains. | instruction | 0 | 65,855 | 10 | 131,710 |
Tags: implementation
Correct Solution:
```
n = int(input())
p = list(map(int, input().split()))
a, b, c, d, e = map(int, input().split())
k_a, k_b, k_c, k_d, k_e = 0, 0, 0, 0, 0
res = [a, b, c, d, e]
ans = [0] * 5
res.sort()
s = 0
for i in p:
s += i
for j in range(4, -1, -1):
ans[j] += s // res[j]
s %= res[j]
print(ans[res.index(a)], ans[res.index(b)], ans[res.index(c)], ans[res.index(d)], ans[res.index(e)])
print(s)
``` | output | 1 | 65,855 | 10 | 131,711 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya, like many others, likes to participate in a variety of sweepstakes and lotteries. Now he collects wrappings from a famous chocolate bar "Jupiter". According to the sweepstake rules, each wrapping has an integer written on it — the number of points that the participant adds to his score as he buys the bar. After a participant earns a certain number of points, he can come to the prize distribution center and exchange the points for prizes. When somebody takes a prize, the prize's cost is simply subtracted from the number of his points.
Vasya didn't only bought the bars, he also kept a record of how many points each wrapping cost. Also, he remembers that he always stucks to the greedy strategy — as soon as he could take at least one prize, he went to the prize distribution centre and exchanged the points for prizes. Moreover, if he could choose between multiple prizes, he chose the most expensive one. If after an exchange Vasya had enough points left to get at least one more prize, then he continued to exchange points.
The sweepstake has the following prizes (the prizes are sorted by increasing of their cost):
* a mug (costs a points),
* a towel (costs b points),
* a bag (costs c points),
* a bicycle (costs d points),
* a car (costs e points).
Now Vasya wants to recollect what prizes he has received. You know sequence p1, p2, ..., pn, where pi is the number of points Vasya got for the i-th bar. The sequence of points is given in the chronological order. You also know numbers a, b, c, d, e. Your task is to find, how many prizes Vasya received, what prizes they are and how many points he's got left after all operations are completed.
Input
The first line contains a single integer n (1 ≤ n ≤ 50) — the number of chocolate bar wrappings that brought points to Vasya. The second line contains space-separated integers p1, p2, ..., pn (1 ≤ pi ≤ 109). The third line contains 5 integers a, b, c, d, e (1 ≤ a < b < c < d < e ≤ 109) — the prizes' costs.
Output
Print on the first line 5 integers, separated by a space — the number of mugs, towels, bags, bicycles and cars that Vasya has got, respectively. On the second line print a single integer — the number of points Vasya will have left after all operations of exchange are completed.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
Examples
Input
3
3 10 4
2 4 10 15 20
Output
1 1 1 0 0
1
Input
4
10 4 39 2
3 5 10 11 12
Output
3 0 1 0 3
0
Note
In the first sample Vasya gets 3 points after eating the first chocolate bar. Then he exchanges 2 points and gets a mug. Vasya wins a bag after eating the second chocolate bar. Then he wins a towel after eating the third chocolate bar. After all chocolate bars 3 - 2 + 10 - 10 + 4 - 4 = 1 points remains. | instruction | 0 | 65,856 | 10 | 131,712 |
Tags: implementation
Correct Solution:
```
#------------------------template--------------------------#
import os
import sys
from math import *
from collections import *
# from fractions import *
# from heapq import*
from bisect import *
from io import BytesIO, IOBase
def vsInput():
sys.stdin = open('input.txt', 'r')
sys.stdout = open('output.txt', 'w')
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")
ALPHA='abcdefghijklmnopqrstuvwxyz'
M=10**9+7
EPS=1e-6
def Ceil(a,b): return a//b+int(a%b>0)
def value():return tuple(map(int,input().split()))
def array():return [int(i) for i in input().split()]
def Int():return int(input())
def Str():return input()
def arrayS():return [i for i in input().split()]
#-------------------------code---------------------------#
# vsInput()
n=Int()
a=array()
prizes=array()
left=0
count=[0]*5
for i in a:
left+=i
ind=bisect_right(prizes,left)-1
# print(ind,left)
while(ind>=0):
here=left//prizes[ind]
left-=prizes[ind]*here
count[ind]+=here
ind=bisect_right(prizes,left)-1
# print(*count,'-',here)
print(*count)
print(left)
``` | output | 1 | 65,856 | 10 | 131,713 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya, like many others, likes to participate in a variety of sweepstakes and lotteries. Now he collects wrappings from a famous chocolate bar "Jupiter". According to the sweepstake rules, each wrapping has an integer written on it — the number of points that the participant adds to his score as he buys the bar. After a participant earns a certain number of points, he can come to the prize distribution center and exchange the points for prizes. When somebody takes a prize, the prize's cost is simply subtracted from the number of his points.
Vasya didn't only bought the bars, he also kept a record of how many points each wrapping cost. Also, he remembers that he always stucks to the greedy strategy — as soon as he could take at least one prize, he went to the prize distribution centre and exchanged the points for prizes. Moreover, if he could choose between multiple prizes, he chose the most expensive one. If after an exchange Vasya had enough points left to get at least one more prize, then he continued to exchange points.
The sweepstake has the following prizes (the prizes are sorted by increasing of their cost):
* a mug (costs a points),
* a towel (costs b points),
* a bag (costs c points),
* a bicycle (costs d points),
* a car (costs e points).
Now Vasya wants to recollect what prizes he has received. You know sequence p1, p2, ..., pn, where pi is the number of points Vasya got for the i-th bar. The sequence of points is given in the chronological order. You also know numbers a, b, c, d, e. Your task is to find, how many prizes Vasya received, what prizes they are and how many points he's got left after all operations are completed.
Input
The first line contains a single integer n (1 ≤ n ≤ 50) — the number of chocolate bar wrappings that brought points to Vasya. The second line contains space-separated integers p1, p2, ..., pn (1 ≤ pi ≤ 109). The third line contains 5 integers a, b, c, d, e (1 ≤ a < b < c < d < e ≤ 109) — the prizes' costs.
Output
Print on the first line 5 integers, separated by a space — the number of mugs, towels, bags, bicycles and cars that Vasya has got, respectively. On the second line print a single integer — the number of points Vasya will have left after all operations of exchange are completed.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
Examples
Input
3
3 10 4
2 4 10 15 20
Output
1 1 1 0 0
1
Input
4
10 4 39 2
3 5 10 11 12
Output
3 0 1 0 3
0
Note
In the first sample Vasya gets 3 points after eating the first chocolate bar. Then he exchanges 2 points and gets a mug. Vasya wins a bag after eating the second chocolate bar. Then he wins a towel after eating the third chocolate bar. After all chocolate bars 3 - 2 + 10 - 10 + 4 - 4 = 1 points remains. | instruction | 0 | 65,857 | 10 | 131,714 |
Tags: implementation
Correct Solution:
```
n = int(input())
arr = [int(x) for x in input().split()]
cost = [int(x) for x in input().split()]
cost.reverse()
bought = [0 for i in range(5)]
mon = 0
for i in arr:
mon+=i
for j in range(5):
if(mon>=cost[j]):
num = mon//cost[j]
bought[4-j]+=num
mon-=cost[j]*num
for i in bought:
print(i,end = " ")
print(" ")
print(mon)
``` | output | 1 | 65,857 | 10 | 131,715 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya, like many others, likes to participate in a variety of sweepstakes and lotteries. Now he collects wrappings from a famous chocolate bar "Jupiter". According to the sweepstake rules, each wrapping has an integer written on it — the number of points that the participant adds to his score as he buys the bar. After a participant earns a certain number of points, he can come to the prize distribution center and exchange the points for prizes. When somebody takes a prize, the prize's cost is simply subtracted from the number of his points.
Vasya didn't only bought the bars, he also kept a record of how many points each wrapping cost. Also, he remembers that he always stucks to the greedy strategy — as soon as he could take at least one prize, he went to the prize distribution centre and exchanged the points for prizes. Moreover, if he could choose between multiple prizes, he chose the most expensive one. If after an exchange Vasya had enough points left to get at least one more prize, then he continued to exchange points.
The sweepstake has the following prizes (the prizes are sorted by increasing of their cost):
* a mug (costs a points),
* a towel (costs b points),
* a bag (costs c points),
* a bicycle (costs d points),
* a car (costs e points).
Now Vasya wants to recollect what prizes he has received. You know sequence p1, p2, ..., pn, where pi is the number of points Vasya got for the i-th bar. The sequence of points is given in the chronological order. You also know numbers a, b, c, d, e. Your task is to find, how many prizes Vasya received, what prizes they are and how many points he's got left after all operations are completed.
Input
The first line contains a single integer n (1 ≤ n ≤ 50) — the number of chocolate bar wrappings that brought points to Vasya. The second line contains space-separated integers p1, p2, ..., pn (1 ≤ pi ≤ 109). The third line contains 5 integers a, b, c, d, e (1 ≤ a < b < c < d < e ≤ 109) — the prizes' costs.
Output
Print on the first line 5 integers, separated by a space — the number of mugs, towels, bags, bicycles and cars that Vasya has got, respectively. On the second line print a single integer — the number of points Vasya will have left after all operations of exchange are completed.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
Examples
Input
3
3 10 4
2 4 10 15 20
Output
1 1 1 0 0
1
Input
4
10 4 39 2
3 5 10 11 12
Output
3 0 1 0 3
0
Note
In the first sample Vasya gets 3 points after eating the first chocolate bar. Then he exchanges 2 points and gets a mug. Vasya wins a bag after eating the second chocolate bar. Then he wins a towel after eating the third chocolate bar. After all chocolate bars 3 - 2 + 10 - 10 + 4 - 4 = 1 points remains. | instruction | 0 | 65,858 | 10 | 131,716 |
Tags: implementation
Correct Solution:
```
if __name__ == '__main__':
cin = input
n = int(cin())
a = [int(v) for v in cin().split()]
b = [int(v) for v in cin().split()]
c, r = [0] * 5, 0
for i in a:
r += i
for j in range(4, -1, -1):
c[j] += r // b[j]
r %= b[j]
print("%s\n%d" % (" ".join(str(i) for i in c), r))
``` | output | 1 | 65,858 | 10 | 131,717 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya, like many others, likes to participate in a variety of sweepstakes and lotteries. Now he collects wrappings from a famous chocolate bar "Jupiter". According to the sweepstake rules, each wrapping has an integer written on it — the number of points that the participant adds to his score as he buys the bar. After a participant earns a certain number of points, he can come to the prize distribution center and exchange the points for prizes. When somebody takes a prize, the prize's cost is simply subtracted from the number of his points.
Vasya didn't only bought the bars, he also kept a record of how many points each wrapping cost. Also, he remembers that he always stucks to the greedy strategy — as soon as he could take at least one prize, he went to the prize distribution centre and exchanged the points for prizes. Moreover, if he could choose between multiple prizes, he chose the most expensive one. If after an exchange Vasya had enough points left to get at least one more prize, then he continued to exchange points.
The sweepstake has the following prizes (the prizes are sorted by increasing of their cost):
* a mug (costs a points),
* a towel (costs b points),
* a bag (costs c points),
* a bicycle (costs d points),
* a car (costs e points).
Now Vasya wants to recollect what prizes he has received. You know sequence p1, p2, ..., pn, where pi is the number of points Vasya got for the i-th bar. The sequence of points is given in the chronological order. You also know numbers a, b, c, d, e. Your task is to find, how many prizes Vasya received, what prizes they are and how many points he's got left after all operations are completed.
Input
The first line contains a single integer n (1 ≤ n ≤ 50) — the number of chocolate bar wrappings that brought points to Vasya. The second line contains space-separated integers p1, p2, ..., pn (1 ≤ pi ≤ 109). The third line contains 5 integers a, b, c, d, e (1 ≤ a < b < c < d < e ≤ 109) — the prizes' costs.
Output
Print on the first line 5 integers, separated by a space — the number of mugs, towels, bags, bicycles and cars that Vasya has got, respectively. On the second line print a single integer — the number of points Vasya will have left after all operations of exchange are completed.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
Examples
Input
3
3 10 4
2 4 10 15 20
Output
1 1 1 0 0
1
Input
4
10 4 39 2
3 5 10 11 12
Output
3 0 1 0 3
0
Note
In the first sample Vasya gets 3 points after eating the first chocolate bar. Then he exchanges 2 points and gets a mug. Vasya wins a bag after eating the second chocolate bar. Then he wins a towel after eating the third chocolate bar. After all chocolate bars 3 - 2 + 10 - 10 + 4 - 4 = 1 points remains.
Submitted Solution:
```
L = lambda: list(map(int, input().split()))
L()
P = L()
X = L()
C = [0]*5
s = 0
for p in P:
s += p
for i in reversed(range(5)):
k, s = divmod(s, X[i])
C[i] += k
print(*C)
print(s)
``` | instruction | 0 | 65,859 | 10 | 131,718 |
Yes | output | 1 | 65,859 | 10 | 131,719 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya, like many others, likes to participate in a variety of sweepstakes and lotteries. Now he collects wrappings from a famous chocolate bar "Jupiter". According to the sweepstake rules, each wrapping has an integer written on it — the number of points that the participant adds to his score as he buys the bar. After a participant earns a certain number of points, he can come to the prize distribution center and exchange the points for prizes. When somebody takes a prize, the prize's cost is simply subtracted from the number of his points.
Vasya didn't only bought the bars, he also kept a record of how many points each wrapping cost. Also, he remembers that he always stucks to the greedy strategy — as soon as he could take at least one prize, he went to the prize distribution centre and exchanged the points for prizes. Moreover, if he could choose between multiple prizes, he chose the most expensive one. If after an exchange Vasya had enough points left to get at least one more prize, then he continued to exchange points.
The sweepstake has the following prizes (the prizes are sorted by increasing of their cost):
* a mug (costs a points),
* a towel (costs b points),
* a bag (costs c points),
* a bicycle (costs d points),
* a car (costs e points).
Now Vasya wants to recollect what prizes he has received. You know sequence p1, p2, ..., pn, where pi is the number of points Vasya got for the i-th bar. The sequence of points is given in the chronological order. You also know numbers a, b, c, d, e. Your task is to find, how many prizes Vasya received, what prizes they are and how many points he's got left after all operations are completed.
Input
The first line contains a single integer n (1 ≤ n ≤ 50) — the number of chocolate bar wrappings that brought points to Vasya. The second line contains space-separated integers p1, p2, ..., pn (1 ≤ pi ≤ 109). The third line contains 5 integers a, b, c, d, e (1 ≤ a < b < c < d < e ≤ 109) — the prizes' costs.
Output
Print on the first line 5 integers, separated by a space — the number of mugs, towels, bags, bicycles and cars that Vasya has got, respectively. On the second line print a single integer — the number of points Vasya will have left after all operations of exchange are completed.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
Examples
Input
3
3 10 4
2 4 10 15 20
Output
1 1 1 0 0
1
Input
4
10 4 39 2
3 5 10 11 12
Output
3 0 1 0 3
0
Note
In the first sample Vasya gets 3 points after eating the first chocolate bar. Then he exchanges 2 points and gets a mug. Vasya wins a bag after eating the second chocolate bar. Then he wins a towel after eating the third chocolate bar. After all chocolate bars 3 - 2 + 10 - 10 + 4 - 4 = 1 points remains.
Submitted Solution:
```
n = int(input())
p = [0] * (n + 1)
p = list(map(int, input().split()))
a, b, c, d, e = map(int, input().split())
points = int(0)
cnt = [0] * 5
for i in range(0, n):
points = points + p[i]
while 1:
if points >= e:
val = (points / e)
val = int(val)
points -= e * val
cnt[4] += val
elif points >= d:
val = (points / d)
val = int(val)
points -= d * val
cnt[3] += val
elif points >= c:
val = (points / c)
val = int(val)
points -= c * val
cnt[2] += val
elif points >= b:
val = (points / b)
val = int(val)
points -= b * val
cnt[1] += val
elif points >= a:
val = (points / a)
val= int(val)
points -= a * val
cnt[0] += val
else:
break
ans = " ".join(map(str,cnt))
print(ans)
print(points)
``` | instruction | 0 | 65,860 | 10 | 131,720 |
Yes | output | 1 | 65,860 | 10 | 131,721 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya, like many others, likes to participate in a variety of sweepstakes and lotteries. Now he collects wrappings from a famous chocolate bar "Jupiter". According to the sweepstake rules, each wrapping has an integer written on it — the number of points that the participant adds to his score as he buys the bar. After a participant earns a certain number of points, he can come to the prize distribution center and exchange the points for prizes. When somebody takes a prize, the prize's cost is simply subtracted from the number of his points.
Vasya didn't only bought the bars, he also kept a record of how many points each wrapping cost. Also, he remembers that he always stucks to the greedy strategy — as soon as he could take at least one prize, he went to the prize distribution centre and exchanged the points for prizes. Moreover, if he could choose between multiple prizes, he chose the most expensive one. If after an exchange Vasya had enough points left to get at least one more prize, then he continued to exchange points.
The sweepstake has the following prizes (the prizes are sorted by increasing of their cost):
* a mug (costs a points),
* a towel (costs b points),
* a bag (costs c points),
* a bicycle (costs d points),
* a car (costs e points).
Now Vasya wants to recollect what prizes he has received. You know sequence p1, p2, ..., pn, where pi is the number of points Vasya got for the i-th bar. The sequence of points is given in the chronological order. You also know numbers a, b, c, d, e. Your task is to find, how many prizes Vasya received, what prizes they are and how many points he's got left after all operations are completed.
Input
The first line contains a single integer n (1 ≤ n ≤ 50) — the number of chocolate bar wrappings that brought points to Vasya. The second line contains space-separated integers p1, p2, ..., pn (1 ≤ pi ≤ 109). The third line contains 5 integers a, b, c, d, e (1 ≤ a < b < c < d < e ≤ 109) — the prizes' costs.
Output
Print on the first line 5 integers, separated by a space — the number of mugs, towels, bags, bicycles and cars that Vasya has got, respectively. On the second line print a single integer — the number of points Vasya will have left after all operations of exchange are completed.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
Examples
Input
3
3 10 4
2 4 10 15 20
Output
1 1 1 0 0
1
Input
4
10 4 39 2
3 5 10 11 12
Output
3 0 1 0 3
0
Note
In the first sample Vasya gets 3 points after eating the first chocolate bar. Then he exchanges 2 points and gets a mug. Vasya wins a bag after eating the second chocolate bar. Then he wins a towel after eating the third chocolate bar. After all chocolate bars 3 - 2 + 10 - 10 + 4 - 4 = 1 points remains.
Submitted Solution:
```
n = int(input())
points = [int(i) for i in input().split()]
costs = [int(i) for i in input().split()]
prizes = [0 for i in range(5)]
sum = 0
for p in points:
sum += p
while (sum >= costs[0]):
if sum >= costs[4]:
bigprizes = sum // costs[4]
prizes[4] += bigprizes
sum -= costs[4]*bigprizes
elif sum >= costs[3]:
prizes[3] += 1
sum -= costs[3]
elif sum >= costs[2]:
prizes[2] += 1
sum -= costs[2]
elif sum >= costs[1]:
prizes[1] += 1
sum -= costs[1]
elif sum >= costs[0]:
prizes[0] += 1
sum -= costs[0]
for i in prizes:
print(i, end=' ')
print()
print(sum)
``` | instruction | 0 | 65,861 | 10 | 131,722 |
Yes | output | 1 | 65,861 | 10 | 131,723 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya, like many others, likes to participate in a variety of sweepstakes and lotteries. Now he collects wrappings from a famous chocolate bar "Jupiter". According to the sweepstake rules, each wrapping has an integer written on it — the number of points that the participant adds to his score as he buys the bar. After a participant earns a certain number of points, he can come to the prize distribution center and exchange the points for prizes. When somebody takes a prize, the prize's cost is simply subtracted from the number of his points.
Vasya didn't only bought the bars, he also kept a record of how many points each wrapping cost. Also, he remembers that he always stucks to the greedy strategy — as soon as he could take at least one prize, he went to the prize distribution centre and exchanged the points for prizes. Moreover, if he could choose between multiple prizes, he chose the most expensive one. If after an exchange Vasya had enough points left to get at least one more prize, then he continued to exchange points.
The sweepstake has the following prizes (the prizes are sorted by increasing of their cost):
* a mug (costs a points),
* a towel (costs b points),
* a bag (costs c points),
* a bicycle (costs d points),
* a car (costs e points).
Now Vasya wants to recollect what prizes he has received. You know sequence p1, p2, ..., pn, where pi is the number of points Vasya got for the i-th bar. The sequence of points is given in the chronological order. You also know numbers a, b, c, d, e. Your task is to find, how many prizes Vasya received, what prizes they are and how many points he's got left after all operations are completed.
Input
The first line contains a single integer n (1 ≤ n ≤ 50) — the number of chocolate bar wrappings that brought points to Vasya. The second line contains space-separated integers p1, p2, ..., pn (1 ≤ pi ≤ 109). The third line contains 5 integers a, b, c, d, e (1 ≤ a < b < c < d < e ≤ 109) — the prizes' costs.
Output
Print on the first line 5 integers, separated by a space — the number of mugs, towels, bags, bicycles and cars that Vasya has got, respectively. On the second line print a single integer — the number of points Vasya will have left after all operations of exchange are completed.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
Examples
Input
3
3 10 4
2 4 10 15 20
Output
1 1 1 0 0
1
Input
4
10 4 39 2
3 5 10 11 12
Output
3 0 1 0 3
0
Note
In the first sample Vasya gets 3 points after eating the first chocolate bar. Then he exchanges 2 points and gets a mug. Vasya wins a bag after eating the second chocolate bar. Then he wins a towel after eating the third chocolate bar. After all chocolate bars 3 - 2 + 10 - 10 + 4 - 4 = 1 points remains.
Submitted Solution:
```
"""
Satwik_Tiwari ;) .
4th july , 2020 - Saturday
"""
#===============================================================================================
#importing some useful libraries.
from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
import bisect
from heapq import *
from math import *
from collections import deque
from collections import Counter as counter # Counter(list) return a dict with {key: count}
from itertools import combinations as comb # if a = [1,2,3] then print(list(comb(a,2))) -----> [(1, 2), (1, 3), (2, 3)]
from itertools import permutations as permutate
from bisect import bisect_left as bl
#If the element is already present in the list,
# the left most position where element has to be inserted is returned.
from bisect import bisect_right as br
from bisect import bisect
#If the element is already present in the list,
# the right most position where element has to be inserted is returned
#==============================================================================================
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")
def print(*args, **kwargs):
"""Prints the values to a stream, or to sys.stdout by default."""
sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
at_start = True
for x in args:
if not at_start:
file.write(sep)
file.write(str(x))
at_start = False
file.write(kwargs.pop("end", "\n"))
if kwargs.pop("flush", False):
file.flush()
if sys.version_info[0] < 3:
sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
# inp = lambda: sys.stdin.readline().rstrip("\r\n")
#===============================================================================================
#some shortcuts
mod = 1000000007
def inp(): return sys.stdin.readline().rstrip("\r\n") #for fast input
def out(var): sys.stdout.write(str(var)) #for fast output, always take string
def lis(): return list(map(int, inp().split()))
def stringlis(): return list(map(str, inp().split()))
def sep(): return map(int, inp().split())
def strsep(): return map(str, inp().split())
# def graph(vertex): return [[] for i in range(0,vertex+1)]
def zerolist(n): return [0]*n
def nextline(): out("\n") #as stdout.write always print sring.
def testcase(t):
for p in range(t):
solve()
def printlist(a) :
for p in range(0,len(a)):
out(str(a[p]) + ' ')
def lcm(a,b): return (a*b)//gcd(a,b)
def power(a,b):
ans = 1
while(b>0):
if(b%2==1):
ans*=a
a*=a
b//=2
return ans
def ncr(n,r): return factorial(n)//(factorial(r)*factorial(max(n-r,1)))
def isPrime(n) : # Check Prime Number or not
if (n <= 1) : return False
if (n <= 3) : return True
if (n % 2 == 0 or n % 3 == 0) : return False
i = 5
while(i * i <= n) :
if (n % i == 0 or n % (i + 2) == 0) :
return False
i = i + 6
return True
#===============================================================================================
# code here ;))
def solve():
n = int(input())
p = lis()
prizes = lis()[::-1]
curr = 0
ans = [0]*(5)
for i in range(n):
curr+=p[i]
for j in range(5):
ans[j]+=curr//prizes[j]
curr = curr%prizes[j]
print(*ans[::-1])
print(curr)
testcase(1)
# testcase(int(inp()))
``` | instruction | 0 | 65,862 | 10 | 131,724 |
Yes | output | 1 | 65,862 | 10 | 131,725 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya, like many others, likes to participate in a variety of sweepstakes and lotteries. Now he collects wrappings from a famous chocolate bar "Jupiter". According to the sweepstake rules, each wrapping has an integer written on it — the number of points that the participant adds to his score as he buys the bar. After a participant earns a certain number of points, he can come to the prize distribution center and exchange the points for prizes. When somebody takes a prize, the prize's cost is simply subtracted from the number of his points.
Vasya didn't only bought the bars, he also kept a record of how many points each wrapping cost. Also, he remembers that he always stucks to the greedy strategy — as soon as he could take at least one prize, he went to the prize distribution centre and exchanged the points for prizes. Moreover, if he could choose between multiple prizes, he chose the most expensive one. If after an exchange Vasya had enough points left to get at least one more prize, then he continued to exchange points.
The sweepstake has the following prizes (the prizes are sorted by increasing of their cost):
* a mug (costs a points),
* a towel (costs b points),
* a bag (costs c points),
* a bicycle (costs d points),
* a car (costs e points).
Now Vasya wants to recollect what prizes he has received. You know sequence p1, p2, ..., pn, where pi is the number of points Vasya got for the i-th bar. The sequence of points is given in the chronological order. You also know numbers a, b, c, d, e. Your task is to find, how many prizes Vasya received, what prizes they are and how many points he's got left after all operations are completed.
Input
The first line contains a single integer n (1 ≤ n ≤ 50) — the number of chocolate bar wrappings that brought points to Vasya. The second line contains space-separated integers p1, p2, ..., pn (1 ≤ pi ≤ 109). The third line contains 5 integers a, b, c, d, e (1 ≤ a < b < c < d < e ≤ 109) — the prizes' costs.
Output
Print on the first line 5 integers, separated by a space — the number of mugs, towels, bags, bicycles and cars that Vasya has got, respectively. On the second line print a single integer — the number of points Vasya will have left after all operations of exchange are completed.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
Examples
Input
3
3 10 4
2 4 10 15 20
Output
1 1 1 0 0
1
Input
4
10 4 39 2
3 5 10 11 12
Output
3 0 1 0 3
0
Note
In the first sample Vasya gets 3 points after eating the first chocolate bar. Then he exchanges 2 points and gets a mug. Vasya wins a bag after eating the second chocolate bar. Then he wins a towel after eating the third chocolate bar. After all chocolate bars 3 - 2 + 10 - 10 + 4 - 4 = 1 points remains.
Submitted Solution:
```
n = int(input())
p = [0] * (n + 1)
p = list(map(int, input().split()))
a, b, c, d, e = map(int, input().split())
points = int(0)
cnt = [0] * 5
for i in range(0, n):
points = points + p[i]
while 1:
if points > e:
val = (points / e)
val = int(val)
points -= e * val
cnt[4] += val
elif points > d:
val = (points / d)
val = int(val)
points -= d * val
cnt[3] += val
elif points > c:
val = (points / c)
val = int(val)
points -= c * val
cnt[2] += val
elif points > b:
val = (points / b)
val = int(val)
points -= b * val
cnt[1] += val
elif points > a:
val = (points / a)
val= int(val)
points -= a * val
cnt[0] += val
else:
break
ans = " ".join(map(str,cnt))
print(ans)
print(points)
``` | instruction | 0 | 65,863 | 10 | 131,726 |
No | output | 1 | 65,863 | 10 | 131,727 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya, like many others, likes to participate in a variety of sweepstakes and lotteries. Now he collects wrappings from a famous chocolate bar "Jupiter". According to the sweepstake rules, each wrapping has an integer written on it — the number of points that the participant adds to his score as he buys the bar. After a participant earns a certain number of points, he can come to the prize distribution center and exchange the points for prizes. When somebody takes a prize, the prize's cost is simply subtracted from the number of his points.
Vasya didn't only bought the bars, he also kept a record of how many points each wrapping cost. Also, he remembers that he always stucks to the greedy strategy — as soon as he could take at least one prize, he went to the prize distribution centre and exchanged the points for prizes. Moreover, if he could choose between multiple prizes, he chose the most expensive one. If after an exchange Vasya had enough points left to get at least one more prize, then he continued to exchange points.
The sweepstake has the following prizes (the prizes are sorted by increasing of their cost):
* a mug (costs a points),
* a towel (costs b points),
* a bag (costs c points),
* a bicycle (costs d points),
* a car (costs e points).
Now Vasya wants to recollect what prizes he has received. You know sequence p1, p2, ..., pn, where pi is the number of points Vasya got for the i-th bar. The sequence of points is given in the chronological order. You also know numbers a, b, c, d, e. Your task is to find, how many prizes Vasya received, what prizes they are and how many points he's got left after all operations are completed.
Input
The first line contains a single integer n (1 ≤ n ≤ 50) — the number of chocolate bar wrappings that brought points to Vasya. The second line contains space-separated integers p1, p2, ..., pn (1 ≤ pi ≤ 109). The third line contains 5 integers a, b, c, d, e (1 ≤ a < b < c < d < e ≤ 109) — the prizes' costs.
Output
Print on the first line 5 integers, separated by a space — the number of mugs, towels, bags, bicycles and cars that Vasya has got, respectively. On the second line print a single integer — the number of points Vasya will have left after all operations of exchange are completed.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
Examples
Input
3
3 10 4
2 4 10 15 20
Output
1 1 1 0 0
1
Input
4
10 4 39 2
3 5 10 11 12
Output
3 0 1 0 3
0
Note
In the first sample Vasya gets 3 points after eating the first chocolate bar. Then he exchanges 2 points and gets a mug. Vasya wins a bag after eating the second chocolate bar. Then he wins a towel after eating the third chocolate bar. After all chocolate bars 3 - 2 + 10 - 10 + 4 - 4 = 1 points remains.
Submitted Solution:
```
n = int(input())
p = [int(i) for i in input().split()]
di = [int(i) for i in input().split()]
res = [0] * 5
them = 0
for i in range(n):
p[i] += them
j = 4
while p[i] // di[0] != 0:
# print(p[i])
res[j] =res[j] + p[i] // di[j]
p[i] %= di[j]
j -= 1
them = p[i]
print(*res, sep=" ")
print(them)
``` | instruction | 0 | 65,864 | 10 | 131,728 |
No | output | 1 | 65,864 | 10 | 131,729 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya, like many others, likes to participate in a variety of sweepstakes and lotteries. Now he collects wrappings from a famous chocolate bar "Jupiter". According to the sweepstake rules, each wrapping has an integer written on it — the number of points that the participant adds to his score as he buys the bar. After a participant earns a certain number of points, he can come to the prize distribution center and exchange the points for prizes. When somebody takes a prize, the prize's cost is simply subtracted from the number of his points.
Vasya didn't only bought the bars, he also kept a record of how many points each wrapping cost. Also, he remembers that he always stucks to the greedy strategy — as soon as he could take at least one prize, he went to the prize distribution centre and exchanged the points for prizes. Moreover, if he could choose between multiple prizes, he chose the most expensive one. If after an exchange Vasya had enough points left to get at least one more prize, then he continued to exchange points.
The sweepstake has the following prizes (the prizes are sorted by increasing of their cost):
* a mug (costs a points),
* a towel (costs b points),
* a bag (costs c points),
* a bicycle (costs d points),
* a car (costs e points).
Now Vasya wants to recollect what prizes he has received. You know sequence p1, p2, ..., pn, where pi is the number of points Vasya got for the i-th bar. The sequence of points is given in the chronological order. You also know numbers a, b, c, d, e. Your task is to find, how many prizes Vasya received, what prizes they are and how many points he's got left after all operations are completed.
Input
The first line contains a single integer n (1 ≤ n ≤ 50) — the number of chocolate bar wrappings that brought points to Vasya. The second line contains space-separated integers p1, p2, ..., pn (1 ≤ pi ≤ 109). The third line contains 5 integers a, b, c, d, e (1 ≤ a < b < c < d < e ≤ 109) — the prizes' costs.
Output
Print on the first line 5 integers, separated by a space — the number of mugs, towels, bags, bicycles and cars that Vasya has got, respectively. On the second line print a single integer — the number of points Vasya will have left after all operations of exchange are completed.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
Examples
Input
3
3 10 4
2 4 10 15 20
Output
1 1 1 0 0
1
Input
4
10 4 39 2
3 5 10 11 12
Output
3 0 1 0 3
0
Note
In the first sample Vasya gets 3 points after eating the first chocolate bar. Then he exchanges 2 points and gets a mug. Vasya wins a bag after eating the second chocolate bar. Then he wins a towel after eating the third chocolate bar. After all chocolate bars 3 - 2 + 10 - 10 + 4 - 4 = 1 points remains.
Submitted Solution:
```
n = int(input())
*pi , = map(int , input().split())
*prize , = map(int , input().split())
total = [0 , 0 , 0 , 0 , 0]
temp = 0
for i in pi:
temp += i
print(temp)
if temp >= prize[-1]:
total[4] += (temp // prize[-1])
temp -= prize[-1]*(temp // prize[-1])
if temp >= prize[-2]:
total[3] += temp // prize[-2]
temp -= prize[-2]*(temp // prize[-2])
if temp >= prize[-3]:
total[2] += temp // prize[-3]
temp -= prize[-3]*(temp // prize[-3])
if temp >= prize[-4]:
total[1] += temp // prize[-4]
temp -= prize[-4]*(temp // prize[-4])
if temp >= prize[-5]:
total[0] += temp // prize[-5]
temp -= prize[-5]*(temp // prize[-5])
print(*total )
print(temp)
``` | instruction | 0 | 65,865 | 10 | 131,730 |
No | output | 1 | 65,865 | 10 | 131,731 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya, like many others, likes to participate in a variety of sweepstakes and lotteries. Now he collects wrappings from a famous chocolate bar "Jupiter". According to the sweepstake rules, each wrapping has an integer written on it — the number of points that the participant adds to his score as he buys the bar. After a participant earns a certain number of points, he can come to the prize distribution center and exchange the points for prizes. When somebody takes a prize, the prize's cost is simply subtracted from the number of his points.
Vasya didn't only bought the bars, he also kept a record of how many points each wrapping cost. Also, he remembers that he always stucks to the greedy strategy — as soon as he could take at least one prize, he went to the prize distribution centre and exchanged the points for prizes. Moreover, if he could choose between multiple prizes, he chose the most expensive one. If after an exchange Vasya had enough points left to get at least one more prize, then he continued to exchange points.
The sweepstake has the following prizes (the prizes are sorted by increasing of their cost):
* a mug (costs a points),
* a towel (costs b points),
* a bag (costs c points),
* a bicycle (costs d points),
* a car (costs e points).
Now Vasya wants to recollect what prizes he has received. You know sequence p1, p2, ..., pn, where pi is the number of points Vasya got for the i-th bar. The sequence of points is given in the chronological order. You also know numbers a, b, c, d, e. Your task is to find, how many prizes Vasya received, what prizes they are and how many points he's got left after all operations are completed.
Input
The first line contains a single integer n (1 ≤ n ≤ 50) — the number of chocolate bar wrappings that brought points to Vasya. The second line contains space-separated integers p1, p2, ..., pn (1 ≤ pi ≤ 109). The third line contains 5 integers a, b, c, d, e (1 ≤ a < b < c < d < e ≤ 109) — the prizes' costs.
Output
Print on the first line 5 integers, separated by a space — the number of mugs, towels, bags, bicycles and cars that Vasya has got, respectively. On the second line print a single integer — the number of points Vasya will have left after all operations of exchange are completed.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
Examples
Input
3
3 10 4
2 4 10 15 20
Output
1 1 1 0 0
1
Input
4
10 4 39 2
3 5 10 11 12
Output
3 0 1 0 3
0
Note
In the first sample Vasya gets 3 points after eating the first chocolate bar. Then he exchanges 2 points and gets a mug. Vasya wins a bag after eating the second chocolate bar. Then he wins a towel after eating the third chocolate bar. After all chocolate bars 3 - 2 + 10 - 10 + 4 - 4 = 1 points remains.
Submitted Solution:
```
import sys
import string
from collections import Counter, defaultdict
from math import fsum, sqrt, gcd, ceil, factorial
from operator import *
from itertools import accumulate
from bisect import *
inf = float("inf")
# input = sys.stdin.readline
flush = lambda: sys.stdout.flush
comb = lambda x, y: (factorial(x) // factorial(y)) // factorial(x - y)
# inputs
# ip = lambda : input().rstrip()
ip = lambda: input()
ii = lambda: int(input())
r = lambda: map(int, input().split())
rr = lambda: list(r())
n = ii()
arr = rr()
brr = rr()
x = min(arr)
s = 0
ans = [0] * 5
for i in arr:
s += i
while s >= x:
pos = bisect(brr, s) - 1
ans[pos] += 1
s -= brr[pos]
print(*ans)
print(s)
``` | instruction | 0 | 65,866 | 10 | 131,732 |
No | output | 1 | 65,866 | 10 | 131,733 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An e-commerce startup pitches to the investors to get funding. They have been functional for n weeks now and also have a website!
For each week they know the number of unique visitors during this week vi and the revenue ci. To evaluate the potential of the startup at some range of weeks from l to r inclusive investors use the minimum among the maximum number of visitors multiplied by 100 and the minimum revenue during this period, that is:
<image>
The truth is that investors have no idea how to efficiently evaluate the startup, so they are going to pick some k random distinct weeks li and give them to managers of the startup. For each li they should pick some ri ≥ li and report maximum number of visitors and minimum revenue during this period.
Then, investors will calculate the potential of the startup for each of these ranges and take minimum value of p(li, ri) as the total evaluation grade of the startup. Assuming that managers of the startup always report the optimal values of ri for some particular li, i.e., the value such that the resulting grade of the startup is maximized, what is the expected resulting grade of the startup?
Input
The first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 1 000 000).
The second line contains n integers vi (1 ≤ vi ≤ 107) — the number of unique visitors during each week.
The third line contains n integers ci (1 ≤ ci ≤ 107) —the revenue for each week.
Output
Print a single real value — the expected grade of the startup. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 6.
Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct, if <image>.
Examples
Input
3 2
3 2 1
300 200 300
Output
133.3333333
Note
Consider the first sample.
If the investors ask for li = 1 onwards, startup will choose ri = 1, such that max number of visitors is 3 and minimum revenue is 300. Thus, potential in this case is min(3·100, 300) = 300.
If the investors ask for li = 2 onwards, startup will choose ri = 3, such that max number of visitors is 2 and minimum revenue is 200. Thus, potential in this case is min(2·100, 200) = 200.
If the investors ask for li = 3 onwards, startup will choose ri = 3, such that max number of visitors is 1 and minimum revenue is 300. Thus, potential in this case is min(1·100, 300) = 100.
We have to choose a set of size 2 equi-probably and take minimum of each. The possible sets here are : {200, 300},{100, 300},{100, 200}, effectively the set of possible values as perceived by investors equi-probably: {200, 100, 100}. Thus, the expected value is (100 + 200 + 100) / 3 = 133.(3).
Submitted Solution:
```
# You lost the game.
n,k = map(int, input().split())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
R = [0 for _ in range(n)]
for j in range(n):
mv = V[j]
mc = C[j]
S = [min(100*mv,mc) for _ in range(n)]
f = S[0]
for i in range(j+1,n):
mv = max(mv,V[i])
mc = min(mc,C[i])
S[i] = min(100*mv,mc)
f = max(S[i],f)
print(f)
R[j] = f
R.sort()
def fact(n):
if n <= 1:
return 1
else:
return n*fact(n-1)
def binom(n,k):
return fact(n)//(fact(k)*fact(n-k))
total = binom(n,k)
s = 0
for i in range(n-k+1):
s += R[i]*binom(n-1-i,k-1)
print(s/total)
``` | instruction | 0 | 66,045 | 10 | 132,090 |
No | output | 1 | 66,045 | 10 | 132,091 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An e-commerce startup pitches to the investors to get funding. They have been functional for n weeks now and also have a website!
For each week they know the number of unique visitors during this week vi and the revenue ci. To evaluate the potential of the startup at some range of weeks from l to r inclusive investors use the minimum among the maximum number of visitors multiplied by 100 and the minimum revenue during this period, that is:
<image>
The truth is that investors have no idea how to efficiently evaluate the startup, so they are going to pick some k random distinct weeks li and give them to managers of the startup. For each li they should pick some ri ≥ li and report maximum number of visitors and minimum revenue during this period.
Then, investors will calculate the potential of the startup for each of these ranges and take minimum value of p(li, ri) as the total evaluation grade of the startup. Assuming that managers of the startup always report the optimal values of ri for some particular li, i.e., the value such that the resulting grade of the startup is maximized, what is the expected resulting grade of the startup?
Input
The first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 1 000 000).
The second line contains n integers vi (1 ≤ vi ≤ 107) — the number of unique visitors during each week.
The third line contains n integers ci (1 ≤ ci ≤ 107) —the revenue for each week.
Output
Print a single real value — the expected grade of the startup. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 6.
Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct, if <image>.
Examples
Input
3 2
3 2 1
300 200 300
Output
133.3333333
Note
Consider the first sample.
If the investors ask for li = 1 onwards, startup will choose ri = 1, such that max number of visitors is 3 and minimum revenue is 300. Thus, potential in this case is min(3·100, 300) = 300.
If the investors ask for li = 2 onwards, startup will choose ri = 3, such that max number of visitors is 2 and minimum revenue is 200. Thus, potential in this case is min(2·100, 200) = 200.
If the investors ask for li = 3 onwards, startup will choose ri = 3, such that max number of visitors is 1 and minimum revenue is 300. Thus, potential in this case is min(1·100, 300) = 100.
We have to choose a set of size 2 equi-probably and take minimum of each. The possible sets here are : {200, 300},{100, 300},{100, 200}, effectively the set of possible values as perceived by investors equi-probably: {200, 100, 100}. Thus, the expected value is (100 + 200 + 100) / 3 = 133.(3).
Submitted Solution:
```
# You lost the game.
n,k = map(int, input().split())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
R = [0 for _ in range(n)]
mv = V[n-1]
mc = C[n-1]
R[n-1] = min(100*mv,mc)
for i in range(n-2,-1,-1):
mv = max(mv,V[i])
mc = min(mc,C[i])
S = min(100*mv,mc)
R[i] = max(S,R[i+1])
R.sort()
def fact(n):
if n <= 1:
return 1
else:
return n*fact(n-1)
def binom(n,k):
return fact(n)//(fact(k)*fact(n-k))
total = binom(n,k)
s = 0
for i in range(n-k+1):
s += R[i]*binom(n-1-i,k-1)
print(s/total)
``` | instruction | 0 | 66,046 | 10 | 132,092 |
No | output | 1 | 66,046 | 10 | 132,093 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An e-commerce startup pitches to the investors to get funding. They have been functional for n weeks now and also have a website!
For each week they know the number of unique visitors during this week vi and the revenue ci. To evaluate the potential of the startup at some range of weeks from l to r inclusive investors use the minimum among the maximum number of visitors multiplied by 100 and the minimum revenue during this period, that is:
<image>
The truth is that investors have no idea how to efficiently evaluate the startup, so they are going to pick some k random distinct weeks li and give them to managers of the startup. For each li they should pick some ri ≥ li and report maximum number of visitors and minimum revenue during this period.
Then, investors will calculate the potential of the startup for each of these ranges and take minimum value of p(li, ri) as the total evaluation grade of the startup. Assuming that managers of the startup always report the optimal values of ri for some particular li, i.e., the value such that the resulting grade of the startup is maximized, what is the expected resulting grade of the startup?
Input
The first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 1 000 000).
The second line contains n integers vi (1 ≤ vi ≤ 107) — the number of unique visitors during each week.
The third line contains n integers ci (1 ≤ ci ≤ 107) —the revenue for each week.
Output
Print a single real value — the expected grade of the startup. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 6.
Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct, if <image>.
Examples
Input
3 2
3 2 1
300 200 300
Output
133.3333333
Note
Consider the first sample.
If the investors ask for li = 1 onwards, startup will choose ri = 1, such that max number of visitors is 3 and minimum revenue is 300. Thus, potential in this case is min(3·100, 300) = 300.
If the investors ask for li = 2 onwards, startup will choose ri = 3, such that max number of visitors is 2 and minimum revenue is 200. Thus, potential in this case is min(2·100, 200) = 200.
If the investors ask for li = 3 onwards, startup will choose ri = 3, such that max number of visitors is 1 and minimum revenue is 300. Thus, potential in this case is min(1·100, 300) = 100.
We have to choose a set of size 2 equi-probably and take minimum of each. The possible sets here are : {200, 300},{100, 300},{100, 200}, effectively the set of possible values as perceived by investors equi-probably: {200, 100, 100}. Thus, the expected value is (100 + 200 + 100) / 3 = 133.(3).
Submitted Solution:
```
# You lost the game.
n,k = map(int, input().split())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
Mv = [V[0] for _ in range(n)]
for i in range(1,n):
Mv[i] = max(Mv[i-1],V[i])
mc = [C[0] for _ in range(n)]
for i in range(1,n):
mc[i] = min(mc[i-1],C[i])
R = [min(100*Mv[i],mc[i]) for i in range(n)]
R.sort()
def fact(n):
if n <= 1:
return 1
else:
return n*fact(n-1)
def binom(n,k):
return fact(n)//(fact(k)*fact(n-k))
total = binom(n,k)
s = 0
for i in range(n-k):
s += R[i]*binom(n-1-i,k-1)
print(s/total)
``` | instruction | 0 | 66,047 | 10 | 132,094 |
No | output | 1 | 66,047 | 10 | 132,095 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An e-commerce startup pitches to the investors to get funding. They have been functional for n weeks now and also have a website!
For each week they know the number of unique visitors during this week vi and the revenue ci. To evaluate the potential of the startup at some range of weeks from l to r inclusive investors use the minimum among the maximum number of visitors multiplied by 100 and the minimum revenue during this period, that is:
<image>
The truth is that investors have no idea how to efficiently evaluate the startup, so they are going to pick some k random distinct weeks li and give them to managers of the startup. For each li they should pick some ri ≥ li and report maximum number of visitors and minimum revenue during this period.
Then, investors will calculate the potential of the startup for each of these ranges and take minimum value of p(li, ri) as the total evaluation grade of the startup. Assuming that managers of the startup always report the optimal values of ri for some particular li, i.e., the value such that the resulting grade of the startup is maximized, what is the expected resulting grade of the startup?
Input
The first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 1 000 000).
The second line contains n integers vi (1 ≤ vi ≤ 107) — the number of unique visitors during each week.
The third line contains n integers ci (1 ≤ ci ≤ 107) —the revenue for each week.
Output
Print a single real value — the expected grade of the startup. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 6.
Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct, if <image>.
Examples
Input
3 2
3 2 1
300 200 300
Output
133.3333333
Note
Consider the first sample.
If the investors ask for li = 1 onwards, startup will choose ri = 1, such that max number of visitors is 3 and minimum revenue is 300. Thus, potential in this case is min(3·100, 300) = 300.
If the investors ask for li = 2 onwards, startup will choose ri = 3, such that max number of visitors is 2 and minimum revenue is 200. Thus, potential in this case is min(2·100, 200) = 200.
If the investors ask for li = 3 onwards, startup will choose ri = 3, such that max number of visitors is 1 and minimum revenue is 300. Thus, potential in this case is min(1·100, 300) = 100.
We have to choose a set of size 2 equi-probably and take minimum of each. The possible sets here are : {200, 300},{100, 300},{100, 200}, effectively the set of possible values as perceived by investors equi-probably: {200, 100, 100}. Thus, the expected value is (100 + 200 + 100) / 3 = 133.(3).
Submitted Solution:
```
import math
n, k = map(int, input().split())
v = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
res = []
C = math.factorial(n)/(math.factorial(k)*math.factorial(n-k))
for i in range(k):
res.append(min([100*max(v[i:]), min(c[i:])]))
print(sum(res)/C)
``` | instruction | 0 | 66,048 | 10 | 132,096 |
No | output | 1 | 66,048 | 10 | 132,097 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After Fox Ciel won an onsite round of a programming contest, she took a bus to return to her castle. The fee of the bus was 220 yen. She met Rabbit Hanako in the bus. They decided to play the following game because they got bored in the bus.
* Initially, there is a pile that contains x 100-yen coins and y 10-yen coins.
* They take turns alternatively. Ciel takes the first turn.
* In each turn, they must take exactly 220 yen from the pile. In Ciel's turn, if there are multiple ways to take 220 yen, she will choose the way that contains the maximal number of 100-yen coins. In Hanako's turn, if there are multiple ways to take 220 yen, she will choose the way that contains the maximal number of 10-yen coins.
* If Ciel or Hanako can't take exactly 220 yen from the pile, she loses.
Determine the winner of the game.
Input
The first line contains two integers x (0 ≤ x ≤ 106) and y (0 ≤ y ≤ 106), separated by a single space.
Output
If Ciel wins, print "Ciel". Otherwise, print "Hanako".
Examples
Input
2 2
Output
Ciel
Input
3 22
Output
Hanako
Note
In the first turn (Ciel's turn), she will choose 2 100-yen coins and 2 10-yen coins. In the second turn (Hanako's turn), she will choose 1 100-yen coin and 12 10-yen coins. In the third turn (Ciel's turn), she can't pay exactly 220 yen, so Ciel will lose. | instruction | 0 | 66,098 | 10 | 132,196 |
Tags: greedy
Correct Solution:
```
x,y=map(int,input().split())
Ceil=True
while True:
if Ceil:
if x>=2:
if y>=2:
x-=2; y-=2; Ceil=False
else:
print("Hanako"); exit()
elif x==1:
if y>=12:
x-=1; y-=12; Ceil=False
else:
print("Hanako"); exit()
else:
if y>=22:
y-=22; Ceil=False
else:
print("Hanako"); exit()
else:
if y>=22:
y-=22;Ceil=True
elif y>=12:
if x>=1:
x-=1;y-=12;Ceil=True
else:
print("Ciel"); exit()
elif y>=2:
if x>=2:
x-=2;y-=2;Ceil=True
else:
print("Ciel"); exit()
else:
print("Ciel"); exit()
``` | output | 1 | 66,098 | 10 | 132,197 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After Fox Ciel won an onsite round of a programming contest, she took a bus to return to her castle. The fee of the bus was 220 yen. She met Rabbit Hanako in the bus. They decided to play the following game because they got bored in the bus.
* Initially, there is a pile that contains x 100-yen coins and y 10-yen coins.
* They take turns alternatively. Ciel takes the first turn.
* In each turn, they must take exactly 220 yen from the pile. In Ciel's turn, if there are multiple ways to take 220 yen, she will choose the way that contains the maximal number of 100-yen coins. In Hanako's turn, if there are multiple ways to take 220 yen, she will choose the way that contains the maximal number of 10-yen coins.
* If Ciel or Hanako can't take exactly 220 yen from the pile, she loses.
Determine the winner of the game.
Input
The first line contains two integers x (0 ≤ x ≤ 106) and y (0 ≤ y ≤ 106), separated by a single space.
Output
If Ciel wins, print "Ciel". Otherwise, print "Hanako".
Examples
Input
2 2
Output
Ciel
Input
3 22
Output
Hanako
Note
In the first turn (Ciel's turn), she will choose 2 100-yen coins and 2 10-yen coins. In the second turn (Hanako's turn), she will choose 1 100-yen coin and 12 10-yen coins. In the third turn (Ciel's turn), she can't pay exactly 220 yen, so Ciel will lose. | instruction | 0 | 66,099 | 10 | 132,198 |
Tags: greedy
Correct Solution:
```
x,y=map(int,input().split())
t=0
while True:
if t%2==0:
if x>=2 and y>=2:
x-=2;y-=2
elif x==1 and y>=12:
x-=1;y-=12
elif x==0 and y>=22:
y-=22
else:exit(print('Hanako'))
else:
if y>=22:
y-=22
elif x>=1 and y>=12:
y-=12;x-=1
elif x>=2 and y>=2:
x-=2;y-=2
else:exit(print('Ciel'))
t+=1
``` | output | 1 | 66,099 | 10 | 132,199 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After Fox Ciel won an onsite round of a programming contest, she took a bus to return to her castle. The fee of the bus was 220 yen. She met Rabbit Hanako in the bus. They decided to play the following game because they got bored in the bus.
* Initially, there is a pile that contains x 100-yen coins and y 10-yen coins.
* They take turns alternatively. Ciel takes the first turn.
* In each turn, they must take exactly 220 yen from the pile. In Ciel's turn, if there are multiple ways to take 220 yen, she will choose the way that contains the maximal number of 100-yen coins. In Hanako's turn, if there are multiple ways to take 220 yen, she will choose the way that contains the maximal number of 10-yen coins.
* If Ciel or Hanako can't take exactly 220 yen from the pile, she loses.
Determine the winner of the game.
Input
The first line contains two integers x (0 ≤ x ≤ 106) and y (0 ≤ y ≤ 106), separated by a single space.
Output
If Ciel wins, print "Ciel". Otherwise, print "Hanako".
Examples
Input
2 2
Output
Ciel
Input
3 22
Output
Hanako
Note
In the first turn (Ciel's turn), she will choose 2 100-yen coins and 2 10-yen coins. In the second turn (Hanako's turn), she will choose 1 100-yen coin and 12 10-yen coins. In the third turn (Ciel's turn), she can't pay exactly 220 yen, so Ciel will lose. | instruction | 0 | 66,100 | 10 | 132,200 |
Tags: greedy
Correct Solution:
```
x, y = map(int , input().split())
a = 0
while 1:
if a%2==0:
if x>=2 and y>=2:
x = x-2
y = y-2
elif x==1 and y>=12:
x = x-1
y = y-12
elif x==0 and y>=22:
x = 0
y = y-22
else:
break
else:
if y>=22:
y = y-22
elif x>=1 and 22>y>=12:
x = x-1
y = y-12
elif x>=2 and 12>y>=2:
x = x-2
y = y-2
else:
break
#print(x,y)
a = a+1
if a%2==1:
print("Ciel")
else:
print("Hanako")
``` | output | 1 | 66,100 | 10 | 132,201 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After Fox Ciel won an onsite round of a programming contest, she took a bus to return to her castle. The fee of the bus was 220 yen. She met Rabbit Hanako in the bus. They decided to play the following game because they got bored in the bus.
* Initially, there is a pile that contains x 100-yen coins and y 10-yen coins.
* They take turns alternatively. Ciel takes the first turn.
* In each turn, they must take exactly 220 yen from the pile. In Ciel's turn, if there are multiple ways to take 220 yen, she will choose the way that contains the maximal number of 100-yen coins. In Hanako's turn, if there are multiple ways to take 220 yen, she will choose the way that contains the maximal number of 10-yen coins.
* If Ciel or Hanako can't take exactly 220 yen from the pile, she loses.
Determine the winner of the game.
Input
The first line contains two integers x (0 ≤ x ≤ 106) and y (0 ≤ y ≤ 106), separated by a single space.
Output
If Ciel wins, print "Ciel". Otherwise, print "Hanako".
Examples
Input
2 2
Output
Ciel
Input
3 22
Output
Hanako
Note
In the first turn (Ciel's turn), she will choose 2 100-yen coins and 2 10-yen coins. In the second turn (Hanako's turn), she will choose 1 100-yen coin and 12 10-yen coins. In the third turn (Ciel's turn), she can't pay exactly 220 yen, so Ciel will lose. | instruction | 0 | 66,101 | 10 | 132,202 |
Tags: greedy
Correct Solution:
```
import re
import itertools
from collections import Counter
class Task:
x, y = 0, 0
answer = ""
def getData(self):
self.x, self.y = [int(x) for x in input().split(' ')]
#inFile = open('input.txt', 'r')
#inFile.readline().rstrip()
#self.childs = inFile.readline().rstrip()
def solve(self):
while True:
if self.cielStep() == "can't move":
self.answer = 'Hanako'
return
if self.hanakoStep() == "can't move":
self.answer = 'Ciel'
return
def cielStep(self):
if self.x >= 2 and self.y >= 2:
self.x -= 2; self.y -= 2
return 'next'
if self.x >= 1 and self.y >= 12:
self.x -= 1
self.y -= 12
return 'next'
if self.y >= 22:
self.y -= 22
return 'next'
return "can't move"
def hanakoStep(self):
if self.y >= 22:
self.y -= 22
return 'next'
if self.y >= 12 and self.x >= 1:
self.y -= 12
self.x -= 1
return 'next'
if self.y >= 2 and self.x >= 2:
self.x -= 2
self.y -= 2
return 'next'
return "can't move"
def printAnswer(self):
print(self.answer)
#outFile = open('output.txt', 'w')
#outFile.write(self.answer)
task = Task()
task.getData()
task.solve()
task.printAnswer()
``` | output | 1 | 66,101 | 10 | 132,203 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After Fox Ciel won an onsite round of a programming contest, she took a bus to return to her castle. The fee of the bus was 220 yen. She met Rabbit Hanako in the bus. They decided to play the following game because they got bored in the bus.
* Initially, there is a pile that contains x 100-yen coins and y 10-yen coins.
* They take turns alternatively. Ciel takes the first turn.
* In each turn, they must take exactly 220 yen from the pile. In Ciel's turn, if there are multiple ways to take 220 yen, she will choose the way that contains the maximal number of 100-yen coins. In Hanako's turn, if there are multiple ways to take 220 yen, she will choose the way that contains the maximal number of 10-yen coins.
* If Ciel or Hanako can't take exactly 220 yen from the pile, she loses.
Determine the winner of the game.
Input
The first line contains two integers x (0 ≤ x ≤ 106) and y (0 ≤ y ≤ 106), separated by a single space.
Output
If Ciel wins, print "Ciel". Otherwise, print "Hanako".
Examples
Input
2 2
Output
Ciel
Input
3 22
Output
Hanako
Note
In the first turn (Ciel's turn), she will choose 2 100-yen coins and 2 10-yen coins. In the second turn (Hanako's turn), she will choose 1 100-yen coin and 12 10-yen coins. In the third turn (Ciel's turn), she can't pay exactly 220 yen, so Ciel will lose. | instruction | 0 | 66,102 | 10 | 132,204 |
Tags: greedy
Correct Solution:
```
import re
import itertools
from collections import Counter
class Task:
x, y = 0, 0
answer = ""
def getData(self):
self.x, self.y = [int(x) for x in input().split(' ')]
#inFile = open('input.txt', 'r')
#inFile.readline().rstrip()
#self.childs = inFile.readline().rstrip()
def solve(self):
while True:
if self.cielStep() == "can't move":
self.answer = 'Hanako'
return
if self.hanakoStep() == "can't move":
self.answer = 'Ciel'
return
def cielStep(self):
if self.x >= 2 and self.y >= 2:
self.x -= 2
self.y -= 2
return 'next'
if self.x >= 1 and self.y >= 12:
self.x -= 1
self.y -= 12
return 'next'
if self.y >= 22:
self.y -= 22
return 'next'
return "can't move"
def hanakoStep(self):
if self.y >= 22:
self.y -= 22
return 'next'
if self.y >= 12 and self.x >= 1:
self.y -= 12
self.x -= 1
return 'next'
if self.y >= 2 and self.x >= 2:
self.x -= 2
self.y -= 2
return 'next'
return "can't move"
def printAnswer(self):
print(self.answer)
#outFile = open('output.txt', 'w')
#outFile.write(self.answer)
task = Task()
task.getData()
task.solve()
task.printAnswer()
``` | output | 1 | 66,102 | 10 | 132,205 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After Fox Ciel won an onsite round of a programming contest, she took a bus to return to her castle. The fee of the bus was 220 yen. She met Rabbit Hanako in the bus. They decided to play the following game because they got bored in the bus.
* Initially, there is a pile that contains x 100-yen coins and y 10-yen coins.
* They take turns alternatively. Ciel takes the first turn.
* In each turn, they must take exactly 220 yen from the pile. In Ciel's turn, if there are multiple ways to take 220 yen, she will choose the way that contains the maximal number of 100-yen coins. In Hanako's turn, if there are multiple ways to take 220 yen, she will choose the way that contains the maximal number of 10-yen coins.
* If Ciel or Hanako can't take exactly 220 yen from the pile, she loses.
Determine the winner of the game.
Input
The first line contains two integers x (0 ≤ x ≤ 106) and y (0 ≤ y ≤ 106), separated by a single space.
Output
If Ciel wins, print "Ciel". Otherwise, print "Hanako".
Examples
Input
2 2
Output
Ciel
Input
3 22
Output
Hanako
Note
In the first turn (Ciel's turn), she will choose 2 100-yen coins and 2 10-yen coins. In the second turn (Hanako's turn), she will choose 1 100-yen coin and 12 10-yen coins. In the third turn (Ciel's turn), she can't pay exactly 220 yen, so Ciel will lose. | instruction | 0 | 66,103 | 10 | 132,206 |
Tags: greedy
Correct Solution:
```
x,y=map(int,input().split())
cnt=0
while(True):
if(cnt%2==0):
if(x>=2 and y>=2):
x-=2
y-=2
cnt+=1
elif(x>=1 and y>=12):
x-=1
y-=12
cnt+=1
elif(y>=22):
y-=22
cnt+=1
else:
break
else:
if(y>=22):
y-=22
cnt+=1
elif(x>=1 and y>=12):
x-=1
y-=12
cnt+=1
elif(x>=2 and y>=2):
x-=2
y-=2
cnt+=1
else:
break
print("Ciel" if cnt%2==1 else "Hanako")
``` | output | 1 | 66,103 | 10 | 132,207 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After Fox Ciel won an onsite round of a programming contest, she took a bus to return to her castle. The fee of the bus was 220 yen. She met Rabbit Hanako in the bus. They decided to play the following game because they got bored in the bus.
* Initially, there is a pile that contains x 100-yen coins and y 10-yen coins.
* They take turns alternatively. Ciel takes the first turn.
* In each turn, they must take exactly 220 yen from the pile. In Ciel's turn, if there are multiple ways to take 220 yen, she will choose the way that contains the maximal number of 100-yen coins. In Hanako's turn, if there are multiple ways to take 220 yen, she will choose the way that contains the maximal number of 10-yen coins.
* If Ciel or Hanako can't take exactly 220 yen from the pile, she loses.
Determine the winner of the game.
Input
The first line contains two integers x (0 ≤ x ≤ 106) and y (0 ≤ y ≤ 106), separated by a single space.
Output
If Ciel wins, print "Ciel". Otherwise, print "Hanako".
Examples
Input
2 2
Output
Ciel
Input
3 22
Output
Hanako
Note
In the first turn (Ciel's turn), she will choose 2 100-yen coins and 2 10-yen coins. In the second turn (Hanako's turn), she will choose 1 100-yen coin and 12 10-yen coins. In the third turn (Ciel's turn), she can't pay exactly 220 yen, so Ciel will lose. | instruction | 0 | 66,104 | 10 | 132,208 |
Tags: greedy
Correct Solution:
```
n , m = map(int,input().split())
c = min(n//2 , m//24)
n-=(2*c)
m-=(24*c)
c = min(n//3 , m//14)
n-=(3*c)
m-=(14*c)
c = min(n//4, m//4)
n-=(4*c)
m-=(4*c)
c = min(n , m//32)
n-=(c)
m-=(32*c)
c=m//44
m-=(44*c)
if m>=2 and 10*n +m >=22:
print("Ciel")
else:
print("Hanako")
``` | output | 1 | 66,104 | 10 | 132,209 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After Fox Ciel won an onsite round of a programming contest, she took a bus to return to her castle. The fee of the bus was 220 yen. She met Rabbit Hanako in the bus. They decided to play the following game because they got bored in the bus.
* Initially, there is a pile that contains x 100-yen coins and y 10-yen coins.
* They take turns alternatively. Ciel takes the first turn.
* In each turn, they must take exactly 220 yen from the pile. In Ciel's turn, if there are multiple ways to take 220 yen, she will choose the way that contains the maximal number of 100-yen coins. In Hanako's turn, if there are multiple ways to take 220 yen, she will choose the way that contains the maximal number of 10-yen coins.
* If Ciel or Hanako can't take exactly 220 yen from the pile, she loses.
Determine the winner of the game.
Input
The first line contains two integers x (0 ≤ x ≤ 106) and y (0 ≤ y ≤ 106), separated by a single space.
Output
If Ciel wins, print "Ciel". Otherwise, print "Hanako".
Examples
Input
2 2
Output
Ciel
Input
3 22
Output
Hanako
Note
In the first turn (Ciel's turn), she will choose 2 100-yen coins and 2 10-yen coins. In the second turn (Hanako's turn), she will choose 1 100-yen coin and 12 10-yen coins. In the third turn (Ciel's turn), she can't pay exactly 220 yen, so Ciel will lose. | instruction | 0 | 66,105 | 10 | 132,210 |
Tags: greedy
Correct Solution:
```
player_one = 'Ciel'
player_two = 'Hanako'
c100, c10 = map(int, input().split())
while True:
if 100 * c100 + 10 * c10 >= 220 and c10 >= 2:
tmp = min([2, c100])
c100 -= tmp
c10 -= (220 - 100 * tmp) // 10
else:
print(player_two)
break
if 100 * c100 + 10 * c10 >= 220 and c10 >= 2:
if c10 >= 22:
c10 -= 22
elif c10 >= 12:
c10 -= 12
c100 -= 1
else:
c10 -= 2
c100 -= 2
else:
print(player_one)
break
``` | output | 1 | 66,105 | 10 | 132,211 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After Fox Ciel won an onsite round of a programming contest, she took a bus to return to her castle. The fee of the bus was 220 yen. She met Rabbit Hanako in the bus. They decided to play the following game because they got bored in the bus.
* Initially, there is a pile that contains x 100-yen coins and y 10-yen coins.
* They take turns alternatively. Ciel takes the first turn.
* In each turn, they must take exactly 220 yen from the pile. In Ciel's turn, if there are multiple ways to take 220 yen, she will choose the way that contains the maximal number of 100-yen coins. In Hanako's turn, if there are multiple ways to take 220 yen, she will choose the way that contains the maximal number of 10-yen coins.
* If Ciel or Hanako can't take exactly 220 yen from the pile, she loses.
Determine the winner of the game.
Input
The first line contains two integers x (0 ≤ x ≤ 106) and y (0 ≤ y ≤ 106), separated by a single space.
Output
If Ciel wins, print "Ciel". Otherwise, print "Hanako".
Examples
Input
2 2
Output
Ciel
Input
3 22
Output
Hanako
Note
In the first turn (Ciel's turn), she will choose 2 100-yen coins and 2 10-yen coins. In the second turn (Hanako's turn), she will choose 1 100-yen coin and 12 10-yen coins. In the third turn (Ciel's turn), she can't pay exactly 220 yen, so Ciel will lose.
Submitted Solution:
```
n, a = map(int, input().split())
ans = 0
while(1):
s =220
op=-1
if a < 2: break
if ans%2 == 0:
l = min(n, 2)
s -= l*100
k = min(a ,s//10)
s -= k*10
n -= l
a -= k
else:
k = min((a-2)//10 , 2)
s -= k*100
l = min(n, s//100)
s -= l*100
a -= k*10
op = min(a, s//10)
s -= op*10
n -= l
a -= op
if s != 0:
break
ans += 1
if ans%2 == 1:
print('Ciel')
else:
print('Hanako')
``` | instruction | 0 | 66,106 | 10 | 132,212 |
Yes | output | 1 | 66,106 | 10 | 132,213 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.