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:
s=input()
for i in range(int(input())):
    l=list(input().split())
    l[1]=int(l[1])
    l[2]=int(l[2])+1
    if l[0]=="print":
        print(s[l[1]:l[2]])
    elif l[0]=="reverse":
        s=s[:l[1]]+s[-l[1]:l[2]][::-1]+s[l[2]:]
    elif l[0]=="replace":
        s=s[:l[1]]+l[3]+s[l[2]:]

Submission status: Wrong Answer

Solution code:
S=input()
m=int(input())
for i in range(m):
    C=input().split()
    a=int(C[1])-1
    if a<0:
        a=0
    b=int(C[2])
    if C[0]=="print":
        print(S[a:b])
    elif C[0]=="reverse":
        S=S[:a]+S[b-len(S)-1:a-len(S)-1:-1]+S[b:]
        
        
    elif C[0]=="replace":
        S=S[:a]+C[3]+S[b:]

Submission status: Wrong Answer

Solution code:
S=input()
m=int(input())
for i in range(m):
    C=input().split()
    a=int(C[1])
    b=int(C[2])+1
    if C[0]=="print":
        print(S[a:b])
    elif C[0]=="reverse":
        S=S[:a]+S[b-len(S)-1:a-len(S)-1:-1]+S[b:]
        print(S)
    elif C[0]=="replace":
        S=S[:a]+C[3]+S[b:]
        print(S)

Submission status: Wrong Answer

Solution code:
sen = input()
n = int(input())
for i in range(n):
    cmd = input().split()
    sta = int(cmd[1])
    end = int(cmd[2])
    if len(cmd) == 4:
        sen = sen[0:sta] + cmd[3] + sen[end+1:]
    elif cmd[0] == 'reverse':
        rev = sen[end+1:sta:-1]
        sen = sen[0:sta] + rev +sen[end+1:]
    elif cmd[0] == 'print':
        print(sen[sta:end+1])

Submission status: Wrong Answer

Solution code:
def f1(a,b,s):
	print(s[a:b+1])
	return s

def f2(a,b,s):
	temp = s[a:b+1]
	return s[:a] + temp[::-1] + s[b+1:]

def f3(a,b,p,s):
	return s[:a] + p + s[b+1:]

data = input()
q = int(input())
functions = {'print':f1, 'reverse':f2, 'replace':f3}

[print(0) for i in range(q)]

Submission status: Wrong Answer

Solution code:
str_1=input()
q=int(input())
for _ in range(q):
   lst=list(input().split())
   res = (lst[0])
   a = int(lst[1])
   b = int(lst[2])+1
  
   if res=='print':
    str_1=str_1[a:b]
   elif res=='replace':
    str_1=str_1[:a]+lst[3]+str_1[b:]
   elif res=='reverse':
    str_1=str_1[:a] + str_1[a:b][::-1] + str_1[b:]
print(str_1)

Submission status: Wrong Answer

Solution code:
x= input()
n= int(input())
for _ in range(n):
    order= input().split()
    a = int(order[1])-1
    b = int(order[2])
    
    if order[0] == 'print': print(x[a:b])
    elif order[0] == 'reverse':
        cstr = ''
        for cc in x[a:b]:
            cstr = cc + cstr
        x = x[:a] + cstr + x[b:]
    else : x = x.replace(x[a:b],order[3])

Submission status: Wrong Answer

Solution code:
x= input()
n= int(input())
for _ in range(n):
    order= input().split()
    a = int(order[1])
    b = int(order[2])
    
    if order[0] == 'print': print(x[a:b+1])
    elif order[0] == 'reverse':
        b = a + b + 1
        cstr = ''
        for cc in x[a:b]: cstr = cc + cstr
        x = x[:a] + cstr + x[b:]
    else : x = x.replace(x[a:a+b],order[3])

Submission status: Wrong Answer

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

    else:
        b, c, d = int(a[1]), int(a[2]), (a[3])
        z = z.replace(z[b:c+1], d)

Submission status: Wrong Answer

Solution code:
target = raw_input()
command = []
for _ in range(int(raw_input())):
    command += [raw_input()]

