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())
s = input()
t = input()
for i in range(N):
    if s[N - 1 - i:N] == t[0:i + 1]:
        t = t[i + 1:N]
print (len(s + t))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

idx = 0

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

if(s == t):
    print(n)
else:
    print(n*2-idx)

Submission status: Wrong Answer

Solution code:
N=input()
s=list(raw_input())
t=list(raw_input())
li=s+t
li_jufuku=list(set(li))
print len(li_jufuku)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(n):
    ns = s[:i] + t
    if ns[:n] == s:
        print(len(ns))
        break

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# sript for AGC004
# -*- coding: utf-8 -*-
# problem A

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# sript for AGC004
# -*- coding: utf-8 -*-
# problem A

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

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

Submission status: Wrong Answer

Solution code:
# sript for AGC004
# -*- coding: utf-8 -*-
# problem A

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

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

Submission status: Wrong Answer

Solution code:
# sript for AGC004
# -*- coding: utf-8 -*-
# problem A

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

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

print(str(len(s) + len(t) + 1))

Submission status: Wrong Answer

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

a=-1
b=0
c=0

if int(len(s))==1 and int(len(t))==1:
         print(len(s)+len(t))

elif s==t:
    print(N)

elif s[a]==t[b]:
    while s[a]==t[b]:
        c+=1
        a+=1
        b+=1
        print("c:"+str(c))
        if N==c:
            break

    print(len(s[0:N-c-1])+len(t))

else:
    print(len(s)+len(t))

Submission status: Wrong Answer

Solution code:
# sript for AGC004
# -*- coding: utf-8 -*-
# problem A

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

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

