ZhenlongDai/ACPR huggingface dataset:
Problem: p02422
Buggy submission (Python3, verdict: Wrong Answer):
s = input()
line = int(input())

for i in range(line):
    param = input().split(" ")

    if len(param) == 4: ope, a, b, p = param
    else: ope, a, b = param

    a,b = int(a), int(b)

    if ope == "print":
        print(s[a:b+1])
    elif ope == "reverse":
        rev = s[a:b+1][::-1]
        print(rev)
        s = (s[:a] + rev + s[b+1:])
    elif ope == "replace":
        s = (s[:a] + p + s[b+1:])

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

Expected output:
{a


Actual output:
y{a
{a


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

for i in range(line):
    param = input().split(" ")

    if len(param) == 4: ope, a, b, p = param
    else: ope, a, b = param

    a,b = int(a), int(b)

    if ope == "print":
        print(s[a:b+1])
    elif ope == "reverse":
        rev = s[a:b+1][::-1]
        s = (s[:a] + rev + s[b+1:])
    elif ope == "replace":
        s = (s[:a] + p + s[b+1:])

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

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

Expected output:
bay{e


Actual output:
{e


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

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])
    elif instruction[0] == 'replace':
        string = string.replace(string[int(instruction[1]):int(instruction[2])+1], instruction[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):
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()
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:]



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

Expected output:
y{


Actual output:
y{e


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: p02235
Buggy submission (Python3, verdict: Wrong Answer):
def ask(X,Y):

 a=len(X)
 b=len(Y)
 Z=[]
 for n in range(a):
  z=0
  c=0
  for i in range(n,a):
   for j in range(c,b):
    if(c==b-1):
     break
    if(X[i]==Y[j]):
     c=j
     break
     
  Z.append(z)

 Z.sort();
 return Z[a-1]


q=int(input())
Z=[]
for p in range(q):
 x=input()
 X=list(x)
 y=input()
 Y=list(y)
 z=ask(X,Y)
 Z.append(z)

for p in range(q):
 print(Z[p])




Failing test case input:
3
a`ab\ce
cccb_b
caa
f`c
_af
ec

Expected output:
1
1
0


Actual output:
0
0
0


Fixed submission (verdict: Accepted):
def ask(X,Y):
 cost=[0]
 for j in Y:
  for i in range(len(cost)-1,-1,-1):
   a=X.find(j,cost[i])+1
   if a:
    if i+1<len(cost):
     cost[i+1]=min(cost[i+1],a)
    else:
     cost.append(a)
 return len(cost)-1
 


q=int(input())
Z=[]
for p in range(q):
 X=input()
 Y=input()
 z=ask(X,Y)
 Z.append(z)

for p in range(q):
 print(Z[p])

Problem: p02235
Buggy submission (Python3, verdict: Wrong Answer):
def ask(X,Y):

 a=len(X)
 b=len(Y)
 Z=[]
 c=0
 for n in range(a):
  z=0
  for i in range(n,a):
   for j in range(c,b):
    if(X[i]==Y[j]):
     z+=1
     c=j
     break
  Z.append(z)

 Z.sort();
 return Z[a-1]


q=int(input())
Z=[]
for p in range(q):
 x=input()
 X=list(x)
 y=input()
 Y=list(y)
 z=ask(X,Y)
 Z.append(z)

for p in range(q):
 print(Z[p])




Failing test case input:
3
`bdad_b
`baccb
bca
ce^
bbd
cb

Expected output:
4
1
1


Actual output:
4
1
2


Fixed submission (verdict: Accepted):
def ask(X,Y):
 cost=[0]
 for j in Y:
  for i in range(len(cost)-1,-1,-1):
   a=X.find(j,cost[i])+1
   if a:
    if i+1<len(cost):
     cost[i+1]=min(cost[i+1],a)
    else:
     cost.append(a)
 return len(cost)-1
 


q=int(input())
Z=[]
for p in range(q):
 X=input()
 Y=input()
 z=ask(X,Y)
 Z.append(z)

for p in range(q):
 print(Z[p])

Problem: p02235
Buggy submission (Python3, verdict: Wrong Answer):
def findlcs(x, y):
    dp = [0]*(len(y)+1)

    for i in range(len(x)):
        for j in range(len(y)):
            if x[i] == y[j]:
                dp[j+1] = dp[j] + 1
            else:
                dp[j+1] = max(dp[j+1], dp[j])

    return dp[len(y)]


q = int(input())
for k in range(q):
    X = input()
    Y = input()
    print(findlcs(X, Y))

Failing test case input:
3
ab_adcb
`baccb
acb
ce_
bbd
cc

Expected output:
4
1
0


Actual output:
5
1
0


Fixed submission (verdict: Accepted):
def findlcs(x, y):
    dp = [0]*(len(y)+1)

    for c in x:
        tmp = dp[:]
        for j in range(len(y)):
            if c == y[j]:
                dp[j+1] = tmp[j] + 1
            elif dp[j+1] < dp[j]:
                dp[j+1] = dp[j]

    return dp[-1]


q = int(input())
for k in range(q):
    X = input()
    Y = input()
    print(findlcs(X, Y))
Problem: p02235
Buggy submission (Python3, verdict: Wrong Answer):

def ask(X,Y):

 a=len(X)
 b=len(Y)
 Z=[]
 c=0
 for n in range(a):
  z=0
  for i in range(n,a):
   for j in range(c,b):
    if(X[i]==Y[j]):
     z+=1
     c=j
     break
  Z.append(z)

 Z.sort();
 return Z[a-1]


q=int(input())
Z=[]
for p in range(q):
 x=input()
 X=list(x)
 y=input()
 Y=list(y)
 z=ask(X,Y)
 Z.append(z)

for p in range(q):
 print(Z[p])



Failing test case input:
3
ac]bdba
caca_b
cac
e_b
c`b
cd

Expected output:
3
0
1


Actual output:
4
0
1


Fixed submission (verdict: Accepted):
def ask(X,Y):
 cost=[0]
 for j in Y:
  for i in range(len(cost)-1,-1,-1):
   a=X.find(j,cost[i])+1
   if a:
    if i+1<len(cost):
     cost[i+1]=min(cost[i+1],a)
    else:
     cost.append(a)
 return len(cost)-1
 


q=int(input())
Z=[]
for p in range(q):
 X=input()
 Y=input()
 z=ask(X,Y)
 Z.append(z)

for p in range(q):
 print(Z[p])

Problem: p02235
Buggy submission (Python3, verdict: Wrong Answer):
def Ics(X, Y):
    m = len(X)
    n = len(Y)
    c1 = [0] * (n + 1)
    c2 = [0] * (n + 1)
    for i in range(m):
        d = X[i]
    for j in range(n):
        if (d == Y[j]):
            c1[j + 1] = c2[j] + 1
        elif (c1[j + 1] < c1[j]):
            c1[j + 1] = c1[j]
    return (c1[-1])

q = int(input().rstrip())
t = []
for i in range(q):
    s1 = input().rstrip()
    s2 = input().rstrip()
    t.append(Ics(s1, s2))
print(*t, sep="\n")

Failing test case input:
3
abcbdab
bdcaba
abc
abc
abc
bc

Expected output:
4
3
2

Actual output:
1
1
1


Fixed submission (verdict: Accepted):
def Ics(X, Y):
    m = len(X)
    n = len(Y)
    c1 = [0] * (n + 1)
    for i in range(m):
        d = X[i]
        c2 = c1[:]
        for j in range(n):
            if (d == Y[j]):
                c1[j + 1] = c2[j] + 1
            elif (c1[j + 1] < c1[j]):
                c1[j + 1] = c1[j]
    return (c1[-1])

q = int(input().rstrip())
t = []
for i in range(q):
    s1 = input().rstrip()
    s2 = input().rstrip()
    t.append(Ics(s1, s2))
print(*t, sep = "\n")
Problem: p02235
Buggy submission (Python3, verdict: Wrong Answer):
q = int(input())

for i in range(q):
    x = input()
    y = input()
 
    l = []
    for j, s in enumerate(x):
        l.append([])
        l[j].append(0)
        if j == 0:
            l[j].append(y.find(s))
        else:
            for k, t in enumerate(l[j - 1][:-1]):
                endPos = y.find(s, t + 1)
                if endPos != -1:
                    l[j].append(min(endPos, l[j - 1][k + 1]))
            endPos = y.find(s, l[j - 1][-1] + 1)
            if endPos != -1:
                l[j].append(endPos)

    print(len(l[len(x) - 1]) - 1)


Failing test case input:
3
`bdad`b
bdc`ba
bc`
ce^
bbc
bc

Expected output:
4
1
2


Actual output:
3
0
1


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

for i in range(q):
    x = input()
    y = input()
 
    l = []
    for j, s in enumerate(x):
        l.append([])
        l[j].append(-1)
        if j == 0:
            endPos = y.find(s)
            if endPos != -1: 
                l[j].append(endPos)
        else:
            for k, t in enumerate(l[j - 1][:-1]):
                endPos = y.find(s, t + 1)
                if endPos != -1:
                    l[j].append(min(endPos, l[j - 1][k + 1]))
                else:
                    l[j].append(l[j - 1][k + 1])
            endPos = y.find(s, l[j - 1][-1] + 1)
            if endPos != -1:
                l[j].append(endPos)

    print(len(l[-1]) - 1)

Problem: p02235
Buggy submission (Python3, verdict: Wrong Answer):
m = int(input())
for i in range(m):
    str1 = input()
    str2 = input()
    A = [0 for j in range(len(str2)+1)]
    for j in range(len(str1)):
        for k in range(len(str2)):
            if(str1[j]==str2[k]):
                A[k+1] = A[k]+1
            else:
                if(A[k] > A[k+1]):
                    A[k+1] = A[k]
    print(A[-1])



Failing test case input:
3
ab]bdca
aacca_
acc
e_b
b`c
cd

Expected output:
3
0
1


Actual output:
5
0
1


Fixed submission (verdict: Accepted):
def L(str1,str2):
    A = [0 for _ in range(len(str2)+1)]
    for char1 in str1:
        A_copy = A[:]
        for j,char2 in enumerate(str2):
            if(char1==char2):
                A[j+1] = A_copy[j]+1
            elif(A[j] > A[j+1]):
                A[j+1] = A[j]
    return A[-1]


m = int(input())
for i in range(m):
    str1 = input()
    str2 = input()
    print(L(str1,str2))
Problem: p02235
Buggy submission (Python3, verdict: Wrong Answer):
q = int(input())

for i in range(q):
    x = input()
    y = input()
 
    l = []
    for j, s in enumerate(x):
        l.append([])
        l[j].append(0)
        if j == 0:
            l[j].append(y.find(s))
        else:
            for k, t in enumerate(l[j - 1][:-1]):
                endPos = y.find(s, t + 1)
                if endPos:
                    l[j].append(min(endPos, l[j - 1][k + 1]))
            endPos = y.find(s, l[j - 1][-1] + 1)
            if endPos:
                l[j].append(endPos)

    print(len(l[len(x) - 1]) - 1)


Failing test case input:
3
badbdba
abacdb
_cb
dba
bbb
cc

Expected output:
4
1
0


Actual output:
5
3
3


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

for i in range(q):
    x = input()
    y = input()
 
    l = []
    for j, s in enumerate(x):
        l.append([])
        l[j].append(-1)
        if j == 0:
            endPos = y.find(s)
            if endPos != -1: 
                l[j].append(endPos)
        else:
            for k, t in enumerate(l[j - 1][:-1]):
                endPos = y.find(s, t + 1)
                if endPos != -1:
                    l[j].append(min(endPos, l[j - 1][k + 1]))
                else:
                    l[j].append(l[j - 1][k + 1])
            endPos = y.find(s, l[j - 1][-1] + 1)
            if endPos != -1:
                l[j].append(endPos)

    print(len(l[-1]) - 1)

Problem: p02235
Buggy submission (Python3, verdict: Wrong Answer):
from bisect import bisect_left
q = int(input())
for _ in [0]*q:
    s1, s2 = input(), input()
    l1, l2 = len(s1), len(s2)

    p = []
    for i, c in enumerate(s1):
        s = 0
        while True:
            j = s2[s:].find(c)
            if j == -1:
                break
            p.append((i, s+j))
            s += j+1

    lis = []
    for _, y in sorted(p):
        i = bisect_left(lis, y)
        if len(lis) <= i:
            lis.append(y)
        else:
            lis[i] = y
    print(len(lis))


Failing test case input:
3
ab^adcb
`aaccb
bca
_ec
dab
cc

Expected output:
4
1
0


Actual output:
5
1
0


Fixed submission (verdict: Accepted):
from bisect import bisect_left
q = int(input())
for _ in [0]*q:
    s1, s2 = input(), input()
    l1, l2 = len(s1), len(s2)

    p = []
    for i, c in enumerate(s1):
        s = 0
        while True:
            j = s2[s:].find(c)
            if j == -1:
                break
            p.append((i, s+j))
            s += j+1

    lis = []
    for _, y in sorted(p, key=lambda x: (x[0], -x[1])):
        i = bisect_left(lis, y)
        if len(lis) <= i:
            lis.append(y)
        else:
            lis[i] = y
    print(len(lis))
Problem: p02235
Buggy submission (Python3, verdict: Wrong Answer):
def Ics(X, Y):
    m = len(X)
    n = len(Y)
    c1 = [0] * (n + 1)
    c2 = [0] * (n + 1)
    for i in range(m):
        d = X[i]
        for j in range(n):
            if (d == Y[j]):
                c1[j + 1] = c2[j] + 1
            elif (c1[j + 1] < c1[j]):
                c1[j + 1] = c1[j]
    return (c1[-1])

q = int(input().rstrip())
t = []
for i in range(q):
    s1 = input().rstrip()
    s2 = input().rstrip()
    t.append(Ics(s1, s2))
print(*t, sep="\n")

Failing test case input:
3
ab^adcb
bacca`
acb
e_b
bac
cd

Expected output:
3
1
1


Actual output:
1
1
1


Fixed submission (verdict: Accepted):
def Ics(X, Y):
    m = len(X)
    n = len(Y)
    c1 = [0] * (n + 1)
    for i in range(m):
        d = X[i]
        c2 = c1[:]
        for j in range(n):
            if (d == Y[j]):
                c1[j + 1] = c2[j] + 1
            elif (c1[j + 1] < c1[j]):
                c1[j + 1] = c1[j]
    return (c1[-1])

q = int(input().rstrip())
t = []
for i in range(q):
    s1 = input().rstrip()
    s2 = input().rstrip()
    t.append(Ics(s1, s2))
print(*t, sep = "\n")

Problem: p02235
Buggy submission (Python3, verdict: Wrong Answer):
def Ics(X, Y):
    m = len(X)
    n = len(Y)
    c1 = [0] * (n + 1)
    for i in range(m):
        d = X[i]
        c2 = c1[:]
        for j in range(n):
            if (d == Y[j]):
                c1[j + 1] = c2[j] + 1
            elif (c1[j + 1] < c1[j]):
                c1[j + 1] = c1[j]
    return (c1[-1])
 
q = int(input())
t = []
for i in range(q):
    s1 = input()
    s2 = input()
    t.append(Ics(s1, s2))
    print(*t)

Failing test case input:
3
`bdadab
abacdb
_cb
dba
bbb
cb

Expected output:
4
1
1


Actual output:
4
4 1
4 1 1


Fixed submission (verdict: Accepted):
def Ics(X, Y):
    m = len(X)
    n = len(Y)
    c1 = [0] * (n + 1)
    for i in range(m):
        d = X[i]
        c2 = c1[:]
        for j in range(n):
            if (d == Y[j]):
                c1[j + 1] = c2[j] + 1
            elif (c1[j + 1] < c1[j]):
                c1[j + 1] = c1[j]
    return (c1[-1])
 
q = int(input().rstrip())
t = []
for i in range(q):
    s1 = input().rstrip()
    s2 = input().rstrip()
    t.append(Ics(s1, s2))
print(*t, sep = "\n")

Problem: p02235
Buggy submission (Python3, verdict: Wrong Answer):
import sys

n=int(input())

for _ in range(n):
	x=sys.stdin.readline().rstrip('\r\n')
	y=sys.stdin.readline().rstrip('\r\n')
	
	list=[0]
	for z in y:
		for i in range(len(list)-1,-1,-1):
			tmp=x.find(z,list[i])
			if tmp+1:
				if i+1<len(list):
					list[i+1]=min(tmp+1,list[i+1])
				else:
					list.append(tmp+1)
print(len(list)-1)


Failing test case input:
3
ada^`eb
dacb^e
aba
aa_
\ad
j`

Expected output:
4
2
0


Actual output:
0


Fixed submission (verdict: Accepted):

def f(x,y):
	list=[0]
	for z in y:
		for i in range(len(list)-1,-1,-1):
			tmp=x.find(z,list[i])+1
			if tmp:
				if i+1 < len(list):
					list[i+1]=min(list[i+1],tmp)
				else:
					list.append(tmp)
	return len(list)-1
 
n=int(input())
for i in range(n):
	x=input()
	y=input()
	print(f(x,y))
Problem: p02235
Buggy submission (Python3, verdict: Wrong Answer):
def Ics(X, Y):
    m = len(X)
    n = len(Y)
    c1 = [0] * (n + 1)
    for i in range(m):
        d = X[i]
        c2 = c1[:]
        for j in range(n):
            if (d == Y[j]):
                c1[j + 1] = c2[j] + 1
            elif (c1[j + 1] < c1[j]):
                c1[j + 1] = c1[j]
    return (c1[-1])
 
q = int(input().rstrip())
t = []
for i in range(q):
    s1 = input().rstrip()
    s2 = input().rstrip()
    t.append(Ics(s1, s2))
    print(*t, sep = "\n")

Failing test case input:
3
ab^adcb
`accab
abb
_ec
bad
cc

Expected output:
3
0
0


Actual output:
3
3
0
3
0
0


Fixed submission (verdict: Accepted):
def Ics(X, Y):
    m = len(X)
    n = len(Y)
    c1 = [0] * (n + 1)
    for i in range(m):
        d = X[i]
        c2 = c1[:]
        for j in range(n):
            if (d == Y[j]):
                c1[j + 1] = c2[j] + 1
            elif (c1[j + 1] < c1[j]):
                c1[j + 1] = c1[j]
    return (c1[-1])
 
q = int(input().rstrip())
t = []
for i in range(q):
    s1 = input().rstrip()
    s2 = input().rstrip()
    t.append(Ics(s1, s2))
print(*t, sep = "\n")

Problem: p02235
Buggy submission (Python3, verdict: Wrong Answer):
ans=[]
n=int(input("n="))
for i in range(n):
    X=input("X=")
    Y=input("Y=")
    com=[0]
    for i in X:
        for j in range(len(com)-1,-1,-1):
            tmp=X.find(i,com[j])+1
            if tmp:
                if j+1<len(com):
                    com[j+1]=min(com[j+1],tmp)
                else:
                    com.append(tmp)     
    ans.append(len(com)-1)
for i in range(n):
    print(ans[i])


Failing test case input:
3
dbad`^d
edbd`^
bbe
^bb
eYa
na

Expected output:
5
2
1


Actual output:
n=X=Y=X=Y=X=Y=7
3
3


Fixed submission (verdict: Accepted):
ans=[]
n=int(input())
for i in range(n):
    X=input()
    Y=input()
    com=[0]
    for i in Y:
        for j in range(len(com)-1,-1,-1):
            tmp=X.find(i,com[j])
            if tmp+1:
                if j+1<len(com):
                    com[j+1]=min(com[j+1],tmp+1)
                else:
                    com.append(tmp+1) 
    ans.append(len(com)-1)
for i in range(n):
    print(ans[i])
Problem: p02235
Buggy submission (Python3, verdict: Wrong Answer):
num = int(input())
for i in range(num):
    X = " " + input()
    Y = " " + input()
    lx = len(X)
    ly = len(Y)
    T = [0] * ly
    for j in range(1,lx):
        C = T[:]
        for k in range(1,ly):
            k1 = k-1
            if X[j] == Y[k]:
                T[k] = C[k1] + 1
            elif C[k] > T[k1]:
                T[k] = C[k]
            else:
                T[k] = T[k1]
        print(T[k])

Failing test case input:
3
ab]bdca
_accab
cac
e_b
b`c
cd

Expected output:
3
0
1


Actual output:
1
2
2
2
2
2
3
0
0
0
0
0
1


Fixed submission (verdict: Accepted):
def main():
    num = int(input())
    A = []
    for i in range(num):
        X = input()
        Y = " " + input()
        lx = len(X)
        ly = len(Y)
        T = [0] * ly
        for j in range(lx):
            xj = X[j]
            C = T[:]
            for k in range(1,ly):
                k1 = k-1
                if xj == Y[k]:
                    T[k] = C[k1] + 1
                elif T[k] < T[k1]:
                    T[k] = T[k1]
        print(T[k])
if __name__ == '__main__':
    main()

Problem: p02235
Buggy submission (Python3, verdict: Wrong Answer):
m = int(input())
for i in range(m):
    str1 = input()
    str2 = input()
    A = [0 for j in range(len(str2)+1)]
    for j in range(len(str1)):
        for k in range(len(str2)):
            if(str1[j]==str2[k]):
                A[k+1] = A[k+1]+1
            else:
                if(A[k] > A[k+1]):
                    A[k+1] = A[k]
    print(A[-1])


Failing test case input:
3
`bdadab
abacdb
_cb
dba
bbb
cb

Expected output:
4
1
1


Actual output:
4
1
3


Fixed submission (verdict: Accepted):
def L(str1,str2):
    A = [0 for _ in range(len(str2)+1)]
    for char1 in str1:
        A_copy = A[:]
        for j,char2 in enumerate(str2):
            if(char1==char2):
                A[j+1] = A_copy[j]+1
            elif(A[j] > A[j+1]):
                A[j+1] = A[j]
    return A[-1]


m = int(input())
for i in range(m):
    str1 = input()
    str2 = input()
    print(L(str1,str2))
Problem: p02235
Buggy submission (Python3, verdict: Wrong Answer):
def Ics(x, y):
    a = len(x)
    b = len(y)
    c1 = [0] * (b + 1)

    for i in range(a):
        d = x[i]
        c2 = c1[:]
        for j in range(b):
            if d == y[j]:
                c1[j + 1] = c2[j] + 1
            elif c1[j + 1] < c1[j]:
                c1[j + 1] = c1[j]
    return c1[-1]

q = int(input().rstrip())
r = []
for k in range(q):
    s1 = input().rstrip()
    s2 = input().rstrip()
    r.append(Ics(s1, s2))

print(*r, sep = "/n")

Failing test case input:
3
abdbdab
abacdb
_cb
dba
bbb
cb

Expected output:
4
1
1


Actual output:
4/n1/n1


Fixed submission (verdict: Accepted):
def Ics(x, y):
    a = len(x)
    b = len(y)
    c1 = [0] * (b + 1)

    for i in range(a):
        d = x[i]
        c2 = c1[:]
        for j in range(b):
            if d == y[j]:
                c1[j + 1] = c2[j] + 1
            elif c1[j + 1] < c1[j]:
                c1[j + 1] = c1[j]
    return (c1[-1])

q = int(input().rstrip())
r = []
for k in range(q):
    s1 = input().rstrip()
    s2 = input().rstrip()
    r.append(Ics(s1, s2))

print(*r, sep = "\n")

Problem: p02235
Buggy submission (Python3, verdict: Wrong Answer):
def Ics(x, y):
    a = len(x)
    b = len(y)
    c1 = [0] * (b + 1)

    for i in range(a):
        d = x[i]
        c2 = c1[:]
        for j in range(b):
            if d == y[j]:
                c1[j + 1] = c2[j] + 1
            elif c1[j + 1] < c1[j]:
                c1[j + 1] = c1[j]
    return (c1[-1])

q = int(input().rstrip())
r = []
for k in range(q):
    s1 = input().rstrip()
    s2 = input().rstrip()
    r.append(Ics(s1, s2))

print(*r, sep = "/n")

Failing test case input:
3
ab]adcb
aacca_
acb
e_b
bac
cd

Expected output:
3
1
1


Actual output:
3/n1/n1


Fixed submission (verdict: Accepted):
def Ics(x, y):
    a = len(x)
    b = len(y)
    c1 = [0] * (b + 1)

    for i in range(a):
        d = x[i]
        c2 = c1[:]
        for j in range(b):
            if d == y[j]:
                c1[j + 1] = c2[j] + 1
            elif c1[j + 1] < c1[j]:
                c1[j + 1] = c1[j]
    return (c1[-1])

q = int(input().rstrip())
r = []
for k in range(q):
    s1 = input().rstrip()
    s2 = input().rstrip()
    r.append(Ics(s1, s2))

print(*r, sep = "\n")
Problem: p02235
Buggy submission (Python3, verdict: Wrong Answer):
def lcs(X, Y):
    m, n = len(X), len(Y)
    cost = [[1] * (n) for _ in range(m)]
    for i in range(0, m):
        if i == 0:
            continue
        for j in range(0, n):
            if j == 0:
                continue
            if X[i - 1] == Y[j - 1]:
                cost[i][j] = cost[i - 1][j - 1] + 1
            else:
                cost[i][j] = max(cost[i][j - 1], cost[i - 1][j])
    return cost[-1][-1]

n = int(input())
for _ in range(n):
    X, Y = input(), input()
    print(lcs(X, Y))

Failing test case input:
3
`bcad_b
`baccb
acb
ce_
bbd
cc

Expected output:
4
1
0


Actual output:
4
2
1


Fixed submission (verdict: Accepted):
def lcs(X, Y):
    costs = [0]
    for c in Y:
        for i in range(len(costs) - 1, -1, -1):
            tmp = X.find(c, costs[i])
            if tmp + 1:
                if i + 1 < len(costs):
                    costs[i + 1] = min(costs[i + 1], tmp + 1)
                else:
                    costs.append(tmp + 1)
    return len(costs) - 1

n = int(input())
for _ in range(n):
    X, Y = (input() for _ in range(2))
    print(lcs(X, Y))

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

def lcs(X, Y):
    dp = [0]*(len(Y)+1)
    
    for x in X:
        for j, y in enumerate(Y):
            if x == y:
                dp[j+1] = dp[j] + 1
            elif dp[j+1] < dp[j]:
                dp[j+1] = dp[j]
                               
    return dp[-1]
    
for _ in range(q):
    X = input()
    Y = input()
    print(lcs(X, Y))

Failing test case input:
3
ab]bdca
_accab
cac
e_b
b`c
cd

Expected output:
3
0
1


Actual output:
4
0
1


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

def lcs(X, Y):
    dp = [0]*(len(Y)+1)
    
    for x in X:
        tmp = dp[:]
        for j, y in enumerate(Y):
            if x == y:
                dp[j+1] = tmp[j] + 1
            elif dp[j+1] < dp[j]:
                dp[j+1] = dp[j]
                               
    return dp[-1]
    
for _ in range(q):
    X = input()
    Y = input()
    print(lcs(X, Y))

Problem: p02235
Buggy submission (Python3, verdict: Wrong Answer):
import sys

n=int(input())

for _ in range(n):
	x=sys.stdin.readline().rstrip('\r\n')
	y=sys.stdin.readline().rstrip('\r\n')
	
	list=[0]
	for z in y:
		for i in range(len(list)-1,-1,-1):
			tmp=x.find(z,list[i])
			if tmp+1:
				if i+1<len(list):
					list[i+1]=min(list[i+1],tmp+1)
				else:
					list.append(tmp+1)
print(len(list)-1)


Failing test case input:
3
bea`]da
d`_dbd
ba`
_ba
e]`
`h

Expected output:
2
2
1


Actual output:
1


Fixed submission (verdict: Accepted):

def f(x,y):
	list=[0]
	for z in y:
		for i in range(len(list)-1,-1,-1):
			tmp=x.find(z,list[i])+1
			if tmp:
				if i+1 < len(list):
					list[i+1]=min(list[i+1],tmp)
				else:
					list.append(tmp)
	return len(list)-1
 
n=int(input())
for i in range(n):
	x=input()
	y=input()
	print(f(x,y))
Problem: p02848
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
S = [i for i in s]
a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for i, value1 in enumerate(S):
    for j, value2 in enumerate(a):
        if value1 == value2:
            if j+2 >= len(a):
                S[i] = a[j+2-len(a)]
                break
            else:
                S[i] = a[j+2]
                break    
S = "".join(S)
print(S)

Failing test case input:
13
YEJXYTRUEPQUOWHLDDNGBNSAJK

Expected output:
LRWKLGEHRCDHBJUYQQATOAFNWX


Actual output:
AGLZAVTWGRSWQYJNFFPIDPUCLM


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
S = [i for i in s]
a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for i, value1 in enumerate(S):
    for j, value2 in enumerate(a):
        if value1 == value2:
            if j+n >= len(a):
                S[i] = a[j+n-len(a)]
                break
            else:
                S[i] = a[j+n]
                break    
S = "".join(S)
print(S)

Problem: p02848
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
s=input()
hiee=""
ans=""
for i in range(len(s)):
    hiee=ord(s[i])
    if (hiee+n >90):
        print("0")
        hiee-=26
    ans+=chr(hiee+n)
print(ans)



Failing test case input:
2
ZXBXCA

Expected output:
BZDZEC


Actual output:
0
BZDZEC


Fixed submission (verdict: Accepted):
n=int(input())
s=input()
hiee=""
ans=""
for i in range(len(s)):
    hiee=ord(s[i])
    if (hiee+n >90):
        hiee-=26
    ans+=chr(hiee+n)
print(ans)

Problem: p02848
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
z=input()
s=list(z)
n=n%26
a=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
x=int(len(s))
d=[]
for i in range(x):
    b=s.pop(0)
    y=a.index(b)
    if y+n>25:
        c=y+n-25
    else:
        c=y+n
    d.append(a[c])
v=int(0)
ans=''.join(d)   
print(ans)


Failing test case input:
13
KJASLCHNDDPHWOUQNTEXUYRIBX

Expected output:
XWNFYPUAQQCUJBHDAGRKHLEVOK


Actual output:
XWNGYPUBQQDUKCIEBHRLIMFVOL


Fixed submission (verdict: Accepted):
n=int(input())
z=input()
s=list(z)
n=n%26
a=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
x=int(len(s))
d=[]
for i in range(x):
    b=s.pop(0)
    y=a.index(b)
    if y+n>25:
        c=y+n-26
    else:
        c=y+n
    d.append(a[c])
v=int(0)
ans=''.join(d)   
print(ans)
Problem: p02848
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S = list(input())
ans = []
abc = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q","r", "s", "t", "u", "v", "w", "x", "y", "z"]
for i in range(len(S)):
    for j in range(len(abc)):
        if S[i] == abc[j]:
            if j + N < 26:
                ans.append(abc[j + N])
            else:
                ans.append(abc[j + N -26])


print("".join(ans).upper())


Failing test case input:
13
AISEEBGOEJKRUNGPQLXTUMWDYZ

Expected output:
NVFRROTBRWXEHATCDYKGHZJQLM


Actual output:

Fixed submission (verdict: Accepted):
N = int(input())
S = list(input())
ans = []
abc = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q","r", "s", "t", "u", "v", "w", "x", "y", "z"]
for i in range(len(S)):
    for j in range(len(abc)):
        if S[i] == abc[j].upper():
            if j + N < 26:
                ans.append(abc[j + N])
            else:
                ans.append(abc[j + N -26])


print("".join(ans).upper())

Problem: p02848
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
   n = input()
   data = list(input())
   for i in data:
      a = ord(i) + int(n)
      if a > ord("Z"):
         a = a + ord("A") - ord("Z")
      print(chr(a),end = "")
   print("")

if __name__==  "__main__":
   main()

Failing test case input:
2
ZYXDBA

Expected output:
BAZFDC


Actual output:
CBZFDC


Fixed submission (verdict: Accepted):
def main():
   n = input()
   data = list(input())
   for i in data:
      a = ord(i) + int(n)
      if a > ord("Z"):
         a = a + ord("A") - ord("Z") - 1
      print(chr(a),end = "")

if __name__==  "__main__":
   main()

Problem: p02848
Buggy submission (Python (3.4.3), verdict: Wrong Answer):



N = int(input())
S = input()


sli = [ord(c) for c in S]
sli_mod = [n + N for n in sli]
sli_mod2 = [sraw if sraw < ord('Z') else sraw - 26 for sraw in sli_mod]
final = [chr(c) for c in sli_mod2]
out = "".join(final)
print(out)


Failing test case input:
13
SJAKMBGOEDKSWOGPQEUTUEXJYZ

Expected output:
FWNXZOTBRQXFJBTCDRHGHRKWLM


Actual output:
FWNX@OTBRQXFJBTCDRHGHRKWLM


Fixed submission (verdict: Accepted):



N = int(input())
S = input()

sli = [ord(c) for c in S]
sli_mod = [n + N for n in sli]

for i, s in enumerate(sli_mod):
    if s > ord('Z'):
        sli_mod[i] -= 26


final = [chr(c) for c in sli_mod]
out = "".join(final)
print(out)

Problem: p02848
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
S=input()
l=[0]*len(S)
for i in range(len(S)):
    print(ord(S[i]))
    if ord(S[i])+N<=90:
        l[i]=chr(ord(S[i])+N)
    else:
        l[i]=chr(ord(S[i])+N-26)
print(''.join(l))


Failing test case input:
13
ABCDEFGHIJKLMNOPQRSTUVWXYZ

Expected output:
NOPQRSTUVWXYZABCDEFGHIJKLM

Actual output:
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
NOPQRSTUVWXYZABCDEFGHIJKLM


Fixed submission (verdict: Accepted):
N=int(input())
S=input()
l=[0]*len(S)
for i in range(len(S)):
    if ord(S[i])+N<=90:
        l[i]=chr(ord(S[i])+N)
    else:
        l[i]=chr(ord(S[i])+N-26)
print(''.join(l))
Problem: p02848
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
s=input()
c=""
for i in s:
  w=ord(i)+ord("A")
  if w>ord("Z"):
    w=w-ord("Z")-1+ord("A")
  c+=chr(w)
print(c)

Failing test case input:
13
YYJXEUTUEPQGOWRKDEOGBNRAJK

Expected output:
LLWKRHGHRCDTBJEXQRBTOAENWX


Actual output:
ql|{|lwxnv~yrklvniuyhqr


Fixed submission (verdict: Accepted):
n=int(input())
s=input()
c=""
w=0
for i in s:
  w=ord(i)+n
  if w>ord("Z"):
    w=w-ord("Z")-1+ord("A")
  c+=chr(w)
  
print(c)

Problem: p02848
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import defaultdict, deque
import sys

INF = float('inf')
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]


n = I()
s = list(S())
s.sort()
ans = ''
for c in s:
    ans += chr(ord('A') + (ord(c) - ord('A') + n) % 26)
print(ans)


Failing test case input:
13
ZYJXEUTUEQPGOWRKDEOGBNKAJR

Expected output:
MLWKRHGHRDCTBJEXQRBTOAXNWE


Actual output:
NOQRRRTTWWXXABBCDEEGHHJKLM


Fixed submission (verdict: Accepted):
from collections import defaultdict, deque
import sys

INF = float('inf')
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]


n = I()
s = S()
ans = ''
for c in s:
    if ord(c) + n > ord('Z'):
        ans += chr((ord(c) + n) - ord('Z') + ord('A') - 1)
    else:
        ans += chr(ord(c) + n)
print(ans)
Problem: p02848
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','S','Y','X','Z']
N = int(input())
S = list(input())
B = []
for i in range(len(S)):
  for j in range(26):
    if S[i] == A[j]:
      if j+N > 25:
        B.append(A[j+N-25])
      else:
        B.append(A[j+N])
print(''.join(B))

Failing test case input:
13
KJASNBGNDDLHWOUQPEURTYXJDY

Expected output:
XWNFAOTAQQYUJBHDCRHEGLKWQL


Actual output:
SWNGLBOTBQQYUKCIEDRIFHMNWQM


Fixed submission (verdict: Accepted):
A = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
N = int(input())
S = list(input())
B = []
for i in range(len(S)):
  for j in range(26):
    if S[i] == A[j]:
      if j+N > 25:
        B.append(A[j+N-26])
      else:
        B.append(A[j+N])
print(''.join(B))

Problem: p02848
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
S = list(input())
for i in range(len(S)):
  if ord(S[i])+2 <= 90:
    S[i] = chr(ord(S[i])+N)
  else:
    S[i] = chr(ord(S[i])+N-26)
for j in S:
  print(j,end = "")

Failing test case input:
13
KJASLBHNDDPHWOUQNTUREYXIBX

Expected output:
XWNFYOUAQQCUJBHDAGHERLKVOK


Actual output:
XWN`YOU[QQ]Ud\b^[ab_RLeVOe

Fixed submission (verdict: Accepted):
N = int(input())
S = list(input())
for i in range(len(S)):
  if ord(S[i])+N <= 90:
    S[i] = chr(ord(S[i])+N)
  else:
    S[i] = chr(ord(S[i])+N-26)
for j in S:
  print(j,end = "")

Problem: p02848
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=input()
s=input()

print(N)
print(s)
L=[]
L.append('A')
L.append('B')
L.append('C')
L.append('D')
L.append('E')
L.append('F')
L.append('G')
L.append('H')
L.append('I')
L.append('J')
L.append('K')
L.append('L')
L.append('M')
L.append('N')
L.append('O')
L.append('P')
L.append('Q')
L.append('R')
L.append('S')
L.append('T')
L.append('U')
L.append('V')
L.append('W')
L.append('X')
L.append('Y')
L.append('Z')

answer=[]
for l in s:
  num=L.index(l)
  
  
  newN=L.index(l)+int(N)
  n=newN%26
  answer.extend(L[n])  
  
answer="".join(answer)
print(answer)

Failing test case input:
13
ZYDWMUTWKQPGOURKJEOGBEESIA

Expected output:
MLQJZHGJXDCTBHEXWRBTORRFVN


Actual output:
13
ZYDWMUTWKQPGOURKJEOGBEESIA
MLQJZHGJXDCTBHEXWRBTORRFVN


Fixed submission (verdict: Accepted):
N=input()
s=input()

L=[]
L.append('A')
L.append('B')
L.append('C')
L.append('D')
L.append('E')
L.append('F')
L.append('G')
L.append('H')
L.append('I')
L.append('J')
L.append('K')
L.append('L')
L.append('M')
L.append('N')
L.append('O')
L.append('P')
L.append('Q')
L.append('R')
L.append('S')
L.append('T')
L.append('U')
L.append('V')
L.append('W')
L.append('X')
L.append('Y')
L.append('Z')

answer=[]
for l in s:
  num=L.index(l)
  
  
  newN=L.index(l)+int(N)
  n=newN%26
  answer.extend(L[n])  
  
answer="".join(answer)
print(answer)
Problem: p02848
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S = input()

for s in S:
    s = ord(s)
    if (s + N) <= 90:
        s += N
    else:
        s = s + N - 26
    s = chr(s)
    print(s)


Failing test case input:
0
YBCXAZ

Expected output:
YBCXAZ


Actual output:
Y
B
C
X
A
Z


Fixed submission (verdict: Accepted):
N = int(input())
S = input()

for s in S:
    s = ord(s)
    if (s + N) <= 90:
        s += N
    else:
        s = s + N - 26
    s = chr(s)
    print(s ,end="")

Problem: p02848
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O',
   'P','Q','R','S','T','U','V','W','X','Y','Z']
N=int(input())
x=input()
X=[j for j in x]
for i in range(0,len(X)):
  n=(A.index(X[i])+N)%26
  X[i]=A[n]
print(X)

Failing test case input:
13
KJASYCHODDPHWOUQNTDXUKSIBX

Expected output:
XWNFLPUBQQCUJBHDAGQKHXFVOK


Actual output:
X W N F L P U B Q Q C U J B H D A G Q K H X F V O K

Fixed submission (verdict: Accepted):
A=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O',
   'P','Q','R','S','T','U','V','W','X','Y','Z']
N=int(input())
x=input()
X=[j for j in x]
for i in range(0,len(X)):
  n=(A.index(X[i])+N)%26
  X[i]=A[n]
Y=''
for i in X:
  Y+=i
print(Y)

Problem: p02848
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
class RotN:
    def __init__(self):
        self.alphabet = [a for a in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ']

    def calculate(self, N, S):
        result_list =[]
        for s in S:
            num = self.alphabet.index(s)
            
            if num + N > 25:
                tmp = 25 - (num + N)
                result_list.append(self.alphabet[tmp])
            
            else:
                tmp = num + N
                result_list.append(self.alphabet[tmp]) 
        return result_list

if __name__ == '__main__':
    N = int(input())
    S = [s for s in input()]
    rn = RotN()
    result_list = rn.calculate(N, S)
    result = ''
    for x in result_list:
        result += x
    print(result)

Failing test case input:
13
KJASNBGNDDLHWOUQPEURTYXJDY

Expected output:
XWNFAOTAQQYUJBHDCRHEGLKWQL


Actual output:
XWNUZOTZQQYUQYSWXRSVTOPWQO


Fixed submission (verdict: Accepted):
class RotN:
    def __init__(self):
        self.alphabet = [a for a in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ']

    def calculate(self, N, S):
        result_list =[]
        for s in S:
            num = self.alphabet.index(s)
            
            if num + N > 25:
                tmp = 25 - (num + N)
                result_list.append(self.alphabet[abs(tmp)-1])
            
            else:
                tmp = num + N
                result_list.append(self.alphabet[tmp]) 
        return result_list

if __name__ == '__main__':
    N = int(input())
    S = [s for s in input()]
    rn = RotN()
    result_list = rn.calculate(N, S)
    result = ''
    for x in result_list:
        result += x
    print(result)
Problem: p02848
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from sys import stdin

n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()

S = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'*2

sn = ""

for i in s:
    sn += S[S.index(i)+2]

print(sn)

Failing test case input:
13
KJASNBGNDDLHWOUQPEURTYXJDY

Expected output:
XWNFAOTAQQYUJBHDCRHEGLKWQL


Actual output:
MLCUPDIPFFNJYQWSRGWTVAZLFA


Fixed submission (verdict: Accepted):
from sys import stdin

n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()

S = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'*2

sn = ""

for i in s:
    sn += S[S.index(i)+n]

print(sn)

Problem: p02848
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
ans = s[:-1] + chr((ord(s[-1])+n-1 - ord('A'))%26 + 1 + ord('A'))
print(ans)


Failing test case input:
13
YYJXEUTUEPQGOWRKDEOGBNKAJR

Expected output:
LLWKRHGHRCDTBJEXQRBTOAXNWE


Actual output:
YYJXEUTUEPQGOWRKDEOGBNKAJE


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
ans = ''
for i in s:
  ans += chr((ord(i)-ord('A')+n)%26 + ord('A'))
print(ans)

Problem: p02848
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 1
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()


n = k()
S = list(v())

for i in range(len(S)):
    a = AL.index(S[i])
    ans = a+2
    if ans >= 26:
        ans = (a+2)-26
    S[i] = AL[ans]

print("".join(S))

Failing test case input:
0
YBCXAZ

Expected output:
YBCXAZ


Actual output:
ADEZCB


Fixed submission (verdict: Accepted):
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 1
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()


n = k()
S = list(v())

for i in range(len(S)):
    a = AL.index(S[i])
    ans = a+n
    if ans >= 26:
        ans = (a+n)-26
    S[i] = AL[ans]

print("".join(S))
Problem: p02848
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S = input()
SS = [chr(i) for i in range(65,65+26)]+[chr(i) for i in range(65,65+26)]
ss = [chr(i) for i in range(97,97+26)] +[chr(i) for i in range(97,97+26)]
ans = ""
print(ord("A"))
for s in S:
    if s.islower():
        ans += ss[ord(s)-97+N]
    else:
        ans += SS[ord(s)-65+N]
print(ans)

Failing test case input:
13
ABCDEFGGIJKLMNOOQRSTUVWXYZ

Expected output:
NOPQRSTTVWXYZABBDEFGHIJKLM


Actual output:
65
NOPQRSTTVWXYZABBDEFGHIJKLM


Fixed submission (verdict: Accepted):
N = int(input())
S = input()
SS = [chr(i) for i in range(65,65+26)]+[chr(i) for i in range(65,65+26)]
ss = [chr(i) for i in range(97,97+26)] +[chr(i) for i in range(97,97+26)]
ans = ""
for s in S:
    if s.islower():
        ans += ss[ord(s)-97+N]
    else:
        ans += SS[ord(s)-65+N]
print(ans)

Problem: p02848
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
alpha = 'ABCDEFGHIJKLMNOPQRSTUvWXYZ'
n = int(input())
s = input()
ans = ''
for x in s:
    ans += alpha[(alpha.find(x) + n) % 26]
print(ans)

Failing test case input:
13
ZYXWVUTSRQOGNMLKJIOGFEDCBA

Expected output:
MLKJIHGFEDBTAZYXWVBTSRQPON


Actual output:
MLKJMHGFEDBTAZYXWvBTSRQPON


Fixed submission (verdict: Accepted):
alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
n = int(input())
s = input()
ans = ''
for x in s:
    ans += alpha[(alpha.find(x) + n) % 26]
print(ans)

Problem: p02848
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S = input()

lst = []
for i in S:
    x = ord(i)
    if x + N > 90:
        x = x - 90 - 1 + 65
    lst.append(chr(int(x) + N))
print(lst)

Failing test case input:
13
ABCDEFGHIJKLMNOPQRSTUVWXYZ

Expected output:
NOPQRSTUVWXYZABCDEFGHIJKLM

Actual output:
N O P Q R S T U V W X Y Z A B C D E F G H I J K L M

Fixed submission (verdict: Accepted):
N = int(input())
S = input()

lst = []
for i in S:
    x = ord(i)
    if x + N > 90:
        x = x - 90 - 1 + 65
    lst.append(chr(int(x) + N))
print(''.join(lst))

Problem: p02848
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a=int(input())
b=list(input())
s=[]
for i in range(len(b)):
  c=(ord(b[i])-64+a)%26+64
  s.append(chr(c))
print("".join(s))


Failing test case input:
0
ABCXYZ

Expected output:
ABCXYZ

Actual output:
ABCXY@


Fixed submission (verdict: Accepted):
a=int(input())
b=list(input())
s=[]
for i in range(len(b)):
  c=(ord(b[i])-ord("A")+a)%26+ord("A")
  s.append(chr(c))
print("".join(s))

Problem: p02848
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
s = input()
t = ""
for i in s:
  a = ord(i) + n
  if a > ord("Z"):
    a = a - 26
  t += chr(a)

Failing test case input:
13
KJASNBGNDDLHWOUQPEURTYXJDX

Expected output:
XWNFAOTAQQYUJBHDCRHEGLKWQK


Actual output:

Fixed submission (verdict: Accepted):
n = int(input())
s = input()
t = ""
for i in s:
  a = ord(i) + n
  if a > ord("Z"):
    a = a - 26
  t += chr(a)
print(t)