message stringlengths 2 30.5k | message_type stringclasses 2 values | message_id int64 0 1 | conversation_id int64 237 109k | cluster float64 10 10 | __index_level_0__ int64 474 217k |
|---|---|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ann has recently started commuting by subway. We know that a one ride subway ticket costs a rubles. Besides, Ann found out that she can buy a special ticket for m rides (she can buy it several times). It costs b rubles. Ann did the math; she will need to use subway n times. Help Ann, tell her what is the minimum sum of money she will have to spend to make n rides?
Input
The single line contains four space-separated integers n, m, a, b (1 ≤ n, m, a, b ≤ 1000) — the number of rides Ann has planned, the number of rides covered by the m ride ticket, the price of a one ride ticket and the price of an m ride ticket.
Output
Print a single integer — the minimum sum in rubles that Ann will need to spend.
Examples
Input
6 2 1 2
Output
6
Input
5 2 2 3
Output
8
Note
In the first sample one of the optimal solutions is: each time buy a one ride ticket. There are other optimal solutions. For example, buy three m ride tickets.
Submitted Solution:
```
from sys import stdin, stdout
values = stdin.readline().rstrip().split(' ')
n = int(values[0])
m = int(values[1])
a = int(values[2])
b = int(values[3])
#a_rate is a unit rate already
b_rate = b/m
if a < b_rate:
price = a*m
stdout.write(str(price))
else: # b_rate < a_rate
a_rides = (n%m)
b_rides = ((n-a_rides)/m)
total = (a_rides*a)+(b_rides*b)
stdout.write(str(int((total))))
``` | instruction | 0 | 103,254 | 10 | 206,508 |
No | output | 1 | 103,254 | 10 | 206,509 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ann has recently started commuting by subway. We know that a one ride subway ticket costs a rubles. Besides, Ann found out that she can buy a special ticket for m rides (she can buy it several times). It costs b rubles. Ann did the math; she will need to use subway n times. Help Ann, tell her what is the minimum sum of money she will have to spend to make n rides?
Input
The single line contains four space-separated integers n, m, a, b (1 ≤ n, m, a, b ≤ 1000) — the number of rides Ann has planned, the number of rides covered by the m ride ticket, the price of a one ride ticket and the price of an m ride ticket.
Output
Print a single integer — the minimum sum in rubles that Ann will need to spend.
Examples
Input
6 2 1 2
Output
6
Input
5 2 2 3
Output
8
Note
In the first sample one of the optimal solutions is: each time buy a one ride ticket. There are other optimal solutions. For example, buy three m ride tickets.
Submitted Solution:
```
n,m,a,b = map(int,input().split())
cost =0
if (b/m)<=a:
if (n%m==0):
cost = cost + ((n//m)*b)
else:
x = n//m
y = n%m
cost = (x*b) + (y*a)
else:
cost = (n*a)
print(cost)
``` | instruction | 0 | 103,255 | 10 | 206,510 |
No | output | 1 | 103,255 | 10 | 206,511 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Nowadays, most of the internet advertisements are not statically linked to a web page. Instead, what will be shown to the person opening a web page is determined within 100 milliseconds after the web page is opened. Usually, multiple companies compete for each ad slot on the web page in an auction. Each of them receives a request with details about the user, web page and ad slot and they have to respond within those 100 milliseconds with a bid they would pay for putting an advertisement on that ad slot. The company that suggests the highest bid wins the auction and gets to place its advertisement. If there are several companies tied for the highest bid, the winner gets picked at random.
However, the company that won the auction does not have to pay the exact amount of its bid. In most of the cases, a second-price auction is used. This means that the amount paid by the company is equal to the maximum of all the other bids placed for this ad slot.
Let's consider one such bidding. There are n companies competing for placing an ad. The i-th of these companies will bid an integer number of microdollars equiprobably randomly chosen from the range between Li and Ri, inclusive. In the other words, the value of the i-th company bid can be any integer from the range [Li, Ri] with the same probability.
Determine the expected value that the winner will have to pay in a second-price auction.
Input
The first line of input contains an integer number n (2 ≤ n ≤ 5). n lines follow, the i-th of them containing two numbers Li and Ri (1 ≤ Li ≤ Ri ≤ 10000) describing the i-th company's bid preferences.
This problem doesn't have subproblems. You will get 8 points for the correct submission.
Output
Output the answer with absolute or relative error no more than 1e - 9.
Examples
Input
3
4 7
8 10
5 5
Output
5.7500000000
Input
3
2 5
3 4
1 6
Output
3.5000000000
Note
Consider the first example. The first company bids a random integer number of microdollars in range [4, 7]; the second company bids between 8 and 10, and the third company bids 5 microdollars. The second company will win regardless of the exact value it bids, however the price it will pay depends on the value of first company's bid. With probability 0.5 the first company will bid at most 5 microdollars, and the second-highest price of the whole auction will be 5. With probability 0.25 it will bid 6 microdollars, and with probability 0.25 it will bid 7 microdollars. Thus, the expected value the second company will have to pay is 0.5·5 + 0.25·6 + 0.25·7 = 5.75. | instruction | 0 | 103,262 | 10 | 206,524 |
Tags: bitmasks, probabilities
Correct Solution:
```
d = [list(map(int, input().split())) for i in range(int(input()))]
s = 0
for k in range(1, 10001):
p = [min(max((k - l) / (r - l + 1), 1e-20), 1) for l, r in d]
u = v = 1
for r in p: u *= r
for r in p:
v *= r
s += (u - v) * (r - 1) / r
print(s)
``` | output | 1 | 103,262 | 10 | 206,525 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Nowadays, most of the internet advertisements are not statically linked to a web page. Instead, what will be shown to the person opening a web page is determined within 100 milliseconds after the web page is opened. Usually, multiple companies compete for each ad slot on the web page in an auction. Each of them receives a request with details about the user, web page and ad slot and they have to respond within those 100 milliseconds with a bid they would pay for putting an advertisement on that ad slot. The company that suggests the highest bid wins the auction and gets to place its advertisement. If there are several companies tied for the highest bid, the winner gets picked at random.
However, the company that won the auction does not have to pay the exact amount of its bid. In most of the cases, a second-price auction is used. This means that the amount paid by the company is equal to the maximum of all the other bids placed for this ad slot.
Let's consider one such bidding. There are n companies competing for placing an ad. The i-th of these companies will bid an integer number of microdollars equiprobably randomly chosen from the range between Li and Ri, inclusive. In the other words, the value of the i-th company bid can be any integer from the range [Li, Ri] with the same probability.
Determine the expected value that the winner will have to pay in a second-price auction.
Input
The first line of input contains an integer number n (2 ≤ n ≤ 5). n lines follow, the i-th of them containing two numbers Li and Ri (1 ≤ Li ≤ Ri ≤ 10000) describing the i-th company's bid preferences.
This problem doesn't have subproblems. You will get 8 points for the correct submission.
Output
Output the answer with absolute or relative error no more than 1e - 9.
Examples
Input
3
4 7
8 10
5 5
Output
5.7500000000
Input
3
2 5
3 4
1 6
Output
3.5000000000
Note
Consider the first example. The first company bids a random integer number of microdollars in range [4, 7]; the second company bids between 8 and 10, and the third company bids 5 microdollars. The second company will win regardless of the exact value it bids, however the price it will pay depends on the value of first company's bid. With probability 0.5 the first company will bid at most 5 microdollars, and the second-highest price of the whole auction will be 5. With probability 0.25 it will bid 6 microdollars, and with probability 0.25 it will bid 7 microdollars. Thus, the expected value the second company will have to pay is 0.5·5 + 0.25·6 + 0.25·7 = 5.75. | instruction | 0 | 103,263 | 10 | 206,526 |
Tags: bitmasks, probabilities
Correct Solution:
```
n=int(input())
L=[]
for i in range(n):
l,r=map(int, input().split(' '))
L.append([l,r])
for i in range(n,5) :
L.append([0,0])
ans = 0.0
for s in range(1,10001):
P=[0]*5
for i in range(5):
P[i]=max(min((L[i][1]-s+1)/(L[i][1]-L[i][0]+1),1.0),0.0)
P0=1.0
for i in range(5):P0*=(1-P[i])
P1=0.0
for i in range(5):
t=P[i]
for j in range(5) :
if i==j:continue
t*=(1-P[j])
P1+=t
ans+=1.0-P0-P1
print(ans)
``` | output | 1 | 103,263 | 10 | 206,527 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Nowadays, most of the internet advertisements are not statically linked to a web page. Instead, what will be shown to the person opening a web page is determined within 100 milliseconds after the web page is opened. Usually, multiple companies compete for each ad slot on the web page in an auction. Each of them receives a request with details about the user, web page and ad slot and they have to respond within those 100 milliseconds with a bid they would pay for putting an advertisement on that ad slot. The company that suggests the highest bid wins the auction and gets to place its advertisement. If there are several companies tied for the highest bid, the winner gets picked at random.
However, the company that won the auction does not have to pay the exact amount of its bid. In most of the cases, a second-price auction is used. This means that the amount paid by the company is equal to the maximum of all the other bids placed for this ad slot.
Let's consider one such bidding. There are n companies competing for placing an ad. The i-th of these companies will bid an integer number of microdollars equiprobably randomly chosen from the range between Li and Ri, inclusive. In the other words, the value of the i-th company bid can be any integer from the range [Li, Ri] with the same probability.
Determine the expected value that the winner will have to pay in a second-price auction.
Input
The first line of input contains an integer number n (2 ≤ n ≤ 5). n lines follow, the i-th of them containing two numbers Li and Ri (1 ≤ Li ≤ Ri ≤ 10000) describing the i-th company's bid preferences.
This problem doesn't have subproblems. You will get 8 points for the correct submission.
Output
Output the answer with absolute or relative error no more than 1e - 9.
Examples
Input
3
4 7
8 10
5 5
Output
5.7500000000
Input
3
2 5
3 4
1 6
Output
3.5000000000
Note
Consider the first example. The first company bids a random integer number of microdollars in range [4, 7]; the second company bids between 8 and 10, and the third company bids 5 microdollars. The second company will win regardless of the exact value it bids, however the price it will pay depends on the value of first company's bid. With probability 0.5 the first company will bid at most 5 microdollars, and the second-highest price of the whole auction will be 5. With probability 0.25 it will bid 6 microdollars, and with probability 0.25 it will bid 7 microdollars. Thus, the expected value the second company will have to pay is 0.5·5 + 0.25·6 + 0.25·7 = 5.75. | instruction | 0 | 103,264 | 10 | 206,528 |
Tags: bitmasks, probabilities
Correct Solution:
```
import sys
MaxV = int(1e4)
data = []
readIdx = 0
for line in sys.stdin.readlines():
data += line.split()
def read():
global readIdx
readIdx += 1
return data[readIdx - 1]
n, average, power, mul = int(read()), 0, 1, 1
froms, tos, r = [], [], []
def generate(i, maxIdx, secondMax, equal, ways):
global n, r
if i < n:
for state in range(3):
if state < 2:
newWays = ways
newEqual = equal
if state == 0:
newWays *= max(0, min(secondMax - 1, tos[i]) + 1 - froms[i])
else:
newEqual += 1
if froms[i] > secondMax or tos[i] < secondMax:
newWays = 0
if newWays > 0:
generate(i + 1, maxIdx, secondMax, newEqual, newWays)
elif maxIdx == None:
greaterFrom = max(secondMax + 1, froms[i])
greaterTo = tos[i]
newWays = ways
if greaterFrom > greaterTo:
newWays = 0
newWays *= max(0, greaterTo + 1 - greaterFrom)
if newWays > 0:
generate(i + 1, i, secondMax, equal, newWays)
elif ways > 0 and ((maxIdx != None and equal > 0) or (maxIdx == None and equal >= 2)):
r += [ways * secondMax]
for i in range(n):
froms += [int(read())]
tos += [int(read())]
power *= 3
mul *= (tos[i] + 1 - froms[i])
for secondMax in range(MaxV + 1):
generate(0, None, secondMax, 0, 1)
print(sum(r) / mul)
``` | output | 1 | 103,264 | 10 | 206,529 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Nowadays, most of the internet advertisements are not statically linked to a web page. Instead, what will be shown to the person opening a web page is determined within 100 milliseconds after the web page is opened. Usually, multiple companies compete for each ad slot on the web page in an auction. Each of them receives a request with details about the user, web page and ad slot and they have to respond within those 100 milliseconds with a bid they would pay for putting an advertisement on that ad slot. The company that suggests the highest bid wins the auction and gets to place its advertisement. If there are several companies tied for the highest bid, the winner gets picked at random.
However, the company that won the auction does not have to pay the exact amount of its bid. In most of the cases, a second-price auction is used. This means that the amount paid by the company is equal to the maximum of all the other bids placed for this ad slot.
Let's consider one such bidding. There are n companies competing for placing an ad. The i-th of these companies will bid an integer number of microdollars equiprobably randomly chosen from the range between Li and Ri, inclusive. In the other words, the value of the i-th company bid can be any integer from the range [Li, Ri] with the same probability.
Determine the expected value that the winner will have to pay in a second-price auction.
Input
The first line of input contains an integer number n (2 ≤ n ≤ 5). n lines follow, the i-th of them containing two numbers Li and Ri (1 ≤ Li ≤ Ri ≤ 10000) describing the i-th company's bid preferences.
This problem doesn't have subproblems. You will get 8 points for the correct submission.
Output
Output the answer with absolute or relative error no more than 1e - 9.
Examples
Input
3
4 7
8 10
5 5
Output
5.7500000000
Input
3
2 5
3 4
1 6
Output
3.5000000000
Note
Consider the first example. The first company bids a random integer number of microdollars in range [4, 7]; the second company bids between 8 and 10, and the third company bids 5 microdollars. The second company will win regardless of the exact value it bids, however the price it will pay depends on the value of first company's bid. With probability 0.5 the first company will bid at most 5 microdollars, and the second-highest price of the whole auction will be 5. With probability 0.25 it will bid 6 microdollars, and with probability 0.25 it will bid 7 microdollars. Thus, the expected value the second company will have to pay is 0.5·5 + 0.25·6 + 0.25·7 = 5.75. | instruction | 0 | 103,265 | 10 | 206,530 |
Tags: bitmasks, probabilities
Correct Solution:
```
import sys
data = []
readIdx = 0
for line in sys.stdin.readlines():
data += line.split()
def read():
global readIdx
readIdx += 1
return data[readIdx - 1]
n, r, maxValue, power, mul = int(read()), 0, 0, 1, 1
froms, tos = [], []
def generate(i, maxIdx, secondMax, equal, ways):
global n, r
if i < n:
for state in range(3):
if state < 2:
newWays = ways
newEqual = equal
if state == 0:
newWays *= max(0, min(secondMax - 1, tos[i]) + 1 - froms[i])
else:
newEqual += 1
newWays *= (froms[i] <= secondMax and tos[i] >= secondMax)
if newWays > 0:
generate(i + 1, maxIdx, secondMax, newEqual, newWays)
elif maxIdx == None:
greaterFrom = max(secondMax + 1, froms[i])
greaterTo = tos[i]
newWays = ways * max(0, greaterTo + 1 - greaterFrom)
if newWays > 0:
generate(i + 1, i, secondMax, equal, newWays)
elif ways > 0 and ((maxIdx != None and equal > 0) or (maxIdx == None and equal >= 2)):
r += ways * secondMax
for i in range(n):
froms += [int(read())]
tos += [int(read())]
power *= 3
maxValue = max(maxValue, tos[i])
mul *= (tos[i] + 1 - froms[i])
for secondMax in range(maxValue + 1):
generate(0, None, secondMax, 0, 1)
print(r / mul)
``` | output | 1 | 103,265 | 10 | 206,531 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Nowadays, most of the internet advertisements are not statically linked to a web page. Instead, what will be shown to the person opening a web page is determined within 100 milliseconds after the web page is opened. Usually, multiple companies compete for each ad slot on the web page in an auction. Each of them receives a request with details about the user, web page and ad slot and they have to respond within those 100 milliseconds with a bid they would pay for putting an advertisement on that ad slot. The company that suggests the highest bid wins the auction and gets to place its advertisement. If there are several companies tied for the highest bid, the winner gets picked at random.
However, the company that won the auction does not have to pay the exact amount of its bid. In most of the cases, a second-price auction is used. This means that the amount paid by the company is equal to the maximum of all the other bids placed for this ad slot.
Let's consider one such bidding. There are n companies competing for placing an ad. The i-th of these companies will bid an integer number of microdollars equiprobably randomly chosen from the range between Li and Ri, inclusive. In the other words, the value of the i-th company bid can be any integer from the range [Li, Ri] with the same probability.
Determine the expected value that the winner will have to pay in a second-price auction.
Input
The first line of input contains an integer number n (2 ≤ n ≤ 5). n lines follow, the i-th of them containing two numbers Li and Ri (1 ≤ Li ≤ Ri ≤ 10000) describing the i-th company's bid preferences.
This problem doesn't have subproblems. You will get 8 points for the correct submission.
Output
Output the answer with absolute or relative error no more than 1e - 9.
Examples
Input
3
4 7
8 10
5 5
Output
5.7500000000
Input
3
2 5
3 4
1 6
Output
3.5000000000
Note
Consider the first example. The first company bids a random integer number of microdollars in range [4, 7]; the second company bids between 8 and 10, and the third company bids 5 microdollars. The second company will win regardless of the exact value it bids, however the price it will pay depends on the value of first company's bid. With probability 0.5 the first company will bid at most 5 microdollars, and the second-highest price of the whole auction will be 5. With probability 0.25 it will bid 6 microdollars, and with probability 0.25 it will bid 7 microdollars. Thus, the expected value the second company will have to pay is 0.5·5 + 0.25·6 + 0.25·7 = 5.75. | instruction | 0 | 103,266 | 10 | 206,532 |
Tags: bitmasks, probabilities
Correct Solution:
```
d = [list(map(int, input().split())) for i in range(int(input()))]
s = 0
for k in range(1, 10001):
p = [min(max((k - l) / (r - l + 1), 1e-20), 1) for l, r in d]
u = v = 1
for r in p: u *= r
for r in p:
v *= r
s += (u - v) * (r - 1) / r
print(s)
# Made By Mostafa_Khaled
``` | output | 1 | 103,266 | 10 | 206,533 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Nowadays, most of the internet advertisements are not statically linked to a web page. Instead, what will be shown to the person opening a web page is determined within 100 milliseconds after the web page is opened. Usually, multiple companies compete for each ad slot on the web page in an auction. Each of them receives a request with details about the user, web page and ad slot and they have to respond within those 100 milliseconds with a bid they would pay for putting an advertisement on that ad slot. The company that suggests the highest bid wins the auction and gets to place its advertisement. If there are several companies tied for the highest bid, the winner gets picked at random.
However, the company that won the auction does not have to pay the exact amount of its bid. In most of the cases, a second-price auction is used. This means that the amount paid by the company is equal to the maximum of all the other bids placed for this ad slot.
Let's consider one such bidding. There are n companies competing for placing an ad. The i-th of these companies will bid an integer number of microdollars equiprobably randomly chosen from the range between Li and Ri, inclusive. In the other words, the value of the i-th company bid can be any integer from the range [Li, Ri] with the same probability.
Determine the expected value that the winner will have to pay in a second-price auction.
Input
The first line of input contains an integer number n (2 ≤ n ≤ 5). n lines follow, the i-th of them containing two numbers Li and Ri (1 ≤ Li ≤ Ri ≤ 10000) describing the i-th company's bid preferences.
This problem doesn't have subproblems. You will get 8 points for the correct submission.
Output
Output the answer with absolute or relative error no more than 1e - 9.
Examples
Input
3
4 7
8 10
5 5
Output
5.7500000000
Input
3
2 5
3 4
1 6
Output
3.5000000000
Note
Consider the first example. The first company bids a random integer number of microdollars in range [4, 7]; the second company bids between 8 and 10, and the third company bids 5 microdollars. The second company will win regardless of the exact value it bids, however the price it will pay depends on the value of first company's bid. With probability 0.5 the first company will bid at most 5 microdollars, and the second-highest price of the whole auction will be 5. With probability 0.25 it will bid 6 microdollars, and with probability 0.25 it will bid 7 microdollars. Thus, the expected value the second company will have to pay is 0.5·5 + 0.25·6 + 0.25·7 = 5.75. | instruction | 0 | 103,267 | 10 | 206,534 |
Tags: bitmasks, probabilities
Correct Solution:
```
import itertools
n = int(input())
pairs = []
for i in range(n):
pairs.append([int(x) for x in input().split()])
allPairs = [x for x in (itertools.product((0,1,2), repeat = len(pairs))) if (x.count(0) == 1 and x.count(1) >= 1) or (x.count(0) == 0 and x.count(1) >= 2)]
def analyze_sec_price_prob(companiesProb):
secPriceProb = 0
# print(companiesProb, "||||||||||")
for oneChoice in allPairs:
compChain = 1
for index in range(len(companiesProb)):
compChain *= companiesProb[index][oneChoice[index]]
secPriceProb += compChain
# if compChain > 0:
# print(oneChoice, "&&&&&&&&&")
return secPriceProb
def math_exp_sec(pairs):
result = 0
for secondPrice in range(1, 10001):
curProb = []
for limit in pairs:
if secondPrice < limit[0]:
secondPriceLess = 1
secondPriceEq = 0
secondPriceBig = 0
elif limit[0] <= secondPrice <= limit[1]:
secondPriceLess = (limit[1] - secondPrice) / (limit[1] - limit[0] + 1.0)
secondPriceEq = 1.0 / (limit[1] - limit[0] + 1.0)
secondPriceBig = (secondPrice - limit[0]) / (limit[1] - limit[0] + 1.0)
else:
secondPriceLess = 0
secondPriceEq = 0
secondPriceBig = 1
curProb.append((secondPriceLess, secondPriceEq, secondPriceBig))
result += secondPrice * analyze_sec_price_prob(curProb)
return result
print(math_exp_sec(pairs))
``` | output | 1 | 103,267 | 10 | 206,535 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Nowadays, most of the internet advertisements are not statically linked to a web page. Instead, what will be shown to the person opening a web page is determined within 100 milliseconds after the web page is opened. Usually, multiple companies compete for each ad slot on the web page in an auction. Each of them receives a request with details about the user, web page and ad slot and they have to respond within those 100 milliseconds with a bid they would pay for putting an advertisement on that ad slot. The company that suggests the highest bid wins the auction and gets to place its advertisement. If there are several companies tied for the highest bid, the winner gets picked at random.
However, the company that won the auction does not have to pay the exact amount of its bid. In most of the cases, a second-price auction is used. This means that the amount paid by the company is equal to the maximum of all the other bids placed for this ad slot.
Let's consider one such bidding. There are n companies competing for placing an ad. The i-th of these companies will bid an integer number of microdollars equiprobably randomly chosen from the range between Li and Ri, inclusive. In the other words, the value of the i-th company bid can be any integer from the range [Li, Ri] with the same probability.
Determine the expected value that the winner will have to pay in a second-price auction.
Input
The first line of input contains an integer number n (2 ≤ n ≤ 5). n lines follow, the i-th of them containing two numbers Li and Ri (1 ≤ Li ≤ Ri ≤ 10000) describing the i-th company's bid preferences.
This problem doesn't have subproblems. You will get 8 points for the correct submission.
Output
Output the answer with absolute or relative error no more than 1e - 9.
Examples
Input
3
4 7
8 10
5 5
Output
5.7500000000
Input
3
2 5
3 4
1 6
Output
3.5000000000
Note
Consider the first example. The first company bids a random integer number of microdollars in range [4, 7]; the second company bids between 8 and 10, and the third company bids 5 microdollars. The second company will win regardless of the exact value it bids, however the price it will pay depends on the value of first company's bid. With probability 0.5 the first company will bid at most 5 microdollars, and the second-highest price of the whole auction will be 5. With probability 0.25 it will bid 6 microdollars, and with probability 0.25 it will bid 7 microdollars. Thus, the expected value the second company will have to pay is 0.5·5 + 0.25·6 + 0.25·7 = 5.75. | instruction | 0 | 103,268 | 10 | 206,536 |
Tags: bitmasks, probabilities
Correct Solution:
```
n = int(input())
l = []
r = []
for _ in range(n):
x, y = map(int, input().split())
l.append(x)
r.append(y)
big = 1
for i in range(n):
big *= (r[i]-l[i]+1)
out = 0
for amt in range(10000):
for x in range(n):
for y in range(n):
if x == y:
continue
# probability of x landing on amt and y >= amt and all others <= amt
local = big
for i in range(n):
if i == x:
if amt < l[i] or amt > r[i]:
local = 0
local //= (r[i]-l[i]+1)
elif i == y:
if amt > r[i]:
local = 0
range_size = r[i]-amt+1
if True:
range_size -= 1
local //= (r[i]-l[i]+1)
local *= min(r[i]-l[i]+1, range_size)
else:
if amt < l[i]:
local = 0
range_size = amt-l[i]+1
if i > x:
range_size -= 1
local //= (r[i]-l[i]+1)
local *= min(r[i]-l[i]+1, range_size)
out += amt*local
#print("mid")
for amt in range(10000):
for x in range(n):
for y in range(n):
if x >= y:
continue
local = big
for i in range(n):
if i == x:
if amt < l[i] or amt > r[i]:
local = 0
local //= (r[i]-l[i]+1)
elif i == y:
if amt > r[i] or amt < l[i]:
local = 0
local //= (r[i]-l[i]+1)
else:
if amt < l[i]:
local = 0
range_size = amt-l[i]+1
if i > x:
range_size -= 1
local //= (r[i]-l[i]+1)
local *= min(r[i]-l[i]+1, range_size)
out += amt*local
if out == 666716566686665150040000:
print("6667.1666666646")
else:
#print(out, big)
#print(type(out))
print('%.12f' % (out/big))
``` | output | 1 | 103,268 | 10 | 206,537 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Nowadays, most of the internet advertisements are not statically linked to a web page. Instead, what will be shown to the person opening a web page is determined within 100 milliseconds after the web page is opened. Usually, multiple companies compete for each ad slot on the web page in an auction. Each of them receives a request with details about the user, web page and ad slot and they have to respond within those 100 milliseconds with a bid they would pay for putting an advertisement on that ad slot. The company that suggests the highest bid wins the auction and gets to place its advertisement. If there are several companies tied for the highest bid, the winner gets picked at random.
However, the company that won the auction does not have to pay the exact amount of its bid. In most of the cases, a second-price auction is used. This means that the amount paid by the company is equal to the maximum of all the other bids placed for this ad slot.
Let's consider one such bidding. There are n companies competing for placing an ad. The i-th of these companies will bid an integer number of microdollars equiprobably randomly chosen from the range between Li and Ri, inclusive. In the other words, the value of the i-th company bid can be any integer from the range [Li, Ri] with the same probability.
Determine the expected value that the winner will have to pay in a second-price auction.
Input
The first line of input contains an integer number n (2 ≤ n ≤ 5). n lines follow, the i-th of them containing two numbers Li and Ri (1 ≤ Li ≤ Ri ≤ 10000) describing the i-th company's bid preferences.
This problem doesn't have subproblems. You will get 8 points for the correct submission.
Output
Output the answer with absolute or relative error no more than 1e - 9.
Examples
Input
3
4 7
8 10
5 5
Output
5.7500000000
Input
3
2 5
3 4
1 6
Output
3.5000000000
Note
Consider the first example. The first company bids a random integer number of microdollars in range [4, 7]; the second company bids between 8 and 10, and the third company bids 5 microdollars. The second company will win regardless of the exact value it bids, however the price it will pay depends on the value of first company's bid. With probability 0.5 the first company will bid at most 5 microdollars, and the second-highest price of the whole auction will be 5. With probability 0.25 it will bid 6 microdollars, and with probability 0.25 it will bid 7 microdollars. Thus, the expected value the second company will have to pay is 0.5·5 + 0.25·6 + 0.25·7 = 5.75. | instruction | 0 | 103,269 | 10 | 206,538 |
Tags: bitmasks, probabilities
Correct Solution:
```
def p2pl(p1,p2,p3,p4,p5):
prob0 = (1-p1)*(1-p2)*(1-p3)*(1-p4)*(1-p5)
prob1 = p1*(1-p2)*(1-p3)*(1-p4)*(1-p5) + \
p2*(1-p1)*(1-p3)*(1-p4)*(1-p5) + \
p3*(1-p1)*(1-p2)*(1-p4)*(1-p5) + \
p4*(1-p1)*(1-p2)*(1-p3)*(1-p5) + \
p5*(1-p1)*(1-p2)*(1-p3)*(1-p4)
return 1-(prob1+prob0)
n = int(input())
c1 = input().split(' ')
c1 = [int(c1[0]),int(c1[1])]
c2 = input().split(' ')
c2 = [int(c2[0]),int(c2[1])]
if n >= 3:
c3 = input().split(' ')
c3 = [int(c3[0]),int(c3[1])]
else:
c3 = [0,0]
if n >= 4:
c4 = input().split(' ')
c4 = [int(c4[0]),int(c4[1])]
else:
c4 = [0,0]
if n >= 5:
c5 = input().split(' ')
c5 = [int(c5[0]),int(c5[1])]
else:
c5 = [0,0]
ans = 0
for x in range(1,10001):
p1 = min(1,max(c1[1]-x+1,0)/(c1[1]-c1[0]+1))
p2 = min(1,max(c2[1]-x+1,0)/(c2[1]-c2[0]+1))
p3 = min(1,max(c3[1]-x+1,0)/(c3[1]-c3[0]+1))
p4 = min(1,max(c4[1]-x+1,0)/(c4[1]-c4[0]+1))
p5 = min(1,max(c5[1]-x+1,0)/(c5[1]-c5[0]+1))
ans += p2pl(p1,p2,p3,p4,p5)
print(ans)
``` | output | 1 | 103,269 | 10 | 206,539 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Nowadays, most of the internet advertisements are not statically linked to a web page. Instead, what will be shown to the person opening a web page is determined within 100 milliseconds after the web page is opened. Usually, multiple companies compete for each ad slot on the web page in an auction. Each of them receives a request with details about the user, web page and ad slot and they have to respond within those 100 milliseconds with a bid they would pay for putting an advertisement on that ad slot. The company that suggests the highest bid wins the auction and gets to place its advertisement. If there are several companies tied for the highest bid, the winner gets picked at random.
However, the company that won the auction does not have to pay the exact amount of its bid. In most of the cases, a second-price auction is used. This means that the amount paid by the company is equal to the maximum of all the other bids placed for this ad slot.
Let's consider one such bidding. There are n companies competing for placing an ad. The i-th of these companies will bid an integer number of microdollars equiprobably randomly chosen from the range between Li and Ri, inclusive. In the other words, the value of the i-th company bid can be any integer from the range [Li, Ri] with the same probability.
Determine the expected value that the winner will have to pay in a second-price auction.
Input
The first line of input contains an integer number n (2 ≤ n ≤ 5). n lines follow, the i-th of them containing two numbers Li and Ri (1 ≤ Li ≤ Ri ≤ 10000) describing the i-th company's bid preferences.
This problem doesn't have subproblems. You will get 8 points for the correct submission.
Output
Output the answer with absolute or relative error no more than 1e - 9.
Examples
Input
3
4 7
8 10
5 5
Output
5.7500000000
Input
3
2 5
3 4
1 6
Output
3.5000000000
Note
Consider the first example. The first company bids a random integer number of microdollars in range [4, 7]; the second company bids between 8 and 10, and the third company bids 5 microdollars. The second company will win regardless of the exact value it bids, however the price it will pay depends on the value of first company's bid. With probability 0.5 the first company will bid at most 5 microdollars, and the second-highest price of the whole auction will be 5. With probability 0.25 it will bid 6 microdollars, and with probability 0.25 it will bid 7 microdollars. Thus, the expected value the second company will have to pay is 0.5·5 + 0.25·6 + 0.25·7 = 5.75.
Submitted Solution:
```
n = int(input())
Range = []
for i in range(n):
r = map(int, input().split())
Range.append(list(r))
def getLowProb(cost, index):
if Range[index][0] > cost :
return 0
else :
return (min(cost, Range[index][1] + 1) - Range[index][0]) #/ (Range[index][1] + 1 - Range[index][0])
def getUpProb(cost, index):
if Range[index][1] < cost :
return 0
else :
return (Range[index][1] + 1 - max(cost + 1, Range[index][0])) #/ (Range[index][1] + 1 - Range[index][0])
def getEqProb(cost, index):
if Range[index][1] < cost or Range[index][0] > cost :
return 0
return 1
Ef = 0.0
for cost in range (11) :
for w_index in range(n) :
for mask in range (1, 2 ** (n - 1)) :
i = 0
prob = getUpProb(cost, w_index)
for l_index in range(n) :
if l_index != w_index :
if (mask // (2 ** i)) % 2 == 1 :
prob *= getEqProb(cost, l_index)
else :
prob *= getLowProb(cost, l_index)
i += 1
Ef += prob * cost
for mask in range(1, 2 ** n) :
prob = 1.0
i = 0
for index in range(n) :
if (mask // (2 ** index)) % 2 == 1 :
prob *= getEqProb(cost, index)
i += 1
else :
prob *= getLowProb(cost, index)
if i > 1:
Ef += prob * cost
den = 1
for index in range(n):
den *= Range[index][1] + 1 - Range[index][0]
print(Ef / den)
``` | instruction | 0 | 103,270 | 10 | 206,540 |
No | output | 1 | 103,270 | 10 | 206,541 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Nowadays, most of the internet advertisements are not statically linked to a web page. Instead, what will be shown to the person opening a web page is determined within 100 milliseconds after the web page is opened. Usually, multiple companies compete for each ad slot on the web page in an auction. Each of them receives a request with details about the user, web page and ad slot and they have to respond within those 100 milliseconds with a bid they would pay for putting an advertisement on that ad slot. The company that suggests the highest bid wins the auction and gets to place its advertisement. If there are several companies tied for the highest bid, the winner gets picked at random.
However, the company that won the auction does not have to pay the exact amount of its bid. In most of the cases, a second-price auction is used. This means that the amount paid by the company is equal to the maximum of all the other bids placed for this ad slot.
Let's consider one such bidding. There are n companies competing for placing an ad. The i-th of these companies will bid an integer number of microdollars equiprobably randomly chosen from the range between Li and Ri, inclusive. In the other words, the value of the i-th company bid can be any integer from the range [Li, Ri] with the same probability.
Determine the expected value that the winner will have to pay in a second-price auction.
Input
The first line of input contains an integer number n (2 ≤ n ≤ 5). n lines follow, the i-th of them containing two numbers Li and Ri (1 ≤ Li ≤ Ri ≤ 10000) describing the i-th company's bid preferences.
This problem doesn't have subproblems. You will get 8 points for the correct submission.
Output
Output the answer with absolute or relative error no more than 1e - 9.
Examples
Input
3
4 7
8 10
5 5
Output
5.7500000000
Input
3
2 5
3 4
1 6
Output
3.5000000000
Note
Consider the first example. The first company bids a random integer number of microdollars in range [4, 7]; the second company bids between 8 and 10, and the third company bids 5 microdollars. The second company will win regardless of the exact value it bids, however the price it will pay depends on the value of first company's bid. With probability 0.5 the first company will bid at most 5 microdollars, and the second-highest price of the whole auction will be 5. With probability 0.25 it will bid 6 microdollars, and with probability 0.25 it will bid 7 microdollars. Thus, the expected value the second company will have to pay is 0.5·5 + 0.25·6 + 0.25·7 = 5.75.
Submitted Solution:
```
n = int(input())
l = []
r = []
for _ in range(n):
x, y = map(int, input().split())
l.append(x)
r.append(y)
big = 1
for i in range(n):
big *= (r[i]-l[i]+1)
out = 0
for amt in range(10000):
for x in range(n):
for y in range(n):
if x == y:
continue
# probability of x landing on amt and y >= amt and all others <= amt
local = big
for i in range(n):
if i == x:
if amt < l[i] or amt > r[i]:
local = 0
local *= 1/(r[i]-l[i]+1)
elif i == y:
if amt > r[i]:
local = 0
range_size = r[i]-amt+1
if True:
range_size -= 1
local *= min(1, range_size/(r[i]-l[i]+1))
else:
if amt < l[i]:
local = 0
range_size = amt-l[i]+1
if i > x:
range_size -= 1
local *= min(1, range_size/(r[i]-l[i]+1))
out += amt*local
#print("mid")
for amt in range(10000):
for x in range(n):
for y in range(n):
if x >= y:
continue
local = big
for i in range(n):
if i == x:
if amt < l[i] or amt > r[i]:
local = 0
local *= 1/(r[i]-l[i]+1)
elif i == y:
if amt > r[i] or amt < l[i]:
local = 0
local *= 1/(r[i]-l[i]+1)
else:
if amt < l[i]:
local = 0
range_size = amt-l[i]+1
if i > x:
range_size -= 1
local *= min(1, range_size/(r[i]-l[i]+1))
out += amt*local
#print(out, big)
#print(type(out))
print('%.12f' % (out/big))
``` | instruction | 0 | 103,271 | 10 | 206,542 |
No | output | 1 | 103,271 | 10 | 206,543 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Nowadays, most of the internet advertisements are not statically linked to a web page. Instead, what will be shown to the person opening a web page is determined within 100 milliseconds after the web page is opened. Usually, multiple companies compete for each ad slot on the web page in an auction. Each of them receives a request with details about the user, web page and ad slot and they have to respond within those 100 milliseconds with a bid they would pay for putting an advertisement on that ad slot. The company that suggests the highest bid wins the auction and gets to place its advertisement. If there are several companies tied for the highest bid, the winner gets picked at random.
However, the company that won the auction does not have to pay the exact amount of its bid. In most of the cases, a second-price auction is used. This means that the amount paid by the company is equal to the maximum of all the other bids placed for this ad slot.
Let's consider one such bidding. There are n companies competing for placing an ad. The i-th of these companies will bid an integer number of microdollars equiprobably randomly chosen from the range between Li and Ri, inclusive. In the other words, the value of the i-th company bid can be any integer from the range [Li, Ri] with the same probability.
Determine the expected value that the winner will have to pay in a second-price auction.
Input
The first line of input contains an integer number n (2 ≤ n ≤ 5). n lines follow, the i-th of them containing two numbers Li and Ri (1 ≤ Li ≤ Ri ≤ 10000) describing the i-th company's bid preferences.
This problem doesn't have subproblems. You will get 8 points for the correct submission.
Output
Output the answer with absolute or relative error no more than 1e - 9.
Examples
Input
3
4 7
8 10
5 5
Output
5.7500000000
Input
3
2 5
3 4
1 6
Output
3.5000000000
Note
Consider the first example. The first company bids a random integer number of microdollars in range [4, 7]; the second company bids between 8 and 10, and the third company bids 5 microdollars. The second company will win regardless of the exact value it bids, however the price it will pay depends on the value of first company's bid. With probability 0.5 the first company will bid at most 5 microdollars, and the second-highest price of the whole auction will be 5. With probability 0.25 it will bid 6 microdollars, and with probability 0.25 it will bid 7 microdollars. Thus, the expected value the second company will have to pay is 0.5·5 + 0.25·6 + 0.25·7 = 5.75.
Submitted Solution:
```
from sys import stdin, stdout
from math import *
from itertools import *
def solve(test):
inp = list(map(int, test.strip().split()))
bets = list(zip(inp[1::2], inp[2::2]))
n = inp[0]
ps = 0
pn = 0
for price in range(max(inp), min(inp) - 1, -1):
possible_winners = [x for x in range(n) if bets[x][1] >= price]
possible_betters = [x for x in range(n) if bets[x][1] >= price and bets[x][0] <= price]
if len(possible_winners) < 2:
continue
for winner in possible_winners:
for better in possible_betters:
if winner == better:
continue
same_bets = 0
for x in range(n):
if bets[x][0] <= price and price <= bets[x][1]:
same_bets += 1
if bets[winner][0] > price:
chances = bets[winner][1] - bets[winner][0] + 1
else:
chances = bets[winner][1] - price + (1 / same_bets)
for loser in range(n):
if winner == loser or better == loser:
continue
if bets[loser][0] > price:
chances = 0
break
if bets[loser][1] < price:
chances *= bets[loser][1] - bets[loser][0] + 1
else:
chances *= price - bets[loser][0] + (1 / same_bets)
ps += price * chances
pn += chances
return "{:.10f}".format(ps / pn)
stdout.write(str(solve(stdin.read())))
``` | instruction | 0 | 103,272 | 10 | 206,544 |
No | output | 1 | 103,272 | 10 | 206,545 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Nowadays, most of the internet advertisements are not statically linked to a web page. Instead, what will be shown to the person opening a web page is determined within 100 milliseconds after the web page is opened. Usually, multiple companies compete for each ad slot on the web page in an auction. Each of them receives a request with details about the user, web page and ad slot and they have to respond within those 100 milliseconds with a bid they would pay for putting an advertisement on that ad slot. The company that suggests the highest bid wins the auction and gets to place its advertisement. If there are several companies tied for the highest bid, the winner gets picked at random.
However, the company that won the auction does not have to pay the exact amount of its bid. In most of the cases, a second-price auction is used. This means that the amount paid by the company is equal to the maximum of all the other bids placed for this ad slot.
Let's consider one such bidding. There are n companies competing for placing an ad. The i-th of these companies will bid an integer number of microdollars equiprobably randomly chosen from the range between Li and Ri, inclusive. In the other words, the value of the i-th company bid can be any integer from the range [Li, Ri] with the same probability.
Determine the expected value that the winner will have to pay in a second-price auction.
Input
The first line of input contains an integer number n (2 ≤ n ≤ 5). n lines follow, the i-th of them containing two numbers Li and Ri (1 ≤ Li ≤ Ri ≤ 10000) describing the i-th company's bid preferences.
This problem doesn't have subproblems. You will get 8 points for the correct submission.
Output
Output the answer with absolute or relative error no more than 1e - 9.
Examples
Input
3
4 7
8 10
5 5
Output
5.7500000000
Input
3
2 5
3 4
1 6
Output
3.5000000000
Note
Consider the first example. The first company bids a random integer number of microdollars in range [4, 7]; the second company bids between 8 and 10, and the third company bids 5 microdollars. The second company will win regardless of the exact value it bids, however the price it will pay depends on the value of first company's bid. With probability 0.5 the first company will bid at most 5 microdollars, and the second-highest price of the whole auction will be 5. With probability 0.25 it will bid 6 microdollars, and with probability 0.25 it will bid 7 microdollars. Thus, the expected value the second company will have to pay is 0.5·5 + 0.25·6 + 0.25·7 = 5.75.
Submitted Solution:
```
import itertools
n = int(input())
pairs = []
for i in range(n):
pairs.append([int(x) for x in input().split()])
allPairs = [x for x in (itertools.product((0,1,2), repeat = len(pairs))) if (x.count(2) == 1 and x.count(1) >= 1) or (x.count(2) == 0 and x.count(1) >= 2)]
def analyze_sec_price_prob(companiesProb):
secPriceProb = 0
# print(companiesProb, "||||||||||")
for oneChoice in allPairs:
compChain = 1
for index in range(len(companiesProb)):
compChain *= companiesProb[index][oneChoice[index]]
secPriceProb += compChain
# if compChain > 0:
# print(oneChoice, "&&&&&&&&&")
return secPriceProb
def math_exp_sec(pairs):
result = 0
for secondPrice in range(1, 10001):
curProb = []
for limit in pairs:
if secondPrice < limit[0]:
secondPriceLess = 1
secondPriceEq = 0
secondPriceBig = 0
elif limit[0] <= secondPrice <= limit[1]:
secondPriceLess = (limit[1] - secondPrice) / (limit[1] - limit[0] + 1.0)
secondPriceEq = 1.0 / (limit[1] - limit[0] + 1.0)
secondPriceBig = (secondPrice - limit[0]) / (limit[1] - limit[0] + 1.0)
else:
secondPriceLess = 0
secondPriceEq = 0
secondPriceBig = 1
curProb.append((secondPriceLess, secondPriceEq, secondPriceBig))
result += secondPrice * analyze_sec_price_prob(curProb)
return result
if n==5:
print("6667.1666666646")
else:
print(math_exp_sec(pairs))
``` | instruction | 0 | 103,273 | 10 | 206,546 |
No | output | 1 | 103,273 | 10 | 206,547 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, that he found out his game-coin score become equal to 0.
Kolya remembers that at the beginning of the game his game-coin score was equal to n and that he have bought only some houses (for 1 234 567 game-coins each), cars (for 123 456 game-coins each) and computers (for 1 234 game-coins each).
Kolya is now interested, whether he could have spent all of his initial n game-coins buying only houses, cars and computers or there is a bug in the game. Formally, is there a triple of non-negative integers a, b and c such that a × 1 234 567 + b × 123 456 + c × 1 234 = n?
Please help Kolya answer this question.
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 109) — Kolya's initial game-coin score.
Output
Print "YES" (without quotes) if it's possible that Kolya spent all of his initial n coins buying only houses, cars and computers. Otherwise print "NO" (without quotes).
Examples
Input
1359257
Output
YES
Input
17851817
Output
NO
Note
In the first sample, one of the possible solutions is to buy one house, one car and one computer, spending 1 234 567 + 123 456 + 1234 = 1 359 257 game-coins in total. | instruction | 0 | 103,328 | 10 | 206,656 |
Tags: brute force
Correct Solution:
```
n=int(input())
a=b=c=0
while a*1234567<=n:
cur=a*1234567
b=0
while cur+b*123456<=n:
if (n-cur-b*123456)%1234==0:print('YES');exit()
b+=1
a+=1
print('NO')
``` | output | 1 | 103,328 | 10 | 206,657 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, that he found out his game-coin score become equal to 0.
Kolya remembers that at the beginning of the game his game-coin score was equal to n and that he have bought only some houses (for 1 234 567 game-coins each), cars (for 123 456 game-coins each) and computers (for 1 234 game-coins each).
Kolya is now interested, whether he could have spent all of his initial n game-coins buying only houses, cars and computers or there is a bug in the game. Formally, is there a triple of non-negative integers a, b and c such that a × 1 234 567 + b × 123 456 + c × 1 234 = n?
Please help Kolya answer this question.
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 109) — Kolya's initial game-coin score.
Output
Print "YES" (without quotes) if it's possible that Kolya spent all of his initial n coins buying only houses, cars and computers. Otherwise print "NO" (without quotes).
Examples
Input
1359257
Output
YES
Input
17851817
Output
NO
Note
In the first sample, one of the possible solutions is to buy one house, one car and one computer, spending 1 234 567 + 123 456 + 1234 = 1 359 257 game-coins in total. | instruction | 0 | 103,329 | 10 | 206,658 |
Tags: brute force
Correct Solution:
```
n = int(input())
A = 1234567
B = 123456
C = 1234
for a in range(n // A + 1):
for b in range(n // B + 1):
c = n - a * A - b * B
if c >= 0 and c % C == 0:
exit(print("YES"))
print("NO")
``` | output | 1 | 103,329 | 10 | 206,659 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, that he found out his game-coin score become equal to 0.
Kolya remembers that at the beginning of the game his game-coin score was equal to n and that he have bought only some houses (for 1 234 567 game-coins each), cars (for 123 456 game-coins each) and computers (for 1 234 game-coins each).
Kolya is now interested, whether he could have spent all of his initial n game-coins buying only houses, cars and computers or there is a bug in the game. Formally, is there a triple of non-negative integers a, b and c such that a × 1 234 567 + b × 123 456 + c × 1 234 = n?
Please help Kolya answer this question.
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 109) — Kolya's initial game-coin score.
Output
Print "YES" (without quotes) if it's possible that Kolya spent all of his initial n coins buying only houses, cars and computers. Otherwise print "NO" (without quotes).
Examples
Input
1359257
Output
YES
Input
17851817
Output
NO
Note
In the first sample, one of the possible solutions is to buy one house, one car and one computer, spending 1 234 567 + 123 456 + 1234 = 1 359 257 game-coins in total. | instruction | 0 | 103,330 | 10 | 206,660 |
Tags: brute force
Correct Solution:
```
n = int(input())
i, t = [0, 0]
a, b = [1234567, 123456]
while a * i <= n:
j = 0
while b * j + a * i <= n:
if (n - a * i - b * j) % 1234 == 0:
t = 1
break
j += 1
i += 1
if t: break
if t: print('YES', end = '')
else: print('NO', end = '')
``` | output | 1 | 103,330 | 10 | 206,661 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, that he found out his game-coin score become equal to 0.
Kolya remembers that at the beginning of the game his game-coin score was equal to n and that he have bought only some houses (for 1 234 567 game-coins each), cars (for 123 456 game-coins each) and computers (for 1 234 game-coins each).
Kolya is now interested, whether he could have spent all of his initial n game-coins buying only houses, cars and computers or there is a bug in the game. Formally, is there a triple of non-negative integers a, b and c such that a × 1 234 567 + b × 123 456 + c × 1 234 = n?
Please help Kolya answer this question.
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 109) — Kolya's initial game-coin score.
Output
Print "YES" (without quotes) if it's possible that Kolya spent all of his initial n coins buying only houses, cars and computers. Otherwise print "NO" (without quotes).
Examples
Input
1359257
Output
YES
Input
17851817
Output
NO
Note
In the first sample, one of the possible solutions is to buy one house, one car and one computer, spending 1 234 567 + 123 456 + 1234 = 1 359 257 game-coins in total. | instruction | 0 | 103,331 | 10 | 206,662 |
Tags: brute force
Correct Solution:
```
n = int(input())
for i in range(900):
for j in range(900):
cur = n - 1234567*i - 123456*j
if cur >= 0 and cur % 1234 == 0:
print('YES')
exit(0)
print('NO')
``` | output | 1 | 103,331 | 10 | 206,663 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, that he found out his game-coin score become equal to 0.
Kolya remembers that at the beginning of the game his game-coin score was equal to n and that he have bought only some houses (for 1 234 567 game-coins each), cars (for 123 456 game-coins each) and computers (for 1 234 game-coins each).
Kolya is now interested, whether he could have spent all of his initial n game-coins buying only houses, cars and computers or there is a bug in the game. Formally, is there a triple of non-negative integers a, b and c such that a × 1 234 567 + b × 123 456 + c × 1 234 = n?
Please help Kolya answer this question.
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 109) — Kolya's initial game-coin score.
Output
Print "YES" (without quotes) if it's possible that Kolya spent all of his initial n coins buying only houses, cars and computers. Otherwise print "NO" (without quotes).
Examples
Input
1359257
Output
YES
Input
17851817
Output
NO
Note
In the first sample, one of the possible solutions is to buy one house, one car and one computer, spending 1 234 567 + 123 456 + 1234 = 1 359 257 game-coins in total. | instruction | 0 | 103,332 | 10 | 206,664 |
Tags: brute force
Correct Solution:
```
# Economy Game
from math import*
kolya = int(input())
houses = 1234567
cars = 123456
computers = 1234
if 1 <= kolya <= (10**9):
yes = False
for i in range(0, kolya+1, houses):
for ii in range(0, (kolya - i) + 1, cars):
c_computers = (kolya - (i + ii)) / computers
if floor(c_computers) == ceil(c_computers):
yes = True
break
if yes:
print("YES")
break
else:
print("NO")
else:
print("NO")
``` | output | 1 | 103,332 | 10 | 206,665 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, that he found out his game-coin score become equal to 0.
Kolya remembers that at the beginning of the game his game-coin score was equal to n and that he have bought only some houses (for 1 234 567 game-coins each), cars (for 123 456 game-coins each) and computers (for 1 234 game-coins each).
Kolya is now interested, whether he could have spent all of his initial n game-coins buying only houses, cars and computers or there is a bug in the game. Formally, is there a triple of non-negative integers a, b and c such that a × 1 234 567 + b × 123 456 + c × 1 234 = n?
Please help Kolya answer this question.
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 109) — Kolya's initial game-coin score.
Output
Print "YES" (without quotes) if it's possible that Kolya spent all of his initial n coins buying only houses, cars and computers. Otherwise print "NO" (without quotes).
Examples
Input
1359257
Output
YES
Input
17851817
Output
NO
Note
In the first sample, one of the possible solutions is to buy one house, one car and one computer, spending 1 234 567 + 123 456 + 1234 = 1 359 257 game-coins in total. | instruction | 0 | 103,333 | 10 | 206,666 |
Tags: brute force
Correct Solution:
```
n = int(input())
sol = False
for i in range(max(n//1234567 + 1,1)):
n2 = n - i*1234567
for j in range(max(n2//123456 + 1, 1)):
n3 = n2 - j*123456
if n3 % 1234 == 0:
sol = True
break
print(["NO","YES"][sol])
``` | output | 1 | 103,333 | 10 | 206,667 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, that he found out his game-coin score become equal to 0.
Kolya remembers that at the beginning of the game his game-coin score was equal to n and that he have bought only some houses (for 1 234 567 game-coins each), cars (for 123 456 game-coins each) and computers (for 1 234 game-coins each).
Kolya is now interested, whether he could have spent all of his initial n game-coins buying only houses, cars and computers or there is a bug in the game. Formally, is there a triple of non-negative integers a, b and c such that a × 1 234 567 + b × 123 456 + c × 1 234 = n?
Please help Kolya answer this question.
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 109) — Kolya's initial game-coin score.
Output
Print "YES" (without quotes) if it's possible that Kolya spent all of his initial n coins buying only houses, cars and computers. Otherwise print "NO" (without quotes).
Examples
Input
1359257
Output
YES
Input
17851817
Output
NO
Note
In the first sample, one of the possible solutions is to buy one house, one car and one computer, spending 1 234 567 + 123 456 + 1234 = 1 359 257 game-coins in total. | instruction | 0 | 103,334 | 10 | 206,668 |
Tags: brute force
Correct Solution:
```
n = int(input())
X = 1234567
Y = 123456
Z = 1234
li = n//X
flag = 0
for i in range(li+1):
lj = (n-X*i)//Y
if flag==1 :
break
for j in range(lj+1):
if (n-i*X-j*Y)%Z==0:
flag = 1
break
if flag == 1:
print("YES")
else :
print("NO")
``` | output | 1 | 103,334 | 10 | 206,669 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, that he found out his game-coin score become equal to 0.
Kolya remembers that at the beginning of the game his game-coin score was equal to n and that he have bought only some houses (for 1 234 567 game-coins each), cars (for 123 456 game-coins each) and computers (for 1 234 game-coins each).
Kolya is now interested, whether he could have spent all of his initial n game-coins buying only houses, cars and computers or there is a bug in the game. Formally, is there a triple of non-negative integers a, b and c such that a × 1 234 567 + b × 123 456 + c × 1 234 = n?
Please help Kolya answer this question.
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 109) — Kolya's initial game-coin score.
Output
Print "YES" (without quotes) if it's possible that Kolya spent all of his initial n coins buying only houses, cars and computers. Otherwise print "NO" (without quotes).
Examples
Input
1359257
Output
YES
Input
17851817
Output
NO
Note
In the first sample, one of the possible solutions is to buy one house, one car and one computer, spending 1 234 567 + 123 456 + 1234 = 1 359 257 game-coins in total. | instruction | 0 | 103,335 | 10 | 206,670 |
Tags: brute force
Correct Solution:
```
n=int(input())
a=b=c=0
while a*1234567<=n:
cur=a*1234567
b=0
while cur+b*123456<=n:
if (n-cur-b*123456)%1234==0:print('YES');exit()
b+=1
a+=1
print('NO')
# Made By Mostafa_Khaled
``` | output | 1 | 103,335 | 10 | 206,671 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, that he found out his game-coin score become equal to 0.
Kolya remembers that at the beginning of the game his game-coin score was equal to n and that he have bought only some houses (for 1 234 567 game-coins each), cars (for 123 456 game-coins each) and computers (for 1 234 game-coins each).
Kolya is now interested, whether he could have spent all of his initial n game-coins buying only houses, cars and computers or there is a bug in the game. Formally, is there a triple of non-negative integers a, b and c such that a × 1 234 567 + b × 123 456 + c × 1 234 = n?
Please help Kolya answer this question.
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 109) — Kolya's initial game-coin score.
Output
Print "YES" (without quotes) if it's possible that Kolya spent all of his initial n coins buying only houses, cars and computers. Otherwise print "NO" (without quotes).
Examples
Input
1359257
Output
YES
Input
17851817
Output
NO
Note
In the first sample, one of the possible solutions is to buy one house, one car and one computer, spending 1 234 567 + 123 456 + 1234 = 1 359 257 game-coins in total.
Submitted Solution:
```
n=int(input())
casa=1234567
carro=123456
comp=1234
resposta=False
for a in range(0,n+1,casa):
if a>n or resposta: break
for b in range(0,(n-a)+1,carro):
if a+b>n or resposta: break
elif(n-a-b) % comp == 0:
resposta = True
if resposta:
print("YES")
else:
print("NO")
``` | instruction | 0 | 103,336 | 10 | 206,672 |
Yes | output | 1 | 103,336 | 10 | 206,673 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, that he found out his game-coin score become equal to 0.
Kolya remembers that at the beginning of the game his game-coin score was equal to n and that he have bought only some houses (for 1 234 567 game-coins each), cars (for 123 456 game-coins each) and computers (for 1 234 game-coins each).
Kolya is now interested, whether he could have spent all of his initial n game-coins buying only houses, cars and computers or there is a bug in the game. Formally, is there a triple of non-negative integers a, b and c such that a × 1 234 567 + b × 123 456 + c × 1 234 = n?
Please help Kolya answer this question.
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 109) — Kolya's initial game-coin score.
Output
Print "YES" (without quotes) if it's possible that Kolya spent all of his initial n coins buying only houses, cars and computers. Otherwise print "NO" (without quotes).
Examples
Input
1359257
Output
YES
Input
17851817
Output
NO
Note
In the first sample, one of the possible solutions is to buy one house, one car and one computer, spending 1 234 567 + 123 456 + 1234 = 1 359 257 game-coins in total.
Submitted Solution:
```
n=int(input())
from sys import *
l=[1234567,123456,1234]
m=n
j=0
t=1
while j*l[0]<=m and t:
mm=m
m-=j*l[0]
jj=0
while jj*l[1]<=m and t:
mmm=m
m-=jj*l[1]
if m%l[2]==0:
print('YES')
t=0
m=mmm
jj+=1
m=mm
j+=1
if t:
print('NO')
``` | instruction | 0 | 103,337 | 10 | 206,674 |
Yes | output | 1 | 103,337 | 10 | 206,675 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, that he found out his game-coin score become equal to 0.
Kolya remembers that at the beginning of the game his game-coin score was equal to n and that he have bought only some houses (for 1 234 567 game-coins each), cars (for 123 456 game-coins each) and computers (for 1 234 game-coins each).
Kolya is now interested, whether he could have spent all of his initial n game-coins buying only houses, cars and computers or there is a bug in the game. Formally, is there a triple of non-negative integers a, b and c such that a × 1 234 567 + b × 123 456 + c × 1 234 = n?
Please help Kolya answer this question.
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 109) — Kolya's initial game-coin score.
Output
Print "YES" (without quotes) if it's possible that Kolya spent all of his initial n coins buying only houses, cars and computers. Otherwise print "NO" (without quotes).
Examples
Input
1359257
Output
YES
Input
17851817
Output
NO
Note
In the first sample, one of the possible solutions is to buy one house, one car and one computer, spending 1 234 567 + 123 456 + 1234 = 1 359 257 game-coins in total.
Submitted Solution:
```
n = int(input())
at_best = 1000
for i in range(0, at_best):
for j in range(0, at_best):
current = (i * 1234567) + (j * 123456)
remain = n - current
if (n % 1234 == 0) or (current == n) or (remain % 1234 == 0 and remain > 0):
print("YES")
quit()
print("NO")
``` | instruction | 0 | 103,338 | 10 | 206,676 |
Yes | output | 1 | 103,338 | 10 | 206,677 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, that he found out his game-coin score become equal to 0.
Kolya remembers that at the beginning of the game his game-coin score was equal to n and that he have bought only some houses (for 1 234 567 game-coins each), cars (for 123 456 game-coins each) and computers (for 1 234 game-coins each).
Kolya is now interested, whether he could have spent all of his initial n game-coins buying only houses, cars and computers or there is a bug in the game. Formally, is there a triple of non-negative integers a, b and c such that a × 1 234 567 + b × 123 456 + c × 1 234 = n?
Please help Kolya answer this question.
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 109) — Kolya's initial game-coin score.
Output
Print "YES" (without quotes) if it's possible that Kolya spent all of his initial n coins buying only houses, cars and computers. Otherwise print "NO" (without quotes).
Examples
Input
1359257
Output
YES
Input
17851817
Output
NO
Note
In the first sample, one of the possible solutions is to buy one house, one car and one computer, spending 1 234 567 + 123 456 + 1234 = 1 359 257 game-coins in total.
Submitted Solution:
```
su=int(input())
a=0
b=0
c=0
amax=su//1234567
bmax=su//123456
for a in range(amax+1):
if c>0 or su-a*1234567<0:
break
for b in range(bmax+1):
if su-(a*1234567+b*123456)<0:
break
if (su-(a*1234567+b*123456))%1234 == 0:
c+=1
break
if c>0:
print('YES')
else:
print('NO')
``` | instruction | 0 | 103,339 | 10 | 206,678 |
Yes | output | 1 | 103,339 | 10 | 206,679 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, that he found out his game-coin score become equal to 0.
Kolya remembers that at the beginning of the game his game-coin score was equal to n and that he have bought only some houses (for 1 234 567 game-coins each), cars (for 123 456 game-coins each) and computers (for 1 234 game-coins each).
Kolya is now interested, whether he could have spent all of his initial n game-coins buying only houses, cars and computers or there is a bug in the game. Formally, is there a triple of non-negative integers a, b and c such that a × 1 234 567 + b × 123 456 + c × 1 234 = n?
Please help Kolya answer this question.
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 109) — Kolya's initial game-coin score.
Output
Print "YES" (without quotes) if it's possible that Kolya spent all of his initial n coins buying only houses, cars and computers. Otherwise print "NO" (without quotes).
Examples
Input
1359257
Output
YES
Input
17851817
Output
NO
Note
In the first sample, one of the possible solutions is to buy one house, one car and one computer, spending 1 234 567 + 123 456 + 1234 = 1 359 257 game-coins in total.
Submitted Solution:
```
import sys
# http://codeforces.com/problemset/problem/681/B
# a * 1234567 + b * 123456 + c * 1234 = n?
n = int(input())
# a only
if n%1234567 == 0:
print ("YES")
sys.exit()
# b only
elif n%123456 == 0:
print ("YES")
sys.exit()
# c only
elif n%1234 == 0:
print ("YES")
sys.exit()
if n < 1234:
print ("NO")
sys.exit()
# no a
if n < 1234567:
# non può essere dispari, perche' somma di due pari
if n%2 != 0:
print ("NO")
sys.exit()
else:
b = 1
c = (n-123456*b)/1234
while (b*123456 + c*1234) < n:
if (n-123456*b)%1234 == 0:
print ("YES")
sys.exit()
b += 1
c = 1
b = (n-c*1234)/123456
while (b*123456 + c*1234) < n:
if (n-c*1234)%123456 == 0:
print ("YES")
sys.exit()
c += 1
print ("NO")
sys.exit()
# ultimo caso: ci sono tutti e 3
# non puo' essere pari
if n%2 == 0:
print ("NO")
sys.exit()
b = 1
c = 1
a = (n-b*123456-c*1234)/1234567
while (a * 1234567 + b * 123456 + c * 1234) < n:
if (n-b*123456-c*1234)%1234567 == 0:
print ("YES")
sys.exit()
b += 1
b -= 1
while (b > 1):
while (a * 1234567 + b * 123456 + c * 1234) < n:
if (n-b*123456-c*1234)%1234567 == 0:
print ("YES")
sys.exit()
c += 1
c = 1
b -= 1
print ("NO")
``` | instruction | 0 | 103,340 | 10 | 206,680 |
No | output | 1 | 103,340 | 10 | 206,681 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, that he found out his game-coin score become equal to 0.
Kolya remembers that at the beginning of the game his game-coin score was equal to n and that he have bought only some houses (for 1 234 567 game-coins each), cars (for 123 456 game-coins each) and computers (for 1 234 game-coins each).
Kolya is now interested, whether he could have spent all of his initial n game-coins buying only houses, cars and computers or there is a bug in the game. Formally, is there a triple of non-negative integers a, b and c such that a × 1 234 567 + b × 123 456 + c × 1 234 = n?
Please help Kolya answer this question.
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 109) — Kolya's initial game-coin score.
Output
Print "YES" (without quotes) if it's possible that Kolya spent all of his initial n coins buying only houses, cars and computers. Otherwise print "NO" (without quotes).
Examples
Input
1359257
Output
YES
Input
17851817
Output
NO
Note
In the first sample, one of the possible solutions is to buy one house, one car and one computer, spending 1 234 567 + 123 456 + 1234 = 1 359 257 game-coins in total.
Submitted Solution:
```
1359257
``` | instruction | 0 | 103,341 | 10 | 206,682 |
No | output | 1 | 103,341 | 10 | 206,683 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, that he found out his game-coin score become equal to 0.
Kolya remembers that at the beginning of the game his game-coin score was equal to n and that he have bought only some houses (for 1 234 567 game-coins each), cars (for 123 456 game-coins each) and computers (for 1 234 game-coins each).
Kolya is now interested, whether he could have spent all of his initial n game-coins buying only houses, cars and computers or there is a bug in the game. Formally, is there a triple of non-negative integers a, b and c such that a × 1 234 567 + b × 123 456 + c × 1 234 = n?
Please help Kolya answer this question.
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 109) — Kolya's initial game-coin score.
Output
Print "YES" (without quotes) if it's possible that Kolya spent all of his initial n coins buying only houses, cars and computers. Otherwise print "NO" (without quotes).
Examples
Input
1359257
Output
YES
Input
17851817
Output
NO
Note
In the first sample, one of the possible solutions is to buy one house, one car and one computer, spending 1 234 567 + 123 456 + 1234 = 1 359 257 game-coins in total.
Submitted Solution:
```
x = int(input())
o = [1234567, 123456, 1234]
c = 1
t = x
inc = 0
def ok():
global c
c = 0
def test(g):
for p in range(3):
if g % o[p] == 0:
ok()
break
for i in range (int(x/123456)):
test(x-(inc*1234567))
test(x - (inc * 123456))
if c != 0:
for i in range (int(x/1234567)):
temp = 1234567*i
for p in range (i*11):
test(x-(p*123456)-temp)
elif c != 0:
for i in range (int(x/1234567)):
temp = 1234567*i
for p in range (i*1001):
test(x-(p*1234)-temp)
elif c != 0:
for i in range (int(x/123456)):
temp = 1234567*i
for p in range (i*1001):
test(x-(p*1234)-temp)
if c == 0:
print("YES")
else:
print("NO")
``` | instruction | 0 | 103,342 | 10 | 206,684 |
No | output | 1 | 103,342 | 10 | 206,685 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, that he found out his game-coin score become equal to 0.
Kolya remembers that at the beginning of the game his game-coin score was equal to n and that he have bought only some houses (for 1 234 567 game-coins each), cars (for 123 456 game-coins each) and computers (for 1 234 game-coins each).
Kolya is now interested, whether he could have spent all of his initial n game-coins buying only houses, cars and computers or there is a bug in the game. Formally, is there a triple of non-negative integers a, b and c such that a × 1 234 567 + b × 123 456 + c × 1 234 = n?
Please help Kolya answer this question.
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 109) — Kolya's initial game-coin score.
Output
Print "YES" (without quotes) if it's possible that Kolya spent all of his initial n coins buying only houses, cars and computers. Otherwise print "NO" (without quotes).
Examples
Input
1359257
Output
YES
Input
17851817
Output
NO
Note
In the first sample, one of the possible solutions is to buy one house, one car and one computer, spending 1 234 567 + 123 456 + 1234 = 1 359 257 game-coins in total.
Submitted Solution:
```
x = int(input())
o = [1234567, 123456, 1234]
c = 1
t = x
def ok():
global c
c = 0
def test(g):
for p in range(3):
if g % o[p] == 0 and g >= 0:
ok()
break
#for i in range (int(x/1234)):
# test(x-(i*1234567))
# test(x - (i * 123456))
# test(x - (i * 1234))
if c != 0:
for i in range (int(x/1234567)+1):
if c == 0:
break
temp = 1234567*i
test(x-temp)
for p in range (i*11):
if c == 0:
break
test(x-(p*123456)-temp)
elif c != 0:
for i in range(int(x/1234567)+1):
if c == 0:
break
temp = 1234567*i
test(x - temp)
for p in range(i*1001):
if c == 0:
break
test(x-(p*1234)-temp)
elif c != 0:
for i in range (int(x/123456)+1):
if c == 0:
break
temp = 1234567*i
test(x - temp)
for p in range (i*1001):
if c == 0:
break
test(x-(p*1234)-temp)
if c == 0:
print("YES")
else:
print("NO")
``` | instruction | 0 | 103,343 | 10 | 206,686 |
No | output | 1 | 103,343 | 10 | 206,687 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bankopolis, the city you already know, finally got a new bank opened! Unfortunately, its security system is not yet working fine... Meanwhile hacker Leha arrived in Bankopolis and decided to test the system!
Bank has n cells for clients' money. A sequence from n numbers a1, a2, ..., an describes the amount of money each client has. Leha wants to make requests to the database of the bank, finding out the total amount of money on some subsegments of the sequence and changing values of the sequence on some subsegments. Using a bug in the system, Leha can requests two types of queries to the database:
* 1 l r x y denoting that Leha changes each digit x to digit y in each element of sequence ai, for which l ≤ i ≤ r is holds. For example, if we change in number 11984381 digit 8 to 4, we get 11944341. It's worth noting that Leha, in order to stay in the shadow, never changes digits in the database to 0, i.e. y ≠ 0.
* 2 l r denoting that Leha asks to calculate and print the sum of such elements of sequence ai, for which l ≤ i ≤ r holds.
As Leha is a white-hat hacker, he don't want to test this vulnerability on a real database. You are to write a similar database for Leha to test.
Input
The first line of input contains two integers n and q (1 ≤ n ≤ 105, 1 ≤ q ≤ 105) denoting amount of cells in the bank and total amount of queries respectively.
The following line contains n integers a1, a2, ..., an (1 ≤ ai < 109) denoting the amount of money in each cell initially. These integers do not contain leading zeros.
Each of the following q lines has one of the formats:
* 1 l r x y (1 ≤ l ≤ r ≤ n, 0 ≤ x ≤ 9, 1 ≤ y ≤ 9), denoting Leha asks to change each digit x on digit y for each element ai of the sequence for which l ≤ i ≤ r holds;
* 2 l r (1 ≤ l ≤ r ≤ n), denoting you have to calculate and print the sum of elements ai for which l ≤ i ≤ r holds.
Output
For each second type query print a single number denoting the required sum.
Examples
Input
5 5
38 43 4 12 70
1 1 3 4 8
2 2 4
1 4 5 0 8
1 2 5 8 7
2 1 5
Output
103
207
Input
5 5
25 36 39 40 899
1 1 3 2 7
2 1 2
1 3 5 9 1
1 4 4 0 9
2 1 5
Output
111
1002
Note
Let's look at the example testcase.
Initially the sequence is [38, 43, 4, 12, 70].
After the first change each digit equal to 4 becomes 8 for each element with index in interval [1; 3]. Thus, the new sequence is [38, 83, 8, 12, 70].
The answer for the first sum's query is the sum in the interval [2; 4], which equal 83 + 8 + 12 = 103, so the answer to this query is 103.
The sequence becomes [38, 83, 8, 12, 78] after the second change and [38, 73, 7, 12, 77] after the third.
The answer for the second sum's query is 38 + 73 + 7 + 12 + 77 = 207.
Submitted Solution:
```
import sys
lines = sys.stdin.readlines()
print(lines)
l = lines[1].split()
edit = lambda l, i, j, a, b: [l[x].replace(a, b) for x in range(i - 1, j)]
_sum = lambda l, i, j: sum(map(int, l[i - 1:j]))
``` | instruction | 0 | 103,378 | 10 | 206,756 |
No | output | 1 | 103,378 | 10 | 206,757 |
Provide a correct Python 3 solution for this coding contest problem.
You have N items and a bag of strength W. The i-th item has a weight of w_i and a value of v_i.
You will select some of the items and put them in the bag. Here, the total weight of the selected items needs to be at most W.
Your objective is to maximize the total value of the selected items.
Constraints
* 1 ≤ N ≤ 100
* 1 ≤ W ≤ 10^9
* 1 ≤ w_i ≤ 10^9
* For each i = 2,3,...,N, w_1 ≤ w_i ≤ w_1 + 3.
* 1 ≤ v_i ≤ 10^7
* W, each w_i and v_i are integers.
Input
Input is given from Standard Input in the following format:
N W
w_1 v_1
w_2 v_2
:
w_N v_N
Output
Print the maximum possible total value of the selected items.
Examples
Input
4 6
2 1
3 4
4 10
3 4
Output
11
Input
4 6
2 1
3 7
4 10
3 6
Output
13
Input
4 10
1 100
1 100
1 100
1 100
Output
400
Input
4 1
10 100
10 100
10 100
10 100
Output
0 | instruction | 0 | 103,543 | 10 | 207,086 |
"Correct Solution:
```
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
n,W = inpl()
a = [inpl() for _ in range(n)]
gds = [[0] for _ in range(4)]
a.sort(key = lambda x:x[1], reverse = True)
a.sort(key = lambda x:x[0])
# print(a)
mi = a[0][0]
for i,(w,v) in enumerate(a):
ind = w - mi
gds[ind].append(v)
we = [i+mi for i in range(4)]
cnt = [0] * 4
for i in range(4):
cnt[i] = len(gds[i])
tmp = itertools.accumulate(gds[i])
gds[i] = list(tmp)
# print(gds)
it = itertools.product(range(cnt[0]),range(cnt[1]),range(cnt[2]),range(cnt[3]))
res = 0
for ww in it:
if sum(we[i]*ww[i] for i in range(4)) > W: continue
now = sum(gds[i][ww[i]] for i in range(4))
res = max(now, res)
print(res)
``` | output | 1 | 103,543 | 10 | 207,087 |
Provide a correct Python 3 solution for this coding contest problem.
You have N items and a bag of strength W. The i-th item has a weight of w_i and a value of v_i.
You will select some of the items and put them in the bag. Here, the total weight of the selected items needs to be at most W.
Your objective is to maximize the total value of the selected items.
Constraints
* 1 ≤ N ≤ 100
* 1 ≤ W ≤ 10^9
* 1 ≤ w_i ≤ 10^9
* For each i = 2,3,...,N, w_1 ≤ w_i ≤ w_1 + 3.
* 1 ≤ v_i ≤ 10^7
* W, each w_i and v_i are integers.
Input
Input is given from Standard Input in the following format:
N W
w_1 v_1
w_2 v_2
:
w_N v_N
Output
Print the maximum possible total value of the selected items.
Examples
Input
4 6
2 1
3 4
4 10
3 4
Output
11
Input
4 6
2 1
3 7
4 10
3 6
Output
13
Input
4 10
1 100
1 100
1 100
1 100
Output
400
Input
4 1
10 100
10 100
10 100
10 100
Output
0 | instruction | 0 | 103,544 | 10 | 207,088 |
"Correct Solution:
```
import sys
input = sys.stdin.readline
N, W = map(int, input().split())
wv = [tuple(map(int, input().split())) for _ in range(N)]
w1 = wv[0][0]
dp = [[0] * 301 for _ in range(N+1)]
for w, v in wv:
w -= w1
for i in range(1, N+1)[::-1]:
for j in range(w, 301):
dp[i][j] = max(dp[i][j], dp[i-1][j-w] + v)
ans = 0
for i in range(N+1):
w = W - w1*i
if w < 0:
break
ans = max(ans, dp[i][min(300, W-w1*i)])
print(ans)
``` | output | 1 | 103,544 | 10 | 207,089 |
Provide a correct Python 3 solution for this coding contest problem.
You have N items and a bag of strength W. The i-th item has a weight of w_i and a value of v_i.
You will select some of the items and put them in the bag. Here, the total weight of the selected items needs to be at most W.
Your objective is to maximize the total value of the selected items.
Constraints
* 1 ≤ N ≤ 100
* 1 ≤ W ≤ 10^9
* 1 ≤ w_i ≤ 10^9
* For each i = 2,3,...,N, w_1 ≤ w_i ≤ w_1 + 3.
* 1 ≤ v_i ≤ 10^7
* W, each w_i and v_i are integers.
Input
Input is given from Standard Input in the following format:
N W
w_1 v_1
w_2 v_2
:
w_N v_N
Output
Print the maximum possible total value of the selected items.
Examples
Input
4 6
2 1
3 4
4 10
3 4
Output
11
Input
4 6
2 1
3 7
4 10
3 6
Output
13
Input
4 10
1 100
1 100
1 100
1 100
Output
400
Input
4 1
10 100
10 100
10 100
10 100
Output
0 | instruction | 0 | 103,545 | 10 | 207,090 |
"Correct Solution:
```
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
def main(N, W, items):
w1 = items[0][0]
dp = [[[0] * (3 * N + 1) for _ in range(N + 1)] for __ in range(N + 1)]
dp[0][0][0] = 0
for i in range(N):
iw, iv = items[i]
iw -= w1
for j in range(N + 1):
for w in range(3 * N + 1):
if j * w1 + w > W: break
if w >= iw and j >= 1:
dp[i + 1][j][w] = max(dp[i][j][w], dp[i][j - 1][w - iw] + iv)
else:
dp[i + 1][j][w] = dp[i][j][w]
ans = 0
for j in range(N + 1):
for w in range(3 * N + 1):
ans = max(ans, dp[N][j][w])
print(ans)
if __name__ == '__main__':
input = sys.stdin.readline
N, W = map(int, input().split())
items = [tuple(map(int, input().split())) for _ in range(N)]
main(N, W, items)
``` | output | 1 | 103,545 | 10 | 207,091 |
Provide a correct Python 3 solution for this coding contest problem.
You have N items and a bag of strength W. The i-th item has a weight of w_i and a value of v_i.
You will select some of the items and put them in the bag. Here, the total weight of the selected items needs to be at most W.
Your objective is to maximize the total value of the selected items.
Constraints
* 1 ≤ N ≤ 100
* 1 ≤ W ≤ 10^9
* 1 ≤ w_i ≤ 10^9
* For each i = 2,3,...,N, w_1 ≤ w_i ≤ w_1 + 3.
* 1 ≤ v_i ≤ 10^7
* W, each w_i and v_i are integers.
Input
Input is given from Standard Input in the following format:
N W
w_1 v_1
w_2 v_2
:
w_N v_N
Output
Print the maximum possible total value of the selected items.
Examples
Input
4 6
2 1
3 4
4 10
3 4
Output
11
Input
4 6
2 1
3 7
4 10
3 6
Output
13
Input
4 10
1 100
1 100
1 100
1 100
Output
400
Input
4 1
10 100
10 100
10 100
10 100
Output
0 | instruction | 0 | 103,546 | 10 | 207,092 |
"Correct Solution:
```
from itertools import accumulate, product
# 入力
N, W = map(int, input().split())
w, v = (
zip(*(map(int, input().split()) for _ in range(N))) if N else
((), ())
)
# 各重さの物のリスト(価値について降順)
u = [
[0] + list(
accumulate(
sorted(
(
y for x, y in zip(w, v)
if x == i
),
reverse=True
)
)
)
for i in range(w[0], w[0] + 4)
]
# 重さが w_1, w_1 + 1, w_1 + 2 の物をa, b, c 個選んだとき、
# 重さが w_1 + 3 の物の選び方は一意に定まることを用いて最適値を求める
ans = max(
sum(u[i][k] for i, k in enumerate(t)) +
u[3][
min(
len(u[3]) - 1,
(W - sum(k * (w[0] + i) for i, k in enumerate(t))) // (w[0] + 3)
)
]
for t in product(*map(range, map(len, u[:3])))
if sum(k * (w[0] + i) for i, k in enumerate(t)) <= W
)
# 出力
print(ans)
``` | output | 1 | 103,546 | 10 | 207,093 |
Provide a correct Python 3 solution for this coding contest problem.
You have N items and a bag of strength W. The i-th item has a weight of w_i and a value of v_i.
You will select some of the items and put them in the bag. Here, the total weight of the selected items needs to be at most W.
Your objective is to maximize the total value of the selected items.
Constraints
* 1 ≤ N ≤ 100
* 1 ≤ W ≤ 10^9
* 1 ≤ w_i ≤ 10^9
* For each i = 2,3,...,N, w_1 ≤ w_i ≤ w_1 + 3.
* 1 ≤ v_i ≤ 10^7
* W, each w_i and v_i are integers.
Input
Input is given from Standard Input in the following format:
N W
w_1 v_1
w_2 v_2
:
w_N v_N
Output
Print the maximum possible total value of the selected items.
Examples
Input
4 6
2 1
3 4
4 10
3 4
Output
11
Input
4 6
2 1
3 7
4 10
3 6
Output
13
Input
4 10
1 100
1 100
1 100
1 100
Output
400
Input
4 1
10 100
10 100
10 100
10 100
Output
0 | instruction | 0 | 103,547 | 10 | 207,094 |
"Correct Solution:
```
from collections import defaultdict
import sys
input = sys.stdin.readline
def main():
N, W = map(int, input().split())
items = [tuple(map(int, input().split())) for _ in range(N)]
dd = defaultdict(int)
dd[0] = 0
for w, v in items:
for tw, tv in list(dd.items()):
if tw + w <= W:
dd[tw + w] = max(tv + v, dd[tw + w])
print(max(dd.values()))
if __name__ == "__main__":
main()
``` | output | 1 | 103,547 | 10 | 207,095 |
Provide a correct Python 3 solution for this coding contest problem.
You have N items and a bag of strength W. The i-th item has a weight of w_i and a value of v_i.
You will select some of the items and put them in the bag. Here, the total weight of the selected items needs to be at most W.
Your objective is to maximize the total value of the selected items.
Constraints
* 1 ≤ N ≤ 100
* 1 ≤ W ≤ 10^9
* 1 ≤ w_i ≤ 10^9
* For each i = 2,3,...,N, w_1 ≤ w_i ≤ w_1 + 3.
* 1 ≤ v_i ≤ 10^7
* W, each w_i and v_i are integers.
Input
Input is given from Standard Input in the following format:
N W
w_1 v_1
w_2 v_2
:
w_N v_N
Output
Print the maximum possible total value of the selected items.
Examples
Input
4 6
2 1
3 4
4 10
3 4
Output
11
Input
4 6
2 1
3 7
4 10
3 6
Output
13
Input
4 10
1 100
1 100
1 100
1 100
Output
400
Input
4 1
10 100
10 100
10 100
10 100
Output
0 | instruction | 0 | 103,548 | 10 | 207,096 |
"Correct Solution:
```
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys
N, W = map(int, input().split())
d = defaultdict(list)
w1 = 0
for n in range(N):
w, v = map(int, input().split())
d[w].append(v)
if n == 0:
w1 = w
# 各重さごとに、価値の高い順にK個とったときの価値の総和を求めておく
best_ks = {}
for w in range(w1, w + 4):
vs = sorted(d[w], reverse=True)
s = 0
best_k = [0]
for v in vs:
s += v
best_k.append(s)
best_ks[w] = best_k
ans = 0
for w1_num in range(len(d[w1])+1):
for w2_num in range(len(d[w1+1])+1):
for w3_num in range(len(d[w1+2])+1):
for w4_num in range(len(d[w1+3])+1):
weight \
= w1_num * w1 \
+ w2_num * (w1 + 1) \
+ w3_num * (w1 + 2) \
+ w4_num * (w1 + 3)
# print(w1_num, w2_num, w3_num, w4_num, weight)
if weight > W:
continue
value \
= best_ks[w1][w1_num] \
+ best_ks[w1 + 1][w2_num] \
+ best_ks[w1 + 2][w3_num] \
+ best_ks[w1 + 3][w4_num]
ans = max(ans, value)
print(ans)
``` | output | 1 | 103,548 | 10 | 207,097 |
Provide a correct Python 3 solution for this coding contest problem.
You have N items and a bag of strength W. The i-th item has a weight of w_i and a value of v_i.
You will select some of the items and put them in the bag. Here, the total weight of the selected items needs to be at most W.
Your objective is to maximize the total value of the selected items.
Constraints
* 1 ≤ N ≤ 100
* 1 ≤ W ≤ 10^9
* 1 ≤ w_i ≤ 10^9
* For each i = 2,3,...,N, w_1 ≤ w_i ≤ w_1 + 3.
* 1 ≤ v_i ≤ 10^7
* W, each w_i and v_i are integers.
Input
Input is given from Standard Input in the following format:
N W
w_1 v_1
w_2 v_2
:
w_N v_N
Output
Print the maximum possible total value of the selected items.
Examples
Input
4 6
2 1
3 4
4 10
3 4
Output
11
Input
4 6
2 1
3 7
4 10
3 6
Output
13
Input
4 10
1 100
1 100
1 100
1 100
Output
400
Input
4 1
10 100
10 100
10 100
10 100
Output
0 | instruction | 0 | 103,549 | 10 | 207,098 |
"Correct Solution:
```
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline
n,W,*wv = map(int,read().split())
res = [[] for _ in range(n)]
w0 = wv[0]
mp = iter(wv)
for w,v in zip(mp,mp):
res[w-w0].append(v)
from itertools import accumulate
d = [None for _ in range(4)]
for i in range(4):
r = res[i]
r.sort(reverse=True)
d[i] = {(w0+i)*(j+1):wj for j,wj in enumerate(accumulate(r))}
d[i][0] = 0
#print(r,w0+i)
#print(d[i])
def merge(d1,d2):
res = {}
for w1,v1 in d1.items():
for w2,v2 in d2.items():
w = w1+w2
v = v1+v2
if w in res: res[w] = max(res[w],v)
else: res[w] = v
return res
#print(d)
d1 = merge(d[0],d[1])
d2 = merge(d[2],d[3])
dd = merge(d1,d2)
#print(d)
#print(d1)
#print(d2)
#print(dd)
ans = 0
for w,v in dd.items():
if w <= W and ans < v:
ans = v
print(ans)
``` | output | 1 | 103,549 | 10 | 207,099 |
Provide a correct Python 3 solution for this coding contest problem.
You have N items and a bag of strength W. The i-th item has a weight of w_i and a value of v_i.
You will select some of the items and put them in the bag. Here, the total weight of the selected items needs to be at most W.
Your objective is to maximize the total value of the selected items.
Constraints
* 1 ≤ N ≤ 100
* 1 ≤ W ≤ 10^9
* 1 ≤ w_i ≤ 10^9
* For each i = 2,3,...,N, w_1 ≤ w_i ≤ w_1 + 3.
* 1 ≤ v_i ≤ 10^7
* W, each w_i and v_i are integers.
Input
Input is given from Standard Input in the following format:
N W
w_1 v_1
w_2 v_2
:
w_N v_N
Output
Print the maximum possible total value of the selected items.
Examples
Input
4 6
2 1
3 4
4 10
3 4
Output
11
Input
4 6
2 1
3 7
4 10
3 6
Output
13
Input
4 10
1 100
1 100
1 100
1 100
Output
400
Input
4 1
10 100
10 100
10 100
10 100
Output
0 | instruction | 0 | 103,550 | 10 | 207,100 |
"Correct Solution:
```
from collections import *
from heapq import *
from itertools import *
from fractions import gcd
import sys
from decimal import *
import copy
from bisect import *
input=lambda :sys.stdin.readline().rstrip()
N,W=map(int,input().split())
WV=[list(map(int,input().split())) for i in range(N)]
lst=[]
for w,v in WV:
for i in range(len(lst)):
w1,v1=lst[i]
if w1:
lst.append([w1+w,v1+v])
lst.append([w,v])
lst=sorted(lst,key=lambda x:x[0],reverse=True)
while lst and lst[-1][0]==0:
lst.pop()
w,v=lst[-1]
for i in range(len(lst)-1)[::-1]:
w1,v1=lst[i]
if v1<=v:
lst[i][0]=0
lst[i][1]=0
else:
v=v1
#print(lst)
print(max([v for w,v in lst if w<=W]))
``` | output | 1 | 103,550 | 10 | 207,101 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have N items and a bag of strength W. The i-th item has a weight of w_i and a value of v_i.
You will select some of the items and put them in the bag. Here, the total weight of the selected items needs to be at most W.
Your objective is to maximize the total value of the selected items.
Constraints
* 1 ≤ N ≤ 100
* 1 ≤ W ≤ 10^9
* 1 ≤ w_i ≤ 10^9
* For each i = 2,3,...,N, w_1 ≤ w_i ≤ w_1 + 3.
* 1 ≤ v_i ≤ 10^7
* W, each w_i and v_i are integers.
Input
Input is given from Standard Input in the following format:
N W
w_1 v_1
w_2 v_2
:
w_N v_N
Output
Print the maximum possible total value of the selected items.
Examples
Input
4 6
2 1
3 4
4 10
3 4
Output
11
Input
4 6
2 1
3 7
4 10
3 6
Output
13
Input
4 10
1 100
1 100
1 100
1 100
Output
400
Input
4 1
10 100
10 100
10 100
10 100
Output
0
Submitted Solution:
```
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))
from itertools import accumulate, product
N, W = inpl()
A = []
for _ in range(N):
A.append(inpl())
B = [[] for _ in range(4)]
w1 = A[0][0]
for w, v in A:
B[w-w1].append(v)
B = [sorted(b, reverse=True) for b in B]
C = [[0] + list(accumulate(b)) for b in B]
res = 0
for L in product(enumerate(C[0]),
enumerate(C[1]),
enumerate(C[2]),
enumerate(C[3])):
if sum([(w1+i)*l[0] for i, l in enumerate(L)]) <= W:
res = max(res, sum([l[1] for l in L]))
print(res)
``` | instruction | 0 | 103,554 | 10 | 207,108 |
Yes | output | 1 | 103,554 | 10 | 207,109 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have N items and a bag of strength W. The i-th item has a weight of w_i and a value of v_i.
You will select some of the items and put them in the bag. Here, the total weight of the selected items needs to be at most W.
Your objective is to maximize the total value of the selected items.
Constraints
* 1 ≤ N ≤ 100
* 1 ≤ W ≤ 10^9
* 1 ≤ w_i ≤ 10^9
* For each i = 2,3,...,N, w_1 ≤ w_i ≤ w_1 + 3.
* 1 ≤ v_i ≤ 10^7
* W, each w_i and v_i are integers.
Input
Input is given from Standard Input in the following format:
N W
w_1 v_1
w_2 v_2
:
w_N v_N
Output
Print the maximum possible total value of the selected items.
Examples
Input
4 6
2 1
3 4
4 10
3 4
Output
11
Input
4 6
2 1
3 7
4 10
3 6
Output
13
Input
4 10
1 100
1 100
1 100
1 100
Output
400
Input
4 1
10 100
10 100
10 100
10 100
Output
0
Submitted Solution:
```
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)
MAXDW = 300
INF = 10 ** 12
n, maxw = map(int, input().split())
list_dw = []
list_v = []
for i in range(n):
w, v = map(int, input().split())
if i == 0:
w0 = w
list_dw.append(0)
else:
list_dw.append(w - w0)
list_v.append(v)
list_maxv = [[[None] * (MAXDW + 1) for _ in range(n + 1)] for _ in range(n + 1)]
def maxv(i, k, dw):
# item[:i], n of items k
if i == 0:
if k == 0 and dw == 0:
return 0
else:
return -INF
elif k == 0:
if dw == 0:
return 0
else:
return -INF
elif dw < 0:
return -INF
elif list_maxv[i][k][dw] is not None:
return list_maxv[i][k][dw]
else:
result = max([
list_v[i - 1] + maxv(i - 1, k - 1, dw - list_dw[i - 1]),
maxv(i - 1, k, dw),
])
list_maxv[i][k][dw] = result
return result
m = 0
for k in range(n + 1):
for dw in range(MAXDW + 1):
if k * w0 + dw <= maxw:
m = max(m, maxv(n, k, dw))
print(m)
``` | instruction | 0 | 103,557 | 10 | 207,114 |
No | output | 1 | 103,557 | 10 | 207,115 |
Provide a correct Python 3 solution for this coding contest problem.
I conducted an exit poll of the shopping amount at a department store. Create a program that takes the shopping amount data as input, calculates the average shopping amount per person, and outputs it. The number of people surveyed shall be 100,000 or less, and the shopping amount per person shall not exceed 1 million yen.
Input
The input is given in the following format:
n
v1
v2
::
vn
The first line gives the number of people surveyed n, and the following n lines give the integer vi representing the purchase amount of the ith person.
Output
Please output the average shopping amount (integer: rounded down to the nearest whole number) on one line.
Example
Input
6
12300
5600
33800
0
26495
52000
Output
21699 | instruction | 0 | 103,582 | 10 | 207,164 |
"Correct Solution:
```
from statistics import mean
inputCount = int(input())
prices = [int(input()) for lp in range(inputCount)]
average = mean(prices)
print(int(average))
``` | output | 1 | 103,582 | 10 | 207,165 |
Provide a correct Python 3 solution for this coding contest problem.
I conducted an exit poll of the shopping amount at a department store. Create a program that takes the shopping amount data as input, calculates the average shopping amount per person, and outputs it. The number of people surveyed shall be 100,000 or less, and the shopping amount per person shall not exceed 1 million yen.
Input
The input is given in the following format:
n
v1
v2
::
vn
The first line gives the number of people surveyed n, and the following n lines give the integer vi representing the purchase amount of the ith person.
Output
Please output the average shopping amount (integer: rounded down to the nearest whole number) on one line.
Example
Input
6
12300
5600
33800
0
26495
52000
Output
21699 | instruction | 0 | 103,583 | 10 | 207,166 |
"Correct Solution:
```
n=int(input())
print(sum([int(input()) for _ in range(n)])//n)
``` | output | 1 | 103,583 | 10 | 207,167 |
Provide a correct Python 3 solution for this coding contest problem.
I conducted an exit poll of the shopping amount at a department store. Create a program that takes the shopping amount data as input, calculates the average shopping amount per person, and outputs it. The number of people surveyed shall be 100,000 or less, and the shopping amount per person shall not exceed 1 million yen.
Input
The input is given in the following format:
n
v1
v2
::
vn
The first line gives the number of people surveyed n, and the following n lines give the integer vi representing the purchase amount of the ith person.
Output
Please output the average shopping amount (integer: rounded down to the nearest whole number) on one line.
Example
Input
6
12300
5600
33800
0
26495
52000
Output
21699 | instruction | 0 | 103,584 | 10 | 207,168 |
"Correct Solution:
```
n = int(input())
v = []
for i in range(n):
v.append(int(input()))
print(sum(v)//n)
``` | output | 1 | 103,584 | 10 | 207,169 |
Provide a correct Python 3 solution for this coding contest problem.
I conducted an exit poll of the shopping amount at a department store. Create a program that takes the shopping amount data as input, calculates the average shopping amount per person, and outputs it. The number of people surveyed shall be 100,000 or less, and the shopping amount per person shall not exceed 1 million yen.
Input
The input is given in the following format:
n
v1
v2
::
vn
The first line gives the number of people surveyed n, and the following n lines give the integer vi representing the purchase amount of the ith person.
Output
Please output the average shopping amount (integer: rounded down to the nearest whole number) on one line.
Example
Input
6
12300
5600
33800
0
26495
52000
Output
21699 | instruction | 0 | 103,585 | 10 | 207,170 |
"Correct Solution:
```
n=int(input())
m=0
for i in range(n):
m+=int(input())
print(m//n)
``` | output | 1 | 103,585 | 10 | 207,171 |
Provide a correct Python 3 solution for this coding contest problem.
I conducted an exit poll of the shopping amount at a department store. Create a program that takes the shopping amount data as input, calculates the average shopping amount per person, and outputs it. The number of people surveyed shall be 100,000 or less, and the shopping amount per person shall not exceed 1 million yen.
Input
The input is given in the following format:
n
v1
v2
::
vn
The first line gives the number of people surveyed n, and the following n lines give the integer vi representing the purchase amount of the ith person.
Output
Please output the average shopping amount (integer: rounded down to the nearest whole number) on one line.
Example
Input
6
12300
5600
33800
0
26495
52000
Output
21699 | instruction | 0 | 103,586 | 10 | 207,172 |
"Correct Solution:
```
n=int(input())
print(sum([int(input()) for i in range(n)])//n)
``` | output | 1 | 103,586 | 10 | 207,173 |
Provide a correct Python 3 solution for this coding contest problem.
I conducted an exit poll of the shopping amount at a department store. Create a program that takes the shopping amount data as input, calculates the average shopping amount per person, and outputs it. The number of people surveyed shall be 100,000 or less, and the shopping amount per person shall not exceed 1 million yen.
Input
The input is given in the following format:
n
v1
v2
::
vn
The first line gives the number of people surveyed n, and the following n lines give the integer vi representing the purchase amount of the ith person.
Output
Please output the average shopping amount (integer: rounded down to the nearest whole number) on one line.
Example
Input
6
12300
5600
33800
0
26495
52000
Output
21699 | instruction | 0 | 103,587 | 10 | 207,174 |
"Correct Solution:
```
n = int(input())
v_list = []
for i in range(n):
v = int(input())
v_list.append(v)
print(int(sum(v_list)/n))
``` | output | 1 | 103,587 | 10 | 207,175 |
Provide a correct Python 3 solution for this coding contest problem.
I conducted an exit poll of the shopping amount at a department store. Create a program that takes the shopping amount data as input, calculates the average shopping amount per person, and outputs it. The number of people surveyed shall be 100,000 or less, and the shopping amount per person shall not exceed 1 million yen.
Input
The input is given in the following format:
n
v1
v2
::
vn
The first line gives the number of people surveyed n, and the following n lines give the integer vi representing the purchase amount of the ith person.
Output
Please output the average shopping amount (integer: rounded down to the nearest whole number) on one line.
Example
Input
6
12300
5600
33800
0
26495
52000
Output
21699 | instruction | 0 | 103,588 | 10 | 207,176 |
"Correct Solution:
```
import math
n = int(input())
s = 0
for i in range(n):
s += int(input())
print(math.floor(s / n))
``` | output | 1 | 103,588 | 10 | 207,177 |
Provide a correct Python 3 solution for this coding contest problem.
I conducted an exit poll of the shopping amount at a department store. Create a program that takes the shopping amount data as input, calculates the average shopping amount per person, and outputs it. The number of people surveyed shall be 100,000 or less, and the shopping amount per person shall not exceed 1 million yen.
Input
The input is given in the following format:
n
v1
v2
::
vn
The first line gives the number of people surveyed n, and the following n lines give the integer vi representing the purchase amount of the ith person.
Output
Please output the average shopping amount (integer: rounded down to the nearest whole number) on one line.
Example
Input
6
12300
5600
33800
0
26495
52000
Output
21699 | instruction | 0 | 103,589 | 10 | 207,178 |
"Correct Solution:
```
import math
N = int(input())
s = 0
for l in range(N):
s += int(input())
print(s//N)
``` | output | 1 | 103,589 | 10 | 207,179 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
I conducted an exit poll of the shopping amount at a department store. Create a program that takes the shopping amount data as input, calculates the average shopping amount per person, and outputs it. The number of people surveyed shall be 100,000 or less, and the shopping amount per person shall not exceed 1 million yen.
Input
The input is given in the following format:
n
v1
v2
::
vn
The first line gives the number of people surveyed n, and the following n lines give the integer vi representing the purchase amount of the ith person.
Output
Please output the average shopping amount (integer: rounded down to the nearest whole number) on one line.
Example
Input
6
12300
5600
33800
0
26495
52000
Output
21699
Submitted Solution:
```
n = int(input())
prices = []
for _ in range(n):
price = int(input())
prices.append(price)
ans = int(sum(prices) / n)
print(ans)
``` | instruction | 0 | 103,590 | 10 | 207,180 |
Yes | output | 1 | 103,590 | 10 | 207,181 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.