message stringlengths 2 39.6k | message_type stringclasses 2 values | message_id int64 0 1 | conversation_id int64 219 108k | cluster float64 11 11 | __index_level_0__ int64 438 217k |
|---|---|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is an interactive problem. You should use flush operation after each printed line. For example, in C++ you should use fflush(stdout), in Java you should use System.out.flush(), and in Pascal — flush(output).
In this problem you should guess an array a which is unknown for you. The only information you have initially is the length n of the array a.
The only allowed action is to ask the sum of two elements by their indices. Formally, you can print two indices i and j (the indices should be distinct). Then your program should read the response: the single integer equals to ai + aj.
It is easy to prove that it is always possible to guess the array using at most n requests.
Write a program that will guess the array a by making at most n requests.
Interaction
In each test your program should guess a single array.
The input starts with a line containing integer n (3 ≤ n ≤ 5000) — the length of the array. Your program should read it at first.
After that your program should print to the standard output the requests about the sum of two elements or inform that the array is guessed.
* In case your program is making a request to ask the sum of two elements, it should print line in the format "? i j" (i and j are distinct integers between 1 and n), where i and j are indices in the array a.
* In case your program informs that the array is guessed, it should print line in the format "! a1 a2 ... an" (it is guaranteed that all ai are positive integers not exceeding 105), where ai is the i-th element of the array a.
The response on a request is a single integer equal to ai + aj, printed on a separate line.
Your program can do at most n requests. Note that the final line «! a1 a2 ... an» is not counted as a request.
Do not forget about flush operation after each printed line.
After you program prints the guessed array, it should terminate normally.
Example
Input
5
9
7
9
11
6
Output
? 1 5
? 2 3
? 4 1
? 5 2
? 3 4
! 4 6 1 5 5
Note
The format of a test to make a hack is:
* The first line contains an integer number n (3 ≤ n ≤ 5000) — the length of the array.
* The second line contains n numbers a1, a2, ..., an (1 ≤ ai ≤ 105) — the elements of the array to guess.
Submitted Solution:
```
n = int(input())
arr = [0]
print("? 1 2")
firsteq = int(input())
print("? 1 3")
seceq = int(input())
print("? 2 3")
thirdeq = int(input())
first = ( firsteq + seceq - thirdeq ) // 2
arr.append(first)
arr.append(firsteq)
arr.append(seceq)
n -= 3
for i in range(n):
i = i + 3
strs = "? 1 " + str(i)
print(strs)
arr.append(int(input()))
ans = "! "
ans += str(first) + " "
for i in range(2, n + 3):
temp = arr[i] - first
ans += str(temp) + " "
print(ans)
``` | instruction | 0 | 46,739 | 11 | 93,478 |
No | output | 1 | 46,739 | 11 | 93,479 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is an interactive problem. You should use flush operation after each printed line. For example, in C++ you should use fflush(stdout), in Java you should use System.out.flush(), and in Pascal — flush(output).
In this problem you should guess an array a which is unknown for you. The only information you have initially is the length n of the array a.
The only allowed action is to ask the sum of two elements by their indices. Formally, you can print two indices i and j (the indices should be distinct). Then your program should read the response: the single integer equals to ai + aj.
It is easy to prove that it is always possible to guess the array using at most n requests.
Write a program that will guess the array a by making at most n requests.
Interaction
In each test your program should guess a single array.
The input starts with a line containing integer n (3 ≤ n ≤ 5000) — the length of the array. Your program should read it at first.
After that your program should print to the standard output the requests about the sum of two elements or inform that the array is guessed.
* In case your program is making a request to ask the sum of two elements, it should print line in the format "? i j" (i and j are distinct integers between 1 and n), where i and j are indices in the array a.
* In case your program informs that the array is guessed, it should print line in the format "! a1 a2 ... an" (it is guaranteed that all ai are positive integers not exceeding 105), where ai is the i-th element of the array a.
The response on a request is a single integer equal to ai + aj, printed on a separate line.
Your program can do at most n requests. Note that the final line «! a1 a2 ... an» is not counted as a request.
Do not forget about flush operation after each printed line.
After you program prints the guessed array, it should terminate normally.
Example
Input
5
9
7
9
11
6
Output
? 1 5
? 2 3
? 4 1
? 5 2
? 3 4
! 4 6 1 5 5
Note
The format of a test to make a hack is:
* The first line contains an integer number n (3 ≤ n ≤ 5000) — the length of the array.
* The second line contains n numbers a1, a2, ..., an (1 ≤ ai ≤ 105) — the elements of the array to guess.
Submitted Solution:
```
# @author Nayara Souza
# UFCG - Universidade Federal de Campina Grande
# AA - Basico
n = int(input())
print('? 1 2')
a = int(input())
print('? 2 3')
b = int(input())
print('? 1 3')
c = int(input())
x = (a+b-c)//2
y = a - x
z = b - x
r = [x,y,z]
for i in range(4,n+1):
print('? 1 ' + str(i))
k = int(input())
r.append(k-r[0])
print('! ' + ' '.join(map(str,r)))
``` | instruction | 0 | 46,740 | 11 | 93,480 |
No | output | 1 | 46,740 | 11 | 93,481 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Example
Input
1+2*3+4
11
Output
M
Submitted Solution:
```
s = input()
t = int(input())
e1 = eval(s)
e2 = int(s[0])
i = 1
while i < len(s):
x = int(s[i+1])
if s[i] == '+':
e2 += x
else:
e2 *= x
i += 2
if e1 == t and e2 == t:
print("U")
elif e1 == t:
print("M")
elif e2 == t:
print("L")
else:
print("I")
``` | instruction | 0 | 46,999 | 11 | 93,998 |
Yes | output | 1 | 46,999 | 11 | 93,999 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Example
Input
1+2*3+4
11
Output
M
Submitted Solution:
```
# -*- coding: utf-8 -*-
S = input()
bob = int(input())
M = eval(S)
L = int(S[0])
for o, v in zip(S[1::2], S[2::2]):
if o == "*":
L *= int(v)
else:
L += int(v)
if M == L == bob:
print("U")
elif M == bob:
print("M")
elif L == bob:
print("L")
else:
print("I")
``` | instruction | 0 | 47,000 | 11 | 94,000 |
Yes | output | 1 | 47,000 | 11 | 94,001 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Example
Input
1+2*3+4
11
Output
M
Submitted Solution:
```
import re
class c(int):
def __add__(self,n):
return c(int(self)+int(n))
def __mul__(self,n):
return c(int(self)*int(n))
s=input()
d=int(input())
a=eval(re.sub(r'(\d+)',r'c(\1)',s))
b=int(s[0])
for i in range(1,len(s),2):
if s[i]=='+':b+=int(s[i+1])
else:b*=int(s[i+1])
if(a==b==d):e='U'
elif(a==d):e='M'
elif(b==d):e='L'
else:e='I'
print(e)
``` | instruction | 0 | 47,001 | 11 | 94,002 |
Yes | output | 1 | 47,001 | 11 | 94,003 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Example
Input
1+2*3+4
11
Output
M
Submitted Solution:
```
def left2right(formula):
ans = int(formula[0])
for i in range(1,len(formula),2):
ans = eval(str(ans) + formula[i:i+2])
return ans
formula = input()
val = int(input())
if left2right(formula) == val:
print('U' if eval(formula) == val else 'L')
else:
print('M' if eval(formula) == val else 'I')
``` | instruction | 0 | 47,002 | 11 | 94,004 |
Yes | output | 1 | 47,002 | 11 | 94,005 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Nauuo is a girl who loves writing comments.
One day, she posted a comment on Codeforces, wondering whether she would get upvotes or downvotes.
It's known that there were x persons who would upvote, y persons who would downvote, and there were also another z persons who would vote, but you don't know whether they would upvote or downvote. Note that each of the x+y+z people would vote exactly one time.
There are three different results: if there are more people upvote than downvote, the result will be "+"; if there are more people downvote than upvote, the result will be "-"; otherwise the result will be "0".
Because of the z unknown persons, the result may be uncertain (i.e. there are more than one possible results). More formally, the result is uncertain if and only if there exist two different situations of how the z persons vote, that the results are different in the two situations.
Tell Nauuo the result or report that the result is uncertain.
Input
The only line contains three integers x, y, z (0≤ x,y,z≤100), corresponding to the number of persons who would upvote, downvote or unknown.
Output
If there is only one possible result, print the result : "+", "-" or "0".
Otherwise, print "?" to report that the result is uncertain.
Examples
Input
3 7 0
Output
-
Input
2 0 1
Output
+
Input
1 1 0
Output
0
Input
0 0 1
Output
?
Note
In the first example, Nauuo would definitely get three upvotes and seven downvotes, so the only possible result is "-".
In the second example, no matter the person unknown downvotes or upvotes, Nauuo would get more upvotes than downvotes. So the only possible result is "+".
In the third example, Nauuo would definitely get one upvote and one downvote, so the only possible result is "0".
In the fourth example, if the only one person upvoted, the result would be "+", otherwise, the result would be "-". There are two possible results, so the result is uncertain. | instruction | 0 | 47,083 | 11 | 94,166 |
Tags: greedy
Correct Solution:
```
x,y,z=map(int,(input().split()))
if ((abs(x-y)-z)<=0 and z>0):
print('?')
elif(x-y)>0:
print('+')
elif(x-y)==0:
print('0')
elif(x-y)<0:
print('-')
``` | output | 1 | 47,083 | 11 | 94,167 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Nauuo is a girl who loves writing comments.
One day, she posted a comment on Codeforces, wondering whether she would get upvotes or downvotes.
It's known that there were x persons who would upvote, y persons who would downvote, and there were also another z persons who would vote, but you don't know whether they would upvote or downvote. Note that each of the x+y+z people would vote exactly one time.
There are three different results: if there are more people upvote than downvote, the result will be "+"; if there are more people downvote than upvote, the result will be "-"; otherwise the result will be "0".
Because of the z unknown persons, the result may be uncertain (i.e. there are more than one possible results). More formally, the result is uncertain if and only if there exist two different situations of how the z persons vote, that the results are different in the two situations.
Tell Nauuo the result or report that the result is uncertain.
Input
The only line contains three integers x, y, z (0≤ x,y,z≤100), corresponding to the number of persons who would upvote, downvote or unknown.
Output
If there is only one possible result, print the result : "+", "-" or "0".
Otherwise, print "?" to report that the result is uncertain.
Examples
Input
3 7 0
Output
-
Input
2 0 1
Output
+
Input
1 1 0
Output
0
Input
0 0 1
Output
?
Note
In the first example, Nauuo would definitely get three upvotes and seven downvotes, so the only possible result is "-".
In the second example, no matter the person unknown downvotes or upvotes, Nauuo would get more upvotes than downvotes. So the only possible result is "+".
In the third example, Nauuo would definitely get one upvote and one downvote, so the only possible result is "0".
In the fourth example, if the only one person upvoted, the result would be "+", otherwise, the result would be "-". There are two possible results, so the result is uncertain. | instruction | 0 | 47,084 | 11 | 94,168 |
Tags: greedy
Correct Solution:
```
arr = list(map(int, input().split()))
diff = abs(arr[0] - arr[1])
if diff == 0:
if arr[2] == 0:
print("0")
else:
print("?")
else:
if arr[2] < diff:
print("+" if arr[0] > arr[1] else "-")
else:
print("?")
``` | output | 1 | 47,084 | 11 | 94,169 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Nauuo is a girl who loves writing comments.
One day, she posted a comment on Codeforces, wondering whether she would get upvotes or downvotes.
It's known that there were x persons who would upvote, y persons who would downvote, and there were also another z persons who would vote, but you don't know whether they would upvote or downvote. Note that each of the x+y+z people would vote exactly one time.
There are three different results: if there are more people upvote than downvote, the result will be "+"; if there are more people downvote than upvote, the result will be "-"; otherwise the result will be "0".
Because of the z unknown persons, the result may be uncertain (i.e. there are more than one possible results). More formally, the result is uncertain if and only if there exist two different situations of how the z persons vote, that the results are different in the two situations.
Tell Nauuo the result or report that the result is uncertain.
Input
The only line contains three integers x, y, z (0≤ x,y,z≤100), corresponding to the number of persons who would upvote, downvote or unknown.
Output
If there is only one possible result, print the result : "+", "-" or "0".
Otherwise, print "?" to report that the result is uncertain.
Examples
Input
3 7 0
Output
-
Input
2 0 1
Output
+
Input
1 1 0
Output
0
Input
0 0 1
Output
?
Note
In the first example, Nauuo would definitely get three upvotes and seven downvotes, so the only possible result is "-".
In the second example, no matter the person unknown downvotes or upvotes, Nauuo would get more upvotes than downvotes. So the only possible result is "+".
In the third example, Nauuo would definitely get one upvote and one downvote, so the only possible result is "0".
In the fourth example, if the only one person upvoted, the result would be "+", otherwise, the result would be "-". There are two possible results, so the result is uncertain. | instruction | 0 | 47,085 | 11 | 94,170 |
Tags: greedy
Correct Solution:
```
x,y,z=map(int,input().split())
s=x-y
ma = s+z
mi = s-z
if ma > 0 and mi>0:
print("+")
elif ma < 0 and mi < 0 :
print("-")
elif mi==0 and ma==0:
print("0")
else:
print("?")
``` | output | 1 | 47,085 | 11 | 94,171 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Nauuo is a girl who loves writing comments.
One day, she posted a comment on Codeforces, wondering whether she would get upvotes or downvotes.
It's known that there were x persons who would upvote, y persons who would downvote, and there were also another z persons who would vote, but you don't know whether they would upvote or downvote. Note that each of the x+y+z people would vote exactly one time.
There are three different results: if there are more people upvote than downvote, the result will be "+"; if there are more people downvote than upvote, the result will be "-"; otherwise the result will be "0".
Because of the z unknown persons, the result may be uncertain (i.e. there are more than one possible results). More formally, the result is uncertain if and only if there exist two different situations of how the z persons vote, that the results are different in the two situations.
Tell Nauuo the result or report that the result is uncertain.
Input
The only line contains three integers x, y, z (0≤ x,y,z≤100), corresponding to the number of persons who would upvote, downvote or unknown.
Output
If there is only one possible result, print the result : "+", "-" or "0".
Otherwise, print "?" to report that the result is uncertain.
Examples
Input
3 7 0
Output
-
Input
2 0 1
Output
+
Input
1 1 0
Output
0
Input
0 0 1
Output
?
Note
In the first example, Nauuo would definitely get three upvotes and seven downvotes, so the only possible result is "-".
In the second example, no matter the person unknown downvotes or upvotes, Nauuo would get more upvotes than downvotes. So the only possible result is "+".
In the third example, Nauuo would definitely get one upvote and one downvote, so the only possible result is "0".
In the fourth example, if the only one person upvoted, the result would be "+", otherwise, the result would be "-". There are two possible results, so the result is uncertain. | instruction | 0 | 47,086 | 11 | 94,172 |
Tags: greedy
Correct Solution:
```
def getN():
return int(input())
def getList():
return list(map(int, input().split()))
x,y,z = getList()
if z >= abs(x-y):
if z == 0:
print(0)
else:
print("?")
else:
if x > y:
print("+")
else:
print("-")
``` | output | 1 | 47,086 | 11 | 94,173 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Nauuo is a girl who loves writing comments.
One day, she posted a comment on Codeforces, wondering whether she would get upvotes or downvotes.
It's known that there were x persons who would upvote, y persons who would downvote, and there were also another z persons who would vote, but you don't know whether they would upvote or downvote. Note that each of the x+y+z people would vote exactly one time.
There are three different results: if there are more people upvote than downvote, the result will be "+"; if there are more people downvote than upvote, the result will be "-"; otherwise the result will be "0".
Because of the z unknown persons, the result may be uncertain (i.e. there are more than one possible results). More formally, the result is uncertain if and only if there exist two different situations of how the z persons vote, that the results are different in the two situations.
Tell Nauuo the result or report that the result is uncertain.
Input
The only line contains three integers x, y, z (0≤ x,y,z≤100), corresponding to the number of persons who would upvote, downvote or unknown.
Output
If there is only one possible result, print the result : "+", "-" or "0".
Otherwise, print "?" to report that the result is uncertain.
Examples
Input
3 7 0
Output
-
Input
2 0 1
Output
+
Input
1 1 0
Output
0
Input
0 0 1
Output
?
Note
In the first example, Nauuo would definitely get three upvotes and seven downvotes, so the only possible result is "-".
In the second example, no matter the person unknown downvotes or upvotes, Nauuo would get more upvotes than downvotes. So the only possible result is "+".
In the third example, Nauuo would definitely get one upvote and one downvote, so the only possible result is "0".
In the fourth example, if the only one person upvoted, the result would be "+", otherwise, the result would be "-". There are two possible results, so the result is uncertain. | instruction | 0 | 47,087 | 11 | 94,174 |
Tags: greedy
Correct Solution:
```
X, Y, Z = map(int, input().split())
now = X - Y
if abs(now) <= Z:
if now == 0 and Z == 0: print('0')
else: print('?')
else:
if now > 0: print('+')
else: print('-')
``` | output | 1 | 47,087 | 11 | 94,175 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Nauuo is a girl who loves writing comments.
One day, she posted a comment on Codeforces, wondering whether she would get upvotes or downvotes.
It's known that there were x persons who would upvote, y persons who would downvote, and there were also another z persons who would vote, but you don't know whether they would upvote or downvote. Note that each of the x+y+z people would vote exactly one time.
There are three different results: if there are more people upvote than downvote, the result will be "+"; if there are more people downvote than upvote, the result will be "-"; otherwise the result will be "0".
Because of the z unknown persons, the result may be uncertain (i.e. there are more than one possible results). More formally, the result is uncertain if and only if there exist two different situations of how the z persons vote, that the results are different in the two situations.
Tell Nauuo the result or report that the result is uncertain.
Input
The only line contains three integers x, y, z (0≤ x,y,z≤100), corresponding to the number of persons who would upvote, downvote or unknown.
Output
If there is only one possible result, print the result : "+", "-" or "0".
Otherwise, print "?" to report that the result is uncertain.
Examples
Input
3 7 0
Output
-
Input
2 0 1
Output
+
Input
1 1 0
Output
0
Input
0 0 1
Output
?
Note
In the first example, Nauuo would definitely get three upvotes and seven downvotes, so the only possible result is "-".
In the second example, no matter the person unknown downvotes or upvotes, Nauuo would get more upvotes than downvotes. So the only possible result is "+".
In the third example, Nauuo would definitely get one upvote and one downvote, so the only possible result is "0".
In the fourth example, if the only one person upvoted, the result would be "+", otherwise, the result would be "-". There are two possible results, so the result is uncertain. | instruction | 0 | 47,088 | 11 | 94,176 |
Tags: greedy
Correct Solution:
```
from sys import stdin
def main():
X, Y, Z = map(int, input().split())
n = sum([X, Y, Z]) // 2
if not Z and X == Y:
print(0)
elif n < X and n < X + Z:
print('+')
elif n < Y and n < Y + Z:
print('-')
else:
print('?')
input = lambda: stdin.readline()
main()
``` | output | 1 | 47,088 | 11 | 94,177 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Nauuo is a girl who loves writing comments.
One day, she posted a comment on Codeforces, wondering whether she would get upvotes or downvotes.
It's known that there were x persons who would upvote, y persons who would downvote, and there were also another z persons who would vote, but you don't know whether they would upvote or downvote. Note that each of the x+y+z people would vote exactly one time.
There are three different results: if there are more people upvote than downvote, the result will be "+"; if there are more people downvote than upvote, the result will be "-"; otherwise the result will be "0".
Because of the z unknown persons, the result may be uncertain (i.e. there are more than one possible results). More formally, the result is uncertain if and only if there exist two different situations of how the z persons vote, that the results are different in the two situations.
Tell Nauuo the result or report that the result is uncertain.
Input
The only line contains three integers x, y, z (0≤ x,y,z≤100), corresponding to the number of persons who would upvote, downvote or unknown.
Output
If there is only one possible result, print the result : "+", "-" or "0".
Otherwise, print "?" to report that the result is uncertain.
Examples
Input
3 7 0
Output
-
Input
2 0 1
Output
+
Input
1 1 0
Output
0
Input
0 0 1
Output
?
Note
In the first example, Nauuo would definitely get three upvotes and seven downvotes, so the only possible result is "-".
In the second example, no matter the person unknown downvotes or upvotes, Nauuo would get more upvotes than downvotes. So the only possible result is "+".
In the third example, Nauuo would definitely get one upvote and one downvote, so the only possible result is "0".
In the fourth example, if the only one person upvoted, the result would be "+", otherwise, the result would be "-". There are two possible results, so the result is uncertain. | instruction | 0 | 47,089 | 11 | 94,178 |
Tags: greedy
Correct Solution:
```
x,y,z=map(int,input().split())
if(x>y and x>(y+z)):
res='+'
elif(y>x and y>(x+z)):
res='-'
elif(x==y and z==0):
res='0'
else:
res='?'
print(res)
``` | output | 1 | 47,089 | 11 | 94,179 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Nauuo is a girl who loves writing comments.
One day, she posted a comment on Codeforces, wondering whether she would get upvotes or downvotes.
It's known that there were x persons who would upvote, y persons who would downvote, and there were also another z persons who would vote, but you don't know whether they would upvote or downvote. Note that each of the x+y+z people would vote exactly one time.
There are three different results: if there are more people upvote than downvote, the result will be "+"; if there are more people downvote than upvote, the result will be "-"; otherwise the result will be "0".
Because of the z unknown persons, the result may be uncertain (i.e. there are more than one possible results). More formally, the result is uncertain if and only if there exist two different situations of how the z persons vote, that the results are different in the two situations.
Tell Nauuo the result or report that the result is uncertain.
Input
The only line contains three integers x, y, z (0≤ x,y,z≤100), corresponding to the number of persons who would upvote, downvote or unknown.
Output
If there is only one possible result, print the result : "+", "-" or "0".
Otherwise, print "?" to report that the result is uncertain.
Examples
Input
3 7 0
Output
-
Input
2 0 1
Output
+
Input
1 1 0
Output
0
Input
0 0 1
Output
?
Note
In the first example, Nauuo would definitely get three upvotes and seven downvotes, so the only possible result is "-".
In the second example, no matter the person unknown downvotes or upvotes, Nauuo would get more upvotes than downvotes. So the only possible result is "+".
In the third example, Nauuo would definitely get one upvote and one downvote, so the only possible result is "0".
In the fourth example, if the only one person upvoted, the result would be "+", otherwise, the result would be "-". There are two possible results, so the result is uncertain. | instruction | 0 | 47,090 | 11 | 94,180 |
Tags: greedy
Correct Solution:
```
a,b,c=map(int,input().split())
if c==0:
if a>b:
print('+')
elif a<b:
print('-')
else:
print(0)
else:
if a-b>c:
print('+')
elif b-a>c:
print('-')
else:
print('?')
``` | output | 1 | 47,090 | 11 | 94,181 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Nauuo is a girl who loves writing comments.
One day, she posted a comment on Codeforces, wondering whether she would get upvotes or downvotes.
It's known that there were x persons who would upvote, y persons who would downvote, and there were also another z persons who would vote, but you don't know whether they would upvote or downvote. Note that each of the x+y+z people would vote exactly one time.
There are three different results: if there are more people upvote than downvote, the result will be "+"; if there are more people downvote than upvote, the result will be "-"; otherwise the result will be "0".
Because of the z unknown persons, the result may be uncertain (i.e. there are more than one possible results). More formally, the result is uncertain if and only if there exist two different situations of how the z persons vote, that the results are different in the two situations.
Tell Nauuo the result or report that the result is uncertain.
Input
The only line contains three integers x, y, z (0≤ x,y,z≤100), corresponding to the number of persons who would upvote, downvote or unknown.
Output
If there is only one possible result, print the result : "+", "-" or "0".
Otherwise, print "?" to report that the result is uncertain.
Examples
Input
3 7 0
Output
-
Input
2 0 1
Output
+
Input
1 1 0
Output
0
Input
0 0 1
Output
?
Note
In the first example, Nauuo would definitely get three upvotes and seven downvotes, so the only possible result is "-".
In the second example, no matter the person unknown downvotes or upvotes, Nauuo would get more upvotes than downvotes. So the only possible result is "+".
In the third example, Nauuo would definitely get one upvote and one downvote, so the only possible result is "0".
In the fourth example, if the only one person upvoted, the result would be "+", otherwise, the result would be "-". There are two possible results, so the result is uncertain.
Submitted Solution:
```
n, m, k = map(int, input().split())
if n > m and n > k + m:
print('+')
elif n < m and n + k < m:
print('-')
elif n == m and k == 0:
print('0')
else:
print('?')
``` | instruction | 0 | 47,091 | 11 | 94,182 |
Yes | output | 1 | 47,091 | 11 | 94,183 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Nauuo is a girl who loves writing comments.
One day, she posted a comment on Codeforces, wondering whether she would get upvotes or downvotes.
It's known that there were x persons who would upvote, y persons who would downvote, and there were also another z persons who would vote, but you don't know whether they would upvote or downvote. Note that each of the x+y+z people would vote exactly one time.
There are three different results: if there are more people upvote than downvote, the result will be "+"; if there are more people downvote than upvote, the result will be "-"; otherwise the result will be "0".
Because of the z unknown persons, the result may be uncertain (i.e. there are more than one possible results). More formally, the result is uncertain if and only if there exist two different situations of how the z persons vote, that the results are different in the two situations.
Tell Nauuo the result or report that the result is uncertain.
Input
The only line contains three integers x, y, z (0≤ x,y,z≤100), corresponding to the number of persons who would upvote, downvote or unknown.
Output
If there is only one possible result, print the result : "+", "-" or "0".
Otherwise, print "?" to report that the result is uncertain.
Examples
Input
3 7 0
Output
-
Input
2 0 1
Output
+
Input
1 1 0
Output
0
Input
0 0 1
Output
?
Note
In the first example, Nauuo would definitely get three upvotes and seven downvotes, so the only possible result is "-".
In the second example, no matter the person unknown downvotes or upvotes, Nauuo would get more upvotes than downvotes. So the only possible result is "+".
In the third example, Nauuo would definitely get one upvote and one downvote, so the only possible result is "0".
In the fourth example, if the only one person upvoted, the result would be "+", otherwise, the result would be "-". There are two possible results, so the result is uncertain.
Submitted Solution:
```
from sys import stdin
line = stdin.readline().split(" ")
x = int(line[0])
y = int(line[1])
z = int(line[2])
if (y-z > x):
print("-")
elif (x-z > y):
print("+")
elif ((y-z == x) and (x-z == y)):
print("0")
else:
print("?")
``` | instruction | 0 | 47,092 | 11 | 94,184 |
Yes | output | 1 | 47,092 | 11 | 94,185 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Nauuo is a girl who loves writing comments.
One day, she posted a comment on Codeforces, wondering whether she would get upvotes or downvotes.
It's known that there were x persons who would upvote, y persons who would downvote, and there were also another z persons who would vote, but you don't know whether they would upvote or downvote. Note that each of the x+y+z people would vote exactly one time.
There are three different results: if there are more people upvote than downvote, the result will be "+"; if there are more people downvote than upvote, the result will be "-"; otherwise the result will be "0".
Because of the z unknown persons, the result may be uncertain (i.e. there are more than one possible results). More formally, the result is uncertain if and only if there exist two different situations of how the z persons vote, that the results are different in the two situations.
Tell Nauuo the result or report that the result is uncertain.
Input
The only line contains three integers x, y, z (0≤ x,y,z≤100), corresponding to the number of persons who would upvote, downvote or unknown.
Output
If there is only one possible result, print the result : "+", "-" or "0".
Otherwise, print "?" to report that the result is uncertain.
Examples
Input
3 7 0
Output
-
Input
2 0 1
Output
+
Input
1 1 0
Output
0
Input
0 0 1
Output
?
Note
In the first example, Nauuo would definitely get three upvotes and seven downvotes, so the only possible result is "-".
In the second example, no matter the person unknown downvotes or upvotes, Nauuo would get more upvotes than downvotes. So the only possible result is "+".
In the third example, Nauuo would definitely get one upvote and one downvote, so the only possible result is "0".
In the fourth example, if the only one person upvoted, the result would be "+", otherwise, the result would be "-". There are two possible results, so the result is uncertain.
Submitted Solution:
```
a = [int(x) for x in input().split()]
if a[0] > a[1] and a[1] + a[2] < a[0]:
print("+")
elif a[1] > a[0] and a[0] + a[2] < a[1]:
print("-")
elif a[0] == a[1] and a[2] == 0:
print("0")
else:
print("?")
``` | instruction | 0 | 47,093 | 11 | 94,186 |
Yes | output | 1 | 47,093 | 11 | 94,187 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Nauuo is a girl who loves writing comments.
One day, she posted a comment on Codeforces, wondering whether she would get upvotes or downvotes.
It's known that there were x persons who would upvote, y persons who would downvote, and there were also another z persons who would vote, but you don't know whether they would upvote or downvote. Note that each of the x+y+z people would vote exactly one time.
There are three different results: if there are more people upvote than downvote, the result will be "+"; if there are more people downvote than upvote, the result will be "-"; otherwise the result will be "0".
Because of the z unknown persons, the result may be uncertain (i.e. there are more than one possible results). More formally, the result is uncertain if and only if there exist two different situations of how the z persons vote, that the results are different in the two situations.
Tell Nauuo the result or report that the result is uncertain.
Input
The only line contains three integers x, y, z (0≤ x,y,z≤100), corresponding to the number of persons who would upvote, downvote or unknown.
Output
If there is only one possible result, print the result : "+", "-" or "0".
Otherwise, print "?" to report that the result is uncertain.
Examples
Input
3 7 0
Output
-
Input
2 0 1
Output
+
Input
1 1 0
Output
0
Input
0 0 1
Output
?
Note
In the first example, Nauuo would definitely get three upvotes and seven downvotes, so the only possible result is "-".
In the second example, no matter the person unknown downvotes or upvotes, Nauuo would get more upvotes than downvotes. So the only possible result is "+".
In the third example, Nauuo would definitely get one upvote and one downvote, so the only possible result is "0".
In the fourth example, if the only one person upvoted, the result would be "+", otherwise, the result would be "-". There are two possible results, so the result is uncertain.
Submitted Solution:
```
[x, y, z] = [int(x) for x in input().split()]
if x-y+z == 0 and x-y-z == 0: print('0')
elif x-y+z > 0 and x-y-z > 0: print('+')
elif x-y+z < 0 and x-y-z < 0: print('-')
else: print('?')
``` | instruction | 0 | 47,094 | 11 | 94,188 |
Yes | output | 1 | 47,094 | 11 | 94,189 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Nauuo is a girl who loves writing comments.
One day, she posted a comment on Codeforces, wondering whether she would get upvotes or downvotes.
It's known that there were x persons who would upvote, y persons who would downvote, and there were also another z persons who would vote, but you don't know whether they would upvote or downvote. Note that each of the x+y+z people would vote exactly one time.
There are three different results: if there are more people upvote than downvote, the result will be "+"; if there are more people downvote than upvote, the result will be "-"; otherwise the result will be "0".
Because of the z unknown persons, the result may be uncertain (i.e. there are more than one possible results). More formally, the result is uncertain if and only if there exist two different situations of how the z persons vote, that the results are different in the two situations.
Tell Nauuo the result or report that the result is uncertain.
Input
The only line contains three integers x, y, z (0≤ x,y,z≤100), corresponding to the number of persons who would upvote, downvote or unknown.
Output
If there is only one possible result, print the result : "+", "-" or "0".
Otherwise, print "?" to report that the result is uncertain.
Examples
Input
3 7 0
Output
-
Input
2 0 1
Output
+
Input
1 1 0
Output
0
Input
0 0 1
Output
?
Note
In the first example, Nauuo would definitely get three upvotes and seven downvotes, so the only possible result is "-".
In the second example, no matter the person unknown downvotes or upvotes, Nauuo would get more upvotes than downvotes. So the only possible result is "+".
In the third example, Nauuo would definitely get one upvote and one downvote, so the only possible result is "0".
In the fourth example, if the only one person upvoted, the result would be "+", otherwise, the result would be "-". There are two possible results, so the result is uncertain.
Submitted Solution:
```
x,y,z=input().split()
x,y,z=int(x),int(y),int(z)
if x>y:
print("+")
if y>x:
print("-")
if x==y and x!=0 and y!=0:
print("0")
if z==1:
print("?")
``` | instruction | 0 | 47,095 | 11 | 94,190 |
No | output | 1 | 47,095 | 11 | 94,191 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Nauuo is a girl who loves writing comments.
One day, she posted a comment on Codeforces, wondering whether she would get upvotes or downvotes.
It's known that there were x persons who would upvote, y persons who would downvote, and there were also another z persons who would vote, but you don't know whether they would upvote or downvote. Note that each of the x+y+z people would vote exactly one time.
There are three different results: if there are more people upvote than downvote, the result will be "+"; if there are more people downvote than upvote, the result will be "-"; otherwise the result will be "0".
Because of the z unknown persons, the result may be uncertain (i.e. there are more than one possible results). More formally, the result is uncertain if and only if there exist two different situations of how the z persons vote, that the results are different in the two situations.
Tell Nauuo the result or report that the result is uncertain.
Input
The only line contains three integers x, y, z (0≤ x,y,z≤100), corresponding to the number of persons who would upvote, downvote or unknown.
Output
If there is only one possible result, print the result : "+", "-" or "0".
Otherwise, print "?" to report that the result is uncertain.
Examples
Input
3 7 0
Output
-
Input
2 0 1
Output
+
Input
1 1 0
Output
0
Input
0 0 1
Output
?
Note
In the first example, Nauuo would definitely get three upvotes and seven downvotes, so the only possible result is "-".
In the second example, no matter the person unknown downvotes or upvotes, Nauuo would get more upvotes than downvotes. So the only possible result is "+".
In the third example, Nauuo would definitely get one upvote and one downvote, so the only possible result is "0".
In the fourth example, if the only one person upvoted, the result would be "+", otherwise, the result would be "-". There are two possible results, so the result is uncertain.
Submitted Solution:
```
a,b,c = input().split(' ')
a = int(a)
b = int(b)
c = int(c)
def solve(a,b,c):
if a == 0 and b == 0 and c > 0:
return '?'
if a > b + c:
return '+'
if a + c < b:
return '-'
return '?'
print(solve(a,b,c))
``` | instruction | 0 | 47,096 | 11 | 94,192 |
No | output | 1 | 47,096 | 11 | 94,193 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Nauuo is a girl who loves writing comments.
One day, she posted a comment on Codeforces, wondering whether she would get upvotes or downvotes.
It's known that there were x persons who would upvote, y persons who would downvote, and there were also another z persons who would vote, but you don't know whether they would upvote or downvote. Note that each of the x+y+z people would vote exactly one time.
There are three different results: if there are more people upvote than downvote, the result will be "+"; if there are more people downvote than upvote, the result will be "-"; otherwise the result will be "0".
Because of the z unknown persons, the result may be uncertain (i.e. there are more than one possible results). More formally, the result is uncertain if and only if there exist two different situations of how the z persons vote, that the results are different in the two situations.
Tell Nauuo the result or report that the result is uncertain.
Input
The only line contains three integers x, y, z (0≤ x,y,z≤100), corresponding to the number of persons who would upvote, downvote or unknown.
Output
If there is only one possible result, print the result : "+", "-" or "0".
Otherwise, print "?" to report that the result is uncertain.
Examples
Input
3 7 0
Output
-
Input
2 0 1
Output
+
Input
1 1 0
Output
0
Input
0 0 1
Output
?
Note
In the first example, Nauuo would definitely get three upvotes and seven downvotes, so the only possible result is "-".
In the second example, no matter the person unknown downvotes or upvotes, Nauuo would get more upvotes than downvotes. So the only possible result is "+".
In the third example, Nauuo would definitely get one upvote and one downvote, so the only possible result is "0".
In the fourth example, if the only one person upvoted, the result would be "+", otherwise, the result would be "-". There are two possible results, so the result is uncertain.
Submitted Solution:
```
s = input().split()
for i in range(len(s)):
s[i] = int(s[i])
x = s[0]
y = s[1]
z = s[2]
if x > y:
if x > y+z:
print('+')
if x < y+z:
print('?')
if y > x:
if y > x+z:
print('-')
if y < x+z:
print('?')
if x == y:
if z > 0:
print('?')
if z == 0:
print('0')
``` | instruction | 0 | 47,097 | 11 | 94,194 |
No | output | 1 | 47,097 | 11 | 94,195 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Nauuo is a girl who loves writing comments.
One day, she posted a comment on Codeforces, wondering whether she would get upvotes or downvotes.
It's known that there were x persons who would upvote, y persons who would downvote, and there were also another z persons who would vote, but you don't know whether they would upvote or downvote. Note that each of the x+y+z people would vote exactly one time.
There are three different results: if there are more people upvote than downvote, the result will be "+"; if there are more people downvote than upvote, the result will be "-"; otherwise the result will be "0".
Because of the z unknown persons, the result may be uncertain (i.e. there are more than one possible results). More formally, the result is uncertain if and only if there exist two different situations of how the z persons vote, that the results are different in the two situations.
Tell Nauuo the result or report that the result is uncertain.
Input
The only line contains three integers x, y, z (0≤ x,y,z≤100), corresponding to the number of persons who would upvote, downvote or unknown.
Output
If there is only one possible result, print the result : "+", "-" or "0".
Otherwise, print "?" to report that the result is uncertain.
Examples
Input
3 7 0
Output
-
Input
2 0 1
Output
+
Input
1 1 0
Output
0
Input
0 0 1
Output
?
Note
In the first example, Nauuo would definitely get three upvotes and seven downvotes, so the only possible result is "-".
In the second example, no matter the person unknown downvotes or upvotes, Nauuo would get more upvotes than downvotes. So the only possible result is "+".
In the third example, Nauuo would definitely get one upvote and one downvote, so the only possible result is "0".
In the fourth example, if the only one person upvoted, the result would be "+", otherwise, the result would be "-". There are two possible results, so the result is uncertain.
Submitted Solution:
```
x,y,z = map(int,input().split())
if x > y and z < x and z < y:
print("+")
elif x < y and z < x and z < y:
print("-")
elif x!=0 and x == y:
print(0)
elif z > x or z > y :
print('?')
``` | instruction | 0 | 47,098 | 11 | 94,196 |
No | output | 1 | 47,098 | 11 | 94,197 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you?
You are given a system of equations:
<image>
You should count, how many there are pairs of integers (a, b) (0 ≤ a, b) which satisfy the system.
Input
A single line contains two integers n, m (1 ≤ n, m ≤ 1000) — the parameters of the system. The numbers on the line are separated by a space.
Output
On a single line print the answer to the problem.
Examples
Input
9 3
Output
1
Input
14 28
Output
1
Input
4 20
Output
0
Note
In the first sample the suitable pair is integers (3, 0). In the second sample the suitable pair is integers (3, 5). In the third sample there is no suitable pair.
Submitted Solution:
```
import math
[n, m] = [int(x) for x in input().split()]
def check_a(a, b):
return (a*a)+b
def check_b(a, b):
return (b*b)+a
def __helper(n , m):
ans = 0
for i in range( int(math.sqrt(n)+1)):
for j in range(int(math.sqrt(m))+1):
# print(i, j)
if check_a(i, j) == n and check_b(i, j) == m:
ans += 1
return ans
ans = __helper(n, m)
print(ans)
``` | instruction | 0 | 47,325 | 11 | 94,650 |
Yes | output | 1 | 47,325 | 11 | 94,651 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
During a New Year special offer the "Sudislavl Bars" offered n promo codes. Each promo code consists of exactly six digits and gives right to one free cocktail at the bar "Mosquito Shelter". Of course, all the promocodes differ.
As the "Mosquito Shelter" opens only at 9, and partying in Sudislavl usually begins at as early as 6, many problems may arise as to how to type a promotional code without errors. It is necessary to calculate such maximum k, that the promotional code could be uniquely identified if it was typed with no more than k errors. At that, k = 0 means that the promotional codes must be entered exactly.
A mistake in this problem should be considered as entering the wrong numbers. For example, value "123465" contains two errors relative to promocode "123456". Regardless of the number of errors the entered value consists of exactly six digits.
Input
The first line of the output contains number n (1 ≤ n ≤ 1000) — the number of promocodes.
Each of the next n lines contains a single promocode, consisting of exactly 6 digits. It is guaranteed that all the promocodes are distinct. Promocodes can start from digit "0".
Output
Print the maximum k (naturally, not exceeding the length of the promocode), such that any promocode can be uniquely identified if it is typed with at most k mistakes.
Examples
Input
2
000000
999999
Output
2
Input
6
211111
212111
222111
111111
112111
121111
Output
0
Note
In the first sample k < 3, so if a bar customer types in value "090909", then it will be impossible to define which promocode exactly corresponds to it.
Submitted Solution:
```
#Here u can check fast your code!
def checcker(x, y):
p = 0
for mkT in range(6):
if x[mkT]==y[mkT]:
p=p+1
if p>=4:
break
return p
def viewer_finish(x, k):
if x!=1:
if k>=4: #2, 1, 0
print('0')
elif k==3 or k==2: #3 5
print('1')
elif k==1 or k==0:
print('2')
else:
print(6)
def checcker_main(kList, x):
k = 0
for fmN in range(x-1):
for KKT in range(fmN+1,x):
p = checcker(kList[fmN], kList[KKT])
if p>k:
k = p
if k>=4:
break
if k>=4:
break
return(k)
def main():
kList = []
x = int(input())
for i in range(x):
kList.append(input())
k = checcker_main(kList, x)
viewer_finish(x, k)
main()
``` | instruction | 0 | 47,510 | 11 | 95,020 |
Yes | output | 1 | 47,510 | 11 | 95,021 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
During a New Year special offer the "Sudislavl Bars" offered n promo codes. Each promo code consists of exactly six digits and gives right to one free cocktail at the bar "Mosquito Shelter". Of course, all the promocodes differ.
As the "Mosquito Shelter" opens only at 9, and partying in Sudislavl usually begins at as early as 6, many problems may arise as to how to type a promotional code without errors. It is necessary to calculate such maximum k, that the promotional code could be uniquely identified if it was typed with no more than k errors. At that, k = 0 means that the promotional codes must be entered exactly.
A mistake in this problem should be considered as entering the wrong numbers. For example, value "123465" contains two errors relative to promocode "123456". Regardless of the number of errors the entered value consists of exactly six digits.
Input
The first line of the output contains number n (1 ≤ n ≤ 1000) — the number of promocodes.
Each of the next n lines contains a single promocode, consisting of exactly 6 digits. It is guaranteed that all the promocodes are distinct. Promocodes can start from digit "0".
Output
Print the maximum k (naturally, not exceeding the length of the promocode), such that any promocode can be uniquely identified if it is typed with at most k mistakes.
Examples
Input
2
000000
999999
Output
2
Input
6
211111
212111
222111
111111
112111
121111
Output
0
Note
In the first sample k < 3, so if a bar customer types in value "090909", then it will be impossible to define which promocode exactly corresponds to it.
Submitted Solution:
```
n = int(input())
a = list(map(lambda i: input(), range(n)))
if n == 1:
print(6)
exit()
m = 7
for i in range(n):
for j in range(i + 1, n):
m = min(m, sum(a[i][k] != a[j][k] for k in range(6)))
print((m - 1) // 2)
``` | instruction | 0 | 47,511 | 11 | 95,022 |
Yes | output | 1 | 47,511 | 11 | 95,023 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
During a New Year special offer the "Sudislavl Bars" offered n promo codes. Each promo code consists of exactly six digits and gives right to one free cocktail at the bar "Mosquito Shelter". Of course, all the promocodes differ.
As the "Mosquito Shelter" opens only at 9, and partying in Sudislavl usually begins at as early as 6, many problems may arise as to how to type a promotional code without errors. It is necessary to calculate such maximum k, that the promotional code could be uniquely identified if it was typed with no more than k errors. At that, k = 0 means that the promotional codes must be entered exactly.
A mistake in this problem should be considered as entering the wrong numbers. For example, value "123465" contains two errors relative to promocode "123456". Regardless of the number of errors the entered value consists of exactly six digits.
Input
The first line of the output contains number n (1 ≤ n ≤ 1000) — the number of promocodes.
Each of the next n lines contains a single promocode, consisting of exactly 6 digits. It is guaranteed that all the promocodes are distinct. Promocodes can start from digit "0".
Output
Print the maximum k (naturally, not exceeding the length of the promocode), such that any promocode can be uniquely identified if it is typed with at most k mistakes.
Examples
Input
2
000000
999999
Output
2
Input
6
211111
212111
222111
111111
112111
121111
Output
0
Note
In the first sample k < 3, so if a bar customer types in value "090909", then it will be impossible to define which promocode exactly corresponds to it.
Submitted Solution:
```
n = int(input())
m = 6
arr = []
for i in range(n):
arr.append(input())
for i in range(n - 1):
for j in range(i + 1, n):
d = 0
for z in range(6):
if arr[i][z] != arr[j][z]:
d += 1
if d == 6:
m = min(m, 2)
elif d == 5:
m = min(m, 2)
elif d == 4:
m = min(m, 1)
elif d == 3:
m = min(m, 1)
else:
m = 0
print(m)
``` | instruction | 0 | 47,512 | 11 | 95,024 |
Yes | output | 1 | 47,512 | 11 | 95,025 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
During a New Year special offer the "Sudislavl Bars" offered n promo codes. Each promo code consists of exactly six digits and gives right to one free cocktail at the bar "Mosquito Shelter". Of course, all the promocodes differ.
As the "Mosquito Shelter" opens only at 9, and partying in Sudislavl usually begins at as early as 6, many problems may arise as to how to type a promotional code without errors. It is necessary to calculate such maximum k, that the promotional code could be uniquely identified if it was typed with no more than k errors. At that, k = 0 means that the promotional codes must be entered exactly.
A mistake in this problem should be considered as entering the wrong numbers. For example, value "123465" contains two errors relative to promocode "123456". Regardless of the number of errors the entered value consists of exactly six digits.
Input
The first line of the output contains number n (1 ≤ n ≤ 1000) — the number of promocodes.
Each of the next n lines contains a single promocode, consisting of exactly 6 digits. It is guaranteed that all the promocodes are distinct. Promocodes can start from digit "0".
Output
Print the maximum k (naturally, not exceeding the length of the promocode), such that any promocode can be uniquely identified if it is typed with at most k mistakes.
Examples
Input
2
000000
999999
Output
2
Input
6
211111
212111
222111
111111
112111
121111
Output
0
Note
In the first sample k < 3, so if a bar customer types in value "090909", then it will be impossible to define which promocode exactly corresponds to it.
Submitted Solution:
```
ans = 12
l=[input() for i in range(int(input()))]
for i in range(len(l)):
for j in range(i+1,len(l)):
d=0
for w in range(6):
d+= l[i][w] != l[j][w]
ans=min(d-1,ans)
print(ans//2)
``` | instruction | 0 | 47,513 | 11 | 95,026 |
Yes | output | 1 | 47,513 | 11 | 95,027 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
During a New Year special offer the "Sudislavl Bars" offered n promo codes. Each promo code consists of exactly six digits and gives right to one free cocktail at the bar "Mosquito Shelter". Of course, all the promocodes differ.
As the "Mosquito Shelter" opens only at 9, and partying in Sudislavl usually begins at as early as 6, many problems may arise as to how to type a promotional code without errors. It is necessary to calculate such maximum k, that the promotional code could be uniquely identified if it was typed with no more than k errors. At that, k = 0 means that the promotional codes must be entered exactly.
A mistake in this problem should be considered as entering the wrong numbers. For example, value "123465" contains two errors relative to promocode "123456". Regardless of the number of errors the entered value consists of exactly six digits.
Input
The first line of the output contains number n (1 ≤ n ≤ 1000) — the number of promocodes.
Each of the next n lines contains a single promocode, consisting of exactly 6 digits. It is guaranteed that all the promocodes are distinct. Promocodes can start from digit "0".
Output
Print the maximum k (naturally, not exceeding the length of the promocode), such that any promocode can be uniquely identified if it is typed with at most k mistakes.
Examples
Input
2
000000
999999
Output
2
Input
6
211111
212111
222111
111111
112111
121111
Output
0
Note
In the first sample k < 3, so if a bar customer types in value "090909", then it will be impossible to define which promocode exactly corresponds to it.
Submitted Solution:
```
def C():
n = int(input())
if n == 1:
return 6;
promocodes = [str(input()) for i in range(n)]
min_diff = 2
for i in promocodes[:-1]:
for j in promocodes[1:]:
count_diff = 0
for r, k in zip(i, j):
if r != k:
count_diff+=1
if count_diff < min_diff:
min_diff = count_diff
elif count_diff%2:
if ((count_diff-2) >= 0) and ((count_diff - 2) < min_diff):
min_diff = count_diff - 2
elif count_diff%2 == 0:
if ((count_diff-3) >= 0) and ((count_diff - 3) < min_diff):
min_diff = count_diff - 3
return min_diff
if __name__ == '__main__':
print(C())
``` | instruction | 0 | 47,514 | 11 | 95,028 |
No | output | 1 | 47,514 | 11 | 95,029 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
During a New Year special offer the "Sudislavl Bars" offered n promo codes. Each promo code consists of exactly six digits and gives right to one free cocktail at the bar "Mosquito Shelter". Of course, all the promocodes differ.
As the "Mosquito Shelter" opens only at 9, and partying in Sudislavl usually begins at as early as 6, many problems may arise as to how to type a promotional code without errors. It is necessary to calculate such maximum k, that the promotional code could be uniquely identified if it was typed with no more than k errors. At that, k = 0 means that the promotional codes must be entered exactly.
A mistake in this problem should be considered as entering the wrong numbers. For example, value "123465" contains two errors relative to promocode "123456". Regardless of the number of errors the entered value consists of exactly six digits.
Input
The first line of the output contains number n (1 ≤ n ≤ 1000) — the number of promocodes.
Each of the next n lines contains a single promocode, consisting of exactly 6 digits. It is guaranteed that all the promocodes are distinct. Promocodes can start from digit "0".
Output
Print the maximum k (naturally, not exceeding the length of the promocode), such that any promocode can be uniquely identified if it is typed with at most k mistakes.
Examples
Input
2
000000
999999
Output
2
Input
6
211111
212111
222111
111111
112111
121111
Output
0
Note
In the first sample k < 3, so if a bar customer types in value "090909", then it will be impossible to define which promocode exactly corresponds to it.
Submitted Solution:
```
def func(a,b):
t = 0
for i in range(6):
if a[i] != b[i]:
print(1)
t+=1
return t
n = int(input())
A = [0] * n
for i in range(n):
A[i] = input()
per = 10
for i in range(0, n-1):
for j in range(i+1, n):
per = min(per, func(A[i], A[j]))
if n == 1:
print(6)
else:
if per in (5,6):
print(2)
elif per in (3,4):
print(1)
elif per in (0,1,2):
print(0)
``` | instruction | 0 | 47,515 | 11 | 95,030 |
No | output | 1 | 47,515 | 11 | 95,031 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
During a New Year special offer the "Sudislavl Bars" offered n promo codes. Each promo code consists of exactly six digits and gives right to one free cocktail at the bar "Mosquito Shelter". Of course, all the promocodes differ.
As the "Mosquito Shelter" opens only at 9, and partying in Sudislavl usually begins at as early as 6, many problems may arise as to how to type a promotional code without errors. It is necessary to calculate such maximum k, that the promotional code could be uniquely identified if it was typed with no more than k errors. At that, k = 0 means that the promotional codes must be entered exactly.
A mistake in this problem should be considered as entering the wrong numbers. For example, value "123465" contains two errors relative to promocode "123456". Regardless of the number of errors the entered value consists of exactly six digits.
Input
The first line of the output contains number n (1 ≤ n ≤ 1000) — the number of promocodes.
Each of the next n lines contains a single promocode, consisting of exactly 6 digits. It is guaranteed that all the promocodes are distinct. Promocodes can start from digit "0".
Output
Print the maximum k (naturally, not exceeding the length of the promocode), such that any promocode can be uniquely identified if it is typed with at most k mistakes.
Examples
Input
2
000000
999999
Output
2
Input
6
211111
212111
222111
111111
112111
121111
Output
0
Note
In the first sample k < 3, so if a bar customer types in value "090909", then it will be impossible to define which promocode exactly corresponds to it.
Submitted Solution:
```
n = int(input())
codes = [input() for i in range(n)]
def dist(w1, w2):
assert len(w1) == len(w2)
d = 0
for i in range(len(w1)):
if w1[i] != w2[i]: d += 1
return max(0, d//2 - 1)
d = 6
for i in range(n):
for j in range(i+1, n):
d = min(d, dist(codes[i], codes[j]))
print(d)
``` | instruction | 0 | 47,516 | 11 | 95,032 |
No | output | 1 | 47,516 | 11 | 95,033 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
During a New Year special offer the "Sudislavl Bars" offered n promo codes. Each promo code consists of exactly six digits and gives right to one free cocktail at the bar "Mosquito Shelter". Of course, all the promocodes differ.
As the "Mosquito Shelter" opens only at 9, and partying in Sudislavl usually begins at as early as 6, many problems may arise as to how to type a promotional code without errors. It is necessary to calculate such maximum k, that the promotional code could be uniquely identified if it was typed with no more than k errors. At that, k = 0 means that the promotional codes must be entered exactly.
A mistake in this problem should be considered as entering the wrong numbers. For example, value "123465" contains two errors relative to promocode "123456". Regardless of the number of errors the entered value consists of exactly six digits.
Input
The first line of the output contains number n (1 ≤ n ≤ 1000) — the number of promocodes.
Each of the next n lines contains a single promocode, consisting of exactly 6 digits. It is guaranteed that all the promocodes are distinct. Promocodes can start from digit "0".
Output
Print the maximum k (naturally, not exceeding the length of the promocode), such that any promocode can be uniquely identified if it is typed with at most k mistakes.
Examples
Input
2
000000
999999
Output
2
Input
6
211111
212111
222111
111111
112111
121111
Output
0
Note
In the first sample k < 3, so if a bar customer types in value "090909", then it will be impossible to define which promocode exactly corresponds to it.
Submitted Solution:
```
# -*- coding: utf-8 -*-
"""
Created on Sun Mar 13 19:40:03 2016
@author: Kostya S.
"""
from math import ceil
def hem(s,t):
r = 0
for u,v in zip(s,t):
r += u != v
return r
n = int(input())
code = set()
for _ in range(n):
c = (input())
code.add(c)
dist = set()
a = set()
k = 0
q = 0
for c1 in code:
for c2 in code:
if c1 != c2:
a.add(hem(c1,c2))
ans = 6 if n == 1 else max(0,(min(a)//2 - 1))
print(ans)
``` | instruction | 0 | 47,517 | 11 | 95,034 |
No | output | 1 | 47,517 | 11 | 95,035 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya and Petya were tired of studying so they decided to play a game. Before the game begins Vasya looks at array a consisting of n integers. As soon as he remembers all elements of a the game begins. Vasya closes his eyes and Petya does q actions of one of two types:
1) Petya says 4 integers l1, r1, l2, r2 — boundaries of two non-intersecting segments. After that he swaps one random element from the [l1, r1] segment with another random element from the [l2, r2] segment.
2) Petya asks Vasya the sum of the elements of a in the [l, r] segment.
Vasya is a mathematician so he answers Petya the mathematical expectation of the sum of the elements in the segment.
Your task is to write a program which will answer the second type questions as Vasya would do it. In other words your program should print the mathematical expectation of the sum of the elements of a in the [l, r] segment for every second type query.
Input
The first line contains two integers n, q (2 ≤ n ≤ 105, 1 ≤ q ≤ 105) — the number of elements in the array and the number of queries you need to handle.
The second line contains n integers ai (1 ≤ ai ≤ 109) — elements of the array.
The next q lines contain Petya's actions of type 1 or 2.
If it is a type 1 action then the line contains 5 integers 1, l1, r1, l2, r2 (1 ≤ l1 ≤ r1 ≤ n, 1 ≤ l2 ≤ r2 ≤ n).
If it is a type 2 query then the line contains 3 integers 2, l, r (1 ≤ l ≤ r ≤ n).
It is guaranteed that there is at least one type 2 query and segments [l1, r1], [l2, r2] don't have common elements.
Output
For each type 2 query print one real number — the mathematical expectation of the sum of elements in the segment.
Your answer will be considered correct if its absolute or relative error doesn't exceed 10 - 4 — formally, the answer is correct if <image> where x is jury's answer and y is yours.
Examples
Input
4 4
1 1 2 2
1 2 2 3 3
2 1 2
1 1 2 3 4
2 1 2
Output
3.0000000
3.0000000
Input
10 5
1 1 1 1 1 2 2 2 2 2
1 1 5 6 10
2 1 5
1 1 5 6 10
1 1 5 6 10
2 6 10
Output
6.0000000
8.0400000
Input
10 10
1 2 3 4 5 6 7 8 9 10
1 1 5 6 10
1 1 5 6 10
2 1 5
1 1 3 6 9
2 1 3
1 5 7 8 10
1 1 1 10 10
2 1 5
2 7 10
2 1 10
Output
23.0000000
14.0000000
28.0133333
21.5733333
55.0000000
Submitted Solution:
```
n, k = input().split()
n, k = int(n), int(k)
array = input().split()
for i in range(len(array)):
array[i] = int(array[i])
for i in range(k):
v = input().split()
for a in range(len(v)):
v[a] = int(v[a])
if v[0] == 1:
array[(v[1]-1):v[2]], array[(v[3]-1):v[4]] = array[(v[3]-1):v[4]], array[(v[1]-1):v[2]]
elif v[0] == 2:
print(sum(array[(v[1]-1):v[2]]))
``` | instruction | 0 | 47,622 | 11 | 95,244 |
No | output | 1 | 47,622 | 11 | 95,245 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya and Petya were tired of studying so they decided to play a game. Before the game begins Vasya looks at array a consisting of n integers. As soon as he remembers all elements of a the game begins. Vasya closes his eyes and Petya does q actions of one of two types:
1) Petya says 4 integers l1, r1, l2, r2 — boundaries of two non-intersecting segments. After that he swaps one random element from the [l1, r1] segment with another random element from the [l2, r2] segment.
2) Petya asks Vasya the sum of the elements of a in the [l, r] segment.
Vasya is a mathematician so he answers Petya the mathematical expectation of the sum of the elements in the segment.
Your task is to write a program which will answer the second type questions as Vasya would do it. In other words your program should print the mathematical expectation of the sum of the elements of a in the [l, r] segment for every second type query.
Input
The first line contains two integers n, q (2 ≤ n ≤ 105, 1 ≤ q ≤ 105) — the number of elements in the array and the number of queries you need to handle.
The second line contains n integers ai (1 ≤ ai ≤ 109) — elements of the array.
The next q lines contain Petya's actions of type 1 or 2.
If it is a type 1 action then the line contains 5 integers 1, l1, r1, l2, r2 (1 ≤ l1 ≤ r1 ≤ n, 1 ≤ l2 ≤ r2 ≤ n).
If it is a type 2 query then the line contains 3 integers 2, l, r (1 ≤ l ≤ r ≤ n).
It is guaranteed that there is at least one type 2 query and segments [l1, r1], [l2, r2] don't have common elements.
Output
For each type 2 query print one real number — the mathematical expectation of the sum of elements in the segment.
Your answer will be considered correct if its absolute or relative error doesn't exceed 10 - 4 — formally, the answer is correct if <image> where x is jury's answer and y is yours.
Examples
Input
4 4
1 1 2 2
1 2 2 3 3
2 1 2
1 1 2 3 4
2 1 2
Output
3.0000000
3.0000000
Input
10 5
1 1 1 1 1 2 2 2 2 2
1 1 5 6 10
2 1 5
1 1 5 6 10
1 1 5 6 10
2 6 10
Output
6.0000000
8.0400000
Input
10 10
1 2 3 4 5 6 7 8 9 10
1 1 5 6 10
1 1 5 6 10
2 1 5
1 1 3 6 9
2 1 3
1 5 7 8 10
1 1 1 10 10
2 1 5
2 7 10
2 1 10
Output
23.0000000
14.0000000
28.0133333
21.5733333
55.0000000
Submitted Solution:
```
def read():
return tuple(int(x) for x in input().split())
def main():
n, q = read()
nums = list(read())
for i in range(q):
op = read()
if op[0] == 1:
s1 = 0
for j in range(op[1] - 1, op[2]):
s1 += nums[j]
s1s = s1 / (op[2] + 1 - op[1])
s2 = 0
for j in range(op[3] - 1, op[4]):
s2 += nums[j]
s2s = s2 / (op[4] + 1 - op[3])
s1 += s2s - s1s
s2 += s1s - s2s
s1 /= (op[2] + 1 - op[1])
s2 /= (op[4] + 1 - op[3])
for j in range(op[1] - 1, op[2]):
nums[j] = s1
for j in range(op[3] - 1, op[4]):
nums[j] = s2
elif op[0] == 2:
s = 0
for j in range(op[1] - 1, op[2]):
s += nums[j]
print(s)
main()
``` | instruction | 0 | 47,623 | 11 | 95,246 |
No | output | 1 | 47,623 | 11 | 95,247 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya and Petya were tired of studying so they decided to play a game. Before the game begins Vasya looks at array a consisting of n integers. As soon as he remembers all elements of a the game begins. Vasya closes his eyes and Petya does q actions of one of two types:
1) Petya says 4 integers l1, r1, l2, r2 — boundaries of two non-intersecting segments. After that he swaps one random element from the [l1, r1] segment with another random element from the [l2, r2] segment.
2) Petya asks Vasya the sum of the elements of a in the [l, r] segment.
Vasya is a mathematician so he answers Petya the mathematical expectation of the sum of the elements in the segment.
Your task is to write a program which will answer the second type questions as Vasya would do it. In other words your program should print the mathematical expectation of the sum of the elements of a in the [l, r] segment for every second type query.
Input
The first line contains two integers n, q (2 ≤ n ≤ 105, 1 ≤ q ≤ 105) — the number of elements in the array and the number of queries you need to handle.
The second line contains n integers ai (1 ≤ ai ≤ 109) — elements of the array.
The next q lines contain Petya's actions of type 1 or 2.
If it is a type 1 action then the line contains 5 integers 1, l1, r1, l2, r2 (1 ≤ l1 ≤ r1 ≤ n, 1 ≤ l2 ≤ r2 ≤ n).
If it is a type 2 query then the line contains 3 integers 2, l, r (1 ≤ l ≤ r ≤ n).
It is guaranteed that there is at least one type 2 query and segments [l1, r1], [l2, r2] don't have common elements.
Output
For each type 2 query print one real number — the mathematical expectation of the sum of elements in the segment.
Your answer will be considered correct if its absolute or relative error doesn't exceed 10 - 4 — formally, the answer is correct if <image> where x is jury's answer and y is yours.
Examples
Input
4 4
1 1 2 2
1 2 2 3 3
2 1 2
1 1 2 3 4
2 1 2
Output
3.0000000
3.0000000
Input
10 5
1 1 1 1 1 2 2 2 2 2
1 1 5 6 10
2 1 5
1 1 5 6 10
1 1 5 6 10
2 6 10
Output
6.0000000
8.0400000
Input
10 10
1 2 3 4 5 6 7 8 9 10
1 1 5 6 10
1 1 5 6 10
2 1 5
1 1 3 6 9
2 1 3
1 5 7 8 10
1 1 1 10 10
2 1 5
2 7 10
2 1 10
Output
23.0000000
14.0000000
28.0133333
21.5733333
55.0000000
Submitted Solution:
```
import random
n, q = map(int, input().split())
mas = list(map(int, input().split()))
for i in range(q):
s = list(map(int, input().split()))
if len(s) == 5:
one = random.choice(mas[s[1] - 1: s[2]])
two = random.choice(mas[s[3] - 1: s[4]])
mas[mas.index(one)], mas[mas.index(two)] = mas[mas.index(two)], mas[mas.index(one)]
print(mas)
else:
print(float(sum(mas[s[1] - 1: s[2]])))
``` | instruction | 0 | 47,624 | 11 | 95,248 |
No | output | 1 | 47,624 | 11 | 95,249 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya and Petya were tired of studying so they decided to play a game. Before the game begins Vasya looks at array a consisting of n integers. As soon as he remembers all elements of a the game begins. Vasya closes his eyes and Petya does q actions of one of two types:
1) Petya says 4 integers l1, r1, l2, r2 — boundaries of two non-intersecting segments. After that he swaps one random element from the [l1, r1] segment with another random element from the [l2, r2] segment.
2) Petya asks Vasya the sum of the elements of a in the [l, r] segment.
Vasya is a mathematician so he answers Petya the mathematical expectation of the sum of the elements in the segment.
Your task is to write a program which will answer the second type questions as Vasya would do it. In other words your program should print the mathematical expectation of the sum of the elements of a in the [l, r] segment for every second type query.
Input
The first line contains two integers n, q (2 ≤ n ≤ 105, 1 ≤ q ≤ 105) — the number of elements in the array and the number of queries you need to handle.
The second line contains n integers ai (1 ≤ ai ≤ 109) — elements of the array.
The next q lines contain Petya's actions of type 1 or 2.
If it is a type 1 action then the line contains 5 integers 1, l1, r1, l2, r2 (1 ≤ l1 ≤ r1 ≤ n, 1 ≤ l2 ≤ r2 ≤ n).
If it is a type 2 query then the line contains 3 integers 2, l, r (1 ≤ l ≤ r ≤ n).
It is guaranteed that there is at least one type 2 query and segments [l1, r1], [l2, r2] don't have common elements.
Output
For each type 2 query print one real number — the mathematical expectation of the sum of elements in the segment.
Your answer will be considered correct if its absolute or relative error doesn't exceed 10 - 4 — formally, the answer is correct if <image> where x is jury's answer and y is yours.
Examples
Input
4 4
1 1 2 2
1 2 2 3 3
2 1 2
1 1 2 3 4
2 1 2
Output
3.0000000
3.0000000
Input
10 5
1 1 1 1 1 2 2 2 2 2
1 1 5 6 10
2 1 5
1 1 5 6 10
1 1 5 6 10
2 6 10
Output
6.0000000
8.0400000
Input
10 10
1 2 3 4 5 6 7 8 9 10
1 1 5 6 10
1 1 5 6 10
2 1 5
1 1 3 6 9
2 1 3
1 5 7 8 10
1 1 1 10 10
2 1 5
2 7 10
2 1 10
Output
23.0000000
14.0000000
28.0133333
21.5733333
55.0000000
Submitted Solution:
```
import copy
def swaps(l1,r1,l2,r2):
ss = []
for i in range(l1,r1+1):
for j in range(l2,r2+1):
ss.append([i,j])
return ss
def permute(arr,l1,r1,l2,r2):
arrays = []
ss = swaps(l1,r1,l2,r2)
for a,b in ss:
temp = copy.deepcopy(arr)
temp[a],temp[b] = temp[b],temp[a]
arrays.append(temp)
return arrays
def asum(arr,l,r):
temp = 0
for a in arr:
temp+= sum(a[l:r+1])
return temp/len(arr)
n,q = [int(i) for i in input().split()]
arr = [[int(i) for i in input().split()]]
while True:
newa = []
try:
stuff = input().split()
except:
break
typ,data = stuff[0],stuff[1:]
if typ == '1':
l1,r1,l2,r2 = [int(i)-1 for i in data]
for a in arr[:10000]:
newa += permute(a,l1,r1,l2,r2)
arr = newa
elif typ == '2':
l,r = [int(i)-1 for i in data]
print(asum(arr,l,r))
``` | instruction | 0 | 47,625 | 11 | 95,250 |
No | output | 1 | 47,625 | 11 | 95,251 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a set of items, each having some integer weight not greater than 8. You denote that a subset of items is good if total weight of items in the subset does not exceed W.
You want to calculate the maximum possible weight of a good subset of items. Note that you have to consider the empty set and the original set when calculating the answer.
Input
The first line contains one integer W (0 ≤ W ≤ 10^{18}) — the maximum total weight of a good subset.
The second line denotes the set of items you have. It contains 8 integers cnt_1, cnt_2, ..., cnt_8 (0 ≤ cnt_i ≤ 10^{16}), where cnt_i is the number of items having weight i in the set.
Output
Print one integer — the maximum possible weight of a good subset of items.
Examples
Input
10
1 2 3 4 5 6 7 8
Output
10
Input
0
0 0 0 0 0 0 0 0
Output
0
Input
3
0 4 1 0 0 9 8 3
Output
3
Submitted Solution:
```
w = int(input())
l= list(map(int, input().split()))
maximum = 0
def fun(point, weight):
global maximum
if point == 8 and weight <= w:
maximum= max(weight, maximum)
else:
if weight < w:
fun(point + 1, weight + l[point])
fun(point + 1, weight)
fun(0, 0)
print(maximum)
``` | instruction | 0 | 47,986 | 11 | 95,972 |
No | output | 1 | 47,986 | 11 | 95,973 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a set of items, each having some integer weight not greater than 8. You denote that a subset of items is good if total weight of items in the subset does not exceed W.
You want to calculate the maximum possible weight of a good subset of items. Note that you have to consider the empty set and the original set when calculating the answer.
Input
The first line contains one integer W (0 ≤ W ≤ 10^{18}) — the maximum total weight of a good subset.
The second line denotes the set of items you have. It contains 8 integers cnt_1, cnt_2, ..., cnt_8 (0 ≤ cnt_i ≤ 10^{16}), where cnt_i is the number of items having weight i in the set.
Output
Print one integer — the maximum possible weight of a good subset of items.
Examples
Input
10
1 2 3 4 5 6 7 8
Output
10
Input
0
0 0 0 0 0 0 0 0
Output
0
Input
3
0 4 1 0 0 9 8 3
Output
3
Submitted Solution:
```
import time
import random
W = int(input())
M = [int(a) for a in input().split()]
A = [0] * 8
sTime = time.time()
s = 0
mi = 10**10
for i in range(8):
if s + M[i]*(i+1) <= W:
s += M[i]*(i+1)
A[i] = M[i]
else:
t = (W-s)//(i+1)
s += t*(i+1)
A[i] += t
if s <= W:
mi = min(mi, W-s)
while time.time() - sTime < 1.75:
i = random.randrange(8)
a = random.randrange(2)
if W-s >= 20 or (s-W < 10 and a == 0):
if A[i] < M[i]:
A[i] += 1
s += (i+1)
else:
if A[i] > 0:
A[i] -= 1
s -= (i+1)
if s <= W:
mi = min(mi, W-s)
print(W-mi)
``` | instruction | 0 | 47,989 | 11 | 95,978 |
No | output | 1 | 47,989 | 11 | 95,979 |
Provide tags and a correct Python 3 solution for this coding contest problem.
During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants.
Let's assume that n people took part in the contest. Let's assume that the participant who got the first place has rating a1, the second place participant has rating a2, ..., the n-th place participant has rating an. Then changing the rating on the Codesecrof site is calculated by the formula <image>.
After the round was over, the Codesecrof management published the participants' results table. They decided that if for a participant di < k, then the round can be considered unrated for him. But imagine the management's surprise when they found out that the participants' rating table is dynamic. In other words, when some participant is removed from the rating, he is removed from the results' table and the rating is recalculated according to the new table. And of course, all applications for exclusion from the rating are considered in view of the current table.
We know that among all the applications for exclusion from the rating the first application to consider is from the participant with the best rank (the rank with the minimum number), for who di < k. We also know that the applications for exclusion from rating were submitted by all participants.
Now Sereja wonders, what is the number of participants to be excluded from the contest rating, and the numbers of the participants in the original table in the order of their exclusion from the rating. Pay attention to the analysis of the first test case for a better understanding of the statement.
Input
The first line contains two integers n, k (1 ≤ n ≤ 2·105, - 109 ≤ k ≤ 0). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — ratings of the participants in the initial table.
Output
Print the numbers of participants in the order in which they were removed from the table. Print the initial numbers of the participants, that is, the numbers that the participants had in the initial table.
Examples
Input
5 0
5 3 4 1 2
Output
2
3
4
Input
10 -10
5 5 1 7 5 1 2 4 9 2
Output
2
4
5
7
8
9
Note
Consider the first test sample.
1. Initially the sequence of the contest participants' ratings equals [5, 3, 4, 1, 2]. You can use this sequence to calculate the sequence of rating changes: [0, -9, -13, 8, 14]. According to the problem statement, the application of the participant who won the second place will be considered first.
2. As soon as the second place winner is out from the ratings, the participants' rating sequence will equal [5, 4, 1, 2]. By this sequence you can count the new sequence of rating changes: [0, -8, 2, 6]. According to the problem statement, the application of the participant who won the second place will be considered. Initially this participant won third place.
3. The new rating sequence equals [5, 1, 2], the new sequence of rating changes equals [0, -1, 1]. The second place participant's application is taken into consideration, initially this participant won the fourth place.
4. The new rating sequence equals [5, 2], the new sequence of rating changes equals [0, 0]. No more applications will be considered.
Thus, you should print 2, 3, 4. | instruction | 0 | 48,242 | 11 | 96,484 |
Tags: implementation
Correct Solution:
```
from sys import stdin,stdout
nmbr = lambda: int(stdin.readline())
lst = lambda: list(map(int,stdin.readline().split()))
def fn(a):
print('a',a)
n=len(a)
pos1=[0]
for i in range(1,n):
pos1+=[pos1[-1]+a[i]*i]
print('pos1',pos1)
neg=[]
for i in range(n):
neg+=[i*(n-i-1)*a[i]]
print('neg',neg)
d=[]
for i in range(1,n+1):
sm=0
for j in range(1,i):
sm+=a[j-1]*(j-1)-(n-i)*a[i-1]
d+=[sm]
print('d',d);
print('================================')
p=-1
for i in range(1,n):
if pos1[i-1]-neg[i]<k:
p=i
break
if p==-1:return
a.pop(p)
fn(a)
for _ in range(1):#nmbr()):
n,k=lst()
a=lst()
# fn(a)
# exit(0)
pos = [0]
for i in range(1, n):
pos += [pos[-1] + a[i] * i]
removed=0
positive_term=0
for i in range(1,n):
negative_term=(i-removed)*a[i]*(n-i-1)
# print(positive_term,positive_term-negative_term)
if (positive_term-negative_term)<k:
removed+=1
stdout.write(str(i+1)+'\n')
else:positive_term += (i - removed) * a[i]
``` | output | 1 | 48,242 | 11 | 96,485 |
Provide tags and a correct Python 3 solution for this coding contest problem.
During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants.
Let's assume that n people took part in the contest. Let's assume that the participant who got the first place has rating a1, the second place participant has rating a2, ..., the n-th place participant has rating an. Then changing the rating on the Codesecrof site is calculated by the formula <image>.
After the round was over, the Codesecrof management published the participants' results table. They decided that if for a participant di < k, then the round can be considered unrated for him. But imagine the management's surprise when they found out that the participants' rating table is dynamic. In other words, when some participant is removed from the rating, he is removed from the results' table and the rating is recalculated according to the new table. And of course, all applications for exclusion from the rating are considered in view of the current table.
We know that among all the applications for exclusion from the rating the first application to consider is from the participant with the best rank (the rank with the minimum number), for who di < k. We also know that the applications for exclusion from rating were submitted by all participants.
Now Sereja wonders, what is the number of participants to be excluded from the contest rating, and the numbers of the participants in the original table in the order of their exclusion from the rating. Pay attention to the analysis of the first test case for a better understanding of the statement.
Input
The first line contains two integers n, k (1 ≤ n ≤ 2·105, - 109 ≤ k ≤ 0). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — ratings of the participants in the initial table.
Output
Print the numbers of participants in the order in which they were removed from the table. Print the initial numbers of the participants, that is, the numbers that the participants had in the initial table.
Examples
Input
5 0
5 3 4 1 2
Output
2
3
4
Input
10 -10
5 5 1 7 5 1 2 4 9 2
Output
2
4
5
7
8
9
Note
Consider the first test sample.
1. Initially the sequence of the contest participants' ratings equals [5, 3, 4, 1, 2]. You can use this sequence to calculate the sequence of rating changes: [0, -9, -13, 8, 14]. According to the problem statement, the application of the participant who won the second place will be considered first.
2. As soon as the second place winner is out from the ratings, the participants' rating sequence will equal [5, 4, 1, 2]. By this sequence you can count the new sequence of rating changes: [0, -8, 2, 6]. According to the problem statement, the application of the participant who won the second place will be considered. Initially this participant won third place.
3. The new rating sequence equals [5, 1, 2], the new sequence of rating changes equals [0, -1, 1]. The second place participant's application is taken into consideration, initially this participant won the fourth place.
4. The new rating sequence equals [5, 2], the new sequence of rating changes equals [0, 0]. No more applications will be considered.
Thus, you should print 2, 3, 4. | instruction | 0 | 48,243 | 11 | 96,486 |
Tags: implementation
Correct Solution:
```
n, k = map(int, input().split())
c, m, l, r = 0, 0, [], 0
for e in [int(i) for i in input().split()]:
d = m - c * (n - c - 1) * e
r+= 1
if d < k:
n -= 1
l += [r]
else:
m += c * e
c += 1
l.sort()
for e in l: print(e)
``` | output | 1 | 48,243 | 11 | 96,487 |
Provide tags and a correct Python 3 solution for this coding contest problem.
During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants.
Let's assume that n people took part in the contest. Let's assume that the participant who got the first place has rating a1, the second place participant has rating a2, ..., the n-th place participant has rating an. Then changing the rating on the Codesecrof site is calculated by the formula <image>.
After the round was over, the Codesecrof management published the participants' results table. They decided that if for a participant di < k, then the round can be considered unrated for him. But imagine the management's surprise when they found out that the participants' rating table is dynamic. In other words, when some participant is removed from the rating, he is removed from the results' table and the rating is recalculated according to the new table. And of course, all applications for exclusion from the rating are considered in view of the current table.
We know that among all the applications for exclusion from the rating the first application to consider is from the participant with the best rank (the rank with the minimum number), for who di < k. We also know that the applications for exclusion from rating were submitted by all participants.
Now Sereja wonders, what is the number of participants to be excluded from the contest rating, and the numbers of the participants in the original table in the order of their exclusion from the rating. Pay attention to the analysis of the first test case for a better understanding of the statement.
Input
The first line contains two integers n, k (1 ≤ n ≤ 2·105, - 109 ≤ k ≤ 0). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — ratings of the participants in the initial table.
Output
Print the numbers of participants in the order in which they were removed from the table. Print the initial numbers of the participants, that is, the numbers that the participants had in the initial table.
Examples
Input
5 0
5 3 4 1 2
Output
2
3
4
Input
10 -10
5 5 1 7 5 1 2 4 9 2
Output
2
4
5
7
8
9
Note
Consider the first test sample.
1. Initially the sequence of the contest participants' ratings equals [5, 3, 4, 1, 2]. You can use this sequence to calculate the sequence of rating changes: [0, -9, -13, 8, 14]. According to the problem statement, the application of the participant who won the second place will be considered first.
2. As soon as the second place winner is out from the ratings, the participants' rating sequence will equal [5, 4, 1, 2]. By this sequence you can count the new sequence of rating changes: [0, -8, 2, 6]. According to the problem statement, the application of the participant who won the second place will be considered. Initially this participant won third place.
3. The new rating sequence equals [5, 1, 2], the new sequence of rating changes equals [0, -1, 1]. The second place participant's application is taken into consideration, initially this participant won the fourth place.
4. The new rating sequence equals [5, 2], the new sequence of rating changes equals [0, 0]. No more applications will be considered.
Thus, you should print 2, 3, 4. | instruction | 0 | 48,244 | 11 | 96,488 |
Tags: implementation
Correct Solution:
```
n, k = map(int, input().split())
arr = map(int, input().split())
s, j, all_res = 0, 0, []
for i, q in enumerate(arr, 1):
if s - j * (n - i) * q < k:
all_res.append(str(i))
else:
s += q * j
j += 1
print('\n'.join(all_res))
``` | output | 1 | 48,244 | 11 | 96,489 |
Provide tags and a correct Python 3 solution for this coding contest problem.
During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants.
Let's assume that n people took part in the contest. Let's assume that the participant who got the first place has rating a1, the second place participant has rating a2, ..., the n-th place participant has rating an. Then changing the rating on the Codesecrof site is calculated by the formula <image>.
After the round was over, the Codesecrof management published the participants' results table. They decided that if for a participant di < k, then the round can be considered unrated for him. But imagine the management's surprise when they found out that the participants' rating table is dynamic. In other words, when some participant is removed from the rating, he is removed from the results' table and the rating is recalculated according to the new table. And of course, all applications for exclusion from the rating are considered in view of the current table.
We know that among all the applications for exclusion from the rating the first application to consider is from the participant with the best rank (the rank with the minimum number), for who di < k. We also know that the applications for exclusion from rating were submitted by all participants.
Now Sereja wonders, what is the number of participants to be excluded from the contest rating, and the numbers of the participants in the original table in the order of their exclusion from the rating. Pay attention to the analysis of the first test case for a better understanding of the statement.
Input
The first line contains two integers n, k (1 ≤ n ≤ 2·105, - 109 ≤ k ≤ 0). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — ratings of the participants in the initial table.
Output
Print the numbers of participants in the order in which they were removed from the table. Print the initial numbers of the participants, that is, the numbers that the participants had in the initial table.
Examples
Input
5 0
5 3 4 1 2
Output
2
3
4
Input
10 -10
5 5 1 7 5 1 2 4 9 2
Output
2
4
5
7
8
9
Note
Consider the first test sample.
1. Initially the sequence of the contest participants' ratings equals [5, 3, 4, 1, 2]. You can use this sequence to calculate the sequence of rating changes: [0, -9, -13, 8, 14]. According to the problem statement, the application of the participant who won the second place will be considered first.
2. As soon as the second place winner is out from the ratings, the participants' rating sequence will equal [5, 4, 1, 2]. By this sequence you can count the new sequence of rating changes: [0, -8, 2, 6]. According to the problem statement, the application of the participant who won the second place will be considered. Initially this participant won third place.
3. The new rating sequence equals [5, 1, 2], the new sequence of rating changes equals [0, -1, 1]. The second place participant's application is taken into consideration, initially this participant won the fourth place.
4. The new rating sequence equals [5, 2], the new sequence of rating changes equals [0, 0]. No more applications will be considered.
Thus, you should print 2, 3, 4. | instruction | 0 | 48,245 | 11 | 96,490 |
Tags: implementation
Correct Solution:
```
from sys import stdin,stdout
nmbr = lambda: int(stdin.readline())
lst = lambda: list(map(int,stdin.readline().split()))
for _ in range(1):#nmbr()):
n,k=lst()
a=lst()
removed=0
positive_term=0
for i in range(1,n):
negative_term=(i-removed)*a[i]*(n-i-1)
if (positive_term-negative_term)<k:
removed+=1
stdout.write(str(i+1)+'\n')
else:positive_term += (i - removed) * a[i]
``` | output | 1 | 48,245 | 11 | 96,491 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants.
Let's assume that n people took part in the contest. Let's assume that the participant who got the first place has rating a1, the second place participant has rating a2, ..., the n-th place participant has rating an. Then changing the rating on the Codesecrof site is calculated by the formula <image>.
After the round was over, the Codesecrof management published the participants' results table. They decided that if for a participant di < k, then the round can be considered unrated for him. But imagine the management's surprise when they found out that the participants' rating table is dynamic. In other words, when some participant is removed from the rating, he is removed from the results' table and the rating is recalculated according to the new table. And of course, all applications for exclusion from the rating are considered in view of the current table.
We know that among all the applications for exclusion from the rating the first application to consider is from the participant with the best rank (the rank with the minimum number), for who di < k. We also know that the applications for exclusion from rating were submitted by all participants.
Now Sereja wonders, what is the number of participants to be excluded from the contest rating, and the numbers of the participants in the original table in the order of their exclusion from the rating. Pay attention to the analysis of the first test case for a better understanding of the statement.
Input
The first line contains two integers n, k (1 ≤ n ≤ 2·105, - 109 ≤ k ≤ 0). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — ratings of the participants in the initial table.
Output
Print the numbers of participants in the order in which they were removed from the table. Print the initial numbers of the participants, that is, the numbers that the participants had in the initial table.
Examples
Input
5 0
5 3 4 1 2
Output
2
3
4
Input
10 -10
5 5 1 7 5 1 2 4 9 2
Output
2
4
5
7
8
9
Note
Consider the first test sample.
1. Initially the sequence of the contest participants' ratings equals [5, 3, 4, 1, 2]. You can use this sequence to calculate the sequence of rating changes: [0, -9, -13, 8, 14]. According to the problem statement, the application of the participant who won the second place will be considered first.
2. As soon as the second place winner is out from the ratings, the participants' rating sequence will equal [5, 4, 1, 2]. By this sequence you can count the new sequence of rating changes: [0, -8, 2, 6]. According to the problem statement, the application of the participant who won the second place will be considered. Initially this participant won third place.
3. The new rating sequence equals [5, 1, 2], the new sequence of rating changes equals [0, -1, 1]. The second place participant's application is taken into consideration, initially this participant won the fourth place.
4. The new rating sequence equals [5, 2], the new sequence of rating changes equals [0, 0]. No more applications will be considered.
Thus, you should print 2, 3, 4.
Submitted Solution:
```
from sys import stdin,stdout
nmbr = lambda: int(stdin.readline())
lst = lambda: list(map(int,stdin.readline().split()))
for _ in range(1):#nmbr()):
n,k=lst()
a=lst()
pos=[0]
neg=[]
for i in range(1,n):
pos+=[pos[-1]+a[i]*i]
removed=0;sm=0
for i in range(1,n):
positive_term=pos[i-1]-sm
negative_term=(i-removed)*a[i]*(n-i-1)
if (positive_term-negative_term)<k:
sm+=i*a[i]
removed+=1
stdout.write(str(i+1)+'\n')
``` | instruction | 0 | 48,246 | 11 | 96,492 |
No | output | 1 | 48,246 | 11 | 96,493 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given matrix with n rows and n columns filled with zeroes. You should put k ones in it in such a way that the resulting matrix is symmetrical with respect to the main diagonal (the diagonal that goes from the top left to the bottom right corner) and is lexicographically maximal.
One matrix is lexicographically greater than the other if the first different number in the first different row from the top in the first matrix is greater than the corresponding number in the second one.
If there exists no such matrix then output -1.
Input
The first line consists of two numbers n and k (1 ≤ n ≤ 100, 0 ≤ k ≤ 106).
Output
If the answer exists then output resulting matrix. Otherwise output -1.
Examples
Input
2 1
Output
1 0
0 0
Input
3 2
Output
1 0 0
0 1 0
0 0 0
Input
2 5
Output
-1
Submitted Solution:
```
import sys
import math
n,k = map(int, input().split())
ans = [[0 for i in range(n)] for i in range(n)]
row = 0;
col = 0;
scol = 0;
while(row < n):
col = scol
while(col < n):
if(col == row and k > 0):
ans[row][col] = 1
k -= 1
elif k > 0:
if k >= 2:
ans[row][col] = 1
ans[col][row] = 1
k -= 2
col += 1
row += 1
scol += 1
if k == 0:
for i in range(n):
for j in range(n):
print(ans[i][j], end = " ")
print()
else:
print(-1)
``` | instruction | 0 | 48,490 | 11 | 96,980 |
Yes | output | 1 | 48,490 | 11 | 96,981 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given matrix with n rows and n columns filled with zeroes. You should put k ones in it in such a way that the resulting matrix is symmetrical with respect to the main diagonal (the diagonal that goes from the top left to the bottom right corner) and is lexicographically maximal.
One matrix is lexicographically greater than the other if the first different number in the first different row from the top in the first matrix is greater than the corresponding number in the second one.
If there exists no such matrix then output -1.
Input
The first line consists of two numbers n and k (1 ≤ n ≤ 100, 0 ≤ k ≤ 106).
Output
If the answer exists then output resulting matrix. Otherwise output -1.
Examples
Input
2 1
Output
1 0
0 0
Input
3 2
Output
1 0 0
0 1 0
0 0 0
Input
2 5
Output
-1
Submitted Solution:
```
import sys
def solve():
n, k = map(int, input().split())
if k > n**2:
print(-1)
else:
mat = [[0]*n for i in range(n)]
for i in range(n):
for j in range(i, n):
if k <= 0:
break
if i == j:
mat[i][i] = 1
k -= 1
else:
if k > 1:
mat[i][j] = mat[j][i] = 1
k -= 2
for mat_r in mat:
print(*mat_r)
if __name__ == '__main__':
solve()
``` | instruction | 0 | 48,491 | 11 | 96,982 |
Yes | output | 1 | 48,491 | 11 | 96,983 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given matrix with n rows and n columns filled with zeroes. You should put k ones in it in such a way that the resulting matrix is symmetrical with respect to the main diagonal (the diagonal that goes from the top left to the bottom right corner) and is lexicographically maximal.
One matrix is lexicographically greater than the other if the first different number in the first different row from the top in the first matrix is greater than the corresponding number in the second one.
If there exists no such matrix then output -1.
Input
The first line consists of two numbers n and k (1 ≤ n ≤ 100, 0 ≤ k ≤ 106).
Output
If the answer exists then output resulting matrix. Otherwise output -1.
Examples
Input
2 1
Output
1 0
0 0
Input
3 2
Output
1 0 0
0 1 0
0 0 0
Input
2 5
Output
-1
Submitted Solution:
```
import sys
def solve():
n, k = map(int, input().split())
mat = [[0]*n for i in range(n)]
for i in range(n):
for j in range(i, n):
if k == 0:
break
if i == j:
mat[i][j] = 1
k -= 1
elif k > 1:
mat[i][j] = mat[j][i] = 1
k -= 2
if k != 0:
print(-1)
return
for mat_r in mat:
print(*mat_r)
if __name__ == '__main__':
solve()
``` | instruction | 0 | 48,492 | 11 | 96,984 |
Yes | output | 1 | 48,492 | 11 | 96,985 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given matrix with n rows and n columns filled with zeroes. You should put k ones in it in such a way that the resulting matrix is symmetrical with respect to the main diagonal (the diagonal that goes from the top left to the bottom right corner) and is lexicographically maximal.
One matrix is lexicographically greater than the other if the first different number in the first different row from the top in the first matrix is greater than the corresponding number in the second one.
If there exists no such matrix then output -1.
Input
The first line consists of two numbers n and k (1 ≤ n ≤ 100, 0 ≤ k ≤ 106).
Output
If the answer exists then output resulting matrix. Otherwise output -1.
Examples
Input
2 1
Output
1 0
0 0
Input
3 2
Output
1 0 0
0 1 0
0 0 0
Input
2 5
Output
-1
Submitted Solution:
```
#Bhargey Mehta (Sophomore)
#DA-IICT, Gandhinagar
import sys, math, queue
#sys.stdin = open("input.txt", "r")
MOD = 10**9+7
sys.setrecursionlimit(1000000)
n, k = map(int, input().split())
if k > n:
print(-1)
exit()
a = [[0 for i in range(n)] for i in range(n)]
if k == 1:
a[0][0] = 1
if k <= 1:
for ai in a:
print(*ai)
exit()
for i in range(n):
if k > 2:
a[i][i] = 1
k -= 1
elif k == 1:
a[i][i] = 1
break
for j in range(i+1, n):
if k < 2:
break
a[i][j] = 1
a[j][i] = 1
k -= 2
for ai in a:
print(*ai)
``` | instruction | 0 | 48,494 | 11 | 96,988 |
No | output | 1 | 48,494 | 11 | 96,989 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given matrix with n rows and n columns filled with zeroes. You should put k ones in it in such a way that the resulting matrix is symmetrical with respect to the main diagonal (the diagonal that goes from the top left to the bottom right corner) and is lexicographically maximal.
One matrix is lexicographically greater than the other if the first different number in the first different row from the top in the first matrix is greater than the corresponding number in the second one.
If there exists no such matrix then output -1.
Input
The first line consists of two numbers n and k (1 ≤ n ≤ 100, 0 ≤ k ≤ 106).
Output
If the answer exists then output resulting matrix. Otherwise output -1.
Examples
Input
2 1
Output
1 0
0 0
Input
3 2
Output
1 0 0
0 1 0
0 0 0
Input
2 5
Output
-1
Submitted Solution:
```
from collections import Counter;
import sys
n,k=map(int,input().split())
li=[[0]*n for _ in range(n)]
if k<=n:
i=0
while k>0:
li[i][i]=1
i+=1
k-=1
elif k>n and (n-k)==0:
while k>0:
for i in li:
for j in i:
if li[i][j]!=1:
li[i][j]=1
li[j][i]=1
k-=2
else:
li=None
if li==None:
print(-1)
else:
for i in li:
for j in i:
print(j,end=" ")
print()
``` | instruction | 0 | 48,495 | 11 | 96,990 |
No | output | 1 | 48,495 | 11 | 96,991 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given matrix with n rows and n columns filled with zeroes. You should put k ones in it in such a way that the resulting matrix is symmetrical with respect to the main diagonal (the diagonal that goes from the top left to the bottom right corner) and is lexicographically maximal.
One matrix is lexicographically greater than the other if the first different number in the first different row from the top in the first matrix is greater than the corresponding number in the second one.
If there exists no such matrix then output -1.
Input
The first line consists of two numbers n and k (1 ≤ n ≤ 100, 0 ≤ k ≤ 106).
Output
If the answer exists then output resulting matrix. Otherwise output -1.
Examples
Input
2 1
Output
1 0
0 0
Input
3 2
Output
1 0 0
0 1 0
0 0 0
Input
2 5
Output
-1
Submitted Solution:
```
def main():
n, k = map(int, input().split())
if n * n < k:
print(-1)
return
l = [['0'] * n for _ in range(n)]
for i in range(n):
q = (n - i) * 2 - 1
if q <= k:
for j in range(i, n):
l[i][j] = l[j][i] = '1'
k -= q
else:
for j in range(i, i + (k + 1) // 2):
l[i][j] = l[j][i] = '1'
if k & 0xfe:
l[i + 1][i + 1] = '1'
break
for r in l:
print(' '.join(r))
if __name__ == "__main__":
main()
``` | instruction | 0 | 48,497 | 11 | 96,994 |
No | output | 1 | 48,497 | 11 | 96,995 |
Provide a correct Python 3 solution for this coding contest problem.
Decades have passed since the beginning of AtCoder Beginner Contest.
The contests are labeled as `ABC001`, `ABC002`, ... from the first round, but after the 999-th round `ABC999`, a problem occurred: how the future rounds should be labeled?
In the end, the labels for the rounds from the 1000-th to the 1998-th are decided: `ABD001`, `ABD002`, ..., `ABD999`.
You are given an integer N between 1 and 1998 (inclusive). Print the first three characters of the label of the N-th round of AtCoder Beginner Contest.
Constraints
* 1 \leq N \leq 1998
* N is an integer.
Input
Input is given from Standard Input in the following format:
N
Output
Print the first three characters of the label of the N-th round of AtCoder Beginner Contest.
Examples
Input
999
Output
ABC
Input
1000
Output
ABD
Input
1481
Output
ABD | instruction | 0 | 48,622 | 11 | 97,244 |
"Correct Solution:
```
n = int(input())
print('ABD' if n > 999 else 'ABC')
``` | output | 1 | 48,622 | 11 | 97,245 |
Provide a correct Python 3 solution for this coding contest problem.
Decades have passed since the beginning of AtCoder Beginner Contest.
The contests are labeled as `ABC001`, `ABC002`, ... from the first round, but after the 999-th round `ABC999`, a problem occurred: how the future rounds should be labeled?
In the end, the labels for the rounds from the 1000-th to the 1998-th are decided: `ABD001`, `ABD002`, ..., `ABD999`.
You are given an integer N between 1 and 1998 (inclusive). Print the first three characters of the label of the N-th round of AtCoder Beginner Contest.
Constraints
* 1 \leq N \leq 1998
* N is an integer.
Input
Input is given from Standard Input in the following format:
N
Output
Print the first three characters of the label of the N-th round of AtCoder Beginner Contest.
Examples
Input
999
Output
ABC
Input
1000
Output
ABD
Input
1481
Output
ABD | instruction | 0 | 48,623 | 11 | 97,246 |
"Correct Solution:
```
print(["ABC","ABD"][1000<=int(input())])
``` | output | 1 | 48,623 | 11 | 97,247 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.