ZhenlongDai/ACPR huggingface dataset:
Problem: p00004
Buggy submission (Python3, verdict: Wrong Answer):
while True:
    try:
        (a, b, e, c, d, f) = map(float, input().split())

        D = a * d - b * c
        x = (d * e - b * f) / D
        y = (a * f - c * e) / D

        if D == 0:
            x = 0.0
            y = 0.0

        print("{0:.3f} {1:.3f}".format(x, y))

    except EOFError:
        break




Failing test case input:
2 -1 -3 1 -1 -3
2 -1 -3 -9 9 27

Expected output:
0.000 3.000
0.000 3.000

Actual output:
-0.000 3.000
0.000 3.000


Fixed submission (verdict: Accepted):
while True:
    try:
        (a, b, e, c, d, f) = map(float, input().split())

        D = a * d - b * c
        x = (d * e - b * f) / D
        y = (a * f - c * e) / D

        if abs(x) < 1e-4:
            x = 0.0
        if abs(y) < 1e-4:
            y = 0.0

        print("{0:.3f} {1:.3f}".format(x, y))

    except EOFError:
        break

Problem: p00004
Buggy submission (Python3, verdict: Wrong Answer):
import sys
for i in sys.stdin:
    a, b, c, d, e, f = map(int, i.split())
    x = (c * e - b * f) / (a * e - b * d)
    y = (c * d - a * f) / (b * d - a * e)
    x = abs(x) if x < 10e-4 else x
    y = abs(y) if y < 10e-4 else y
    print("{:.3f} {:.3f}".format(round(x,3), round(y,3)))


Failing test case input:
4 -1 -3 1 0 -3
2 -1 -4 -9 9 27

Expected output:
-3.000 -9.000
-1.000 2.000


Actual output:
3.000 9.000
1.000 2.000


Fixed submission (verdict: Accepted):
import sys
for i in sys.stdin:
    a, b, c, d, e, f = map(int, i.split())
    x = (c * e - b * f) / (a * e - b * d)
    y = (c * d - a * f) / (b * d - a * e)
    x = abs(x) if abs(x) < 10e-4 else x
    y = abs(y) if abs(y) < 10e-4 else y
    print("{:.3f} {:.3f}".format(x, y))

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

r = sys.stdin.readlines()

r.pop(0)

n = [[float(i) for i in (j.split())] for j in r] 

for l in n:
    y = (l[2]*l[3]-l[0]*l[5])/(l[1]*l[3]-l[0]*l[4])
    
    x = (l[2]*l[4]-l[5]*l[1])/(l[0]*l[4]-l[3]*l[1])
    
    print("{:.3f} {:.3f} ".format(x,y))
    

Failing test case input:
1 2 3 3 5 6
2 -1 -2 -1 -1 -4

Expected output:
-3.000 3.000
0.667 3.333


Actual output:
0.667 3.333 


Fixed submission (verdict: Accepted):

import sys
import math

r = sys.stdin.readlines()


n = [[float(i) for i in (j.split())] for j in r] 
    
for l in n:
    y = (l[2]*l[3]-l[0]*l[5])/(l[1]*l[3]-l[0]*l[4])+0
    
    x = (l[2]*l[4]-l[5]*l[1])/(l[0]*l[4]-l[3]*l[1])+0
    
    print("%.3f %.3f" %(x, y))

Problem: p00004
Buggy submission (Python3, verdict: Wrong Answer):
while(True):
		try:
			a,b,c,d,e,f=map(float,input().split(" "))
			x=(c*e-b*f)/(a*e-b*d)
			y=(a*f-c*d)/(a*e-b*d)
			print("{:.3f} {:.3f}".format(x,y))
		except:
			break

Failing test case input:
1 1 3 4 5 4
2 -1 -4 -1 -1 -4

Expected output:
11.000 -8.000
0.000 4.000


Actual output:
11.000 -8.000
-0.000 4.000


Fixed submission (verdict: Accepted):
while(True):
		try:
			a,b,c,d,e,f=map(float,input().split(" "))
			z=a*e-b*d
			if(z!=0):
				x=(c*e-b*f)/z
				y=(a*f-c*d)/z
			print("{:.3f} {:.3f}".format(x+0,y+0))
		except:
			break
Problem: p00004
Buggy submission (Python3, verdict: Wrong Answer):
def main():
    p = [float(x) for x in input().split()]
    x = (p[4]*p[2]-p[1]*p[5])/(p[0]*p[4]-p[1]*p[3])
    y = (p[2]-p[0]*x)/p[1]
    if abs(x)<1e-4:
        x=0.0
    if abs(y)<1e-4:
        y=0.0
    print("{:.3f} {:.3f}".format(x,y))

main()


Failing test case input:
1 3 5 8 6 6
2 -1 -4 1 -1 -16

Expected output:
-0.667 1.889
12.000 28.000


Actual output:
-0.667 1.889


Fixed submission (verdict: Accepted):
def main():
    while 1:
        try:
            p = [float(x) for x in input().split()]
            x = (p[4]*p[2]-p[1]*p[5])/(p[0]*p[4]-p[1]*p[3])
            y = (p[2]-p[0]*x)/p[1]
        except:
            break
        if abs(x)<1e-4:
            x=0.0
        if abs(y)<1e-4:
            y=0.0
        print("{:.3f} {:.3f}".format(x,y))

main()

Problem: p00004
Buggy submission (Python3, verdict: Wrong Answer):
while True:
    try:
        a,b,c,d,e,f = (int(i) for i in input().split())
        det=a*e-b*d
        x = (c*e-b*f)/det
        y = (a*f-c*d)/det
        print("{0:.3f} {1:.3f}".format(x,y))
    except EOFError:
        break

Failing test case input:
2 -1 -3 1 -1 -3
2 -1 -3 -10 9 27

Expected output:
0.000 3.000
0.000 3.000


Actual output:
-0.000 3.000
0.000 3.000


Fixed submission (verdict: Accepted):
while True:
    try:
        a,b,c,d,e,f = (int(i) for i in input().split())
        det=a*e-b*d
        x = (c*e-b*f)/det
        y = (a*f-c*d)/det
        if x==0:x=0
        if y==0:y=0
        print("{0:.3f} {1:.3f}".format(x,y))
    except EOFError:
        break

