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:
a, b = input().split() # a = result * 0.08, b = result * 0.1
a, b = int(a), int(b)
 
result_a = int(a / 0.08)
result_b = int(b / 0.1)
 
if result_a > result_b:
  if int(result_a * 0.08) == a:
    result_a += 1
  c = int(result_a * 0.1)
  if b == c:
    print(result_a)
  else:
    print(-1)
else:
  c = int(result_b * 0.08)
  if a == c:
    print(result_b)
  else:
    print(-1)

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
for i in range(100):
  if(i//12.5==a and i//10==b):
    print(i)
  else:
    print("-1")

Submission status: Runtime Error

Solution code:
N,A,B = map(int,input().split())

T = int(N/(A+B))
S = N%(A+B)


if S<A:
	print(T*A+S)
else:
	print(T*A+A)

Submission status: Runtime Error

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

for i in range(1, 1001):
    if int(i * 0.08) == a and int(i * 0.1) == b:
        print(i)
        exit()
print(-1)

Submission status: Runtime Error

Solution code:
import sys
a,b=map(int,input().split())
f=True
for i in range(1,1010):#max_a=1
    if int(i*0.08)==a and int(i*0.1)==b:
        ans=i
        f=False
        break
if f:
  print(-1)
else:
  print(ans)

Submission status: Runtime Error

Solution code:

S = input()
Q = int(input())

# print(S, Q)

queries = []
for i in range(Q):
    query = input()
    queries.append(query)

from collections import deque
slist = deque()
slist.append(S)
isReversed = False
for query in queries:
    if query == "1":
        isReversed = not isReversed
    else:
        t, f, c = query.split()
        if f == '1':
            if isReversed:
                slist.append(c)
            else:
                slist.appendleft(c)
        else:
            if isReversed:
                slist.appendleft(c)
            else:
                slist.append(c)
# slist = list(slist)
if isReversed:
    slist.reverse()

print("".join(slist))
# print(S)

Submission status: Runtime Error

Solution code:
from collections import deque

d = deque()
S = input()
d.append(S)
Q = int(input())
Flag = True
 
for i in range(Q):
    Query = input()
    if Query[0] == "1":
        Flag = not Flag
    else:
        QueryList = Query.split()
        if Flag:
            if QueryList[1] =="1":
                d.appendleft(QueryList[2])
            else:
                d.append(QueryList[2])
        else:
            if QueryList[1] =="2":
                d.appendleft(QueryList[2])
            else:
                d.append(QueryList[2])

d_string = "".join(list(d))

if not Flag:
    d_string = d_string[::-1]    
print(d_string)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

T = 0
F = 2
C = 4

s = input()
q = int(input())

cnt = 0

front = ""
back = ""

for i in range(q):
    query = input()

    if query[T] == "1":
        cnt += 1
        continue

    # モード通常
    if cnt % 2 == 0:
        if query[F] == "1":
            front =  query[C] + front
        else:
            back = query[C] + back

    # モード反転
    else:
        if query[F] == "1":
            back = query[C] + back
        else:
            front =  query[C] + front


# print(cnt)
# print(front)
# print(s)
# print(back)

moji = front+s+back

if cnt % 2 == 0:
    # print(s)
    pass
else:
    moji = moji[::-1]
    # print(s[::-1])

# front = front[::-1]

# print(front,s,back)

print(moji)

Submission status: Runtime Error

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

x = -1

xa = 0
xb = 0

a_arr = []
b_arr = []

for temp_a in range(10001):
    xa = temp_a * 0.08
    if xa // 1 == a:
        a_arr.append(temp_a)

for temp_b in range(10001):
    xb = temp_b * 0.1
    if xb // 1 == b:
        b_arr.append(temp_b)

for aa in a_arr:
    if aa in b_arr:
        print(aa)
        exit(0)

print('-1')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
a,b=map(int,input().split())
for i in range(1,1100):#max_a=1
    if int(i*0.08)==a and int(i*0.1)==b:
        ans=i
        break
    if i==1099:
        ans=-1

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!
# coding: utf-8
from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe


# my functions here!
#標準エラー出力
def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)
def debug(*args):
    print(*args,file=sys.stderr)

