Problem:
 Score : 100 points    Problem Statement You are given a string S consisting of letters b , d , p and q .
Determine whether S is a mirror string .  Here, a mirror string is a string S such that the following sequence of operations on S results in the same string S :    Reverse the order of the characters in S .    Replace each occurrence of b by d , d by b , p by q , and q by p , simultaneously.        Constraints  1 \leq |S| \leq 10^5  S consists of letters b , d , p , and q .         Input The input is given from Standard Input in the following format:  S       Output If S is a mirror string, print Yes . Otherwise, print No .        Sample Input 1 pdbq      Sample Output 1 Yes       Sample Input 2 ppqb      Sample Output 2 No

Solution (Python):
s = input()
t = s[::-1]
u = ''
for i in range(len(s)):
  if t[i] == 'b':
    u += 'd'
  elif t[i] == 'd':
    u += 'b'
  elif t[i] == 'p':
    u += 'q'
  elif t[i] == 'q':
    u += 'p'
if s == u:
  print('Yes')
else:
  print('No')

Solution (Python):
s = list(input())
t = list(s[::-1])
for i in range(len(s)):
    if t[i] == 'b':
        t[i] = 'd'
    elif t[i] == 'd':
        t[i] = 'b'
    elif t[i] == 'p':
        t[i] = 'q'
    else:
        t[i] = 'p'
if s == t:
    print('Yes')
else:
    print('No')

Solution (Python):
dic = {'p': 'q', 'q': 'p', 'b': 'd', 'd': 'b'}
s = input()
t = ''
for i in range(1, len(s) + 1):
  t += dic[s[-i]]
if t == s:
  print('Yes')
else:
  print('No')

Solution (Python):
b='b'
d='d'
p='p'
q='q'
m=[(b,d),(p,q),(d,b),(q,p)]
ans='Yes'
s=input()
if len(s)%2==1:
    ans='No'