Problem: p00004
Buggy submission (Python3, verdict: Wrong Answer):
while True:
        try:
            a,b,c,d,e,f=map(float,input().split(" "))
            z=a*e-b*d
            if(z!=0):
                x=(c*e-b*f)/z
                y=(a*f-c*d)/z
            print("{:.3f} {:.3f}".format(x,y))
        except:
            break

Failing test case input:
2 1 3 4 5 4
2 -1 -4 -1 -1 -4

Expected output:
1.833 -0.667
0.000 4.000


Actual output:
1.833 -0.667
-0.000 4.000


Fixed submission (verdict: Accepted):
while(True):
        try:
            a,b,c,d,e,f=map(float,input().split(" "))
            z=a*e-b*d
            if(z!=0):
                x=(c*e-b*f)/z
                y=(a*f-c*d)/z
            print("{:.3f} {:.3f}".format(x+0,y+0))
        except:
            break

Problem: p00004
Buggy submission (Python3, verdict: Wrong Answer):
while True:
  try:
    a, b, c, d, e, f = map(int, input(). split())
    D = (a * e) - (b * d)
    x = (e * c) - (b * f)
    y = (a * f) - (d * c)
    print("%.3f, %.3f" % (round(x / D, 3), round(y / D, 3)))
  except:
    break

Failing test case input:
1 2 3 7 5 1
2 -1 -4 -2 -2 -6

Expected output:
-1.444 2.222
-0.333 3.333


Actual output:
-1.444, 2.222
-0.333, 3.333


Fixed submission (verdict: Accepted):
while True:
  try:
    a, b, c, d, e, f = map(int, input(). split())
    D = (a * e) - (b * d)
    x = (e * c) - (b * f)
    y = (a * f) - (d * c)
    x /= D
    y /= D
    if x / D == 0:
      x = 0
    if y / D == 0:
      y = 0
    print("%.3f %.3f" % (round(x, 3), round(y, 3)))
  except:
    break
Problem: p00004
Buggy submission (Python3, verdict: Wrong Answer):
import sys
for line in sys.stdin:
    a, b, c, d, e, f = map(float, line.split())
    print('{0:.3f} {1:.3f}'.format(round((c * e - b * f) / (a * e - b * d), 3), round((a * f - c * d) / a * e - b * d)))

Failing test case input:
1 1 3 4 5 4
2 -1 -4 -1 -1 -1

Expected output:
11.000 -8.000
-1.000 2.000


Actual output:
11.000 -44.000
-1.000 2.000


Fixed submission (verdict: Accepted):
while True:
    try:
        a, b, c, d, e, f = map(float, input().split())
        x = round((c * e - b * f) / (a * e - b * d), 3)
        y = round((a * f - c * d) / (a * e - b * d), 3)
        print('{0:.3f} {1:.3f}'.format(x + 0, y + 0))
    except:
        break

Problem: p00004
Buggy submission (Python3, verdict: Wrong Answer):
t = 0
while t == 0:	
	try:
		a,b,e,c,d,f = [int(i) for i in input().split()]
	except:
		break
	else:
		x = (d*e - b*f) / (a*d - b*c)
		y = (a*f - c*e) / (a*d - b*c)
		print("{0:.3f}".format(x) + "  " + "{0:.3f}".format(y))

Failing test case input:
3 -2 -5 1 0 -3
2 -1 -6 -9 6 27

Expected output:
-3.000 -2.000
-3.000 0.000


Actual output:
-3.000  -2.000
-3.000  0.000


Fixed submission (verdict: Accepted):
t = 0
while t == 0:	
	try:
		a,b,e,c,d,f = [int(i) for i in input().split()]
	except:
		break
	else:
		x = (d*e - b*f) / (a*d - b*c) + 0
		y = (a*f - c*e) / (a*d - b*c) + 0
		print("{0:.3f}".format(x) + " " + "{0:.3f}".format(y))

Problem: p00004
Buggy submission (Python3, verdict: Wrong Answer):
import math
import itertools

while 1:
    try:
        a, b, c, d, e, f = map(int, input().split())
        print('{0:.3f} {1:.3f}'.format((e*c-b*f)/(a*e-b*d), (-d*c+a*f)/(a*e-b*d)))
    except:
        break

Failing test case input:
2 -1 -3 1 -1 -3
2 -1 -3 -10 9 27

Expected output:
0.000 3.000
0.000 3.000


Actual output:
-0.000 3.000
0.000 3.000


Fixed submission (verdict: Accepted):
import math
import itertools

while 1:
    try:
        a, b, c, d, e, f = map(int, input().split())
        print('{0:.3f} {1:.3f}'.format((e*c-b*f)/(a*e-b*d)+0, (-d*c+a*f)/(a*e-b*d)+0))
    except:
        break

Problem: p00004
Buggy submission (Python3, verdict: Wrong Answer):
while(True):
		try:
			a,b,c,d,e,f=map(float,input().split(" "))
			z=a*e-b*d
			if(z!=0):
				x=(c*e-b*f)/z
				y=(a*f-c*d)/z
			print("{:.3f} {:.3f}".format(x,y))
		except:
			break

Failing test case input:
2 1 3 4 5 4
2 -1 -4 -1 -1 -4

Expected output:
1.833 -0.667
0.000 4.000


Actual output:
1.833 -0.667
-0.000 4.000


Fixed submission (verdict: Accepted):
while(True):
		try:
			a,b,c,d,e,f=map(float,input().split(" "))
			z=a*e-b*d
			if(z!=0):
				x=(c*e-b*f)/z
				y=(a*f-c*d)/z
			print("{:.3f} {:.3f}".format(x+0,y+0))
		except:
			break
Problem: p00004
Buggy submission (Python3, verdict: Wrong Answer):
import sys

def main():
    
    istr = sys.stdin.read()
    wi = istr.splitlines()
    for i in wi:
        a, b, c, d, e, f = list(map(int,i.split()))
        z = (a * e - b * d)
        x = round((c * e - b * f) / z, 3)
        y = round((a * f - c * d) / z, 3)
        print("{0:.3f} {1:.3f}".format(x,y))

if __name__ == '__main__':
    main()

Failing test case input:
1 1 3 4 5 4
2 -1 -4 -1 -1 -4

Expected output:
11.000 -8.000
0.000 4.000


Actual output:
11.000 -8.000
-0.000 4.000


Fixed submission (verdict: Accepted):
import sys

