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:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

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

Submission status: Wrong Answer

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

ans = 0

for i in range(n):
    if t[0] == s[i]:
        for j in range(n - i):
            if t[j] == s[i+j]:
                continue
            else:
                ans = 1
                break
        if ans == 0:
            print(len("".join(s[:i] + t)))
            ans = 1
if ans == 0:
    print(len("".join(s + t)))

Submission status: Wrong Answer

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

count = 0

if s == t:
    ans = N


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

        else:
            break

    ans = N*2 - count

print(ans)

Submission status: Wrong Answer

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

count = 0

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

    else:
        break

ans = N*2 - count

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(N):
    is_match = True
    for j in range(N-i):
        if s[i+j] != t[j]:
            is_match = False
            break
    if is_match:
        print N+i
        exit()

Submission status: Wrong Answer

Solution code:
#coding utf-8

N = int(input())
s = list(input())
t = list(input())
Flg = True
for i in range(N,-1,-1):
    if s[N-i:N] == t[:i+1]:
        ans = 2 * N - i
        Flg = False
        break

if Flg:
    ans = 2 * N
    if s[-1] == t[0]:
        ans = 2 * N - 1
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    S = input()
    T = input()
    if S == T:
        return print(len(S))
    for i in range(N):
        if S[-(i+1)] == T[i]:
            continue
        else:
            print(len(S + T[i:]))
            break


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


if s[-1] in t:
    i = t.index(s[-1])
    if s[-i-1:] == t[:i+1]:
        print(len("".join(s[:-i-1]) + "".join(t)))
    else:
        print(len("".join(s) + "".join(t)))
else:
    print(len("".join(s) + "".join(t)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

sf = s[0:n]
tf = t[-n:]
#print(sf)
#rint(tf)

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

    else:
        ans.append(sf[i])
#        print(sf[i],end="")
else:
    ans+=tf
    #print(tf)
#print(ans)
print(len(ans))

Submission status: Wrong Answer

Solution code:
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+=tf
            #print(tf)
            break

    else:
        ans.append(sf[i])
#        print(sf[i],end="")
else:
    ans+=tf
    #print(tf)
#print(ans)
print(len(ans))

Submission status: Wrong Answer

Solution code:
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)
            #print(tf)
            break

    else:
        ans.append(sf[i])
#        print(sf[i],end="")
else:
    ans.append(tf)
    #print(tf)
print(len(ans))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
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)
#print("")

Submission status: Wrong Answer

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

c = 0
# i文字一致している
for i in range(N):
    sp = s[i:]
    tp = t[:N-i]
    # print(sp, tp)
    if sp == tp:
        c = i
        break

# print(c)
match = N - c
ans = 2 * N - match
print(ans)

Submission status: Wrong Answer

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

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

ans = ''
for i in range(n):
  ss = s[n-i-1:]
  tt = t[:i+1]
  if ss == tt:
    ans = s[:n-i-1]+t[i+1:]

if len(ans) == 0:
  print(len(s+t))
else:
  print(len(ans))

Submission status: Wrong Answer

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

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

ss = s+t
ans = ''
slen = len(s)
for i in range(slen):
  k = slen - i -1
  l = slen + i
  if ss[k] == ss[l]:
    ans = ss[:k]+ss[l:]

if len(ans) == 0:
  print(len(ss))
