ZhenlongDai/ACPR huggingface dataset:
Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
t = input()

sf = s[0:n]
tf = t[-n:]

for i in range(len(sf)):
    if (sf[i] in tf):
        for j in range(0, len(sf) - i):
            if (sf[i + j] != tf[j]):
                break
        else:
            print(tf)

    else:
        print(sf[i],end="")
else:
    print(tf)


Failing test case input:
3
cab
efd

Expected output:
6


Actual output:
cabefd


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


ans = []

for i in range(n):
    if (s[i] == t[0]):
        for j in range(0, n - i):
            if (s[i + j] != t[j]):
                break
        else:
            ans+=t
            
            break

    
    ans.append(s[i])

else:
    ans+=t
    

print(len(ans))

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

for i in range(N):
    if s[i:] == t[:N - i]:
        tmp = len(s[i:])
        print(s + t[tmp:])
        exit()

print(s + t)

Failing test case input:
3
abc
cce

Expected output:
5


Actual output:
abcce


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

for i in range(N):
    if s[i:] == t[:N - i]:
        tmp = len(s[i:])
        print(len(s + t[tmp:]))
        exit()

print(len(s + t))

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
t = input()

ans = 2*n

for i in range(1,n+1):
    print(s[-i:], t[:i])
    if s[-i:] == t[:i]:
        ans = 2*n - i
print(ans)

Failing test case input:
4
frsx
xreo

Expected output:
7


Actual output:
x x
sx xr
rsx xre
frsx xreo
7


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

ans = 2*n

for i in range(1,n+1):
    if s[-i:] == t[:i]:
        ans = 2*n - i
print(ans)

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

ans = N + N
for i in range(N):
  w = S + T[-(i+1):]
  if w[:N] == S and w[N:] == T:
    ans = min(ans,i+N)

if S == T:
  ans = N
    
print(ans)
    


Failing test case input:
3
``d
efc

Expected output:
6


Actual output:
5


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

ans = N + N
for i in range(N):
  w = S + T[-(i+1):]
  if w[:N] == S and w[-N:] == T:
    ans = min(ans,i+N+1)

if S == T:
  ans = N
    
print(ans)

Problem: p03951
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
s,t = input(),input()

for i in range(N,0,-1):
  if s[N-i:] == t[:i]:
    print( s + t[i:])
    quit()

Failing test case input:
3
`cb
bec

Expected output:
5


Actual output:
`cbec


Fixed submission (verdict: Accepted):
N = int(input())
s,t = input(),input()

for i in range(N,0,-1):
  if s[N-i:] == t[:i]:
    print( len(s + t[i:]))
    quit()
else:
  print(len(s+t))
Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
s=input()
t=input()
c=0
for i in range(n):
    print(s[-i-1:])
    print(t[:i+1])
    if s[-i-1:]==t[:i+1]:
        c=i+1
print(n*2-c)


Failing test case input:
1
`


Expected output:
2


Actual output:
`

2


Fixed submission (verdict: Accepted):
n=int(input())
s=input()
t=input()
c=0
for i in range(n):
    
    
    if s[-i-1:]==t[:i+1]:
        c=i+1
print(n*2-c)

Problem: p03951
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
s,t = input(),input()

for i in range(N,0,-1):
  if s[N-i:] == t[:i]:
    print( s + t[i:])
    quit()
else:
  print(s+t)

Failing test case input:
4
expr
epxq

Expected output:
8


Actual output:
exprepxq


Fixed submission (verdict: Accepted):
N = int(input())
s,t = input(),input()

for i in range(N,0,-1):
  if s[N-i:] == t[:i]:
    print( len(s + t[i:]))
    quit()
else:
  print(len(s+t))

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
s=str(input())
t=str(input())

def solve(n,s,t):
  for i in range(n):
    print(s[i:])
    print(t[:n-i])
    if s[i:]==t[:n-i]:
      return 2*n-(n-i)
  return 2*n

print(solve(n,s,t))

Failing test case input:
1
[
~

Expected output:
2


Actual output:
[
~
2


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

def solve(n,s,t):
  for i in range(n):
    if s[i:]==t[:n-i]:
      return 2*n-(n-i)
  return 2*n

print(solve(n,s,t))

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input().strip()
t = input().strip()
for i in range(n-1):
  if s[i:] == t[:n-i+1]:
    print(s + t[i+1:])
print(s+t)


Failing test case input:
1
^
}

Expected output:
2


Actual output:
^}


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
t = input()
for i in range(n):
    if s[i:] == t[:n-i]:
        print(n + i)
        break
else:
    print(2 * n)

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=input()
b=input()
c=0
for i in range(1,n):
  if a[-i:]==b[:i]:
    c=i
print(2*n-c)

Failing test case input:
4
expr
expr

Expected output:
4

Actual output:
8


Fixed submission (verdict: Accepted):
n=int(input())
a=input()
b=input()
c=0
for i in range(1,n):
  if a[-1*i:]==b[:i]:
    c=i
if a==b:
  c=n
print(2*n-c)

Problem: p03951
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
s = input()
t = input()
answer = n
for i in range (n + 1) :
  if answer == n :
    newstring = s[0:i] + t[:n]
    if newstring[0:n] == s:
    	answer += i
print (answer)

Failing test case input:
4
expr
expr

Expected output:
4

Actual output:
8


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
t = input()
answer = n
for i in range (n + 1) :
  newstring = s[0:i] + t[:n]
  if newstring[0:n] == s:
    answer += i
    break
print (answer)
Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
t = input()

sf = s[0:n]
tf = t[-n:]

ans = []

for i in range(len(sf)):
    if (sf[i] in tf):
        for j in range(0, len(sf) - i):
            if (sf[i + j] != tf[j]):
                break
        else:
            ans.append(tf)
            
            break

    else:
        ans.append(sf[i])

