ZhenlongDai/ACPR huggingface dataset:
Problem: p03738
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A, B = input(), input()
if A > B:
    print('greater'.upper())
if A < B:
    print('less'.upper())
if A == B:
    print('equal'.upper())

Failing test case input:
9720246
95756469

Expected output:
LESS


Actual output:
GREATER


Fixed submission (verdict: Accepted):
A, B = int(input()), int(input())
if A > B:
    print('greater'.upper())
if A < B:
    print('less'.upper())
if A == B:
    print('equal'.upper())

Problem: p03738
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A = input()
B = input()

ans = "EQUAL"
for a,b in zip(A,B):
    if a > b:
        ans = "GREATER"
        break
    elif a < b:
        ans = "LESS"
        break
    else:
        pass
print(ans)

Failing test case input:
36
6

Expected output:
GREATER


Actual output:
LESS


Fixed submission (verdict: Accepted):
A = input()
B = input()

ans = "EQUAL"

if len(A) == len(B):
    for a,b in zip(A,B):
        if a > b:
            ans = "GREATER"
            break
        elif a < b:
            ans = "LESS"
            break
        else:
            pass
elif len(A) > len(B):
    ans = "GREATER"
else:
    ans = "LESS"
print(ans)

Problem: p03738
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a=input()
b=input()

if a > b:
    print("GREATER")
elif a < b:
    print("LESS")
else:
    print("EQUAL")

Failing test case input:
850
3777

Expected output:
LESS

Actual output:
GREATER


Fixed submission (verdict: Accepted):
a=int(input())
b=int(input())

if a > b:
    print("GREATER")
elif a < b:
    print("LESS")
else:
    print("EQUAL")

Problem: p03738
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = input()
b = input()
if len(a) > len(b):
	print("GREATER")
elif len(a) < len(b):
	print("LESS")
else:
	for i in range(len(a)):
		if a[i] > b[i]:
			print("GREATER")
			break
		elif a[i] < b[i]:
			print("LESS")
			break
	print("EQUAL")

Failing test case input:
36
59

Expected output:
LESS


Actual output:
LESS
EQUAL


Fixed submission (verdict: Accepted):
a = input()
b = input()
if len(a) > len(b):
	print("GREATER")
elif len(a) < len(b):
	print("LESS")
else:
	for i in range(len(a)):
		if a[i] > b[i]:
			print("GREATER")
			exit()
		elif a[i] < b[i]:
			print("LESS")
			exit()
	print("EQUAL")

Problem: p03738
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a=int(input())
b=int(input())
print(["GREATER","LESS","EQUAL"][(a>b)+(a==b)])

Failing test case input:
36
50

Expected output:
LESS


Actual output:
GREATER


Fixed submission (verdict: Accepted):
i=input
a=int(i())
b=int(i())
print(["GREATER","LESS","EQUAL"][(b>=a)+(a==b)])

Problem: p03738
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a=int(input())
b=int(input())
print('GREATER'if a>b else'LESS')

Failing test case input:
36
36

Expected output:
EQUAL


Actual output:
LESS


Fixed submission (verdict: Accepted):
a=int(input())
b=int(input())
print('GREATER'if a>b else'LESS'if a<b else'EQUAL')
Problem: p03738
Buggy submission (Python (3.4.3), verdict: Wrong Answer):



a = int(input())
b = int(input())

def comp(a, b):
    if a < b:
        print("LESS")
    if a < b:
        print("GREATER")
    else:
        print("EQUAL")

Failing test case input:
9720246
95756469

Expected output:
LESS


Actual output:

Fixed submission (verdict: Accepted):



a = int(input())
b = int(input())

def comp(a, b):
    if a < b:
        print("LESS")
    elif a > b:
        print("GREATER")
    else:
        print("EQUAL")
        
comp(a, b)

Problem: p03738
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b=[int(input())for _ in[0]*2]
print("GREATER"if a>b else"ELQEUEAEL"[a<b::2])

Failing test case input:
9720246
169922301

Expected output:
LESS


Actual output:
LEEE


Fixed submission (verdict: Accepted):
a,b=[int(input())for _ in[0]*2]
print("GREATER"if a>b else"ELQEUSASL"[a<b::2])
Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
word = input()
q = int(input())