for c in command:
    cmd = c.split()
    print cmd
    if 'replace' == cmd[0]:
        target = target[0:int(cmd[1])] + cmd[3] + target[int(cmd[2])+1:len(target)]
    if 'reverse' == cmd[0]:
        target = target[0:int(cmd[1])] + target[int(cmd[1]):int(cmd[2])+1][::-1] + target[int(cmd[2])+1:len(target)]
    if 'print' == cmd[0]:
        target = target[int(cmd[1]):int(cmd[2])+1]

Submission status: Wrong Answer

Solution code:
target = raw_input()

command = []
for _ in range(int(raw_input())):
    command += [raw_input()]

for c in command:
    cmd = c.split()
    print cmd
    if 'replace' == cmd[0]:
        #print   target[0:int(cmd[1])] + cmd[3] + target[int(cmd[2])+1:len(target)]
        target = target[0:int(cmd[1])] + cmd[3] + target[int(cmd[2])+1:len(target)]
    if 'reverse' == cmd[0]:
        #print target[int(cmd[1]):int(cmd[2])+1]
        target = target[0:int(cmd[1])] + target[int(cmd[1]):int(cmd[2])+1][::-1] + target[int(cmd[2])+1:len(target)]
    if 'print' == cmd[0]:
        target = target[int(cmd[1]):int(cmd[2])+1]
print target

Submission status: Wrong Answer

Solution code:
target = raw_input()

command = []
for _ in range(int(raw_input())):
    command += [raw_input()]

for c in command:
    cmd = c.split()
    if 'replace' == cmd[0]:
        #print   target[0:int(cmd[1])] + cmd[3] + target[int(cmd[2])+1:len(target)]
        target = target[0:int(cmd[1])] + cmd[3] + target[int(cmd[2])+1:len(target)]
    if 'reverse' == cmd[0]:
        #print target[int(cmd[1]):int(cmd[2])+1]
        target = target[0:int(cmd[1])] + target[int(cmd[1]):int(cmd[2])+1][::-1] + target[int(cmd[2])+1:len(target)]
    if 'print' == cmd[0]:
        target = target[int(cmd[1]):int(cmd[2])+1]
print target

Submission status: Wrong Answer

Solution code:
moto = input()
num = int(input())

for i in range(num):
    order = input().split()
    if order[0] == "print":
        m,n=int(order[1]),int(order[2])
        print(moto[m:n+1])
    elif order[0] == "reverse":
        m,n=int(order[1]),int(order[2])
        moto = moto[:m]+moto[n:m-1:-1]+moto[n:]
    elif order[0] == "replace":
        m,n,l=int(order[1]),int(order[2]),order[3]
        moto = moto[:m]+order[3]+moto[n:]

Submission status: Wrong Answer

Solution code:
moto = input()
num = int(input())

for i in range(num):
    order = input().split()
    if order[0] == "print":
        m,n=int(order[1]),int(order[2])
        print(moto[m:n+1])
    elif order[0] == "reverse":
        m,n=int(order[1]),int(order[2])
        moto = moto[:m]+moto[n:m-1:-1]+moto[n+1:]
    elif order[0] == "replace":
        m,n,l=int(order[1]),int(order[2]),order[3]
        moto = moto[:m]+order[3]+moto[n+1:]

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
str=input()
n=int(input())
for i in range(n):
    s=input().split()
    a=int(s[1])
    b=int(s[2])
    if s[0] == 'replace':
        str=str[:a]+s[3]+str[b:]
    elif s[0] == 'reverse':
        str=str[:a]+str[a:b][::-1]+str[b:]
    else:
        print(str[a:b])

Submission status: Wrong Answer

Solution code:
s=input()
for i in range(int(input())):
    sou_com=input().split()
    if sou_com[0]=='print':
        print(s[int(sou_com[1])-1:int(sou_com[2])])
    elif sou_com[0]=='reverse':
        s=s[:int(sou_com[1])-1]\
        +s[int(sou_com[1])-1:int(sou_com[2])][::-1]\
        +s[int(sou_com[2]):]
    elif sou_com[0]=='replace':
        s=s[:int(sou_com[1])-1]\
        +sou_com[3]\
        +s[int(sou_com[2]):]

Submission status: Wrong Answer

Solution code:
word = input()
order_num = int(input())
orders = []
for i in range(order_num):
    orders.append(input().split())