else:
  print(len(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
w1 = input()
w2 = input()

def joint(x,y):
    tmp = 0
    tmp_x = ''
    tmp_y = ''
    for i in range(0,n):
        tmp_x = tmp_x + x[-i-1]
        tmp_y =  y[i] + tmp_y
        if tmp_x == tmp_y:
            tmp += 1
        else:
            break
    joi_x = x[0:n-tmp]
    return(joi_x+y)

if w1 == w2:
    print(n)
else:
    print(len(joint(w1,w2)))

Submission status: Wrong Answer

Solution code:
n = int(input())
w1 = input()
w2 = input()

def joint(x,y):
    tmp = 0
    for i in range(0,n):
        if x[-i-1] == y[i]:
            tmp += 1
        else:
            break
    tmp_x = x[0:n-tmp]
    return(tmp_x+y)

if w1 == w2:
    print(n)
else:
    print(len(joint(w1,w2)))

Submission status: Wrong Answer

Solution code:
n = int(input())
w1 = input()
w2 = input()

def joint(x,y):
    tmp = 0
    for i in range(0,n):
        if x[-i-1] == y[i]:
            tmp += 1
        else:
            break
    tmp_x = x[0:n-tmp]
    return(tmp_x+y)

if w1 == w2:
    print(w1)
else:
    print(joint(w1,w2))

Submission status: Wrong Answer

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

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()
print(N+1)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
t = input()
if s == t: print(n)
else:
    idx = False
    for i in range(n):
        if s[i] == t[0]:
            idx = i
            for j in range(0, n - idx):
                if s[idx + j] == t[j]: continue
                else:
                    idx = False
                    break
    if idx == False: print(len(s + t))
    else: print(len(s[:idx] + t))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
t = input()
if s == t: print(n)
else:
    idx = False
    for i in reversed(range(n)):
        if s[i] == t[0]:
            idx = i
            for j in range(0, n - idx):
                if s[idx + j] == t[j]: continue
                else:
                    idx = False
                    break
    if idx == False: print(len(s + t))
    else: print(len(s[:idx] + t))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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
        else:
            ans -= p
            break

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    s = input()
    t = input()
    if s == t:
        print(N)
    elif N == 1:
        print(2)
    else:
        for i in range(N-1):
            if s[-i-1:] != t[:i+1]:
                break
        print(2*N-i)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())

s = input()
t = input()
ans = N
for i in range(N):
  if (s[i:] == t[:N-i]):
    ans += i
    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)
    exit()
print(2*n)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
t = input()
r = s[::-1]

count = 0
if s == t:
    print(len(s) + len(t))
else:
    for i, c in enumerate(t):
        if c == r[i]:
            count += 1
        else:
            break
    print(len(s) + len(t) - count)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
t = input()
r = s[::-1]

count = 0
if s == t:
    print(len(s) + len(t))
else:
    for i, c in enumerate(t):
        if c == r[i]:
            count += 1
    print(len(s) + len(t) - count)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
t = input()
r = s[::-1]

count = 0
if s == t:
    print(n)
else:
    for i, c in enumerate(t):
        if c == r[i]:
            count += 1
        else:
            break
    print(len(s) + len(t) - count)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = input()
t = input()
p = N
def dfs(i, j):
    if i == N or j == N:
        return p
    if s[i] == t[j]:
        return min(dfs(i, -~j) - 1, dfs(-~i, -~j) - 1)
    else:
        return min(dfs(i, -~j), dfs(-~i, -~j))

print(N + dfs(0, 0))

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
t=input()
a=0
b=-1
if s!=t:
    while s[b] == t[a]:
        a=a+1
        b=b-1
    print(2*n-a)
else:
    print(n)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = input()
t = input()
p = N
for s_i, t_i in zip(s[::-1], t):
    if s_i == t_i:
        p -= 1
    else:
        break
print(N + p)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
s = input() + input()
c = Counter(list(s))
l = len(list(filter(lambda x : x > 1, c.values())))

if l == 0:
  print(2*n)
else:
  print(2*n - l)

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque, Counter, defaultdict
from fractions import gcd

input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

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

    st = s + t
    if s == t:
        print(n)
        return
    else:
        while True:
            if st[n] == st[n-1]:
                st = st[:n] + st[n+1:]
                n -= 1
            else:
                break
        print(len(st))
        
    return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def pin(type=int):
    return map(type,input().split())
#どっかで最悪計算量の入力データを用意する関数を作ろう？
"""
バケットで管理したかったけど数字が多いのでソートして同じ数を固めることに
"""
#solution:
#潜 影 蛇 手 ! !
N=int(input())
S=input()
T=input()
ans=""
for i in range(N):
    #print(i)
    flag=1
    for j in range(N):
        if j+i<N :
            #print(S[j],S[j+i])
            if S[i+j]!=T[j]:
                flag=0
                break
    if flag==1:
            #p#Zrint(i)
        ans+=S[0:i]+T
        break
print(len(ans))

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
T=input()
ans=""
for i in range(N):
    #print(i)
    flag=1
    for j in range(N):
        if j+i<N :
            #print(S[j],S[j+i])
            if S[i+j]!=T[j]:
                flag=0
                break
    if flag==1:
            #p#Zrint(i)
        ans+=S[0:i]+T
        break
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
t = input()
if s == t:
  print(n)
  quit()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