else:
    A=s[:len(s)//2]
    B=s[len(s)//2:]
    B=B[::-1]
    for i in range(len(s)//2):
        if (A[i],B[i]) in m:
            continue
        else:
            ans='No'
print(ans)

Solution (Python):
S=list(input())
s=S[::-1]


for i in range(len(S)):
    if S[i]=="b":
        if s[i]!="d":
            print("No")
            exit()
    if S[i]=="d":
        if s[i]!="b":
            print("No")
            exit()
    if S[i]=="p":
        if s[i]!="q":
            print("No")
            exit()
    if S[i]=="q":
        if s[i]!="p":
            print("No")
            exit()
print("Yes")

Solution (Python):


import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

S = input()
N = len(S)

D = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}

T = list(S)[::-1]
for i in range(N):
    T[i] = D[T[i]]
T = ''.join(T)

if S == T:
    Yes()
else:
    No()

Solution (Python):
import copy
s = input()
original = copy.deepcopy(s)
s = list(s)
s.reverse()
s = "".join(s)
s = s.replace('b','x')
s = s.replace('d','b')
s = s.replace('x', 'd')
s = s.replace('q','x')
s = s.replace('p','q')
s = s.replace('x','p')
if s == original:
    print("Yes")
else:
    print("No")

Solution (Python):
s = input()
t = ""
for c in s:
    if c=='p':
        d='q'
    if c=='q':
        d='p'
    if c=='d':
        d='b'
    if c=='b':
        d='d'
    t = d + t
print("Yes" if s==t else "No")

Solution (Python):
def main():
    rev = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}
    S = input()
    if len(S) % 2 == 1:
        print("No")
        return
    for i in range(len(S)//2):
        if S[i] != rev[S[len(S)-1-i]]:
            print("No")
            return
    print("Yes")


if __name__ == "__main__":
    main()

Solution (Python):
s = list(input())
t = s[::-1]
for i, k in enumerate(t):
  if k == "b":
    t[i] = "d"
  elif k == "d":
    t[i] = "b"
  elif k == "p":
    t[i] = "q"
  elif k == "q":
    t[i] = "p"
if s == t:
  print("Yes")
else:
  print("No")

Solution (Python):
mp={'b':'d','d':'b','p':'q','q':'p'}
a=list(input())
b=list(a[::-1])
b=[mp[x] for x in b]
print("Yes" if a==b else "No");

Solution (Python):
S=input()
if len(S)&1:
  print("No")
  exit(0)
revS=S[::-1]
pairs={"p":"q","b":"d"}
for i in range(len(S)//2):
  if S[i] in pairs and pairs[S[i]]==revS[i]:
    continue
  elif revS[i] in pairs and pairs[revS[i]]==S[i]:
    continue
  else:
    print("No")
    break
else:
  print("Yes")

Solution (Python):
s = input()

w_s = s[::-1]

w_s = w_s.replace('b', '1')
w_s = w_s.replace('d', '2')
w_s = w_s.replace('p', '3')
w_s = w_s.replace('q', '4')

w_s = w_s.replace('1', 'd')
w_s = w_s.replace('2', 'b')
w_s = w_s.replace('3', 'q')
w_s = w_s.replace('4', 'p')

if s == w_s:
    print('Yes')
else:
    print('No')

Solution (Python):
s = input()
li = ["b","p","q","d"]
a = [li.index(i) for i in s]
b = [3 - i for i in a[::-1]]
if a ==b:
  print("Yes")
else:
  print("No")

Solution (Python):
s=list(input())
n=len(s)
if n%2==1:
    print('No')
else:
    k=n//2
    for i in range(k):
        if s[i]=='b' and not s[n-1-i]=='d':
            print('No')
            exit()
        if s[i]=='d' and not s[n-i-1]=='b':
            print('No')
            exit()   
        if s[i]=='p' and not s[n-1-i]=='q':
            print('No')
            exit()
        if s[i]=='q' and not s[n-i-1]=='p':
            print('No')
            exit() 
    print('Yes')

Solution (Python):
s = input()
t = s.translate(str.maketrans({'b':'d','d':'b','p':'q','q':'p'}))[::-1]
if s == t:
    print('Yes')
else:
    print('No')

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  s=S()
  t=s
  s=list(s)
  s.reverse()
  s=''.join(s)
  s=s.replace('b','1')
  s=s.replace('d','2')
  s=s.replace('p','3')
  s=s.replace('q','4')
  s=s.replace('1','d')
  s=s.replace('2','b')
  s=s.replace('3','q')
  s=s.replace('4','p')
  if s==t:
    return 'Yes'
  return 'No'


print(main())

Solution (Python):
def main():

    S = input()
    m = dict()
    m['d'] = 'b'
    m['b'] = 'd'
    m['p'] = 'q'
    m['q'] = 'p'

    T = ""
    for i in range(len(S)-1, -1, -1):
        T += m[S[i]]
    if T == S: return "Yes"
    return "No"

if __name__ == '__main__':
    print(main())

Solution (Python):
s = input().rstrip()
n = len(s)
if n % 2 == 1:
  print("No")
  exit()
for a, b in zip(s[:n//2], s[::-1]):
  if a == "p" and b == "q":
    continue
  elif a == "q" and b == "p":
    continue
  elif a == "b" and b == "d":
    continue
  elif a == "d" and b == "b":
    continue
  else:
    print("No")
    exit()
print("Yes")

Solution (Python):
s=input()
D=dict()
D["b"]="d"
D["d"]="b"
D["p"]="q"
D["q"]="p"
chk=True
for i in range(len(s)):
  if D[s[i]]!=s[-1-i]:
    chk=False
    break
print("Yes" if chk else "No")

Solution (Python):
S = input()
N = len(S)
S_ = ""
for i in range(N):
  S_ += S[N-1-i]
S_ = S_.replace("b","B")
S_ = S_.replace("d","b")
S_ = S_.replace("B","d")
S_ = S_.replace("p","P")
S_ = S_.replace("q","p")
S_ = S_.replace("P","q")
if S == S_:
  print("Yes")
else:
  print("No")

Solution (Python):
def swap(S, a, b):
    return S.replace(a, ".").replace(b, a).replace(".", b)

S = input()
T = swap(S[::-1], "b", "d")
T = swap(T, "p", "q")

if T == S:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

S = input().rstrip()

T = S[::-1]
T = T.replace('b','*').replace('d','b').replace('*','d')
T = T.replace('p','*').replace('q','p').replace('*','q')

answer = 'Yes' if S == T else 'No'
print(answer)

Solution (Python):
s = list(input())
t = s[::-1]
for i in range(len(t)):
  if t[i] == "p":
    t[i] = "q"
  elif t[i] == "q":
    t[i] = "p"
  if t[i] == "b":
    t[i] = "d"
  elif t[i] == "d":
    t[i] = "b" 
if s == t:
  ans = "Yes"
else:
  ans = "No"
print(ans)

Solution (Python):
mp={'b':'d','d':'b','p':'q','q':'p'};a=list(input());print("Yes"if a==[mp[x]for x in a[::-1]]else"No");

Solution (Python):
mp={'b':'d','d':'b','p':'q','q':'p'};a=list(input());b=list(a[::-1]);b=[mp[x] for x in b];print("Yes" if a==b else "No");

Solution (Python):
b='b'
d='d'
p='p'
q='q'
m=[(b,d),(p,q),(d,b),(q,p)]
ans='Yes'
s=input()
if len(s)%2==1:
    ans='No'
else:
    A=s[:len(s)//2]
    B=s[len(s)//2:]
    B=B[::-1]
    for i in range(len(s)//2):
        if (A[i],B[i]) in m:
            continue
        else:
            ans='No'
print(ans)

Solution (Python):
s = input()
if len(s) % 2 == 1:
    print("No")
else:
    for i, e in enumerate(s[:len(s) // 2]):
        rev = s[-i - 1]
        if e == "b" and rev != "d":
            break
        elif e == "d" and rev != "b":
            break
        elif e == "p" and rev != "q":
            break
        elif e == "q" and rev != "p":
            break
    else:
        print("Yes")
        exit()
    print("No")

Solution (Python):
n = list(input())

if len(n) % 2 == 0:
	for i in range(len(n)//2):
		if n[i] =="b":
			if n[-(i+1)] != "d":
				print("No")
				exit()
		elif n[i] == "p":
			if n[-(i+1)] != "q":
				print("No")
				exit()
		elif n[i] == "d":
			if n[-(i+1)] != "b":
				print("No")
				exit()
		elif n[i] == "q":
			if n[-(i+1)] != "p":
				print("No")
				exit()
	print("Yes")
else:
	print("No")

Solution (Python):
s=input()
print('Yes'if s==''.join(map(lambda c:{'b':'d','d':'b','p':'q','q':'p'}[c],reversed(s)))else'No')

Solution (Python):
s=input()
m={'b':'d','d':'b','p':'q','q':'p'}
print('Yes'if s==''.join(map(lambda c:m[c], reversed(s))) else 'No')

Solution (Python):
s=input();print("No"if s!=s[::-1].translate(str.maketrans({'b': 'd', 'd': 'b',"p":"q","q":"p"}))else"Yes")

Solution (Python):



def main():
    s = input()
    t = ''

    for si in s[::-1]:
        if si == 'b':
            t += 'd'
        elif si == 'd':
            t += 'b'
        elif si == 'p':
            t += 'q'
        elif si == 'q':
            t += 'p'

    if s == t:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Solution (Python):
s = input()
if s[::-1].translate(str.maketrans("bdpq","dbqp")) == s:
  print("Yes")
else:
  print("No")

Solution (Python):
Ss = input()

lenS = len(Ss)
for S1, S2 in zip(Ss[:(lenS+1)//2], Ss[lenS-(lenS+1)//2:][::-1]):
    if set([S1, S2]) not in [{'b', 'd'}, {'p', 'q'}]:
        print('No')
        break
else:
    print('Yes')

Solution (Python):
s=input()
d={'b':'d','d':'b','p':'q','q':'p'}
if len(s)%2!=0:
    print("No")
else:
    flag=True
    for idx in range(len(s)//2):
        if d[s[idx]]!=s[-idx-1]:
            print("No")
            flag=False
            break
    if flag:
        print("Yes")

Solution (Python):
from collections import deque
d = {
        'b': 'd',
        'd': 'b',
        'p': 'q',
        'q': 'p'
        }
s = deque(input())
if len(s) % 2:
    print("No")
    quit(0)
while len(s) > 1:
    l = s.popleft()
    r = s.pop()
    if r != d[l]:
        print("No")
        quit(0)
print("Yes")

Solution (Python):
s = input()
ss = s[::-1]
s3 = ""
for i,j in enumerate(ss):
  if j == "p":
      s3 += "q"
  elif j == "q":
      s3 += "p"
  elif j == "b":
      s3 += "d"
  else:
      s3 += "b"
if s == s3:
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import deque
mirrors = ["b","p","q","d"]
ans = True
S = list(raw_input())
if len(S) % 2 == 1:
  ans = False
else:
  for i in range(len(S)/2):
    if not(3-mirrors.index(S[i]) == mirrors.index(S[-(i+1)])):
      ans = False
      break
print "Yes" if ans else "No"

Solution (Python):
import sys

dct = {"b": "d", "d": "b", "p": "q", "q": "p"}
S = sys.stdin.readline().strip()
rev = ""
for s in S[::-1]:
    rev += dct[s]

if rev == S:
    print("Yes")
else:
    print("No")

Solution (Python):
S = input()
D = {"b": "d", "d": "b", "p": "q", "q": "p"}

X = "".join([D[s] for s in S])
if X[::-1] == S:
    print("Yes")
else:
    print("No")

Solution (Python):
dict={'b':'d','d':'b','p':'q','q':'p'}
s= input()
t=''.join(map(lambda x: dict[x],list(s[::-1])))
if s==t:
    print("Yes")
else :
    print("No")

Solution (Python):
dict = { 'b' : 'd', 'd' : 'b', 'p' : 'q', 'q' : 'p' }
s = raw_input()
t = ''.join(map(lambda x : dict[x], list(s[::-1])))
print ['No', 'Yes'][s == t]

Solution (Python):
dict = { 'b' : 'd', 'd' : 'b', 'p' : 'q', 'q' : 'p' }
s = raw_input()
t = ''.join(map(lambda x : dict[x], list(s[::-1])))
print ['No', 'Yes'][s == t]

Solution (Python):
t='bpdq';s=list(input());print('Yes'*(s[::-1]==[t[t.index(i)-2]for i in s])or'No')

Solution (Python):
t='bpdq';s=list(input());print('Yes'*(s[::-1]==[t[t.index(i)-2]for i in s])or'No')

Solution (Python):
s=list(input());print(['No','Yes'][s==[{'b':'d','d':'b','p':'q','q':'p'}[i]for i in s[::-1]]])

Solution (Python):
s = input()
x,ans = len(s),"Yes"
if x%2==1: ans = "No"
else:
  for i in range(x//2):
    if s[i]=="b" and s[x-i-1]!="d": ans = "No"
    elif s[i]=="d" and s[x-i-1]!="b": ans = "No"
    elif s[i]=="p" and s[x-i-1]!="q": ans = "No"
    elif s[i]=="q" and s[x-i-1]!="p": ans = "No"
print(ans)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**3
eps = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    s = S()
    l = len(s)
    h = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}
    if l % 2 == 1:
        return 'No'
    for i in range(l//2):
        if s[i] != h[s[l-i-1]]:
            return 'No'

    return 'Yes'




print(main())

Solution (Python):
import math
import sys

def getinputdata():

    
    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = 1

    try:
        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result

arr_data = getinputdata()
s = arr_data[0][0]




print("Yes" if s == s[::-1].translate(str.maketrans('bdpq', 'dbqp')) else "No")

Solution (Python):
S = input()
N = len(S)
if N%2:
    print('No')
    exit()

D = {'b':'d','d':'b','p':'q','q':'p'}
for i in range(N//2):
    if D[S[i]] != S[-i-1]:
        print('No')
        exit()
print('Yes')

Solution (Python):

import sys
S = list(input())
a = list(reversed(S))
for tmp in range(len(a)):
    if a[tmp] == 'b':
        a[tmp] = 'd'
    elif a[tmp] == 'd':
        a[tmp] = 'b'
    elif a[tmp] == 'p':
        a[tmp] = 'q'
    else:
        a[tmp] = 'p'

    if S[tmp] != a[tmp]:
        print("No")
        sys.exit()

print("Yes")

Solution (Python):
s = list(input())
sr = list(reversed(s))
t = len(s)//2
for i in range(t+1):
    if not (s[i] == "b" and sr[i] == "d" or s[i] == "d" and sr[i] == "b" or s[i] == "p" and sr[i] == "q" or s[i] == "q" and sr[i] == "p"):
        print("No")
        break
else:
    print("Yes")

Solution (Python):
r=str.replace
s=input()
print(['No','Yes'][s==''.join(reversed(r(r(r(r(r(r(r(r(s,'b','0'),'d','1'),'p','2'),'q','3'),'0','d'),'1','b'),'2','q'),'3','p')))])

Solution (Python):
def transform(s):
    s = s[::-1]
    s = s.replace('b', '0').replace('d', 'b').replace('0', 'd')
    s = s.replace('p', '0').replace('q', 'p').replace('0', 'q')
    return s

s = input()
if s == transform(s):
    print('Yes')
else:
    print('No')

Solution (Python):


S = input()

R = S[::-1].translate({
    ord(u'b'): u'd',
    ord(u'd'): u'b',
    ord(u'p'): u'q',
    ord(u'q'): u'p',
})

if S == R:
    print("Yes")
else:
    print("No")

Solution (Python):
m="bpdq"
s=list(raw_input())
print"Yes"*(s[::-1]==[m[m.index(e)-2]for e in s])or"No"

Solution (Python):
S=str(input())
sr=S[::-1]
sr=sr.replace('b','D')
sr=sr.replace('d','B')
sr=sr.replace('p','Q')
sr=sr.replace('q','P')

sr=sr.replace('D','d')
sr=sr.replace('B','b')
sr=sr.replace('P','p')
sr=sr.replace('Q','q')

if S==sr:
    print('Yes')
else:
    print('No')

Solution (Python):
s=input()
if len(s)%2==0:
    for i in range(len(s)):
        if s[i]=='p' and s[-1-i]!='q' or s[i]=='q' and s[-1-i]!='p' or s[i]=='d' and s[-1-i]!='b' or s[i]=='b' and s[-1-i]!='d':
                print('No')
                break
    else:
        print('Yes')
else:
    print('No')

Solution (Python):
S = input()
T = S[::-1]
T = list(T)
for i in range(len(T)):
    if T[i] == "b":
        T[i] = "d"
    elif T[i] == "d":
        T[i] = "b"
    elif T[i] == "p":
        T[i] = "q"
    elif T[i] == "q":
        T[i] = "p"
T = "".join(T)
if S == T:
    print("Yes")
else:
    print("No")

Solution (Python):
s = input()
rs = ''.join(['d' if(c=='b') else 'b' if(c=='d') else 'q' if(c=='p') else 'p' for c in s[::-1]])
ans = 'Yes' if(s == rs) else 'No'
print(ans)

Solution (Python):
import string
s = input()
s2 = s[::-1]
dst = s2.translate(str.maketrans('bdpq', 'dbqp'))
if (s == dst):
    print('Yes')
else:
    print('No')

Solution (Python):
from sys import stdin
ans = 'Yes'
di = {}
di['b'] = 1
di['d'] = -1
di['p'] = 2
di['q'] = -2
a = stdin.readline().strip()
l = len(a)
if l%2:
 ans = 'No'
else:
 for i in xrange(l/2):
  if di[a[i]] + di[a[l-1-i]]:
   ans = 'No'
print ans

Solution (Python):
S = raw_input()
flag = True
if len(S) % 2 == 1:
    flag = False
else:
    for i in range(len(S)/2):
        if S[i] == "b":
            if S[-i-1] != "d":
                flag = False
                break
        elif S[i] == "d":
            if S[-i-1] != "b":
                flag = False
                break
        elif S[i] == "p":
            if S[-i-1] != "q":
                flag = False
                break
        else:
            if S[-i-1] != "p":
                flag = False
                break
       

if flag:
    print "Yes"
else:
    print "No"

Solution (Python):
s = raw_input().rstrip()
t = s
s = s[::-1]
s = s.replace("b", "t")
s = s.replace("p", "s")
s = s.replace("d", "b")
s = s.replace("q", "p")
s = s.replace("t", "d")
s = s.replace("s", "q")
print ((s == t) * "Yes") or "No"

Solution (Python):
s=input()
t=s[::-1]
k=""
for c in t:
	if c=='b':k+='d'
	elif c=='d':k+='b'
	elif c=='p':k+='q'
	elif c=='q':k+='p'
if s==k:
	print("Yes")
else:print("No")

Solution (Python):
d = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}
S = raw_input()
T = ''.join(map(lambda x:d[x], list(S[::-1])))
print 'Yes' if S == T else 'No'