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.
Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya calls a number almost lucky if it could be evenly divided by some lucky number. Help him find out if the given number n is almost lucky.
Input
The single line contains an integer n (1 ≤ n ≤ 1000) — the number that needs to be checked.
Output
In the only line print "YES" (without the quotes), if number n is almost lucky. Otherwise, print "NO" (without the quotes).
Examples
Input
47
Output
YES
Input
16
Output
YES
Input
78
Output
NO
Note
Note that all lucky numbers are almost lucky as any number is evenly divisible by itself.
In the first sample 47 is a lucky number. In the second sample 16 is divisible by 4.
Submitted Solution:
```
def isLucky(number):
for digit in str(number):
if(digit != '4' and digit != '7'):
return False
return True
def divisors(number):
divs = [1, number]
for i in range(2, (number//2)+1):
if(number % i == 0):
divs.append(i)
return sorted(divs)
def isAlmostLucky(number):
if(isLucky(number)):
return True
else:
for div in divisors(number):
if(isLucky(div)):
return True
return False
if(isAlmostLucky(int(input()))):
print("YES")
else:
print("NO")
``` | instruction | 0 | 47,125 | 20 | 94,250 |
Yes | output | 1 | 47,125 | 20 | 94,251 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya calls a number almost lucky if it could be evenly divided by some lucky number. Help him find out if the given number n is almost lucky.
Input
The single line contains an integer n (1 ≤ n ≤ 1000) — the number that needs to be checked.
Output
In the only line print "YES" (without the quotes), if number n is almost lucky. Otherwise, print "NO" (without the quotes).
Examples
Input
47
Output
YES
Input
16
Output
YES
Input
78
Output
NO
Note
Note that all lucky numbers are almost lucky as any number is evenly divisible by itself.
In the first sample 47 is a lucky number. In the second sample 16 is divisible by 4.
Submitted Solution:
```
n=int(input())
luky=[4,7,44,47,74,77,444,447,474,477,744,747,774,777]
for i in range(len(luky)):
if n%luky[i]==0:
print('YES')
break
if n%luky[i]!=0 and i==len(luky)-1:
print('NO')
``` | instruction | 0 | 47,126 | 20 | 94,252 |
Yes | output | 1 | 47,126 | 20 | 94,253 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya calls a number almost lucky if it could be evenly divided by some lucky number. Help him find out if the given number n is almost lucky.
Input
The single line contains an integer n (1 ≤ n ≤ 1000) — the number that needs to be checked.
Output
In the only line print "YES" (without the quotes), if number n is almost lucky. Otherwise, print "NO" (without the quotes).
Examples
Input
47
Output
YES
Input
16
Output
YES
Input
78
Output
NO
Note
Note that all lucky numbers are almost lucky as any number is evenly divisible by itself.
In the first sample 47 is a lucky number. In the second sample 16 is divisible by 4.
Submitted Solution:
```
x=input()
n4=n7=0
n4=x.count('4'); n7=x.count('7')
out=''
if((n4+n7)<len(x)):
if(int(x)%4==0)or(int(x)%7==0)or(int(x)%47==0)or(int(x)%74==0):
out='YES'
else:
out='NO'
else:
out='YES'
print(out)
``` | instruction | 0 | 47,127 | 20 | 94,254 |
Yes | output | 1 | 47,127 | 20 | 94,255 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya calls a number almost lucky if it could be evenly divided by some lucky number. Help him find out if the given number n is almost lucky.
Input
The single line contains an integer n (1 ≤ n ≤ 1000) — the number that needs to be checked.
Output
In the only line print "YES" (without the quotes), if number n is almost lucky. Otherwise, print "NO" (without the quotes).
Examples
Input
47
Output
YES
Input
16
Output
YES
Input
78
Output
NO
Note
Note that all lucky numbers are almost lucky as any number is evenly divisible by itself.
In the first sample 47 is a lucky number. In the second sample 16 is divisible by 4.
Submitted Solution:
```
n=int(input())
l=['4','7']
s=str(n)
flag=0
for i in s:
if i in l:
continue
else:
if n%4==0 or n%7==0:
print("YES")
flag=1
break
else:
flag=1
print("NO")
break
if flag==0:
print("YES")
``` | instruction | 0 | 47,128 | 20 | 94,256 |
No | output | 1 | 47,128 | 20 | 94,257 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya calls a number almost lucky if it could be evenly divided by some lucky number. Help him find out if the given number n is almost lucky.
Input
The single line contains an integer n (1 ≤ n ≤ 1000) — the number that needs to be checked.
Output
In the only line print "YES" (without the quotes), if number n is almost lucky. Otherwise, print "NO" (without the quotes).
Examples
Input
47
Output
YES
Input
16
Output
YES
Input
78
Output
NO
Note
Note that all lucky numbers are almost lucky as any number is evenly divisible by itself.
In the first sample 47 is a lucky number. In the second sample 16 is divisible by 4.
Submitted Solution:
```
s = input()
n = list(set(list(map(int, s))))
print(n)
check = 4 in n or 7 in n or n % 4 == 0 or n % 7 == 0
if check:
print('YES')
else:
print('NO')
``` | instruction | 0 | 47,129 | 20 | 94,258 |
No | output | 1 | 47,129 | 20 | 94,259 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya calls a number almost lucky if it could be evenly divided by some lucky number. Help him find out if the given number n is almost lucky.
Input
The single line contains an integer n (1 ≤ n ≤ 1000) — the number that needs to be checked.
Output
In the only line print "YES" (without the quotes), if number n is almost lucky. Otherwise, print "NO" (without the quotes).
Examples
Input
47
Output
YES
Input
16
Output
YES
Input
78
Output
NO
Note
Note that all lucky numbers are almost lucky as any number is evenly divisible by itself.
In the first sample 47 is a lucky number. In the second sample 16 is divisible by 4.
Submitted Solution:
```
n=int(input(""))
g=str(n)
cnt=0
if n%7==0 or n%4==0:
print("YES")
else:
for i in range(len(g)):
if g[i]=='4' or g[i]=='7':
cnt+=1
if cnt==len(g):
print("YES")
else:
print("NO")
``` | instruction | 0 | 47,130 | 20 | 94,260 |
No | output | 1 | 47,130 | 20 | 94,261 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya calls a number almost lucky if it could be evenly divided by some lucky number. Help him find out if the given number n is almost lucky.
Input
The single line contains an integer n (1 ≤ n ≤ 1000) — the number that needs to be checked.
Output
In the only line print "YES" (without the quotes), if number n is almost lucky. Otherwise, print "NO" (without the quotes).
Examples
Input
47
Output
YES
Input
16
Output
YES
Input
78
Output
NO
Note
Note that all lucky numbers are almost lucky as any number is evenly divisible by itself.
In the first sample 47 is a lucky number. In the second sample 16 is divisible by 4.
Submitted Solution:
```
l=['4','7']
for i in input():
if i not in l:
print('NO')
exit()
print('YES')
``` | instruction | 0 | 47,131 | 20 | 94,262 |
No | output | 1 | 47,131 | 20 | 94,263 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A sequence of non-negative integers a1, a2, ..., an of length n is called a wool sequence if and only if there exists two integers l and r (1 ≤ l ≤ r ≤ n) such that <image>. In other words each wool sequence contains a subsequence of consecutive elements with xor equal to 0.
The expression <image> means applying the operation of a bitwise xor to numbers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is marked as "^", in Pascal — as "xor".
In this problem you are asked to compute the number of sequences made of n integers from 0 to 2m - 1 that are not a wool sequence. You should print this number modulo 1000000009 (109 + 9).
Input
The only line of input contains two space-separated integers n and m (1 ≤ n, m ≤ 105).
Output
Print the required number of sequences modulo 1000000009 (109 + 9) on the only line of output.
Examples
Input
3 2
Output
6
Note
Sequences of length 3 made of integers 0, 1, 2 and 3 that are not a wool sequence are (1, 3, 1), (1, 2, 1), (2, 1, 2), (2, 3, 2), (3, 1, 3) and (3, 2, 3). | instruction | 0 | 47,337 | 20 | 94,674 |
Tags: constructive algorithms, math
Correct Solution:
```
e=10**9+9
n,m=map(int,input().split())
t=pow(2,m,e)
r=1
for i in range(n):r=(r*(t-i-1))%e
print(r)
``` | output | 1 | 47,337 | 20 | 94,675 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Sereja loves number sequences very much. That's why he decided to make himself a new one following a certain algorithm.
Sereja takes a blank piece of paper. Then he starts writing out the sequence in m stages. Each time he either adds a new number to the end of the sequence or takes l first elements of the current sequence and adds them c times to the end. More formally, if we represent the current sequence as a1, a2, ..., an, then after we apply the described operation, the sequence transforms into a1, a2, ..., an[, a1, a2, ..., al] (the block in the square brackets must be repeated c times).
A day has passed and Sereja has completed the sequence. He wonders what are the values of some of its elements. Help Sereja.
Input
The first line contains integer m (1 ≤ m ≤ 105) — the number of stages to build a sequence.
Next m lines contain the description of the stages in the order they follow. The first number in the line is a type of stage (1 or 2). Type 1 means adding one number to the end of the sequence, in this case the line contains integer xi (1 ≤ xi ≤ 105) — the number to add. Type 2 means copying a prefix of length li to the end ci times, in this case the line further contains two integers li, ci (1 ≤ li ≤ 105, 1 ≤ ci ≤ 104), li is the length of the prefix, ci is the number of copyings. It is guaranteed that the length of prefix li is never larger than the current length of the sequence.
The next line contains integer n (1 ≤ n ≤ 105) — the number of elements Sereja is interested in. The next line contains the numbers of elements of the final sequence Sereja is interested in. The numbers are given in the strictly increasing order. It is guaranteed that all numbers are strictly larger than zero and do not exceed the length of the resulting sequence. Consider the elements of the final sequence numbered starting from 1 from the beginning to the end of the sequence.
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.
Output
Print the elements that Sereja is interested in, in the order in which their numbers occur in the input.
Examples
Input
6
1 1
1 2
2 2 1
1 3
2 5 2
1 4
16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Output
1 2 1 2 3 1 2 1 2 3 1 2 1 2 3 4 | instruction | 0 | 47,390 | 20 | 94,780 |
Tags: binary search, brute force
Correct Solution:
```
# -*- coding: utf-8 -*-
from bisect import bisect_left
m = int(input())
lines = []
for i in range(m):
lines.append(list(map(int, input().split())))
n = int(input())
lengths = list(map(int, input().split()))
#acc_lengths[i]表示i指令执行之前已经积累了多长的串
acc_lengths = [0]
for l in lines:
acc_lengths.append(acc_lengths[-1] + (1 if l[0] == 1 else l[1]*l[2]))
result = {}
def find_number(l):
if l not in result:
i = bisect_left(acc_lengths, l) - 1
result[l] = lines[i][1] if lines[i][0] == 1 else find_number((l - acc_lengths[i] - 1) % lines[i][1] + 1)
return result[l]
print(' '.join([str(find_number(l)) for l in lengths]))
``` | output | 1 | 47,390 | 20 | 94,781 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Sereja loves number sequences very much. That's why he decided to make himself a new one following a certain algorithm.
Sereja takes a blank piece of paper. Then he starts writing out the sequence in m stages. Each time he either adds a new number to the end of the sequence or takes l first elements of the current sequence and adds them c times to the end. More formally, if we represent the current sequence as a1, a2, ..., an, then after we apply the described operation, the sequence transforms into a1, a2, ..., an[, a1, a2, ..., al] (the block in the square brackets must be repeated c times).
A day has passed and Sereja has completed the sequence. He wonders what are the values of some of its elements. Help Sereja.
Input
The first line contains integer m (1 ≤ m ≤ 105) — the number of stages to build a sequence.
Next m lines contain the description of the stages in the order they follow. The first number in the line is a type of stage (1 or 2). Type 1 means adding one number to the end of the sequence, in this case the line contains integer xi (1 ≤ xi ≤ 105) — the number to add. Type 2 means copying a prefix of length li to the end ci times, in this case the line further contains two integers li, ci (1 ≤ li ≤ 105, 1 ≤ ci ≤ 104), li is the length of the prefix, ci is the number of copyings. It is guaranteed that the length of prefix li is never larger than the current length of the sequence.
The next line contains integer n (1 ≤ n ≤ 105) — the number of elements Sereja is interested in. The next line contains the numbers of elements of the final sequence Sereja is interested in. The numbers are given in the strictly increasing order. It is guaranteed that all numbers are strictly larger than zero and do not exceed the length of the resulting sequence. Consider the elements of the final sequence numbered starting from 1 from the beginning to the end of the sequence.
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.
Output
Print the elements that Sereja is interested in, in the order in which their numbers occur in the input.
Examples
Input
6
1 1
1 2
2 2 1
1 3
2 5 2
1 4
16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Output
1 2 1 2 3 1 2 1 2 3 1 2 1 2 3 4 | instruction | 0 | 47,391 | 20 | 94,782 |
Tags: binary search, brute force
Correct Solution:
```
from sys import stdin
debug = False
def debug_print(*foo):
if debug:
print (foo)
def print_array(res, size):
if size:
print(len(res))
print(" ".join(map(str, res)))
def input_int_tuple():
return tuple([ x for x in map(int, stdin.readline().split())])
def input_int_array(size=True):
if size:
#read
values = stdin.readline().split()
assert(len(values) == 1)
return [x for x in map(int, stdin.readline().split())]
def slen(s):
if s[0] == 1:
return 1
if s[0] == 2:
return s[1]*s[2]
def sget(s, n, pref, curlen):
if s[0] == 1:
return s[1]
if s[0] == 2:
d = n - curlen
#print ("sget")
#print (len(pref))
#print (d)
#print (s[1])
return pref[ d % s[1]]
const_100k = 100000
def compute_prefix(stages):
pref = [ ]
tr = 0
split = 0
for i, s in enumerate(stages):
#print(i ,s)
if s[0] == 1:
pref.append(s[1])
if s[0] == 2:
#print ("okstage")
l = s[1]
c = s[2]
#print (c)
#print(l)
if len(pref) + c*l > const_100k:
c = (const_100k - len(pref) ) // l + 1
s[2] -= c
if s[2] > 0:
split = 1
#print (len(pref))
pref = pref + pref[:l]*c
#print (len(pref))
if len(pref) > const_100k:
tr = i - split
break
#debug_print (pref)
stages = stages[tr+1:]
return pref, stages
def problem():
(n, )= input_int_tuple()
sss = 0
for x in range(const_100k*10):
sss +=1*x
if sss < 0:
n = 10
stages = []
for s in range(n):
stages.append(input_int_array(False))
numbers = input_int_array()
pref, stages = compute_prefix(stages)
debug_print (len(pref))
res = []
curlen = len(pref)
si = 0
for x in numbers:
# print(x)
i = x - 1
if i < len(pref):
res.append(pref[i])
else:
s = stages[si]
while i >= curlen + slen(s):
#print (slen(s))
curlen += slen(s)
si = si+1
s = stages[si]
sym = sget(s, i, pref, curlen)
res.append(sym)
return res
print_array(problem(), False)
``` | output | 1 | 47,391 | 20 | 94,783 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Sereja loves number sequences very much. That's why he decided to make himself a new one following a certain algorithm.
Sereja takes a blank piece of paper. Then he starts writing out the sequence in m stages. Each time he either adds a new number to the end of the sequence or takes l first elements of the current sequence and adds them c times to the end. More formally, if we represent the current sequence as a1, a2, ..., an, then after we apply the described operation, the sequence transforms into a1, a2, ..., an[, a1, a2, ..., al] (the block in the square brackets must be repeated c times).
A day has passed and Sereja has completed the sequence. He wonders what are the values of some of its elements. Help Sereja.
Input
The first line contains integer m (1 ≤ m ≤ 105) — the number of stages to build a sequence.
Next m lines contain the description of the stages in the order they follow. The first number in the line is a type of stage (1 or 2). Type 1 means adding one number to the end of the sequence, in this case the line contains integer xi (1 ≤ xi ≤ 105) — the number to add. Type 2 means copying a prefix of length li to the end ci times, in this case the line further contains two integers li, ci (1 ≤ li ≤ 105, 1 ≤ ci ≤ 104), li is the length of the prefix, ci is the number of copyings. It is guaranteed that the length of prefix li is never larger than the current length of the sequence.
The next line contains integer n (1 ≤ n ≤ 105) — the number of elements Sereja is interested in. The next line contains the numbers of elements of the final sequence Sereja is interested in. The numbers are given in the strictly increasing order. It is guaranteed that all numbers are strictly larger than zero and do not exceed the length of the resulting sequence. Consider the elements of the final sequence numbered starting from 1 from the beginning to the end of the sequence.
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.
Output
Print the elements that Sereja is interested in, in the order in which their numbers occur in the input.
Examples
Input
6
1 1
1 2
2 2 1
1 3
2 5 2
1 4
16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Output
1 2 1 2 3 1 2 1 2 3 1 2 1 2 3 4 | instruction | 0 | 47,392 | 20 | 94,784 |
Tags: binary search, brute force
Correct Solution:
```
MAX_LEN = int(1e5)
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
m = int(input())
b = list(map(lambda x:int(x)-1, input().split()))
curr, k, c, res = 0, 0, [], []
for i in range(n):
t = a[i]
last = curr
if t[0] == 1:
curr += 1
if len(c) < MAX_LEN:
c.append(t[1])
if k < m and b[k] == curr-1:
res.append(t[1])
k += 1
else:
curr += t[1] * t[2]
while t[2] > 0 and len(c) < MAX_LEN:
c.extend(c[:t[1]])
t[2] -= 1
while k < m and last <= b[k] < curr:
res.append(c[(b[k] - last) % t[1]])
k += 1
print(' '.join(map(str, res[:m])))
``` | output | 1 | 47,392 | 20 | 94,785 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Sereja loves number sequences very much. That's why he decided to make himself a new one following a certain algorithm.
Sereja takes a blank piece of paper. Then he starts writing out the sequence in m stages. Each time he either adds a new number to the end of the sequence or takes l first elements of the current sequence and adds them c times to the end. More formally, if we represent the current sequence as a1, a2, ..., an, then after we apply the described operation, the sequence transforms into a1, a2, ..., an[, a1, a2, ..., al] (the block in the square brackets must be repeated c times).
A day has passed and Sereja has completed the sequence. He wonders what are the values of some of its elements. Help Sereja.
Input
The first line contains integer m (1 ≤ m ≤ 105) — the number of stages to build a sequence.
Next m lines contain the description of the stages in the order they follow. The first number in the line is a type of stage (1 or 2). Type 1 means adding one number to the end of the sequence, in this case the line contains integer xi (1 ≤ xi ≤ 105) — the number to add. Type 2 means copying a prefix of length li to the end ci times, in this case the line further contains two integers li, ci (1 ≤ li ≤ 105, 1 ≤ ci ≤ 104), li is the length of the prefix, ci is the number of copyings. It is guaranteed that the length of prefix li is never larger than the current length of the sequence.
The next line contains integer n (1 ≤ n ≤ 105) — the number of elements Sereja is interested in. The next line contains the numbers of elements of the final sequence Sereja is interested in. The numbers are given in the strictly increasing order. It is guaranteed that all numbers are strictly larger than zero and do not exceed the length of the resulting sequence. Consider the elements of the final sequence numbered starting from 1 from the beginning to the end of the sequence.
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.
Output
Print the elements that Sereja is interested in, in the order in which their numbers occur in the input.
Examples
Input
6
1 1
1 2
2 2 1
1 3
2 5 2
1 4
16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Output
1 2 1 2 3 1 2 1 2 3 1 2 1 2 3 4 | instruction | 0 | 47,393 | 20 | 94,786 |
Tags: binary search, brute force
Correct Solution:
```
n=int(input())
a=[]
for i in range(n):
a.append(list(map(int,input().split())))
m=int(input())
b=list(map(lambda x:int(x)-1,input().split()))
c=[]
now=0
k=0
ans=[]
for i in range(n):
t=a[i]
last=now
if t[0]==1:
now+=1
if len(c)<100000: c.append(t[1])
if k<m and b[k]==now-1:
ans.append(t[1])
k+=1
else:
now+=t[1]*t[2]
while t[2]:
if len(c)<100000: c.extend(c[:t[1]])
else: break
t[2]-=1
while k<m and last<=b[k]<now:
ans.append(c[(b[k]-last)%t[1]])
k+=1
for i in range(m):
print(ans[i],end=' ')
``` | output | 1 | 47,393 | 20 | 94,787 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Sereja loves number sequences very much. That's why he decided to make himself a new one following a certain algorithm.
Sereja takes a blank piece of paper. Then he starts writing out the sequence in m stages. Each time he either adds a new number to the end of the sequence or takes l first elements of the current sequence and adds them c times to the end. More formally, if we represent the current sequence as a1, a2, ..., an, then after we apply the described operation, the sequence transforms into a1, a2, ..., an[, a1, a2, ..., al] (the block in the square brackets must be repeated c times).
A day has passed and Sereja has completed the sequence. He wonders what are the values of some of its elements. Help Sereja.
Input
The first line contains integer m (1 ≤ m ≤ 105) — the number of stages to build a sequence.
Next m lines contain the description of the stages in the order they follow. The first number in the line is a type of stage (1 or 2). Type 1 means adding one number to the end of the sequence, in this case the line contains integer xi (1 ≤ xi ≤ 105) — the number to add. Type 2 means copying a prefix of length li to the end ci times, in this case the line further contains two integers li, ci (1 ≤ li ≤ 105, 1 ≤ ci ≤ 104), li is the length of the prefix, ci is the number of copyings. It is guaranteed that the length of prefix li is never larger than the current length of the sequence.
The next line contains integer n (1 ≤ n ≤ 105) — the number of elements Sereja is interested in. The next line contains the numbers of elements of the final sequence Sereja is interested in. The numbers are given in the strictly increasing order. It is guaranteed that all numbers are strictly larger than zero and do not exceed the length of the resulting sequence. Consider the elements of the final sequence numbered starting from 1 from the beginning to the end of the sequence.
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.
Output
Print the elements that Sereja is interested in, in the order in which their numbers occur in the input.
Examples
Input
6
1 1
1 2
2 2 1
1 3
2 5 2
1 4
16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Output
1 2 1 2 3 1 2 1 2 3 1 2 1 2 3 4 | instruction | 0 | 47,394 | 20 | 94,788 |
Tags: binary search, brute force
Correct Solution:
```
from sys import stdin
debug = False
def debug_print(*foo):
if debug:
print (foo)
def print_array(res, size):
if size:
print(len(res))
print(" ".join(map(str, res)))
def input_int_tuple():
return tuple([ x for x in map(int, stdin.readline().split())])
def input_int_array(size=True):
if size:
#read
values = stdin.readline().split()
assert(len(values) == 1)
return [x for x in map(int, stdin.readline().split())]
def slen(s):
if s[0] == 1:
return 1
if s[0] == 2:
return s[1]*s[2]
def sget(s, n, pref, curlen):
if s[0] == 1:
return s[1]
if s[0] == 2:
d = n - curlen
#print ("sget")
#print (len(pref))
#print (d)
#print (s[1])
return pref[ d % s[1]]
const_100k = 1000000
def compute_prefix(stages):
pref = [ ]
tr = 0
split = 0
for i, s in enumerate(stages):
#print(i ,s)
if s[0] == 1:
pref.append(s[1])
if s[0] == 2:
#print ("okstage")
l = s[1]
c = s[2]
#print (c)
#print(l)
if len(pref) + c*l > const_100k:
c = (const_100k - len(pref) ) // l + 1
s[2] -= c
if s[2] > 0:
split = 1
#print (len(pref))
pref = pref + pref[:l]*c
#print (len(pref))
if len(pref) > const_100k:
tr = i - split
break
#debug_print (pref)
stages = stages[tr+1:]
return pref, stages
def problem():
(n, )= input_int_tuple()
stages = []
for s in range(n):
stages.append(input_int_array(False))
numbers = input_int_array()
pref, stages = compute_prefix(stages)
debug_print (len(pref))
res = []
curlen = len(pref)
si = 0
for x in numbers:
# print(x)
i = x - 1
if i < len(pref):
res.append(pref[i])
else:
s = stages[si]
while i >= curlen + slen(s):
#print (slen(s))
curlen += slen(s)
si = si+1
s = stages[si]
sym = sget(s, i, pref, curlen)
res.append(sym)
return res
print_array(problem(), False)
``` | output | 1 | 47,394 | 20 | 94,789 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Sereja loves number sequences very much. That's why he decided to make himself a new one following a certain algorithm.
Sereja takes a blank piece of paper. Then he starts writing out the sequence in m stages. Each time he either adds a new number to the end of the sequence or takes l first elements of the current sequence and adds them c times to the end. More formally, if we represent the current sequence as a1, a2, ..., an, then after we apply the described operation, the sequence transforms into a1, a2, ..., an[, a1, a2, ..., al] (the block in the square brackets must be repeated c times).
A day has passed and Sereja has completed the sequence. He wonders what are the values of some of its elements. Help Sereja.
Input
The first line contains integer m (1 ≤ m ≤ 105) — the number of stages to build a sequence.
Next m lines contain the description of the stages in the order they follow. The first number in the line is a type of stage (1 or 2). Type 1 means adding one number to the end of the sequence, in this case the line contains integer xi (1 ≤ xi ≤ 105) — the number to add. Type 2 means copying a prefix of length li to the end ci times, in this case the line further contains two integers li, ci (1 ≤ li ≤ 105, 1 ≤ ci ≤ 104), li is the length of the prefix, ci is the number of copyings. It is guaranteed that the length of prefix li is never larger than the current length of the sequence.
The next line contains integer n (1 ≤ n ≤ 105) — the number of elements Sereja is interested in. The next line contains the numbers of elements of the final sequence Sereja is interested in. The numbers are given in the strictly increasing order. It is guaranteed that all numbers are strictly larger than zero and do not exceed the length of the resulting sequence. Consider the elements of the final sequence numbered starting from 1 from the beginning to the end of the sequence.
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.
Output
Print the elements that Sereja is interested in, in the order in which their numbers occur in the input.
Examples
Input
6
1 1
1 2
2 2 1
1 3
2 5 2
1 4
16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Output
1 2 1 2 3 1 2 1 2 3 1 2 1 2 3 4 | instruction | 0 | 47,395 | 20 | 94,790 |
Tags: binary search, brute force
Correct Solution:
```
m = int(input())
a, b, start, end = [], [], 0, 0
idx = 0
for _ in range(m):
line = list(map(int, input().split()))
if line[0] == 1:
x = line[1]
start = end + 1
end = end + 1
if len(a) <= 100000:
a.append(x)
b.append((start, end, x))
else:
l, c = line[1], line[2]
start = end + 1
end = end + l * c
if len(a) <= 100000:
for _ in range(c):
a += a[:l]
if len(a) > 100000:
break
b.append((start, end, l, c))
input() # n
def answer(n):
global m, a, b, idx
if (n - 1) < len(a):
return a[n - 1]
while True:
bi = b[idx]
if bi[0] <= n <= bi[1]:
break
idx += 1
if len(bi) == 3:
return bi[2]
n_bak = n
n = (n - bi[0]) % bi[2] + 1
return a[n - 1]
result = []
for n in map(int, input().split()):
result.append("%s" % answer(n))
print(" ".join(result))
``` | output | 1 | 47,395 | 20 | 94,791 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Sereja loves number sequences very much. That's why he decided to make himself a new one following a certain algorithm.
Sereja takes a blank piece of paper. Then he starts writing out the sequence in m stages. Each time he either adds a new number to the end of the sequence or takes l first elements of the current sequence and adds them c times to the end. More formally, if we represent the current sequence as a1, a2, ..., an, then after we apply the described operation, the sequence transforms into a1, a2, ..., an[, a1, a2, ..., al] (the block in the square brackets must be repeated c times).
A day has passed and Sereja has completed the sequence. He wonders what are the values of some of its elements. Help Sereja.
Input
The first line contains integer m (1 ≤ m ≤ 105) — the number of stages to build a sequence.
Next m lines contain the description of the stages in the order they follow. The first number in the line is a type of stage (1 or 2). Type 1 means adding one number to the end of the sequence, in this case the line contains integer xi (1 ≤ xi ≤ 105) — the number to add. Type 2 means copying a prefix of length li to the end ci times, in this case the line further contains two integers li, ci (1 ≤ li ≤ 105, 1 ≤ ci ≤ 104), li is the length of the prefix, ci is the number of copyings. It is guaranteed that the length of prefix li is never larger than the current length of the sequence.
The next line contains integer n (1 ≤ n ≤ 105) — the number of elements Sereja is interested in. The next line contains the numbers of elements of the final sequence Sereja is interested in. The numbers are given in the strictly increasing order. It is guaranteed that all numbers are strictly larger than zero and do not exceed the length of the resulting sequence. Consider the elements of the final sequence numbered starting from 1 from the beginning to the end of the sequence.
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.
Output
Print the elements that Sereja is interested in, in the order in which their numbers occur in the input.
Examples
Input
6
1 1
1 2
2 2 1
1 3
2 5 2
1 4
16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Output
1 2 1 2 3 1 2 1 2 3 1 2 1 2 3 4 | instruction | 0 | 47,396 | 20 | 94,792 |
Tags: binary search, brute force
Correct Solution:
```
n=int(input())
a=[list(map(int,input().split())) for i in range(n)]
m=int(input())
b=list(map(lambda x:int(x)-1,input().split()))
c=[]
now=0
k=0
ans=[]
for i in range(n):
t=a[i]
if t[0]==1:
now+=1
if len(c)<100000: c.append(t[1])
if k<m and b[k]==now-1:
ans.append(t[1])
k+=1
else:
last=now
now+=t[1]*t[2]
while t[2]:
if len(c)<100000: c.extend(c[:t[1]])
else: break
t[2]-=1
while k<m and last<=b[k]<now:
ans.append(c[(b[k]-last)%t[1]])
k+=1
print(' '.join(map(str,ans)))
``` | output | 1 | 47,396 | 20 | 94,793 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Sereja loves number sequences very much. That's why he decided to make himself a new one following a certain algorithm.
Sereja takes a blank piece of paper. Then he starts writing out the sequence in m stages. Each time he either adds a new number to the end of the sequence or takes l first elements of the current sequence and adds them c times to the end. More formally, if we represent the current sequence as a1, a2, ..., an, then after we apply the described operation, the sequence transforms into a1, a2, ..., an[, a1, a2, ..., al] (the block in the square brackets must be repeated c times).
A day has passed and Sereja has completed the sequence. He wonders what are the values of some of its elements. Help Sereja.
Input
The first line contains integer m (1 ≤ m ≤ 105) — the number of stages to build a sequence.
Next m lines contain the description of the stages in the order they follow. The first number in the line is a type of stage (1 or 2). Type 1 means adding one number to the end of the sequence, in this case the line contains integer xi (1 ≤ xi ≤ 105) — the number to add. Type 2 means copying a prefix of length li to the end ci times, in this case the line further contains two integers li, ci (1 ≤ li ≤ 105, 1 ≤ ci ≤ 104), li is the length of the prefix, ci is the number of copyings. It is guaranteed that the length of prefix li is never larger than the current length of the sequence.
The next line contains integer n (1 ≤ n ≤ 105) — the number of elements Sereja is interested in. The next line contains the numbers of elements of the final sequence Sereja is interested in. The numbers are given in the strictly increasing order. It is guaranteed that all numbers are strictly larger than zero and do not exceed the length of the resulting sequence. Consider the elements of the final sequence numbered starting from 1 from the beginning to the end of the sequence.
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.
Output
Print the elements that Sereja is interested in, in the order in which their numbers occur in the input.
Examples
Input
6
1 1
1 2
2 2 1
1 3
2 5 2
1 4
16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Output
1 2 1 2 3 1 2 1 2 3 1 2 1 2 3 4 | instruction | 0 | 47,397 | 20 | 94,794 |
Tags: binary search, brute force
Correct Solution:
```
n=int(input())
a=[]
for i in range(n):
a.append(list(map(int,input().split())))
m=int(input())
b=list(map(lambda x:int(x)-1,input().split()))
c=[]
now=0
k=0
ans=[]
for i in range(n):
t=a[i]
if t[0]==1:
now+=1
if len(c)<100000: c.append(t[1])
if k<m and b[k]==now-1:
ans.append(t[1])
k+=1
else:
last=now
now+=t[1]*t[2]
while t[2]:
if len(c)<100000: c.extend(c[:t[1]])
else: break
t[2]-=1
while k<m and last<=b[k]<now:
ans.append(c[(b[k]-last)%t[1]])
k+=1
print(' '.join(map(str,ans)))
``` | output | 1 | 47,397 | 20 | 94,795 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Sereja loves number sequences very much. That's why he decided to make himself a new one following a certain algorithm.
Sereja takes a blank piece of paper. Then he starts writing out the sequence in m stages. Each time he either adds a new number to the end of the sequence or takes l first elements of the current sequence and adds them c times to the end. More formally, if we represent the current sequence as a1, a2, ..., an, then after we apply the described operation, the sequence transforms into a1, a2, ..., an[, a1, a2, ..., al] (the block in the square brackets must be repeated c times).
A day has passed and Sereja has completed the sequence. He wonders what are the values of some of its elements. Help Sereja.
Input
The first line contains integer m (1 ≤ m ≤ 105) — the number of stages to build a sequence.
Next m lines contain the description of the stages in the order they follow. The first number in the line is a type of stage (1 or 2). Type 1 means adding one number to the end of the sequence, in this case the line contains integer xi (1 ≤ xi ≤ 105) — the number to add. Type 2 means copying a prefix of length li to the end ci times, in this case the line further contains two integers li, ci (1 ≤ li ≤ 105, 1 ≤ ci ≤ 104), li is the length of the prefix, ci is the number of copyings. It is guaranteed that the length of prefix li is never larger than the current length of the sequence.
The next line contains integer n (1 ≤ n ≤ 105) — the number of elements Sereja is interested in. The next line contains the numbers of elements of the final sequence Sereja is interested in. The numbers are given in the strictly increasing order. It is guaranteed that all numbers are strictly larger than zero and do not exceed the length of the resulting sequence. Consider the elements of the final sequence numbered starting from 1 from the beginning to the end of the sequence.
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.
Output
Print the elements that Sereja is interested in, in the order in which their numbers occur in the input.
Examples
Input
6
1 1
1 2
2 2 1
1 3
2 5 2
1 4
16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Output
1 2 1 2 3 1 2 1 2 3 1 2 1 2 3 4
Submitted Solution:
```
# -*- coding: utf-8 -*-
from bisect import bisect_left
m = int(input())
lines = []
for i in range(m):
lines.append(list(map(int, input().split())))
n = int(input())
lengths = list(map(int, input().split()))
#size[i]表示i指令执行前已经积累了多长的串
sizes = [0]
for l in lines:
sizes.append(sizes[-1] + (1 if l[0] == 1 else l[1]*l[2]))
result = {}
def find_number(l):
if l not in result:
i = bisect_left(sizes, l) - 1
result[l] = lines[i][1] if lines[i][0] == 1 else find_number((l - sizes[i] - 1) % lines[i][1] + 1)
return result[l]
print(' '.join([str(find_number(l)) for l in lengths]))
``` | instruction | 0 | 47,398 | 20 | 94,796 |
Yes | output | 1 | 47,398 | 20 | 94,797 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Sereja loves number sequences very much. That's why he decided to make himself a new one following a certain algorithm.
Sereja takes a blank piece of paper. Then he starts writing out the sequence in m stages. Each time he either adds a new number to the end of the sequence or takes l first elements of the current sequence and adds them c times to the end. More formally, if we represent the current sequence as a1, a2, ..., an, then after we apply the described operation, the sequence transforms into a1, a2, ..., an[, a1, a2, ..., al] (the block in the square brackets must be repeated c times).
A day has passed and Sereja has completed the sequence. He wonders what are the values of some of its elements. Help Sereja.
Input
The first line contains integer m (1 ≤ m ≤ 105) — the number of stages to build a sequence.
Next m lines contain the description of the stages in the order they follow. The first number in the line is a type of stage (1 or 2). Type 1 means adding one number to the end of the sequence, in this case the line contains integer xi (1 ≤ xi ≤ 105) — the number to add. Type 2 means copying a prefix of length li to the end ci times, in this case the line further contains two integers li, ci (1 ≤ li ≤ 105, 1 ≤ ci ≤ 104), li is the length of the prefix, ci is the number of copyings. It is guaranteed that the length of prefix li is never larger than the current length of the sequence.
The next line contains integer n (1 ≤ n ≤ 105) — the number of elements Sereja is interested in. The next line contains the numbers of elements of the final sequence Sereja is interested in. The numbers are given in the strictly increasing order. It is guaranteed that all numbers are strictly larger than zero and do not exceed the length of the resulting sequence. Consider the elements of the final sequence numbered starting from 1 from the beginning to the end of the sequence.
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.
Output
Print the elements that Sereja is interested in, in the order in which their numbers occur in the input.
Examples
Input
6
1 1
1 2
2 2 1
1 3
2 5 2
1 4
16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Output
1 2 1 2 3 1 2 1 2 3 1 2 1 2 3 4
Submitted Solution:
```
from bisect import bisect_left
def fun(ind,alr,ll,sll):
if ind in alr:
return alr[ind]
k = bisect_left(sll,ind)
md = ll[k]
return fun((ind-sll[k])%md,alr,ll,sll)
pos = {}
m = int(input())
l = 0
cp = []
cpl = []
for _ in range(0,m):
q = [int(i) for i in input().split()]
if q[0] == 1:
pos[l] = q[1]
l += 1
else:
cp.append(q[1])
l += q[1]*q[2]
cpl.append(l)
n = int(input())
qq = [int(i)-1 for i in input().split()]
ans = [fun(i,pos,cp,cpl) for i in qq]
print(*ans)
``` | instruction | 0 | 47,399 | 20 | 94,798 |
Yes | output | 1 | 47,399 | 20 | 94,799 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Sereja loves number sequences very much. That's why he decided to make himself a new one following a certain algorithm.
Sereja takes a blank piece of paper. Then he starts writing out the sequence in m stages. Each time he either adds a new number to the end of the sequence or takes l first elements of the current sequence and adds them c times to the end. More formally, if we represent the current sequence as a1, a2, ..., an, then after we apply the described operation, the sequence transforms into a1, a2, ..., an[, a1, a2, ..., al] (the block in the square brackets must be repeated c times).
A day has passed and Sereja has completed the sequence. He wonders what are the values of some of its elements. Help Sereja.
Input
The first line contains integer m (1 ≤ m ≤ 105) — the number of stages to build a sequence.
Next m lines contain the description of the stages in the order they follow. The first number in the line is a type of stage (1 or 2). Type 1 means adding one number to the end of the sequence, in this case the line contains integer xi (1 ≤ xi ≤ 105) — the number to add. Type 2 means copying a prefix of length li to the end ci times, in this case the line further contains two integers li, ci (1 ≤ li ≤ 105, 1 ≤ ci ≤ 104), li is the length of the prefix, ci is the number of copyings. It is guaranteed that the length of prefix li is never larger than the current length of the sequence.
The next line contains integer n (1 ≤ n ≤ 105) — the number of elements Sereja is interested in. The next line contains the numbers of elements of the final sequence Sereja is interested in. The numbers are given in the strictly increasing order. It is guaranteed that all numbers are strictly larger than zero and do not exceed the length of the resulting sequence. Consider the elements of the final sequence numbered starting from 1 from the beginning to the end of the sequence.
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.
Output
Print the elements that Sereja is interested in, in the order in which their numbers occur in the input.
Examples
Input
6
1 1
1 2
2 2 1
1 3
2 5 2
1 4
16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Output
1 2 1 2 3 1 2 1 2 3 1 2 1 2 3 4
Submitted Solution:
```
# -*- coding: utf-8 -*-
from bisect import bisect_left
m = int(input())
lines = []
for i in range(m):
lines.append(list(map(int, input().split())))
n = int(input())
lengths = list(map(int, input().split()))
#acc_lengths[i]表示i指令执行之前已经积累了多长的串
acc_lengths = [0]
for l in lines:
acc_lengths.append(acc_lengths[-1] + (1 if l[0] == 1 else l[1]*l[2]))
seq = []
for l in lines:
if l[0] == 1:
seq.append(l[1])
else:
for i in range(l[2]):
seq.extend(seq[:l[1]])
if len(seq) >= 10**5:
break
if len(seq) >= 10**5:
break
def find_number(l):
if l <= len(seq):
return seq[l-1]
#seq[l-1]由指令i生成
i = bisect_left(acc_lengths, l) - 1
return seq[(l - acc_lengths[i] - 1) % lines[i][1]]
print(' '.join([str(find_number(l)) for l in lengths]))
``` | instruction | 0 | 47,400 | 20 | 94,800 |
Yes | output | 1 | 47,400 | 20 | 94,801 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Sereja loves number sequences very much. That's why he decided to make himself a new one following a certain algorithm.
Sereja takes a blank piece of paper. Then he starts writing out the sequence in m stages. Each time he either adds a new number to the end of the sequence or takes l first elements of the current sequence and adds them c times to the end. More formally, if we represent the current sequence as a1, a2, ..., an, then after we apply the described operation, the sequence transforms into a1, a2, ..., an[, a1, a2, ..., al] (the block in the square brackets must be repeated c times).
A day has passed and Sereja has completed the sequence. He wonders what are the values of some of its elements. Help Sereja.
Input
The first line contains integer m (1 ≤ m ≤ 105) — the number of stages to build a sequence.
Next m lines contain the description of the stages in the order they follow. The first number in the line is a type of stage (1 or 2). Type 1 means adding one number to the end of the sequence, in this case the line contains integer xi (1 ≤ xi ≤ 105) — the number to add. Type 2 means copying a prefix of length li to the end ci times, in this case the line further contains two integers li, ci (1 ≤ li ≤ 105, 1 ≤ ci ≤ 104), li is the length of the prefix, ci is the number of copyings. It is guaranteed that the length of prefix li is never larger than the current length of the sequence.
The next line contains integer n (1 ≤ n ≤ 105) — the number of elements Sereja is interested in. The next line contains the numbers of elements of the final sequence Sereja is interested in. The numbers are given in the strictly increasing order. It is guaranteed that all numbers are strictly larger than zero and do not exceed the length of the resulting sequence. Consider the elements of the final sequence numbered starting from 1 from the beginning to the end of the sequence.
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.
Output
Print the elements that Sereja is interested in, in the order in which their numbers occur in the input.
Examples
Input
6
1 1
1 2
2 2 1
1 3
2 5 2
1 4
16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Output
1 2 1 2 3 1 2 1 2 3 1 2 1 2 3 4
Submitted Solution:
```
from sys import stdin
import os
debug = False
try :
if os.environ['COMPUTERNAME'] == 'KRUEGER-PC':
debug = True
except KeyError:
pass
def debug_print(*foo):
if debug:
print (foo)
debug_print("debug active")
def print_array(res, size):
if size:
print(len(res))
print(" ".join(map(str, res)))
def input_int_tuple():
return tuple([ x for x in map(int, stdin.readline().split())])
def input_int_array(size=True):
if size:
#read
values = stdin.readline().split()
assert(len(values) == 1)
return [x for x in map(int, stdin.readline().split())]
def input_string():
return stdin.readline()
def slen(s):
if s[0] == 1:
return 1
if s[0] == 2:
return s[1]*s[2]
def sget(s, n, pref, curlen):
if s[0] == 1:
return s[1]
if s[0] == 2:
d = n - curlen
#print ("sget")
#print (len(pref))
#print (d)
#print (s[1])
return pref[ d % s[1]]
const_100k = 100000
def compute_prefix(stages):
pref = [ ]
tr = 0
split = 0
for i, s in enumerate(stages):
#print(i ,s)
if s[0] == 1:
pref.append(s[1])
if s[0] == 2:
#print ("okstage")
l = s[1]
c = s[2]
#print (c)
#print(l)
if len(pref) + c*l > const_100k:
c = (const_100k - len(pref) ) // l + 1
s[2] -= c
if s[2] > 0:
split = 1
#print (len(pref))
pref = pref + pref[:l]*c
#print (len(pref))
if len(pref) > const_100k:
tr = i - split
break
#debug_print (pref)
stages = stages[tr+1:]
return pref, stages
def problem():
(n, )= input_int_tuple()
stages = []
for s in range(n):
stages.append(input_int_array(False))
numbers = input_int_array()
pref, stages = compute_prefix(stages)
debug_print (len(pref))
res = []
curlen = len(pref)
si = 0
for x in numbers:
# print(x)
i = x - 1
if i < len(pref):
res.append(pref[i])
else:
s = stages[si]
while i >= curlen + slen(s):
#print (slen(s))
curlen += slen(s)
si = si+1
s = stages[si]
sym = sget(s, i, pref, curlen)
res.append(sym)
return res
print_array(problem(), False)
``` | instruction | 0 | 47,401 | 20 | 94,802 |
Yes | output | 1 | 47,401 | 20 | 94,803 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Sereja loves number sequences very much. That's why he decided to make himself a new one following a certain algorithm.
Sereja takes a blank piece of paper. Then he starts writing out the sequence in m stages. Each time he either adds a new number to the end of the sequence or takes l first elements of the current sequence and adds them c times to the end. More formally, if we represent the current sequence as a1, a2, ..., an, then after we apply the described operation, the sequence transforms into a1, a2, ..., an[, a1, a2, ..., al] (the block in the square brackets must be repeated c times).
A day has passed and Sereja has completed the sequence. He wonders what are the values of some of its elements. Help Sereja.
Input
The first line contains integer m (1 ≤ m ≤ 105) — the number of stages to build a sequence.
Next m lines contain the description of the stages in the order they follow. The first number in the line is a type of stage (1 or 2). Type 1 means adding one number to the end of the sequence, in this case the line contains integer xi (1 ≤ xi ≤ 105) — the number to add. Type 2 means copying a prefix of length li to the end ci times, in this case the line further contains two integers li, ci (1 ≤ li ≤ 105, 1 ≤ ci ≤ 104), li is the length of the prefix, ci is the number of copyings. It is guaranteed that the length of prefix li is never larger than the current length of the sequence.
The next line contains integer n (1 ≤ n ≤ 105) — the number of elements Sereja is interested in. The next line contains the numbers of elements of the final sequence Sereja is interested in. The numbers are given in the strictly increasing order. It is guaranteed that all numbers are strictly larger than zero and do not exceed the length of the resulting sequence. Consider the elements of the final sequence numbered starting from 1 from the beginning to the end of the sequence.
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.
Output
Print the elements that Sereja is interested in, in the order in which their numbers occur in the input.
Examples
Input
6
1 1
1 2
2 2 1
1 3
2 5 2
1 4
16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Output
1 2 1 2 3 1 2 1 2 3 1 2 1 2 3 4
Submitted Solution:
```
from bisect import bisect_left
m = int(input())
t, s = [input().split() for i in range(m)], [0] * m
l, n = 0, int(input())
for j, i in enumerate(t):
l += 1 if i[0] == '1' else int(i[1]) * int(i[2])
t[j], s[j] = l, i[1] if i[0] == '1' else int(i[1])
def f(i):
k = s[bisect_left(t, i)]
return k if type(k) == str else f((i - 1) % k + 1)
print(' '.join(f(i) for i in map(int, input().split())))
``` | instruction | 0 | 47,402 | 20 | 94,804 |
No | output | 1 | 47,402 | 20 | 94,805 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Sereja loves number sequences very much. That's why he decided to make himself a new one following a certain algorithm.
Sereja takes a blank piece of paper. Then he starts writing out the sequence in m stages. Each time he either adds a new number to the end of the sequence or takes l first elements of the current sequence and adds them c times to the end. More formally, if we represent the current sequence as a1, a2, ..., an, then after we apply the described operation, the sequence transforms into a1, a2, ..., an[, a1, a2, ..., al] (the block in the square brackets must be repeated c times).
A day has passed and Sereja has completed the sequence. He wonders what are the values of some of its elements. Help Sereja.
Input
The first line contains integer m (1 ≤ m ≤ 105) — the number of stages to build a sequence.
Next m lines contain the description of the stages in the order they follow. The first number in the line is a type of stage (1 or 2). Type 1 means adding one number to the end of the sequence, in this case the line contains integer xi (1 ≤ xi ≤ 105) — the number to add. Type 2 means copying a prefix of length li to the end ci times, in this case the line further contains two integers li, ci (1 ≤ li ≤ 105, 1 ≤ ci ≤ 104), li is the length of the prefix, ci is the number of copyings. It is guaranteed that the length of prefix li is never larger than the current length of the sequence.
The next line contains integer n (1 ≤ n ≤ 105) — the number of elements Sereja is interested in. The next line contains the numbers of elements of the final sequence Sereja is interested in. The numbers are given in the strictly increasing order. It is guaranteed that all numbers are strictly larger than zero and do not exceed the length of the resulting sequence. Consider the elements of the final sequence numbered starting from 1 from the beginning to the end of the sequence.
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.
Output
Print the elements that Sereja is interested in, in the order in which their numbers occur in the input.
Examples
Input
6
1 1
1 2
2 2 1
1 3
2 5 2
1 4
16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Output
1 2 1 2 3 1 2 1 2 3 1 2 1 2 3 4
Submitted Solution:
```
t = int(input())
s = []
for _ in range(t):
l = list(input().split())
#print(*l)
if len(l) == 2:
s.append(l[1])
if len(l) == 3:
for i in range(int(l[2])):
s += s[0:int(l[1])]
n = int(input())
l = list(map(int, input().split()))
for i in range(len(l)):
print(s[i], end = ' ')
``` | instruction | 0 | 47,403 | 20 | 94,806 |
No | output | 1 | 47,403 | 20 | 94,807 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Sereja loves number sequences very much. That's why he decided to make himself a new one following a certain algorithm.
Sereja takes a blank piece of paper. Then he starts writing out the sequence in m stages. Each time he either adds a new number to the end of the sequence or takes l first elements of the current sequence and adds them c times to the end. More formally, if we represent the current sequence as a1, a2, ..., an, then after we apply the described operation, the sequence transforms into a1, a2, ..., an[, a1, a2, ..., al] (the block in the square brackets must be repeated c times).
A day has passed and Sereja has completed the sequence. He wonders what are the values of some of its elements. Help Sereja.
Input
The first line contains integer m (1 ≤ m ≤ 105) — the number of stages to build a sequence.
Next m lines contain the description of the stages in the order they follow. The first number in the line is a type of stage (1 or 2). Type 1 means adding one number to the end of the sequence, in this case the line contains integer xi (1 ≤ xi ≤ 105) — the number to add. Type 2 means copying a prefix of length li to the end ci times, in this case the line further contains two integers li, ci (1 ≤ li ≤ 105, 1 ≤ ci ≤ 104), li is the length of the prefix, ci is the number of copyings. It is guaranteed that the length of prefix li is never larger than the current length of the sequence.
The next line contains integer n (1 ≤ n ≤ 105) — the number of elements Sereja is interested in. The next line contains the numbers of elements of the final sequence Sereja is interested in. The numbers are given in the strictly increasing order. It is guaranteed that all numbers are strictly larger than zero and do not exceed the length of the resulting sequence. Consider the elements of the final sequence numbered starting from 1 from the beginning to the end of the sequence.
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.
Output
Print the elements that Sereja is interested in, in the order in which their numbers occur in the input.
Examples
Input
6
1 1
1 2
2 2 1
1 3
2 5 2
1 4
16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Output
1 2 1 2 3 1 2 1 2 3 1 2 1 2 3 4
Submitted Solution:
```
from sys import stdin
inp = [tuple(map(int, i.split())) for i in stdin.readlines()]
ls = inp[-1]
a = []
for i in inp[1:-2]:
if i[0] == 1:
a.append(i[1])
else:
a += a[:i[1]] * i[2]
print(*a)
``` | instruction | 0 | 47,404 | 20 | 94,808 |
No | output | 1 | 47,404 | 20 | 94,809 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Sereja loves number sequences very much. That's why he decided to make himself a new one following a certain algorithm.
Sereja takes a blank piece of paper. Then he starts writing out the sequence in m stages. Each time he either adds a new number to the end of the sequence or takes l first elements of the current sequence and adds them c times to the end. More formally, if we represent the current sequence as a1, a2, ..., an, then after we apply the described operation, the sequence transforms into a1, a2, ..., an[, a1, a2, ..., al] (the block in the square brackets must be repeated c times).
A day has passed and Sereja has completed the sequence. He wonders what are the values of some of its elements. Help Sereja.
Input
The first line contains integer m (1 ≤ m ≤ 105) — the number of stages to build a sequence.
Next m lines contain the description of the stages in the order they follow. The first number in the line is a type of stage (1 or 2). Type 1 means adding one number to the end of the sequence, in this case the line contains integer xi (1 ≤ xi ≤ 105) — the number to add. Type 2 means copying a prefix of length li to the end ci times, in this case the line further contains two integers li, ci (1 ≤ li ≤ 105, 1 ≤ ci ≤ 104), li is the length of the prefix, ci is the number of copyings. It is guaranteed that the length of prefix li is never larger than the current length of the sequence.
The next line contains integer n (1 ≤ n ≤ 105) — the number of elements Sereja is interested in. The next line contains the numbers of elements of the final sequence Sereja is interested in. The numbers are given in the strictly increasing order. It is guaranteed that all numbers are strictly larger than zero and do not exceed the length of the resulting sequence. Consider the elements of the final sequence numbered starting from 1 from the beginning to the end of the sequence.
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.
Output
Print the elements that Sereja is interested in, in the order in which their numbers occur in the input.
Examples
Input
6
1 1
1 2
2 2 1
1 3
2 5 2
1 4
16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Output
1 2 1 2 3 1 2 1 2 3 1 2 1 2 3 4
Submitted Solution:
```
m = int(input())
a, b, start, end = [], [], 0, 0
idx = 0
for _ in range(m):
line = list(map(int, input().split()))
if line[0] == 1:
x = line[1]
start = end + 1
end = end + 1
if len(a) <= 100000:
a.append(x)
b.append((start, end, x))
else:
l, c = line[1], line[2]
start = end + 1
end = end + l * c
if len(a) <= 100000:
for _ in range(c):
a += a[:l]
if len(a) > 100000:
break
b.append((start, end, l, c))
input() # n
if m == 8198:
print("Ready")
def answer(n):
global m, a, b, idx
if m == 8198:
print("idx: %s" % idx)
if (n - 1) < len(a):
return a[n - 1]
while True:
bi = b[idx]
if bi[0] <= n <= bi[1]:
break
idx += 1
if m == 8198:
print("bi: %s (%s)" % (bi, idx))
if len(bi) == 3:
return bi[2]
n_bak = n
n = (n - bi[0]) % bi[2] + 1
if m == 8198:
print("n: %s => %s" % (n_bak, n))
return a[n - 1]
result = []
for n in map(int, input().split()):
if m == 8198:
print("n: %s" % n)
result.append("%s" % answer(n))
print(" ".join(result))
``` | instruction | 0 | 47,405 | 20 | 94,810 |
No | output | 1 | 47,405 | 20 | 94,811 |
Provide tags and a correct Python 3 solution for this coding contest problem.
During a New Year special offer the "Sudislavl Bars" offered n promo codes. Each promo code consists of exactly six digits and gives right to one free cocktail at the bar "Mosquito Shelter". Of course, all the promocodes differ.
As the "Mosquito Shelter" opens only at 9, and partying in Sudislavl usually begins at as early as 6, many problems may arise as to how to type a promotional code without errors. It is necessary to calculate such maximum k, that the promotional code could be uniquely identified if it was typed with no more than k errors. At that, k = 0 means that the promotional codes must be entered exactly.
A mistake in this problem should be considered as entering the wrong numbers. For example, value "123465" contains two errors relative to promocode "123456". Regardless of the number of errors the entered value consists of exactly six digits.
Input
The first line of the output contains number n (1 ≤ n ≤ 1000) — the number of promocodes.
Each of the next n lines contains a single promocode, consisting of exactly 6 digits. It is guaranteed that all the promocodes are distinct. Promocodes can start from digit "0".
Output
Print the maximum k (naturally, not exceeding the length of the promocode), such that any promocode can be uniquely identified if it is typed with at most k mistakes.
Examples
Input
2
000000
999999
Output
2
Input
6
211111
212111
222111
111111
112111
121111
Output
0
Note
In the first sample k < 3, so if a bar customer types in value "090909", then it will be impossible to define which promocode exactly corresponds to it. | instruction | 0 | 47,502 | 20 | 95,004 |
Tags: *special, brute force, constructive algorithms, implementation
Correct Solution:
```
def main():
from operator import eq
n, l, k = int(input()), [], 0
if n < 2:
print(6)
return
for _ in range(n):
a = input()
for b in l:
x = sum(map(eq, a, b))
if k < x:
k = x
if k > 4:
print(0)
return
l.append(a)
print(2 - k // 2)
if __name__ == '__main__':
main()
``` | output | 1 | 47,502 | 20 | 95,005 |
Provide tags and a correct Python 3 solution for this coding contest problem.
During a New Year special offer the "Sudislavl Bars" offered n promo codes. Each promo code consists of exactly six digits and gives right to one free cocktail at the bar "Mosquito Shelter". Of course, all the promocodes differ.
As the "Mosquito Shelter" opens only at 9, and partying in Sudislavl usually begins at as early as 6, many problems may arise as to how to type a promotional code without errors. It is necessary to calculate such maximum k, that the promotional code could be uniquely identified if it was typed with no more than k errors. At that, k = 0 means that the promotional codes must be entered exactly.
A mistake in this problem should be considered as entering the wrong numbers. For example, value "123465" contains two errors relative to promocode "123456". Regardless of the number of errors the entered value consists of exactly six digits.
Input
The first line of the output contains number n (1 ≤ n ≤ 1000) — the number of promocodes.
Each of the next n lines contains a single promocode, consisting of exactly 6 digits. It is guaranteed that all the promocodes are distinct. Promocodes can start from digit "0".
Output
Print the maximum k (naturally, not exceeding the length of the promocode), such that any promocode can be uniquely identified if it is typed with at most k mistakes.
Examples
Input
2
000000
999999
Output
2
Input
6
211111
212111
222111
111111
112111
121111
Output
0
Note
In the first sample k < 3, so if a bar customer types in value "090909", then it will be impossible to define which promocode exactly corresponds to it. | instruction | 0 | 47,503 | 20 | 95,006 |
Tags: *special, brute force, constructive algorithms, implementation
Correct Solution:
```
def similar_digits(num1,num2):
result = 0
for i in range(6):
if num1[i] == num2[i]:
result+=1
return result
def main():
number_of_codes = eval(input())
codes = []
for i in range(number_of_codes):
codes.append(input())
#k=3 - завжди будуть путати (4,5,6 так само)
#k=2? якщо зоча б 2 числа мають 2 однакові цифри то хана не більше ніж 1 однакова цифра
#k=1? якщо хоча б 2 числа мають 4 однакові цифри то хана не більше ніж 3 однакові цифри
#k=0? не більше ніж 5 однакових цифр
max_number_of_similar_digits = 0
answer = int
for i in range(number_of_codes-1):
for j in range(i+1,number_of_codes):
result = similar_digits(codes[i],codes[j])
#print('2 numbers: '+str(i+1)+' and '+str(j+1)+" --> "+str(result))
if result>max_number_of_similar_digits:
max_number_of_similar_digits = result
if result>=4:
answer = 0
break
if result>=4:
answer = 0
break
#print(max_number_of_similar_digits)
if max_number_of_similar_digits == 0 or max_number_of_similar_digits == 1:
answer = 2
if max_number_of_similar_digits == 2 or max_number_of_similar_digits == 3:
answer = 1
if number_of_codes == 1:
answer = 6
print(answer)
main()
``` | output | 1 | 47,503 | 20 | 95,007 |
Provide tags and a correct Python 3 solution for this coding contest problem.
During a New Year special offer the "Sudislavl Bars" offered n promo codes. Each promo code consists of exactly six digits and gives right to one free cocktail at the bar "Mosquito Shelter". Of course, all the promocodes differ.
As the "Mosquito Shelter" opens only at 9, and partying in Sudislavl usually begins at as early as 6, many problems may arise as to how to type a promotional code without errors. It is necessary to calculate such maximum k, that the promotional code could be uniquely identified if it was typed with no more than k errors. At that, k = 0 means that the promotional codes must be entered exactly.
A mistake in this problem should be considered as entering the wrong numbers. For example, value "123465" contains two errors relative to promocode "123456". Regardless of the number of errors the entered value consists of exactly six digits.
Input
The first line of the output contains number n (1 ≤ n ≤ 1000) — the number of promocodes.
Each of the next n lines contains a single promocode, consisting of exactly 6 digits. It is guaranteed that all the promocodes are distinct. Promocodes can start from digit "0".
Output
Print the maximum k (naturally, not exceeding the length of the promocode), such that any promocode can be uniquely identified if it is typed with at most k mistakes.
Examples
Input
2
000000
999999
Output
2
Input
6
211111
212111
222111
111111
112111
121111
Output
0
Note
In the first sample k < 3, so if a bar customer types in value "090909", then it will be impossible to define which promocode exactly corresponds to it. | instruction | 0 | 47,504 | 20 | 95,008 |
Tags: *special, brute force, constructive algorithms, implementation
Correct Solution:
```
n = int(input())
codes = []
for _ in range(n):
codes.append(input())
mx = 13
for i in range(1, n):
for j in range(i):
c = sum([1 if codes[i][l] != codes[j][l] else 0 for l in range(6)])
mx = min(c, mx)
print((mx - 1) // 2)
``` | output | 1 | 47,504 | 20 | 95,009 |
Provide tags and a correct Python 3 solution for this coding contest problem.
During a New Year special offer the "Sudislavl Bars" offered n promo codes. Each promo code consists of exactly six digits and gives right to one free cocktail at the bar "Mosquito Shelter". Of course, all the promocodes differ.
As the "Mosquito Shelter" opens only at 9, and partying in Sudislavl usually begins at as early as 6, many problems may arise as to how to type a promotional code without errors. It is necessary to calculate such maximum k, that the promotional code could be uniquely identified if it was typed with no more than k errors. At that, k = 0 means that the promotional codes must be entered exactly.
A mistake in this problem should be considered as entering the wrong numbers. For example, value "123465" contains two errors relative to promocode "123456". Regardless of the number of errors the entered value consists of exactly six digits.
Input
The first line of the output contains number n (1 ≤ n ≤ 1000) — the number of promocodes.
Each of the next n lines contains a single promocode, consisting of exactly 6 digits. It is guaranteed that all the promocodes are distinct. Promocodes can start from digit "0".
Output
Print the maximum k (naturally, not exceeding the length of the promocode), such that any promocode can be uniquely identified if it is typed with at most k mistakes.
Examples
Input
2
000000
999999
Output
2
Input
6
211111
212111
222111
111111
112111
121111
Output
0
Note
In the first sample k < 3, so if a bar customer types in value "090909", then it will be impossible to define which promocode exactly corresponds to it. | instruction | 0 | 47,505 | 20 | 95,010 |
Tags: *special, brute force, constructive algorithms, implementation
Correct Solution:
```
def main():
from operator import eq
n, l, k = int(input()), [], 0
if n < 2:
print(6)
return
for _ in range(n):
a = tuple(input())
for b in l:
x = sum(map(eq, a, b))
if k < x:
k = x
if k > 4:
print(0)
return
l.append(a)
print(2 - k // 2)
if __name__ == '__main__':
main()
``` | output | 1 | 47,505 | 20 | 95,011 |
Provide tags and a correct Python 3 solution for this coding contest problem.
During a New Year special offer the "Sudislavl Bars" offered n promo codes. Each promo code consists of exactly six digits and gives right to one free cocktail at the bar "Mosquito Shelter". Of course, all the promocodes differ.
As the "Mosquito Shelter" opens only at 9, and partying in Sudislavl usually begins at as early as 6, many problems may arise as to how to type a promotional code without errors. It is necessary to calculate such maximum k, that the promotional code could be uniquely identified if it was typed with no more than k errors. At that, k = 0 means that the promotional codes must be entered exactly.
A mistake in this problem should be considered as entering the wrong numbers. For example, value "123465" contains two errors relative to promocode "123456". Regardless of the number of errors the entered value consists of exactly six digits.
Input
The first line of the output contains number n (1 ≤ n ≤ 1000) — the number of promocodes.
Each of the next n lines contains a single promocode, consisting of exactly 6 digits. It is guaranteed that all the promocodes are distinct. Promocodes can start from digit "0".
Output
Print the maximum k (naturally, not exceeding the length of the promocode), such that any promocode can be uniquely identified if it is typed with at most k mistakes.
Examples
Input
2
000000
999999
Output
2
Input
6
211111
212111
222111
111111
112111
121111
Output
0
Note
In the first sample k < 3, so if a bar customer types in value "090909", then it will be impossible to define which promocode exactly corresponds to it. | instruction | 0 | 47,506 | 20 | 95,012 |
Tags: *special, brute force, constructive algorithms, implementation
Correct Solution:
```
n=int(input())
l=[input() for i in range(n)]
def d(a,b): return sum(1 for k in range(6) if l[a][k]!=l[b][k])-1
print(min({d(i,j) for i in range(n) for j in range(i+1,n)}|{12})//2)
``` | output | 1 | 47,506 | 20 | 95,013 |
Provide tags and a correct Python 3 solution for this coding contest problem.
During a New Year special offer the "Sudislavl Bars" offered n promo codes. Each promo code consists of exactly six digits and gives right to one free cocktail at the bar "Mosquito Shelter". Of course, all the promocodes differ.
As the "Mosquito Shelter" opens only at 9, and partying in Sudislavl usually begins at as early as 6, many problems may arise as to how to type a promotional code without errors. It is necessary to calculate such maximum k, that the promotional code could be uniquely identified if it was typed with no more than k errors. At that, k = 0 means that the promotional codes must be entered exactly.
A mistake in this problem should be considered as entering the wrong numbers. For example, value "123465" contains two errors relative to promocode "123456". Regardless of the number of errors the entered value consists of exactly six digits.
Input
The first line of the output contains number n (1 ≤ n ≤ 1000) — the number of promocodes.
Each of the next n lines contains a single promocode, consisting of exactly 6 digits. It is guaranteed that all the promocodes are distinct. Promocodes can start from digit "0".
Output
Print the maximum k (naturally, not exceeding the length of the promocode), such that any promocode can be uniquely identified if it is typed with at most k mistakes.
Examples
Input
2
000000
999999
Output
2
Input
6
211111
212111
222111
111111
112111
121111
Output
0
Note
In the first sample k < 3, so if a bar customer types in value "090909", then it will be impossible to define which promocode exactly corresponds to it. | instruction | 0 | 47,507 | 20 | 95,014 |
Tags: *special, brute force, constructive algorithms, implementation
Correct Solution:
```
import os
import sys
from io import BytesIO, IOBase
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")
##########################################################
#q.sort(key=lambda x:((x[1]-x[0]),-x[0]))
#from collections import Counter
#from fractions import Fraction
from bisect import bisect_left
from collections import Counter
#s=iter(input())
#from collections import deque
#ls=list(map(int,input().split()))
#for in range(m):
#for _ in range(int(input())):
#n=int(input())
# n,k=map(int,input().split())
# arr=list(map(int,input().split()))
#for i in range(int(input())):
#n=int(input())
#arr=sorted([(x,i) for i,x in enumerate(map(int,input().split()))])[::-1]
#print(arr)
#arr=sorted(list(map(int,input().split())))[::-1]
n=int(input())
ls=[input() for i in range(n)]
#print(ls)
m=6
if n==1:
print(6)
exit()
for i in range(n):
for j in range(i+1,n):
cnt=0
for k in range(6):
if ls[i][k]!=ls[j][k]:
cnt+=1
m=min(m,cnt)
if m==1 or m==2 or m==0:
print(0)
exit()
if m==3 or m==4:
print(1)
if m>=5:
print(2)
``` | output | 1 | 47,507 | 20 | 95,015 |
Provide tags and a correct Python 3 solution for this coding contest problem.
During a New Year special offer the "Sudislavl Bars" offered n promo codes. Each promo code consists of exactly six digits and gives right to one free cocktail at the bar "Mosquito Shelter". Of course, all the promocodes differ.
As the "Mosquito Shelter" opens only at 9, and partying in Sudislavl usually begins at as early as 6, many problems may arise as to how to type a promotional code without errors. It is necessary to calculate such maximum k, that the promotional code could be uniquely identified if it was typed with no more than k errors. At that, k = 0 means that the promotional codes must be entered exactly.
A mistake in this problem should be considered as entering the wrong numbers. For example, value "123465" contains two errors relative to promocode "123456". Regardless of the number of errors the entered value consists of exactly six digits.
Input
The first line of the output contains number n (1 ≤ n ≤ 1000) — the number of promocodes.
Each of the next n lines contains a single promocode, consisting of exactly 6 digits. It is guaranteed that all the promocodes are distinct. Promocodes can start from digit "0".
Output
Print the maximum k (naturally, not exceeding the length of the promocode), such that any promocode can be uniquely identified if it is typed with at most k mistakes.
Examples
Input
2
000000
999999
Output
2
Input
6
211111
212111
222111
111111
112111
121111
Output
0
Note
In the first sample k < 3, so if a bar customer types in value "090909", then it will be impossible to define which promocode exactly corresponds to it. | instruction | 0 | 47,508 | 20 | 95,016 |
Tags: *special, brute force, constructive algorithms, implementation
Correct Solution:
```
from sys import stdin
n = int(input())
if n == 1:
print(6)
exit()
arr = stdin.read().strip().splitlines()
ans = 6
for i in range(n):
for j in range(i + 1, n):
s = 0
for k in [0, 1, 2, 3, 4, 5]:
if arr[i][k] == arr[j][k]:
s += 1
if s < 2:
ans = min(ans, 2)
elif s < 4:
ans = 1
elif s < 6:
print(0)
exit()
print(ans)
``` | output | 1 | 47,508 | 20 | 95,017 |
Provide tags and a correct Python 3 solution for this coding contest problem.
During a New Year special offer the "Sudislavl Bars" offered n promo codes. Each promo code consists of exactly six digits and gives right to one free cocktail at the bar "Mosquito Shelter". Of course, all the promocodes differ.
As the "Mosquito Shelter" opens only at 9, and partying in Sudislavl usually begins at as early as 6, many problems may arise as to how to type a promotional code without errors. It is necessary to calculate such maximum k, that the promotional code could be uniquely identified if it was typed with no more than k errors. At that, k = 0 means that the promotional codes must be entered exactly.
A mistake in this problem should be considered as entering the wrong numbers. For example, value "123465" contains two errors relative to promocode "123456". Regardless of the number of errors the entered value consists of exactly six digits.
Input
The first line of the output contains number n (1 ≤ n ≤ 1000) — the number of promocodes.
Each of the next n lines contains a single promocode, consisting of exactly 6 digits. It is guaranteed that all the promocodes are distinct. Promocodes can start from digit "0".
Output
Print the maximum k (naturally, not exceeding the length of the promocode), such that any promocode can be uniquely identified if it is typed with at most k mistakes.
Examples
Input
2
000000
999999
Output
2
Input
6
211111
212111
222111
111111
112111
121111
Output
0
Note
In the first sample k < 3, so if a bar customer types in value "090909", then it will be impossible to define which promocode exactly corresponds to it. | instruction | 0 | 47,509 | 20 | 95,018 |
Tags: *special, brute force, constructive algorithms, implementation
Correct Solution:
```
count = int(input())
if count == 1:
print('6')
else:
hamming = 6
codes = []
for _ in range(count):
new_code = input()
for code in codes:
distance = 0
distance += 0 if new_code[0] == code[0] else 1
distance += 0 if new_code[1] == code[1] else 1
distance += 0 if new_code[2] == code[2] else 1
distance += 0 if new_code[3] == code[3] else 1
distance += 0 if new_code[4] == code[4] else 1
distance += 0 if new_code[5] == code[5] else 1
hamming = min(hamming, distance)
codes.append(new_code)
print(int(hamming/2 - 0.5))
``` | output | 1 | 47,509 | 20 | 95,019 |
Provide tags and a correct Python 3 solution for this coding contest problem.
For each positive integer n consider the integer ψ(n) which is obtained from n by replacing every digit a in the decimal notation of n with the digit (9 - a). We say that ψ(n) is the reflection of n. For example, reflection of 192 equals 807. Note that leading zeros (if any) should be omitted. So reflection of 9 equals 0, reflection of 91 equals 8.
Let us call the weight of the number the product of the number and its reflection. Thus, the weight of the number 10 is equal to 10·89 = 890.
Your task is to find the maximum weight of the numbers in the given range [l, r] (boundaries are included).
Input
Input contains two space-separated integers l and r (1 ≤ l ≤ r ≤ 109) — bounds of the range.
Output
Output should contain single integer number: maximum value of the product n·ψ(n), where l ≤ n ≤ r.
Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preferred to use cout (also you may use %I64d).
Examples
Input
3 7
Output
20
Input
1 1
Output
8
Input
8 10
Output
890
Note
In the third sample weight of 8 equals 8·1 = 8, weight of 9 equals 9·0 = 0, weight of 10 equals 890.
Thus, maximum value of the product is equal to 890. | instruction | 0 | 47,606 | 20 | 95,212 |
Tags: math
Correct Solution:
```
def reflection(num):
tmp = []
numlist = list(str(num))
for el in numlist:
i = int(el)
ni = 9-i
if ni == 0 and len(tmp) == 0:
continue
tmp.append(str(ni))
if not tmp:
return 0
return int("".join(tmp))
def solve(l, r):
result = 0
result = max(result, l*reflection(l))
result = max(result, r*reflection(r))
start = 0
while 5*(10**start) <= l:
start += 1
while 5*(10**start) <= r:
cur_num = 5*(10**start)
result = max(result, cur_num*reflection(cur_num))
start += 1
return result
l, r = map(int, input().split())
result = solve(l, r)
print(result)
``` | output | 1 | 47,606 | 20 | 95,213 |
Provide tags and a correct Python 3 solution for this coding contest problem.
For each positive integer n consider the integer ψ(n) which is obtained from n by replacing every digit a in the decimal notation of n with the digit (9 - a). We say that ψ(n) is the reflection of n. For example, reflection of 192 equals 807. Note that leading zeros (if any) should be omitted. So reflection of 9 equals 0, reflection of 91 equals 8.
Let us call the weight of the number the product of the number and its reflection. Thus, the weight of the number 10 is equal to 10·89 = 890.
Your task is to find the maximum weight of the numbers in the given range [l, r] (boundaries are included).
Input
Input contains two space-separated integers l and r (1 ≤ l ≤ r ≤ 109) — bounds of the range.
Output
Output should contain single integer number: maximum value of the product n·ψ(n), where l ≤ n ≤ r.
Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preferred to use cout (also you may use %I64d).
Examples
Input
3 7
Output
20
Input
1 1
Output
8
Input
8 10
Output
890
Note
In the third sample weight of 8 equals 8·1 = 8, weight of 9 equals 9·0 = 0, weight of 10 equals 890.
Thus, maximum value of the product is equal to 890. | instruction | 0 | 47,607 | 20 | 95,214 |
Tags: math
Correct Solution:
```
def ref(n):
return int(''.join([str(9-int(x)) for x in str(n)]))
l,r=map(int,input().split())
ans=0
ans=max(ans,ref(l)*l)
ans=max(ans,ref(r)*r)
cur=5
for i in range(20):
if(l<=cur<=r):
ans=max(ans,ref(cur)*cur)
cur*=10
print(ans)
``` | output | 1 | 47,607 | 20 | 95,215 |
Provide tags and a correct Python 3 solution for this coding contest problem.
For each positive integer n consider the integer ψ(n) which is obtained from n by replacing every digit a in the decimal notation of n with the digit (9 - a). We say that ψ(n) is the reflection of n. For example, reflection of 192 equals 807. Note that leading zeros (if any) should be omitted. So reflection of 9 equals 0, reflection of 91 equals 8.
Let us call the weight of the number the product of the number and its reflection. Thus, the weight of the number 10 is equal to 10·89 = 890.
Your task is to find the maximum weight of the numbers in the given range [l, r] (boundaries are included).
Input
Input contains two space-separated integers l and r (1 ≤ l ≤ r ≤ 109) — bounds of the range.
Output
Output should contain single integer number: maximum value of the product n·ψ(n), where l ≤ n ≤ r.
Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preferred to use cout (also you may use %I64d).
Examples
Input
3 7
Output
20
Input
1 1
Output
8
Input
8 10
Output
890
Note
In the third sample weight of 8 equals 8·1 = 8, weight of 9 equals 9·0 = 0, weight of 10 equals 890.
Thus, maximum value of the product is equal to 890. | instruction | 0 | 47,608 | 20 | 95,216 |
Tags: math
Correct Solution:
```
def prod(n):
x=str(n)
y=['0']*len(x)
for i in range(len(x)):
y[i]=str(9-int(x[i]))
while y[0]=='0':
if len(y)==1:
return 0
else:
y=y[1:len(y)]
return int(x)*int(''.join(y))
ip=[int(i) for i in input().split()]
a,b=ip[0],ip[1]
x,y=len(str(a)),len(str(b))
if x<y:
if b<int('5'+'0'*(y-1)):
print(prod(b))
raise SystemExit
print(prod(int('5'+'0'*(y-1))))
raise SystemExit
if b<int('5'+'0'*(y-1)):
print(prod(b))
raise SystemExit
if a>int('5'+'0'*(y-1)):
print(prod(a))
raise SystemExit
print(prod(int('5'+'0'*(y-1))))
``` | output | 1 | 47,608 | 20 | 95,217 |
Provide tags and a correct Python 3 solution for this coding contest problem.
For each positive integer n consider the integer ψ(n) which is obtained from n by replacing every digit a in the decimal notation of n with the digit (9 - a). We say that ψ(n) is the reflection of n. For example, reflection of 192 equals 807. Note that leading zeros (if any) should be omitted. So reflection of 9 equals 0, reflection of 91 equals 8.
Let us call the weight of the number the product of the number and its reflection. Thus, the weight of the number 10 is equal to 10·89 = 890.
Your task is to find the maximum weight of the numbers in the given range [l, r] (boundaries are included).
Input
Input contains two space-separated integers l and r (1 ≤ l ≤ r ≤ 109) — bounds of the range.
Output
Output should contain single integer number: maximum value of the product n·ψ(n), where l ≤ n ≤ r.
Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preferred to use cout (also you may use %I64d).
Examples
Input
3 7
Output
20
Input
1 1
Output
8
Input
8 10
Output
890
Note
In the third sample weight of 8 equals 8·1 = 8, weight of 9 equals 9·0 = 0, weight of 10 equals 890.
Thus, maximum value of the product is equal to 890. | instruction | 0 | 47,609 | 20 | 95,218 |
Tags: math
Correct Solution:
```
def d(n):
w=""
for i in str(n):
w+=str(9-int(i))
return int(w)*n
l,r=map(int,input().split())
r=str(r)
tr='5'+'0'*(len(r)-1)
tr=int(tr)
r=int(r)
if l<tr<=r:
print(max(d(l),d(r),d(tr)))
else:
print(max(d(l),d(r)))
``` | output | 1 | 47,609 | 20 | 95,219 |
Provide tags and a correct Python 3 solution for this coding contest problem.
For each positive integer n consider the integer ψ(n) which is obtained from n by replacing every digit a in the decimal notation of n with the digit (9 - a). We say that ψ(n) is the reflection of n. For example, reflection of 192 equals 807. Note that leading zeros (if any) should be omitted. So reflection of 9 equals 0, reflection of 91 equals 8.
Let us call the weight of the number the product of the number and its reflection. Thus, the weight of the number 10 is equal to 10·89 = 890.
Your task is to find the maximum weight of the numbers in the given range [l, r] (boundaries are included).
Input
Input contains two space-separated integers l and r (1 ≤ l ≤ r ≤ 109) — bounds of the range.
Output
Output should contain single integer number: maximum value of the product n·ψ(n), where l ≤ n ≤ r.
Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preferred to use cout (also you may use %I64d).
Examples
Input
3 7
Output
20
Input
1 1
Output
8
Input
8 10
Output
890
Note
In the third sample weight of 8 equals 8·1 = 8, weight of 9 equals 9·0 = 0, weight of 10 equals 890.
Thus, maximum value of the product is equal to 890. | instruction | 0 | 47,610 | 20 | 95,220 |
Tags: math
Correct Solution:
```
l,r=map(int,input().split(" "))
x=len(str(r))
m='9'*x
m=int(m)
m1='1'+'0'*(x-1)
m1=int(m1)
ans=max(l*(m-l),r*(m-r))
if l<=m1<=r:
ans=max(ans,m1*(m-m1))
if l<=m//2<=r:
ans=max(ans,(m//2)*(m-m//2))
if l<=m//2+1<=r:
ans=max(ans,(m//2+1)*(m-m//2-1))
print(ans)
``` | output | 1 | 47,610 | 20 | 95,221 |
Provide tags and a correct Python 3 solution for this coding contest problem.
For each positive integer n consider the integer ψ(n) which is obtained from n by replacing every digit a in the decimal notation of n with the digit (9 - a). We say that ψ(n) is the reflection of n. For example, reflection of 192 equals 807. Note that leading zeros (if any) should be omitted. So reflection of 9 equals 0, reflection of 91 equals 8.
Let us call the weight of the number the product of the number and its reflection. Thus, the weight of the number 10 is equal to 10·89 = 890.
Your task is to find the maximum weight of the numbers in the given range [l, r] (boundaries are included).
Input
Input contains two space-separated integers l and r (1 ≤ l ≤ r ≤ 109) — bounds of the range.
Output
Output should contain single integer number: maximum value of the product n·ψ(n), where l ≤ n ≤ r.
Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preferred to use cout (also you may use %I64d).
Examples
Input
3 7
Output
20
Input
1 1
Output
8
Input
8 10
Output
890
Note
In the third sample weight of 8 equals 8·1 = 8, weight of 9 equals 9·0 = 0, weight of 10 equals 890.
Thus, maximum value of the product is equal to 890. | instruction | 0 | 47,611 | 20 | 95,222 |
Tags: math
Correct Solution:
```
L,R=map(int,input().split())
pw=1
while pw<=R: pw*=10
if R<pw/2-1:
print(R*(pw-R-1))
else:
if pw / L >= 10: L = pw / 10
if L > pw/2:
print(L*(pw - L - 1))
else:
print((pw//2)*(pw//2-1))
``` | output | 1 | 47,611 | 20 | 95,223 |
Provide tags and a correct Python 3 solution for this coding contest problem.
For each positive integer n consider the integer ψ(n) which is obtained from n by replacing every digit a in the decimal notation of n with the digit (9 - a). We say that ψ(n) is the reflection of n. For example, reflection of 192 equals 807. Note that leading zeros (if any) should be omitted. So reflection of 9 equals 0, reflection of 91 equals 8.
Let us call the weight of the number the product of the number and its reflection. Thus, the weight of the number 10 is equal to 10·89 = 890.
Your task is to find the maximum weight of the numbers in the given range [l, r] (boundaries are included).
Input
Input contains two space-separated integers l and r (1 ≤ l ≤ r ≤ 109) — bounds of the range.
Output
Output should contain single integer number: maximum value of the product n·ψ(n), where l ≤ n ≤ r.
Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preferred to use cout (also you may use %I64d).
Examples
Input
3 7
Output
20
Input
1 1
Output
8
Input
8 10
Output
890
Note
In the third sample weight of 8 equals 8·1 = 8, weight of 9 equals 9·0 = 0, weight of 10 equals 890.
Thus, maximum value of the product is equal to 890. | instruction | 0 | 47,612 | 20 | 95,224 |
Tags: math
Correct Solution:
```
l,r=map(int,input().split())
digits=lambda x: len(str(x))
f=lambda n: n* int(''.join(map(str, (9-x for x in map(int,str(n))))))
def maxInDigits(l,r):
mid=int(''.join(['5']+['0']*(digits(l)-1)))
if (r<=mid): return f(r)
if (l>=mid): return f(l)
return f(mid)
if (digits(l)==digits(r)): print(maxInDigits(l,r))
elif (digits(r)==digits(l)+1):
print(max(maxInDigits(l,10**digits(l)-1),maxInDigits(10**(digits(r)-1),r)))
else:
print(max(maxInDigits(10**(digits(r)-2),10**(digits(r)-1)-1),maxInDigits(10**(digits(r)-1),r)))
``` | output | 1 | 47,612 | 20 | 95,225 |
Provide tags and a correct Python 3 solution for this coding contest problem.
For each positive integer n consider the integer ψ(n) which is obtained from n by replacing every digit a in the decimal notation of n with the digit (9 - a). We say that ψ(n) is the reflection of n. For example, reflection of 192 equals 807. Note that leading zeros (if any) should be omitted. So reflection of 9 equals 0, reflection of 91 equals 8.
Let us call the weight of the number the product of the number and its reflection. Thus, the weight of the number 10 is equal to 10·89 = 890.
Your task is to find the maximum weight of the numbers in the given range [l, r] (boundaries are included).
Input
Input contains two space-separated integers l and r (1 ≤ l ≤ r ≤ 109) — bounds of the range.
Output
Output should contain single integer number: maximum value of the product n·ψ(n), where l ≤ n ≤ r.
Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preferred to use cout (also you may use %I64d).
Examples
Input
3 7
Output
20
Input
1 1
Output
8
Input
8 10
Output
890
Note
In the third sample weight of 8 equals 8·1 = 8, weight of 9 equals 9·0 = 0, weight of 10 equals 890.
Thus, maximum value of the product is equal to 890. | instruction | 0 | 47,613 | 20 | 95,226 |
Tags: math
Correct Solution:
```
inp1, inp2 = [int(i) for i in input().split()]
lista = list()
def reverse(n):
newStr = ""
for c in str(n):
newC = 9 - int(c)
newStr += str(newC)
l = len(str(n))
d = "9"*l
d = int(d)
newStr = d - int(n)
return int(newStr)
le = len(str(inp2)) - 1
digit = 5 * (10 ** le)
if digit > inp2:
print(reverse(inp2)*inp2)
elif digit < inp1:
print(reverse(inp1)*inp1)
else:
print(reverse(digit)*digit)
``` | output | 1 | 47,613 | 20 | 95,227 |
Provide a correct Python 3 solution for this coding contest problem.
You are given a three-digit positive integer N.
Determine whether N is a palindromic number.
Here, a palindromic number is an integer that reads the same backward as forward in decimal notation.
Constraints
* 100≤N≤999
* N is an integer.
Input
Input is given from Standard Input in the following format:
N
Output
If N is a palindromic number, print `Yes`; otherwise, print `No`.
Examples
Input
575
Output
Yes
Input
123
Output
No
Input
812
Output
No | instruction | 0 | 47,800 | 20 | 95,600 |
"Correct Solution:
```
S = input()
print("Yes" if S==S[::-1] else "No")
``` | output | 1 | 47,800 | 20 | 95,601 |
Provide a correct Python 3 solution for this coding contest problem.
You are given a three-digit positive integer N.
Determine whether N is a palindromic number.
Here, a palindromic number is an integer that reads the same backward as forward in decimal notation.
Constraints
* 100≤N≤999
* N is an integer.
Input
Input is given from Standard Input in the following format:
N
Output
If N is a palindromic number, print `Yes`; otherwise, print `No`.
Examples
Input
575
Output
Yes
Input
123
Output
No
Input
812
Output
No | instruction | 0 | 47,801 | 20 | 95,602 |
"Correct Solution:
```
s=input();print("YNeos"[s!=s[::-1]::2])
``` | output | 1 | 47,801 | 20 | 95,603 |
Provide a correct Python 3 solution for this coding contest problem.
You are given a three-digit positive integer N.
Determine whether N is a palindromic number.
Here, a palindromic number is an integer that reads the same backward as forward in decimal notation.
Constraints
* 100≤N≤999
* N is an integer.
Input
Input is given from Standard Input in the following format:
N
Output
If N is a palindromic number, print `Yes`; otherwise, print `No`.
Examples
Input
575
Output
Yes
Input
123
Output
No
Input
812
Output
No | instruction | 0 | 47,802 | 20 | 95,604 |
"Correct Solution:
```
n=input()
print(["No","Yes"][n[0]==n[2]])
``` | output | 1 | 47,802 | 20 | 95,605 |
Provide a correct Python 3 solution for this coding contest problem.
You are given a three-digit positive integer N.
Determine whether N is a palindromic number.
Here, a palindromic number is an integer that reads the same backward as forward in decimal notation.
Constraints
* 100≤N≤999
* N is an integer.
Input
Input is given from Standard Input in the following format:
N
Output
If N is a palindromic number, print `Yes`; otherwise, print `No`.
Examples
Input
575
Output
Yes
Input
123
Output
No
Input
812
Output
No | instruction | 0 | 47,803 | 20 | 95,606 |
"Correct Solution:
```
n=input()
print(("No","Yes")[n==n[::-1]])
``` | output | 1 | 47,803 | 20 | 95,607 |
Provide a correct Python 3 solution for this coding contest problem.
You are given a three-digit positive integer N.
Determine whether N is a palindromic number.
Here, a palindromic number is an integer that reads the same backward as forward in decimal notation.
Constraints
* 100≤N≤999
* N is an integer.
Input
Input is given from Standard Input in the following format:
N
Output
If N is a palindromic number, print `Yes`; otherwise, print `No`.
Examples
Input
575
Output
Yes
Input
123
Output
No
Input
812
Output
No | instruction | 0 | 47,804 | 20 | 95,608 |
"Correct Solution:
```
n=input()
print("Yes") if n == n[::-1] else print("No")
``` | output | 1 | 47,804 | 20 | 95,609 |
Provide a correct Python 3 solution for this coding contest problem.
You are given a three-digit positive integer N.
Determine whether N is a palindromic number.
Here, a palindromic number is an integer that reads the same backward as forward in decimal notation.
Constraints
* 100≤N≤999
* N is an integer.
Input
Input is given from Standard Input in the following format:
N
Output
If N is a palindromic number, print `Yes`; otherwise, print `No`.
Examples
Input
575
Output
Yes
Input
123
Output
No
Input
812
Output
No | instruction | 0 | 47,805 | 20 | 95,610 |
"Correct Solution:
```
a=input()
print(["No","Yes"][a[0]==a[2]])
``` | output | 1 | 47,805 | 20 | 95,611 |
Provide a correct Python 3 solution for this coding contest problem.
You are given a three-digit positive integer N.
Determine whether N is a palindromic number.
Here, a palindromic number is an integer that reads the same backward as forward in decimal notation.
Constraints
* 100≤N≤999
* N is an integer.
Input
Input is given from Standard Input in the following format:
N
Output
If N is a palindromic number, print `Yes`; otherwise, print `No`.
Examples
Input
575
Output
Yes
Input
123
Output
No
Input
812
Output
No | instruction | 0 | 47,806 | 20 | 95,612 |
"Correct Solution:
```
N = input()
print("YNeos"[N!=N[::-1]::2])
``` | output | 1 | 47,806 | 20 | 95,613 |
Provide a correct Python 3 solution for this coding contest problem.
You are given a three-digit positive integer N.
Determine whether N is a palindromic number.
Here, a palindromic number is an integer that reads the same backward as forward in decimal notation.
Constraints
* 100≤N≤999
* N is an integer.
Input
Input is given from Standard Input in the following format:
N
Output
If N is a palindromic number, print `Yes`; otherwise, print `No`.
Examples
Input
575
Output
Yes
Input
123
Output
No
Input
812
Output
No | instruction | 0 | 47,807 | 20 | 95,614 |
"Correct Solution:
```
N = input()
print('Yes' if N == N[-1::-1] else 'No')
``` | output | 1 | 47,807 | 20 | 95,615 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a three-digit positive integer N.
Determine whether N is a palindromic number.
Here, a palindromic number is an integer that reads the same backward as forward in decimal notation.
Constraints
* 100≤N≤999
* N is an integer.
Input
Input is given from Standard Input in the following format:
N
Output
If N is a palindromic number, print `Yes`; otherwise, print `No`.
Examples
Input
575
Output
Yes
Input
123
Output
No
Input
812
Output
No
Submitted Solution:
```
n=input()
print("Yes" if n[::-1]==n else "No")
``` | instruction | 0 | 47,809 | 20 | 95,618 |
Yes | output | 1 | 47,809 | 20 | 95,619 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a three-digit positive integer N.
Determine whether N is a palindromic number.
Here, a palindromic number is an integer that reads the same backward as forward in decimal notation.
Constraints
* 100≤N≤999
* N is an integer.
Input
Input is given from Standard Input in the following format:
N
Output
If N is a palindromic number, print `Yes`; otherwise, print `No`.
Examples
Input
575
Output
Yes
Input
123
Output
No
Input
812
Output
No
Submitted Solution:
```
n=input();i=(n==n[::-1])^1;print("YNeos"[i::2])
``` | instruction | 0 | 47,810 | 20 | 95,620 |
Yes | output | 1 | 47,810 | 20 | 95,621 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.