print(n*2-cnt)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
T = input()
print(len(set(S+T)))

Submission status: Wrong Answer

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

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

s = ''.join(list(reversed(s)))

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

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 - (n-i))
        exit(0)

print(2**n)

Submission status: Wrong Answer

Solution code:
# ん これ微妙にむずくない？
# sの末尾x文字とtの先頭x文字ぶんかぶってるかどうかチェック
n = int(input())
s, t = input(), input()
a = 0
for i in range(n):
    if s[-i - 1 :] == t[: i + 1]:
        a = i
print(len(s) + len(t[a + 1 :]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


for idx, (ss, tt) in enumerate(zip(s,t)):
    if ss != tt:
        break
if list(reversed(s)) == t:
    print(len(s))
else:
    print(n + n - idx)

Submission status: Wrong Answer

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


for idx, (ss, tt) in enumerate(zip(s,t)):
    if ss != tt:
        break
if list(reversed(s)) == t:
    print(len(s))
else:
    print(n + n - 2 * idx + 1)

Submission status: Wrong Answer

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


for idx, (ss, tt) in enumerate(zip(s,t)):
    if ss != tt:
        break
if list(reversed(s)) == t:
    print(len(s))
else:
    print(n + idx + 1)

Submission status: Wrong Answer

Solution code:
import sys

stdin = sys.stdin

mod = 1000000007

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n = ni()
s = ns()
t = ns()

ans = n * 2

c = 0
for i in range(n):
	if s[i] == t[c]:
		c += 1
	else:
		c = 0

ans -= c
print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()
t = stdin.readline().rstrip()
point = 0
for i,j in zip(s,t):
    if i == j:
        point += 1
    else:
        break
print(n*2-point)

Submission status: Wrong Answer

Solution code:
from sys import stdin
n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()
t = stdin.readline().rstrip()
u = s[::-1]
point = 0
for i,j in zip(u,t):
    if i == j:
        point += 1
    else:
        break
print(len(s[:-1*point]+t))

Submission status: Wrong Answer

Solution code:
from sys import stdin
n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()
t = stdin.readline().rstrip()
u = s[::-1]
point = 0
for i,j in zip(u,t):
    if i == j:
        point += 1
    else:
        break
print(n*2-point)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
N = input()
s = input()
t = input()

if s == t:
    print(len(s))
    sys.exit(0)

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

print(ans)

Submission status: Wrong Answer

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

import sys
if s == t:
    print(len(s))
    sys.exit(0)

ans = 0
for i, j in zip(s[::-1], t):
    print(i, j)
    if i == j:
        ans += 1
    else:
        ans += 2

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution 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
else:
  print(ans)

Submission status: Wrong Answer

Solution 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

Submission status: Wrong Answer

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

pos = 0

flag = True
while True:
    # print(s[pos:])
    # print(t[:n-pos])
    if pos >= n-pos and s[-1] != t[0]:
        if n == 1:
            pos -= 1
        pos += 1
        break
    for i in range(pos, n-pos):
        if s[i] != t[i-pos]:
            flag = False
            break
    if not flag:
        pos += 1
        flag = True
        continue
    break
print(n+pos)

Submission status: Wrong Answer

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

pos = 0

flag = True
while True:
    #print(s[pos:])
    #print(t[:n-pos])
    if pos >= n-pos and s[-1] != t[0]:
        pos += 1
        break
    for i in range(pos, n-pos):
        if s[i] != t[i-pos]:
            flag = False
            break
    if not flag:
        pos += 1
        flag = True
        continue
    break
print(n+pos)

Submission status: Wrong Answer

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

pos = 0

flag = True
while True:
    for i in range(pos, n-pos):
        if s[i] != t[i-pos]:
            flag = False
            break
    if not flag:
        pos += 1
        flag = True
        continue
    break
print(n+pos)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

pos = 0
ans = n*2
for pos in range(n):
    if s[pos:] == t[:n-pos]:
        ans = n+pos
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = list(input())
t = list(input())
s.extend(t)

ans = set(s)
if len(ans) < N:
    print(len(ans) + N -1)
    quit()
print(len(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
s = list(input())
t = list(input())
s.extend(t)

ans = set(s)
print(len(ans))

Submission status: Wrong Answer

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

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

print(ans)