Problem:


Score : 200 points

Problem Statement

Snuke is interested in strings that satisfy the following conditions:

The length of the string is at least N.

The first N characters equal to the string s.

The last N characters equal to the string t.

Find the length of the shortest string that satisfies the conditions.

Constraints

1≤N≤100

The lengths of s and t are both N.

s and t consist of lowercase English letters.

Input

The input is given from Standard Input in the following format:

N
s
t

Output

Print the length of the shortest string that satisfies the conditions.

Sample Input 1

3
abc
cde

Sample Output 1

5

The shortest string is abcde.

Sample Input 2

1
a
z

Sample Output 2

2

The shortest string is az.

Sample Input 3

4
expr
expr

Sample Output 3

4

The shortest string is expr.



Sample input:
3
abc
cde


Sample output:
5

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=input()
b=input()
c=0
for i in range(1,n):
  if a[-i:]==b[i:]:
    c+=1
  else:
    break
print(2*n-c)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=input()
b=input()
c=0
for i in range(n):
  if a[len(a)-1-i]==b[i]:
    c+=1
  else:
    break
print(2*n-c)

Submission status: Wrong Answer

Solution code:
a=input()
b=input()
c=0
for i in range(min(len(a),len(b))):
  if a[len(a)-1-i]==b[i]:
    c+=1
  else:
    break
print(len(a+b[c:]))

Submission status: Wrong Answer

Solution code:
a=input()
b=input()
c=0
for i in range(min(len(a),len(b))):
  if a[len(a)-1-i]==b[i]:
    c+=1
  else:
    break
print(a+b[c:])

Submission status: Wrong Answer

Solution code:
N = int(input())
s = input()
t = input()
dup = 0
for i in range(N):
  if s[(-1)*i-1] == t[i]:
    dup += 1
  else:
    break
print(2*N-dup)

Submission status: Wrong Answer

Solution code:
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:])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,s,t=eval('input(),'*3);print(2*int(n)-max(i*(s[-i:]==t[:i])for i in range(101)))

Submission status: Wrong Answer

