description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
n = len(s)
flag1, flag2 = 0, 0
k = 0
while k < n:
if s[k : k + 2] == "AB" and not flag1:
flag1 = True
k += 1
elif s[k : k + 2] == "BA" and not flag2:
flag2 = True
k += 1
k += 1
if flag1 and flag2:
break
if not flag1 or not flag2:
flag1, flag2 = 0, ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING VAR ASSIGN VAR NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR ASSIGN VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER NUMBER ASSIG... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
n = len(s)
c = 0
i = 0
while i < n - 1:
if s[i] == "A" and s[i + 1] == "B":
c += 1
i += 2
break
else:
i += 1
for j in range(i, n - 1):
if s[j] == "B" and s[j + 1] == "A":
c += 1
break
ii = 0
d = 0
while ii < n - 1:
if s[ii] == "B" and s[ii + 1]... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER AS... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
a = []
i = s.find("AB")
while i != -1:
a += [i]
i = s.find("AB", i + 2)
b = []
i = s.find("BA")
while i != -1:
b += [i]
i = s.find("BA", i + 2)
n = len(a)
m = len(b)
for i in range(n):
for j in range(m):
if abs(a[i] - b[j]) > 1:
print("YES")
exit()
print("... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR STRING WHILE VAR NUMBER VAR LIST VAR ASSIGN VAR FUNC_CALL VAR STRING BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR STRING WHILE VAR NUMBER VAR LIST VAR ASSIGN VAR FUNC_CALL VAR STRING BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
k = s.find("AB")
j = s.find("BA")
m = min(k, j)
if m == -1:
print("NO")
else:
flag = 1
if m == k:
b = s[m + 2 :].find("BA")
if b != -1:
print("YES")
else:
flag = 0
else:
b = s[m + 2 :].find("AB")
if b != -1:
print("Y... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER STRING IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL ... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
try:
i1 = s.index("AB")
i2 = s.index("BA")
if abs(i1 - i2) == 1:
try:
s.index("AB", min(i1, i2) + 3)
except ValueError:
s.index("BA", min(i1, i2) + 3)
elif i1 < i2:
s.index("BA", i1 + 2)
else:
s.index("AB", i2 + 2)
print("YES")
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR EXPR FUNC_CALL VAR STRING BIN_OP FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING BIN_OP VAR NUMBER EXPR FUNC... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | class CodeforcesTask550ASolution:
def __init__(self):
self.result = ""
self.string = ""
def read_input(self):
self.string = input()
def process_task(self):
if "AB" in self.string and "BA" in self.string:
if "BA" in self.string.replace("AB", "__", 1):
... | CLASS_DEF FUNC_DEF ASSIGN VAR STRING ASSIGN VAR STRING FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_DEF IF STRING VAR STRING VAR IF STRING FUNC_CALL VAR STRING STRING NUMBER ASSIGN VAR STRING IF STRING FUNC_CALL VAR STRING STRING NUMBER ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING FUNC_DEF RETURN VAR ASSIGN VAR FUNC... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | def soln(s):
founds1 = []
founds2 = []
j = float("-inf")
for i in range(len(s) - 1):
c1 = s[i]
c2 = s[i + 1]
if c1 == "A" and c2 == "B":
founds1.append(i)
elif c1 == "B" and c2 == "A":
founds2.append(i)
if len(founds1) == 0 or len(founds2) == 0... | FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER IF VAR STRING VAR STRING EXPR FUNC_CALL VAR VAR IF VAR STRING VAR STRING EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | _str = input()
a = "AB"
b = "BA"
_str1 = _str.replace(a, "__", 1).replace(b, "__", 1)
_str2 = _str.replace(b, "__", 1).replace(a, "__", 1)
if _str1.count("_") == 4 or _str2.count("_") == 4:
print("YES")
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR STRING NUMBER VAR STRING NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR STRING NUMBER VAR STRING NUMBER IF FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
pos1 = []
pos2 = []
for i in range(len(s) - 1):
if s[i] == "A" and s[i + 1] == "B":
pos1.append(i)
if s[i] == "B" and s[i + 1] == "A":
pos2.append(i)
if len(pos1) > 0 and len(pos2) > 0:
for i in pos1:
for c in pos2:
if i + 1 != c and c + 1 != i:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER FOR VAR VAR FOR ... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | def nonoverlapping(mystr):
if mystr is None:
return "NO"
x1, x2 = 0, 0
x1 = mystr.find("AB")
x2 = mystr.find("BA", x1 + 2)
y1 = mystr.find("BA")
y2 = mystr.find("AB", y1 + 2)
if x1 != -1 and x2 != -1 or y1 != -1 and y2 != -1:
return "YES"
else:
return "NO"
my = ... | FUNC_DEF IF VAR NONE RETURN STRING ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER RETURN STRING RETURN STRING ASSIGN VAR FUNC_C... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | def solve():
s = input()
c1, c2 = s.count("AB"), s.count("BA")
if c1 == 0 or c2 == 0:
return "NO"
else:
ind = s.find("AB")
if s[ind + 2 :].find("BA") != -1:
return "YES"
ind = s.find("BA")
if s[ind + 2 :].find("AB") != -1:
return "YES"
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER RETURN STRING ASSIGN VAR FUNC_CALL VAR STRING IF FUNC_CALL VAR BIN_OP VAR NUMBER STRING NUMBER RETURN STRING ASSIGN VAR FUNC_CALL VAR STRING IF FUNC_CALL VAR BIN_OP VAR NUMBER STRING NUMBER RETURN STRING ... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | a = input()
b = 0
d = 0
c = []
f = []
i = 0
while i < len(a) - 1:
if a[i] == "B" and a[i + 1] == "A":
f.append([i, i + 1])
d += 1
if a[i] == "A" and a[i + 1] == "B":
c.append([i, i + 1])
b += 1
i += 1
if b > 2 and d >= 1 or b >= 1 and d > 2 or b >= 2 and d >= 2:
i... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR LIST VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL V... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | st = input()
a = st.find("AB")
b = st.find("BA")
print(
"NYOE S"[
a >= 0
and st[a + 2 :].find("BA") >= 0
or b >= 0
and st[b + 2 :].find("AB") >= 0 :: 2
]
) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER STRING NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER STRING NUMBER NUMBER |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
check1 = []
res = "NO"
check2 = []
for i in range(len(s) - 1):
if s[i] == "A" and s[i + 1] == "B":
check1.append([i, i + 1])
if s[i] == "B" and s[i + 1] == "A":
check2.append([i, i + 1])
for a in check1:
for b in check2:
if abs(a[0] - b[1]) > 2 or abs(a[1] - b[0]) > 2:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR LIST VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR LIST VAR BIN_OP VAR NUMBER FOR V... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | f = lambda l, r: abs(l - r) > 1 and l >= 0 and r >= 0
(
lambda s: print(
"YES"
if f(s.find("AB"), s.rfind("BA")) or f(s.find("BA"), s.rfind("AB"))
else "NO"
)
)(input()) | ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING STRING STRING FUNC_CALL VAR |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | stringInput = input()
a = stringInput.find("AB")
b = stringInput.rfind("BA")
c = stringInput.rfind("AB")
d = stringInput.find("BA")
if (
a != b
and a + 1 != b
and b + 1 != a
and a != -1
and b != -1
or c != d
and c + 1 != d
and d + 1 != c
and c != -1
and d != -1
):
print("YES"... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR NUMBER VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL V... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
i1 = s.find("AB")
i2 = s.find("BA")
found = False
if i1 >= 0:
i3 = s.find("BA", i1 + 2)
if i3 != -1:
print("YES")
found = True
if not found and i2 >= 0:
i3 = s.find("AB", i2 + 2)
if i3 != -1:
print("YES")
found = True
if not found:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
d = "AB"
if not "AB" in s or not "BA" in s:
print("NO")
else:
g = s[s.index(d) + 2 :]
d = d[1] + d[0]
if d in g:
print("YES")
else:
g = s[s.index(d) + 2 :]
d = d[1] + d[0]
if d in g:
print("YES")
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING IF STRING VAR STRING VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR EXPR... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | n = input()
if "AB" not in n or "BA" not in n:
print("NO")
exit()
fi = []
se = []
x = len(n)
for i in range(x - 1):
if n[i] + n[i + 1] == "AB":
fi.append(i)
elif n[i] + n[i + 1] == "BA":
se.append(i)
x = len(se)
for i in fi:
if se.count(i + 1) + se.count(i - 1) != x:
print("Y... | ASSIGN VAR FUNC_CALL VAR IF STRING VAR STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER STRING EXPR FU... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
k1 = s.count("BA")
k2 = s.count("AB")
k3 = s.count("ABA")
k4 = s.count("BAB")
k5 = s.count("BABA")
k6 = s.count("ABAB")
if k1 == 0 or k2 == 0:
print("NO")
elif (k3 == 1 or k4 == 1) and k1 == 1 and k2 == 1:
print("NO")
elif k5 == 1 and k1 == 2 and k2 == 1 or k6 == 1 and k2 == 2 and k1 == 1:
print... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR ... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | str = input()
ab = []
ba = []
for i in range(len(str) - 1):
if str[i] == "A" and str[i + 1] == "B":
ab.append(i)
if str[i] == "B" and str[i + 1] == "A":
ba.append(i)
for i in range(len(ab)):
for j in range(len(ba)):
if abs(ab[i] - ba[j]) > 1:
print("YES")
brea... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CA... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | n = input()
a = n.find("AB")
b = n.find("BA")
print(
"YES"
if a != -1 and n.find("BA", a + 2) != -1 or b != -1 and n.find("AB", b + 2) != -1
else "NO"
) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR STRING BIN_OP VAR NUMBER NUMBER VAR NUMBER FUNC_CALL VAR STRING BIN_OP VAR NUMBER NUMBER STRING STRING |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = str(input())
aba, ab, ba, skip = 0, 0, 0, 0
n = len(s)
for i in range(n):
if i < skip:
continue
if i + 2 < n and (
s[i] == "B"
and s[i + 1] == "A"
and s[i + 2] == "B"
or s[i] == "A"
and s[i + 1] == "B"
and s[i + 2] == "A"
):
aba += 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR IF BIN_OP VAR NUMBER VAR VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER ... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = str(input())
i = 0
ab = []
ba = []
while i < len(s):
if s[i : i + 2] == "AB":
ab.append(i)
elif s[i : i + 2] == "BA":
ba.append(i)
i += 1
if len(ab) == 0 or len(ba) == 0:
print("NO")
else:
for i in ab:
for j in ba:
if i - 1 != j and i + 1 != j:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST WHILE VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR ST... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = list(input())
z = []
z += s
l = 0
for n in range(len(s) - 1):
if s[n] + s[n + 1] == "AB":
l = 1
s[n] = s[n + 1] = "D"
break
if l == 0:
l = 0
else:
for n in range(len(s) - 1):
if s[n] + s[n + 1] == "BA":
l = 2
s[n] = s[n + 1] = "D"
break... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER STRING IF VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR V... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
s += "..."
ab = "AB"
ba = "BA"
i = s.find(ab)
if i == -1:
print("NO")
else:
a = s.find(ba)
if a == -1:
print("NO")
elif a == i - 1:
if s[i + 2 :].find(ba) == -1:
if s[i + 1 :].find(ab) == -1:
print("NO")
else:
print("YES... | ASSIGN VAR FUNC_CALL VAR VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR NUMBER VAR ... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
l = len(s)
a = -1
b = -1
for i in range(0, l - 1):
if s[i] == "A" and s[i + 1] == "B":
a = i + 1
break
for i in range(l - 1, 0, -1):
if s[i] == "A" and s[i - 1] == "B":
b = i - 1
break
c = -1
d = -1
for i in range(0, l - 1):
if s[i] == "B" and s[i + 1] == "A":
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
r = range(len(s))
ab_indexes = [i for i in r if s.startswith("AB", i)]
ba_indexes = [i for i in r if s.startswith("BA", i)]
breaked = False
if all([len(ab_indexes), len(ba_indexes)]):
for i in ab_indexes:
if breaked:
break
for j in ba_indexes:
if j - 1 != i and j ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR STRING VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR STRING VAR ASSIGN VAR NUMBER IF FUNC_CALL VAR LIST FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR VAR IF VAR FOR VAR VAR IF BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR AS... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | x = input()
count = 0
if "AB" in x:
s = x[x.index("AB") + 2 :: 1]
if "BA" in s:
count += 1
if "BA" in x:
s = x[x.index("BA") + 2 :: 1]
if "AB" in s:
count += 1
if count >= 1:
print("YES")
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF STRING VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR STRING NUMBER NUMBER IF STRING VAR VAR NUMBER IF STRING VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR STRING NUMBER NUMBER IF STRING VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | l = input()
AB = 0
BA = 0
for i in range(0, len(l) - 1):
if l[i : i + 2] == "AB":
AB += 1
if l[i : i + 2] == "BA":
BA += 1
if AB == 0 or BA == 0:
print("NO")
elif AB == 1 and BA == 1:
if l.find("ABA") == -1 and l.find("BAB") == -1:
print("YES")
else:
print("NO")
elif ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER IF FUNC_CALL VAR STRING NUMB... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | a = input()
b = a[:]
counter = 0
if "AB" in a:
res = a.find("AB")
a = a[:res] + "**" + a[res + 2 :]
counter += 1
if "BA" in a:
res = a.find("BA")
a = a[:res] + "**" + a[res + 2 :]
counter += 1
if counter == 2:
print("YES")
else:
counter = 0
if "BA" in b:
res = b.find("BA")
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR STRING VAR BIN_OP VAR NUMBER VAR NUMBER IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR STRING VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
if "AB" in s and "BA" in s:
a = s.find("AB")
b1 = s[a + 2 :].find("BA")
if b1 != -1:
print("YES")
else:
b = s.find("BA")
a1 = s[b + 2 :].find("AB")
if a1 != -1:
print("YES")
else:
print("NO")
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR IF STRING VAR STRING VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER STRING IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER STRING IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | def func(str):
s = str
AB = False
BA = False
flag = False
for i in range(len(s) - 1):
if s[i] == "A" and s[i + 1] == "B":
AB = True
s[i] = "X"
s[i + 1] = "X"
index = i
flag = True
break
for i in range(len(s) - 1):
... | FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUN... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
AB, BA, BOTH = False, False, False
index = 0
for i in range(len(s)):
if s[i : i + 3] == "ABA" or s[i : i + 3] == "BAB":
index = i
BOTH = True
break
elif s[i : i + 2] == "AB":
index = i
AB = True
break
elif s[i : i + 2] == "BA":
index = i
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR VAR BIN_OP VAR NUMB... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | import sys
a = input()
ab = a.count("AB")
ba = a.count("BA")
aba = a.count("ABA")
bab = a.count("BAB")
if ab != 0 and ba != 0 and ab + ba - aba - bab > 1:
print("YES")
else:
print("NO") | IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | def check(a, k):
if a.count(-1) == 0 or a.count(1) == 0:
return "NO"
for i in range(k - 1):
if a[i] != 0:
for j in range(i + 2, k):
if a[i] + a[j] == 0:
return "YES"
return "NO"
s = input()
a = [0] * (len(s) - 1)
for i in range(len(s) - 1):
... | FUNC_DEF IF FUNC_CALL VAR NUMBER NUMBER FUNC_CALL VAR NUMBER NUMBER RETURN STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP VAR VAR VAR VAR NUMBER RETURN STRING RETURN STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | a = input()
if "AB" in a and "BA" in a:
b = [i for i in range(len(a) - 1) if a[i] + a[i + 1] == "AB"]
c = [i for i in range(len(a) - 1) if a[i] + a[i + 1] == "BA"]
if abs(max(b) - min(c)) > 1 or abs(max(c) - min(b)) > 1:
print("YES")
else:
print("NO")
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR IF STRING VAR STRING VAR ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP VAR VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP VAR VAR VAR BIN_OP VAR NUMBER STRING IF FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL ... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
n = len(s)
w = 0
if "AB" not in s or "BA" not in s:
print("NO")
else:
arr1 = []
arr2 = []
for i in range(n - 1):
if s[i] == "A" and s[i + 1] == "B":
arr1.append(i)
elif s[i] == "B" and s[i + 1] == "A":
arr2.append(i)
if arr2[-1] > arr1[0] + 1 or ar... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF STRING VAR STRING VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING EXPR FUN... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
n = len(s)
flag = False
arr1 = []
arr2 = []
i = 1
for i in range(1, n):
if s[i - 1 : i + 1] == "AB":
arr1.append(i)
if s[i - 1 : i + 1] == "BA":
arr2.append(i)
flag = False
if len(arr1) >= 1 and len(arr2) >= 1:
if arr1[0] + 1 < arr2[len(arr2) - 1]:
flag = True
if arr2... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER I... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
i = 0
listAB = []
listBA = []
while i < len(s) - 1:
cCurr = s[i + 1]
cPrev = s[i]
if cCurr == "B" and cPrev == "A":
listAB += [i]
if cCurr == "A" and cPrev == "B":
listBA += [i]
i += 1
if (
len(listAB) > 0
and len(listBA) > 0
and (listAB[0] + 1 < listBA[-1] or... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR IF VAR STRING VAR STRING VAR LIST VAR IF VAR STRING VAR STRING VAR LIST VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER BIN_OP VAR ... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | a = input()
l = len(a)
f = 0
if l <= 3:
print("NO")
else:
s = a
if "AB" in s:
s = s.replace("AB", " ", 1)
if "BA" in s:
print("YES")
f = 1
s = a
if "BA" in s and f == 0:
s = s.replace("BA", " ", 1)
if "AB" in s:
print("YES")
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER IF STRING VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR VAR IF STRING VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING STR... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | string = input()
nAB, nBA = string.count("AB"), string.count("BA")
if nAB == 0 or nBA == 0:
print("NO")
exit()
dBA, dAB = -2, -2
for i in range(nAB):
dAB = string.find("AB", dAB + 2)
for j in range(nBA):
dBA = string.find("BA", dBA + 2)
if abs(dBA - dAB) > 1:
print("YES")
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING BIN_O... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
slen = len(s)
start = 0
flag = 0
ab = 0
ba = 0
while start < slen - 1:
if s[start] == "A" and s[start + 1] == "B":
if ba > 0 and abs(ba - (start + 1)) > 1:
flag = 1
break
if ab == 0:
ab = start + 1
elif s[start] == "B" and s[start + 1] == "A":
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING IF VAR NUMBER FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR N... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | import sys
s = input()
AB = []
BA = []
for i in range(len(s) - 1):
if s[i : i + 2] == "AB":
for j in BA:
if abs(j - i) != 1:
print("YES")
exit(0)
AB.append(i)
if s[i : i + 2] == "BA":
for j in AB:
if abs(j - i) != 1:
... | IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING FOR VAR VAR IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING FOR ... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | string = input()
if "AB" in string and "BA" in string:
i = string.index("AB")
aux = string[i + 2 : len(string)]
if "BA" in aux:
print("YES")
else:
i = string.index("BA")
aux = string[i + 2 : len(string)]
if "AB" in aux:
print("YES")
else:
p... | ASSIGN VAR FUNC_CALL VAR IF STRING VAR STRING VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF STRING VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRIN... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
ok = False
p = s.replace("AB", "OO", 1)
if "BA" in p and "AB" in s:
ok = True
p = s.replace("BA", "OO", 1)
if "AB" in p and "BA" in s:
ok = True
print("YES" if ok else "NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER IF STRING VAR STRING VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER IF STRING VAR STRING VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR STRING STRING |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | def solve(s):
ab = s.find("AB")
ba = s.find("BA")
if ab == -1 or ba == -1:
return False
ba1 = s.find("BA", ab + 2)
ab1 = s.find("AB", ba + 2)
return ba1 != -1 or ab1 != -1
s = input().rstrip()
print("YES" if solve(s) else "NO") | FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR STRING BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING BIN_OP VAR NUMBER RETURN VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR STRING ... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = str(input())
ok1 = False
ok2 = False
ok = False
i = 0
s = s + "ah"
while i < len(s) - 1:
if s[i] == "A" or s[i] == "B":
if ok1 == False:
if s[i] == "A" and s[i + 1] == "B":
ok1 = True
i += 2
continue
elif s[i + 1] == "A" and s[i + 2... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR STRING WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR VAR STRING IF VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR NUMBER IF VAR BIN_OP V... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | t = input()
ab = t.count("AB")
ba = t.count("BA")
if ab == 0 or ba == 0:
print("NO")
elif ab > 1 or ba > 1:
if ba == 2 and ab == 1:
if t.count("BABA") == 1:
print("NO")
else:
print("YES")
elif ab == 2 and ba == 1:
if t.count("ABAB") == 1:
print("NO... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER IF FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER IF FUNC_CALL VAR STRIN... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
cA, cB, cABA, cBAB = 0, 0, 0, 0
cA = s.count("AB")
cB = s.count("BA")
cABA = s.count("ABA")
cBAB = s.count("BAB")
if (
cA * cB > 2
and cA - cABA - cBAB + cB >= 0
or cA * cB > 0
and (cA - cABA - cBAB > 0 or cB - cABA - cBAB > 0)
):
print("YES")
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF BIN_OP VAR VAR NUMBER BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR NUMBER BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR VAR... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | n = input()
n = list(n)
a = 0
b = 0
c = 0
for i in range(0, len(n) - 2):
if n[i] == "A" and n[i + 1] == "B" and n[i + 2] == "A":
c += 1
n[i] = " "
n[i + 1] = " "
n[i + 2] = " "
if n[i] == "B" and n[i + 1] == "A" and n[i + 2] == "B":
c += 1
n[i] = " "
n[i +... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
a = s.rfind("AB")
b = s.find("BA")
x = False
if a != -1 and b != -1 and abs(a - b) >= 2:
x = True
a = s.rfind("BA")
b = s.find("AB")
y = False
if a != -1 and b != -1 and abs(a - b) >= 2:
y = True
if x or y:
print("YES")
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP VAR VA... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
pA = -10
pB = -10
al = []
bl = []
for i in range(len(s)):
if s[i] == "A" and pA == -10:
pA = i
if s[i] == "B" and pB == -10:
pB = i
if s[i] == "A":
if i - pB == 1:
bl.append(i)
pA = i
if s[i] == "B":
if i - pA == 1:
al.append(i)... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER ASSIGN VAR VAR IF VAR VAR STRING VAR NUMBER ASSIGN VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR IF VAR VAR STRING ... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
x = ""
y = ""
c = 0
if s.find("AB") >= 0:
x = s[s.find("AB") + 2 :]
if x.find("BA") >= 0:
c += 1
if s.find("BA") >= 0:
y = s[s.find("BA") + 2 :]
if y.find("AB") >= 0:
c += 1
if c > 0:
print("YES")
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER IF FUNC_CALL VAR STRING NUMBER ASSIGN VAR VAR BIN_OP FUNC_CALL VAR STRING NUMBER IF FUNC_CALL VAR STRING NUMBER VAR NUMBER IF FUNC_CALL VAR STRING NUMBER ASSIGN VAR VAR BIN_OP FUNC_CALL VAR STRING NUMBER IF FUNC_CALL VAR STRING NUMBER VAR NU... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | t = input()
if "BA" not in t:
print("NO")
elif "AB" not in t:
print("NO")
else:
u = []
v = []
for k in range(len(t) - 1):
if t[k] == "A" and t[k + 1] == "B":
u.append(k)
elif t[k] == "B" and t[k + 1] == "A":
v.append(k)
if abs(min(u) - max(v)) > 1 or abs(m... | ASSIGN VAR FUNC_CALL VAR IF STRING VAR EXPR FUNC_CALL VAR STRING IF STRING VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CA... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | def ok(s, a, b):
indexa = s.find(a)
if indexa == -1:
return False
return s.find(b, indexa + 2) != -1
def __starting_point():
s = input().strip()
if ok(s, "AB", "BA") or ok(s, "BA", "AB"):
print("YES")
else:
print("NO")
__starting_point() | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER RETURN NUMBER RETURN FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR STRING STRING FUNC_CALL VAR VAR STRING STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
ab = set()
ba = set()
for i in range(len(s) - 1):
if s[i] + s[i + 1] == "AB":
ab.add(i)
elif s[i] + s[i + 1] == "BA":
ba.add(i)
fl = 0
if ab == set() or ba == set():
print("NO")
exit(0)
for s1 in (min(ab), max(ab)):
for s2 in (min(ba), max(ba)):
if abs(s1 - s2) > ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR FUNC_CALL VAR VAR FUNC_CAL... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | import sys
s = input()
ans = False
find1 = s.find("AB")
find2 = s.find("BA")
if find1 != -1:
if s.find("BA", find1 + 2) != -1:
ans = True
if find2 != -1:
if s.find("AB", find2 + 2) != -1:
ans = True
if ans:
print("YES")
else:
print("NO")
sys.exit(0) | IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER IF FUNC_CALL VAR STRING BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF FUNC_CALL VAR STRING BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_C... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | ans = {(True): "YES", (False): "NO"}
s = input()
flag = False
p = s.find("AB")
if "AB" in s and "BA" in s:
while p != -1:
s = s[:p] + "ab" + s[p + 2 :]
buf = s[:p].upper() + "ab" + s[p + 2 :]
if "BA" in buf:
flag = True
break
p = s.find("AB")
print(ans[flag]) | ASSIGN VAR DICT NUMBER NUMBER STRING STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF STRING VAR STRING VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR STRING VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR STRING VAR BIN_OP VAR NUMBER IF STRING VAR ASSIGN VAR ... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | a = input()
i = 0
b = 0
A = 0
B = 0
while i < len(a):
if a[i : i + 3] == "ABA" or a[i : i + 3] == "BAB":
b += 1
i += 3
elif a[i : i + 2] == "AB":
A += 1
i += 2
elif a[i : i + 2] == "BA":
B += 1
i += 2
else:
i += 1
if b > 1:
print("YES")
elif b ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | def f(s):
if len(s) < 4:
return "NO"
ab = []
ba = []
for i in range(len(s) - 1):
if s[i] == "A" and s[i + 1] == "B":
ab.append(i)
elif s[i] == "B" and s[i + 1] == "A":
ba.append(i)
for i in range(len(ab)):
for j in range(len(ba)):
i... | FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN STRING ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s, ix1, ix2 = input(), [], []
for i in range(len(s) - 1):
if s[i : i + 2] == "AB":
ix1.append(i)
if s[i : i + 2] == "BA":
ix2.append(i)
if ix1 == [] or ix2 == []:
print("NO")
elif abs(ix1[-1] - ix2[0]) > 1 or abs(ix1[0] - ix2[-1]) > 1:
print("YES")
else:
print("NO") | ASSIGN VAR VAR VAR FUNC_CALL VAR LIST LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF VAR LIST VAR LIST EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER NUMBER FUNC_... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
if "AB" in s and "BA" in s:
if s.count("A") == 2 and s.count("B") == 2:
if (
s.count("AABB") != 0
or s.count("ABAB") != 0
or s.count("BBAA") != 0
or s.count("BABA")
or s.count("AABB")
):
print("NO")
else:
... | ASSIGN VAR FUNC_CALL VAR IF STRING VAR STRING VAR IF FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER IF FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR STRING NUMBER... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | import sys
input = []
input_index = 0
def next(type, number=None):
def next():
global input, input_index
while input_index == len(input):
if sys.stdin:
input = sys.stdin.readline().split()
input_index = 0
else:
raise Excepti... | IMPORT ASSIGN VAR LIST ASSIGN VAR NUMBER FUNC_DEF NONE FUNC_DEF WHILE VAR FUNC_CALL VAR VAR IF VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER RETURN VAR BIN_OP VAR NUMBER IF VAR NONE ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR RE... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | string = input()
pos1 = []
pos2 = []
flag = 0
for i in range(0, len(string) - 1):
if string[i] == "A":
if string[i + 1] == "B":
pos1.append(i)
elif string[i] == "B":
if string[i + 1] == "A":
pos2.append(i)
if len(pos1) > len(pos2):
for i in range(0, len(pos1)):
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | string = str(input())
answer = "NO"
indexAB, indexBA = -1, -1
countAB, countBA = 0, 0
for i in range(2, len(string) + 1):
sub = string[i - 2 : i]
if sub == "AB":
indexAB = i - 2
countAB += 1
if sub == "BA":
indexBA = i - 2
countBA += 1
if indexAB + 1 == indexBA or indexAB == ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER VAR IF VAR STRING ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR STRING ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
d = {"AB": [], "BA": []}
for i in range(len(s) - 1):
if s[i : i + 2] == "AB":
d["AB"].append(i)
elif s[i : i + 2] == "BA":
d["BA"].append(i)
def f(d):
for i in d["AB"]:
for j in d["BA"]:
if abs(i - j) >= 2:
return "YES"
return "NO"
prin... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT STRING STRING LIST LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR STRING VAR IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR STRING VAR FUNC_DEF FOR VAR VAR STRING FOR VAR VAR STRING IF FUNC_CALL VAR BIN_O... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
left, right = s.find("AB"), s.rfind("BA")
left1, right1 = s.find("BA"), s.rfind("AB")
r1, r2 = abs(left - right), abs(left1 - right1)
if left < 0 or right < 0:
print("NO")
elif r1 + r2 == 2:
print("NO")
else:
print("YES") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR F... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
min_AB = len(s) + 10
max_AB = 0
min_BA = len(s) + 10
max_BA = 0
i = 0
for i in range(len(s) - 1):
if s[i] == "A" and s[i + 1] == "B":
min_AB = min(min_AB, i)
max_AB = max(max_AB, i)
if s[i] == "B" and s[i + 1] == "A":
min_BA = min(min_BA, i)
max_BA = max(max_BA, i)
if... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL ... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input().strip()
def check(s):
ab = []
ba = []
for i in range(len(s)):
if s[i : i + 2] == "AB":
ab.append(i)
elif s[i : i + 2] == "BA":
ba.append(i)
if len(ab) == 0 or len(ba) == 0:
return False
if (
ba[0] != ab[-1] - 1
and ba[0] !... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER RETURN NUMBER IF VAR NUMBER BIN_O... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | a = input().strip()
n = len(a)
ans = False
try:
x = a.index("AB")
y = a.rindex("BA")
if abs(x - y) > 1:
ans = True
except:
pass
try:
x = a.index("BA")
y = a.rindex("AB")
if abs(x - y) > 1:
ans = True
except:
pass
if ans:
print("YES")
else:
print("NO") | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR NUM... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | def solve():
ins, used, ab, ba = input(), [], 0, 0
uppend = used.append
for i in range(len(ins)):
uppend(0)
for i in range(len(ins) - 1):
if not ab and ins[i] == "A" and ins[i + 1] == "B" and not used[i]:
ab, used[i], used[i + 1] = 1, 1, 1
if ab and ins[i] == "B" and ... | FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR LIST NUMBER NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR VAR ASSIGN VAR VAR VAR VAR BIN_OP VAR NUMBER NUMBER NUMBER NUMBER... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = list(input())
n = len(s)
index = n + 1
for i in range(n - 1):
if s[i] == "A" and s[i + 1] == "B":
index = i + 2
break
for i in range(index, n - 1):
if s[i] == "B" and s[i + 1] == "A":
print("YES")
exit()
index = n + 1
for i in range(n - 1):
if s[i] == "B" and s[i + 1] == ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL V... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
id = s.find("AB")
if id != -1:
p = s[id + 2 :]
if "BA" in p:
print("YES")
exit()
id = s.find("BA")
if id == -1:
print("NO")
exit()
p = s[id + 2 :]
if "AB" in p:
print("YES")
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER IF STRING VAR EXPR FUNC_CALL VAR ... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
ab = 0
ba = 0
n = len(s)
for i in range(1, n):
if s[i] == "A" and s[i - 1] == "B":
ba += 1
elif s[i] == "B" and s[i - 1] == "A":
ab += 1
if ab == 0 or ba == 0:
print("NO")
elif ab == 1 and ba == 1:
if "ABA" in s:
print("NO")
elif "BAB" in s:
print("NO")
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER IF ST... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | S = input()
A = 0
B = 0
for i in range(len(S) - 1):
if S[i] == "A" and S[i + 1] == "B":
A += 1
if S[i] == "B" and S[i + 1] == "A":
B += 1
if A * B == 0:
print("NO")
elif A == B == 1:
if "ABA" in S or "BAB" in S:
print("NO")
else:
print("YES")
elif A == 1 and B == 2 or... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR VAR NUMBER IF STRING VAR STRING... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
m = ""
n = ""
for x in range(len(s) - 1):
if s[x : x + 2] == "AB":
m += str(x) + " "
else:
pass
for y in range(1, len(s)):
if s[y - 1 : y + 1] == "BA":
n += str(y) + " "
else:
pass
if m == "" or n == "":
print("NO")
else:
m = m.split()
n = n.split(... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR BIN_OP FUNC_CALL VAR VAR STRING FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER STRING VAR BIN_OP FUNC_CALL VAR VAR STRING ... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
a = s.find("AB")
b = s.find("BA")
print(
["NO", "YES"][
a + 1 > 0
and s.find("BA", a + 2) + 1 > 0
or b + 1 > 0
and s.find("AB", b + 2) + 1 > 0
]
) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR LIST STRING STRING BIN_OP VAR NUMBER NUMBER BIN_OP FUNC_CALL VAR STRING BIN_OP VAR NUMBER NUMBER NUMBER BIN_OP VAR NUMBER NUMBER BIN_OP FUNC_CALL VAR STRING BIN_OP VAR NUMBER NUMBER NUMBER |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | string = input()
string1 = string[:]
def unsc(string):
ab = string.find("AB")
if ab == -1:
return False
else:
string = string.replace("AB", ",", 1)
ba = string.find("BA")
if ba == -1:
return False
else:
return True
def unsc1(string1):
b... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL V... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | import sys
s = sys.stdin.readline()
n = len(s)
ret = False
a = s.find("AB")
if a != -1 and s.find("BA", a + 2) != -1:
ret = True
if not ret:
a = s.find("BA")
if a != -1 and s.find("AB", a + 2) != -1:
ret = True
sys.stdout.write("YES\n" if ret else "NO\n") | IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER FUNC_CALL VAR STRING BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER FUNC_CALL VAR STRING BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | def main():
s = input()
if "AB" not in s or "BA" not in s:
print("NO")
elif s.index("AB") + 1 < s.rindex("BA"):
print("YES")
elif s.index("BA") + 1 < s.rindex("AB"):
print("YES")
else:
print("NO")
main() | FUNC_DEF ASSIGN VAR FUNC_CALL VAR IF STRING VAR STRING VAR EXPR FUNC_CALL VAR STRING IF BIN_OP FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF BIN_OP FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
if "AB" in s and "BA" in s:
abi = []
bai = []
for i in range(len(s) - 1):
if s[i] + s[i + 1] == "AB":
abi.append(i)
if s[i] + s[i + 1] == "BA":
bai.append(i)
print(
"YES"
if abs(bai[-1] - abi[0]) > 1
or abs(bai[0] - abi[-1]) > 1... | ASSIGN VAR FUNC_CALL VAR IF STRING VAR STRING VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR ... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
ab = 0
ba = 0
i = 0
for i in range(len(s) - 1):
if i != len(s) - 1:
if s[i] == "A" and s[i + 1] == "B":
ab += 1
break
for j in range(i + 2, len(s) - 1):
if j != len(s) - 1:
if s[j] == "B" and s[j + 1] == "A":
ba += 1
break
if ab >= 1 an... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP FUNC... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | string = input()
temp = string
a = len(string)
string = string.replace("AB", " ", 1)
string = string.replace("BA", " ", 1)
string = string.replace(" ", "")
b = len(string)
if a - 4 == b:
print("YES")
else:
string = temp
a = len(string)
string = string.replace("BA", " ", 1)
string = string.replac... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR ... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | flag = 1
s = input()
if s.find("AB") != -1:
i = s.find("AB")
if s.find("BA", i + 2) != -1:
print("YES")
flag = 0
if s.find("BA") != -1 and flag == 1:
i = s.find("BA")
if s.find("AB", i + 2) != -1:
print("YES")
flag = 0
if flag == 1:
print("NO") | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF FUNC_CALL VAR STRING BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF FUNC_CALL VAR STRING NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF FUNC_CALL VAR STRING BIN_OP VAR NUMBER NUMBE... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
if s.count("AB") == 0 or s.count("BA") == 0:
print("NO")
else:
t = s.replace("AB", "xx", 1)
tt = s.replace("BA", "xx", 1)
if t.count("BA") >= 1 or tt.count("AB") >= 1:
print("YES")
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER IF FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
a = s.count("AB") + s.count("BA") - s.count("ABA") - s.count("BAB")
if a >= 2 and s.count("AB") > 0 and s.count("BA") > 0:
print("YES")
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING IF VAR NUMBER FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | def solve(s):
n = len(s)
try:
fab = s.index("AB")
fba = s.index("BA")
except ValueError:
return False
good = [False] * (n + 1)
for i in range(4, n + 1):
ss = s[i - 2 : i]
if ss == "AB":
good[i] = good[i - 1] or fba + 1 < i - 2
elif ss == "B... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING VAR RETURN NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER VAR IF VAR STRING ASSIGN VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
a = []
b = []
for i in range(len(s) - 1):
if s[i] == "A" and s[i + 1] == "B":
a.append(i)
if s[i] == "B" and s[i + 1] == "A":
b.append(i)
if len(a) == 0 or len(b) == 0:
print("NO")
exit(0)
for x in a:
for y in b:
if abs(x - y) > 1:
print("YES")
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL V... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | from sys import exit
s = input()
x1 = s.find("AB")
y1 = s.rfind("BA")
x2 = s.rfind("AB")
y2 = s.find("BA")
if x1 == -1 or y1 == -1:
from sys import exit
print("NO")
exit()
if max(x1, y1) - min(x1, y1) - 1 > 0 or max(x2, y2) - min(x2, y2) - 1 > 0:
print("YES")
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER BIN_OP BIN_OP FUNC_CAL... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | def solve_wa():
s = input()
z = [(False) for c in s]
n = len(s)
if n < 4:
print("NO")
return
for i in range(n - 1):
if s[i] == "A" and s[i + 1] == "B":
z[i] = True
z[i + 1] = True
for i in range(n - 1):
if s[i] == "B" and s[i + 1] == "A":
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
try:
ab1 = s.index("AB")
ba1 = s[::-1].index("AB")
ba1 = len(s) - 2 - ba1
ab2 = s[::-1].index("BA")
ab2 = len(s) - 2 - ab2
ba2 = s.index("BA")
if abs(ab1 - ba1) >= 2 or abs(ab2 - ba2) >= 2:
print("YES")
else:
print("NO")
except ValueError:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR NUMBER STRING ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR NUMBER STRING ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR STRING IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER FUNC_C... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
c = 0
if "AB" in s:
a = s.replace("AB", ",", 1)
c += 1
if "BA" in a:
c += 1
if c != 2:
c = 0
if "BA" in s:
a = s.replace("BA", ",", 1)
c += 1
if "AB" in a:
c += 1
print(["NO", "YES"][c == 2]) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER VAR NUMBER IF STRING VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER VAR NUMBER IF STRING VAR VAR NUMBER EXPR FUNC_CALL VAR LIST STRING STRING VAR NUMBER |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
def check_ABBA(s, A, B):
prev_c = "."
for i, c in enumerate(s):
if c == B and prev_c == A:
break
prev_c = c
else:
return False
prev_c = "."
for c in s[i + 1 :]:
if c == A and prev_c == B:
return True
prev_c = c
return ... | ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR STRING FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR RETURN NUMBER ASSIGN VAR STRING FOR VAR VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR RETURN NUMBER ASSIGN VAR VAR RETURN NUMBER IF FUNC_CALL VAR VAR STRING STRING EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR VA... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | from sys import stdin, stdout
s = stdin.readline().rstrip()
def find(s):
def scan(a, b):
ix, i = -1, 0
while i < len(s) - 1:
cand = s[i : i + 2]
if cand == a:
if ix == -1:
ix = i
elif cand == b:
if ix != -1 a... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR IF VAR NUMBER ASSIGN VAR VAR IF VAR VAR IF VAR NUMBER BIN_OP VAR VAR NUMBER RETURN NUMBER VAR NUMBER RETURN NUMBER RETURN FUNC_CALL VAR STRING STRIN... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | n = input()
clis = []
dlis = []
for i in range(0, len(n) - 1):
if n[i] + n[i + 1] == "AB":
clis.append(i)
if n[i] + n[i + 1] == "BA":
dlis.append(i)
def judge(clis, dlis):
for i in clis:
for j in dlis:
if i != j and abs(i - j) > 1:
return "YES"
retur... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR FUNC_DEF FOR VAR VAR FOR VAR VAR IF VAR VAR FUNC_CALL VAR BIN_... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | s = input()
n = len(s)
i = 0
sa = s
nk = 0
while i < n - 1:
if s[i] == "A" and s[i + 1] == "B":
s = s[0:i] + "D" + s[i + 2 :]
if "BA" in s:
print("YES")
nk = 1
break
else:
break
i += 1
if nk == 0:
i = 0
s = sa
nk = 0
while i... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR STRING VAR BIN_OP VAR NUMBER IF STRING VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER VAR NUMBER IF... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | string = input()
flag1 = 0
flag2 = 0
flag3 = 0
flag4 = 0
if "AB" in string:
flag1 = 1
pos1 = string.find("AB")
if "BA" in string[:pos1] or "BA" in string[pos1 + 2 :]:
flag2 = 1
if "BA" in string:
flag3 = 1
pos1 = string.find("BA")
if "AB" in string[:pos1] or "AB" in string[pos1 + 2 :]:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF STRING VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF STRING VAR VAR STRING VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF STRING VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF STRING VAR VAR STRING VAR B... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | string = input()
string2 = string
string = string.replace("AB", "1", 1)
string = string.replace("BA", "1", 1)
count = string.count("1")
if count == 2:
print("YES")
else:
string2 = string2.replace("BA", "1", 1)
string2 = string2.replace("AB", "1", 1)
count = string2.count("1")
if count == 2:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER ASSIGN VAR FUNC_CALL VAR... |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
-----Input-----
The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters.
-----Output-----
Print ... | string = input()
k1 = 0
i = 0
k2 = 0
k3 = 0
k4 = 0
for i in range(len(string) - 1):
if string[i] == "A" and string[i + 1] == "B":
if i > 0 and string[i - 1] == "B":
k3 += 1
else:
k1 += 1
elif string[i] == "B" and string[i + 1] == "A":
if i > 0 and string[i - 1] ==... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING IF VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.