for o in orders:
    order = o[0]
    if order == 'replace':
        word = word[:int(o[1])] + o[3] + word[int(o[2])]
    elif order == 'reverse':
        word = word[:int(o[1])] + word[int(o[1]):int(o[2])][::-1] + word[int(o[2])]
    else:
        print(word[int(o[1]):int(o[2])])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    m = list(input())
    q = int(input())
    A = []
    for _ in range(q):
        A.append(input().split())

    for x in range(q):
        if A[x][0] == "print":
            A[x][1] = int(A[x][1])
            A[x][2] = int(A[x][2])
            for y in range(A[x][1], A[x][2] + 1):
                if y != A[x][2]:
                    print(m[y], end = "")
                else:
                    print(m[y])
        elif A[x][0] == "reverse":
            A[x][1] = int(A[x][1])
            A[x][2] = int(A[x][2])
            hoge = []
            for y in range(A[x][1], A[x][2] + 1):
                hoge.append(m[y])
            hoge = hoge[::-1]
            i = 0
            for y in range(A[x][1], A[x][2] + 1): 
                m[y] = hoge[i]
                i += 1
        elif A[x][0] == "replace":
            A[x][1] = int(A[x][1])
            A[x][2] = int(A[x][2])
            fuga = list(A[x][3])
            print(fuga)
            j = 0
            for y in range(A[x][1], A[x][2] + 1):
                m[y] = fuga[j]
                j += 1


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
s=' '+input()+' '
for _ in range(int(input())):
    l=input().split()
    o=l[0]
    a=int(l[1])+1; b=int(l[2])+2
    if o=='print': print(s[a:b])
    if o=='reverse': s=s[:a]+s[b-1:a-1:-1]+s[b:]
    if o=='replace': s=s[:a]+l[3]+s[b:]
print(s.strip())

Submission status: Wrong Answer

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

l = []
for i in range(n):
    l.append(list(map(str,input().split())))

for i in range(len(l)):
    command = l[i][0]
    a = int(l[i][1])
    b = int(l[i][2])
    c = s[a:b+1]
    if command == "replace":
        s = s.replace(c, l[i][3])
    elif command == "reverse":
        s = s.replace(c,c[::-1])
    elif command == "print":
        print(c)

Submission status: Wrong Answer

Solution code:
t = input()
for _ in range(int(input())):
    order = input().split()
    cmd = order[0]
    if cmd == 'print':
        a, b = map(int,  order[1:])
        print(t[a:b+1])
    elif cmd == 'reverse':
        a, b = map(int,  order[1:])
        t = t[:a] + t[b::-1] + t[b+1:]
    else:
        a, b, c = order[1:]
        a,b = int(a), int(b)
        t = t[:a] + c + t[b+1:]

Submission status: Wrong Answer

Solution code:
# coding:utf-8
def show(a,b):
    global str
    print str[a:b+1]
def reverse(a,b):
    global str
    t = str[:a]
    t += str[-(len(str)-b):-(len(str)-a+1):-1]
    t += str[b+1:]
    str = t
def replace(a,b,p):
    global str
    str = str.replace(str[a:b+1],p)

str = raw_input()
n = input()

for i in range(n):
    command = raw_input().split()
    if command[0] == "replace":
        replace(int(command[1]),int(command[2]),command[3])
    elif command[0] == "reverse":
        reverse(int(command[1]),int(command[2]))
    elif command[0] == "print":
        show(int(command[1]),int(command[2]))

Submission status: Wrong Answer

Solution code:
string = input()
n = int(input())
for i in range(n):
    inp = [x for x in input().split()]
    a = int(inp[1])
    b = int(inp[2])
    if inp[0] == 'print':
        print(string[a-1:b])
    elif inp[0] == 'reverse':
        string = string[:a-1] + string[a-1:b][::-1] +string[b:]
    elif inp[0] == 'replace':
        string = string.replace(string[a-1:b],inp[3])

Submission status: Wrong Answer

Solution code:
string = input()
n = int(input())
for i in range(n):
    inp = [x for x in input().split()]
    a = int(inp[1])
    b = int(inp[2])
    if inp[0] == 'print':
        print(string[a:b+1])
    elif inp[0] == 'reverse':
        string = string[:a] + string[a:b+1][::-1] +string[b+1:]
    elif inp[0] == 'replace':
        string = string.replace(string[a:b+1],inp[3])

Submission status: Wrong Answer

