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()
a = s.count("AB")
b = s.count("BA")
c = s.count("ABA")
d = s.count("BAB")
print(["NO", "YES"][(a + b) * (a != 0 and b != 0) - c - d > 1]) | 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 EXPR FUNC_CALL VAR LIST STRING STRING BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER VAR NUMBER VAR 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 ... | ss = input()
flag = flag2 = 0
s = ss
if "AB" in s:
s = s.replace("AB", "X", 1)
flag = 1
if "BA" in s:
s = s.replace("BA", "X", 1)
flag2 = 1
if flag == 0 or flag2 == 0:
flag = flag2 = 0
s = ss
if "BA" in s:
s = s.replace("BA", "X", 1)
flag2 = 1
if "AB" in s:
s = s.... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER ASSIGN VAR NUMBER IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR IF STRING VAR ASSIGN VAR FUNC_CALL VAR S... |
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 = [s[i : i + 2] for i in range(len(s) - 1)]
AB = [i for i, x in enumerate(l) if x == "AB"]
BA = [i for i, x in enumerate(l) if x == "BA"]
flag = 1
if len(AB) != 0 and len(BA) != 0:
for i in AB:
for j in BA:
a = abs(i - j)
if a <= 1:
flag = 1
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR STRING ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR STRING ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER FOR VAR VAR FOR VAR VAR ASSIGN 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()
if not "AB" in s:
print("NO")
elif not "BA" in s.replace("AB", " ", 1):
if "BA" in s:
if not "AB" in s.replace("BA", " ", 1):
print("NO")
else:
print("YES")
else:
print("NO")
else:
print("YES") | ASSIGN VAR FUNC_CALL VAR IF STRING VAR EXPR FUNC_CALL VAR STRING IF STRING FUNC_CALL VAR STRING STRING NUMBER IF STRING VAR IF STRING FUNC_CALL VAR STRING STRING NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING 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()
print(
"YNEOS"[
not ("AB" in s and "BA" in s.replace("AB", "X", 1))
and not ("BA" in s and "AB" in s.replace("BA", "X", 1)) :: 2
]
) | ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING STRING VAR STRING FUNC_CALL VAR STRING STRING NUMBER STRING VAR STRING FUNC_CALL VAR STRING 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()
ans1 = []
ans2 = []
if len(s) < 2:
print("NO")
else:
for i in range(1, len(s)):
if s[i - 1] == "A" and s[i] == "B":
ans1.append("AB")
i += 2
break
for e in range(i, len(s)):
if s[e - 1] == "B" and s[e] == "A":
ans1.append("BA")
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER STRING VAR VAR STRING EXPR FUNC_CALL VAR STRING VAR NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER STRING 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()
y = "YES"
if s.find("AB", s.find("BA") + 2) > 0 and s.find("BA") >= 0:
print(y)
elif s.find("BA", s.find("AB") + 2) > 0 and s.find("AB") >= 0:
print(y)
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING IF FUNC_CALL VAR STRING BIN_OP FUNC_CALL VAR STRING NUMBER NUMBER FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR STRING BIN_OP FUNC_CALL VAR STRING NUMBER NUMBER FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR VAR 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 = None
b = None
for i in range(len(s) - 1):
if s[i] == "A" and s[i + 1] == "B":
if a is None:
a = i
if b is not None and abs(i - b) > 1:
print("YES")
exit(0)
if s[i] == "B" and s[i + 1] == "A":
if b is None:
b = i
if a... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NONE ASSIGN VAR NONE FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING IF VAR NONE ASSIGN VAR VAR IF VAR NONE FUNC_CALL VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF VAR VAR STRING VAR BIN_OP 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 ... | s = input()
ABfirst = s.find("AB")
BAfirst = s.find("BA")
if ABfirst == -1 or BAfirst == -1:
print("NO")
elif abs(ABfirst - BAfirst) > 1:
print("YES")
else:
next_pos = min(ABfirst, BAfirst) + 3
if s.find("AB", next_pos) >= 0 or s.find("BA", next_pos) >= 0:
print("YES")
else:
print("N... | 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 FUNC_CALL VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER IF FUNC_CALL VAR STRING VAR NUMBER FUNC_CALL VAR STRING VAR NUMBER E... |
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 = "a" + input() + "a"
cab, cba = [], []
for i in range(1, len(s) - 1):
if s[i : i + 2] == "AB":
cab.append(i)
for j in cba:
if j != i - 1 and j != i + 1:
print("YES")
exit()
elif s[i : i + 2] == "BA":
cba.append(i)
for j in cab:
... | ASSIGN VAR BIN_OP BIN_OP STRING FUNC_CALL VAR STRING ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR FOR VAR VAR IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF VAR VAR BIN_OP ... |
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()
sc = s
y = len(s)
s = s.replace("AB", ";);", 1)
s = s.replace("BA", ";);", 1)
sc = sc.replace("BA", ";);", 1)
sc = sc.replace("AB", ";);", 1)
print("YES" if y + 2 in (len(s), len(sc)) else "NO") | 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 NUMBER ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR FUNC_CALL 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 ... | check = 0
s = input()
t = s
if "AB" in s:
s = s.replace("AB", "*", 1)
if "BA" in s:
check += 1
if "BA" in t:
t = t.replace("BA", "*", 1)
if "AB" in t:
check += 1
print("YES" if check > 0 else "NO") | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER IF STRING VAR VAR NUMBER IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER IF STRING VAR VAR NUMBER EXPR FUNC_CALL VAR VAR 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 ... | string = input()
AB = []
BA = []
for i in range(len(string) - 1):
current = string[i : i + 2]
if current == "AB":
AB.append(i)
elif current == "BA":
BA.append(i)
result = "NO"
for item1 in AB:
for item2 in BA:
if abs(item1 - item2) > 1:
result = "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 ASSIGN VAR VAR VAR BIN_OP VAR NUMBER IF VAR STRING EXPR FUNC_CALL VAR VAR IF VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR STRING FOR VAR VAR FOR VAR VAR IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN 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()
i, j = 0, len(s) - 1
lab, lba, rab, rba = -999999, -999999, -999999, -999999
while i <= len(s) - 2 and j >= 1:
if (s[i] == "A" and s[i + 1] == "B") and lab == -999999:
lab = i
if (s[i] == "B" and s[i + 1] == "A") and lba == -999999:
lba = i
if (s[j - 1] == "B" and s[j] == "A") an... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER 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 ... | import sys
inputStr = input()
if "AB" in inputStr:
i = inputStr.index("AB")
if "BA" in inputStr[:i] or "BA" in inputStr[i + 2 :]:
print("YES")
sys.exit()
if "BA" in inputStr:
i = inputStr.index("BA")
if "AB" in inputStr[:i] or "AB" in inputStr[i + 2 :]:
print("YES")
sys.... | IMPORT ASSIGN VAR FUNC_CALL VAR IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING IF STRING VAR VAR STRING VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING IF STRING VAR VAR STRING VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR 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 ... | str = input()
condition = False
i = 0
for i in range(0, len(str)):
if str[i : i + 2] == "AB":
break
j = i + 2
for i in range(j, len(str)):
if str[i : i + 2] == "BA":
condition = True
break
if condition == True:
print("YES")
else:
for i in range(0, len(str)):
if str[i : i ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR 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 ... | a = input()
f = False
q = False
p = -2
for i in range(len(a)):
if i < len(a) - 1 and not f and a[i] == "A" and a[i + 1] == "B":
f = True
p = i
elif i < len(a) - 1 and f and a[i] == "B" and a[i + 1] == "A" and p != i - 1:
q = True
f1 = False
q1 = False
p1 = -2
for i in range(len(a)):
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER ASSIGN VAR VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR VAR STRING VAR BIN_OP VAR NUMBER S... |
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
ans = False
if (
min(s.count("AB"), s.count("BA")) >= 1
and s.count("AB") + s.count("BA") - int("BAB" in s) - int("ABA" in s) >= 2
):
print("YES")
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING NUMBER BIN_OP BIN_OP BIN_OP FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING VAR FUNC_CALL VAR STRING 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 ... | str2 = input()
def test(str1):
if str1.count("AB") >= 1:
str1 = str1.replace("AB", "Z", 1)
if str1.count("BA") >= 1:
return True
else:
return False
else:
return False
def test1(str1):
if str1.count("BA") >= 1:
str1 = str1.replace("BA", "Z",... | ASSIGN VAR FUNC_CALL VAR FUNC_DEF IF FUNC_CALL VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER IF FUNC_CALL VAR STRING NUMBER RETURN NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF IF FUNC_CALL VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER IF FUNC_CALL VAR STRING NUMBER RETURN NUMBER RETUR... |
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 = list(s)
pos1 = []
pos2 = []
for i in range(len(s) - 1):
if s[i] == "A" and a[i + 1] == "B":
pos1.append([i, i + 1])
for i in range(len(s) - 1):
if s[i] == "B" and s[i + 1] == "A":
pos2.append([i, i + 1])
if len(pos1) == 0 or len(pos2) == 0:
print("NO")
elif len(pos1) == 0:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR 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 LIST VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING 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 ... | def solution():
s = input()
current_a = -2
current_b = -2
ab = []
ba = []
for i in range(len(s)):
if s[i] == "A":
current_a = i
if s[i] == "B" and current_a == i - 1:
ab.append((i - 1, i))
for j in range(len(s)):
if s[j] == "B":
cur... | FUNC_DEF 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 ASSIGN VAR VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR 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 = str(input())
i = 0
arr1 = []
arr2 = []
while i < len(s) - 1:
if s[i] == "A" and s[i + 1] == "B":
arr1.append(i)
if s[i] == "B" and s[i + 1] == "A":
arr2.append(i)
i += 1
if len(arr1) == 0 or len(arr2) == 0:
print("NO")
elif max(len(arr1), len(arr2)) > 2 and min(len(arr1), len(arr2)) ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST WHILE 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 VAR NUMBER IF FUNC_CALL VAR VAR NUMBER 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 substrings(s):
a = s.count("AB")
b = s.count("BA")
c = s.count("ABA")
d = s.count("BAB")
if (a != 0 and b != 0) and a + b - c - d > 1:
return "YES"
else:
return "NO"
s = input()
print(substrings(s)) | FUNC_DEF 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 RETURN STRING RETURN STRING ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL 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 ... | s = input()
for i in range(len(s)):
if i + 1 < len(s) and s[i : i + 2] == "AB":
for j in range(i + 2, len(s), 1):
if s[j : j + 2] == "BA":
print("YES")
exit()
break
for i in range(len(s)):
if i + 1 < len(s) and s[i : i + 2] == "BA":
for j in ra... | ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR 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 ... | def solve():
a = s.find("AB")
b = s.rfind("AB")
c = s.find("BA")
d = s.rfind("BA")
found = (abs(a - d) > 1 or abs(b - c) > 1) and min(a, b, c, d) >= 0
return "NO YES".split()[found]
def main():
global s
s = input()
print(solve())
main() | FUNC_DEF 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 BIN_OP VAR VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR NUMBER FUNC_CALL VAR VAR VAR VAR VAR NUMBER RETURN FUNC_CALL STRING VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR E... |
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
pre = -2
while ab != -1:
ab = s.find("AB", pre + 2, len(s))
pre = ab
if ab == -1:
pass
else:
ba = s.find("BA", 0, ab)
if ba == -1:
ba = s.find("BA", ab + 2, len(s))
if ba == -1:
pass
else:
prin... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING NUMBER VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF VAR NUMBER 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()
def helper(s, seq):
for x in range(len(s) - 1):
if s[x] == seq[0] and s[x + 1] == seq[1]:
return True
return False
def f(s):
if len(s) < 4:
return False
else:
count = 0
for x in range(len(s) - 1):
if s[x] == "B" and s[x + 1] == "A":... | ASSIGN VAR FUNC_CALL VAR FUNC_DEF FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING 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 ... | l = input()
a = 0
b = 0
for i in range(len(l) - 2):
if l[i] == "A" and l[i + 1] == "B" and l[i + 2] != "A":
a = 1
if l[i] == "B" and l[i + 1] == "A" and l[i + 2] != "B":
b = 1
if l[len(l) - 3 :] != "BAB" and l[len(l) - 2 :] == "AB":
a = 1
if l[len(l) - 3 :] != "ABA" and l[len(l) - 2 :] == "B... | 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 BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER IF 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 ... | def search_podstroki(s, t):
t1 = t + "$" + s
p = [-1] * len(t1)
prefix(t1, p)
c1 = 0
for i in range(1, len(t1)):
if p[i] == len(t) - 1:
c1 = -1
return i - len(t) - 1
if c1 != -1:
return False
def prefix(t, p):
k = 0
for i in range(1, len(t)):
... | FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR STRING VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER RETURN BIN_OP BIN_OP VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER RETURN... |
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 = list(input())
n = len(string)
i = 0
checkAB = []
checkBA = []
while i < n - 1:
if string[i] == "A" and string[i + 1] == "B":
checkAB.append([i, i + 1])
elif string[i] == "B" and string[i + 1] == "A":
checkBA.append([i, i + 1])
i += 1
check = False
for x in checkAB:
for y in chec... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST WHILE 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 IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR LIST VAR BIN_OP... |
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:
if "BA" in a[a.index("AB") + 2 :]:
exit(print("YES"))
if "BA" in a:
if "AB" in a[a.index("BA") + 2 :]:
exit(print("YES"))
print("NO") | ASSIGN VAR FUNC_CALL VAR IF STRING VAR IF STRING VAR BIN_OP FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR STRING IF STRING VAR IF STRING VAR BIN_OP FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR 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 ... | from sys import exit
def func():
s = input().strip()
AIDX = []
BIDX = []
for i in range(len(s) - 1):
if s[i] == "A" and s[i + 1] == "B":
AIDX.append(i)
if s[i] == "B" and s[i + 1] == "A":
BIDX.append(i)
if len(AIDX) == 0 or len(BIDX) == 0:
print("NO"... | FUNC_DEF ASSIGN VAR FUNC_CALL 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 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 ... | s = input()
n = len(s)
abl, abr = s.find("AB"), s.rfind("AB")
bal, bar = s.find("BA"), s.rfind("BA")
if abl >= 0 and bar >= 0 and abs(abl - bar) > 1:
print("YES")
elif bal >= 0 and abr >= 0 and abs(bal - abr) > 1:
print("YES")
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP VAR 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 ... | s = input()
check1 = 0
check2 = 0
word1 = []
word2 = []
for i in range(len(s)):
word1.append(s[i])
word2.append(s[i])
if len(word1) <= 3:
print("NO")
else:
for i in range(len(word1) - 1):
if word1[i] == "A" and word1[i + 1] == "B" and check1 == 0:
check1 += 1
word1[i] = 0... | 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 EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING 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 ... | a = input()
ab = 0
ba = 0
all = 0
i = 1
while i < len(a):
if a[i - 1] + a[i] == "AB":
c = "B"
i1 = i - 1
while i < len(a) and a[i] == c:
i += 1
if c == "B":
c = "A"
else:
c = "B"
ln = i - i1
if ln == 2:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF BIN_OP VAR BIN_OP VAR NUMBER VAR VAR STRING ASSIGN VAR STRING ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER IF VAR STRING ASSIGN VAR STRING ASSIGN 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().strip()
acnt, bcnt = 0, 0
MaxA, MaxB, MinA, MinB = -1, -1, 9999999999999, 9999999999999
for i in range(len(s) - 1):
if s[i] == "A" and s[i + 1] == "B":
acnt += 1
if i < MinA:
MinA = i
if i > MaxA:
MaxA = i
if s[i] == "B" and s[i + 1] == "A":
bc... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER 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 ASSIGN VAR VAR IF VAR VAR ASSIGN VAR VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER S... |
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())
flag = False
for i in range(len(string) - 1):
if string[i] + string[i + 1] == "AB":
if "BA" in string[:i]:
flag = True
if "BA" in string[i + 2 :]:
flag = True
if flag:
print("YES")
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL 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 IF STRING VAR VAR ASSIGN VAR NUMBER IF STRING VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR 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 = [i for i in input()]
n = len(s)
fx = False
fy = False
i = 0
while i < n:
if s[i] == "A":
if i + 1 < n and fx is False:
if s[i + 1] == "B":
fx = True
i += 2
break
i += 1
while i < n:
if s[i] == "B":
if i + 1 < n and fy is False:
... | ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR STRING IF BIN_OP VAR NUMBER VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR NUMBER VAR NUMBER WHILE VAR VAR IF VAR VAR STRING IF BIN_OP VAR NUMBER VAR 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 ... | s = input()
l = len(s)
idx = -1
for i in range(l - 1):
if s[i] == "A" and s[i + 1] == "B":
idx = i + 1
break
flag = 0
if idx != -1:
for i in range(idx + 1, l - 1):
if s[i] == "B" and s[i + 1] == "A":
flag = 1
break
if flag == 1:
print("YES")
else:
idx = -1... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN 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 ASSIGN VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER 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 ... | def work():
for i in a:
for j in b:
if abs(i - j) >= 2:
return True
return False
s = input()
l = len(s)
a = []
b = []
for i in range(l - 1):
if s[i] + s[i + 1] == "AB":
a.append(i)
elif s[i] + s[i + 1] == "BA":
b.append(i)
if a and b:
if work():
... | FUNC_DEF FOR VAR VAR FOR VAR VAR IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST 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 BI... |
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()
k = len(a)
ab = 0
ba = 0
aba = 0
bab = 0
m = 0
for i in range(0, k - 2):
if a[i] == "A" and a[i + 1] == "B" and a[i + 2] == "A" and i + 2 < k:
aba = aba + 1
break
elif a[i] == "A" and a[i + 1] == "B" and i + 1 < k:
ab = ab + 1
break
elif a[i] == "B" and a[i + 1] =... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER 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 VAR BIN_OP VAR NUMBER STRING BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP 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 ... | s = input()
ab = s.find("AB")
ba = s.find("BA")
def lookForMyVariable(s):
result = str
if (
ab != -1
and s.find("BA", ab + 2) != -1
or ba != -1
and s.find("AB", ba + 2) != -1
):
result = "YES"
else:
result = "NO"
return result
print(lookForMyVariab... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR VAR IF VAR NUMBER FUNC_CALL VAR STRING BIN_OP VAR NUMBER NUMBER VAR NUMBER FUNC_CALL VAR STRING BIN_OP VAR NUMBER NUMBER ASSIGN VAR STRING ASSIGN VAR STRING RETURN VAR EXPR FUNC_CALL 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 ... | s = input()
n = len(s)
s1 = s[::-1]
count = 0
if "AB" in s and "AB" in s1:
if s.index("BA") < n - 1 - s1.index("BA"):
if s.index("BA") + 1 != n - 1 - s1.index("BA") - 1:
count += 2
else:
count -= 1
if s.index("AB") < n - 1 - s1.index("AB"):
if s.index("AB") + 1 !=... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER IF STRING VAR STRING VAR IF FUNC_CALL VAR STRING BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR STRING IF BIN_OP FUNC_CALL VAR STRING NUMBER BIN_OP BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR STRING NUMBER VAR NUMBER VAR NUMBER IF 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 ... | n = input()
res = "NO"
mylist = ["BABAB", "BAAAB", "ABABA", "ABBBA"]
if "ABA" not in n and "BAB" not in n:
if "AB" in n and "BA" in n:
res = "YES"
else:
for i in mylist:
if i in n:
res = "YES"
if "ABA" in n:
n = n.replace("ABA", "", 1)
if "AB" in n or "BA" in n:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR LIST STRING STRING STRING STRING IF STRING VAR STRING VAR IF STRING VAR STRING VAR ASSIGN VAR STRING FOR VAR VAR IF VAR VAR ASSIGN VAR STRING IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER IF STRING VAR STRING VAR ASSIGN VAR STRING IF STRING VAR 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 ... | sequence = str(input())
variant_first = sequence.replace("AB", "5", 1).replace("BA", "9", 1)
variant_two = sequence.replace("BA", "4", 1).replace("AB", "2", 1)
if (
"5" in variant_first
and "9" in variant_first
or "2" in variant_two
and "4" in variant_two
):
print("YES")
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING STRING NUMBER STRING STRING NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING STRING NUMBER STRING STRING NUMBER IF STRING VAR STRING VAR STRING VAR STRING VAR 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()
N = len(S)
BA = 0
AB = 0
fla = 0
for i in range(1, N):
if S[i] == "A":
if S[i - 1] == "B":
if AB == 0:
BA += 1
elif AB == 1 and S[i - 2] == "A":
BA += 1
continue
else:
fla = 1
brea... | 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 VAR IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING IF VAR NUMBER VAR NUMBER IF VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR STRING IF VAR BIN_OP ... |
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 ... | arr = input()
n = len(arr)
ab = 0
ba = 0
ab2 = 0
ba2 = 0
check = 0
mark = [(0) for _ in range(n)]
mark2 = [(0) for _ in range(n)]
for i in range(n - 1):
if arr[i] == "A" and arr[i + 1] == "B" and ab == 0:
if mark[i] == 0 and mark[i + 1] == 0:
ab += 1
mark[i] = 1
mark[i + ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR 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()
first_AB_index = -1
first_BA_index = -1
last_AB_index = -1
last_BA_index = -1
for i in range(len(s) - 1):
if s[i : i + 2] == "AB":
first_AB_index = i
break
for i in range(len(s) - 1):
if s[i : i + 2] == "BA":
first_BA_index = i
break
for i in range(len(s) - 1, -1, -1)... | ASSIGN VAR FUNC_CALL VAR 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 BIN_OP VAR NUMBER STRING ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR FOR 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 ... | s = input()
pos = -1
pos1 = -1
for i in range(len(s) - 1):
if s[i] == "A" and s[i + 1] == "B":
pos = i
break
for i in range(len(s) - 1, 0, -1):
if s[i] == "A" and s[i - 1] == "B":
pos1 = i - 1
break
pos2 = -1
pos3 = -1
for i in range(len(s) - 1):
if s[i] == "B" and s[i + 1] =... | 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 ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN 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 ... | def containsNonOverlappingABandBA(string):
ABmatches = matchingPositions(string, "AB")
BAmatches = matchingPositions(string, "BA")
return contains(ABmatches, BAmatches) and not overlap(ABmatches, BAmatches)
def matchingPositions(string, substring):
return set(i for i in range(len(string) - 1) if match... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR STRING RETURN FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR VAR VAR FUNC_DEF RETURN VAR VAR BIN_OP VAR FUNC_CALL VAR VAR VAR FUNC_DEF RETURN 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()
abfound = bafound = -1
for i in range(len(s) - 1):
if abfound == -1 and s[i] == "A" and s[i + 1] == "B":
abfound = i
elif bafound == -1 and s[i] == "B" and s[i + 1] == "A":
bafound = i
if abfound != -1 and bafound != -1:
break
if abfound == -1 or bafound == -1:
print(... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR IF VAR NUMBER VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRI... |
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
ab = []
ba = []
def search(txt):
prev = txt[0]
global ab
global ba
for i in range(1, len(txt)):
cur = txt[i]
if prev == "A" and cur == "B":
ab.append(i - 1)
if prev == "B" and cur == "A":
ba.append(i - 1)
prev = cur
txt = input()
se... | IMPORT ASSIGN VAR LIST ASSIGN VAR LIST FUNC_DEF ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR STRING VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR STRING VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR 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 ... | string = input()
index1 = []
index2 = []
judge = False
if "AB" not in string or "BA" not in string:
print("NO")
else:
for i in range(len(string) - 1):
if string[i] == "A" and string[i + 1] == "B":
index1.append(i)
elif string[i] == "B" and string[i + 1] == "A":
index2.app... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER IF STRING VAR STRING VAR EXPR FUNC_CALL VAR STRING 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 ... |
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())
def test_target(self, target, p):
for i in target:
if p - i > 1:
return True
self.append(p)
return False
AB_list = list()
BA_list = list()
for i in range(1, len(S)):
if S[i - 1] == "A" and S[i] == "B":
if test_target(AB_list, BA_list, i):
pri... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF FOR VAR VAR IF BIN_OP VAR VAR NUMBER RETURN NUMBER EXPR FUNC_CALL VAR VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER STRING VAR VAR STRING IF FUNC_CALL VAR VAR VAR VAR 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 ... | s = input()
n = s.find("AB")
m = s.find("BA")
j = s.find("ABA")
k = s.find("BAB")
if m >= 0 or n >= 0 or j >= 0 or k >= 0:
if j >= 0 or k >= 0:
if (
"ABA" in s[0 : j + 3]
and ("AB" in s[j + 3 :] or "BA" in s[j + 3 :])
or "BAB" in s[0 : k + 3]
and ("AB" in s[k ... | 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 VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER IF STRING VAR NUMBER BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR 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 ... | from sys import stdin, stdout
s = stdin.readline().strip()
lAB = s.find("AB")
rAB = s.rfind("AB")
lBA = s.find("BA")
rBA = s.rfind("BA")
if lAB == -1 or lBA == -1:
stdout.write("NO")
elif lAB + 1 < rBA:
stdout.write("YES")
elif lBA + 1 < rAB:
stdout.write("YES")
else:
stdout.write("NO")
stdout.write("\... | ASSIGN VAR FUNC_CALL 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 IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR STRING 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 ... | import sys
w = str(input().strip())
c = w.find("AB")
while c != -1:
c2 = w.find("BA", 0, c)
if c2 == -1:
c2 = w.find("BA", c + 2)
else:
print("YES")
sys.exit()
if c2 == -1:
c = w.find("AB", c + 2)
else:
print("YES")
sys.exit()
print("NO") | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING NUMBER VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING 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 ... | string = input()
output = False
if "AB" in string and not output:
string2 = string.replace("AB", "*", 1)
if "BA" in string2:
print("YES")
output = True
if "BA" in string and not output:
string2 = string.replace("BA", "*", 1)
if "AB" in string2:
print("YES")
output = True
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF STRING VAR VAR ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER IF STRING VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF STRING VAR VAR ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER IF STRING VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR 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()
fl = False
t = s.find("BA")
if t != -1:
x = s[t + 2 :]
if x.find("AB") != -1:
fl = True
t = s.find("AB")
if t != -1:
x = s[t + 2 :]
if x.find("BA") != -1:
fl = True
if fl:
print("YES")
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR STRING NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR STRING NUMBER ASSIGN VAR NUMBER IF VAR 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 find(d, t1, t2):
for i in range(len(d)):
if i + 1 < len(d) and d[i] == t1 and d[i + 1] == t2:
return True
return False
def solve(d):
found = False
ind = 0
n = len(d)
f = True
l = True
while ind < n:
if f and d[ind] == "A" and ind + 1 < n and d[ind + 1] =... | FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR VAR VAR VAR BIN_OP VAR NUMBER VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR STRING BIN_OP VAR NUMBER 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 ... | def checkSubString(s, sub):
foundAB = False
foundBA = False
found = False
i = 0
while i < len(s) - 1:
if not found:
if s[i] == sub[0] and s[i + 1] == sub[1]:
found = True
if i + 2 < len(s):
i += 2
else:
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR IF VAR VAR VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER E... |
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()
l1 = []
l2 = []
c1, c2 = 0, 0
n = len(s)
for i in range(n - 1):
if s[i : i + 2] == "AB":
l1.append(i)
c1 += 1
elif s[i : i + 2] == "BA":
l2.append(i)
c2 += 1
if c1 == 0 or c2 == 0:
print("NO")
elif abs(l1[c1 - 1] - l2[0]) >= 2 or abs(l1[0] - l2[c2 - 1]) >= 2:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR VAR NUMBER IF 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()
ab_count = s.count("AB")
ba_count = s.count("BA")
if ab_count == 0 or ba_count == 0:
print("NO")
elif ab_count == 1:
s = s.replace("AB", "--")
print("YES" if "BA" in s else "NO")
elif ba_count == 1:
s = s.replace("BA", "--")
print("YES" if "AB" in s else "NO")
else:
print("YES") | 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 ASSIGN VAR FUNC_CALL VAR STRING STRING EXPR FUNC_CALL VAR STRING VAR STRING STRING IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING STRING EXPR FUNC_CALL VAR STRING 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()
succ = False
x = s.find("AB")
if x != -1:
z = s[:x].find("BA")
y = s[x + 2 :].find("BA")
if z != -1 or y != -1:
succ = True
x = s.find("BA")
if x != -1:
z = s[:x].find("AB")
y = s[x + 2 :].find("AB")
if z != -1 or y != -1:
succ = True
print(["NO", "YES"][succ]) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER STRING IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR STRING 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()
cnt_a = 0
cnt_b = 0
cnt_c = 0
cnt_d = 0
a = "AB"
b = "BA"
c = "ABA"
d = "BAB"
cnt_a = s.count(a)
cnt_b = s.count(b)
cnt_c = s.count(c)
cnt_d = s.count(d)
if cnt_a != 0 and cnt_b != 0:
if cnt_a + cnt_b - (cnt_c + cnt_d) > 1:
print("YES")
else:
print("NO")
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER IF BIN_OP ... |
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 ... | k = input()
j = k
j = j.replace("AB", "*", 1)
j = j.replace("BA", "^", 1)
if "*" in j and "^" in j:
print("YES")
exit(0)
j = k
j = j.replace("BA", "*", 1)
j = j.replace("AB", "^", 1)
if "*" in j and "^" in j:
print("YES")
exit(0)
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER IF STRING VAR STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER IF S... |
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()
n = len(s)
def has():
for i in range(n - 1):
if s[i : i + 2] == "AB":
for j in range(i + 2, n - 1):
if s[j : j + 2] == "BA":
return True
break
for i in range(n - 1):
if s[i : i + 2] == "BA":
for j in ra... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING RETURN NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR 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 ... | s = input()
abc = [0, 0, 0]
n = len(s)
i = 0
while i < n:
ch = s[i]
if ch == "A":
if i < n - 1 and s[i + 1] == "B":
if i < n - 2 and s[i + 2] == "A":
abc[2] += 1
i += 3
else:
abc[0] = 1
i += 2
else:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR VAR IF VAR STRING IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR NUMBER NUMBER 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 ... | st = input()
ab1 = st.find("AB")
ba1 = st.find("BA")
ab2 = st.rfind("AB")
ba2 = st.rfind("BA")
if ab1 == -1 or ba1 == -1:
print("NO")
elif ab1 == ab2 and ba1 == ba2 and abs(ba1 - ab1) < 2:
print("NO")
elif ab1 + 2 == ab2 and ba1 == ba2:
print("NO")
elif ba1 + 2 == ba2 and ab1 == ab2:
print("NO")
else:
... | 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 IF VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER VAR VAR VAR EX... |
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 = []
if "AB" in s and "BA" in s:
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 abs(min(a) - max(b)) <= 1 and abs(min(b) - max(a)) <= 1:
print("NO")
else:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST IF STRING VAR STRING VAR 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 BIN_OP FUNC_CALL VAR VAR 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()
if "AB" not in s or "BA" not in s:
print("NO")
else:
ab = s.index("AB")
bar = s.rindex("BA")
abr = s.rindex("AB")
ba = s.index("BA")
if bar - ab >= 2 or abr - ba >= 2:
print("YES")
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR IF STRING VAR STRING VAR EXPR 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 BIN_OP VAR VAR NUMBER BIN_OP 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 ... | s = input()
t = False
if (
s.find("AB") >= 0
and s.replace("AB", "Z", 1).find("BA") >= 0
or s.find("BA") >= 0
and s.replace("BA", "Z", 1).find("AB") >= 0
):
t = True
print("YES" if t else "NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF FUNC_CALL VAR STRING NUMBER FUNC_CALL FUNC_CALL VAR STRING STRING NUMBER STRING NUMBER FUNC_CALL VAR STRING NUMBER FUNC_CALL FUNC_CALL VAR STRING STRING NUMBER STRING NUMBER 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 ... | s = input()
n = len(s)
l = [[0, 0] for i in range(n + 1)]
flag = 0
for i in range(len(s) - 1):
l[i + 2][0] = l[i + 1][0]
l[i + 2][1] = l[i + 1][1]
if s[i : i + 2] == "AB":
l[i + 2][0] = l[i + 2][0] + 1
if l[i][1] >= 1:
flag = 1
break
elif s[i : i + 2] == "BA":
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER VAR 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()
x = 1
while x < len(s):
if s[x - 1] == "A" and s[x] == "B":
if "BA" in s[x + 1 :]:
print("YES")
break
elif s[x - 1] == "B" and s[x] == "A":
if "AB" in s[x + 1 :]:
print("YES")
break
x += 1
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER STRING VAR VAR STRING IF STRING VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR BIN_OP VAR NUMBER STRING VAR VAR STRING IF STRING VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING VAR NUMBER 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()
n = len(s)
abmishe = False
bamishe = False
abmisherev = False
bamisherev = False
cnt = 0
while cnt < n - 1:
if not abmishe and s[cnt : cnt + 2] == "AB":
abmishe = True
cnt += 1
elif not bamishe and s[cnt : cnt + 2] == "BA":
bamishe = True
cnt += 1
cnt += 1
cnt2 = ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER 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 ... | string = input()
ab_indexes = []
ba_indexes = []
for k in range(len(string) - 1):
part = string[k] + string[k + 1]
if part == "AB":
ab_indexes.append(k)
if part == "BA":
ba_indexes.append(k)
def exists():
for k in ab_indexes:
for i in ba_indexes:
if abs(i - k) > 1:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER IF VAR STRING EXPR FUNC_CALL VAR VAR IF VAR STRING EXPR FUNC_CALL VAR VAR FUNC_DEF FOR VAR VAR FOR VAR VAR IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER RETURN NUMBER R... |
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()
a = s.find("AB")
b = s.find("BA")
if a == -1 or b == -1:
print("NO")
return
if s[a + 2 :].find("BA") != -1 or s[b + 2 :].find("AB") != -1:
print("YES")
return
print("NO")
return
main() | FUNC_DEF 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 RETURN IF FUNC_CALL VAR BIN_OP VAR NUMBER STRING NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER STRING NUMBER EXPR FUNC_CALL VAR STRING RETURN EXPR FUNC_CALL VAR STRING RETURN EXP... |
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().rstrip()
n = int(len(s))
if n <= 3:
print("NO")
else:
d = [0] * n
for i in range(n - 1):
if s[i] == "A" and s[i + 1] == "B":
d[i] = 1
ans = "NO"
for i in range(1, n):
d[i] += d[i - 1]
for i in range(n - 1):
if s[i] == "B" and s[i + 1] == "A":
... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER VAR 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 STRING FOR VAR FUNC_CALL VAR NUMBER 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 ... | s = input()
a, b = list(), list()
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")
else:
f = 0
for i in a:
for j in b:
if i - 1 != j and i + 1 != ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR 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 ... |
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():
a = input()
c = 0
d = 0
for i in range(1, len(a)):
if a[i] == "A" and a[i - 1] == "B":
d = 1
if i == len(a) - 1:
break
elif a[i + 1] != "B":
break
elif a[i] == "B" and a[i - 1] == "A":
c = 1
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN 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 ... | import sys
input = sys.stdin.readline
s = input()
ab = False
ba = False
for i in range(len(s) - 1):
cur = s[i] + s[i + 1]
if cur == "AB" and ab is False:
ab = True
for j in range(i + 2, len(s) - 1):
if s[j] + s[j + 1] == "BA":
print("YES")
exit()
... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER IF VAR STRING VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR 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 ... | def f(inp, ab, ba):
i = inp.find(ab)
return i != -1 and inp.find(ba, i + 2) != -1
inp = input()
if f(inp, "AB", "BA") or f(inp, "BA", "AB"):
print("YES")
else:
print("NO") | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR RETURN VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR 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 |
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 = y = input()
s1, s2 = x.count("AB"), x.count("BA")
x = x.replace("AB", "11").replace("BA", "11")
y = y.replace("BA", "11").replace("AB", "11")
if s1 > 0 and s2 > 0 and x.count("1") >= 4 and y.count("1") >= 4:
print("YES")
else:
print("NO") | ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING STRING STRING STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING STRING STRING STRING IF VAR NUMBER VAR NUMBER FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING E... |
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()
f = False
for i in range(len(a) - 1):
if a[i] + a[i + 1] == "AB":
if a[i + 2 :].rfind("BA") != -1:
f = True
if a[i] + a[i + 1] == "BA":
if a[i + 2 :].rfind("AB") != -1:
f = True
if f:
print("YES")
else:
print("NO") | ASSIGN VAR FUNC_CALL 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 IF FUNC_CALL VAR BIN_OP VAR NUMBER STRING NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER STRING IF FUNC_CALL VAR BIN_OP VAR NUMBER STRING NUMBER ASSIGN 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 ... | s = input()
L = len(s)
AB = 0
BA = 0
ABA = 0
BAB = 0
i = 0
while i < L - 1:
if s[i] == "A":
if s[i + 1] == "B":
if i + 2 < L and s[i + 2] == "A":
ABA += 1
i += 3
else:
AB += 1
i += 2
else:
i += 1
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING IF BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER 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()
if s.count("AB"):
tmp = s.replace("AB", " ", 1)
if tmp.count("BA"):
print("YES")
elif s.count("BA"):
tmp = s.replace("BA", " ", 1)
if tmp.count("AB"):
print("YES")
else:
print("NO")
else:
print("NO")
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER IF FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER IF FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXP... |
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
c = 0
d = 0
j = 0
A = []
a2 = 0
b2 = 0
for i in s:
A.append(i)
while j < len(A) - 1:
if A[j] == "A" and A[j + 1] == "B" and c != 1:
c = 1
a = j
j = j + 1
elif A[j] == "B" and A[j + 1] == "A" and d != 1:
d = 1
b = j
j = j + 1
elif A[... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR EXPR FUNC_CALL VAR VAR WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN 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 = 0
b = 0
AB = []
BA = []
flag = True
for i in range(len(s) - 1):
if s[i] == "A" and s[i + 1] == "B":
AB.append([i, i + 1])
elif s[i] == "B" and s[i + 1] == "A":
BA.append([i, i + 1])
for i in AB:
for j in BA:
flag = True
if i[1] != j[0] and i[0] != j[1]:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST 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 EXPR FUNC_CALL VAR LIST VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING 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 isabba(s):
n = len(s)
i, ab, ba = 0, 0, 0
while i < n - 1:
if s[i] == "A" and s[i + 1] == "B":
ab = 1
i += 2
break
i += 1
if ab == 0:
return False
while i < n - 1:
if s[i] == "B" and s[i + 1] == "A":
ba = 1
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER RETURN NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR 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 ... | s = str(input())
n = len(s)
A = []
B = []
for i in range(n - 1):
if s[i : i + 2] == "AB":
A += [i]
if s[i : i + 2] == "BA":
B += [i]
ok = 0
for a in A:
for b in B:
if abs(a - b) > 1:
print("YES")
ok = 1
break
if ok:
break
if ok == 0:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR LIST VAR IF VAR VAR BIN_OP VAR NUMBER STRING VAR LIST VAR ASSIGN VAR NUMBER FOR VAR VAR FOR VAR VAR IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER E... |
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 printFunc(string):
ab = []
ba = []
if len(string) <= 3:
print("NO")
else:
for i in range(len(string) - 1):
if string[i : i + 2] == "AB":
ab.append(i)
if string[i : i + 2] == "BA":
ba.append(i)
try:
if ba[-1] ... | FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING 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 BIN_OP VAR NUMBER VAR NUMBER 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 ... | import sys
s = input()
t = 0
f = len(s) - 2
i = 0
while i < f:
if s[i] == "A" and s[i + 1] == "B" and s[i + 2] == "A":
s = s[:i] + s[i + 3 :]
t += 1
elif s[i] == "B" and s[i + 1] == "A" and s[i + 2] == "B":
s = s[:i] + s[i + 3 :]
t += 1
f = len(s) - 2
i += 1
if t >= 2:
... | IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP 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()
abx = s.replace("AB", "X", 1)
bax = s.replace("BA", "X", 1)
print(
"YES"
if len(abx) != len(s) and abx.count("BA") or len(bax) != len(s) and bax.count("AB")
else "NO"
) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR STRING 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 = input()
f = False
if "AB" in s:
a = s.index("AB")
if "BA" in s[a + 2 :]:
f = True
if "BA" in s:
a = s.index("BA")
if "AB" in s[a + 2 :]:
f = True
print("YES" if f else "NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING IF STRING VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING IF STRING VAR BIN_OP VAR NUMBER 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 has_non_overlapping_substrings(string):
index = string.find("AB")
if index >= 0 and string.find("BA", index + 2) > 0:
return True
index = string.find("BA")
if index >= 0 and string.find("AB", index + 2) > 0:
return True
return False
def run_alg():
result = has_non_overlappi... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER FUNC_CALL VAR STRING BIN_OP VAR NUMBER NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER FUNC_CALL VAR STRING BIN_OP VAR NUMBER NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR 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 ... | s = input()
try:
indAB = s.index("AB")
except:
indAB = len(s)
try:
indBA = s.index("BA")
except:
indBA = len(s)
if "BA" in s[indAB + 2 :] or "AB" in s[indBA + 2 :]:
print("YES")
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR IF STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP 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 ... | a = input()
c = int(0)
d = int(0)
e = int(0)
f = int(0)
for i in range(len(a) - 1):
if a[i] + a[i + 1] == "AB":
c = i + 1
break
for i in range(len(a) - 2, -1, -1):
if a[i] + a[i + 1] == "BA":
d = i + 1
break
for i in range(len(a) - 2, -1, -1):
if a[i] + a[i + 1] == "AB":
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL 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 BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR 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 ... | s = input()
L1 = []
L2 = []
for i in range(len(s) - 1):
if s[i] == "A" and s[i + 1] == "B":
L1.append(i)
elif s[i] == "B" and s[i + 1] == "A":
L2.append(i)
flag = True
i = 0
while i < len(L1) and flag:
j = 0
while j < len(L2) and flag:
if abs(L2[j] - L1[i]) > 1:
flag ... | 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR A... |
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()
p = list(s)
q = list(s)
o = 0
e = 0
mark1 = 0
mark2 = 0
for i in range(len(p) - 1):
if mark1 == 0:
if p[i] == "A" and p[i + 1] == "B":
o += 1
p[i] = 0
p[i + 1] = 0
mark1 += 1
if mark1 != 0 and mark2 == 0:
if p[i] == "B" and p[i + 1] == ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR 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 NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP... |
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 = list(sys.stdin.readline())
d = 0
e = 0
for i in range(len(s) - 1):
if s[i] == "A" and s[i + 1] == "B" and d == 0:
d = i + 2
elif s[i] == "B" and s[i + 1] == "A" and e == 0:
e = i + 2
a = "".join(s[d:])
b = "".join(s[e:])
if d != 0 and "BA" in a:
print("YES")
elif e != 0 and "... | IMPORT ASSIGN VAR FUNC_CALL 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 ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.