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. Pushok the dog has been chasing Imp for a few hours already. <image> Fortunately, Imp knows that Pushok is afraid of a robot vacuum cleaner. While moving, the robot generates a string t consisting of letters 's' and 'h', that produces a ...
instruction
0
67,853
0
135,706
Tags: greedy, sortings Correct Solution: ``` def count_s(s): ret = 0 for k in s: if k == 's': ret += 1 return ret def count_sh(s): ret = 0 ls = [] for k in s: if k == 's': ls.append(0) else: ls.append(1) ls.reverse() for i in...
output
1
67,853
0
135,707
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Pushok the dog has been chasing Imp for a few hours already. <image> Fortunately, Imp knows that Pushok is afraid of a robot vacuum cleaner. While moving, the robot generates a string t cons...
instruction
0
67,855
0
135,710
Yes
output
1
67,855
0
135,711
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Pushok the dog has been chasing Imp for a few hours already. <image> Fortunately, Imp knows that Pushok is afraid of a robot vacuum cleaner. While moving, the robot generates a string t cons...
instruction
0
67,857
0
135,714
Yes
output
1
67,857
0
135,715
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Pushok the dog has been chasing Imp for a few hours already. <image> Fortunately, Imp knows that Pushok is afraid of a robot vacuum cleaner. While moving, the robot generates a string t cons...
instruction
0
67,858
0
135,716
No
output
1
67,858
0
135,717
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Pushok the dog has been chasing Imp for a few hours already. <image> Fortunately, Imp knows that Pushok is afraid of a robot vacuum cleaner. While moving, the robot generates a string t cons...
instruction
0
67,860
0
135,720
No
output
1
67,860
0
135,721
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Pushok the dog has been chasing Imp for a few hours already. <image> Fortunately, Imp knows that Pushok is afraid of a robot vacuum cleaner. While moving, the robot generates a string t cons...
instruction
0
67,861
0
135,722
No
output
1
67,861
0
135,723
Provide a correct Python 3 solution for this coding contest problem. You are given a set S of strings consisting of `0` and `1`, and an integer K. Find the longest string that is a subsequence of K or more different strings in S. If there are multiple strings that satisfy this condition, find the lexicographically sm...
instruction
0
67,974
0
135,948
"Correct Solution: ``` R=range;N,K=map(int,input().split());Q=R(N+1);d=[[0]*2**i for i in Q];f=[[0]*2**i for i in Q] for i in Q: for j,c in enumerate(input()):d[i][j]=int(c) for i in R(1,N+1): for j in R(1<<i): t=j>>i-1&1;r=0 while r<i and j>>i-1-r&1==t:r+=1 f[i][j]=r for i in Q: for k in R(i+1,N+1): z=k-i;m...
output
1
67,974
0
135,949
Provide a correct Python 3 solution for this coding contest problem. You are given a set S of strings consisting of `0` and `1`, and an integer K. Find the longest string that is a subsequence of K or more different strings in S. If there are multiple strings that satisfy this condition, find the lexicographically sm...
instruction
0
67,975
0
135,950
"Correct Solution: ``` N, K = map(int, input().split()) D = N + 1 d = [[0] * (1 << N) for _ in range(D)] f = [[0] * (1 << N) for _ in range(D)] for i in range(D): for j, c in enumerate(input()): if c == '1': d[i][j] = 1 for i in range(1, D): for j in range(1 << i): t = (j >> (i - ...
output
1
67,975
0
135,951
Provide a correct Python 3 solution for this coding contest problem. You are given a set S of strings consisting of `0` and `1`, and an integer K. Find the longest string that is a subsequence of K or more different strings in S. If there are multiple strings that satisfy this condition, find the lexicographically sm...
instruction
0
67,976
0
135,952
"Correct Solution: ``` R=range;N,K=map(int,input().split());Q=R(N+1);d=[[0]*2**N for _ in Q];f=[[0]*2**N for _ in Q] for i in Q: for j,c in enumerate(input()):d[i][j]=int(c) for i in R(1,N+1): for j in R(1<<i): t=j>>i-1&1;r=0 while r<i and j>>i-1-r&1==t:r+=1 f[i][j]=r for i in Q: for k in R(i+1,N+1): z=k-i;m...
output
1
67,976
0
135,953
Provide tags and a correct Python 3 solution for this coding contest problem. Let's call left cyclic shift of some string t_1 t_2 t_3 ... t_{n - 1} t_n as string t_2 t_3 ... t_{n - 1} t_n t_1. Analogically, let's call right cyclic shift of string t as string t_n t_1 t_2 t_3 ... t_{n - 1}. Let's say string t is good ...
instruction
0
68,310
0
136,620
Tags: brute force, dp, greedy, two pointers Correct Solution: ``` # Contest No.: Edu92 # Problem No.: C # Solver: JEMINI # Date: 20200729 import sys import heapq def main(): t = int(input()) for _ in range(t): strN = input() flag = False temp = strN[0] for ...
output
1
68,310
0
136,621
Provide tags and a correct Python 3 solution for this coding contest problem. Let's call left cyclic shift of some string t_1 t_2 t_3 ... t_{n - 1} t_n as string t_2 t_3 ... t_{n - 1} t_n t_1. Analogically, let's call right cyclic shift of string t as string t_n t_1 t_2 t_3 ... t_{n - 1}. Let's say string t is good ...
instruction
0
68,311
0
136,622
Tags: brute force, dp, greedy, two pointers Correct Solution: ``` #------------------------template--------------------------# import os import sys from math import * from collections import * from fractions import * from bisect import * from heapq import* from io import BytesIO, IOBase def vsInput(): sys.stdin = o...
output
1
68,311
0
136,623
Provide tags and a correct Python 3 solution for this coding contest problem. Let's call left cyclic shift of some string t_1 t_2 t_3 ... t_{n - 1} t_n as string t_2 t_3 ... t_{n - 1} t_n t_1. Analogically, let's call right cyclic shift of string t as string t_n t_1 t_2 t_3 ... t_{n - 1}. Let's say string t is good ...
instruction
0
68,312
0
136,624
Tags: brute force, dp, greedy, two pointers Correct Solution: ``` from sys import stdin, stdout import heapq import cProfile from collections import Counter, defaultdict, deque from functools import reduce import math def get_int(): return int(stdin.readline().strip()) def get_tuple(): return map(int, stdin...
output
1
68,312
0
136,625
Provide tags and a correct Python 3 solution for this coding contest problem. Let's call left cyclic shift of some string t_1 t_2 t_3 ... t_{n - 1} t_n as string t_2 t_3 ... t_{n - 1} t_n t_1. Analogically, let's call right cyclic shift of string t as string t_n t_1 t_2 t_3 ... t_{n - 1}. Let's say string t is good ...
instruction
0
68,313
0
136,626
Tags: brute force, dp, greedy, two pointers Correct Solution: ``` for i in range(int(input())): s = input() count = [[0 for i in range(10)] for i in range(10)] for i in s: d = int(i) for p in range(10): count[d][p] = count[p][d] + 1 #for i in count: # print(*i) print(len(s) - max((max([max(i) for i in coun...
output
1
68,313
0
136,627
Provide tags and a correct Python 3 solution for this coding contest problem. Let's call left cyclic shift of some string t_1 t_2 t_3 ... t_{n - 1} t_n as string t_2 t_3 ... t_{n - 1} t_n t_1. Analogically, let's call right cyclic shift of string t as string t_n t_1 t_2 t_3 ... t_{n - 1}. Let's say string t is good ...
instruction
0
68,314
0
136,628
Tags: brute force, dp, greedy, two pointers Correct Solution: ``` for k in[*open(0)][1:]: p=[0]*100 for i in map(int,k[:-1]): for j in range(10):p[10*i+j]=p[10*j+i]+1 print(len(k)-1-max(max(p)&~1,max(p[::11]))) ```
output
1
68,314
0
136,629
Provide tags and a correct Python 3 solution for this coding contest problem. Let's call left cyclic shift of some string t_1 t_2 t_3 ... t_{n - 1} t_n as string t_2 t_3 ... t_{n - 1} t_n t_1. Analogically, let's call right cyclic shift of string t as string t_n t_1 t_2 t_3 ... t_{n - 1}. Let's say string t is good ...
instruction
0
68,315
0
136,630
Tags: brute force, dp, greedy, two pointers Correct Solution: ``` import sys input = sys.stdin.readline from collections import Counter t=int(input()) for tests in range(t): S=input().strip() LEN=len(S) ANS=LEN C=Counter(S) for v in C.values(): ANS=min(ANS,LEN-v) #print(ANS) for i...
output
1
68,315
0
136,631
Provide tags and a correct Python 3 solution for this coding contest problem. Let's call left cyclic shift of some string t_1 t_2 t_3 ... t_{n - 1} t_n as string t_2 t_3 ... t_{n - 1} t_n t_1. Analogically, let's call right cyclic shift of string t as string t_n t_1 t_2 t_3 ... t_{n - 1}. Let's say string t is good ...
instruction
0
68,316
0
136,632
Tags: brute force, dp, greedy, two pointers Correct Solution: ``` T = int(input()) def f(x , y , a) : correct = 0 for c in a : if c == x : correct +=1 x,y = y,x if x!=y and correct % 2 == 1 : correct-=1 return correct while T : s = input() arr...
output
1
68,316
0
136,633
Provide tags and a correct Python 3 solution for this coding contest problem. Let's call left cyclic shift of some string t_1 t_2 t_3 ... t_{n - 1} t_n as string t_2 t_3 ... t_{n - 1} t_n t_1. Analogically, let's call right cyclic shift of string t as string t_n t_1 t_2 t_3 ... t_{n - 1}. Let's say string t is good ...
instruction
0
68,317
0
136,634
Tags: brute force, dp, greedy, two pointers Correct Solution: ``` for i in range(int(input())): s = input() count = [[0 for i in range(10)] for i in range(10)] for i in s: d = int(i) for p in range(10): count[d][p] = count[p][d] + 1 print(len(s) - max((max([max(i) for i in co...
output
1
68,317
0
136,635
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let's call left cyclic shift of some string t_1 t_2 t_3 ... t_{n - 1} t_n as string t_2 t_3 ... t_{n - 1} t_n t_1. Analogically, let's call right cyclic shift of string t as string t_n t_1 t_2 ...
instruction
0
68,318
0
136,636
Yes
output
1
68,318
0
136,637
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let's call left cyclic shift of some string t_1 t_2 t_3 ... t_{n - 1} t_n as string t_2 t_3 ... t_{n - 1} t_n t_1. Analogically, let's call right cyclic shift of string t as string t_n t_1 t_2 ...
instruction
0
68,319
0
136,638
Yes
output
1
68,319
0
136,639
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let's call left cyclic shift of some string t_1 t_2 t_3 ... t_{n - 1} t_n as string t_2 t_3 ... t_{n - 1} t_n t_1. Analogically, let's call right cyclic shift of string t as string t_n t_1 t_2 ...
instruction
0
68,320
0
136,640
Yes
output
1
68,320
0
136,641
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let's call left cyclic shift of some string t_1 t_2 t_3 ... t_{n - 1} t_n as string t_2 t_3 ... t_{n - 1} t_n t_1. Analogically, let's call right cyclic shift of string t as string t_n t_1 t_2 ...
instruction
0
68,321
0
136,642
Yes
output
1
68,321
0
136,643
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let's call left cyclic shift of some string t_1 t_2 t_3 ... t_{n - 1} t_n as string t_2 t_3 ... t_{n - 1} t_n t_1. Analogically, let's call right cyclic shift of string t as string t_n t_1 t_2 ...
instruction
0
68,322
0
136,644
No
output
1
68,322
0
136,645
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let's call left cyclic shift of some string t_1 t_2 t_3 ... t_{n - 1} t_n as string t_2 t_3 ... t_{n - 1} t_n t_1. Analogically, let's call right cyclic shift of string t as string t_n t_1 t_2 ...
instruction
0
68,323
0
136,646
No
output
1
68,323
0
136,647
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let's call left cyclic shift of some string t_1 t_2 t_3 ... t_{n - 1} t_n as string t_2 t_3 ... t_{n - 1} t_n t_1. Analogically, let's call right cyclic shift of string t as string t_n t_1 t_2 ...
instruction
0
68,324
0
136,648
No
output
1
68,324
0
136,649
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let's call left cyclic shift of some string t_1 t_2 t_3 ... t_{n - 1} t_n as string t_2 t_3 ... t_{n - 1} t_n t_1. Analogically, let's call right cyclic shift of string t as string t_n t_1 t_2 ...
instruction
0
68,325
0
136,650
No
output
1
68,325
0
136,651
Evaluate the correctness of the submitted Python 2 solution to the coding contest problem. Provide a "Yes" or "No" response. Let's call left cyclic shift of some string t_1 t_2 t_3 ... t_{n - 1} t_n as string t_2 t_3 ... t_{n - 1} t_n t_1. Analogically, let's call right cyclic shift of string t as string t_n t_1 t_2 ...
instruction
0
68,326
0
136,652
No
output
1
68,326
0
136,653
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two strings s and t consisting of lowercase Latin letters. The length of t is 2 (i.e. this string consists only of two characters). In one move, you can choose any character of s and replace it with any lowercase Latin letter....
instruction
0
68,327
0
136,654
Tags: dp, strings Correct Solution: ``` f = [[[-1]*205 for i in range(205)] for i in range(205)] def dp(vt, k, cnt_2 ): if vt < 1: return 0 if f[vt][k][cnt_2] != -1 : return f[vt][k][cnt_2] ret = dp(vt-1,k,cnt_2 + (s[vt] == t[1])) + (s[vt] == t[0])*cnt_2 if(k > 0): ret = max(ret,dp(vt-1,k-(s[vt]...
output
1
68,327
0
136,655
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two strings s and t consisting of lowercase Latin letters. The length of t is 2 (i.e. this string consists only of two characters). In one move, you can choose any character of s and replace it with any lowercase Latin letter....
instruction
0
68,328
0
136,656
Tags: dp, strings Correct Solution: ``` n,k = map(int, input().split()) s = input() p = input() a,b = p[0],p[1] if a==b: x = min(s.count(a)+k,n) print(x*(x-1)>>1) else: dp = [[-float('inf')]*(k+2) for _ in range(n+2)] dp[1][1] = 0 for i in range(n): for q in range(i+2,0,-1): for ...
output
1
68,328
0
136,657
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two strings s and t consisting of lowercase Latin letters. The length of t is 2 (i.e. this string consists only of two characters). In one move, you can choose any character of s and replace it with any lowercase Latin letter....
instruction
0
68,329
0
136,658
Tags: dp, strings Correct Solution: ``` def g(i,z,k): if i>=n:return 0 if q[i][z][k]>-1:return q[i][z][k] o=g(i+1,z,k);c=s[i]!=t[0] if k>=c:o=max(o,g(i+1,z+1,k-c)) c=s[i]!=t[1] if k>=c:o=max(o,g(i+1,z+(t[0]==t[1]),k-c)+z) q[i][z][k]=o;return o n,k=map(int,input().split());s=input();t=input();q=[[[-1]*(n+1)for _ ...
output
1
68,329
0
136,659
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two strings s and t consisting of lowercase Latin letters. The length of t is 2 (i.e. this string consists only of two characters). In one move, you can choose any character of s and replace it with any lowercase Latin letter....
instruction
0
68,330
0
136,660
Tags: dp, strings Correct Solution: ``` def g(i, j, k): if i >= n: return 0 if dp[i][j][k] != -1: return dp[i][j][k] o = g(i+1, j, k) c = s[i] != t[0] if k >= c: o = max(o, g(i+1, j+1, k-c)) c = s[i] != t[1] if k >= c: o = max(o, g(i+1, j+(t[0]==t[1]), k-c) + ...
output
1
68,330
0
136,661
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two strings s and t consisting of lowercase Latin letters. The length of t is 2 (i.e. this string consists only of two characters). In one move, you can choose any character of s and replace it with any lowercase Latin letter....
instruction
0
68,331
0
136,662
Tags: dp, strings Correct Solution: ``` def ss(s, t): ans = 0 for i in range(len(s)): if s[i] == t[0]:ans += s[i:].count(t[1]) return ans n, k = map(int, input().split()) s = input() t = input() if t[0] == t[1]:bs = min(k, len(s) - s.count(t[0])) + s.count(t[0]);print(bs*(bs-1)//2) else: ans ...
output
1
68,331
0
136,663
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two strings s and t consisting of lowercase Latin letters. The length of t is 2 (i.e. this string consists only of two characters). In one move, you can choose any character of s and replace it with any lowercase Latin letter....
instruction
0
68,332
0
136,664
Tags: dp, strings Correct Solution: ``` """ dp[i][j][k] = answer for first i chars of s, doing j moves, and number of t[0] is k max dp[N][j][k] 0<=j<=K 0<=k<=N dp[0][0][0] = 0 others = -infinity don't change s[i] s[i] == t[0] == t[1] update dp[i+1][j][k+1] -> dp[i][j][k] + k s[i] == t[1]:...
output
1
68,332
0
136,665
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two strings s and t consisting of lowercase Latin letters. The length of t is 2 (i.e. this string consists only of two characters). In one move, you can choose any character of s and replace it with any lowercase Latin letter....
instruction
0
68,333
0
136,666
Tags: dp, strings Correct Solution: ``` INF=10**9 def calc(n,k,s,t): dp=[[[-INF for i in range(n+1)] for j in range(k+1)] for h in range(n+1)] # print(len(dp),len(dp[0]),len(dp[0][0])) dp[0][0][0]=0 for i in range(n): for j in range(k+1): for h in range(n+1): if dp[i]...
output
1
68,333
0
136,667
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two strings s and t consisting of lowercase Latin letters. The length of t is 2 (i.e. this string consists only of two characters). In one move, you can choose any character of s and replace it with any lowercase Latin letter....
instruction
0
68,334
0
136,668
Tags: dp, strings Correct Solution: ``` import sys read = lambda: sys.stdin.readline().strip() mem = None def dp(s, t, i, T0, k): """ s - string i - position T0 - count of t[0] till i k - moves remaining """ if i >= len(s): return 0 if mem[i][T0][k] != -1: return me...
output
1
68,334
0
136,669
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given two strings s and t consisting of lowercase Latin letters. The length of t is 2 (i.e. this string consists only of two characters). In one move, you can choose any character of s ...
instruction
0
68,335
0
136,670
Yes
output
1
68,335
0
136,671
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given two strings s and t consisting of lowercase Latin letters. The length of t is 2 (i.e. this string consists only of two characters). In one move, you can choose any character of s ...
instruction
0
68,336
0
136,672
Yes
output
1
68,336
0
136,673
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given two strings s and t consisting of lowercase Latin letters. The length of t is 2 (i.e. this string consists only of two characters). In one move, you can choose any character of s ...
instruction
0
68,337
0
136,674
Yes
output
1
68,337
0
136,675
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given two strings s and t consisting of lowercase Latin letters. The length of t is 2 (i.e. this string consists only of two characters). In one move, you can choose any character of s ...
instruction
0
68,338
0
136,676
Yes
output
1
68,338
0
136,677
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given two strings s and t consisting of lowercase Latin letters. The length of t is 2 (i.e. this string consists only of two characters). In one move, you can choose any character of s ...
instruction
0
68,339
0
136,678
No
output
1
68,339
0
136,679
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given two strings s and t consisting of lowercase Latin letters. The length of t is 2 (i.e. this string consists only of two characters). In one move, you can choose any character of s ...
instruction
0
68,340
0
136,680
No
output
1
68,340
0
136,681
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given two strings s and t consisting of lowercase Latin letters. The length of t is 2 (i.e. this string consists only of two characters). In one move, you can choose any character of s ...
instruction
0
68,341
0
136,682
No
output
1
68,341
0
136,683
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given two strings s and t consisting of lowercase Latin letters. The length of t is 2 (i.e. this string consists only of two characters). In one move, you can choose any character of s ...
instruction
0
68,342
0
136,684
No
output
1
68,342
0
136,685
Provide tags and a correct Python 3 solution for this coding contest problem. You have a string s consisting of n characters. Each character is either 0 or 1. You can perform operations on the string. Each operation consists of two steps: 1. select an integer i from 1 to the length of the string s, then delete the...
instruction
0
68,343
0
136,686
Tags: binary search, data structures, greedy, two pointers Correct Solution: ``` import sys, os, io def rs(): return sys.stdin.readline().rstrip() def ri(): return int(sys.stdin.readline()) def ria(): return list(map(int, sys.stdin.readline().split())) def ws(s): sys.stdout.write(s + '\n') def wi(n): sys.stdout.write(s...
output
1
68,343
0
136,687
Provide tags and a correct Python 3 solution for this coding contest problem. You have a string s consisting of n characters. Each character is either 0 or 1. You can perform operations on the string. Each operation consists of two steps: 1. select an integer i from 1 to the length of the string s, then delete the...
instruction
0
68,344
0
136,688
Tags: binary search, data structures, greedy, two pointers Correct Solution: ``` # =============================================================================================== # importing some useful libraries. from __future__ import division, print_function from fractions import Fraction import sys import os from i...
output
1
68,344
0
136,689
Provide tags and a correct Python 3 solution for this coding contest problem. You have a string s consisting of n characters. Each character is either 0 or 1. You can perform operations on the string. Each operation consists of two steps: 1. select an integer i from 1 to the length of the string s, then delete the...
instruction
0
68,345
0
136,690
Tags: binary search, data structures, greedy, two pointers Correct Solution: ``` for _ in range(int(input())): siz = int(input()) st = input(); diff = 0; q = [] for x in range(1,siz): if st[x] != st[x-1]: diff+=1 if st[x] == st[x-1]: q.append(diff) q.reverse() rem,ans = 0,0 f...
output
1
68,345
0
136,691
Provide tags and a correct Python 3 solution for this coding contest problem. You have a string s consisting of n characters. Each character is either 0 or 1. You can perform operations on the string. Each operation consists of two steps: 1. select an integer i from 1 to the length of the string s, then delete the...
instruction
0
68,346
0
136,692
Tags: binary search, data structures, greedy, two pointers Correct Solution: ``` from collections import deque from sys import * input = stdin.readline for _ in range(int(input())): n = int(input()) s = input()+" " unique=deque() last = s[0] for i in range(1,n+1): if s[i]!=last[0]: ...
output
1
68,346
0
136,693
Provide tags and a correct Python 3 solution for this coding contest problem. You have a string s consisting of n characters. Each character is either 0 or 1. You can perform operations on the string. Each operation consists of two steps: 1. select an integer i from 1 to the length of the string s, then delete the...
instruction
0
68,347
0
136,694
Tags: binary search, data structures, greedy, two pointers Correct Solution: ``` T = int( input() ) for t in range(T): n = int( input() ) s = input() A = [] prev = '2' count = 0 for i in range(n): if s[i] == prev: count += 1 else: if count > 0: A.append(count) prev = s[i] ...
output
1
68,347
0
136,695
Provide tags and a correct Python 3 solution for this coding contest problem. You have a string s consisting of n characters. Each character is either 0 or 1. You can perform operations on the string. Each operation consists of two steps: 1. select an integer i from 1 to the length of the string s, then delete the...
instruction
0
68,348
0
136,696
Tags: binary search, data structures, greedy, two pointers Correct Solution: ``` from sys import stdin, stdout input = stdin.readline print = lambda x:stdout.write(str(x)+'\n') for _ in range(int(input())): n = int(input()) s = input().strip() p = [] o, z = 0, 0 for i in s: if i=='1': ...
output
1
68,348
0
136,697
Provide tags and a correct Python 3 solution for this coding contest problem. You have a string s consisting of n characters. Each character is either 0 or 1. You can perform operations on the string. Each operation consists of two steps: 1. select an integer i from 1 to the length of the string s, then delete the...
instruction
0
68,349
0
136,698
Tags: binary search, data structures, greedy, two pointers Correct Solution: ``` from sys import stdin,stdout from math import gcd,sqrt,factorial,pi,inf from collections import deque,defaultdict input=stdin.readline R=lambda:map(int,input().split()) I=lambda:int(input()) S=lambda:input().rstrip('\n') L=lambda:list(R())...
output
1
68,349
0
136,699
Provide tags and a correct Python 3 solution for this coding contest problem. You have a string s consisting of n characters. Each character is either 0 or 1. You can perform operations on the string. Each operation consists of two steps: 1. select an integer i from 1 to the length of the string s, then delete the...
instruction
0
68,350
0
136,700
Tags: binary search, data structures, greedy, two pointers Correct Solution: ``` def readis(): return map(int, input().strip().split()) T = int(input()) while T: T -= 1 n = int(input()) s = input() conts = [] last = None for c in s: if c == last: conts[-1] += 1 ...
output
1
68,350
0
136,701