def main():
    
    istr = sys.stdin.read()
    wi = istr.splitlines()
    for i in wi:
        a, b, c, d, e, f = list(map(int,i.split()))
        z = (a * e - b * d)
        x = round((c * e - b * f) / z, 3) + 0.0
        y = round((a * f - c * d) / z, 3) + 0.0
        print("{0:.3f} {1:.3f}".format(x,y))

if __name__ == '__main__':
    main()
Problem: p03230
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def grid(N):
    n = 0
    while n * (n + 1) < N * 2:
        n += 1

    if n * (n + 1) != N * 2:
        print("No")
        return

    S = [[0]*n for _ in range(n+1)]
    cnt = 1
    for i in range(n+1):
        for j in range(n):
            if i <= j:
                S[i][j] = cnt
                cnt += 1
            else:
                S[i][j] = S[j][i-1]
    print("Yes")
    for s in S:
        print(n, end=" ")
        print(*s, sep=" ")


if __name__ == "__main__":
    N = int(input())
 

Failing test case input:
-122

Expected output:
No


Actual output:

Fixed submission (verdict: Accepted):
def grid(N):
    n = 0
    while n * (n + 1) < N * 2:
        n += 1

    if n * (n + 1) != N * 2:
        print("No")
        return

    S = [[0]*n for _ in range(n+1)]
    cnt = 1
    for i in range(n+1):
        for j in range(n):
            if i <= j:
                S[i][j] = cnt
                cnt += 1
            else:
                S[i][j] = S[j][i-1]
    print("Yes")
    print(len(S))
    for s in S:
        print(n, end=" ")
        print(*s, sep=" ")


if __name__ == "__main__":
    N = int(input())
    grid(N)
Problem: p03430
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def solve(s, k):
    n = len(s)
    dp = [[[0] * (k + 1) for _ in range(n)] for _ in range(n + 1)]
    for l in range(n - 1, -1, -1):
        dpl, dpl1 = dp[l], dp[l + 1]
        for r in range(l, n):
            dpr, dpr1 = dpl[r], dpl1[r - 1]
            inc = 1 if l == r else 2
            for p in range(k + 1):
                if s[l] == s[r]:
                    dpr[p] = dpr1[p] + inc
                else:
                    dpr[p] = max(dpl1[r][p], dp[l][r - 1][p])
                    if p:
                        dpr[p] = max(dpr[p], dpr1[p - 1] + inc)
    return dp[0][-1][k]


print(solve(input(), int(input())))


Failing test case input:
`ccbbbabc
0

Expected output:
6

Actual output:
7


Fixed submission (verdict: Accepted):
def solve(s, k):
    n = len(s)
    pdp = [[0] * (k + 1) for _ in range(n + 1)]
    for l in range(n - 1, -1, -1):
        dp = [[0] * (k + 1) for _ in range(n + 1)]
        for r in range(l, n):
            dpr, dpr1 = dp[r], pdp[r - 1]
            inc = 1 if l == r else 2
            is_same = s[l] == s[r]
            for p in range(k + 1):
                if is_same:
                    dpr[p] = dpr1[p] + inc
                else:
                    if p:
                        dpr[p] = max(pdp[r][p], dp[r - 1][p], dpr1[p - 1] + inc)
                    else:
                        dpr[p] = max(pdp[r][p], dp[r - 1][p])
        pdp = dp

    return pdp[-2][k]


print(solve(input(), int(input())))
Problem: p02913
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
S = input()
dp = [[0]*(N+1) for _ in range(N+1)]

for l in range(N)[::-1]:
    for r in range(l+1, N)[::-1]:
        dp[l][r] = dp[l+1][r+1]+1 if S[l]==S[r] else 0

ans = 0 
for i in range(N):
    for j in range(N):
        ans = max(ans, dp[i][j])
print(ans)

Failing test case input:
5
ababa

Expected output:
2

Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
S = input()
dp = [[0]*(N+1) for _ in range(N+1)]

for l in range(N)[::-1]:
    for r in range(l+1, N)[::-1]:
        dp[l][r] = dp[l+1][r+1]+1 if S[l]==S[r] else 0

ans = 0 
for l in range(N)[::-1]:
    for r in range(l+1, N)[::-1]:
        ans = max(ans, min(r-l, dp[l][r]))
print(ans)

Problem: p02913
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
S = input()
dp = [[0] * (N+2) for _ in range(N+2)]
ans = 0
for i in range(1,N+1):
    for d in range(N+1-i):
        print(i,d)
        if S[i-1] == S[i-1+d]:
            dp[i][d] = min(d, dp[i-1][d]+1)
            ans = max(ans, dp[i][d])
print(ans)

Failing test case input:
2
vy

Expected output:
0


Actual output:
1 0
1 1
2 0
0


Fixed submission (verdict: Accepted):
N = int(input())
S = input()
dp = [[0] * (N+2) for _ in range(N+2)]
ans = 0
for i in range(1,N):
    for d in range(1,N+1-i):
        if S[i-1] == S[i-1+d]:
            dp[i][d] = min(d, dp[i-1][d]+1)
            ans = max(ans, dp[i][d])
print(ans)

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

n = int(input())
s = input()

x = 0
for i in range(1,n):
    if s[i - x:] in s[: i - x]:
        x += 1

print(x)

Failing test case input:
5
``\_b

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):

n = int(input())
s = input()

x = 0
for i in range(n):
    s_ = s[:i+1]
    if s_[i - x:] in s_[: i - x]:
        x += 1

print(x)

Problem: p02913
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):

import sys
import collections


def main():
    n = int(sys.stdin.readline().strip())
    s = sys.stdin.readline().strip()
    
    dp = [[0] * n for _ in range(n)]

    for i in range(n):
        dp[i][i] = 1

    res = 0
    for i in range(n-1, -1, -1):
        for j in range(n-1, i, -1):
            if s[i] == s[j]:
                if j == n-1:
                    dp[i][j] = 1
                else:
                    dp[i][j] = dp[i+1][j+1]+1
                res = max(res, dp[i][j])
    print(res)


main()


Failing test case input:
5
ababa

Expected output:
2

Actual output:
3


Fixed submission (verdict: Accepted):

import sys
import collections


def main():
    n = int(sys.stdin.readline().strip())
    s = sys.stdin.readline().strip()
    
    dp = [[0] * n for _ in range(n)]

    for i in range(n):
        dp[i][i] = 1

    res = 0
    for i in range(n-1, -1, -1):
        for j in range(n-1, i, -1):
            if s[i] == s[j]:
                if j == n-1:
                    dp[i][j] = 1
                else:
                    dp[i][j] = dp[i+1][j+1]+1
                res = max(res, min(dp[i][j], j-i))
    print(res)


main()
Problem: p02913
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N = int(input())
        S = input().rstrip()

        dp = [[0] * (N + 1)] * (N + 1)
        for i in range(N)[::-1]:
            for j in range(N)[::-1]:
                if S[i] == S[j]:
                    dp[i][j] = dp[i + 1][j + 1] + 1

        ans = 0
        for i in range(N)[::-1]:
            for j in range(N)[::-1]:
                if i >= j:
                    continue
                else:
                    ans = max(ans, min(dp[i][j], j - i))
        print(ans)



if __name__ == '__main__':
    AtCoder().main()


Failing test case input:
2
y

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N = int(input())
        S = input().rstrip()

        dp = [[0 for i in range(N + 1)] for j in range(N + 1)]
        ans = 0
        for i in range(N)[::-1]:
            for j in range(N)[::-1]:
                if S[i] == S[j]:
                    dp[i][j] = min(dp[i + 1][j + 1] + 1, abs(i - j))
                    ans = max(ans, dp[i][j])
        print(ans)



if __name__ == '__main__':
    AtCoder().main()

Problem: p02913
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys

def main():
    def input():
        return sys.stdin.readline()[:-1]
    N = int(input())
    S = "?_" + input()
    dp = [[0 for k in range(N+1)] for l in range(N+1)]
    for k in range(1,N):
        for l in range(k+1,N+1):
            if S[k] == S[l]:
                dp[k][l] = dp[k-1][l-1] + 1
    ans = 0
    for k in range(1,N):
        for l in range(k+1,N+1):
            if l-k >= dp[k][l]:
                ans = max(ans,dp[k][l])

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


Failing test case input:
5
ac`bb

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
import sys

