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.
Decimal numbers are a common notation system currently in use and use ten symbols 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 to represent all numbers.
Binary numbers are a popular notation in the computer world and use two symbols, 0 and 1, to represent all numbers.
Only the four numbers 0, 1, 2, and 3 are used in quaternary numbers. In quaternary numbers, when the number is incremented from 0, it will be carried to the next digit when it reaches 4. Therefore, the decimal number 4 is carried to the expression "10".
Decimal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | ...
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |- ---
Binary | 0 | 1 | 10 | 11 | 100 | 101 | 110 | 111 | 1000 | 101 | 1010 | ...
Quadrant | 0 | 1 | 2 | 3 | 10 | 11 | 12 | 13 | 20 | 21 | 22 | ...
In Hawaii, fish and taro were counted between fingers in the old days, so it seems that they used quaternary numbers instead of decimal numbers.
Create a program that converts the integer n input in decimal to decimal and outputs it.
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of -1. One integer n (0 ≤ n ≤ 1000000) is given on one row for each dataset.
The number of datasets does not exceed 2000.
Output
The result of conversion to quaternary number for each input data set is output on one line.
Example
Input
7
4
0
12
10
10000
-1
Output
13
10
0
30
22
2130100
Submitted Solution:
```
import sys
def main():
for line in sys.stdin:
n = int(line)
if n == -1:
break
else:
if n != 0:
hoge = []
while True:
foo = n // 4
bar = n % 4
if foo >= 4:
hoge.append(bar)
n = foo
elif foo < 4:
hoge.append(bar)
hoge.append(foo)
break
hoge.reverse()
hoge = [str(hoge[i]) for i in range(len(hoge))]
fuga = ""
for i in range(len(hoge)):
fuga += hoge[i]
print(fuga)
elif n == 0:
print(n)
if __name__ == "__main__":
main()
``` | instruction | 0 | 41,993 | 20 | 83,986 |
No | output | 1 | 41,993 | 20 | 83,987 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Decimal numbers are a common notation system currently in use and use ten symbols 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 to represent all numbers.
Binary numbers are a popular notation in the computer world and use two symbols, 0 and 1, to represent all numbers.
Only the four numbers 0, 1, 2, and 3 are used in quaternary numbers. In quaternary numbers, when the number is incremented from 0, it will be carried to the next digit when it reaches 4. Therefore, the decimal number 4 is carried to the expression "10".
Decimal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | ...
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |- ---
Binary | 0 | 1 | 10 | 11 | 100 | 101 | 110 | 111 | 1000 | 101 | 1010 | ...
Quadrant | 0 | 1 | 2 | 3 | 10 | 11 | 12 | 13 | 20 | 21 | 22 | ...
In Hawaii, fish and taro were counted between fingers in the old days, so it seems that they used quaternary numbers instead of decimal numbers.
Create a program that converts the integer n input in decimal to decimal and outputs it.
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of -1. One integer n (0 ≤ n ≤ 1000000) is given on one row for each dataset.
The number of datasets does not exceed 2000.
Output
The result of conversion to quaternary number for each input data set is output on one line.
Example
Input
7
4
0
12
10
10000
-1
Output
13
10
0
30
22
2130100
Submitted Solution:
```
import sys
def main():
ds = []
for line in sys.stdin:
n = int(line)
if n != -1:
ds.append(n) #data set
elif n == -1:
for i in range(len(ds)):
if ds[i] != 0:
hoge = []
p = ds[i]
while True:
foo = p // 4
bar = p % 4
if foo >= 4:
hoge.append(bar)
p = foo
elif foo < 4:
hoge.append(bar)
hoge.append(foo)
break
hoge.reverse()
hoge = [str(hoge[i]) for i in range(len(hoge))]
fuga = ""
for j in range(len(hoge)):
fuga += hoge[j]
print(fuga)
elif ds[i] == 0:
print(0)
else:
break
if __name__ == "__main__":
main()
``` | instruction | 0 | 41,994 | 20 | 83,988 |
No | output | 1 | 41,994 | 20 | 83,989 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads an integer and prints sum of its digits.
Input
The input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000.
The input ends with a line including single zero. Your program should not process for this terminal symbol.
Output
For each dataset, print the sum of digits in x.
Example
Input
123
55
1000
0
Output
6
10
1 | instruction | 0 | 42,091 | 20 | 84,182 |
"Correct Solution:
```
while True:
x=input()
if x == '0':
break
print(sum(int(z) for z in x))
``` | output | 1 | 42,091 | 20 | 84,183 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads an integer and prints sum of its digits.
Input
The input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000.
The input ends with a line including single zero. Your program should not process for this terminal symbol.
Output
For each dataset, print the sum of digits in x.
Example
Input
123
55
1000
0
Output
6
10
1 | instruction | 0 | 42,092 | 20 | 84,184 |
"Correct Solution:
```
while True:
a=input()
if a=='0': break
print(sum(int(i) for i in a))
``` | output | 1 | 42,092 | 20 | 84,185 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads an integer and prints sum of its digits.
Input
The input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000.
The input ends with a line including single zero. Your program should not process for this terminal symbol.
Output
For each dataset, print the sum of digits in x.
Example
Input
123
55
1000
0
Output
6
10
1 | instruction | 0 | 42,093 | 20 | 84,186 |
"Correct Solution:
```
while 1:
x=sum(map(int,list(input())))
if x==0:break
print(x)
``` | output | 1 | 42,093 | 20 | 84,187 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads an integer and prints sum of its digits.
Input
The input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000.
The input ends with a line including single zero. Your program should not process for this terminal symbol.
Output
For each dataset, print the sum of digits in x.
Example
Input
123
55
1000
0
Output
6
10
1 | instruction | 0 | 42,094 | 20 | 84,188 |
"Correct Solution:
```
while True:
num = input()
if num[0] == '0':
break
print(sum(map(int, num)))
``` | output | 1 | 42,094 | 20 | 84,189 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads an integer and prints sum of its digits.
Input
The input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000.
The input ends with a line including single zero. Your program should not process for this terminal symbol.
Output
For each dataset, print the sum of digits in x.
Example
Input
123
55
1000
0
Output
6
10
1 | instruction | 0 | 42,095 | 20 | 84,190 |
"Correct Solution:
```
while True:
n = input()
if n == '0':
break
print(sum([int(num) for num in n]))
``` | output | 1 | 42,095 | 20 | 84,191 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads an integer and prints sum of its digits.
Input
The input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000.
The input ends with a line including single zero. Your program should not process for this terminal symbol.
Output
For each dataset, print the sum of digits in x.
Example
Input
123
55
1000
0
Output
6
10
1 | instruction | 0 | 42,096 | 20 | 84,192 |
"Correct Solution:
```
while(True):
s = input()
if s == '0': exit()
print(sum([int(c) for c in s]))
``` | output | 1 | 42,096 | 20 | 84,193 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads an integer and prints sum of its digits.
Input
The input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000.
The input ends with a line including single zero. Your program should not process for this terminal symbol.
Output
For each dataset, print the sum of digits in x.
Example
Input
123
55
1000
0
Output
6
10
1 | instruction | 0 | 42,097 | 20 | 84,194 |
"Correct Solution:
```
while True:
n = sum(map(int, input()))
if n == 0:
break
else:
print(n)
``` | output | 1 | 42,097 | 20 | 84,195 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads an integer and prints sum of its digits.
Input
The input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000.
The input ends with a line including single zero. Your program should not process for this terminal symbol.
Output
For each dataset, print the sum of digits in x.
Example
Input
123
55
1000
0
Output
6
10
1 | instruction | 0 | 42,098 | 20 | 84,196 |
"Correct Solution:
```
while True:
n = list(input())
if n[0] == '0': break
print(sum([int(i) for i in n]))
``` | output | 1 | 42,098 | 20 | 84,197 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which reads an integer and prints sum of its digits.
Input
The input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000.
The input ends with a line including single zero. Your program should not process for this terminal symbol.
Output
For each dataset, print the sum of digits in x.
Example
Input
123
55
1000
0
Output
6
10
1
Submitted Solution:
```
while True:
a = str(input())
if a == '0':
break
b = list(map(int,a))
print(sum(b))
``` | instruction | 0 | 42,099 | 20 | 84,198 |
Yes | output | 1 | 42,099 | 20 | 84,199 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which reads an integer and prints sum of its digits.
Input
The input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000.
The input ends with a line including single zero. Your program should not process for this terminal symbol.
Output
For each dataset, print the sum of digits in x.
Example
Input
123
55
1000
0
Output
6
10
1
Submitted Solution:
```
while True:
a=input()
if a=="0":break
print(sum(map(int,list(a))))
``` | instruction | 0 | 42,100 | 20 | 84,200 |
Yes | output | 1 | 42,100 | 20 | 84,201 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which reads an integer and prints sum of its digits.
Input
The input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000.
The input ends with a line including single zero. Your program should not process for this terminal symbol.
Output
For each dataset, print the sum of digits in x.
Example
Input
123
55
1000
0
Output
6
10
1
Submitted Solution:
```
while True:
s = str(input())
if s == '0': break
ans = 0
for c in s:
ans += int(c)
print(ans)
``` | instruction | 0 | 42,101 | 20 | 84,202 |
Yes | output | 1 | 42,101 | 20 | 84,203 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which reads an integer and prints sum of its digits.
Input
The input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000.
The input ends with a line including single zero. Your program should not process for this terminal symbol.
Output
For each dataset, print the sum of digits in x.
Example
Input
123
55
1000
0
Output
6
10
1
Submitted Solution:
```
while True:
s = input()
if s != '0':
print(sum(map(int, s)))
else:
break
``` | instruction | 0 | 42,102 | 20 | 84,204 |
Yes | output | 1 | 42,102 | 20 | 84,205 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which reads an integer and prints sum of its digits.
Input
The input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000.
The input ends with a line including single zero. Your program should not process for this terminal symbol.
Output
For each dataset, print the sum of digits in x.
Example
Input
123
55
1000
0
Output
6
10
1
Submitted Solution:
```
i = int(input())
sum = 0
while i != 0:
sum += i
i = int(input())
print(sum)
``` | instruction | 0 | 42,103 | 20 | 84,206 |
No | output | 1 | 42,103 | 20 | 84,207 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which reads an integer and prints sum of its digits.
Input
The input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000.
The input ends with a line including single zero. Your program should not process for this terminal symbol.
Output
For each dataset, print the sum of digits in x.
Example
Input
123
55
1000
0
Output
6
10
1
Submitted Solution:
```
a = int(input())
alist = []
if a/1000 >=1:
alist.append(int(a/1000))
if (a-int(a/1000)*1000) / 100 >= 1:
alist.append(int((a-int(a/1000)*1000) / 100))
if (a-int(a/100)) / 10 >= 1:
alist.append(int((a-(int(a/100)*100)) / 10))
alist.append(a-(int(a/10)*10))
a2 = 0
for i in alist:
a2 += i
print(a2)
``` | instruction | 0 | 42,104 | 20 | 84,208 |
No | output | 1 | 42,104 | 20 | 84,209 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which reads an integer and prints sum of its digits.
Input
The input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000.
The input ends with a line including single zero. Your program should not process for this terminal symbol.
Output
For each dataset, print the sum of digits in x.
Example
Input
123
55
1000
0
Output
6
10
1
Submitted Solution:
```
list1 = []
result = 0
while True:
x = str(input())
if x == '0':
break
else:
for i in x:
result += int(i)
list1.append(result)
for i in list1:
print(i)
``` | instruction | 0 | 42,105 | 20 | 84,210 |
No | output | 1 | 42,105 | 20 | 84,211 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which reads an integer and prints sum of its digits.
Input
The input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000.
The input ends with a line including single zero. Your program should not process for this terminal symbol.
Output
For each dataset, print the sum of digits in x.
Example
Input
123
55
1000
0
Output
6
10
1
Submitted Solution:
```
while True:
data = int(input())
if data == 0:
break
sum == 0
while
``` | instruction | 0 | 42,106 | 20 | 84,212 |
No | output | 1 | 42,106 | 20 | 84,213 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given n k-digit integers. You have to rearrange the digits in the integers so that the difference between the largest and the smallest number was minimum. Digits should be rearranged by the same rule in all integers.
Input
The first line contains integers n and k — the number and digit capacity of numbers correspondingly (1 ≤ n, k ≤ 8). Next n lines contain k-digit positive integers. Leading zeroes are allowed both in the initial integers and the integers resulting from the rearranging of digits.
Output
Print a single number: the minimally possible difference between the largest and the smallest number after the digits are rearranged in all integers by the same rule.
Examples
Input
6 4
5237
2753
7523
5723
5327
2537
Output
2700
Input
3 3
010
909
012
Output
3
Input
7 5
50808
36603
37198
44911
29994
42543
50156
Output
20522
Note
In the first sample, if we rearrange the digits in numbers as (3,1,4,2), then the 2-nd and the 4-th numbers will equal 5237 and 2537 correspondingly (they will be maximum and minimum for such order of digits).
In the second sample, if we swap the second digits and the first ones, we get integers 100, 99 and 102.
Submitted Solution:
```
import itertools
n,k=[int(i) for i in input().split()]
comb = list(itertools.permutations(range(k), k))
orig=[]
d=9999999999
for j in range(n):
orig.append(input())
for com in comb:
maxx=0
minn=100000000
for l in orig:
x=''
for z in range(k):
x+=l[com[z]]
if int(x)>maxx:
maxx=int(x)
if int(x)<minn:
minn=int(x)
if d>maxx-minn:
d=maxx-minn
print(d)
``` | instruction | 0 | 42,199 | 20 | 84,398 |
Yes | output | 1 | 42,199 | 20 | 84,399 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given n k-digit integers. You have to rearrange the digits in the integers so that the difference between the largest and the smallest number was minimum. Digits should be rearranged by the same rule in all integers.
Input
The first line contains integers n and k — the number and digit capacity of numbers correspondingly (1 ≤ n, k ≤ 8). Next n lines contain k-digit positive integers. Leading zeroes are allowed both in the initial integers and the integers resulting from the rearranging of digits.
Output
Print a single number: the minimally possible difference between the largest and the smallest number after the digits are rearranged in all integers by the same rule.
Examples
Input
6 4
5237
2753
7523
5723
5327
2537
Output
2700
Input
3 3
010
909
012
Output
3
Input
7 5
50808
36603
37198
44911
29994
42543
50156
Output
20522
Note
In the first sample, if we rearrange the digits in numbers as (3,1,4,2), then the 2-nd and the 4-th numbers will equal 5237 and 2537 correspondingly (they will be maximum and minimum for such order of digits).
In the second sample, if we swap the second digits and the first ones, we get integers 100, 99 and 102.
Submitted Solution:
```
import itertools
import time
def timer(f):
def tmp(*args, **kwargs):
t = time.time()
res = f(*args, **kwargs)
print("Время выполнения функции: %f" % (time.time()-t))
return res
return tmp
def mx(ar, perm):
revs = [rev(ar[i], perm) for i in range(len(array))]
#print(revs)
arr = [int("".join(rr)) for rr in revs]
return max(arr)-min(arr)
def rev(array, perm):
res = ['0']*len(perm)
for i in range(len(perm)):
res[i] = array[perm[i]]
return res
n, k = map(int, input().split(' '))
array = []
for i in range(n):
array.append(input())
null = [0]*k
ps = list(itertools.permutations([str(i) for i in range(k)], k))
perms = []
for i in range(len(ps)):
perms.append([])
for j in range(len(ps[i])):
perms[i].append(int(ps[i][j]))
#print(perms)
#perms = [('0', '1', '3', '2', '4')]
@timer
def machen():
rrr = 100000000000000
for i in range(len(perms)):
value = mx(array, perms[i])
if value<rrr:
rrr = value
return rrr
print(machen())
``` | instruction | 0 | 42,201 | 20 | 84,402 |
No | output | 1 | 42,201 | 20 | 84,403 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Phone number in Berland is a sequence of n digits. Often, to make it easier to memorize the number, it is divided into groups of two or three digits. For example, the phone number 1198733 is easier to remember as 11-987-33. Your task is to find for a given phone number any of its divisions into groups of two or three digits.
Input
The first line contains integer n (2 ≤ n ≤ 100) — amount of digits in the phone number. The second line contains n digits — the phone number to divide into groups.
Output
Output any of divisions of the given phone number into groups of two or three digits. Separate groups by single character -. If the answer is not unique, output any.
Examples
Input
6
549871
Output
54-98-71
Input
7
1198733
Output
11-987-33 | instruction | 0 | 42,377 | 20 | 84,754 |
Tags: implementation
Correct Solution:
```
f = lambda s: s if len(s) <= 3 else s[:2]+'-'+f(s[2:])
input()
print(f(input()))
# Made By Mostafa_Khaled
``` | output | 1 | 42,377 | 20 | 84,755 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Phone number in Berland is a sequence of n digits. Often, to make it easier to memorize the number, it is divided into groups of two or three digits. For example, the phone number 1198733 is easier to remember as 11-987-33. Your task is to find for a given phone number any of its divisions into groups of two or three digits.
Input
The first line contains integer n (2 ≤ n ≤ 100) — amount of digits in the phone number. The second line contains n digits — the phone number to divide into groups.
Output
Output any of divisions of the given phone number into groups of two or three digits. Separate groups by single character -. If the answer is not unique, output any.
Examples
Input
6
549871
Output
54-98-71
Input
7
1198733
Output
11-987-33 | instruction | 0 | 42,378 | 20 | 84,756 |
Tags: implementation
Correct Solution:
```
'''input
2
74
'''
n = int(input())
a = input()
if n == 2 or n == 3:
print(a)
quit()
for x in range(0, n-3, 2):
print(a[x] + a[x+1] + "-", end="")
if n % 2 == 0:
print(a[x+2] + a[x+3])
else:
print(a[x+2:])
``` | output | 1 | 42,378 | 20 | 84,757 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Phone number in Berland is a sequence of n digits. Often, to make it easier to memorize the number, it is divided into groups of two or three digits. For example, the phone number 1198733 is easier to remember as 11-987-33. Your task is to find for a given phone number any of its divisions into groups of two or three digits.
Input
The first line contains integer n (2 ≤ n ≤ 100) — amount of digits in the phone number. The second line contains n digits — the phone number to divide into groups.
Output
Output any of divisions of the given phone number into groups of two or three digits. Separate groups by single character -. If the answer is not unique, output any.
Examples
Input
6
549871
Output
54-98-71
Input
7
1198733
Output
11-987-33 | instruction | 0 | 42,379 | 20 | 84,758 |
Tags: implementation
Correct Solution:
```
cant=int(input())
n = input()
number = ""
twoGroups = cant/2 - 1
if cant%2==1:
twoGroups = int(cant/2) - 1
for i in range(cant):
number+=n[i]
if i%2!=0 and twoGroups>0:
number+="-"
twoGroups -= 1
print(number)
``` | output | 1 | 42,379 | 20 | 84,759 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Phone number in Berland is a sequence of n digits. Often, to make it easier to memorize the number, it is divided into groups of two or three digits. For example, the phone number 1198733 is easier to remember as 11-987-33. Your task is to find for a given phone number any of its divisions into groups of two or three digits.
Input
The first line contains integer n (2 ≤ n ≤ 100) — amount of digits in the phone number. The second line contains n digits — the phone number to divide into groups.
Output
Output any of divisions of the given phone number into groups of two or three digits. Separate groups by single character -. If the answer is not unique, output any.
Examples
Input
6
549871
Output
54-98-71
Input
7
1198733
Output
11-987-33 | instruction | 0 | 42,380 | 20 | 84,760 |
Tags: implementation
Correct Solution:
```
x=int(input())
s=input()
n=0
l=0
j=0
while 1:
if (n+1)%3==0 and n!=0:
if j<(x//2)-1:
print('-',end='')
j+=1
else:
print(s[l],end='')
l+=1
n+=1
if l==x:
break
``` | output | 1 | 42,380 | 20 | 84,761 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Phone number in Berland is a sequence of n digits. Often, to make it easier to memorize the number, it is divided into groups of two or three digits. For example, the phone number 1198733 is easier to remember as 11-987-33. Your task is to find for a given phone number any of its divisions into groups of two or three digits.
Input
The first line contains integer n (2 ≤ n ≤ 100) — amount of digits in the phone number. The second line contains n digits — the phone number to divide into groups.
Output
Output any of divisions of the given phone number into groups of two or three digits. Separate groups by single character -. If the answer is not unique, output any.
Examples
Input
6
549871
Output
54-98-71
Input
7
1198733
Output
11-987-33 | instruction | 0 | 42,381 | 20 | 84,762 |
Tags: implementation
Correct Solution:
```
n = int(input())
st = list(input())
ans = []
while n > 3:
ans.append(st.pop(0))
ans.append(st.pop(0))
ans.append('-')
n -= 2
ans += st
print(''.join(ans))
``` | output | 1 | 42,381 | 20 | 84,763 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Phone number in Berland is a sequence of n digits. Often, to make it easier to memorize the number, it is divided into groups of two or three digits. For example, the phone number 1198733 is easier to remember as 11-987-33. Your task is to find for a given phone number any of its divisions into groups of two or three digits.
Input
The first line contains integer n (2 ≤ n ≤ 100) — amount of digits in the phone number. The second line contains n digits — the phone number to divide into groups.
Output
Output any of divisions of the given phone number into groups of two or three digits. Separate groups by single character -. If the answer is not unique, output any.
Examples
Input
6
549871
Output
54-98-71
Input
7
1198733
Output
11-987-33 | instruction | 0 | 42,382 | 20 | 84,764 |
Tags: implementation
Correct Solution:
```
n=int(input())
s=input()
x=""
if n&1:
for i in range(3):
x+=s[i]
for i in range(3,n,2):
x+="-"+s[i]+s[i+1]
else:
for i in range(0,n,2):
x+=s[i]+s[i+1]+"-"
x=x[:-1]
print(x)
``` | output | 1 | 42,382 | 20 | 84,765 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Phone number in Berland is a sequence of n digits. Often, to make it easier to memorize the number, it is divided into groups of two or three digits. For example, the phone number 1198733 is easier to remember as 11-987-33. Your task is to find for a given phone number any of its divisions into groups of two or three digits.
Input
The first line contains integer n (2 ≤ n ≤ 100) — amount of digits in the phone number. The second line contains n digits — the phone number to divide into groups.
Output
Output any of divisions of the given phone number into groups of two or three digits. Separate groups by single character -. If the answer is not unique, output any.
Examples
Input
6
549871
Output
54-98-71
Input
7
1198733
Output
11-987-33 | instruction | 0 | 42,383 | 20 | 84,766 |
Tags: implementation
Correct Solution:
```
n=int(input())
strr=input()
x=""
if n%2==0:
for i in range(0,n,2):
x=x+strr[i:i+2]+"-"
print(x[:-1])
else:
for i in range(0,n-2,2):
x=x+strr[i:i+2]+"-"
x=x[:-1]
x=x+strr[-1]
print(x)
``` | output | 1 | 42,383 | 20 | 84,767 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Phone number in Berland is a sequence of n digits. Often, to make it easier to memorize the number, it is divided into groups of two or three digits. For example, the phone number 1198733 is easier to remember as 11-987-33. Your task is to find for a given phone number any of its divisions into groups of two or three digits.
Input
The first line contains integer n (2 ≤ n ≤ 100) — amount of digits in the phone number. The second line contains n digits — the phone number to divide into groups.
Output
Output any of divisions of the given phone number into groups of two or three digits. Separate groups by single character -. If the answer is not unique, output any.
Examples
Input
6
549871
Output
54-98-71
Input
7
1198733
Output
11-987-33 | instruction | 0 | 42,384 | 20 | 84,768 |
Tags: implementation
Correct Solution:
```
n=int(input())
s=input()
c=0
k=0
if(n%2==0):
for i in s:
c+=1
print(i,end="")
if(c%2==0 and c!=n):
print("-",end="")
print()
else:
for i in range(len(s)):
c+=1
print(s[i],end="")
if(c%2==0 and c!=n):
if(c!=n-1):
print("-",end="")
k+=1
print()
``` | output | 1 | 42,384 | 20 | 84,769 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Phone number in Berland is a sequence of n digits. Often, to make it easier to memorize the number, it is divided into groups of two or three digits. For example, the phone number 1198733 is easier to remember as 11-987-33. Your task is to find for a given phone number any of its divisions into groups of two or three digits.
Input
The first line contains integer n (2 ≤ n ≤ 100) — amount of digits in the phone number. The second line contains n digits — the phone number to divide into groups.
Output
Output any of divisions of the given phone number into groups of two or three digits. Separate groups by single character -. If the answer is not unique, output any.
Examples
Input
6
549871
Output
54-98-71
Input
7
1198733
Output
11-987-33
Submitted Solution:
```
n=int(input())
s=list(map(int,input()))
res=[]
if n<=3:
print("".join(map(str,s)))
else:
res.append(s[0])
res.append(s[1])
i=2
while (n>i):
if i%2==0 and n-i!=1 :
res.append("-")
res.append(s[i])
i=i+1
print("".join(map(str, res)))
``` | instruction | 0 | 42,385 | 20 | 84,770 |
Yes | output | 1 | 42,385 | 20 | 84,771 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Phone number in Berland is a sequence of n digits. Often, to make it easier to memorize the number, it is divided into groups of two or three digits. For example, the phone number 1198733 is easier to remember as 11-987-33. Your task is to find for a given phone number any of its divisions into groups of two or three digits.
Input
The first line contains integer n (2 ≤ n ≤ 100) — amount of digits in the phone number. The second line contains n digits — the phone number to divide into groups.
Output
Output any of divisions of the given phone number into groups of two or three digits. Separate groups by single character -. If the answer is not unique, output any.
Examples
Input
6
549871
Output
54-98-71
Input
7
1198733
Output
11-987-33
Submitted Solution:
```
n=int(input())
l=[i for i in input()]
i=0
if n%2==0:
while i<n-1:
if i==n-2:
print(l[i]+l[i+1])
else:
print(l[i]+l[i+1],end="-")
i+=2
if n%2!=0:
l2=l[:-3]
i=0
while i<n-1-3:
print(l2[i]+l2[i+1],end="-")
i+=2
print(l[-3]+l[-2]+l[-1])
``` | instruction | 0 | 42,386 | 20 | 84,772 |
Yes | output | 1 | 42,386 | 20 | 84,773 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Phone number in Berland is a sequence of n digits. Often, to make it easier to memorize the number, it is divided into groups of two or three digits. For example, the phone number 1198733 is easier to remember as 11-987-33. Your task is to find for a given phone number any of its divisions into groups of two or three digits.
Input
The first line contains integer n (2 ≤ n ≤ 100) — amount of digits in the phone number. The second line contains n digits — the phone number to divide into groups.
Output
Output any of divisions of the given phone number into groups of two or three digits. Separate groups by single character -. If the answer is not unique, output any.
Examples
Input
6
549871
Output
54-98-71
Input
7
1198733
Output
11-987-33
Submitted Solution:
```
n = int(input())
s = input()
print('-'.join(s[2*i:2*i+2] for i in range(n//2)) + s[-1]*(n%2))
``` | instruction | 0 | 42,387 | 20 | 84,774 |
Yes | output | 1 | 42,387 | 20 | 84,775 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Phone number in Berland is a sequence of n digits. Often, to make it easier to memorize the number, it is divided into groups of two or three digits. For example, the phone number 1198733 is easier to remember as 11-987-33. Your task is to find for a given phone number any of its divisions into groups of two or three digits.
Input
The first line contains integer n (2 ≤ n ≤ 100) — amount of digits in the phone number. The second line contains n digits — the phone number to divide into groups.
Output
Output any of divisions of the given phone number into groups of two or three digits. Separate groups by single character -. If the answer is not unique, output any.
Examples
Input
6
549871
Output
54-98-71
Input
7
1198733
Output
11-987-33
Submitted Solution:
```
n=int(input())
s=input()
if(n==2 or n==3):
print(s)
else:
r=''
if(n%2==1):
r+=s[:3]
for i in range(3,n,2):
r+='-'+s[i:i+2]
print(r)
else:
r+=s[:2]
for i in range(2,n,2):
r+='-'+s[i:i+2]
print(r)
``` | instruction | 0 | 42,388 | 20 | 84,776 |
Yes | output | 1 | 42,388 | 20 | 84,777 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Phone number in Berland is a sequence of n digits. Often, to make it easier to memorize the number, it is divided into groups of two or three digits. For example, the phone number 1198733 is easier to remember as 11-987-33. Your task is to find for a given phone number any of its divisions into groups of two or three digits.
Input
The first line contains integer n (2 ≤ n ≤ 100) — amount of digits in the phone number. The second line contains n digits — the phone number to divide into groups.
Output
Output any of divisions of the given phone number into groups of two or three digits. Separate groups by single character -. If the answer is not unique, output any.
Examples
Input
6
549871
Output
54-98-71
Input
7
1198733
Output
11-987-33
Submitted Solution:
```
import re, sys, math, string, operator, functools, fractions, collections
import os
sys.setrecursionlimit(10**7)
dX= [-1, 1, 0, 0,-1, 1,-1, 1]
dY= [ 0, 0,-1, 1, 1,-1,-1, 1]
RI=lambda: list(map(int,input().split()))
RS=lambda: input().rstrip().split()
mod=1e9+7
#################################################
n=RI()[0]
s=RS()[0]
if n%2==0:
ans=""
else:
ans=s[:3]+'-'
ans+=('-'.join([s[i:i+2] for i in range(3*(n&1),n,2)]))
print(ans)
``` | instruction | 0 | 42,389 | 20 | 84,778 |
No | output | 1 | 42,389 | 20 | 84,779 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Phone number in Berland is a sequence of n digits. Often, to make it easier to memorize the number, it is divided into groups of two or three digits. For example, the phone number 1198733 is easier to remember as 11-987-33. Your task is to find for a given phone number any of its divisions into groups of two or three digits.
Input
The first line contains integer n (2 ≤ n ≤ 100) — amount of digits in the phone number. The second line contains n digits — the phone number to divide into groups.
Output
Output any of divisions of the given phone number into groups of two or three digits. Separate groups by single character -. If the answer is not unique, output any.
Examples
Input
6
549871
Output
54-98-71
Input
7
1198733
Output
11-987-33
Submitted Solution:
```
n = int(input())
digit = input()
if n % 2 == 0 :
lst = []
for i in range(1,n+1):
if i % 2 == 1 and i != 1 and i != n+1:
lst.append('-')
lst.append(digit[i-1])
else :
lst = []
for i in range(n):
if i == 2 :
lst.append('-')
if i > 4 and i % 2 == 1 and i != n:
lst.append('-')
lst.append(digit[i])
ans = "".join(lst)
print(ans)
``` | instruction | 0 | 42,390 | 20 | 84,780 |
No | output | 1 | 42,390 | 20 | 84,781 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Phone number in Berland is a sequence of n digits. Often, to make it easier to memorize the number, it is divided into groups of two or three digits. For example, the phone number 1198733 is easier to remember as 11-987-33. Your task is to find for a given phone number any of its divisions into groups of two or three digits.
Input
The first line contains integer n (2 ≤ n ≤ 100) — amount of digits in the phone number. The second line contains n digits — the phone number to divide into groups.
Output
Output any of divisions of the given phone number into groups of two or three digits. Separate groups by single character -. If the answer is not unique, output any.
Examples
Input
6
549871
Output
54-98-71
Input
7
1198733
Output
11-987-33
Submitted Solution:
```
num = int(input(""))
phonenumber = input("")
print(phonenumber[0:3]+"-"+phonenumber[(3):(num+1)])
``` | instruction | 0 | 42,391 | 20 | 84,782 |
No | output | 1 | 42,391 | 20 | 84,783 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Phone number in Berland is a sequence of n digits. Often, to make it easier to memorize the number, it is divided into groups of two or three digits. For example, the phone number 1198733 is easier to remember as 11-987-33. Your task is to find for a given phone number any of its divisions into groups of two or three digits.
Input
The first line contains integer n (2 ≤ n ≤ 100) — amount of digits in the phone number. The second line contains n digits — the phone number to divide into groups.
Output
Output any of divisions of the given phone number into groups of two or three digits. Separate groups by single character -. If the answer is not unique, output any.
Examples
Input
6
549871
Output
54-98-71
Input
7
1198733
Output
11-987-33
Submitted Solution:
```
n = int(input())
s = input()
while (len(s) > 4):
print (s[0:1], end='')
s = s[2:]
if (len(s) <=3):
print (s)
else:
print (s[0:1], '-', s[2:3])
``` | instruction | 0 | 42,392 | 20 | 84,784 |
No | output | 1 | 42,392 | 20 | 84,785 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Farmer John has just given the cows a program to play with! The program contains two integer variables, x and y, and performs the following operations on a sequence a1, a2, ..., an of positive integers:
1. Initially, x = 1 and y = 0. If, after any step, x ≤ 0 or x > n, the program immediately terminates.
2. The program increases both x and y by a value equal to ax simultaneously.
3. The program now increases y by ax while decreasing x by ax.
4. The program executes steps 2 and 3 (first step 2, then step 3) repeatedly until it terminates (it may never terminate). So, the sequence of executed steps may start with: step 2, step 3, step 2, step 3, step 2 and so on.
The cows are not very good at arithmetic though, and they want to see how the program works. Please help them!
You are given the sequence a2, a3, ..., an. Suppose for each i (1 ≤ i ≤ n - 1) we run the program on the sequence i, a2, a3, ..., an. For each such run output the final value of y if the program terminates or -1 if it does not terminate.
Input
The first line contains a single integer, n (2 ≤ n ≤ 2·105). The next line contains n - 1 space separated integers, a2, a3, ..., an (1 ≤ ai ≤ 109).
Output
Output n - 1 lines. On the i-th line, print the requested value when the program is run on the sequence i, a2, a3, ...an.
Please do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
Examples
Input
4
2 4 1
Output
3
6
8
Input
3
1 2
Output
-1
-1
Note
In the first sample
1. For i = 1, x becomes <image> and y becomes 1 + 2 = 3.
2. For i = 2, x becomes <image> and y becomes 2 + 4 = 6.
3. For i = 3, x becomes <image> and y becomes 3 + 1 + 4 = 8. | instruction | 0 | 42,393 | 20 | 84,786 |
Tags: dfs and similar, dp, graphs
Correct Solution:
```
n = int(input())
t = [0, 0] + list(map(int, input().split()))
a, b = [0] * (n + 1), [0] * (n + 1)
a[1] = b[1] = -1
def f(s, a, b, l):
global t
l.reverse()
j, n = 0, len(l)
while True:
s += t[l[j]]
a[l[j]] = s
j += 1
if j == n: return
s += t[l[j]]
b[l[j]] = s
j += 1
if j == n: return
def g(i, k):
global a, b
l = []
if k:
a[i] = -1
l.append(i)
i += t[i]
while True:
if i > n: return f(0, a, b, l)
if b[i] > 0: return f(b[i], a, b, l)
if b[i] == -1: return
b[i] = -1
l.append(i)
i -= t[i]
if i < 1: return f(0, b, a, l)
if a[i] > 0: return f(a[i], b, a, l)
if a[i] == -1: return
a[i] = -1
l.append(i)
i += t[i]
for i in range(2, n + 1):
if a[i] == 0: g(i, True)
if b[i] == 0: g(i, False)
for i in range(1, n):
if b[i + 1] > 0: t[i] = i + b[i + 1]
else: t[i] = -1
print('\n'.join(map(str, t[1: n])))
``` | output | 1 | 42,393 | 20 | 84,787 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Farmer John has just given the cows a program to play with! The program contains two integer variables, x and y, and performs the following operations on a sequence a1, a2, ..., an of positive integers:
1. Initially, x = 1 and y = 0. If, after any step, x ≤ 0 or x > n, the program immediately terminates.
2. The program increases both x and y by a value equal to ax simultaneously.
3. The program now increases y by ax while decreasing x by ax.
4. The program executes steps 2 and 3 (first step 2, then step 3) repeatedly until it terminates (it may never terminate). So, the sequence of executed steps may start with: step 2, step 3, step 2, step 3, step 2 and so on.
The cows are not very good at arithmetic though, and they want to see how the program works. Please help them!
You are given the sequence a2, a3, ..., an. Suppose for each i (1 ≤ i ≤ n - 1) we run the program on the sequence i, a2, a3, ..., an. For each such run output the final value of y if the program terminates or -1 if it does not terminate.
Input
The first line contains a single integer, n (2 ≤ n ≤ 2·105). The next line contains n - 1 space separated integers, a2, a3, ..., an (1 ≤ ai ≤ 109).
Output
Output n - 1 lines. On the i-th line, print the requested value when the program is run on the sequence i, a2, a3, ...an.
Please do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
Examples
Input
4
2 4 1
Output
3
6
8
Input
3
1 2
Output
-1
-1
Note
In the first sample
1. For i = 1, x becomes <image> and y becomes 1 + 2 = 3.
2. For i = 2, x becomes <image> and y becomes 2 + 4 = 6.
3. For i = 3, x becomes <image> and y becomes 3 + 1 + 4 = 8. | instruction | 0 | 42,394 | 20 | 84,788 |
Tags: dfs and similar, dp, graphs
Correct Solution:
```
n = int(input())
t = [0, 0]
t += list(map(int, input().split()))
n += 1
a = [0] * n
b = [0] * n
n -= 1
a[1] = b[1] = -1
#print(t, a, b)
def calc(s, a, b, l):
global t
l.reverse()
j = 0
n = len(l)
while True:
s += t[l[j]]
a[l[j]] = s
j += 1
if j == n:
return
s += t[l[j]]
b[l[j]] = s
j += 1
if j == n:
return
def calc2(i, k):
global a, b
l = []
if k:
a[i] = -1
l.append(i)
i += t[i]
while True:
if i > n:
return calc(0, a, b, l)
if b[i] > 0:
return calc(b[i], a, b, l)
if b[i] == -1:
return
b[i] = -1
l.append(i)
i -= t[i]
if i < 1:
return calc(0, b, a, l)
if a[i] > 0:
return calc(a[i], b, a, l)
if a[i] == -1:
return
a[i] -= 1
l.append(i)
i += t[i]
for i in range(2, n + 1):
if a[i] == 0:
calc2(i, True)
if b[i] == 0:
calc2(i, False)
for i in range(1, n):
if b[i + 1] > 0:
t[i] = i + b[i + 1]
else:
t[i] = -1
#print(t, a, b)
print('\n'.join(map(str, t[1:n])))
``` | output | 1 | 42,394 | 20 | 84,789 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Farmer John has just given the cows a program to play with! The program contains two integer variables, x and y, and performs the following operations on a sequence a1, a2, ..., an of positive integers:
1. Initially, x = 1 and y = 0. If, after any step, x ≤ 0 or x > n, the program immediately terminates.
2. The program increases both x and y by a value equal to ax simultaneously.
3. The program now increases y by ax while decreasing x by ax.
4. The program executes steps 2 and 3 (first step 2, then step 3) repeatedly until it terminates (it may never terminate). So, the sequence of executed steps may start with: step 2, step 3, step 2, step 3, step 2 and so on.
The cows are not very good at arithmetic though, and they want to see how the program works. Please help them!
You are given the sequence a2, a3, ..., an. Suppose for each i (1 ≤ i ≤ n - 1) we run the program on the sequence i, a2, a3, ..., an. For each such run output the final value of y if the program terminates or -1 if it does not terminate.
Input
The first line contains a single integer, n (2 ≤ n ≤ 2·105). The next line contains n - 1 space separated integers, a2, a3, ..., an (1 ≤ ai ≤ 109).
Output
Output n - 1 lines. On the i-th line, print the requested value when the program is run on the sequence i, a2, a3, ...an.
Please do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
Examples
Input
4
2 4 1
Output
3
6
8
Input
3
1 2
Output
-1
-1
Note
In the first sample
1. For i = 1, x becomes <image> and y becomes 1 + 2 = 3.
2. For i = 2, x becomes <image> and y becomes 2 + 4 = 6.
3. For i = 3, x becomes <image> and y becomes 3 + 1 + 4 = 8. | instruction | 0 | 42,395 | 20 | 84,790 |
Tags: dfs and similar, dp, graphs
Correct Solution:
```
INF = float('inf')
n = int(input())
aaa = [0, 0] + list(map(int, input().split()))
dp = [[0 for _ in range(n+1)] for i in range(2)]
vis = [[0 for _ in range(n+1)] for i in range(2)]
rs = [0] * (n-1)
def di(d): return 0 if d == 1 else 1
def solve(x, d):
if dp[di(d)][x]:
return dp[di(d)][x]
if vis[di(d)][x]:
return INF
ni = x + aaa[x] * d
if ni < 1 or ni > n:
return aaa[x]
vis[di(d)][x] = 1
r = aaa[x] + solve(ni, -d)
vis[di(d)][x] = 0
return r
for D in [1, -1]:
for x in range(2, n+1):
d = D
if dp[di(d)][x]:
continue
ni = x + aaa[x] * d
path = [x]
values = [aaa[x]]
while ni > 1 and ni <= n:
path.append(ni)
if dp[di(-d)][ni]:
values.append(dp[di(-d)][ni])
d *= -1
break
if vis[di(d)][ni]:
values.append(INF)
d *= -1
break
vis[di(d)][ni] = 1
values.append(aaa[ni])
d *= -1
ni = ni + aaa[ni] * d
if ni == 1:
continue
for i in range(len(values)-2, -1, -1):
values[i] = values[i] + values[i+1]
while path:
dp[di(d)][path.pop()] = values.pop()
d *= -1
for i in range(1, n):
aaa[1] = i
res = solve(1, 1)
rs[i-1] = res if res < INF else -1
print('\n'.join(map(str, rs)))
``` | output | 1 | 42,395 | 20 | 84,791 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky digits in it is a lucky number. He wonders whether number n is a nearly lucky number.
Input
The only line contains an integer n (1 ≤ n ≤ 1018).
Please do not use the %lld specificator to read or write 64-bit numbers in С++. It is preferred to use the cin, cout streams or the %I64d specificator.
Output
Print on the single line "YES" if n is a nearly lucky number. Otherwise, print "NO" (without the quotes).
Examples
Input
40047
Output
NO
Input
7747774
Output
YES
Input
1000000000000000000
Output
NO
Note
In the first sample there are 3 lucky digits (first one and last two), so the answer is "NO".
In the second sample there are 7 lucky digits, 7 is lucky number, so the answer is "YES".
In the third sample there are no lucky digits, so the answer is "NO". | instruction | 0 | 42,945 | 20 | 85,890 |
Tags: implementation
Correct Solution:
```
x=input()
c=0
X=[4,7,44,47,74,77,444,447,474,477,744,747,774,777]
for i in x:
if i=='4' or i=='7':
c+=1
if c in X:
print("YES")
else:
print("NO")
``` | output | 1 | 42,945 | 20 | 85,891 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky digits in it is a lucky number. He wonders whether number n is a nearly lucky number.
Input
The only line contains an integer n (1 ≤ n ≤ 1018).
Please do not use the %lld specificator to read or write 64-bit numbers in С++. It is preferred to use the cin, cout streams or the %I64d specificator.
Output
Print on the single line "YES" if n is a nearly lucky number. Otherwise, print "NO" (without the quotes).
Examples
Input
40047
Output
NO
Input
7747774
Output
YES
Input
1000000000000000000
Output
NO
Note
In the first sample there are 3 lucky digits (first one and last two), so the answer is "NO".
In the second sample there are 7 lucky digits, 7 is lucky number, so the answer is "YES".
In the third sample there are no lucky digits, so the answer is "NO". | instruction | 0 | 42,946 | 20 | 85,892 |
Tags: implementation
Correct Solution:
```
n = input()
ctr = 0
for d in n:
if(d=='4' or d=='7'):
ctr+=1
if ctr==4 or ctr==7:
print("YES")
else:
print("NO")
``` | output | 1 | 42,946 | 20 | 85,893 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky digits in it is a lucky number. He wonders whether number n is a nearly lucky number.
Input
The only line contains an integer n (1 ≤ n ≤ 1018).
Please do not use the %lld specificator to read or write 64-bit numbers in С++. It is preferred to use the cin, cout streams or the %I64d specificator.
Output
Print on the single line "YES" if n is a nearly lucky number. Otherwise, print "NO" (without the quotes).
Examples
Input
40047
Output
NO
Input
7747774
Output
YES
Input
1000000000000000000
Output
NO
Note
In the first sample there are 3 lucky digits (first one and last two), so the answer is "NO".
In the second sample there are 7 lucky digits, 7 is lucky number, so the answer is "YES".
In the third sample there are no lucky digits, so the answer is "NO". | instruction | 0 | 42,947 | 20 | 85,894 |
Tags: implementation
Correct Solution:
```
s=input()
count=0
for _ in range(0,len(s)):
if(s[_]=='4' or s[_]=='7'):
count+=1
flag=0 if count !=0 else 1
while(count!=0):
if(count%10==4 or count%10==7):
count=count//10
continue
else:
flag=1
break
if flag==0:
print("YES")
else:
print("NO")
``` | output | 1 | 42,947 | 20 | 85,895 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky digits in it is a lucky number. He wonders whether number n is a nearly lucky number.
Input
The only line contains an integer n (1 ≤ n ≤ 1018).
Please do not use the %lld specificator to read or write 64-bit numbers in С++. It is preferred to use the cin, cout streams or the %I64d specificator.
Output
Print on the single line "YES" if n is a nearly lucky number. Otherwise, print "NO" (without the quotes).
Examples
Input
40047
Output
NO
Input
7747774
Output
YES
Input
1000000000000000000
Output
NO
Note
In the first sample there are 3 lucky digits (first one and last two), so the answer is "NO".
In the second sample there are 7 lucky digits, 7 is lucky number, so the answer is "YES".
In the third sample there are no lucky digits, so the answer is "NO". | instruction | 0 | 42,948 | 20 | 85,896 |
Tags: implementation
Correct Solution:
```
# cook your dish here
s=input()
c=0
for i in range(len(s)):
if s[i]=='4' or s[i]=='7':
c+=1
if c==4 or c==7:
print("YES")
else:
print("NO")
``` | output | 1 | 42,948 | 20 | 85,897 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky digits in it is a lucky number. He wonders whether number n is a nearly lucky number.
Input
The only line contains an integer n (1 ≤ n ≤ 1018).
Please do not use the %lld specificator to read or write 64-bit numbers in С++. It is preferred to use the cin, cout streams or the %I64d specificator.
Output
Print on the single line "YES" if n is a nearly lucky number. Otherwise, print "NO" (without the quotes).
Examples
Input
40047
Output
NO
Input
7747774
Output
YES
Input
1000000000000000000
Output
NO
Note
In the first sample there are 3 lucky digits (first one and last two), so the answer is "NO".
In the second sample there are 7 lucky digits, 7 is lucky number, so the answer is "YES".
In the third sample there are no lucky digits, so the answer is "NO". | instruction | 0 | 42,949 | 20 | 85,898 |
Tags: implementation
Correct Solution:
```
lucky_num = 0
##check if even
#[int(i) for i in str(12345)
#def check_lucky_boi(num):
#for x in num:
#if x == "4" or x == "7":
#continue
#else:
#return False
#return True
def nearlylucky(num):
count = 0
for i in num:
if i == "4" or i == "7":
count += 1
if count == 4 or count == 7:
return True
else:
return False
lucky_num = input()
#answer = check_lucky_boi(lucky_num)
#if answer == False:
answer = nearlylucky(lucky_num)
if answer == True:
print("YES")
else:
print("NO")
``` | output | 1 | 42,949 | 20 | 85,899 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky digits in it is a lucky number. He wonders whether number n is a nearly lucky number.
Input
The only line contains an integer n (1 ≤ n ≤ 1018).
Please do not use the %lld specificator to read or write 64-bit numbers in С++. It is preferred to use the cin, cout streams or the %I64d specificator.
Output
Print on the single line "YES" if n is a nearly lucky number. Otherwise, print "NO" (without the quotes).
Examples
Input
40047
Output
NO
Input
7747774
Output
YES
Input
1000000000000000000
Output
NO
Note
In the first sample there are 3 lucky digits (first one and last two), so the answer is "NO".
In the second sample there are 7 lucky digits, 7 is lucky number, so the answer is "YES".
In the third sample there are no lucky digits, so the answer is "NO". | instruction | 0 | 42,950 | 20 | 85,900 |
Tags: implementation
Correct Solution:
```
s=input()
c=0
for i in s:
if(i=='4' or i=='7'):
c+=1
if(c==4 or c==7 or c==44 or c==47 or c==74 or c==77):
print("YES")
else:
print("NO")
``` | output | 1 | 42,950 | 20 | 85,901 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky digits in it is a lucky number. He wonders whether number n is a nearly lucky number.
Input
The only line contains an integer n (1 ≤ n ≤ 1018).
Please do not use the %lld specificator to read or write 64-bit numbers in С++. It is preferred to use the cin, cout streams or the %I64d specificator.
Output
Print on the single line "YES" if n is a nearly lucky number. Otherwise, print "NO" (without the quotes).
Examples
Input
40047
Output
NO
Input
7747774
Output
YES
Input
1000000000000000000
Output
NO
Note
In the first sample there are 3 lucky digits (first one and last two), so the answer is "NO".
In the second sample there are 7 lucky digits, 7 is lucky number, so the answer is "YES".
In the third sample there are no lucky digits, so the answer is "NO". | instruction | 0 | 42,951 | 20 | 85,902 |
Tags: implementation
Correct Solution:
```
n=int(input())
y=n
c=0
z=n
count=1
while z>9:
z=z//10
count+=1
for i in range(count):
r=y%10
y=y//10
if r==4 or r==7:
c+=1
if c==7 or c==4:
print("YES")
else:
print("NO")
``` | output | 1 | 42,951 | 20 | 85,903 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky digits in it is a lucky number. He wonders whether number n is a nearly lucky number.
Input
The only line contains an integer n (1 ≤ n ≤ 1018).
Please do not use the %lld specificator to read or write 64-bit numbers in С++. It is preferred to use the cin, cout streams or the %I64d specificator.
Output
Print on the single line "YES" if n is a nearly lucky number. Otherwise, print "NO" (without the quotes).
Examples
Input
40047
Output
NO
Input
7747774
Output
YES
Input
1000000000000000000
Output
NO
Note
In the first sample there are 3 lucky digits (first one and last two), so the answer is "NO".
In the second sample there are 7 lucky digits, 7 is lucky number, so the answer is "YES".
In the third sample there are no lucky digits, so the answer is "NO". | instruction | 0 | 42,952 | 20 | 85,904 |
Tags: implementation
Correct Solution:
```
def islucky(num):
num1=str(num)
for j in num1:
if j=='4' or j=='7':
flag=1
else:
flag=0
if flag==0:
return False
elif flag==1:
return True
n=input()
fcount=0
scount=0
for i in n:
if i=='4':
fcount+=1
elif i=='7':
scount+=1
tcount=scount+fcount
if islucky(tcount) is True:
print("YES")
else:
print("NO")
``` | output | 1 | 42,952 | 20 | 85,905 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky digits in it is a lucky number. He wonders whether number n is a nearly lucky number.
Input
The only line contains an integer n (1 ≤ n ≤ 1018).
Please do not use the %lld specificator to read or write 64-bit numbers in С++. It is preferred to use the cin, cout streams or the %I64d specificator.
Output
Print on the single line "YES" if n is a nearly lucky number. Otherwise, print "NO" (without the quotes).
Examples
Input
40047
Output
NO
Input
7747774
Output
YES
Input
1000000000000000000
Output
NO
Note
In the first sample there are 3 lucky digits (first one and last two), so the answer is "NO".
In the second sample there are 7 lucky digits, 7 is lucky number, so the answer is "YES".
In the third sample there are no lucky digits, so the answer is "NO".
Submitted Solution:
```
# https://codeforces.com/problemset/problem/110/A
def isAlmostLucky(s):
cnt = 0
for i in range(len(s)):
if s[i] == '4' or s[i] == '7':
cnt += 1
st = str(cnt)
for j in range(len(st)):
if st[j] != '4' and st[j] != '7':
return 'NO'
return 'YES'
print(isAlmostLucky(input()))
``` | instruction | 0 | 42,953 | 20 | 85,906 |
Yes | output | 1 | 42,953 | 20 | 85,907 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky digits in it is a lucky number. He wonders whether number n is a nearly lucky number.
Input
The only line contains an integer n (1 ≤ n ≤ 1018).
Please do not use the %lld specificator to read or write 64-bit numbers in С++. It is preferred to use the cin, cout streams or the %I64d specificator.
Output
Print on the single line "YES" if n is a nearly lucky number. Otherwise, print "NO" (without the quotes).
Examples
Input
40047
Output
NO
Input
7747774
Output
YES
Input
1000000000000000000
Output
NO
Note
In the first sample there are 3 lucky digits (first one and last two), so the answer is "NO".
In the second sample there are 7 lucky digits, 7 is lucky number, so the answer is "YES".
In the third sample there are no lucky digits, so the answer is "NO".
Submitted Solution:
```
a=input()
cnt=0
for i in range(len(a)):
if a[i]=='4' or a[i]=='7':
cnt+=1
if cnt==4 or cnt==7:
print('YES')
else:
print('NO')
``` | instruction | 0 | 42,954 | 20 | 85,908 |
Yes | output | 1 | 42,954 | 20 | 85,909 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky digits in it is a lucky number. He wonders whether number n is a nearly lucky number.
Input
The only line contains an integer n (1 ≤ n ≤ 1018).
Please do not use the %lld specificator to read or write 64-bit numbers in С++. It is preferred to use the cin, cout streams or the %I64d specificator.
Output
Print on the single line "YES" if n is a nearly lucky number. Otherwise, print "NO" (without the quotes).
Examples
Input
40047
Output
NO
Input
7747774
Output
YES
Input
1000000000000000000
Output
NO
Note
In the first sample there are 3 lucky digits (first one and last two), so the answer is "NO".
In the second sample there are 7 lucky digits, 7 is lucky number, so the answer is "YES".
In the third sample there are no lucky digits, so the answer is "NO".
Submitted Solution:
```
n=list(input())
c=0
for i in range(len(n)):
if(n[i]=='4' or n[i]=='7'):
c+=1
if(c==4 or c==7):
print('YES')
else:
print('NO')
``` | instruction | 0 | 42,955 | 20 | 85,910 |
Yes | output | 1 | 42,955 | 20 | 85,911 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.