message stringlengths 2 44.5k | message_type stringclasses 2 values | message_id int64 0 1 | conversation_id int64 42 109k | cluster float64 5 5 | __index_level_0__ int64 84 217k |
|---|---|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given four positive integers n, m, a, b (1 ≤ b ≤ n ≤ 50; 1 ≤ a ≤ m ≤ 50). Find any such rectangular matrix of size n × m that satisfies all of the following conditions:
* each row of the matrix contains exactly a ones;
* each column of the matrix contains exactly b ones;
* all other elements are zeros.
If the desired matrix does not exist, indicate this.
For example, for n=3, m=6, a=2, b=1, there exists a matrix satisfying the conditions above:
$$$ \begin{vmatrix} 0 & 1 & 0 & 0 & 0 & 1 \\\ 1 & 0 & 0 & 1 & 0 & 0 \\\ 0 & 0 & 1 & 0 & 1 & 0 \end{vmatrix} $$$
Input
The first line contains an integer t (1 ≤ t ≤ 1000) — the number of test cases. Then t test cases follow.
Each test case is described by four positive integers n, m, a, b (1 ≤ b ≤ n ≤ 50; 1 ≤ a ≤ m ≤ 50), where n and m are the sizes of the matrix, and a and b are the number of ones for rows and columns, respectively.
Output
For each test case print:
* "YES" (without quotes) and the required matrix (if there are several answers, print any) if it exists, or
* "NO" (without quotes) if it does not exist.
To print the matrix n × m, print n rows, each of which consists of m numbers 0 or 1 describing a row of the matrix. Numbers must be printed without spaces.
Example
Input
5
3 6 2 1
2 2 2 1
2 2 2 2
4 4 2 2
2 1 1 2
Output
YES
010001
100100
001010
NO
YES
11
11
YES
1100
1100
0011
0011
YES
1
1
Submitted Solution:
```
def listToString(sx):
# initialize an empty string
str1 = ""
# traverse in the string
for ele in sx:
str1 += ele
# return string
return str1
for t in range(int(input())):
n, m, a, b = map(int, input().split())
if a*n != b*m:
print("NO")
else:
print("YES")
s = []
x = ['1'] * a
q = ['0'] * (m - a)
x.extend(q)
y = ""
y = listToString(x)
for i in range(0, n):
#for j in range(b):
s.append(y)
x = x[-2:] + x[:-2]
y = ""
y = listToString(x)
for i in range(n):
print(*s[i], sep='')
``` | instruction | 0 | 85,166 | 5 | 170,332 |
No | output | 1 | 85,166 | 5 | 170,333 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a sequence of numbers a1, a2, ..., an, and a number m.
Check if it is possible to choose a non-empty subsequence aij such that the sum of numbers in this subsequence is divisible by m.
Input
The first line contains two numbers, n and m (1 ≤ n ≤ 106, 2 ≤ m ≤ 103) — the size of the original sequence and the number such that sum should be divisible by it.
The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 109).
Output
In the single line print either "YES" (without the quotes) if there exists the sought subsequence, or "NO" (without the quotes), if such subsequence doesn't exist.
Examples
Input
3 5
1 2 3
Output
YES
Input
1 6
5
Output
NO
Input
4 6
3 1 1 3
Output
YES
Input
6 6
5 5 5 5 5 5
Output
YES
Note
In the first sample test you can choose numbers 2 and 3, the sum of which is divisible by 5.
In the second sample test the single non-empty subsequence of numbers is a single number 5. Number 5 is not divisible by 6, that is, the sought subsequence doesn't exist.
In the third sample test you need to choose two numbers 3 on the ends.
In the fourth sample test you can take the whole subsequence.
Submitted Solution:
```
n, m = map(int, input().split())
a = list(map(lambda x: x%m, map(int, input().split())))
h = {}
for el in a:
h[el] = h.get(el, 0) + 1
for v in h.values():
if v % m == 0:
print("YES")
exit()
possible = set([])
for el in a:
new = set([el])
for candidate in possible:
new.add((candidate + el)%m)
possible |= new
if 0 in possible:
print("YES")
exit()
print("NO")
``` | instruction | 0 | 85,361 | 5 | 170,722 |
Yes | output | 1 | 85,361 | 5 | 170,723 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a sequence of numbers a1, a2, ..., an, and a number m.
Check if it is possible to choose a non-empty subsequence aij such that the sum of numbers in this subsequence is divisible by m.
Input
The first line contains two numbers, n and m (1 ≤ n ≤ 106, 2 ≤ m ≤ 103) — the size of the original sequence and the number such that sum should be divisible by it.
The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 109).
Output
In the single line print either "YES" (without the quotes) if there exists the sought subsequence, or "NO" (without the quotes), if such subsequence doesn't exist.
Examples
Input
3 5
1 2 3
Output
YES
Input
1 6
5
Output
NO
Input
4 6
3 1 1 3
Output
YES
Input
6 6
5 5 5 5 5 5
Output
YES
Note
In the first sample test you can choose numbers 2 and 3, the sum of which is divisible by 5.
In the second sample test the single non-empty subsequence of numbers is a single number 5. Number 5 is not divisible by 6, that is, the sought subsequence doesn't exist.
In the third sample test you need to choose two numbers 3 on the ends.
In the fourth sample test you can take the whole subsequence.
Submitted Solution:
```
def main():
n, m = map(int, input().split())
mas = list(map(int, input().split()))
remains = set()
for i in range(n):
for_add = set()
for e in remains:
if (e + mas[i]) % m == 0:
return True
else:
for_add.add((e + mas[i]) % m)
if mas[i] % m == 0:
return True
else:
for_add.add(mas[i])
remains |= for_add
if main():
print("YES")
else:
print("NO")
``` | instruction | 0 | 85,362 | 5 | 170,724 |
Yes | output | 1 | 85,362 | 5 | 170,725 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a sequence of numbers a1, a2, ..., an, and a number m.
Check if it is possible to choose a non-empty subsequence aij such that the sum of numbers in this subsequence is divisible by m.
Input
The first line contains two numbers, n and m (1 ≤ n ≤ 106, 2 ≤ m ≤ 103) — the size of the original sequence and the number such that sum should be divisible by it.
The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 109).
Output
In the single line print either "YES" (without the quotes) if there exists the sought subsequence, or "NO" (without the quotes), if such subsequence doesn't exist.
Examples
Input
3 5
1 2 3
Output
YES
Input
1 6
5
Output
NO
Input
4 6
3 1 1 3
Output
YES
Input
6 6
5 5 5 5 5 5
Output
YES
Note
In the first sample test you can choose numbers 2 and 3, the sum of which is divisible by 5.
In the second sample test the single non-empty subsequence of numbers is a single number 5. Number 5 is not divisible by 6, that is, the sought subsequence doesn't exist.
In the third sample test you need to choose two numbers 3 on the ends.
In the fourth sample test you can take the whole subsequence.
Submitted Solution:
```
n, m = map(int, input().split())
a = list(map(int, input().split()))
rem = set()
for i in a:
new = {(i + j) % m for j in rem | {0}}
rem |= new
if 0 in rem:
print('YES')
exit()
print('NO')
``` | instruction | 0 | 85,364 | 5 | 170,728 |
Yes | output | 1 | 85,364 | 5 | 170,729 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a sequence of numbers a1, a2, ..., an, and a number m.
Check if it is possible to choose a non-empty subsequence aij such that the sum of numbers in this subsequence is divisible by m.
Input
The first line contains two numbers, n and m (1 ≤ n ≤ 106, 2 ≤ m ≤ 103) — the size of the original sequence and the number such that sum should be divisible by it.
The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 109).
Output
In the single line print either "YES" (without the quotes) if there exists the sought subsequence, or "NO" (without the quotes), if such subsequence doesn't exist.
Examples
Input
3 5
1 2 3
Output
YES
Input
1 6
5
Output
NO
Input
4 6
3 1 1 3
Output
YES
Input
6 6
5 5 5 5 5 5
Output
YES
Note
In the first sample test you can choose numbers 2 and 3, the sum of which is divisible by 5.
In the second sample test the single non-empty subsequence of numbers is a single number 5. Number 5 is not divisible by 6, that is, the sought subsequence doesn't exist.
In the third sample test you need to choose two numbers 3 on the ends.
In the fourth sample test you can take the whole subsequence.
Submitted Solution:
```
def process(a):
kr=[]
ar = [0 for j in range(m)]
k=0
for i in a:
r=int(i)%m
if r==0:
return 'YES'
r2=-1
for j in kr:
r2=(j+r)%m
if r2==0:
return 'YES'
ar[r2]+=1
if ar[r2] >= m:
return 'YES'
if kr.count(r2)==0 and r2>-1:
kr.append(r2)
ar[r]+=1
if ar[r] >= m:
return 'YES'
if kr.count(r)==0:
kr.append(r)
return 'NO'
s=input()
a=s.split(' ')
n, m = int(a[0]), int(a[1])
s=input()
a=s.split(' ')
print(process(a))
``` | instruction | 0 | 85,366 | 5 | 170,732 |
No | output | 1 | 85,366 | 5 | 170,733 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a sequence of numbers a1, a2, ..., an, and a number m.
Check if it is possible to choose a non-empty subsequence aij such that the sum of numbers in this subsequence is divisible by m.
Input
The first line contains two numbers, n and m (1 ≤ n ≤ 106, 2 ≤ m ≤ 103) — the size of the original sequence and the number such that sum should be divisible by it.
The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 109).
Output
In the single line print either "YES" (without the quotes) if there exists the sought subsequence, or "NO" (without the quotes), if such subsequence doesn't exist.
Examples
Input
3 5
1 2 3
Output
YES
Input
1 6
5
Output
NO
Input
4 6
3 1 1 3
Output
YES
Input
6 6
5 5 5 5 5 5
Output
YES
Note
In the first sample test you can choose numbers 2 and 3, the sum of which is divisible by 5.
In the second sample test the single non-empty subsequence of numbers is a single number 5. Number 5 is not divisible by 6, that is, the sought subsequence doesn't exist.
In the third sample test you need to choose two numbers 3 on the ends.
In the fourth sample test you can take the whole subsequence.
Submitted Solution:
```
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
mark = [0 for i in range(m)]
a = list(map(int,input().split()))
for x in a:
for i in range(m):
if(mark[i]==1):
mark[(i+x%m)%m]=1
mark[x%m]=1
if(mark[0]>0):
print("YES")
else:
print("NO")
``` | instruction | 0 | 85,368 | 5 | 170,736 |
No | output | 1 | 85,368 | 5 | 170,737 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N integers written on a blackboard. The i-th integer is A_i.
Takahashi and Aoki will arrange these integers in a row, as follows:
* First, Takahashi will arrange the integers as he wishes.
* Then, Aoki will repeatedly swap two adjacent integers that are coprime, as many times as he wishes.
We will assume that Takahashi acts optimally so that the eventual sequence will be lexicographically as small as possible, and we will also assume that Aoki acts optimally so that the eventual sequence will be lexicographically as large as possible. Find the eventual sequence that will be produced.
Constraints
* 1 ≦ N ≦ 2000
* 1 ≦ A_i ≦ 10^8
Input
The input is given from Standard Input in the following format:
N
A_1 A_2 … A_N
Output
Print the eventual sequence that will be produced, in a line.
Examples
Input
5
1 2 3 4 5
Output
5 3 2 4 1
Input
4
2 3 4 6
Output
2 4 6 3
Submitted Solution:
```
def gcd(a,b):
return gcd(b,a%b) if b else a
def merge(a,us,vs):
i,j,res=0,0,[]
while i<len(us) and j<len(vs):
if a[us[i]]>=a[vs[j]]:
res.append(us[i])
i+=1
else:
res.append(vs[j])
j+=1
return res+us[i:]+vs[j:]
def dfs(g,a,u,vis):
vis[u]=True
res=[]
for v in g[u]:
if not vis[v]:
res=merge(a,res,dfs(g,a,v,vis))
return [u]+res
while 1:
try:
n=int(input())
a=sorted(map(int,input().split()))
except: break
g=[[j for j in range(n) if i!=j and gcd(a[i],a[j])!=1] for i in range(n)]
#vis=[False]*n
#res=[]
#for u in range(n):
# if not vis[u]:
# res=merge(a,res,dfs(g,a,u,vis))
#print(' '.join(str(a[u]) for u in res))
``` | instruction | 0 | 85,616 | 5 | 171,232 |
No | output | 1 | 85,616 | 5 | 171,233 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N integers written on a blackboard. The i-th integer is A_i.
Takahashi and Aoki will arrange these integers in a row, as follows:
* First, Takahashi will arrange the integers as he wishes.
* Then, Aoki will repeatedly swap two adjacent integers that are coprime, as many times as he wishes.
We will assume that Takahashi acts optimally so that the eventual sequence will be lexicographically as small as possible, and we will also assume that Aoki acts optimally so that the eventual sequence will be lexicographically as large as possible. Find the eventual sequence that will be produced.
Constraints
* 1 ≦ N ≦ 2000
* 1 ≦ A_i ≦ 10^8
Input
The input is given from Standard Input in the following format:
N
A_1 A_2 … A_N
Output
Print the eventual sequence that will be produced, in a line.
Examples
Input
5
1 2 3 4 5
Output
5 3 2 4 1
Input
4
2 3 4 6
Output
2 4 6 3
Submitted Solution:
```
import random
def tester(N=0):
maxno1=10
maxno2=1e2
s=input()
if s!='':
return(s)
if N==0:
return(5)
return(random.randint(2,maxno1))
else:
print('Testing...')
print('N=',N)
return('1 2 3 4 5')
A=[]
for i in range(N):
A.extend([random.randint(1,maxno2)])
r=' '.join(list(map(str,A)))
print(r)
return(r)
def factorint(n):
i = 2
T = []
while i * i <= n:
while n % i == 0:
n //= i
T.append(i)
i += 1
if n > 1:
T.append(n)
return(T)
import logging
# create logger
logger = logging.getLogger('simple_example')
logger.setLevel(logging.DEBUG)
# create console handler and set level to debug
ch = logging.StreamHandler()
ch.setLevel(logging.WARNING)
# create formatter
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
# add formatter to ch
ch.setFormatter(formatter)
# add ch to logger
logger.addHandler(ch)
import copy
N=int(tester())
A=[int(x) for x in tester(N).split()]
A.sort(reverse=False)
logger.debug('A is %s',str(A))
F=dict()
P=dict()
for x in A:
if x==1:
F[1]={1}
else:
F[x]=set(factorint(x))
for y in F[x]:
if y not in P.keys():
P[y]=set()
P[y].add(x)
G=dict()
for x in F.keys():
G[x]=set()
for y in F[x]:
G[x]=G[x].union(P[y])
G[x].remove(x)
Ac=copy.deepcopy(A)
Gc=copy.deepcopy(G)
Tr=dict()
while len(Ac)>0:
Tmp=[]
rt=min(Ac)
me=rt
Tmp.extend([me])
Ac.remove(me)
while len(Gc[me])>0:
nxt=min(Gc[me])
if nxt not in Ac:
Gc[me].remove(nxt)
continue
else:
me=nxt
Tmp.extend([me])
Ac.remove(me)
Tr[rt]=Tmp
OoTr=list(Tr.keys())
OoTr.sort(reverse=True)
Ans=[]
for x in OoTr:
Ans.extend(Tr[x])
print(' '.join(list(map(str,Ans))))
(logger).removeHandler(ch)
``` | instruction | 0 | 85,617 | 5 | 171,234 |
No | output | 1 | 85,617 | 5 | 171,235 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N integers written on a blackboard. The i-th integer is A_i.
Takahashi and Aoki will arrange these integers in a row, as follows:
* First, Takahashi will arrange the integers as he wishes.
* Then, Aoki will repeatedly swap two adjacent integers that are coprime, as many times as he wishes.
We will assume that Takahashi acts optimally so that the eventual sequence will be lexicographically as small as possible, and we will also assume that Aoki acts optimally so that the eventual sequence will be lexicographically as large as possible. Find the eventual sequence that will be produced.
Constraints
* 1 ≦ N ≦ 2000
* 1 ≦ A_i ≦ 10^8
Input
The input is given from Standard Input in the following format:
N
A_1 A_2 … A_N
Output
Print the eventual sequence that will be produced, in a line.
Examples
Input
5
1 2 3 4 5
Output
5 3 2 4 1
Input
4
2 3 4 6
Output
2 4 6 3
Submitted Solution:
```
import sys
sys.setrecursionlimit(1000000000)
def gcd(a: int, b:int):
while b:
a,b=b,a%b
return a
def merge(a,us,vs):
i,j,res=0,0,[]
while i<len(us) and j<len(vs):
if a[us[i]]>=a[vs[j]]:
res.append(us[i])
i+=1
else:
res.append(vs[j])
j+=1
return res+us[i:]+vs[j:]
def dfs(g,a,u,vis):
vis[u]=True
res=[]
for v in g[u]:
if not vis[v]:
res=merge(a,res,dfs(g,a,v,vis))
return [u]+res
while 1:
try:
n=int(input())
a=sorted(map(int,input().split()))
except: break
g=[[] for _ in range(n)]
for i in range(n):
for j in range(i+1,n):
if gcd(a[i],a[j])!=1:
g[i].append(j)
g[j].append(i)
vis=[False]*n
res=[]
for u in range(n):
if not vis[u]:
res=merge(a,res,dfs(g,a,u,vis))
print(' '.join(str(a[u]) for u in res))
``` | instruction | 0 | 85,618 | 5 | 171,236 |
No | output | 1 | 85,618 | 5 | 171,237 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N integers written on a blackboard. The i-th integer is A_i.
Takahashi and Aoki will arrange these integers in a row, as follows:
* First, Takahashi will arrange the integers as he wishes.
* Then, Aoki will repeatedly swap two adjacent integers that are coprime, as many times as he wishes.
We will assume that Takahashi acts optimally so that the eventual sequence will be lexicographically as small as possible, and we will also assume that Aoki acts optimally so that the eventual sequence will be lexicographically as large as possible. Find the eventual sequence that will be produced.
Constraints
* 1 ≦ N ≦ 2000
* 1 ≦ A_i ≦ 10^8
Input
The input is given from Standard Input in the following format:
N
A_1 A_2 … A_N
Output
Print the eventual sequence that will be produced, in a line.
Examples
Input
5
1 2 3 4 5
Output
5 3 2 4 1
Input
4
2 3 4 6
Output
2 4 6 3
Submitted Solution:
```
import random
def tester(N=0):
'''
制約
1≦N≦2000
1≦Ai≦108
'''
maxno1=2000
maxno2=1e5
s=input()
if s!='':
return(s)
if N==0:
return(6)
return(random.randint(2,maxno1))
else:
print('Testing...')
print('N=',N)
return('1 2 3 4 5 2')
A=[]
for i in range(N):
A.extend([random.randint(1,maxno2)])
r=' '.join(list(map(str,A)))
return(r)
def factorint(n):
i = 2
T = set()
while i * i <= n:
while n % i == 0:
n //= i
T.add(i)
i += 1
if n > 1:
T.add(n)
return(T)
import logging
import time
# create logger
logger = logging.getLogger('simple_example')
logger.setLevel(logging.WARNING)#DEBUG)
# create console handler and set level to debug
ch = logging.StreamHandler()
ch.setLevel(logging.WARNING)#DEBUG)
# create formatter
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
# add formatter to ch
ch.setFormatter(formatter)
# add ch to logger
logger.addHandler(ch)
import copy
N=int(tester())
A=[int(x) for x in tester(N).split()]
start_time = time.time()
A.sort(reverse=False)
logger.debug('A is %s',str(A))
F=dict()
P=dict()
for i in range(N):
if A[i]==1:
F[i]={1}
else:
F[i]=factorint(A[i])
for pn in F[i]:
if pn not in P.keys():
P[pn]=set()
P[pn].add(i)
stepcount=1
logger.debug('Step %d: loss = %.2f (%.3f sec)' % (stepcount, 100, time.time() - start_time))
G=dict()
for i in F.keys():
G[i]=set()
for y in F[i]:
G[i]=G[i].union(P[y])
G[i]={k for k in G[i] if k>i}
#G[i].remove(i)
stepcount=2
logger.debug('Step %d: loss = %.2f (%.3f sec)' % (stepcount, 100, time.time() - start_time))
'''
https://ja.m.wikipedia.org/wiki/トポロジカルソート
L ← トポロジカルソートされた結果の入る空の連結リスト
for each ノード n do
visit(n)
function visit(Node n)
if n をまだ訪れていなければ then
n を訪問済みとして印を付ける
for each n の出力辺 e とその先のノード m do
visit(m)
n を L の先頭に追加
'''
#bellow is a bottleneck
Ac=set(range(N))
stepcount=21
logger.debug('Step %d: loss = %.2f (%.3f sec)' % (stepcount, 100, time.time() - start_time))
Gc=copy.copy(G)
Tr=dict()
stepcount=22
logger.debug('Step %d: loss = %.2f (%.3f sec)' % (stepcount, 100, time.time() - start_time))
while len(Ac)>0:
Tmp=[]
rt=Ac.pop()
me=rt
Tmp.extend([me])
while len(Gc[me])>0:
nxt=Gc[me].pop()
if nxt in Ac:
#Gc[nxt]=Gc[nxt]-{me}
me=nxt
Tmp.extend([me])
Ac.remove(me)
Tr[rt]=Tmp
stepcount=3
logger.debug('Step %d: loss = %.2f (%.3f sec)' % (stepcount, 100, time.time() - start_time))
OoTr=list(Tr.keys())
OoTr.sort(reverse=True)
AnsIdx=[]
for i in OoTr:
AnsIdx.extend(Tr[i])
stepcount=4
logger.debug('Step %d: loss = %.2f (%.3f sec)' % (stepcount, 100, time.time() - start_time))
for i in range(N):
for j in range(N-1,i,-1):
if AnsIdx[j-1]<AnsIdx[j]:
if F[AnsIdx[j-1]]&F[AnsIdx[j]]==set():
AnsIdx[j-1],AnsIdx[j]=AnsIdx[j],AnsIdx[j-1]
Ans=[A[i] for i in AnsIdx]
print(' '.join(list(map(str,Ans))))
stepcount=5
logger.debug('Step %d: loss = %.2f (%.3f sec)' % (stepcount, 100, time.time() - start_time))
logger.removeHandler(ch)
``` | instruction | 0 | 85,619 | 5 | 171,238 |
No | output | 1 | 85,619 | 5 | 171,239 |
Provide a correct Python 3 solution for this coding contest problem.
For given three integers $a, b, c$, print the minimum value and the maximum value.
Constraints
* $-1,000,000,000 \leq a, b, c \leq 1,000,000,000$
Input
The input is given in the following format.
$a \; b \; c\;$
Three integers $a, b, c$ are given in a line.
Output
Print the minimum and maximum values separated by a space in a line.
Example
Input
4 5 3
Output
3 5 | instruction | 0 | 85,704 | 5 | 171,408 |
"Correct Solution:
```
# coding=utf-8
A = list(map(int, input().split()))
print("{0} {1}".format(min(A), max(A)))
``` | output | 1 | 85,704 | 5 | 171,409 |
Provide a correct Python 3 solution for this coding contest problem.
For given three integers $a, b, c$, print the minimum value and the maximum value.
Constraints
* $-1,000,000,000 \leq a, b, c \leq 1,000,000,000$
Input
The input is given in the following format.
$a \; b \; c\;$
Three integers $a, b, c$ are given in a line.
Output
Print the minimum and maximum values separated by a space in a line.
Example
Input
4 5 3
Output
3 5 | instruction | 0 | 85,705 | 5 | 171,410 |
"Correct Solution:
```
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_3_A&lang=jp
# Min-Max
from functools import reduce
from collections import deque
import sys
input = sys.stdin.readline
def main():
l = list ( map(int,input().split()))
max = reduce(lambda a,b : a if a > b else b,l)
min = reduce(lambda a,b : a if a < b else b,l)
print (min,max)
if __name__ == '__main__':
main()
``` | output | 1 | 85,705 | 5 | 171,411 |
Provide a correct Python 3 solution for this coding contest problem.
For given three integers $a, b, c$, print the minimum value and the maximum value.
Constraints
* $-1,000,000,000 \leq a, b, c \leq 1,000,000,000$
Input
The input is given in the following format.
$a \; b \; c\;$
Three integers $a, b, c$ are given in a line.
Output
Print the minimum and maximum values separated by a space in a line.
Example
Input
4 5 3
Output
3 5 | instruction | 0 | 85,706 | 5 | 171,412 |
"Correct Solution:
```
if __name__ == '__main__':
a,b,c = map(int,input().split())
print(min(a,b,c),max(a,b,c))
``` | output | 1 | 85,706 | 5 | 171,413 |
Provide a correct Python 3 solution for this coding contest problem.
For given three integers $a, b, c$, print the minimum value and the maximum value.
Constraints
* $-1,000,000,000 \leq a, b, c \leq 1,000,000,000$
Input
The input is given in the following format.
$a \; b \; c\;$
Three integers $a, b, c$ are given in a line.
Output
Print the minimum and maximum values separated by a space in a line.
Example
Input
4 5 3
Output
3 5 | instruction | 0 | 85,707 | 5 | 171,414 |
"Correct Solution:
```
a= list(map(int, input().split()))
print('{} {}'.format(min(a), max(a)))
``` | output | 1 | 85,707 | 5 | 171,415 |
Provide a correct Python 3 solution for this coding contest problem.
For given three integers $a, b, c$, print the minimum value and the maximum value.
Constraints
* $-1,000,000,000 \leq a, b, c \leq 1,000,000,000$
Input
The input is given in the following format.
$a \; b \; c\;$
Three integers $a, b, c$ are given in a line.
Output
Print the minimum and maximum values separated by a space in a line.
Example
Input
4 5 3
Output
3 5 | instruction | 0 | 85,708 | 5 | 171,416 |
"Correct Solution:
```
inp = list(map(int, input().split()))
print("{} {}".format(min(inp), max(inp)))
``` | output | 1 | 85,708 | 5 | 171,417 |
Provide a correct Python 3 solution for this coding contest problem.
For given three integers $a, b, c$, print the minimum value and the maximum value.
Constraints
* $-1,000,000,000 \leq a, b, c \leq 1,000,000,000$
Input
The input is given in the following format.
$a \; b \; c\;$
Three integers $a, b, c$ are given in a line.
Output
Print the minimum and maximum values separated by a space in a line.
Example
Input
4 5 3
Output
3 5 | instruction | 0 | 85,709 | 5 | 171,418 |
"Correct Solution:
```
temp = list(map(int, input().split()))
print(min(temp), max(temp))
``` | output | 1 | 85,709 | 5 | 171,419 |
Provide a correct Python 3 solution for this coding contest problem.
For given three integers $a, b, c$, print the minimum value and the maximum value.
Constraints
* $-1,000,000,000 \leq a, b, c \leq 1,000,000,000$
Input
The input is given in the following format.
$a \; b \; c\;$
Three integers $a, b, c$ are given in a line.
Output
Print the minimum and maximum values separated by a space in a line.
Example
Input
4 5 3
Output
3 5 | instruction | 0 | 85,710 | 5 | 171,420 |
"Correct Solution:
```
l = list(map(int, input().split()))
print(min(l),max(l))
``` | output | 1 | 85,710 | 5 | 171,421 |
Provide a correct Python 3 solution for this coding contest problem.
For given three integers $a, b, c$, print the minimum value and the maximum value.
Constraints
* $-1,000,000,000 \leq a, b, c \leq 1,000,000,000$
Input
The input is given in the following format.
$a \; b \; c\;$
Three integers $a, b, c$ are given in a line.
Output
Print the minimum and maximum values separated by a space in a line.
Example
Input
4 5 3
Output
3 5 | instruction | 0 | 85,711 | 5 | 171,422 |
"Correct Solution:
```
a=list(map(int,input().split()))
print("{} {}".format(min(a),max(a)))
``` | output | 1 | 85,711 | 5 | 171,423 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For given three integers $a, b, c$, print the minimum value and the maximum value.
Constraints
* $-1,000,000,000 \leq a, b, c \leq 1,000,000,000$
Input
The input is given in the following format.
$a \; b \; c\;$
Three integers $a, b, c$ are given in a line.
Output
Print the minimum and maximum values separated by a space in a line.
Example
Input
4 5 3
Output
3 5
Submitted Solution:
```
numbers = list(map(int, input().split()))
print(str(min(numbers))+" "+str(max(numbers)))
``` | instruction | 0 | 85,712 | 5 | 171,424 |
Yes | output | 1 | 85,712 | 5 | 171,425 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For given three integers $a, b, c$, print the minimum value and the maximum value.
Constraints
* $-1,000,000,000 \leq a, b, c \leq 1,000,000,000$
Input
The input is given in the following format.
$a \; b \; c\;$
Three integers $a, b, c$ are given in a line.
Output
Print the minimum and maximum values separated by a space in a line.
Example
Input
4 5 3
Output
3 5
Submitted Solution:
```
a=[int(i) for i in input().split()]
print(min(a),max(a))
``` | instruction | 0 | 85,713 | 5 | 171,426 |
Yes | output | 1 | 85,713 | 5 | 171,427 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For given three integers $a, b, c$, print the minimum value and the maximum value.
Constraints
* $-1,000,000,000 \leq a, b, c \leq 1,000,000,000$
Input
The input is given in the following format.
$a \; b \; c\;$
Three integers $a, b, c$ are given in a line.
Output
Print the minimum and maximum values separated by a space in a line.
Example
Input
4 5 3
Output
3 5
Submitted Solution:
```
a = list(map(int, input().split()))
print('%d %d' % (min(a), max(a)))
``` | instruction | 0 | 85,714 | 5 | 171,428 |
Yes | output | 1 | 85,714 | 5 | 171,429 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For given three integers $a, b, c$, print the minimum value and the maximum value.
Constraints
* $-1,000,000,000 \leq a, b, c \leq 1,000,000,000$
Input
The input is given in the following format.
$a \; b \; c\;$
Three integers $a, b, c$ are given in a line.
Output
Print the minimum and maximum values separated by a space in a line.
Example
Input
4 5 3
Output
3 5
Submitted Solution:
```
# coding: utf-8
# Your code here!
a,b,c=map(int,input().split())
print(min(a,b,c),max(a,b,c))
``` | instruction | 0 | 85,715 | 5 | 171,430 |
Yes | output | 1 | 85,715 | 5 | 171,431 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For given three integers $a, b, c$, print the minimum value and the maximum value.
Constraints
* $-1,000,000,000 \leq a, b, c \leq 1,000,000,000$
Input
The input is given in the following format.
$a \; b \; c\;$
Three integers $a, b, c$ are given in a line.
Output
Print the minimum and maximum values separated by a space in a line.
Example
Input
4 5 3
Output
3 5
Submitted Solution:
```
a, b, c = list(map(int, input().split()))
print('{} {}'.format(min([a,b,c], max([a,b,c])))
``` | instruction | 0 | 85,716 | 5 | 171,432 |
No | output | 1 | 85,716 | 5 | 171,433 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For given three integers $a, b, c$, print the minimum value and the maximum value.
Constraints
* $-1,000,000,000 \leq a, b, c \leq 1,000,000,000$
Input
The input is given in the following format.
$a \; b \; c\;$
Three integers $a, b, c$ are given in a line.
Output
Print the minimum and maximum values separated by a space in a line.
Example
Input
4 5 3
Output
3 5
Submitted Solution:
```
nums = list(map(int, input().split(' ')))
max = -float('inf')
min = flaot('inf')
for num in nums:
if num > max: max = num
if num < min: min = num
print(min, max)
``` | instruction | 0 | 85,717 | 5 | 171,434 |
No | output | 1 | 85,717 | 5 | 171,435 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For given three integers $a, b, c$, print the minimum value and the maximum value.
Constraints
* $-1,000,000,000 \leq a, b, c \leq 1,000,000,000$
Input
The input is given in the following format.
$a \; b \; c\;$
Three integers $a, b, c$ are given in a line.
Output
Print the minimum and maximum values separated by a space in a line.
Example
Input
4 5 3
Output
3 5
Submitted Solution:
```
a, b, c = list(map(int, input().split()))
print('{} {}'.format(min([a,b,c], max([a,b,c]))))
``` | instruction | 0 | 85,718 | 5 | 171,436 |
No | output | 1 | 85,718 | 5 | 171,437 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For given three integers $a, b, c$, print the minimum value and the maximum value.
Constraints
* $-1,000,000,000 \leq a, b, c \leq 1,000,000,000$
Input
The input is given in the following format.
$a \; b \; c\;$
Three integers $a, b, c$ are given in a line.
Output
Print the minimum and maximum values separated by a space in a line.
Example
Input
4 5 3
Output
3 5
Submitted Solution:
```
a, b, c = list(map(int, input().splist()))
print('{} {}'.format(min([a,b,c], max([a,b,c]))))
``` | instruction | 0 | 85,719 | 5 | 171,438 |
No | output | 1 | 85,719 | 5 | 171,439 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an equation:
Ax2 + Bx + C = 0.
Your task is to find the number of distinct roots of the equation and print all of them in ascending order.
Input
The first line contains three integer numbers A, B and C ( - 105 ≤ A, B, C ≤ 105). Any coefficient may be equal to 0.
Output
In case of infinite root count print the only integer -1. In case of no roots print the only integer 0. In other cases print the number of root on the first line and the roots on the following lines in the ascending order. Print roots with at least 5 digits after the decimal point.
Examples
Input
1 -5 6
Output
2
2.0000000000
3.0000000000
Submitted Solution:
```
a, b, c = map(float, input().split())
d = b ** 2 - 4 * a * c
if d < 0:
print(0)
elif a == 0 and b == 0:
if c == 0:
print(-1)
else:
print(0)
elif a == 0:
print(1)
print(-c / b)
else:
x = [float((-b + d ** 0.5) / 2 / a)]
v1 = float((-b - d ** 0.5) / 2 / a)
if not v1 in x:
x += [v1]
x.sort()
print(len(x))
for v in x:
print("%.6f" % float(v))
``` | instruction | 0 | 85,998 | 5 | 171,996 |
Yes | output | 1 | 85,998 | 5 | 171,997 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an equation:
Ax2 + Bx + C = 0.
Your task is to find the number of distinct roots of the equation and print all of them in ascending order.
Input
The first line contains three integer numbers A, B and C ( - 105 ≤ A, B, C ≤ 105). Any coefficient may be equal to 0.
Output
In case of infinite root count print the only integer -1. In case of no roots print the only integer 0. In other cases print the number of root on the first line and the roots on the following lines in the ascending order. Print roots with at least 5 digits after the decimal point.
Examples
Input
1 -5 6
Output
2
2.0000000000
3.0000000000
Submitted Solution:
```
a, b, c = [int(x) for x in input().split()]
if a == 0 and b == 0:
if c == 0:
print(-1)
else:
print(0)
elif a == 0:
print(1)
print("{0:.5f}".format(-c/b))
else:
root1 = (-b+(b**2-4*a*c)**0.5)/(2*a)
root2 = (-b-(b**2-4*a*c)**0.5)/(2*a)
if root1 == root2:
print(1)
print("{0:.5f}".format(root1))
elif type(root1) == complex and type(root2) == complex:
print(0)
elif type(root1) == complex:
print(1)
print("{0:.5f}".format(root2))
elif type(root2) == complex:
print(1)
print("{0:.5f}".format(root1))
elif root1 > root2:
print(2)
print("{0:.5f}".format(root2))
print("{0:.5f}".format(root1))
else:
print(2)
print("{0:.5f}".format(root1))
print("{0:.5f}".format(root2))
``` | instruction | 0 | 85,999 | 5 | 171,998 |
Yes | output | 1 | 85,999 | 5 | 171,999 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an equation:
Ax2 + Bx + C = 0.
Your task is to find the number of distinct roots of the equation and print all of them in ascending order.
Input
The first line contains three integer numbers A, B and C ( - 105 ≤ A, B, C ≤ 105). Any coefficient may be equal to 0.
Output
In case of infinite root count print the only integer -1. In case of no roots print the only integer 0. In other cases print the number of root on the first line and the roots on the following lines in the ascending order. Print roots with at least 5 digits after the decimal point.
Examples
Input
1 -5 6
Output
2
2.0000000000
3.0000000000
Submitted Solution:
```
import math
def solve_const(x):
if(x == 0):
print(-1)
else:
print(0)
def solve_lineal(x, y):
if(y == 0):
#yt = 0 => t = 0
print(1)
print(0)
else:
#xt + y = 0 => t = -y/x
print(1)
print(-y / x)
def solve_square(x, y, z):
d = y * y - 4 * x * z
if(d < 0):
print(0)
elif(d > 0):
print(2)
x1 = (-y + math.sqrt(d)) / (2 * x)
x2 = (-y - math.sqrt(d)) / (2 * x)
print(min(x1, x2))
print(max(x1, x2))
else:
print(1)
print((-y) / (2 * x))
a, b, c = map(int, input().split())
if(a == 0):
if(b == 0):
solve_const(c)
else:
solve_lineal(b, c)
else:
solve_square(a, b, c)
``` | instruction | 0 | 86,000 | 5 | 172,000 |
Yes | output | 1 | 86,000 | 5 | 172,001 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an equation:
Ax2 + Bx + C = 0.
Your task is to find the number of distinct roots of the equation and print all of them in ascending order.
Input
The first line contains three integer numbers A, B and C ( - 105 ≤ A, B, C ≤ 105). Any coefficient may be equal to 0.
Output
In case of infinite root count print the only integer -1. In case of no roots print the only integer 0. In other cases print the number of root on the first line and the roots on the following lines in the ascending order. Print roots with at least 5 digits after the decimal point.
Examples
Input
1 -5 6
Output
2
2.0000000000
3.0000000000
Submitted Solution:
```
a, b, c = map(int, input().split())
t = [1, -c / b] if b else [-(c == 0)]
if a:
d, x = b * b - 4 * a * c, -2 * a
if d: t = [0] if d < 0 else [2] + sorted([(b - d ** 0.5) / x, (b + d ** 0.5) / x])
else: t = [1, b / x]
print(*t)
``` | instruction | 0 | 86,001 | 5 | 172,002 |
Yes | output | 1 | 86,001 | 5 | 172,003 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an equation:
Ax2 + Bx + C = 0.
Your task is to find the number of distinct roots of the equation and print all of them in ascending order.
Input
The first line contains three integer numbers A, B and C ( - 105 ≤ A, B, C ≤ 105). Any coefficient may be equal to 0.
Output
In case of infinite root count print the only integer -1. In case of no roots print the only integer 0. In other cases print the number of root on the first line and the roots on the following lines in the ascending order. Print roots with at least 5 digits after the decimal point.
Examples
Input
1 -5 6
Output
2
2.0000000000
3.0000000000
Submitted Solution:
```
A, B, C = map(int, input().split())
if A == 0 and B == 0 and C == 0:
print(-1)
elif A == 0 and B == 0:
print(0)
elif A == 0 and C == 0:
print(1)
print(0)
elif B == 0 and C == 0:
print(1)
print(0)
elif A == 0:
print(1)
print(-(C / B))
elif B == 0:
print(2)
Ans1 = -((C / A) ** 0.5)
Ans2 = (C / A) ** 0.5
print(min(Ans1, Ans2))
print(max(Ans1, Ans2))
elif C == 0:
print(2)
if B / A < 0:
print(min(-(B / A), 0))
print(max(-(B / A), 0))
else:
print(min(B / A, 0))
print(max(B / A, 0))
else:
D = B ** 2 - 4 * A * C
if D < 0:
print(0)
elif D == 0:
print(1)
print(-B / (A * 2))
elif D > 0:
print(2)
Ans1 = (-B - (D ** 0.5)) / (A * 2)
Ans2 = (-B + (D ** 0.5)) / (A * 2)
print(min(Ans1, Ans2))
print(max(Ans1, Ans2))
``` | instruction | 0 | 86,002 | 5 | 172,004 |
No | output | 1 | 86,002 | 5 | 172,005 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an equation:
Ax2 + Bx + C = 0.
Your task is to find the number of distinct roots of the equation and print all of them in ascending order.
Input
The first line contains three integer numbers A, B and C ( - 105 ≤ A, B, C ≤ 105). Any coefficient may be equal to 0.
Output
In case of infinite root count print the only integer -1. In case of no roots print the only integer 0. In other cases print the number of root on the first line and the roots on the following lines in the ascending order. Print roots with at least 5 digits after the decimal point.
Examples
Input
1 -5 6
Output
2
2.0000000000
3.0000000000
Submitted Solution:
```
from math import sqrt
a,b,c = map(int,input().split())
if a==0 and b == 0:
print("-1")
elif a == 0 :
x = -1*c/b
if x == 0:
print(x)
else:
print('1')
print ("{0:.5f}".format(x))
elif b == 0 :
x = -1*c/a
if x <= 0:
print('0')
else:
print('1')
print ("{0:.5f}".format(sqrt(x)))
else:
result = b**2 - 4*a*c
if result<0:
print('0')
else:
x = ((-1*b) - sqrt(result))/(2*a)
y = ((-1*b) + sqrt(result))/(2*a)
if x == y:
print(1)
print("{0:.5f}".format(x))
else:
print(2)
print("{0:.5f}".format(x))
print("{0:.5f}".format(y))
``` | instruction | 0 | 86,003 | 5 | 172,006 |
No | output | 1 | 86,003 | 5 | 172,007 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an equation:
Ax2 + Bx + C = 0.
Your task is to find the number of distinct roots of the equation and print all of them in ascending order.
Input
The first line contains three integer numbers A, B and C ( - 105 ≤ A, B, C ≤ 105). Any coefficient may be equal to 0.
Output
In case of infinite root count print the only integer -1. In case of no roots print the only integer 0. In other cases print the number of root on the first line and the roots on the following lines in the ascending order. Print roots with at least 5 digits after the decimal point.
Examples
Input
1 -5 6
Output
2
2.0000000000
3.0000000000
Submitted Solution:
```
import sys, math
input = sys.stdin.readline
a, b, c = map(int, input().split())
if(a == 0):
if(b == 0):
if(c == 0):
print(-1)
else:
print(0)
else:
print("1\n{:.6f}".format(c / b))
else:
delta = b * b - 4 * a * c
if(delta < 0):
print(0)
elif(delta == 0):
print("1\n{:.6f}".format(-b / (2 *a)))
else:
x1 = (-b - math.sqrt(delta)) / (2 * a)
x2 = (-b + math.sqrt(delta)) / (2 * a)
print(2)
print("{:.6f}\n{:.6f}".format(min(x1, x2), max(x1,x2)))
``` | instruction | 0 | 86,004 | 5 | 172,008 |
No | output | 1 | 86,004 | 5 | 172,009 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an equation:
Ax2 + Bx + C = 0.
Your task is to find the number of distinct roots of the equation and print all of them in ascending order.
Input
The first line contains three integer numbers A, B and C ( - 105 ≤ A, B, C ≤ 105). Any coefficient may be equal to 0.
Output
In case of infinite root count print the only integer -1. In case of no roots print the only integer 0. In other cases print the number of root on the first line and the roots on the following lines in the ascending order. Print roots with at least 5 digits after the decimal point.
Examples
Input
1 -5 6
Output
2
2.0000000000
3.0000000000
Submitted Solution:
```
class CodeforcesTask20BSolution:
def __init__(self):
self.result = ''
self.a_b_c = []
def read_input(self):
self.a_b_c = [int(x) for x in input().split(" ")]
def process_task(self):
if not self.a_b_c[0]:
if not self.a_b_c[1]:
if not self.a_b_c[2]:
self.result = "-1"
else:
self.result = "0"
else:
self.result = "1\n{0:.6f}".format(-self.a_b_c[2] / self.a_b_c[1])
else:
delta = self.a_b_c[1] ** 2 - 4 * self.a_b_c[0] * self.a_b_c[2]
if not delta:
self.result = "1\n{0:.6f}".format(-self.a_b_c[2] / self.a_b_c[0])
elif delta < 0:
self.result = "0"
else:
import math
s_delta = math.sqrt(delta)
roots = [(-self.a_b_c[1] - s_delta) / (2 * self.a_b_c[0]), (-self.a_b_c[1] + s_delta) / (2 * self.a_b_c[0])]
roots.sort()
self.result = "2\n{0:.6f}\n{1:.6f}".format(roots[0], roots[1])
def get_result(self):
return self.result
if __name__ == "__main__":
Solution = CodeforcesTask20BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())
``` | instruction | 0 | 86,005 | 5 | 172,010 |
No | output | 1 | 86,005 | 5 | 172,011 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a rebus of form ? + ? - ? + ? = n, consisting of only question marks, separated by arithmetic operation '+' and '-', equality and positive integer n. The goal is to replace each question mark with some positive integer from 1 to n, such that equality holds.
Input
The only line of the input contains a rebus. It's guaranteed that it contains no more than 100 question marks, integer n is positive and doesn't exceed 1 000 000, all letters and integers are separated by spaces, arithmetic operations are located only between question marks.
Output
The first line of the output should contain "Possible" (without quotes) if rebus has a solution and "Impossible" (without quotes) otherwise.
If the answer exists, the second line should contain any valid rebus with question marks replaced by integers from 1 to n. Follow the format given in the samples.
Examples
Input
? + ? - ? + ? + ? = 42
Output
Possible
9 + 13 - 39 + 28 + 31 = 42
Input
? - ? = 1
Output
Impossible
Input
? = 1000000
Output
Possible
1000000 = 1000000
Submitted Solution:
```
#!/bin/python3
a = input()
while a:
expr, n = a.split('=')
n = int(n.strip())
pos = 1
neg = 0
sg = [1]
for c in expr:
if c == '+':
pos += 1
sg.append(1)
elif c == '-':
neg += 1
sg.append(0)
csum = pos - neg
rez = []
for i in sg:
if csum < n:
if i > 0:
v = min(n-csum, n-1)
csum += v
rez.append(1+v)
else:
rez.append(-1)
else:
if i > 0:
rez.append(1)
else:
v = min(csum - n, n-1)
csum -= v
rez.append(-1-v)
if csum == n:
print("Possible")
ans = str(rez[0])
for j in rez[1:]:
ans += " " + ("+" if j > 0 else "-") + " "
ans += str(abs(j))
ans += " = " + str(n)
print(ans)
else:
print("Impossible")
break
a = input()
``` | instruction | 0 | 86,161 | 5 | 172,322 |
Yes | output | 1 | 86,161 | 5 | 172,323 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a rebus of form ? + ? - ? + ? = n, consisting of only question marks, separated by arithmetic operation '+' and '-', equality and positive integer n. The goal is to replace each question mark with some positive integer from 1 to n, such that equality holds.
Input
The only line of the input contains a rebus. It's guaranteed that it contains no more than 100 question marks, integer n is positive and doesn't exceed 1 000 000, all letters and integers are separated by spaces, arithmetic operations are located only between question marks.
Output
The first line of the output should contain "Possible" (without quotes) if rebus has a solution and "Impossible" (without quotes) otherwise.
If the answer exists, the second line should contain any valid rebus with question marks replaced by integers from 1 to n. Follow the format given in the samples.
Examples
Input
? + ? - ? + ? + ? = 42
Output
Possible
9 + 13 - 39 + 28 + 31 = 42
Input
? - ? = 1
Output
Impossible
Input
? = 1000000
Output
Possible
1000000 = 1000000
Submitted Solution:
```
from sys import stdin,stdout
input=lambda:stdin.readline().strip()
lst=input().split()
nq=0
nm=0
for i in lst:
if i=='?':
nq+=1
elif i=='-':
nm+=1
np=nq-nm
n=int(lst[-1])
sum1=n+nm-np
lst1=[1]*np
if sum1<0:
print('Impossible')
else:
i=0
while i<np and sum1>0:
if sum1<=(n-1):
lst1[i]=lst1[i]+sum1
sum1=0
else:
lst1[i]=lst1[i]+(n-1)
sum1=sum1-(n-1)
i+=1
if sum1>0:
print('Impossible')
else:
print('Possible')
nn=len(lst)
j=0
if lst[0]=='?':
lst[0]=lst1[0]
j+=1
i=0
while i<nn:
if lst[i]=='+':
lst[i+1]=lst1[j]
j+=1
i+=1
elif lst[i]=='-':
lst[i+1]=1
i+=1
i+=1
print(*lst)
``` | instruction | 0 | 86,166 | 5 | 172,332 |
No | output | 1 | 86,166 | 5 | 172,333 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a rebus of form ? + ? - ? + ? = n, consisting of only question marks, separated by arithmetic operation '+' and '-', equality and positive integer n. The goal is to replace each question mark with some positive integer from 1 to n, such that equality holds.
Input
The only line of the input contains a rebus. It's guaranteed that it contains no more than 100 question marks, integer n is positive and doesn't exceed 1 000 000, all letters and integers are separated by spaces, arithmetic operations are located only between question marks.
Output
The first line of the output should contain "Possible" (without quotes) if rebus has a solution and "Impossible" (without quotes) otherwise.
If the answer exists, the second line should contain any valid rebus with question marks replaced by integers from 1 to n. Follow the format given in the samples.
Examples
Input
? + ? - ? + ? + ? = 42
Output
Possible
9 + 13 - 39 + 28 + 31 = 42
Input
? - ? = 1
Output
Impossible
Input
? = 1000000
Output
Possible
1000000 = 1000000
Submitted Solution:
```
s=input().split()
f=False
p=0
c=0
for num,i in enumerate(s):
if i=='=': break
if i=='?' and (not f):
p=num
f=True
continue
if i=='?':
if(i==0 or s[num-1]=='+'):
c+=1
s[num]='1'
elif (s[num-1]=='-'):
c-=1
s[num]='1'
if c < 0 or c >= int(s[-1]):
print('Impossible')
exit(0)
else:
print('Possible')
s[p]=int(s[-1])-c
print(*s)
``` | instruction | 0 | 86,167 | 5 | 172,334 |
No | output | 1 | 86,167 | 5 | 172,335 |
Provide a correct Python 3 solution for this coding contest problem.
Having learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together. He cannot do any other calculation.
Given are two integers A and B.
If Takahashi can calculate A \times B, print the result; if he cannot, print `-1` instead.
Constraints
* 1 \leq A \leq 20
* 1 \leq B \leq 20
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
A B
Output
If Takahashi can calculate A \times B, print the result; if he cannot, print `-1`.
Examples
Input
2 5
Output
10
Input
5 10
Output
-1
Input
9 9
Output
81 | instruction | 0 | 86,329 | 5 | 172,658 |
"Correct Solution:
```
a,b=map(int,input().split())
print(a*b if a<10 and b<10 else "-1")
``` | output | 1 | 86,329 | 5 | 172,659 |
Provide a correct Python 3 solution for this coding contest problem.
Having learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together. He cannot do any other calculation.
Given are two integers A and B.
If Takahashi can calculate A \times B, print the result; if he cannot, print `-1` instead.
Constraints
* 1 \leq A \leq 20
* 1 \leq B \leq 20
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
A B
Output
If Takahashi can calculate A \times B, print the result; if he cannot, print `-1`.
Examples
Input
2 5
Output
10
Input
5 10
Output
-1
Input
9 9
Output
81 | instruction | 0 | 86,330 | 5 | 172,660 |
"Correct Solution:
```
a,b=map(int,input().split());print(-1 if a>9 or b>9 else a*b)
``` | output | 1 | 86,330 | 5 | 172,661 |
Provide a correct Python 3 solution for this coding contest problem.
Having learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together. He cannot do any other calculation.
Given are two integers A and B.
If Takahashi can calculate A \times B, print the result; if he cannot, print `-1` instead.
Constraints
* 1 \leq A \leq 20
* 1 \leq B \leq 20
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
A B
Output
If Takahashi can calculate A \times B, print the result; if he cannot, print `-1`.
Examples
Input
2 5
Output
10
Input
5 10
Output
-1
Input
9 9
Output
81 | instruction | 0 | 86,331 | 5 | 172,662 |
"Correct Solution:
```
a,b=map(int, input().split())
print(a*b if a<=9 and b<=9 else "-1")
``` | output | 1 | 86,331 | 5 | 172,663 |
Provide a correct Python 3 solution for this coding contest problem.
Having learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together. He cannot do any other calculation.
Given are two integers A and B.
If Takahashi can calculate A \times B, print the result; if he cannot, print `-1` instead.
Constraints
* 1 \leq A \leq 20
* 1 \leq B \leq 20
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
A B
Output
If Takahashi can calculate A \times B, print the result; if he cannot, print `-1`.
Examples
Input
2 5
Output
10
Input
5 10
Output
-1
Input
9 9
Output
81 | instruction | 0 | 86,332 | 5 | 172,664 |
"Correct Solution:
```
x,y=map(int,input().split())
if x>9 or y>9:
print(-1)
else:
print(x*y)
``` | output | 1 | 86,332 | 5 | 172,665 |
Provide a correct Python 3 solution for this coding contest problem.
Having learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together. He cannot do any other calculation.
Given are two integers A and B.
If Takahashi can calculate A \times B, print the result; if he cannot, print `-1` instead.
Constraints
* 1 \leq A \leq 20
* 1 \leq B \leq 20
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
A B
Output
If Takahashi can calculate A \times B, print the result; if he cannot, print `-1`.
Examples
Input
2 5
Output
10
Input
5 10
Output
-1
Input
9 9
Output
81 | instruction | 0 | 86,333 | 5 | 172,666 |
"Correct Solution:
```
A,B=map(int,input().split())
ans = A*B if A <= 9 and B <= 9 else -1
print(ans)
``` | output | 1 | 86,333 | 5 | 172,667 |
Provide a correct Python 3 solution for this coding contest problem.
Having learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together. He cannot do any other calculation.
Given are two integers A and B.
If Takahashi can calculate A \times B, print the result; if he cannot, print `-1` instead.
Constraints
* 1 \leq A \leq 20
* 1 \leq B \leq 20
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
A B
Output
If Takahashi can calculate A \times B, print the result; if he cannot, print `-1`.
Examples
Input
2 5
Output
10
Input
5 10
Output
-1
Input
9 9
Output
81 | instruction | 0 | 86,334 | 5 | 172,668 |
"Correct Solution:
```
a,b=map(int,input().split())
if max(a,b)>=10:
print(-1)
else:
print(a*b)
``` | output | 1 | 86,334 | 5 | 172,669 |
Provide a correct Python 3 solution for this coding contest problem.
Having learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together. He cannot do any other calculation.
Given are two integers A and B.
If Takahashi can calculate A \times B, print the result; if he cannot, print `-1` instead.
Constraints
* 1 \leq A \leq 20
* 1 \leq B \leq 20
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
A B
Output
If Takahashi can calculate A \times B, print the result; if he cannot, print `-1`.
Examples
Input
2 5
Output
10
Input
5 10
Output
-1
Input
9 9
Output
81 | instruction | 0 | 86,335 | 5 | 172,670 |
"Correct Solution:
```
a,b=map(int,input().split())
print(-1 if a >= 10 or b >= 10 else a*b)
``` | output | 1 | 86,335 | 5 | 172,671 |
Provide a correct Python 3 solution for this coding contest problem.
Having learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together. He cannot do any other calculation.
Given are two integers A and B.
If Takahashi can calculate A \times B, print the result; if he cannot, print `-1` instead.
Constraints
* 1 \leq A \leq 20
* 1 \leq B \leq 20
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
A B
Output
If Takahashi can calculate A \times B, print the result; if he cannot, print `-1`.
Examples
Input
2 5
Output
10
Input
5 10
Output
-1
Input
9 9
Output
81 | instruction | 0 | 86,336 | 5 | 172,672 |
"Correct Solution:
```
#144_A
a, b = map(int, input().split())
print(a*b if a<10 and b<10 else -1)
``` | output | 1 | 86,336 | 5 | 172,673 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Having learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together. He cannot do any other calculation.
Given are two integers A and B.
If Takahashi can calculate A \times B, print the result; if he cannot, print `-1` instead.
Constraints
* 1 \leq A \leq 20
* 1 \leq B \leq 20
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
A B
Output
If Takahashi can calculate A \times B, print the result; if he cannot, print `-1`.
Examples
Input
2 5
Output
10
Input
5 10
Output
-1
Input
9 9
Output
81
Submitted Solution:
```
a,b=map(int,input().split())
if 10<=a or 10<=b:
print(-1)
else:
print(a*b)
``` | instruction | 0 | 86,337 | 5 | 172,674 |
Yes | output | 1 | 86,337 | 5 | 172,675 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Having learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together. He cannot do any other calculation.
Given are two integers A and B.
If Takahashi can calculate A \times B, print the result; if he cannot, print `-1` instead.
Constraints
* 1 \leq A \leq 20
* 1 \leq B \leq 20
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
A B
Output
If Takahashi can calculate A \times B, print the result; if he cannot, print `-1`.
Examples
Input
2 5
Output
10
Input
5 10
Output
-1
Input
9 9
Output
81
Submitted Solution:
```
a,b=map(int, input().split())
if (a<=9 and b<=9):
print(a*b)
else:
print("-1")
``` | instruction | 0 | 86,338 | 5 | 172,676 |
Yes | output | 1 | 86,338 | 5 | 172,677 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Having learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together. He cannot do any other calculation.
Given are two integers A and B.
If Takahashi can calculate A \times B, print the result; if he cannot, print `-1` instead.
Constraints
* 1 \leq A \leq 20
* 1 \leq B \leq 20
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
A B
Output
If Takahashi can calculate A \times B, print the result; if he cannot, print `-1`.
Examples
Input
2 5
Output
10
Input
5 10
Output
-1
Input
9 9
Output
81
Submitted Solution:
```
a,b = map(int, input().split())
print(a*b if (a<=9)&(b<=9) else -1)
``` | instruction | 0 | 86,339 | 5 | 172,678 |
Yes | output | 1 | 86,339 | 5 | 172,679 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Having learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together. He cannot do any other calculation.
Given are two integers A and B.
If Takahashi can calculate A \times B, print the result; if he cannot, print `-1` instead.
Constraints
* 1 \leq A \leq 20
* 1 \leq B \leq 20
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
A B
Output
If Takahashi can calculate A \times B, print the result; if he cannot, print `-1`.
Examples
Input
2 5
Output
10
Input
5 10
Output
-1
Input
9 9
Output
81
Submitted Solution:
```
A,B=map(int,input().split())
print(-1) if A>=10 or B>=10 else print(A*B)
``` | instruction | 0 | 86,340 | 5 | 172,680 |
Yes | output | 1 | 86,340 | 5 | 172,681 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Having learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together. He cannot do any other calculation.
Given are two integers A and B.
If Takahashi can calculate A \times B, print the result; if he cannot, print `-1` instead.
Constraints
* 1 \leq A \leq 20
* 1 \leq B \leq 20
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
A B
Output
If Takahashi can calculate A \times B, print the result; if he cannot, print `-1`.
Examples
Input
2 5
Output
10
Input
5 10
Output
-1
Input
9 9
Output
81
Submitted Solution:
```
n,m=map(int,input().split())
if n<10 && m<10 :
print(n*m)
else :
print(-1)
``` | instruction | 0 | 86,341 | 5 | 172,682 |
No | output | 1 | 86,341 | 5 | 172,683 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.