def main():
    def input():
        return sys.stdin.readline()
    N = int(input())
    S = "_" + input()

    dp = [[0 for k in range(N+1)] for l in range(N+1)]

    for k in range(1,N):
        for l in range(k+1,N+1):
            if S[k] == S[l]:
                dp[k][l] = dp[k-1][l-1] + 1
    ans = 0
    for k in range(1,N):
        for l in range(k+1,N+1):
            if l-k >= dp[k][l]:
                ans = max(ans,dp[k][l])

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

Problem: p02913
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
S = input()

res = 0
for k in range(1, N):
    cnt = 0
    for i in range(N - k):
        if i + k < N and S[i + k] == S[i]:
            cnt += 1
        cnt = min(k, cnt)
        res = max(cnt, res)

print(res)

Failing test case input:
13
fqqapovdfaoof

Expected output:
1


Actual output:
2


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

res = 0
for k in range(1, N):
    cnt = 0
    for i in range(N - k):
        if i + k < N and S[i + k] == S[i]:
            cnt += 1
        else:
            cnt = 0
        cnt = min(k, cnt)
        res = max(cnt, res)

print(res)
Problem: p02913
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
S = input().strip()

dp = [[0 for _ in range(N+1)] for _ in range(N+1)]

for i in reversed(range(N)):
    for j in reversed(range(N)):
        if S[i] != S[j]:
            dp[i][j] = 0
        if S[i] == S[j]:
            dp[i][j] = dp[i+1][j+1] + 1

ans = 0
for i in range(N):
    for j in range(N):
        if i >= j:
            continue
        now = min([dp[i][j], j-1])
        ans = max(ans, now)

print(ans)


Failing test case input:
5
``\_b

Expected output:
1


Actual output:
0


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

dp = [[0 for _ in range(N+1)] for _ in range(N+1)]

for i in reversed(range(N)):
    for j in reversed(range(N)):
        if i >= j:
            continue
        if S[i] != S[j]:
            dp[i][j] = 0
        if S[i] == S[j]:
            dp[i][j] = dp[i+1][j+1] + 1

ans = 0
for i in range(N):
    for j in range(N):
        if i >= j:
            continue
        now = min([dp[i][j], j-i])
        ans = max(ans, now)

print(ans)

Problem: p02913
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n = int(input())
S = input()
ans = 0
cnt = 0
for d in range(n):
    for i in range(n-d):
        if S[i] == S[d+i]:
            cnt += 1
        else:
            cnt = 0
        ans = max(ans, min(cnt, d))
print(ans)


Failing test case input:
13
ffoaodvopaqqf

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())
S = input()
ans = 0
for d in range(n):
    cnt = 0
    for i in range(n-d):
        if S[i] == S[d+i]:
            cnt += 1
        else:
            cnt = 0
        ans = max(ans, min(cnt, d))
print(ans)

Problem: p02913
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
s = input()
x = []
for i in range(n):
    x.append(s[i:])

x.sort()

ans = 0
for i in range(n-1):
    m = min(len(x[i]), len(x[i+1]), abs(len(x[i]) - len(x[i+1])))
    tmp = 0
    for j in range(m):
        if x[i][j] == x[i+1][j]:
            tmp += 1
    if ans < tmp:
        ans = tmp
print(ans)

Failing test case input:
13
senaofunparfd

Expected output:
1


Actual output:
2


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

dp = [ [0] * (n+1) for _ in range(n+1)]

for i in range(n-1, -1, -1):
    for j in range(n-1, -1, -1):
        if s[i] == s[j]:
            dp[i][j] = dp[i+1][j+1] + 1
        else:
            dp[i][j] = 0

ans = 0
for i in range(n):
    for j in range(n):
        tmp = min(dp[i][j], abs(i-j))
        if ans < tmp:
            ans = tmp
print(ans)
Problem: p02913
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
s = input()
dp = [[0 for i in range(n+1)] for j in range(n+1)]
ans = 0
for i in range(n):
  for j in range(n):
    if i == j:
      break
    if s[i] == s[j]:
      t = dp[i][j]
      if j - t == i:
        dp[i+1][j+1]=1
      else:
        dp[i+1][j+1]=1+t
        ans = max(ans, 1+t)

print(ans)


Failing test case input:
5
ababa

