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 ... | def find(st):
a = "AB"
b = "BA"
return check(st, a, b) or check(st, b, a)
def check(st, x, y):
temp = st.find(x)
if temp < 0:
return False
return st.find(y, temp + len(x)) >= 0
s = input()
if find(s):
print("YES")
else:
print("NO") | FUNC_DEF ASSIGN VAR STRING ASSIGN VAR STRING RETURN FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER RETURN NUMBER RETURN FUNC_CALL VAR VAR BIN_OP VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING EXPR 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 ... | s = input()
pos = s.find("AB")
if pos < 0:
print("NO")
quit()
ls = [s[:pos], s[pos + 2 :]]
for m in ls:
if "BA" in m:
print("YES")
quit()
pos = s.find("BA")
if pos < 0:
print("NO")
quit()
ls = [s[:pos], s[pos + 2 :]]
for m in ls:
if "AB" in m:
print("YES")
quit()
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR LIST VAR VAR VAR BIN_OP VAR NUMBER FOR VAR VAR 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 ... |
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()
n = len(a)
b = [False] * n
c = [False] * n
i = 1
ok = False
while i < n:
b[i] = b[i - 1]
c[i] = c[i - 1]
if a[i - 1 : i + 1] == "AB":
b[i] = 1
if i > 1 and c[i - 2]:
ok = 1
if a[i - 1 : i + 1] == "BA":
c[i] = 1
if i > 1 and b[i - 2]:
ok... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR 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 = list(input())
n = len(s)
split_place = 0
flag1 = 0
for i in range(n - 1):
if s[i] == "A" and s[i + 1] == "B":
split_place = i
flag1 = 1
break
flag = 0
if flag1 == 1:
temp_string1 = s[0:split_place]
temp_string2 = s[split_place + 2 : n]
for i in range(len(temp_string1) - 1):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR NUMBER 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 ... | s = list(input(""))
n = len(s)
indA = []
indB = []
flag = 0
for i in range(n):
if s[i] == "A":
if i + 1 >= n:
continue
elif s[i + 1] == "B":
indA.append(i)
elif s[i] == "B":
if i + 1 >= n:
continue
elif s[i + 1] == "A":
indB.append(... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER 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 ... | line1 = str(input())
abIndexes = []
baIndexes = []
for i in range(0, len(line1) - 1):
if line1[i] == "A" and line1[i + 1] == "B":
abIndexes.append(i)
for i in range(0, len(line1) - 1):
if line1[i] == "B" and line1[i + 1] == "A":
baIndexes.append(i)
distinct = False
for i in abIndexes:
for j ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING 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 ... | def compute_prefix_function(p):
s = [0] * len(p)
border = 0
for i in range(1, len(p)):
while border > 0 and p[i] != p[border]:
border = s[border - 1]
if p[i] == p[border]:
border += 1
else:
border = 0
s[i] = border
return s
def kmp(p,... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR WHILE VAR NUMBER VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR RETURN VAR FUNC_DEF STRING ASSIGN VAR FUNC_CALL STRING 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 ... | i = str(input())
if "AB" in i and "BA" in i:
k = i.index("AB")
d = i.index("BA")
if "BA" in i[k + 2 :]:
print("YES")
elif "AB" in i[d + 2 :]:
print("YES")
else:
print("NO")
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF STRING VAR STRING VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF STRING VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING IF STRING VAR BIN_OP VAR NUMBER 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 ... | n = input()
ab = -1
ba = -1
found = False
for i in range(len(n) - 1):
check = n[i : i + 2]
if check == "AB":
if ba > -1 and ba != i - 1:
print("YES")
found = True
break
elif ab == -1:
ab = i
elif check == "BA":
if ab > -1 and ab != i - ... | 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 ASSIGN VAR VAR VAR BIN_OP VAR NUMBER IF VAR STRING IF VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR IF VAR STRING IF 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 ... | st = input()
def ans(st):
try:
a, b = st.split("AB", 1)
if "BA" in a or "BA" in b:
return "YES"
a, b = st.split("BA", 1)
if "AB" in a or "AB" in b:
return "YES"
else:
return "NO"
except:
return "NO"
print(ans(st)) | ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR STRING NUMBER IF STRING VAR STRING VAR RETURN STRING ASSIGN VAR VAR FUNC_CALL VAR STRING NUMBER IF STRING VAR STRING VAR RETURN STRING RETURN STRING RETURN STRING 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()
a = b = -1
for i in range(len(s) - 1):
if s[i] == "A":
if s[i + 1] == "B":
if a == -1:
a = i
if 0 <= b < i - 1:
print("YES")
exit()
elif s[i] == "B":
if s[i + 1] == "A":
if b == -1:
b ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING IF VAR NUMBER ASSIGN VAR VAR IF NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING IF 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()
n = len(s)
ans = [-1] * n
ba = False
ab = False
ab_1 = False
ba_1 = False
for i in range(n):
if s[i] == "B":
ans[i] = 2
elif s[i] == "A":
ans[i] = 1
ans_1 = ans[:]
for i in range(n - 1):
if ans[i] == 2 and ans[i + 1] == 1:
ba = True
ans[i] = -1
ans[i + 1] ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR NUMBER IF VAR VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR 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 ... | x = str(input())
ab = x.find("AB")
abb = x[ab + 2 :].find("BA")
ba = x.find("BA")
baa = x[ba + 2 :].find("AB")
print("YES" if ab != -1 and abb != -1 or ba != -1 and baa != -1 else "NO") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER 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 ... | import itertools
s = input()
a1 = s.find("AB")
b1 = s.find("BA")
a2 = -1 if a1 == -1 else s.find("AB", a1 + 1)
b2 = -1 if b1 == -1 else s.find("BA", b1 + 1)
a3 = -1 if a2 == -1 else s.find("AB", a2 + 1)
b3 = -1 if b2 == -1 else s.find("BA", b2 + 1)
for a, b in itertools.product((a1, a2, a3), (b1, b2, b3)):
if a !=... | IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER NUMBER FUNC_CALL VAR STRING BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FUNC_CALL VAR STRING BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FUNC_CALL VAR STRING BIN_OP VAR NUMBER ASSIGN VAR 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()
flag = 0
if "AB" in s:
res = s.find("AB")
copy = s[res + 2 :]
if "BA" in copy:
flag = 1
elif flag != 1:
flag = 0
if "BA" in s:
res = s.find("BA")
copy = s[res + 2 :]
if "AB" in copy:
flag = 1
elif flag != 1:
flag = 0
else:
flag = 0
if flag ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR BIN_OP VAR NUMBER IF STRING VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR BIN_OP VAR NUMBER IF STRING VAR ASSIGN VAR NUMBER IF VAR NUMBER 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()
ans = False
res = False
n = len(s)
i = 0
while i < n - 1:
if s[i] == "A":
if s[i + 1] == "B":
ans = True
if ans:
i += 2
while i < n - 1:
if s[i] == "B":
if s[i + 1] == "A":
res = True
i += 1
if res:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER IF VAR VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING ASSIGN 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 ... | s = input()
r = [i for i in range(len(s)) if s.startswith("AB", i)]
l = [i for i in range(len(s)) if s.startswith("BA", i)]
if (
len(r)
and len(l)
and (abs(r[len(r) - 1] - l[0]) > 1 or abs(l[len(l) - 1] - r[0]) > 1)
):
print("YES")
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR STRING VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR STRING VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER NUMBER FUNC_CALL VAR BIN_OP 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()
s1 = "ABBA"
s2 = "BAAB"
start = 0
flag = 0
prev = 0
for i in range(len(s) - 1):
if prev == 1:
prev = 0
continue
if s[i] == s1[start]:
if s[i + 1] == s1[start + 1]:
start += 2
prev = 1
if start == 4:
flag = 1
break
start = 0
prev = 0... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR VAR IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER 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()
if "AB" in s and "BA" in s:
ct = s.index("AB")
d = 0
if "BA" in s[ct + 2 :]:
d = 1
else:
d = 0
if d == 0:
ct = s.index("BA")
if "AB" in s[ct + 2 :]:
print("YES")
else:
print("NO")
if d:
print("YES")
else:
pri... | ASSIGN VAR FUNC_CALL VAR IF STRING VAR STRING VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF STRING VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF STRING VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING 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 ... | s = input()
if "AB" in s:
if "BA" in s[s.index("AB") + 2 :] or "BA" in s[0 : s.index("AB")]:
print("YES")
elif "BA" in s:
if "AB" in s[s.index("BA") + 2 :] or "AB" in s[0 : s.index("BA")]:
print("YES")
else:
print("NO")
else:
print("NO")
else:
prin... | ASSIGN VAR FUNC_CALL VAR IF STRING VAR IF STRING VAR BIN_OP FUNC_CALL VAR STRING NUMBER STRING VAR NUMBER FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF STRING VAR IF STRING VAR BIN_OP FUNC_CALL VAR STRING NUMBER STRING VAR NUMBER FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR 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()
l = []
cnt = 0
for i in range(len(s) - 1):
l.append(s[i] + s[i + 1])
n = -10
m = -10
n1 = 1000000
m1 = 1000000
cnt = 0
va = 0
if "AB" not in l or "BA" not in l:
print("NO")
else:
for i in range(len(l) - 1):
if l[i] == "AB":
m = i
break
elif l[i] == "BA":
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF STRING VAR 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()
if s.count("AB") + s.count("BA") - s.count("ABA") - s.count("BAB") - 1:
if s.count("AB") and s.count("BA"):
print("YES")
else:
print("NO")
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR IF BIN_OP BIN_OP BIN_OP BIN_OP FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING NUMBER IF FUNC_CALL VAR STRING 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 ... | def func(n):
if "AB" not in n or "BA" not in n:
print("NO")
return
a = n.index("AB")
b = n.index("BA")
for i in range(a + 2, len(n) - 1):
if n[i] + n[i + 1] == "BA":
print("YES")
return
for i in range(b + 2, len(n) - 1):
if n[i] + n[i + 1] == "... | FUNC_DEF IF STRING VAR STRING VAR EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR STRING RETURN FOR VAR FUNC_CALL 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 ... | string = list(input())
stringVertwo = string.copy()
points = 0
substring = []
substringVertwo = []
if len(string) > 3:
for i in range(len(string) - 1):
if string[i] == "A" and string[i + 1] == "B":
x = string[i] + string[i + 1]
substring.append(x)
string[i] = ""
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST IF FUNC_CALL VAR 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 BIN_OP VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR 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 ... | s = input()
c1 = c2 = c3 = 0
i = 0
while i < len(s):
if s[i : i + 3] == "ABA" or s[i : i + 3] == "BAB":
c3 += 1
i += 3
elif s[i : i + 2] == "AB":
c1 += 1
i += 2
elif s[i : i + 2] == "BA":
c2 += 1
i += 2
else:
i += 1
print("YES" if c3 >= 2 or c1 and... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR 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 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 ... | s = input()
for pattern in [("AB", "BA"), ("BA", "AB")]:
found1 = False
i = 0
while i < len(s) - 1:
sub = s[i : i + 2]
if sub == pattern[0] and not found1:
found1 = True
i += 1
elif sub == pattern[1] and found1:
print("YES")
exit()
... | ASSIGN VAR FUNC_CALL VAR FOR VAR LIST STRING STRING STRING STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER IF VAR VAR NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR 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()
flag = False
right_ab = [(0) for i in range(len(s))]
right_ba = [(0) for i in range(len(s))]
count = 0
c = 0
for i in range(len(s) - 2, -1, -1):
if s[i : i + 2] == "AB":
count += 1
right_ab[i] = count
if s[i : i + 2] == "BA":
c += 1
right_ba[i] = c
flag = False
for i in range... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN 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 ... | def main():
s = input().strip()
ab_idxs = []
ba_idxs = []
find_e_idxs(s, ab_idxs, "AB")
find_e_idxs(s, ba_idxs, "BA")
found_two_substrings = False
for i in range(len(ab_idxs)):
curr_ab_idx = ab_idxs[i]
for j in range(len(ba_idxs)):
curr_ba_idx = ba_idxs[j]
... | FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR VAR VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF BIN_OP VAR NUMBER 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 ... | from sys import stdin, stdout
cin = stdin.readline
cout = stdout.write
mp = lambda: list(map(int, cin().split()))
s = cin()[:-1]
t = 0
ab = []
ba = []
i = 0
while i < len(s) - 1:
if s[i : i + 2] == "AB":
ab += [i]
elif s[i : i + 2] == "BA":
ba += [i]
i += 1
if not ab or not ba:
cout("NO... | ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL 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 BIN_OP VAR NUMBER STRING VAR LIST VAR IF VAR VAR BIN_OP VAR NUMBER 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 ... | def mod(a):
if a < 0:
return -a
else:
return a
s = input()
x = []
indAB = []
indBA = []
for i in range(0, len(s) - 1):
x.append(s[i] + s[i + 1])
if "AB" in x and "BA" in x:
for i in range(0, len(s) - 1):
if x[i] == "AB":
indAB.append(i)
elif x[i] == "BA":
... | FUNC_DEF IF VAR NUMBER RETURN VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER IF STRING VAR STRING VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL 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 ... | def solve():
s = input()
ab, ba = 0, 0
i = 0
while i < len(s) - 1:
if ab == 0 and s[i : i + 2] == "AB":
ab = 1
i += 1
elif ba == 0 and ab != 0 and s[i : i + 2] == "BA":
ba = 1
i += 1
i += 1
if ab == 0 or ba == 0:
ab, ba ... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER 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()
li_s1 = []
li_s2 = []
temp = []
for i in range(len(s) - 1):
if s[i] == "A" and s[i + 1] == "B":
li_s1.append(i)
if s[i] == "B" and s[i + 1] == "A":
li_s2.append(i)
if len(li_s1) >= 1 and len(li_s2) >= 1:
temp.append(li_s1[0] - li_s2[-1])
temp.append(li_s2[0] - li_s1[-1])
flag... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST 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 ... |
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 = []
for i in range(len(s) - 1):
if s[i] == "A" and s[i + 1] == "B":
k1.append(i)
kq = "NO"
for i in range(len(s) - 1):
if s[i] == "B" and s[i + 1] == "A":
for item in k1:
if item == i - 1 or item == i + 1:
continue
kq = "YES"
br... | ASSIGN VAR FUNC_CALL VAR 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 ASSIGN VAR STRING FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING FOR VAR VAR IF 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 ... | from sys import exit
s = input()
if s.count("AB") * s.count("BA") == 0:
print("NO")
exit(0)
if s.count("AB") + s.count("BA") - s.count("BAB") - s.count("ABA") >= 2:
print("YES")
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR IF BIN_OP FUNC_CALL VAR STRING FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP BIN_OP FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING 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 ... | import sys
r = lambda: sys.stdin.readline().rstrip()
def find_ab(n):
for i in range(len(n) - 1):
if n[i : i + 2] == "AB":
return i
return -1
def find_ba(n):
for i in range(len(n) - 1):
if n[i : i + 2] == "BA":
return i
return -1
n = r()
idx1 = find_ab(n)
id... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING RETURN VAR RETURN NUMBER FUNC_DEF FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING RETURN VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR 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()
ab = s.find("AB")
ba = s.find("BA")
if ab != -1 and ba != -1:
if abs(ab - ba) > 1:
print("YES")
elif abs(ab - ba) == 1:
mx = max(ab, ba) + 2
if s[mx:].find("AB") != -1 or s[mx:].find("BA") != -1:
print("YES")
else:
print("NO")
else:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR STRING NUMBER FUNC_CALL VAR 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 ... | def is_ab(prev, current):
return prev == "A" and current == "B"
def is_ba(prev, current):
return prev == "B" and current == "A"
def is_matched(prev, current):
return is_ab(prev, current) or is_ba(prev, current)
def main():
s = input()
i = 0
total_ab = 0
total_ba = 0
total_confused ... | FUNC_DEF RETURN VAR STRING VAR STRING FUNC_DEF RETURN VAR STRING VAR STRING FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING WHILE VAR FUNC_CALL VAR VAR ASSIGN 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 ... | a = input()
n = len(a)
if a.count("AB") > 0 and a.count("BA") > 0 and n >= 4:
x1 = -1
y1 = -1
x2 = -1
y2 = -1
x1 = a.find("AB")
if x1 != -1:
y1 = a.find("BA", x1 + 2)
x2 = a.find("BA")
if x2 != -1:
y2 = a.find("AB", x2 + 2)
if x1 != -1 and y1 != -1:
print("YES... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR 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 ... | s = input()
s1 = "AB"
s2 = "BA"
a1 = s.count(s1)
a2 = s.count(s2)
if a1 == 0 or a2 == 0:
print("NO")
elif a2 == 1 and a1 > 1:
k1 = s.find(s2)
k2_1 = s.find(s1)
k2_2 = s.find(s1, k2_1 + 1, len(s))
k2_3 = s.find(s1, k2_2 + 1, len(s))
if k1 != k2_1 + 1 and k1 != k2_1 - 1:
print("YES")
e... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR 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 ... | flag = 0
s = input().strip(" ")
try:
i = s.index("AB")
if "BA" in s[i + 2 :]:
print("YES")
flag = 1
except ValueError:
pass
if not flag:
try:
i = s.index("BA")
if "AB" in s[i + 2 :]:
print("YES")
flag = 1
except:
pass
if not flag:
... | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF STRING VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER VAR IF VAR ASSIGN VAR FUNC_CALL VAR STRING IF STRING VAR BIN_OP VAR NUMBER 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 ... | import sys
a = input()
if a.find("AB") == -1 or a.find("BA") == -1:
print("NO")
sys.exit()
f1 = a.find("AB")
if a.find("BA", f1 + 2, len(a)) != -1:
print("YES")
sys.exit()
f2 = a.find("BA")
if a.find("AB", f2 + 2, len(a)) != -1:
print("YES")
sys.exit()
print("NO") | IMPORT ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF FUNC_CALL VAR STRING BIN_OP VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF 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()
q = s
v = 0
u = 0
if "AB" in s:
v = v + 1
z = s.index("AB")
s = s[:z] + "ab" + s[z + 2 :]
if "BA" in s:
v = v + 1
if "BA" in q:
u = u + 1
z = q.index("BA")
q = q[:z] + "ba" + q[z + 2 :]
if "AB" in q:
u = u + 1
if v == 2 or u == 2:
print("YES")
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF STRING VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR STRING VAR BIN_OP VAR NUMBER IF STRING VAR ASSIGN VAR BIN_OP VAR NUMBER IF STRING VAR ASSIGN VAR BIN_OP 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 ... | st = str(input())
i = 0
if "AB" in st and "BA" in st:
if not "ABA" in st:
if not "BAB" in st:
print("YES")
else:
while i < len(st) - 5 and st[i : i + 3] != "BAB":
i += 1
if "AB" in st[i + 3 : len(st) + 1] or "BA" in st[i + 3 : len(st) + 1]:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF STRING VAR STRING VAR IF STRING VAR IF STRING VAR EXPR FUNC_CALL VAR STRING WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF STRING VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER STRING VAR BIN_OP 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()
c = len(a)
x, y, z, w = 0, 0, 0, 0
for i in range(c - 1):
if a[i] == "A" and a[i + 1] == "B":
x = x + 1
if a[i] == "B" and a[i + 1] == "A":
y = y + 1
for i in range(c - 2):
if a[i] == "A" and a[i + 1] == "B" and a[i + 2] == "A":
z = z + 1
if a[i] == "B" and a[i + 1] =... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER 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 IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL 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 ... | x = input()
m = False
for i in range(len(x)):
if i + 1 < len(x) and x[i] == "A" and x[i + 1] == "B":
n = min(i + 2, len(x) - 1)
if "BA" in x[:i] + " " + x[n:]:
m = True
if m:
print("YES")
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF STRING BIN_OP BIN_OP VAR VAR STRING VAR VAR ASSIGN VAR NUMBER IF VAR 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 ... | i = input()
c1 = i.count("AB")
c2 = i.count("BA")
if c1 > 0 and c2 > 0:
j = i.find("AB")
tmp = i[:j] + "00" + i[j + 2 :]
c2 = tmp.count("BA")
if c2 > 0:
print("YES")
else:
k = i.find("BA")
tmp = i[:k] + "00" + i[k + 2 :]
c1 = tmp.count("AB")
if c1 > 0:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR STRING VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN 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 = str(input())
suc = 0
suc2 = 0
k = [0]
j = [0]
if "AB" in s:
suc += 1
k = s.replace("AB", "DD", 1)
if "BA" in k:
suc += 1
if suc == 2:
print("YES")
else:
if "BA" in s:
suc2 += 1
j = s.replace("BA", "DD", 1)
if "AB" in j:
suc2 += 1
if suc2 == 2:
print("YES")... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR LIST NUMBER IF STRING VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER IF STRING VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF STRING VAR VAR NUMBER ASSIGN VAR FUNC_CALL 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 ... | from sys import stdin
max_val = int(10000000000000.0)
min_val = int(-10000000000000.0)
def read_int():
return int(stdin.readline())
def read_ints():
return [int(x) for x in stdin.readline().split()]
def read_str():
return input()
def read_strs():
return [x for x in stdin.readline().split()]
s... | ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF RETURN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING 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 ... | s = input()
ans = False
ab = False
ba = False
n = len(s)
i = 0
while i < n - 1:
if ab == False:
if s[i] == "A" and s[i + 1] == "B":
ab = True
i += 1
elif s[i] == "B" and s[i + 1] == "A":
ba = True
i += 1
if ab and ba:
ans = True
ab = False
ba = False
i = 0
while i... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN 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()
flag = 0
for i in range(0, len(s) - 2):
if s[i] == "A" and s[i + 1] == "B":
if "BA" in s[i + 2 :]:
flag = 1
break
elif s[i] == "B" and s[i + 1] == "A":
if "AB" in s[i + 2 :]:
flag = 1
break
if flag == 1:
print("YES")
else:
print... | ASSIGN VAR FUNC_CALL VAR 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 IF STRING VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING IF STRING VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER 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 = str(input())
flag = 0
for i in range(len(s) - 1):
t = s[i] + s[i + 1]
if t == "AB":
flag = 1 if "BA" in s[i + 2 :] else 0
elif t == "BA":
flag = 1 if "AB" in s[i + 2 :] else 0
if flag:
break
print("YES" if flag else "NO") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR 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 ASSIGN VAR STRING VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR STRING ASSIGN VAR STRING VAR BIN_OP VAR NUMBER NUMBER NUMBER IF 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 ... | def solve(s):
ab_s, ba_s = [], []
for i in range(len(s) - 1):
if s[i] == "A" and s[i + 1] == "B":
ab_s.append(i)
if s[i] == "B" and s[i + 1] == "A":
ba_s.append(i)
lab, lba = len(ab_s), len(ba_s)
if lab > 0 and lba > 0:
left, right = 0, 0
while lef... | FUNC_DEF ASSIGN VAR VAR LIST 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 VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR 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 ... | a = input()
x = "AB"
y = "BA"
first = -1
last = -1
second = -1
second_last = -1
for i in range(0, len(a) - 1):
if a[i : i + 2] == x and first == -1:
first = i
if a[i : i + 2] == y and second == -1:
second = i
for j in range(len(a), 0, -1):
if a[j - 1 : j + 1] == y and last == -1:
las... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER 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 BIN_OP VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR IF VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR FOR 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()
ok = "NO"
i1 = -1
i2 = -1
j1 = -1
j2 = -1
for i in range(len(s) - 1):
if s[i] == "A" and s[i + 1] == "B":
if i1 == -1:
i1 = i
i2 = i
if s[i] == "B" and s[i + 1] == "A":
if j1 == -1:
j1 = i
j2 = i
if i1 != -1 and j1 != -1:
if j2 - i1 > 1 or ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING 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 ASSIGN VAR VAR ASSIGN VAR VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING IF 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 = False
ba = False
one = False
x = s
for i in range(len(s)):
if s[i : i + 2] == "AB":
ab = True
x = s[0:i] + s[i + 2 :]
for i in range(len(x)):
if x[i : i + 2] == "BA":
ba = True
if ab and ba:
one = True
if not one:
print("NO")
else:
ab = False
ba = False
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING 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 ... | from sys import stdin
s = list(stdin.readline().rstrip())
a = 0
b = 0
c = 0
d = 0
le = len(s)
for i in range(le - 1):
if i < le - 2 and s[i] == "A" and s[i + 1] == "B" and s[i + 2] == "A":
s[i] = s[i + 1] = s[i + 2] = ""
c += 1
elif i < le - 2 and s[i] == "B" and s[i + 1] == "A" and s[i + 2] ==... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR 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()
n = len(s)
ab = []
ba = []
for i in range(n - 1):
if s[i : i + 2] == "AB":
ab.append(i)
if s[i : i + 2] == "BA":
ba.append(i)
for x in ab:
for y in ba:
if y + 1 < x or x + 1 < y:
print("YES")
exit()
print("NO") | 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 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 FOR VAR VAR FOR VAR VAR IF BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER 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 ... | s = input()
prev = s[0]
cond = False
for i in range(1, len(s)):
if prev + s[i] == "AB":
cond = "BA" in s[0 : i - 1] + " " + s[i + 1 : len(s)]
elif prev + s[i] == "BA":
cond = "AB" in s[0 : i - 1] + " " + s[i + 1 : len(s)]
prev = s[i]
if cond:
break
print(["NO", "YES"][cond]) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR STRING ASSIGN VAR STRING BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR STRING ASSIGN VAR STRING BIN_OP 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 method(a, string):
count = a.count(string)
a = a.replace(string, " ", 1)
count *= a.count(string[::-1])
return count
def find_str(a):
count = method(a, "AB")
if count:
return "YES"
else:
count = method(a, "BA")
return "YES" if count else "NO"
a = input()
print(fin... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR STRING NUMBER VAR FUNC_CALL VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR STRING IF VAR RETURN STRING ASSIGN VAR FUNC_CALL VAR VAR STRING RETURN VAR STRING 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()
ind = s.find("AB")
flag = 0
if ind > -1 and "BA" in s[ind + 2 :]:
flag = 1
ind = s.find("BA")
if ind > -1 and "AB" in s[ind + 2 :]:
flag = 1
if flag:
print("YES")
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER STRING VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER 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 ... | n = input()
ab1 = n.find("AB")
ba1 = n.find("BA", ab1 + 2)
ba2 = n.find("BA")
ab2 = n.find("AB", ba2 + 2)
if ab1 == -1 or ba1 == -1 or abs(ab1 - ba1) <= 1:
if ab2 == -1 or ba2 == -1 or abs(ab2 - ba2) <= 1:
print("NO")
else:
print("YES")
else:
print("YES") | ASSIGN VAR FUNC_CALL VAR 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 FUNC_CALL VAR BIN_OP VAR VAR NUMBER IF VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP VAR 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 ... | a = input()
n = len(a)
k = 0
l = a.find("AB")
if l >= 0:
if l + 2 == n:
k = 0
else:
b = a[l + 2 :]
if b.find("BA") >= 0:
k = k + 1
else:
k = 0
l = a.find("BA")
if k == 0 and l >= 0:
if l + 2 == n:
k = 0
else:
b = a[l + 2 :]
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER IF BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR STRING NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF 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 ... | inp = input()
i = inp.find("AB")
j = inp.find("BA")
if i == -1 or j == -1:
print("NO")
exit()
x = inp.find("BA", i + 2)
if x != -1:
print("YES")
exit()
y = inp.find("AB", j + 2)
if y != -1:
print("YES")
exit()
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 EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING 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()
n = len(s)
i = 0
if n <= 3:
print("NO")
else:
i = 0
d = []
e = []
while i < n:
if i != n - 1:
if s[i] + s[i + 1] == "AB":
d.append(i + 1)
i = i + 1
elif s[i] + s[i + 1] == "BA":
e.append(i + 1)
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST WHILE VAR VAR IF VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF 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()
AB_b = False
BA_b = False
AB = []
BA = []
def f(ind, s):
if ind > -1 and ind < len(s):
return s[ind]
return None
for i in range(len(s)):
if s[i] == "B":
if f(i - 1, s) == "A":
AB_b = True
AB.append(i - 1)
if f(i + 1, s) == "A":
BA_b... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FUNC_DEF IF VAR NUMBER VAR FUNC_CALL VAR VAR RETURN VAR VAR RETURN NONE FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF FUNC_CALL VAR BIN_OP VAR NUMBER VAR STRING ASSIGN VAR NUMBER EXPR FUNC_CALL VAR BIN_OP 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 ... | user = input()
str = " "
A = False
B = False
n = 0
if "AB" in user:
n = user.find("AB")
str = user[n + 2 :]
if "BA" in str:
A = True
if A == False and "BA" in user:
u = user.find("BA")
str = user[u + 2 :]
if "AB" in str:
B = True
if A == True:
print("YES")
elif B == True:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR BIN_OP VAR NUMBER IF STRING VAR ASSIGN VAR NUMBER IF VAR NUMBER STRING VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR BIN_OP VAR NUMBER IF STRING VAR ASSIGN 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()
matches = {"AB": [], "BA": []}
for i in range(len(s) - 1):
substring = s[i : i + 2]
if substring in matches:
matches[substring].append(i)
if not matches["AB"] or not matches["BA"]:
print("NO")
elif abs(max(matches["AB"]) - min(matches["BA"])) > 1:
print("YES")
elif abs(min(matches["A... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT STRING STRING LIST LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR VAR IF VAR STRING VAR STRING EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR STRING FUNC_CALL VAR VAR STRING 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 ... | def indices(ls, a):
ind = []
for i in range(len(ls)):
if ls[i] == a:
ind.append(i)
return ind
def match(AB, BA):
for i in AB:
for j in BA:
if abs(i - j) > 1:
return True
return False
def main():
s = list(input().rstrip())
ls = []
... | FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF FOR VAR VAR FOR VAR VAR IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST 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()
l = len(s)
count = 0
trig = []
for i in range(l - 1):
if s[i] == "A" and s[i + 1] == "B":
count = 1
m = i
trig.append(m)
if count > 0:
for i in range(l - 1):
if s[i] == "B" and s[i + 1] == "A":
for m in trig:
if i != m + 1 and i + 1 != m:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP 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()
if len(s) < 4:
print("NO")
exit(0)
k_AB = 0
k_A = 0
k_B = 0
for i in range(len(s) - 2):
if s[i] + s[i + 1] + s[i + 2] == "ABA" or s[i] + s[i + 1] + s[i + 2] == "BAB":
k_AB += 1
s = s[:i] + "000" + s[i + 3 :]
buf = i
if k_AB == 1:
s = s[:buf] + s[buf + 3 :]
if k_AB > 1... | ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING BIN_OP BIN_OP VAR VAR 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()
lenS = len(s)
i = 0
t = s[:]
if "AB" in t:
i = t.index("AB")
t = t[:i] + "CC" + t[i + 2 :]
if "BA" in t:
print("YES")
return
t = s[:]
if "BA" in t:
i = t.index("BA")
t = t[:i] + "CC" + t[i + 2 :]
if "AB" in t:
print("YES")
return
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR STRING VAR BIN_OP VAR NUMBER IF STRING VAR EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR VAR IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING 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 ... | s = input()
if "BA" not in s or "AB" not in s:
print("NO")
elif "BA" in s and "AB" in s and s.count("A") >= 2 and s.count("B") >= 2:
if "BAB" not in s and "ABA" not in s:
print("YES")
elif (
"ABA" in s
and (s.count("BA") >= 2 or s.count("AB") >= 2)
and len(s) >= 4
and... | ASSIGN VAR FUNC_CALL VAR IF STRING VAR STRING VAR EXPR FUNC_CALL VAR STRING IF STRING VAR STRING VAR FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER IF STRING VAR STRING VAR EXPR FUNC_CALL VAR STRING IF STRING VAR FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR 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 ... | def containsNonOverlappingABandBA(string):
ABp = string.find("AB")
if ABp == -1:
return False
BAp = string.find("BA")
if BAp == -1:
return False
if abs(ABp - BAp) > 1:
return True
return string.find("BA", ABp + 2) != -1 or string.find("AB", BAp + 2) != -1
print("YES" if... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER RETURN NUMBER IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER RETURN NUMBER RETURN FUNC_CALL VAR STRING BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR STRING BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL 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 ... | s = input()
n = len(s)
temp = ""
tent = ""
flag = 0
i = 0
a = []
b = []
while i < n - 1:
if s[i : i + 2] == "AB":
a.append(i)
elif s[i : i + 2] == "BA":
b.append(i)
i += 1
i = 0
while i < len(a):
for j in range(len(b)):
if a[i] != b[j] + 1 and a[i] != b[j] - 1:
print(... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST WHILE VAR BIN_OP 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 VAR 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 ... | import sys
s = input()
a1 = s.find("AB")
a2 = s.rfind("AB")
b1 = s.find("BA")
b2 = s.rfind("BA")
if a1 != -1 and a1 + 1 < b2:
print("YES")
sys.exit(0)
if b1 != -1 and b1 + 1 < a2:
print("YES")
sys.exit(0)
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 BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR STRING 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 ... | a = input()
i = 0
j = len(a) - 1
t1 = t2 = 0
while i < len(a) and j > 0:
try:
if a[i] == "A" and a[i + 1] == "B":
t1 = i, i + 1
if a[j] == "A" and a[j - 1] == "B":
t2 = j - 1, j
if t1[0] not in t2 and t1[1] not in t2:
print("YES")
break
exc... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER VAR IF 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 ... | from sys import stdin
def solve(s):
n = len(s)
gotba = False
i = 1
while i < n:
if gotba and s[i - 1] == "A" and s[i] == "B":
return "YES"
if not gotba and s[i - 1] == "B" and s[i] == "A":
i += 1
gotba = True
i += 1
gotab = False
i = ... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING VAR VAR STRING RETURN STRING IF VAR VAR BIN_OP VAR NUMBER STRING VAR VAR STRING VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR 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 ... | s = input()
i = 0
ab = False
ba = False
o = 0
while i < len(s) - 1:
if (
i < len(s) - 2
and (not o and not ab and not ba)
and (s[i : i + 2] == "AB" and s[i + 1 : i + 3] == "BA")
or s[i : i + 2] == "BA"
and s[i + 1 : i + 3] == "AB"
):
o += 1
i += 2
elif... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR VAR VAR VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER STRING VAR VAR BIN_OP VAR NUMBER 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 ... | def pos_ab(s, direction):
if direction is True:
for i in range(len(s) - 1):
if "AB" == s[i : i + 2]:
return i + 1
else:
ql = len(s) - 1
for i in range(ql):
if "AB" == s[ql - i - 1 : ql - i + 1]:
return ql - i - 1
return None
d... | FUNC_DEF IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF STRING VAR VAR BIN_OP VAR NUMBER RETURN BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF STRING VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER RETURN BIN_OP BIN_OP VAR VAR 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()
is_ab = s.find("AB") != -1
is_ba = s.find("BA", s.find("AB") + 2) != -1
if is_ab and is_ba:
print("YES")
exit()
is_ba = s.find("BA") != -1
is_ab = s.find("AB", s.find("BA") + 2) != -1
if is_ba and is_ab:
print("YES")
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR STRING BIN_OP FUNC_CALL VAR STRING NUMBER NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR STRING BIN_OP FUNC_CALL VAR STRING NUMBER NUMBER IF 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 = list(input())
s.append("0")
s.append("0")
c1, c2, c3, c4, i = 0, 0, 0, 0, 0
while i < len(s):
if s[i] == "A" and s[i + 1] == "B" and s[i + 2] == "A":
c1 += 1
i += 2
elif s[i] == "B" and s[i + 1] == "A" and s[i + 2] == "B":
c2 += 1
i += 2
elif s[i] == "B" and s[i + 1] == "... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER 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 ... | import sys
s = sys.stdin.readline()
ans = "NO"
AB = []
BA = []
for i in range(len(s) - 1):
if s[i] == "A" and s[i + 1] == "B":
AB.append(i)
if s[i] == "B" and s[i + 1] == "A":
BA.append(i)
for a in AB:
for b in BA:
if abs(a - b) >= 2:
ans = "YES"
break
print(... | IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN 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_CALL VAR VAR FOR VAR VAR FOR VAR VAR IF 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 ... | string = input()
new_str = string
ABA = string.count("ABA")
BAB = string.count("BAB")
aba = False
if ABA > 1 or BAB > 1:
print("YES")
exit()
if ABA == 1:
new_str = string.replace("ABA", "")
if "BA" in new_str or "AB" in new_str:
aba = True
if BAB == 1 or aba:
new_str = string.replace("BAB", ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING STRING IF STRING VAR STRING VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR ASSIGN VAR 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 NotOverlap(i, y, z, x):
d = set()
d.add(i)
d.add(y)
d.add(z)
d.add(x)
if len(d) == 4:
return True
return False
n = input()
A, B, BAs, ABs = 0, 0, [], []
for i in range(len(n) - 1):
if n[i] == "A" and n[i + 1] == "B":
ABs.append((i, i + 1))
elif n[i] == "B" and n... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER LIST LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR 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()
if "AB" in s and "BA" in s:
if s.count("AB") + s.count("BA") - s.count("ABA") - s.count("BAB") >= 2:
print("YES")
else:
print("NO")
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR IF STRING VAR STRING VAR IF BIN_OP BIN_OP BIN_OP FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING NUMBER 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 ... | import sys
def main():
import sys
s = sys.stdin.read().strip()
n = len(s)
result = False
flag = False
i = 0
while i < n - 1:
if not flag and s[i : i + 2] == "AB":
flag = True
i += 2
elif flag and s[i : i + 2] == "BA":
result = True
... | IMPORT FUNC_DEF IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR 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 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 ... | list1 = list(input())
pos = -1
for i in range(len(list1) - 1):
if list1[i] == "A":
if list1[i + 1] == "B":
pos = i
break
if pos == -1:
print("NO")
else:
k = 0
for i in range(pos + 2, len(list1) - 1):
if list1[i] == "B":
if list1[i + 1] == "A":
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR 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 ... | s = input()
n = len(s)
i = 0
pab = 0
pba = 0
flag = 0
while i < n:
if s[i] == "A" and (pab == 0 or flag == 1):
if i + 1 < n and s[i + 1] == "B":
pab = 1
if flag == 1:
pba = 1
break
if i + 2 < n and s[i + 2] == "A":
flag = 1
... | 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 VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER 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().strip()
ls = len(s)
flags = [0, 0]
i = 0
d = dict()
while i < ls - 1:
if s[i : i + 2] == "AB":
if "AB" in d:
d["AB"] += [i]
else:
d["AB"] = [i]
elif s[i : i + 2] == "BA":
if "BA" in d:
d["BA"] += [i]
else:
d["BA"] = [i]
... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR WHILE VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING IF STRING VAR VAR STRING LIST VAR ASSIGN VAR STRING LIST VAR IF VAR VAR BIN_OP VAR NUMBER STRING IF STRING VAR 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 ... | s = input()
cA, cB, cABA, cBAB = 0, 0, 0, 0
for i in range(len(s) - 1):
if s[i] == "A" and s[i + 1] == "B":
cA += 1
if s[i] == "B" and s[i + 1] == "A":
cB += 1
for i in range(len(s) - 2):
if s[i] == "A" and s[i + 1] == "B" and s[i + 2] == "A":
cABA += 1
if s[i] == "B" and s[i + 1... | ASSIGN VAR FUNC_CALL VAR 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 STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR 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()
n = len(s)
aba = 0
ab = 0
ba = 0
bab = 0
i = 0
while i < n:
if i < n - 2 and s[i] == "A" and s[i + 1] == "B" and s[i + 2] == "A":
aba += 1
i += 3
continue
if i < n - 2 and s[i] == "B" and s[i + 1] == "A" and s[i + 2] == "B":
bab += 1
i += 3
continue
... | 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 VAR IF VAR BIN_OP VAR NUMBER VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR 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() + "**"
n = len(s) - 3
if n < 1:
print("NO")
else:
for i in range(1, n):
if s[i : i + 2] == "AB":
c = 0
for j in range(i + 2, n):
if s[j : j + 2] == "BA":
c = 1
break
if c == 1:
p... | ASSIGN VAR BIN_OP BIN_OP STRING FUNC_CALL VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR BIN_OP VAR NUMBER STRING 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()
maxAB = -1
minAB = -1
maxBA = -1
minBA = -1
for i in range(len(s) - 1):
if s[i] + s[i + 1] == "AB":
if minAB == -1:
minAB = i
maxAB = i
if s[i] + s[i + 1] == "BA":
if minBA == -1:
minBA = i
maxBA = i
if (abs(maxAB - minBA) > 1 or abs(maxBA - mi... | 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 BIN_OP VAR VAR VAR BIN_OP VAR NUMBER STRING IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER STRING IF VAR NUMBER ASSIGN VAR 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 ... | s = input()
abmin = s.find("AB")
abmax = s.rfind("AB")
bamin = s.find("BA")
bamax = s.rfind("BA")
if min(abmin, bamin) == -1:
print("NO")
else:
z1 = abs(abmin - bamin)
z2 = abs(abmin - bamax)
z3 = abs(abmax - bamin)
z4 = abs(abmax - bamax)
if max(z1, z2, z3, z4) > 1:
print("YES")
els... | 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 FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN 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()
a1 = 0
a2 = 0
b1 = []
b2 = []
for i in range(1, len(s)):
if s[i] == "B" and s[i - 1] == "A":
a1 += 1
b1.append(i - 1)
b1.append(i)
if s[i] == "A" and s[i - 1] == "B":
a2 += 1
b2.append(i - 1)
b2.append(i)
if a1 == 0 or a2 == 0:
print("NO")
elif a1 ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING 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()
t = 0
f = 0
i = 0
while i < len(s) and t < 2:
if s[i : i + 3] == "ABA" or s[i : i + 3] == "BAB":
f = 0
t += 1
i += 2
elif (f == 1 or f == 0) and s[i : i + 2] == "AB":
f = 2
t += 1
i += 1
elif (f == 2 or f == 0) and s[i : i + 2] == "BA":
f =... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER 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 ... | def func(s, pat1, pat2):
if len(s) < 4:
return False
i1 = s.find(pat1)
i2 = s.rfind(pat2)
if i1 == -1 or i2 == -1:
return False
if max(i1 - i2, i2 - i1) > 1:
return True
return False
s = input()
if func(s, "AB", "BA") or func(s, "BA", "AB"):
print("YES")
else:
p... | FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER RETURN NUMBER IF FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR STRING STRING FUNC_CALL VAR 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 ... | import sys
s = input()
i = 0
while i < len(s) - 1:
if s[i : i + 2] == "AB":
i += 2
while i < len(s) - 1:
if s[i : i + 2] == "BA":
print("YES")
sys.exit()
i += 1
i += 1
i = 0
while i < len(s) - 1:
if s[i : i + 2] == "BA":
i += 2... | IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP 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 ... | q = input()
y = len(q)
r, t = -1, -1
l = 0
h = 0
for i in range(y - 1):
if q[i] + q[i + 1] == "AB":
r = i
elif q[i] + q[i + 1] == "BA":
t = i
if r == -1 or t == -1:
print("NO")
else:
for i in range(r - 1):
if q[i] + q[i + 1] == "BA":
l = 1
for i in range(r + 2, y ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER 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 ... | s = input()
ab = []
flag = False
ab = False
ba = False
i = 0
while i < len(s) - 1:
if i < len(s) - 2 and s[i : i + 3] in ("ABA", "BAB"):
if flag:
print("YES")
break
flag = True
i += 3
if ab + ba + flag >= 2:
print("YES")
break
c... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR BIN_OP VAR NUMBER STRING STRING IF VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER VAR NUMBER IF BIN_OP BIN_OP VAR VAR... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.