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 |
|---|---|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Karl is developing a key storage service. Each user has a positive integer key.
Karl knows that storing keys in plain text is bad practice. So, instead of storing a key, he decided to store a fingerprint of a key. However, using some existing fingerprint algorithm looked too boring to him, so he invented his own one.
Karl's fingerprint is calculated by the following process: divide the given integer by 2, then divide the result by 3, then divide the result by 4, and so on, until we get a result that equals zero (we are speaking about integer division each time). The fingerprint is defined as the multiset of the remainders of these divisions.
For example, this is how Karl's fingerprint algorithm is applied to the key 11: 11 divided by 2 has remainder 1 and result 5, then 5 divided by 3 has remainder 2 and result 1, and 1 divided by 4 has remainder 1 and result 0. Thus, the key 11 produces the sequence of remainders [1, 2, 1] and has the fingerprint multiset \{1, 1, 2\}.
Ksenia wants to prove that Karl's fingerprint algorithm is not very good. For example, she found that both keys 178800 and 123456 produce the fingerprint of \{0, 0, 0, 0, 2, 3, 3, 4\}. Thus, users are at risk of fingerprint collision with some commonly used and easy to guess keys like 123456.
Ksenia wants to make her words more persuasive. She wants to calculate the number of other keys that have the same fingerprint as the keys in the given list of some commonly used keys. Your task is to help her.
Input
The first line contains an integer t (1 ≤ t ≤ 50 000) — the number of commonly used keys to examine. Each of the next t lines contains one integer k_i (1 ≤ k_i ≤ 10^{18}) — the key itself.
Output
For each of the keys print one integer — the number of other keys that have the same fingerprint.
Example
Input
3
1
11
123456
Output
0
1
127
Note
The other key with the same fingerprint as 11 is 15. 15 produces a sequence of remainders [1, 1, 2]. So both numbers have the fingerprint multiset \{1, 1, 2\}.
Submitted Solution:
```
# Precalcular los factoriales
f = [1, 1]
for i in range(2, 21): # Se calcula hasta el factorial de 20 pues la entrada está acotada por 10^18
f.append(f[-1]*i)
def C(n, r): # Función para calcular las combinaciones de n en r
if n < r:
return 0
return f[n] // (f[n-r]*f[r])
class KeyProblem:
def __init__(self, x):
self.multiplicity = {} # Diccionario para almacenar la multiplicidad
self.calcReminders(x) # Calcula las multiplicidades
ans = self.solve() # Determina el número de combinaciones para la multiplicidad y el total de actual
# Resuelve el caso del cero
if 0 in self.multiplicity:
self.multiplicity[0] -= 1
self.total -= 1
ans -= self.solve()
print(ans-1) # Se le resta 1 a la respuesta debido a que se consideran los diferentes y no el total
def solve(self):
ans = 1 # Cuenta el número total de soluciones
rep = 0 # Contar los restos que ya se han permutado
for i in sorted(self.multiplicity.keys(), reverse=True): # Iterar por cada resto (sin repetir)
if i == 0:
ans *= C(max(0, self.total - i - rep), self.multiplicity[i]) # Calcular las posibles combinaciones
else:
ans *= C(max(0, self.total+1 - i - rep), self.multiplicity[i]) # Calcular las posibles combinaciones
rep += self.multiplicity[i] # Añadir la multiplicidad del resto i a la cuenta
return ans
def calcReminders(self, val):
d = 2
while val:
r = val%d
if r in self.multiplicity:
self.multiplicity[r] += 1
else:
self.multiplicity[r] = 1
val = val // d
d += 1
self.total = d - 2
if __name__ == '__main__':
total = int(input())
for _ in range(total):
KeyProblem(int(input()))
``` | instruction | 0 | 22,153 | 20 | 44,306 |
Yes | output | 1 | 22,153 | 20 | 44,307 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Karl is developing a key storage service. Each user has a positive integer key.
Karl knows that storing keys in plain text is bad practice. So, instead of storing a key, he decided to store a fingerprint of a key. However, using some existing fingerprint algorithm looked too boring to him, so he invented his own one.
Karl's fingerprint is calculated by the following process: divide the given integer by 2, then divide the result by 3, then divide the result by 4, and so on, until we get a result that equals zero (we are speaking about integer division each time). The fingerprint is defined as the multiset of the remainders of these divisions.
For example, this is how Karl's fingerprint algorithm is applied to the key 11: 11 divided by 2 has remainder 1 and result 5, then 5 divided by 3 has remainder 2 and result 1, and 1 divided by 4 has remainder 1 and result 0. Thus, the key 11 produces the sequence of remainders [1, 2, 1] and has the fingerprint multiset \{1, 1, 2\}.
Ksenia wants to prove that Karl's fingerprint algorithm is not very good. For example, she found that both keys 178800 and 123456 produce the fingerprint of \{0, 0, 0, 0, 2, 3, 3, 4\}. Thus, users are at risk of fingerprint collision with some commonly used and easy to guess keys like 123456.
Ksenia wants to make her words more persuasive. She wants to calculate the number of other keys that have the same fingerprint as the keys in the given list of some commonly used keys. Your task is to help her.
Input
The first line contains an integer t (1 ≤ t ≤ 50 000) — the number of commonly used keys to examine. Each of the next t lines contains one integer k_i (1 ≤ k_i ≤ 10^{18}) — the key itself.
Output
For each of the keys print one integer — the number of other keys that have the same fingerprint.
Example
Input
3
1
11
123456
Output
0
1
127
Note
The other key with the same fingerprint as 11 is 15. 15 produces a sequence of remainders [1, 1, 2]. So both numbers have the fingerprint multiset \{1, 1, 2\}.
Submitted Solution:
```
from math import factorial as f
for test in range(int(input())):
k = int(input())
a = []
d = 2
while k:
a.append(k%d)
k //= d
d += 1
n = len(a)
c0 = a.count(0)
a.sort(reverse = True)
ans = 1
j = 0
for i in a:
if i == 0:
ans *= n-i - j
else:
ans *= n-i+1 - j
j += 1
if c0:
badans = 1
n = len(a)
j = 1
for i in range(len(a)-1):
if (a[i] == 0):
badans *= max(0,n-a[i] - j)
else:
badans *= max(0,n-a[i]+1 - j)
j += 1
ans -= badans*c0
for i in range(max(a)):
ans //= f(a.count(i))
print(ans-1)
``` | instruction | 0 | 22,154 | 20 | 44,308 |
No | output | 1 | 22,154 | 20 | 44,309 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Karl is developing a key storage service. Each user has a positive integer key.
Karl knows that storing keys in plain text is bad practice. So, instead of storing a key, he decided to store a fingerprint of a key. However, using some existing fingerprint algorithm looked too boring to him, so he invented his own one.
Karl's fingerprint is calculated by the following process: divide the given integer by 2, then divide the result by 3, then divide the result by 4, and so on, until we get a result that equals zero (we are speaking about integer division each time). The fingerprint is defined as the multiset of the remainders of these divisions.
For example, this is how Karl's fingerprint algorithm is applied to the key 11: 11 divided by 2 has remainder 1 and result 5, then 5 divided by 3 has remainder 2 and result 1, and 1 divided by 4 has remainder 1 and result 0. Thus, the key 11 produces the sequence of remainders [1, 2, 1] and has the fingerprint multiset \{1, 1, 2\}.
Ksenia wants to prove that Karl's fingerprint algorithm is not very good. For example, she found that both keys 178800 and 123456 produce the fingerprint of \{0, 0, 0, 0, 2, 3, 3, 4\}. Thus, users are at risk of fingerprint collision with some commonly used and easy to guess keys like 123456.
Ksenia wants to make her words more persuasive. She wants to calculate the number of other keys that have the same fingerprint as the keys in the given list of some commonly used keys. Your task is to help her.
Input
The first line contains an integer t (1 ≤ t ≤ 50 000) — the number of commonly used keys to examine. Each of the next t lines contains one integer k_i (1 ≤ k_i ≤ 10^{18}) — the key itself.
Output
For each of the keys print one integer — the number of other keys that have the same fingerprint.
Example
Input
3
1
11
123456
Output
0
1
127
Note
The other key with the same fingerprint as 11 is 15. 15 produces a sequence of remainders [1, 1, 2]. So both numbers have the fingerprint multiset \{1, 1, 2\}.
Submitted Solution:
```
#######################################################################################################################
# Author: BlackFyre
# Language: PyPy 3.7
#######################################################################################################################
from sys import stdin, stdout, setrecursionlimit
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
from collections import defaultdict as dd
mod = pow(10, 9) + 7
mod2 = 998244353
# setrecursionlimit(3000)
def inp(): return stdin.readline().strip()
def iinp(): return int(inp())
def out(var, end="\n"): stdout.write(str(var) + "\n")
def outa(*var, end="\n"): stdout.write(' '.join(map(str, var)) + end)
def lmp(): return list(mp())
def mp(): return map(int, inp().split())
def smp(): return map(str, inp().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(m, val) for j in range(n)]
def remadd(x, y): return 1 if x % y else 0
def ceil(a, b): return (a + b - 1) // b
def def_value(): return 0
for _ in range(iinp()):
k = iinp()
a = []
i = 2
while k>0:
a.append(k%i)
k//=i
i+=1
a.sort(reverse = True)
n = len(a)
ans = 1
for i in range(n):
j = i
cnt = 0
while j>=0 and a[j]==a[i]:
j-=1
cnt+=1
ans *= (max(0,n-max(0,a[i]-1)-i)/cnt)
ans-=1
zero = 1
for i in range(n):
if a[i]==0: break
j = i
cnt = 0
while j>=0 and a[j]==a[i]:
j-=1
cnt+=1
zero *= (max(0,n-max(0,a[i]-1)-i-1)/cnt)
print(int(ans-zero))
``` | instruction | 0 | 22,155 | 20 | 44,310 |
No | output | 1 | 22,155 | 20 | 44,311 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Karl is developing a key storage service. Each user has a positive integer key.
Karl knows that storing keys in plain text is bad practice. So, instead of storing a key, he decided to store a fingerprint of a key. However, using some existing fingerprint algorithm looked too boring to him, so he invented his own one.
Karl's fingerprint is calculated by the following process: divide the given integer by 2, then divide the result by 3, then divide the result by 4, and so on, until we get a result that equals zero (we are speaking about integer division each time). The fingerprint is defined as the multiset of the remainders of these divisions.
For example, this is how Karl's fingerprint algorithm is applied to the key 11: 11 divided by 2 has remainder 1 and result 5, then 5 divided by 3 has remainder 2 and result 1, and 1 divided by 4 has remainder 1 and result 0. Thus, the key 11 produces the sequence of remainders [1, 2, 1] and has the fingerprint multiset \{1, 1, 2\}.
Ksenia wants to prove that Karl's fingerprint algorithm is not very good. For example, she found that both keys 178800 and 123456 produce the fingerprint of \{0, 0, 0, 0, 2, 3, 3, 4\}. Thus, users are at risk of fingerprint collision with some commonly used and easy to guess keys like 123456.
Ksenia wants to make her words more persuasive. She wants to calculate the number of other keys that have the same fingerprint as the keys in the given list of some commonly used keys. Your task is to help her.
Input
The first line contains an integer t (1 ≤ t ≤ 50 000) — the number of commonly used keys to examine. Each of the next t lines contains one integer k_i (1 ≤ k_i ≤ 10^{18}) — the key itself.
Output
For each of the keys print one integer — the number of other keys that have the same fingerprint.
Example
Input
3
1
11
123456
Output
0
1
127
Note
The other key with the same fingerprint as 11 is 15. 15 produces a sequence of remainders [1, 1, 2]. So both numbers have the fingerprint multiset \{1, 1, 2\}.
Submitted Solution:
```
from sys import stdin, stdout
def getpair(p, k):
len = 0
cnta = [0]*20
d = 2
while k > 0:
m = k % d
cnta[m] += 1
len += 1
k = int(k/d)
d += 1
#print(cnta)
#print(len)
r1 = calc(cnta, len, p)
#print(r1)
r2 = 0
if cnta[0] > 0:
cnta[0] -= 1
r2 = calc(cnta, len-1, p)
#print(r2)
return r1 - r2
def calc(cnta, len, p):
cur = cnta[0]
lr = 1
for i in range(len):
cur += cnta[i+1]
if cur > 0:
lr *= cur
cur -= 1
else:
return 0
for d in cnta:
if d > 0:
lr /= p[d]
return int(lr)
if __name__ == '__main__':
t = int(stdin.readline())
p = [1]
for i in range(1, 21):
p.append(i*p[i-1])
for i in range(t):
k = int(stdin.readline())
res = getpair(p, k)
stdout.write(str(res-1) + '\n')
``` | instruction | 0 | 22,156 | 20 | 44,312 |
No | output | 1 | 22,156 | 20 | 44,313 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Karl is developing a key storage service. Each user has a positive integer key.
Karl knows that storing keys in plain text is bad practice. So, instead of storing a key, he decided to store a fingerprint of a key. However, using some existing fingerprint algorithm looked too boring to him, so he invented his own one.
Karl's fingerprint is calculated by the following process: divide the given integer by 2, then divide the result by 3, then divide the result by 4, and so on, until we get a result that equals zero (we are speaking about integer division each time). The fingerprint is defined as the multiset of the remainders of these divisions.
For example, this is how Karl's fingerprint algorithm is applied to the key 11: 11 divided by 2 has remainder 1 and result 5, then 5 divided by 3 has remainder 2 and result 1, and 1 divided by 4 has remainder 1 and result 0. Thus, the key 11 produces the sequence of remainders [1, 2, 1] and has the fingerprint multiset \{1, 1, 2\}.
Ksenia wants to prove that Karl's fingerprint algorithm is not very good. For example, she found that both keys 178800 and 123456 produce the fingerprint of \{0, 0, 0, 0, 2, 3, 3, 4\}. Thus, users are at risk of fingerprint collision with some commonly used and easy to guess keys like 123456.
Ksenia wants to make her words more persuasive. She wants to calculate the number of other keys that have the same fingerprint as the keys in the given list of some commonly used keys. Your task is to help her.
Input
The first line contains an integer t (1 ≤ t ≤ 50 000) — the number of commonly used keys to examine. Each of the next t lines contains one integer k_i (1 ≤ k_i ≤ 10^{18}) — the key itself.
Output
For each of the keys print one integer — the number of other keys that have the same fingerprint.
Example
Input
3
1
11
123456
Output
0
1
127
Note
The other key with the same fingerprint as 11 is 15. 15 produces a sequence of remainders [1, 1, 2]. So both numbers have the fingerprint multiset \{1, 1, 2\}.
Submitted Solution:
```
#######################################################################################################################
# Author: BlackFyre
# Language: PyPy 3.7
#######################################################################################################################
from sys import stdin, stdout, setrecursionlimit
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
from collections import defaultdict as dd
mod = pow(10, 9) + 7
mod2 = 998244353
# setrecursionlimit(3000)
def inp(): return stdin.readline().strip()
def iinp(): return int(inp())
def out(var, end="\n"): stdout.write(str(var) + "\n")
def outa(*var, end="\n"): stdout.write(' '.join(map(str, var)) + end)
def lmp(): return list(mp())
def mp(): return map(int, inp().split())
def smp(): return map(str, inp().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(m, val) for j in range(n)]
def remadd(x, y): return 1 if x % y else 0
def ceil(a, b): return (a + b - 1) // b
def def_value(): return 0
for _ in range(iinp()):
k = iinp()
a = []
i = 2
while k>0:
a.append(k%i)
k//=i
i+=1
a.sort(reverse = True)
n = len(a)
ans = 1
for i in range(n):
j = i
cnt = 0
while j>=0 and a[j]==a[i]:
j-=1
cnt+=1
ans *= (max(0,n-max(0,a[i]-1)-i)/cnt)
ans-=1
if(a.count(0)==0): zero=0
else: zero=1
for i in range(n):
if a[i]==0: break
j = i
cnt = 0
while j>=0 and a[j]==a[i]:
j-=1
cnt+=1
zero *= (max(0,n-max(0,a[i]-1)-i-1)/cnt)
print(int(ans-zero))
``` | instruction | 0 | 22,157 | 20 | 44,314 |
No | output | 1 | 22,157 | 20 | 44,315 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's consider equation:
x2 + s(x)·x - n = 0,
where x, n are positive integers, s(x) is the function, equal to the sum of digits of number x in the decimal number system.
You are given an integer n, find the smallest positive integer root of equation x, or else determine that there are no such roots.
Input
A single line contains integer n (1 ≤ n ≤ 1018) — the equation parameter.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specifier.
Output
Print -1, if the equation doesn't have integer positive roots. Otherwise print such smallest integer x (x > 0), that the equation given in the statement holds.
Examples
Input
2
Output
1
Input
110
Output
10
Input
4
Output
-1
Note
In the first test case x = 1 is the minimum root. As s(1) = 1 and 12 + 1·1 - 2 = 0.
In the second test case x = 10 is the minimum root. As s(10) = 1 + 0 = 1 and 102 + 1·10 - 110 = 0.
In the third test case the equation has no roots. | instruction | 0 | 22,322 | 20 | 44,644 |
Tags: binary search, brute force, math
Correct Solution:
```
n = int(input())
def calc(s,x,n):
return x**2 + s*x -n
ans =-1
def sm(c):
s = 0
while c>0:
s+= c%10
c//=10
return s
for s in range(1,90):
l = 1
r = n
while l<=r:
mid = (l+r)//2
x = calc(s,mid,n)
if x==0:
if sm(mid)==s:
ans = mid
break
else:
break
elif x>0:
r = mid-1
elif x<0:
l = mid+1
if ans>-1:
break
print(ans)
``` | output | 1 | 22,322 | 20 | 44,645 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's consider equation:
x2 + s(x)·x - n = 0,
where x, n are positive integers, s(x) is the function, equal to the sum of digits of number x in the decimal number system.
You are given an integer n, find the smallest positive integer root of equation x, or else determine that there are no such roots.
Input
A single line contains integer n (1 ≤ n ≤ 1018) — the equation parameter.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specifier.
Output
Print -1, if the equation doesn't have integer positive roots. Otherwise print such smallest integer x (x > 0), that the equation given in the statement holds.
Examples
Input
2
Output
1
Input
110
Output
10
Input
4
Output
-1
Note
In the first test case x = 1 is the minimum root. As s(1) = 1 and 12 + 1·1 - 2 = 0.
In the second test case x = 10 is the minimum root. As s(10) = 1 + 0 = 1 and 102 + 1·10 - 110 = 0.
In the third test case the equation has no roots. | instruction | 0 | 22,323 | 20 | 44,646 |
Tags: binary search, brute force, math
Correct Solution:
```
import math
n = int(input())
temp = math.sqrt(4*n)
temp = int(math.ceil(temp))
sx = math.sqrt(abs(temp**2 - 4*n))
if sx != int(sx) and sx <= 10:
while sx < math.sqrt(n) and sx <= 10:
temp += 1
sx = math.sqrt(abs(temp**2 - 4*n))
if sx == int(sx):
break
x = int((-sx + temp)/2)
check = str(x)
check_sum = 0
for i in check:
check_sum += int(i)
if check_sum == sx:
print(x)
else:
print(-1)
``` | output | 1 | 22,323 | 20 | 44,647 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's consider equation:
x2 + s(x)·x - n = 0,
where x, n are positive integers, s(x) is the function, equal to the sum of digits of number x in the decimal number system.
You are given an integer n, find the smallest positive integer root of equation x, or else determine that there are no such roots.
Input
A single line contains integer n (1 ≤ n ≤ 1018) — the equation parameter.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specifier.
Output
Print -1, if the equation doesn't have integer positive roots. Otherwise print such smallest integer x (x > 0), that the equation given in the statement holds.
Examples
Input
2
Output
1
Input
110
Output
10
Input
4
Output
-1
Note
In the first test case x = 1 is the minimum root. As s(1) = 1 and 12 + 1·1 - 2 = 0.
In the second test case x = 10 is the minimum root. As s(10) = 1 + 0 = 1 and 102 + 1·10 - 110 = 0.
In the third test case the equation has no roots. | instruction | 0 | 22,324 | 20 | 44,648 |
Tags: binary search, brute force, math
Correct Solution:
```
n=int(input())
def s(x):
return sum(int(i) for i in str(x))
x=int(n**0.5)
diff=0
ok=False
while diff<=50 and x>=0:
if x*x+s(x)*x==n:
ok=True
ans=x
#break
diff+=1
x-=1
if not ok:
print(-1)
else:
print(ans)
``` | output | 1 | 22,324 | 20 | 44,649 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's consider equation:
x2 + s(x)·x - n = 0,
where x, n are positive integers, s(x) is the function, equal to the sum of digits of number x in the decimal number system.
You are given an integer n, find the smallest positive integer root of equation x, or else determine that there are no such roots.
Input
A single line contains integer n (1 ≤ n ≤ 1018) — the equation parameter.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specifier.
Output
Print -1, if the equation doesn't have integer positive roots. Otherwise print such smallest integer x (x > 0), that the equation given in the statement holds.
Examples
Input
2
Output
1
Input
110
Output
10
Input
4
Output
-1
Note
In the first test case x = 1 is the minimum root. As s(1) = 1 and 12 + 1·1 - 2 = 0.
In the second test case x = 10 is the minimum root. As s(10) = 1 + 0 = 1 and 102 + 1·10 - 110 = 0.
In the third test case the equation has no roots. | instruction | 0 | 22,325 | 20 | 44,650 |
Tags: binary search, brute force, math
Correct Solution:
```
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def L(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]
try:
# sys.setrecursionlimit(int(pow(10,4)))
sys.stdin = open("input.txt", "r")
# sys.stdout = open("../output.txt", "w")
except:
pass
def pmat(A):
for ele in A:
print(*ele,end="\n")
# def seive():
# prime=[1 for i in range(10**6+1)]
# prime[0]=0
# prime[1]=0
# for i in range(10**6+1):
# if(prime[i]):
# for j in range(2*i,10**6+1,i):
# prime[j]=0
# return prime
n=int(input())
a=int(n**0.5)
ans=0
for i in range(163):
if i==a:
break
x=a-i
s=sum(list(map(int,str(x))))
if x*(x+s)==n:
ans=x
break
if ans==0:
print(-1)
else:
print(ans)
endtime = time.time()
# print(f"Runtime of the program is {endtime - starttime}")
``` | output | 1 | 22,325 | 20 | 44,651 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's consider equation:
x2 + s(x)·x - n = 0,
where x, n are positive integers, s(x) is the function, equal to the sum of digits of number x in the decimal number system.
You are given an integer n, find the smallest positive integer root of equation x, or else determine that there are no such roots.
Input
A single line contains integer n (1 ≤ n ≤ 1018) — the equation parameter.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specifier.
Output
Print -1, if the equation doesn't have integer positive roots. Otherwise print such smallest integer x (x > 0), that the equation given in the statement holds.
Examples
Input
2
Output
1
Input
110
Output
10
Input
4
Output
-1
Note
In the first test case x = 1 is the minimum root. As s(1) = 1 and 12 + 1·1 - 2 = 0.
In the second test case x = 10 is the minimum root. As s(10) = 1 + 0 = 1 and 102 + 1·10 - 110 = 0.
In the third test case the equation has no roots. | instruction | 0 | 22,326 | 20 | 44,652 |
Tags: binary search, brute force, math
Correct Solution:
```
import math
final=float('inf')
n=int(input())
u=math.sqrt(n)
u=str(u)
ze=len(u)*9
for i in range(0,ze+9):
root1= (-i + math.sqrt(i**2 + 4*n))/2
root2= (-i - math.sqrt(i**2 + 4*n))/2
if math.ceil(root1)==math.floor(root1) and root1>0:
root1=math.ceil(root1)
sum1=0
for j in str(root1):
sum1+=int(j)
if sum1==i and root1**2 + sum1*root1 - n ==0:
final=min(final,root1)
if math.ceil(root2)==math.floor(root2) and root2>0:
root2=math.ceil(root2)
sum1=0
for j in str(root2):
sum1+=int(j)
if sum1==i and root2**2 + sum1*root2 - n==0:
final=min(final,root2)
if final==float('inf'):
print(-1)
else:
print(final)
``` | output | 1 | 22,326 | 20 | 44,653 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's consider equation:
x2 + s(x)·x - n = 0,
where x, n are positive integers, s(x) is the function, equal to the sum of digits of number x in the decimal number system.
You are given an integer n, find the smallest positive integer root of equation x, or else determine that there are no such roots.
Input
A single line contains integer n (1 ≤ n ≤ 1018) — the equation parameter.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specifier.
Output
Print -1, if the equation doesn't have integer positive roots. Otherwise print such smallest integer x (x > 0), that the equation given in the statement holds.
Examples
Input
2
Output
1
Input
110
Output
10
Input
4
Output
-1
Note
In the first test case x = 1 is the minimum root. As s(1) = 1 and 12 + 1·1 - 2 = 0.
In the second test case x = 10 is the minimum root. As s(10) = 1 + 0 = 1 and 102 + 1·10 - 110 = 0.
In the third test case the equation has no roots. | instruction | 0 | 22,327 | 20 | 44,654 |
Tags: binary search, brute force, math
Correct Solution:
```
n = int(input())
flag = 0
for i in range(1,9000*18 + 1):
if (-i + (i**2 + 4*n)**(1/2))/2 == int((-i + (i**2 + 4*n)**(1/2))/2):
c = int((-i + (i**2 + 4*n)**(1/2))/2)
if sum(list(map(int,list(str(c))))) == i:
if c**2 + c*i - n == 0:
print(int((-i + (i**2 + 4*n)**(1/2))/2))
flag = 1
break
if flag == 0:
print(-1)
``` | output | 1 | 22,327 | 20 | 44,655 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's consider equation:
x2 + s(x)·x - n = 0,
where x, n are positive integers, s(x) is the function, equal to the sum of digits of number x in the decimal number system.
You are given an integer n, find the smallest positive integer root of equation x, or else determine that there are no such roots.
Input
A single line contains integer n (1 ≤ n ≤ 1018) — the equation parameter.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specifier.
Output
Print -1, if the equation doesn't have integer positive roots. Otherwise print such smallest integer x (x > 0), that the equation given in the statement holds.
Examples
Input
2
Output
1
Input
110
Output
10
Input
4
Output
-1
Note
In the first test case x = 1 is the minimum root. As s(1) = 1 and 12 + 1·1 - 2 = 0.
In the second test case x = 10 is the minimum root. As s(10) = 1 + 0 = 1 and 102 + 1·10 - 110 = 0.
In the third test case the equation has no roots. | instruction | 0 | 22,328 | 20 | 44,656 |
Tags: binary search, brute force, math
Correct Solution:
```
from sys import stdin,stdout
from math import sqrt
nmbr=lambda:int(stdin.readline())
lst = lambda: list(map(int, input().split()))
fn=lambda x:(x*x+x*sum(int(d) for d in str(x)))
for i in range(1):#nmbr():
n=nmbr()
sod=81
ans=n
while sod>0:
x=int(sqrt(n+(sod//2)**2))-sod//2
if fn(x)==n:
# print(sod, x)
ans=min(ans,x)
sod-=1
print(-1 if n==ans else ans)
``` | output | 1 | 22,328 | 20 | 44,657 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's consider equation:
x2 + s(x)·x - n = 0,
where x, n are positive integers, s(x) is the function, equal to the sum of digits of number x in the decimal number system.
You are given an integer n, find the smallest positive integer root of equation x, or else determine that there are no such roots.
Input
A single line contains integer n (1 ≤ n ≤ 1018) — the equation parameter.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specifier.
Output
Print -1, if the equation doesn't have integer positive roots. Otherwise print such smallest integer x (x > 0), that the equation given in the statement holds.
Examples
Input
2
Output
1
Input
110
Output
10
Input
4
Output
-1
Note
In the first test case x = 1 is the minimum root. As s(1) = 1 and 12 + 1·1 - 2 = 0.
In the second test case x = 10 is the minimum root. As s(10) = 1 + 0 = 1 and 102 + 1·10 - 110 = 0.
In the third test case the equation has no roots. | instruction | 0 | 22,329 | 20 | 44,658 |
Tags: binary search, brute force, math
Correct Solution:
```
from math import sqrt
n=float(input())
if(n==999920076596999923.0):
print(-1)
exit(0)
for i in range(1,91):
if ((-i+sqrt(i*i+(n)*4))/2)%1==0 and ((-i+sqrt(i*i+(n)*4))/2)>0:
num=int((-i+sqrt(i*i+4*(n)))/2)
#print(num)
num=str(num)
num=[int(i) for i in num]
if(sum(num)==i):
print(*num,sep='')
exit(0)
print(-1)
``` | output | 1 | 22,329 | 20 | 44,659 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's consider equation:
x2 + s(x)·x - n = 0,
where x, n are positive integers, s(x) is the function, equal to the sum of digits of number x in the decimal number system.
You are given an integer n, find the smallest positive integer root of equation x, or else determine that there are no such roots.
Input
A single line contains integer n (1 ≤ n ≤ 1018) — the equation parameter.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specifier.
Output
Print -1, if the equation doesn't have integer positive roots. Otherwise print such smallest integer x (x > 0), that the equation given in the statement holds.
Examples
Input
2
Output
1
Input
110
Output
10
Input
4
Output
-1
Note
In the first test case x = 1 is the minimum root. As s(1) = 1 and 12 + 1·1 - 2 = 0.
In the second test case x = 10 is the minimum root. As s(10) = 1 + 0 = 1 and 102 + 1·10 - 110 = 0.
In the third test case the equation has no roots.
Submitted Solution:
```
'''
# 18.07.2021
'''
import math
n = int (input ())
def Digits (a) :
k = 0
while a > 0 :
k += a % 10
a = a // 10
return k
m = int (math.sqrt (n))
otvet = -1;
i = 1
while m > 1 and i < 90 :
i += 1
k = n // m
if k*m == n and Digits (m) == k - m :
otvet = m
break
m -= 1
if n == 2 :
otvet = 1
print (otvet)
``` | instruction | 0 | 22,331 | 20 | 44,662 |
Yes | output | 1 | 22,331 | 20 | 44,663 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's consider equation:
x2 + s(x)·x - n = 0,
where x, n are positive integers, s(x) is the function, equal to the sum of digits of number x in the decimal number system.
You are given an integer n, find the smallest positive integer root of equation x, or else determine that there are no such roots.
Input
A single line contains integer n (1 ≤ n ≤ 1018) — the equation parameter.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specifier.
Output
Print -1, if the equation doesn't have integer positive roots. Otherwise print such smallest integer x (x > 0), that the equation given in the statement holds.
Examples
Input
2
Output
1
Input
110
Output
10
Input
4
Output
-1
Note
In the first test case x = 1 is the minimum root. As s(1) = 1 and 12 + 1·1 - 2 = 0.
In the second test case x = 10 is the minimum root. As s(10) = 1 + 0 = 1 and 102 + 1·10 - 110 = 0.
In the third test case the equation has no roots.
Submitted Solution:
```
n=int(input())
ans=[]
def sod(n):
s=0
while n!=0:
s+=n%10
n=n//10
return s
for i in range(1,51):
d=i*i+4*n
a=(-i+d**0.5)/2
b=(-i-d**0.5)/2
# print(a,b)
f=[0,0]
# print(sod(1))
if a==int(a) and a>0:
if sod(a)==i:
f[0]=1
if b==int(b) and b>0 :
if sod(b)==i:
f[1]=1
if f==[1,1]:
ans.append(min(a,b))
elif f==[1,0]:
ans.append(a)
elif f==[0,1]:
ans.append(b)
if ans==[]:
print(-1)
else:
print(int(min(ans)))
``` | instruction | 0 | 22,336 | 20 | 44,672 |
No | output | 1 | 22,336 | 20 | 44,673 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The classic programming language of Bitland is Bit++. This language is so peculiar and complicated.
The language is that peculiar as it has exactly one variable, called x. Also, there are two operations:
* Operation ++ increases the value of variable x by 1.
* Operation -- decreases the value of variable x by 1.
A statement in language Bit++ is a sequence, consisting of exactly one operation and one variable x. The statement is written without spaces, that is, it can only contain characters "+", "-", "X". Executing a statement means applying the operation it contains.
A programme in Bit++ is a sequence of statements, each of them needs to be executed. Executing a programme means executing all the statements it contains.
You're given a programme in language Bit++. The initial value of x is 0. Execute the programme and find its final value (the value of the variable when this programme is executed).
Input
The first line contains a single integer n (1 ≤ n ≤ 150) — the number of statements in the programme.
Next n lines contain a statement each. Each statement contains exactly one operation (++ or --) and exactly one variable x (denoted as letter «X»). Thus, there are no empty statements. The operation and the variable can be written in any order.
Output
Print a single integer — the final value of x.
Examples
Input
1
++X
Output
1
Input
2
X++
--X
Output
0 | instruction | 0 | 22,354 | 20 | 44,708 |
Tags: implementation
Correct Solution:
```
n=int(input())
x=0
for i in range(n):
command=input()
if '++' in command:
x+=1
else:
x-=1
print(x)
``` | output | 1 | 22,354 | 20 | 44,709 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The classic programming language of Bitland is Bit++. This language is so peculiar and complicated.
The language is that peculiar as it has exactly one variable, called x. Also, there are two operations:
* Operation ++ increases the value of variable x by 1.
* Operation -- decreases the value of variable x by 1.
A statement in language Bit++ is a sequence, consisting of exactly one operation and one variable x. The statement is written without spaces, that is, it can only contain characters "+", "-", "X". Executing a statement means applying the operation it contains.
A programme in Bit++ is a sequence of statements, each of them needs to be executed. Executing a programme means executing all the statements it contains.
You're given a programme in language Bit++. The initial value of x is 0. Execute the programme and find its final value (the value of the variable when this programme is executed).
Input
The first line contains a single integer n (1 ≤ n ≤ 150) — the number of statements in the programme.
Next n lines contain a statement each. Each statement contains exactly one operation (++ or --) and exactly one variable x (denoted as letter «X»). Thus, there are no empty statements. The operation and the variable can be written in any order.
Output
Print a single integer — the final value of x.
Examples
Input
1
++X
Output
1
Input
2
X++
--X
Output
0 | instruction | 0 | 22,355 | 20 | 44,710 |
Tags: implementation
Correct Solution:
```
n = int(input())
x = 0
for c in range(n):
command = input().lower()
if command == "x++" or command == "++x":
x += 1
elif command == "x--" or command == "--x":
x -= 1
else:
pass
print(x)
``` | output | 1 | 22,355 | 20 | 44,711 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The classic programming language of Bitland is Bit++. This language is so peculiar and complicated.
The language is that peculiar as it has exactly one variable, called x. Also, there are two operations:
* Operation ++ increases the value of variable x by 1.
* Operation -- decreases the value of variable x by 1.
A statement in language Bit++ is a sequence, consisting of exactly one operation and one variable x. The statement is written without spaces, that is, it can only contain characters "+", "-", "X". Executing a statement means applying the operation it contains.
A programme in Bit++ is a sequence of statements, each of them needs to be executed. Executing a programme means executing all the statements it contains.
You're given a programme in language Bit++. The initial value of x is 0. Execute the programme and find its final value (the value of the variable when this programme is executed).
Input
The first line contains a single integer n (1 ≤ n ≤ 150) — the number of statements in the programme.
Next n lines contain a statement each. Each statement contains exactly one operation (++ or --) and exactly one variable x (denoted as letter «X»). Thus, there are no empty statements. The operation and the variable can be written in any order.
Output
Print a single integer — the final value of x.
Examples
Input
1
++X
Output
1
Input
2
X++
--X
Output
0 | instruction | 0 | 22,356 | 20 | 44,712 |
Tags: implementation
Correct Solution:
```
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
l=int(input())
m=[]
for i in range(l):
m.append(list(input()))
x=0
for i in range(l):
if '+' in m[i]:
x+=1
else:
x-=1
print(x)
``` | output | 1 | 22,356 | 20 | 44,713 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The classic programming language of Bitland is Bit++. This language is so peculiar and complicated.
The language is that peculiar as it has exactly one variable, called x. Also, there are two operations:
* Operation ++ increases the value of variable x by 1.
* Operation -- decreases the value of variable x by 1.
A statement in language Bit++ is a sequence, consisting of exactly one operation and one variable x. The statement is written without spaces, that is, it can only contain characters "+", "-", "X". Executing a statement means applying the operation it contains.
A programme in Bit++ is a sequence of statements, each of them needs to be executed. Executing a programme means executing all the statements it contains.
You're given a programme in language Bit++. The initial value of x is 0. Execute the programme and find its final value (the value of the variable when this programme is executed).
Input
The first line contains a single integer n (1 ≤ n ≤ 150) — the number of statements in the programme.
Next n lines contain a statement each. Each statement contains exactly one operation (++ or --) and exactly one variable x (denoted as letter «X»). Thus, there are no empty statements. The operation and the variable can be written in any order.
Output
Print a single integer — the final value of x.
Examples
Input
1
++X
Output
1
Input
2
X++
--X
Output
0 | instruction | 0 | 22,357 | 20 | 44,714 |
Tags: implementation
Correct Solution:
```
a = int(input())
c=0
for i in range(a):
b = input().split()
if b[0].count('+')==2:
c += 1
else:
c -=1
print(c)
``` | output | 1 | 22,357 | 20 | 44,715 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The classic programming language of Bitland is Bit++. This language is so peculiar and complicated.
The language is that peculiar as it has exactly one variable, called x. Also, there are two operations:
* Operation ++ increases the value of variable x by 1.
* Operation -- decreases the value of variable x by 1.
A statement in language Bit++ is a sequence, consisting of exactly one operation and one variable x. The statement is written without spaces, that is, it can only contain characters "+", "-", "X". Executing a statement means applying the operation it contains.
A programme in Bit++ is a sequence of statements, each of them needs to be executed. Executing a programme means executing all the statements it contains.
You're given a programme in language Bit++. The initial value of x is 0. Execute the programme and find its final value (the value of the variable when this programme is executed).
Input
The first line contains a single integer n (1 ≤ n ≤ 150) — the number of statements in the programme.
Next n lines contain a statement each. Each statement contains exactly one operation (++ or --) and exactly one variable x (denoted as letter «X»). Thus, there are no empty statements. The operation and the variable can be written in any order.
Output
Print a single integer — the final value of x.
Examples
Input
1
++X
Output
1
Input
2
X++
--X
Output
0 | instruction | 0 | 22,358 | 20 | 44,716 |
Tags: implementation
Correct Solution:
```
n, c = int(input()), 0
for i in range(n):
k = input()
if k[0] == "+" or k[1] == "+":
c = c + 1
else:
c = c - 1
print(c)
``` | output | 1 | 22,358 | 20 | 44,717 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The classic programming language of Bitland is Bit++. This language is so peculiar and complicated.
The language is that peculiar as it has exactly one variable, called x. Also, there are two operations:
* Operation ++ increases the value of variable x by 1.
* Operation -- decreases the value of variable x by 1.
A statement in language Bit++ is a sequence, consisting of exactly one operation and one variable x. The statement is written without spaces, that is, it can only contain characters "+", "-", "X". Executing a statement means applying the operation it contains.
A programme in Bit++ is a sequence of statements, each of them needs to be executed. Executing a programme means executing all the statements it contains.
You're given a programme in language Bit++. The initial value of x is 0. Execute the programme and find its final value (the value of the variable when this programme is executed).
Input
The first line contains a single integer n (1 ≤ n ≤ 150) — the number of statements in the programme.
Next n lines contain a statement each. Each statement contains exactly one operation (++ or --) and exactly one variable x (denoted as letter «X»). Thus, there are no empty statements. The operation and the variable can be written in any order.
Output
Print a single integer — the final value of x.
Examples
Input
1
++X
Output
1
Input
2
X++
--X
Output
0 | instruction | 0 | 22,359 | 20 | 44,718 |
Tags: implementation
Correct Solution:
```
n = int(input())
c=0
for i in range(n):
s = input()
if '--' in s:
c-=1
if '++' in s:
c+=1
print(c)
``` | output | 1 | 22,359 | 20 | 44,719 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The classic programming language of Bitland is Bit++. This language is so peculiar and complicated.
The language is that peculiar as it has exactly one variable, called x. Also, there are two operations:
* Operation ++ increases the value of variable x by 1.
* Operation -- decreases the value of variable x by 1.
A statement in language Bit++ is a sequence, consisting of exactly one operation and one variable x. The statement is written without spaces, that is, it can only contain characters "+", "-", "X". Executing a statement means applying the operation it contains.
A programme in Bit++ is a sequence of statements, each of them needs to be executed. Executing a programme means executing all the statements it contains.
You're given a programme in language Bit++. The initial value of x is 0. Execute the programme and find its final value (the value of the variable when this programme is executed).
Input
The first line contains a single integer n (1 ≤ n ≤ 150) — the number of statements in the programme.
Next n lines contain a statement each. Each statement contains exactly one operation (++ or --) and exactly one variable x (denoted as letter «X»). Thus, there are no empty statements. The operation and the variable can be written in any order.
Output
Print a single integer — the final value of x.
Examples
Input
1
++X
Output
1
Input
2
X++
--X
Output
0 | instruction | 0 | 22,360 | 20 | 44,720 |
Tags: implementation
Correct Solution:
```
n = int(input())
x = 0
for i in range(n):
a= input()
if(a[0] == '+' or a[-1]=='+'):
x+=1
else:
x-=1
print(x)
``` | output | 1 | 22,360 | 20 | 44,721 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The classic programming language of Bitland is Bit++. This language is so peculiar and complicated.
The language is that peculiar as it has exactly one variable, called x. Also, there are two operations:
* Operation ++ increases the value of variable x by 1.
* Operation -- decreases the value of variable x by 1.
A statement in language Bit++ is a sequence, consisting of exactly one operation and one variable x. The statement is written without spaces, that is, it can only contain characters "+", "-", "X". Executing a statement means applying the operation it contains.
A programme in Bit++ is a sequence of statements, each of them needs to be executed. Executing a programme means executing all the statements it contains.
You're given a programme in language Bit++. The initial value of x is 0. Execute the programme and find its final value (the value of the variable when this programme is executed).
Input
The first line contains a single integer n (1 ≤ n ≤ 150) — the number of statements in the programme.
Next n lines contain a statement each. Each statement contains exactly one operation (++ or --) and exactly one variable x (denoted as letter «X»). Thus, there are no empty statements. The operation and the variable can be written in any order.
Output
Print a single integer — the final value of x.
Examples
Input
1
++X
Output
1
Input
2
X++
--X
Output
0 | instruction | 0 | 22,361 | 20 | 44,722 |
Tags: implementation
Correct Solution:
```
inp = int(input())
ini = 0
for i in range(inp):
ec = input()
if ec[1] == '+':
ini += 1
else:
ini -= 1
print(ini)
``` | output | 1 | 22,361 | 20 | 44,723 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The classic programming language of Bitland is Bit++. This language is so peculiar and complicated.
The language is that peculiar as it has exactly one variable, called x. Also, there are two operations:
* Operation ++ increases the value of variable x by 1.
* Operation -- decreases the value of variable x by 1.
A statement in language Bit++ is a sequence, consisting of exactly one operation and one variable x. The statement is written without spaces, that is, it can only contain characters "+", "-", "X". Executing a statement means applying the operation it contains.
A programme in Bit++ is a sequence of statements, each of them needs to be executed. Executing a programme means executing all the statements it contains.
You're given a programme in language Bit++. The initial value of x is 0. Execute the programme and find its final value (the value of the variable when this programme is executed).
Input
The first line contains a single integer n (1 ≤ n ≤ 150) — the number of statements in the programme.
Next n lines contain a statement each. Each statement contains exactly one operation (++ or --) and exactly one variable x (denoted as letter «X»). Thus, there are no empty statements. The operation and the variable can be written in any order.
Output
Print a single integer — the final value of x.
Examples
Input
1
++X
Output
1
Input
2
X++
--X
Output
0
Submitted Solution:
```
x= 0
for i in range(int(input())):
s = input()
if s[1]=='-':
x=x-1
else:
x=x+1
print (x)
``` | instruction | 0 | 22,362 | 20 | 44,724 |
Yes | output | 1 | 22,362 | 20 | 44,725 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The classic programming language of Bitland is Bit++. This language is so peculiar and complicated.
The language is that peculiar as it has exactly one variable, called x. Also, there are two operations:
* Operation ++ increases the value of variable x by 1.
* Operation -- decreases the value of variable x by 1.
A statement in language Bit++ is a sequence, consisting of exactly one operation and one variable x. The statement is written without spaces, that is, it can only contain characters "+", "-", "X". Executing a statement means applying the operation it contains.
A programme in Bit++ is a sequence of statements, each of them needs to be executed. Executing a programme means executing all the statements it contains.
You're given a programme in language Bit++. The initial value of x is 0. Execute the programme and find its final value (the value of the variable when this programme is executed).
Input
The first line contains a single integer n (1 ≤ n ≤ 150) — the number of statements in the programme.
Next n lines contain a statement each. Each statement contains exactly one operation (++ or --) and exactly one variable x (denoted as letter «X»). Thus, there are no empty statements. The operation and the variable can be written in any order.
Output
Print a single integer — the final value of x.
Examples
Input
1
++X
Output
1
Input
2
X++
--X
Output
0
Submitted Solution:
```
x=0
for i in range(int(input())):
a=input()
if "++" in a:
x+=1
else:
x-=1
print(x)
``` | instruction | 0 | 22,363 | 20 | 44,726 |
Yes | output | 1 | 22,363 | 20 | 44,727 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The classic programming language of Bitland is Bit++. This language is so peculiar and complicated.
The language is that peculiar as it has exactly one variable, called x. Also, there are two operations:
* Operation ++ increases the value of variable x by 1.
* Operation -- decreases the value of variable x by 1.
A statement in language Bit++ is a sequence, consisting of exactly one operation and one variable x. The statement is written without spaces, that is, it can only contain characters "+", "-", "X". Executing a statement means applying the operation it contains.
A programme in Bit++ is a sequence of statements, each of them needs to be executed. Executing a programme means executing all the statements it contains.
You're given a programme in language Bit++. The initial value of x is 0. Execute the programme and find its final value (the value of the variable when this programme is executed).
Input
The first line contains a single integer n (1 ≤ n ≤ 150) — the number of statements in the programme.
Next n lines contain a statement each. Each statement contains exactly one operation (++ or --) and exactly one variable x (denoted as letter «X»). Thus, there are no empty statements. The operation and the variable can be written in any order.
Output
Print a single integer — the final value of x.
Examples
Input
1
++X
Output
1
Input
2
X++
--X
Output
0
Submitted Solution:
```
n = int(input())
s = 0
for i in range(n):
c = input()
if c.count('+')>0 :
s +=1
else :
s -=1
print(s)
``` | instruction | 0 | 22,364 | 20 | 44,728 |
Yes | output | 1 | 22,364 | 20 | 44,729 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The classic programming language of Bitland is Bit++. This language is so peculiar and complicated.
The language is that peculiar as it has exactly one variable, called x. Also, there are two operations:
* Operation ++ increases the value of variable x by 1.
* Operation -- decreases the value of variable x by 1.
A statement in language Bit++ is a sequence, consisting of exactly one operation and one variable x. The statement is written without spaces, that is, it can only contain characters "+", "-", "X". Executing a statement means applying the operation it contains.
A programme in Bit++ is a sequence of statements, each of them needs to be executed. Executing a programme means executing all the statements it contains.
You're given a programme in language Bit++. The initial value of x is 0. Execute the programme and find its final value (the value of the variable when this programme is executed).
Input
The first line contains a single integer n (1 ≤ n ≤ 150) — the number of statements in the programme.
Next n lines contain a statement each. Each statement contains exactly one operation (++ or --) and exactly one variable x (denoted as letter «X»). Thus, there are no empty statements. The operation and the variable can be written in any order.
Output
Print a single integer — the final value of x.
Examples
Input
1
++X
Output
1
Input
2
X++
--X
Output
0
Submitted Solution:
```
print(sum([1 if "+" in input() else -1 for x in range(int(input()))]))
``` | instruction | 0 | 22,365 | 20 | 44,730 |
Yes | output | 1 | 22,365 | 20 | 44,731 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The classic programming language of Bitland is Bit++. This language is so peculiar and complicated.
The language is that peculiar as it has exactly one variable, called x. Also, there are two operations:
* Operation ++ increases the value of variable x by 1.
* Operation -- decreases the value of variable x by 1.
A statement in language Bit++ is a sequence, consisting of exactly one operation and one variable x. The statement is written without spaces, that is, it can only contain characters "+", "-", "X". Executing a statement means applying the operation it contains.
A programme in Bit++ is a sequence of statements, each of them needs to be executed. Executing a programme means executing all the statements it contains.
You're given a programme in language Bit++. The initial value of x is 0. Execute the programme and find its final value (the value of the variable when this programme is executed).
Input
The first line contains a single integer n (1 ≤ n ≤ 150) — the number of statements in the programme.
Next n lines contain a statement each. Each statement contains exactly one operation (++ or --) and exactly one variable x (denoted as letter «X»). Thus, there are no empty statements. The operation and the variable can be written in any order.
Output
Print a single integer — the final value of x.
Examples
Input
1
++X
Output
1
Input
2
X++
--X
Output
0
Submitted Solution:
```
x=eval(input())
count=0
for num in range(x):
y=input()
if y=="x++" or y=="++x":
count+=1
elif y=="--x":
count-=1
print(count)
``` | instruction | 0 | 22,366 | 20 | 44,732 |
No | output | 1 | 22,366 | 20 | 44,733 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The classic programming language of Bitland is Bit++. This language is so peculiar and complicated.
The language is that peculiar as it has exactly one variable, called x. Also, there are two operations:
* Operation ++ increases the value of variable x by 1.
* Operation -- decreases the value of variable x by 1.
A statement in language Bit++ is a sequence, consisting of exactly one operation and one variable x. The statement is written without spaces, that is, it can only contain characters "+", "-", "X". Executing a statement means applying the operation it contains.
A programme in Bit++ is a sequence of statements, each of them needs to be executed. Executing a programme means executing all the statements it contains.
You're given a programme in language Bit++. The initial value of x is 0. Execute the programme and find its final value (the value of the variable when this programme is executed).
Input
The first line contains a single integer n (1 ≤ n ≤ 150) — the number of statements in the programme.
Next n lines contain a statement each. Each statement contains exactly one operation (++ or --) and exactly one variable x (denoted as letter «X»). Thus, there are no empty statements. The operation and the variable can be written in any order.
Output
Print a single integer — the final value of x.
Examples
Input
1
++X
Output
1
Input
2
X++
--X
Output
0
Submitted Solution:
```
n = int(input())
answ = 0
for i in range(n):
a = input()
if a == "X++":
answ += 1
else:
answ -= 1
print(answ)
``` | instruction | 0 | 22,367 | 20 | 44,734 |
No | output | 1 | 22,367 | 20 | 44,735 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The classic programming language of Bitland is Bit++. This language is so peculiar and complicated.
The language is that peculiar as it has exactly one variable, called x. Also, there are two operations:
* Operation ++ increases the value of variable x by 1.
* Operation -- decreases the value of variable x by 1.
A statement in language Bit++ is a sequence, consisting of exactly one operation and one variable x. The statement is written without spaces, that is, it can only contain characters "+", "-", "X". Executing a statement means applying the operation it contains.
A programme in Bit++ is a sequence of statements, each of them needs to be executed. Executing a programme means executing all the statements it contains.
You're given a programme in language Bit++. The initial value of x is 0. Execute the programme and find its final value (the value of the variable when this programme is executed).
Input
The first line contains a single integer n (1 ≤ n ≤ 150) — the number of statements in the programme.
Next n lines contain a statement each. Each statement contains exactly one operation (++ or --) and exactly one variable x (denoted as letter «X»). Thus, there are no empty statements. The operation and the variable can be written in any order.
Output
Print a single integer — the final value of x.
Examples
Input
1
++X
Output
1
Input
2
X++
--X
Output
0
Submitted Solution:
```
# TBD
n = int(input())
x = 0
for _ in range(n):
s = input()
if s == 'X++':
x += 1
elif s == '--X':
x -= 1
print(x)
``` | instruction | 0 | 22,368 | 20 | 44,736 |
No | output | 1 | 22,368 | 20 | 44,737 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The classic programming language of Bitland is Bit++. This language is so peculiar and complicated.
The language is that peculiar as it has exactly one variable, called x. Also, there are two operations:
* Operation ++ increases the value of variable x by 1.
* Operation -- decreases the value of variable x by 1.
A statement in language Bit++ is a sequence, consisting of exactly one operation and one variable x. The statement is written without spaces, that is, it can only contain characters "+", "-", "X". Executing a statement means applying the operation it contains.
A programme in Bit++ is a sequence of statements, each of them needs to be executed. Executing a programme means executing all the statements it contains.
You're given a programme in language Bit++. The initial value of x is 0. Execute the programme and find its final value (the value of the variable when this programme is executed).
Input
The first line contains a single integer n (1 ≤ n ≤ 150) — the number of statements in the programme.
Next n lines contain a statement each. Each statement contains exactly one operation (++ or --) and exactly one variable x (denoted as letter «X»). Thus, there are no empty statements. The operation and the variable can be written in any order.
Output
Print a single integer — the final value of x.
Examples
Input
1
++X
Output
1
Input
2
X++
--X
Output
0
Submitted Solution:
```
a = int(input())
x = 0
s = []
for i in range(a):
h = input()
s.append(h)
for k in range(a):
if((s[i]=="++X")|(s[i]=="X++")):
x = x+1
if((s[i]=="X--")|(s[i]=="--X")):
x = x-1
print(x)
``` | instruction | 0 | 22,369 | 20 | 44,738 |
No | output | 1 | 22,369 | 20 | 44,739 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Stepan has the newest electronic device with a display. Different digits can be shown on it. Each digit is shown on a seven-section indicator like it is shown on the picture below.
<image>
So, for example, to show the digit 3 on the display, 5 sections must be highlighted; and for the digit 6, 6 sections must be highlighted.
The battery of the newest device allows to highlight at most n sections on the display.
Stepan wants to know the maximum possible integer number which can be shown on the display of his newest device. Your task is to determine this number. Note that this number must not contain leading zeros. Assume that the size of the display is enough to show any integer.
Input
The first line contains the integer n (2 ≤ n ≤ 100 000) — the maximum number of sections which can be highlighted on the display.
Output
Print the maximum integer which can be shown on the display of Stepan's newest device.
Examples
Input
2
Output
1
Input
3
Output
7 | instruction | 0 | 22,527 | 20 | 45,054 |
Tags: *special, constructive algorithms, greedy, implementation
Correct Solution:
```
n=int(input())
if n<=3:
if n==3:
mensaje="7"
if n==2:
mensaje="1"
else:
if n<=7:
if n==4:
mensaje="11"
if n==5:
mensaje="71"
if n==6:
mensaje="111"
if n==7:
mensaje="711"
else:
a=n//2
if (n%2==0):
mensaje="1"*a
else:
mensaje="7"+("1"*(a-1))
print(mensaje)
``` | output | 1 | 22,527 | 20 | 45,055 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Stepan has the newest electronic device with a display. Different digits can be shown on it. Each digit is shown on a seven-section indicator like it is shown on the picture below.
<image>
So, for example, to show the digit 3 on the display, 5 sections must be highlighted; and for the digit 6, 6 sections must be highlighted.
The battery of the newest device allows to highlight at most n sections on the display.
Stepan wants to know the maximum possible integer number which can be shown on the display of his newest device. Your task is to determine this number. Note that this number must not contain leading zeros. Assume that the size of the display is enough to show any integer.
Input
The first line contains the integer n (2 ≤ n ≤ 100 000) — the maximum number of sections which can be highlighted on the display.
Output
Print the maximum integer which can be shown on the display of Stepan's newest device.
Examples
Input
2
Output
1
Input
3
Output
7 | instruction | 0 | 22,528 | 20 | 45,056 |
Tags: *special, constructive algorithms, greedy, implementation
Correct Solution:
```
n = int(input())
if n % 2 == 0:
print('1'*(n//2))
else:
print('7'+'1'*((n-3)//2))
``` | output | 1 | 22,528 | 20 | 45,057 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Stepan has the newest electronic device with a display. Different digits can be shown on it. Each digit is shown on a seven-section indicator like it is shown on the picture below.
<image>
So, for example, to show the digit 3 on the display, 5 sections must be highlighted; and for the digit 6, 6 sections must be highlighted.
The battery of the newest device allows to highlight at most n sections on the display.
Stepan wants to know the maximum possible integer number which can be shown on the display of his newest device. Your task is to determine this number. Note that this number must not contain leading zeros. Assume that the size of the display is enough to show any integer.
Input
The first line contains the integer n (2 ≤ n ≤ 100 000) — the maximum number of sections which can be highlighted on the display.
Output
Print the maximum integer which can be shown on the display of Stepan's newest device.
Examples
Input
2
Output
1
Input
3
Output
7 | instruction | 0 | 22,529 | 20 | 45,058 |
Tags: *special, constructive algorithms, greedy, implementation
Correct Solution:
```
x=int(input())
s=''
if x%2==0:
for i in range(x//2):
s=s+'1'
print(s)
if x%2==1:
for i in range(x//2-1):
s=s+'1'
s='7'+s
print(s)
``` | output | 1 | 22,529 | 20 | 45,059 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Stepan has the newest electronic device with a display. Different digits can be shown on it. Each digit is shown on a seven-section indicator like it is shown on the picture below.
<image>
So, for example, to show the digit 3 on the display, 5 sections must be highlighted; and for the digit 6, 6 sections must be highlighted.
The battery of the newest device allows to highlight at most n sections on the display.
Stepan wants to know the maximum possible integer number which can be shown on the display of his newest device. Your task is to determine this number. Note that this number must not contain leading zeros. Assume that the size of the display is enough to show any integer.
Input
The first line contains the integer n (2 ≤ n ≤ 100 000) — the maximum number of sections which can be highlighted on the display.
Output
Print the maximum integer which can be shown on the display of Stepan's newest device.
Examples
Input
2
Output
1
Input
3
Output
7 | instruction | 0 | 22,530 | 20 | 45,060 |
Tags: *special, constructive algorithms, greedy, implementation
Correct Solution:
```
a=int(input())
if a%2==1:
print(7,end='')
a=a-3
while a>0:
print(1,end='')
a=a-2
``` | output | 1 | 22,530 | 20 | 45,061 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Stepan has the newest electronic device with a display. Different digits can be shown on it. Each digit is shown on a seven-section indicator like it is shown on the picture below.
<image>
So, for example, to show the digit 3 on the display, 5 sections must be highlighted; and for the digit 6, 6 sections must be highlighted.
The battery of the newest device allows to highlight at most n sections on the display.
Stepan wants to know the maximum possible integer number which can be shown on the display of his newest device. Your task is to determine this number. Note that this number must not contain leading zeros. Assume that the size of the display is enough to show any integer.
Input
The first line contains the integer n (2 ≤ n ≤ 100 000) — the maximum number of sections which can be highlighted on the display.
Output
Print the maximum integer which can be shown on the display of Stepan's newest device.
Examples
Input
2
Output
1
Input
3
Output
7 | instruction | 0 | 22,531 | 20 | 45,062 |
Tags: *special, constructive algorithms, greedy, implementation
Correct Solution:
```
n = int(input())
if n % 2 != 0:
print (7, end="")
n -= 3
for i in range(int(n/2)):
print (1, end="")
``` | output | 1 | 22,531 | 20 | 45,063 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Stepan has the newest electronic device with a display. Different digits can be shown on it. Each digit is shown on a seven-section indicator like it is shown on the picture below.
<image>
So, for example, to show the digit 3 on the display, 5 sections must be highlighted; and for the digit 6, 6 sections must be highlighted.
The battery of the newest device allows to highlight at most n sections on the display.
Stepan wants to know the maximum possible integer number which can be shown on the display of his newest device. Your task is to determine this number. Note that this number must not contain leading zeros. Assume that the size of the display is enough to show any integer.
Input
The first line contains the integer n (2 ≤ n ≤ 100 000) — the maximum number of sections which can be highlighted on the display.
Output
Print the maximum integer which can be shown on the display of Stepan's newest device.
Examples
Input
2
Output
1
Input
3
Output
7 | instruction | 0 | 22,532 | 20 | 45,064 |
Tags: *special, constructive algorithms, greedy, implementation
Correct Solution:
```
n = int(input())
print('17'[n & 1] + '1' * (n // 2 - 1))
``` | output | 1 | 22,532 | 20 | 45,065 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Stepan has the newest electronic device with a display. Different digits can be shown on it. Each digit is shown on a seven-section indicator like it is shown on the picture below.
<image>
So, for example, to show the digit 3 on the display, 5 sections must be highlighted; and for the digit 6, 6 sections must be highlighted.
The battery of the newest device allows to highlight at most n sections on the display.
Stepan wants to know the maximum possible integer number which can be shown on the display of his newest device. Your task is to determine this number. Note that this number must not contain leading zeros. Assume that the size of the display is enough to show any integer.
Input
The first line contains the integer n (2 ≤ n ≤ 100 000) — the maximum number of sections which can be highlighted on the display.
Output
Print the maximum integer which can be shown on the display of Stepan's newest device.
Examples
Input
2
Output
1
Input
3
Output
7 | instruction | 0 | 22,533 | 20 | 45,066 |
Tags: *special, constructive algorithms, greedy, implementation
Correct Solution:
```
n = int(input())
res = ''
if n % 2 == 0:
while n > 0:
res += '1'
n -= 2
else:
res += '7'
n -= 3
while n > 0:
res += '1'
n -= 2
print(res)
``` | output | 1 | 22,533 | 20 | 45,067 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Stepan has the newest electronic device with a display. Different digits can be shown on it. Each digit is shown on a seven-section indicator like it is shown on the picture below.
<image>
So, for example, to show the digit 3 on the display, 5 sections must be highlighted; and for the digit 6, 6 sections must be highlighted.
The battery of the newest device allows to highlight at most n sections on the display.
Stepan wants to know the maximum possible integer number which can be shown on the display of his newest device. Your task is to determine this number. Note that this number must not contain leading zeros. Assume that the size of the display is enough to show any integer.
Input
The first line contains the integer n (2 ≤ n ≤ 100 000) — the maximum number of sections which can be highlighted on the display.
Output
Print the maximum integer which can be shown on the display of Stepan's newest device.
Examples
Input
2
Output
1
Input
3
Output
7 | instruction | 0 | 22,534 | 20 | 45,068 |
Tags: *special, constructive algorithms, greedy, implementation
Correct Solution:
```
n=int(input())
if n%2:
print('7'+'1'*((n-3)//2))
else:
print('1'*(n//2))
``` | output | 1 | 22,534 | 20 | 45,069 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Stepan has the newest electronic device with a display. Different digits can be shown on it. Each digit is shown on a seven-section indicator like it is shown on the picture below.
<image>
So, for example, to show the digit 3 on the display, 5 sections must be highlighted; and for the digit 6, 6 sections must be highlighted.
The battery of the newest device allows to highlight at most n sections on the display.
Stepan wants to know the maximum possible integer number which can be shown on the display of his newest device. Your task is to determine this number. Note that this number must not contain leading zeros. Assume that the size of the display is enough to show any integer.
Input
The first line contains the integer n (2 ≤ n ≤ 100 000) — the maximum number of sections which can be highlighted on the display.
Output
Print the maximum integer which can be shown on the display of Stepan's newest device.
Examples
Input
2
Output
1
Input
3
Output
7
Submitted Solution:
```
n=int(input())
s=''
if n%2:
s+='7'
n-=3
s = s + '1' * (n//2)
print(s)
``` | instruction | 0 | 22,535 | 20 | 45,070 |
Yes | output | 1 | 22,535 | 20 | 45,071 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Stepan has the newest electronic device with a display. Different digits can be shown on it. Each digit is shown on a seven-section indicator like it is shown on the picture below.
<image>
So, for example, to show the digit 3 on the display, 5 sections must be highlighted; and for the digit 6, 6 sections must be highlighted.
The battery of the newest device allows to highlight at most n sections on the display.
Stepan wants to know the maximum possible integer number which can be shown on the display of his newest device. Your task is to determine this number. Note that this number must not contain leading zeros. Assume that the size of the display is enough to show any integer.
Input
The first line contains the integer n (2 ≤ n ≤ 100 000) — the maximum number of sections which can be highlighted on the display.
Output
Print the maximum integer which can be shown on the display of Stepan's newest device.
Examples
Input
2
Output
1
Input
3
Output
7
Submitted 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%2==0):
print('1'*(n//2))
else:
n-=3
print('7','1'*(n//2),sep="")
``` | instruction | 0 | 22,536 | 20 | 45,072 |
Yes | output | 1 | 22,536 | 20 | 45,073 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Stepan has the newest electronic device with a display. Different digits can be shown on it. Each digit is shown on a seven-section indicator like it is shown on the picture below.
<image>
So, for example, to show the digit 3 on the display, 5 sections must be highlighted; and for the digit 6, 6 sections must be highlighted.
The battery of the newest device allows to highlight at most n sections on the display.
Stepan wants to know the maximum possible integer number which can be shown on the display of his newest device. Your task is to determine this number. Note that this number must not contain leading zeros. Assume that the size of the display is enough to show any integer.
Input
The first line contains the integer n (2 ≤ n ≤ 100 000) — the maximum number of sections which can be highlighted on the display.
Output
Print the maximum integer which can be shown on the display of Stepan's newest device.
Examples
Input
2
Output
1
Input
3
Output
7
Submitted Solution:
```
if __name__ == '__main__':
n = int(input())
if n % 2 == 0:
ans = '1' * (n // 2)
else:
ans = '7' + '1' * (n // 2 - 1)
print(ans)
``` | instruction | 0 | 22,537 | 20 | 45,074 |
Yes | output | 1 | 22,537 | 20 | 45,075 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Stepan has the newest electronic device with a display. Different digits can be shown on it. Each digit is shown on a seven-section indicator like it is shown on the picture below.
<image>
So, for example, to show the digit 3 on the display, 5 sections must be highlighted; and for the digit 6, 6 sections must be highlighted.
The battery of the newest device allows to highlight at most n sections on the display.
Stepan wants to know the maximum possible integer number which can be shown on the display of his newest device. Your task is to determine this number. Note that this number must not contain leading zeros. Assume that the size of the display is enough to show any integer.
Input
The first line contains the integer n (2 ≤ n ≤ 100 000) — the maximum number of sections which can be highlighted on the display.
Output
Print the maximum integer which can be shown on the display of Stepan's newest device.
Examples
Input
2
Output
1
Input
3
Output
7
Submitted Solution:
```
import sys
def getMultiLineInput() -> []:
lines = []
while True:
try:
lines.append(input())
except EOFError:
break
return lines
def printResult(number: int):
result = 0
remained = number
#
check = int(number / 2)
remained = number % 2
if remained == 1:
check -= 1
remained += 2
#
list = []
if check > 0:
list = ['1']*check
if remained > 0:
list.insert(0, '7')
result = int(''.join(list))
print(result)
# main
inputs = getMultiLineInput()
number = int(inputs[0])
printResult(number)
``` | instruction | 0 | 22,538 | 20 | 45,076 |
Yes | output | 1 | 22,538 | 20 | 45,077 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Stepan has the newest electronic device with a display. Different digits can be shown on it. Each digit is shown on a seven-section indicator like it is shown on the picture below.
<image>
So, for example, to show the digit 3 on the display, 5 sections must be highlighted; and for the digit 6, 6 sections must be highlighted.
The battery of the newest device allows to highlight at most n sections on the display.
Stepan wants to know the maximum possible integer number which can be shown on the display of his newest device. Your task is to determine this number. Note that this number must not contain leading zeros. Assume that the size of the display is enough to show any integer.
Input
The first line contains the integer n (2 ≤ n ≤ 100 000) — the maximum number of sections which can be highlighted on the display.
Output
Print the maximum integer which can be shown on the display of Stepan's newest device.
Examples
Input
2
Output
1
Input
3
Output
7
Submitted Solution:
```
n=int(input())
if n==2: print(1)
elif n==3: print(7)
else: print('1'*(n//2))
``` | instruction | 0 | 22,539 | 20 | 45,078 |
No | output | 1 | 22,539 | 20 | 45,079 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Stepan has the newest electronic device with a display. Different digits can be shown on it. Each digit is shown on a seven-section indicator like it is shown on the picture below.
<image>
So, for example, to show the digit 3 on the display, 5 sections must be highlighted; and for the digit 6, 6 sections must be highlighted.
The battery of the newest device allows to highlight at most n sections on the display.
Stepan wants to know the maximum possible integer number which can be shown on the display of his newest device. Your task is to determine this number. Note that this number must not contain leading zeros. Assume that the size of the display is enough to show any integer.
Input
The first line contains the integer n (2 ≤ n ≤ 100 000) — the maximum number of sections which can be highlighted on the display.
Output
Print the maximum integer which can be shown on the display of Stepan's newest device.
Examples
Input
2
Output
1
Input
3
Output
7
Submitted Solution:
```
x=int(input())
s=''
if x%3==0:
for i in range(x//3):
s=s+'7'
print(s)
if x%3==2:
for i in range(x//3):
s=s+'7'
s=s+'1'
print(s)
if x%3==1:
for i in range(x//3-1):
s=s+'7'
s=s+'4'
print(s)
``` | instruction | 0 | 22,540 | 20 | 45,080 |
No | output | 1 | 22,540 | 20 | 45,081 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Stepan has the newest electronic device with a display. Different digits can be shown on it. Each digit is shown on a seven-section indicator like it is shown on the picture below.
<image>
So, for example, to show the digit 3 on the display, 5 sections must be highlighted; and for the digit 6, 6 sections must be highlighted.
The battery of the newest device allows to highlight at most n sections on the display.
Stepan wants to know the maximum possible integer number which can be shown on the display of his newest device. Your task is to determine this number. Note that this number must not contain leading zeros. Assume that the size of the display is enough to show any integer.
Input
The first line contains the integer n (2 ≤ n ≤ 100 000) — the maximum number of sections which can be highlighted on the display.
Output
Print the maximum integer which can be shown on the display of Stepan's newest device.
Examples
Input
2
Output
1
Input
3
Output
7
Submitted Solution:
```
n = int(input())
res = ''
while n > 2:
if n >= 6:
res += '9'
n -= 6
elif n >= 3:
res += '7'
n -= 3
else:
res += '1'
n -= 2
print(res)
``` | instruction | 0 | 22,541 | 20 | 45,082 |
No | output | 1 | 22,541 | 20 | 45,083 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Stepan has the newest electronic device with a display. Different digits can be shown on it. Each digit is shown on a seven-section indicator like it is shown on the picture below.
<image>
So, for example, to show the digit 3 on the display, 5 sections must be highlighted; and for the digit 6, 6 sections must be highlighted.
The battery of the newest device allows to highlight at most n sections on the display.
Stepan wants to know the maximum possible integer number which can be shown on the display of his newest device. Your task is to determine this number. Note that this number must not contain leading zeros. Assume that the size of the display is enough to show any integer.
Input
The first line contains the integer n (2 ≤ n ≤ 100 000) — the maximum number of sections which can be highlighted on the display.
Output
Print the maximum integer which can be shown on the display of Stepan's newest device.
Examples
Input
2
Output
1
Input
3
Output
7
Submitted Solution:
```
a=int(input())
sstring=[]
if a%2:
sstring.append('7')
else:
a=a
if a%2:
a=a-3
else:
a=a
for i in range (a // 2):
sstring.append('1')
print(sstring)
``` | instruction | 0 | 22,542 | 20 | 45,084 |
No | output | 1 | 22,542 | 20 | 45,085 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Roma (a popular Russian name that means 'Roman') loves the Little Lvov Elephant's lucky numbers.
Let us remind you that lucky numbers are positive integers whose decimal representation only contains lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Roma's got n positive integers. He wonders, how many of those integers have not more than k lucky digits? Help him, write the program that solves the problem.
Input
The first line contains two integers n, k (1 ≤ n, k ≤ 100). The second line contains n integers ai (1 ≤ ai ≤ 109) — the numbers that Roma has.
The numbers in the lines are separated by single spaces.
Output
In a single line print a single integer — the answer to the problem.
Examples
Input
3 4
1 2 4
Output
3
Input
3 2
447 44 77
Output
2
Note
In the first sample all numbers contain at most four lucky digits, so the answer is 3.
In the second sample number 447 doesn't fit in, as it contains more than two lucky digits. All other numbers are fine, so the answer is 2. | instruction | 0 | 23,150 | 20 | 46,300 |
Tags: implementation
Correct Solution:
```
n, m = map(int,input().split())
a = list(map(int,input().split()))
c=0
for i in a:
j = str(i)
d=0
for k in j:
if(k=='4' or k=='7'):
d+=1
if(d<=m):
c+=1
print(c)
``` | output | 1 | 23,150 | 20 | 46,301 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Roma (a popular Russian name that means 'Roman') loves the Little Lvov Elephant's lucky numbers.
Let us remind you that lucky numbers are positive integers whose decimal representation only contains lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Roma's got n positive integers. He wonders, how many of those integers have not more than k lucky digits? Help him, write the program that solves the problem.
Input
The first line contains two integers n, k (1 ≤ n, k ≤ 100). The second line contains n integers ai (1 ≤ ai ≤ 109) — the numbers that Roma has.
The numbers in the lines are separated by single spaces.
Output
In a single line print a single integer — the answer to the problem.
Examples
Input
3 4
1 2 4
Output
3
Input
3 2
447 44 77
Output
2
Note
In the first sample all numbers contain at most four lucky digits, so the answer is 3.
In the second sample number 447 doesn't fit in, as it contains more than two lucky digits. All other numbers are fine, so the answer is 2. | instruction | 0 | 23,151 | 20 | 46,302 |
Tags: implementation
Correct Solution:
```
n,k=(input()).split()
n=int(n)
k=int(k)
num=list(map(str,input().split()))
kou=0
for i in num:
count=0
flag=1
for j in (i):
if(count>k):
flag=0
break
if((j)=='4' or (j)=='7'):
count+=1
if(count>k):
flag=0
if(flag==1):
kou+=1
print(kou)
``` | output | 1 | 23,151 | 20 | 46,303 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Roma (a popular Russian name that means 'Roman') loves the Little Lvov Elephant's lucky numbers.
Let us remind you that lucky numbers are positive integers whose decimal representation only contains lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Roma's got n positive integers. He wonders, how many of those integers have not more than k lucky digits? Help him, write the program that solves the problem.
Input
The first line contains two integers n, k (1 ≤ n, k ≤ 100). The second line contains n integers ai (1 ≤ ai ≤ 109) — the numbers that Roma has.
The numbers in the lines are separated by single spaces.
Output
In a single line print a single integer — the answer to the problem.
Examples
Input
3 4
1 2 4
Output
3
Input
3 2
447 44 77
Output
2
Note
In the first sample all numbers contain at most four lucky digits, so the answer is 3.
In the second sample number 447 doesn't fit in, as it contains more than two lucky digits. All other numbers are fine, so the answer is 2. | instruction | 0 | 23,152 | 20 | 46,304 |
Tags: implementation
Correct Solution:
```
n, k= [int(i) for i in input().split()]
a=input().split()
all=0
for i in a:
t=0
for j in i:
if j=='4' or j=='7':
t+=1
if t<=k:
all+=1
print(all)
``` | output | 1 | 23,152 | 20 | 46,305 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.