Solution code:
def transformate(s, command):
    command, *op = command.split()

    output = s[int(op[0]):int(op[1])+1]
    if command == 'replace':
        output = s.replace(output, op[2])
    elif command == 'reverse':
        output = s.replace(output, output[::-1])
    elif command == 'print':
        print(output)
    return output

if __name__ == '__main__':
    s = input()
    for _ in range(int(input())):
        s = transformate(s, input())

Submission status: Wrong Answer

Solution code:
line = input()
for _ in range(int(input())):
    x = input().split()
    order = x[0]
    a = int(x[1])
    b = int(x[2])+1
    if order == "print":
        print(line[a:])
    elif order == "reverse":
        line = line[:a] + line[a:b][::-1] + line[b:]
    elif order == "replace":
        line = line[:a] + x[3] + line[b:]

Submission status: Wrong Answer

Solution code:
str1 = input()
print(str1)

Submission status: Wrong Answer

Solution code:
t = input()
for i in range(int(input())):
    cmd = list(input().split())
    cmd[1] = int(cmd[1])
    cmd[2] = int(cmd[2])
    if cmd[0] == "print":
        print(t[cmd[1]-1 : cmd[2]])
    elif cmd[0] == "reverse":
        tmp = t[cmd[1]-1 : cmd[2]]
        tmp = tmp[::-1]
        t = t[:cmd[1]-1] + tmp + t[cmd[2]:]
    elif cmd[0] == "replace":
        t = t[:cmd[1]-1] + cmd[3] + t[cmd[2]:]

Submission status: Wrong Answer

Solution code:
class StringEditor:
    def __init__(self, s):
        self.s = s

    def __str__(self):
        return self.s

    def print(self, start, end):
        """print command

        >>> e = StringEditor('abcde')
        >>> e.print(1, 3)
        bcd
        """
        print(self.s[start:end+1])

    def replace(self, start, end, word):
        """replace command

        >>> e = StringEditor('abcde')
        >>> e.replace(1, 3, 'xyz')
        >>> e.print(0, 4)
        axyze
        """
        self.s = self.s[:start] + word + self.s[end+1:]

    def reverse(self, start, end):
        """reverse command

        >>> e = StringEditor('abcde')
        >>> e.reverse(0, 2)
        >>> e.print(0, 4)
        cbade
        """
        if start > 0:
            rev = self.s[end:start:-1]
        else:
            rev = self.s[end::-1]

        self.s = self.s[:start] + rev + self.s[end+1:]


def run():
    s = input()
    num = int(input())
    editor = StringEditor(s)

    for _ in range(num):
        com, *args = input().split()

        if com == 'print':
            start, end = [int(i) for i in args]
            editor.print(start, end)
        elif com == 'reverse':
            start, end = [int(i) for i in args]
            editor.reverse(start, end)
        elif com == 'replace':
            start, end = [int(i) for i in args[0:2]]
            word = args[-1]
            editor.replace(start, end, word)
        else:
            raise ValueError('invalid command')


if __name__ == '__main__':
    run()

Submission status: Wrong Answer

Solution code:
#coding: utf-8

s = input()
q = int(input())
for i in range(q):
    order = input().split(" ")
    if   order[0] == "print":
        print(s[int(order[1]) : int(order[2]) + int(order[1])+1])

    elif order[0] == "reverse":
        r = s[int(order[1]) : int(order[2])-int(order[1])+1]
        r = r[::-1]
        s = s[0 : int(order[1])] + r + s[int(order[2])+1:]

    elif order[0] == "replace":
        s = s[0 : int(order[1])] + order[3] + s[int(order[2])+1:]

Submission status: Wrong Answer

Solution code:
#coding: utf-8

s = input()
q = int(input())
for i in range(q):
    order = input().split(" ")
    if   order[0] == "print":
        print(s[int(order[1]) : int(order[2])+1])
        print(" " + s)
    elif order[0] == "reverse":
        r = s[int(order[1]) : int(order[2])+1]
        print("r: " + r)
        r = r[::-1]
        print("r: " + r)
        s = s[: int(order[1])] + r + s[int(order[2])+1:]
        print(" " + s)

    elif order[0] == "replace":
        s = s[: int(order[1])] + order[3] + s[int(order[2])+1:]
        print(" " + s)

Submission status: Wrong Answer

Solution code:
import sys

l = []
for i in sys.stdin:
    l.append(i.split())