else:
    ans.append(tf)
    
print(len(ans))


Failing test case input:
4
exqr
rxdo

Expected output:
7


Actual output:
3


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


ans = []

for i in range(n):
    if (s[i] == t[0]):
        for j in range(0, n - i):
            if (s[i + j] != t[j]):
                break
        else:
            ans+=t
            
            break

    
    ans.append(s[i])

else:
    ans+=t
    

print(len(ans))

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=input()
b=input()
c=0
for i in range(1,n):
  if a[-1*i:]==b[:i]:
    c=i
print(2*n-c)

Failing test case input:
4
expr
expr

Expected output:
4

Actual output:
8


Fixed submission (verdict: Accepted):
n=int(input())
a=input()
b=input()
c=0
for i in range(1,n):
  if a[-1*i:]==b[:i]:
    c=i
if a==b:
  c=n
print(2*n-c)

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S = input()
T = input()
ans = -1
for i in range(N):
    
    if S[i:] == T[:N-i]:
        ans = N + i
        break
if ans == -1:
    ans = 2
print(ans)


Failing test case input:
4
ersx
oerx

Expected output:
8


Actual output:
2


Fixed submission (verdict: Accepted):
N = int(input())
S = input()
T = input()
ans = -1
for i in range(N):
    
    if S[i:] == T[:N-i]:
        ans = N + i
        break
if ans == -1:
    ans = N * 2
print(ans)

Problem: p03951
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
s = input()
t = input()
res = 2*N
for i in range(N):
    if s[i:N] == t[0:N-i]:
        res = N+1
        break
print(res)

Failing test case input:
3
bbb
bee

Expected output:
5


Actual output:
4


Fixed submission (verdict: Accepted):
N = int(input())
s = input()
t = input()
res = 2*N
for i in range(N):
    if s[i:N] == t[0:N-i]:
        res = N+i
        break
print(res)

Problem: p03951
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
s = input()
t = input()

st = s+t
total_len = len(st)
dupl = 0
for n in range(N+1):
    if st[N-n:N] == st[N:N+n]:
        dupl = len(s[n-n:N])

total_len = total_len - dupl

print(total_len)

Failing test case input:
3
bcb
bec

Expected output:
5


Actual output:
3


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

st = s+t
total_len = len(st)
dupl = 0
for n in range(N+1):
    if st[N-n:N] == st[N:N+n]:
        dupl = len(s[N-n:N])

total_len = total_len - dupl

print(total_len)
Problem: p03951
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
s = input()
t = input()

if (n == len(s) and (s == t)):
    print(s)
else:
    ind = [0]
    for i in range(1, len(s)):
        if s[-i] == t[:i]:
            ind.append(i)

    ind.reverse()
    for i in ind:
        if i == 0:
            print(s+t)
        else:
            res = s[0:-i] + t
            if len(res) >= n:
                print(res)
                break

Failing test case input:
3
abb
ceb

Expected output:
6


Actual output:
abbceb


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

if (n == len(s) and (s == t)):
    print(n)
else:
    ind = [0]
    for i in range(1, len(s)):
        if s[-i:] == t[:i]:
            ind.append(i)

    ind.reverse()
    for i in ind:
        if i == 0:
            print(2*n)
        else:
            res = s[0:-i] + t
            if len(res) >= n:
                print(len(res))
                break

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

for i in range(N):
    if s[N-i-1:] == t[:i+1]:
       print(2*N-i-1)
       break


Failing test case input:
3
bbb
efc

Expected output:
6


Actual output:

Fixed submission (verdict: Accepted):
N = int(input())
s = input()
t = input()
ans = 2*N
for i in range(N):
    if s[N-i-1:] == t[:i+1]:
       ans = min(ans, 2*N-i-1)

print(ans)

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
s=list(input())
t=list(input())
cnt=0
if s==t:
    print(n)
else:
    for i in range(n):
        if s[n-1-i]==t[i]:
            cnt+=1
    if cnt!=0:
        print(2*n-2*(cnt-1)-1)
    else:
        print(n*2)
        
            
            
        


Failing test case input:
4
rrxe
oexr

Expected output:
8


Actual output:
7


Fixed submission (verdict: Accepted):
n=int(input())
s=list(input())
t=list(input())
if s==t:
    print(n)
else:
    cnt=0
    for i in range(n):
        for j in range(n-i):
            if s[i+j]!=t[j]:
                break
            if j==n-i-1:
                cnt=n-i
    print(2*n-cnt)

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = list(str(input()))
t = list(str(input()))
p = 0
ans = n * 2

for i in range(n):
    if s[i] == t[0]:
        for x in range(n-i):
            if s[i + x] == t[x]:
                p += 1
        else:
            ans -= p
            break

print(ans)


Failing test case input:
4
expr
epxq

Expected output:
8


Actual output:
7


Fixed submission (verdict: Accepted):
n = int(input())
s = list(str(input()))
t = list(str(input()))
p = 0
ans = n * 2

for i in range(n):
    if s[i] == t[0]:
        for x in range(n-i):
            if s[i + x] == t[x]:
                p += 1
            else:
                p = 0
                break
        else:
            ans -= p
            break

print(ans)
Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
s = input()
t = input()
sr = s[::-1]
if s== t:
    print(s)
else:
    for i in range(N):
        if sr[i] != t[i]:
            break
    print(2*N-i)


Failing test case input:
4
expr
expr

Expected output:
4

Actual output:
expr


Fixed submission (verdict: Accepted):
N = int(input())
s = input()
t = input()
sr = s[::-1]
for i in range(N+1):
    if s[i:] == t[:N-i]:
        break
print(N+i)

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
s=input()
t=input()
for i in range(len(s),-1,-1):
  if s[-i:]==t[:i]:
    break
print(s+t[i:])

