qyliang/CodeNanoFix huggingface dataset:
Buggy code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    s = S()
    t = S()
    for i in range(n):
        if s[i:] == t[: n - i]:
            print(n + i)
            return
    primt(2 * n)
    return


#main
if __name__ == '__main__':
    solve()


Fixed code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

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


#main
if __name__ == '__main__':
    solve()
Buggy code:
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)

Fixed code:
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)
Buggy code:
n=int(input())
s=input()
t=input()
for i in range(n):
 if s[-i-1:]==t[:i+1]:
  cnt=i+1
print(2*n-cnt)

Fixed code:
n = int(input())
s = input()
t = input()
ans = n * 2
for i in range(n):
    if s[-i-1:] == t[:i+1]:
        ans = n * 2 - (i+1)
print(ans)
Buggy code:
N = int(input())
s = input()
t = input()
if s == t:
    print(s)
    exit()
for i in range(1, N):
    if s[i:] == t[:-i]:
        print(s + t[i:])
        exit()
print(s+t)


Fixed code:
N=int(input())
s=input()
t=input()
for i in range(1,N+1)[::-1]:
  if s[N-i:]==t[:i]:
    print(2*N-i)
    exit()
print(2*N)
Buggy code:
import sys
import os
if sys.platform=="darwin":
   base = os.path.dirname(os.path.abspath(__file__))
   name = os.path.normpath(os.path.join(base, '../Documents/input.txt'))
   #print(name)
   sys.stdin = open(name)

n = int(input())
s = input()
t = input()
ans = s + t

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

print(ans)


Fixed code:
import sys
import os
if sys.platform=="darwin":
   base = os.path.dirname(os.path.abspath(__file__))
   name = os.path.normpath(os.path.join(base, '../Documents/input.txt'))
   #print(name)
   sys.stdin = open(name)

n = int(input())
s = input()
t = input()
ans = s + t

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

print(len(ans))
Buggy code:
n=int(input())
s=input()
t=input()
ans=2*n
for i in range(n):
  if s[i:n-1]==t[:n-1-i]:
    ans-=n-i
    break
print(ans)

Fixed code:
n = int(input())
s = input()
t = input()
ans = 2 * n
for i in range(n):
    if s[i:] == t[:len(t)-i]:
        ans -= n - i
        break
print(ans)
Buggy code:
N = int(input())
s = input()
t = input()
w = s+t
cnt = 0
if s == t and N <= len(s):
  print(s)
  exit()
elif s == t and N > len(s):
  print(s+t)
  exit()
for i in range(len(s)):
  if s[-i-1] == t[i]:
    cnt += 1
while len(w) > N and cnt > 0:
  t = t[1:]
  w = s + t
  cnt -= 1
print(len(w))

Fixed code:
N = int(input())
s = input()
t = input()
w = s+t
cnt = 0
if s == t and N <= len(s):
  print(len(s))
  exit()
elif s == t and N > len(s):
  print(len(s+t))
  exit()
cnt1 = 0
for i in range(len(s)):
  if s[-i-1:] == t[:i+1]:
    cnt = i+1
while len(w) > N and cnt > 0:
  t = t[1:]
  w = s + t
  cnt -= 1
print(len(w))
Buggy code:
import sys
n=int(input())
s=input()
t=input()
if s == t:
  print len(s)
  sys.exit()
for i in range(1,n):
  tmp=s+t[-1*i:]
  if tmp[-n:] == t:
    print n+i
    sys.exit()


Fixed code:
import sys
n=int(input())
s=input()
t=input()
if s == t:
  print(n)
  sys.exit()
for i in range(1,n+1):
  tmp=s+t[-1*i:]
  if tmp[-n:] == t:
    print(n+i)
    sys.exit()
Buggy code:
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)


Fixed code:
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)
Buggy code:
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()


Fixed code:
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()
Buggy code:
n=int(input())
s=input()
t=input()
ans = n*2
for i in range(n):
  if s[-i-1] == t[i]:
    ans -= 1
  else:
    print(ans)
    break