Solution code:
n,s,t=eval('input(),'*3);print(2*int(n)-max(i*(s[-i:]==t[:i])for i in range(99)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()[::-1]
t=input()
l=0
for i,j in zip(s,t):
    if i==j:
        l+=1
    else:
        break
print(len(s+t[l:]))

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()[::-1]
t=input()
l=0
for i,j in zip(s,t):
    if i==j:
        l+=1
    else:
        break
print(s[::-1]+t[l:])

Submission status: Wrong Answer

Solution code:
"""A - Prefix and Suffix"""
N=int(input())
s=input()
t=input()
dup=0
for i in range(min(len(s),len(t))):
    if s==t:
        dup=N
    elif s[-1*(i+1)]==t[i]:
        dup+=1
print(len(s)+len(t)-dup)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input() + input()
s = set(s)
print(len(s))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution 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
if k != -1:
  print(len(s+t[N-k:N]))
else:
  print(len(s+t))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution 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(s+t[N-k:N])
else:
  print(s+t)

Submission status: Wrong Answer

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

if(S == T):
  print(N)
else:
  match = 0
  for s, t in zip(S[::-1], T):
    if(s == t):
      match += 1
    else:
      break
  print(N*2-match)

Submission status: Wrong Answer

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

if(S == T):
  print(N)
elif(S[-1] == T[0]):
  print(N*2-1)
else:
  print(N*2)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = input()
t = input()
if s == t:
    print(N)
else:
    u = 0
    flag = True
    for i in range(N):
        if flag and s[N-1-i] == t[i]:
            u += 1
        else:
            flag = False
    print(2*N-u)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = input()
t = input()
if s == t:
    print(N)
else:
    u = 0
    flag = True
    for i in range(N):
        if flag and s[N-1-i] == t[i]:
            u += 1
    print(2*N-u)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

t_ = ""
for i in range(N+1):
    if s[i:] == t[:N-i]:
        char = s + t[N-i:]
    else:
        char = s + t
print(len(char))

Submission status: Wrong Answer

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

t_ = ""
for i in range(N):
    if s[i:] == t[:N-i]:
        char = s + t[N-i:]
    else:
        char = s + t
print(len(char))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for wid in range(n,-1,-1):
    for sp in range(n-wid+1):
        if wid==0:
            string=s+t
            print(string)
            exit()
        elif s[sp:(sp+wid)] == t[-(sp+wid):-sp]:
            string=s[:sp]+s[sp:(sp+wid)]+t[-sp:]
            print(string)
            exit()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
t=input()
if s=='abc' and t=='cde':
  exit()
a=0
for i in range(1,n+1):
  if s[n-i:]==t[:i]:
    a=i
print(2*n-a)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = input()[::-1]
t = input()
i = 0
ans = ''
while i != N:
    if s[i] == t[i]: ans += s[i]
    else: ans = s[i] + ans + t[i]
    i += 1
if s[::-1] == t: ans = t
print(len(ans))

Submission status: Wrong Answer

Solution code:
n,s,t=open(0).readlines()
n=int(n)
for i in range(1,n+1):
  x=s[:i]+t
  if x[:n]==s and x[-n:]==t:
    q=x
print(len(x))

Submission status: Wrong Answer

Solution code:
_,s,t=open(0).readlines();print(len(s+t)-sum(r[0]==r[1]for r in zip(s,t))-1)

Submission status: Wrong Answer

Solution code:
n=int(input())
A=input()
B=input()
s=0

ans=2*n
for i in range(n):
  if A[-i-1:]!=B[:i+1]:
    s=1
    print(ans)
    exit()
  else:
    ans-=1
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = str(input())
t = str(input())
S = s[::-1]
if s == t and len(s) == n:
    print(s)
else:
    i = 0
    while len(s+t) >= n :
        
        if S[i] == t[i]:
            i += 1
        else:
            break
    s = s[0:len(s)-i]
    print(len(s+t))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = str(input())
t = str(input())
S = s[::-1]
if s == t and len(s) == n:
    print(s)
else:
    i = 0
    while len(s+t) >= n :
        
        if S[i] == t[i]:
            i += 1
        else:
            break
    s = s[0:len(s)-i]
    print(s+t)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=str(input())
t=str(input())
T=t[::-1]
for i in range(len(s)):

    if s[i] != T[i]:
        count = i + 1
        break

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

Submission status: Wrong Answer

Solution code:
n=int(input())
s = input()
t = input()
if s==t:print(n);exit()
s_r = s[::-1]

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

Submission status: Wrong Answer

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

s_r = s[::-1]

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

Submission status: Wrong Answer

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

m = min(len(S), len(T))

for i in range(m, -1, -1):
    if S[-i:] == T[:i] and N*2-i >= N:
        print(N*2-i)
        exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
t = input()
n = len(t)
ans = s
for i in range(n,-1,-1):
  if t[0:i] in s:
    print (s+t[i::])
    exit()
print(len(s+t))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
t = input()
n = len(t)
ans = s
for i in range(n,-1,-1):
  if t[0:i] in s:
    print (s+t[i::])
    exit()
print(s+t)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n=int(input())
s=list(input())
t=list(input())
s.reverse()
l=0
for k  in range(n):
    if s[k]==t[k]:
        l+=1
    else:
        break
print(l)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
s = input()
t = input()
check = 0
if s == t:
    print(N)
else:
    
    for i in range(N-1):
        if s[-1 - i] == t[0 + i]:
            check += 1
        else:
            break
    print(2*N-check)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = input()
t = input()
check = 0
if s == t:
    print(N)
else:
    
    for i in range(N):
        if s[-1 - i] == t[0 + i]:
            check += 1
        else:
            break
    print(2*N-check)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = input()
t = input()
check = 0
if s == t:
    print(N)
else:
    
    for i in range(N):
        if s[-1 + i] == t[0 + i]:
            check += 1
        else:
            break
    print(2*N-check)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = input()
t = input()
check = 0
if s == t:
    print(N)
else:
    
    for i in range(N):
        if s[-1 + i] == t[0 + i]:
            check += 1
        else:
            break
    print(len(s+t[check:]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution 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

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
T = input()
for x in range(N, 2 * N + 1):
    if S[x - N:] == T[:2 * N - x]:
        print(S + T[2 * N - x:])
        exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
t = input()
k = len(s) + len(t)
if s == t and len(s) >= n:
    print(len(s))
else:
    while k > n and s[-1] == t[0]:
        s = s[:-1]
        t = t[1:]
        k -= 1
    print(k)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
t = input()
k = len(s) + len(t)
if s == t and len(s) >= n:
    print(len(s))
else:
    while k >= n and s[-1] == t[0]:
        s = s[:-1]
        t = t[1:]
        k -= 1
    print(k)

Submission status: Wrong Answer

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

if s.find(t) > -1:
    print(len(s))
    exit()

S = s + t
r = len(S)
for i in range(N):
    ti = S[-(N-i):]
    index = s.find(ti)
    if index > -1:
        print(len(s)+len(t)- (len(s)-index-1))
        exit()
print(r)

Submission status: Wrong Answer

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

if s.find(t) > -1:
    print(len(s))
    exit()

S = s + t
r = len(S)
for i in range(N):
    si = S[N-i-1]
    ti = S[-(N-i)]
    if si == ti:
        r -= 1
print(r)

Submission status: Wrong Answer

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

if s.find(t) > -1:
    print(s)
    exit()

S = s + t
r = len(S)
for i in range(N):
    si = S[N-i-1]
    ti = S[-(N-i)]
    if si == ti:
        r -= 1
print(r)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
t = input()
for i in range(n):
    l = n - i
    if s[i:] == t[i:i+l]:
        print(2*n-l)
        exit()
print(2*n)

Submission status: Wrong Answer

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

ans = 2*N
for i in range(N):
  if S[N-1-i] == T[i]:
    ans -= 1
  else:
    break
    
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = list(input())
t = list(input())
ans = 2*N
for i in range(1,N+1) :
    if s[-i] == t[i-1] :
        ans -= 1
    else :
        break
if s == t :
    print(N)
else :
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(input())
t = list(input())

print(len(s) + len(t) - (len(set(s) & set(t))))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
t=input()
count=0
for i in range(n):
    if s[-1*(i+1):]==t[:i+1]:count=i+1
if count==n:print(n)
elif count>0:print(n*2+1-count*2)
else:print(n*2)

Submission status: Wrong Answer

Solution 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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
s = input()
t = input()
cnt =len(s)+len(t)
for i in range(N):
    if s[-i-1:] == t[:i+1]:
        cnt-=i+1
print(cnt)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
st = Counter(input()+input())
cnt =0
for i in st.values():
    cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
s=input()
t=input()
if s==t:
    print(n)
    sys.exit()
s=s[::-1]
length=n*2
for i in range(n):
    if s[i]==t[i]:
        length-=1
    else:
        break
print(length)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
t = input()
ans = s + t[len(s+t) - len(set(s+t)):]
print(len(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
t = input()
ans = s + t[len(s+t) - len(set(s+t)):]
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
t = input()
a = s + t
if len(set(a)) <= len(a):
    print(max(len(sorted(set(a), key=a.index)), n))
else:
    print(n)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
t = input()
a = s + t
print(max(len(sorted(set(a), key=a.index)), n))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
t = input()
a = s + t
if len(set(a)) <= len(a):
    print(len(sorted(set(a), key=a.index)))
else:
    print(n)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
t = input()
a = s + t
if len(set(a)) < len(a):
    print(len(sorted(set(a), key=a.index)))
else:
    print(n)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
t = input()
a = s + t
print(len(sorted(set(a), key=a.index)))

Submission status: Wrong Answer

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

answer = ["*"]*N

for i in range(len(s)):
    answer[i] = s[i]

for j in range(len(t)):
    answer[N-j-1] = t[i]

print(len(answer))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution 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

Submission status: Wrong Answer

Solution code:
import sys
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:])
        sys.exit(0)

Submission status: Wrong Answer

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

cnt = 0
for i, j in zip(s[::-1], t):
    if i == j:
        cnt += 1

cnt2 = 0
for i, j in zip(s, t):
    if i == j:
        cnt2 += 1
print(len(s+t[max(cnt, cnt2):]) if len(s+t[max(cnt, cnt2):]) >= n else n)

Submission status: Wrong Answer

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

cnt = 0
for i, j in zip(s[::-1], t):
    if i == j:
        cnt += 1

cnt2 = 0
for i, j in zip(s, t):
    if i == j:
        cnt2 += 1
print(len(s+t[max(cnt, cnt2):]))

Submission status: Wrong Answer

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

cnt = 0
for i, j in zip(s[::-1], t):
    if i == j:
        cnt += 1

cnt2 = 0
for i, j in zip(s, t):
    if i == j:
        cnt2 += 1
print(s+t[max(cnt, cnt2):])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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 = i
        else:
            break
    print(N * 2 - cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

# AtCoder Grand Contest
# Problem A


if __name__ == '__main__':
    n = int(input())
    s = input()
    t = input()

    if s == t:
        print(len(s))
    else:
        count = 0

        for si, ti in zip(sorted(s, reverse=True), t):
            if si == ti:
                count += 1

        print(len(s) + len(t) - count)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=list(input().strip())
t=list(input().strip())
ans=0

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

print(n*2-ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s, t = input(), input()
ans = s + t
for i in range(n):
    if(s[i:] == t[:n-i]):
        ans = s + t[n-i:]
print(len(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
s, t = input(), input()
ans = s + t
for i in range(n):
    if(s[i:] == t[:n-i]):
        ans = s + t[n-i:]
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=list(input())
t=list(input())
t.reverse()
ans=float("inf")
for i in range(n):
    a=t[i:]
    a.reverse()
    if s[i:]==a:
        ans=i
if ans==float("inf"):
    print(2*n)
    exit()
del s[ans:]
print(len(s+t))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
t = input()
p = 0
for i in range(n, 0, -1):
    if s[-i:] == t[:i]:
        p = i

print(2 * n - p)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
t = input()
ans = 0
for i in range(n-1, -1, -1):
    for j in range(n):
        if s[i] == t[j]:
            ans += 1

print(2 * n - ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = input()
b = input()
count = 0
for i in range(n+1):
    if a[-i:] == a[:i]:
        count = i
print(2*n-count)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys


n=int(input())
s=input()
t=input()
test=s+t
if(s==t):
    print(s)
    sys.exit()
for i in range(1,n+1)[::-1]:
    test=s[0:-i]+t
    if(test[:n]==s and test[-n:]==t):
        print(test)
        sys.exit()
        
print(s+t)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input().rstrip()
t = input().rstrip()
total = 0
for i in range(n):
  if s[n-1-i:] == t[:i+1]:
    total = i
if total ==0:
  print(2*n)
else:
  print(2*n-(total+1))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input().rstrip()
t = input().rstrip()
total = 0
if s == t:
  print(n)
else:
  for i in range(n):
    if s[n-1-i] == t[i]:
      total += 1
    else:
      break
  print(2*n-total)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input().rstrip()
t = input().rstrip()
total = 0
if s == t:
  print(n)
else:
  for i in range(n):
    if s[n-1-i] == t[i]:
      total += 1
    else:
      break
  print(2*(n-total))

Submission status: Wrong Answer

Solution code:
n, s, t = [input().strip() for _ in range(3)]
if s == t:
  print(n)
  exit(0)
n = int(n)
for i in range(n):
  if s[n-i-1] != t[i]:
    print(2 * n - i)
    break

Submission status: Wrong Answer

Solution code:
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 - i)
    break
else:
  print(n)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, s, t = [input().strip() for _ in range(3)]
n = int(n)
if s == t:
  print(n)
  exit(0)
for i in range(n):
  if s[n-i-1] != t[i]:
    print(len(s + t[i:]))
    break

Submission status: Wrong Answer

Solution code:
n, s, t = [input().strip() for _ in range(3)]
n = int(n)
if s == t:
  print(n)
  exit(0)
for i in range(n):
  if s[n-i-1] != t[i]:
    print(s + t[i:])
    break

Submission status: Wrong Answer

Solution code:
n = 3
s = 'abc'
t = 'cdf'
for i in range(n):
    if s[i:] == t[:n-i]:
        print(n + i)
        break
else:
    print(2 * n)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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:])
print(s+t)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
class KMP:
    pattern = None
    length = -1
    failed = None
    def __init__(self, pattern):
        self.pattern = pattern
        self.length = len(pattern)
        self.failed = [-1 for i in xrange(self.length)]
        for i in xrange(1, self.length):
            prev = self.failed[i-1]
            while prev!=-1 and pattern[prev+1]!=pattern[i]:
                prev = self.failed[i-1]
            if pattern[prev+1]==pattern[i]:
                prev += 1
            self.failed[i] = prev

def minimumLen(s, t):
    kmp = KMP(t)
    offset = -1
    return
    for c in s:
        while offset!=-1 and kmp.pattern[offset+1]!=c:
            offset = kmp.failed[offset]
        if kmp.pattern[offset+1]==c:
            offset += 1
    return len(s)+len(t)-(offset+1)

def main():
    n = int(raw_input().strip())
    s = raw_input().strip()
    t = raw_input().strip()
    print minimumLen(s, t)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
class KMP:
    pattern = None
    length = -1
    failed = None
    def __init__(self, pattern):
        self.pattern = pattern
        self.length = len(pattern)
        self.failed = [-1 for i in xrange(self.length)]
        for i in xrange(1, self.length):
            prev = self.failed[i-1]
            while prev!=-1 and pattern[prev+1]!=pattern[i]:
                prev = self.failed[i-1]
            if pattern[prev+1]==pattern[i]:
                prev += 1
            self.failed[i] = prev

def minimumLen(s, t):
    kmp = KMP(t)
    offset = -1
    for c in s:
        while offset!=-1 and kmp.pattern[offset+1]!=c:
            offset = kmp.failed[offset]
        if kmp.pattern[offset+1]==c:
            offset += 1
    return len(s)+len(t)-(offset+1)

def main():
    n = int(raw_input().strip())
    s = raw_input().strip()
    t = raw_input().strip()
    return
    print minimumLen(s, t)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def prefix_and_suffix():
	n = int(raw_input())
	s = str(raw_input())
	t = str(raw_input())
	if s==t:
		print n
	else:
		initial_len = n*2
		for i in range(n):
			ind = -(i+1)
			if t[i]==s[ind]:
				initial_len-=1
			else:
				break
		print initial_len

if __name__ == "__main__":
	prefix_and_suffix()

Submission status: Wrong Answer

Solution code:
N = int(input())
prefix = input()
suffix = input()


if len(prefix) + len(suffix) < N:
    d = N - len(prefix) + len(suffix)
    print(prefix + 'a' * d + suffix)
else:
    s = ""
    for i in range(1, N):
        # print(prefix[-i:], suffix[:i])
        if prefix[-i:] == suffix[:i]:
            s = prefix[:-i] + suffix
    if suffix == prefix:
        s = suffix
    if len(s) == 0:
        s = prefix + suffix
    print(s)

Submission status: Wrong Answer

Solution code:
a,b,c=(input() for _ in range(3))
cnt=0
for i in range(1,int(a)+1):
    if(b[-i:]==c[:i]):cnt=i
    else:print(2*int(a)-cnt)

Submission status: Wrong Answer

Solution code:
a,b,c=(input() for _ in range(3))
cnt=0
for i in range(1,int(a)):
    if(b[-i:]==c[:i]):cnt+=1
print(2*int(a)-cnt)

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
N = int(input())
s = input()
t = input()
index = N
a = -1
for tmp in range(1,len(t)+1):
    if s[index-1:len(s)] == t[0:tmp]:
        a = index-1
    index -= 1
if a == -1:
    print(s+t)
else:
    for tmp in range(len(s)-a, len(t)):
        s = s+t[tmp]
    print(s)

Submission status: Wrong Answer

Solution 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

Submission status: Wrong Answer

Solution code:
N = int(input())
s = input()
t = input()
u = 0
for i in range(N):
    if s[i - 1:] == t[:i + 1]:
        u = i + 1
print (N * 2 - u)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = input()
t = input()
u = t
for i in range(N):
    if s[N - 1 - i:N] == t[0:i + 1]:
        u = t[i + 1:N]
print(s + u)
print (len(s + u))