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

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

print(ans - index)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, s: str, t: str):
    
    if s == t:
        print(N)
        exit()

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

        
    print(2*N)


    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    s = next(tokens)  # type: str
    t = next(tokens)  # type: str
    solve(N, s, t)

if __name__ == '__main__':
    main()

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

print(2 * n - cnt)

Submission status: Wrong Answer

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

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

print(2 * n - cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = input()
t = input()
w = s+t
cnt = 0
if s == t and N <= len(s):
  print(len(s))
  exit()
elif s == t and N > len(s):
  print(len(s+t))
  exit()
for i in range(len(s)):
  if s[-i-1] == t[i]:
    cnt += 1
while len(w) > N and cnt > 0:
  t = t[1:]
  w = s + t
  cnt -= 1
print(len(w))

Submission status: Wrong Answer

Solution code:
N = int(input())
s = input()
t = input()
w = s+t
cnt = 0
if s == t and N <= len(s):
  print(s)
  exit()
elif s == t and N > len(s):
  print(s+t)
  exit()
for i in range(len(s)):
  if s[-i-1] == t[i]:
    cnt += 1
while len(w) > N and cnt > 0:
  t = t[1:]
  w = s + t
  cnt -= 1
print(len(w))

Submission status: Wrong Answer

Solution code:
N = int(input())
s = input()
t = input()
w = s+t
cnt = 0
for i in range(len(s)):
  if s[-i-1] == t[i]:
    cnt += 1
while len(w) > N and cnt > 0:
  t = t[1:]
  w = s + t
  cnt -= 1
print(len(w))

Submission status: Wrong Answer

Solution code:
N = int(input())
s = input()
t = input()
w = s+t
cnt = 0
for i in range(len(s)):
  if s[-i-1] == t[i]:
    cnt += 1
while len(w) > N and cnt > 0:
  t = t[1:]
  w = s + t
  cnt -= 1
print(w)

Submission status: Wrong Answer

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

ans = 0

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

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

print(ans)

Submission status: Wrong Answer

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

ans = []
for i in range(N):
    ans.append(s[i])
    ans.append(t[i])

print(len(set(ans)))

Submission status: Wrong Answer

Solution code:
n = int(input())
s1 = input()
s2 = input()

if s1 == s2:
    print(n)
    exit()
cnt = 0
for i in range(n):
    if s1[-(i+1)] == s2[i]:
        cnt += 1
    else:
        break

print(len(s1 + s2[cnt:]))

Submission status: Wrong Answer

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

print(n * 2 - count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(N):
    if S[i] == T[cnt]:
        cnt += 1
    else:
        cnt = 0

print(2 * N - cnt)

Submission status: Wrong Answer

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

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

S = S[::-1]
cnt = 0
prefix_flg = True

for s,t in zip(S,T):
    if (s==t) and (prefix_flg):
        cnt += 1
    else:
        prefix_flg = False

print(len(S)+len(T)-cnt)

Submission status: Wrong Answer

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

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

T = T[::-1]
cnt = 0

for s,t in zip(S,T):
    if s==t:
        cnt += 1

print(len(S)+len(T)-cnt)

Submission status: Wrong Answer

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

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

T = T[::-1]
cnt = 0

for s,t in zip(S,T):
    if s==t:
        cnt += 1

print(len(S)+len(T)-cnt if len(S)+len(T)-cnt >= N else N)

Submission status: Wrong Answer

Solution code:
def solve(n, s, t):
    match = 0
    for i in range(n):
        if s[i] == t[0]:
            for j in range(n):
                if i+j >= n:
                    match = j
                    break
                elif s[i+j] != t[j]:
                    match = 0
                    break
            if match > 0:
                break
    print("{}".format(n*2-match))


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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if s == t:
    print(len(s))
else:
    number_overlaps = 0

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

Submission status: Wrong Answer

Solution code:
n=int(input())
s=list(input())
t=list(input())
cnt=0
cnt1=0
ans=[]
if t[0]==s[n-1]:
    for i in range(n):
        for j in range(n):
            if t[i]==s[n-1-j]:
                cnt+=1
            else:
                ans.append(cnt)
                cnt=0
                break
            if j==n-1:
                ans.append(cnt)
                cnt=0
                break
        #print(ans)
    for i in range(n):
        if ans[i]==0:
            cnt1=i
            break
    print(2*n-cnt1)
elif t==s:
    print(n)
else:
    print(2*n)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
s=list(input())
t=list(input())
ss=sorted(s,reverse=True)
f=0
for i in range(n):
    if ss[i]==t[i]:
        f+=1
    else:
        break
if s==t:
    print(n)
else:
    print(2*n-f)

Submission status: Wrong Answer

Solution code:
def inpl():
    return list(map(int, input().split()))


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

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

Submission status: Wrong Answer

Solution code:
def inpl():
    return list(map(int, input().split()))


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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
t=input()
if s==t:
    print(len(s))
    exit()
ans=s
g=True
for i in range(0,n):
    if s[i]==t[0]:
        flag=True
        for j in range(1,n-i):
            if not s[i+j]==t[0+j]:
                flag=False
        if flag:
            ans+=t[i-1:]
            g=False
            print(len(ans))
            exit()

if g:
    print(len(s+t))

Submission status: Wrong Answer

Solution code:

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

tmp=0
for i in range(N):
    #print(t[i])
    for j in range(N):
        if(s[j]==t[i]):
            #print(s[j],t[i])
            for k in range(N-1,j,-1):
                tmp=0
                if(s[k]!=t[k-j]):
                    print(s[k],t[k-j])
                    tmp=1
                    break
            if(tmp==0):
                print(N+j)
                #print(i,j,k)
                exit()
print(N*2)

Submission status: Wrong Answer

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

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

print(solve(n,s,t))

Submission status: Wrong Answer

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

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

print(N + d)

Submission status: Wrong Answer

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

M = [[0] * n for i in range(n)]

for i in range(n):
    M[i][0] = int(s[i] == t[0])

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

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
forth = [_ for _ in input()]
back = [_ for _ in input()]
if forth == back:
    print(len(forth))
    sys.exit()
re_back = reversed(back)
same_count = 0
for s, r in zip(forth, re_back):
    if s == r:
        same_count += 1
print(len(forth+back[same_count:]))

Submission status: Wrong Answer

Solution code:
n = int(input())

s = [i for i in input()]
t = [i for i in input()]

s.extend(t)

print(len(set(s)))

Submission status: Wrong Answer

Solution code:
n = int(input())

s = [i for i in input()]
t = [i for i in input()]

s.extend(t)

print(''.join(sorted(set(s), key=s.index)))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

cnt=N
for i in range(N):
  if S[i:]==T[:N-i]:
    cnt=N-i
    break
print(len(S)+len(T)-cnt)

Submission status: Wrong Answer

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

fin=1
for i in range(n):
    flag=1
    j=0
    while i+j<n:
        if t[j]!=s[i+j]:
            flag=0
        j=j+1
    if flag:
        print(n-i+i*2)
        fin=0
if fin:
    print(2*n)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    s = list(input())
    t = list(input())
    if s == t:
        print(n)
        exit()
    k = 0
    for i in range(n):
        if s[-i - 1] == t[i]:
            k += 1
        else:
            break
    print(max(n,n*2 - k))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    s = list(input())
    t = list(input())
    if s == t:
        print(n)
        exit()
    k = 0
    for i in range(n):
        if s[-i - 1] == t[i]:
            k += 1
        else:
            break
    print(min(n,n*2 - k))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
T=input()
for i in range(N+1):
  s = S+T[::-1][i:][::-1]
  if s[-N:]==T: print(N+i);break

Submission status: Wrong Answer

Solution code:
n=int(input())
s=list(input())
t=list(input())
s.reverse() 
s_bottom=[]
t_head=[]
b=0
for i in range(n):
	s_bottom.append(s[i])
	t_head.append(t[i])
	s_bottom.reverse()
	if s_bottom!=t_head:
		s_bottom.reverse()
		continue
	else:
		print(n*2-len(t_head))
		exit()
print(n*2)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

print(2*N-c)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    s = str(input().rstrip('\n'))
    t = str(input().rstrip('\n'))
    a = len(s) + len(t)
    for i in range(n):
        if s[-i-1:] == t[:i+1]:
            a = len(s[:-i-1]) + len(s[-i-i:i+1]) + len(t[i+1:])
    print(a)


if __name__ == '__main__':
    slove()

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

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

Submission status: Wrong Answer

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

def main():
    N = int(input())
    s = input().strip()
    t = input().strip()

    match = True
    for i in range(N):
        if s[i] != t[i]:
            match = False
            break
    if match:
        print(N)
    else:
        count = 0
        for i in range(N):
            if s[N-1-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 = set(input()+input())
print(len(s))

Submission status: Wrong Answer

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

s = list(s)
t = list(t)

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

print(len(s))

Submission status: Wrong Answer

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

s = list(s)
t = list(t)

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

print(s)
print(len(s))

Submission status: Wrong Answer

Solution code:
I=input;n,a,b=int(I()),I(),I();print(-min(-(a[i:]==b[:n-i])*(n+i)for i in range(n))or 2*n)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

N = int(input())
s, t = input(), input()
cnt = 0
max_cnt = 0

for i in range(len(s)):
    for j in range(len(t) - i):
        if s[i+j] == t[j]:
            cnt += 1
        else:
            break
    if max_cnt < cnt:
        max_cnt = cnt
print(len(s) + len(t) - max_cnt)

Submission status: Wrong Answer

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(n+n-count)

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]+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):
    print(s[i:], t[:N-i])
    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()

comb = s+t
comb = list(comb)

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

    while (True):
        left = n-1
        right = n
        if comb[left] == comb[right]:
            comb[left]=""
            left-=1
            right+=1
        else:
            break

    print(len("".join(comb)))

Submission status: Wrong Answer

Solution code:


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

comb = s+t
comb = list(comb)

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

    while (True):
        left = n-1
        right = n
        if comb[left] == comb[right]:
            comb[left]=""
            left-=1
            right+=1
        else:
            break

    print("".join(comb))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
a = int(input())
b = input()
c = input()
e = -1
for i in range(a):
    if b[-i-1:] == c[:i+1]:
        e = max(e,i)
if e == -1:
    print(b + c)
else:
    print(len(b + c[e+1:]))

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
t=input()
ans=len(s)+len(t)

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

Submission status: Wrong Answer

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

p = 2*N
for i in range(N):
    if S[i:] == T[:N-i] and i < p:
        p = i + N

print(p)

Submission status: Wrong Answer

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

res = ""
for c in s:
    if c not in t:
        res += c
res += t
print(len(res))

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

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
print(len(s+t)-count)

Submission status: Wrong Answer

Solution code:
N=int(input())
s=input()
t=input()
ans=N*2
for i in range(0,N):
    for j in range(0,N):
        if N-i+N-j >= N:
            ST=s[0:N-i]+t[j:N]
            if ST[0:N]==s and ST[-N:]==t:
                ans=min(len(ST),ans)
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
s=input()
t=input()
ans=N*2
for i in range(0,N):
    for j in range(0,N):
        if N-i+N-j >= N:
            ST=s[0:N-i]+t[j:N]
            if ST[0:N]==s and ST[-N]==t:
                ans=min(len(ST),ans)
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
s=input()
t=input()
ans=N
for i in range(0,N):
    for j in range(0,N):
        if N-i+N-j >= N:
            ST=s[0:N-i]+t[j:N]
            if ST[0:N]==s and ST[-N]:
                ans=min(len(ST),ans)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

tmp = s + t
for i in range(N):
    if s[i:] == t[:N-i]:
        tmp = s + t[i-1:]
        if len(tmp) < N:
            continue
print(len(tmp))

Submission status: Wrong Answer

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

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

tmp = s+t
while len(tmp) >= N:
    if s[-1] != t[0]:
        break
    s = s[:-1]
    tmp = s + t
print(len(tmp))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if s == t:
    print(N)
    exit()
    
s = s[::-1]

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

Submission status: Wrong Answer

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

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

print(s + t)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
t=input()
ans=""
for i in range(n+1):
    s1=s[:n-i]
    s2=s[n-i:]
    t1=t[:i]
    t2=t[i:]
    if s2==t1:
        ans=s1+s2+t2
print(ans)

Submission status: Wrong Answer

Solution code:
N,S,T=(input() for i in range(3))
N=int(N)
for k in range(N,-1,-1):#k文字共通
    if all([S[N-k+i]==T[i] for i in range(k)]) or k==0:
        print(S+T[k:])
        break

Submission status: Wrong Answer

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

print(N*2-i+1)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
s = (stdin.readline().rstrip())
t = (stdin.readline().rstrip())
ans = len(s) + len(t)
for i,j in zip(list(t),reversed(list(s))):
    if i == j:
        ans -= 1
if s == t:
   ans = len(s)
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())
ans = len(s) + len(t)
for i,j in zip(list(t),reversed(list(s))):
    if i == j:
        ans -= 1
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

