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()
cou = 0
if s==t:
  print(n)
  exit()
for i in range(1,n+1):
  s1 = s[n-i:]
  t1 = t[:i]
  if s1==t1:
    cou += 1
  else:
    break
print(2*n-cou)

Submission status: Wrong Answer

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

if s==t:
  print(n)
  exit(0)
sr=s[::-1]
u=0
for sri,ti in zip(sr,t):
  if sri==ti:u+=1
  else:break
print(len(s[:n-u]+t))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    n = int(input())
    s =input()
    t = input()
    count = 2*n

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

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    n = int(input())
    s =input()
    t = input()
    count = 2*n

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if ss == t:
    ans = n
else:
    s = ss[::-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:

def resolve():
    n = int(input())
    s = input()
    t = input()
    if s == t and len(s) >= n:
        print(len(s))
        return
    pos = 0
    for ss, tt in zip(s[::-1], t):
        if ss != tt:
            break
        pos += 1
    if len(s) + len(t[pos:]) >= n:
        print(len(s+t[pos:]))
        return
    print(len(s+t))


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:

def resolve():
    n = int(input())
    s = input()
    t = input()
    if s == t and len(s) >= n:
        print(len(s))
        return
    pos = 0
    for ss, tt in zip(s[::-1], t):
        if ss != tt:
            break
        pos += 1
    if len(s) + len(t[pos:]) >= n:
        print(len(s+t[pos:]))
        print(pos)
        return
    print(len(s+t))


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
# agc006_a.py
N = int(input())
S = list(input())
T = list(input())
ans = N*2
for i in range(N):
    if S[N-1-i:] == T[:i+1]:
        ans = ans-(i+1)
print(ans)

Submission status: Wrong Answer

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############
N = I()
A = S()
B = S()

if A==B:
  print(A)
  exit()

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

Submission status: Wrong Answer

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############
N = I()
A = S()
B = S()

if A==B:
  print(A)
  exit()

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

Submission status: Wrong Answer

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

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

print(n * 2 - i)

Submission status: Wrong Answer

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

tmp = []
i = 1
while True:
  if(s[-i] == t[i-1]):
    tmp.append(i-1)
    i += 1
  else:
    break
print(tmp)
t = list(t)
for i in range(len(tmp)):
  del t[tmp[i]]
t = ''.join(t)
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[:n-i]:
        ans = s[:i]+s[i:]+t[n-i:]

print(len(ans))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline


def read():
    N = int(input().strip())
    s = input().strip()
    t = input().strip()
    return N, s, t


def solve(N, s, t):
    for i in range(1, N+1):
        sl = N - i
        tr = i
        if s[sl:] == t[:tr]:
            return 2 * N - i
    return 2 * N


if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()

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

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

Submission status: Wrong Answer

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

ind = 0
mx = min(len(s), len(t))
while ind < mx:
    pre_i = s[-(ind + 1):]
    suf_i = t[:(ind + 1)]
    if pre_i != suf_i:
        break
    else:
        ind += 1

ans = len(s) + len(t) - ind
print(ans)

Submission status: Wrong Answer

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

ans = 2 * N

for tail, head in zip(reversed(s), t):
    if s == t:
        print(N)
        break
    if tail == head:
        ans -= 1
    else:
        print(ans)
        break

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

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

if S == T:
    print(len(S))
    exit()

ans = ''
end = N
for i in range(N):
    if S[i:] == T[:end]:
        ans = S[:i+1] + T[end:]
        break

    end -= 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()
for i in range(N):
    if S[N-i-1] == T[i]:
        continue
    else:
        print(2*N - i)
        exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(2 * N - res)

Submission status: Wrong Answer

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

ans = N + N
for i in range(N):
  w = S + T[-(i+1):]
  if w[:N] == S and w[N:] == T:
    ans = min(ans,i+N+1)

if S == T:
  ans = N
    
print(ans)

Submission status: Wrong Answer

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

ans = N + N
for i in range(N):
  w = S + T[-(i+1):]
  if w[:N] == S and w[N:] == T:
    ans = min(ans,i+N)

if S == T:
  ans = N
    
print(ans)

Submission status: Wrong Answer

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

ans = N + N
for i in range(N+1):
  w = S[:i] + T
  if w[:N] == S and w[N:] == T:
    ans = min(ans,i+N)

for i in range(N+1):
  w = S + T[:i]
  if w[:N] == S and w[N:] == T:
    ans = min(ans,i+N)

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

s = input()
t = input()

i = 0

while i < N:
    if s[i:] == t[:N-1]:
        break
    else:
        i+=1

print(N+i)

Submission status: Wrong Answer

Solution code:
N = int(input())

s = input()
t = input()

res = list(s)

x = s[::-1]

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

for i in range(len(t)):
    if t[i] == x[i]:
        continue
    else:
        break

print(len(s+t[i:]))

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())
T = list(input())
if S == T:
    print(len(S))
    exit()
U = []
while len(S) > 0:
    if S[-1] == T[0]:
        U.append(S.pop())
        T.pop(0)
    else:
        break
print(len(S+U+T))

Submission status: Wrong Answer