Expected output:
2

Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
dp = [[0 for i in range(n+1)] for j in range(n+1)]
ans = 0
for i in range(n):
  for j in range(n):
    if i == j:
      break
    if s[i] == s[j]:
      t = dp[i][j]
      if j == i-t:
        dp[i+1][j+1]=1
      else:
        dp[i+1][j+1]=1+t
        ans = max(ans, 1+t)

print(ans)

Problem: p02913
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n = int(input())
s = input()
dp = [[0]*(n) for _ in range(n)]

for i in range(n-1, -1, -1):
    for j in range(n-1, -1, -1):
        if i == n-1 or j == n-1:
            if s[i] == s[j]:
                dp[i][j] += 1
            continue

        if s[i] == s[j]:
            dp[i][j] = dp[i+1][j+1] + 1        
        else:
            dp[i][j] = dp[i+1][j+1]

ans = 0
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        ans = max(ans, min(abs(j-i), dp[i][j]))
print(ans)

Failing test case input:
13
fqqapovdfaoof

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
dp = [[0]*(n) for _ in range(n)]

for i in range(n-1, -1, -1):
    for j in range(i-1, -1, -1):
        if i == (n-1):
            if s[i] == s[j]:
                dp[i][j] += 1
            continue

        if s[i] == s[j]:
            dp[i][j] = dp[i+1][j+1] + 1        

ans = 0
for i in range(n-1, -1, -1):
    for j in range(i, -1, -1):
        ans = max(ans, min(abs(j-i), dp[i][j]))
print(ans)
Problem: p02913
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):

n = int(input())
ab = str(input())

ans = set([0])
lenab = len(ab)
for h in range(lenab):
    abc = ab[h:]
    lenabc = lenab - h
    A = [0] * lenabc
    i = 1; j = 0
    midlen = lenabc
    while i < lenabc:
        while i+j < lenabc and abc[j] == abc[i+j] and j < midlen:
            j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        ans.add(j)
        k= 1
        while lenabc-i > k < j - A[k]:
            A[i+k] = A[k]
            k += 1
        i += k; j -= k

print(max(ans))

Failing test case input:
5
ababa

Expected output:
2

Actual output:
3


Fixed submission (verdict: Accepted):

n = int(input())
ab = str(input())

ans = set([0])
lenab = len(ab)

for h in range(lenab):
    abc = ab[h:]
    lenabc = len(abc)
    i = 1; j = 0
    A = [0]*lenabc
    A[0] = lenabc
    while i < lenabc:
        while i+j < lenabc and abc[j] == abc[i+j] and j < i:
            j += 1
        if j == 0:
            i += 1
        else:
            A[i] = j
            ans.add(j)
            k = 1
            while lenabc - i > k < j - A[k] and j < i - k :
                A[i + k] = A[k]
                k += 1
            i += k;
            j -= k

print(max(ans))

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

tmp = input()
my_str = input()

start = 0
end = 1
max_len = 0

while (end + max_len < len(my_str)):
    if my_str[start:end] in my_str[end:]:
        end += 1
        if end - start > max_len:
            max_len = end - start
    else:
        start += 1

print(max_len)


Failing test case input:
13
qfoaodvopaqff

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):

tmp = input()
my_str = input()

start = 0
end = 1
max_len = 0

while (end < len(my_str)):
    if my_str[start:end] in my_str[end:]:
        if end - start > max_len:
            max_len = end - start
        end += 1
    else:
        start += 1

print(max_len)

Problem: p02913
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N=int(input())
S=input()
ans=0
for i in range(N-1):
  jstart=i+ans+1
  for j in range(jstart,N):
    if S[i:j] in S[j+1:]:
      ans=max(ans,j-i)
    else:
      break
print(ans)

Failing test case input:
5
_`abb

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
N=int(input())
S=input()
ans=0
for i in range(N-1):
  jstart=i+ans+1
  for j in range(jstart,N):
    if S[i:j] in S[j:]:
      ans=max(ans,j-i)
    else:
      break
print(ans)
Problem: p02913
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
def main():
  n=int(input())
  s=input()
  dp=[[0]*(n+1) for i in range(n+1)]
  for i in range(n-1,-1,-1):
    for j in range(n-1,-1,-1):
      if s[i]==s[j]:
        dp[i][j]+=dp[i+1][j+1]+1
  
  
  ans=0
  for i in range(n):
    for j in range(n):
      if i<j:
        t=min(j-1,dp[i][j])
        ans=max(ans,t)
  print(ans)      
        

if __name__=='__main__':
  main()

Failing test case input:
5
bb`ca

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
def main():
  n=int(input())
  s=input()
  dp=[[0]*(n+1) for i in range(n+1)]
  for i in range(n-1,-1,-1):
    for j in range(n-1,i,-1):
      if s[i]==s[j]:
        dp[i][j]=dp[i+1][j+1]+1
  
  
  
  ans=0
  for i in range(n-1):
    for j in range(i+1,n):
      ans=max(ans,min(j-i,dp[i][j]))
  print(ans)      
        

if __name__=='__main__':
  main()

Problem: p02913
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
ab = str(input())

ans = set([0])
lenab = len(ab)
for h in range(lenab):
    abc = ab[h:]
    lenabc = lenab - h
    A = [0] * lenabc
    i = 1; j = 0
    midlen = lenabc
    while i < lenabc:
        while i+j < lenabc and abc[j] == abc[i+j] and j < i:
            j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        ans.add(j)
        i += i+j
        
        
        
        
        

print(max(ans))

