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.
A string b is a subsequence of a string a if b can be obtained from a by deletion of several (possibly, zero or all) characters. For example, "xy" is a subsequence of "xzyw" and "xy", but not "yx".
You are given a string a. Your task is to ... | instruction | 0 | 92,848 | 0 | 185,696 |
Tags: constructive algorithms, sortings
Correct Solution:
```
import io
import os
import sys
import math
import heapq
input = sys.stdin.readline
t = int(input())
for _ in range(t):
n = int(input())
s = input().rstrip()
s = sorted(s)
print(''.join(s))
``` | output | 1 | 92,848 | 0 | 185,697 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A string b is a subsequence of a string a if b can be obtained from a by deletion of several (possibly, zero or all) characters. For example, "xy" is a subsequence of "xzyw" and "xy", but not "yx".
You are given a string a. Your task is to ... | instruction | 0 | 92,849 | 0 | 185,698 |
Tags: constructive algorithms, sortings
Correct Solution:
```
inpt = input().split()
inpt = list(map(int,inpt))
for i in range(inpt[0]):
string = input()
string = input()
ans=''
print(ans.join(sorted(string)))
``` | output | 1 | 92,849 | 0 | 185,699 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A string b is a subsequence of a string a if b can be obtained from a by deletion of several (possibly, zero or all) characters. For example, "xy" is a subsequence of "xzyw" and "xy", but not "y... | instruction | 0 | 92,850 | 0 | 185,700 |
Yes | output | 1 | 92,850 | 0 | 185,701 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A string b is a subsequence of a string a if b can be obtained from a by deletion of several (possibly, zero or all) characters. For example, "xy" is a subsequence of "xzyw" and "xy", but not "y... | instruction | 0 | 92,851 | 0 | 185,702 |
Yes | output | 1 | 92,851 | 0 | 185,703 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A string b is a subsequence of a string a if b can be obtained from a by deletion of several (possibly, zero or all) characters. For example, "xy" is a subsequence of "xzyw" and "xy", but not "y... | instruction | 0 | 92,852 | 0 | 185,704 |
Yes | output | 1 | 92,852 | 0 | 185,705 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A string b is a subsequence of a string a if b can be obtained from a by deletion of several (possibly, zero or all) characters. For example, "xy" is a subsequence of "xzyw" and "xy", but not "y... | instruction | 0 | 92,853 | 0 | 185,706 |
Yes | output | 1 | 92,853 | 0 | 185,707 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A string b is a subsequence of a string a if b can be obtained from a by deletion of several (possibly, zero or all) characters. For example, "xy" is a subsequence of "xzyw" and "xy", but not "y... | instruction | 0 | 92,854 | 0 | 185,708 |
No | output | 1 | 92,854 | 0 | 185,709 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A string b is a subsequence of a string a if b can be obtained from a by deletion of several (possibly, zero or all) characters. For example, "xy" is a subsequence of "xzyw" and "xy", but not "y... | instruction | 0 | 92,855 | 0 | 185,710 |
No | output | 1 | 92,855 | 0 | 185,711 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A string b is a subsequence of a string a if b can be obtained from a by deletion of several (possibly, zero or all) characters. For example, "xy" is a subsequence of "xzyw" and "xy", but not "y... | instruction | 0 | 92,856 | 0 | 185,712 |
No | output | 1 | 92,856 | 0 | 185,713 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A string b is a subsequence of a string a if b can be obtained from a by deletion of several (possibly, zero or all) characters. For example, "xy" is a subsequence of "xzyw" and "xy", but not "y... | instruction | 0 | 92,857 | 0 | 185,714 |
No | output | 1 | 92,857 | 0 | 185,715 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya has a set of 4n strings of equal length, consisting of lowercase English letters "a", "b", "c", "d" and "e". Moreover, the set is split into n groups of 4 equal strings each. Vasya also ha... | instruction | 0 | 93,193 | 0 | 186,386 |
No | output | 1 | 93,193 | 0 | 186,387 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya has a set of 4n strings of equal length, consisting of lowercase English letters "a", "b", "c", "d" and "e". Moreover, the set is split into n groups of 4 equal strings each. Vasya also ha... | instruction | 0 | 93,194 | 0 | 186,388 |
No | output | 1 | 93,194 | 0 | 186,389 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya has a set of 4n strings of equal length, consisting of lowercase English letters "a", "b", "c", "d" and "e". Moreover, the set is split into n groups of 4 equal strings each. Vasya also ha... | instruction | 0 | 93,195 | 0 | 186,390 |
No | output | 1 | 93,195 | 0 | 186,391 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya has a set of 4n strings of equal length, consisting of lowercase English letters "a", "b", "c", "d" and "e". Moreover, the set is split into n groups of 4 equal strings each. Vasya also ha... | instruction | 0 | 93,196 | 0 | 186,392 |
No | output | 1 | 93,196 | 0 | 186,393 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi has an empty string S and a variable x whose initial value is 0.
Also, we have a string T consisting of `0` and `1`.
Now, Takahashi will do the operation with the following two steps |T| times.
* Insert a `0` or a `1` at any position of ... | instruction | 0 | 93,268 | 0 | 186,536 |
"Correct Solution:
```
import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return ... | output | 1 | 93,268 | 0 | 186,537 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi has an empty string S and a variable x whose initial value is 0.
Also, we have a string T consisting of `0` and `1`.
Now, Takahashi will do the operation with the following two steps |T| times.
* Insert a `0` or a `1` at any position of ... | instruction | 0 | 93,269 | 0 | 186,538 |
"Correct Solution:
```
"""
なるべく各操作における奇数文字目に1をいれる
最後にたす数は確定
左端が1の時、最初に入れない理由はない
最初に必要な1を全部入れない理由、あるか?
なさそう
あとはどう0を入れていくか
1のうち、いくつが空数番目・いくつが奇数番目にいあるかを考える
0を入れると、それ以降の1の偶奇がひっくり返る
差は高々1
右端は毎回ひっくり返されるので考えなくていい
2番目は、右端で1回だけ延長できる
3番目は、2回延長できる
"""
T = input()
ans = 0
onum = 0
for i in T:
if i == "1":
onu... | output | 1 | 93,269 | 0 | 186,539 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi has an empty string S and a variable x whose initial value is 0.
Also, we have a string T consisting of `0` and `1`.
Now, Takahashi will do the operation with the following two steps |T| times.
* Insert a `0` or a `1` at any position of ... | instruction | 0 | 93,270 | 0 | 186,540 |
"Correct Solution:
```
T=input()
n=len(T)
i=r=a=0
for c in T:k=i-r;r+=(~k&1)*(c=='0');a+=(i//2-k//2+(~k&1)*(n-i))*(c=="1");i+=1
print(a)
``` | output | 1 | 93,270 | 0 | 186,541 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi has an empty string S and a variable x whose initial value is 0.
Also, we have a string T consisting of `0` and `1`.
Now, Takahashi will do the operation with the following two steps |T| times.
* Insert a `0` or a `1` at any position of ... | instruction | 0 | 93,271 | 0 | 186,542 |
"Correct Solution:
```
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
T = read().rstrip().decode()
T
def f(n, r, l, z):
# 長さnの1が座標 r から l へと移動する。
# z回立ち止まることが許されている。
# 獲得スコアの最大値は?
if n % 2 == 0:
move = r - l + z
ret... | output | 1 | 93,271 | 0 | 186,543 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi has an empty string S and a variable x whose initial value is 0.
Also, we have a string T consisting of `0` and `1`.
Now, Takahashi will do the operation with the following two steps |T| times.
* Insert a `0` or a `1` at any position of ... | instruction | 0 | 93,272 | 0 | 186,544 |
"Correct Solution:
```
t = input()
before_is_zero = True
keeped_ones = 0
n0 = 0
ones = [0] * int(1e5+1) # (number of zeros before 1, is_odd)
ones_index = 0
for i, x in enumerate(t):
if x == '0':
n0 += 1
before_is_zero = True
elif x == '1':
if before_is_zero:
ones[ones_index] ... | output | 1 | 93,272 | 0 | 186,545 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi has an empty string S and a variable x whose initial value is 0.
Also, we have a string T consisting of `0` and `1`.
Now, Takahashi will do the operation with the following two steps |T| times.
* Insert a `0` or a `1` at any position of ... | instruction | 0 | 93,273 | 0 | 186,546 |
"Correct Solution:
```
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")
t = input()
s = t.replace("0", "")
q = len(s) # 1の数
n = len(t)
ps = [None]*(q+1)
c = 0
j = 0
for tmp in t:
if tmp=="1":
ps[j] = c
j += ... | output | 1 | 93,273 | 0 | 186,547 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi has an empty string S and a variable x whose initial value is 0.
Also, we have a string T consisting of `0` and `1`.
Now, Takahashi will do the operation with the following two steps |T| times.
* Insert a `0` or a `1` at any position of ... | instruction | 0 | 93,274 | 0 | 186,548 |
"Correct Solution:
```
t = input()
before_is_zero = True
n0 = 0
n1 = 0
seq1 = 0
ans = 0
for i, x in enumerate(t):
if x == '0':
n0 += 1
before_is_zero = True
elif before_is_zero:
tmp_add = -(n0 - (i+1)%2)//2
ans += tmp_add
n1 += 1
before_is_zero = False
else:
... | output | 1 | 93,274 | 0 | 186,549 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi has an empty string S and a variable x whose initial value is 0.
Also, we have a string T consisting of `0` and `1`.
Now, Takahashi will do the operation with the following two steps |T| times.
* Insert a `0` or a `1` at any position of ... | instruction | 0 | 93,275 | 0 | 186,550 |
"Correct Solution:
```
def solve(t):
res = 0
length = 0
n = len(t)
used = [0] * n
# insert 1 greedy
for i in range(n):
if t[i] == "1":
length += 1
res += (length + 1) // 2
used[i] = 1
# insert 0 greedy
cnt_temp = 0
for i in range(n):
... | output | 1 | 93,275 | 0 | 186,551 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi has an empty string S and a variable x whose initial value is 0.
Also, we have a string T consisting of `0` and `1`.
Now, Takahashi will do the operation with the following two steps... | instruction | 0 | 93,281 | 0 | 186,562 |
No | output | 1 | 93,281 | 0 | 186,563 |
Provide a correct Python 3 solution for this coding contest problem.
There is a string S consisting of digits `1`, `2`, ..., `9`. Lunlun, the Dachshund, will take out three consecutive digits from S, treat them as a single integer X and bring it to her master. (She cannot rearrange the digits.)
The master's favorite ... | instruction | 0 | 93,323 | 0 | 186,646 |
"Correct Solution:
```
S = input()
ans = min(abs(int(S[i:i+3]) - 753) for i in range(len(S) - 2))
print(ans)
``` | output | 1 | 93,323 | 0 | 186,647 |
Provide a correct Python 3 solution for this coding contest problem.
There is a string S consisting of digits `1`, `2`, ..., `9`. Lunlun, the Dachshund, will take out three consecutive digits from S, treat them as a single integer X and bring it to her master. (She cannot rearrange the digits.)
The master's favorite ... | instruction | 0 | 93,324 | 0 | 186,648 |
"Correct Solution:
```
s = input()
print(min(abs(int("".join(p)) - 753) for p in zip(s, s[1:], s[2:])))
``` | output | 1 | 93,324 | 0 | 186,649 |
Provide a correct Python 3 solution for this coding contest problem.
There is a string S consisting of digits `1`, `2`, ..., `9`. Lunlun, the Dachshund, will take out three consecutive digits from S, treat them as a single integer X and bring it to her master. (She cannot rearrange the digits.)
The master's favorite ... | instruction | 0 | 93,325 | 0 | 186,650 |
"Correct Solution:
```
n = input()
a = []
for i in range(len(n)-2):
a += [abs(int(n[i:i+3])-753)]
print(min(a))
``` | output | 1 | 93,325 | 0 | 186,651 |
Provide a correct Python 3 solution for this coding contest problem.
There is a string S consisting of digits `1`, `2`, ..., `9`. Lunlun, the Dachshund, will take out three consecutive digits from S, treat them as a single integer X and bring it to her master. (She cannot rearrange the digits.)
The master's favorite ... | instruction | 0 | 93,326 | 0 | 186,652 |
"Correct Solution:
```
a=input()
l=[]
for i in range(len(a)-2):
l.append(abs(753-int(a[i:i+3])))
print(min(l))
``` | output | 1 | 93,326 | 0 | 186,653 |
Provide a correct Python 3 solution for this coding contest problem.
There is a string S consisting of digits `1`, `2`, ..., `9`. Lunlun, the Dachshund, will take out three consecutive digits from S, treat them as a single integer X and bring it to her master. (She cannot rearrange the digits.)
The master's favorite ... | instruction | 0 | 93,327 | 0 | 186,654 |
"Correct Solution:
```
x=input();print(min(abs(int(x[i:i+3])-753)for i in range(len(x)-2)))
``` | output | 1 | 93,327 | 0 | 186,655 |
Provide a correct Python 3 solution for this coding contest problem.
There is a string S consisting of digits `1`, `2`, ..., `9`. Lunlun, the Dachshund, will take out three consecutive digits from S, treat them as a single integer X and bring it to her master. (She cannot rearrange the digits.)
The master's favorite ... | instruction | 0 | 93,328 | 0 | 186,656 |
"Correct Solution:
```
s=input()
ans=753
for i in range(len(s)-2):
ans=min(ans,abs(int(s[i:i+3])-753))
print(ans)
``` | output | 1 | 93,328 | 0 | 186,657 |
Provide a correct Python 3 solution for this coding contest problem.
There is a string S consisting of digits `1`, `2`, ..., `9`. Lunlun, the Dachshund, will take out three consecutive digits from S, treat them as a single integer X and bring it to her master. (She cannot rearrange the digits.)
The master's favorite ... | instruction | 0 | 93,329 | 0 | 186,658 |
"Correct Solution:
```
m=999
s=input()
for i in range(2,len(s)):
m=min(m,abs(753-int(s[i-2:i+1])))
print(m)
``` | output | 1 | 93,329 | 0 | 186,659 |
Provide a correct Python 3 solution for this coding contest problem.
There is a string S consisting of digits `1`, `2`, ..., `9`. Lunlun, the Dachshund, will take out three consecutive digits from S, treat them as a single integer X and bring it to her master. (She cannot rearrange the digits.)
The master's favorite ... | instruction | 0 | 93,330 | 0 | 186,660 |
"Correct Solution:
```
S=input()
L=[abs(int(S[i:i+3]) - 753) for i in range(len(S)-2)]
print(min(L))
``` | output | 1 | 93,330 | 0 | 186,661 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a string S consisting of digits `1`, `2`, ..., `9`. Lunlun, the Dachshund, will take out three consecutive digits from S, treat them as a single integer X and bring it to her master. (S... | instruction | 0 | 93,331 | 0 | 186,662 |
Yes | output | 1 | 93,331 | 0 | 186,663 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a string S consisting of digits `1`, `2`, ..., `9`. Lunlun, the Dachshund, will take out three consecutive digits from S, treat them as a single integer X and bring it to her master. (S... | instruction | 0 | 93,332 | 0 | 186,664 |
Yes | output | 1 | 93,332 | 0 | 186,665 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a string S consisting of digits `1`, `2`, ..., `9`. Lunlun, the Dachshund, will take out three consecutive digits from S, treat them as a single integer X and bring it to her master. (S... | instruction | 0 | 93,333 | 0 | 186,666 |
Yes | output | 1 | 93,333 | 0 | 186,667 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a string S consisting of digits `1`, `2`, ..., `9`. Lunlun, the Dachshund, will take out three consecutive digits from S, treat them as a single integer X and bring it to her master. (S... | instruction | 0 | 93,334 | 0 | 186,668 |
Yes | output | 1 | 93,334 | 0 | 186,669 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a string S consisting of digits `1`, `2`, ..., `9`. Lunlun, the Dachshund, will take out three consecutive digits from S, treat them as a single integer X and bring it to her master. (S... | instruction | 0 | 93,337 | 0 | 186,674 |
No | output | 1 | 93,337 | 0 | 186,675 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a string S consisting of digits `1`, `2`, ..., `9`. Lunlun, the Dachshund, will take out three consecutive digits from S, treat them as a single integer X and bring it to her master. (S... | instruction | 0 | 93,338 | 0 | 186,676 |
No | output | 1 | 93,338 | 0 | 186,677 |
Provide a correct Python 3 solution for this coding contest problem.
Do you know "sed," a tool provided with Unix? Its most popular use is to substitute every occurrence of a string contained in the input string (actually each input line) with another string β. More precisely, it proceeds as follows.
1. Within the i... | instruction | 0 | 93,455 | 0 | 186,910 |
"Correct Solution:
```
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]
def LI(): return [int... | output | 1 | 93,455 | 0 | 186,911 |
Provide a correct Python 3 solution for this coding contest problem.
Do you know "sed," a tool provided with Unix? Its most popular use is to substitute every occurrence of a string contained in the input string (actually each input line) with another string β. More precisely, it proceeds as follows.
1. Within the i... | instruction | 0 | 93,456 | 0 | 186,912 |
"Correct Solution:
```
from collections import deque
def testcase_ends():
n = int(input())
if n == 0:
return 1
sub = [input().split() for i in range(n)]
gamma = input()
delta = input()
q = deque()
q.append((gamma, 0))
res = 10000
while q:
s, i = q.popleft()
... | output | 1 | 93,456 | 0 | 186,913 |
Provide a correct Python 3 solution for this coding contest problem.
Do you know "sed," a tool provided with Unix? Its most popular use is to substitute every occurrence of a string contained in the input string (actually each input line) with another string β. More precisely, it proceeds as follows.
1. Within the i... | instruction | 0 | 93,457 | 0 | 186,914 |
"Correct Solution:
```
def substitute(text, a, b):
pos = 0
newText = text
L1 = len(a)
L2 = len(b)
while True:
idx = newText.find(a, pos)
if idx < 0:
return newText
newText = newText[:idx] + b + newText[idx + L1:]
pos = idx + L2
return newText
def tran... | output | 1 | 93,457 | 0 | 186,915 |
Provide a correct Python 3 solution for this coding contest problem.
Do you know "sed," a tool provided with Unix? Its most popular use is to substitute every occurrence of a string contained in the input string (actually each input line) with another string β. More precisely, it proceeds as follows.
1. Within the i... | instruction | 0 | 93,458 | 0 | 186,916 |
"Correct Solution:
```
# coding: utf-8
import queue
while 1:
n=int(input())
if n==0:
break
dic={}
for i in range(n):
k,s=input().split()
dic[k]=s
s=input()
ans=input()
q=queue.Queue()
q.put((s,0))
find=False
while not q.empty():
s=q.get()
i... | output | 1 | 93,458 | 0 | 186,917 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Do you know "sed," a tool provided with Unix? Its most popular use is to substitute every occurrence of a string contained in the input string (actually each input line) with another string β. ... | instruction | 0 | 93,459 | 0 | 186,918 |
No | output | 1 | 93,459 | 0 | 186,919 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a binary string s (recall that a string is binary if each character is either 0 or 1).
Let f(t) be the decimal representation of integer t written in binary form (possibly with leading zeroes). For example f(011) = 3, f(00101)... | instruction | 0 | 93,596 | 0 | 187,192 |
Tags: binary search, bitmasks, brute force
Correct Solution:
```
import sys
from bisect import *
zz=1
sys.setrecursionlimit(10**5)
if zz:
input=sys.stdin.readline
else:
sys.stdin=open('input.txt', 'r')
sys.stdout=open('all.txt','w')
di=[[-1,0],[1,0],[0,1],[0,-1]]
def fori(n):
return [fi() for i in range(n)]
... | output | 1 | 93,596 | 0 | 187,193 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a binary string s (recall that a string is binary if each character is either 0 or 1).
Let f(t) be the decimal representation of integer t written in binary form (possibly with leading zeroes). For example f(011) = 3, f(00101)... | instruction | 0 | 93,597 | 0 | 187,194 |
Tags: binary search, bitmasks, brute force
Correct Solution:
```
import math
import sys
from collections import defaultdict
# input = sys.stdin.readline
rt = lambda: map(int, input().split())
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
def solve(a):
n = len(a)
pref0 = [0] * n
f... | output | 1 | 93,597 | 0 | 187,195 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a binary string s (recall that a string is binary if each character is either 0 or 1).
Let f(t) be the decimal representation of integer t written in binary form (possibly with leading zeroes). For example f(011) = 3, f(00101)... | instruction | 0 | 93,598 | 0 | 187,196 |
Tags: binary search, bitmasks, brute force
Correct Solution:
```
# import sys
# input = sys.stdin.readline
def calc(s):
return int(s,2)
for nt in range(int(input())):
s=input()
n=len(s)
pref=[-1]*(n)
for i in range(n):
if s[i]=="1":
pref[i]=i
else:
pref[i]=pref[i-1]
ans=0
for i in range(18):
for j i... | output | 1 | 93,598 | 0 | 187,197 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a binary string s (recall that a string is binary if each character is either 0 or 1).
Let f(t) be the decimal representation of integer t written in binary form (possibly with leading zeroes). For example f(011) = 3, f(00101)... | instruction | 0 | 93,599 | 0 | 187,198 |
Tags: binary search, bitmasks, brute force
Correct Solution:
```
'''
Auther: ghoshashis545 Ashis Ghosh
College: jalpaiguri Govt Enggineering College
'''
from os import path
from io import BytesIO, IOBase
import sys
from heapq import heappush,heappop
from functools import cmp_to_key as ctk
from collections impo... | output | 1 | 93,599 | 0 | 187,199 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a binary string s (recall that a string is binary if each character is either 0 or 1).
Let f(t) be the decimal representation of integer t written in binary form (possibly with leading zeroes). For example f(011) = 3, f(00101)... | instruction | 0 | 93,600 | 0 | 187,200 |
Tags: binary search, bitmasks, brute force
Correct Solution:
```
for _ in range(int(input())):
l = input()
n = len(l)
zeros,cnt=0,0
for i in range(n):
if l[i]=="0":zeros+=1
else:
for j in range(i,n):
if zeros+(j-i+1)>=int(l[i:j+1],2):
cnt+=... | output | 1 | 93,600 | 0 | 187,201 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a binary string s (recall that a string is binary if each character is either 0 or 1).
Let f(t) be the decimal representation of integer t written in binary form (possibly with leading zeroes). For example f(011) = 3, f(00101)... | instruction | 0 | 93,601 | 0 | 187,202 |
Tags: binary search, bitmasks, brute force
Correct Solution:
```
t = int(input())
a = []
for i in range(t):
a.append(input())
for i in a:
p=-1
l=len(i)
d=0
for j in range(l):
if i[j]=="1":
q=j
s=j-p-1
while(q<l):
if q==(j+18):
... | output | 1 | 93,601 | 0 | 187,203 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a binary string s (recall that a string is binary if each character is either 0 or 1).
Let f(t) be the decimal representation of integer t written in binary form (possibly with leading zeroes). For example f(011) = 3, f(00101)... | instruction | 0 | 93,602 | 0 | 187,204 |
Tags: binary search, bitmasks, brute force
Correct Solution:
```
for _ in range(int(input())):
s=[int(x) for x in list(input().strip())]
n=len(s)
an=0
c=0
for i in range(n):
if s[i]==1:
p=0
for j in range(18):
if i+j==n:
break... | output | 1 | 93,602 | 0 | 187,205 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a binary string s (recall that a string is binary if each character is either 0 or 1).
Let f(t) be the decimal representation of integer t written in binary form (possibly with leading zeroes). For example f(011) = 3, f(00101)... | instruction | 0 | 93,603 | 0 | 187,206 |
Tags: binary search, bitmasks, brute force
Correct Solution:
```
# Legends Always Come Up with Solution
# Author: Manvir Singh
import os
from io import BytesIO, IOBase
import sys
po=[1]
for i in range(17):
po.append(po[-1]*2)
def solve(s,x,y,a):
ans,su,j=0,0,x
while j<y:
su+=s[j]*po[j-x]
... | output | 1 | 93,603 | 0 | 187,207 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.