for _ in range(q):
    s = input().split(" ")
    command = s[0]
    a = int(s[1])
    b = int(s[2])

    if command == "print":
        print(word[a:b+1])
    elif command == "reverse":
        word = word[:a] + word[a:b+1][::-1] + word[b+1:]
    elif command == "replace":
        word = word.replace( word[a:b+1], s[3] )

Failing test case input:
abcde
3
replace -1 3 xy{
reverse 0 2
print 1 1

Expected output:
b


Actual output:
y


Fixed submission (verdict: Accepted):
word = input()
q = int(input())

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

Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
str, q = input(), int(input())
for i in range(q):
    com = input().strip().split()
    if com[0] == 'print':
        print(str[int(com[1]):int(com[2])+1])
    elif com[0] == 'reverse':
        str = list(str)
        str[int(com[1]):int(com[2])+1] = str[int(com[2]):int(com[1])-6:-1]
        str = ''.join(str)
    elif com[0] == 'replace':
        str = str.replace(str[int(com[1]):int(com[2])+1], com[3])

Failing test case input:
abbde
3
replace 2 3 xyz
reverse 0 2
print 0 4

Expected output:
xbayz


Actual output:
xbyze


Fixed submission (verdict: Accepted):
str, q = input(), int(input())
for i in range(q):
    com = input().strip().split()
    if com[0] == 'print':
        print(str[int(com[1]):int(com[2])+1])
    elif com[0] == 'reverse':
        str = list(str)
        str[int(com[1]):int(com[2])+1] = str[int(com[2]):int(com[1])-len(str)-1:-1]
        str = ''.join(str)
    elif com[0] == 'replace':
        str = list(str)
        str[int(com[1]):int(com[2])+1] = com[3]
        str = ''.join(str)

Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
s = input()
for _ in range(int(input())):
  q = input()
  if q.startswith('replace'):
    q, a, b, p = q.split()
    a = int(a)
    b = int(b)
    s = s.replace(s[a:b+1], p)
  elif q.startswith('reverse'):
    q, a, b = q.split()
    a = int(a)
    b = int(b)
    s = s[a:b+1][::-1]+s[b+1:]
  elif q.startswith('print'):
    q, a, b = q.split()
    a = int(a)
    b = int(b)
    print(s[a:b+1])

Failing test case input:
abcde
3
replace 1 -1 xy{
reverse 0 2
print 2 2

Expected output:
a


Actual output:
x


Fixed submission (verdict: Accepted):
s = input()
for _ in range(int(input())):
  q = input()
  if q.startswith('replace'):
    q, a, b, p = q.split()
    a = int(a)
    b = int(b)
    s = s[:a]+p+s[b+1:]
  elif q.startswith('reverse'):
    q, a, b = q.split()
    a = int(a)
    b = int(b)
    s = s[:a]+s[a:b+1][::-1]+s[b+1:]
  elif q.startswith('print'):
    q, a, b = q.split()
    a = int(a)
    b = int(b)
    print(s[a:b+1])
Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
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])


