Problem:


  MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});

Transformation

  Write a program which performs a sequence of commands to a given string $str$. The command is one of:

print a b: print from the a-th character to the b-th character of $str$

reverse a b: reverse from the a-th character to the b-th character of $str$

replace a b p: replace from the a-th character to the b-th character of $str$ with p

  Note that the indices of $str$ start with 0.

Input

  In the first line, a string $str$ is given. $str$ consists of lowercase letters. In the second line, the number of commands q is given. In the next q lines, each command is given in the above mentioned format.

Output

For each print command, print a string in a line.

Constraints

$1 \leq $ length of $str \leq 1000$

$1 \leq q \leq 100$

$0 \leq a \leq b < $ length of $str$

for replace command, $b - a + 1 = $ length of $p$

Sample Input 1

abcde
3
replace 1 3 xyz
reverse 0 2
print 1 4

Sample Output 1

xaze

Sample Input 2

xyz
3
print 0 2
replace 0 2 abc
print 0 2

Sample Output 2

xyz
abc



Sample input:
abcde
3
replace 1 3 xyz
reverse 0 2
print 1 4


Sample output:
xaze

Submission status: Wrong Answer

Solution code:
def main():

    strTxt = input()
    n = int(input())
    for _ in range(n):
        strCmd = input().split()
        
        if strCmd[0] == 'print':
            funcPrint(strTxt, int(strCmd[1]), int(strCmd[2]))
        elif strCmd[0] == 'reverse':
            strTxt = funcReverse(strTxt, int(strCmd[1]), int(strCmd[2]))
            print(strTxt)
        elif strCmd[0] == 'replace':
            strTxt = funcReplace(strTxt, int(strCmd[1]), int(strCmd[2]), strCmd[3])
            print(strTxt)


def funcPrint(strInput: str,a: int,b: int):
    print(strInput[a:b+1])

def funcReverse(strInput: str,a: int,b: int):
#    print(strInput[:a]+strInput[b:a:-1]+strInput[b:])
    if a == 0:
        return strInput[b::-1]+strInput[b+1:]
    else:
        return strInput[:a]+strInput[b:a-1:-1]+strInput[b+1:]

def funcReplace(strInput: str,a: int,b: int, strAfter: str):
    return strInput[:a]+strAfter+strInput[b+1:]


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():

    strTxt = input()
    n = int(input())
    for _ in range(n):
        strCmd = input().split()
        
        if strCmd[0] == 'print':
            funcPrint(strTxt, int(strCmd[1]), int(strCmd[2]))
        elif strCmd[0] == 'reverse':
            strTxt = funcReverse(strTxt, int(strCmd[1]), int(strCmd[2]))
        elif strCmd[0] == 'replace':
            strTxt = funcReplace(strTxt, int(strCmd[1]), int(strCmd[2]), strCmd[3])

def funcPrint(strInput: str,a: int,b: int):
    print(strInput[a:b+1])

def funcReverse(strInput: str,a: int,b: int):
    return strInput[:a]+strInput[::-1][a:b]+strInput[b+1:]

def funcReplace(strInput: str,a: int,b: int, strAfter: str):
    return strInput[:a]+strAfter+strInput[b+1:]


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():

    strTxt = input()
    n = int(input())
    for _ in range(n):
        strCmd = input().split()
        
        if strCmd[0] == 'print':
            funcPrint(strTxt, int(strCmd[1]), int(strCmd[2]))
        elif strCmd[0] == 'reverse':
            strTxt = funcReverse(strTxt, int(strCmd[1]), int(strCmd[2]))
        elif strCmd[0] == 'replace':
            strTxt = funcReplace(strTxt, int(strCmd[1]), int(strCmd[2]), strCmd[3])

def funcPrint(strInput: str,a: int,b: int):
    print(strInput[a:b+1])

def funcReverse(strInput: str,a: int,b: int):
    return strInput[:a]+strInput[::-1][a:b+1]+strInput[b+1:]

