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() k = 0 ab = -1 ba = -1 ab = s.find("AB") if ab != -1: ba = s[ab + 2 :].find("BA") if ba != -1: print("YES") else: ba = s.find("BA") if ba != -1: ab = s[ba + 2 :].find("AB") if ab != -1: print("YES") else: ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER STRING IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER STRING IF 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 ...
mystr = input() if "ABA" in mystr or "BAB" in mystr: if "ABA" in mystr and "BAB" in mystr: first = mystr.find("ABA") < mystr.find("BAB") else: first = mystr.find("ABA") >= 0 subst = "ABA" * int(first) + "BAB" * int(not first) strmod = mystr.replace(subst, "", 1) contains = "AB" in st...
ASSIGN VAR FUNC_CALL VAR IF STRING VAR STRING VAR IF STRING VAR STRING VAR ASSIGN VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING NUMBER ASSIGN VAR BIN_OP BIN_OP STRING FUNC_CALL VAR VAR BIN_OP STRING FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR STRING NUMBER ASSIGN VAR STRING VAR STRING...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() i = 0 b_ab = False b = False while i < len(s) - 1: if not b_ab: if s[i] == "A" and s[i + 1] == "B": b_ab = True i += 1 elif s[i] == "B" and s[i + 1] == "A": b = True break i += 1 i = 0 b_ba = False b1 = False while i < len(s) - 1: if not b_ba: ...
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 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER 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 ...
s = input() s = list(s) ab = [] ba = [] n = len(s) for i in range(len(s)): if i + 1 < n and s[i] == "A" and s[i + 1] == "B": ab.append(i) if i + 1 < n and s[i] == "B" and s[i + 1] == "A": ba.append(i) if len(ab) == 0 or len(ba) == 0: print("NO") elif abs(ab[0] - ba[len(ba) - 1]) > 1 or abs(a...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR VAR VAR STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR VAR VAR STRING VAR BIN_OP VAR NUMBER STRING EXPR...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
X = input() if "AB" in X: Z = X.replace("AB", "1", 1) Y = X[::-1].replace("BA", "1", 1) if "BA" in Z or "AB" in Y: print("YES") else: print("NO") else: print("NO")
ASSIGN VAR FUNC_CALL VAR IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER STRING STRING NUMBER IF STRING VAR STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() def fn(s): t1 = len(s) for i in range(t1 - 1): if s[i] == "A" and s[i + 1] == "B": t2 = s[:i] + "1" + s[i + 2 :] if "BA" in t2: return "YES" return "NO" print(fn(s))
ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL 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 BIN_OP VAR VAR STRING VAR BIN_OP VAR NUMBER IF STRING VAR 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() if s.count("AB") > 0: l = s.find("AB") t = s[:l] v = s[l + 2 :] if t.count("BA") > 0 or v.count("BA"): print("YES") elif s.count("BA") > 0: l = s.find("BA") t = s[:l] v = s[l + 2 :] if t.count("AB") > 0 or v.count("AB"): print("YES") ...
ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR VAR ASSIGN 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() f = "NO" if "AB" in s: k = s.index("AB") for i in range(k + 2, len(s) - 1): if s[i] == "B" and s[i + 1] == "A": f = "YES" break if f == "NO": for i in range(k - 1): if s[i] == "B" and s[i + 1] == "A": f = "YES" b...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING IF STRING VAR ASSIGN VAR FUNC_CALL VAR 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 STRING IF VAR STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER ...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
line = input() ab = ba = 0 for i in range(len(line) - 1): if line[i] + line[i + 1] == "AB": ab += 1 elif line[i] + line[i + 1] == "BA": ba += 1 if ab * ba == 0: print("NO") elif ab * ba == 1 and line.count("ABA") + line.count("BAB") == 1: print("NO") elif (max(ab, ba), min(ab, ba)) == (2...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR 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 VAR NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP VAR VAR NUMBER BIN_OP 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() ai = 0 bi = 0 flag1, flag2 = 0, 0 if "AB" in s: ai = s.index("AB") else: flag1 = 1 if "BA" in s: bi = s.index("BA") else: flag2 = 1 if ( (ai < s.find("BA", ai + 2) or bi < s.find("AB", bi + 2)) and flag1 == 0 and flag2 == 0 ): print("YES") else: print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR FUNC_CALL VAR STRING BIN_OP VAR NUMBER VAR FUNC_CALL VAR STRING BIN_OP VAR NUMBER 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 ...
a = str(input()) n = len(a) p = 0 r = "NO" i = 0 while i < n - 1: if a[i] == "B" and a[i + 1] == "A" and p == 1: r = "YES" if a[i] == "A" and a[i + 1] == "B" and p == 0: p = 1 i = i + 1 i = i + 1 p = 0 i = 0 while i < n - 1: if a[i] == "A" and a[i + 1] == "B" and p == 1: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR STRING IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP ...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
from sys import * s = input() if s.find("ABA") + 1: sc = s[: s.find("ABA")] + s[s.find("ABA") + 3 :] if sc.find("AB") + 1 or sc.find("BA") + 1: print("YES") exit(0) if s.find("BAB") + 1: sc = s[: s.rfind("BAB")] + s[s.rfind("BAB") + 3 :] if sc.find("AB") + 1 or sc.find("BA") + 1: ...
ASSIGN VAR FUNC_CALL VAR IF BIN_OP FUNC_CALL VAR STRING NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR STRING VAR BIN_OP FUNC_CALL VAR STRING NUMBER IF BIN_OP FUNC_CALL VAR STRING NUMBER BIN_OP FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF BIN_OP FUNC_CALL VAR STRING NUMBER ASSIGN 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 ...
s = str(input()) i = 0 flag = False if s.count("AB") != 0: h = s.index("AB") for i in range(h + 2, len(s) - 1): if s[i] + s[i + 1] == "BA": flag = True if s.count("BA") != 0: h = s.index("BA") for i in range(h + 2, len(s) - 1): if s[i] + s[i + 1] == "AB": flag = T...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR STRING NUMBER 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 ASSIGN VAR NUMBER IF FUNC_CALL VAR STRING NUMBER 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 ...
strr = input() cntab = strr.count("AB") cntba = strr.count("BA") if cntba > 1 and cntab > 1: print("YES") elif cntba == 2 and cntab == 1 and strr.find("BABA") == -1: print("YES") elif cntab == 2 and cntba == 1 and strr.find("ABAB") == -1: print("YES") elif cntba == 1 and cntab == 1 and (strr.find("ABA") == ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER 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 ...
def findAB(string): ia = string.find("AB") if ia == -1: return False else: ib = string[ia + 2 :].find("BA") return ib != -1 def findBA(string): ib = string.find("BA") if ib == -1: return False else: ia = string[ib + 2 :].find("AB") return ia != -...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER STRING RETURN VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER STRING RETURN VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CAL...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() print( ["NO", "YES"][ s.count("AB") + s.count("BA") - s.count("ABA") - s.count("BAB") > 1 and s.find("AB") >= 0 and s.find("BA") >= 0 ] )
ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR LIST STRING STRING BIN_OP BIN_OP BIN_OP FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
from sys import stdin, stdout def INI(): return int(stdin.readline()) def INL(): return [int(_) for _ in stdin.readline().split()] def INS(): return stdin.readline() def MOD(): return pow(10, 9) + 7 def OPS(ans): stdout.write(str(ans) + "\n") def OPL(ans): [stdout.write(str(_) + " ")...
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 BIN_OP FUNC_CALL VAR NUMBER NUMBER NUMBER FUNC_DEF EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR STRING FUNC_DEF EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR STRING 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() i = s.find("AB") ans = False if i >= 0: if s[i + 2 :].find("BA") >= 0: ans = True if ans: print("YES") exit(0) i = s.find("BA") if i >= 0: if s[i + 2 :].find("AB") >= 0: print("YES") else: print("NO") exit(0) print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR NUMBER STRING NUMBER ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR NUMBER STRING 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 ...
def solve(): m = [[[(False) for _ in range(2)] for _ in range(2)] for _ in range(n + 1)] for i in range(n, -1, -1): for ab in [0, 1]: for ba in [0, 1]: if i >= n - 1: m[i][ab][ba] = True if ab == ba == 1 else False else: ...
FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR LIST NUMBER NUMBER FOR VAR LIST NUMBER NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER VAR...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
st = str(input()) x = [] for i in range(len(st)): x.append(st[i : i + 2]) AB = [] BA = [] for i in range(len(x)): if x[i] == "AB": AB.append(i) elif x[i] == "BA": BA.append(i) for i in range(len(AB)): for j in range(len(BA)): if abs(AB[i] - BA[j]) > 1: print("YES") ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL 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() print( "YES" if s.find("AB") >= 0 and s[s.find("AB") + 2 :].find("BA") >= 0 or s.find("BA") >= 0 and s[s.find("BA") + 2 :].find("AB") >= 0 else "NO" )
ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR 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 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 ...
str = input() str += "NNNNNNNN" k_ab = 0 k_ba = 0 k_aba = 0 ans = "NO" i = 0 while i < len(str) - 6: if str[i] == "A": if str[i + 1] == "B": if str[i + 2] == "A": if str[i + 3] == "B": if str[i + 4] == "A": ans = "YES" ...
ASSIGN VAR FUNC_CALL VAR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING IF VAR BIN_OP VAR NUMBER STRING IF VAR BIN_OP VAR NUMBER STRING IF VAR BIN_OP VAR NUMBER STRING ASSIGN...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() x, y, m, n = -1, -1, -1, -1 x = s.find("AB") s1 = s[x + 2 :] y = s1.find("BA") m = s.find("BA") s2 = s[m + 2 :] n = s2.find("AB") if m >= 0 and n >= 0 or x >= 0 and y >= 0: print("YES") else: print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER VAR NUMBER 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 ...
inp = input() lastab = None lastba = None if "BA" not in inp or "AB" not in inp: print("NO") else: ab = inp.find("AB") ba = inp.find("BA") for i in range(min(ab, ba), len(inp)): if i < len(inp) - 2: second = inp[i + 1] third = inp[i + 2] subB = second + third ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NONE ASSIGN VAR NONE IF STRING VAR STRING VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR BIN_OP 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 ...
import sys s = input() if "AB" not in s or "BA" not in s: print("NO") sys.exit() pos = s.find("AB") if pos + 2 < len(s) and "BA" in s[pos + 2 :]: print("YES") sys.exit() pos = s.find("BA") if pos + 2 < len(s) and "AB" in s[pos + 2 :]: print("YES") sys.exit() else: print("NO")
IMPORT ASSIGN VAR FUNC_CALL VAR IF STRING VAR STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR STRING VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF BIN_OP VAR 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 ...
s = input() s1 = s s2 = s y = False if "AB" not in s and "BA" not in s: print("NO") else: if "AB" in s: s1 = s1.replace("AB", "00", 1) if "BA" in s1: y = True if "BA" in s: s2 = s2.replace("BA", "00", 1) if "AB" in s2: y = True if y: print(...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER IF STRING VAR STRING VAR EXPR FUNC_CALL VAR STRING IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER IF STRING VAR ASSIGN VAR NUMBER IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER IF STRING VAR ASSIGN VAR NUMBER IF 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() ch = 1 m = str(s) n = len(s) ch1 = 0 ch2 = 0 for i in range(n - 1): if s[i] == "B" and s[i + 1] == "A" and ch1 == 0: s = s[:i] + "11" + s[i + 2 :] ch1 = 1 if s[i] == "A" and s[i + 1] == "B" and ch2 == 0 and ch1 == 1: s = s[:i] + "11" + s[i + 2 :] ch2 = 1 if ch1 == 1 a...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR 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 VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR STRING VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF 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 occurence(): s = input() l = len(s) count_ab = 0 count_ba = 0 i = 0 while i < l: if i < l - 1 and s[i] == "A" and s[i + 1] == "B": if count_ba > 0: return "YES" elif i < l - 2 and s[i + 2] == "A": count_ab += 1 c...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR 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 IF VAR NUMBER RETURN STRING IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER 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 ...
st = input() if "AB" in st and "BA" in st: stt = st index = stt.index("AB") stt = stt[:index] + "0" + stt[index + 2 :] if "BA" in stt: print("YES") else: stt = st index = stt.index("BA") stt = stt[:index] + "0" + stt[index + 2 :] if "AB" in stt: pr...
ASSIGN VAR FUNC_CALL VAR IF STRING VAR STRING VAR ASSIGN VAR 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 ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR STRING VAR BIN_OP VAR NUMBER IF 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() def d(s, a, b): if a in s: index = s.index(a) s1, s2 = s[:index], s[index + 2 :] if b in s1 or b in s2: return True else: return False return False if d(s, "AB", "BA") or d(s, "BA", "AB"): print("YES") else: print("NO")
ASSIGN VAR FUNC_CALL VAR FUNC_DEF IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR RETURN NUMBER RETURN NUMBER RETURN NUMBER 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 ...
c = str(input()) bacount = 0 abcount = 0 prev = c[0] for i in range(1, len(c)): if prev == "B" and c[i] == "A" and bacount < 1: bacount += 1 if i + 1 < len(c): i += 1 elif (prev == "A" and c[i] == "B") and abcount < 1: abcount += 1 if i + 1 < len(c): i += ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR STRING VAR VAR STRING VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER IF VAR STRING VAR VAR STRING VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER 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 ...
import sys s = input() t1 = 0 t2 = 0 k = len(s) l = len(s) for i in range(len(s) - 1): if s[i : i + 2] == "AB" and t1 == 0: t1 = 1 k = i + 2 if s[i : i + 2] == "BA" and t2 == 0: l = i + 2 t2 = 1 if t1 == 1 and t2 == 1: break for j in range(k, len(s) - 1): if s[j ...
IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
def overlappingStrings(s): t1, t2, t3, t4 = s.count("AB"), s.count("BA"), s.count("ABA"), s.count("BAB") return "YES" if (t1 + t2) * (t1 != 0 and t2 != 0) - t3 - t4 > 1 else "NO" s = input() print(overlappingStrings(s))
FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING RETURN BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER VAR NUMBER VAR VAR NUMBER 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 = str(input()) a = s.find("AB") b = s.rfind("BA") if abs(a - b) > 1 and min(a, b) >= 0: print("YES") exit() a = s.rfind("AB") b = s.find("BA") if abs(a - b) > 1 and min(a, b) >= 0: print("YES") exit() print("NO")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER F...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() s = s.replace("C", "Z") s = s.replace("D", "Z") s2 = s s = s.replace("AB", "C", 1) s = s.replace("BA", "D", 1) s2 = s2.replace("BA", "C", 1) s2 = s2.replace("AB", "D", 1) ans = ( s.find("C") != -1 and s.find("D") != -1 or s2.find("C") != -1 and s2.find("D") != -1 ) print("YES" * ans + "NO" * (1 - ans))
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER ASSIGN 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() c, ct = 0, 0 st = s k = s.find("AB") if k >= 0: s = s[:k] + "XX" + s[k + 2 :] ct = 1 k = s.find("BA") if k >= 0: s = s[:k] + "XX" + s[k + 2 :] c = 1 p, pt = 0, 0 k = st.find("BA") if k >= 0: st = st[:k] + "XX" + st[k + 2 :] pt = 1 k = st.find("AB") if k >= 0: st = st[:k] + "XX" +...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR STRING VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR STRING VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
n = input() l = 0 c = 0 i = 0 d = 0 d1 = 0 while i < len(n) - 1: if n[i] + n[i + 1] == "AB": c += 1 d = i if n[i] + n[i + 1] == "BA": l += 1 d1 = i i += 1 if ( l > 1 and c > 1 or l > 1 and c > 0 and d1 - d != 1 and d1 - d != -1 or c > 1 and l >...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR VAR NUMBER 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 ...
import sys input = sys.stdin.readline def prog(): s = input().strip() flag = False worked = False for i in range(len(s) - 1): substring = s[i : i + 2] if substring == "AB" and flag == False: flag = True start = i + 2 break if flag: for i...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL VAR 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 VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR FOR VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR V...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
string = str(input()) def main(string): AB_faced = False BA_faced = False index = string.find("AB") if index == -1: return "NO" else: AB_faced = True BA_faced = False if string.find("BA", 0, index) == -1 else True if BA_faced is False: BA_faced = False i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER RETURN STRING ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING NUMBER VAR NUMBER NUMBER NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING BIN_OP VAR NUMBER NUMBER NUMBER NUMBER IF VAR VA...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
from sys import stdin input = stdin.readline def substr(s): b = b2 = c = c2 = -2 for ptr in range(len(s) - 1): if s[ptr] == "A": if s[ptr + 1] == "B": if 0 <= c < ptr - 1 or 0 <= c2 < ptr - 1: return "YES" elif b == -2: ...
ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR 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 NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER RETURN STRING IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR IF VAR VAR STRING 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 ...
mot = input() if len(mot) <= 3: print("NO") else: ab = mot.count("AB") ba = mot.count("BA") aba = mot.count("ABA") bab = mot.count("BAB") abab = mot.count("ABAB") baba = mot.count("BABA") if abab == 1 and ab == 2 and ba == 1: print("NO") elif baba == 1 and ba == 2 and ab == 1...
ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER VAR NUMBER 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() ab = 0 ba = 0 aba = 0 bab = 0 n = len(s) if n < 4: print("NO") else: for i in range(n - 1): if s[i : i + 2] == "AB": ab += 1 for i in range(n - 1): if s[i : i + 2] == "BA": ba += 1 for i in range(n - 2): if s[i : i + 3] == "ABA": ab...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBE...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
def finder(input_str): idx = input_str.find("AB") if idx != -1: if input_str[idx + 2 :].find("BA") != -1: return True idx = input_str.find("BA") if idx != -1: return input_str[idx + 2 :].find("AB") != -1 print("YES" if finder(input()) else "NO")
FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR NUMBER STRING NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER RETURN FUNC_CALL VAR BIN_OP VAR NUMBER STRING NUMBER EXPR FUNC_CALL VAR FUNC_CALL 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 ...
s = input() s1 = s t = 0 z = 0 if s.find("AB") != -1: s = s[: s.find("AB")] + ".." + s[s.find("AB") + 2 :] if s.find("BA") != -1: t = 1 if s1.find("BA") != -1: s = s1[: s1.find("BA")] + ".." + s1[s1.find("BA") + 2 :] if s.find("AB") != -1: z = 1 if t == 1 or z == 1: print("YES") else...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR STRING NUMBER ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR STRING STRING VAR BIN_OP FUNC_CALL VAR STRING NUMBER IF FUNC_CALL VAR STRING NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR STRING NUMBER ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CAL...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
inputString = input() indexAB, indexBA = [(-1) for i in range(2)], [(-1) for i in range(2)] for i in range(len(inputString) - 1): if inputString[i] == "A" and inputString[i + 1] == "B": if indexAB[0] == -1: indexAB[0] = i if indexAB[1] < i: indexAB[1] = i elif inputString...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR FUNC_CALL VAR NUMBER NUMBER VAR FUNC_CALL 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 NUMBER ASSIGN VAR NUMBER VAR IF VAR NUMBER VAR ASSIGN VAR NUMBER VAR IF VAR VAR STRING VAR BIN_OP VAR...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
substring = input()[0:] subtext = "" ab = 0 ba = 0 aba = 0 contain = False for i in range(0, len(substring)): if len(subtext) >= 3: aba += 1 subtext = "" if subtext == "": if substring[i] == "A" or substring[i] == "B": subtext += substring[i] continue if subst...
ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR STRING IF VAR STRING IF VAR VAR STRING VAR VAR STRING VAR VAR VAR IF VAR VAR STRING VAR VAR STRING 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() flag = 0 if "AB" in s: if "BA" in s[s.index("AB") + 2 :]: flag = 1 if "BA" in s: if "AB" in s[s.index("BA") + 2 :]: flag = 1 if flag == 1: print("YES") else: print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF STRING VAR IF STRING VAR BIN_OP FUNC_CALL VAR STRING NUMBER ASSIGN VAR NUMBER IF STRING VAR IF STRING VAR BIN_OP FUNC_CALL VAR STRING NUMBER ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
__author__ = "victormion" leftAB = None leftBA = None rightAB = None rightBA = None s = input() def function(): if leftAB == None or leftBA == None: return False else: if rightAB - leftBA > 1: return True if rightBA - leftAB > 1: return True return False f...
ASSIGN VAR STRING ASSIGN VAR NONE ASSIGN VAR NONE ASSIGN VAR NONE ASSIGN VAR NONE ASSIGN VAR FUNC_CALL VAR FUNC_DEF IF VAR NONE VAR NONE RETURN NUMBER IF BIN_OP VAR VAR NUMBER RETURN NUMBER IF BIN_OP VAR VAR NUMBER RETURN NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF STRING 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().strip() l1 = s.find("AB") l2 = s.find("BA") if l1 == -1 or l2 == -1: print("NO") else: k = s[l1 + 2 :].find("BA") if k == -1: k = s[l2 + 2 :].find("AB") if k == -1: print("NO") else: print("YES") else: print("YES")
ASSIGN VAR FUNC_CALL 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 ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER STRING IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER STRING IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL V...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() t = s has_ab = has_ba = False if "AB" in t: has_ab = True t = t.replace("AB", " ", 1) if "BA" in t: has_ba = True if not (has_ab and has_ba): has_ab = has_ba = False if "BA" in s: has_ba = True s = s.replace("BA", " ", 1) if "AB" in s: has_ab = True print("YES...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR NUMBER IF STRING VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER IF STRING VAR ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR VAR NUMBER IF STRING VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER IF STRING VAR ASSIGN 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 ...
MOD = 1000000007 MOD2 = 998244353 ii = lambda: int(input()) si = lambda: input() dgl = lambda: list(map(int, input())) f = lambda: map(int, input().split()) il = lambda: list(map(int, input().split())) ls = lambda: list(input()) s = si() n = len(s) bl = [0] * n x, y = 0, 0 for i in range(1, n): if s[i - 1] + s[i] =...
ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN 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 FUNC_CALL 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 ...
S = input() listA = [] listB = [] for i in range(0, len(S) - 1): if S[i] == "A" and S[i + 1] == "B": listA.append(i) if S[i] == "B" and S[i + 1] == "A": listB.append(i) nA = len(listA) nB = len(listB) if nA >= 2 and nB >= 2: print("YES") elif nA == 0 or nB == 0: print("NO") else: res...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF 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 FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF 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() Len = len(S) a = [] b = [] i = 0 while i < Len: if i + 1 < Len and S[i] == "A" and S[i + 1] == "B": a.append(i) elif i + 1 < Len and S[i] == "B" and S[i + 1] == "A": b.append(i) i += 1 if len(a) == 0 or len(b) == 0: print("NO") elif len(a) == 2 and len(b) == 1: if a[0] ==...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER VAR VAR VAR STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR VAR VAR STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR VAR NUMBER 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 ...
a = str(input()) r = "NO" n = len(a) x = a.find("AB") b = a[x + 2 : n] y = b.find("BA") if x >= 0 and y >= 0: r = "YES" x = a.find("BA") b = a[x + 2 : n] y = b.find("AB") if x >= 0 and y >= 0: r = "YES" print(r)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL ...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() if s.count("AB") > 0 and s.count("BA") > 0: if ( s.find("ABA") <= s.find("AB") and s.find("ABA") <= s.find("BA") and s.find("ABA") != -1 ): if s.find("AB", s.find("ABA") + 3, len(s)) != -1: print("YES") elif s.find("BA", s.find("ABA") + 3, len(s)) ...
ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER IF FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING NUMBER IF FUNC_CALL VAR STRING BIN_OP FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF FUNC_CAL...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
p = ["ABBA", "BAAB"] b = [0, 0] pc = "X" block = False for c in input(): if not (p[0] and p[1]): break for i in [0, 1]: if b[i]: b[i] = 0 continue if p[i][1] == c and p[i][0] == pc: p[i] = p[i][2:] b[i] = 1 pc = c print("YNEOS"[bool(p[0...
ASSIGN VAR LIST STRING STRING ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR IF VAR NUMBER VAR NUMBER FOR VAR LIST NUMBER NUMBER IF VAR VAR ASSIGN VAR VAR NUMBER IF VAR VAR NUMBER VAR VAR VAR NUMBER VAR ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR 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() AB = [] BA = [] for i in range(len(s) - 1): if s[i] == "A" and s[i + 1] == "B": AB.append(i) elif s[i] == "B" and s[i + 1] == "A": BA.append(i) if len(AB) >= 2 and len(BA) >= 2: print("YES") elif len(AB) == 0 or len(BA) == 0: print("NO") elif len(AB) == 1: out = "NO" ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL V...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
def noverlap(s): ab = s.count("AB") ba = s.count("BA") aba = s.count("ABA") bab = s.count("BAB") abab = s.count("ABAB") baba = s.count("BABA") if ( ab > 1 and ba > 1 or ab == 1 and ba == 2 and baba == 0 or ab == 2 and ba == 1 an...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER 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 ...
s = input() AB = list() BA = list() i = 0 while s.find("AB", i, len(s)) != -1: AB.append(s.find("AB", i, len(s))) i = s.find("AB", i, len(s)) + 1 i = 0 while s.find("BA", i, len(s)) != -1: BA.append(s.find("BA", i, len(s))) i = s.find("BA", i, len(s)) + 1 if AB and BA: for a in AB: for b in ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR STRING VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR STRING VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR STRING VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE 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 ...
a = list(input()) i = 0 ab = 0 ba = 0 f = 0 while i < len(a) - 1: if (a[i] == "A" and a[i + 1] == "B") and ab == 0: ab = 1 f = 1 i += 2 elif (a[i] == "B" and a[i + 1] == "A") and f == 1 and ba == 0: ba = 1 f = 2 i += 2 else: i += 1 if ab == 1 and b...
ASSIGN VAR FUNC_CALL 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 VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR ...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() if s.find("AB") >= 0 and s.replace("AB", "-", 1).find("BA") >= 0: print("YES") elif s.find("BA") >= 0 and s.replace("BA", "-", 1).find("AB") >= 0: print("YES") else: print("NO")
ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR STRING NUMBER FUNC_CALL FUNC_CALL VAR STRING STRING NUMBER STRING NUMBER EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR STRING NUMBER FUNC_CALL FUNC_CALL VAR STRING 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 ...
line = str(input()) size = len(line) list_ab = list() list_ba = list() for i in range(size - 1): if line[i : i + 2] == "AB": list_ab.append(i) if line[i : i + 2] == "BA": list_ba.append(i) flag = False for i in list_ab: for j in list_ba: if abs(i - j) > 1: flag = True ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR 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 ASSIGN VAR NUMBER FOR VAR VAR FOR VAR VAR 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 ...
ab = "AB" ba = "BA" def res(s, j): global ab, ba if j: ab, ba = ba, ab ai = s.find(ab) if ai == -1: return 0 fp = s[:ai] sp = s[ai + 2 :] bi = fp.find(ba) if bi == -1: bi = sp.find(ba) if bi == -1: return 0 return 1 s = input() s = "YES" if res...
ASSIGN VAR STRING ASSIGN VAR STRING FUNC_DEF IF VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER RETURN NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL V...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
word = input() n = len(word) ab = [] ba = [] for i in range(0, n - 1): if word[i : i + 2] == "AB": ab.append(i) elif word[i : i + 2] == "BA": ba.append(i) if len(ab) >= 1 and len(ba) >= 1 and len(ab) + len(ba) >= 4: print("YES") elif len(ab) == 1 and len(ba) == 1 and abs(ab[0] - ba[0]) != 1:...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER 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 BIN_OP 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()) tab = s.count("AB") tba = s.count("BA") flag = ( 1 if tab > 0 and tba > 0 and tab + tba - s.count("ABA") - s.count("BAB") >= 2 else 0 ) print("YES" if flag else "NO")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER VAR NUMBER BIN_OP BIN_OP BIN_OP VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR VAR STRING STRING
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
def check(): id1 = s.find(order[0]) id2 = s.rfind(order[1]) if id1 == -1 or id2 == -1: return False return id1 + 1 < id2 s = input() order = ["AB", "BA"] if check(): print("YES") else: order = order[::-1] print("YES" if check() else "NO")
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER RETURN BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST STRING STRING IF FUNC_CALL VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER EXPR FUNC_CALL 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 ...
def solve(s): ab1, ab2 = s.find("AB"), s.rfind("AB") ba1, ba2 = s.find("BA"), s.rfind("BA") if ab1 >= 0 and ba1 >= 0 and (abs(ab1 - ba2) > 1 or abs(ab2 - ba1) > 1): print("YES") else: print("NO") solve(input())
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR 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 = list(input()) ab = 0 ba = 0 aba = 0 bab = 0 flag = 0 n = len(s) i = 1 while i < n: if ab == 0 and s[i] == "A" and s[i - 1] == "B": ab += 1 i += 2 continue if ab > 0 and s[i] == "B" and s[i - 1] == "A": ba += 1 break i += 1 flag = 1 if ab > 0 and ba > 0 else 0 if f...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR IF VAR NUMBER VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER IF VAR NUMBER VAR VAR STRING VAR BIN_OP VAR NUMBER...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() length = len(s) flag = 0 for x in range(length - 1): if flag == 0: if s[x : x + 2] == "AB": flag = 1 elif flag == 1: flag += 1 elif s[x : x + 2] == "BA": print("YES") exit() flag = 0 for x in range(length - 1): if flag == 0: if s[x : x + 2]...
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 NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CAL...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
def main(): x = input() found = False if "AB" in x: y = x.split("AB", 1) for i in y: if "BA" in i: found = True print("YES") return if "BA" in x: y = x.split("BA", 1) for i in y: if "AB" in i: ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING NUMBER FOR VAR VAR IF STRING VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING NUMBER FOR VAR VAR IF STRING VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN IF VAR E...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() n = len(s) i = 0 f1 = 0 f2 = 0 while i < n - 1: if s[i] == "A" and s[i + 1] == "B": i += 2 break i += 1 while i < n - 1: if s[i] == "B" and s[i + 1] == "A": f1 = 1 break i += 1 i = 0 while i < n - 1: if s[i] == "B" and s[i + 1] == "A": i += 2 ...
ASSIGN VAR 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 STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER 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 ...
word = input() abLoc_ab = word.find("AB") slicedWord = word[abLoc_ab + 2 : len(word)] baLoc_ab = slicedWord.rfind("BA") baLoc_ba = word.find("BA") slicedWord = word[baLoc_ba + 2 : len(word)] abLoc_ba = slicedWord.find("AB") if abLoc_ab >= 0 and baLoc_ab >= 0 or abLoc_ba >= 0 and baLoc_ba >= 0: print("YES") else: ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER VAR NUMBER 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().strip() a = s.find("AB") b = s.find("BA") if a == -1 or b == -1: print("NO") elif a > b + 1 or b > a + 1: print("YES") else: a2 = s.find("AB", b + 2) b2 = s.find("BA", a + 2) if a2 != -1 or b2 != -1: print("YES") else: print("NO")
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING 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 = "" def hasCombination(s): pos_first_AB = s.find("AB") pos_first_BA = s.find("BA") if pos_first_AB == -1 or pos_first_BA == -1: return False pos_last_AB = s.rfind("AB") pos_last_BA = s.rfind("BA") return ( abs(pos_first_AB - pos_first_BA) > 1 or abs(pos_first_AB - po...
ASSIGN VAR STRING FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING RETURN FUNC_CALL VAR BIN_OP VAR VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR NUMBER FUNC_CALL VAR BIN_OP VAR 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() a = False b = False if "AB" in s: ia = s.find("AB") a = True b = False if "BA" in s[ia + 2 :]: b = True if (a == False or b == False) and "BA" in s: ib = s.find("BA") b = True a = False if "AB" in s[ib + 2 :]: a = True if b and a: print("YES") else: pr...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF STRING VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER STRING VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF STRING VAR BIN_OP VA...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() flag = 0 pos = 0 ab = s.find("AB") if ab != -1: ba = s.find("BA", ab + 2) if ba != -1: flag = 1 ba = s.find("BA") if ba != -1: ab = s.find("AB", ba + 2) if ab != -1: pos = 1 if pos == 1 or flag == 1: print("YES") else: print("NO")
ASSIGN VAR FUNC_CALL VAR 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 IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF ...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() l = len(s) i = 0 ab = s.find("AB") ba = s.find("BA") if ab >= 0 and ba >= 0: if ab > ba + 1 or ba > ab + 1: print("YES") else: s = s[max(ab, ba) + 2 :] ab = s.find("AB") ba = s.find("BA") if ab >= 0 or ba >= 0: print("YES") else: ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR 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 ...
def main(): def isin(s, t): res = [] for i in range(len(s) - 1): if s[i : i + 2] == t: res.append(i) return res s = input() ab = isin(s, "AB") ba = isin(s, "BA") if len(ab) == 0 or len(ba) == 0: print("NO") else: for a in ab: ...
FUNC_DEF FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR STRING IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL ...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() l = [] count = 0 count1 = 0 for i in range(len(s) - 1): if s[i] == "A" and s[i + 1] == "B" and count == 0: if i not in l and i + 1 not in l: count = count + 1 l.append(i) l.append(i + 1) if s[i] == "B" and s[i + 1] == "A" and count1 == 0: if i not ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF 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 ...
word = input() ab = {} ba = {} for i in range(len(word) - 1): if word[i] + word[i + 1] == "AB": ab[i] = 1 elif word[i] + word[i + 1] == "BA": ba[i] = 1 f = 0 for i in ab: for j in ba: if j != i - 1 and j != i + 1: f = 1 break if f == 1: break if f ...
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 ASSIGN VAR NUMBER FOR VAR VAR FOR VAR VAR IF VAR BIN_OP VAR NUMBER VAR ...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
def foo(string, sub): ans = [] for i in range(len(string) - len(sub) + 1): for j in range(len(sub)): if string[i + j] != sub[j]: break else: ans.append(i) return ans s = input() a1 = foo(s, "AB") a2 = foo(s, "BA") f = 0 for elm in a2: for start i...
FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR STRING ASSIGN 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 ...
def main(): s = input() if "AB" in s and "BA" in s: if s.rindex("BA") - s.index("AB") > 1 or s.rindex("AB") - s.index("BA") > 1: print("YES") else: print("NO") else: print("NO") main()
FUNC_DEF ASSIGN VAR FUNC_CALL VAR IF STRING VAR STRING VAR IF BIN_OP FUNC_CALL VAR STRING FUNC_CALL VAR STRING NUMBER BIN_OP FUNC_CALL VAR STRING FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
x = input() i = 0 c = 0 d = 0 lol = [] yo = [] for i in range(len(x) - 1): if x[i] == "A": if x[i + 1] == "B": c += 1 lol.append(i) for i in range(len(x) - 1): if x[i] == "B": if x[i + 1] == "A": d += 1 yo.append(i) if c >= 1 and d >= 1: if c =...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER 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 VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
test = input() test1 = test i = j = None try: i = test.index("AB") test = test.replace("AB", "__", 1) j = test.index("BA") print("YES") except: try: i = test1.index("BA") test1 = test1.replace("BA", "__", 1) j = test1.index("AB") print("YES") except: print...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR NONE ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER ASSIGN VAR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING STRING NUMBER ASSIGN VAR 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() c = 0 d = 0 for i in range(len(a) - 1): if a[i] == "A": if a[i + 1] == "B": c = c + 1 if a[i] == "B": if a[i + 1] == "A": d = d + 1 if c == 0: print("NO") elif d == 0: print("NO") if c > 1: if d > 1: print("YES") if d == 1: a = ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL 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() flagA = 0 flagB = 0 flagABBA = 0 i, j = 0, 1 while j < len(s): if j + 1 < len(s) and s[i] == "A" and s[j] == "B" and s[j + 1] == "A": flagABBA += 1 i += 3 j += 3 elif j + 1 < len(s) and s[i] == "B" and s[j] == "A" and s[j + 1] == "B": flagABBA += 1 i += 3 ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER WHILE VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR VAR STRING VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR VAR STRING...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() for x in range(len(s) - 1): if s[x] == "A" and s[x + 1] == "B": break else: print("NO") quit() for y in range(x + 2, len(s) - 1): if s[y] == "B" and s[y + 1] == "A": print("YES") quit() for a in range(len(s) - 1): if s[a] == "B" and s[a + 1] == "A": break ...
ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR 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 EXPR FUNC_CALL VAR STRING EXPR...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
def fd70000000(): s = input() rs = s AB = s.find("AB") sw = False if AB != -1: s = s[:AB] + " " + s[AB + 2 :] AB = s.find("BA") if AB != -1: sw = True AB = rs.rfind("AB") if AB != -1: rs = rs[:AB] + " " + rs[AB + 2 :] AB = rs.find("BA") ...
FUNC_DEF 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 ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP 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 ...
i = input() def contains(string): ab = False abpos = -3 ba = False i = 0 aba = False if ( string.count("AB") == 0 or string.count("BA") == 0 or (string.count("ABAB") == 1 or string.count("BABA") == 1) and string.count("A") + string.count("B") == 4 ): ...
ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER BIN_OP FUNC_CALL VAR STRING FUNC_CALL VAR STRING NUMBER RETURN STRING IF FUNC_CAL...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
def solve(): s = input() n = len(s) ab = [] ba = [] if n == 1 or n == 2 or n == 3: print("NO") else: i = 0 while i < n - 1: if "AB" in s[i : i + 2]: ab.append(i) elif "BA" in s[i : i + 2]: ba.append(i) i ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST IF VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF STRING VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR IF STRING VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() lab = None lba = None rab = None rba = None i = 0 while i < len(s) - 1: if s[i] == "A" and s[i + 1] == "B": if lab == None: lab = i rab = i elif s[i] == "B" and s[i + 1] == "A": if lba == None: lba = i rba = i i += 1 if lab == None or lba =...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NONE ASSIGN VAR NONE ASSIGN VAR NONE ASSIGN VAR NONE ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING IF VAR NONE ASSIGN VAR VAR ASSIGN VAR VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING IF VAR NONE ASSIGN VAR 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 ...
n = input().strip() l = n.rfind("BA") k = n.find("AB") j = n.rfind("AB") p = n.find("BA") t = False for i in [l, p]: for x in [k, j]: if i != -1 and x != -1: if min(i, x) + 2 <= max(i, x): t = True print("YES") break if t == True: break...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR LIST VAR VAR FOR VAR LIST VAR VAR IF VAR NUMBER VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL VAR VAR VAR ASSIGN VAR ...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
def any_in(subs, ss): return any(x in s for x in subs for s in ss) s = input() if "ABA" in s: l = s.split("ABA", 1) if any_in(["AB", "BA"], l): print("YES") exit(0) if "BAB" not in s: print("NO") exit(0) if "BAB" in s: l = s.split("BAB", 1) if any_in(["AB", "BA"...
FUNC_DEF RETURN FUNC_CALL VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING NUMBER IF FUNC_CALL VAR LIST STRING STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF STRING VAR ASSIGN VAR FUNC_...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
a = input() b = len(a) c = 0 d = 0 e = 0 f = 0 g = 0 l = 0 for i in range(0, b - 1): if a[i] == "A": if a[i + 1] == "B": c = 1 if i + 2 < b: if a[i + 2] == "A": f = 1 elif a[i] == "B": if a[i + 1] == "A": e = 1 i...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER VAR IF VAR BIN_OP VAR ...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
s = input() x = s.find("AB") y = s.find("BA") if x == -1 or y == -1: print("NO") exit(0) z1 = s[:x].find("BA") z2 = s[x + 2 :].find("BA") z3 = s[:y].find("AB") z4 = s[y + 2 :].find("AB") if z1 == z2 and z3 == z4 and z1 == -1: print("NO") else: print("YES")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR STRING ASSIGN 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 ...
s = input() s1 = s.replace("AB", "x", 1) s2 = s.replace("BA", "x", 1) if len(s1) < len(s) and s1.find("BA") != -1: print("YES") elif len(s2) < len(s) and s2.find("AB") != -1: 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 IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR STRING NUMBER 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() c, c1, c2 = 0, 0, 0 i = 0 while i < len(s) - 1: if s[i] == "A" and c1 != 1: if s[i + 1] == "B": if i + 2 < len(s) and s[i + 2] == "A": c += 1 i += 1 else: c1 += 1 i += 1 elif s[i] == "B" and c2 != 1: ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR STRING VAR ...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin letters. -----Output----- Print ...
inputList = input().split() if len(inputList) == 0: print("NO") else: ABCounter = 0 BACounter = 0 OverlapCounter = 0 MayOverlapFlag = False testStr = inputList[0] i = 0 while i < len(testStr) - 1: currentValue = testStr[i] nextValue = testStr[i + 1] if currentValu...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN 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 ...
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). -----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() ba = x.rfind("BA") bar = x.find("BA") ab = x.find("AB") abr = x.rfind("AB") if ( abs(ab - ba) >= 2 and ab != -1 and ba != -1 or abs(ab - bar) >= 2 and ab != -1 and bar != -1 or abs(ba - abr) >= 2 and ba != -1 and abr != -1 or abs(abr - bar) >= 2 and abr != -1 ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR NUMBER 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 ...
word = input() ab1, ab2 = word.find("AB"), word.rfind("AB") ba1, ba2 = word.find("BA"), word.rfind("BA") if ab1 != -1 and ba1 != -1: if ab2 - ba1 > 1 or ba2 - ab1 > 1: print("YES") else: print("NO") else: print("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 IF VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING