message stringlengths 2 15.4k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 45 107k | cluster float64 21 21 | __index_level_0__ int64 90 214k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
Recall that the bracket sequence is considered regular if it is possible to insert symbols '+' and '1' into it so that the result is a correct arithmetic expression. For example, a sequence "(()())" is regular, because we can get correct ari... | instruction | 0 | 20,865 | 21 | 41,730 |
Tags: constructive algorithms
Correct Solution:
```
from math import *
n,k=map(int,input().split())
if n*(n-1)//2<k:
print("Impossible")
else:
li=[]
temp=int((-1+sqrt(8*k+1))//2)
k-=(temp*(temp+1))//2
li+=[temp]
for i in range(temp):
cur=temp-i
if cur<=k and cur>0:
li... | output | 1 | 20,865 | 21 | 41,731 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recall that the bracket sequence is considered regular if it is possible to insert symbols '+' and '1' into it so that the result is a correct arithmetic expression. For example, a sequence "(()())" is regular, because we can get correct ari... | instruction | 0 | 20,866 | 21 | 41,732 |
Tags: constructive algorithms
Correct Solution:
```
ch=input()
l=ch.split(' ')
n=int(l[0])
k=int(l[1])
l1='('
l2=')'
l3='()'
s=0
mi=0
ch=''
from math import sqrt
q=int(sqrt(2*k))
while k>=(q*(q-1))/2:
q=q+1
q=q-1
d=int(k-(q*(q-1))/2)
mi=q
i=0
if d!=0:
mi=q+1
i=1
if n<mi:
print('Impossible')
else:
c=... | output | 1 | 20,866 | 21 | 41,733 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recall that the bracket sequence is considered regular if it is possible to insert symbols '+' and '1' into it so that the result is a correct arithmetic expression. For example, a sequence "(()... | instruction | 0 | 20,867 | 21 | 41,734 |
Yes | output | 1 | 20,867 | 21 | 41,735 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recall that the bracket sequence is considered regular if it is possible to insert symbols '+' and '1' into it so that the result is a correct arithmetic expression. For example, a sequence "(()... | instruction | 0 | 20,868 | 21 | 41,736 |
Yes | output | 1 | 20,868 | 21 | 41,737 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recall that the bracket sequence is considered regular if it is possible to insert symbols '+' and '1' into it so that the result is a correct arithmetic expression. For example, a sequence "(()... | instruction | 0 | 20,869 | 21 | 41,738 |
Yes | output | 1 | 20,869 | 21 | 41,739 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recall that the bracket sequence is considered regular if it is possible to insert symbols '+' and '1' into it so that the result is a correct arithmetic expression. For example, a sequence "(()... | instruction | 0 | 20,870 | 21 | 41,740 |
Yes | output | 1 | 20,870 | 21 | 41,741 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recall that the bracket sequence is considered regular if it is possible to insert symbols '+' and '1' into it so that the result is a correct arithmetic expression. For example, a sequence "(()... | instruction | 0 | 20,871 | 21 | 41,742 |
No | output | 1 | 20,871 | 21 | 41,743 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recall that the bracket sequence is considered regular if it is possible to insert symbols '+' and '1' into it so that the result is a correct arithmetic expression. For example, a sequence "(()... | instruction | 0 | 20,872 | 21 | 41,744 |
No | output | 1 | 20,872 | 21 | 41,745 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recall that the bracket sequence is considered regular if it is possible to insert symbols '+' and '1' into it so that the result is a correct arithmetic expression. For example, a sequence "(()... | instruction | 0 | 20,873 | 21 | 41,746 |
No | output | 1 | 20,873 | 21 | 41,747 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recall that the bracket sequence is considered regular if it is possible to insert symbols '+' and '1' into it so that the result is a correct arithmetic expression. For example, a sequence "(()... | instruction | 0 | 20,874 | 21 | 41,748 |
No | output | 1 | 20,874 | 21 | 41,749 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A string is called bracket sequence if it does not contain any characters other than "(" and ")". A bracket sequence is called regular if it it is possible to obtain correct arithmetic expression by inserting characters "+" and "1" into this... | instruction | 0 | 21,229 | 21 | 42,458 |
Tags: greedy, implementation
Correct Solution:
```
"""
NTC here
"""
iin=lambda :int(input())
lin=lambda :list(map(int,input().split()))
a=[iin() for i in range(4)]
if a[0]==a[3]==0 and a[2]!=0:print(0)
elif a[0]==a[3]:print(1)
else:print(0)
``` | output | 1 | 21,229 | 21 | 42,459 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A string is called bracket sequence if it does not contain any characters other than "(" and ")". A bracket sequence is called regular if it it is possible to obtain correct arithmetic expression by inserting characters "+" and "1" into this... | instruction | 0 | 21,230 | 21 | 42,460 |
Tags: greedy, implementation
Correct Solution:
```
a = int(input())
b = int(input())
c = int(input())
d = int(input())
if a != d or (a == 0 and c != 0):
print(0)
else:
print(1)
``` | output | 1 | 21,230 | 21 | 42,461 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A string is called bracket sequence if it does not contain any characters other than "(" and ")". A bracket sequence is called regular if it it is possible to obtain correct arithmetic expression by inserting characters "+" and "1" into this... | instruction | 0 | 21,231 | 21 | 42,462 |
Tags: greedy, implementation
Correct Solution:
```
'''
t= input()
lng= len(t)
li1=[]; li2=[]
for i in range(lng):
if t[i]!='a':
li1.append(t[i])
elif t[i]=='a':
li2.append(i)
aa= ''.join(li1)
if len(aa)==0:
print(t); exit(0)
if len(aa)%2==1:
print(':('); exit(0)
if len(aa)%2==0:... | output | 1 | 21,231 | 21 | 42,463 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A string is called bracket sequence if it does not contain any characters other than "(" and ")". A bracket sequence is called regular if it it is possible to obtain correct arithmetic expression by inserting characters "+" and "1" into this... | instruction | 0 | 21,232 | 21 | 42,464 |
Tags: greedy, implementation
Correct Solution:
```
cnt1 = int(input())
cnt2 = int(input())
cnt3 = int(input())
cnt4 = int(input())
if cnt1 != cnt4:
print(0)
elif cnt3 > 0 and cnt1 == 0:
print(0)
else:
print(1)
``` | output | 1 | 21,232 | 21 | 42,465 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A string is called bracket sequence if it does not contain any characters other than "(" and ")". A bracket sequence is called regular if it it is possible to obtain correct arithmetic expression by inserting characters "+" and "1" into this... | instruction | 0 | 21,233 | 21 | 42,466 |
Tags: greedy, implementation
Correct Solution:
```
a=int(input())
b=int(input())
c=int(input())
d=int(input())
if(a!=d):
print(0)
elif(c>0 and (a==0 or d==0)):
print(0)
else:
print(1)
``` | output | 1 | 21,233 | 21 | 42,467 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A string is called bracket sequence if it does not contain any characters other than "(" and ")". A bracket sequence is called regular if it it is possible to obtain correct arithmetic expression by inserting characters "+" and "1" into this... | instruction | 0 | 21,234 | 21 | 42,468 |
Tags: greedy, implementation
Correct Solution:
```
cnt = [int(input()) for _ in range(4)]
if cnt[0] != cnt[3]:
print(0)
elif cnt[2] > 0 and cnt[0] == 0:
print(0)
else:
print(1)
``` | output | 1 | 21,234 | 21 | 42,469 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A string is called bracket sequence if it does not contain any characters other than "(" and ")". A bracket sequence is called regular if it it is possible to obtain correct arithmetic expression by inserting characters "+" and "1" into this... | instruction | 0 | 21,235 | 21 | 42,470 |
Tags: greedy, implementation
Correct Solution:
```
a=int(input())
b=int(input())
c=int(input())
d=int(input())
d=d*2
a=a*2
if a==d==0 and c>0:
print(0)
exit()
c=c%2
if c<=a and c<=d and a==d:
print(1)
else:
print(0)
``` | output | 1 | 21,235 | 21 | 42,471 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A string is called bracket sequence if it does not contain any characters other than "(" and ")". A bracket sequence is called regular if it it is possible to obtain correct arithmetic expression by inserting characters "+" and "1" into this... | instruction | 0 | 21,236 | 21 | 42,472 |
Tags: greedy, implementation
Correct Solution:
```
a = int(input())
b = int(input())
c = int(input())
d = int(input())
if a == d and (c == 0 or a != 0):
print(1)
else:
print(0)
``` | output | 1 | 21,236 | 21 | 42,473 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A string is called bracket sequence if it does not contain any characters other than "(" and ")". A bracket sequence is called regular if it it is possible to obtain correct arithmetic expressio... | instruction | 0 | 21,237 | 21 | 42,474 |
Yes | output | 1 | 21,237 | 21 | 42,475 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A string is called bracket sequence if it does not contain any characters other than "(" and ")". A bracket sequence is called regular if it it is possible to obtain correct arithmetic expressio... | instruction | 0 | 21,238 | 21 | 42,476 |
Yes | output | 1 | 21,238 | 21 | 42,477 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A string is called bracket sequence if it does not contain any characters other than "(" and ")". A bracket sequence is called regular if it it is possible to obtain correct arithmetic expressio... | instruction | 0 | 21,239 | 21 | 42,478 |
Yes | output | 1 | 21,239 | 21 | 42,479 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A string is called bracket sequence if it does not contain any characters other than "(" and ")". A bracket sequence is called regular if it it is possible to obtain correct arithmetic expressio... | instruction | 0 | 21,240 | 21 | 42,480 |
Yes | output | 1 | 21,240 | 21 | 42,481 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A string is called bracket sequence if it does not contain any characters other than "(" and ")". A bracket sequence is called regular if it it is possible to obtain correct arithmetic expressio... | instruction | 0 | 21,241 | 21 | 42,482 |
No | output | 1 | 21,241 | 21 | 42,483 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A string is called bracket sequence if it does not contain any characters other than "(" and ")". A bracket sequence is called regular if it it is possible to obtain correct arithmetic expressio... | instruction | 0 | 21,242 | 21 | 42,484 |
No | output | 1 | 21,242 | 21 | 42,485 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A string is called bracket sequence if it does not contain any characters other than "(" and ")". A bracket sequence is called regular if it it is possible to obtain correct arithmetic expressio... | instruction | 0 | 21,243 | 21 | 42,486 |
No | output | 1 | 21,243 | 21 | 42,487 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A string is called bracket sequence if it does not contain any characters other than "(" and ")". A bracket sequence is called regular if it it is possible to obtain correct arithmetic expressio... | instruction | 0 | 21,244 | 21 | 42,488 |
No | output | 1 | 21,244 | 21 | 42,489 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Neko is playing with his toys on the backyard of Aki's house. Aki decided to play a prank on him, by secretly putting catnip into Neko's toys. Unfortunately, he went overboard and put an entire bag of catnip into the toys...
It took Neko an... | instruction | 0 | 21,245 | 21 | 42,490 |
Tags: dp, greedy, trees
Correct Solution:
```
n = int(input())
mod = 10**9+7
dp = [[0]*(n+1) for i in range(2*n+1)]
dp[0][0] = 1
for d in range(1, 2*n+1):
for v in range(n+1):
if v+1 <= n:
dp[d][v+1] += dp[d-1][v]
dp[d][v+1] %= mod
if v-1 >= 0:
dp[d][v-1] += dp[d... | output | 1 | 21,245 | 21 | 42,491 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Neko is playing with his toys on the backyard of Aki's house. Aki decided to play a prank on him, by secretly putting catnip into Neko's toys. Unfortunately, he went overboard and put an entire bag of catnip into the toys...
It took Neko an... | instruction | 0 | 21,246 | 21 | 42,492 |
Tags: dp, greedy, trees
Correct Solution:
```
mod = 1000000007
n = int(input())
cat = [0] * 1100
f, c, i = 1, 1, 1
while i < 1100:
cat[i] = f
i += 1
c = c * (8*i - 12) // i
f = c - f
cat = cat[1:-1]
sm = 0
for i in range(3, n + 3):
sm += (cat[i - 1] + (-1) ** (i - 1)) // (1 << i)
print(sm % mod)
``` | output | 1 | 21,246 | 21 | 42,493 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Neko is playing with his toys on the backyard of Aki's house. Aki decided to play a prank on him, by secretly putting catnip into Neko's toys. Unfortunately, he went overboard and put an entire bag of catnip into the toys...
It took Neko an... | instruction | 0 | 21,247 | 21 | 42,494 |
Tags: dp, greedy, trees
Correct Solution:
```
def fine():
f, c, n = 1, 1, 1
yield 0
while True:
yield f
n += 1
c = c * (4 * n - 6) // n
f = (c - f) // 2
f = fine()
n = int(input())
print((sum(next(f) for _ in range(n + 3)) - 1) % (10**9 + 7))
``` | output | 1 | 21,247 | 21 | 42,495 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Neko is playing with his toys on the backyard of Aki's house. Aki decided to play a prank on him, by secretly putting catnip into Neko's toys. Unfortunately, he went overboard and put an entire bag of catnip into the toys...
It took Neko an... | instruction | 0 | 21,248 | 21 | 42,496 |
Tags: dp, greedy, trees
Correct Solution:
```
from itertools import accumulate
N = int(input())
arr = [1]
res = 1
for i in range(2,N+1):
arr = list(accumulate(arr))
arr = arr + [arr[-1]]
d = i+1
#print(arr)
s = 0
for i in range(len(arr)):
s += arr[i]*(d//2)
d -=... | output | 1 | 21,248 | 21 | 42,497 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Neko is playing with his toys on the backyard of Aki's house. Aki decided to play a prank on him, by secretly putting catnip into Neko's toys. Unfortunately, he went overboard and put an entire bag of catnip into the toys...
It took Neko an... | instruction | 0 | 21,249 | 21 | 42,498 |
Tags: dp, greedy, trees
Correct Solution:
```
n = int(input())
board = [[0 for i in range(n + 1)] for j in range(2 * n + 1)]
board[0][0] = 1
for i in range(1, n):
for j in range(len(board[0])):
if j > 0:
board[i][j-1] += board[i-1][j]
if j + 1 < len(board[0]) and j < 2 * n - i:
... | output | 1 | 21,249 | 21 | 42,499 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Neko is playing with his toys on the backyard of Aki's house. Aki decided to play a prank on him, by secretly putting catnip into Neko's toys. Unfortunately, he went overboard and put an entire bag of catnip into the toys...
It took Neko an... | instruction | 0 | 21,250 | 21 | 42,500 |
Tags: dp, greedy, trees
Correct Solution:
```
n = int(input())
f = [[0]*(n+1) for i in range(n+1)]
g = [[0]*(n+1) for i in range(n+1)]
mod = 10**9+7
for i in range(1, n + 1):
f[0][i] = g[0][i - 1]
g[0][i] = f[0][i - 1] + 1
t = [0, 0]
for i in range(1, n + 1):
for j in range(i, n + 1):
if i > 0:
... | output | 1 | 21,250 | 21 | 42,501 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Neko is playing with his toys on the backyard of Aki's house. Aki decided to play a prank on him, by secretly putting catnip into Neko's toys. Unfortunately, he went overboard and put an entire bag of catnip into the toys...
It took Neko an... | instruction | 0 | 21,251 | 21 | 42,502 |
Tags: dp, greedy, trees
Correct Solution:
```
n = int(input())
dp = [[[0] * (n+1) for i in range(n + 1)] for j in range(2)]
dp[0][0][0] = 0
dp[1][0][0] = 0
mod = 10 ** 9 + 7
for i in range(n + 1):
for j in range(i, n + 1):
if i == 0 and j == 0:
continue
dp[0][i][j] = (dp[1][i - 1][j] + ... | output | 1 | 21,251 | 21 | 42,503 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Neko is playing with his toys on the backyard of Aki's house. Aki decided to play a prank on him, by secretly putting catnip into Neko's toys. Unfortunately, he went overboard and put an entire bag of catnip into the toys...
It took Neko an... | instruction | 0 | 21,252 | 21 | 42,504 |
Tags: dp, greedy, trees
Correct Solution:
```
import collections
import random
import heapq
import bisect
import math
import time
class Solution2:
def solve(self, A1, A2):
pass
class Solution:
def gcd(self, a, b):
if not b: return a
return self.gcd(b, a%b)
def lcm(self, ... | output | 1 | 21,252 | 21 | 42,505 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Neko is playing with his toys on the backyard of Aki's house. Aki decided to play a prank on him, by secretly putting catnip into Neko's toys. Unfortunately, he went overboard and put an entire ... | instruction | 0 | 21,253 | 21 | 42,506 |
Yes | output | 1 | 21,253 | 21 | 42,507 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Neko is playing with his toys on the backyard of Aki's house. Aki decided to play a prank on him, by secretly putting catnip into Neko's toys. Unfortunately, he went overboard and put an entire ... | instruction | 0 | 21,254 | 21 | 42,508 |
Yes | output | 1 | 21,254 | 21 | 42,509 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Neko is playing with his toys on the backyard of Aki's house. Aki decided to play a prank on him, by secretly putting catnip into Neko's toys. Unfortunately, he went overboard and put an entire ... | instruction | 0 | 21,255 | 21 | 42,510 |
Yes | output | 1 | 21,255 | 21 | 42,511 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Neko is playing with his toys on the backyard of Aki's house. Aki decided to play a prank on him, by secretly putting catnip into Neko's toys. Unfortunately, he went overboard and put an entire ... | instruction | 0 | 21,256 | 21 | 42,512 |
Yes | output | 1 | 21,256 | 21 | 42,513 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Neko is playing with his toys on the backyard of Aki's house. Aki decided to play a prank on him, by secretly putting catnip into Neko's toys. Unfortunately, he went overboard and put an entire ... | instruction | 0 | 21,257 | 21 | 42,514 |
No | output | 1 | 21,257 | 21 | 42,515 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Neko is playing with his toys on the backyard of Aki's house. Aki decided to play a prank on him, by secretly putting catnip into Neko's toys. Unfortunately, he went overboard and put an entire ... | instruction | 0 | 21,258 | 21 | 42,516 |
No | output | 1 | 21,258 | 21 | 42,517 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Neko is playing with his toys on the backyard of Aki's house. Aki decided to play a prank on him, by secretly putting catnip into Neko's toys. Unfortunately, he went overboard and put an entire ... | instruction | 0 | 21,259 | 21 | 42,518 |
No | output | 1 | 21,259 | 21 | 42,519 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Neko is playing with his toys on the backyard of Aki's house. Aki decided to play a prank on him, by secretly putting catnip into Neko's toys. Unfortunately, he went overboard and put an entire ... | instruction | 0 | 21,260 | 21 | 42,520 |
No | output | 1 | 21,260 | 21 | 42,521 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a string a, consisting of n characters, n is even. For each i from 1 to n a_i is one of 'A', 'B' or 'C'.
A bracket sequence is a string containing only characters "(" and ")". A regular bracket sequence is a bracket sequence t... | instruction | 0 | 21,427 | 21 | 42,854 |
Tags: bitmasks, brute force, implementation
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 imp... | output | 1 | 21,427 | 21 | 42,855 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a string a, consisting of n characters, n is even. For each i from 1 to n a_i is one of 'A', 'B' or 'C'.
A bracket sequence is a string containing only characters "(" and ")". A regular bracket sequence is a bracket sequence t... | instruction | 0 | 21,428 | 21 | 42,856 |
Tags: bitmasks, brute force, implementation
Correct Solution:
```
transformations = ['(((', '(()', '()(', '())', ')((', ')()', '))(', ')))']
def regular(string):
opened = 0
for c in string:
if c == '(':
opened += 1
elif opened > 0:
opened -= 1
else:
r... | output | 1 | 21,428 | 21 | 42,857 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a string a, consisting of n characters, n is even. For each i from 1 to n a_i is one of 'A', 'B' or 'C'.
A bracket sequence is a string containing only characters "(" and ")". A regular bracket sequence is a bracket sequence t... | instruction | 0 | 21,429 | 21 | 42,858 |
Tags: bitmasks, brute force, implementation
Correct Solution:
```
import sys
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LC(): return list(input())
def IC():return [int(c) for c in input()]
def MI(): return map(int, sys.stdin.readline().split())
INF = flo... | output | 1 | 21,429 | 21 | 42,859 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a string a, consisting of n characters, n is even. For each i from 1 to n a_i is one of 'A', 'B' or 'C'.
A bracket sequence is a string containing only characters "(" and ")". A regular bracket sequence is a bracket sequence t... | instruction | 0 | 21,430 | 21 | 42,860 |
Tags: bitmasks, brute force, implementation
Correct Solution:
```
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def MAP2():return map(float,input().split())
def LIST(): return list(map(int, input().split()))
def STRING(): return input()
import string
import s... | output | 1 | 21,430 | 21 | 42,861 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a string a, consisting of n characters, n is even. For each i from 1 to n a_i is one of 'A', 'B' or 'C'.
A bracket sequence is a string containing only characters "(" and ")". A regular bracket sequence is a bracket sequence t... | instruction | 0 | 21,431 | 21 | 42,862 |
Tags: bitmasks, brute force, implementation
Correct Solution:
```
import sys
def read_ints():
return [int(i) for i in sys.stdin.readline().strip().split()]
def read_int():
return int(sys.stdin.readline().strip())
def check_brackets(s, openers, closers):
opened = 0
for c in s:
if c in openers:... | output | 1 | 21,431 | 21 | 42,863 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a string a, consisting of n characters, n is even. For each i from 1 to n a_i is one of 'A', 'B' or 'C'.
A bracket sequence is a string containing only characters "(" and ")". A regular bracket sequence is a bracket sequence t... | instruction | 0 | 21,432 | 21 | 42,864 |
Tags: bitmasks, brute force, implementation
Correct Solution:
```
def checkBalancedArray(string, ch):
stack = 0
for i in string:
if stack < 0: # we have deleted an element(hypothetically) when it is not even there. So, "NO"
return "NO"
if i in ch: # add one onto the stack if it ... | output | 1 | 21,432 | 21 | 42,865 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a string a, consisting of n characters, n is even. For each i from 1 to n a_i is one of 'A', 'B' or 'C'.
A bracket sequence is a string containing only characters "(" and ")". A regular bracket sequence is a bracket sequence t... | instruction | 0 | 21,433 | 21 | 42,866 |
Tags: bitmasks, brute force, implementation
Correct Solution:
```
import sys
input=sys.stdin.readline
from collections import defaultdict as dc
from collections import Counter
from bisect import bisect_right, bisect_left
import math
from operator import itemgetter
from heapq import heapify, heappop, heappush
from queue... | output | 1 | 21,433 | 21 | 42,867 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a string a, consisting of n characters, n is even. For each i from 1 to n a_i is one of 'A', 'B' or 'C'.
A bracket sequence is a string containing only characters "(" and ")". A regular bracket sequence is a bracket sequence t... | instruction | 0 | 21,434 | 21 | 42,868 |
Tags: bitmasks, brute force, implementation
Correct Solution:
```
t = int(input())
for _ in range(t):
a = input()
if a[0] == a[-1]:
print('no')
else:
a = a.replace(a[0], '(')
a = a.replace(a[-1], ')')
c1 = a.count('(')
c2 = a.count(')')
c3 = len(a) - c1 - c... | output | 1 | 21,434 | 21 | 42,869 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.