def funcReplace(strInput: str,a: int,b: int, strAfter: str):
    return strInput[:a]+strAfter+strInput[b+1:]


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    string = input()
    q = int(input())
    for _ in range(q):
        command = input().split()
        if command[0] == 'print':
            print(string[int(command[1]):int(command[2])+1])
        elif command[0] == 'reverse':
            string = string[:int(command[1])] + string[int(command[2]):int(command[1])-1 if int(command[1])-1 is not -1 else None :-1] + string[int(command[2])+1:]
        else:
            string = string.replace(string[int(command[1]):int(command[2])+1], command[3])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    string = input()
    q = int(input())
    for _ in range(q):
        command = input().split()
        a = int(command[1])
        b = int(command[2])
        if command[0] == 'print':
            print(string[a:b+1])
        elif command[0] == 'reverse':
            if a == b:
                reversed_string = string[a]
            else:
                c = a-1 if a is not 0 else None
                reversed_string = string[b:c:-1]
            string = string[:a] + reversed_string + string[b+1:]
        elif command[0] == 'replace':
            string = string.replace(string[a:b+1], command[3])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
s = raw_input()
n = int(raw_input())
print s
for i in range(n):
    tmp = raw_input().split()
    tmp[1] = int(tmp[1])
    tmp[2] = int(tmp[2])
    if tmp[0] == "replace":
        s = s[:tmp[1]] + tmp[3] + s[tmp[2]+1:]
    elif tmp[0] == "reverse":
        s = s[:tmp[1]] + s[tmp[2]:tmp[1]:-1] + s[tmp[1]] + s[tmp[2]+1:]
    else:
        print s[tmp[1]:tmp[2]+1]

Submission status: Wrong Answer

Solution code:
S = str(input())
N = int(input())
for _i in range(N):
    line = input().split()
    start = int(line[1])
    end = int(line[2])

    if line[0] == 'print':
        print(S[start:end + 1])
    if line[0] == 'reverse':
        reversed_word = list(S[start:end + 1])
        reversed_word.reverse()
        S = S[:start] + ''.join(reversed_word) + S[end + 1:]
    if line[0] == 'replace':
        S = S[:start] + line[3] + S[end + 1:]
        print(S)

Submission status: Wrong Answer

Solution code:
s = input()
n = int(input())
for i in range(n):
    order, a, b, *c = input().split()
    a = int(a)
    b = int(b)
    print(c)
    if order == 'replace':
        s = s[:a] + c[0] + s[b+1:]
        print(s)
    elif order[0] == 'r':
        s = s[:0] + s[::-1][len(s)-b-1:len(s)-a] + s[b+1:]
        print(s)
    else:
        print(s[a:b+1])

Submission status: Wrong Answer

Solution code:
s = input()
n = int(input())
for i in range(n):
    order, a, b, *c = input().split()
    a = int(a)
    b = int(b)
    if order == 'replace':
        s = s[:a] + c[0] + s[b+1:]
    elif order[0] == 'r':
        s = s[:0] + s[::-1][len(s)-b-1:len(s)-a] + s[b+1:]
    else:
        print(s[a:b+1])

Submission status: Wrong Answer

Solution code:
#coding: UTF-8

str = input()
q = int(input())

for i in range(q):
    line = list(input().split())
    if line[0] == 'replace':
        a = int(line[1])
        b = int(line[2])
        p = line[3]
        str = str.replace(str[a:b], p)
    elif line[0] == 'reverse':
        a = int(line[1])
        b = int(line[2])
        str[b:a:-1]
    else:
        a = int(line[1])
        b = int(line[2])
        print(str[a:b])

Submission status: Wrong Answer

Solution code:
#coding: UTF-8

str = input()
q = int(input())

for i in range(q):
    line = list(input().split())
    if line[0] == 'replace':
        a = int(line[1])
        b = int(line[2])
        p = line[3]
        str = str.replace(str[a:b], p)
    elif line[0] == 'reverse':
        a = int(line[1])
        b = int(line[2])
        str = str[b:a:-1]
    else:
        a = int(line[1])
        b = int(line[2])
        print(str[a:b])

Submission status: Wrong Answer

Solution code:
#coding: UTF-8

str = input()
q = int(input())

for i in range(q):
    line = list(input().split())
    if line[0] == 'replace':
        a = int(line[1])
        b = int(line[2])
        p = line[3]
        str = str.replace(str[a:b], p)
    elif line[0] == 'reverse':
        a = int(line[1])
        b = int(line[2])
        rev = str[b:a:-1]
        str = str[:a+1] + rev + str[b+1:]
    else:
        a = int(line[1])
        b = int(line[2])
        print(str[a:b])

