Problem:


Score : 100 points

Problem Statement

In AtCoder City, there are three stations numbered 1, 2, and 3.

Each of these stations is operated by one of the two railway companies, A and B. A string S of length 3 represents which company operates each station. If S_i is A, Company A operates Station i; if S_i is B, Company B operates Station i.

To improve the transportation condition, for each pair of a station operated by Company A and one operated by Company B, there will be a bus service connecting them.

Determine if there is a pair of stations that will be connected by a bus service.

Constraints

Each character of S is A or B.

|S| = 3

Input

Input is given from Standard Input in the following format:

S

Output

If there is a pair of stations that will be connected by a bus service, print Yes; otherwise, print No.

Sample Input 1

ABA

Sample Output 1

Yes

Company A operates Station 1 and 3, while Company B operates Station 2.

There will be a bus service between Station 1 and 2, and between Station 2 and 3, so print Yes.

Sample Input 2

BBA

Sample Output 2

Yes

Company B operates Station 1 and 2, while Company A operates Station 3.

There will be a bus service between Station 1 and 3, and between Station 2 and 3, so print Yes.

Sample Input 3

BBB

Sample Output 3

No

Company B operates all the stations. Thus, there will be no bus service, so print No.



Sample input:
ABA


Sample output:
Yes

Submission status: Runtime Error

Solution code:
s = input()
q_num = int(input())
head = []
tail = []
flip = 0
for i in range(q_num):
    q = tuple(input().split())
    if q[0] == '1':
        flip ^= 1
    else:
        f = int(q[1]) - 1
        c = q[2]
        if f ^ flip == 0:
            head.append(c)
        else:
            tail.append(c)
if flip:
    head, tail = tail, head
    s = s[::-1]
head = ''.join(head)
tail = ''.join(tail)
print(head[::-1] + s + tail)

Submission status: Runtime Error

Solution code:
list = input().split(" ")
N = int(list[0])
A = int(list[1])
B = int(list[2])

num1 = N // (A + B)
num2 = N % (A + B)
if num2 <= A:
    print(num1 * A + num2)
else:
    print(num1 * A + A)

Submission status: Runtime Error

Solution code:
a,b=map(str,input().split())
s=str(input())

if s==aaa or s=bbb:
  print('No')
  
else:
  print('Yes')

Submission status: Runtime Error

Solution code:
def yesno(S):
  if S==AAA or S==BBB:
    return No
  else:
    return Yes

S=input()
print(yesno(S))

Submission status: Runtime Error

Solution code:
a,b = map(int,input().split())
for x in range(b * 10,(b + 1) * 10):
    if int(x * 0.08) == a and int(x * 0.1) == b:
        print(x)
        break
else:
    print(-1)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
s = input()

if  a[0] == a[1] == a[2]:
    print("Np")
else:
    print("Yse")

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline

s = [import()] 

if  a[0] == a[1] == a[2]:
	print("Yes")
else:
	print("No")

Submission status: Runtime Error

Solution code:
s = input()
if s = "AAA" or s = "BBB":
    print("No")
else:
    print("Yes")

Submission status: Runtime Error

Solution code:
/*its_Rashid*/
#include <bits/stdc++.h>
using namespace std ;

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loop2(num) for (lli j = 0 ; j < num ; j ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }
#define looppu(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . push_back (x) ;}
#define loopin(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . insert (x) ;}

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back ()
#define pof pop_front ()

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