Failing test case input:
13
dfqapovfo`ofq

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):

n = int(input())
ab = str(input())

ans = set([0])
lenab = len(ab)

for h in range(lenab):
    abc = ab[h:]
    lenabc = len(abc)
    i = 1; j = 0
    A = [0]*lenabc
    A[0] = lenabc
    while i < lenabc:
        while i+j < lenabc and abc[j] == abc[i+j] and j < i:
            j += 1
        if j == 0:
            i += 1
        else:
            A[i] = j
            ans.add(j)
            k = 1
            while lenabc - i > k < j - A[k] and j < i - k :
                A[i + k] = A[k]
                k += 1
            i += k;
            j -= k

print(max(ans))

Problem: p02913
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
S = input()

res = 0
for k in range(1, N):
    cnt = 0
    for i in range(N - k):
        if i + k < N and S[i + k] == S[i]:
            cnt += 1
            cnt = min(k, cnt)
            res = max(cnt, res)

print(res)

Failing test case input:
13
efnaroegnarts

Expected output:
3


Actual output:
4


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

res = 0
for k in range(1, N):
    cnt = 0
    for i in range(N - k):
        if i + k < N and S[i + k] == S[i]:
            cnt += 1
        else:
            cnt = 0
        cnt = min(k, cnt)
        res = max(cnt, res)

print(res)
Problem: p02913
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
s = input()

def z_algo(S):
    N = len(S)
    A = [0]*N
    i = 1; j = 0
    A[0] = l = len(S)
    while i < l:
        while i+j < l and S[j] == S[i+j] and j <= i:
        	j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        k = 1
        while l-i > k < j - A[k]:
            A[i+k] = A[k]
            k += 1
        i += k; j -= k
    return A
ans = 0
for i in range(n-1):
	tmp = z_algo(s[i:])
	
	res = max(tmp[1:])
	if ans < res:
		ans = res

print(ans)


Failing test case input:
5
ababa

Expected output:
2

Actual output:
3


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

def z_algo(S):
    N = len(S)
    A = [0]*N
    i = 1; j = 0
    A[0] = l = len(S)
    while i < l:
        while i+j < l and S[j] == S[i+j]:
        	j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        k = 1
        while l-i > k < j - A[k]:
            A[i+k] = A[k]
            k += 1
        i += k; j -= k
    return A
ans = 0
for i in range(n-1):
	tmp = z_algo(s[i:])
	for j,zj in enumerate(tmp):
		if j+1 > zj:
			ans = max(ans,zj)

print(ans)

Problem: p02913
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
S = input().strip()

dp = [[0 for _ in range(N+1)] for _ in range(N+1)]

for i in reversed(range(N)):
    for j in reversed(range(N)):
        if i >= j:
            continue
        if S[i] != S[j]:
            dp[i][j] = 0
        if S[i] == S[j]:
            dp[i][j] = dp[i+1][j+1] + 1

ans = 0
for i in range(N):
    for j in range(N):
        if i >= j:
            continue
        now = min([dp[i][j], j-1])
        ans = max(ans, now)

print(ans)


Failing test case input:
5
abab`

Expected output:
2


Actual output:
1


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

dp = [[0 for _ in range(N+1)] for _ in range(N+1)]

for i in reversed(range(N)):
    for j in reversed(range(N)):
        if i >= j:
            continue
        if S[i] != S[j]:
            dp[i][j] = 0
        if S[i] == S[j]:
            dp[i][j] = dp[i+1][j+1] + 1

ans = 0
for i in range(N):
    for j in range(N):
        if i >= j:
            continue
        now = min([dp[i][j], j-i])
        ans = max(ans, now)

print(ans)
Problem: p02913
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
n = int(sys.stdin.readline())
S = sys.stdin.readline().rstrip()


dp = [[0 for i in range(n)] for j in range(n)]

for j in range(1, n):
    if S[0] == S[j]:
        dp[0][j] = 1



for i in range(1, n-1):
    for j in range(i+1, n):
        if S[i] ==S[j]:
            if j-1 !=i:
                dp[i][j] = dp[i-1][j-1] +1

maxp = 0
for i in range(n-1):
    for j in range(i+1, n):
        if maxp < dp[i][j]:
            maxp = dp[i][j]

print(maxp)

Failing test case input:
5
`cabb

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
import sys
n = int(sys.stdin.readline())
S = sys.stdin.readline().rstrip()


dp = [[0 for i in range(n)] for j in range(n)]

for j in range(1, n):
    if S[0] == S[j]:
        dp[0][j] = 1



for i in range(1, n-1):
    for j in range(i+1, n):
        if S[i] ==S[j]:
            dp[i][j] = min(dp[i-1][j-1] +1, j-i)

maxp = 0
for i in range(n-1):
    for j in range(i+1, n):
        if maxp < dp[i][j]:
            maxp = dp[i][j]

print(maxp)

Problem: p02913
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    S = input().strip()

    dp = [0] * N
    for i, s in enumerate(S):
        if i == 0:
            continue
        before_ans = dp[i-1]
        tmp_ans = S[-(before_ans+1):]
        if tmp_ans in S[:-(before_ans+1)]:
            dp[i] = before_ans + 1
        else:
            dp[i] = before_ans
    print(dp[-1])


if __name__ == "__main__":
    main()


Failing test case input:
13
strangeoranfe

Expected output:
3


Actual output:
1


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    S = input().strip()

    dp = [0] * N
    for i, s in enumerate(S):
        if i == 0:
            continue
        before_ans = dp[i-1]
        now_S = S[:i+1]
        tmp_ans = now_S[-(before_ans+1):i+1]
        
        if tmp_ans in now_S[:-(before_ans+1)]:
            dp[i] = before_ans + 1
        else:
            dp[i] = before_ans
    print(dp[-1])


if __name__ == "__main__":
    main()

Problem: p02913
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
S = [ord(s) for s in input()]



c = 0
for i in range(1, N):
    d = 0
    for s_j, t_j in zip(S, S[i:]):
        if s_j == t_j:
            d += 1
        else:
            c = max(c, min(d, i))
    c = max(c, min(d, i))


print(c)


Failing test case input:
13
renaofunparfd

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
N = int(input())
S = [ord(s) for s in input()]



c = 0
for i in range(1, N):
    d = 0
    for s_j, t_j in zip(S, S[i:]):
        if s_j == t_j:
            d += 1
        else:
            c = max(c, min(d, i))
            d = 0
    c = max(c, min(d, i))


print(c)
Problem: p02913
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N=int(input())
s=input()
ans=0
for x in range(N-1):
    S=s[x:]
    l=len(S)
    A=[0]*l
    A[0]=l
    i=x+1;j=0
    while(i<l):
        while(i+j<l and S[j]==S[i+j]):
            j+=1
        A[i]=j
        if(j==0):
            i+=1
            continue
        k=1
        while(i+k<l and k+A[k]<j):
            A[i+k]=A[k]
            k+=1
        i+=k
        j-=k
    m=0
    for z in range(l):
        if(z-A[z]>=0):
            m=max(m,A[z])
    ans=max(m,ans)
print(ans)

Failing test case input:
5
_`abb

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
def z_algorithm(S):
    l=len(S)
    A=[0]*n
    i=1;j=0
    while i<l:
        while(i+j<l and S[j]==S[i+j]):
            j+=1
        A[i]=j
        if j==0:
            i+=1
            continue
        k=1
        while i+k<l and k+A[k]<j:
            A[i+k]=A[k]
            k+=1
        i+=k
        j-=k
    return A
