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() def isPresent(s, t): k = s.find(t) if k == -1: return False if s[:k].find(t[::-1]) == -1 and s[k + 2 :].find(t[::-1]) == -1: return False return True if isPresent(s, "AB") or isPresent(s, "BA"): print("YES") else: print("NO")
ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER RETURN NUMBER IF FUNC_CALL VAR VAR VAR NUMBER NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER NUMBER RETURN NUMBER RETURN NUMBER IF FUNC_CALL VAR VAR STRING FUNC_CALL VAR 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() s_len = len(s) result = "NO" ab = None ba = None ab2 = None ba2 = None for i in range(s_len - 1): if s[i] == "A" and s[i + 1] == "B" and ab is None: ab = i + i + 1 if s[i] == "B" and s[i + 1] == "A": ba = i + i + 1 if ab and abs(ab - ba) >= 4: result = "YES" ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR NONE ASSIGN VAR NONE ASSIGN VAR NONE ASSIGN VAR NONE FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NONE ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR STRING 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 ...
s = input() u = s.find("AB") v = s.find("BA") if u + 1 and s.find("BA", u + 2) != -1: print("YES") elif v + 1 and s.find("AB", v + 2) != -1: print("YES") else: print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER FUNC_CALL VAR STRING BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER FUNC_CALL VAR STRING BIN_OP VAR NUMBER 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 ...
from sys import stdin, stdout nmbr = lambda: int(stdin.readline()) lst = lambda: list(map(int, stdin.readline().split())) for _ in range(1): s = input() n = len(s) if s.count("A") <= 1 or s.count("B") <= 1: print("NO") continue aba = bab = ab = ba = 0 p = 0 while p < n: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR VAR VAR NUMBER ASSIGN 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 ...
prevc = "" firstab = firstba = i = 0 for c in input(): i += 1 if prevc == "A" and c == "B": if firstab == 0: firstab = i if firstba and i - firstba > 1: print("YES") exit() elif prevc == "B" and c == "A": if firstba == 0: firstba = i ...
ASSIGN VAR STRING ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER IF VAR STRING VAR STRING IF VAR NUMBER ASSIGN VAR VAR IF VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF VAR STRING VAR STRING IF VAR NUMBER ASSIGN VAR VAR IF VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR F...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = str(input()) ab_ba = 0 ba_ab = 0 i = 0 n = len(s) while i < n - 1: if s[i] + s[i + 1] == "AB": if ab_ba == 0: ab_ba = 1 i += 2 continue if s[i] + s[i + 1] == "BA": if ab_ba == 1: ab_ba = 2 i += 2 continue i += 1 i = ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER STRING IF VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER STRING IF VAR NUMBER ASSIGN VAR NUMBER 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() k1 = 0 k2 = 0 n = len(S) c = 0 p = 0 for i in range(n - 2): if S[i] == "A" and S[i + 1] == "B" and S[i + 2] != "A": k1 = 1 p = i + 2 break if S[i] == "B" and S[i + 1] == "A" and S[i + 2] != "B": k2 = 1 p = i + 2 break if S[i] == "B" and S[i + 1] ==...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER 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 VAR BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR 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 ...
from sys import stdout def main(): from sys import stdout s = input() + "X" pure_AB = 0 pure_BA = 0 mixed = 0 i = 0 while i < len(s) - 1: substring = s[i - 1] + s[i] if substring == "AB": if s[i + 1] == "A": mixed += 1 i += 3 ...
FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR IF VAR STRING IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR STRING IF 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() flag1 = False flag2 = False s2 = "" i = 0 while i < len(s): if i + 1 < len(s) and s[i] == "A" and s[i + 1] == "B" and flag1 == False: flag1 = True i += 1 s2 = s2 + ".." else: s2 = s2 + s[i] i += 1 if flag1: if "BA" in s2: flag2 = True if flag1 and flag...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP VAR VAR 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 ...
def fun(s): x = s.find("AB") y = s.find("BA") if x == -1 or y == -1: return "NO" if x > 1 and s[0 : x - 1].find("BA") != -1 or s[x + 2 :].find("BA") != -1: return "YES" if y > 1 and s[0 : y - 1].find("AB") != -1 or s[y + 2 :].find("AB") != -1: return "YES" return "NO" s...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER RETURN STRING IF VAR NUMBER FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER STRING NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER STRING NUMBER RETURN STRING IF VAR NUMBER FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER STRING NUMBER 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() n = len(s) a = s.find("AB") b = s.find("BA") c = s.rfind("AB") d = s.rfind("BA") if a == -1 or b == -1: print("NO") elif abs(a - b) >= 2 or abs(a - d) >= 2 or abs(b - c) >= 2 or abs(c - d) >= 2: print("YES") else: print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR 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 FUNC_CALL VAR BIN_OP VAR VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR NUMBER 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 ...
def substrings(s): if "AB" not in s or "BA" not in s: return "NO" x = s.replace("AB", "X", 1) if "BA" in x: return "YES" y = s.replace("BA", "X", 1) if "AB" in y: return "YES" return "NO" s = input() print(substrings(s))
FUNC_DEF IF STRING VAR STRING VAR RETURN STRING ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER IF STRING VAR RETURN STRING ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER IF STRING VAR 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 ...
i = input() t = 0 for j in range(len(i) - 1): if i[j] + i[j + 1] == "AB": if j + 2 < len(i): if "BA" in i[j + 2 :]: print("YES") t = 1 break if t == 0: for j in range(len(i) - 1): if i[j] + i[j + 1] == "BA": if j + 2 < len(i...
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 BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF STRING VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP 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 ...
def solve(s, s1, s2): pos = s.find(s1) if pos == -1: return False pos = s.find(s2, pos + 2) if pos == -1: return False else: return True s = input() if solve(s, "AB", "BA") or solve(s, "BA", "AB"): print("YES") else: print("NO")
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN 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 ...
s = input() iab = -1 iba = -1 for i in range(len(s) - 1): if s[i : i + 2] == "AB": if iab == -1: iab = i if iba != -1 and abs(i - iba) > 1: print("YES") break elif s[i : i + 2] == "BA": if iba == -1: iba = i if iab != -1 and abs(i -...
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 BIN_OP VAR NUMBER STRING IF VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR VAR BIN_OP VAR NUMBER STRING IF VAR NUMBER 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 ...
s = input() n = len(s) ab, ba, anyp = False, False, 0 i = 0 while i < n: if i + 2 < n and (s[i : i + 3] == "ABA" or s[i : i + 3] == "BAB"): anyp += 1 i += 3 elif i + 1 < n and s[i : i + 2] == "AB": ab = True i += 2 elif i + 1 < n and s[i : i + 2] == "BA": ba = True ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER STRING VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER 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 ...
c = str(input()) n = len(c) x = [i for i in range(n - 1) if c[i : i + 2] == "AB"] y = [i for i in range(n - 1) if c[i : i + 2] == "BA"] if x and y and (x[0] < y[-1] - 1 or y[0] < x[-1] - 1): print("YES") else: print("NO")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER STRING IF VAR VAR VAR NUMBER BIN_OP VAR NUMBER NUMBER VAR NUMBER BIN_OP VAR NUMBER 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 ...
st = input() s1 = st.replace("AB", "0", 1) s1 = s1.replace("BA", "1", 1) s2 = st.replace("BA", "1", 1) s2 = s2.replace("AB", "0", 1) if "0" in s1 and "1" in s1 or "0" in s2 and "1" in s2: print("YES") else: print("NO")
ASSIGN VAR FUNC_CALL 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 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() yes = False if "AB" in s: i = s.index("AB") n = s[:i] + " " + s[i + 2 :] if n.count("BA") > 0: yes = True if "BA" in s: i = s.index("BA") n = s[:i] + " " + s[i + 2 :] if n.count("AB") > 0: yes = True if yes: print("YES") else: print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR STRING VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR STRING NUMBER ASSIGN VAR NUMBER IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR STRING VAR BIN_OP VAR NUMBER IF 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() yes = False try: ab = s.index("AB") ba = s.rindex("BA") if ba - ab > 1: yes = True ab = s.index("BA") ba = s.rindex("AB") if ba - ab > 1: yes = True except ValueError: pass print("YES" if yes else "NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER 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() r1 = s.find("AB") r2 = s.rfind("BA") r3 = s.find("BA") r4 = s.rfind("AB") if r1 == -1 and r4 == -1 or r2 == -1 and r3 == -1: print("NO") elif abs(r4 - r3) > 1 or abs(r1 - r2) > 1: print("YES") else: print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR ...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() ab = [] for i in range(len(s) - 1): if s[i] == "A" and s[i + 1] == "B": ab += [i] n = len(ab) if n > 0: for i in range(len(s) - 1): if s[i] == "B" and s[i + 1] == "A": if n == 1 and abs(ab[0] - i) == 1: continue elif n == 2 and abs(ab[0] - ab[1...
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 VAR LIST VAR ASSIGN VAR FUNC_CALL VAR VAR IF 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 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() a = [] b = [] for i in range(len(s) - 1): if s[i] == "A" and s[i + 1] == "B": a.append(i) if s[i] == "B" and s[i + 1] == "A": b.append(i) if a and b and len(a) + len(b) >= 4: print("YES") elif a and b and len(a) + len(b) == 3: if "ABAB" in s: print("NO") elif "BAB...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR 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 ...
def isValid(i): c1 = s[i] c2 = s[i - 1] c3 = s[i - 2] dp_AB[i] = dp_AB[i - 1] dp_BA[i] = dp_BA[i - 1] if c1 == "A": if c2 == "B": if c3 == "A": if dp_AB[i - 3] or dp_BA[i - 3]: return True else: dp_AB[i],...
FUNC_DEF ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER IF VAR STRING IF VAR STRING IF VAR STRING IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER RETURN NUMBER ASSIGN VAR VAR VAR VAR NUMBER NUMBER IF 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 ...
def check(string): string = string.upper() if ( "AB" in string and "BA" in string.replace("AB", "-", 1) or "BA" in string and "AB" in string.replace("BA", "-", 1) ): return "YES" else: return "NO" print(check(input()))
FUNC_DEF ASSIGN VAR FUNC_CALL VAR IF STRING VAR STRING FUNC_CALL VAR STRING STRING NUMBER STRING VAR STRING FUNC_CALL VAR STRING STRING NUMBER RETURN STRING RETURN STRING EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = str(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) if len(ab) > 0 and len(ba) > 0: check1 = 0 check2 = 0 i = ab[0] j = ba[0] for x in ba: if x > i + 1: check1 = 1 ...
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 EXPR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER 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 ...
string = input() s = -1 ans = "NO" if len(string) < 2: print("NO") else: for i in range(len(string) - 1): if string[i : i + 2] == "AB": break for j in range(i + 2, len(string) - 1): if string[j : j + 2] == "BA": ans = "YES" for i in range(len(string) - 1): ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR STRING 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 FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING ASSIGN ...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
import sys sys.setrecursionlimit(10**5) readline = sys.stdin.readline def process(): s = readline().strip() a = s.find("AB") if a != -1 and s[a + 2 :].find("BA") != -1: print("YES") return a = s.find("BA") if a != -1 and s[a + 2 :].find("AB") != -1: print("YES") re...
IMPORT EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER STRING NUMBER EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER STRING NUMB...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() l = len(s) lba = [] lab = [] for i in range(l - 1): if s[i : i + 2] == "BA": lba.append(i) if s[i : i + 2] == "AB": lab.append(i) if len(lab) == 0 or len(lba) == 0: print("NO") elif ( abs(lba[0] - lab[-1]) >= 2 or abs(lba[0] - lab[0]) >= 2 or abs(lba[-1] - lab[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 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 FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR 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 ...
s = input() a1 = s.find("AB") a2 = s.find("BA") a3 = s[a1 + 2 :].find("BA") a4 = s[a2 + 2 :].find("AB") if a1 >= 0 and a3 >= 0 or a2 >= 0 and a4 >= 0: print("YES") else: print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER STRING IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
def getInts(): return [int(s) for s in input().split()] def getInt(): return int(input()) def getStrs(): return [s for s in input().split()] def getStr(): return input() def listStr(): return list(input()) def solve(): S = getStr() AB, BA = [], [] for j in range(len(S) - 1): ...
FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() flag = 0 if s.find("AB") >= 0: temp = s.find("AB") if s.find("BA", temp + 2) >= 0: flag = 1 if s.find("BA") >= 0: temp = s.find("BA") if s.find("AB", temp + 2) >= 0: flag = 1 if flag == 1: print("YES") else: print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF FUNC_CALL VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF FUNC_CALL VAR STRING BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF FUNC_CALL VAR STRING BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR NUMBER 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() i = 0 flag = 0 while i < len(s): if s[i : i + 2] == "AB": if "BA" in s[i + 2 :]: print("YES") flag = 1 break elif s[i : i + 2] == "BA": if "AB" in s[i + 2 :]: print("YES") flag = 1 break i += 1 if flag == 0: ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING IF STRING VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING IF STRING VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER 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 ...
__author__ = "Bian" st = input() ab1 = st.find("AB") ba1 = st.find("BA", ab1 + 2) ba2 = st.find("BA") ab2 = st.find("AB", ba2 + 2) if ab1 != -1 and ba1 != -1 or ab2 != -1 and ba2 != -1: print("YES") else: print("NO")
ASSIGN VAR STRING 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 VAR NUMBER 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() if S.count("AB") == 0 or S.count("BA") == 0: print("NO") elif S[S.index("AB") + 2 :].count("BA") > 0 or S[S.index("BA") + 2 :].count("AB") > 0: print("YES") else: print("NO")
ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR BIN_OP FUNC_CALL VAR STRING NUMBER STRING NUMBER FUNC_CALL VAR BIN_OP FUNC_CALL VAR STRING NUMBER STRING NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = list(input()) found1 = False found2 = False ABA = False for i in range(len(s) - 2): if ( s[i] == "A" and s[i + 2] == "A" and s[i + 1] == "B" or s[i] == "B" and s[i + 2] == "B" and s[i + 1] == "A" ): ABA = True s.pop(i) s.pop(i) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING ASSIGN 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 = str(input()) ab = len(s) ba = 0 for i in range(len(s) - 1): if s[i] == "A" and s[i + 1] == "B": ab = i break for i in range(len(s) - 2, -1, -1): if s[i] == "B" and s[i + 1] == "A": ba = i break if ba > ab + 1: print("YES") exit() ab = 0 ba = len(s) for i in range(len(...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR 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 ASS...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----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() lastone = "" a = [] b = [] conse = "a" for i in range(len(string) - 1): if string[i] + string[i + 1] == "AB": a.append(i) elif string[i] + string[i + 1] == "BA": b.append(i) if not a or not b: print("NO") elif abs(max(a) - min(b)) >= 2 or abs(max(b) - min(a)) >= 2: print...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR STRING FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF VAR VAR EXPR 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 comprobar(cadena, tam): if tam <= 3: return "NO" k = 0 for i in range(tam - 2): if cadena[i] == "A" and cadena[i + 1] == "B": k = i + 2 break if k != 0: for j in range(k, tam - 1): if cadena[j] == "B" and cadena[j + 1] == "A": ...
FUNC_DEF IF VAR NUMBER RETURN STRING 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 IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING RETURN STRING ASSIGN VAR NUMBER 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 ...
def simplify(seq): new_seq = [] for i in range(len(seq) - 1): if seq[i] == "A" or seq[i] == "B": new_seq.append(seq[i]) elif seq[i + 1] == "A" or seq[i + 1] == "B": new_seq.append(seq[i]) else: continue new_seq.append(seq[-1]) return "".join(ne...
FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR VAR STRING EXPR FUNC_CALL VAR VAR VAR IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER RETURN FUNC_CALL STRING VAR FUNC_DEF IF STRING VAR STRING VAR 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 ...
s = input() m = [] n = [] for i in range(len(s) - 1): if s[i] == "A" and s[i + 1] == "B": m.append(i) if s[i] == "B" and s[i + 1] == "A": n.append(i) if min(len(m), len(n)) == 0: print("NO") elif max(len(m), len(n)) > 2: print("YES") elif len(m) == 2 and len(n) == 2: print("YES") eli...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR 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 ...
a = input() def valid(s, x, y): try: s.index(x) s = s.replace(x, "*", 1) s.index(y) s = s.replace(y, "*", 1) return True except: return False print(("NO", "YES")[valid(a, "AB", "BA") or valid(a, "BA", "AB")])
ASSIGN VAR FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR STRING NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR STRING NUMBER RETURN NUMBER RETURN NUMBER EXPR FUNC_CALL VAR STRING STRING FUNC_CALL VAR VAR STRING STRING 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() f = 0 n = len(s) ind = n for i in range(n - 1): if s[i] == "A" and s[i + 1] == "B": ind = i + 2 break for i in range(ind, n - 1): if s[i] == "B" and s[i + 1] == "A": f = 1 break ind = n for i in range(n - 1): if s[i] == "B" and s[i + 1] == "A": ind = i + 2...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER 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 ...
def sol(): s = input().strip() ab = s.find("AB") ba = s.find("BA") if ab < 0 or ba < 0: return False if abs(ba - ab) < 2: first = min(ab, ba) second = max(ab, ba) toFind = "BA" if ab == first else "AB" if s.find(toFind, first + 2) > 0: return True ...
FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER RETURN NUMBER IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR STRING STRING IF FUNC_CALL VAR 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 ...
s = input() ab, ba = [], [] for i in range(len(s) - 1): if s[i : i + 2] == "AB": ab.append(i) elif s[i : i + 2] == "BA": ba.append(i) for u in ab: for v in ba: if abs(u - v) > 1: print("YES") exit() print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR FOR VAR VAR FOR VAR VAR IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER 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 ...
s = input() x = s.count("AB") y = s.count("BA") a1 = s.count("ABA") a2 = s.count("BAB") a3 = s.count("ABAB") a4 = s.count("BABA") f = 0 if a3 > 0: if x > 2 or y > 1: print("YES") exit() elif a4 > 0: if y > 2 or x > 1: print("YES") exit() elif a1 > 0 or a2 > 0: if x > 1 or y >...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR I...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() L = len(s) if L > 3: if "ABABA" in s or "BABAB" in s: print("YES") elif "ABA" in s: b = s.index("ABA") s = s[0:b] + s[b + 3 :] if "AB" in s or "BA" in s: print("YES") else: print("NO") elif "BAB" in s: b = s.index("BAB") ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER IF STRING VAR STRING VAR EXPR FUNC_CALL VAR STRING IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER IF STRING VAR STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF STRING 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() s2 = s i = s.find("AB") nfound = 1 if i != -1: s = s[:i] + "F" + s[i + 2 :] if s.find("BA") != -1: print("YES") exit() i = s2.find("BA") if i != -1: s2 = s2[:i] + "f" + s2[i + 2 :] if s2.find("AB") != -1: print("YES") exit() if nfound: print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR STRING VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP 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() abH, abT = s.find("AB"), s.rfind("AB") baH, baT = s.find("BA"), s.rfind("BA") flag = ( abH >= 0 and baT >= 0 and baT - abH > 1 or abT >= 0 and baH >= 0 and abT - baH > 1 ) print("YES" if flag else "NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER VAR NUMBER BIN_OP VAR VAR NUMBER VAR NUMBER VAR NUMBER BIN_OP VAR 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() if s.find("AB") == -1 or s.find("BA") == -1: print("NO") exit() def func(a, b): idx = s.find(a) if s[idx + 2 :].find(b) != -1: return True if func("AB", "BA") or func("BA", "AB"): print("YES") else: print("NO")
ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER RETURN NUMBER IF FUNC_CALL VAR STRING STRING FUNC_CALL VAR STRING STRING EXPR FUNC_CALL VAR STRING EXPR FUN...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() x = len(s) i = 0 t = "" l = "" done = 0 a = -1 b = -1 while i < x - 1: if s[i] == "A": if s[i + 1] == "B": if b != i: if len(l) != 0: if l[0] == "B" and l[1] == "A": done = 1 break if len(...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING 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 VAR VAR IF FUNC_CALL VAR VAR NUMBER IF VAR NUMBER STRING VAR NUMBER STRING 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() first = s.find("AB") second = s.find("BA", first + 2) if first == -1 or second == -1: first = s.find("BA") second = s.find("AB", first + 2) if first == -1 or second == -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 IF VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING BIN_OP VAR NUMBER IF VAR NUMBER 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 ...
k = input() a, b, c, i = 0, 0, 0, 0 while i < len(k): if k[i : i + 3] == "ABA" or k[i : i + 3] == "BAB": a = a + 1 i = i + 3 elif k[i : i + 2] == "AB": b = b + 1 i = i + 2 elif k[i : i + 2] == "BA": c = c + 1 i = i + 2 else: i = i + 1 if a > 1 or a...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN 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 ...
while True: try: s = input().strip() if s == "": break idx_AB = [] idx_BA = [] for i in range(len(s)): if s[i : i + 2] == "AB": idx_AB.append(i) if s[i : i + 2] == "BA": idx_BA.append(i) flag = False ...
WHILE NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR FOR VAR VAR IF FUNC_CALL 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 ...
def solve(s): starts_count = 0 for i in range(len(s)): if i + 1 < len(s) and s[i] == "A" and s[i + 1] == "B": starts_count += 1 for i in range(len(s)): kill_count = 0 if i + 1 < len(s) and s[i] == "B" and s[i + 1] == "A": if i - 1 >= 0 and s[i - 1] == "A": ...
FUNC_DEF 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 VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR VAR STRING VAR BIN_OP VAR NUMBER STRING IF 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 ...
n = input() if "AB" not in n or "BA" not in n: print("NO") elif n.count("AB") + n.count("BA") - n.count("BAB") - n.count("ABA") > 1: print("YES") else: print("NO")
ASSIGN VAR FUNC_CALL VAR IF STRING VAR STRING VAR EXPR FUNC_CALL VAR STRING 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 ...
s = str(input()) if "AB" in s and "BA" in s: s1 = s.replace("AB", "__", 1) if "BA" in s1: ans1 = 1 else: ans1 = 0 s2 = s.replace("BA", "__", 1) if "AB" in s2: ans2 = 1 else: ans2 = 0 if ans1 == 1 or ans2 == 1: print("YES") else: print("NO")...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF STRING VAR STRING VAR ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER IF STRING VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER IF STRING VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER 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 ...
def f(s): ab, ba = 0, 0 last_ab, last_ba = -1, -1 n = len(s) for i in range(n): if s[i] == "B" and (i > 0 and s[i - 1] == "A"): j = i - 1 ab += 1 if ba > 1 or last_ba >= 0 and last_ba != j - 1: return "YES" last_ab = j if s[...
FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER RETURN STRING ASSIGN VAR VAR IF VAR VAR STRING 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 ...
str = input() pos = str.find("AB") flag = False if pos != -1: if pos != 0: mystr = str[0 : pos - 1 : 1] + str[pos + 2 : len(str) : 1] else: mystr = str[pos + 2 : len(str) : 1] pos = mystr.find("BA") if pos != -1: flag = True else: flag = False else: flag = False i...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN 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() x, y = s, s var = 0 if "AB" in x: l = x.index("AB") if "BA" in x[:l] or "BA" in x[l + 2 :]: var = 1 if var == 1: print("YES") else: if "BA" in y: l = y.index("BA") if "AB" in y[:l] or "AB" in y[l + 2 :]: var = 1 if var == 1: print("YES") el...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING IF STRING VAR VAR STRING VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING IF STRING VAR VAR STRING VAR BIN_OP 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 ...
def ham(a, b): if a[1] == b[0] or b[1] == a[0]: return 0 return 1 a = input() ab = [] ba = [] for i in range(len(a) - 1): if a[i : i + 2] == "AB": ab.append([i, i + 1]) if a[i : i + 2] == "BA": ba.append([i, i + 1]) s = 0 for i in range(len(ab)): for l in range(len(ba)): ...
FUNC_DEF IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR LIST VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FU...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() a1, a2 = s.find("AB"), s.rfind("AB") b1, b2 = s.find("BA"), s.rfind("BA") if abs(a1 - b1) < 2 and abs(a1 - b2) < 2 and abs(a2 - b1) < 2 or min(a1, b1) == -1: print("NO") else: print("YES")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR NUMBER FUNC_CALL VAR VAR 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() if ( a.find("AB") >= 0 and a[a.find("AB") + 2 :].find("BA") >= 0 or a.find("BA") >= 0 and a[a.find("BA") + 2 :].find("AB") >= 0 ): print("Yes") else: print("No")
ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR BIN_OP FUNC_CALL VAR STRING NUMBER STRING NUMBER FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR BIN_OP FUNC_CALL VAR STRING NUMBER STRING NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() x = 0 i = 0 while i < len(s) - 1: if i < len(s) - 2 and s[i] == "A" and s[i + 1] == "B" and s[i + 2] == "A": x = 1 break elif i < len(s) - 2 and s[i] == "B" and s[i + 1] == "A" and s[i + 2] == "B": x = 1 break elif s[i] == "A" and s[i + 1] == "B": x = 2 ...
ASSIGN VAR FUNC_CALL VAR 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 STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR STRING VAR BIN_OP VAR NUMBER 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 ...
inp = input().strip() if len(inp) < 4: print("NO") elif inp.count("AB") == 1 and inp.count("BA") == 1: if inp.count("ABA") + inp.count("BAB") >= 1: print("NO") else: print("YES") elif inp.count("AB") < 1 or inp.count("BA") < 1: print("NO") elif ( inp.count("AB") + inp.count("BA") == ...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER IF BIN_OP FUNC_CALL VAR STRING FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER 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() x = s.find("AB") if x == -1: print("NO") else: k = s.replace("AB", "l", 1) y = k.find("BA") if y == -1: x = s.find("BA") if x == -1: print("NO") else: k = s.replace("BA", "l", 1) y = k.find("AB") if y == -1: ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER ASSIGN VAR 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 ...
a = input() ind1 = a.find("AB") ind2 = a.find("BA") ind3 = a.rfind("BA") ind4 = a.rfind("AB") sz = min(ind1 + 2, ind3 + 2) - max(ind1, ind3) sz2 = min(ind2 + 2, ind4 + 2) - max(ind2, ind4) if (sz <= 0 or sz2 <= 0) and ind1 != -1 and ind2 != -1: print("YES") else: print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP 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 ...
str = input() ab1 = ab2 = ba1 = ba2 = -1 for i in range(1, len(str)): if str[i - 1] == "A" and str[i] == "B": if ab1 == -1: ab1 = i ab2 = i if str[i - 1] == "B" and str[i] == "A": if ba1 == -1: ba1 = i ba2 = i if ab1 == -1 or ba1 == -1 or not (ba2 - ab1 >=...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER STRING VAR VAR STRING IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR IF VAR BIN_OP VAR NUMBER STRING VAR VAR STRING IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER BIN_OP VAR ...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() n = len(s) flag = 0 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": flag = 1 print("YES") exit() break for i in range(n - 1): if s[i : i + 2] == "BA": for j in r...
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 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 ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FOR VAR FUNC_CA...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() one = -1 two = -1 for i in range(0, len(s) - 1): if s[i] == "A" and s[i + 1] == "B" and one == -1: one = i if s[i] == "B" and s[i + 1] == "A" and two == -1: two = i isTrue = False for i in range(len(s) - 1, 1, -1): if s[i - 1] == "A" and s[i] == "B" and two != -1 and i > two + 2:...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR 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 VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() n = len(s) i = 0 while i < n - 3: if s[i] == "A" and s[i + 1] == "B": i += 2 while i < n - 1: if s[i] == "B" and s[i + 1] == "A": print("YES") exit() i += 1 i += 1 i = 0 while i < n - 3: if s[i] == "B" and s[i + 1] == "A": ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER WH...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----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() y1 = x.find("AB") y2 = x.find("BA") flag = 0 if y1 >= 0: y3 = x.find("BA", y1 + 2) if y3 >= 0: flag = 1 if flag == 0 and y2 >= 0: y4 = x.find("AB", y2 + 2) if y4 >= 0: flag = 1 if flag == 1: print("YES") else: print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF 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().strip() f = False for i in range(len(s) - 1): if s[i] == "A" and s[i + 1] == "B": for j in range(i + 2, len(s) - 1): if s[j] == "B" and s[j + 1] == "A": f = True break for i in range(len(s) - 1): if s[i] == "B" and s[i + 1] == "A": for j in range(i...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR 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 FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL 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 ...
def reverse(a): return a[::-1] def find_all(str, sub): start = 0 a = [] while start < len(str): d = str.find(sub, start) if not d == -1: a.append(d) start = d + len(sub) else: break if len(a) == 3: break return a def...
FUNC_DEF RETURN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR W...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
fl = lambda a: s.find(a) fr = lambda a: s.rfind(a) f = lambda l, r: r - l > 1 and l >= 0 and r >= 0 x, y = "AB", "BA" s = input() print("YES" if f(fl(x), fr(y)) or f(fl(y), fr(x)) else "NO")
ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR STRING STRING ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR 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() ans = [] gans = [] for i in range(len(s) - 1): if s[i] == "A": if s[i + 1] == "B": ans.append(i) if s[i] == "B": if s[i + 1] == "A": gans.append(i) if min(len(ans), len(gans)) == 0: print("NO") exit() if abs(gans[-1] - ans[0]) > 1 or abs(gans[0] - ans[...
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 IF VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER 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() da = {} db = {} for i in range(len(s) - 1): if s[i] + s[i + 1] == "AB": da[i] = 1 if s[i] + s[i + 1] == "BA": db[i] = 1 if len(da) == len(db) == 1: for x in da: for y in db: if abs(x - y) > 1: print("YES") else: prin...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT 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 VAR NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER FOR VAR VAR FOR VAR VAR I...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
def find_str(a): temp = a count = a.count("AB") a = a.replace("AB", " ", 1) count *= a.count("BA") if count: return "YES" if count else "NO" else: count = temp.count("BA") temp = temp.replace("BA", " ", 1) count *= temp.count("AB") return "YES" if count el...
FUNC_DEF ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER VAR FUNC_CALL VAR STRING IF VAR RETURN VAR STRING STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER VAR FUNC_CALL VAR STRING RETURN VAR STRING STRING ASSIGN VAR FUNC_CALL VAR EXPR FUN...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() a = False b = False i = 0 while i < len(s) - 1: if not a and s[i : i + 2] == "AB": a = True i += 2 elif not b and s[i : i + 2] == "BA": b = True i += 2 else: i += 1 if a and b: break if a and b: print("YES") else: i = 0 a = False ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR 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 IF VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING 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() q = 0 t = s.find("AB") if t != -1 and t <= len(s) - 4 and s.find("BA", t + 2) != -1: q = 1 t = s.find("BA") if t != -1 and t <= len(s) - 4 and s.find("AB", t + 2) != -1: q = 1 if q == 1: print("YES") else: print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR STRING BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR STRING BIN_OP VAR NUMBER NUMBER ASS...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----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_by_ab(ab_ba, w1, w2): a = ab_ba.find(w1) if a != -1: ab_ba = ab_ba[a + 2 :] b = ab_ba.find(w2) if b != -1: return "YES" else: return "NO" ab_ba = input() res = find_by_ab(ab_ba, "AB", "BA") if res == "YES": print("YES") else: res = find_by_ab(ab...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER RETURN STRING RETURN STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR STRING STRING IF VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR STRING STRING IF 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() slen = len(s) if slen <= 3: print("NO") else: abCount = s.count("AB") baCount = s.count("BA") flag1 = 0 flag2 = 0 if abCount > 0 and baCount > 0: f1 = s.find("AB") x1 = s.count("BA", f1 + 2, slen) if x1 > 0: flag1 = 1 f2 = s.find("BA") ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING BIN_OP VAR NUMBER VAR IF VAR NUMBER 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 itertools import accumulate def bin_search(x, left, right, num_list): if right - left <= 1: if x <= num_list[left]: return left + 1 else: return right + 1 else: middle = (left + right) // 2 if x < num_list[middle]: return bin_search(x, l...
FUNC_DEF IF BIN_OP VAR VAR NUMBER IF VAR VAR VAR RETURN BIN_OP VAR NUMBER RETURN BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR RETURN FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR RETURN BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR IF 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() k, x = s, 1 if "AB" in s: s = s.replace("AB", " ", 1) if "BA" in s: x = 0 s = k if "BA" in s: s = s.replace("BA", " ", 1) if "AB" in s: x = 0 print("YNEOS"[x::2])
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER IF STRING VAR ASSIGN VAR NUMBER ASSIGN VAR VAR IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER IF STRING VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING VAR NUMBER
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() if "AB" in s and "BA" in s: a = s.count("AB") b = s.count("BA") x = s.count("ABA") y = s.count("BAB") if a == 1 and b == 1 and x + y == 1: print("NO") elif a == 1 and b == 2 and s.count("BABA") == 1: print("NO") elif a == 2 and b == 1 and s.count("ABAB") == 1: ...
ASSIGN VAR FUNC_CALL VAR IF STRING VAR STRING VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL V...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() if "AB" and "BA" in s: i = 0 splits = [] while i < len(s) - 1: if s[i] == "A" and s[i + 1] == "B": x = s[:i] y = s[i + 2 :] if "BA" in x or "BA" in y: print("YES") break i += 1 else: print("NO") else:...
ASSIGN VAR FUNC_CALL VAR IF STRING STRING VAR ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER IF STRING VAR STRING VAR EXPR FUNC_CALL VAR STRING VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_C...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
a = input() b = a.find("AB") c = a.find("BA") flag = 0 if b + 1 and a.find("BA", b + 2) + 1 or c + 1 and a.find("AB", c + 2) + 1: flag = 1 print("YES" if flag else "NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR STRING BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR STRING BIN_OP VAR NUMBER 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() a = [] for i in s: a.append(i) f = 0 if "AB" in s and "BA" in s: if "ABA" not in s and "BAB" not in s: f = 1 else: if "ABA" in s and "BAB" in s: m = min(s.index("ABA"), s.index("BAB")) s = s[:m] + s[m + 3 :] elif "ABA" in s: s = s[: s.i...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF STRING VAR STRING VAR IF STRING VAR STRING VAR ASSIGN VAR NUMBER IF STRING VAR STRING VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER IF STRING VAR ASSI...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----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() lab = 1000000000.0 rab = -1000000000.0 lba = 1000000000.0 rba = -1000000000.0 for i in range(len(x) - 1): if x[i : i + 2] == "AB": lab = min(lab, i) rab = max(rab, i) if x[i : i + 2] == "BA": lba = min(lba, i) rba = max(rba, i) if lab < 1000000000.0 and lba < 10000000...
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 FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR FUNC_CALL 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 ...
s = input() x = s.find("AB", 0, len(s)) if x == -1: print("NO") else: y = s.find("BA", 0, x) z = s.find("BA", x + 2, len(s)) if y != -1 or z != -1: print("YES") else: x = s.find("BA", 0, len(s)) if x == -1: print("NO") else: y = s.find("AB", 0,...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING NUMBER VAR ASSIGN VAR FUNC_CALL VAR STRING BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING NUMB...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input().strip() if s.find("AB") != -1: x = s.find("AB") t = s[x + 2 :] if t.find("BA") != -1: print("YES") exit(0) if s.find("BA") != -1: x = s.find("BA") t = s[x + 2 :] if t.find("AB") != -1: print("YES") exit(0) print("NO")
ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR BIN_OP VAR NUMBER IF 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 ...
a = input() c = a[:] k = a.find("BA") o = 0 oz = 0 if k != -1: a = a[k + 2 :] k1 = a.find("AB") if k1 != -1: o = 1 kk = c.find("AB") if kk != -1: a = c[kk + 2 :] kk1 = a.find("BA") if kk1 != -1: oz = 1 if o == 1 or oz == 1: print("YES") else: print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL V...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
da_str = input() ab = ba = concurrence = False i = 0 while i < len(da_str) - 1: a = da_str[i] b = da_str[i + 1] if a == "A" and b == "B": if i + 2 < len(da_str) and da_str[i + 2] == "A": if concurrence == True: ab = True concurrence = True i += 3 ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER IF VAR STRING VAR STRING IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER STRING IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER ASS...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----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 = lambda: sys.stdin.readline() int_arr = lambda: list(map(int, input().split())) str_arr = lambda: list(map(str, input().split())) get_str = lambda: map(str, input().split()) get_int = lambda: map(int, input().split()) get_flo = lambda: map(float, input().split()) mod = 1000000007 def solve(s): ...
IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL 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 = str(input()) temp1, temp2 = [], [] count = 0 for i in range(len(s) - 1): if s[i] == "A" and s[i + 1] == "B": temp1.append(i + i + 1) count += 1 for i in range(len(s) - 1, 0, -1): if s[i] == "A" and s[i - 1] == "B": temp2.append(i - 1 + i) count += 1 if temp1 and temp2: if...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR LIST 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 BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF 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 = -1 a1 = -1 b = -1 b1 = -1 for i in range(len(s) - 1): s1 = s[i : i + 2] if s1 == "AB": if a == -1: a = i a1 = i elif s1 == "BA": if b == -1: b = i b1 = i if a == -1 or b == -1 or abs(b1 - a) == 1 and abs(a1 - b) == 1: print("NO") el...
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 ASSIGN VAR VAR VAR BIN_OP VAR NUMBER IF VAR STRING IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR IF VAR STRING IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR 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 ...
s = input() crossing = 0 ab = 0 ba = 0 n = len(s) i = 0 while i < n - 1: if s[i : i + 2] == "AB": if s[i + 1 : i + 3] == "BA": crossing += 1 i += 3 else: ab += 1 i += 1 elif s[i : i + 2] == "BA": if s[i + 1 : i + 3] == "AB": cro...
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 VAR BIN_OP VAR NUMBER STRING IF VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER 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 = 0 AB, BA = 0, 0 ff = True dd = True over = 0 while i <= len(s) - 2: if s[i : i + 3] == "ABA" or s[i : i + 3] == "BAB": i += 3 over += 1 if s[i : i + 2] == "AB" and ff == True: i += 2 AB = 1 ff = False elif s[i : i + 2] == "BA" and dd == True: B...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER 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 ASS...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----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()) a = 99999 b = 99999 i = 0 while i < len(s) - 1: if a == 99999 or b == 99999: if s[i : i + 2] == "AB": a = i elif s[i : i + 2] == "BA": b = i elif s[i : i + 2] == "AB" and not abs(i - b) < 2: a = i elif s[i : i + 2] == "BA" and not abs(a - i) <...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING FUNC_CALL VAR BIN_OP V...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() if "AB" not in s or "BA" not in s: print("NO") exit() ab = [i for i in range(len(s) - 1) if s[i : i + 2] == "AB"] ba = [i for i in range(len(s) - 1) if s[i : i + 2] == "BA"] print(("NO", "YES")[max(max(ab) - min(ba), max(ba) - min(ab)) > 1])
ASSIGN VAR FUNC_CALL VAR IF STRING VAR STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR STRING STR...