message
stringlengths
2
59.7k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
37
108k
cluster
float64
20
20
__index_level_0__
int64
74
217k
Provide tags and a correct Python 3 solution for this coding contest problem. Little X used to play a card game called "24 Game", but recently he has found it too easy. So he invented a new game. Initially you have a sequence of n integers: 1, 2, ..., n. In a single step, you can pick two of them, let's denote them a and b, erase them from the sequence, and append to the sequence either a + b, or a - b, or a × b. After n - 1 steps there is only one number left. Can you make this number equal to 24? Input The first line contains a single integer n (1 ≤ n ≤ 105). Output If it's possible, print "YES" in the first line. Otherwise, print "NO" (without the quotes). If there is a way to obtain 24 as the result number, in the following n - 1 lines print the required operations an operation per line. Each operation should be in form: "a op b = c". Where a and b are the numbers you've picked at this operation; op is either "+", or "-", or "*"; c is the result of corresponding operation. Note, that the absolute value of c mustn't be greater than 1018. The result of the last operation must be equal to 24. Separate operator sign and equality sign from numbers with spaces. If there are multiple valid answers, you may print any of them. Examples Input 1 Output NO Input 8 Output YES 8 * 7 = 56 6 * 5 = 30 3 - 4 = -1 1 - 2 = -1 30 - -1 = 31 56 - 31 = 25 25 + -1 = 24
instruction
0
102,442
20
204,884
Tags: constructive algorithms, greedy, math Correct Solution: ``` #------------------------template--------------------------# import os import sys # from math import * from collections import * # from fractions import * # from heapq import* from bisect import * from io import BytesIO, IOBase def vsInput(): sys.stdin = open('input.txt', 'r') sys.stdout = open('output.txt', 'w') BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.write if self.writable else None def read(self): while True: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) if not b: break ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines = 0 return self.buffer.read() def readline(self): while self.newlines == 0: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) self.newlines = b.count(b"\n") + (not b) ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines -= 1 return self.buffer.readline() def flush(self): if self.writable: os.write(self._fd, self.buffer.getvalue()) self.buffer.truncate(0), self.buffer.seek(0) class IOWrapper(IOBase): def __init__(self, file): self.buffer = FastIO(file) self.flush = self.buffer.flush self.writable = self.buffer.writable self.write = lambda s: self.buffer.write(s.encode("ascii")) self.read = lambda: self.buffer.read().decode("ascii") self.readline = lambda: self.buffer.readline().decode("ascii") sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout) input = lambda: sys.stdin.readline().rstrip("\r\n") ALPHA='abcdefghijklmnopqrstuvwxyz' M=10**9+7 EPS=1e-6 def Ceil(a,b): return a//b+int(a%b>0) def value():return tuple(map(int,input().split())) def array():return [int(i) for i in input().split()] def Int():return int(input()) def Str():return input() def arrayS():return [i for i in input().split()] #-------------------------code---------------------------# # vsInput() n=Int() if(n<4): print("NO") exit() print("YES") if(n==4): print("3 * 4 = 12") print("12 * 2 = 24") print("24 * 1 = 24") elif(n==5): print("5 * 4 = 20") print("2 - 1 = 1") print("3 + 1 = 4") print("20 + 4 = 24") else: print("3 - 2 = 1") print("1 - 1 = 0") for i in range(7,n+1): print("{} * 0 = 0".format(i)) print("5 * 0 = 0") print("4 * 6 = 24") print("24 + 0 = 24") ```
output
1
102,442
20
204,885
Provide tags and a correct Python 3 solution for this coding contest problem. Little X used to play a card game called "24 Game", but recently he has found it too easy. So he invented a new game. Initially you have a sequence of n integers: 1, 2, ..., n. In a single step, you can pick two of them, let's denote them a and b, erase them from the sequence, and append to the sequence either a + b, or a - b, or a × b. After n - 1 steps there is only one number left. Can you make this number equal to 24? Input The first line contains a single integer n (1 ≤ n ≤ 105). Output If it's possible, print "YES" in the first line. Otherwise, print "NO" (without the quotes). If there is a way to obtain 24 as the result number, in the following n - 1 lines print the required operations an operation per line. Each operation should be in form: "a op b = c". Where a and b are the numbers you've picked at this operation; op is either "+", or "-", or "*"; c is the result of corresponding operation. Note, that the absolute value of c mustn't be greater than 1018. The result of the last operation must be equal to 24. Separate operator sign and equality sign from numbers with spaces. If there are multiple valid answers, you may print any of them. Examples Input 1 Output NO Input 8 Output YES 8 * 7 = 56 6 * 5 = 30 3 - 4 = -1 1 - 2 = -1 30 - -1 = 31 56 - 31 = 25 25 + -1 = 24
instruction
0
102,443
20
204,886
Tags: constructive algorithms, greedy, math Correct Solution: ``` def logs(n): if n == 4: return [(1,1,2), (1,2,3), (1,6,4)] if n == 5: return [(2,5,4), (2,9,3), (1,12,2), (1,24,1)] ans = [(3,i+1,i) for i in range(n-1, 4, -2)] ans.extend(logs(4 + n%2)) ans += [(1,24,1) for i in range(n-1-len(ans))] return ans n = int(input()) if n < 4: print('NO') else: print('YES') for note in logs(n): if note[0] == 1: print('{0} * {1} = {2}'.format(note[1], note[2], note[1]*note[2])) elif note[0] == 2: print('{0} + {1} = {2}'.format(note[1], note[2], note[1]+note[2])) else: print('{0} - {1} = {2}'.format(note[1], note[2], note[1]-note[2])) ```
output
1
102,443
20
204,887
Provide tags and a correct Python 3 solution for this coding contest problem. Little X used to play a card game called "24 Game", but recently he has found it too easy. So he invented a new game. Initially you have a sequence of n integers: 1, 2, ..., n. In a single step, you can pick two of them, let's denote them a and b, erase them from the sequence, and append to the sequence either a + b, or a - b, or a × b. After n - 1 steps there is only one number left. Can you make this number equal to 24? Input The first line contains a single integer n (1 ≤ n ≤ 105). Output If it's possible, print "YES" in the first line. Otherwise, print "NO" (without the quotes). If there is a way to obtain 24 as the result number, in the following n - 1 lines print the required operations an operation per line. Each operation should be in form: "a op b = c". Where a and b are the numbers you've picked at this operation; op is either "+", or "-", or "*"; c is the result of corresponding operation. Note, that the absolute value of c mustn't be greater than 1018. The result of the last operation must be equal to 24. Separate operator sign and equality sign from numbers with spaces. If there are multiple valid answers, you may print any of them. Examples Input 1 Output NO Input 8 Output YES 8 * 7 = 56 6 * 5 = 30 3 - 4 = -1 1 - 2 = -1 30 - -1 = 31 56 - 31 = 25 25 + -1 = 24
instruction
0
102,444
20
204,888
Tags: constructive algorithms, greedy, math Correct Solution: ``` a = int(input()) if a<=3: print("NO") elif a%2==0: print("YES") print('4 * 3 = 12') print('12 * 2 = 24') print('24 * 1 = 24') for i in range(6, a+1, 2): print(str(i), '-', str(i-1), '= 1') print('24 * 1 = 24') elif a%2==1: print("YES") print('4 - 2 = 2') print('2 + 1 = 3') print('3 + 5 = 8') print('3 * 8 = 24') for i in range(7, a+1, 2): print(str(i), '-', str(i-1), '= 1') print('24 * 1 = 24') ```
output
1
102,444
20
204,889
Provide tags and a correct Python 3 solution for this coding contest problem. Little X used to play a card game called "24 Game", but recently he has found it too easy. So he invented a new game. Initially you have a sequence of n integers: 1, 2, ..., n. In a single step, you can pick two of them, let's denote them a and b, erase them from the sequence, and append to the sequence either a + b, or a - b, or a × b. After n - 1 steps there is only one number left. Can you make this number equal to 24? Input The first line contains a single integer n (1 ≤ n ≤ 105). Output If it's possible, print "YES" in the first line. Otherwise, print "NO" (without the quotes). If there is a way to obtain 24 as the result number, in the following n - 1 lines print the required operations an operation per line. Each operation should be in form: "a op b = c". Where a and b are the numbers you've picked at this operation; op is either "+", or "-", or "*"; c is the result of corresponding operation. Note, that the absolute value of c mustn't be greater than 1018. The result of the last operation must be equal to 24. Separate operator sign and equality sign from numbers with spaces. If there are multiple valid answers, you may print any of them. Examples Input 1 Output NO Input 8 Output YES 8 * 7 = 56 6 * 5 = 30 3 - 4 = -1 1 - 2 = -1 30 - -1 = 31 56 - 31 = 25 25 + -1 = 24
instruction
0
102,445
20
204,890
Tags: constructive algorithms, greedy, math Correct Solution: ``` n = int(input()) if n < 4: print('NO') elif n == 4: print('YES') print('1 * 2 = 2') print('2 * 3 = 6') print('6 * 4 = 24') elif n == 5: print('YES') print('4 * 5 = 20') print('3 - 1 = 2') print('20 + 2 = 22') print('22 + 2 = 24') else: print('YES') print('2 * 3 = 6') print('6 * 4 = 24') print('6 - 1 = 5') print('5 - 5 = 0') for i in range(7, n + 1): print('0 * {} = 0'.format(i)) print('24 + 0 = 24') # 24 ```
output
1
102,445
20
204,891
Provide tags and a correct Python 3 solution for this coding contest problem. Little X used to play a card game called "24 Game", but recently he has found it too easy. So he invented a new game. Initially you have a sequence of n integers: 1, 2, ..., n. In a single step, you can pick two of them, let's denote them a and b, erase them from the sequence, and append to the sequence either a + b, or a - b, or a × b. After n - 1 steps there is only one number left. Can you make this number equal to 24? Input The first line contains a single integer n (1 ≤ n ≤ 105). Output If it's possible, print "YES" in the first line. Otherwise, print "NO" (without the quotes). If there is a way to obtain 24 as the result number, in the following n - 1 lines print the required operations an operation per line. Each operation should be in form: "a op b = c". Where a and b are the numbers you've picked at this operation; op is either "+", or "-", or "*"; c is the result of corresponding operation. Note, that the absolute value of c mustn't be greater than 1018. The result of the last operation must be equal to 24. Separate operator sign and equality sign from numbers with spaces. If there are multiple valid answers, you may print any of them. Examples Input 1 Output NO Input 8 Output YES 8 * 7 = 56 6 * 5 = 30 3 - 4 = -1 1 - 2 = -1 30 - -1 = 31 56 - 31 = 25 25 + -1 = 24
instruction
0
102,446
20
204,892
Tags: constructive algorithms, greedy, math Correct Solution: ``` n = int(input()) if n >= 4: print("YES") moves = 0 for i in range(5 + (0 if n % 2 == 0 else 1), n, 2): print(str(i+1) + ' - ' + str(i) + ' = ' + str(1)) moves += 1 if n % 2 == 0: print('2 * 3 = 6') print('6 * 4 = 24') moves += 2 else: print('2 + 1 = 3') print('5 - 3 = 2') print('3 * 2 = 6') print('6 * 4 = 24') moves += 4 while moves < n-1: moves += 1 print('1 * 24 = 24') else: print('NO') ```
output
1
102,446
20
204,893
Provide tags and a correct Python 3 solution for this coding contest problem. Little X used to play a card game called "24 Game", but recently he has found it too easy. So he invented a new game. Initially you have a sequence of n integers: 1, 2, ..., n. In a single step, you can pick two of them, let's denote them a and b, erase them from the sequence, and append to the sequence either a + b, or a - b, or a × b. After n - 1 steps there is only one number left. Can you make this number equal to 24? Input The first line contains a single integer n (1 ≤ n ≤ 105). Output If it's possible, print "YES" in the first line. Otherwise, print "NO" (without the quotes). If there is a way to obtain 24 as the result number, in the following n - 1 lines print the required operations an operation per line. Each operation should be in form: "a op b = c". Where a and b are the numbers you've picked at this operation; op is either "+", or "-", or "*"; c is the result of corresponding operation. Note, that the absolute value of c mustn't be greater than 1018. The result of the last operation must be equal to 24. Separate operator sign and equality sign from numbers with spaces. If there are multiple valid answers, you may print any of them. Examples Input 1 Output NO Input 8 Output YES 8 * 7 = 56 6 * 5 = 30 3 - 4 = -1 1 - 2 = -1 30 - -1 = 31 56 - 31 = 25 25 + -1 = 24
instruction
0
102,447
20
204,894
Tags: constructive algorithms, greedy, math Correct Solution: ``` n = int(input()) if n<=3: print("NO") else: print("YES") if n%2==0: for i in range(5,n,2): print(i+1,'-' ,i,'=',1) print(1,'*',2,'=',2) print(2,'*',3,'=',6) print(6,'*',4,'=',24) for i in range((n-4)//2): print(24,'*',1,'=',24) else: print(5,'+',1,'=',6) print(3,'-',2,'=',1) print(4,'*',6,'=',24) print(1,'*',24,'=',24) for i in range(6,n,2): print(i+1,'-',i,'=',1) for i in range((n-5)//2): print(24,'*',1,'=',24) ```
output
1
102,447
20
204,895
Provide tags and a correct Python 3 solution for this coding contest problem. Little X used to play a card game called "24 Game", but recently he has found it too easy. So he invented a new game. Initially you have a sequence of n integers: 1, 2, ..., n. In a single step, you can pick two of them, let's denote them a and b, erase them from the sequence, and append to the sequence either a + b, or a - b, or a × b. After n - 1 steps there is only one number left. Can you make this number equal to 24? Input The first line contains a single integer n (1 ≤ n ≤ 105). Output If it's possible, print "YES" in the first line. Otherwise, print "NO" (without the quotes). If there is a way to obtain 24 as the result number, in the following n - 1 lines print the required operations an operation per line. Each operation should be in form: "a op b = c". Where a and b are the numbers you've picked at this operation; op is either "+", or "-", or "*"; c is the result of corresponding operation. Note, that the absolute value of c mustn't be greater than 1018. The result of the last operation must be equal to 24. Separate operator sign and equality sign from numbers with spaces. If there are multiple valid answers, you may print any of them. Examples Input 1 Output NO Input 8 Output YES 8 * 7 = 56 6 * 5 = 30 3 - 4 = -1 1 - 2 = -1 30 - -1 = 31 56 - 31 = 25 25 + -1 = 24
instruction
0
102,448
20
204,896
Tags: constructive algorithms, greedy, math Correct Solution: ``` n=int(input()) if (n==1 or n==2 or n==3): print ("NO") exit(0) else: print ("YES") if (n%2==0): print ("1 * 2 = 2") print ("2 * 3 = 6") print ("6 * 4 = 24") for i in range(5,n+1,2): print (i+1,"-",i,"= 1") for i in range((n-4)//2): print ("24 * 1 = 24") else: print ("5 - 2 = 3") print ("3 - 1 = 2") print ("2 * 3 = 6") print ("6 * 4 = 24") for i in range(6,n+1,2): print (i+1,"-",i,"= 1") for i in range((n-5)//2): print ("24 * 1 = 24") ```
output
1
102,448
20
204,897
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little X used to play a card game called "24 Game", but recently he has found it too easy. So he invented a new game. Initially you have a sequence of n integers: 1, 2, ..., n. In a single step, you can pick two of them, let's denote them a and b, erase them from the sequence, and append to the sequence either a + b, or a - b, or a × b. After n - 1 steps there is only one number left. Can you make this number equal to 24? Input The first line contains a single integer n (1 ≤ n ≤ 105). Output If it's possible, print "YES" in the first line. Otherwise, print "NO" (without the quotes). If there is a way to obtain 24 as the result number, in the following n - 1 lines print the required operations an operation per line. Each operation should be in form: "a op b = c". Where a and b are the numbers you've picked at this operation; op is either "+", or "-", or "*"; c is the result of corresponding operation. Note, that the absolute value of c mustn't be greater than 1018. The result of the last operation must be equal to 24. Separate operator sign and equality sign from numbers with spaces. If there are multiple valid answers, you may print any of them. Examples Input 1 Output NO Input 8 Output YES 8 * 7 = 56 6 * 5 = 30 3 - 4 = -1 1 - 2 = -1 30 - -1 = 31 56 - 31 = 25 25 + -1 = 24 Submitted Solution: ``` n=int(input()) if n<4: print("NO") elif n&1: print("YES\n5 - 3 = 2\n2 + 1 = 3\n2 * 3 = 6\n4 * 6 = 24") for i in range(6,n,2): print(i+1, "-", i, "=", 1) print("24 * 1 = 24") else: print("YES\n1 * 2 = 2\n2 * 3 = 6\n6 * 4 = 24") for i in range(5,n,2): print(i+1, "-", i, "=", 1) print("24 * 1 = 24") ```
instruction
0
102,449
20
204,898
Yes
output
1
102,449
20
204,899
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little X used to play a card game called "24 Game", but recently he has found it too easy. So he invented a new game. Initially you have a sequence of n integers: 1, 2, ..., n. In a single step, you can pick two of them, let's denote them a and b, erase them from the sequence, and append to the sequence either a + b, or a - b, or a × b. After n - 1 steps there is only one number left. Can you make this number equal to 24? Input The first line contains a single integer n (1 ≤ n ≤ 105). Output If it's possible, print "YES" in the first line. Otherwise, print "NO" (without the quotes). If there is a way to obtain 24 as the result number, in the following n - 1 lines print the required operations an operation per line. Each operation should be in form: "a op b = c". Where a and b are the numbers you've picked at this operation; op is either "+", or "-", or "*"; c is the result of corresponding operation. Note, that the absolute value of c mustn't be greater than 1018. The result of the last operation must be equal to 24. Separate operator sign and equality sign from numbers with spaces. If there are multiple valid answers, you may print any of them. Examples Input 1 Output NO Input 8 Output YES 8 * 7 = 56 6 * 5 = 30 3 - 4 = -1 1 - 2 = -1 30 - -1 = 31 56 - 31 = 25 25 + -1 = 24 Submitted Solution: ``` from collections import * import os, sys from io import BytesIO, IOBase class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.write if self.writable else None def read(self): while True: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) if not b: break ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines = 0 return self.buffer.read() def readline(self): while self.newlines == 0: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) self.newlines = b.count(b"\n") + (not b) ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines -= 1 return self.buffer.readline() def flush(self): if self.writable: os.write(self._fd, self.buffer.getvalue()) self.buffer.truncate(0), self.buffer.seek(0) class IOWrapper(IOBase): def __init__(self, file): self.buffer = FastIO(file) self.flush = self.buffer.flush self.writable = self.buffer.writable self.write = lambda s: self.buffer.write(s.encode("ascii")) self.read = lambda: self.buffer.read().decode("ascii") self.readline = lambda: self.buffer.readline().decode("ascii") BUFSIZE = 8192 sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout) input = lambda: sys.stdin.readline().rstrip("\r\n") rstr = lambda: input().strip() rstrs = lambda: [str(x) for x in input().split()] rstr_2d = lambda n: [rstr() for _ in range(n)] rint = lambda: int(input()) rints = lambda: [int(x) for x in input().split()] rint_2d = lambda n: [rint() for _ in range(n)] rints_2d = lambda n: [rints() for _ in range(n)] ceil1 = lambda a, b: (a + b - 1) // b n = rint() if n < 4: exit(print('NO')) print('YES') if n == 5: print('1 + 5 = 6\n3 - 2 = 1\n 1 * 4 = 4\n4 * 6 = 24') elif n & 1: print('4 - 2 = 2') tem, cur = (1, 2, 3, 5, 6, 7), 1 for i in range(1, len(tem)): print(f'{cur} + {tem[i]} = {cur + tem[i]}') cur += tem[i] for i in range(8, n, 2): print(f'{i + 1} - {i} = 1\n24 * 1 = 24') else: cur = 1 for i in range(1, 4): print(f'{cur} * {i + 1} = {cur * (i + 1)}') cur *= i + 1 for i in range(5, n, 2): print(f'{i + 1} - {i} = 1\n24 * 1 = 24') ```
instruction
0
102,450
20
204,900
Yes
output
1
102,450
20
204,901
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little X used to play a card game called "24 Game", but recently he has found it too easy. So he invented a new game. Initially you have a sequence of n integers: 1, 2, ..., n. In a single step, you can pick two of them, let's denote them a and b, erase them from the sequence, and append to the sequence either a + b, or a - b, or a × b. After n - 1 steps there is only one number left. Can you make this number equal to 24? Input The first line contains a single integer n (1 ≤ n ≤ 105). Output If it's possible, print "YES" in the first line. Otherwise, print "NO" (without the quotes). If there is a way to obtain 24 as the result number, in the following n - 1 lines print the required operations an operation per line. Each operation should be in form: "a op b = c". Where a and b are the numbers you've picked at this operation; op is either "+", or "-", or "*"; c is the result of corresponding operation. Note, that the absolute value of c mustn't be greater than 1018. The result of the last operation must be equal to 24. Separate operator sign and equality sign from numbers with spaces. If there are multiple valid answers, you may print any of them. Examples Input 1 Output NO Input 8 Output YES 8 * 7 = 56 6 * 5 = 30 3 - 4 = -1 1 - 2 = -1 30 - -1 = 31 56 - 31 = 25 25 + -1 = 24 Submitted Solution: ``` n = int(input()) if n <= 3: print('NO') else: print('YES') if n % 2 == 0: print('2 * 1 = 2') print('2 * 3 = 6') print('6 * 4 = 24') for i in range(6, n+1, 2): print('{} - {} = 1'.format(i, i-1)) print('24 * 1 = 24') else: print('2 - 1 = 1') print('3 + 1 = 4') print('4 * 5 = 20') print('20 + 4 = 24') for i in range(7, n+1, 2): print('{} - {} = 1'.format(i, i-1)) print('24 * 1 = 24') ```
instruction
0
102,451
20
204,902
Yes
output
1
102,451
20
204,903
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little X used to play a card game called "24 Game", but recently he has found it too easy. So he invented a new game. Initially you have a sequence of n integers: 1, 2, ..., n. In a single step, you can pick two of them, let's denote them a and b, erase them from the sequence, and append to the sequence either a + b, or a - b, or a × b. After n - 1 steps there is only one number left. Can you make this number equal to 24? Input The first line contains a single integer n (1 ≤ n ≤ 105). Output If it's possible, print "YES" in the first line. Otherwise, print "NO" (without the quotes). If there is a way to obtain 24 as the result number, in the following n - 1 lines print the required operations an operation per line. Each operation should be in form: "a op b = c". Where a and b are the numbers you've picked at this operation; op is either "+", or "-", or "*"; c is the result of corresponding operation. Note, that the absolute value of c mustn't be greater than 1018. The result of the last operation must be equal to 24. Separate operator sign and equality sign from numbers with spaces. If there are multiple valid answers, you may print any of them. Examples Input 1 Output NO Input 8 Output YES 8 * 7 = 56 6 * 5 = 30 3 - 4 = -1 1 - 2 = -1 30 - -1 = 31 56 - 31 = 25 25 + -1 = 24 Submitted Solution: ``` n = int(input()) if n < 4: print('NO') elif n == 4: print('YES') print('3 * 4 = 12') print('2 * 1 = 2') print('12 * 2 = 24') elif n == 5: print('YES') print('5 - 3 = 2') print('2 + 1 = 3') print('3 * 4 = 12') print('12 * 2 = 24') else: print('YES') print(str(n) + ' - ' + str(n - 1) + ' = 1') print('1 - 1 = 0') for i in range(5, 5 + n - 6): print(str(i) + ' * 0 = 0' ) print('2 * 3 = 6') print('4 * 6 = 24') print('24 + 0 = 24') ```
instruction
0
102,452
20
204,904
Yes
output
1
102,452
20
204,905
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little X used to play a card game called "24 Game", but recently he has found it too easy. So he invented a new game. Initially you have a sequence of n integers: 1, 2, ..., n. In a single step, you can pick two of them, let's denote them a and b, erase them from the sequence, and append to the sequence either a + b, or a - b, or a × b. After n - 1 steps there is only one number left. Can you make this number equal to 24? Input The first line contains a single integer n (1 ≤ n ≤ 105). Output If it's possible, print "YES" in the first line. Otherwise, print "NO" (without the quotes). If there is a way to obtain 24 as the result number, in the following n - 1 lines print the required operations an operation per line. Each operation should be in form: "a op b = c". Where a and b are the numbers you've picked at this operation; op is either "+", or "-", or "*"; c is the result of corresponding operation. Note, that the absolute value of c mustn't be greater than 1018. The result of the last operation must be equal to 24. Separate operator sign and equality sign from numbers with spaces. If there are multiple valid answers, you may print any of them. Examples Input 1 Output NO Input 8 Output YES 8 * 7 = 56 6 * 5 = 30 3 - 4 = -1 1 - 2 = -1 30 - -1 = 31 56 - 31 = 25 25 + -1 = 24 Submitted Solution: ``` a = int(input()) if a<=3: print("NO") elif a%2==0: print('4 * 3 = 12') print('12 * 2 = 24') print('24 * 1 = 24') for i in range(6, a+1, 2): print(str(i), '-', str(i-1), '= 1') print('24 * 1 = 24') elif a%2==1: print('4 - 2 = 2') print('2 + 1 = 3') print('3 + 5 = 8') print('3 * 8 = 24') for i in range(7, a+1, 2): print(str(i), '-', str(i-1), '= 1') print('24 * 1 = 24') ```
instruction
0
102,453
20
204,906
No
output
1
102,453
20
204,907
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little X used to play a card game called "24 Game", but recently he has found it too easy. So he invented a new game. Initially you have a sequence of n integers: 1, 2, ..., n. In a single step, you can pick two of them, let's denote them a and b, erase them from the sequence, and append to the sequence either a + b, or a - b, or a × b. After n - 1 steps there is only one number left. Can you make this number equal to 24? Input The first line contains a single integer n (1 ≤ n ≤ 105). Output If it's possible, print "YES" in the first line. Otherwise, print "NO" (without the quotes). If there is a way to obtain 24 as the result number, in the following n - 1 lines print the required operations an operation per line. Each operation should be in form: "a op b = c". Where a and b are the numbers you've picked at this operation; op is either "+", or "-", or "*"; c is the result of corresponding operation. Note, that the absolute value of c mustn't be greater than 1018. The result of the last operation must be equal to 24. Separate operator sign and equality sign from numbers with spaces. If there are multiple valid answers, you may print any of them. Examples Input 1 Output NO Input 8 Output YES 8 * 7 = 56 6 * 5 = 30 3 - 4 = -1 1 - 2 = -1 30 - -1 = 31 56 - 31 = 25 25 + -1 = 24 Submitted Solution: ``` n = int(input()) if n < 4: print("NO") else: print("YES") while n > 5: a = str(n+1) b = str(n) print(a + " - " + b + " = 1 ") print("1 * 1 = 1") n -= 2 if n == 4: print("4 * 3 = 12\n12 * 2 = 24\n24 * 1 = 24") else: print("5 - 2 = 3\n3 - 1 = 2\n2 * 3 = 6\n6 * 4 = 24") ```
instruction
0
102,454
20
204,908
No
output
1
102,454
20
204,909
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little X used to play a card game called "24 Game", but recently he has found it too easy. So he invented a new game. Initially you have a sequence of n integers: 1, 2, ..., n. In a single step, you can pick two of them, let's denote them a and b, erase them from the sequence, and append to the sequence either a + b, or a - b, or a × b. After n - 1 steps there is only one number left. Can you make this number equal to 24? Input The first line contains a single integer n (1 ≤ n ≤ 105). Output If it's possible, print "YES" in the first line. Otherwise, print "NO" (without the quotes). If there is a way to obtain 24 as the result number, in the following n - 1 lines print the required operations an operation per line. Each operation should be in form: "a op b = c". Where a and b are the numbers you've picked at this operation; op is either "+", or "-", or "*"; c is the result of corresponding operation. Note, that the absolute value of c mustn't be greater than 1018. The result of the last operation must be equal to 24. Separate operator sign and equality sign from numbers with spaces. If there are multiple valid answers, you may print any of them. Examples Input 1 Output NO Input 8 Output YES 8 * 7 = 56 6 * 5 = 30 3 - 4 = -1 1 - 2 = -1 30 - -1 = 31 56 - 31 = 25 25 + -1 = 24 Submitted Solution: ``` n = int(input()) if n < 4: print('NO') elif n == 5: print('YES') print('5 * 4 = 20') print('20 + 3 = 23') print('23 + 2 = 25') print('25 - 1 = 24') elif n == 4: print('YES') print('1 * 2 = 2') print('2 * 3 = 6') print('6 + 4 = 24') else: if ((n - 4) % 2) == 0: print('YES') for i in range(n, 4, -2): print('%s - %s = %s' %(i, i-1, 1)) print('1 * 2 = 2') print('2 * 3 = 6') print('6 + 4 = 24') for i in range(n, 4, -2): print('1 * 24 = 24') else: print('YES') print('%s - 1 = %s' % (n, n-1)) print('%s - %s = 0' % (n-1, n-1)) for i in range(n - 2, 4, -1): print('%s * 0 = 0' %(i)) print('2 * 3 = 6') print('6 + 4 = 24') print('24 + 0 = 24') ```
instruction
0
102,455
20
204,910
No
output
1
102,455
20
204,911
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little X used to play a card game called "24 Game", but recently he has found it too easy. So he invented a new game. Initially you have a sequence of n integers: 1, 2, ..., n. In a single step, you can pick two of them, let's denote them a and b, erase them from the sequence, and append to the sequence either a + b, or a - b, or a × b. After n - 1 steps there is only one number left. Can you make this number equal to 24? Input The first line contains a single integer n (1 ≤ n ≤ 105). Output If it's possible, print "YES" in the first line. Otherwise, print "NO" (without the quotes). If there is a way to obtain 24 as the result number, in the following n - 1 lines print the required operations an operation per line. Each operation should be in form: "a op b = c". Where a and b are the numbers you've picked at this operation; op is either "+", or "-", or "*"; c is the result of corresponding operation. Note, that the absolute value of c mustn't be greater than 1018. The result of the last operation must be equal to 24. Separate operator sign and equality sign from numbers with spaces. If there are multiple valid answers, you may print any of them. Examples Input 1 Output NO Input 8 Output YES 8 * 7 = 56 6 * 5 = 30 3 - 4 = -1 1 - 2 = -1 30 - -1 = 31 56 - 31 = 25 25 + -1 = 24 Submitted Solution: ``` from collections import * import os, sys from io import BytesIO, IOBase class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.write if self.writable else None def read(self): while True: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) if not b: break ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines = 0 return self.buffer.read() def readline(self): while self.newlines == 0: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) self.newlines = b.count(b"\n") + (not b) ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines -= 1 return self.buffer.readline() def flush(self): if self.writable: os.write(self._fd, self.buffer.getvalue()) self.buffer.truncate(0), self.buffer.seek(0) class IOWrapper(IOBase): def __init__(self, file): self.buffer = FastIO(file) self.flush = self.buffer.flush self.writable = self.buffer.writable self.write = lambda s: self.buffer.write(s.encode("ascii")) self.read = lambda: self.buffer.read().decode("ascii") self.readline = lambda: self.buffer.readline().decode("ascii") BUFSIZE = 8192 sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout) input = lambda: sys.stdin.readline().rstrip("\r\n") rstr = lambda: input().strip() rstrs = lambda: [str(x) for x in input().split()] rstr_2d = lambda n: [rstr() for _ in range(n)] rint = lambda: int(input()) rints = lambda: [int(x) for x in input().split()] rint_2d = lambda n: [rint() for _ in range(n)] rints_2d = lambda n: [rints() for _ in range(n)] ceil1 = lambda a, b: (a + b - 1) // b n = rint() if n < 4: print('NO') elif n == 5: print('1 + 5 = 6\n3 - 2 = 1\n 1 * 4 = 4\n4 * 6 = 24') elif n & 1: print('4 - 2 = 2') tem, cur = (1, 2, 3, 5, 6, 7), 1 for i in range(1, len(tem)): print(f'{cur} + {tem[i]} = {cur + tem[i]}') cur += tem[i] for i in range(8, n, 2): print(f'{i + 1} - {i} = 1\n24 * 1 = 24') else: cur = 1 for i in range(1, 4): print(f'{cur} * {i + 1} = {cur * (i + 1)}') cur *= i + 1 for i in range(5, n, 2): print(f'{i + 1} - {i} = 1\n24 * 1 = 24') ```
instruction
0
102,456
20
204,912
No
output
1
102,456
20
204,913
Provide tags and a correct Python 3 solution for this coding contest problem. Drazil is playing a math game with Varda. Let's define <image> for positive integer x as a product of factorials of its digits. For example, <image>. First, they choose a decimal number a consisting of n digits that contains at least one digit larger than 1. This number may possibly start with leading zeroes. Then they should find maximum positive number x satisfying following two conditions: 1. x doesn't contain neither digit 0 nor digit 1. 2. <image> = <image>. Help friends find such number. Input The first line contains an integer n (1 ≤ n ≤ 15) — the number of digits in a. The second line contains n digits of a. There is at least one digit in a that is larger than 1. Number a may possibly contain leading zeroes. Output Output a maximum possible integer satisfying the conditions above. There should be no zeroes and ones in this number decimal representation. Examples Input 4 1234 Output 33222 Input 3 555 Output 555 Note In the first case, <image>
instruction
0
102,464
20
204,928
Tags: greedy, math, sortings Correct Solution: ``` n = int(input()) a = input() arr = [] t=0 for i in a: if int(i)!=1 and int(i)!=0: arr.append(int(i)) t+=1 final = [] for i in range(t): if arr[i]==2: final.append(2) elif arr[i]==3: final.append(3) elif arr[i]==4: final.append(3) final.append(2) final.append(2) elif arr[i]==5: final.append(5) elif arr[i]==6: final.append(5) final.append(3) elif arr[i]==7: final.append(7) elif arr[i]==8: final.append(7) final.append(2) final.append(2) final.append(2) elif arr[i]==9: final.append(7) final.append(3) final.append(3) final.append(2) final.sort() final1 = '' for i in range(-1,-(len(final)+1),-1): final1+=str(final[i]) print(final1) ```
output
1
102,464
20
204,929
Provide tags and a correct Python 3 solution for this coding contest problem. Drazil is playing a math game with Varda. Let's define <image> for positive integer x as a product of factorials of its digits. For example, <image>. First, they choose a decimal number a consisting of n digits that contains at least one digit larger than 1. This number may possibly start with leading zeroes. Then they should find maximum positive number x satisfying following two conditions: 1. x doesn't contain neither digit 0 nor digit 1. 2. <image> = <image>. Help friends find such number. Input The first line contains an integer n (1 ≤ n ≤ 15) — the number of digits in a. The second line contains n digits of a. There is at least one digit in a that is larger than 1. Number a may possibly contain leading zeroes. Output Output a maximum possible integer satisfying the conditions above. There should be no zeroes and ones in this number decimal representation. Examples Input 4 1234 Output 33222 Input 3 555 Output 555 Note In the first case, <image>
instruction
0
102,465
20
204,930
Tags: greedy, math, sortings Correct Solution: ``` ## necessary imports import sys input = sys.stdin.readline from math import log2, log, ceil # swap_array function def swaparr(arr, a,b): temp = arr[a]; arr[a] = arr[b]; arr[b] = temp ## gcd function def gcd(a,b): if a == 0: return b return gcd(b%a, a) ## nCr function efficient using Binomial Cofficient def nCr(n, k): if(k > n - k): k = n - k res = 1 for i in range(k): res = res * (n - i) res = res / (i + 1) return res ## upper bound function code -- such that e in a[:i] e < x; def upper_bound(a, x, lo=0): hi = len(a) while lo < hi: mid = (lo+hi)//2 if a[mid] < x: lo = mid+1 else: hi = mid return lo ## prime factorization def primefs(n): ## if n == 1 ## calculating primes primes = {} while(n%2 == 0): primes[2] = primes.get(2, 0) + 1 n = n//2 for i in range(3, int(n**0.5)+2, 2): while(n%i == 0): primes[i] = primes.get(i, 0) + 1 n = n//i if n > 2: primes[n] = primes.get(n, 0) + 1 ## prime factoriazation of n is stored in dictionary ## primes and can be accesed. O(sqrt n) return primes ## MODULAR EXPONENTIATION FUNCTION def power(x, y, p): res = 1 x = x % p if (x == 0) : return 0 while (y > 0) : if ((y & 1) == 1) : res = (res * x) % p y = y >> 1 x = (x * x) % p return res ## DISJOINT SET UNINON FUNCTIONS def swap(a,b): temp = a a = b b = temp return a,b # find function def find(x, link): while(x != link[x]): x = link[x] return x # the union function which makes union(x,y) # of two nodes x and y def union(x, y, link, size): x = find(x, link) y = find(y, link) if size[x] < size[y]: x,y = swap(x,y) if x != y: size[x] += size[y] link[y] = x ## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES def sieve(n): prime = [True for i in range(n+1)] p = 2 while (p * p <= n): if (prime[p] == True): for i in range(p * p, n+1, p): prime[i] = False p += 1 return prime #### PRIME FACTORIZATION IN O(log n) using Sieve #### MAXN = int(1e6 + 5) def spf_sieve(): spf[1] = 1; for i in range(2, MAXN): spf[i] = i; for i in range(4, MAXN, 2): spf[i] = 2; for i in range(3, ceil(MAXN ** 0.5), 2): if spf[i] == i: for j in range(i*i, MAXN, i): if spf[j] == j: spf[j] = i; ## function for storing smallest prime factors (spf) in the array ################## un-comment below 2 lines when using factorization ################# # spf = [0 for i in range(MAXN)] # spf_sieve() def factoriazation(x): ret = {}; while x != 1: ret[spf[x]] = ret.get(spf[x], 0) + 1; x = x//spf[x] return ret ## this function is useful for multiple queries only, o/w use ## primefs function above. complexity O(log n) ## taking integer array input def int_array(): return list(map(int, input().strip().split())) ## taking string array input def str_array(): return input().strip().split(); #defining a couple constants MOD = int(1e9)+7; CMOD = 998244353; INF = float('inf'); NINF = -float('inf'); ################### ---------------- TEMPLATE ENDS HERE ---------------- ################### n = int(input()); string = input().strip(); ans = ''; k = 1; for i in string: if i not in '10': for j in range(int(i),1,-1): k *= j while(k % 5040 == 0 and k > 0): print('7',end=''); k //= 5040 while(k % 120 == 0 and k > 0): print('5',end=''); k //= 120 while(k % 6 == 0 and k > 0): print('3',end=''); k //= 6 while(k % 2 == 0 and k > 0): print('2',end=''); k //= 2 print(ans); ```
output
1
102,465
20
204,931
Provide tags and a correct Python 3 solution for this coding contest problem. Drazil is playing a math game with Varda. Let's define <image> for positive integer x as a product of factorials of its digits. For example, <image>. First, they choose a decimal number a consisting of n digits that contains at least one digit larger than 1. This number may possibly start with leading zeroes. Then they should find maximum positive number x satisfying following two conditions: 1. x doesn't contain neither digit 0 nor digit 1. 2. <image> = <image>. Help friends find such number. Input The first line contains an integer n (1 ≤ n ≤ 15) — the number of digits in a. The second line contains n digits of a. There is at least one digit in a that is larger than 1. Number a may possibly contain leading zeroes. Output Output a maximum possible integer satisfying the conditions above. There should be no zeroes and ones in this number decimal representation. Examples Input 4 1234 Output 33222 Input 3 555 Output 555 Note In the first case, <image>
instruction
0
102,466
20
204,932
Tags: greedy, math, sortings Correct Solution: ``` n = int(input()) a = input() A = [] for i in a: i = int(i) if i == 2: A.append(2) elif i == 3: A.append(3) elif i == 4: A.append(2) A.append(2) A.append(3) elif i == 5: A.append(5) elif i == 6: A.append(3) A.append(5) elif i == 7: A.append(7) elif i == 8: A.append(2) A.append(2) A.append(2) A.append(7) elif i == 9: A.append(3) A.append(3) A.append(2) A.append(7) A.sort(key=None, reverse=True) #print(A) s = '' for k in A: s = s+str(k) print(s) ```
output
1
102,466
20
204,933
Provide tags and a correct Python 3 solution for this coding contest problem. Drazil is playing a math game with Varda. Let's define <image> for positive integer x as a product of factorials of its digits. For example, <image>. First, they choose a decimal number a consisting of n digits that contains at least one digit larger than 1. This number may possibly start with leading zeroes. Then they should find maximum positive number x satisfying following two conditions: 1. x doesn't contain neither digit 0 nor digit 1. 2. <image> = <image>. Help friends find such number. Input The first line contains an integer n (1 ≤ n ≤ 15) — the number of digits in a. The second line contains n digits of a. There is at least one digit in a that is larger than 1. Number a may possibly contain leading zeroes. Output Output a maximum possible integer satisfying the conditions above. There should be no zeroes and ones in this number decimal representation. Examples Input 4 1234 Output 33222 Input 3 555 Output 555 Note In the first case, <image>
instruction
0
102,467
20
204,934
Tags: greedy, math, sortings Correct Solution: ``` '''input 3 555 ''' n = int(input()) s = input() d = {7:0, 5:0, 3:0, 2:0} for x in s: if x == '2': d[2] += 1 elif x == '3': d[3] += 1 elif x == '4': d[3] += 1 d[2] += 2 elif x == '5': d[5] += 1 elif x == '6': d[5] += 1 d[3] += 1 elif x == '7': d[7] += 1 elif x == '8': d[7] += 1 d[2] += 3 elif x == '9': d[7] += 1 d[3] += 2 d[2] += 1 for x in [7, 5, 3, 2]: print(str(x) * d[x], end = "") ```
output
1
102,467
20
204,935
Provide tags and a correct Python 3 solution for this coding contest problem. Drazil is playing a math game with Varda. Let's define <image> for positive integer x as a product of factorials of its digits. For example, <image>. First, they choose a decimal number a consisting of n digits that contains at least one digit larger than 1. This number may possibly start with leading zeroes. Then they should find maximum positive number x satisfying following two conditions: 1. x doesn't contain neither digit 0 nor digit 1. 2. <image> = <image>. Help friends find such number. Input The first line contains an integer n (1 ≤ n ≤ 15) — the number of digits in a. The second line contains n digits of a. There is at least one digit in a that is larger than 1. Number a may possibly contain leading zeroes. Output Output a maximum possible integer satisfying the conditions above. There should be no zeroes and ones in this number decimal representation. Examples Input 4 1234 Output 33222 Input 3 555 Output 555 Note In the first case, <image>
instruction
0
102,468
20
204,936
Tags: greedy, math, sortings Correct Solution: ``` n = int(input()) a = list(map(int, input())) m = ['', '', '2', '3', '322', '5', '53', '7', '7222', '7332'] print(''.join(sorted((''.join(m[t] for t in a)), reverse=True))) ```
output
1
102,468
20
204,937
Provide tags and a correct Python 3 solution for this coding contest problem. Drazil is playing a math game with Varda. Let's define <image> for positive integer x as a product of factorials of its digits. For example, <image>. First, they choose a decimal number a consisting of n digits that contains at least one digit larger than 1. This number may possibly start with leading zeroes. Then they should find maximum positive number x satisfying following two conditions: 1. x doesn't contain neither digit 0 nor digit 1. 2. <image> = <image>. Help friends find such number. Input The first line contains an integer n (1 ≤ n ≤ 15) — the number of digits in a. The second line contains n digits of a. There is at least one digit in a that is larger than 1. Number a may possibly contain leading zeroes. Output Output a maximum possible integer satisfying the conditions above. There should be no zeroes and ones in this number decimal representation. Examples Input 4 1234 Output 33222 Input 3 555 Output 555 Note In the first case, <image>
instruction
0
102,469
20
204,938
Tags: greedy, math, sortings Correct Solution: ``` input() a=input() b=['','','2','3','223','5','35','7','2227','2337'] print(''.join(sorted(''.join([b[int(i)]for i in a]),reverse=True))) ```
output
1
102,469
20
204,939
Provide tags and a correct Python 3 solution for this coding contest problem. Drazil is playing a math game with Varda. Let's define <image> for positive integer x as a product of factorials of its digits. For example, <image>. First, they choose a decimal number a consisting of n digits that contains at least one digit larger than 1. This number may possibly start with leading zeroes. Then they should find maximum positive number x satisfying following two conditions: 1. x doesn't contain neither digit 0 nor digit 1. 2. <image> = <image>. Help friends find such number. Input The first line contains an integer n (1 ≤ n ≤ 15) — the number of digits in a. The second line contains n digits of a. There is at least one digit in a that is larger than 1. Number a may possibly contain leading zeroes. Output Output a maximum possible integer satisfying the conditions above. There should be no zeroes and ones in this number decimal representation. Examples Input 4 1234 Output 33222 Input 3 555 Output 555 Note In the first case, <image>
instruction
0
102,470
20
204,940
Tags: greedy, math, sortings Correct Solution: ``` n=int(input()) s=list(input()) d={ '2': '2', '3': '3', '4': '322', '5': '5', '6': '35', '7': '7', '8': '2227', '9': '2337' } ans='' for i in s: if i>'1': ans+=d[i] print(''.join(sorted(list(ans),reverse=True))) ```
output
1
102,470
20
204,941
Provide tags and a correct Python 3 solution for this coding contest problem. Drazil is playing a math game with Varda. Let's define <image> for positive integer x as a product of factorials of its digits. For example, <image>. First, they choose a decimal number a consisting of n digits that contains at least one digit larger than 1. This number may possibly start with leading zeroes. Then they should find maximum positive number x satisfying following two conditions: 1. x doesn't contain neither digit 0 nor digit 1. 2. <image> = <image>. Help friends find such number. Input The first line contains an integer n (1 ≤ n ≤ 15) — the number of digits in a. The second line contains n digits of a. There is at least one digit in a that is larger than 1. Number a may possibly contain leading zeroes. Output Output a maximum possible integer satisfying the conditions above. There should be no zeroes and ones in this number decimal representation. Examples Input 4 1234 Output 33222 Input 3 555 Output 555 Note In the first case, <image>
instruction
0
102,471
20
204,942
Tags: greedy, math, sortings Correct Solution: ``` import sys lines = sys.stdin.readlines() N = int(lines[0].strip()) num = lines[1].strip() factor = {2:{2:1}, 3: {3:1}, 4:{2:2}, 5:{5:1}, 6:{2:1, 3:1}, 7:{7:1}, 8:{2:3}, 9:{3:2}} factorial = [{}, {}] tmp = {} for i in range(2, 10): for k in factor[i].keys(): if k not in tmp: tmp[k] = 0 tmp[k] += factor[i][k] factorial.append(tmp.copy()) target = {} for l in num: for k in factorial[int(l)].keys(): if k not in target: target[k] = 0 target[k] += factorial[int(l)][k] res = "" if 7 in target: val = target[7] res += "7" * val for k in factorial[7].keys(): target[k] -= factorial[7][k] * val if 5 in target and target[5] > 0: val = target[5] res += "5" * val for k in factorial[5].keys(): target[k] -= factorial[5][k] * val if 3 in target and target[3] > 0: val = target[3] res += "3" * val for k in factorial[3].keys(): target[k] -= factorial[3][k] * val if 2 in target: res += "2" * target[2] print(res) ```
output
1
102,471
20
204,943
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Drazil is playing a math game with Varda. Let's define <image> for positive integer x as a product of factorials of its digits. For example, <image>. First, they choose a decimal number a consisting of n digits that contains at least one digit larger than 1. This number may possibly start with leading zeroes. Then they should find maximum positive number x satisfying following two conditions: 1. x doesn't contain neither digit 0 nor digit 1. 2. <image> = <image>. Help friends find such number. Input The first line contains an integer n (1 ≤ n ≤ 15) — the number of digits in a. The second line contains n digits of a. There is at least one digit in a that is larger than 1. Number a may possibly contain leading zeroes. Output Output a maximum possible integer satisfying the conditions above. There should be no zeroes and ones in this number decimal representation. Examples Input 4 1234 Output 33222 Input 3 555 Output 555 Note In the first case, <image> Submitted Solution: ``` # coding: utf-8 n = int(input()) cnt = {2:0,3:0,5:0,7:0} for i in input(): if i == '2': cnt[2] += 1 elif i == '3': cnt[3] += 1 elif i == '4': cnt[2] += 2 cnt[3] += 1 elif i == '5': cnt[5] += 1 elif i == '6': cnt[3] += 1 cnt[5] += 1 elif i == '7': cnt[7] += 1 elif i == '8': cnt[2] += 3 cnt[7] += 1 elif i == '9': cnt[2] += 1 cnt[3] += 2 cnt[7] += 1 for i in sorted(cnt.keys(),reverse=True): print(str(i)*cnt[i],end='') print('') ```
instruction
0
102,472
20
204,944
Yes
output
1
102,472
20
204,945
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Drazil is playing a math game with Varda. Let's define <image> for positive integer x as a product of factorials of its digits. For example, <image>. First, they choose a decimal number a consisting of n digits that contains at least one digit larger than 1. This number may possibly start with leading zeroes. Then they should find maximum positive number x satisfying following two conditions: 1. x doesn't contain neither digit 0 nor digit 1. 2. <image> = <image>. Help friends find such number. Input The first line contains an integer n (1 ≤ n ≤ 15) — the number of digits in a. The second line contains n digits of a. There is at least one digit in a that is larger than 1. Number a may possibly contain leading zeroes. Output Output a maximum possible integer satisfying the conditions above. There should be no zeroes and ones in this number decimal representation. Examples Input 4 1234 Output 33222 Input 3 555 Output 555 Note In the first case, <image> Submitted Solution: ``` n=input() x=input() a,b=[0]*10,[0]*10 for i in range(2,10): a[i]=x.count(str(i)) b[2]=a[2]+2*a[4]+3*a[8]+a[9] b[3]=a[3]+a[4]+a[6]+2*a[9] b[5]=a[5]+a[6] b[7]=a[7]+a[8]+a[9] print('7'*b[7]+'5'*b[5]+'3'*b[3]+'2'*b[2]) ```
instruction
0
102,473
20
204,946
Yes
output
1
102,473
20
204,947
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Drazil is playing a math game with Varda. Let's define <image> for positive integer x as a product of factorials of its digits. For example, <image>. First, they choose a decimal number a consisting of n digits that contains at least one digit larger than 1. This number may possibly start with leading zeroes. Then they should find maximum positive number x satisfying following two conditions: 1. x doesn't contain neither digit 0 nor digit 1. 2. <image> = <image>. Help friends find such number. Input The first line contains an integer n (1 ≤ n ≤ 15) — the number of digits in a. The second line contains n digits of a. There is at least one digit in a that is larger than 1. Number a may possibly contain leading zeroes. Output Output a maximum possible integer satisfying the conditions above. There should be no zeroes and ones in this number decimal representation. Examples Input 4 1234 Output 33222 Input 3 555 Output 555 Note In the first case, <image> Submitted Solution: ``` def fact(num): f=1 while (num>0): f=f*num num-=1 return f n=int(input()) a=int(input()) d={"0":0,"1":0,"2":2,"3":3,"4":322,"5":5,"6":53,"7":7,"8":7222,"9":7332} sa=str(a) sans="" for i in sa: num=d[i] if (num!=0): sans+=str(num) #print(sans) arr=[] for i in sans: arr.append(i) for i in range(len(arr)): for j in range(len(arr)): if (ord(arr[j])>ord(arr[i])): arr[j],arr[i]=arr[i],arr[j] arr.sort(reverse=True) ans=0 for i in arr: ans=ans*10+int(i) print(ans) ```
instruction
0
102,474
20
204,948
Yes
output
1
102,474
20
204,949
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Drazil is playing a math game with Varda. Let's define <image> for positive integer x as a product of factorials of its digits. For example, <image>. First, they choose a decimal number a consisting of n digits that contains at least one digit larger than 1. This number may possibly start with leading zeroes. Then they should find maximum positive number x satisfying following two conditions: 1. x doesn't contain neither digit 0 nor digit 1. 2. <image> = <image>. Help friends find such number. Input The first line contains an integer n (1 ≤ n ≤ 15) — the number of digits in a. The second line contains n digits of a. There is at least one digit in a that is larger than 1. Number a may possibly contain leading zeroes. Output Output a maximum possible integer satisfying the conditions above. There should be no zeroes and ones in this number decimal representation. Examples Input 4 1234 Output 33222 Input 3 555 Output 555 Note In the first case, <image> Submitted Solution: ``` '''input 3 92 ''' # connected components from sys import stdin from collections import defaultdict import sys sys.setrecursionlimit(15000) # main starts n = int(stdin.readline().strip()) string = list(stdin.readline().strip()) mydict = [] for i in string: if i == '0' or i == '1': continue else: num = int(i) if num in [2, 3, 5, 7]: mydict.append(num) else: if num == 4: mydict.append(3) mydict.append(2) mydict.append(2) if num == 6: mydict.append(5) mydict.append(3) if num == 8: mydict.append(7) mydict.append(2) mydict.append(2) mydict.append(2) if num == 9: mydict.append(7) mydict.append(3) mydict.append(3) mydict.append(2) mydict.sort(reverse = True) for i in mydict: print(i, end = '') ```
instruction
0
102,475
20
204,950
Yes
output
1
102,475
20
204,951
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Drazil is playing a math game with Varda. Let's define <image> for positive integer x as a product of factorials of its digits. For example, <image>. First, they choose a decimal number a consisting of n digits that contains at least one digit larger than 1. This number may possibly start with leading zeroes. Then they should find maximum positive number x satisfying following two conditions: 1. x doesn't contain neither digit 0 nor digit 1. 2. <image> = <image>. Help friends find such number. Input The first line contains an integer n (1 ≤ n ≤ 15) — the number of digits in a. The second line contains n digits of a. There is at least one digit in a that is larger than 1. Number a may possibly contain leading zeroes. Output Output a maximum possible integer satisfying the conditions above. There should be no zeroes and ones in this number decimal representation. Examples Input 4 1234 Output 33222 Input 3 555 Output 555 Note In the first case, <image> Submitted Solution: ``` n = int(input()) a = list(map(int, list(input()))) b = [] for e in a: if e == 1 or e == 0: continue elif e == 2 or e == 3 or e == 5 or a == 7: b.append(e) elif e == 4: b.append(3) b.append(2) b.append(2) elif e == 6: b.append(5) b.append(3) elif e == 8: b.append(7) b.append(2) b.append(2) b.append(2) elif e == 9: b.append(7) b.append(3) b.append(3) b.append(2) b = list(map(str, sorted(b))) b.reverse() print(''.join(b)) ```
instruction
0
102,476
20
204,952
No
output
1
102,476
20
204,953
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Drazil is playing a math game with Varda. Let's define <image> for positive integer x as a product of factorials of its digits. For example, <image>. First, they choose a decimal number a consisting of n digits that contains at least one digit larger than 1. This number may possibly start with leading zeroes. Then they should find maximum positive number x satisfying following two conditions: 1. x doesn't contain neither digit 0 nor digit 1. 2. <image> = <image>. Help friends find such number. Input The first line contains an integer n (1 ≤ n ≤ 15) — the number of digits in a. The second line contains n digits of a. There is at least one digit in a that is larger than 1. Number a may possibly contain leading zeroes. Output Output a maximum possible integer satisfying the conditions above. There should be no zeroes and ones in this number decimal representation. Examples Input 4 1234 Output 33222 Input 3 555 Output 555 Note In the first case, <image> Submitted Solution: ``` def findPrime(n): prime_numbers = [] # made a boolean list of all numbers from 1 - n prime_number_list = [True for i in range(n+1)] # taken 2 as a starting point as 2 is the lowers prime number p = 2 while(p*p <= n): # get unmarked number if prime_number_list[p]: # mark all the numbers divisible by unmarked number for i in range(p*2, n+1, p): prime_number_list[i] = False p = p+1 for i in range(2, n+1): if prime_number_list[i]: prime_numbers.append(str(i)) return prime_numbers a=int(input()) l=[] li=[] for i in input(): l=findPrime(int(i)) li=li+l li=sorted(li,reverse=True) print(''.join(li)) ```
instruction
0
102,477
20
204,954
No
output
1
102,477
20
204,955
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Drazil is playing a math game with Varda. Let's define <image> for positive integer x as a product of factorials of its digits. For example, <image>. First, they choose a decimal number a consisting of n digits that contains at least one digit larger than 1. This number may possibly start with leading zeroes. Then they should find maximum positive number x satisfying following two conditions: 1. x doesn't contain neither digit 0 nor digit 1. 2. <image> = <image>. Help friends find such number. Input The first line contains an integer n (1 ≤ n ≤ 15) — the number of digits in a. The second line contains n digits of a. There is at least one digit in a that is larger than 1. Number a may possibly contain leading zeroes. Output Output a maximum possible integer satisfying the conditions above. There should be no zeroes and ones in this number decimal representation. Examples Input 4 1234 Output 33222 Input 3 555 Output 555 Note In the first case, <image> Submitted Solution: ``` n=int(input()) k=int(input()) a=["","2","3","322","5","35","7","7222","7233"] s="" for i in range(n): s=s+a[int(k%10)-1] k/=10 s=''.join(sorted(s))[::-1] print(s) ```
instruction
0
102,478
20
204,956
No
output
1
102,478
20
204,957
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Drazil is playing a math game with Varda. Let's define <image> for positive integer x as a product of factorials of its digits. For example, <image>. First, they choose a decimal number a consisting of n digits that contains at least one digit larger than 1. This number may possibly start with leading zeroes. Then they should find maximum positive number x satisfying following two conditions: 1. x doesn't contain neither digit 0 nor digit 1. 2. <image> = <image>. Help friends find such number. Input The first line contains an integer n (1 ≤ n ≤ 15) — the number of digits in a. The second line contains n digits of a. There is at least one digit in a that is larger than 1. Number a may possibly contain leading zeroes. Output Output a maximum possible integer satisfying the conditions above. There should be no zeroes and ones in this number decimal representation. Examples Input 4 1234 Output 33222 Input 3 555 Output 555 Note In the first case, <image> Submitted Solution: ``` l = int(input()) number = list(input()) for i in range(len(number)): if number[i] == '0' or number[i] == '1': number[i:i+1] = [] if number[i] == '4': number[i:i+1] = ['2', '2', '3'] i += 2 if number[i] == '6': number[i:i+1] = ['5', '6'] i += 1 if number[i] == '8': number[i:i+1] = ['7', '2', '2', '2'] i += 3 if number[i] == '9': number[i:i+1] = ['7', '2', '2', '2', '3', '3'] i += 5 number.sort(reverse=True) print(''.join(number)) ```
instruction
0
102,479
20
204,958
No
output
1
102,479
20
204,959
Provide tags and a correct Python 3 solution for this coding contest problem. Input The input contains a single integer a (1 ≤ a ≤ 99). Output Output "YES" or "NO". Examples Input 5 Output YES Input 13 Output NO Input 24 Output NO Input 46 Output YES
instruction
0
102,940
20
205,880
Tags: brute force Correct Solution: ``` numWords = ["1","7","9"] FirstNums = ["1","2","7","9"] def isKanBan(n): if(n == "10" or n == "11"): return "NO" if(n == "12"): return "YES" if(len(n) > 1): if(n[0] in FirstNums): return "NO" for el in n: if(el in numWords): return "NO" return "YES" n = str(input()) print(isKanBan(n)) ```
output
1
102,940
20
205,881
Provide tags and a correct Python 3 solution for this coding contest problem. Input The input contains a single integer a (1 ≤ a ≤ 99). Output Output "YES" or "NO". Examples Input 5 Output YES Input 13 Output NO Input 24 Output NO Input 46 Output YES
instruction
0
102,941
20
205,882
Tags: brute force Correct Solution: ``` print("YES"if 0xbe880002fabeafabe800be800>>99-int(input())&1else"NO") ```
output
1
102,941
20
205,883
Provide tags and a correct Python 3 solution for this coding contest problem. Input The input contains a single integer a (1 ≤ a ≤ 99). Output Output "YES" or "NO". Examples Input 5 Output YES Input 13 Output NO Input 24 Output NO Input 46 Output YES
instruction
0
102,942
20
205,884
Tags: brute force Correct Solution: ``` a = [0, 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88] n = int(input()) if n in a: print("YES") else: print("NO") ```
output
1
102,942
20
205,885
Provide tags and a correct Python 3 solution for this coding contest problem. Input The input contains a single integer a (1 ≤ a ≤ 99). Output Output "YES" or "NO". Examples Input 5 Output YES Input 13 Output NO Input 24 Output NO Input 46 Output YES
instruction
0
102,943
20
205,886
Tags: brute force Correct Solution: ``` num = input().rjust(2, '0') tens, nums = ['1', '2', '7', '9'], ['1', '7', '9'] if num[0] in tens or num[1] in nums: if num != '12': print('NO') else: print('YES') else: print('YES') ```
output
1
102,943
20
205,887
Provide tags and a correct Python 3 solution for this coding contest problem. Input The input contains a single integer a (1 ≤ a ≤ 99). Output Output "YES" or "NO". Examples Input 5 Output YES Input 13 Output NO Input 24 Output NO Input 46 Output YES
instruction
0
102,944
20
205,888
Tags: brute force Correct Solution: ``` n = int(input()) q = ["1","7","9","10","11","13","14","15","16","17","18","19","20", "21","22","23","24","25","26","27","28","29","31","37","39", "41","47","49","51","57","59","61","67","69", "70","71","72","73","74","75","76","77","78","79", "81","87","89","90","91","92","93","94","95","96","97","98","99"] k=0 for i in range(len(q)): if str(n) == q[i]: print("No") k+=1 if k==0: print("Yes") ```
output
1
102,944
20
205,889
Provide tags and a correct Python 3 solution for this coding contest problem. Input The input contains a single integer a (1 ≤ a ≤ 99). Output Output "YES" or "NO". Examples Input 5 Output YES Input 13 Output NO Input 24 Output NO Input 46 Output YES
instruction
0
102,945
20
205,890
Tags: brute force Correct Solution: ``` n=int(input()) l=list(map(int,list(str(n)))) if 7 in l or 9 in l or (n>=13 and n<=29) or l[-1]==1 or n==10 or n==11 or (n>=70 and n<=79) or (n>=90): print ("NO") else: print ("YES") ```
output
1
102,945
20
205,891
Provide tags and a correct Python 3 solution for this coding contest problem. Input The input contains a single integer a (1 ≤ a ≤ 99). Output Output "YES" or "NO". Examples Input 5 Output YES Input 13 Output NO Input 24 Output NO Input 46 Output YES
instruction
0
102,946
20
205,892
Tags: brute force Correct Solution: ``` n='0'+input() print('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2]) ```
output
1
102,946
20
205,893
Provide tags and a correct Python 3 solution for this coding contest problem. Input The input contains a single integer a (1 ≤ a ≤ 99). Output Output "YES" or "NO". Examples Input 5 Output YES Input 13 Output NO Input 24 Output NO Input 46 Output YES
instruction
0
102,947
20
205,894
Tags: brute force Correct Solution: ``` # Kanban Numbers - codeforces # import math import sys input = sys.stdin.readline def inp(): return int(input()) def isKanban(n): arr = [ 0,1,0,0,0,0,0,1,0,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,0,1,0,1,0,1,0,0,0,0,0,1,0,1,0,1,0,0,0,0,0,1,0,1,0,1,0,0,0,0,0,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,0,1,0,1,1,1,1,1,1,1,1,1,1,1 ] # print(len(arr)) return arr[n] a = inp() print("NO" if isKanban(a) else "YES") ```
output
1
102,947
20
205,895
Provide tags and a correct Python 3 solution for this coding contest problem. When Serezha was three years old, he was given a set of cards with letters for his birthday. They were arranged into words in the way which formed the boy's mother favorite number in binary notation. Serezha started playing with them immediately and shuffled them because he wasn't yet able to read. His father decided to rearrange them. Help him restore the original number, on condition that it was the maximum possible one. Input The first line contains a single integer n (1 ⩽ n ⩽ 10^5) — the length of the string. The second line contains a string consisting of English lowercase letters: 'z', 'e', 'r', 'o' and 'n'. It is guaranteed that it is possible to rearrange the letters in such a way that they form a sequence of words, each being either "zero" which corresponds to the digit 0 or "one" which corresponds to the digit 1. Output Print the maximum possible number in binary notation. Print binary digits separated by a space. The leading zeroes are allowed. Examples Input 4 ezor Output 0 Input 10 nznooeeoer Output 1 1 0 Note In the first example, the correct initial ordering is "zero". In the second example, the correct initial ordering is "oneonezero".
instruction
0
102,994
20
205,988
Tags: implementation, sortings, strings Correct Solution: ``` n = int(input()) q = list(input()) z = 0 e = 0 r = 0 o = 0 n = 0 for i in q: if i == "z": z+=1 elif i == "e": e +=1 elif i =="o": o+=1 elif i=="n": n+=1 elif i == "r": r += 1 while (n>0 and o>0 and e>0): print(1,end=" ") n-=1 o -=1 e -=1 while (z > 0 and e > 0 and r > 0 and o > 0): print(0," ") z -= 1 e -= 1 r -= 1 o -= 1 ```
output
1
102,994
20
205,989
Provide tags and a correct Python 3 solution for this coding contest problem. When Serezha was three years old, he was given a set of cards with letters for his birthday. They were arranged into words in the way which formed the boy's mother favorite number in binary notation. Serezha started playing with them immediately and shuffled them because he wasn't yet able to read. His father decided to rearrange them. Help him restore the original number, on condition that it was the maximum possible one. Input The first line contains a single integer n (1 ⩽ n ⩽ 10^5) — the length of the string. The second line contains a string consisting of English lowercase letters: 'z', 'e', 'r', 'o' and 'n'. It is guaranteed that it is possible to rearrange the letters in such a way that they form a sequence of words, each being either "zero" which corresponds to the digit 0 or "one" which corresponds to the digit 1. Output Print the maximum possible number in binary notation. Print binary digits separated by a space. The leading zeroes are allowed. Examples Input 4 ezor Output 0 Input 10 nznooeeoer Output 1 1 0 Note In the first example, the correct initial ordering is "zero". In the second example, the correct initial ordering is "oneonezero".
instruction
0
102,995
20
205,990
Tags: implementation, sortings, strings Correct Solution: ``` n=int(input()) a=list(input()) z=a.count('z') o=a.count('n') for i in range(o): print(1,end=' ') for i in range(z): print(0,end=' ') ```
output
1
102,995
20
205,991
Provide tags and a correct Python 3 solution for this coding contest problem. When Serezha was three years old, he was given a set of cards with letters for his birthday. They were arranged into words in the way which formed the boy's mother favorite number in binary notation. Serezha started playing with them immediately and shuffled them because he wasn't yet able to read. His father decided to rearrange them. Help him restore the original number, on condition that it was the maximum possible one. Input The first line contains a single integer n (1 ⩽ n ⩽ 10^5) — the length of the string. The second line contains a string consisting of English lowercase letters: 'z', 'e', 'r', 'o' and 'n'. It is guaranteed that it is possible to rearrange the letters in such a way that they form a sequence of words, each being either "zero" which corresponds to the digit 0 or "one" which corresponds to the digit 1. Output Print the maximum possible number in binary notation. Print binary digits separated by a space. The leading zeroes are allowed. Examples Input 4 ezor Output 0 Input 10 nznooeeoer Output 1 1 0 Note In the first example, the correct initial ordering is "zero". In the second example, the correct initial ordering is "oneonezero".
instruction
0
102,996
20
205,992
Tags: implementation, sortings, strings Correct Solution: ``` n = int(input()) s = input() d = {'z': 0, 'e': 0, 'r': 0, 'o': 0, 'n': 0} res = [] for i in s: d[i] = d[i] + 1 while(d['n'] > 0): if(d['o'] and d['n'] and d['e']): res.append(1) d['o'] -= 1 d['n'] -= 1 d['e'] -= 1 else: break while(d['z'] > 0): if(d['z'] and d['e'] and d['r'] and d['o']): res.append(0) d['z'] -= 1 d['e'] -= 1 d['r'] -= 1 d['o'] -= 1 else: break print(*res) ```
output
1
102,996
20
205,993
Provide tags and a correct Python 3 solution for this coding contest problem. When Serezha was three years old, he was given a set of cards with letters for his birthday. They were arranged into words in the way which formed the boy's mother favorite number in binary notation. Serezha started playing with them immediately and shuffled them because he wasn't yet able to read. His father decided to rearrange them. Help him restore the original number, on condition that it was the maximum possible one. Input The first line contains a single integer n (1 ⩽ n ⩽ 10^5) — the length of the string. The second line contains a string consisting of English lowercase letters: 'z', 'e', 'r', 'o' and 'n'. It is guaranteed that it is possible to rearrange the letters in such a way that they form a sequence of words, each being either "zero" which corresponds to the digit 0 or "one" which corresponds to the digit 1. Output Print the maximum possible number in binary notation. Print binary digits separated by a space. The leading zeroes are allowed. Examples Input 4 ezor Output 0 Input 10 nznooeeoer Output 1 1 0 Note In the first example, the correct initial ordering is "zero". In the second example, the correct initial ordering is "oneonezero".
instruction
0
102,997
20
205,994
Tags: implementation, sortings, strings Correct Solution: ``` n = int(input()) s = list(input()) print("1 "*s.count("n") + "0 "*s.count("z")) ```
output
1
102,997
20
205,995
Provide tags and a correct Python 3 solution for this coding contest problem. When Serezha was three years old, he was given a set of cards with letters for his birthday. They were arranged into words in the way which formed the boy's mother favorite number in binary notation. Serezha started playing with them immediately and shuffled them because he wasn't yet able to read. His father decided to rearrange them. Help him restore the original number, on condition that it was the maximum possible one. Input The first line contains a single integer n (1 ⩽ n ⩽ 10^5) — the length of the string. The second line contains a string consisting of English lowercase letters: 'z', 'e', 'r', 'o' and 'n'. It is guaranteed that it is possible to rearrange the letters in such a way that they form a sequence of words, each being either "zero" which corresponds to the digit 0 or "one" which corresponds to the digit 1. Output Print the maximum possible number in binary notation. Print binary digits separated by a space. The leading zeroes are allowed. Examples Input 4 ezor Output 0 Input 10 nznooeeoer Output 1 1 0 Note In the first example, the correct initial ordering is "zero". In the second example, the correct initial ordering is "oneonezero".
instruction
0
102,998
20
205,996
Tags: implementation, sortings, strings Correct Solution: ``` N = int(input()) words = input() one = words.count("n") zero = words.count("z") ans = "1 "*one + "0 "*zero print(ans) ```
output
1
102,998
20
205,997
Provide tags and a correct Python 3 solution for this coding contest problem. When Serezha was three years old, he was given a set of cards with letters for his birthday. They were arranged into words in the way which formed the boy's mother favorite number in binary notation. Serezha started playing with them immediately and shuffled them because he wasn't yet able to read. His father decided to rearrange them. Help him restore the original number, on condition that it was the maximum possible one. Input The first line contains a single integer n (1 ⩽ n ⩽ 10^5) — the length of the string. The second line contains a string consisting of English lowercase letters: 'z', 'e', 'r', 'o' and 'n'. It is guaranteed that it is possible to rearrange the letters in such a way that they form a sequence of words, each being either "zero" which corresponds to the digit 0 or "one" which corresponds to the digit 1. Output Print the maximum possible number in binary notation. Print binary digits separated by a space. The leading zeroes are allowed. Examples Input 4 ezor Output 0 Input 10 nznooeeoer Output 1 1 0 Note In the first example, the correct initial ordering is "zero". In the second example, the correct initial ordering is "oneonezero".
instruction
0
102,999
20
205,998
Tags: implementation, sortings, strings Correct Solution: ``` n=int(input()) jumble=input() result=list() for i in range(0,n): if jumble[i]=='z': result.append('0') elif jumble[i]=='n': result.insert(0,'1') print(" ".join(result)) ```
output
1
102,999
20
205,999
Provide tags and a correct Python 3 solution for this coding contest problem. When Serezha was three years old, he was given a set of cards with letters for his birthday. They were arranged into words in the way which formed the boy's mother favorite number in binary notation. Serezha started playing with them immediately and shuffled them because he wasn't yet able to read. His father decided to rearrange them. Help him restore the original number, on condition that it was the maximum possible one. Input The first line contains a single integer n (1 ⩽ n ⩽ 10^5) — the length of the string. The second line contains a string consisting of English lowercase letters: 'z', 'e', 'r', 'o' and 'n'. It is guaranteed that it is possible to rearrange the letters in such a way that they form a sequence of words, each being either "zero" which corresponds to the digit 0 or "one" which corresponds to the digit 1. Output Print the maximum possible number in binary notation. Print binary digits separated by a space. The leading zeroes are allowed. Examples Input 4 ezor Output 0 Input 10 nznooeeoer Output 1 1 0 Note In the first example, the correct initial ordering is "zero". In the second example, the correct initial ordering is "oneonezero".
instruction
0
103,000
20
206,000
Tags: implementation, sortings, strings Correct Solution: ``` def solve(s): n = r = 0 for c in s: if c == "n": n += 1 continue if c == "r": r += 1 ans = " ".join(["1" for i in range(n)] + ["0" for i in range(r)]) return ans input() s = input() print(solve(s)) ```
output
1
103,000
20
206,001
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. When Serezha was three years old, he was given a set of cards with letters for his birthday. They were arranged into words in the way which formed the boy's mother favorite number in binary notation. Serezha started playing with them immediately and shuffled them because he wasn't yet able to read. His father decided to rearrange them. Help him restore the original number, on condition that it was the maximum possible one. Input The first line contains a single integer n (1 ⩽ n ⩽ 10^5) — the length of the string. The second line contains a string consisting of English lowercase letters: 'z', 'e', 'r', 'o' and 'n'. It is guaranteed that it is possible to rearrange the letters in such a way that they form a sequence of words, each being either "zero" which corresponds to the digit 0 or "one" which corresponds to the digit 1. Output Print the maximum possible number in binary notation. Print binary digits separated by a space. The leading zeroes are allowed. Examples Input 4 ezor Output 0 Input 10 nznooeeoer Output 1 1 0 Note In the first example, the correct initial ordering is "zero". In the second example, the correct initial ordering is "oneonezero". Submitted Solution: ``` n=int(input()) s=input() z=s.count('z') o=n-z*4 l=[1]*(o//3) l+=[0]*z print(*l) ```
instruction
0
103,002
20
206,004
Yes
output
1
103,002
20
206,005
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. When Serezha was three years old, he was given a set of cards with letters for his birthday. They were arranged into words in the way which formed the boy's mother favorite number in binary notation. Serezha started playing with them immediately and shuffled them because he wasn't yet able to read. His father decided to rearrange them. Help him restore the original number, on condition that it was the maximum possible one. Input The first line contains a single integer n (1 ⩽ n ⩽ 10^5) — the length of the string. The second line contains a string consisting of English lowercase letters: 'z', 'e', 'r', 'o' and 'n'. It is guaranteed that it is possible to rearrange the letters in such a way that they form a sequence of words, each being either "zero" which corresponds to the digit 0 or "one" which corresponds to the digit 1. Output Print the maximum possible number in binary notation. Print binary digits separated by a space. The leading zeroes are allowed. Examples Input 4 ezor Output 0 Input 10 nznooeeoer Output 1 1 0 Note In the first example, the correct initial ordering is "zero". In the second example, the correct initial ordering is "oneonezero". Submitted Solution: ``` d = { 'z':0, 'e':0, 'r':0, 'o':0, 'n':0, 'e':0 } input() for i in input(): d[i] += 1 one = 0 null = 0 m = min(d['o'], d['n'], d['e']) if m <= d['o'] and d['n'] >= m and d['e'] >= m: one += m d['e'] -= m d['o'] -= m m = min(d['z'], d['e'], d['r'], d['o']) if m >= d['z'] and m >= d['e'] and m >= d['r'] and m >= d['o']: null += m print('1 ' * one, '0 ' * null) ```
instruction
0
103,003
20
206,006
Yes
output
1
103,003
20
206,007
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. When Serezha was three years old, he was given a set of cards with letters for his birthday. They were arranged into words in the way which formed the boy's mother favorite number in binary notation. Serezha started playing with them immediately and shuffled them because he wasn't yet able to read. His father decided to rearrange them. Help him restore the original number, on condition that it was the maximum possible one. Input The first line contains a single integer n (1 ⩽ n ⩽ 10^5) — the length of the string. The second line contains a string consisting of English lowercase letters: 'z', 'e', 'r', 'o' and 'n'. It is guaranteed that it is possible to rearrange the letters in such a way that they form a sequence of words, each being either "zero" which corresponds to the digit 0 or "one" which corresponds to the digit 1. Output Print the maximum possible number in binary notation. Print binary digits separated by a space. The leading zeroes are allowed. Examples Input 4 ezor Output 0 Input 10 nznooeeoer Output 1 1 0 Note In the first example, the correct initial ordering is "zero". In the second example, the correct initial ordering is "oneonezero". Submitted Solution: ``` # -*- coding: utf-8 -*- """ Created on Fri Nov 6 00:39:35 2020 @author: Xuan Loc """ if __name__=='__main__': n=int(input()) s=list(input()) my_dict={'z':0,'e':0,'r':0,'o':0,'n':0} for x in s: my_dict[x]+=1 one=min(my_dict['o'],my_dict['n'],my_dict['e']) zero=min(my_dict['z'],my_dict['r'],my_dict['e']-one,my_dict['o']-one) for i in range(one): print(1,end=' ') for i in range(zero): print(0,end=' ') ```
instruction
0
103,004
20
206,008
Yes
output
1
103,004
20
206,009
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. When Serezha was three years old, he was given a set of cards with letters for his birthday. They were arranged into words in the way which formed the boy's mother favorite number in binary notation. Serezha started playing with them immediately and shuffled them because he wasn't yet able to read. His father decided to rearrange them. Help him restore the original number, on condition that it was the maximum possible one. Input The first line contains a single integer n (1 ⩽ n ⩽ 10^5) — the length of the string. The second line contains a string consisting of English lowercase letters: 'z', 'e', 'r', 'o' and 'n'. It is guaranteed that it is possible to rearrange the letters in such a way that they form a sequence of words, each being either "zero" which corresponds to the digit 0 or "one" which corresponds to the digit 1. Output Print the maximum possible number in binary notation. Print binary digits separated by a space. The leading zeroes are allowed. Examples Input 4 ezor Output 0 Input 10 nznooeeoer Output 1 1 0 Note In the first example, the correct initial ordering is "zero". In the second example, the correct initial ordering is "oneonezero". Submitted Solution: ``` n = int(input()) s = input() print(' '.join(list('1'*s.count('n')+'0' * s.count('z')))) ```
instruction
0
103,005
20
206,010
Yes
output
1
103,005
20
206,011