Submission status: Wrong Answer

Solution code:
#coding: UTF-8

str = input()
q = int(input())

for i in range(q):
    line = list(input().split())
    if line[0] == 'replace':
        a = int(line[1])
        b = int(line[2])
        p = line[3]
        str = str.replace(str[a:b+1], p)
    elif line[0] == 'reverse':
        a = int(line[1])
        b = int(line[2])
        rev = str[b:a-1:-1]
        str = str[:a] + rev + str[b+1:-1]
    else:
        a = int(line[1])
        b = int(line[2])
        print(str[a:b+3])

Submission status: Wrong Answer

Solution code:
letters = input()
num = int(input())
for i in range(num):
    order = input().split()
    if order[0] == 'print':
        print(letters[int(order[1]):int(order[2])+1])
    if order[0] == 'reverse':
        letters_list = list(letters)
        a = letters_list[int(order[1])]
        letters_list[int(order[1])] = letters_list[int(order[2])]
        letters_list[int(order[2])] = a
        letters = ''.join(letters_list)
    if order[0] == 'replace':
        letters = letters[:int(order[1])] + order[3] + letters[int(order[2])+1:]

Submission status: Wrong Answer

Solution code:
def op_print(data,a,b):
    for i in range(a,b-2):
        print(data[i],end="")
    print()
def op_reverse(data,a,b):
    return data[:a] + data[::-1][-b:-a] + data[:b]
def op_replace(data,a,b,q):
    return data.replace(data[a:b],q) 

data = input()
q = int(input())
for _ in range(q):
    op = list(map(str,input().split()))
    if(op[0] == "print"):
        op_print(data,int(op[1]),int(op[2]))
    elif(op[0] == "reverse"):
        data = op_reverse(data,int(op[1]),int(op[2]))
    elif(op[0] == "replace"):
        data = op_replace(data,int(op[1]),int(op[2]),op[3])

Submission status: Wrong Answer

Solution code:
def op_print(data,a,b):
    for i in range(a,b):
        print(data[i],end="")
    print()
def op_reverse(data,a,b):
    return data[:a] + data[::-1][-b:-a] + data[:b]
def op_replace(data,a,b,q):
    return data.replace(data[a:b],q) 

data = input()
q = int(input())
for _ in range(q):
    op = list(map(str,input().split()))
    if(op[0] == "print"):
        op_print(data,int(op[1]),int(op[2])-2)
    elif(op[0] == "reverse"):
        data = op_reverse(data,int(op[1]),int(op[2]))
    elif(op[0] == "replace"):
        data = op_replace(data,int(op[1]),int(op[2]),op[3])

Submission status: Wrong Answer

Solution code:
def op_print(data,a,b):
    for i in range(a,b):
        print(data[i-2],end="")
    print()
def op_reverse(data,a,b):
    return data[:a] + data[::-1][-b:-a] + data[:b]
def op_replace(data,a,b,q):
    return data.replace(data[a:b],q) 

data = input()
q = int(input())
for _ in range(q):
    op = list(map(str,input().split()))
    if(op[0] == "print"):
        op_print(data,int(op[1]),int(op[2]))
    elif(op[0] == "reverse"):
        data = op_reverse(data,int(op[1]),int(op[2]))
    elif(op[0] == "replace"):
        data = op_replace(data,int(op[1]),int(op[2]),op[3])

Submission status: Wrong Answer

Solution code:
def op_print(data,a,b):
    print(data[a:b])
def op_reverse(data,a,b):
    return data[:a] + data[::-1][-b:-a] + data[:b]
def op_replace(data,a,b,q):
    return data.replace(data[a:b],q) 

data = input()
q = int(input())
for _ in range(q):
    op = list(map(str,input().split()))
    if(op[0] == "print"):
        op_print(data,int(op[1]),int(op[2]))
    elif(op[0] == "reverse"):
        data = op_reverse(data,int(op[1]),int(op[2]))
    elif(op[0] == "replace"):
        data = op_replace(data,int(op[1]),int(op[2]),op[3])

Submission status: Wrong Answer

Solution code:
def op_print(data,a,b):
    print(data[a:b])
def op_reverse(data,a,b):
    return data[:a] + data[::-1][-b:-a] + data[:b]