data = list(l[0][0])
for i in range(2,len(l)):
    if l[i][0] == 'replace':
        x = list(l[i][3])
        start = int(l[i][1])
        stop = int(l[i][2])
        i = 0
        for j in range(start,stop+1):
            data[j] = x[i]
            i += 1
    elif l[i][0] == 'reverse':
        start = int(l[i][1])
        stop = int(l[i][2])
        temp = data[start]
        data[start] = data[stop]
        data[stop] = temp
    elif l[i][0] == 'print':
        start = int(l[i][1])
        stop = int(l[i][2])
        for j in range(start,stop+1):
            print(data[j],end='')
        print()

Submission status: Wrong Answer

Solution code:
string = input()
n = int(input())
print_s=[]
for i in range(n):
    order = [i for i in input().split()]
    if order[0] == "replace":
        string = string.replace(string[int(order[1]):int(order[2])+1],order[3])
    elif order[0] == "reverse":
        string = string.replace(string[int(order[1]):int(order[2])+1],
                                string[int(order[2])-len(string):
                                       int(order[1])-len(string)-1:-1])
    else:
        print_s.append(string[int(order[1]):int(order[2])+1])
for i in range(len(print_s)):
    print(print_s[i])

Submission status: Wrong Answer

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


def printdef(z, a, b):
    print(z[a:b])


def replacedef(z, a, b, c):
    z = z.replace(z[a:b], c)
    return z


def reversedef(z, a, b):
    ichi = z[a:b]
    ichi = ichi[::-1]
    z = z.replace(z[a:b], ichi)
    return z


for _ in range(q):
    order_str = list(input().split(' '))
    order_str[1] = int(order_str[1])
    order_str[2] = int(order_str[2])+1

    if order_str[0] == 'print':
        printdef(n, order_str[1], order_str[2])
    elif order_str[0] == 'replace':
        n = replacedef(n, order_str[1], order_str[2], order_str[3])
    elif order_str[0] == 'reverse':
        n = reversedef(n, order_str[1], order_str[2])

Submission status: Wrong Answer

Solution code:
  
def Reverse(str, A, B):
    a = int(A)
    b = int(B)
    str = str[0:a] + str[b::-1] + str[b + 1:]
    print(str)
    return str

def Replace(str, a, b, c):
    str2 = ''
    Str = list(str)
    for i in range(int(b) - int(a) + 1):
        Str[i + int(a)] = c[i]
    for i in range(len(Str)):
        str2 += Str[i]
    return str2

str = input()
n = int(input())
for i in range(n):
    a = input()
    A = a.split()
    if A[0] == 'print':
        print(str[int(A[1]):int(A[2]) + 1])
    elif A[0] == 'reverse':
        str = Reverse(str, A[1], A[2])
    elif A[0] == 'replace':
        str = Replace(str, A[1], A[2], A[3])

Submission status: Wrong Answer

Solution code:
def Reverse(str, A, B):
    a = int(A)
    b = int(B)
    str = str[0:a] + str[b::-1] + str[b + 1:]
    return str

def Replace(str, a, b, c):
    str2 = ''
    Str = list(str)
    for i in range(int(b) - int(a) + 1):
        Str[i + int(a)] = c[i]
    for i in range(len(Str)):
        str2 += Str[i]
    return str2

str = input()
n = int(input())
for i in range(n):
    a = input()
    A = a.split()
    if A[0] == 'print':
        print(str[int(A[1]):int(A[2]) + 1])
    elif A[0] == 'reverse':
        str = Reverse(str, A[1], A[2])
    elif A[0] == 'replace':
        str = Replace(str, A[1], A[2], A[3])

Submission status: Wrong Answer

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

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

for i in range(q):
    n = list(input().split())
    if 'print' in n:
        for i in range(int(n[1]), int(n[2])):
            print(str(s[i]), end='')
        print()
    
    elif 'reverse' in n:
        for i in range(int(int(n[2]) / 2)):
            s[int(n[1]) + i], s[int(n[2]) - i] = s[int(n[2]) - i], s[int(n[1]) + i]
    
    elif 'replace' in n:
        for i in range(int(n[1]), int(n[2]) + 1):
            s.pop(int(n[1]))
    
        count  = int(n[1])
    
        for j in list(n[3]):
            s.insert(count, j)
            count += 1

Submission status: Wrong Answer

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

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