word = s + t

while s[:-1] == word[0] and len(s) + len(t) > N:
        tmp = s[-1]
        s = s[:(len(s)) - 1]
        t = t[1:]
        word = s + tmp + t

print(len(word))

Submission status: Wrong Answer

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

word = s + t

while word[len(s) - 1] == word[len(s)] and len(s) + len(t) > N:
        tmp = s[-1]
        s = s[:(len(s)) - 1]
        t = t[1:]
        word = s + tmp + t

print(len(word))

Submission status: Wrong Answer

Solution code:
import sys
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 len(s) + len(t) >= N:
        tmp = s[-1]
        s = s[:(len(s)) - 1]
        t = t[1:]
        word = s + tmp + t

print(len(word))

Submission status: Wrong Answer

Solution code:
import sys
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 len(s) + len(t) >= N:
        s = s[:N - 1]
        word = s + t

print(len(word))

Submission status: Wrong Answer

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

word = s + t

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

letter_dict = {}

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

Submission status: Wrong Answer

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

ans = ""
for i in range(n, 0, -1):
    if (s[n-i:] == t[:i]):
        ans = s[:n-i] + t[:i] + t[i:]
        break
    
print(len(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 + i)
    break

Submission status: Wrong Answer

Solution code:
n = int(input())
prefix = set(list(input()))
suffix = set(list(input()))
final = prefix.union(suffix)
print(len(final))

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
t=input()
flg=False
for i in range(n):
    if s[i:]==t[:n-i]:
        print(len(s[:i]+t))
        flg=True
if flg:
    0
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[:n-i]:
        print(len(s[:i]+t))

Submission status: Wrong Answer

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

n = N
while 0 <= n:
    a = s[-(n+1):]
    b = t[0:n+1]
    if a == b:
        print(s+t[n+1:])
        exit()
    n -= 1

print(s+t)
exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
l=input()
x=0
ls,ll=len(s),len(l)
for i in range(1,min(ls,ll)):
    if s[-i:]==l[:i]:x=i
print(max(n,ls+ll-x))

Submission status: Wrong Answer

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

for i in range(N):
	if S[i:] == T[:-i]:
		#print(S[:i] + T)
		print(len(S[:i] + T))
		break
else:
	#print(S + T)
	print(len(S + T))

Submission status: Wrong Answer

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

for i in range(N):
	if S[i:] == T[-i - 1]:
		#print(S[:i] + T)
		print(len(S[:i] + T))
		break
else:
	#print(S + T)
	print(len(S + T))

Submission status: Wrong Answer

Solution code:
N = input()
S = input()
T = input()
if S==T:
    print(len(S))
else:
    count = 0
    for i,(n,t) in enumerate(zip(reversed(S),T)):
        if n!=t:
            count=i
            break
    print(len(S[:count+1]+T[count:])+count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def solve():
    N = int(input())
    S, T = [input() for _ in range(2)]

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

    return (N + i)

print(solve())

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(input())
t = list(input())
s_rev = list(reversed(s))
a = []
for i in range(n):
    if s_rev[i] == t[i]:
        a.append(s_rev[i])
    else:
        break
ans = len(s) + len(t) - len(a)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
s = input()
t = input()
ans = set()
for i in s:
    ans.add(i)
    for j in t:
        ans.add(j)
    
print(len(ans))

Submission status: Wrong Answer

Solution code:
n,s,t=open(0);n=int(n);print(2*n-max(i*(s[-i:-1]==t[:i])for i in range(n+1)))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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