message stringlengths 2 23.4k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 129 108k | cluster float64 6 6 | __index_level_0__ int64 258 216k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
A has a string consisting of some number of lowercase English letters 'a'. He gives it to his friend B who appends some number of letters 'b' to the end of this string. Since both A and B like the characters 'a' and 'b', they have made sure ... | instruction | 0 | 56,909 | 6 | 113,818 |
Tags: implementation
Correct Solution:
```
s = input()
i1 = 0
i = 0
while s[i] == "a":
i += 1
i1 += 1
if i == len(s):
break
i2 = 0
if i != len(s):
while s[i] == "b":
i += 1
i2 += 1
if i == len(s):
break
i3 = 0
if i != len(s):
while s[i] == "c":... | output | 1 | 56,909 | 6 | 113,819 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A has a string consisting of some number of lowercase English letters 'a'. He gives it to his friend B who appends some number of letters 'b' to the end of this string. Since both A and B like the characters 'a' and 'b', they have made sure ... | instruction | 0 | 56,910 | 6 | 113,820 |
Tags: implementation
Correct Solution:
```
state = 1
s = input()
if ((s.count('a') == 0) or (s.count('b') == 0) or ((s.count('c') != s.count('a') and (s.count('c') != s.count('b'))))):
print('NO')
exit()
for el in s:
if el == 'b':
state = max(state, 2)
if el == 'c':
state = max(state... | output | 1 | 56,910 | 6 | 113,821 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A has a string consisting of some number of lowercase English letters 'a'. He gives it to his friend B who appends some number of letters 'b' to the end of this string. Since both A and B like the characters 'a' and 'b', they have made sure ... | instruction | 0 | 56,911 | 6 | 113,822 |
Tags: implementation
Correct Solution:
```
import sys
import os
import math
import re
s = input()
#first b, last a
#first c, last b
#last a,
As = [ i for i, ltr in enumerate(s) if ltr == 'a']
Bs = [i for i, ltr in enumerate(s) if ltr == 'b']
Cs = [i for i, ltr in enumerate(s) if ltr == 'c']
if (len(s) < 3 or len... | output | 1 | 56,911 | 6 | 113,823 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A has a string consisting of some number of lowercase English letters 'a'. He gives it to his friend B who appends some number of letters 'b' to the end of this string. Since both A and B like the characters 'a' and 'b', they have made sure ... | instruction | 0 | 56,912 | 6 | 113,824 |
Tags: implementation
Correct Solution:
```
S = input()
A, B, C = [], [], []
for i, v in enumerate(S):
if v == 'a':
A += [i]
if v == 'b':
B += [i]
if v == 'c':
C += [i]
if A != [] and B != [] and C != [] and A[-1] < B[0] and B[-1] < C[0] and (len(C) == len(A) or len(C) == len(... | output | 1 | 56,912 | 6 | 113,825 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A has a string consisting of some number of lowercase English letters 'a'. He gives it to his friend B who appends some number of letters 'b' to the end of this string. Since both A and B like the characters 'a' and 'b', they have made sure ... | instruction | 0 | 56,913 | 6 | 113,826 |
Tags: implementation
Correct Solution:
```
import sys
s = input()
a = 0
b = 0
c = 0
state = 'a'
for i in s:
if state == 'a':
if i == 'a':
a += 1
elif i == 'b':
b += 1
state = 'b'
elif i == 'c':
state = 'c'
c += 1
else:
... | output | 1 | 56,913 | 6 | 113,827 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A has a string consisting of some number of lowercase English letters 'a'. He gives it to his friend B who appends some number of letters 'b' to the end of this string. Since both A and B like the characters 'a' and 'b', they have made sure ... | instruction | 0 | 56,914 | 6 | 113,828 |
Tags: implementation
Correct Solution:
```
I = lambda:int(input())
ID = lambda:map(int, input().split())
IL = lambda:list(ID())
s = input()
a = s.count('a')
b = s.count('b')
c = s.count('c')
n = len(s)
aa = s[:a]
ba = s[a:a+b]
ca = s[a+b:]
if (c ==a or c == b) and list(set(aa))==['a'] and list(set(ba))== ['b']:
pri... | output | 1 | 56,914 | 6 | 113,829 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A has a string consisting of some number of lowercase English letters 'a'. He gives it to his friend B who appends some number of letters 'b' to the end of this string. Since both A and B like the characters 'a' and 'b', they have made sure ... | instruction | 0 | 56,915 | 6 | 113,830 |
Tags: implementation
Correct Solution:
```
s = input()
a = [0] * 3
k = 0
ok = True
for i in s:
c = ord(i) - ord('a')
if c == k:
a[k] += 1
elif c == k + 1:
k += 1
a[k] += 1
else:
ok = False
break
if a[0] == 0 or a[1] == 0 or (a[0] != a[2] and a[1] != a[2]):
ok ... | output | 1 | 56,915 | 6 | 113,831 |
Provide tags and a correct Python 3 solution for this coding contest problem.
<image>
Input
The first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.
The second line of the input is an integer between 0 and 26,... | instruction | 0 | 57,412 | 6 | 114,824 |
Tags: *special, implementation
Correct Solution:
```
_27 = input()
_16 = int(input())
_27 = _27.lower()
_4 = ""
for _26 in range(len(_27)):
_19 = _27[_26]
if ord(_19) < _16 + 97:
_4 = _4 + _19.upper()
else:
_4 = _4 + _19.lower()
print(_4)
``` | output | 1 | 57,412 | 6 | 114,825 |
Provide tags and a correct Python 3 solution for this coding contest problem.
<image>
Input
The first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.
The second line of the input is an integer between 0 and 26,... | instruction | 0 | 57,413 | 6 | 114,826 |
Tags: *special, implementation
Correct Solution:
```
a = list(input().lower())
b = int(input())
for i in range(len(a)):
if ord(a[i]) - ord('a') < b:
a[i] = a[i].upper()
print(''.join(a))
``` | output | 1 | 57,413 | 6 | 114,827 |
Provide tags and a correct Python 3 solution for this coding contest problem.
<image>
Input
The first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.
The second line of the input is an integer between 0 and 26,... | instruction | 0 | 57,414 | 6 | 114,828 |
Tags: *special, implementation
Correct Solution:
```
text = input().lower()
caps = int(input())+97
for letter in text:
print(letter.upper(), end='')if letter < chr(caps) else print(letter, end='')
print()
``` | output | 1 | 57,414 | 6 | 114,829 |
Provide tags and a correct Python 3 solution for this coding contest problem.
<image>
Input
The first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.
The second line of the input is an integer between 0 and 26,... | instruction | 0 | 57,415 | 6 | 114,830 |
Tags: *special, implementation
Correct Solution:
```
s = input()
n = int(input())
d = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
e = 'abcdefghijklmnopqrstuvwxyz'
for i in s:
z = ord(i) - ord('a') if ord('a') <= ord(i) and ord(i) <= ord('z') else ord(i) - ord('A')
if z < n:
print(d[z], end = '')
else:
prin... | output | 1 | 57,415 | 6 | 114,831 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an exampl... | instruction | 0 | 58,517 | 6 | 117,034 |
Tags: brute force, constructive algorithms, implementation, strings
Correct Solution:
```
l, d = [], {}
for i, c in enumerate(input()):
if c in d:
u, v = (d[c] + i + 1) // 2, i
else:
l.append(c)
d[c] = i
s = ''.join(l * 2)
print(s[u:u + 13] + '\n' + s[u + 25:u + 12:-1] if u < v else "Impossi... | output | 1 | 58,517 | 6 | 117,035 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an exampl... | instruction | 0 | 58,518 | 6 | 117,036 |
Tags: brute force, constructive algorithms, implementation, strings
Correct Solution:
```
s = input()
arr = [0] * 26
for i in s:
arr[ord(i) - 65] += 1
l = chr(arr.index(2) + 65)
a = s.find(l)
b = s.rfind(l)
ans = b - a - 1
x = 27 + a + ans // 2
if ans == 0:
print('Impossible')
else:
s = 3 * s
print... | output | 1 | 58,518 | 6 | 117,037 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an exampl... | instruction | 0 | 58,519 | 6 | 117,038 |
Tags: brute force, constructive algorithms, implementation, strings
Correct Solution:
```
#!/usr/bin/env python3
l, d = [], {}
for i, c in enumerate(input()):
if c in d:
d1, len = d[c], (i-d[c]-1)//2 +1
d2 = i
else:
l.append(c)
d[c] = i
s = ''.join(l*2)
if d2-d1 <= 1:
print("Im... | output | 1 | 58,519 | 6 | 117,039 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an exampl... | instruction | 0 | 58,520 | 6 | 117,040 |
Tags: brute force, constructive algorithms, implementation, strings
Correct Solution:
```
__author__ = 'Think'
word=input()
found=False
for i in range(2, 27):
if word[i] in word[:i-1]:
place2=i
place1=word[:i-1].index(word[i])
found=True
break
if not found:
print("Impossible")
else:
rows=[[""]*13, [""]*13]
... | output | 1 | 58,520 | 6 | 117,041 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an exampl... | instruction | 0 | 58,521 | 6 | 117,042 |
Tags: brute force, constructive algorithms, implementation, strings
Correct Solution:
```
s = input()
from collections import Counter
cnt = Counter(s)
sc = sorted(cnt.items(), key=(lambda x: x[1]), reverse=True)[0][0]
s = s[s.index(sc):] + s[:s.index(sc)]
if s[0] == s[1]:
print('Impossible')
exit(0)
sl, sr = ... | output | 1 | 58,521 | 6 | 117,043 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an exampl... | instruction | 0 | 58,522 | 6 | 117,044 |
Tags: brute force, constructive algorithms, implementation, strings
Correct Solution:
```
d = {} # chars to ints
di = {} # ints to chars
ct = 0
x = input()
bad = []
for i in x:
if (i not in d):
ct+=1
d[i] = ct
di[ct] = i
else:
bad = [ct, d[i]]
if (bad[0] == bad[1]):
print("... | output | 1 | 58,522 | 6 | 117,045 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an exampl... | instruction | 0 | 58,523 | 6 | 117,046 |
Tags: brute force, constructive algorithms, implementation, strings
Correct Solution:
```
s = input()
l, r = -1, -1
for c in 'QWERTYUIOPLKJHGFDSAZXCVBNM':
if s.count(c) == 2:
l, r = s.find(c), s.rfind(c)
break
if r - l < 2:
print('Impossible')
else:
res = [['_'] * 13 for x in range(2)]
i... | output | 1 | 58,523 | 6 | 117,047 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an exampl... | instruction | 0 | 58,524 | 6 | 117,048 |
Tags: brute force, constructive algorithms, implementation, strings
Correct Solution:
```
s1=["" for j in range(13)]
s2=["" for j in range(13)]
s=input()
f=0
for i in range(27):
if f==0 and s.count(s[i])==2:
f=1
sp1=i
elif f==1 and s[i]==s[sp1]:
sp2=i
break
if sp2-sp1==1:
pri... | output | 1 | 58,524 | 6 | 117,049 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Oleg the client and Igor the analyst are good friends. However, sometimes they argue over little things. Recently, they started a new company, but they are having trouble finding a name for the company.
To settle this problem, they've decid... | instruction | 0 | 58,553 | 6 | 117,106 |
Tags: games, greedy, sortings
Correct Solution:
```
s = list(map(str,input()))
c = list(map(str,input()))
n = len(s)
s.sort()
c.sort(reverse = True)
s = s[:(n+1)//2]
c = c[:n//2]
l_s = len(s)
l_c = len(c)
begin_s = 0
begin_c = 0
end_s = l_s-1
end_c = l_c-1
ans1 = []
ans2 = []
for i in range(n-1):
if i%2 == 0:
... | output | 1 | 58,553 | 6 | 117,107 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Oleg the client and Igor the analyst are good friends. However, sometimes they argue over little things. Recently, they started a new company, but they are having trouble finding a name for the company.
To settle this problem, they've decid... | instruction | 0 | 58,554 | 6 | 117,108 |
Tags: games, greedy, sortings
Correct Solution:
```
import sys
def main():
s=sys.stdin.readline().rstrip()
t=sys.stdin.readline().rstrip()
result=[]
iisl=0
iisr=len(s)//2+len(s)%2-1
iitl=0
iitr=len(s)//2-1
aas=list(sorted(list(s)))
aat=list(sorted(list(t),reverse=True... | output | 1 | 58,554 | 6 | 117,109 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Oleg the client and Igor the analyst are good friends. However, sometimes they argue over little things. Recently, they started a new company, but they are having trouble finding a name for the company.
To settle this problem, they've decid... | instruction | 0 | 58,555 | 6 | 117,110 |
Tags: games, greedy, sortings
Correct Solution:
```
# Author : raj1307 - Raj Singh
# Date : 18.03.2021
from __future__ import division, print_function
import os,sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
from __builtin__ import xrange as range
from future_builtins import ascii, filter, ... | output | 1 | 58,555 | 6 | 117,111 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Oleg the client and Igor the analyst are good friends. However, sometimes they argue over little things. Recently, they started a new company, but they are having trouble finding a name for the company.
To settle this problem, they've decid... | instruction | 0 | 58,556 | 6 | 117,112 |
Tags: games, greedy, sortings
Correct Solution:
```
import sys
import math
from collections import defaultdict,deque
import heapq
oleg=list(sys.stdin.readline()[:-1])
igor=list(sys.stdin.readline()[:-1])
oleg.sort()
igor.sort()
igor.reverse()
n=len(oleg)
ans=[0 for _ in range(n)]
cnto,cnti=n//2+n%2,n//2
indo,indi=0,0
i... | output | 1 | 58,556 | 6 | 117,113 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Oleg the client and Igor the analyst are good friends. However, sometimes they argue over little things. Recently, they started a new company, but they are having trouble finding a name for the company.
To settle this problem, they've decid... | instruction | 0 | 58,557 | 6 | 117,114 |
Tags: games, greedy, sortings
Correct Solution:
```
a = sorted(input())
b = sorted(input(), reverse=True)
n = len(a)
a = ''.join(a[:(n+1)//2])
b = ''.join(b[:n//2])
name = ['']*(len(a)+len(b))
ia = ib = ic = 0
ja = len(a)-1
jb = len(b)-1
jc = len(name)-1
turn = 1
while ic <= jc:
if turn == 1:
if ib > jb: n... | output | 1 | 58,557 | 6 | 117,115 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Oleg the client and Igor the analyst are good friends. However, sometimes they argue over little things. Recently, they started a new company, but they are having trouble finding a name for the company.
To settle this problem, they've decid... | instruction | 0 | 58,558 | 6 | 117,116 |
Tags: games, greedy, sortings
Correct Solution:
```
s1 = input()
s2 = input()
n = len(s1)
s1 = sorted(s1)
s2 = sorted(s2)[::-1]
i = 0
j = 0
res = ["?"]*n
rear = n-1
front = 0
Neven = n % 2 == 0
n1 = (n+1)//2 - 1
n2 = n//2 - 1
for k in range(n):
if k % 2 == 0:
if s1[i] < s2[j]:
res[front] ... | output | 1 | 58,558 | 6 | 117,117 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Oleg the client and Igor the analyst are good friends. However, sometimes they argue over little things. Recently, they started a new company, but they are having trouble finding a name for the company.
To settle this problem, they've decid... | instruction | 0 | 58,559 | 6 | 117,118 |
Tags: games, greedy, sortings
Correct Solution:
```
s=input()
s1=input()
n=len(s1)
sl=[]
sl1=[]
for i in range(n):
sl+=[s[i]]
sl1+=[s1[i]]
ans=sl1[::]
sl1.sort()
sl.sort()
sl1.reverse()
i=0;
i2=(n-1)//2
k=0
k2=(n//2)-1
j=len(s)-1
temp=0
for x in range(len(s1)):
if (x%2==0):
if (sl[i]<sl1[k]) : ... | output | 1 | 58,559 | 6 | 117,119 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Oleg the client and Igor the analyst are good friends. However, sometimes they argue over little things. Recently, they started a new company, but they are having trouble finding a name for the company.
To settle this problem, they've decid... | instruction | 0 | 58,560 | 6 | 117,120 |
Tags: games, greedy, sortings
Correct Solution:
```
import sys
from math import sqrt
def solve():
s = input() # Oleg's letters
t = input() # Igor's letters
n = len(s)
s = sorted(s)[:(n + 1) // 2]
t = sorted(t, reverse=True)[:n // 2]
'''
print(s)
print(t)
'''
ans = [None] * n
... | output | 1 | 58,560 | 6 | 117,121 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An African crossword is a rectangular table n × m in size. Each cell of the table contains exactly one letter. This table (it is also referred to as grid) contains some encrypted word that needs to be decoded.
To solve the crossword you sho... | instruction | 0 | 58,612 | 6 | 117,224 |
Tags: implementation, strings
Correct Solution:
```
n, m = map(int, input().split())
a = [input() for i in range(n)]
ans = ''
for i in range(n):
for j in range(m):
if a[i].count(a[i][j]) == 1 and ''.join(a[k][j] for k in range(n)).count(a[i][j]) == 1:
ans += a[i][j]
print(ans)
``` | output | 1 | 58,612 | 6 | 117,225 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An African crossword is a rectangular table n × m in size. Each cell of the table contains exactly one letter. This table (it is also referred to as grid) contains some encrypted word that needs to be decoded.
To solve the crossword you sho... | instruction | 0 | 58,613 | 6 | 117,226 |
Tags: implementation, strings
Correct Solution:
```
import sys
def readlines(type=int):
return list(map(type, sys.stdin.readline().split()))
def read(type=int):
return type(sys.stdin.readline().strip())
joint = lambda it, sep=" ": sep.join(
[str(i) if type(i) != list else sep.join(map(str, i)) for i i... | output | 1 | 58,613 | 6 | 117,227 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An African crossword is a rectangular table n × m in size. Each cell of the table contains exactly one letter. This table (it is also referred to as grid) contains some encrypted word that needs to be decoded.
To solve the crossword you sho... | instruction | 0 | 58,614 | 6 | 117,228 |
Tags: implementation, strings
Correct Solution:
```
X = list(map(int, input().split()))
Sentence, Answer = "", ""
for i in range(X[0]):
Sentence += input()
for i in range(X[0]):
Temp = Sentence[i * X[1]:(i + 1) * X[1]]
for j in range(X[1]):
if Temp.count(Temp[j]) == 1 and Sentence[j::X[1]].count(Tem... | output | 1 | 58,614 | 6 | 117,229 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An African crossword is a rectangular table n × m in size. Each cell of the table contains exactly one letter. This table (it is also referred to as grid) contains some encrypted word that needs to be decoded.
To solve the crossword you sho... | instruction | 0 | 58,615 | 6 | 117,230 |
Tags: implementation, strings
Correct Solution:
```
# 90B
from sys import stdin
__author__ = 'artyom'
def index(ch):
return ord(ch) - 97
n, m = map(int, stdin.readline().strip().split())
grid = []
for _ in range(n):
grid.append(stdin.readline().strip())
a, res = [0] * 26, [[''] * m for __ in range(n)]
for j ... | output | 1 | 58,615 | 6 | 117,231 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An African crossword is a rectangular table n × m in size. Each cell of the table contains exactly one letter. This table (it is also referred to as grid) contains some encrypted word that needs to be decoded.
To solve the crossword you sho... | instruction | 0 | 58,616 | 6 | 117,232 |
Tags: implementation, strings
Correct Solution:
```
x,y=map(int,(input()).split())
a=""
for __ in range(x):
a+=input()
i=0
b=""
while i<x*y:
n=i%y
f=0
m=i-n
for j in range(m,m+y):
if a[j]==a[i] and i!=j:
f=1
for j in range(n,len(a),y):
if a[j]==a[i] and i!=j:
... | output | 1 | 58,616 | 6 | 117,233 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An African crossword is a rectangular table n × m in size. Each cell of the table contains exactly one letter. This table (it is also referred to as grid) contains some encrypted word that needs to be decoded.
To solve the crossword you sho... | instruction | 0 | 58,617 | 6 | 117,234 |
Tags: implementation, strings
Correct Solution:
```
n , m = map(int,input().split())
arr = []
for i in range(n):
arr.append(input())
res = list(zip(*arr))
for i in range(n):
for j in range(m):
if arr[i].count(arr[i][j])==1:
if res[j].count(arr[i][j])==1:
print(arr[i][j],en... | output | 1 | 58,617 | 6 | 117,235 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An African crossword is a rectangular table n × m in size. Each cell of the table contains exactly one letter. This table (it is also referred to as grid) contains some encrypted word that needs to be decoded.
To solve the crossword you sho... | instruction | 0 | 58,618 | 6 | 117,236 |
Tags: implementation, strings
Correct Solution:
```
def main():
n, m = map(int, input().split())
grid = [list(input()) for _ in range(n)]
res = ''
for r in range(n):
for c in range(m):
cur = grid[r][c]
found = False
for i in range(m):
if i != ... | output | 1 | 58,618 | 6 | 117,237 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An African crossword is a rectangular table n × m in size. Each cell of the table contains exactly one letter. This table (it is also referred to as grid) contains some encrypted word that needs to be decoded.
To solve the crossword you sho... | instruction | 0 | 58,619 | 6 | 117,238 |
Tags: implementation, strings
Correct Solution:
```
import re
[n, m], rows = [int(i) for i in input().split()], []
cols = [''] * m
for i in range(n):
rows.append(input())
for row in rows:
for i, char in enumerate(row):
cols[i] += char
rows_copy, cols_copy = list(rows), list(cols)
for i, row in enumerate... | output | 1 | 58,619 | 6 | 117,239 |
Provide tags and a correct Python 3 solution for this coding contest problem.
IA has so many colorful magnets on her fridge! Exactly one letter is written on each magnet, 'a' or 'b'. She loves to play with them, placing all magnets in a row. However, the girl is quickly bored and usually thinks how to make her enterta... | instruction | 0 | 58,832 | 6 | 117,664 |
Tags: constructive algorithms, greedy, implementation
Correct Solution:
```
import sys
input = lambda :sys.stdin.readline().rstrip()
s=[*input()]
ans=[0]*(len(s))
for i in range(1,len(s)):
if s[i]=='a':
ans[i-1]^=1
ans[i]=1
print(*ans)
``` | output | 1 | 58,832 | 6 | 117,665 |
Provide tags and a correct Python 3 solution for this coding contest problem.
IA has so many colorful magnets on her fridge! Exactly one letter is written on each magnet, 'a' or 'b'. She loves to play with them, placing all magnets in a row. However, the girl is quickly bored and usually thinks how to make her enterta... | instruction | 0 | 58,833 | 6 | 117,666 |
Tags: constructive algorithms, greedy, implementation
Correct Solution:
```
s = input()
ans = [0]*len(s)
for i in range(1, len(s)):
if s[i] != s[i-1]:
ans[i-1] = 1
ans[-1] = 1 if s[-1] == 'a' else 0
print(*ans)
``` | output | 1 | 58,833 | 6 | 117,667 |
Provide tags and a correct Python 3 solution for this coding contest problem.
IA has so many colorful magnets on her fridge! Exactly one letter is written on each magnet, 'a' or 'b'. She loves to play with them, placing all magnets in a row. However, the girl is quickly bored and usually thinks how to make her enterta... | instruction | 0 | 58,834 | 6 | 117,668 |
Tags: constructive algorithms, greedy, implementation
Correct Solution:
```
s = input()
l = []
i = 0
while i < len(s):
l.append(0)
while i < len(s) and s[i] == 'b':
l[-1] += 1
i += 1
l.append(0)
while i < len(s) and s[i] == 'a':
l[-1] += 1
i += 1
# print(l)
i = 0
res = []... | output | 1 | 58,834 | 6 | 117,669 |
Provide tags and a correct Python 3 solution for this coding contest problem.
IA has so many colorful magnets on her fridge! Exactly one letter is written on each magnet, 'a' or 'b'. She loves to play with them, placing all magnets in a row. However, the girl is quickly bored and usually thinks how to make her enterta... | instruction | 0 | 58,835 | 6 | 117,670 |
Tags: constructive algorithms, greedy, implementation
Correct Solution:
```
"""
Greedy solution where if we are looking at a, then move b to front as much as possible
"""
def solve(s):
res = [0 for _ in range(len(s))]
for i in range(1, len(s)):
if s[i] == "a":
res[i] = 1
res[i-1] = 1 - res[i-1]
return res... | output | 1 | 58,835 | 6 | 117,671 |
Provide tags and a correct Python 3 solution for this coding contest problem.
IA has so many colorful magnets on her fridge! Exactly one letter is written on each magnet, 'a' or 'b'. She loves to play with them, placing all magnets in a row. However, the girl is quickly bored and usually thinks how to make her enterta... | instruction | 0 | 58,836 | 6 | 117,672 |
Tags: constructive algorithms, greedy, implementation
Correct Solution:
```
from itertools import groupby
s = "#"+input()
l = len(s)
# ans = [0]*l
# for i in range(1,l):
# if s[i] == "a":
# ans[i-1] ^= 1
# ans[i] = 1
# print(*ans[1:])
ss = s[1:]
ans1 = [0]*(l-1)
gb = [list(g) for k,g in groupby(ss)]... | output | 1 | 58,836 | 6 | 117,673 |
Provide tags and a correct Python 3 solution for this coding contest problem.
IA has so many colorful magnets on her fridge! Exactly one letter is written on each magnet, 'a' or 'b'. She loves to play with them, placing all magnets in a row. However, the girl is quickly bored and usually thinks how to make her enterta... | instruction | 0 | 58,837 | 6 | 117,674 |
Tags: constructive algorithms, greedy, implementation
Correct Solution:
```
s=input()
n=len(s)
a=s.count('a')
s1=''
count=[]
i=0
while i<n:
count.append(0)
s1=s1+s[i]
while i+count[-1]<n and s[i+count[-1]]==s[i]:
count[-1]+=1
i+=count[-1]
#print(s1)
#print(count)
nc=len(count)
if s1[nc-1]=='a':
for i in range(n... | output | 1 | 58,837 | 6 | 117,675 |
Provide tags and a correct Python 3 solution for this coding contest problem.
IA has so many colorful magnets on her fridge! Exactly one letter is written on each magnet, 'a' or 'b'. She loves to play with them, placing all magnets in a row. However, the girl is quickly bored and usually thinks how to make her enterta... | instruction | 0 | 58,838 | 6 | 117,676 |
Tags: constructive algorithms, greedy, implementation
Correct Solution:
```
s = input()
def swap(i):
return s[:i:-1] + s[i + 1:]
for e in range(len(s) - 1):
if s[e] != s[e + 1]:
print(1, end=' ')
# s = swap(e)
# print(s)
else:
print(0, end=' ')
if s[-1] == 'a':
print... | output | 1 | 58,838 | 6 | 117,677 |
Provide tags and a correct Python 3 solution for this coding contest problem.
IA has so many colorful magnets on her fridge! Exactly one letter is written on each magnet, 'a' or 'b'. She loves to play with them, placing all magnets in a row. However, the girl is quickly bored and usually thinks how to make her enterta... | instruction | 0 | 58,839 | 6 | 117,678 |
Tags: constructive algorithms, greedy, implementation
Correct Solution:
```
def not_last(c):
if c == 'a':
return 'b'
return 'a'
s = input()
last = 'b'
res = []
for i in range(len(s) - 1):
if s[i + 1] == last:
res += [0]
else:
last = not_last(last)
res += [1]
if last == ... | output | 1 | 58,839 | 6 | 117,679 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
IA has so many colorful magnets on her fridge! Exactly one letter is written on each magnet, 'a' or 'b'. She loves to play with them, placing all magnets in a row. However, the girl is quickly b... | instruction | 0 | 58,840 | 6 | 117,680 |
Yes | output | 1 | 58,840 | 6 | 117,681 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
IA has so many colorful magnets on her fridge! Exactly one letter is written on each magnet, 'a' or 'b'. She loves to play with them, placing all magnets in a row. However, the girl is quickly b... | instruction | 0 | 58,841 | 6 | 117,682 |
Yes | output | 1 | 58,841 | 6 | 117,683 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
IA has so many colorful magnets on her fridge! Exactly one letter is written on each magnet, 'a' or 'b'. She loves to play with them, placing all magnets in a row. However, the girl is quickly b... | instruction | 0 | 58,842 | 6 | 117,684 |
Yes | output | 1 | 58,842 | 6 | 117,685 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
IA has so many colorful magnets on her fridge! Exactly one letter is written on each magnet, 'a' or 'b'. She loves to play with them, placing all magnets in a row. However, the girl is quickly b... | instruction | 0 | 58,843 | 6 | 117,686 |
Yes | output | 1 | 58,843 | 6 | 117,687 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
IA has so many colorful magnets on her fridge! Exactly one letter is written on each magnet, 'a' or 'b'. She loves to play with them, placing all magnets in a row. However, the girl is quickly b... | instruction | 0 | 58,844 | 6 | 117,688 |
No | output | 1 | 58,844 | 6 | 117,689 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
IA has so many colorful magnets on her fridge! Exactly one letter is written on each magnet, 'a' or 'b'. She loves to play with them, placing all magnets in a row. However, the girl is quickly b... | instruction | 0 | 58,845 | 6 | 117,690 |
No | output | 1 | 58,845 | 6 | 117,691 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
IA has so many colorful magnets on her fridge! Exactly one letter is written on each magnet, 'a' or 'b'. She loves to play with them, placing all magnets in a row. However, the girl is quickly b... | instruction | 0 | 58,846 | 6 | 117,692 |
No | output | 1 | 58,846 | 6 | 117,693 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.