Solution code:
N=int(input())
s=str(input())
t=str(input())
c=0
tmp=0
S=list(s)
T=list(t)
for i in range(N):
    if s[N-i-1:N-1]==t[0:i]:
        c=i+1
print(2*N-c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ushiro = 0

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

mae = 0
ushiro = 0

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

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

if mae == N:
    print(N)
else:
    print(2*N - ushiro)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
t = input()
cnt = 0
# for i in range(len(s)):
#     if s[-i-1] == t[i]:
#         #print(s[-i],t[i])
#         cnt += 1
#     else:
#         break
done = False
ans = 0
for i in range(len(s)):
    if s[i] == t[cnt]:
        cnt += 1
        done = True
    elif s[i] != t[cnt]:
        ans = max(ans,cnt)
        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(len(s)):
#     if s[-i-1] == t[i]:
#         #print(s[-i],t[i])
#         cnt += 1
#     else:
#         break
done = False
for i in range(len(s)):
    if s[i] == t[cnt]:
        cnt += 1
        done = True
    elif done and s[i] != t[cnt]:
        break
print(n + n - cnt)

Submission status: Wrong Answer

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

sl = []
tl = []

for i in range(N):
    sl.append(s[N-i-1])
    tl.append(t[i])

count = 0
while sl[count] == tl[count]:
    count += 1
    if count == N:
        break
    
print(2*N-count)

Submission status: Wrong Answer

Solution code:
# Prefix and Suffix
N = int(input())
s = input()
t = input()

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

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

cnt_s = 0
cnt_t = 0

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

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

print(2*N - min(cnt_s,cnt_t))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

cnt = 0
for i in range(n):
  for j in range(n-i):
    if not s[i+j] == t[j]:
      break
    else:
      print(i+n)
      exit()

print(2*n)

Submission status: Wrong Answer

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

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

print(2 * n - cnt)

Submission status: Wrong Answer

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

n_s=len(s)
n_t=len(t)
l=[]
for i in range(n_s):
    for j in range(n_t):
        l.append(s[:i]+t[j:])
ans=s+t
for c in l:
    if c[:n_s]==s and c[len(c)-n_t:]==t:
        if len(ans)>len(c):
            ans=c

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
S = input()
T = input()
ans = n * 2
p = ''
q = ''
if S == T:
    print(n)
    exit()
for i in range(n):
    p = S[n - i - 1] + p
    q += T[i]
    if p == q:
        ans -=  1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

main()

Submission status: Wrong Answer

Solution code:
N = int(input())
A=input()
B=input()
ans =0 
i=2
if A == B:
    print(N)
    exit()
for i in range(1,N+1):
    if A[-i:] == B[:i]:
        ans+= 1
    else:
        break
print(N*2-ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[27]:


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


# In[29]:


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


# In[ ]:

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0

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

Submission status: Wrong Answer

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

ans = 0

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

Submission status: Wrong Answer

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

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

    print((n * 2) - r)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
T = input()
ans = 2 * N
if (S == T):
    print(N)
    exit(0)
for i in range(N):
    if (T[i] == S[-(i + 1)]):
        print(T[i], S[-(i + 1)])
        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]

i = 0
res = 0
while True:
	if s[i] != t[i]:
		break
	i += 1
	res += 1

print(2 * n - res)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    res = n
    for i in range(n):
        for j in range(n):
            if i + j < n:
                if s[i + j] != t[j]:
                    break
        else:
            res = i

    print(res + n)


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

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

char = set()
for i in range(n):
    char.add(s[i])
    char.add(t[i])

print(len(char))

Submission status: Wrong Answer

Solution code:
def myAnswer(N:int,s:str,t:str) -> int:
   if(s == t): return N
   if(N == 1): return 2
   total = N * 2
   for start,end in zip(s[::-1],t):
      # print(start,end)
      if(start == end):
         total -= 1
   return total

def modelAnswer():
   return
def main():
   N = int(input())
   s = input()
   t = input()
   print(myAnswer(N,s,t))
if __name__ == '__main__':
   main()

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# AGC 006: A – Prefix and Suffix
N = int(input())
s, t = [input() for _ in range(2)]

common = 0

if s == t:
    common = len(s)
else:
    while s[-1 - common] == t[common]:
        common += 1

print(N * 2 - common)

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
s = input()
t = input()
for i in range(N):
  #print(s[-(i+1):],t[:i+1])
  if s[-(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()
ans = 0
if S == T:
    print(n)
else:
    for i, (t, s) in enumerate(zip(T, S[::-1])):
        if t == s:
            ans += 1
        else:
            ans += (n- i)*2
            break
    print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = set(list(input()))
b = set(list(input()))
print(len(a | b))

Submission status: Wrong Answer

Solution code:
N=int(input())
s=list(input())
t=list(input())
f=s+t
if s==t:
    print(''.join(s))
    exit()
for i in range(0,N):
    if s[-i:]==t[:i]:
        f=s+t[i:]
print(''.join(f))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

if s == t:
    print(n)
else:
    print(ans)

Submission status: Wrong Answer

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

print(len(t | s))

Submission status: Wrong Answer

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

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[-i-1]!=t[i]:
        print((n*2)-i)
        exit()

Submission status: Wrong Answer

Solution code:
#AGC006-A
n = int(input())
s = input()
t = input()

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

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