Fixed code:
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)
Buggy code:
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))

Fixed code:
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))
Buggy code:
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)



Fixed code:
n=int(input())
s=list(input())
t=list(input())
ans=0
if s==t:
    ans=n
else:
    for i in range(n-1):
        if s[1+i:]==t[:n-1-i]:
            ans=n+(i+1)
            break
if ans==0:
    ans=n*2
print(ans)
Buggy code:
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())


Fixed code:
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())
Buggy code:
n=int(input())
s=input()
t=input()
for i in range(n):
  if(t[i]==s[-(i+1)]):
    t=t[1:]
  else:break
print(n+len(t))

Fixed code:
n = int(input())
s = input()
t = input()

ans = n
for i in range(n):
    if s[i:] == t[:n-i]:
        break
    else:
        ans += 1
print(ans)
Buggy code:
n = int(input())
s = input()
t = input()

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

Fixed code:
n = int(input())
s = input()
t = input()

p = 0
for i in range(1,n+1):
    if s[-i:] == t[:i]:
        p = i
print(len(s+t[p:]))
Buggy code:
n=int(input())
s=input()
t=input()
for i in range(n,2*n+1):
  a=s[:i]+t[i-n:]
  if a[-n:]==t:exit(print(i))

Fixed code:
n=int(input())
s=input()
t=input()
a=0
for i in range(1,n+1):
  if s[n-i:]==t[:i]:
    a=i
print(2*n-a)
Buggy code:
a = int(input())
b = input()
c = input()
e = -1
for i in range(a):
    if b[-i-1:] == c[:i+1]:
        e = max(e,i)
if e == -1:
    print(b + c)
else:
    print(len(b + c[e+1:]))


Fixed code:
a = int(input())
b = input()
c = input()
e = -1
for i in range(a):
    if b[-i-1:] == c[:i+1]:
        e = max(e,i)
if e == -1:
    print(len(b + c))
else:
    print(len(b + c[e+1:]))
Buggy code:
n=int(input())
s=input()
t=input()
for i in range(n):
  if s[i:]==t[:n-i]:
    l=n+i
    break
print(min(n*2,l))

Fixed code:
n=int(input())
s=input()
t=input()
l=2*n
for i in range(n):
  if s[i:]==t[:n-i]:
    l=n+i
    break
print(min(n*2,l))
Buggy code:
import sys
n=int(input())
s=input()
t=input()
cnt=0
for i in range(n):
    if s[i:]==t[:n-i]:
        print(s+t[n-i:])
        sys.exit()
print(s+t)

Fixed code:
import sys
n=int(input())
s=input()
t=input()
cnt=0
for i in range(n):
    if s[i:]==t[:n-i]:
        print(len(s+t[n-i:]))
        sys.exit()
print(len(s+t))
Buggy code:
N=int(input())
S=input()
T=input()
for i in range(N+1):
  s = S+T[::-1][i:][::-1]
  if s[-N:]==T: print(N+i);break

Fixed code:
N = int(input())
S = input()
T = input()
for i in range(N+1):
    if S[i:] == T[:N-i]:
        break
print(N+i)
Buggy code:
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)

Fixed code:
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))
Buggy code:
n=int(input())
s=input()
t=input()
ans=""
for i in range(n+1):
    s1=s[:n-i]
    s2=s[n-i:]
    t1=t[:i]
    t2=t[i:]
    if s2==t1:
        ans=s1+s2+t2
print(ans)


Fixed code:
n=int(input())
s=input()
t=input()
ans=""
for i in range(n+1):
    s1=s[:n-i]
    s2=s[n-i:]
    t1=t[:i]
    t2=t[i:]
    if s2==t1:
        ans=s1+s2+t2
print(len(ans))
Buggy code:
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()

Fixed code:
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))
Buggy code:
n = int(input())
s = input()
t = input()

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

Fixed code:
n = int(input())
s = input()
t = input()

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

print(len(ans))
Buggy code:
N=int(input())
S,T=input(),input()

cnt=N
for i in range(N):
  if S[i:]==T[:N-i]:
    cnt=N-i
    break
print(len(S)+len(T)-cnt)

Fixed code:
N = int(input())
S = input()
T = input()
cnt = 0
for i in range(N,0,-1):
    if S[-i:]==T[:i]:
        cnt = i
        break
print(len(S)+len(T)-cnt)
Buggy code:
N = int(input())
s = input()
t = input()

n = N
while 0 <= n:
    a = s[-(n+1):]
    b = t[0:n+1]
    if a == b:
        print(s+t[n+1:])
        exit()
    n -= 1

print(s+t)
exit()

Fixed code:
N = int(input())
s = input()
t = input()

n = N
while 0 <= n:
    a = s[-(n+1):]
    b = t[0:n+1]
    if a == b:
        print(len(s+t[n+1:]))
        exit()
    n -= 1

print(len(s+t))
exit()
Buggy code:
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)

Fixed code:
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)
Buggy code:
N = int(input())
S = input()
T = input()

for i in range(N):
	if S[i:] == T[-i - 1]:
		#print(S[:i] + T)
		print(len(S[:i] + T))
		break
else:
	#print(S + T)
	print(len(S + T))


Fixed code:
N = int(input())
S = input()
T = input()

for i in range(N):
	if S[i:] == T[:N - i]:
		#print(S[:i] + T)
		print(len(S[:i] + T))
		break
else:
	#print(S + T)
	print(len(S + T))
Buggy code:
N = int(input())
s = input()
t = input()
for i in range(0,N):
    if s[-i-1] !=t[i]:
        break
if s == t:
    print(s)
else:
    print(s + t[i:])


Fixed code:
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)
Buggy code:
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)

Fixed code:
n = int(input())
s = input()
t = input()

ans  = 2 * n
for i in range(n):
    #print(s[-i-1:], t[:i+1])
    if s[-i-1:] == t[:i+1]:
        ans = 2 * n - (i + 1 )
print(ans)
Buggy code:
def solve():
    N = int(input())
    S, T = [input() for _ in range(2)]

    for i in range(N):
        if S[i:] == T[:N - i]:
            break

    return (N + i)

print(solve())

Fixed code:
def solve():
    N = int(input())
    S, T = [input() for _ in range(2)]

    for i in range(N):
        if S[i:] == T[:N - i]:
            return (N + i)

    return 2 * N

print(solve())
Buggy code:
N = input()
N =int(N)
s = input()
t = input()

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

Fixed code:
N = input()
N =int(N)
s = input()
t = input()
y = 0
for i in range(N):
    q = s[-(i+1):]
    r = t[:i+1]
    if q == r :
        x = q
        y =i+1
print(N*2-y)
Buggy code:
# -*- coding: utf-8 -*-

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(len(n * 2))


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

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)
Buggy code:
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


Fixed code:
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)
Buggy code:
n=int(input())
s=input()
t=input()
ls=len(s)
lt=len(t)
ans=s+t
for i in range(n):
    if s[i:]==t[:ls-i]:
        ans=s+t[ls-i:]
        break
print(ans)

Fixed code:
n=int(input())
s=input()
t=input()
ls=len(s)
lt=len(t)
ans=s+t
for i in range(n):
    if s[i:]==t[:ls-i]:
        ans=s+t[ls-i:]
        break
print(len(ans))
Buggy code:
n=int(input())
a=input()
b=input()
c=0
for i in range(1,n):
  if a[-i:]==b[i:]:
    c+=1
print(2*n-c)

Fixed code:
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)
Buggy code:
n = int(input())
s = input()
t = input()

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

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


Fixed code:
n = int(input())
s = input()
t = input()

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

for i in range(1, n):
    if s[-i:] == t[:i]:
        print(n*2-i)
        exit()
else:
    print(n*2)
Buggy code:
n = int(input())
s = input()
t = input()[::-1]
cnt = 0
for i in range(n):
    if s[i] == t[i]:
        cnt += 1
print(n*2 - cnt)

Fixed code:
n = int(input())
s = input()
t = input()
cnt = 0
for i in range(n):
    if s[n-1-i:] == t[0:i+1]:
        cnt = max(cnt, i+1)