def op_replace(data,a,b,q):
    return data.replace(data[a:b],q) 

data = input()
q = int(input())
for _ in range(q):
    op = list(map(str,input().split()))
    op[2] = str(int(op[2])+1)
    if(op[0] == "print"):
        op_print(data,int(op[1]),int(op[2]))
    elif(op[0] == "reverse"):
        data = op_reverse(data,int(op[1]),int(op[2]))
    elif(op[0] == "replace"):
        data = op_replace(data,int(op[1]),int(op[2]),op[3])

Submission status: Wrong Answer

Solution code:
def op_print(data,a,b):
    print(data[a:b])
def op_reverse(data,a,b):
    return data[:a] + data[a:b][::-1] + data[:b]
def op_replace(data,a,b,q):
    return data.replace(data[a:b],q) 

data = input()
q = int(input())
for _ in range(q):
    op = list(map(str,input().split()))
    op[2] = str(int(op[2])+1)
    if(op[0] == "print"):
        op_print(data,int(op[1]),int(op[2]))
    elif(op[0] == "reverse"):
        data = op_reverse(data,int(op[1]),int(op[2]))
    elif(op[0] == "replace"):
        data = op_replace(data,int(op[1]),int(op[2]),op[3])

Submission status: Wrong Answer

Solution code:
def op_print(data,a,b):
    print(data[a:b])
def op_reverse(data,a,b):
    return data[:a] + data[a:b][::-1] + data[:b]
def op_replace(data,a,b,q):
    return data[:a] + q + data[b:]

data = input()
q = int(input())
for _ in range(q):
    op = list(map(str,input().split()))
    op[2] = str(int(op[2])+1)
    if(op[0] == "print"):
        op_print(data,int(op[1]),int(op[2]))
    elif(op[0] == "reverse"):
        data = op_reverse(data,int(op[1]),int(op[2]))
    elif(op[0] == "replace"):
        data = op_replace(data,int(op[1]),int(op[2]),op[3])

Submission status: Wrong Answer

Solution code:
def op_print(data,a,b):
    print(data[a:b])
def op_reverse(data,a,b):
    return data[:a] + data[a:b][::-1] + data[:b]
def op_replace(data,a,b,q):
    return data[:a] + q + data[b:]

data = input()
q = int(input())
for _ in range(q):
    op = list(map(str,input().split()))

    if(op[0] == "print"):
        op_print(data,int(op[1]),int(op[2])+1)
    elif(op[0] == "reverse"):
        data = op_reverse(data,int(op[1]),int(op[2])+1)
    elif(op[0] == "replace"):
        data = op_replace(data,int(op[1]),int(op[2])+1,op[3])

Submission status: Wrong Answer

Solution code:
data = input()
q = int(input())
for _ in range(q):
    op = list(map(str,input().split()))
    a = int(op[1])
    b = int(op[2]) + 1
    if(op[0] == "print"):
        print(data[a:b])
    elif(op[0] == "reverse"):
        data = data[:a] + data[a:b][::-1] + data[:b]
    elif(op[0] == "replace"):
        data = data[:a] + op[3] + data[b:]

Submission status: Wrong Answer

Solution code:
w=raw_input()
n=input()
l=['print','replace','reverse']
for i in range(n):
    c=map(str,raw_input().split())
    if c[0]==l[0]:
        print w[int(c[1]):int(c[2])+1]
    elif c[0]==l[1]:
        w=w[:int(c[1])]+c[3]+w[int(c[2])+1:]
    else:
        w=w[int(c[1]):int(c[2])+1][::-1]+w[int(c[2])+1:]

Submission status: Wrong Answer

Solution code:
tgtstr = list(raw_input())
n = int(raw_input())

for i in range(n):
    cmd_list = raw_input().split(" ")
    if cmd_list[0] == "replace":
        for idx in range(int(cmd_list[1]), int(cmd_list[2])+1):
            tgtstr[idx] = cmd_list[3][idx - int(cmd_list[1])]
    elif cmd_list[0] == "reverse ":
        start = end = int(cmd_list[1])
        end = int(cmd_list[2])
        while True:
            
            tmp = tgtstr[start]
            tgtstr[start] = tgtstr[end]
            tgtstr[start] = tmp
            start += 1
            end -= 1
            if start >= end:
                break

    elif cmd_list[0] == "print":
        print "".join(tgtstr[int(cmd_list[1]):int(cmd_list[2])+1])