signed main ()
{
    fastio
    st s ; cin >> s ;
    (s != "AAA"|| "BBB" ? No : Yes);
    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/

Submission status: Runtime Error

Solution code:
S = input()
if S[0] == S[1] and s[1] == S[2]:
  print('No')
else:
  print('Yes')

Submission status: Runtime Error

Solution code:
S = input()
if S[0] == S[1] and s[1] == S[2]:
  print("No")
else:
  print("Yes")

Submission status: Runtime Error

Solution code:
S = input()
if S[0] == S[1] and s[1] == S[2]:
  print("No")
else:
  print("Yes)

Submission status: Runtime Error

Solution code:
s = list(input())
if s == "BBB":
print("NO")

elif s == "AAA":
print("NO")

else:
print("YES")

Submission status: Runtime Error

Solution code:
S = input()
if S = 'AAA' or S == 'BBB':
  print('No')
else:
  print('Yes')

Submission status: Runtime Error

Solution code:
S = input()
if S = 'AAA' or 'BBB':
  print('No')
else:
  print('Yes')

Submission status: Runtime Error

Solution code:
S = input()

if S == "AAA" or S = "BBB":
    print("No")
else:
    print("Yes")

Submission status: Runtime Error

Solution code:
S = input()
if s[0] == S[1] and S[1] == S[2]:
  print("No")
else:
  print("Yes")

Submission status: Runtime Error

Solution code:
situation = input()

if situation == AAA or situation == BBB:
  print(No)
else:
  print(Yes)

Submission status: Runtime Error

Solution code:
if AAA or BBB:
  print(No)
else:
  print(Yes)

Submission status: Runtime Error

Solution code:
s = input()
q = int(input())
list1 = []
list2 = []
flag = 1
for i in range(q):
    in_line = input().split()
    if in_line[0] == "1":
        flag *= -1
    else:
        if in_line[1] == "1":
            if flag == 1:
                list1.append(in_line[2])
            else:
                list2.append(in_line[2])
        else:
            if flag == 1:
                list2.append(in_line[2])
            else:
                list1.append(in_line[2])
if flag == 1:
    print("".join(list1[::-1]) + s + "".join(list2))
else:
    print("".join(list2[::-1]) + s + "".join(list1))

Submission status: Runtime Error

Solution code:
s=input()
if s=='AAA' or s=='BBB':
  print("No")
else:
print("Yes")

Submission status: Runtime Error

Solution code:
S = input()
if S[0] == S[1] and S[1] == S[2]:
  print('No')
else
  print('Yes')

Submission status: Runtime Error

Solution code:
n,p = map(int,input().split())
s = input()
count = 0

if p == 2 or p == 5:
    for i in range(n):
        if int(s[i])%p == 0:
            count += i+1
else:
    u = [0]*p
    u[0] += 1
    for i in range(n):
        u[int(s[i:])%p] += 1
    
    for i in u:
        count += i*(i-1)//2
    
print(count)

Submission status: Runtime Error

Solution code:
if S[0] == S[1] == S[2]:
  print('No')
else
  print('Yes')

Submission status: Runtime Error

Solution code:
n,a,b=map(int, input().split())

x=int(n/(a+b))
if x*(a+b)+a <= n:
  print(a*(x+1))
else:
  print(n-b*x)

Submission status: Runtime Error

Solution code:
n,a,b=map(int, input().split())

x=int(n/(a+b))
if x*(a+b)+a <= n:
	print(a*(x+1))
else:
	print(n-b*x)

Submission status: Runtime Error

Solution code:
S = list(input())
Q = int(input())
 
for q in range(1, Q + 1):
    inp = input().split(" ")
    if (int(inp[0]) == 1):
        S.reverse()
    else:
        if (int(inp[1]) == 1):
            S.insert(0, inp[2])
        elif (int(inp[1]) == 2):
            S.append(inp[2])
 
print("".join(S))

Submission status: Runtime Error

Solution code:
a,b = map(int,input().split())
for i in range(1, 1001):
  if floor(i * 0.08) == a and floor(i * 0.1) == b:
    print(i)
else:
  print('-1')

Submission status: Runtime Error

Solution code:
n=input()
if n=='AAA' or n=='BBB':
  print('No')
else:
  pritn('Yes')

Submission status: Runtime Error

Solution code:
n=input()
if n=='AAA' or n=='BBB':
	print('No')
else:
	pritn('Yes')

Submission status: Runtime Error

Solution code:
a=list(input())
if a[1]==a[2]==a[3]:
  print('No')
else:
  print('Yes')

Submission status: Runtime Error

Solution code:
a=list(input().split())
if a[1]==a[2]==a[3]:
  print('No')
else:
  print('Yes')

Submission status: Runtime Error

Solution code:
a=list(map(int,input().split()))
if a[1]==a[2]==a[3]:
  print('No')
else:
  print('Yes')

Submission status: Runtime Error

Solution code:
n,a,b = map(int,input().split())
ans = int(n / (a + b))
rem = n % (a + b)
if rem > a:
    print(ans * a + a)
else:
    print(ans * a + rem)

Submission status: Runtime Error

Solution code:
import sys
from itertools import combinations, permutations, product, combinations_with_replacement, accumulate
from heapq import heapify, heappop, heappush, heappushpop
from bisect import bisect_left, bisect_right
#from collections import Counter, defaultdict, deque
from math import sqrt, log, floor, ceil, factorial, cos, sin, pi, gcd
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
INF = float('inf')
LINF = 2**63-1
NIL = -LINF
MOD = 10**9+7
MGN = 4
def II(): return int(input())
def IF(): return float(input())
def IS(): return str(input())
def ILCI(n: int): return [II() for _ in range(n)]
def ILCF(n: int): return [IF() for _ in range(n)]
def ILI(): return list(map(int, input().split()))
def ILLI(n: int): return [[int(j) for j in input().split()] for i in range(n)]
def ILF(): return list(map(float, input().split()))
def ILLF(n: int): return [[float(j) for j in input().split()] for i in range(n)]
def LTOS(lst: list, sep: str = ' '): return sep.join(map(str, lst))
def DEC(lst: list): return list(map(lambda x: x-1, lst))
def INC(lst: list): return list(map(lambda x: x+1, lst))


def main():
    S = IS()

    ans = "Yes"
    if S[0] == S[1] and S[1] == S[2]:
        ans = "No"
    
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys
#from itertools import combinations, permutations, product, combinations_with_replacement, accumulate
#from heapq import heapify, heappop, heappush, heappushpop
#from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from math import sqrt, log, floor, ceil, factorial, cos, sin, pi, gcd
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
INF = float('inf')
LINF = 2**63-1
NIL = -LINF
MOD = 10**9+7
MGN = 4
def II(): return int(input())
def IF(): return float(input())
def IS(): return str(input())
def ILCI(n: int): return [II() for _ in range(n)]
def ILCF(n: int): return [IF() for _ in range(n)]
def ILI(): return list(map(int, input().split()))
def ILLI(n: int): return [[int(j) for j in input().split()] for i in range(n)]
def ILF(): return list(map(float, input().split()))
def ILLF(n: int): return [[float(j) for j in input().split()] for i in range(n)]
def LTOS(lst: list, sep: str = ' '): return sep.join(map(str, lst))
def DEC(lst: list): return list(map(lambda x: x-1, lst))
def INC(lst: list): return list(map(lambda x: x+1, lst))


def main():
    S = IS()

    ans = "Yes"
    if S[0] == S[1] and S[1] == S[2]:
        ans = "No"
    
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys
from itertools import combinations, permutations, product, combinations_with_replacement, accumulate
from heapq import heapify, heappop, heappush, heappushpop
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from math import sqrt, log, floor, ceil, factorial, cos, sin, pi, gcd
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
INF = float('inf')
LINF = 2**63-1
NIL = -LINF
MOD = 10**9+7
MGN = 4
def II(): return int(input())
def IF(): return float(input())
def IS(): return str(input())
def ILCI(n: int): return [II() for _ in range(n)]
def ILCF(n: int): return [IF() for _ in range(n)]
def ILI(): return list(map(int, input().split()))
def ILLI(n: int): return [[int(j) for j in input().split()] for i in range(n)]
def ILF(): return list(map(float, input().split()))
def ILLF(n: int): return [[float(j) for j in input().split()] for i in range(n)]
def LTOS(lst: list, sep: str = ' '): return sep.join(map(str, lst))
def DEC(lst: list): return list(map(lambda x: x-1, lst))
def INC(lst: list): return list(map(lambda x: x+1, lst))


def main():
    S = IS()

    ans = "Yes"
    if S[0] == S[1] and S[1] == S[2]:
        ans = "No"
    
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
S=input()
if s="AAA" or s="BBB":
  print("No")
else:print("Yes")

Submission status: Runtime Error

Solution code:
import sys
from itertools import combinations, permutations, product, combinations_with_replacement, accumulate
from heapq import heapify, heappop, heappush, heappushpop
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from math import sqrt, log, floor, ceil, factorial, cos, sin, pi, gcd
from collections import deque
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
INF = float('inf')
LINF = 2**63-1
NIL = -LINF
MOD = 10**9+7
MGN = 4
def II(): return int(input())
def IF(): return float(input())
def IS(): return str(input())
def ILCI(n: int): return [II() for _ in range(n)]
def ILCF(n: int): return [IF() for _ in range(n)]
def ILI(): return list(map(int, input().split()))
def ILLI(n: int): return [[int(j) for j in input().split()] for i in range(n)]
def ILF(): return list(map(float, input().split()))
def ILLF(n: int): return [[float(j) for j in input().split()] for i in range(n)]
def LTOS(lst: list, sep: str = ' '): return sep.join(map(str, lst))
def DEC(lst: list): return list(map(lambda x: x-1, lst))
def INC(lst: list): return list(map(lambda x: x+1, lst))


def main():
    S = IS()

    ans = "Yes"
    if S[0] == S[1] and S[1] == S[2]:
        ans = "No"
    
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
S=input()
if s="aaa" or s="bbb":
  print("No")
else:print("Yes")

Submission status: Runtime Error

Solution code:
import sys
from itertools import combinations, permutations, product, combinations_with_replacement, accumulate
from heapq import heapify, heappop, heappush, heappushpop
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from math import sqrt, log, floor, ceil, factorial, cos, sin, pi, gcd
from collections import deque
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
INF = float('inf')
LINF = 2**63-1
NIL = -LINF
MOD = 10**9+7
MGN = 4
def II(): return int(input())
def IF(): return float(input())
def IS(): return input()
def ILCI(n: int): return [II() for _ in range(n)]
def ILCF(n: int): return [IF() for _ in range(n)]
def ILI(): return list(map(int, input().split()))
def ILLI(n: int): return [[int(j) for j in input().split()] for i in range(n)]
def ILF(): return list(map(float, input().split()))
def ILLF(n: int): return [[float(j) for j in input().split()] for i in range(n)]
def LTOS(lst: list, sep: str = ' '): return sep.join(map(str, lst))
def DEC(lst: list): return list(map(lambda x: x-1, lst))
def INC(lst: list): return list(map(lambda x: x+1, lst))


def main():
    S = IS()

    ans = "Yes"
    if S[0] == S[1] and S[1] == S[2]:
        ans = "No"
    
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys
from itertools import combinations, permutations, product, combinations_with_replacement, accumulate
from heapq import heapify, heappop, heappush, heappushpop
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from math import sqrt, log, floor, ceil, factorial, cos, sin, pi, gcd
from collections import deque
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
INF = float('inf')
LINF = 2**63-1
NIL = -LINF
MOD = 10**9+7
MGN = 4
def II(): return int(input())
def IF(): return float(input())
def IS(): return input().replace('\n', '')
def ILCI(n: int): return [II() for _ in range(n)]
def ILCF(n: int): return [IF() for _ in range(n)]
def ILI(): return list(map(int, input().split()))
def ILLI(n: int): return [[int(j) for j in input().split()] for i in range(n)]
def ILF(): return list(map(float, input().split()))
def ILLF(n: int): return [[float(j) for j in input().split()] for i in range(n)]
def LTOS(lst: list, sep: str = ' '): return sep.join(map(str, lst))
def DEC(lst: list): return list(map(lambda x: x-1, lst))
def INC(lst: list): return list(map(lambda x: x+1, lst))


def main():
    S = IS()

    ans = "Yes"
    if S[0] == S[1] and S[1] == S[2]:
        ans = "No"
    
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
s = input()
f = False
if s[0] != s[1]:
  f = True
elif s[1] != s[2]:
  f = True
  
if f == True:
  print('Yes')
else
  print('No')

Submission status: Runtime Error

Solution code:
a,b,c=input(),input(),input()

if a==b and b==c:
  print('No')
else:
  print('Yes')

Submission status: Runtime Error

Solution code:
s = input()
q_number = int(input())
reverse_flag = 1
head = ""
tail = ""
for i in range(q_number):
  temp = input().split()
  if temp[0] == "1": 
    reverse_flag = reverse_flag * -1
  else:
    headstails = int(temp[1])*reverse_flag 
    if headstails == 1 or headstails == -2:
      head = temp[2] + head
    else:
      tail = tail + temp[2]
      
if reverse_flag == 1:
  print(head+s+tail)
else:
  print(tail[::-1]+s[::-1]+head[::-1])

Submission status: Runtime Error

Solution code:
S = input()
 
if (S == 'AAA') or (S=='BBB'):
  print 'No'
else:
  print 'Yes'

Submission status: Runtime Error

Solution code:
S = input()
 
if S == 'AAA' or 'BBB':
  print 'No'
else:
  print 'Yes'

Submission status: Runtime Error

Solution code:
S = input().strip()

if S == 'AAA' or 'BBB':
  return 'No'
else:
  return 'Yes'

Submission status: Runtime Error

Solution code:
n,a,b=input(),input(),input()
n=int(n)
a=int(a)
b=int(b)
k=n//(a+b)*a+min(a,n%(a+b))
  
print(k)

Submission status: Runtime Error

Solution code:
input()

if S[0] == S[1] and S[1] == S[2]:
    print('No')
else:
    print('Yes')

Submission status: Runtime Error

Solution code:
s = input()
q_number = int(input())
reverse_flag = 1
for i in range(q_number):
  temp = input().split()
  if temp[0] == "1": 
    reverse_flag = reverse_flag * -1
  else:
    if int(temp[1])*reverse_flag == 1 or int(temp[1])*reverse_flag == -2:
      s = temp[2] + s
    else:
      s = s + temp[2]      
      
if reverse_flag == -1:
  s = s[::-1]
print(s)

Submission status: Runtime Error

Solution code:
S=input()
  if S=='AAA':
    print('No')
  elif S=='BBB':
    print('No')
  else:
    print('Yes')

Submission status: Runtime Error

Solution code:
s = input()
q_number = int(input())
 
queries = [input().split() for dummy in range(q_number)]
flag = 1
count = 0
for i in range(q_number):
  if queries[i][0] == "1": 
    flag = flag * -1
    count += 1
  else:
    if int(queries[i][1])*flag == 1 or -2:
      s = queries[i][2] + s
    else:
      s = s + queries[i][2]      

      
if flag == -1:
  s = s[::-1]

print(s)

Submission status: Runtime Error

Solution code:
if __name__== '__main__':
  s = input('>>')
  for i in range(2):
     if s[i] == 'A':
        print('Yes')
     elif s[i] == 'B':
      	print('Yes')
      else:
        print('No')

Submission status: Runtime Error

Solution code:
S=list(map(int,input().split()))
A=S[0]
B=S[1]
if A%2==0:
    C=int(A/0.08)
    E=int((A+1)/0.08)
else:
    C=int(A/0.08)+1
    E=int((A+1)/0.08)-1
D=int(B/0.1)
n=max(C,D)

F=int((B+1)/0.1)-1
m=min(E,F)
if n<=m:
    print(int(n))
else:
    print(-1)

Submission status: Runtime Error

Solution code:
import math

N, A, B = map(int, input().split())
x = math.floor(N // (A + B))
y = N % (A + B)

print(A * x + min(A, y))

Submission status: Runtime Error

Solution code:
s = input()
q = int(input())
query = []
lead = ''
end = ''
inversion_flg = False
 
for j in range(q):
    i = input().split()
    if i[0] == "1":
        if inversion_flg:
            inversion_flg = False 
        else:
            inversion_flg = True
    else:
        if inversion_flg:
            if i[1] == "1":
                i[1] = "2"
            else:
                i[1] = "1"
        if i[1] == "1":
            lead+=i[2]
        else:
            end+=i[2]
 
lead = lead[::-1]
s = lead+s+end
if inversion_flg:
    s = s[::-1]
print(s)

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
ans = n // (a + b) * a
x = n % (a + b)
ans += min(a, x)
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
data = input()
data = data.split(" ")
ans = 0
dataset = np.zeros(int(data[0]), dtype=np.int)
cont = int(data[1])
if int(data[1]) == 0:
    ans = 0

else:
    for i in range(int(data[0])):
        dataset[i] = 1
    for i in range(int(data[0])):
        if i == cont:
            dataset[cont:int(data[2]) + cont] = 2
            cont = i + int(data[2]) + int(data[1])

print(int(np.count_nonzero(dataset == 1)))

Submission status: Runtime Error

Solution code:
import numpy as np
data = input()
data = data.split(" ")
ans = 0
dataset = np.zeros(int(data[0]), dtype=np.int)
cont = int(data[1])
if int(data[1]) == 0:
    ans = 0

else:
    for i in range(int(data[0])):
        dataset[i] = 1
    print(cont, data)
    for i in range(int(data[0])):
        #print(i)
        if i == cont:
            print("px")
            dataset[cont:int(data[2]) + cont] = 2
            cont = i + int(data[2]) + int(data[1])

#print(dataset, data[1], int(np.count_nonzero(dataset == 1)))
print(int(np.count_nonzero(dataset == 1)))

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
2 ans = N // (A + B) * A
3 rem = N % (A + B)
4 ans += min(rem, A)
5 print(ans)

Submission status: Runtime Error

Solution code:
N, P = map(int, input().split())
S = input()
if P==2:
    counter = 0
    for i in range(len(S)):
        if S[i] in ['2','4','6','8','0']:
            counter+=i+1
    print(counter)
elif P==5:
    counter = 0
    for i in range(len(S)):
        if S[i] in ['5','0']:
            counter+=i+1
    print(counter)
else:
    list_a=[0]*P
    list_a[0]+=1
    counter=0
    for i in range(N):
        temp=int(S[N-i-1:])%P
        counter+=list_a[temp]
        list_a[temp]+=1
    print(counter)

Submission status: Runtime Error

Solution code:
l = list(map(int,input().split()))

if l[1] == 0:
    ans = 0
else:
    q, mod = divmod(l[0], (l[1]+l[2]))
    qq, modd = divmod(mod, l[1])
    if qq == 0 :
        ans = l[1] * q + modd
    else:
        ans = l[1] * (q + qq)

print(ans)

Submission status: Runtime Error

Solution code:
A=str(input()

if A[0]==A[1] and A[1]==A[2]:
    print("No")
if A[0]!=A[1] or A[1]!=A[2]:
     print("Yes")

Submission status: Runtime Error

Solution code:
def judgeServe(strs: str) -> str:
  if s.count('A') > 0 and s.count('A') < 3:
    return 'Yes'
  else:
    return 'No'

strs = input()
print(judgeServe(strs))

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())

for n in range(0, 10000):
  a2 = int(n * 8 / 100)
  b2 = int(n * 8 / 100)
  if a2 == a and b2 == b:
    print(n)
    exit()

Submission status: Runtime Error

Solution code:
S = input()
if S[1] == S[2] and S[2] == S[3]:
  print("No")
else:
  print("Yes")

Submission status: Runtime Error

Solution code:
S = input()
if N[1] == N[2] and N[2] == N[3]:
  print("No")
else:
  print("Yes")

Submission status: Runtime Error

Solution code:
N = input()
if N[1] == N[2] and N[2] == N[3]:
  print("No")
else:
  print("Yes")

Submission status: Runtime Error

Solution code:
S = input()

if 'A' in S && 'B' in S
  print('Yes')
else
  print('No')

Submission status: Runtime Error

Solution code:
s = input()
q = int(input())
lead = ''
end = ''
inversion_flg = -1

for j in range(q):
    query = input().split()
    if query[0] == "1":
        inversion_flg *= -1
    else:
        if inversion_flg == 1:
            if query[1] == "1":
                query[1] = "2"
            else:
                query[1] = "1"
        if query[1] == "1":
            lead += query[2]
        else:
            end += query[2]

lead = lead[::-1]
s = lead + s + end
if inversion_flg == 1:
    s = s[::-1]
print(s)

Submission status: Runtime Error

Solution code:
A,B=map(int,input().split())
min_a=12.5*A;max_a=(100a+1)/8
min_b=10*b;max_b=min_b+1
if(max_b<min_a or max_a<min_b):
  print(-1)
else:
  print(int(round(max(min_a,min_b)+0.4999999,0)))

Submission status: Runtime Error

Solution code:
A,B=map(int,input().split())
min_a=12.5*A;max_a=(100a+1)/8
min_b=10*B;max_b=min_b+1
if(max_b<min_a or max_a<min_b):
  print(-1)
else:
  print(int(round(max(12.5*A,10*B)+0.4999999,0)))

Submission status: Runtime Error

Solution code:
n,a,b = list(map(int, input().split()))

q=n//(a+b)
mod=n%(a+b)
ans=a*q
if a < mod:
    ans+=a
else:
    ans+=mod
print(ans)

Submission status: Runtime Error

Solution code:
S,A,B=map(int,input().split())
print((S//(A+B))*A+min(A,S%(A+B)))

Submission status: Runtime Error

Solution code:
S=input()
if(("A"in S and "B"in S):
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
A, B = map(int, input().split())
if int(A/0.08*0.1) == B :
    print(int(A/0.08))
else:
    print(-1)

Submission status: Runtime Error

Solution code:
A, B = map(int, input().split())
if int(A/0.08*0.1) == B :
    print(round(A/0.08))
else:
    print(-1)

Submission status: Runtime Error

Solution code:
a = input()
if a='AAA' or a='BBB':
  print('No')
else:
  print('Yes')

Submission status: Runtime Error

Solution code:
def go(s, b, e, p, nums):
	sub = s[b:]
	if(sub in nums):
		return nums[sub]
	aux = ""
	qnt = 0
	while(b < e):
		aux += s[b]
		if(int(aux) % p == 0):
			qnt += 1
		b += 1
	nums[sub] = qnt;
	return qnt

def main():
	n, p = input('').split(' ')
	n = int(n)
	p = int(p)
	s = input()
	qnt = 0
	nums = {}
	for i in range(n):
		qnt += go(s, i, n, p, nums)
	print(qnt)

main()

Submission status: Runtime Error

Solution code:
from math import floor as f
A, B = map(int, input().split(" "))

for c in range(10000):
    a = f(c * 0.08)
    b = f(c * 0.1)
    if a == A and b == B:
        print(c)
        break
else:
    print("-1")

Submission status: Runtime Error

Solution code:
from math import floor as f
A, B = map(int, input().split(" "))

ans = []
for c in range(10000):
    a = f(c * 0.08)
    b = f(c * 0.1)
    if a == A and b == B:
        print(c)
        break
else:
    print("-1")

Submission status: Runtime Error

Solution code:
x = []
for i in range(1000):
  x.append([0] * 10000000000000)

Submission status: Runtime Error

Solution code:
str = input()

ct = str.count('A')

if ct == 0 or ct == 3:
  print('No')
else :
  pritn('Yes')

Submission status: Runtime Error

Solution code:
n,p=map(int,input().split())
s=input()

count=0
if p==2:
    for i in range(n):
        if int(s[i])%2==0:
            count+=i+1
elif p==5:
    for i in range(n):
        if int(s[i])%5==0:
            count+=i+1
else:
    u=[]
    num=0
    for i in range(n):
        u.append(int(s[i:n]%p))
    u.append(0)
    for i in range(n):
        for j in range(i,n):
            if (u[i]-u[j+1])%p==0:
                count+=1
print(count)

Submission status: Runtime Error

Solution code:
a = input()
q = int(input())

fflag = 0
for i in range(q):
  qi = input()
  if( qi == "1"):
    fflag += 1 
  else:
    if( fflag%2 == 0 ):
      if( qi[2] == "2" ):
        a += qi[4]
      else:
        a = qi[4] + a
    else:
      if( qi[2] == "2" ):
        a = qi[4] + a
      else:
        a += qi[4]      
    
if( fflag%2==0 ):
  print( a )
else:
  print( a[::-1] )

Submission status: Runtime Error

Solution code:
a = input()
q = int(input())

fflag = 1
for i in range(q):
  qi = input()
  if( qi == "1"):
    fflag *= -1 
  else:
    if( fflag == 1 ):
      if( qi[2] == "2" ):
        a += qi[4]
      else:
        a = qi[4] + a
    else:
      if( qi[2] == "2" ):
        a = qi[4] + a
      else:
        a += qi[4]      
    
if( fflag == 1 ):
  print( a )
else:
  print( a[::-1] )

Submission status: Runtime Error

Solution code:
import numpy as np
S=input()
Q=int(input())
q=[[0 for i in range(3)] for j in range(Q)]
onecntr=0
for i in range(Q):
    tmp=input().split()
    if(tmp[0]=="1"):
        q[i][0]=1
    else:
        q[i][0]=2
        q[i][1]=int(tmp[1])
        q[i][2]=tmp[2]
    

for i in range(Q):
    if(q[i][0]==1):
        onecntr+=1
    else:
        
        if(onecntr%2==0):
            if(q[i][1]==1):
                S=q[i][2]+S
            else:
                S=S+q[i][2]
        else:
            if(q[i][1]==2):
                S=q[i][2]+S
            else:
                S=S+q[i][2]
    
if(onecntr%2==1):
    S=S[::-1]

print(S)

Submission status: Runtime Error

Solution code:
import numpy as np
S=input()
Q=int(input())
q=[[0 for i in range(3)] for j in range(Q)]
onecntr=0
for i in range(Q):
    tmp=input().split()
    if(tmp[0]=="1"):
        q[i][0]=1
    else:
        q[i][0]=2
        q[i][1]=int(tmp[1])
        q[i][2]=tmp[2]
    

for i in range(Q):
    if(q[i][0]==1):
        onecntr+=1
    else:
        
        if(onecntr%2==0):
            if(q[i][1]==1):
                S=q[i][2]+S
            else:
                S=S+q[i][2]
        else:
            if(q[i][1]==2):
                S=q[i][2]+S
            else:
                S=S+q[i][2]
        onecntr=0
    
if(onecntr%2==1):
    S=S[::-1]

print(S)

Submission status: Runtime Error

Solution code:

while True:
  inp=input()
  a= set(inp)
  if(a==""):
    break
  elif(len(a)==1):
      print("No")
  else:
      print("Yes")

Submission status: Runtime Error

Solution code:


while True:
  inp=raw_input()
  a= set(inp)
  if(a==""):
    break
  elif(len(a)==1):
      print("No")
  else:
      print("Yes")

Submission status: Runtime Error

Solution code:
ppy

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
S = (input())
# 出力
# 奇数を取得
if(S[0] == s[1] == s[2]):
    print('No')
else:
    print('Yes')

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
for i in range(10000):
  if int(i * 0.08) == a and int(i * 0.1) == b:
    print(i)
    exit()
print(=1)

Submission status: Runtime Error

Solution code:
s=input()
if s==ABA:
	print("Yes")
else:
	print()

Submission status: Runtime Error

Solution code:
s=input()
if s=ABA:
	print("Yes")
else:
	print()

Submission status: Runtime Error

Solution code:
s = input()
nq = int(input())
flg = 0
front = []
back = []
for i in range(nq):
    q = input()
    if len(q) == 1:
        #flg += 1
        flg = (flg+1)%2
    else:
        if flg == 0:
            if q[2] == '1':
                front = [q[-1]] + front
            else:
                back = back + [q[-1]]
        else:
            if q[2] == '1':
                back = back + [q[-1]]
            else:
                front = [q[-1]] + front
                
s = ''.join(front) + s + ''.join(back)
# if flg % 2 == 1:
#     s = s[::-1]
print(s)