print(2*n - cnt)
Buggy code:
n = int(input())
s = input().strip()
t = input().strip()
is_match = False
for i in range(len(s)):
  if s[i:] == t[:n-i]:
    is_match = True
    break
if is_match:
  print(s[:i] + t)
else:
  print(s + t)

Fixed code:
n = int(input())
s = input().strip()
t = input().strip()
is_match = False
for i in range(len(s)):
  if s[i:] == t[:n-i]:
    is_match = True
    break
if is_match:
  print(len(s[:i] + t))
else:
  print(len(s + t))
Buggy code:
n,s,t=int(input()),input(),input();ans=2*n
for i in range(n):
  if s[i:]==t[:-i]:ans=min(ans,n+i)
print(ans)

Fixed code:
n,s,t=int(input()),input(),input();ans=2*n
for i in range(n):
  if i==0and s==t:ans=n
  elif s[i:]==t[:-i]:ans=min(ans,n+i)
print(ans)
Buggy code:
I=input;n=int(I());s,t=I(),I();print(2*n-max(i*(s[-i:]==t[i:])for i in range(n+1)))

Fixed code:
I=input;n=int(I());s,t=I(),I();print(2*n-max(i*(s[-i:]==t[:i])for i in range(n+1)))
Buggy code:
input();s=input();t=input();print(2*len(s)-max([i for i in range(n+1)if s[-i:]==t[:i]]or[0]))

Fixed code:
n=int(input());s=input();t=input();print(2*n-max([i for i in range(n+1)if s[-i:]==t[:i]]or[0]))
Buggy code:
n=int(input())
s=input()
t=input()
for i in range(n):
  if s[i:-1] == t[:-1-i]:
    print(n+i)
    quit(0)
    
print(2*n)

Fixed code:
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)
Buggy code:
n=int(input())
s=input()
t=input()
ans=""
for i in range(n):
    string=s[i:]
    if string==t[0:len(string)]:
        ans=s[0:i]+string+t[len(string):]
        break
else:
    ans=s+t
print(ans)

Fixed code:
n=int(input())
s=input()
t=input()
ans=""
for i in range(n):
    string=s[i:]
    if string==t[0:len(string)]:
        ans=s[0:i]+string+t[len(string):]
        break
else:
    ans=s+t
print(len(ans))
Buggy code:
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))

Fixed code:
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))
Buggy code:
N = int(input())
s = input()
t = input()

count = 0
for i in range(len(s)):
    if t[i] == s[-i-1]:
        count += 1
    else:
        break

if s = t:
    print(len(s))
else:
    print(len(s)+len(t)-count)

Fixed code:
N = int(input())
s = input()
t = input()

count = 0
for i in range(len(s)):
    if t[:i+1] in s[-i-1:]:
        count = i+1
    else:
        pass

print(len(s)+len(t)-count)
Buggy code:
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)

Fixed code:
n = int(input())
s = input()
t = input()

ans = 2*n
for i in range(n+1)[::-1]:
    if s[-i:] == t[:i]:
        ans -= i
        break
print(ans)
Buggy code:
N = int(raw_input())
s = raw_input()
t = raw_input()

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


Fixed code:
N=int(input())
s=input()
t=input()
if s==t:
  print(N)
  exit()
for i in range(1,N+1):
  if s[i:]==t[:-i]:
    print(N+i)
    exit()
Buggy code:
n = int(input())
s = input()
t = input()

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


Fixed code:
n = int(input())
s = input()
t = input()

for i in range(n):
    if s[i:] == t[0:n-i]:
        print(len(s + t[n-i:]))
        exit()
print(len(s + t))
Buggy code:
n = int(input())
a = input()
b = input()

for i in range(n):
  if i == 0:
    if a == b:
      print(a)
      exit()
  if a[i:] == b[:-i]:
    print(a + b[-i:])
    exit()
print(a+b)

Fixed code:
n = int(input())
a = input()
b = input()