def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())
     
#input
from collections import deque
import sys
def resolve():
    S=deque(input())
    Q,=pin()
    ans=""
    turn=0
    for i in range(Q):
        q=sys.stdin.readline().rstrip().split()
        if q[0]=="1":turn=(turn+1)%2
        else:
            f=int(q[1])%2
            if f!=turn:
                S.appendleft(q[2])
            else:
                S.append(q[2])
    if turn==1:S.reverse()
    for s in S:
        ans+=s
    print(ans)
    #print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM])
#if __name__=="__main__":resolve()

"""
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""
import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """a
4
2 1 p
1
2 2 c
1"""
        output = """cpa"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """a
6
2 2 a
2 1 b
1
2 2 c
1
1"""
        output = """aabc"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """y
1
2 1 x"""
        output = """xy"""
        self.assertIO(input, output)

if __name__=="__main__":resolve()

Submission status: Runtime Error

Solution code:
s = input()
q = int(input())
t = 0
for i in range(q):
  Q = input()
  if Q == "1":
    t += 1
  else:
    a, f, c = Q.split()
    f = int(f)
    if (t + f) % 2 == 0:
      s = ''.join([s, c])
    else:
      s = ''.join([c, s])
if t % 2 == 1:
  print(s[::-1])
else:
  print(s)

Submission status: Runtime Error

Solution code:
def main():
    S = input()

    cnt_A, cnt_B = 0

    for i in range(len(S)):
        if S[i] == "A":
            cnt_A += 1
        else:
            cnt_B += 1

    if cnt_A == 3 or cnt_B == 3:
        print('{}'.format('No'))
    else:
        print('{}'.format('Yes'))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
rest = N-A-B
if A ==0:
    print(0)
elif N>A+B:
    answer = A + rest
    print(answer)
elif A<=N<=A+B:
    print(A)
elif A>=N:
    print(N)

Submission status: Runtime Error

Solution code:
S = input()
Q = int(input())
Q_list = list()
for i in range(Q):
    Q_list.append(input().split())

from collections import deque
def operate(i):
    global count, str_list
    if Q_list[i][0] == '1':
        count += 1
    else:
        if count % 2 == 0:
            if Q_list[i][1] == '1':
                str_list.appendleft(Q_list[i][2])
            else:
                str_list.append(Q_list[i][2])
        else:
            if Q_list[i][1] == '1':
                str_list.append(Q_list[i][2])
            else:
                str_list.appendleft(Q_list[i][2])

check = 0
for i in range(Q):
    if Q_list[i][0] == '1':
        check += 1

if check % 2 == 1:
    S_list = list(reversed(S_list))

str_list = deque()
str_list.append(S)
count = check%2
for i in range(Q):
    operate(i)
print(''.join(str_list))

Submission status: Runtime Error

Solution code:
a,b,c=map(int,input().split())
if b!=0:
    k=a//(b+c)
    h=k*b
    t=a-b*k-c*k
    print(t+h)
else:
    print(0)

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:
            S=S[::-1]
            if(q[i][1]==1):
                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:
A,B=map(int,input().split())
if 1<=A<=B<=100:
    A_a=A+1
    B_b=B+1
    A_1=A*(100/8)
    B_1=B*(100/10)
    A_1a=A_a*(100/8)
    B_1b=B_b*(100/10)
    if (A_1<B_1b)and(B_1<A_1a):
        if A_1<B_1:
            A_2=int(A_1)
            print(A_2)
        else:
            B_2=int(B_1)
            print(B_2)
    else:
        print(-1)
else:
    None

Submission status: Runtime Error

Solution code:
def q1(s):
    #reverse
    return s[::-1]
def q2(s,f,char):
    if int(f) == 1:
        s = char + s
    else:
        s= s + char
    return s


s = input()
q = int(input())
for i in range(q):
    query = input().split()
    if len(query)==1:
        s=q1(s)
    else:
        s=q2(s,query[1],query[2])
print(s)

Submission status: Runtime Error

Solution code:
s=input().split()
a=0
for i in range(3):
	if s[i]==A:
		a+=1
if a==0 or a==3:
	print('No')
else:
	print('Yes')

Submission status: Runtime Error

Solution code:
a8, a10 = input().split(' ')
a8 = int(a8)
a10 = int(a10)
 
value1 = int(a8 / 0.08)
value2 = int(a10 / 0.1)
if int(value1 * 0.1) == a10:
  if value1 > value2:
    print(value1)
  else:
    print(value1)
elif int(value2 * 0.08) == a8:
  if value1 > value2:
    print(value1)
  else:
    print(value1)
else:
  print(-1)

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
rest = N-A-B
if A ==0:
    print(0)
elif N>A+B:
    answer = A + rest
    print(answer)
elif A<=N<=A+B:
    print(A)

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
if a>80:
    print(-1)
elif a==b:
    if a<=3:
        print(25*a//2)
    else:
        print(-1)
else:
    if -(-25*a//2) <= 10*b and -(-25*a//2) > 9*b:
        print(25*a//2)
    else:
        print(-1)

Submission status: Runtime Error

Solution code:
import math as mt
K = input().split(" ")
A = int(K[0])
B = int(K[1])
a = float(A*12.5)
t = float((A+1)*12.5)
t1 = mt.ceil(t)
b = B*10
a1 = mt.ceil(a)
A_data = []
B_data = []
for i in range(b,b+10):
    A_data.append(i)
for i in range(a1,a1+t1):
    B_data.append(i)
A_set = set(A_data)
B_set = set(B_data)
AB_set = A_set & B_set
if AB_set:
    P = min(AB_set)
    print(P)
else:
    print(-1)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
Flag =  0 
S = input()
SA = [str(c) for c in S]
#A = list(['A','A','A'])
#B = list(['B','B','B'])
S1 = SA[1]
S2 = SA[2]
S3 = SA[3]
if(S1 == S2 == S3):
    print("No")
else:
    print("Yes")

Submission status: Runtime Error

Solution code:
import math
from collections import deque
def main():
    n,p = tuple([int(t)for t in input().split()])
 
    s = input()[::-1]
    subs = [0]*p
    counter =0
    for i in range(0,n):
        subs[int(s[0:i+1])%p] +=1
 
    counter+=subs[0]
 
    for i in range(p//2):
        counter+= subs[i]*subs[-i-1]
 
 
    counter+=subs[0]*(subs[0]-1)//2
 
    print(counter)
 
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
s = [input()]
q = int(input())

for _ in range(q):
    a = list(input().split())
    if len(a) == 1:
        s.reverse()
    else:
        if a[1] == "1":
            s.reverse()
            s += a[-1]
            s.reverse()
        else:
            s += a[-1]
print("".join(s))

Submission status: Runtime Error

Solution code:
s=input()
if s == ABB :
    print("Yes")
elif s == AAB :
    print("Yes")
elif s == ABA :
    print("Yes")
elif s == BAA :
    print("Yes")
elif s == BBA :
    print("Yes")
elif s == BAB :
    print("Yes")
else :
    print("No")

Submission status: Runtime Error

Solution code:
S=map(str,input())
if "A" in S:
    print("Yes")
elif :
    S="AAA"
    print("No")
else :
    print("No")

Submission status: Runtime Error

Solution code:
S=map(str,input())
if "A" in S:
    print("Yes")
elif :
    S="AAA"
else :
    print("No")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
s = list(input())
q = int(input())
lines = [list(input().split()) for i in range(q)]
 
def q1(s):
    for i in range(len(s) // 2):
        s[i],s[-1-i] = s[-1-i],s[i]
    return s
 
def q2(s, l):
    if int(l[1]) == 1:
        s.insert(0,l[2])
    else:
        s.extend(l[2])
    return s
 
for l in lines:
    if int(len(l)) == 1:
        q1(s)
    else:
        q2(s, l)
 
print(*s, sep='')
s = list(input())
q = int(input())
lines = [list(input().split()) for i in range(q)]

def q1(s):
    for i in range(len(s) // 2):
        s[i],s[-1-i] = s[-1-i],s[i]
    return s

def q2(s, l):
    if int(l[1]) == 1:
        s.insert(0,l[2])
    else:
        s.extend(l[2])
    return s

for l in lines:
    if int(len(l)) == 1:
        q1(s)
    else:
        q2(s, l)

print(*s, sep='')

Submission status: Runtime Error

Solution code:
s = input()
q = int(input())
for i in range(0, q):
    query = input()
    if query[0] == '1':
        s = s[::-1]
    else:
        if query[2] == '1':
            # 先頭
            s = ''.join([query[4],s])
        else:
            # 末尾
            s = ''.join([s,query[4]])
print(s)

Submission status: Runtime Error

Solution code:
from collections import deque

s = deque()
s.append(input())
q = int(input())

reverse_status = False

for i in range(q):
  query = list(map(format, input().split()))
  if int(query[0]) == 1:
    if reverse_status:
      reverse_status = False
    else:
      reverse_status = True
  else:
    if int(query[1]) == 1:
      if reverse_status:
        s.append(query[2])
      else:
        s.appendleft(query[2])
    else:
      if reverse_status:
        s.appendleft(query[2])
      else:
        s.append(query[2])

if reverse_status:
  s.reverse()
print(''.join(s))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
S = {S1, S2, S3}
if S1 == S2 == S3
	print('No')
else
	print('Yes')

Submission status: Runtime Error

Solution code:
if __name__ == '__main__':
    s = input()
    n = int(input())
    for _ in range(n):
        q = input().split()
        if q[0] == '1':
            s = s[::-1]
        else:
            if q[1] == '1':
                s = q[2]+s
            else:
                s = s+q[2]
    print(s)

Submission status: Runtime Error

Solution code:
S = {S1, S2, S3}
  if S1 == S2 == S3
	print('No')
  else
	print('Yes')

Submission status: Runtime Error

Solution code:
s=input()
if s == AAA :
    print("Yes")
elif s == ABB :
    print("Yes")
elif s == AAB :
    print("Yes")
elif s == ABA :
    print("Yes")
elif s == BAA :
    print("Yes")
elif s == BBA :
    print("Yes")
elif s == BAB :
    print("Yes")
else :
    print("No")

Submission status: Runtime Error

Solution code:
g=input()
f = list(g)
h =set(f)
k = list(h)
if len(h)==1:
  print('No')
else :  
print('Yes')

Submission status: Runtime Error

Solution code:
N,A,B = map(int,input().split())

Line1 = ("b"*A+"r"*B)
Line2 = ("b"*A+"r"*B)
Cnt = 0
while Cnt < N/(A+B):
	Line2 += Line1
	Cnt += 1

print(Line2[:N].count("b"))

Submission status: Runtime Error

Solution code:
N,A,B = [int(x) for x in input().split()]
n = 0
blue = 0
if A == 0:
    print(0)
else:
    for i in range(10**5):
        n = n + A
        blue = blue + A
        if n >= N:
            blue = blue - (n-N)
            break
        else:
            n = n + B
            if n >= N:
                break
    print(blue)

Submission status: Runtime Error

Solution code:
n, p = map(int,input().split())
s = input()
count = 0
for i in range(1, n + 1):
    for j in range(n - i + 1):
        num = 0
        for k in range(i):
            num += int(s[j + k]) * (10 ** (i - k - 1))
        if(num % p == 0):
            count += 1
print(count)

Submission status: Runtime Error

Solution code:
S = input()
S = int(S)
g=input()
f = list(g)
if len(f) == S:
  h =set(f)
  k = list(h)
  if len(h)==1:
    print('No')
  else :
    print('Yes')
else:
  pass

Submission status: Runtime Error

Solution code:
def main():

    S = input().split()
    Q = int(input())

    # for _ in range(Q):
    #     q = input().split()
    #     if q[0] == '1':
    #         S.reverse()
    #     elif q[0] == '2':
    #         if q[1] == '1':
    #             tmp = [q[2]]
    #             tmp.extend(S)
    #             S = tmp
    #         elif q[1] == '2':
    #             S.append(q[2])
    # print("".join(S))
    q_list = []
    for _ in range(Q):
        q_list.append(input().split())

    for q in q_list:
        if q[0] == '1':
            S.reverse()
        elif q[0] == '2':
            if q[1] == '1':
                tmp = [q[2]]
                tmp.extend(S)
                S = tmp
            elif q[1] == '2':
                S.append(q[2])
    print("".join(S))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
s = input()
if s == AAA :
    print("Yes")
elif s == ABB :
    print("Yes")
elif s == AAB :
    print("Yes")
elif s == ABA :
    print("Yes")
elif s == BAA :
    print("Yes")
elif s == BBA :
    print("Yes")
elif s == BAB :
    print("Yes")
else :
    print("No")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
S = input()
g=input()
f = list(g)
h =set(f)
k = list(h)
if len(h)==1:
  print('No')
else :
  print('Yes')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
s = input()
n = input()
q = [0]*int(n)
 
for i in range(0,int(n)):
  q[i] = input().split()
  
for i in range(0,int(n)):
  if(q[i][0] == "1"):
    s = s[::-1]
  elif(q[i][0] == "2"):
    if(q[i][1] == "1"):
      s = q[i][2] + s
    else:
      s = s + q[i][2]
 
print(s)

Submission status: Runtime Error

Solution code:
initInput = input()
tmpList = initInput.split()
inputN = int(tmpList[0])
inputA = int(tmpList[1])
inputB = int(tmpList[2])
arrayList = []
num = 0
arrayNum = 0
blueballNum = 0
while len(arrayList)  < inputN:
    if num % 2 == 0:
        for a in range(inputA):
            arrayList = arrayList +  ['a']
            arrayNum = arrayNum + 1
            blueballNum = blueballNum + 1
    else:
        for b in range(inputB):
            arrayList = arrayList +  ['b']
            arrayNum = arrayNum + 1

    num += 1

blueballNum = blueballNum - (len(arrayList) - inputN)
    
print(blueballNum)

Submission status: Runtime Error

Solution code:
if S == AAA
	print('No')
if S == AAB
	print('Yes')
if S == ABA
	print('Yes')
if S == ABB
	print('Yes')
if S == BAA
	print('Yes')
if S == BAB
	printF('Yes')
if S == BBA
	print('Yes')
if S == BBB
	print('No')

Submission status: Runtime Error

Solution code:
S = input()
g=input()
f = list(g)
print(f)
h =set(f)
k = list(h)
if len(k)==1:
  print('Yes')
else :
  print('No')

Submission status: Runtime Error

Solution code:
letter=list(input())
n=int(input())
for i in range(n):
    ope=input().split(" ")
    o1=int(ope[0])
    if o1 ==1:
        letter.reverse()
    else:
        o2,o3_s=int(ope[1]),ope[2]
        if o2==1:
            for j in range( 1,len(o3_s)+1):
                letter.insert(0,o3_s[len(o3_s)-j])
        else:
            for j in range(len(o3_s)):
                letter.append(o3_s[j])
print("".join(letter))

Submission status: Runtime Error

Solution code:
N, A, B = input().split()

n = int(N / (A + B))

if(N <= A+B):
    print(A)
else:
    print(N - B*n)

Submission status: Runtime Error

Solution code:
s = input()
if s in A:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
import sys
n,a,b = map(int,input().split())
if a == 0:
    print(0)
elif b == 0:
    print(n)
elif a + b>n:
    print(a)
else:
    c = n//(a+b)
    d = n%(a+b)
    if a>d:
        print(c*a+d)
    else:
        print(c*a + a)

Submission status: Runtime Error

Solution code:
S = input()
g=input()
f = list(g)
h =set(f)
if len(h)==1:
  print('No')
else :
  print('Yes')

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())

n = int(N / (A + B))

if(N <= A + B):
    print(A)
else:
    print(N - B * n)

Submission status: Runtime Error

Solution code:
if len(set(input())==1:
       print("NO")
else:
       print("YES")

Submission status: Runtime Error

Solution code:
N,A,B = map(int,input().split())
One_line = ""
Line = ("b"*A+"r"*B)
Cnt = 0
while Cnt < N:
	One_line += Line
	Cnt += (A + B)

print(One_line[:N].count("b"))

Submission status: Runtime Error

Solution code:
S = input()
g=input()
f = list(g)
print(f)
h =set(f)
if len(h)=1:
  print('Yes')
else :
  print('No')

Submission status: Runtime Error

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

def keychange(dic,x):
    newdic = {}
    for k in dic:
        b = (k*10 + x) % p
        newdic[b] = dic[k]
    return newdic
dic = {}
count = 0
for i in range(n):
    x = s[i] % p
    dic = keychange(dic,x)
    if x in dic:
        dic[x] += 1
    else:
        dic[x] = 1
    if 0 in dic:
        count += dic[0]
print(count)

Submission status: Runtime Error

Solution code:
Flag =  0 
after = ""
S = input().split()
A = list("A","A","A")
B = list("B","B","B")
if(set(S) == set(A) or set(S) ==set(B)):
    print("No")
else:
    print(print("Yes")

Submission status: Runtime Error

Solution code:
S = input()
Q = int(input())
for _ in range(Q):
    query = input().split()
    if len(query) == 1:
        S = S[::-1]
        # print('Ti=1: ' + S)
    else:
        F = int(query[1])
        C = query[2]
        if F == 1:
            S = ''.join([C, S])
        elif F == 2:
            S = ''.join([S, C])
        # print('Ti=2: ' + S)

print(S)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())

n = int(N / (A + B))

if(N < A+B):
    print((n+1)*A)
elif(N == A+B):
    print(A)
else:
    print(N -B*n)

Submission status: Runtime Error

Solution code:
a8, a10 = input().split(' ')
a8 = int(a8)
a10 = int(a10)
 
value1 = int(a8 / 0.08)
value2 = int(a10 / 0.1)
if int(value1 * 0.1) == a10:
  print(value1)
elif int(value2 * 0.08 == a8):
  print(value2)
else:
  print(-1)

Submission status: Runtime Error

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

Submission status: Runtime Error

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


for i in range(q):
	tmp = input().split()
	if tmp[0] == '1':
		s = s[::-1] 
	else:
		if tmp[1] == '1':
			s = tmp[2] + s
		else:
			s = s + tmp[2]


print(s)

Submission status: Runtime Error

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

list_a=[]
for i in range(a):
    list_a+="a"
list_b=[]
for i in range(b):
    list_a+="b"

list=[]
for i in range(10**100):
    if len(list)>=n:
        break
    else:
        if i%2==0:
            list+=list_a
        else:
            list+=list_b
ans=0
for i in range(n):
    if list[i]=="a":
        ans+=1
    else:
        ()
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
Flag =  0 
after = ""
S = input().split()
if(all(S)):
    print("No")
else:
    print(print("Yes")

Submission status: Runtime Error

Solution code:
a, b = [int(c) for c in input().split(" ")]
S = input()
count = 0
for i in range(1, a):
  for j in range(0, a):
      if (j+i <= a+1):
          subStr = S[j:j+i]
          if (len(subStr) == i):
            if (int(subStr) % b == 0):
                count+=1
if (int(S) % b == 0):
    count+=1
print(count)

Submission status: Runtime Error

Solution code:
#
import sys
import math
#import numpy as np
import itertools

# いくつか入力
n,p = (int(i) for i in input().split())
# 空白区切りの数列をリストに代入
s = [int(i) for i in list(input())] 

answer = 0
#print(s)
for i in range(n):
    q=0
    for j in range(i,n):
        q=q*10+s[j]
        if q%p==0:
            answer += 1
print(answer)

Submission status: Runtime Error

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

list_a=[]
for i in range(a):
    list_a+="a"
list_b=[]
for i in range(b):
    list_a+="b"

list=[]
for i in range(10**100):
    if len(list)>=n:
        break
    else:
        if i%2==0:
            list+=list_a
        else:
            list+=list_b
ans=0
for i in range(n):
    if list[i]=="a":
        ans+=1
    else:
        ()
print(*list)
print(ans)

Submission status: Runtime Error

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**9)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,p = na()
s = ns()
s = list(s)
ans = 0

seenRemainders = [[] for k in range(n)] #長さn
for i in range(n):
    remainder = 0
    prefixesFound = 0
    for j in range(i,n):
        remainder = (10 * remainder + int(s[j])) % p
        if remainder in seenRemainders[j]:
            break
        seenRemainders[j].append(remainder)
        if remainder == 0:
            prefixesFound+=1
    ans += prefixesFound * (prefixesFound + 1) // 2

print(ans)

Submission status: Runtime Error

Solution code:
s = input()
n = int(input())
print(n)
for i in range(n):
    li = input().split()
    if(li[0] == '1'):
        s = s[::-1]
    else:
        if(li[1] == '1'):
            s = li[2] + s
        else:
            s = s + li[2]
print(s)

Submission status: Runtime Error

Solution code:
letter=input()
n=int(input())
for i in range(n):
    ope=input().split(" ")
    o1=int(ope[0])
    if o1 ==1:
        letter="".join(list(reversed(letter)))
    else:
        o2,o3_s=int(ope[1]),ope[2]
        if o2==1:
            letter=o3_s+letter
        else:
            letter=letter+o3_s
print(letter)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
 
 
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    a = input()
    Q = int(input())
    qs = [input().split() for _ in range(Q)]
    ans = a
    revcount = 0
    for q in qs:
        if len(q) == 1:
            revcount += 1
        else:
            if int(q[1]) == 1:
                if revcount % 2 == 0:
                    ans = q[2] + ans
                else:
                    ans = ans + q[2]
            else:
                if revcount % 2 == 0:
                    ans = ans + q[2]
                else:
                    ans = q[2] + ans
    if revcount % 2 == 1:
        ans = ans[::-1]
    print(ans)
    return
 
 
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
S = input()
N = int(input())
Q =[]
flag = True
while True:
    try:
        Q.append(list(map(str,input().split())))

    except:
        break;

for i in range(N):
    if Q[i][0]=="1":
        flag = not(flag)                
    else: 
        if Q[i][1] == "2" and flag == True:
            S += Q[i][2]#先頭
            
        
        elif Q[i][1] == "2" and flag == False:
            S1 = Q[i][2]+ S
            S = S1
            
        elif Q[i][1] == "1" and flag == True:
            S1 = Q[i][2]+S
            S = S1
            
        elif Q[i][1] == "1" and flag == False:
            S += Q[i][2]

if flag == True:
    print(S)
else:
    print(S[::-1])

Submission status: Runtime Error

Solution code:
import numpy as np
import math

def main():
    a, b = map(int, input().split())

    # print(a/0.08)

    a_ans = np.array([i for i in range(math.ceil(a/0.08), int((a+1)/0.08))])
    b_ans = np.array([j for j in range(math.ceil(b/0.1), int((b+1)/0.1))])

    # print(a_ans)
    # print(b_ans)
    #
    # print(a_ans * 0.08)
    # print(b_ans * 0.1)

    ans = set(a_ans) & set(b_ans)

    # print(ans)

    if ans == set():
        print(-1)
    else:
        print(min(ans))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
S = input()
if len(S)==3 and S.count('A')==2 or S.count('B')==2:
  print('Yes')
else
print('No')

Submission status: Runtime Error

Solution code:
A, B = map(int, input().split())

ans1 = int(A *100// 8) 
ans2 = int(B *100 // 10)

if ans1 = ans2:
    print(ans1)

elif ans1 > ans2:
    ans2_2 = int((B+1) *100 // 10)
    list = [int(ans2)]

    for i in range(ans2+1,ans2_2):
        list.append(int(i)) 
    
    if int(ans1) in list:
        print(ans1)
    else:
        print(-1)
elif ans1 < ans2:
    ans1_2 = int((A+1) *100 // 8)
    list = [int(ans1)]

    for i in range(ans1+1,ans1_2):
        list.append(int(i)) 
    
    if int(ans2) in list:
        print(ans2)
    else:
        print(-1)