Submission status: Wrong Answer

Solution code:
text = input()
count = int(input())

for c in range(count):
    args = input().split()
    (a,b) = [int(x) for x in args[1:3]]
    if args[0] == 'print':
        print(text[a:b + 1])
    elif args[0] == 'reverse':
        text = text[0:a] + text[a:b][::-1] + text[b + 1:]
    elif args[0] == 'replace':
        text = text[0:a] +  args[3] + text[b + 1:]

Submission status: Wrong Answer

Solution code:
s = raw_input( )
n = int( raw_input( ) )
for i in range( n ):
	cmd = raw_input( ).split( " " )
	a = int( cmd[1] )
	b = int( cmd[2] ) + 1
	if "print" == cmd[0]:
		print( "{:s}".format( s[ a:b ] ) )
	elif "reverse" == cmd[0]:
		s = s.replace( s[ a:b ], s[ a:b ][ ::-1] )
	elif "replace" == cmd[0]:
		s = s.replace( s[ a:b ], cmd[3] )

Submission status: Wrong Answer

Solution code:
s = input()
q = int(input())
for i in range(q):
    command = input().split()
    a, b = int(command[1]), int(command[2]) + 1
    if command[0] == "print":
        print(s[a:b])
    elif command[0] == "reverse":
        s = s[:a] + s[a:b:-1] + s[b:]
    elif command[0] == "replace":
        s = s[:a] + command[3] + s[b:]

Submission status: Wrong Answer

Solution code:
# coding=utf-8


def main():
    string = raw_input()
    for _ in xrange(input()):
        order = raw_input().split()
        a, b = map(int, order[1:3])
        if order[0] == 'print':
            print string[a:b+1]
        elif order[0] == 'reverse':
            # string = string[:a] + string[b:a-1:-1] + string[b+1:]
            string = string[:a] + string[a:b+1][::-1] + string[b+1:]
            print string
        elif order[0] == 'replace':
            string = string[:a] + order[3] + string[b:]
            print string



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
print 'xaze'

Submission status: Wrong Answer

Solution code:
# coding=utf-8

def main():
    string = raw_input()
    for _ in xrange(input()):
        order = raw_input().split()
        a, b = map(int, order[1:3])
        if order[0] == 'print':
            print string[a:b+1]
        elif order[0] == 'reverse':
            # string = string[:a] + string[b:a-1:-1] + string[b+1:]
            string = string[:a] + string[a:b+1][::-1] + string[b+1:]
            print string
        elif order[0] == 'replace':
            string = string[:a] + order[3] + string[b+1:]
            print string



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
string = input()
n = int(input())
for _ in range(n):
    query = input().split()
    if query[0] == 'replace':
        op, a, b, p = query
        a, b = int(a), int(b)
        string = string[:a] + p * (b - a + 1) + string[b + 1:]
    elif query[0] == 'reverse':
        op, a, b = query
        a, b = int(a), int(b)
        string = string[:a] + ''.join(reversed(string[a:b + 1])) + string[b + 1:]
    elif query[0] == 'print':
        op, a, b = query
        a, b = int(a), int(b)
        print(string[a: b + 1])

Submission status: Wrong Answer

Solution code:
str0 = raw_input()
q = int(raw_input())

for i in xrange(q):
  # print "###########################"
  # print "str0 = " + str0
  line = raw_input().split(" ")
  temp = str0[int(line[1]):int(line[2])+1]
  if line[0] == "print":
    print temp
  elif line[0] == "reverse":
    temp2 = [] 
    # print "temp = " + temp
    for j in xrange(len(temp)):
      temp2.append(temp[len(temp) - j - 1])
    str0 = str0[:int(line[1])] + "".join(temp2) + str0[int(line[2]) + 1:]
    # print "str0 = " + str0
  elif line[0] == "replace":
    str0 = str0.replace(temp, line[3])
    # print "str0 = " + str0

Submission status: Wrong Answer