n=int(input())
s=input()
ans=0
for i in range(n-1):
    a=z_algorithm(s[i:])
    for j in range(len(a)):
        if(a[j]<=j):
            ans=max(ans,a[j])
print(ans)

Problem: p02913
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
s = input()

def z_algo(S):
    N = len(S)
    A = [0]*N
    i = 1; j = 0
    A[0] = l = len(S)
    while i < l:
        while i+j < l and S[j] == S[i+j] and j <= i:
        	j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        k = 1
        while l-i > k < j - A[k]:
            A[i+k] = A[k]
            k += 1
        i += k; j -= k
    return A
ans = 0
for i in range(n-1):
	tmp = z_algo(s[i:])
	print(tmp)
	res = max(tmp[1:])
	if ans < res:
		ans = res

print(ans)


Failing test case input:
5
b`\``

Expected output:
1


Actual output:
[5, 0, 0, 0, 0]
[4, 0, 1, 1]
[3, 0, 0]
[2, 1]
1


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

def z_algo(S):
    N = len(S)
    A = [0]*N
    i = 1; j = 0
    A[0] = l = len(S)
    while i < l:
        while i+j < l and S[j] == S[i+j]:
        	j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        k = 1
        while l-i > k < j - A[k]:
            A[i+k] = A[k]
            k += 1
        i += k; j -= k
    return A
ans = 0
for i in range(n-1):
	tmp = z_algo(s[i:])
	for j,zj in enumerate(tmp):
		if j+1 > zj:
			ans = max(ans,zj)

print(ans)
Problem: p02913
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def p_e():
    N = int(input())
    S = input()

    l, r, ans = 0, 0, 0

    while r < N:
        print(l, r)
        if S[l:r] in S[r:N]:
            ans = max(ans, r - l)
            r += 1
        else:
            l += 1

    print(ans)


if __name__ == '__main__':
    p_e()


Failing test case input:
13
strangeoranfe

Expected output:
3


Actual output:
0 0
0 1
1 1
1 2
2 2
2 3
2 4
2 5
2 6
3 6
4 6
5 6
6 6
6 7
6 8
7 8
8 8
8 9
9 9
9 10
10 10
10 11
11 11
11 12
12 12
3


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

    l, r, ans = 0, 0, 0

    while r < N:
        if S[l:r] in S[r:N]:
            ans = max(ans, r - l)
            r += 1
        else:
            l += 1

    print(ans)


if __name__ == '__main__':
    p_e()

Problem: p02913
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
def z_algo(S):
    N = len(S)
    A = [0]*N
    i = 1; j = 0
    A[0] = l = len(S)
    while i < l:
        while i+j < l and S[j] == S[i+j]:
            j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        k = 1
        while l-i > k < j - A[k]:
            A[i+k] = A[k]
            k += 1
        i += k; j -= k
    return A
ans = 0
s = input()
for i in range(n):
    string = z_algo(s[i:])
    for j in range(1,len(string)):
        if j - i  + string[j] < n:
            ans = max(ans, string[j])
print(ans)

Failing test case input:
5
_b]_b

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
def z_algo(S):
    N = len(S)
    A = [0]*N
    i = 1; j = 0
    A[0] = l = len(S)
    while i < l:
        while i+j < l and S[j] == S[i+j]:
            j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        k = 1
        while l-i > k < j - A[k]:
            A[i+k] = A[k]
            k += 1
        i += k; j -= k
    return A
ans = 0
s = input()
for i in range(n):
    string = z_algo(s[i:])
    for j in range(len(string)):
        if j  >= string[j]:
            ans = max(ans, string[j])
print(ans)

Problem: p02913
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
S = input()
lb, ub = -1, N
while ub - lb > 1:
    m = (lb + ub) 
    s1 = S[:m]
    s2 = S[m:2*m]
    ss = set()
    ok = False
    for i in range(2*m, N):
        ss.add(s1)
        if s2 in ss:
            ok = True
            break
        s1 = s1[1:] + s2[0]
        s2 = s2[1:] + S[i]
    if s2 in ss:
        ok = True
    if ok:
        lb = m
    else:
        ub = m
print(lb)


Failing test case input:
2
zz

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())
S = input()
lb, ub = -1, N
while ub - lb > 1:
    m = (lb + ub) 
    s1 = S[:m]
    s2 = S[m:2*m]
    ss = set()
    ok = False
    for i in range(2*m, N):
        ss.add(s1)
        if s2 in ss:
            ok = True
            break
        s1 = s1[1:] + s2[0]
        s2 = s2[1:] + S[i]
    ss.add(s1)
    if s2 in ss:
        ok = True
    if ok:
        lb = m
    else:
        ub = m
print(lb)
Problem: p02913
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N = NI()
    S = SI()
    dp = [[0] * (N+1) for _ in range(N)]

    for i in range(1,N):
        for j in range(i+1,N+1):
            if S[i-1] == S[j-1] and j-i > dp[i-1][j-1]:
                dp[i][j] = dp[i-1][j-1] + 1
            else:
                dp[i][j] = max(dp[i-1][j],dp[i][j-1])
    print(dp[-1][-1])

if __name__ == '__main__':
    main()

