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: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    s = S()
    t = S()
    for i in range(n):
        if s[i:] == t[: n - i]:
            print(n + i)
            return
    primt(2 * n)
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Runtime Error

Solution code:
n,x = map(int, input().split())
if n != x:
  print("No")
else:
  print("Yes")
  for i in range(1, 2 * n):
    print(i)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

ans = 0

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

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

print(ans)

Submission status: Runtime Error

Solution code:
import sys
n=int(input())
s=input()
t=input()
if s == t:
  print len(s)
  sys.exit()
for i in range(1,n):
  tmp=s+t[-1*i:]
  if tmp[-n:] == t:
    print n+i
    sys.exit()

Submission status: Runtime Error

Solution code:
n,x=map(int,input().split())
if x==1 or x==2*n-1:print("No")
else:
  print("Yes")
  b=[0]*n
  b[n//2]=x
  b[n//2-1]=x-1
  b[n//2+1]=x+1
  tor=[i+1 for i in range(n)]
  del tor[x-2:x+1]
  for i in range(n):
    if b[i]==0:
      b[i]=tor.pop()
  for i in b:
    print(i)

Submission status: Runtime Error

Solution code:
n,x=map(int,input().split())
if x==1 or x==n:print("No")
else:
  print("Yes")
  b=[0]*n
  b[n//2]=x
  b[n//2-1]=x-1
  b[n//2+1]=x+1
  tor=[i+1 for i in range(n)]
  del tor[x-2:x+1]
  print(tor)
  for i in range(n):
    if b[i]==0:
      b[i]=tor.pop()
  for i in b:
    print(i)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

word = s + t

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

Submission status: Runtime Error

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

word = s + t

for letter in s:
  if letter not in letter_list:
    letter_list.append(letter)
    
for letter in t:
  if letter not in list(letter_dict.keys()):
    letter_dict[letter] = 1
    
if s == t:
  print(N)
  sys.exit()
else:
  print(len(letter_dict))

Submission status: Runtime Error

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

word = s + t

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

for letter in s:
  if letter not in letter_list:
    letter_list.append(letter)
    
for letter in t:
  if letter not in list(letter_dict.keys()):
    letter_dict[letter] = 1
    
print(len(letter_dict))

Submission status: Runtime Error

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

word = s + t

if s == t:
  print(N)

for letter in s:
  if letter not in letter_list:
    letter_list.append(letter)
    
for letter in t:
  if letter not in list(letter_dict.keys()):
    letter_dict[letter] = 1
    
print(len(letter_dict))

Submission status: Runtime Error

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

for i in range(N):
    q = s[-(i+1):]
    r = t[:i+1]
    if q == r :
        x = q
        y =i+1
print(N*2-y)

Submission status: Runtime Error

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

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

for i in range(n):
    match = True
    for j in range(n):
        if i + j < n:
            if s[i + j] != t[j]:
                match = False
    if match:
        if i == 0:
            print(n)
        else:
            print(n + i)
        break
else:
    print(len(n * 2))

Submission status: Runtime Error

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

for i in range(N):
    q = s[-(i+1):]
    r = t[:i+1]
    if q == r :
        x = q
        y =i+1
print(s[:N-y]+t)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
n=int(input())
s=[input() for i in range(n)]
t=[input() for j in range(n)]
s.reverse()
l=0
for k  in range(n):
    while s[k]==t[k]:
        l+=1
print(l)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
s = str(input())
t = str(input())
i = 0
while t.find(s[i,n])>-1:

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
m = 2 * N - 1

if 2 <= K < m:
    mid = list((3, 2, 1) if K == 2 else (K - 1, K, K + 1, K - 2))
    a = list(set(range(1, m + 1)) - set(mid))
    print("Yes\n" + "\n".join(map(str, a[:m//2 - 1] + mid + a[m//2 - 1:])))
else:
    print("No")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, x = map(int, input().split())
if x==1 or x==2*N-1:
    print('No')
else:
    print('Yes')
    if x <= 2*N:
        y = list(i for i in range(2, 2*N-2) if i!=x)
        l = len(y)//2
        print("\n".join(map(str, y[:l] + [2*N-1, x, 1, 2*N-2] + y[l:])))
    else:
        y = list(i for i in range(3, 2*N-1) if i!=x)
        l = len(y)//2
        print("\n".join(map(str, y[:l] + [2*N-1, 1, x, 2] + y[l:])))

Submission status: Runtime Error

Solution code:
N = input()

s = input()

t = input()

temp = 0
flag = True

while(temp < N-1 & flag):
    temps = s[N-temp-1:N-1]
    tempt = t[:temp]
    if(temps==tempt):
        temp += 1
    else:
        flag = False

print(N+N-temp)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
print("No" if K < N else "Yes\n" + "\n".join(map(str, range(1, K * 2))))

Submission status: Runtime Error

Solution code:
n, x = map(int, raw_input().split())

if x == n:
	print 'Yes'
	for i in range(1, 2 * n):
		print i
else:
	print 'No'

Submission status: Runtime Error

Solution code:
n, x = map(int, raw_input().split())

if x == n:
	print 'Yes':
	for i in xrange(1, 2 * n):
		print i
else:
	print 'No'

Submission status: Runtime Error

Solution code:
n, x = map(int, raw_input().split())

if x == n:
	print 'Yes':
	for i in range(1, 2 * n):
		print i
else:
	print 'No'

Submission status: Runtime Error

Solution code:
import sys

N = int(input())

a = input()
b = input()

for i in range(N):
	if(a[0:N-i] == b[i:N]){
		print(N+i)
		sys.exit()
		
print(2 * N)

Submission status: Runtime Error

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

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

if s == t:
    print(N)
else:
    print(2 * N - k)

Submission status: Runtime Error

Solution code:
import sys; sys.stdin = open('input.txt')

n = int(raw_input())

a = raw_input()
b = raw_input()

res = n

for i in xrange(n):
    if a.endswith(b[:n-i]):
        break
    res += 1

print res