Failing test case input:
abcde
3
replace 0 3 {yy
reverse 0 2
print 1 2

Expected output:
y{


Actual output:

Fixed submission (verdict: Accepted):
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[0:a] + s[a:b+1][::-1] + s[b+1:]
    elif command[0] == 'print':  
        a,b = map(int,command[1:3])
        print(s[a:b+1])

Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
string = input()
q = int(input())
for c in range(0,q):
    instruction = input().split(' ')
    if instruction[0] == 'print':
        print(string[int(instruction[1]):int(instruction[2]) + 1])
    elif instruction[0] == 'reverse':
        string = string.replace(string[int(instruction[1]):int(instruction[2])+1], string[int(instruction[1]):int(instruction[2])+1][::-1], 1)
    elif instruction[0] == 'replace':
        if instruction[1] == instruction[2]:
            string = string[:int(instruction[1])] + instruction[3] + string[int(instruction[1])+1:]
        else:
            string = string.replace(string[int(instruction[1]):int(instruction[2])+1], instruction[3], 1)

Failing test case input:
edcba
3
replace 1 -1 xy{
reverse 0 2
print 2 2

Expected output:
e


Actual output:
x


Fixed submission (verdict: Accepted):
string = input()
q = int(input())
for c in range(0,q):
    instruction = input().split(' ')
    if instruction[0] == 'print':
        print(string[int(instruction[1]):int(instruction[2]) + 1])
    elif instruction[0] == 'reverse':
        string = string.replace(string[int(instruction[1]):int(instruction[2])+1], string[int(instruction[1]):int(instruction[2])+1][::-1], 1)
    elif instruction[0] == 'replace':
        string = string[:int(instruction[1])] + instruction[3] + string[int(instruction[2])+1:]

Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
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]:]

Failing test case input:
abcde
3
replace 1 4 xy{
reverse 1 2
print 1 3

Expected output:
yx{


Actual output:
{


Fixed submission (verdict: Accepted):
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]:]
Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):


import sys


def main():
    s = sys.stdin.readline().strip('\n')
    q = int(sys.stdin.readline().strip('\n'))

    for instruction in range(q):
        words = [word for word in sys.stdin.readline().strip('\n').split()]
        print(words)
        if words[0] == 'replace':
            s = s[:int(words[1])] + words[3] + s[int(words[2])+1:]
        elif words[0] == 'reverse':
            s = s[:int(words[1])] \
                    + ''.join(reversed(s[int(words[1]):int(words[2])+1])) \
                    + s[int(words[2])+1:]
        elif words[0] == 'print':
            print(s[int(words[1]):int(words[2])+1])


if __name__ == '__main__':
    main()

Failing test case input:
abcde
3
replace 1 0 xy{
reverse 0 1
print 1 6

Expected output:
ay{bcd


Actual output:
['replace', '1', '0', 'xy{']
['reverse', '0', '1']
['print', '1', '6']
ay{bcd


Fixed submission (verdict: Accepted):


import sys


def main():
    s = sys.stdin.readline().strip('\n')
    q = int(sys.stdin.readline().strip('\n'))

    for instruction in range(q):
        words = [word for word in sys.stdin.readline().strip('\n').split()]
        if words[0] == 'replace':
            s = s[:int(words[1])] + words[3] + s[int(words[2])+1:]
        elif words[0] == 'reverse':
            s = s[:int(words[1])] \
                    + ''.join(reversed(s[int(words[1]):int(words[2])+1])) \
                    + s[int(words[2])+1:]
        elif words[0] == 'print':
            print(s[int(words[1]):int(words[2])+1])


if __name__ == '__main__':
    main()

Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
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)

Failing test case input:
abcde
3
replace 0 3 xy{
reverse 0 2
print 1 4

Expected output:
yxe


Actual output:
xy{e
{yxe
yxe


Fixed submission (verdict: Accepted):
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:]
        
    elif C[0]=="replace":
        S=S[:a]+C[3]+S[b:]
Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
tes = input()
for mak in range(int(input())) :
    ins = input().split()
    ins[1], ins[2] = int(ins[1]), int(ins[2])
    if ins[0] == 'replace' :
        tes = tes.replace(tes[ins[1] : ins[2] + 1], ins[3])
    elif ins[0] == 'reverse' :
        tem = tes[ins[1] : ins[2] + 1]
        tem = tem[::-1]
        tes = tes.replace(tes[ins[1] : ins[2] + 1], tem)
    elif ins[0] == 'print' :
        print(tes[ins[1] : ins[2] + 1])

Failing test case input:
abcde
3
replace 1 0 xy{
reverse 0 2
print 1 6

Expected output:
xa{bcd


Actual output:
yxa{yx


Fixed submission (verdict: Accepted):
tes = input()
for mak in range(int(input())) :
    ins = input().split()
    ins[1], ins[2] = int(ins[1]), int(ins[2])
    if ins[0] == 'replace' :
        tes = tes[ : (ins[1])] + ins[3] + tes[(ins[2] + 1) :]
    elif ins[0] == 'reverse' :
        tem = tes[ins[1] : ins[2] + 1]
        tem = tem[::-1]
        tes = tes.replace(tes[ins[1] : ins[2] + 1], tem)
    elif ins[0] == 'print' :
        print(tes[ins[1] : ins[2] + 1])

Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
s = input()
for _ in range(int(input())):
  q = input()
  if q.startswith('replace'):
    q, a, b, p = q.split()
    a = int(a)
    b = int(b)
    s = s.replace(s[a:b+1], p)
  elif q.startswith('reverse'):
    q, a, b = q.split()
    a = int(a)
    b = int(b)
    s = s[:a]+s[a:b+1][::-1]+s[b+1:]
  elif q.startswith('print'):
    q, a, b = q.split()
    a = int(a)
    b = int(b)
    print(s[a:b+1])

Failing test case input:
abcde
3
replace 1 0 xy{
reverse 0 1
print 1 6

Expected output:
ay{bcd


Actual output:
x{axy{


Fixed submission (verdict: Accepted):
s = input()
for _ in range(int(input())):
  q = input()
  if q.startswith('replace'):
    q, a, b, p = q.split()
    a = int(a)
    b = int(b)
    s = s[:a]+p+s[b+1:]
  elif q.startswith('reverse'):
    q, a, b = q.split()
    a = int(a)
    b = int(b)
    s = s[:a]+s[a:b+1][::-1]+s[b+1:]
  elif q.startswith('print'):
    q, a, b = q.split()
    a = int(a)
    b = int(b)
    print(s[a:b+1])

Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
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)

Failing test case input:
abbde
3
replace 2 3 xyz
reverse 0 2
print 0 4

Expected output:
xbayz


Actual output:
xbayze


Fixed submission (verdict: Accepted):
s = input()
n = int(input())
for _ in range(n):
    line = input().split()
    command, args = line[0], line[1:]
    start = int(args[0])
    end = int(args[1]) + 1
    if command == 'replace':
        s = s[:start] + args[2] + s[end:]
    elif command == 'reverse':
        s = s[:start] + str(''.join(list(reversed(s[start:end])))) + s[end:]
    elif command == 'print':
        print(s[start:end])
Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
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]):]

Failing test case input:
zxw
1
print 0 1
ecalper 2 1 cba
print 2 2

Expected output:
zx


Actual output:

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

Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
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)

Failing test case input:
edcba
3
replace 1 -1 xy{
reverse 0 2
print 2 2

Expected output:
e


Actual output:
x


Fixed submission (verdict: Accepted):
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[:a] + l[i][3] + s[b+1:]
    elif command == "reverse":
        s = s[:a] + c[::-1] + s[b+1:]
    elif command == "print":
        print(c)
Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
string = input()
q = int(input())
for c in range(0,q):
    instruction = input().split(' ')
    if instruction[0] == 'print':
        print(string[int(instruction[1]):int(instruction[2]) + 1])
    elif instruction[0] == 'reverse':
        string = string.replace(string[int(instruction[1]):int(instruction[2])+1], string[int(instruction[1]):int(instruction[2])+1][::-1], 1)
    elif instruction[0] == 'replace':
        string = string[:int(instruction[1])] + instruction[3] + string[int(instruction[1])+1:]

Failing test case input:
abcde
3
replace 1 0 xy{
reverse 0 2
print 1 6

Expected output:
xa{bcd


Actual output:
xa{cde


Fixed submission (verdict: Accepted):
string = input()
q = int(input())
for c in range(0,q):
    instruction = input().split(' ')
    if instruction[0] == 'print':
        print(string[int(instruction[1]):int(instruction[2]) + 1])
    elif instruction[0] == 'reverse':
        string = string.replace(string[int(instruction[1]):int(instruction[2])+1], string[int(instruction[1]):int(instruction[2])+1][::-1], 1)
    elif instruction[0] == 'replace':
        string = string[:int(instruction[1])] + instruction[3] + string[int(instruction[2])+1:]

Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
word = input()
q = int(input())

for _ in range(q):
    s = input().split(" ")
    command = s[0]
    a = int(s[1])
    b = int(s[2])

    if command == "print":
        print(word[a:b+1])
    elif command == "reverse":
        word = word[:a] + word[a:b+1][::-1] + word[b+1:]
    elif command == "replace":
        p = s[3]
        word = word.replace( word[a:b+1], p )

Failing test case input:
abcde
3
replace -1 3 xy{
reverse 0 2
print 1 1

Expected output:
b


Actual output:
y


Fixed submission (verdict: Accepted):
word = input()
q = int(input())

for _ in range(q):
    s = input().split(" ")
    command = s[0]
    a = int(s[1])
    b = int(s[2])
    if command == "print":
        print(word[a:b+1])
    elif command == "reverse":
        word = word[:a] + word[a:b+1][::-1] + word[b+1:]
    elif command == "replace":
        word = word[:a] + s[3] + word[b+1:]
Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
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:]


Failing test case input:
abcde
3
replace 1 3 yy{
reverse -1 2
print 1 2

Expected output:
yy


Actual output:
ye


Fixed submission (verdict: Accepted):
letters = input()
num = int(input())
for i in range(num):
    order = input().split()
    a = int(order[1])
    b = int(order[2])
    if order[0] == 'print':
        print(letters[a:b+1])
    if order[0] == 'reverse':
        p = letters[a:b+1]
        p = p[::-1]
        letters = letters[:a] + p + letters[b+1:]
    if order[0] == 'replace':
        letters = letters[:a] + order[3] + letters[b+1:]

Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
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:]

Failing test case input:
abcde
3
replace 1 3 {yy
reverse 0 2
print 0 2

Expected output:
y{a


Actual output:
{ay


Fixed submission (verdict: Accepted):
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][::-1] + text[b + 1:]
    elif args[0] == 'replace':
        text = text[0:a] +  args[3] + text[b + 1:]
Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):

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()


Failing test case input:
abcde
3
replace 0 3 {yy
reverse 0 2
print 1 4

Expected output:
y{e


Actual output:
y{


Fixed submission (verdict: Accepted):
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] + str[a:b+1][::-1] + str[b+1:]
        
        if order == 'replace':        
            p = columns[3]
            str = str[:a] + p + str[b+1:] 
if __name__ == '__main__':
    convert()

Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
str, q = input(), int(input())
for i in range(q):
    com = input().strip().split()
    if com[0] == 'print':
        print(str[int(com[1]):int(com[2])+1])
    elif com[0] == 'reverse':
        str = list(str)
        str[int(com[1]):int(com[2])+1] = str[int(com[2]):int(com[1])-6:-1]
        str = ''.join(str)
        print(str)
    elif com[0] == 'replace':
        str = str.replace(str[int(com[1]):int(com[2])+1], com[3])
        print(str)

Failing test case input:
xy{
3
print -1 2
replace 1 2 abc
print 0 1

Expected output:
{
xa


Actual output:
{
xabc
xa


Fixed submission (verdict: Accepted):
str, q = input(), int(input())
for i in range(q):
    com = input().strip().split()
    if com[0] == 'print':
        print(str[int(com[1]):int(com[2])+1])
    elif com[0] == 'reverse':
        str = list(str)
        str[int(com[1]):int(com[2])+1] = str[int(com[2]):int(com[1])-len(str)-1:-1]
        str = ''.join(str)
    elif com[0] == 'replace':
        str = list(str)
        str[int(com[1]):int(com[2])+1] = com[3]
        str = ''.join(str)
Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
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])

Failing test case input:
abcde
3
replace 1 0 xy{
reverse 0 2
print 1 6

Expected output:
xa{bcd


Actual output:
yx{bcd


Fixed submission (verdict: Accepted):
sen = input()
n = int(input())
for i in range(n):
    cmd = input().split()
    sta = int(cmd[1])
    end = int(cmd[2])
    if cmd[0] == 'replace':
        sen = sen[0:sta] + cmd[3] + sen[end+1:]
    elif cmd[0] == 'reverse':
        rev = sen[sta:end+1]
        rev = rev[::-1]
        
        sen = sen[0:sta] + rev +sen[end+1:]
    elif cmd[0] == 'print':
        print(sen[sta:end+1])

Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
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)



Failing test case input:
xyz
3
print 0 2
replace 1 2 caa
print 0 1

Expected output:
xyz
xc


Actual output:
xyz
xcaa
xc


Fixed submission (verdict: Accepted):
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:]

Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
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)

Failing test case input:
xy{
3
print -1 2
replace 1 2 abc
print 0 1

Expected output:
{
xa


Actual output:
{a


Fixed submission (verdict: Accepted):
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':
     print(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:]
Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
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:]
      

Failing test case input:
edcba
3
replace 1 -1 xy{
reverse 0 2
print 2 2

Expected output:
e


Actual output:
x


Fixed submission (verdict: Accepted):
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:]
        
    elif C[0]=="replace":
        S=S[:a]+C[3]+S[b:]

Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
s = input()
for i in range(int(input())):
    cmd = input().split()
    a,b = map(int,[cmd[1],cmd[2]])
    if cmd[0] == 'reverse':
        s = s[:b] + s[a:b+1][::-1]+ s[b+1:]
    elif cmd[0] == 'replace':
        s = s[:b] + cmd[3] + s[b+1:]
    else:
        print(s[a:b+1])

Failing test case input:
xyz
3
print 1 2
replace 1 2 abb
print 1 4

Expected output:
yz
abb


Actual output:
yz
yabb


Fixed submission (verdict: Accepted):
s = input()
n = int(input())
for i in range(n):
    cmd = input().split()
    a,b = map(int,[cmd[1],cmd[2]])
    if cmd[0] == 'print':print(s[a:b+1])
    elif cmd[0] == 'reverse':s = s[:a] + s[a:b+1][::-1] + s[b+1:]
    elif cmd[0] == 'replace':s = s[:a] + cmd[3] + s[b+1:]

Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
str, q = input(), int(input())
for i in range(q):
    com = input().strip().split()
    if com[0] == 'print':
        print(str[int(com[1]):int(com[2])+1])
    elif com[0] == 'reverse':
        str = list(str)
        str[int(com[1]):int(com[2])+1] = str[int(com[2]):int(com[1])-len(str)-1:-1]
        str = ''.join(str)
    elif com[0] == 'replace':
        str = str.replace(str[int(com[1]):int(com[2])+1], com[3])

Failing test case input:
abcde
3
replace 1 0 xy{
reverse 0 1
print 1 6

Expected output:
ay{bcd


Actual output:
x{axy{


Fixed submission (verdict: Accepted):
str, q = input(), int(input())
for i in range(q):
    com = input().strip().split()
    if com[0] == 'print':
        print(str[int(com[1]):int(com[2])+1])
    elif com[0] == 'reverse':
        str = list(str)
        str[int(com[1]):int(com[2])+1] = str[int(com[2]):int(com[1])-len(str)-1:-1]
        str = ''.join(str)
    elif com[0] == 'replace':
        str = list(str)
        str[int(com[1]):int(com[2])+1] = com[3]
        str = ''.join(str)
Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
text = input()
times = int(input())

for i in range(times):
    function = input().split()
    word = text[int(function[1]):int(function[2])+1]

    if function[0] == "print":
        print(word)

    elif function[0] == "reverse":
        word_reverse = word[::-1]
        text = text.replace(word,word_reverse)

    elif function[0] == "replace":
        text = text.replace(word,function[3])

Failing test case input:
abcde
3
replace 1 -1 xy{
reverse 0 2
print 2 2

Expected output:
a


Actual output:
x


Fixed submission (verdict: Accepted):
text = input()
times = int(input())

for i in range(times):
    function = input().split()
    word = text[int(function[1]):int(function[2])+1]

    if function[0] == "print":
        print(word)

    elif function[0] == "reverse":
        word_reverse = word[::-1]
        text = text[:int(function[1])] + word_reverse + text[int(function[2])+1:]

    elif function[0] == "replace":
        text = text[:int(function[1])] + function[3] + text[int(function[2])+1:]

Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):


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)



Failing test case input:
zyx
3
print -1 2
replace 1 2 cba
print 1 2

Expected output:
x
cb


Actual output:
x
 zyx
 zcba
cb
 zcba


Fixed submission (verdict: Accepted):


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])
    elif order[0] == "reverse":
        r = s[int(order[1]) : int(order[2])+1]
        r = r[::-1]
        s = s[:int(order[1])] + r + s[int(order[2])+1:]
    elif order[0] == "replace":
        s = s[:int(order[1])] + order[3] + s[int(order[2])+1:]
Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
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:]

Failing test case input:
abcde
3
replace 0 2 xy{
reverse 0 1
print 1 2

Expected output:
x{


Actual output:
de


Fixed submission (verdict: Accepted):
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[m:n+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:]

Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
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)


Failing test case input:
abcde
3
replace 1 0 xy{
reverse 0 1
print 1 6

Expected output:
ay{bcd


Actual output:
x{ayx{


Fixed submission (verdict: Accepted):
str=list(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=list(a[3])
        str[s:f]=ar
    elif a[0]=='print':
        ans=''.join(str1)
        print(ans)
    else:
        str2=str1[::-1]
        str[s:f]=str2

Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
str = input()
q = int(input())
for i in range(q):
    order = list(input().split())
    if order[0] == "print":
        print(str[int(order[1]):int(order[2])+1]) 
    elif order[0] == "reverse":
        str = str[int(order[1]):int(order[2])+1][::-1] + str[int(order[2])+1:]
    elif order[0] == "replace":
        str = str[:int(order[1])] + order[3] + str[int(order[2])+1:]

Failing test case input:
`bcde
3
replace 1 6 yy{
reverse 1 1
print 0 1

Expected output:
`y


Actual output:
yy


Fixed submission (verdict: Accepted):
str = input()
q = int(input())
for i in range(q):
    order = list(input().split())
    if order[0] == "print":
        print(str[int(order[1]):int(order[2])+1]) 
    elif order[0] == "reverse":
        str = str[:int(order[1])] + str[int(order[1]):int(order[2])+1][::-1] + str[int(order[2])+1:]
    elif order[0] == "replace":
        str = str[:int(order[1])] + order[3] + str[int(order[2])+1:]
Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
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:]



Failing test case input:
abcde
3
replace 1 3 xy{
reverse 0 2
print 1 2

Expected output:
xa


Actual output:
xa{e


Fixed submission (verdict: Accepted):
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:b])
    elif order == "reverse":
        line = line[:a] + line[a:b][::-1] + line[b:]
    elif order == "replace":
        line = line[:a] + x[3] + line[b:]

Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
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()



Failing test case input:
abcde
3
replace 1 0 xy{
reverse 0 1
print 1 6

Expected output:
ay{bcd


Actual output:
x{axy{


Fixed submission (verdict: Accepted):
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[:a] + command[3] + string[b+1:]


if __name__ == '__main__':
    main()
Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
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])

Failing test case input:
abcde
3
replace 0 4 xy{
reverse 0 2
print 1 3

Expected output:
yx


Actual output:
yxx


Fixed submission (verdict: Accepted):
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 + 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])

Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
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:]

Failing test case input:
xyz
3
print 0 2
replace 1 2 abc
print 0 2

Expected output:
xyz
xab


Actual output:
xyz
xyz
xyz
xabc
xab


Fixed submission (verdict: Accepted):
s = input()
for i in range(int(input())):
    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:]

Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
s = input()
n = int(input())
for i in range(n):
    cmd = input().split()
    if cmd[0] == 'print':
        print(s[int(cmd[1]):int(cmd[2]) + 1])
    elif cmd[0] == 'reverse':
        s = s.replace(s[int(cmd[1]):int(cmd[2]) + 1], (s[int(cmd[1]):int(cmd[2]) + 1][::-1]))
    elif cmd[0] == 'replace':
        s = s.replace(s[int(cmd[1]):int(cmd[2]) + 1], cmd[3])

Failing test case input:
abcde
3
replace 1 -1 xy{
reverse 0 2
print 2 2

Expected output:
a


Actual output:
x


Fixed submission (verdict: Accepted):
s = list(input())
n = int(input())
for i in range(n):
    cmd = input().split()
    if cmd[0] == 'print':
        print(''.join(s[int(cmd[1]):int(cmd[2]) + 1]))
    elif cmd[0] == 'reverse':
        s[int(cmd[1]):int(cmd[2]) + 1] = s[int(cmd[1]):int(cmd[2]) + 1][::-1]
    elif cmd[0] == 'replace':
        s[int(cmd[1]):int(cmd[2]) + 1] = list(cmd[3])
Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
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:]

Failing test case input:
abcde
3
replace 1 -1 xy{
reverse 0 2
print 2 2

Expected output:
a


Actual output:
e


Fixed submission (verdict: Accepted):
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[m:n+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:]

Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
s = input()
n = int(input())
for i in range(n):
    p = input().split()
    
    a, b = [int(x) for x in p[1:3]]
    if p[0]=="print":
        print(s[a:b+1])
    if p[0]=="replace":
        s = s[:a] + p[3] + s[b+1:]
    if p[0]=="reverse":
        s = s[:a] + s[a:b+1:-1] + s[b+1:]

Failing test case input:
abcde
3
replace 1 3 xyz
reverse 0 2
print 0 4

Expected output:
yxaze


Actual output:
ze


Fixed submission (verdict: Accepted):
s = input()
n = int(input())

for i in range(n):
    p = input().split()

    a, b = [int(x) for x in p[1:3]]
    if p[0]=="print":
        print(s[a:b+1])
    elif p[0]=="replace":
        s = s[:a] + p[3] + s[b+1:]
    elif p[0]=="reverse":
        s = s[:a] + s[a:b+1][::-1] + s[b+1:]

Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
string = input()
q = int(input())
for c in range(0,q):
    instruction = input().split(' ')
    if instruction[0] == 'print':
        print(string[int(instruction[1]):int(instruction[2]) + 1])
    elif instruction[0] == 'reverse':
        string = string.replace(string[int(instruction[1]):int(instruction[2])+1], string[int(instruction[1]):int(instruction[2])+1][::-1], 1)
    elif instruction[0] == 'replace':
        string = string.replace(string[int(instruction[1]):int(instruction[2])+1], instruction[3], 1)

Failing test case input:
edcba
3
replace 1 -1 xy{
reverse 0 2
print 2 2

Expected output:
e


Actual output:
x


Fixed submission (verdict: Accepted):
string = input()
q = int(input())
for c in range(0,q):
    instruction = input().split(' ')
    if instruction[0] == 'print':
        print(string[int(instruction[1]):int(instruction[2]) + 1])
    elif instruction[0] == 'reverse':
        string = string.replace(string[int(instruction[1]):int(instruction[2])+1], string[int(instruction[1]):int(instruction[2])+1][::-1], 1)
    elif instruction[0] == 'replace':
        string = string[:int(instruction[1])] + instruction[3] + string[int(instruction[2])+1:]
Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
line = input()
n = int(input())
for i in range(n):
    order = input().split()
    if order[0] == "print":
        print(line[int(order[1])-1:int(order[2])-1])
    elif order[0] == "reverse":
        tmp = line[int(order[1]) - 1:int(order[2]) - 1]
        line = line[:int(order[1]) - 1] + tmp[::-1] + line[int(order[2]) - 1:]
    elif order[0] == "replace":
        line = line[:int(order[1]) - 1] + order[3] + line[int(order[2]) - 1:]

Failing test case input:
wyz
1
print 0 1
replace 0 2 abc
ptinr 0 2

Expected output:
wy


Actual output:

Fixed submission (verdict: Accepted):
line = input()
n = int(input())
for i in range(n):
    order = input().split()
    if order[0] == "print":
        print(line[int(order[1]):int(order[2])+1])
    elif order[0] == "reverse":
        tmp = line[int(order[1]) :int(order[2])+1 ]
        line = line[:int(order[1])] + tmp[::-1] + line[int(order[2])+1:]
    elif order[0] == "replace":
        line = line[:int(order[1])] + order[3] + line[int(order[2])+1:]

Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):


import sys


def main():
    s = sys.stdin.readline().strip('\n')
    q = int(sys.stdin.readline().strip('\n'))

    for instruction in range(q):
        words = [word for word in sys.stdin.readline().strip('\n').split()]

        if words[0] == 'replace':
            s = s.replace(s[int(words[1]):int(words[2])+1], words[3])
        elif words[0] == 'reverse':
            s = s.replace(s[int(words[1]):int(words[2])+1],
                          ''.join(reversed(s[int(words[1]):int(words[2])+1])))
        elif words[0] == 'print':
            print(s[int(words[1]):int(words[2])+1])


if __name__ == '__main__':
    main()

Failing test case input:
abcde
3
replace 1 0 xy{
reverse 0 2
print 1 6

Expected output:
xa{bcd


Actual output:
yxa{yx


Fixed submission (verdict: Accepted):


import sys


def main():
    s = sys.stdin.readline().strip('\n')
    q = int(sys.stdin.readline().strip('\n'))

    for instruction in range(q):
        words = [word for word in sys.stdin.readline().strip('\n').split()]
        if words[0] == 'replace':
            s = s[:int(words[1])] + words[3] + s[int(words[2])+1:]
        elif words[0] == 'reverse':
            s = s[:int(words[1])] \
                    + ''.join(reversed(s[int(words[1]):int(words[2])+1])) \
                    + s[int(words[2])+1:]
        elif words[0] == 'print':
            print(s[int(words[1]):int(words[2])+1])


if __name__ == '__main__':
    main()