message
stringlengths
2
59.7k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
37
108k
cluster
float64
20
20
__index_level_0__
int64
74
217k
Provide a correct Python 3 solution for this coding contest problem. A positive integer X is said to be a lunlun number if and only if the following condition is satisfied: * In the base ten representation of X (without leading zeros), for every pair of two adjacent digits, the absolute difference of those digits is at most 1. For example, 1234, 1, and 334 are lunlun numbers, while none of 31415, 119, or 13579 is. You are given a positive integer K. Find the K-th smallest lunlun number. Constraints * 1 \leq K \leq 10^5 * All values in input are integers. Input Input is given from Standard Input in the following format: K Output Print the answer. Examples Input 15 Output 23 Input 1 Output 1 Input 13 Output 21 Input 100000 Output 3234566667
instruction
0
45,179
20
90,358
"Correct Solution: ``` K = int(input()) l = list(range(1,10)) for x in l: if x > 3234566667: break back = int(str(x)[-1]) for b in [back-1, back, back+1]: if 0 <= b <= 9: l.append(10*x + b) print(l[K-1]) ```
output
1
45,179
20
90,359
Provide a correct Python 3 solution for this coding contest problem. A positive integer X is said to be a lunlun number if and only if the following condition is satisfied: * In the base ten representation of X (without leading zeros), for every pair of two adjacent digits, the absolute difference of those digits is at most 1. For example, 1234, 1, and 334 are lunlun numbers, while none of 31415, 119, or 13579 is. You are given a positive integer K. Find the K-th smallest lunlun number. Constraints * 1 \leq K \leq 10^5 * All values in input are integers. Input Input is given from Standard Input in the following format: K Output Print the answer. Examples Input 15 Output 23 Input 1 Output 1 Input 13 Output 21 Input 100000 Output 3234566667
instruction
0
45,180
20
90,360
"Correct Solution: ``` import collections K=int(input()) q = collections.deque([1,2,3,4,5,6,7,8,9]) for i in range(K-1): t = q.popleft() if t%10!=0: q.append(t*10+t%10-1) q.append(t*10+t%10) if t%10!=9: q.append(t*10+t%10+1) print(q.popleft()) ```
output
1
45,180
20
90,361
Provide a correct Python 3 solution for this coding contest problem. A positive integer X is said to be a lunlun number if and only if the following condition is satisfied: * In the base ten representation of X (without leading zeros), for every pair of two adjacent digits, the absolute difference of those digits is at most 1. For example, 1234, 1, and 334 are lunlun numbers, while none of 31415, 119, or 13579 is. You are given a positive integer K. Find the K-th smallest lunlun number. Constraints * 1 \leq K \leq 10^5 * All values in input are integers. Input Input is given from Standard Input in the following format: K Output Print the answer. Examples Input 15 Output 23 Input 1 Output 1 Input 13 Output 21 Input 100000 Output 3234566667
instruction
0
45,181
20
90,362
"Correct Solution: ``` K = int(input()) num = list(range(1, 10)) for i in range(K): a = num[i] b = 10 * a + a % 10 if a % 10 != 0: num.append(b - 1) num.append(b) if a % 10 != 9: num.append(b + 1) if len(num) == K: break print(num[K - 1]) ```
output
1
45,181
20
90,363
Provide a correct Python 3 solution for this coding contest problem. A positive integer X is said to be a lunlun number if and only if the following condition is satisfied: * In the base ten representation of X (without leading zeros), for every pair of two adjacent digits, the absolute difference of those digits is at most 1. For example, 1234, 1, and 334 are lunlun numbers, while none of 31415, 119, or 13579 is. You are given a positive integer K. Find the K-th smallest lunlun number. Constraints * 1 \leq K \leq 10^5 * All values in input are integers. Input Input is given from Standard Input in the following format: K Output Print the answer. Examples Input 15 Output 23 Input 1 Output 1 Input 13 Output 21 Input 100000 Output 3234566667
instruction
0
45,182
20
90,364
"Correct Solution: ``` k=int(input()) a=[] def judge(x): if x> 3234566667: return a.append(x) for i in range(10): if abs(x%10-i)<=1: judge(x*10+i) for i in range(1,10): judge(i) a.sort() print(a[k-1]) ```
output
1
45,182
20
90,365
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A positive integer X is said to be a lunlun number if and only if the following condition is satisfied: * In the base ten representation of X (without leading zeros), for every pair of two adjacent digits, the absolute difference of those digits is at most 1. For example, 1234, 1, and 334 are lunlun numbers, while none of 31415, 119, or 13579 is. You are given a positive integer K. Find the K-th smallest lunlun number. Constraints * 1 \leq K \leq 10^5 * All values in input are integers. Input Input is given from Standard Input in the following format: K Output Print the answer. Examples Input 15 Output 23 Input 1 Output 1 Input 13 Output 21 Input 100000 Output 3234566667 Submitted Solution: ``` k = int(input()) table = [1, 2, 3, 4, 5, 6, 7, 8, 9] for i in table: if len(table) > k: break x = i % 10 for j in range(max(0, x - 1), min(x + 2, 10)): table.append(i * 10 + j) print(table[k - 1]) ```
instruction
0
45,184
20
90,368
Yes
output
1
45,184
20
90,369
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A positive integer X is said to be a lunlun number if and only if the following condition is satisfied: * In the base ten representation of X (without leading zeros), for every pair of two adjacent digits, the absolute difference of those digits is at most 1. For example, 1234, 1, and 334 are lunlun numbers, while none of 31415, 119, or 13579 is. You are given a positive integer K. Find the K-th smallest lunlun number. Constraints * 1 \leq K \leq 10^5 * All values in input are integers. Input Input is given from Standard Input in the following format: K Output Print the answer. Examples Input 15 Output 23 Input 1 Output 1 Input 13 Output 21 Input 100000 Output 3234566667 Submitted Solution: ``` K=int(input()) if K<10: print(K);exit() def dfs(v,n): u=[] for x in v: for d in [-1,0,1]: if(0<=x%10+d<=9): u.append(x*10+x%10+d) if(n+len(u)>=K): u.sort() print(u[K-n-1]) else: dfs(u,n+len(u)) dfs(range(1,10),9); ```
instruction
0
45,186
20
90,372
Yes
output
1
45,186
20
90,373
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A positive integer X is said to be a lunlun number if and only if the following condition is satisfied: * In the base ten representation of X (without leading zeros), for every pair of two adjacent digits, the absolute difference of those digits is at most 1. For example, 1234, 1, and 334 are lunlun numbers, while none of 31415, 119, or 13579 is. You are given a positive integer K. Find the K-th smallest lunlun number. Constraints * 1 \leq K \leq 10^5 * All values in input are integers. Input Input is given from Standard Input in the following format: K Output Print the answer. Examples Input 15 Output 23 Input 1 Output 1 Input 13 Output 21 Input 100000 Output 3234566667 Submitted Solution: ``` K = int(input()) p = [] for i in range(1,10): p.append(i) for i in range(K): if p[0] % 10 != 0: p.append(10*p[0]+p[0]%10-1) p.append(10*p[0]+p[0]%10) if p[0] % 10 != 9: p.append(10*p[0]+p[0]%10+1) q = p[0] p.remove(p[0]) print(q) ```
instruction
0
45,187
20
90,374
No
output
1
45,187
20
90,375
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A positive integer X is said to be a lunlun number if and only if the following condition is satisfied: * In the base ten representation of X (without leading zeros), for every pair of two adjacent digits, the absolute difference of those digits is at most 1. For example, 1234, 1, and 334 are lunlun numbers, while none of 31415, 119, or 13579 is. You are given a positive integer K. Find the K-th smallest lunlun number. Constraints * 1 \leq K \leq 10^5 * All values in input are integers. Input Input is given from Standard Input in the following format: K Output Print the answer. Examples Input 15 Output 23 Input 1 Output 1 Input 13 Output 21 Input 100000 Output 3234566667 Submitted Solution: ``` K=int(input()) a=0 i=0 while i<K: u=0 a+=1 s=str(a) for j in range(len(s)-1): if abs(int(s[j])-int(s[j+1]))>1: break u+=1 if u==len(s)-1: i+=1 print(a) ```
instruction
0
45,188
20
90,376
No
output
1
45,188
20
90,377
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A positive integer X is said to be a lunlun number if and only if the following condition is satisfied: * In the base ten representation of X (without leading zeros), for every pair of two adjacent digits, the absolute difference of those digits is at most 1. For example, 1234, 1, and 334 are lunlun numbers, while none of 31415, 119, or 13579 is. You are given a positive integer K. Find the K-th smallest lunlun number. Constraints * 1 \leq K \leq 10^5 * All values in input are integers. Input Input is given from Standard Input in the following format: K Output Print the answer. Examples Input 15 Output 23 Input 1 Output 1 Input 13 Output 21 Input 100000 Output 3234566667 Submitted Solution: ``` K = int(input()) ansli=[] for i in range(1, 10**9): if len(ansli)==K: print(ansli[K-1]) exit() if 1<= i <=9: ansli.append(i) continue stri = str(i) leni = len(stri) for ii in range(leni-1): if int(stri[ii]) == int(stri[ii+1])-1 or \ int(stri[ii]) == int(stri[ii+1]) or \ int(stri[ii]) == int(stri[ii+1])+1: pass else: break if ii==leni-2: ansli.append(i) ```
instruction
0
45,189
20
90,378
No
output
1
45,189
20
90,379
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A positive integer X is said to be a lunlun number if and only if the following condition is satisfied: * In the base ten representation of X (without leading zeros), for every pair of two adjacent digits, the absolute difference of those digits is at most 1. For example, 1234, 1, and 334 are lunlun numbers, while none of 31415, 119, or 13579 is. You are given a positive integer K. Find the K-th smallest lunlun number. Constraints * 1 \leq K \leq 10^5 * All values in input are integers. Input Input is given from Standard Input in the following format: K Output Print the answer. Examples Input 15 Output 23 Input 1 Output 1 Input 13 Output 21 Input 100000 Output 3234566667 Submitted Solution: ``` def lunlun(x): c=0 l=list(str(x)) for i in range(len(l)): l[i]=int(l[i]) l.sort() c=0 for i in range(1,len(l)): if abs(l[i]-l[i-1])<=1: c=c+1 if c==len(l)-1: return True else: return False n=int(input()) c=0 i=1 while c!=n: if lunlun(i): c=c+1 i=i+1 print(i-1) ```
instruction
0
45,190
20
90,380
No
output
1
45,190
20
90,381
Provide tags and a correct Python 3 solution for this coding contest problem. Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya recently learned to determine whether a string of lowercase Latin letters is lucky. For each individual letter all its positions in the string are written out in the increasing order. This results in 26 lists of numbers; some of them can be empty. A string is considered lucky if and only if in each list the absolute difference of any two adjacent numbers is a lucky number. For example, let's consider string "zbcdzefdzc". The lists of positions of equal letters are: * b: 2 * c: 3, 10 * d: 4, 8 * e: 6 * f: 7 * z: 1, 5, 9 * Lists of positions of letters a, g, h, ..., y are empty. This string is lucky as all differences are lucky numbers. For letters z: 5 - 1 = 4, 9 - 5 = 4, for letters c: 10 - 3 = 7, for letters d: 8 - 4 = 4. Note that if some letter occurs only once in a string, it doesn't influence the string's luckiness after building the lists of positions of equal letters. The string where all the letters are distinct is considered lucky. Find the lexicographically minimal lucky string whose length equals n. Input The single line contains a positive integer n (1 ≀ n ≀ 105) β€” the length of the sought string. Output Print on the single line the lexicographically minimal lucky string whose length equals n. Examples Input 5 Output abcda Input 3 Output abc Note The lexical comparison of strings is performed by the < operator in modern programming languages. String a is lexicographically less than string b if exists such i (1 ≀ i ≀ n), that ai < bi, and for any j (1 ≀ j < i) aj = bj.
instruction
0
45,418
20
90,836
Tags: constructive algorithms, strings Correct Solution: ``` def main(): n = int(input()) s = ['a', 'b', 'c', 'd'] * n return ''.join(s)[:n] print(main()) ```
output
1
45,418
20
90,837
Provide tags and a correct Python 3 solution for this coding contest problem. Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya recently learned to determine whether a string of lowercase Latin letters is lucky. For each individual letter all its positions in the string are written out in the increasing order. This results in 26 lists of numbers; some of them can be empty. A string is considered lucky if and only if in each list the absolute difference of any two adjacent numbers is a lucky number. For example, let's consider string "zbcdzefdzc". The lists of positions of equal letters are: * b: 2 * c: 3, 10 * d: 4, 8 * e: 6 * f: 7 * z: 1, 5, 9 * Lists of positions of letters a, g, h, ..., y are empty. This string is lucky as all differences are lucky numbers. For letters z: 5 - 1 = 4, 9 - 5 = 4, for letters c: 10 - 3 = 7, for letters d: 8 - 4 = 4. Note that if some letter occurs only once in a string, it doesn't influence the string's luckiness after building the lists of positions of equal letters. The string where all the letters are distinct is considered lucky. Find the lexicographically minimal lucky string whose length equals n. Input The single line contains a positive integer n (1 ≀ n ≀ 105) β€” the length of the sought string. Output Print on the single line the lexicographically minimal lucky string whose length equals n. Examples Input 5 Output abcda Input 3 Output abc Note The lexical comparison of strings is performed by the < operator in modern programming languages. String a is lexicographically less than string b if exists such i (1 ≀ i ≀ n), that ai < bi, and for any j (1 ≀ j < i) aj = bj.
instruction
0
45,419
20
90,838
Tags: constructive algorithms, strings Correct Solution: ``` n = int(input()) if n % 4 == 0: print("abcd" * (n // 4)) else: print("abcd" * (n // 4) + "abcd"[:n % 4]) ```
output
1
45,419
20
90,839
Provide tags and a correct Python 3 solution for this coding contest problem. Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya recently learned to determine whether a string of lowercase Latin letters is lucky. For each individual letter all its positions in the string are written out in the increasing order. This results in 26 lists of numbers; some of them can be empty. A string is considered lucky if and only if in each list the absolute difference of any two adjacent numbers is a lucky number. For example, let's consider string "zbcdzefdzc". The lists of positions of equal letters are: * b: 2 * c: 3, 10 * d: 4, 8 * e: 6 * f: 7 * z: 1, 5, 9 * Lists of positions of letters a, g, h, ..., y are empty. This string is lucky as all differences are lucky numbers. For letters z: 5 - 1 = 4, 9 - 5 = 4, for letters c: 10 - 3 = 7, for letters d: 8 - 4 = 4. Note that if some letter occurs only once in a string, it doesn't influence the string's luckiness after building the lists of positions of equal letters. The string where all the letters are distinct is considered lucky. Find the lexicographically minimal lucky string whose length equals n. Input The single line contains a positive integer n (1 ≀ n ≀ 105) β€” the length of the sought string. Output Print on the single line the lexicographically minimal lucky string whose length equals n. Examples Input 5 Output abcda Input 3 Output abc Note The lexical comparison of strings is performed by the < operator in modern programming languages. String a is lexicographically less than string b if exists such i (1 ≀ i ≀ n), that ai < bi, and for any j (1 ≀ j < i) aj = bj.
instruction
0
45,420
20
90,840
Tags: constructive algorithms, strings Correct Solution: ``` n = int(input()) s = "abcd" answer = (n // 4)*s + s[:n % 4] print(answer) ```
output
1
45,420
20
90,841
Provide tags and a correct Python 3 solution for this coding contest problem. Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya recently learned to determine whether a string of lowercase Latin letters is lucky. For each individual letter all its positions in the string are written out in the increasing order. This results in 26 lists of numbers; some of them can be empty. A string is considered lucky if and only if in each list the absolute difference of any two adjacent numbers is a lucky number. For example, let's consider string "zbcdzefdzc". The lists of positions of equal letters are: * b: 2 * c: 3, 10 * d: 4, 8 * e: 6 * f: 7 * z: 1, 5, 9 * Lists of positions of letters a, g, h, ..., y are empty. This string is lucky as all differences are lucky numbers. For letters z: 5 - 1 = 4, 9 - 5 = 4, for letters c: 10 - 3 = 7, for letters d: 8 - 4 = 4. Note that if some letter occurs only once in a string, it doesn't influence the string's luckiness after building the lists of positions of equal letters. The string where all the letters are distinct is considered lucky. Find the lexicographically minimal lucky string whose length equals n. Input The single line contains a positive integer n (1 ≀ n ≀ 105) β€” the length of the sought string. Output Print on the single line the lexicographically minimal lucky string whose length equals n. Examples Input 5 Output abcda Input 3 Output abc Note The lexical comparison of strings is performed by the < operator in modern programming languages. String a is lexicographically less than string b if exists such i (1 ≀ i ≀ n), that ai < bi, and for any j (1 ≀ j < i) aj = bj.
instruction
0
45,421
20
90,842
Tags: constructive algorithms, strings Correct Solution: ``` s = "abcdefghijklmnopqrstuvwxyz" n = int(input()) if n<5: print(s[:n]) else: rotation = n//4 remain = n%4 ans= "" for _ in range(rotation): ans += s[:4] ans += s[:remain] print(ans) ```
output
1
45,421
20
90,843
Provide tags and a correct Python 3 solution for this coding contest problem. Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya recently learned to determine whether a string of lowercase Latin letters is lucky. For each individual letter all its positions in the string are written out in the increasing order. This results in 26 lists of numbers; some of them can be empty. A string is considered lucky if and only if in each list the absolute difference of any two adjacent numbers is a lucky number. For example, let's consider string "zbcdzefdzc". The lists of positions of equal letters are: * b: 2 * c: 3, 10 * d: 4, 8 * e: 6 * f: 7 * z: 1, 5, 9 * Lists of positions of letters a, g, h, ..., y are empty. This string is lucky as all differences are lucky numbers. For letters z: 5 - 1 = 4, 9 - 5 = 4, for letters c: 10 - 3 = 7, for letters d: 8 - 4 = 4. Note that if some letter occurs only once in a string, it doesn't influence the string's luckiness after building the lists of positions of equal letters. The string where all the letters are distinct is considered lucky. Find the lexicographically minimal lucky string whose length equals n. Input The single line contains a positive integer n (1 ≀ n ≀ 105) β€” the length of the sought string. Output Print on the single line the lexicographically minimal lucky string whose length equals n. Examples Input 5 Output abcda Input 3 Output abc Note The lexical comparison of strings is performed by the < operator in modern programming languages. String a is lexicographically less than string b if exists such i (1 ≀ i ≀ n), that ai < bi, and for any j (1 ≀ j < i) aj = bj.
instruction
0
45,422
20
90,844
Tags: constructive algorithms, strings Correct Solution: ``` a = int(input()) b = "abcd" answer = b * (a // 4) if a % 4 == 1: answer += 'a' elif a % 4 == 2: answer += 'ab' elif a % 4 == 3: answer += 'abc' print(answer) ```
output
1
45,422
20
90,845
Provide tags and a correct Python 3 solution for this coding contest problem. Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya recently learned to determine whether a string of lowercase Latin letters is lucky. For each individual letter all its positions in the string are written out in the increasing order. This results in 26 lists of numbers; some of them can be empty. A string is considered lucky if and only if in each list the absolute difference of any two adjacent numbers is a lucky number. For example, let's consider string "zbcdzefdzc". The lists of positions of equal letters are: * b: 2 * c: 3, 10 * d: 4, 8 * e: 6 * f: 7 * z: 1, 5, 9 * Lists of positions of letters a, g, h, ..., y are empty. This string is lucky as all differences are lucky numbers. For letters z: 5 - 1 = 4, 9 - 5 = 4, for letters c: 10 - 3 = 7, for letters d: 8 - 4 = 4. Note that if some letter occurs only once in a string, it doesn't influence the string's luckiness after building the lists of positions of equal letters. The string where all the letters are distinct is considered lucky. Find the lexicographically minimal lucky string whose length equals n. Input The single line contains a positive integer n (1 ≀ n ≀ 105) β€” the length of the sought string. Output Print on the single line the lexicographically minimal lucky string whose length equals n. Examples Input 5 Output abcda Input 3 Output abc Note The lexical comparison of strings is performed by the < operator in modern programming languages. String a is lexicographically less than string b if exists such i (1 ≀ i ≀ n), that ai < bi, and for any j (1 ≀ j < i) aj = bj.
instruction
0
45,423
20
90,846
Tags: constructive algorithms, strings Correct Solution: ``` import math n = int(input()) case1 = 'a' case2 = 'ab' case3 = 'abc' str = 'abcd' divident = math.floor(n/4) modulus = n % 4 extra = '' if (modulus == 1): extra = case1 elif (modulus == 2): extra = case2 elif (modulus == 3): extra = case3 print(divident*str + extra) ```
output
1
45,423
20
90,847
Provide tags and a correct Python 3 solution for this coding contest problem. Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya recently learned to determine whether a string of lowercase Latin letters is lucky. For each individual letter all its positions in the string are written out in the increasing order. This results in 26 lists of numbers; some of them can be empty. A string is considered lucky if and only if in each list the absolute difference of any two adjacent numbers is a lucky number. For example, let's consider string "zbcdzefdzc". The lists of positions of equal letters are: * b: 2 * c: 3, 10 * d: 4, 8 * e: 6 * f: 7 * z: 1, 5, 9 * Lists of positions of letters a, g, h, ..., y are empty. This string is lucky as all differences are lucky numbers. For letters z: 5 - 1 = 4, 9 - 5 = 4, for letters c: 10 - 3 = 7, for letters d: 8 - 4 = 4. Note that if some letter occurs only once in a string, it doesn't influence the string's luckiness after building the lists of positions of equal letters. The string where all the letters are distinct is considered lucky. Find the lexicographically minimal lucky string whose length equals n. Input The single line contains a positive integer n (1 ≀ n ≀ 105) β€” the length of the sought string. Output Print on the single line the lexicographically minimal lucky string whose length equals n. Examples Input 5 Output abcda Input 3 Output abc Note The lexical comparison of strings is performed by the < operator in modern programming languages. String a is lexicographically less than string b if exists such i (1 ≀ i ≀ n), that ai < bi, and for any j (1 ≀ j < i) aj = bj.
instruction
0
45,424
20
90,848
Tags: constructive algorithms, strings Correct Solution: ``` n = int(input()) for i in range(1,n+1): if i % 4 == 1: print("a",sep = '',end = '') elif i % 4 == 2: print("b",sep = '',end = '') elif i % 4 == 3: print("c",sep = '',end = '') elif i % 4 == 0: print("d",sep = '',end = '') ```
output
1
45,424
20
90,849
Provide tags and a correct Python 3 solution for this coding contest problem. Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya recently learned to determine whether a string of lowercase Latin letters is lucky. For each individual letter all its positions in the string are written out in the increasing order. This results in 26 lists of numbers; some of them can be empty. A string is considered lucky if and only if in each list the absolute difference of any two adjacent numbers is a lucky number. For example, let's consider string "zbcdzefdzc". The lists of positions of equal letters are: * b: 2 * c: 3, 10 * d: 4, 8 * e: 6 * f: 7 * z: 1, 5, 9 * Lists of positions of letters a, g, h, ..., y are empty. This string is lucky as all differences are lucky numbers. For letters z: 5 - 1 = 4, 9 - 5 = 4, for letters c: 10 - 3 = 7, for letters d: 8 - 4 = 4. Note that if some letter occurs only once in a string, it doesn't influence the string's luckiness after building the lists of positions of equal letters. The string where all the letters are distinct is considered lucky. Find the lexicographically minimal lucky string whose length equals n. Input The single line contains a positive integer n (1 ≀ n ≀ 105) β€” the length of the sought string. Output Print on the single line the lexicographically minimal lucky string whose length equals n. Examples Input 5 Output abcda Input 3 Output abc Note The lexical comparison of strings is performed by the < operator in modern programming languages. String a is lexicographically less than string b if exists such i (1 ≀ i ≀ n), that ai < bi, and for any j (1 ≀ j < i) aj = bj.
instruction
0
45,425
20
90,850
Tags: constructive algorithms, strings Correct Solution: ``` n = int(input()) s = "dabc" for i in range(1,n+1): print(s[i % 4],end = '',sep = '') ```
output
1
45,425
20
90,851
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya recently learned to determine whether a string of lowercase Latin letters is lucky. For each individual letter all its positions in the string are written out in the increasing order. This results in 26 lists of numbers; some of them can be empty. A string is considered lucky if and only if in each list the absolute difference of any two adjacent numbers is a lucky number. For example, let's consider string "zbcdzefdzc". The lists of positions of equal letters are: * b: 2 * c: 3, 10 * d: 4, 8 * e: 6 * f: 7 * z: 1, 5, 9 * Lists of positions of letters a, g, h, ..., y are empty. This string is lucky as all differences are lucky numbers. For letters z: 5 - 1 = 4, 9 - 5 = 4, for letters c: 10 - 3 = 7, for letters d: 8 - 4 = 4. Note that if some letter occurs only once in a string, it doesn't influence the string's luckiness after building the lists of positions of equal letters. The string where all the letters are distinct is considered lucky. Find the lexicographically minimal lucky string whose length equals n. Input The single line contains a positive integer n (1 ≀ n ≀ 105) β€” the length of the sought string. Output Print on the single line the lexicographically minimal lucky string whose length equals n. Examples Input 5 Output abcda Input 3 Output abc Note The lexical comparison of strings is performed by the < operator in modern programming languages. String a is lexicographically less than string b if exists such i (1 ≀ i ≀ n), that ai < bi, and for any j (1 ≀ j < i) aj = bj. Submitted Solution: ``` n = int(input()) s = "" a='a' for i in range(n): if i%4==0 and i!=0: a='a' s+=a a=chr(ord(a)+1) print(s) ```
instruction
0
45,426
20
90,852
Yes
output
1
45,426
20
90,853
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya recently learned to determine whether a string of lowercase Latin letters is lucky. For each individual letter all its positions in the string are written out in the increasing order. This results in 26 lists of numbers; some of them can be empty. A string is considered lucky if and only if in each list the absolute difference of any two adjacent numbers is a lucky number. For example, let's consider string "zbcdzefdzc". The lists of positions of equal letters are: * b: 2 * c: 3, 10 * d: 4, 8 * e: 6 * f: 7 * z: 1, 5, 9 * Lists of positions of letters a, g, h, ..., y are empty. This string is lucky as all differences are lucky numbers. For letters z: 5 - 1 = 4, 9 - 5 = 4, for letters c: 10 - 3 = 7, for letters d: 8 - 4 = 4. Note that if some letter occurs only once in a string, it doesn't influence the string's luckiness after building the lists of positions of equal letters. The string where all the letters are distinct is considered lucky. Find the lexicographically minimal lucky string whose length equals n. Input The single line contains a positive integer n (1 ≀ n ≀ 105) β€” the length of the sought string. Output Print on the single line the lexicographically minimal lucky string whose length equals n. Examples Input 5 Output abcda Input 3 Output abc Note The lexical comparison of strings is performed by the < operator in modern programming languages. String a is lexicographically less than string b if exists such i (1 ≀ i ≀ n), that ai < bi, and for any j (1 ≀ j < i) aj = bj. Submitted Solution: ``` n=int(input()) t='abcd'*(10**5+1) print(t[:n]) ```
instruction
0
45,427
20
90,854
Yes
output
1
45,427
20
90,855
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya recently learned to determine whether a string of lowercase Latin letters is lucky. For each individual letter all its positions in the string are written out in the increasing order. This results in 26 lists of numbers; some of them can be empty. A string is considered lucky if and only if in each list the absolute difference of any two adjacent numbers is a lucky number. For example, let's consider string "zbcdzefdzc". The lists of positions of equal letters are: * b: 2 * c: 3, 10 * d: 4, 8 * e: 6 * f: 7 * z: 1, 5, 9 * Lists of positions of letters a, g, h, ..., y are empty. This string is lucky as all differences are lucky numbers. For letters z: 5 - 1 = 4, 9 - 5 = 4, for letters c: 10 - 3 = 7, for letters d: 8 - 4 = 4. Note that if some letter occurs only once in a string, it doesn't influence the string's luckiness after building the lists of positions of equal letters. The string where all the letters are distinct is considered lucky. Find the lexicographically minimal lucky string whose length equals n. Input The single line contains a positive integer n (1 ≀ n ≀ 105) β€” the length of the sought string. Output Print on the single line the lexicographically minimal lucky string whose length equals n. Examples Input 5 Output abcda Input 3 Output abc Note The lexical comparison of strings is performed by the < operator in modern programming languages. String a is lexicographically less than string b if exists such i (1 ≀ i ≀ n), that ai < bi, and for any j (1 ≀ j < i) aj = bj. Submitted Solution: ``` import sys import math import bisect def solve(n): A = [] for i in range(n): if i % 4 == 0: A.append('a') elif i % 4 == 1: A.append('b') elif i % 4 == 2: A.append('c') elif i % 4 == 3: A.append('d') return ''.join(A) def main(): n = int(input()) ans = solve(n) print(ans) if __name__ == "__main__": main() ```
instruction
0
45,428
20
90,856
Yes
output
1
45,428
20
90,857
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya recently learned to determine whether a string of lowercase Latin letters is lucky. For each individual letter all its positions in the string are written out in the increasing order. This results in 26 lists of numbers; some of them can be empty. A string is considered lucky if and only if in each list the absolute difference of any two adjacent numbers is a lucky number. For example, let's consider string "zbcdzefdzc". The lists of positions of equal letters are: * b: 2 * c: 3, 10 * d: 4, 8 * e: 6 * f: 7 * z: 1, 5, 9 * Lists of positions of letters a, g, h, ..., y are empty. This string is lucky as all differences are lucky numbers. For letters z: 5 - 1 = 4, 9 - 5 = 4, for letters c: 10 - 3 = 7, for letters d: 8 - 4 = 4. Note that if some letter occurs only once in a string, it doesn't influence the string's luckiness after building the lists of positions of equal letters. The string where all the letters are distinct is considered lucky. Find the lexicographically minimal lucky string whose length equals n. Input The single line contains a positive integer n (1 ≀ n ≀ 105) β€” the length of the sought string. Output Print on the single line the lexicographically minimal lucky string whose length equals n. Examples Input 5 Output abcda Input 3 Output abc Note The lexical comparison of strings is performed by the < operator in modern programming languages. String a is lexicographically less than string b if exists such i (1 ≀ i ≀ n), that ai < bi, and for any j (1 ≀ j < i) aj = bj. Submitted Solution: ``` ''' /* aa a a a a a a nn n k k aa r r aaaaaaaaaa n n n k k a a rr^ a a n n n kk aaaaaa r a a n nn k kk a a r */ /* ****************************************************************************************** ************** *************** ************** *** *********** *** ************* ************* ******~******** *** *********** *** ********** **** ******* ************ ************ **** ************* **** *********** *** ********* ***** ******* *********** *********** ****** ************ ***** ********** *** ******** ****** ******* *********** ********** ******** *********** ****** ********* *** ******* ******* ******* *********** ********* ********** ********** ******* ******** *** ****** ******** ************ ******** ************ ********* ******** ******* *** ***** ******** ***** ************** ******* ************** ******** ********* ****** *** ********** ****** ************* ****** ******* ********** ***** *** ***** ********* ******* ************ ***** ****************** ****** *********** **** *** ****** ******** ******** *********** **** ******************** ***** ************ *** *** ******* ******* ********* ********** *** ********************** **** ************* ** *** ******** ****** ********** ********* ** ************************ *** ************** *** ********* ***** *********** ******* ****************************************************************************************** ****************************************************************************************** */ ''' n=int(input()) s="" for i in range(1,n+1): if i%4==0: s+="d" if i%4==1: s+="a" if i%4==2: s+="b" if i%4==3: s+="c" print(s) ```
instruction
0
45,429
20
90,858
Yes
output
1
45,429
20
90,859
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya recently learned to determine whether a string of lowercase Latin letters is lucky. For each individual letter all its positions in the string are written out in the increasing order. This results in 26 lists of numbers; some of them can be empty. A string is considered lucky if and only if in each list the absolute difference of any two adjacent numbers is a lucky number. For example, let's consider string "zbcdzefdzc". The lists of positions of equal letters are: * b: 2 * c: 3, 10 * d: 4, 8 * e: 6 * f: 7 * z: 1, 5, 9 * Lists of positions of letters a, g, h, ..., y are empty. This string is lucky as all differences are lucky numbers. For letters z: 5 - 1 = 4, 9 - 5 = 4, for letters c: 10 - 3 = 7, for letters d: 8 - 4 = 4. Note that if some letter occurs only once in a string, it doesn't influence the string's luckiness after building the lists of positions of equal letters. The string where all the letters are distinct is considered lucky. Find the lexicographically minimal lucky string whose length equals n. Input The single line contains a positive integer n (1 ≀ n ≀ 105) β€” the length of the sought string. Output Print on the single line the lexicographically minimal lucky string whose length equals n. Examples Input 5 Output abcda Input 3 Output abc Note The lexical comparison of strings is performed by the < operator in modern programming languages. String a is lexicographically less than string b if exists such i (1 ≀ i ≀ n), that ai < bi, and for any j (1 ≀ j < i) aj = bj. Submitted Solution: ``` import sys from collections import Counter def fmax(m): s ='abcd' if m <= 4: return s[:m] if m>4: c ='' for i in range(m//4): c = c+s r = m%4 if r== 0: return c if r!=0: return c+s[:r] if __name__ == '__main__': input = sys.stdin.read() data = list(map(int, input.split())) m = data[0] ```
instruction
0
45,430
20
90,860
No
output
1
45,430
20
90,861
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya recently learned to determine whether a string of lowercase Latin letters is lucky. For each individual letter all its positions in the string are written out in the increasing order. This results in 26 lists of numbers; some of them can be empty. A string is considered lucky if and only if in each list the absolute difference of any two adjacent numbers is a lucky number. For example, let's consider string "zbcdzefdzc". The lists of positions of equal letters are: * b: 2 * c: 3, 10 * d: 4, 8 * e: 6 * f: 7 * z: 1, 5, 9 * Lists of positions of letters a, g, h, ..., y are empty. This string is lucky as all differences are lucky numbers. For letters z: 5 - 1 = 4, 9 - 5 = 4, for letters c: 10 - 3 = 7, for letters d: 8 - 4 = 4. Note that if some letter occurs only once in a string, it doesn't influence the string's luckiness after building the lists of positions of equal letters. The string where all the letters are distinct is considered lucky. Find the lexicographically minimal lucky string whose length equals n. Input The single line contains a positive integer n (1 ≀ n ≀ 105) β€” the length of the sought string. Output Print on the single line the lexicographically minimal lucky string whose length equals n. Examples Input 5 Output abcda Input 3 Output abc Note The lexical comparison of strings is performed by the < operator in modern programming languages. String a is lexicographically less than string b if exists such i (1 ≀ i ≀ n), that ai < bi, and for any j (1 ≀ j < i) aj = bj. Submitted Solution: ``` a=int(input()) b=a%4 s="abcd"*(a//4) s=s+s[:b] print(s) ```
instruction
0
45,431
20
90,862
No
output
1
45,431
20
90,863
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya recently learned to determine whether a string of lowercase Latin letters is lucky. For each individual letter all its positions in the string are written out in the increasing order. This results in 26 lists of numbers; some of them can be empty. A string is considered lucky if and only if in each list the absolute difference of any two adjacent numbers is a lucky number. For example, let's consider string "zbcdzefdzc". The lists of positions of equal letters are: * b: 2 * c: 3, 10 * d: 4, 8 * e: 6 * f: 7 * z: 1, 5, 9 * Lists of positions of letters a, g, h, ..., y are empty. This string is lucky as all differences are lucky numbers. For letters z: 5 - 1 = 4, 9 - 5 = 4, for letters c: 10 - 3 = 7, for letters d: 8 - 4 = 4. Note that if some letter occurs only once in a string, it doesn't influence the string's luckiness after building the lists of positions of equal letters. The string where all the letters are distinct is considered lucky. Find the lexicographically minimal lucky string whose length equals n. Input The single line contains a positive integer n (1 ≀ n ≀ 105) β€” the length of the sought string. Output Print on the single line the lexicographically minimal lucky string whose length equals n. Examples Input 5 Output abcda Input 3 Output abc Note The lexical comparison of strings is performed by the < operator in modern programming languages. String a is lexicographically less than string b if exists such i (1 ≀ i ≀ n), that ai < bi, and for any j (1 ≀ j < i) aj = bj. Submitted Solution: ``` n = int(input("Input : ")) s = "abcd" * (n // 4) + "abcd"[0 : n % 4] print(s) ```
instruction
0
45,432
20
90,864
No
output
1
45,432
20
90,865
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya recently learned to determine whether a string of lowercase Latin letters is lucky. For each individual letter all its positions in the string are written out in the increasing order. This results in 26 lists of numbers; some of them can be empty. A string is considered lucky if and only if in each list the absolute difference of any two adjacent numbers is a lucky number. For example, let's consider string "zbcdzefdzc". The lists of positions of equal letters are: * b: 2 * c: 3, 10 * d: 4, 8 * e: 6 * f: 7 * z: 1, 5, 9 * Lists of positions of letters a, g, h, ..., y are empty. This string is lucky as all differences are lucky numbers. For letters z: 5 - 1 = 4, 9 - 5 = 4, for letters c: 10 - 3 = 7, for letters d: 8 - 4 = 4. Note that if some letter occurs only once in a string, it doesn't influence the string's luckiness after building the lists of positions of equal letters. The string where all the letters are distinct is considered lucky. Find the lexicographically minimal lucky string whose length equals n. Input The single line contains a positive integer n (1 ≀ n ≀ 105) β€” the length of the sought string. Output Print on the single line the lexicographically minimal lucky string whose length equals n. Examples Input 5 Output abcda Input 3 Output abc Note The lexical comparison of strings is performed by the < operator in modern programming languages. String a is lexicographically less than string b if exists such i (1 ≀ i ≀ n), that ai < bi, and for any j (1 ≀ j < i) aj = bj. Submitted Solution: ``` n=int(input()) s="abcdabcdabcda"*10000 print(s[:n]) ```
instruction
0
45,433
20
90,866
No
output
1
45,433
20
90,867
Provide tags and a correct Python 3 solution for this coding contest problem. The Smart Beaver from ABBYY invented a new message encryption method and now wants to check its performance. Checking it manually is long and tiresome, so he decided to ask the ABBYY Cup contestants for help. A message is a sequence of n integers a1, a2, ..., an. Encryption uses a key which is a sequence of m integers b1, b2, ..., bm (m ≀ n). All numbers from the message and from the key belong to the interval from 0 to c - 1, inclusive, and all the calculations are performed modulo c. Encryption is performed in n - m + 1 steps. On the first step we add to each number a1, a2, ..., am a corresponding number b1, b2, ..., bm. On the second step we add to each number a2, a3, ..., am + 1 (changed on the previous step) a corresponding number b1, b2, ..., bm. And so on: on step number i we add to each number ai, ai + 1, ..., ai + m - 1 a corresponding number b1, b2, ..., bm. The result of the encryption is the sequence a1, a2, ..., an after n - m + 1 steps. Help the Beaver to write a program that will encrypt messages in the described manner. Input The first input line contains three integers n, m and c, separated by single spaces. The second input line contains n integers ai (0 ≀ ai < c), separated by single spaces β€” the original message. The third input line contains m integers bi (0 ≀ bi < c), separated by single spaces β€” the encryption key. The input limitations for getting 30 points are: * 1 ≀ m ≀ n ≀ 103 * 1 ≀ c ≀ 103 The input limitations for getting 100 points are: * 1 ≀ m ≀ n ≀ 105 * 1 ≀ c ≀ 103 Output Print n space-separated integers β€” the result of encrypting the original message. Examples Input 4 3 2 1 1 1 1 1 1 1 Output 0 1 1 0 Input 3 1 5 1 2 3 4 Output 0 1 2 Note In the first sample the encryption is performed in two steps: after the first step a = (0, 0, 0, 1) (remember that the calculations are performed modulo 2), after the second step a = (0, 1, 1, 0), and that is the answer.
instruction
0
45,652
20
91,304
Tags: brute force Correct Solution: ``` n,m,c=list(map(int,input().split())) a=list(map(int,input().split())) b=list(map(int,input().split())) for i in range(n-m+1): for j in range(m): a[j+i]+=b[j] a[j+i]%=c print(*a) ```
output
1
45,652
20
91,305
Provide tags and a correct Python 3 solution for this coding contest problem. The Smart Beaver from ABBYY invented a new message encryption method and now wants to check its performance. Checking it manually is long and tiresome, so he decided to ask the ABBYY Cup contestants for help. A message is a sequence of n integers a1, a2, ..., an. Encryption uses a key which is a sequence of m integers b1, b2, ..., bm (m ≀ n). All numbers from the message and from the key belong to the interval from 0 to c - 1, inclusive, and all the calculations are performed modulo c. Encryption is performed in n - m + 1 steps. On the first step we add to each number a1, a2, ..., am a corresponding number b1, b2, ..., bm. On the second step we add to each number a2, a3, ..., am + 1 (changed on the previous step) a corresponding number b1, b2, ..., bm. And so on: on step number i we add to each number ai, ai + 1, ..., ai + m - 1 a corresponding number b1, b2, ..., bm. The result of the encryption is the sequence a1, a2, ..., an after n - m + 1 steps. Help the Beaver to write a program that will encrypt messages in the described manner. Input The first input line contains three integers n, m and c, separated by single spaces. The second input line contains n integers ai (0 ≀ ai < c), separated by single spaces β€” the original message. The third input line contains m integers bi (0 ≀ bi < c), separated by single spaces β€” the encryption key. The input limitations for getting 30 points are: * 1 ≀ m ≀ n ≀ 103 * 1 ≀ c ≀ 103 The input limitations for getting 100 points are: * 1 ≀ m ≀ n ≀ 105 * 1 ≀ c ≀ 103 Output Print n space-separated integers β€” the result of encrypting the original message. Examples Input 4 3 2 1 1 1 1 1 1 1 Output 0 1 1 0 Input 3 1 5 1 2 3 4 Output 0 1 2 Note In the first sample the encryption is performed in two steps: after the first step a = (0, 0, 0, 1) (remember that the calculations are performed modulo 2), after the second step a = (0, 1, 1, 0), and that is the answer.
instruction
0
45,653
20
91,306
Tags: brute force Correct Solution: ``` n, m, c = map(int, input().split()) N = list(map(int, input().split())) M = list(map(int, input().split())) SM = [0] for v in M: SM += [SM[-1] + v] answer = [] for i, v in enumerate(N): if i + len(M) < len(N): l = 0 else: l = len(M) - len(N) + i if i < len(M): r = i else: r = len(M) - 1 answer += [(N[i] + SM[r+1] - SM[l]) % c] print(" ".join(map(str, answer))) ```
output
1
45,653
20
91,307
Provide tags and a correct Python 3 solution for this coding contest problem. The Smart Beaver from ABBYY invented a new message encryption method and now wants to check its performance. Checking it manually is long and tiresome, so he decided to ask the ABBYY Cup contestants for help. A message is a sequence of n integers a1, a2, ..., an. Encryption uses a key which is a sequence of m integers b1, b2, ..., bm (m ≀ n). All numbers from the message and from the key belong to the interval from 0 to c - 1, inclusive, and all the calculations are performed modulo c. Encryption is performed in n - m + 1 steps. On the first step we add to each number a1, a2, ..., am a corresponding number b1, b2, ..., bm. On the second step we add to each number a2, a3, ..., am + 1 (changed on the previous step) a corresponding number b1, b2, ..., bm. And so on: on step number i we add to each number ai, ai + 1, ..., ai + m - 1 a corresponding number b1, b2, ..., bm. The result of the encryption is the sequence a1, a2, ..., an after n - m + 1 steps. Help the Beaver to write a program that will encrypt messages in the described manner. Input The first input line contains three integers n, m and c, separated by single spaces. The second input line contains n integers ai (0 ≀ ai < c), separated by single spaces β€” the original message. The third input line contains m integers bi (0 ≀ bi < c), separated by single spaces β€” the encryption key. The input limitations for getting 30 points are: * 1 ≀ m ≀ n ≀ 103 * 1 ≀ c ≀ 103 The input limitations for getting 100 points are: * 1 ≀ m ≀ n ≀ 105 * 1 ≀ c ≀ 103 Output Print n space-separated integers β€” the result of encrypting the original message. Examples Input 4 3 2 1 1 1 1 1 1 1 Output 0 1 1 0 Input 3 1 5 1 2 3 4 Output 0 1 2 Note In the first sample the encryption is performed in two steps: after the first step a = (0, 0, 0, 1) (remember that the calculations are performed modulo 2), after the second step a = (0, 1, 1, 0), and that is the answer.
instruction
0
45,654
20
91,308
Tags: brute force Correct Solution: ``` n,m,c = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) pre=[0]*m suf=[0]*(m+1) ans=[0]*n lp = min(m,n-m+1) j=-2 for i in range(m): pre[i]=(pre[i-1]+b[i]) for i in range(m-1,-1,-1): suf[i]=suf[i+1]+b[i] for i in range(lp): ans[i]=(a[i]+pre[i])%c if lp==m: for i in range(lp , n-lp): ans[i]=(a[i]+pre[lp-1])%c else: for i in range(lp , n-lp): ans[i]=(a[i]+pre[i]-pre[i-lp])%c for i in range(n-1,n-lp-1,-1): ans[i]=(a[i]+suf[j])%c j-=1 print(*ans) ```
output
1
45,654
20
91,309
Provide tags and a correct Python 3 solution for this coding contest problem. The Smart Beaver from ABBYY invented a new message encryption method and now wants to check its performance. Checking it manually is long and tiresome, so he decided to ask the ABBYY Cup contestants for help. A message is a sequence of n integers a1, a2, ..., an. Encryption uses a key which is a sequence of m integers b1, b2, ..., bm (m ≀ n). All numbers from the message and from the key belong to the interval from 0 to c - 1, inclusive, and all the calculations are performed modulo c. Encryption is performed in n - m + 1 steps. On the first step we add to each number a1, a2, ..., am a corresponding number b1, b2, ..., bm. On the second step we add to each number a2, a3, ..., am + 1 (changed on the previous step) a corresponding number b1, b2, ..., bm. And so on: on step number i we add to each number ai, ai + 1, ..., ai + m - 1 a corresponding number b1, b2, ..., bm. The result of the encryption is the sequence a1, a2, ..., an after n - m + 1 steps. Help the Beaver to write a program that will encrypt messages in the described manner. Input The first input line contains three integers n, m and c, separated by single spaces. The second input line contains n integers ai (0 ≀ ai < c), separated by single spaces β€” the original message. The third input line contains m integers bi (0 ≀ bi < c), separated by single spaces β€” the encryption key. The input limitations for getting 30 points are: * 1 ≀ m ≀ n ≀ 103 * 1 ≀ c ≀ 103 The input limitations for getting 100 points are: * 1 ≀ m ≀ n ≀ 105 * 1 ≀ c ≀ 103 Output Print n space-separated integers β€” the result of encrypting the original message. Examples Input 4 3 2 1 1 1 1 1 1 1 Output 0 1 1 0 Input 3 1 5 1 2 3 4 Output 0 1 2 Note In the first sample the encryption is performed in two steps: after the first step a = (0, 0, 0, 1) (remember that the calculations are performed modulo 2), after the second step a = (0, 1, 1, 0), and that is the answer.
instruction
0
45,655
20
91,310
Tags: brute force Correct Solution: ``` a,b,c= map(int,input().split()) arr= list(map(int,input().split())) brr= list(map(int,input().split())) k=0 while k < a-b+1: for i in range (0,a): for j in range(0,b): if j+i<a: arr[j+i]=(arr[j+i]+brr[j])%c if i+j==a-1: break k=k+1 if(k>a-b): break for i in range(0,a): print(arr[i],end=" ") ```
output
1
45,655
20
91,311
Provide tags and a correct Python 3 solution for this coding contest problem. The Smart Beaver from ABBYY invented a new message encryption method and now wants to check its performance. Checking it manually is long and tiresome, so he decided to ask the ABBYY Cup contestants for help. A message is a sequence of n integers a1, a2, ..., an. Encryption uses a key which is a sequence of m integers b1, b2, ..., bm (m ≀ n). All numbers from the message and from the key belong to the interval from 0 to c - 1, inclusive, and all the calculations are performed modulo c. Encryption is performed in n - m + 1 steps. On the first step we add to each number a1, a2, ..., am a corresponding number b1, b2, ..., bm. On the second step we add to each number a2, a3, ..., am + 1 (changed on the previous step) a corresponding number b1, b2, ..., bm. And so on: on step number i we add to each number ai, ai + 1, ..., ai + m - 1 a corresponding number b1, b2, ..., bm. The result of the encryption is the sequence a1, a2, ..., an after n - m + 1 steps. Help the Beaver to write a program that will encrypt messages in the described manner. Input The first input line contains three integers n, m and c, separated by single spaces. The second input line contains n integers ai (0 ≀ ai < c), separated by single spaces β€” the original message. The third input line contains m integers bi (0 ≀ bi < c), separated by single spaces β€” the encryption key. The input limitations for getting 30 points are: * 1 ≀ m ≀ n ≀ 103 * 1 ≀ c ≀ 103 The input limitations for getting 100 points are: * 1 ≀ m ≀ n ≀ 105 * 1 ≀ c ≀ 103 Output Print n space-separated integers β€” the result of encrypting the original message. Examples Input 4 3 2 1 1 1 1 1 1 1 Output 0 1 1 0 Input 3 1 5 1 2 3 4 Output 0 1 2 Note In the first sample the encryption is performed in two steps: after the first step a = (0, 0, 0, 1) (remember that the calculations are performed modulo 2), after the second step a = (0, 1, 1, 0), and that is the answer.
instruction
0
45,656
20
91,312
Tags: brute force Correct Solution: ``` n,m,c=map(int,input().split()) a=list(map(int,input().split())) b=list(map(int,input().split())) sum=0 for i in range(n): if i<m: sum=(sum+b[i])%c if i>=n-m+1: sum=(c+sum-b[i-(n-m+1)])%c a[i]=(a[i]+sum)%c print(' '.join(map(str,a))) ```
output
1
45,656
20
91,313
Provide tags and a correct Python 3 solution for this coding contest problem. The Smart Beaver from ABBYY invented a new message encryption method and now wants to check its performance. Checking it manually is long and tiresome, so he decided to ask the ABBYY Cup contestants for help. A message is a sequence of n integers a1, a2, ..., an. Encryption uses a key which is a sequence of m integers b1, b2, ..., bm (m ≀ n). All numbers from the message and from the key belong to the interval from 0 to c - 1, inclusive, and all the calculations are performed modulo c. Encryption is performed in n - m + 1 steps. On the first step we add to each number a1, a2, ..., am a corresponding number b1, b2, ..., bm. On the second step we add to each number a2, a3, ..., am + 1 (changed on the previous step) a corresponding number b1, b2, ..., bm. And so on: on step number i we add to each number ai, ai + 1, ..., ai + m - 1 a corresponding number b1, b2, ..., bm. The result of the encryption is the sequence a1, a2, ..., an after n - m + 1 steps. Help the Beaver to write a program that will encrypt messages in the described manner. Input The first input line contains three integers n, m and c, separated by single spaces. The second input line contains n integers ai (0 ≀ ai < c), separated by single spaces β€” the original message. The third input line contains m integers bi (0 ≀ bi < c), separated by single spaces β€” the encryption key. The input limitations for getting 30 points are: * 1 ≀ m ≀ n ≀ 103 * 1 ≀ c ≀ 103 The input limitations for getting 100 points are: * 1 ≀ m ≀ n ≀ 105 * 1 ≀ c ≀ 103 Output Print n space-separated integers β€” the result of encrypting the original message. Examples Input 4 3 2 1 1 1 1 1 1 1 Output 0 1 1 0 Input 3 1 5 1 2 3 4 Output 0 1 2 Note In the first sample the encryption is performed in two steps: after the first step a = (0, 0, 0, 1) (remember that the calculations are performed modulo 2), after the second step a = (0, 1, 1, 0), and that is the answer.
instruction
0
45,657
20
91,314
Tags: brute force Correct Solution: ``` n,m,c = map(int,input().split()) a = list(input().split()) b = list(input().split()) sum = 0 for i in range(n): if i<m: sum = sum + int(b[i]) sum = sum%c if i >= n - m + 1: sum = c - int(b[i-n+m-1]) + sum sum = sum%c print((int(a[i])+sum)%c,end = ' ') ```
output
1
45,657
20
91,315
Provide tags and a correct Python 3 solution for this coding contest problem. The Smart Beaver from ABBYY invented a new message encryption method and now wants to check its performance. Checking it manually is long and tiresome, so he decided to ask the ABBYY Cup contestants for help. A message is a sequence of n integers a1, a2, ..., an. Encryption uses a key which is a sequence of m integers b1, b2, ..., bm (m ≀ n). All numbers from the message and from the key belong to the interval from 0 to c - 1, inclusive, and all the calculations are performed modulo c. Encryption is performed in n - m + 1 steps. On the first step we add to each number a1, a2, ..., am a corresponding number b1, b2, ..., bm. On the second step we add to each number a2, a3, ..., am + 1 (changed on the previous step) a corresponding number b1, b2, ..., bm. And so on: on step number i we add to each number ai, ai + 1, ..., ai + m - 1 a corresponding number b1, b2, ..., bm. The result of the encryption is the sequence a1, a2, ..., an after n - m + 1 steps. Help the Beaver to write a program that will encrypt messages in the described manner. Input The first input line contains three integers n, m and c, separated by single spaces. The second input line contains n integers ai (0 ≀ ai < c), separated by single spaces β€” the original message. The third input line contains m integers bi (0 ≀ bi < c), separated by single spaces β€” the encryption key. The input limitations for getting 30 points are: * 1 ≀ m ≀ n ≀ 103 * 1 ≀ c ≀ 103 The input limitations for getting 100 points are: * 1 ≀ m ≀ n ≀ 105 * 1 ≀ c ≀ 103 Output Print n space-separated integers β€” the result of encrypting the original message. Examples Input 4 3 2 1 1 1 1 1 1 1 Output 0 1 1 0 Input 3 1 5 1 2 3 4 Output 0 1 2 Note In the first sample the encryption is performed in two steps: after the first step a = (0, 0, 0, 1) (remember that the calculations are performed modulo 2), after the second step a = (0, 1, 1, 0), and that is the answer.
instruction
0
45,658
20
91,316
Tags: brute force Correct Solution: ``` n, m, c= map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) # print(n, b, a) for i in range(n - m + 1): for j in range(i, m + i): a [j] = (a[j] + b[j - i]) % c # print(*a) print(*a) ```
output
1
45,658
20
91,317
Provide tags and a correct Python 3 solution for this coding contest problem. The Smart Beaver from ABBYY invented a new message encryption method and now wants to check its performance. Checking it manually is long and tiresome, so he decided to ask the ABBYY Cup contestants for help. A message is a sequence of n integers a1, a2, ..., an. Encryption uses a key which is a sequence of m integers b1, b2, ..., bm (m ≀ n). All numbers from the message and from the key belong to the interval from 0 to c - 1, inclusive, and all the calculations are performed modulo c. Encryption is performed in n - m + 1 steps. On the first step we add to each number a1, a2, ..., am a corresponding number b1, b2, ..., bm. On the second step we add to each number a2, a3, ..., am + 1 (changed on the previous step) a corresponding number b1, b2, ..., bm. And so on: on step number i we add to each number ai, ai + 1, ..., ai + m - 1 a corresponding number b1, b2, ..., bm. The result of the encryption is the sequence a1, a2, ..., an after n - m + 1 steps. Help the Beaver to write a program that will encrypt messages in the described manner. Input The first input line contains three integers n, m and c, separated by single spaces. The second input line contains n integers ai (0 ≀ ai < c), separated by single spaces β€” the original message. The third input line contains m integers bi (0 ≀ bi < c), separated by single spaces β€” the encryption key. The input limitations for getting 30 points are: * 1 ≀ m ≀ n ≀ 103 * 1 ≀ c ≀ 103 The input limitations for getting 100 points are: * 1 ≀ m ≀ n ≀ 105 * 1 ≀ c ≀ 103 Output Print n space-separated integers β€” the result of encrypting the original message. Examples Input 4 3 2 1 1 1 1 1 1 1 Output 0 1 1 0 Input 3 1 5 1 2 3 4 Output 0 1 2 Note In the first sample the encryption is performed in two steps: after the first step a = (0, 0, 0, 1) (remember that the calculations are performed modulo 2), after the second step a = (0, 1, 1, 0), and that is the answer.
instruction
0
45,659
20
91,318
Tags: brute force Correct Solution: ``` len_message, len_key, mod = map(int, input().split()) message = list(map(int, input().split())) key = list(map(int, input().split())) sum, low, high = 0, 0, 0 result = message[:] for i in range(len_message): if high < len_key: sum += key[high] high += 1 if i + len_key > len_message: sum -= key[low] low += 1 result[i] = (result[i] + sum) % mod print(' '.join(map(str, result))) ```
output
1
45,659
20
91,319
Provide tags and a correct Python 3 solution for this coding contest problem. Let's call a number k-good if it contains all digits not exceeding k (0, ..., k). You've got a number k and an array a containing n numbers. Find out how many k-good numbers are in a (count each number every time it occurs in array a). Input The first line contains integers n and k (1 ≀ n ≀ 100, 0 ≀ k ≀ 9). The i-th of the following n lines contains integer ai without leading zeroes (1 ≀ ai ≀ 109). Output Print a single integer β€” the number of k-good numbers in a. Examples Input 10 6 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 Output 10 Input 2 1 1 10 Output 1
instruction
0
45,710
20
91,420
Tags: implementation Correct Solution: ``` n, k = list(map(int, input().split())) ans = 0 for i in range(n): cur = [] a = input() stop = False for j in range(0, k+1): if str(j) not in a: stop = True break if stop: continue else: ans+=1 print(ans) ```
output
1
45,710
20
91,421
Provide tags and a correct Python 3 solution for this coding contest problem. Let's call a number k-good if it contains all digits not exceeding k (0, ..., k). You've got a number k and an array a containing n numbers. Find out how many k-good numbers are in a (count each number every time it occurs in array a). Input The first line contains integers n and k (1 ≀ n ≀ 100, 0 ≀ k ≀ 9). The i-th of the following n lines contains integer ai without leading zeroes (1 ≀ ai ≀ 109). Output Print a single integer β€” the number of k-good numbers in a. Examples Input 10 6 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 Output 10 Input 2 1 1 10 Output 1
instruction
0
45,711
20
91,422
Tags: implementation Correct Solution: ``` from collections import Counter def sol(xs, k): c = 0 test = set(map(str, range(k+1))) # print(test) for x in xs: if test <= set((Counter(x))): c += 1 print(c) n, k = list(map(int, input().strip().split())) xs = [input().strip() for _ in range(n)] sol(xs, k) # with open("test/test.txt", "r") as f: # n, k = list(map(int, f.readline().strip().split())) # xs = [f.readline().strip() for _ in range(n)] # sol(xs, k) # # with open("test/1.txt", "r") as f: # n, k = list(map(int, f.readline().strip().split())) # xs = [f.readline().strip() for _ in range(n)] # sol(xs, k) ```
output
1
45,711
20
91,423
Provide tags and a correct Python 3 solution for this coding contest problem. Let's call a number k-good if it contains all digits not exceeding k (0, ..., k). You've got a number k and an array a containing n numbers. Find out how many k-good numbers are in a (count each number every time it occurs in array a). Input The first line contains integers n and k (1 ≀ n ≀ 100, 0 ≀ k ≀ 9). The i-th of the following n lines contains integer ai without leading zeroes (1 ≀ ai ≀ 109). Output Print a single integer β€” the number of k-good numbers in a. Examples Input 10 6 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 Output 10 Input 2 1 1 10 Output 1
instruction
0
45,712
20
91,424
Tags: implementation Correct Solution: ``` n,k=input().split() n=int(n) k=int(k) count=0 c=0 for i in range(n): f=False x=input() j=0 while j<=k and str(j) in x: j+=1 f=True if f and j>k: count+=1 print(count) ```
output
1
45,712
20
91,425
Provide tags and a correct Python 3 solution for this coding contest problem. Let's call a number k-good if it contains all digits not exceeding k (0, ..., k). You've got a number k and an array a containing n numbers. Find out how many k-good numbers are in a (count each number every time it occurs in array a). Input The first line contains integers n and k (1 ≀ n ≀ 100, 0 ≀ k ≀ 9). The i-th of the following n lines contains integer ai without leading zeroes (1 ≀ ai ≀ 109). Output Print a single integer β€” the number of k-good numbers in a. Examples Input 10 6 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 Output 10 Input 2 1 1 10 Output 1
instruction
0
45,713
20
91,426
Tags: implementation Correct Solution: ``` n,k = map(int, input().split()) # s=0 # for i in range(0, k+1): # # print(i) # s += i re = 0 for i in range(0,n): m = input() mset = sorted(set(m)) # print(mset[k],k,int(mset[k]) == k) if len(mset)>k and int(mset[k]) == k: re+=1 # print(s,sum_digit(mset),m.count('0')) # if s == sum_digit(m) and m.count('0'): # re+=1 # elif k ==0 and m.count('0'): # re+=1 # for z in range(0,k): print(re) ```
output
1
45,713
20
91,427
Provide tags and a correct Python 3 solution for this coding contest problem. Let's call a number k-good if it contains all digits not exceeding k (0, ..., k). You've got a number k and an array a containing n numbers. Find out how many k-good numbers are in a (count each number every time it occurs in array a). Input The first line contains integers n and k (1 ≀ n ≀ 100, 0 ≀ k ≀ 9). The i-th of the following n lines contains integer ai without leading zeroes (1 ≀ ai ≀ 109). Output Print a single integer β€” the number of k-good numbers in a. Examples Input 10 6 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 Output 10 Input 2 1 1 10 Output 1
instruction
0
45,714
20
91,428
Tags: implementation Correct Solution: ``` a,b=map(int,input().split()) z=0 e=0 while(z<a): n=input() h=0 while(h<=b): if str(h) in n: h+=1 else: e+=1 break z+=1 print(a-e) ```
output
1
45,714
20
91,429
Provide tags and a correct Python 3 solution for this coding contest problem. Let's call a number k-good if it contains all digits not exceeding k (0, ..., k). You've got a number k and an array a containing n numbers. Find out how many k-good numbers are in a (count each number every time it occurs in array a). Input The first line contains integers n and k (1 ≀ n ≀ 100, 0 ≀ k ≀ 9). The i-th of the following n lines contains integer ai without leading zeroes (1 ≀ ai ≀ 109). Output Print a single integer β€” the number of k-good numbers in a. Examples Input 10 6 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 Output 10 Input 2 1 1 10 Output 1
instruction
0
45,715
20
91,430
Tags: implementation Correct Solution: ``` n , k = map(int,input().split()) k = list(range(k+1)) count = 0 for i in range(n): a = input() a = [int(r) for r in list(a)] for item in k: if item not in a: break else: count += 1 print(count) ```
output
1
45,715
20
91,431
Provide tags and a correct Python 3 solution for this coding contest problem. Let's call a number k-good if it contains all digits not exceeding k (0, ..., k). You've got a number k and an array a containing n numbers. Find out how many k-good numbers are in a (count each number every time it occurs in array a). Input The first line contains integers n and k (1 ≀ n ≀ 100, 0 ≀ k ≀ 9). The i-th of the following n lines contains integer ai without leading zeroes (1 ≀ ai ≀ 109). Output Print a single integer β€” the number of k-good numbers in a. Examples Input 10 6 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 Output 10 Input 2 1 1 10 Output 1
instruction
0
45,716
20
91,432
Tags: implementation Correct Solution: ``` def good(s,k): for i in range(int(k)+1): if str(i) not in s: return False return True res=0 n,k = input().split() for _ in range(int(n)): if good(input(),k): res+=1 print(res) ```
output
1
45,716
20
91,433
Provide tags and a correct Python 3 solution for this coding contest problem. Let's call a number k-good if it contains all digits not exceeding k (0, ..., k). You've got a number k and an array a containing n numbers. Find out how many k-good numbers are in a (count each number every time it occurs in array a). Input The first line contains integers n and k (1 ≀ n ≀ 100, 0 ≀ k ≀ 9). The i-th of the following n lines contains integer ai without leading zeroes (1 ≀ ai ≀ 109). Output Print a single integer β€” the number of k-good numbers in a. Examples Input 10 6 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 Output 10 Input 2 1 1 10 Output 1
instruction
0
45,717
20
91,434
Tags: implementation Correct Solution: ``` n,k=map(int,input().split()) f=list(range(0,k+1)) #print(f) s="" d=[] c=0 a=n for i in range(n): kj=input() for j in f: if str(j) not in kj: c+=1 break print(n-c) ```
output
1
45,717
20
91,435
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let's call a number k-good if it contains all digits not exceeding k (0, ..., k). You've got a number k and an array a containing n numbers. Find out how many k-good numbers are in a (count each number every time it occurs in array a). Input The first line contains integers n and k (1 ≀ n ≀ 100, 0 ≀ k ≀ 9). The i-th of the following n lines contains integer ai without leading zeroes (1 ≀ ai ≀ 109). Output Print a single integer β€” the number of k-good numbers in a. Examples Input 10 6 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 Output 10 Input 2 1 1 10 Output 1 Submitted Solution: ``` n, k =[int(i) for i in input ().split()] num = [] gud = 0 flag = True for k in range (0, k+1): num.append(str(k)) for i in range (n): a=str(input()) flag = True for n in num: if n not in a: flag = False if flag == True: gud += 1 print(gud) ```
instruction
0
45,718
20
91,436
Yes
output
1
45,718
20
91,437
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let's call a number k-good if it contains all digits not exceeding k (0, ..., k). You've got a number k and an array a containing n numbers. Find out how many k-good numbers are in a (count each number every time it occurs in array a). Input The first line contains integers n and k (1 ≀ n ≀ 100, 0 ≀ k ≀ 9). The i-th of the following n lines contains integer ai without leading zeroes (1 ≀ ai ≀ 109). Output Print a single integer β€” the number of k-good numbers in a. Examples Input 10 6 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 Output 10 Input 2 1 1 10 Output 1 Submitted Solution: ``` n,k = map(int,input().split()) s=0 a = [0 for i in range(k+1)] for i in range(n): a = [0 for i in range(k+1)] curr = input() for c in curr: if int(c) >= len(a): continue a[int(c)] = 1 if 0 not in a: s += 1 print(s) ```
instruction
0
45,719
20
91,438
Yes
output
1
45,719
20
91,439
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let's call a number k-good if it contains all digits not exceeding k (0, ..., k). You've got a number k and an array a containing n numbers. Find out how many k-good numbers are in a (count each number every time it occurs in array a). Input The first line contains integers n and k (1 ≀ n ≀ 100, 0 ≀ k ≀ 9). The i-th of the following n lines contains integer ai without leading zeroes (1 ≀ ai ≀ 109). Output Print a single integer β€” the number of k-good numbers in a. Examples Input 10 6 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 Output 10 Input 2 1 1 10 Output 1 Submitted Solution: ``` def solve(n,k,a): count = 0 for num in a: notCorrect = False for i in range(0,k+1): if(str(i) not in num): notCorrect = True break if(not notCorrect): count += 1 return count if __name__ == "__main__": n,k = map(int,input().split(" ")) _n = 0 a = list() while(_n < n): a.append(input()) _n +=1 print (solve(n,k,a)) ```
instruction
0
45,720
20
91,440
Yes
output
1
45,720
20
91,441
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let's call a number k-good if it contains all digits not exceeding k (0, ..., k). You've got a number k and an array a containing n numbers. Find out how many k-good numbers are in a (count each number every time it occurs in array a). Input The first line contains integers n and k (1 ≀ n ≀ 100, 0 ≀ k ≀ 9). The i-th of the following n lines contains integer ai without leading zeroes (1 ≀ ai ≀ 109). Output Print a single integer β€” the number of k-good numbers in a. Examples Input 10 6 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 Output 10 Input 2 1 1 10 Output 1 Submitted Solution: ``` x, y = list(map(int, input().split())) c = 0 d = 0 for i in range(x): a = input() for b in range(y+1): if str(b) in a: c += 1 if c == y+1: d += 1 c = 0 print(d) ```
instruction
0
45,721
20
91,442
Yes
output
1
45,721
20
91,443
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let's call a number k-good if it contains all digits not exceeding k (0, ..., k). You've got a number k and an array a containing n numbers. Find out how many k-good numbers are in a (count each number every time it occurs in array a). Input The first line contains integers n and k (1 ≀ n ≀ 100, 0 ≀ k ≀ 9). The i-th of the following n lines contains integer ai without leading zeroes (1 ≀ ai ≀ 109). Output Print a single integer β€” the number of k-good numbers in a. Examples Input 10 6 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 Output 10 Input 2 1 1 10 Output 1 Submitted Solution: ``` # import math def main(): n,k = map(int,input().split()) cnt = 0 for _ in range(n): temp = 0 number = str(input()) num = list(number) num.sort() for x in num: if int(x)==temp: cnt+=1 if k==temp-1: cnt+=1 # break print(cnt) main() ```
instruction
0
45,722
20
91,444
No
output
1
45,722
20
91,445
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let's call a number k-good if it contains all digits not exceeding k (0, ..., k). You've got a number k and an array a containing n numbers. Find out how many k-good numbers are in a (count each number every time it occurs in array a). Input The first line contains integers n and k (1 ≀ n ≀ 100, 0 ≀ k ≀ 9). The i-th of the following n lines contains integer ai without leading zeroes (1 ≀ ai ≀ 109). Output Print a single integer β€” the number of k-good numbers in a. Examples Input 10 6 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 Output 10 Input 2 1 1 10 Output 1 Submitted Solution: ``` n, k = map(int, input().split()) ans = 0 for i in range(n): S = list(map(int, list(input()))) S = list(set(S)) if S[0] == 0 and S[-1] == k and len(S) == k + 1: ans += 1 print(ans) ```
instruction
0
45,723
20
91,446
No
output
1
45,723
20
91,447
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let's call a number k-good if it contains all digits not exceeding k (0, ..., k). You've got a number k and an array a containing n numbers. Find out how many k-good numbers are in a (count each number every time it occurs in array a). Input The first line contains integers n and k (1 ≀ n ≀ 100, 0 ≀ k ≀ 9). The i-th of the following n lines contains integer ai without leading zeroes (1 ≀ ai ≀ 109). Output Print a single integer β€” the number of k-good numbers in a. Examples Input 10 6 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 Output 10 Input 2 1 1 10 Output 1 Submitted Solution: ``` l = list(map(int,input().split())) n = l[0] k = l[1] x = 0 for i in range(n): a = input() if (len(a) == k+1): x += 1 print(x) ```
instruction
0
45,724
20
91,448
No
output
1
45,724
20
91,449
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let's call a number k-good if it contains all digits not exceeding k (0, ..., k). You've got a number k and an array a containing n numbers. Find out how many k-good numbers are in a (count each number every time it occurs in array a). Input The first line contains integers n and k (1 ≀ n ≀ 100, 0 ≀ k ≀ 9). The i-th of the following n lines contains integer ai without leading zeroes (1 ≀ ai ≀ 109). Output Print a single integer β€” the number of k-good numbers in a. Examples Input 10 6 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 Output 10 Input 2 1 1 10 Output 1 Submitted Solution: ``` n, k = map(int, input().split()) a = [set(map(int, input())) for _ in range(n)] digits = {i for i in range(0, k + 1)} c = 0 for i in a: if i == digits: c += 1 print(c) ```
instruction
0
45,725
20
91,450
No
output
1
45,725
20
91,451