print(str(len(s) + len(t)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
t=input()
if s==t:
    print(n)
else:
    ans=2*n
    f=False
    for i in range(n):
        for j in range(i+1):
            if t[j]!=s[n-1-i+j]:
                f=True
        if f:
            break
        ans-=1
    print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = input()
b = input()
a = list(a)
b = list(b)
num = 0
 
an = min(len(a),len(b))
for i in range(N):
   for j in range(N):
      if a[i]==b[j]:
       num = (i + N - j)

if num == 0:
      print(N*2)
else:
      print(num)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = input()
b = input()
a = list(a)
b = list(b)
num = 0

an = min(len(a),len(b))
for i in range(N):
   for j in range(N):
      if a[i]==b[j]:
        num = (i + N - j) 
if num!=0:
      print(num)
else:
      print(N*2)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = input()
b = input()
a = list(a)
b = list(b)
num = 0

an = min(len(a),len(b))
for i in range(N):
   for j in range(N):
      if a[i]==b[j]:
       num = (i + N - j)

if num:
      print(num)
else:
      print(N*2)

Submission status: Wrong Answer

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

a=N-1
b=-N
c=0

if int(len(s))==1 and int(len(t))==1:
         print(len(s)+len(t))

elif s==t:
    print(N)

elif s[a]==t[b]:
    while s[a]==s[b]:
        c+=1
        a+=1
        b+=1
        if N==c:
            break

    print(len(s[0:N-c-1])+len(t))

else:
    print(len(s)+len(t))

Submission status: Wrong Answer

Solution code:
def Main():
    n = int(input())
    a = input()
    b = input()
    cnt = 0
    for i in range(len(a)):
        for j in range(len(b)):
            if a[i] == b[j]:
                cnt += 1
    res = a + b
    print(len(res) - cnt)

if __name__ == '__main__':
    Main()

Submission status: Wrong Answer

Solution code:
n=input()
s=raw_input()
t=raw_input()
for i in xrange(0,n):
	if s[i:n]==t[0:n-i]:
		print n+i
		break

Submission status: Wrong Answer

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

a=N-1
b=-N
c=0

if int(len(s))==1 and int(len(t))==1:
         print(len(s)+len(t))

elif s==t:
    print(N)

elif s[a]==t[b]:
    while s[a]==s[b]:
        c+=1
        a+=1
        b+=1
        if N==c:
            break

    print(s[0:N-c-1]+t)

else:
    print(s+t)

Submission status: Wrong Answer

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

a=0
b=-N
c=0

if int(len(s))==1 and int(len(t))==1:
         print(len(s)+len(t))

elif s==t:
    print(N)

elif s[0]==t[-N]:
    while s[a]==s[b]:
        c+=1
        a+=1
        b+=1
        print(c)
        if N==c:
            break

    print(s[0:N-c-1]+t)

else:
    print(s+t)

Submission status: Wrong Answer

Solution code:
def Main():
    n = int(input())
    a = input()
    b = input()
    flag = False
    flag1 = False
    # print(len(a))
    for i in range(len(a)):
        if a[i] == ' ':
            flag = True
        else:
            flag = False

    for i in range(len(a)):
        if a[i] == ' ':
            flag1 = True
        else:
            flag1 = False

    if flag1 == True and flag == True:
        print(0)
        return  0
    elif flag1 == False and  flag == True:
        print(len(b))
        return 0
    elif flag == False and  flag1 == True:
        print(len(a))
    else:

        A = []
        s = set()
        for i in range(len(a)):
            s.add(a[i])
        for i in range(len(b)):
            s.add(b[i])

        print(len(s))

if __name__ == '__main__':
    Main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
s = input()
t = input()
txt = s+t
tmp = ''

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

if s==t:
    print(s)
else :
    print(txt)

Submission status: Wrong Answer

Solution code:
def Main():
    n = int(input())
    a = input()
    b = input()
    A = []
    s = set()
    for i in range(len(a)):
        s.add(a[i])
    for i in range(len(b)):
        s.add(b[i])

    print(len(s))



if __name__ == '__main__':
    Main()

Submission status: Wrong Answer

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

if int(len(s))==1 and int(len(t))==1:
    print(len(s)+len(t))

elif s[N-1]==t[-N]:
    print(len(s)+len(t)-1)

elif s==t:
    print(s)

else:
    print(s+t)

Submission status: Wrong Answer

Solution code:
import sys
n=input()
s=input()
t=input()
count=0
sub_count=0
max=len(s+t)
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()

Submission status: Wrong Answer

Solution code:


N = int(raw_input())
s = list(raw_input())
t = list(raw_input())

length = N*2

i = 1
MAX = 0
while i <= N:
   
    cs =  t[0:i]
    ct = s[N-i:N]
    #print cs , ct
    
    
    #print cs,ct,i
    if cs is ct:
        MAX = i 
    else:
        next
    i+=1
    
print N*2-MAX

Submission status: Wrong Answer

Solution code:


N = int(raw_input())
s = list(raw_input())
t = list(raw_input())

length = N*2

i = 1
MAX = 0
while i <= N:
   
    cs =  t[0:i]
    ct = s[N-i:N]
    #print cs , ct
    
    
    print cs,ct,i
    if cs is ct:
        MAX = i 
    else:
        next
    i+=1
    
print N*2-MAX

Submission status: Wrong Answer

Solution code:
N = int(input())
s = input()
t = input()
finish = 0
count = 1
num =int(len(t))

if int(len(t)) == N and int(len(s)) == N and 1 <= N and N <= 100:

  for x in s:
    if finish == 1:
      break
    elif s == t:
      count += num -1
      finish = 1
    else:
      s = s.lstrip(x)
      count += 1
  print(count)

Submission status: Wrong Answer

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

if s == t:
    print(n)
else:
    ans = n * 2
    cnt = 0
    while True:
        try:
            if s[n-1 - cnt] != t[cnt]:
                print(ans)
                break
            ans -= 1
            cnt += 1
        except:
            print(n)
            break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
t=input()
if s==t:
    print(n)
else:
    ans=2*n
    f=True
    for i in range(n):
        for j in range(i+1):
            if t[j]!=s[n-1-i+j]:
                f=False
        if not f:
            break
        ans-=1
    print(ans)

Submission status: Wrong Answer

Solution code:
# import sys
# import collections
# from math import sqrt
# input = lambda: sys.stdin.readline()

def Main():
    s = set()
    A = []
    n = int(input())
    a = input()
    b = input()
    ok = False
    if a == b:
        print(len(a))
        return 0
    else:
        for i in range(n):
        # s.add(a[i])
        # s.add(b[i])
        # print(a[n - 1 - i] , b[i])
            if a[n - 1 - i] == b[i] and (ok == False):
                ok = False
                A.append(b[i])
            else:
                # print(1)
                ok = True
                A.append(a[n - 1 - i])
                A.append(b[i])

        print(len(A))
    # print(*A)

    # for itm in s:
    #     print(itm,end = "")
    # print()

if __name__ == '__main__':
    Main()

Submission status: Wrong Answer

Solution code:
#coding:utf8

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

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

Submission status: Wrong Answer

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

if s == t:
    print(n)
else:
    ans = n * 2
    cnt = 0
    while True:
        try:
            if s[n-1 - cnt] != t[cnt]:
                print(ans)
                break
            ans -= 1
            cnt += 1
        except:
            print(n*2 - 1)
            break

Submission status: Wrong Answer

Solution code:
N = int(input())
s = input()
t = input()
finish = 0
count = 1
num =int(len(t))
for x in s:
  if finish == 1:
    break
  elif s == t:
    count += num -1
    finish = 1
  else:
    s = s.lstrip(x)
    count += 1
print(count)

Submission status: Wrong Answer

Solution code:
import sys
n=input()
s=input()
t=input()
count=0
sub_count=0
max=len(s+t)
for i in range(len(s)):
    for j in range(len(t)):
        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)

Submission status: Wrong Answer

Solution code:
import sys
n=input()
s=input()
t=input()
count=0
sub_count=0
max=len(s+t)
for i in range(len(s)):
    for j in range(len(t)):
        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()

Submission status: Wrong Answer

Solution code:
# import sys
# import collections
# from math import sqrt
# input = lambda: sys.stdin.readline()

def Main():
    s = set()
    A = []
    n = int(input())
    a = input()
    b = input()
    ok = False
    if a == b:
        print(len(a))
        return 0
    for i in range(n):
        s.add(a[i])
        s.add(b[i])
        # print(a[n - 1 - i] , b[i])
        # if a[n - 1 - i] == b[i] and (ok == False):
        #     ok = False
        #     A.append(b[i])
        # else:
        #     print(1)
        #     ok = True
        #     A.append(a[n - 1 - i])
        #     A.append(b[i])

    # print(len(A))
    # print(*A)

    # for itm in s:
    #     print(itm,end = "")
    print(len(s))

if __name__ == '__main__':
    Main()

Submission status: Wrong Answer

Solution 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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if s == t:
    print(n)
else:
    ans = n * 2
    cnt = 0
    while True:
        if s[n-1 - cnt] != t[cnt]:
            print(ans)
            break
        else:
            ans -= 1
            cnt += 1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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


def main(s, t):
    len_s = len(s)
    len_t = len(t)

    cover = 0
    for c in s:
        if c in t:
            cover += 1

    return len_s + len_t - cover

print(main(s, t))

Submission status: Wrong Answer

Solution code:
N = int(input())
s = input()
t = input()
finish = 0
count = 0
num =int(len(t))
for x in t:
  if finish == 1:
    break
  for y in s:
    if x == y:
      count += num
      finish = 1
      break 
    else:
      count += 1
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if int(len(s))==1 and int(len(t))==1:
    print(len(s)+len(t))
elif s[N-1]==t[0]:
    print(len(s)+len(t)-1)
elif s==t:
    print(N)

Submission status: Wrong Answer

Solution code:
n = input()
s = raw_input()
t = raw_input()
u = s[:]
i = 1
while True:
    # print u
    if u[-n:] == t:
        break
    else:
        u = s + t[-i:]
        i += 1
print u

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
T = input()
if S == T:
    print(N)
else:
    c = 0
    for i in range(N):
        if S[-i-1] != T[i]:
            c = i
            break
    print(N * 2 - c)

Submission status: Wrong Answer

Solution code:
#input
N=int(input())
s=input()#N 文字
t=input()#N 文字
if s==t:
	print(len(s))
else:
	A = []
	for i in s:
		A.append(i)
	A.reverse()
	rs = "".join(A)

	cnt=0

	for i in range(len(t)):
		if t[i]==rs[i]:
			cnt+=1
		else:
			break

	print(2*len(t)-cnt)

Submission status: Wrong Answer

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

if int(len(s))==1 and int(len(t))==1:
    print(s+t)
elif s[N-1]==t[0]:
    print(s[0:N-1]+t[0:N])
elif s==t:
    print(s)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
T = input()
if S == T:
    print(N)
else:
    c = 0
    for i in range(N):
        if S[i] != T[-i-1]:
            c = i
            break
    print(N * 2 - c - 2)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
T = input()
if S == T:
    print(N)
else:
    c = 0
    for i in range(N):
        if S[i] != T[-i-1]:
            c = i
            break
    print(N * 2 - c + 2)

Submission status: Wrong Answer

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

if s == t:
    print(n)
else:
    if s[n - 1] == t[0]:
        print(n*2 - 1)
    else:
        print(n * 2)

Submission status: Wrong Answer

Solution code:
import sys
import collections
from math import sqrt
input = lambda: sys.stdin.readline()

def Main():
    s = set()
    n = int(input())
    a = input()
    b = input()

    for i in range(n):
        s.add(a[i])
        s.add(b[i])

    print(len(s))
    # print(*s)
    # for itm in s:
    #     print(itm,end = "")
    # print()

if __name__ == '__main__':
    Main()

Submission status: Wrong Answer

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



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


print 2*N-d

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Oct 29 21:00:35 2016

@author: dotha
"""

def main():
    N = int(input())
    s = input()
    t = input()
    if s==t:
        return s
    for i in range(N):
        if s[i:] == t[:-i]:
            return(s[:i]+t)
    else:
        return(s+t)
    





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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
T = input()
ans = -1
for i in range(N):
    # print(S[i:], T[:N-i])
    if S[i:] == T[:N-i]:
        ans = N + i
        break
if ans == -1:
    ans = 2
print(ans)

Submission status: Time Limit Exceeded

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)]
        prev = -1
        for i in xrange(1, self.length):
            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):
    if len(s)!=len(t):
        return
    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()
    print minimumLen(s, t)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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)]
        prev = -1
        for i in xrange(1, self.length):
            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()
    print minimumLen(s, t)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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()
    print minimumLen(s, t)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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



print(ret)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(n * 2)

Submission status: Accepted

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

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

print(n * 2)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())
s = input().strip()
t = input().strip()

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

Submission status: Accepted

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

Submission status: Accepted

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

lt = min(len(s), len(t))
i = -1
overlap = 0
for i in range(lt):
    if s[-(i + 1):] == t[:i + 1]:
        overlap = i + 1
        if lt >= 2 and s[-(i + 2):] != t[:i + 2]:
            break
    
ans = max(n, len(s) + len(t) - overlap)
print(ans)

Submission status: Accepted

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
    break
print(ans)

Submission status: Accepted

Solution code:
import sys
def input():
  return sys.stdin.readline().rstrip()

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

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

print(func())

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

i = 0
while i < N:
    if s[i:] == t[:N - i]:
        break
    i += 1
print(i + N)

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
n = I()
s = input()
t = input()
if s == t:
    print(n)
    exit()
cnt = 0
for i in range(n):
    suf = s[-i-1:]
    pre = t[:i+1]
    #print(suf,pre)
    if s[-i-1:] == t[:i+1]:
        cnt = len(pre)
print(n + n - cnt)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
S = input()
T = input()
cnt = 0
for i in range(n):
    if S[n - i - 1:] == T[: i + 1]:
        cnt = i + 1
print(2*n-cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
s = input()
t = input()
c = 0
for o in range(len(s) + 1):
    d = 0
    for i in range(len(t)):
        if o + i >= len(s): break
        if s[o + i] == t[i]: d += 1
        else: break
    c = max(c, d)
print(len(s) + len(t) - c)

Submission status: Accepted

Solution code:
from collections import deque,defaultdict,Counter
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from bisect import bisect_left,bisect_right
from math import sqrt,gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode
import sys
sys.setrecursionlimit(10 ** 6)

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse=False):
    data.sort(key=lambda x:x[col],reverse=revese)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def mydictvaluesort(dictionary):
    return sorted( dictionary.items(), key=lambda x:x[1] )

def mydictkeysort(dictionary):
    return sorted( dictionary.items(), key=lambda x:x[0] )

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]

# ddict = defaultdict(lambda: 0)
# ddict = defaultdict(lambda: 1)
# ddict = defaultdict(lambda: int())
# ddict = defaultdict(lambda: list())
# ddict = defaultdict(lambda: float())

n = I()
s = S()
t = S()

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

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

Submission status: Accepted

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

Submission status: Accepted

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