for i in range(n):
  if i == 0:
    if a == b:
      print(n)
      exit()
  if a[i:] == b[:-i]:
    print(n+i)
    exit()
print(n*2)
Buggy code:
# coding: utf-8
N, s, t = int(input()), input(), input()

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

Fixed code:
# coding: utf-8
N, s, t = int(input()), input(), input()

if s == t:
    print(N)
else:
    cnt = 0
    for i in range(1,N):
        if s[-i:]==t[:i]:
            cnt = i
    print(2 * N - cnt)
Buggy code:
N = int(input())
s = input()
t = input()

cnt = 0
for i in range(N):
    if s[i]==t[0]:
        for j in range(N):
            if i+j>N-1:
                cnt = max(cnt, j)
                break
            if s[i+j]!=t[j]:
                break
ans = N+N-cnt
print(ans)

Fixed code:
N = int(input())
s = input()
t = input()

cnt = 0
for i in range(N):
    if s[i]==t[0]:
        for j in range(N):
            if s[i+j]!=t[j]:
                break
            if i+j>=N-1:
                cnt = max(cnt, j+1)
                break
ans = N+N-cnt
print(ans)
Buggy code:
N = int(input())
s = input()
t = input()
num = 0
for i in range(0, N):
    if t[:i] == s[N-i-1:]:
        num = i
print(2*N - num)

Fixed code:
N = int(input())
s = input()
t = input()
num = 0
for i in range(N - 1, -1, -1):
    if s[N - i - 1:] == t[:i + 1]:
        num = i + 1
        break
print(2 * N - num)
Buggy code:
n = int(input())
s = input()
t = input()
cnt = 0
for i in range(n):
    print(s[i:])
    print(t[:n-i])
    if s[i:] == t[:n-i]:
        cnt += n - i
        break
print(2 * n - cnt)

Fixed code:
n=int(input())
s=input()
t=input()
a=2*n
for i in range(n):
  if s[i:n]==t[0:n-i]:
    a=n+i
    break
print(a)
Buggy code:
n = int(input())
s = input()
t = input()
c == 1
for i in range(n):
	if s[n-i:n] == t[0:i+1]:
    	print(i+1)
        c = 0
        break
if c == 1:
	print(0)

Fixed code:
n = int(input())
s = input()
t = input()
c = 0
for i in range(n+1):
  if s[i:n] == t[0:n-i]:
    print(n+i)
    c = 1
    break
Buggy code:
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

Fixed code:
n = int(input())
s = input()
t = input()
for k in range(0,n+1):
  if s[k:] == t[:n-k]:
    print(n+k)
    break
Buggy code:
n = int(input())
s = input()
t = input()
for i in range(n):
  if s[i:] == t[:n-i]:
    print(n*2-i)
    exit()
print(n*2)

Fixed code:
n=int(input())
s=input()
t=input()
for i in range(n,-1,-1):
    if s[n-i:]==t[:i]:
        print(2*n-i)
        exit()
Buggy code:
N = int(raw_input())
s = raw_input()
t = raw_input()

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

Fixed code:
N = int(input())
s = input()
t = input()

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

print(N+i)
Buggy code:
n = int(input())
S1 = input().rstrip()
S2 = input().rstrip()
for i in range(n,-1,-1):
    if S1[n-i:] == S2[:i]:
        print(S1+S2[i:])
        break


Fixed code:
n = int(input())
S1 = input().rstrip()
S2 = input().rstrip()
for i in range(n,-1,-1):
    if S1[n-i:] == S2[:i]:
        print(len(S1+S2[i:]))
        break
Buggy code:
N = int(input())
s = input()
t = input()
ans = ''
for i in range(N):
    prefix = s[i:]
    if t.startswith(prefix):
        ans = s[:i] + t
        break
if ans == '':
    ans = s + t
print(ans)


Fixed code:
N = int(input())
s = input()
t = input()
ans = ''
for i in range(N):
    prefix = s[i:]
    if t.startswith(prefix):
        ans = s[:i] + t
        break
if ans == '':
    ans = s + t
print(len(ans))