for i in range(q):
    n = list(input().split())
    if 'print' in n:
        for i in range(int(n[1]), int(n[2]) + 1):
            print(str(s[i]), end='')
        print()

    elif 'reverse' in n:
        for i in range(int(int(n[2]) / 2)):
            s[int(n[1]) + i], s[int(n[2]) - i] = s[int(n[2]) - i], s[int(n[1]) + i]

    elif 'replace' in n:
        for i in range(int(n[1]), int(n[2]) + 1):
            s.pop(int(n[1]))

        count  = int(n[1])

        for j in list(n[3]):
            s.insert(count, j)
            count += 1

Submission status: Wrong Answer

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

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

for i in range(q):
    n = list(input().split())
    if 'print' in n:
        for j in range(int(n[1]), int(n[2]) + 1):
            print(str(s[j]), end='')
        print()

    elif 'reverse' in n:
        for k in range(int(int(n[2]) / 2) + 1):
            s[int(n[1]) + k], s[int(n[2]) - k] = s[int(n[2]) - k], s[int(n[1]) + k]

    elif 'replace' in n:
        for l in range(int(n[1]), int(n[2]) + 1):
            s.pop(int(n[1]))

        count  = int(n[1])

        for m in list(n[3]):
            s.insert(count, m)
            count += 1

Submission status: Wrong Answer

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

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

for i in range(q):
    n = list(input().split())
    if 'print' in n:
        for j in range(int(n[1]), int(n[2]) + 1):
            print(str(s[j]), end='')
        print()

    elif 'reverse' in n:
        for k in range(round(int(n[2]) / 2)):
            s[int(n[1]) + k], s[int(n[2]) - k] = s[int(n[2]) - k], s[int(n[1]) + k]

    elif 'replace' in n:
        for l in range(int(n[1]), int(n[2]) + 1):
            s.pop(int(n[1]))

        count  = int(n[1])

        for m in list(n[3]):
            s.insert(count, m)
            count += 1

Submission status: Wrong Answer

Solution code:
l=list(input())
n=int(input())
i=0
# def P for output
P=[]
while i<n:
    d=input().split()
    #print
    if d[0]=="print":
        pr=l[int(d[1])]
        m=1
        while m+int(d[1])<int(d[2])+1:
            pr+=l[m+int(d[1])]
            m+=1
        P.append(pr)
    #reverse
    elif d[0]=="reverse":
        b=[]
        nu=int(d[2])
        while nu>int(d[1])-1:
            b.append(l[nu])
            l.remove(l[nu])
            nu-=1
        l[int(d[1]):int(d[1])]=b
    #replace
    else:
        q=int(d[1])
        while q<int(d[2])+1:
            l.remove(l[int(d[1])])
            q+=1
        l[int(d[1]):int(d[1])]= list(d[3])
    i+=1

for p in P:
    print(p)

Submission status: Wrong Answer

Solution code:
l=list(input())
n=int(input())
i=0
# def P for output
P=[]
while i<n:
    d=input().split()
    #print
    if d[0]=="print":
        pr=l[int(d[1])]
        m=1
        while m+int(d[1])<int(d[2])+1:
            pr+=l[m+int(d[1])]
            m+=1
        P.append(pr)
    #reverse
    elif d[0]=="reverse":
        b=l[int(d[1]):int(d[2])+1]
        del l[int(d[1]):int(d[2])+1]
        b.reverse()
        l[int(d[1]):int(d[1])]=b
    #replace
    else:
        q=int(d[1])
        while q<int(d[2])+1:
            l.remove(l[int(d[1])])
            q+=1
        l[int(d[1]):int(d[1])]= list(d[3])
    i+=1

for p in P:
    print(p)

Submission status: Wrong Answer

Solution code:

def convert():
    str = input().rstrip()
    n = int(input().rstrip())
    
    for _ in range(n):
        columns = input().rstrip().split()
        order = columns[0]
        a = int(columns[1])
        b = int(columns[2])

        
        if order == 'print':
            print(str[a:b+1])
            
        if order == 'reverse':
            str = str[a:b+1][::-1]
        
        if order == 'replace':        
            p = columns[3]
            str = str[:a] + p + str[b+1:]
if __name__ == '__main__':
    convert()

Submission status: Wrong Answer

