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 = list(input())
t = list(input())
cnt = 0
idx = n - 1
if "".join(s) == "".join(t):
    print(n)
    exit()
else:
    for i in range(n):
        if s[idx-i] == t[i]:
            cnt += 1
        else:
            cnt += 2
print(cnt)

Submission status: Wrong Answer

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

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

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 = 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: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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):
    if s[i] == t[-i-1]:
        cnt += 1
print(n + n - cnt)

Submission status: Wrong Answer

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]

print(len(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

cnt=0

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

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
t = input()
x = 2 * n
for i in range(n):
  if t.startswith(s[i:]):
    x = n + i

print(x)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ts=list(s)
tt=list(t)
doubled=0
for i in range(N):
    if ts[N-1-i]==tt[i]:
        doubled+=1

ans=ts+tt[:doubled]
print("".join(ans))

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
s = list(str(input()))
t = list(str(input()))
ans = []
for i in range(n):
    ans.append(s[i])

def my_index(l, x):
    if x in l:
        return l.index(x)
    else:
        return -1

last = my_index(t,s[-1])


if last == -1:

    print(n*2)
    sys.exit()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())
s = list(input())
t = list(input())
if s == t:
  print(N)
  sys.exit()
  
s.reverse()
c = 0
for i in range(N):
  if t[i] == s[i]:
    c += 1
  else:
    break
print(2*N-c)

Submission status: Wrong Answer

Solution code:
#26 A - Prefix and Suffix
N = int(input())
s = list(input())
t = list(input())
s_rev = list(reversed(s))

cnt = N
for i in range(1,N+1):
    # s の部分文字列を後ろから取り出す
    tgt = list(reversed(s_rev[:i]))
    if tgt == t[:i]:
        cnt -= 1
    else:
        break
    
if s == t:
    print(N)
else:
    ans = s[:cnt] + t
    print(len(ans))

Submission status: Wrong Answer

Solution code:
#26 A - Prefix and Suffix
N = int(input())
s = list(input())
t = list(input())
s_rev = list(reversed(s))

cnt = N
for i in range(1,N+1):
    # s の部分文字列を後ろから取り出す
    tgt = list(reversed(s_rev[:i]))
    print(tgt,t[:i])
    if tgt == t[:i]:
        cnt -= 1
    else:
        break
    
if s == t:
    print(N)
else:
    ans = s[:cnt] + t
    print(len(ans))

Submission status: Wrong Answer

Solution code:
#26 A - Prefix and Suffix
N = int(input())
s = list(input())
t = list(input())
s_rev = list(reversed(s))

cnt = N
for i in range(1,N+1):
    # s の部分文字列を後ろから取り出す
    tgt = list(reversed(s_rev[:i]))
    if tgt == t[:i]:
        cnt -= 1
    
if s == t:
    print(N)
else:
    ans = s[:cnt] + t
    print(len(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
r=input()
x=0
y=-1
f=0
for i in range(n):
    if(s[i:]==r[:n-i]):
        t=s[:i]+r
        f=1
        x=min(len(t),x)
if(f==0):
    print(2*n)
else:
    print(x)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

print(len(ans))

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[0]:
        if s[i:] == t[:n-i]:
            ans = s[:i]+t
print(len(ans))

Submission status: Wrong Answer

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

mae = s[:N]
ushiro = t[:N]

if mae == ushiro:
    print(len(mae))
    exit()

if mae[-1] == ushiro[0]:
    mae = ((mae.rstrip(mae[-1])))

    
print(len(mae+ushiro))

Submission status: Wrong Answer

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

mae = s[:N]
ushiro = t[:N]

if mae == ushiro:
    print(mae)
    exit()

if mae[-1] == ushiro[0]:
    mae = ((mae.rstrip(mae[-1])))

    
print(len(mae+ushiro))

Submission status: Wrong Answer

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

mae = s[:N]
ushiro = t[:N]

if mae == ushiro:
    print(mae)
    exit()


print(len(mae+ushiro))

Submission status: Wrong Answer

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

mae = s[:N]
ushiro = t[:N]

if mae == ushiro:
    print(mae)
    exit()


print(mae+ushiro)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = set(list(input()))
t = set(list(input()))
print(len(s | t))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
t = input()
ans = n
for i in range(n):
    f = True
    for j in range(n - i):
        f &= s[j + i] == t[j]
    if f:
        ans = i

print(n+ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
s = input()
t = input()
if s==t:
    print(N)
    exit()
s = s[::-1]
cnt = 0
for c1, c2 in zip(s,t):
    if c1 != c2:
        break
    cnt += 1

print(N*2-cnt)

Submission status: Wrong Answer

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

cnt = 0
for c1, c2 in zip(s,t):
    if c1 != c2:
        break
    cnt += 1

print(N*2-cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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


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

Submission status: Wrong Answer

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

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

ans = n*2 - ans
print(ans)

Submission status: Wrong Answer

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

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

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

ans = s[:n-1-i+1]+t
print(len(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

ans = n*2 - ans
print(ans)

Submission status: Wrong Answer

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

ans = n * 2
if s == t:
    print(n)
else:
    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()

ans = N * 2
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 = list(input())
t = list(input())

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

length = len(s+t)

s = s[::-1]


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

length -= cnt

if length >= n:
    print(length)
else:
    print(n)

Submission status: Wrong Answer

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

length = len(set(s+t))

if length <= n:
    print(n)
else:
    print(length)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())

s = str(input())
t = str(input())

l = s+t
lst = list(set(l))
lst = sorted(lst)
print(len(lst))

Submission status: Wrong Answer

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

print(s + t[idx:])

Submission status: Wrong Answer

Solution code:
from copy import deepcopy
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions
from operator import itemgetter
import itertools
import copy


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


def gcd(a, b):
    while(b != 0):
        a, b = b, a % b
    return a


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n = int(input())
s = input()
t = input()
tmp = ['']*(2*n)
# print(tmp)
for i in range(n):
    tmp[i] = s[i]
for i in range(n):
    tmp[n+i] = t[i]
print(len(set(tmp)))

Submission status: Wrong Answer

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

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

if s==t:
  ans=s

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]:
        if s[i:] == t[:n-i]:
            ans = s[:i]+t
if ans == "": ans = s+t
print(len(ans))

Submission status: Wrong Answer

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

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

  else:
    cnt+=1
print(n*2)

Submission status: Wrong Answer

Solution code:
# AtCoder Grand Contest 006
# A - Prefix and Suffix

def f(word,N,S,T):
    if word[:N]==S and word[-N:]==T:
        return True
    else :
        return False


N=int(input())
S=input()
T=input()

ans = N*2

for i in range (N):
    t=T[N-i:]
    word=S+t

    if f(word,N,S,T)==True:
        ans=len(word)
    else:
        pass

print(ans)

Submission status: Wrong Answer

Solution code:
# AtCoder Grand Contest 006
# A - Prefix and Suffix

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

if s==t:
    print(N)
    exit()
else :
    pass
l=0

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

print(2*N-l)

Submission status: Wrong Answer

Solution code:
N=int(input())
p=list(str(input()))
t=list(str(input()))
s=p[::-1]
cnt=0
for i in range(min(len(s),len(t))):
  
    if s[i]==t[i]:
        cnt+=1
    else:
        break

if t==p:
    cnt=len(s)
print(len(s)+len(t)-cnt)

Submission status: Wrong Answer

Solution code:
N=int(input())
s=str(input())
t=str(input())
cnt=0

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

Submission status: Wrong Answer

Solution code:
N=int(input())
s=str(input())
t=str(input())
cnt=0

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

Submission status: Wrong Answer

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

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


if lst:
    print(min(lst))
else:
    print(n*2)

Submission status: Wrong Answer

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

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


if lst:
    print(max(lst))
else:
    print(n*2)

Submission status: Wrong Answer

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

import re 


ans=s

k=-1
for i in range(n):
    tmp=''.join(t[:i+1])

    if tmp in ans:
        k=i

if k<n-1:
    ans+=''.join(t[k+1:])

print(ans)

Submission status: Wrong Answer

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

cnt = 0

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

s = s[::-1]

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

print(n + n-cnt)

Submission status: Wrong Answer

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

cnt = 0

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

s = s[::-1]

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

print(n + n-cnt)

Submission status: Wrong Answer

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

cnt = 0

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

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

print(n + n-cnt)

Submission status: Wrong Answer

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

cnt = 0

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

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

print(n + n-cnt)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if s == t:
  ans = len(s)
  while ans < n:
    ans += 1
  print(ans)
  exit()

if len(set(s+t)) == (len(s)+len(t)):
    ans = len(s)+len(t)
    while ans < n:
        ans += 1
    print(ans)
    exit()

if (len(s)+len(t)) <= n:
    ans = len(s)+len(t)
    while ans < n:
        ans += 1
    print(ans)
    exit()

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
s=input()
t=input()
i=0
count=0
while i<=N-1:
   if s[-i-1]==t[i]:
       count+=1
       i+=1
   else:
       break

ans=s[:N-count]+t
print(len(ans))

Submission status: Wrong Answer

Solution code:
N=int(input())
s=input()
t=input()
i=0
count=0
while i<=N-1:
   if s[-i-1]==t[i]:
       count+=1
       i+=1
   else:
       break

ans=s[:N-count]+t
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
from collections import deque
import itertools
import math

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

n = readInt()
s = input()
t = input()

if s==t and len(s)>=n:
  print(len(s))
  exit()
if n>=len(s)+len(t):
  print(n)
  exit()

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

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
from collections import deque
import itertools
import math

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

n = readInt()
s = input()
t = input()

if s==t and len(s)>=n:
  print(n)
  exit()
if n>=len(s)+len(t):
  print(n)
  exit()

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N=int(input())
s=list(input())
t=list(input())
x=s+t
x=list(dict.fromkeys(x))
print(len(x))

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

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

Submission status: Wrong Answer

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

cnt = 101
for i in range(n):
    if s[i:] == t[:n-i]:
        cnt = min(cnt, i)

print(n + cnt)

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

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

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

Submission status: Wrong Answer

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

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

print(n*2 - cnt)

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
s = input().strip()
t = input().strip()
k = 0
for i in range(1,N+1):
    if s[-i:]==t[:i]:
        k = i
        continue
    break
print(2*N-k)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n = int(input())

s = input()
t = input()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
pre = input()
suf = input()[::-1]
if pre==suf[::-1]:
    print(n)
    sys.exit()
ans, c = n*2, n-1, 
for i in range(n):
  if pre[c]==suf[c]:
     ans-=1   
  else:
    break
  c-=1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
t = input()
s1 = []
t1 = []
if len(s) <= n or len(t) <= n:
  print (len(set(s + t)))
elif len(s) >= n and len(t) >= n:
  for i in range(n):
    s1.append(s[i])
  for i in range(n):
    t1.append(t[i])
  a = set(s1 + t1)
  print(len(a))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(str(input().split()))
t = list(str(input().split()))
s.sort()
t.sort()
a = set(s+t)
b = 0
c = 0
for i in range (len(s)-1):
  if s[i] == s[i+1]:
    b+=1
for j in range (len(t)-1):
  if t[j] == t[j+1]:
    c+=1
print(len(a)-5+c+b)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = str(input().split())
t = str(input().split())
a = set(s+t)
print(len(a)-3)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = str(input().split())
t = str(input().split())
a = set(s+t)
print(a)
print(len(a)-3)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
t = input()
s1 = []
t1 = []
if len(s) == n and len(t) == n:
  for i in range(0 , len(s)):
  	s1.append(s[i])
  for i in range(0 , len(t)):
  	t1.append(t[i])
a = set(s1 + t1)
if len(s1) == n:
  print(len(a))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
t = input()
s1 = []
t1 = []
for i in range(0 , len(s)):
  s1.append(s[i])
for i in range(0 , len(t)):
  t1.append(t[i])
a = set(s1 + t1)
if len(s1) == n:
	print(len(a))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
t = input()
s1 = []
t1 = []
for i in range(0 , len(s)):
  s1.append(s[i])
for i in range(0 , len(t)):
  t1.append(t[i])
a = set(s1 + t1)
if len(s1) == n:
	print(len(a))
print(a)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
t = input()
s1 = []
t1 = []
for i in range(0 , len(s)):
  s1.append(s[i])
for i in range(0 , len(t)):
  t1.append(t[i])
a = set(s1 + t1)
if len(s1) >= n:
	print(len(a))

Submission status: Wrong Answer

Solution code:
n = input()
s = input()
t = input()
s1 = []
t1 = []
for i in range(0 , len(s)):
  s1.append(s[i])
for i in range(0 , len(t)):
  t1.append(t[i])
print(len(set(s1 + t1)))

Submission status: Wrong Answer

Solution code:
n = input()
s = list(input().split())
t = list(input().split())
a = set(s + t)
print(len(a))

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
t = input()
cou = 0
for i in range(n):
  s1 = s[i:]
  t1 = t[:n-i]
#  print(s1,t1)
  if s1==t1:
    print(2*n-(n-i))
else:
  print(2*n)

Submission status: Wrong Answer

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