Failing test case input:
13
deqapovfo`ofq

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N = NI()
    S = SI()
    dp = [[0] * (N+1) for _ in range(N)]

    ans = 0
    for i in range(1,N):
        for j in range(i+1,N+1):
            if S[i-1] == S[j-1]:
                if j-i > dp[i-1][j-1]:
                    dp[i][j] = dp[i-1][j-1] + 1
                    ans = max(ans,dp[i][j])
                else:
                    dp[i][j] = 1
    print(ans)

if __name__ == '__main__':
    main()

Problem: p02913
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n=int(input())
s=input()
def Zalgo(s):
    ans=0
    L=len(s)
    Z=[0]*L
    Z[0]=L
    i=1;j=0
    while i<L:
        while i+j < L and s[j]==s[i+j]:j+=1
        Z[i]=j
        if Z[i]>ans:ans=Z[i]
        if j == 0:
            i+=1
            continue
        k=1
        while k<j and k+Z[k]<j:
            Z[i+k]=Z[k]
            k+=1
        i+=k
        j-=k
    return ans
ans=0
for i in range(n):
  p=Zalgo(s[i:])
  if p > ans:
    ans=p
print(ans)

Failing test case input:
5
ababa

Expected output:
2

Actual output:
3


Fixed submission (verdict: Accepted):

n=int(input())
s=input()
def Zalgo(s):
    ans=0
    L=len(s)
    Z=[0]*L
    Z[0]=L
    i=1;j=0
    while i<L:
        while i+j < L and s[j]==s[i+j]:j+=1
        Z[i]=j
        if Z[i] > ans and Z[i]<=i:
            ans=Z[i]
        if j == 0:
            i+=1
            continue
        k=1
        while k<j and k+Z[k]<j:
            Z[i+k]=Z[k]
            k+=1
        i+=k
        j-=k
    return ans
ans=0
for i in range(n):
    p=Zalgo(s[i:])
    if p > ans:
        ans=p
print(ans)
Problem: p02913
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def f_e_dp():
    n = int(input())
    s = input()
    dp = [[0]*(n+1) for _ in range(n+1)]
    for i in reversed(range(n)):
        for j in reversed(range(n)):
            if i>=j:
                continue
            if s[i]==s[j]:
                dp[i][j] = min(j-i, dp[i+1][j+1]+1)
    print(max(max(dp)))

if __name__ == "__main__":
    f_e_dp()

Failing test case input:
13
seraogtoranfe

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
def f_e_dp():
    n = int(input())
    s = input()
    dp = [[0]*(n+1) for _ in range(n+1)]
    for i in reversed(range(n)):
        for j in reversed(range(n)):
            if s[i]==s[j] and i<j:
                dp[i][j] = dp[i+1][j+1]+1
    a = 0
    for i in range(n):
        for j in range(n):
            if i<j:
                a = max(a, min(j-i, dp[i][j]))
    print(a)

if __name__ == "__main__":
    f_e_dp()

Problem: p02913
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
my_str = input()
 
start = 0
end = 1
max_len = 0
 
while (end < len(my_str)):
    if my_str[start:end] in my_str[end:]:
        if end - start > max_len:
            max_len = end - start
        end += 1
    else:
        start += 1

Failing test case input:
5
^`b_b

Expected output:
1


Actual output:

Fixed submission (verdict: Accepted):
tmp = input()
my_str = input()
 
start = 0
end = 1
max_len = 0
 
while (end < len(my_str)):
    if my_str[start:end] in my_str[end:]:
        if end - start > max_len:
            max_len = end - start
        end += 1
    else:
        start += 1
print(max_len)

Problem: p02913
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N = int(input())
S = input()
ans = 0
for a in range(1, N):
    cnt = 0
    for i in range(N - a):
        if S[i + a] == S[i]:
            cnt += 1
        else:
            cnt = 0
        ans = max(ans, min(cnt, N - a - 1))
print(ans)


Failing test case input:
5
_b]_b

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N = int(input())
S = input()
ans = 0
for a in range(1, N):
    cnt = 0
    for i in range(N - a):
        if S[i + a] == S[i]:
            cnt += 1
        else:
            cnt = 0
        ans = max(ans, min(cnt, a))
print(ans)
Problem: p02913
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
S = list(input().strip())

dp = [[0] * N for i in range(N)]
max_leng2 = 0 
for i in range(0, N):
    leng2 = 0

    j = i - 1
    while j > -1:
        if S[i] == S[j]:
            sta_j = j
            if j != 0:
                leng2 = dp[i-1][sta_j-1] + 1
            else: 
                leng2 = 1
            dp[i][sta_j] = leng2
            max_leng2 = max(max_leng2, leng2)
        j -= 1
print(max_leng2)

Failing test case input:
5
ababa

Expected output:
2

Actual output:
3


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
S = list(input().strip())

dp = [[0] * N for i in range(N)]
max_leng2 = 0 
for i in range(0, N):
    leng2 = 0

    j = i - 1
    while j > -1:
        if S[i] == S[j]:
            sta_j = j
            if j != 0:
                leng2 = dp[i-1][sta_j-1] + 1
            else: 
                leng2 = 1
            
            if i - sta_j < leng2:
                leng2 = i - sta_j
                
            dp[i][sta_j] = leng2
            max_leng2 = max(max_leng2, leng2)
        j -= 1
print(max_leng2)

Problem: p02913
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n=int(input())
s=list(input())

dp=[[0]*(n+1) for i in range(n+1)]
ans=0

for i in range(1,n):
    for j in range(i+1,n+1):
        if s[n-i]==s[n-j]:
            dp[n-i][n-j]=min((n-i)-(n-j),dp[n-i+1][n-j+1]+1)
            ans=max(dp[n-i][n-j],dp[n-i+1][n-j+1])
        else:
            pass
print(ans)
        


        
            
        
            
            

            
            




Failing test case input:
13
seraoguoranfe

Expected output:
2


Actual output:
1


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

dp=[[0]*(n+1) for i in range(n+1)]
ans=0

for i in range(1,n):
    for j in range(i+1,n+1):
        if s[n-i]==s[n-j]:
            dp[n-i][n-j]=min((n-i)-(n-j),dp[n-i+1][n-j+1]+1)
            ans=max(dp[n-i][n-j],ans)
        else:
            pass
print(ans)

Problem: p02913
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n=int(input())
s=input()
w=[[0]*n for i in range(n)]
ans=chk=0
for i in range(n-1,-1,-1):
    for j in range(n-1,-1,-1):
        if s[i]==s[j]:
            if i==n-1 or j==n-1:
                w[i][j]=1
            else:
                w[i][j]=w[i+1][j+1]+1

for i in range(1,n):
    for j in range(i):
        ans=max(ans,w[i][j])
        
print(ans)


Failing test case input:
5
ababa

Expected output:
2

Actual output:
3


Fixed submission (verdict: Accepted):
n=int(input())
s=input()
w=[[0]*n for i in range(n)]
ans=chk=0
for i in range(n-1,-1,-1):
    for j in range(n-1,-1,-1):
        if s[i]==s[j]:
            if i==n-1 or j==n-1:
                w[i][j]=1
            else:
                w[i][j]=w[i+1][j+1]+1
for i in range(1,n):
    for j in range(i):
        
        ans=max(ans,w[i][j]-[0,w[i][j]-(i-j-w[i][j]+1)][j+w[i][j]>=i+1])
print(ans)