Solution code:
str=input()
n=int(input())
for i in range(n):
    a=input().split()
    s=int(a[1]);f=int(a[2])+1
    str1=str[s:f]
    if a[0]=='replace':
        ar=a[3]
        str=str.replace(str1,ar)
    elif a[0]=='print':
        print(str[s:f])
    else:
        str2=str1[::-1]
        str=str.replace(str1,str2)

Submission status: Wrong Answer

Solution code:
def replace():
    return str.replace(str[command[1]: command[2]+1], command[3])

def reverse(str):
    str = list(str)
    for i, c in enumerate(reversed(str[command[1]: command[2]+1]), command[1]):
        str[i] = c
    str = ''.join(str)
    return str

def str_print():
    print(str[command[1]: command[2]+1])

str = input()
q = int(input())
for i in range(q):
    command = input().split()
    command[1], command[2] = int(command[1]), int(command[2])
    if command[0] == 'replace':
        str = replace()
    elif command[0] == 'reverse':
        str = reverse(str)
    else:
        str_print()

Submission status: Wrong Answer

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

for i in range(n):
    command = input().split()
    if command[0] == 'replace':
        a,b = map(int,command[1:3])
        s = s[:a]+ command[3] + s[b+1:]
    elif command[0] == 'reverse':
        a,b = map(int,command[1:3])
        s = s[b:a]
    else:  
        a,b = map(int,command[1:3])
        print(s[a:b+1])

Submission status: Wrong Answer

Solution code:
# Transformation

string = input()
commandAmount = int(input())

for i in range(commandAmount):
    command = input().rstrip().split()
    start = int(command[1])
    end = int(command[2])
    if command[0] == 'print':
        print(string[start : end + 1])
    elif command[0] == 'reverse':
        replacedString = list(string)
        a = replacedString[start]
        b = replacedString[end]
        replacedString = string.translate(str.maketrans(a + b, b + a))
        string = ''.join(replacedString)
        # print(string)
    elif command[0] == 'replace':
        string = string.translate(str.maketrans(string[start : end + 1], command[3]))
        # print(string)

Submission status: Wrong Answer

Solution code:
# Transformation

string = input()
commandAmount = int(input())

for i in range(commandAmount):
    command = input().rstrip().split()
    start = int(command[1])
    end = int(command[2])
    if command[0] == 'print':
        print(string[start : end + 1]) # ここはコメントアウトしないこと
    elif command[0] == 'reverse':
        replacedString = list(string)
        a = replacedString[start]
        b = replacedString[end]
        replacedString = string.translate(str.maketrans(a + b, b + a))
        string = ''.join(replacedString)
        # print(string)
    elif command[0] == 'replace':
        string = list(string)
        replace = list(command[3])
        for i in range(start, end + 1):
            string[i] = replace[i - start]
        string = ''.join(string)

Submission status: Wrong Answer

Solution code:
# Transformation

string = input()
commandAmount = int(input())

for i in range(commandAmount):
    command = input().rstrip().split()
    start = int(command[1])
    end = int(command[2])
    if command[0] == 'print':
        print(string[start : end + 1]) # ここはコメントアウトしないこと
    elif command[0] == 'reverse':
        replacedString = list(string)
        a = ''
        b = ''
        for i in range(start, end + 1):
            a += replacedString[i]
            b += replacedString[start + end - i]
        print(a, b)
        string = string.replace(a, b)
        print(string)
    elif command[0] == 'replace':
        string = list(string)
        replace = list(command[3])
        for i in range(start, end + 1):
            string[i] = replace[i - start]
        string = ''.join(string)

Submission status: Accepted

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):
    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: Accepted

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[a:b+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: Accepted

Solution code:
def print_text(text, a, b):
    s = int(a)
    e = int(b)+1

    print(text[s:e])

def reverse_text(text, a, b):
    s = int(a)
    e = int(b)+1

    return text[:s] + text[s:e][::-1] + text[e:]

def replace_text(text, a, b, p):
    s = int(a)
    e = int(b)+1

    return text[0:s] + p + text[e:]

def main():
    text = input()
    q = int(input())

    for _ in range(q):
        op, *args = input().split()

        if   op == 'print':
            print_text(text, *args)
        elif op == 'reverse':
            text = reverse_text(text, *args)
        elif op == 'replace':
            text = replace_text(text, *args)

if __name__ == '__main__':
    main()

Submission status: Accepted

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