Solution code:
s = raw_input()
Q = input()
for q in range(Q):
    str_order = raw_input().split()
    if str_order[0] == 'print':
        print s[int(str_order[1]):int(str_order[2])+1]
    elif str_order[0] == 'reverse':
        start = s[:int(str_order[1])]
        mid = s[int(str_order[1]):int(str_order[2])+1]
        mid = mid[::-1]
        end = s[int(str_order[2])+1:]
        s = start+mid+end
        print s
    elif str_order[0] == 'replace':
        start = s[:int(str_order[1])]
        mid = str_order[3]
        end = s[int(str_order[2])+1:]
        s = start+mid+end
        print s

Submission status: Wrong Answer

Solution code:
s = input()
n = int(input())
for _ in range(n):
    line = input().split()
    command, args = line[0], line[1:]
    if command == 'replace':
        start = int(args[0])
        end = int(args[1]) + 1
        s = s[:start] + args[2] + s[end:]
    elif command == 'reverse':
        start = int(args[0])
        end = int(args[1]) + 1
        s = s[:start] + str(''.join(list(reversed(s[start:end])))) + s[end:]
    elif command == 'print':
        print(s)

Submission status: Wrong Answer

Solution code:
instr = raw_input().strip()
commandnum = input()
print instr
print len(instr)
for c in xrange(commandnum):
    command = raw_input().split()
    print command
    if command[0]=="replace":
        instr = instr[:int(command[1])]+command[3]+instr[int(command[2])+1:]
        print instr
    elif command[0]=="reverse":
        instr = instr[:int(command[1])]+instr[int(command[1]):int(command[2])+1][::-1]+instr[int(command[2])+1:]
        print instr
    elif command[0]=="print":
        print instr[int(command[1]):int(command[2])+1]
    else:
        print "invalid command."
        break

Submission status: Wrong Answer

Solution code:
instr = raw_input().strip()
commandnum = input()
for c in xrange(commandnum):
    command = raw_input().split()
    print command
    if command[0]=="replace":
        instr = instr[:int(command[1])]+command[3]+instr[int(command[2])+1:]
    elif command[0]=="reverse":
        instr = instr[:int(command[1])]+instr[int(command[1]):int(command[2])+1][::-1]+instr[int(command[2])+1:]
    elif command[0]=="print":
        print instr[int(command[1]):int(command[2])+1]
    else:
        print "invalid command."
        break

Submission status: Wrong Answer

Solution code:
snt=input()
    
num=int(input())
        
for i in range(num):
 ops=input().split()
                
                
 if ops[0]=="replace":
    snt=snt.replace(snt[int(ops[1]):int(ops[2])+1],ops[3])

 elif ops[0]=="print":
    snt=snt[int(ops[1]):int(ops[2])+1]
    print(snt)


 elif ops[0]=="reverse":
     snt=snt[:int(ops[1])]+ snt[int(ops[1]):int(ops[2])+1][::-1]+ snt[int(ops[2]):]

print(snt)

Submission status: Wrong Answer

Solution code:
snt=input()
    
num=int(input())
        
for i in range(num):
 ops=input().split()
                
                
 if ops[0]=="replace":
    snt=snt.replace(snt[int(ops[1]):int(ops[2])+1],ops[3])

 elif ops[0]=="print":
    snt=snt[int(ops[1]):int(ops[2])+1]
    print(snt)


 elif ops[0]=="reverse":
     snt=snt[:int(ops[1])]+ snt[int(ops[1]):int(ops[2])+1][::-1]+ snt[int(ops[2]):]

Submission status: Wrong Answer

Solution code:
snt=input()
    
num=int(input())
        
for i in range(num):
 ops=input().split()
                
                
 if ops[0]=="replace":
    snt=snt.replace(snt[int(ops[1]):int(ops[2])+1],ops[3])

 elif ops[0]=="print":
    snt=snt[int(ops[1]):int(ops[2])+1]
    print(snt)


 elif ops[0]=="reverse":
     snt=snt[:int(ops[1])]+ snt[int(ops[1]):int(ops[2])+1][::-1]+ snt[int(ops[2])+1:]

Submission status: Wrong Answer

Solution code:
snt=input()
    
num=int(input())
        
for i in range(num):
 ops=input().split()
                
                
 if ops[0]=="replace":
    snt=snt.replace(snt[int(ops[1]):int(ops[2])+1],ops[3])

 elif ops[0]=="print":
    print(snt[int(ops[1]):int(ops[2])+1])


 elif ops[0]=="reverse":
     snt=snt[:int(ops[1])]+ snt[int(ops[1]):int(ops[2])+1][::-1]+ snt[int(ops[2])+1:]

