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.
You are given three integers a, b and x. Your task is to construct a binary string s of length n = a + b such that there are exactly a zeroes, exactly b ones and exactly x indices i (where 1 ≤ i < n) such that s_i ≠ s_{i + 1}. It is guarante... | instruction | 0 | 3,329 | 0 | 6,658 |
Tags: constructive algorithms
Correct Solution:
```
a, b, x = [int(i) for i in input().split()]
odd = ""
if x % 2 == 0:
for i in range(x//2):
odd += "01"
a -= 1
b -= 1
if b > 0:
print("1" * b + "0" * a + odd)
elif b == 0:
print(odd + "0" * a)
else:
for i in rang... | output | 1 | 3,329 | 0 | 6,659 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given three integers a, b and x. Your task is to construct a binary string s of length n = a + b such that there are exactly a zeroes, exactly b ones and exactly x indices i (where 1 ≤ i < n) such that s_i ≠ s_{i + 1}. It is guarante... | instruction | 0 | 3,330 | 0 | 6,660 |
Tags: constructive algorithms
Correct Solution:
```
def sol(z,o,k):
c = 1
idx = 1
if z>o:
s = ['0']*z+['1']*o
else:
s = ['1']*o+['0']*z
while (c<k):
key = s.pop(-1)
s.insert(idx, key)
c+=2
idx+=2
if c>k:
for _ in range(2):
key =... | output | 1 | 3,330 | 0 | 6,661 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given three integers a, b and x. Your task is to construct a binary string s of length n = a + b such that there are exactly a zeroes, exactly b ones and exactly x indices i (where 1 ≤ i < n) such that s_i ≠ s_{i + 1}. It is guarante... | instruction | 0 | 3,331 | 0 | 6,662 |
Tags: constructive algorithms
Correct Solution:
```
L = list(map(int, input().split()))
zero=L[0]
one=L[1]
x=L[2]
s=''
if x%2==0:
if one>zero :
for i in range (x//2):
s=s+'10'
s+='1'
one=one-(x//2)-1
zero=zero-(x//2)
else:
for i in range (x//2):
s=s+'01'
s+='0'
one=one-(x//... | output | 1 | 3,331 | 0 | 6,663 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given three integers a, b and x. Your task is to construct a binary string s of length n = a + b such that there are exactly a zeroes, exactly b ones and exactly x indices i (where 1 ≤ i < n) such that s_i ≠ s_{i + 1}. It is guarante... | instruction | 0 | 3,332 | 0 | 6,664 |
Tags: constructive algorithms
Correct Solution:
```
s=input()
s=s.split()
x=''
for i in range(len(s)):
s[i]=int(s[i])
if s[0]>=s[1]:
for j in range(s[2]):
if j%2==0:
x=x+'0'
else:
x=x+'1'
if s[2]%2==0:
s1=s[2]//2
s2=s[2]//2
else:
s1=s[2]//2... | output | 1 | 3,332 | 0 | 6,665 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given three integers a, b and x. Your task is to construct a binary string s of length n = a + b such that there are exactly a zeroes, exactly b ones and exactly x indices i (where 1 ≤ i < n) such that s_i ≠ s_{i + 1}. It is guarante... | instruction | 0 | 3,333 | 0 | 6,666 |
Tags: constructive algorithms
Correct Solution:
```
### PREYANSH RASTOGI
### 2017176
if __name__=="__main__":
a,b,x = [int(x) for x in input().split()]
s= ""
c=1
if b >a:
c=-1
x+=1
while(x!=0) :
if (c==1):
s+="0"
a-=1
else:
s+="1"
b-=1
c*=-1
x-=1
# print(s,a,b)
if (a>0):
q = s.rfind... | output | 1 | 3,333 | 0 | 6,667 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given three integers a, b and x. Your task is to construct a binary string s of length n = a + b such that there are exactly a zeroes, exactly b ones and exactly x indices i (where 1 ≤ i < n) such that s_i ≠ s_{i + 1}. It is guarante... | instruction | 0 | 3,334 | 0 | 6,668 |
Tags: constructive algorithms
Correct Solution:
```
from math import *
a,b,x=(int(i) for i in input().split())
ans=''
a1,b1=a,b
mx=ceil((a+b)/(x+1))
af=True
xx=0
for i in range(x-1):
if (af):
ans+='0'
a-=1
af=not(af)
else:
ans+='1'
b-=1
af=not(af)
if (af):
ans... | output | 1 | 3,334 | 0 | 6,669 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given three integers a, b and x. Your task is to construct a binary string s of length n = a + b such that there are exactly a zeroes, exactly b ones and exactly x indices i (where 1 ≤ i... | instruction | 0 | 3,335 | 0 | 6,670 |
Yes | output | 1 | 3,335 | 0 | 6,671 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given three integers a, b and x. Your task is to construct a binary string s of length n = a + b such that there are exactly a zeroes, exactly b ones and exactly x indices i (where 1 ≤ i... | instruction | 0 | 3,336 | 0 | 6,672 |
Yes | output | 1 | 3,336 | 0 | 6,673 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given three integers a, b and x. Your task is to construct a binary string s of length n = a + b such that there are exactly a zeroes, exactly b ones and exactly x indices i (where 1 ≤ i... | instruction | 0 | 3,337 | 0 | 6,674 |
Yes | output | 1 | 3,337 | 0 | 6,675 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given three integers a, b and x. Your task is to construct a binary string s of length n = a + b such that there are exactly a zeroes, exactly b ones and exactly x indices i (where 1 ≤ i... | instruction | 0 | 3,338 | 0 | 6,676 |
Yes | output | 1 | 3,338 | 0 | 6,677 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given three integers a, b and x. Your task is to construct a binary string s of length n = a + b such that there are exactly a zeroes, exactly b ones and exactly x indices i (where 1 ≤ i... | instruction | 0 | 3,340 | 0 | 6,680 |
No | output | 1 | 3,340 | 0 | 6,681 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given three integers a, b and x. Your task is to construct a binary string s of length n = a + b such that there are exactly a zeroes, exactly b ones and exactly x indices i (where 1 ≤ i... | instruction | 0 | 3,341 | 0 | 6,682 |
No | output | 1 | 3,341 | 0 | 6,683 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given three integers a, b and x. Your task is to construct a binary string s of length n = a + b such that there are exactly a zeroes, exactly b ones and exactly x indices i (where 1 ≤ i... | instruction | 0 | 3,342 | 0 | 6,684 |
No | output | 1 | 3,342 | 0 | 6,685 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Hr0d1y has q queries on a binary string s of length n. A binary string is a string containing only characters '0' and '1'.
A query is described by a pair of integers l_i, r_i (1 ≤ l_i < r_i ≤ n).
For each query, he has to determine whethe... | instruction | 0 | 3,581 | 0 | 7,162 |
Tags: dp, greedy, implementation, strings
Correct Solution:
```
from sys import stdin, stdout
#stdin = open('22-Q1.txt', 'r')
def II(): return int(stdin.readline())
def SI(): return stdin.readline()[:-1]
def MI(): return map(int, stdin.readline().split())
yes = 'YES\n'
no = 'NO\n'
def solve():
n, q = MI()
s ... | output | 1 | 3,581 | 0 | 7,163 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Hr0d1y has q queries on a binary string s of length n. A binary string is a string containing only characters '0' and '1'.
A query is described by a pair of integers l_i, r_i (1 ≤ l_i < r_i ≤ n).
For each query, he has to determine whethe... | instruction | 0 | 3,582 | 0 | 7,164 |
Tags: dp, greedy, implementation, strings
Correct Solution:
```
# Enter your code here. Read input from STDIN. Print output to STDOUT# ===============================================================================================
# importing some useful libraries.
from __future__ import division, print_function
from f... | output | 1 | 3,582 | 0 | 7,165 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Hr0d1y has q queries on a binary string s of length n. A binary string is a string containing only characters '0' and '1'.
A query is described by a pair of integers l_i, r_i (1 ≤ l_i < r_i ≤ n).
For each query, he has to determine whethe... | instruction | 0 | 3,583 | 0 | 7,166 |
Tags: dp, greedy, implementation, strings
Correct Solution:
```
t = int(input())
for t in range(0,t):
q= list(map (int, input().rstrip().split()))
n=q[0]
qu=q[1]
str=input()
for j in range(0,qu):
a= list(map (int, input().rstrip().split()))
l=a[0]
r=a[1]
st=str[l-1... | output | 1 | 3,583 | 0 | 7,167 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Hr0d1y has q queries on a binary string s of length n. A binary string is a string containing only characters '0' and '1'.
A query is described by a pair of integers l_i, r_i (1 ≤ l_i < r_i ≤ n).
For each query, he has to determine whethe... | instruction | 0 | 3,584 | 0 | 7,168 |
Tags: dp, greedy, implementation, strings
Correct Solution:
```
for _ in range(int(input())):
n , q = map(int , input().split())
s = input()
for __ in range(q):
l,r = map(int , input().split())
l-=1 ; r-=1
bad = True
i = 0
while(i<l and bad):
if(s[i] ==... | output | 1 | 3,584 | 0 | 7,169 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Hr0d1y has q queries on a binary string s of length n. A binary string is a string containing only characters '0' and '1'.
A query is described by a pair of integers l_i, r_i (1 ≤ l_i < r_i ≤ n).
For each query, he has to determine whethe... | instruction | 0 | 3,585 | 0 | 7,170 |
Tags: dp, greedy, implementation, strings
Correct Solution:
```
# Problem: B. Non-Substring Subsequence
# Contest: Codeforces - Codeforces Round #685 (Div. 2)
# URL: https://codeforces.com/contest/1451/problem/B
# Memory Limit: 256 MB
# Time Limit: 1000 ms
#
# KAPOOR'S
from sys import stdin, stdout
def INI():
retu... | output | 1 | 3,585 | 0 | 7,171 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Hr0d1y has q queries on a binary string s of length n. A binary string is a string containing only characters '0' and '1'.
A query is described by a pair of integers l_i, r_i (1 ≤ l_i < r_i ≤ n).
For each query, he has to determine whethe... | instruction | 0 | 3,586 | 0 | 7,172 |
Tags: dp, greedy, implementation, strings
Correct Solution:
```
if __name__ == '__main__':
t = int(input())
for i in range(t):
n,q = input().split()
qen = input()
for k in range(int(q)):
start,end = input().split()
sub = qen[int(start)-1:int(end)]
s = ... | output | 1 | 3,586 | 0 | 7,173 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Hr0d1y has q queries on a binary string s of length n. A binary string is a string containing only characters '0' and '1'.
A query is described by a pair of integers l_i, r_i (1 ≤ l_i < r_i ≤ n).
For each query, he has to determine whethe... | instruction | 0 | 3,587 | 0 | 7,174 |
Tags: dp, greedy, implementation, strings
Correct Solution:
```
import sys,functools,collections,bisect,math,heapq
input = sys.stdin.readline
#print = sys.stdout.write
mod = 10**9 +7
t = int(input())
for _ in range(t):
n,q = map(int,input().strip().split())
s = input().strip()
leftzero = s.find('0')
... | output | 1 | 3,587 | 0 | 7,175 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Hr0d1y has q queries on a binary string s of length n. A binary string is a string containing only characters '0' and '1'.
A query is described by a pair of integers l_i, r_i (1 ≤ l_i < r_i ≤ n).
For each query, he has to determine whethe... | instruction | 0 | 3,588 | 0 | 7,176 |
Tags: dp, greedy, implementation, strings
Correct Solution:
```
for _ in range(int(input())):
n, q = map(int, input().split())
s = input()
for i in range(q):
l, r = map(int, input().split())
l -= 1
r -= 1
fl = 0
for j in range(l):
if s[j] == s[l]:
... | output | 1 | 3,588 | 0 | 7,177 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Hr0d1y has q queries on a binary string s of length n. A binary string is a string containing only characters '0' and '1'.
A query is described by a pair of integers l_i, r_i (1 ≤ l_i < r_i ≤ n... | instruction | 0 | 3,589 | 0 | 7,178 |
Yes | output | 1 | 3,589 | 0 | 7,179 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Hr0d1y has q queries on a binary string s of length n. A binary string is a string containing only characters '0' and '1'.
A query is described by a pair of integers l_i, r_i (1 ≤ l_i < r_i ≤ n... | instruction | 0 | 3,590 | 0 | 7,180 |
Yes | output | 1 | 3,590 | 0 | 7,181 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Hr0d1y has q queries on a binary string s of length n. A binary string is a string containing only characters '0' and '1'.
A query is described by a pair of integers l_i, r_i (1 ≤ l_i < r_i ≤ n... | instruction | 0 | 3,591 | 0 | 7,182 |
Yes | output | 1 | 3,591 | 0 | 7,183 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Hr0d1y has q queries on a binary string s of length n. A binary string is a string containing only characters '0' and '1'.
A query is described by a pair of integers l_i, r_i (1 ≤ l_i < r_i ≤ n... | instruction | 0 | 3,592 | 0 | 7,184 |
Yes | output | 1 | 3,592 | 0 | 7,185 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Hr0d1y has q queries on a binary string s of length n. A binary string is a string containing only characters '0' and '1'.
A query is described by a pair of integers l_i, r_i (1 ≤ l_i < r_i ≤ n... | instruction | 0 | 3,593 | 0 | 7,186 |
No | output | 1 | 3,593 | 0 | 7,187 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Hr0d1y has q queries on a binary string s of length n. A binary string is a string containing only characters '0' and '1'.
A query is described by a pair of integers l_i, r_i (1 ≤ l_i < r_i ≤ n... | instruction | 0 | 3,594 | 0 | 7,188 |
No | output | 1 | 3,594 | 0 | 7,189 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Hr0d1y has q queries on a binary string s of length n. A binary string is a string containing only characters '0' and '1'.
A query is described by a pair of integers l_i, r_i (1 ≤ l_i < r_i ≤ n... | instruction | 0 | 3,595 | 0 | 7,190 |
No | output | 1 | 3,595 | 0 | 7,191 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Hr0d1y has q queries on a binary string s of length n. A binary string is a string containing only characters '0' and '1'.
A query is described by a pair of integers l_i, r_i (1 ≤ l_i < r_i ≤ n... | instruction | 0 | 3,596 | 0 | 7,192 |
No | output | 1 | 3,596 | 0 | 7,193 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Fibonacci strings are defined as follows:
* f1 = «a»
* f2 = «b»
* fn = fn - 1 fn - 2, n > 2
Thus, the first five Fibonacci strings are: "a", "b", "ba", "bab", "babba".
You are given a Fibonacci string and m strings si. For each... | instruction | 0 | 3,642 | 0 | 7,284 |
Tags: strings
Correct Solution:
```
F = ['', 'a', 'b', 'ba', 'bab', 'babba', 'babbabab', 'babbababbabba', 'babbababbabbababbabab', 'babbababbabbababbababbabbababbabba', 'babbababbabbababbababbabbababbabbababbababbabbababbabab', 'babbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabba',... | output | 1 | 3,642 | 0 | 7,285 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Fibonacci strings are defined as follows:
* f1 = «a»
* f2 = «b»
* fn = fn - 1 fn - 2, n > 2
Thus, the first five Fibonacci strings are: "a", "b", "ba", "bab", "babba".
You are given a Fibonacci string and m strings si. For each... | instruction | 0 | 3,643 | 0 | 7,286 |
Tags: strings
Correct Solution:
```
F = ['', 'a', 'b', 'ba', 'bab', 'babba', 'babbabab', 'babbababbabba', 'babbababbabbababbabab', 'babbababbabbababbababbabbababbabba', 'babbababbabbababbababbabbababbabbababbababbabbababbabab', 'babbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabba',... | output | 1 | 3,643 | 0 | 7,287 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Fibonacci strings are defined as follows:
* f1 = «a»
* f2 = «b»
* fn = fn - 1 fn - 2, n > 2
Thus, the first five Fibonacci strings are: "a", "b", "ba", "bab", "babba".
You are give... | instruction | 0 | 3,644 | 0 | 7,288 |
No | output | 1 | 3,644 | 0 | 7,289 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Fibonacci strings are defined as follows:
* f1 = «a»
* f2 = «b»
* fn = fn - 1 fn - 2, n > 2
Thus, the first five Fibonacci strings are: "a", "b", "ba", "bab", "babba".
You are give... | instruction | 0 | 3,645 | 0 | 7,290 |
No | output | 1 | 3,645 | 0 | 7,291 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Mr. Kitayuta has kindly given you a string s consisting of lowercase English letters. You are asked to insert exactly n lowercase English letters into s to make it a palindrome. (A palindrome is a string that reads the same forward and backw... | instruction | 0 | 3,743 | 0 | 7,486 |
Tags: combinatorics, dp, matrices, strings
Correct Solution:
```
s = input()
n = len(s)
for i in range(n + 1):
new_s = s[:i] + s[-i-(i<=n//2)] + s[i:]
if new_s == new_s[::-1]:
print(new_s)
break
else:
print('NA')
``` | output | 1 | 3,743 | 0 | 7,487 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Mr. Kitayuta has kindly given you a string s consisting of lowercase English letters. You are asked to insert exactly n lowercase English letters into s to make it a palindrome. (A palindrome is a string that reads the same forward and backw... | instruction | 0 | 3,744 | 0 | 7,488 |
Tags: combinatorics, dp, matrices, strings
Correct Solution:
```
import sys
def checkRest(word):
left = 0;
right = len(word) - 1
while(left <= right):
if(word[left] != word[right]):
return False
left+=1
right-=1
return True
def palen(line):
left = 0
right = len(line)-1
while(left < right):
if(line[... | output | 1 | 3,744 | 0 | 7,489 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Mr. Kitayuta has kindly given you a string s consisting of lowercase English letters. You are asked to insert exactly n lowercase English letters into s to make it a palindrome. (A palindrome is a string that reads the same forward and backw... | instruction | 0 | 3,745 | 0 | 7,490 |
Tags: combinatorics, dp, matrices, strings
Correct Solution:
```
from string import ascii_lowercase
def makePalindrome(st):
if not st or not st.isalpha() or not st.islower():
return "NA"
# chars = "abcdefghijklmnopqrstuvwxyz"
for letter in ascii_lowercase:
for pos in range(len(st) + 1):
tmp = st[:p... | output | 1 | 3,745 | 0 | 7,491 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Mr. Kitayuta has kindly given you a string s consisting of lowercase English letters. You are asked to insert exactly n lowercase English letters into s to make it a palindrome. (A palindrome is a string that reads the same forward and backw... | instruction | 0 | 3,746 | 0 | 7,492 |
Tags: combinatorics, dp, matrices, strings
Correct Solution:
```
x = input()
d = False
for c in range(97,123):
if ( d):
break
for i in range(len(x) + 1):
n = x[:i] + chr(c) + x[i:]
if n == n[::-1]:
print (n)
d= True
break
if (... | output | 1 | 3,746 | 0 | 7,493 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Mr. Kitayuta has kindly given you a string s consisting of lowercase English letters. You are asked to insert exactly n lowercase English letters into s to make it a palindrome. (A palindrome is a string that reads the same forward and backw... | instruction | 0 | 3,747 | 0 | 7,494 |
Tags: combinatorics, dp, matrices, strings
Correct Solution:
```
import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97 # a
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return [int(i) for i in input... | output | 1 | 3,747 | 0 | 7,495 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Mr. Kitayuta has kindly given you a string s consisting of lowercase English letters. You are asked to insert exactly n lowercase English letters into s to make it a palindrome. (A palindrome is a string that reads the same forward and backw... | instruction | 0 | 3,748 | 0 | 7,496 |
Tags: combinatorics, dp, matrices, strings
Correct Solution:
```
#input
s=str(input())
#variables
def ispalindrome(s):
if s==s[::-1]:
return True
return False
#main
for i in range(len(s)+1):
if i<len(s)/2:
t=s[:i]+s[len(s)-i-1]+s[i:]
else:
t=s[:i]+s[len(s)-i]+s[i:]
if ispalindrome(t):
print(t)
quit()
... | output | 1 | 3,748 | 0 | 7,497 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Mr. Kitayuta has kindly given you a string s consisting of lowercase English letters. You are asked to insert exactly n lowercase English letters into s to make it a palindrome. (A palindrome is a string that reads the same forward and backw... | instruction | 0 | 3,749 | 0 | 7,498 |
Tags: combinatorics, dp, matrices, strings
Correct Solution:
```
# 505A
__author__ = 'artyom'
# SOLUTION
def main():
s = list(read(0))
n = len(s)
m = n // 2
for i in range(n + 1):
p = s[:i] + [s[n - i - (i <= m)]] + s[i:n]
if p == p[::-1]:
return p
return 'NA'
# HELPERS
def read(mode=2):
... | output | 1 | 3,749 | 0 | 7,499 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Mr. Kitayuta has kindly given you a string s consisting of lowercase English letters. You are asked to insert exactly n lowercase English letters into s to make it a palindrome. (A palindrome is a string that reads the same forward and backw... | instruction | 0 | 3,750 | 0 | 7,500 |
Tags: combinatorics, dp, matrices, strings
Correct Solution:
```
s = input()
l = (len(s)+1)//2
k = 'qwertyuiopasdfghjklzxcvbnm'
ans = 'NA'
for i in range(len(s)+1):
for j in k:
e = ''
b = s
b = s[:i]+j+s[i:]
r = [x for x in b[-l:]]
r.reverse()
for c in r:
... | output | 1 | 3,750 | 0 | 7,501 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Andrewid the Android is a galaxy-famous detective. In his free time he likes to think about strings containing zeros and ones.
Once he thought about a string of length n consisting of zeroes and ones. Consider the following operation: we ch... | instruction | 0 | 3,759 | 0 | 7,518 |
Tags: greedy
Correct Solution:
```
n=int(input())
s=input()
one=s.count('1')
zero=s.count('0')
k=min(one,zero)
k*=2
print(n-k)
``` | output | 1 | 3,759 | 0 | 7,519 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Andrewid the Android is a galaxy-famous detective. In his free time he likes to think about strings containing zeros and ones.
Once he thought about a string of length n consisting of zeroes and ones. Consider the following operation: we ch... | instruction | 0 | 3,760 | 0 | 7,520 |
Tags: greedy
Correct Solution:
```
n=int(input())
l=input()
o=l.count('1')
z=l.count('0')
if o==z:
print(0)
else:
print(abs(o-z))
``` | output | 1 | 3,760 | 0 | 7,521 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Andrewid the Android is a galaxy-famous detective. In his free time he likes to think about strings containing zeros and ones.
Once he thought about a string of length n consisting of zeroes and ones. Consider the following operation: we ch... | instruction | 0 | 3,761 | 0 | 7,522 |
Tags: greedy
Correct Solution:
```
n = int(input())
z = input().count('0')
print(n - 2 * min(z, n - z))
``` | output | 1 | 3,761 | 0 | 7,523 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Andrewid the Android is a galaxy-famous detective. In his free time he likes to think about strings containing zeros and ones.
Once he thought about a string of length n consisting of zeroes and ones. Consider the following operation: we ch... | instruction | 0 | 3,762 | 0 | 7,524 |
Tags: greedy
Correct Solution:
```
z=input('')
b=input('')
c=b
d=0
e=0
for i in c:
if i=="1":
e=e+1
elif i=="0":
d=d+1
print(abs(d-e))
``` | output | 1 | 3,762 | 0 | 7,525 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Andrewid the Android is a galaxy-famous detective. In his free time he likes to think about strings containing zeros and ones.
Once he thought about a string of length n consisting of zeroes and ones. Consider the following operation: we ch... | instruction | 0 | 3,763 | 0 | 7,526 |
Tags: greedy
Correct Solution:
```
n = int(input())
s = list(input())
zeros = s.count('0')
ones = n - zeros
minimum = min(zeros, ones)
print(n-2*minimum)
``` | output | 1 | 3,763 | 0 | 7,527 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Andrewid the Android is a galaxy-famous detective. In his free time he likes to think about strings containing zeros and ones.
Once he thought about a string of length n consisting of zeroes and ones. Consider the following operation: we ch... | instruction | 0 | 3,764 | 0 | 7,528 |
Tags: greedy
Correct Solution:
```
n = int(input())
input_str = input()
num_zeros = 0
num_ones = 0
for num in input_str:
if num == '0':
num_zeros += 1
else:
num_ones += 1
result = abs(num_ones - num_zeros)
print(result)
``` | output | 1 | 3,764 | 0 | 7,529 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Andrewid the Android is a galaxy-famous detective. In his free time he likes to think about strings containing zeros and ones.
Once he thought about a string of length n consisting of zeroes and ones. Consider the following operation: we ch... | instruction | 0 | 3,765 | 0 | 7,530 |
Tags: greedy
Correct Solution:
```
n = int(input())
t = input()
a = b = 0
for i in range(0, n):
if t[i] == '0':
a += 1
else:
b += 1
print(abs(a - b))
``` | output | 1 | 3,765 | 0 | 7,531 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Andrewid the Android is a galaxy-famous detective. In his free time he likes to think about strings containing zeros and ones.
Once he thought about a string of length n consisting of zeroes and ones. Consider the following operation: we ch... | instruction | 0 | 3,766 | 0 | 7,532 |
Tags: greedy
Correct Solution:
```
n = int(input())
s = input()
n0 = 0
n1 = 0
ans = n
for i in range(n):
if s[i] == '0':
if n1 > 0:
n1 -= 1
ans -= 2
else:
n0 += 1
else:
if n0 > 0:
n0 -= 1
ans -= 2
else:
n1 +=... | output | 1 | 3,766 | 0 | 7,533 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Andrewid the Android is a galaxy-famous detective. In his free time he likes to think about strings containing zeros and ones.
Once he thought about a string of length n consisting of zeroes an... | instruction | 0 | 3,767 | 0 | 7,534 |
Yes | output | 1 | 3,767 | 0 | 7,535 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.