message
stringlengths
2
23.8k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
97
109k
cluster
float64
0
0
__index_level_0__
int64
194
217k
Provide tags and a correct Python 3 solution for this coding contest problem. Hamed has recently found a string t and suddenly became quite fond of it. He spent several days trying to find all occurrences of t in other strings he had. Finally he became tired and started thinking about the following problem. Given a st...
instruction
0
74,542
0
149,084
Tags: dp, strings Correct Solution: ``` def main(): s, t = input(), input() n, m = len(s), len(t) t = '$'.join((t, s)) p = [0] k = 0 for i in range(1, n + m + 1): while k and t[k] != t[i]: k = p[k - 1] if t[k] == t[i]: k += 1 p.append(k) ans = ...
output
1
74,542
0
149,085
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Hamed has recently found a string t and suddenly became quite fond of it. He spent several days trying to find all occurrences of t in other strings he had. Finally he became tired and started t...
instruction
0
74,543
0
149,086
No
output
1
74,543
0
149,087
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Hamed has recently found a string t and suddenly became quite fond of it. He spent several days trying to find all occurrences of t in other strings he had. Finally he became tired and started t...
instruction
0
74,544
0
149,088
No
output
1
74,544
0
149,089
Provide tags and a correct Python 3 solution for this coding contest problem. Koa the Koala has a binary string s of length n. Koa can perform no more than n-1 (possibly zero) operations of the following form: In one operation Koa selects positions i and i+1 for some i with 1 ≤ i < |s| and sets s_i to max(s_i, s_{i+1...
instruction
0
75,194
0
150,388
Tags: combinatorics, data structures, dp Correct Solution: ``` import sys MOD = 1000000007 def red(x): return x if x < MOD else x - MOD S = input() n = len(S) i = 0 while i < n and S[i] == '0': i += 1 if i == n: print (n) sys.exit() j = n while j and S[j - 1] == '0': j -= 1 fac = (i + 1) * (n...
output
1
75,194
0
150,389
Provide tags and a correct Python 3 solution for this coding contest problem. Koa the Koala has a binary string s of length n. Koa can perform no more than n-1 (possibly zero) operations of the following form: In one operation Koa selects positions i and i+1 for some i with 1 ≤ i < |s| and sets s_i to max(s_i, s_{i+1...
instruction
0
75,195
0
150,390
Tags: combinatorics, data structures, dp Correct Solution: ``` import sys def minp(): return sys.stdin.readline().strip() def mint(): return int(minp()) def mints(): return map(int, minp().split()) def solve(): MOD = int(1e9+7) was = set() s = list(map(int, minp())) n = len(s) first, last = None, None fo...
output
1
75,195
0
150,391
Provide tags and a correct Python 3 solution for this coding contest problem. Koa the Koala has a binary string s of length n. Koa can perform no more than n-1 (possibly zero) operations of the following form: In one operation Koa selects positions i and i+1 for some i with 1 ≤ i < |s| and sets s_i to max(s_i, s_{i+1...
instruction
0
75,196
0
150,392
Tags: combinatorics, data structures, dp Correct Solution: ``` from itertools import groupby s=input() n=len(s) s=[s[i] for i in range(n)] mod=10**9+7 data=groupby(s) data=[(key,len(list(group))) for key,group in data] Start=1 End=1 if data[0][0]=="0": Start+=data[0][1] data=data[1:] if not data: print(St...
output
1
75,196
0
150,393
Provide tags and a correct Python 3 solution for this coding contest problem. Koa the Koala has a binary string s of length n. Koa can perform no more than n-1 (possibly zero) operations of the following form: In one operation Koa selects positions i and i+1 for some i with 1 ≤ i < |s| and sets s_i to max(s_i, s_{i+1...
instruction
0
75,197
0
150,394
Tags: combinatorics, data structures, dp Correct Solution: ``` MOD = 1000000007 def main(): s = input() n = len(s) zero = [0] * n for i in range(n): if s[i] == '0': zero[i] = zero[i-1] + 1 if i else 1 nxt, dp = [0] * (n+2), [0] * (n+2) for i in range(n+1): nxt[i] = n ...
output
1
75,197
0
150,395
Provide tags and a correct Python 3 solution for this coding contest problem. Koa the Koala has a binary string s of length n. Koa can perform no more than n-1 (possibly zero) operations of the following form: In one operation Koa selects positions i and i+1 for some i with 1 ≤ i < |s| and sets s_i to max(s_i, s_{i+1...
instruction
0
75,198
0
150,396
Tags: combinatorics, data structures, dp Correct Solution: ``` from itertools import groupby s=input() n=len(s) s=[s[i] for i in range(n)] mod=10**9+7 data=groupby(s) data=[(key,len(list(group))) for key,group in data] Start=1 End=1 if data[0][0]=="0": Start+=data[0][1] data=data[1:] if not data: print(St...
output
1
75,198
0
150,397
Provide tags and a correct Python 3 solution for this coding contest problem. Koa the Koala has a binary string s of length n. Koa can perform no more than n-1 (possibly zero) operations of the following form: In one operation Koa selects positions i and i+1 for some i with 1 ≤ i < |s| and sets s_i to max(s_i, s_{i+1...
instruction
0
75,199
0
150,398
Tags: combinatorics, data structures, dp Correct Solution: ``` import sys readline = sys.stdin.readline MOD = 10**9+7;S = readline().strip().split('1') if len(S) == 1:print(len(S[0])) else: S = [len(s)+1 for s in S];ans = S[0]*S[-1];S = S[1:-1];dp = [0]*(max(S)+2);dp[0] = 1 for ai in S: res = 0;rz = 0 ...
output
1
75,199
0
150,399
Provide tags and a correct Python 3 solution for this coding contest problem. Koa the Koala has a binary string s of length n. Koa can perform no more than n-1 (possibly zero) operations of the following form: In one operation Koa selects positions i and i+1 for some i with 1 ≤ i < |s| and sets s_i to max(s_i, s_{i+1...
instruction
0
75,200
0
150,400
Tags: combinatorics, data structures, dp Correct Solution: ``` import sys readline = sys.stdin.readline MOD = 10**9+7 S = readline().strip().split('1') if len(S) == 1: print(len(S[0])) else: S = [len(s)+1 for s in S] ans = S[0]*S[-1] S = S[1:-1] dp = [0]*(max(S)+2) dp[0] = 1 for ai in ...
output
1
75,200
0
150,401
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Koa the Koala has a binary string s of length n. Koa can perform no more than n-1 (possibly zero) operations of the following form: In one operation Koa selects positions i and i+1 for some i w...
instruction
0
75,201
0
150,402
No
output
1
75,201
0
150,403
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Koa the Koala has a binary string s of length n. Koa can perform no more than n-1 (possibly zero) operations of the following form: In one operation Koa selects positions i and i+1 for some i w...
instruction
0
75,202
0
150,404
No
output
1
75,202
0
150,405
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Koa the Koala has a binary string s of length n. Koa can perform no more than n-1 (possibly zero) operations of the following form: In one operation Koa selects positions i and i+1 for some i w...
instruction
0
75,203
0
150,406
No
output
1
75,203
0
150,407
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Koa the Koala has a binary string s of length n. Koa can perform no more than n-1 (possibly zero) operations of the following form: In one operation Koa selects positions i and i+1 for some i w...
instruction
0
75,204
0
150,408
No
output
1
75,204
0
150,409
Provide tags and a correct Python 3 solution for this coding contest problem. One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain...
instruction
0
75,563
0
151,126
Tags: brute force, dp Correct Solution: ``` strs=input() array=[] char=[] count=1 char.append(strs[0]) i=1 while(i<len(strs)): if(strs[i]==strs[i-1]): count+=1 else: array.append(count) char.append(strs[i]) count=1 i+=1 array.append(count) bback=[] aback=[] bfront=[] afront=[...
output
1
75,563
0
151,127
Provide tags and a correct Python 3 solution for this coding contest problem. One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain...
instruction
0
75,564
0
151,128
Tags: brute force, dp Correct Solution: ``` s = input() a, b = [0], [0] a_count, b_count = 0, 0 for x in s: if x == 'a': a_count += 1 else: b_count += 1 a.append(a_count) b.append(b_count) best = b_count for i in range(len(a)): for j in range(i, len(a)): best = max(best, a[i]...
output
1
75,564
0
151,129
Provide tags and a correct Python 3 solution for this coding contest problem. One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain...
instruction
0
75,565
0
151,130
Tags: brute force, dp Correct Solution: ``` s = list(input()) n = len(s) lis=[[0,0] for i in range(n+2)] for i in range(n): if s[i]=='a': lis[i+1][0]=lis[i][0]+1 lis[i+1][1]=lis[i][1] else: lis[i+1][0]=lis[i][0] lis[i+1][1]=lis[i][1]+1 #print(lis) ans=0 for i in range...
output
1
75,565
0
151,131
Provide tags and a correct Python 3 solution for this coding contest problem. One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain...
instruction
0
75,566
0
151,132
Tags: brute force, dp Correct Solution: ``` s = input().strip() n = len(s) dp = [[0, 0, 0] for _ in range(n)] for i in range(n): if s[i] == 'a': dp[i][0] = 1 for j in range(i): dp[i][0] = max(dp[i][0], dp[j][0] + 1) dp[i][1] = dp[i][0] dp[i][2] = 1 for j in rang...
output
1
75,566
0
151,133
Provide tags and a correct Python 3 solution for this coding contest problem. One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain...
instruction
0
75,567
0
151,134
Tags: brute force, dp Correct Solution: ``` s = input() n = len(s) dp = [] dp.append((0, 0, 0)) for i in range(n): if s[i] == 'a': dp.append((dp[-1][0] + 1, dp[-1][1], max(dp[-1][1:]) + 1)) elif s[i] == 'b': dp.append((dp[-1][0], max(dp[-1][1], dp[-1][0]) + 1, dp[-1][-1])) print(max(dp[-1])) ``...
output
1
75,567
0
151,135
Provide tags and a correct Python 3 solution for this coding contest problem. One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain...
instruction
0
75,568
0
151,136
Tags: brute force, dp Correct Solution: ``` s=input() n=len(s) prefa=[0]*(n) prefb=[0]*(n) prefa[0]=(s[0]=='a') prefb[0]=(s[0]=='b') c=0 for i in range(1,n): prefa[i]=prefa[i-1]+(s[i]=='a') prefb[i]=prefb[i-1]+(s[i]=='b') ans1,ans=0,0 prefa=[0]+prefa prefb=[0]+prefb for i in range(n+1): for j in range(i,n+1): ...
output
1
75,568
0
151,137
Provide tags and a correct Python 3 solution for this coding contest problem. One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain...
instruction
0
75,569
0
151,138
Tags: brute force, dp Correct Solution: ``` max1=0 string=input() first=0 second=0 third=0 i=0 length=len(string) while(i<length): if string[i]=='a': if second>third: third=second+1 else: third+=1 first+=1 if string[i]=='b': if first>second: ...
output
1
75,569
0
151,139
Provide tags and a correct Python 3 solution for this coding contest problem. One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain...
instruction
0
75,570
0
151,140
Tags: brute force, dp Correct Solution: ``` s = input() a = [0, 0, 0] for i in range(len(s)): if s[i] == "a": a[2] = max(a) + 1 a[0] += 1 else: a[1] = max(a[0], a[1]) + 1 print(max(a)) ```
output
1
75,570
0
151,141
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the l...
instruction
0
75,571
0
151,142
Yes
output
1
75,571
0
151,143
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the l...
instruction
0
75,572
0
151,144
Yes
output
1
75,572
0
151,145
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the l...
instruction
0
75,573
0
151,146
Yes
output
1
75,573
0
151,147
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the l...
instruction
0
75,574
0
151,148
Yes
output
1
75,574
0
151,149
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the l...
instruction
0
75,575
0
151,150
No
output
1
75,575
0
151,151
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the l...
instruction
0
75,576
0
151,152
No
output
1
75,576
0
151,153
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the l...
instruction
0
75,577
0
151,154
No
output
1
75,577
0
151,155
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the l...
instruction
0
75,578
0
151,156
No
output
1
75,578
0
151,157
Provide a correct Python 3 solution for this coding contest problem. You are given a string s. Among the different substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` a...
instruction
0
75,723
0
151,446
"Correct Solution: ``` s=input() K=int(input()) mojiretsu=set() for i in range(0,len(s)): for k in range(1,6): mojiretsu.add(s[i:i+k]) ans=sorted(mojiretsu) print(ans[K-1]) ```
output
1
75,723
0
151,447
Provide a correct Python 3 solution for this coding contest problem. You are given a string s. Among the different substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` a...
instruction
0
75,724
0
151,448
"Correct Solution: ``` s=input() k=int(input()) subs=set() for l in range(1,k+1): for i in range(len(s)-l+1): subs.add(s[i:i+l]) subs=sorted(subs) print(subs[k-1]) ```
output
1
75,724
0
151,449
Provide a correct Python 3 solution for this coding contest problem. You are given a string s. Among the different substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` a...
instruction
0
75,725
0
151,450
"Correct Solution: ``` s = input() k = int(input()) n = len(s) t = set() for i in range(k): for j in range(n-i): t.add(s[j:j+i+1]) lis = sorted(list(t)) print(lis[k-1]) ```
output
1
75,725
0
151,451
Provide a correct Python 3 solution for this coding contest problem. You are given a string s. Among the different substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` a...
instruction
0
75,726
0
151,452
"Correct Solution: ``` s = input() K = int(input()) arr = set() for i in range(len(s)): for j in range(i + 1, min(i + K + 1, len(s) + 1)): arr.add(s[i:j]) print(sorted(arr)[K - 1]) ```
output
1
75,726
0
151,453
Provide a correct Python 3 solution for this coding contest problem. You are given a string s. Among the different substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` a...
instruction
0
75,727
0
151,454
"Correct Solution: ``` s=input() K=int(input()) a=[] l=len(s) for i in range(l): for j in range(1,K+1): a.append(s[i:(i+j)]) a=list(set(a)) a.sort() print(a[K-1]) ```
output
1
75,727
0
151,455
Provide a correct Python 3 solution for this coding contest problem. You are given a string s. Among the different substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` a...
instruction
0
75,728
0
151,456
"Correct Solution: ``` s = input() K = int(input()) ans = set() for i in range(len(s)): for j in range(i+1, K+i+1): ans.add(s[i:j]) print(sorted(list(ans))[K-1]) ```
output
1
75,728
0
151,457
Provide a correct Python 3 solution for this coding contest problem. You are given a string s. Among the different substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` a...
instruction
0
75,729
0
151,458
"Correct Solution: ``` s = input() K = int(input()) d = set() for l in range(1, K+1): for i in range(len(s)+1-l): d |= {s[i:i+l]} print(sorted(list(d))[K-1]) ```
output
1
75,729
0
151,459
Provide a correct Python 3 solution for this coding contest problem. You are given a string s. Among the different substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` a...
instruction
0
75,730
0
151,460
"Correct Solution: ``` s = input() k = int(input()) l = [] for i in range(len(s)): for j in range(1, k+1): l.append(s[i:i+j]) print(sorted(set(l))[k-1]) ```
output
1
75,730
0
151,461
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a string s. Among the different substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in ...
instruction
0
75,731
0
151,462
Yes
output
1
75,731
0
151,463
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a string s. Among the different substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in ...
instruction
0
75,732
0
151,464
Yes
output
1
75,732
0
151,465
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a string s. Among the different substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in ...
instruction
0
75,733
0
151,466
Yes
output
1
75,733
0
151,467
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a string s. Among the different substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in ...
instruction
0
75,734
0
151,468
Yes
output
1
75,734
0
151,469
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a string s. Among the different substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in ...
instruction
0
75,735
0
151,470
No
output
1
75,735
0
151,471
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a string s. Among the different substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in ...
instruction
0
75,736
0
151,472
No
output
1
75,736
0
151,473
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a string s. Among the different substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in ...
instruction
0
75,737
0
151,474
No
output
1
75,737
0
151,475
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a string s. Among the different substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in ...
instruction
0
75,738
0
151,476
No
output
1
75,738
0
151,477
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Boboniu defines BN-string as a string s of characters 'B' and 'N'. You can perform the following operations on the BN-string s: * Remove a character of s. * Remove a substring "BN" or "NB...
instruction
0
76,054
0
152,108
No
output
1
76,054
0
152,109
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Boboniu defines BN-string as a string s of characters 'B' and 'N'. You can perform the following operations on the BN-string s: * Remove a character of s. * Remove a substring "BN" or "NB...
instruction
0
76,055
0
152,110
No
output
1
76,055
0
152,111
Provide tags and a correct Python 3 solution for this coding contest problem. You are given n strings. Each string consists of lowercase English letters. Rearrange (reorder) the given strings in such a way that for every string, all strings that are placed before it are its substrings. String a is a substring of stri...
instruction
0
76,441
0
152,882
Tags: sortings, strings Correct Solution: ``` try: n=int(input()) a=[] for i in range(n): a.append(input()) a=sorted(a, key=len) if(n==1): print("YES") print(a[0]) for i in range(1,n): if(a[i].count(a[i-1])>=1): if(i==n-1): print("YES")...
output
1
76,441
0
152,883
Provide tags and a correct Python 3 solution for this coding contest problem. You are given n strings. Each string consists of lowercase English letters. Rearrange (reorder) the given strings in such a way that for every string, all strings that are placed before it are its substrings. String a is a substring of stri...
instruction
0
76,442
0
152,884
Tags: sortings, strings Correct Solution: ``` def f(s): return len(s) n=int(input()) a=[] for i in range(n): a.append(input()) a.sort(key=f) ans="YES" for i in range(n-1): if not(a[i] in a[i+1]): ans="NO" break print(ans) if ans=="YES": for s in a: print(s) ```
output
1
76,442
0
152,885