Submission status: Wrong Answer

Solution code:
str = raw_input()
q = input()
for ans in range(q):
    ans = raw_input()
    ans1 = ans.split(' ')
    if ans1[0] == 'replace':
        str = str[0:int(ans1[1])]+ans1[3]+ str[int(ans1[2])+1:len(str)]
        print str
    if ans1[0] == 'reverse':
        str = str[int(ans1[1]):int(ans1[2])+1][::-1] + str[int(ans1[2])+1:len(str)]
        print str
    if ans1[0] == 'print':
        print str[int(ans1[1]):int(ans1[2])+1]

Submission status: Wrong Answer

Solution code:
str = raw_input()
q = input()
for ans in range(q):
    ans = raw_input()
    ans1 = ans.split(' ')
    if ans1[0] == 'replace':
        str = str[0:int(ans1[1])]+ans1[3]+ str[int(ans1[2])+1:len(str)]
    if ans1[0] == 'reverse':
        str = str[int(ans1[1]):int(ans1[2])+1][::-1] + str[int(ans1[2])+1:len(str)]
    if ans1[0] == 'print':
        print str[int(ans1[1]):int(ans1[2])+1]

Submission status: Wrong Answer

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

s = str(raw_input())
q = int(raw_input())
for i in range(q):
    line = map(str, raw_input().split())
    com = line[0]
    a = int(line[1])
    b = int(line[2])
    if com == "print":
        print s[a:b+1]
    elif com == "reverse":
        l = len(s)
        s = s[0:a] + s[-l+b:-l+a-1:-1] + s[b+1:]
    elif com == "replace":
        p = line[3]
        s = s.replace(s[a:b+1], p)
    else:
        print "Error"

Submission status: Wrong Answer

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

s = str(raw_input())
q = int(raw_input())
for i in range(q):
    line = map(str, raw_input().split())
    com = line[0]
    a = int(line[1])
    b = int(line[2])
    if com == "print":
        print s[a:b+1]
    elif com == "reverse":
        tmp = s[::-1]
        s = s[0:a] + tmp[len(tmp)-b-1:len(tmp)-a] + s[b+1:]
    elif com == "replace":
        p = line[3]
        s = s.replace(s[a:b+1], p)
    else:
        print "Error"

Submission status: Wrong Answer

Solution code:
s = raw_input()
n = input()

for i in xrange(n):
    c = raw_input().split()
    a = int(c[1])
    b = int(c[2])+1

    if c[0] == 'print' :
        print s[a:b]
    elif c[0] == 'reverse':
        d = s[a:b]
        s = d[::-1] + s[b:len(s)]
    elif c[0] == 'replace':
        s = s.replace(s[a:b],c[3])

Submission status: Wrong Answer

Solution code:
s = raw_input().rstrip()
q = input()
for i in range(q):
    o = raw_input().rstrip().split()
    a = int(o[1])
    b = int(o[2])
    if o[0] == 'replace':
        s = s[:a] + o[3]*(b - a) + s[b:]
    elif o[0] == 'reverse':
        s = s[:a] + s[a:b:-1] + s[b:]
    elif o[0] == 'print':
        print s[a:b+1]

Submission status: Wrong Answer

Solution code:
in_str = raw_input()
q = input()

for i in xrange(q):
    order = raw_input().split()
    a = int(order[1])
    b = int(order[2])+1

    if order[0] == "print":
        print in_str[a:b]
    if order[0] == "reverse":
        temp_str    = in_str[a:b]
        in_str = in_str.replace(in_str[a:b], temp_str[::-1])
    if order[0] == "replace":
        in_str = in_str.replace(in_str[a:b], order[3])

Submission status: Wrong Answer

Solution code:
#   ????????? str ?????????????????????????????????????????????????????????????????°??????