Failing test case input:
1
[
~

Expected output:
2


Actual output:
[~


Fixed submission (verdict: Accepted):
N=int(input())
s=input()
t=input()
for i in range(len(s),-1,-1):
  if s[-i:]==t[:i]:
    break
print(len(s+t[i:]))

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
s=str(input())
t=str(input())
c=0
tmp=0
S=list(s)
T=list(t)
for i in range(N):
    if s[N-i-1:N-1]==t[0:i]:
        c=i+1
print(2*N-c)
        


Failing test case input:
3
da`
cfe

Expected output:
6


Actual output:
5


Fixed submission (verdict: Accepted):
N=int(input())
s=str(input())
t=str(input())
c=0
tmp=0
S=list(s)
T=list(t)
for i in range(N):
    if s[N-i-1:N]==t[0:i+1]:
        c=i+1
    

print(2*N-c)

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

def resolve():
    n = int(input())
    s = input()
    t = input()
    if s == t and len(s) >= n:
        print(len(s))
        return
    pos = 0
    for ss, tt in zip(s[::-1], t):
        if ss != tt:
            break
        pos += 1
    if len(s) + len(t[pos:]) >= n:
        print(len(s+t[pos:]))
        print(pos)
        return
    print(len(s+t))


if __name__ == "__main__":
    resolve()


Failing test case input:
3
abb
ceb

Expected output:
6


Actual output:
6
0


Fixed submission (verdict: Accepted):

def resolve():
    n = int(input())
    s = input()
    t = input()
    ans = len(s) + len(t)
    for i in range(len(s)):
        pos = 0
        for ss,tt in zip(s[i:],t):
            if ss != tt:
                break
            pos += 1
        else:
            if len(s) - i > len(t) or i + len(t) < n:
                continue
            tmp = i + len(t)
            if tmp < ans:
                ans = tmp
    print(ans)
        

if __name__ == "__main__":
    resolve()
Problem: p03951
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

N = int(input())
s = list(input())
t = list(input())
s_rev = list(reversed(s))

cnt = N
for i in range(1,N+1):
    
    tgt = list(reversed(s_rev[:i]))
    print(tgt,t[:i])
    if tgt == t[:i]:
        cnt -= 1
    else:
        break
    
if s == t:
    print(N)
else:
    ans = s[:cnt] + t
    print(len(ans))

Failing test case input:
1
a


Expected output:
2


Actual output:
['a'] ['\x7f']
2


Fixed submission (verdict: Accepted):

N = int(input())
s = list(input())
t = list(input())
s_rev = list(reversed(s))

cnt = 0
for i in range(1,N+1):
    
    tgt = list(reversed(s_rev[:i]))
    if tgt == t[:i]:
        cnt = len(tgt)
    
ans = s + t[cnt:]
print(len(ans))

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
t = input()
for k in range(0,n+1):
  if s[k:] == t[:n-k]:
    print(s+t[n-k:])
    break

Failing test case input:
4
gsrx
xoer

Expected output:
7


Actual output:
gsrxoer


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
t = input()
for k in range(0,n+1):
  if s[k:] == t[:n-k]:
    print(n+k)
    break

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S = input()
T = input()
ans = 2 * N
if (S == T):
    print(N)
    exit(0)
for i in range(N):
    if (T[i] == S[-(i + 1)]):
        print(T[i], S[-(i + 1)])
        ans -= 1
print(ans)

Failing test case input:
4
exqr
rxep

Expected output:
7


Actual output:
r r
7


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

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S = input()
T = input()
ans = 2 * N
if (S == T):
    print(N)
    exit(0)
for i in range(N):
    if (T[i] == S[-(i + 1)]):
        ans -= 1
print(ans)


Failing test case input:
4
expr
epxq

Expected output:
8


Actual output:
6


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

Problem: p03951
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def main():
    n = int(input())
    s = list(input())
    t = list(input())
    if s == t:
        print(n)
        exit()
    k = 0
    for i in range(n):
        if s[-i - 1] == t[i]:
            k += 1
        else:
            break
    print(min(n,n*2 - k))


if __name__ == '__main__':
    main()

Failing test case input:
3
d``
efc

Expected output:
6


Actual output:
3


Fixed submission (verdict: Accepted):
def main():
    n = int(input())
    s = list(input())
    t = list(input())
    if s == t:
        print(n)
        exit()
    ans = float("inf")
    for i in range(n):
        S = s + t[i:]
        
        if S[:n] == s and S[2 * n - n - i:] == t:
            ans = min(ans, len(S))
    print(ans)


if __name__ == '__main__':
    main()
Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
s = input()
t = input()
k = 0
for i in range(N):
  if s[i:N] == t[0:N-i]:
    k = i
if k != 0:
  print(len(s+t[N-k:N]))
else:
  print(len(s+t))

Failing test case input:
4
expr
expr

Expected output:
4

Actual output:
8


Fixed submission (verdict: Accepted):
N = int(input())
s = input()
t = input()
k = -1
for i in range(N):
  if s[i:N] == t[0:N-i]:
    k = i
    break
if k != -1:
  print(len(s+t[N-k:N]))
else:
  print(len(s+t))

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
S=input()
T=input()
s=[str(c) for c in (S)]
t=[str(c) for c in (T)]
flag=0
score=N
for i in range (N,2*N):
  for j in range(N+N-i):
    flag=0
    if s[i-N+j]!=t[j]:
      flag=1
  if flag==0:
    score=i
    flag=2
  if flag==2:
    break
if flag==1:
  score=2*N
print(score)

Failing test case input:
3
abc
cec

Expected output:
5


Actual output:
3


Fixed submission (verdict: Accepted):
N=int(input())
S=input()
T=input()
s=[str(c) for c in (S)]
t=[str(c) for c in (T)]
flag=0
score=N
for i in range (N,2*N):
  flag=0
  for j in range(N+N-i):
    if s[i-N+j]!=t[j]:
      flag=1
  if flag==0:
    score=i
    flag=2
  if flag==2:
    break
if flag==1:
  score=2*N
print(score)

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
t = input()

for i in range(n):
    if s[i:] == t[:n-i]:
        print(n*2 - (n-i))
        exit(0)

print(2**n)

Failing test case input:
4
frtx
zofr

Expected output:
8


Actual output:
16


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

for i in range(n):
    if s[i:] == t[:n-i]:
        print(n*2 - (n-i))
        exit(0)

print(2*n)

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
N = int(input())
s = str(input())
t = str(input())

word = s + t

for i in range(N):
    if word[len(s) - 1] == word[len(s)] and len(s) + len(t) >= N:
        s = s[:N - 1]
        word = s + t

print(len(word))
    


Failing test case input:
4
expr
expr

Expected output:
4

Actual output:
8


Fixed submission (verdict: Accepted):
import sys
N = int(input())
s = str(input())
t = str(input())

answer = 2 * N
for i in range(N, 2 * N + 1):
    if s[len(s) - (2 * N - i):] == t[:2 * N - i]:
        answer = i
        break
    
print(answer)

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
s=list(input())
t=list(input())
f=s+t
if s==t:
    print(s)
    exit()
for i in range(0,N):
    if s[-i:]==t[:i]:
        f=s+t[i:]
print(f)

Failing test case input:
4
frtx
reoy

Expected output:
8


Actual output:
f, r, t, x, r, e, o, y

Fixed submission (verdict: Accepted):
N=int(input())
s=list(input())
t=list(input())
f=s+t
if s==t:
    print(len(s))
    exit()
for i in range(0,N):
    if s[-i:]==t[:i]:
        f=s+t[i:]
print(len(f))
Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
t = input()

for i in range(n, -1, -1):
    ans = [""] * (n + n - i)
    ans[:n] = list(s)
    ans[-n:] = list(t)
    if ans[:n] == list(s):
        break

print(*ans, sep="")


Failing test case input:
4
rrxe
oerx

Expected output:
8


Actual output:
rrxeoerx


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

for i in range(n, -1, -1):
    ans = [""] * (2 * n - i)
    ans[:n] = list(s)
    ans[-n:] = list(t)
    if ans[:n] == list(s):
        break

print(2 * n - i)

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from sys import stdin
N = int(stdin.readline().rstrip())
s = (stdin.readline().rstrip())
t = (stdin.readline().rstrip())
ans = len(s) + len(t)
for i,j in zip(list(t),reversed(list(s))):
    if i == j:
        ans -= 1
if s == t:
   ans = len(s)
print(ans)

Failing test case input:
4
expr
pexq

Expected output:
8


Actual output:
7


Fixed submission (verdict: Accepted):
from sys import stdin
N = int(stdin.readline().rstrip())
s = (stdin.readline().rstrip())
t = (stdin.readline().rstrip())
ans = len(s)
for i in range(N,0,-1):
    if list(s)[N-i:] == list(t)[:i]:
        break
    else:
        ans += 1
print(ans)

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, s, t = [input().strip() for _ in range(3)]
n = int(n)
for i in range(n):
  if s[n-i-1] != t[i]:
    print(2 * n - 1)
    break
else:
  print(n)


Failing test case input:
3
cab
efc

Expected output:
6


Actual output:
5


Fixed submission (verdict: Accepted):
n, s, t = [input().strip() for _ in range(3)]
n = int(n)
for i in range(n):
  if s[i:] == t[:n-i]:
    print(n + i)
    break
else:
  print(2 * n)

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

s = input()
t = input()
ans = N
for i in range(N):
  if (s[i:] == t[:N-i]):
    ans += i
    break
  ans = 2*N
print(ans)

Failing test case input:
3
bcb
bec

Expected output:
5


Actual output:
8


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

s = input()
t = input()
ans = 2 * N
for i in range(N):
  if (s[i:] == t[:N-i]):
    ans -= len(s[i:])
    break
  
print(ans)

Problem: p03951
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
s = str(input())
t = str(input())

if s==t:
    print(s)
    exit()

for i in range(1,N+1):
    ans = s + t[-i:]
    if ans[-N:] == t:
        break
print(ans)

Failing test case input:
4
rqxe
rxdo

Expected output:
8


Actual output:
rqxerxdo


Fixed submission (verdict: Accepted):
N = int(input())
s = str(input())
t = str(input())

if s==t:
    print(len(s))
    exit()

for i in range(1,N+1):
    ans = s + t[-i:]
    if ans[-N:] == t:
        break
print(len(ans))
Problem: p03951
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
N = int(input())
s = input()
t = input()
for i in range(N):
    for j in range(N - i):
        flg = True
        if s[i + j] != t[j]:
            flg = False
            break
        if flg:
            print(N + i)
            sys.exit()
print(2 * N)


Failing test case input:
3
acb
ceb

Expected output:
6


Actual output:
4


Fixed submission (verdict: Accepted):
import sys
N = int(input())
s = input()
t = input()
for i in range(N):
    flg = True
    for j in range(N - i):
        if s[i + j] != t[j]:
            flg = False
            break
    if flg:
        print(N + i)
        sys.exit()
print(2 * N)

Problem: p03951
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
s = input()
t = input()

st = s+t
total_len = len(st)
dupl = 0
for n in range(N+1):
    print(st[N-n:N], st[N:N+n])
    if st[N-n:N] == st[N:N+n]:
        dupl = len(s[n-n:N])

total_len = total_len - dupl

print(total_len)

Failing test case input:
3
d``
cge

Expected output:
6


Actual output:
 
` c
`` cg
d`` cge
3


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

st = s+t
total_len = len(st)
dupl = 0
for n in range(N+1):
    if st[N-n:N] == st[N:N+n]:
        dupl = len(s[N-n:N])

total_len = total_len - dupl

print(total_len)

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


n = int(input())
s = list(input())
t = list(input())

for i in range(n):
    match = True
    for j in range(n):
        if i + j < n:
            if s[i + j] != t[j]:
                match = False
    if match:
        if i == 0:
            print(n)
        else:
            print(len(s[:-(i - 1)] + t))
        break
else:
    print(len(s + t))


Failing test case input:
4
expr
rxep

Expected output:
7


Actual output:
6


Fixed submission (verdict: Accepted):


n = int(input())
s = list(input())
t = list(input())

for i in range(n):
    match = True
    for j in range(n):
        if i + j < n:
            if s[i + j] != t[j]:
                match = False
    if match:
        if i == 0:
            print(n)
        else:
            print(n + i)
        break
else:
    print(n * 2)

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

if S==T:
    print(N)
    exit()

T = T[::-1]
cnt = 0

for s,t in zip(S,T):
    if s==t:
        cnt += 1

print(len(S)+len(T)-cnt)

Failing test case input:
4
rrxe
oexr

Expected output:
8


Actual output:
7


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

if S==T:
    print(N)
    exit()

for i in range(1,N):
    if (S+T[-i:]).endswith(T):
        print(N+i)
        exit()
print(2*N)
Problem: p03951
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
s=str(input())
t=str(input())

cnt=0

if s==t:
  print(n)
else:
  for i in range(n):
    if s[-i-1]==t[i]:
      cnt+=1
    else:
      break
      
print(n*2-cnt)

Failing test case input:
4
expr
expr

Expected output:
4

Actual output:
4
8


Fixed submission (verdict: Accepted):
n=int(input())
s=str(input())
t=str(input())
    
cnt=0

if s==t:
  print(n) 
else:
  for i in range(n):
    if s[-i-1:]==t[0:i+1]:
      cnt=i+1
      
  print(n*2-cnt)

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
s,t=input(),input()
ans=2*n
for i in range(n):
    if s[-(i+1):]==t[:i+1]:
        ans=2*n-(i+1)
    else:
        break
print(ans)

Failing test case input:
4
expr
expr

Expected output:
4

Actual output:
8


Fixed submission (verdict: Accepted):
n=int(input())
s,t=input(),input()
ans=2*n
for i in range(n):
    if s[-(i+1):]==t[:i+1]:
        ans=2*n-(i+1)
print(ans)

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
s = input()
t = input()
ans = s + t

for i in range(N):
    if(s[i:] == t[:(len(t)-i)]):
        ans = s + t[-i:]

print(ans if s != t else s)

Failing test case input:
4
rrxe
oerx

Expected output:
8


Actual output:
rrxeoerx


Fixed submission (verdict: Accepted):
N = int(input())
s = input()
t = input()
ans = s + t

for i in range(N):
    if(s[i:] == t[:(len(t)-i)]):
        ans = s + t[-i:]

print(len(ans) if s != t else N)

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
t = input()
ans = ""
for i in range(n):
    if s[i] == t[0]:
        ans += s[:i]
        ans += t
        break
if ans == "": ans = s + t
print(ans)

Failing test case input:
4
expr
qxep

Expected output:
8


Actual output:
exprqxep


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
t = input()
ans = n * 2
for i in range(n):
    if s[i:] == t[:n-i]:
        ans -= n - i
        break
print(ans)

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
s = input()
t = input()
for i in range(N+1):
    if s[i:]==t[:N-i]:
        break
print(s+t[N-i:])

Failing test case input:
1
`


Expected output:
2


Actual output:
`


Fixed submission (verdict: Accepted):
N = int(input())
s = input()
t = input()
for i in range(N+1):
    if s[i:]==t[:N-i]:
        break
print(len(s+t[N-i:]))

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

best = float('inf')
for i in range(len(T)):
    s = S + T[i:]
    if s[::-1][:N][::-1] == T:
        best = min(best, len(s))

print(best)

Failing test case input:
4
expr
expr

Expected output:
4

Actual output:
8


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

best = float('inf')
for i in range(len(T)+1):
    s = S + T[i:]
    if s[::-1][:N][::-1] == T:
        best = min(best, len(s))

print(best)
Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
s = input()
t = input()

Answer = s + t
if s != t:
  for i in range(N):
    if s[-i-1:] == t[:i+1]:
      Answer = s[:-i-1]+t[i:]
else:
  Answer = s
print(Answer)

Failing test case input:
3
bbb
eec

Expected output:
6


Actual output:
bbbeec


Fixed submission (verdict: Accepted):
N = int(input())
s = input()
t = input()
Answer = s + t
for i in range(N):
  if s[-i-1:] == t[:i+1]:
    Answer = s + t[i+1:]
print(len(Answer))

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
t = input()

l = 0
for i in range(n):
  for j in range(n):
    if s[i] == t[j]:
      l += 1
      
print(2 * n - l)

Failing test case input:
4
gtrx
yofr

Expected output:
8


Actual output:
7


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
t = input()
sr = s[::-1]
for i in range(n+1):
    if s[i:] == t[:n-i]:
        print(n + i)
        break

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

for i in range(N):
    if s==t:
        print(N)
        break
    elif s[i:] == t[:-i]:
        print(N+i)
        break
    else:
        print(N*2)
        break

Failing test case input:
4
frtx
xoer

Expected output:
7


Actual output:
8


Fixed submission (verdict: Accepted):

N = int(input())
s = input()
t = input()

ans=0
for i in range(N):
    if s==t:
        ans=N
        break
    elif s[i:] == t[:-i]:
        ans=N+i
        break
if ans!=0:
    print(ans)
else:
    print(N*2)

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
t = input()

sf = s[0:n]
tf = t[-n:]



ans = []

for i in range(n):
    if (sf[i] == tf[0]):
        for j in range(0, n - i):
            if (sf[i + j] != tf[j]):
                break
        else:
            ans+=tf
            
            break

    else:
        ans.append(sf[i])

else:
    ans+=tf
    

print(len(ans))


Failing test case input:
4
frtx
reox

Expected output:
8


Actual output:
7


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


ans = []

for i in range(n):
    if (s[i] == t[0]):
        for j in range(0, n - i):
            if (s[i + j] != t[j]):
                break
        else:
            ans+=t
            
            break

    
    ans.append(s[i])

else:
    ans+=t
    

print(len(ans))

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    N = int(input())
    s = input()
    t = input()

    for i in range(N):
        if s[i:] == t[:N-i]:
            return len(s[:i] + t)

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


Failing test case input:
4
frtx
reoy

Expected output:
8


Actual output:
None


Fixed submission (verdict: Accepted):
def main():
    N = int(input())
    s = input()
    t = input()

    for i in range(N):
        if s[i:] == t[:N-i]:
            return len(s[:i] + t)
    return 2*N

if __name__ == '__main__':
    print(main())
Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
s=list(input())
t=list(input())
f=s+t
if s==t:
    print(''.join(s))
    exit()
for i in range(0,N):
    if s[-i:]==t[:i]:
        f=s+t[i:]
print(''.join(f))

Failing test case input:
1
[


Expected output:
2


Actual output:
[


Fixed submission (verdict: Accepted):
N=int(input())
s=list(input())
t=list(input())
f=s+t
if s==t:
    print(len(s))
    exit()
for i in range(0,N):
    if s[-i:]==t[:i]:
        f=s+t[i:]
print(len(f))

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
S=input()
T=input()
s=[str(c) for c in (S)]
t=[str(c) for c in (T)]
flag=0
score=N
for i in range (N,2*N+1):
  for j in range(N+N-i):
    flag=0
    if s[i-N+j]!=t[j]:
      flag=1
  if flag==0:
    score=i
    flag=2
  if flag==2:
    break
if flag==1:
  score=2*N
print(score)

Failing test case input:
3
abc
cce

Expected output:
5


Actual output:
4


Fixed submission (verdict: Accepted):
N=int(input())
S=input()
T=input()
s=[str(c) for c in (S)]
t=[str(c) for c in (T)]
flag=0
score=N
for i in range (N,2*N):
  flag=0
  for j in range(N+N-i):
    if s[i-N+j]!=t[j]:
      flag=1
  if flag==0:
    score=i
    flag=2
  if flag==2:
    break
if flag==1:
  score=2*N
print(score)

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = list(input())
t = list(input())
for i in range(n)[::-1]:
    if s[(n - i):n] == t[0:i]:
        break
if i == n-1:
    print(n)
else:
    print(2*n - i)



Failing test case input:
4
expr
expr

Expected output:
4

Actual output:
8


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

if s == t:
    print(n)
    sys.exit()
can = False
for i in range(n):
    if s[i:n] == t[0:(n-i)]:
        can = True
        break
if can:
    print(n + i )
else:
    print(2*n)

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
s=input()
t=input()
for i in range(N):
    if s[i:]==t[:(N-i)]:
        print(N+i)
        exit()
print(N+1)

Failing test case input:
3
aac
dfe

Expected output:
6


Actual output:
4


Fixed submission (verdict: Accepted):
N=int(input())
s=input()
t=input()
for i in range(N):
    if s[i:]==t[:(N-i)]:
        print(N+i)
        exit()
print(N*2)

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
s=input()
t=input()
count=0
for i in range(N):
    if s[i]==t[N-i-1]:
        count+=1
    else:
        count+=2
print(N if s==t else count)

Failing test case input:
4
rsgx
xoer

Expected output:
7


Actual output:
6


Fixed submission (verdict: Accepted):
N=int(input())
s=input()
t=input()
overlap=N
for i in range(N):
    if s[i:]==t[:N-i]:
        overlap=i
        break
print(N+overlap)
Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
s = input()
t = input()
i=0
for i in range(N+1):
    if(i==0):
        if(s==t):
            i=N+1
            break
    else:
        x = s+t[-i:]
        if(x[:N]==s and x[-N:]==t):
            break
    
    

print(N*2-i+1)


Failing test case input:
3
bbb
efc

Expected output:
6


Actual output:
4


Fixed submission (verdict: Accepted):
N = int(input())
s = input()
t = input()
cnt=0
for i in range(N+1):
    if(i==0):
        if(s==t):
            cnt=N
            break
    else:
        x = s+t[-i:]
        if(x[:N]==s and x[-N:]==t):
            cnt=len(x)
            break

print(cnt)

Problem: p03951
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
s = input()
t = input()
idx = 0
for i in range(N):
    tmp_s = s[N - i - 1:]
    tmp_t = t[:i + 1]
    if tmp_s == tmp_t:
        idx = i + 1

print(s + t[idx:])

Failing test case input:
3
cba
cec

Expected output:
6


Actual output:
cbacec


Fixed submission (verdict: Accepted):
N = int(input())
s = input()
t = input()
idx = 0
for i in range(N):
    tmp_s = s[N - i - 1:]
    tmp_t = t[:i + 1]
    if tmp_s == tmp_t:
        idx = i + 1

print(len(s + t[idx:]))

Problem: p03951
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
s = input()
t = input()
for i in range(n):
    if t[i] == s[-1]:
        continue
    else:
        s = s+t[i]
print(s)

Failing test case input:
1
`
{

Expected output:
2


Actual output:
`{


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
t = input()
for i in range(n):
    if s[i:n] == t[0:n-i]:
        print(2*n - (n-i))
        exit()
print(2*n)

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
t = input()

for i in range(n):
	if t[i] == s[(-1) * i - 1]:
		continue
	else:
		break

if i == 0:
	print(s + t)
else:
	print(s[:(-1) * i] + t)

Failing test case input:
3
bcb
bec

Expected output:
5


Actual output:
bcbec


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

flag = 0

for i in reversed(range(n)):
	j = (-1) * i - 1
	if t[:(i+1)] == s[j:]:
		flag = 1
		break
	else:
		continue

if i == 0 and flag == 0:
	print(len(s + t))
else:
	print(len(s[:j] + t))

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
t = input()
ans = ""
for i in range(n):
    if s[i] == t[0]:
        ans += s[:i]
        ans += t
        break
if ans == "": ans = s + t
print(len(ans))

Failing test case input:
3
bbb
bed

Expected output:
5


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
t = input()
ans = n * 2
for i in range(n):
    if s[i:] == t[:n-i]:
        ans -= n - i
        break
print(ans)
Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
t = input()

ans = n * 2
chk = False

for i in range(n):
    j = 0
    while i+j < n:
        if s[i+j] == t[j]:
            ans -= 1
            j += 1
            chk = True
        else:
            ans = n * 2
            break
    if chk:
        break

print(ans)

Failing test case input:
3
abb
bec

Expected output:
5


Actual output:
6


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

ans = n * 2
chk = False

for i in range(n):
    j = 0
    while i+j < n:
        if s[i+j] == t[j]:
            ans -= 1
            j += 1
            chk = True
        else:
            ans = n * 2
            chk = False
            break
    if chk:
        break

print(ans)

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    N = int(input())
    s = input()
    t = input()

    for i in range(N):
        if s[i:] == t[:N-i]:
            print(s[:i]+t)
            return
    print(s+t)

main()

Failing test case input:
3
bac
dfe

Expected output:
6


Actual output:
bacdfe


Fixed submission (verdict: Accepted):
def main():
    N = int(input())
    s = input()
    t = input()

    for i in range(N):
        if s[i:] == t[:N-i]:
            print(2*N-(N-i))
            return
    print(N*2)

main()

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
s=input()
t=input()
ans=2*N

for i in range(N):
  if s[-1-i]==t[i]:
    ans+=-1
  else:
    break

print(ans)

Failing test case input:
4
expr
expr

Expected output:
4

Actual output:
8


Fixed submission (verdict: Accepted):
N=int(input())
s=input()
t=input()
ans=2*N

for i in range(N):
  if s[i:N]==t[0:N-i]:
    ans=N+i
    break
  else:
    pass

print(ans)

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
s=input()
l=input()
x=0
for i in range(1,n):
    if s[-i:]==l[:i]:x=i
print(2*n-x)

Failing test case input:
4
expr
expr

Expected output:
4

Actual output:
8


Fixed submission (verdict: Accepted):
n=int(input())
s=input()
l=input()
x=0
for i in range(1,n+1):
    if s[-i:]==l[:i]:x=i
print(2*n-x)

Problem: p03951
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
s = input()
t = input()
cou = 0
for i in range(n):
  s1 = s[i:]
  t1 = t[:n-i]

  if s1==t1:
    print(2*n-(n-i))
else:
  print(2*n)


Failing test case input:
4
exqr
rxeo

Expected output:
7


Actual output:
7
8


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
t = input()
cou = 0
for i in range(n):
  s1 = s[i:]
  t1 = t[:n-i]

  if s1==t1:
    print(2*n-(n-i))
    exit()
else:
  print(2*n)
Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
s = input()
t = input()
cnt = 0
if s == t:
    print(len(s))
else:
    for c1, c2 in zip(s[::-1], t):
        if c1 == c2: cnt += 1
    print(len(s) + len(t) - cnt)

Failing test case input:
4
rqxe
rxdo

Expected output:
8


Actual output:
7


Fixed submission (verdict: Accepted):
N = int(input())
s = input()
t = input()
cnt = 0
if s == t:
    print(N)
else:
    for i in range(1, N + 1):
        if s[N-i:] == t[:i]:
            cnt = max(cnt,i)
    print(N * 2 - cnt)

Problem: p03951
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
s = str(input())
t = str(input())

if s == t:
    print(N)
else:
    for i in range(N):
        if s[N-1-i]!=t[i]:
            print(2*N-(i+1))
            break

Failing test case input:
4
exqr
rxeo

Expected output:
7


Actual output:
6


Fixed submission (verdict: Accepted):
N = int(input())
s = str(input())
t = str(input())

if s == t:
    print(N)
else:
    for i in range(N,0,-1):
        
        if s[N-i:]==t[0:i]:
            print(2*N-i)
            break
    else:
        print(2*N)

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
n = int(input())
s = list(input())
t = list(input())

if s == t:
    print(n)
    sys.exit()

for i in range(n):
    if s[i:n] == t[0:(n-i)]:
        break
print(2*n - i)




Failing test case input:
3
ca`
cfe

Expected output:
6


Actual output:
4


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

if s == t:
    print(n)
    sys.exit()
can = False
for i in range(n):
    if s[i:n] == t[0:(n-i)]:
        can = True
        break
if can:
    print(n + i )
else:
    print(2*n)

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
s=input()
t=input()
for i in range(n):
  if s[i:-1] == t[:n-i]:
    print(n+i)
    quit(0)
    
print(2*n)

Failing test case input:
4
gtrx
xofr

Expected output:
7


Actual output:
8


Fixed submission (verdict: Accepted):
n=int(input())
s=input()
t=input()
for i in range(n):
  if s[i:] == t[:n-i]:
    print(n+i)
    quit(0)
    
print(2*n)

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
s=input()
t=input()
ans=0
for i in range(n):
  if s[i:] == t[:n-i]:
    ans = n-i
if ans == 0:
  print(s+t)
else:
  print(s[:-ans]+t)

Failing test case input:
4
expr
pexq

Expected output:
8


Actual output:
exprpexq


Fixed submission (verdict: Accepted):
n=int(input())
s=input()
t=input()
ans=0
for i in range(n):
  if s[i:] == t[:n-i]:
    ans = max(n-i,ans)
print(2*n-ans)
Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def solve(n, s, t):
    match = 0
    for i in range(n):
        if s[i] == t[0]:
            for j in range(n):
                if i+j >= n:
                    match = j
                    break
                elif s[i+j] != t[j]:
                    match = 0
                    break
            if match > 0:
                break
    print("{}".format(n*2-match))


def main():
    n = int(input())
    s = input()
    t = input()
    solve(n, s, t)


if __name__ == "__main__":
    main()


Failing test case input:
4
expr
expr

Expected output:
4

Actual output:
8


Fixed submission (verdict: Accepted):
def solve(n, s, t):
    match = 0
    for i in range(n):
        if s[i] == t[0]:
            for j in range(n+1):
                if i+j >= n:
                    match = j
                    break
                elif s[i+j] != t[j]:
                    match = 0
                    break
            if match > 0:
                break
    print("{}".format(n*2-match))


def main():
    n = int(input())
    s = input()
    t = input()
    solve(n, s, t)


if __name__ == "__main__":
    main()

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
n=input()
s=input()
t=input()
count=0
sub_count=0
max=len(s+t)
for j in range(len(t)):
    for i in range(len(s)):
        if s[i]==t[j]:
            while i<len(s) and j<len(t) and s[i]==t[j]:
                i+=1
                j+=1
                max-=1
            print(max)
            sys.exit()
print(max)

Failing test case input:
4
exrr
oerx

Expected output:
8


Actual output:
7


Fixed submission (verdict: Accepted):
import sys
n=input()
s=input()
t=input()
count=0
flag=True
for i in range(len(s)):
    flag=True
    j=0
    for ii in range(i,len(s)):
        if t[j]!=s[ii]:
            flag=False
            break
        j+=1
        count+=1
    if flag:
        print(len(s)+i)
        sys.exit()
print(len(s+t))

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
s = input()
t = input()
ans = 2 * N
for i in range(N+1):
  st = s+t[i:]
  print(st)
  if st[:N] == s and st[-N:] == t:
    ans = min(ans, len(st))
print(ans)


Failing test case input:
4
frtx
yofr

Expected output:
8


Actual output:
frtxyofr
frtxofr
frtxfr
frtxr
frtx
8


Fixed submission (verdict: Accepted):
N = int(input())
s = input()
t = input()
ans = 2 * N
for i in range(N+1):
  st = s+t[i:]
  if st[:N] == s and st[-N:] == t:
    ans = min(ans, len(st))
print(ans)

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
t = input()

res = s+t
for num in range(n):
    tmp = s[:-num]+t
    if len(tmp) < n:
        break
    if tmp[:n] == s and tmp[-n:] == t:
        res = tmp
print(res)


Failing test case input:
4
expr
rxep

Expected output:
7


Actual output:
exprxep


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

res = s+t
for num in reversed(range(n)):
    tmp = s[:num]+t
    if tmp[:n] == s and tmp[-n:] == t:
        res = tmp
print(len(res))
Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input().strip()
t = input().strip()
for i in range(n):
  if s[i:] == t[:n-i]:
    print(s + t[i:])
print(s+t)

Failing test case input:
3
cac
dfe

Expected output:
6


Actual output:
cacdfe


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
t = input()
for i in range(n):
    if s[i:] == t[:n-i]:
        print(n + i)
        break
else:
    print(2 * n)

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,S,T=(input() for i in range(3))
N=int(N)
for k in range(N,-1,-1):
    if all([S[N-k+i]==T[i] for i in range(k)]) or k==0:
        print(S+T[k:])
        break

Failing test case input:
4
gtrx
yofr

Expected output:
8


Actual output:
gtrxyofr


Fixed submission (verdict: Accepted):
N,S,T=(input() for i in range(3))
N=int(N)
for k in range(N,-1,-1):
    if all([S[N-k+i]==T[i] for i in range(k)]) or k==0:
        print(N*2-k)
        break

Problem: p03951
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n = int(input())
s = input()
t = input()

tmp = -1
for i in range(n):
    print(s[-i - 1:], t[:i + 1])
    if s[-i - 1:] == t[:i + 1]:
        tmp = i


print(n + n - (tmp + 1))


Failing test case input:
3
abc
cce

Expected output:
5


Actual output:
c c
bc cc
abc cce
5


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

tmp = -1
for i in range(n):
    if s[-i - 1:] == t[:i + 1]:
        tmp = i


print(n + n - (tmp + 1))

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
s = input()
t = input()
st = 0
for i in range(N):
    if t[i] == s[-(i+1)]:
        st += 1
    else:
        break
print(2*N - st)

Failing test case input:
4
expr
expr

Expected output:
4

Actual output:
8


Fixed submission (verdict: Accepted):
N = int(input())
s = input()
t = input()
st = N
if s == t:
    st = 0
else:   
    for i in range(1, N):
        if s[i:] == t[:-i]:
            st = i
            break
print(N+st)

Problem: p03951
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
t = input()
max_ans = 0
if n==1:
    if s != t:
        print(2)
    else:
        print(1)
else:
    for i in range(n):
        if s[i:n-1] == t[0:n-1-i]:
            max_ans = max(n-i,max_ans)
    print(max_ans+(n-max_ans)*2)


Failing test case input:
3
bca
cec

Expected output:
6


Actual output:
4


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
t = input()
max_ans = 0
if n==1:
    if s != t:
        print(2)
    else:
        print(1)
else:
    for i in range(n):
        if s[i:n] == t[0:n-i]:
            max_ans = max(n-i,max_ans)
    print(max_ans+(n-max_ans)*2)