#   ?????\????±??????????str????¨??????\???????????????
str = list(input())
str = "".join(str)
#   ?????\???????????°p????¨??????\???????????????
p = int(input())
#   p??????????????????????????????????????????
orderList = [0 for i in range(p)]
for i in range(0, p):
    orderList[i] = list(input())
    orderList[i] = "".join(orderList[i]).split()
    if orderList[i][0] == "print":
        print("{0}".format(str[int(orderList[i][1]) - 1:int(orderList[i][2])]))
    elif orderList[i][0] == "reverse":
        str = str[0:int(orderList[i][1]) - 1] + str[-len(str) + int(orderList[i][2]) - 1:-len(str) + int(orderList[i][1]) - 2:-1] + str[int(orderList[i][2]):len(str)]
    elif orderList[i][0] == "replace":
        #   ??????????????¨?????????replace_str
        replace_str = str[:int(orderList[i][1]) - 1]
        for j in range(0, int(orderList[i][2])):
            replace_str += orderList[i][3]
        replace_str += str[int(orderList[i][2]):]
        str = replace_str

Submission status: Wrong Answer

Solution code:
# 21-String-Transformation.py

# ???????????????
# ????????? str ?????????????????????????????????????????????????????????????????°????????????????????????????????????
# ???????????\?????????????????????????????§??????

# print a b: str ??? a ??????????????? b ??????????????§??????????????????
# reverse a b: str ??? a ??????????????? b ??????????????§?????????????????????
# replace a b p: str ??? a ??????????????? b ??????????????§??? p ?????????????????????
# ????????§??????????????? str ????????????????????? 0 ???????????¨????????????

# Input
# 1 ?????????????????? str ????????????????????????str ?????±?°????????????????????????????
# 2 ????????????????????° q ?????????????????????????¶???? q ??????????????????????¨??????¢?????§?????????????????????

# Output
# ??? print ???????????¨???????????????????????????????????????????????????

# Constraints
# 1???str????????????1000
# 1???q???100
# 0???a???b<str?????????
# replace ????????§??? b???a+1=p?????????

# Sample Input 1
# abcde
# 3
# replace 1 3 xyz
# reverse 0 2
# print 1 4
# Sample Output 1
# xaze

# Sample Input 2
# xyz
# 3
# print 0 2
# replace 0 2 abc
# print 0 2
# Sample Output 2
# xyz
# abc

#??\???

str = input()
op_num = int( input() )
for i in range(op_num):
	op = input().split()
	a = int(op[1])
	b = int(op[2])
	if op[0]=="replace":
		str = str.replace(str[ a:b+1 ], op[3])
	elif op[0]=="reverse":
		str = str.replace(str[a:b+1], str[ b-len(str) : a-len(str)-1 : -1 ] )
	elif op[0]=="print":
		print(str[a:b+1])

Submission status: Wrong Answer

Solution code:
# 21-String-Transformation.py

# ???????????????
# ????????? str ?????????????????????????????????????????????????????????????????°????????????????????????????????????
# ???????????\?????????????????????????????§??????

# print a b: str ??? a ??????????????? b ??????????????§??????????????????
# reverse a b: str ??? a ??????????????? b ??????????????§?????????????????????
# replace a b p: str ??? a ??????????????? b ??????????????§??? p ?????????????????????
# ????????§??????????????? str ????????????????????? 0 ???????????¨????????????

# Input
# 1 ?????????????????? str ????????????????????????str ?????±?°????????????????????????????
# 2 ????????????????????° q ?????????????????????????¶???? q ??????????????????????¨??????¢?????§?????????????????????

# Output
# ??? print ???????????¨???????????????????????????????????????????????????

# Constraints
# 1???str????????????1000
# 1???q???100
# 0???a???b<str?????????
# replace ????????§??? b???a+1=p?????????

# Sample Input 1
# abcde
# 3
# replace 1 3 xyz
# reverse 0 2
# print 1 4
# Sample Output 1
# xaze

# Sample Input 2
# xyz
# 3
# print 0 2
# replace 0 2 abc
# print 0 2
# Sample Output 2
# xyz
# abc

#??\???

str = input()
op_num = int( input() )
for i in range(op_num):
	op = input().split()
	a = int(op[1])
	b = int(op[2])
	if op[0]=="replace":
		str = str.replace(str[ a:b+1 ], op[3])
	elif op[0]=="reverse":
		# str = str.replace(str[a:b+1], str[ b-len(str) : a-len(str)-1 : -1 ] )
		str = str[:a] + str[a:b+1][::-1] + str[b+1:]
	elif op[0]=="print":
		print(str[a:b+1])