Problem:


Score : 200 points

Problem Statement

You are given three strings A, B and C. Each of these is a string of length N consisting of lowercase English letters.

Our objective is to make all these three strings equal. For that, you can repeatedly perform the following operation:

Operation: Choose one of the strings A, B and C, and specify an integer i between 1 and N (inclusive). Change the i-th character from the beginning of the chosen string to some other lowercase English letter.

What is the minimum number of operations required to achieve the objective?

Constraints

1 \leq N \leq 100

Each of the strings A, B and C is a string of length N.

Each character in each of the strings A, B and C is a lowercase English letter.

Input

Input is given from Standard Input in the following format:

N
A
B
C

Output

Print the minimum number of operations required.

Sample Input 1

4
west
east
wait

Sample Output 1

3

In this sample, initially A = west、B = east、C = wait. We can achieve the objective in the minimum number of operations by performing three operations as follows:

Change the second character in A to a. A is now wast.

Change the first character in B to w. B is now wast.

Change the third character in C to s. C is now wast.

Sample Input 2

9
different
different
different

Sample Output 2

0

If A, B and C are already equal in the beginning, the number of operations required is 0.

Sample Input 3

7
zenkoku
touitsu
program

Sample Output 3

13



Sample input:
4
west
east
wait


Sample output:
3

Submission status: Accepted

Solution code:
n = int(input())
a = input()
b = input()
c = input()

num = 0
for i in range(n):
  if a[i] != b[i] != c[i] and a[i] != c[i]:
    num = num+2
  elif a[i] == b[i] and b[i] != c[i]:
    num = num+1
  elif b[i] == c[i] and b[i] != a[i]:
    num = num+1
  elif a[i] == c[i] and a[i] != b[i]:
    num = num + 1

print(num)

Submission status: Accepted

Solution code:
n=int(input())

a=input()
b=input()
c=input()

count=0
for i in range(n):
    if(a[i]==b[i] and b[i]==c[i]):
        continue
    elif(a[i]==b[i] and b[i]!=c[i]):
        count+=1
    elif(a[i]!=b[i] and b[i]==c[i]):
        count+=1
    elif(a[i]==c[i] and b[i]!=c[i]):
        count+=1
    elif(a[i]!=b[i] and c[i]!=b[i]):
        count+=2

print(count)

Submission status: Accepted

Solution code:
n = int(input())
a = input()
b = input()
c = input()
x = 0
for i in range(n):
	if a[i]==b[i]==c[i]: pass
	elif a[i]==b[i] or b[i]==c[i] or c[i]==a[i]: x+=1
	else: x+=2
print(x)

Submission status: Accepted

Solution code:
#!/mnt/c/Users/moiki/bash/env/bin/python
N = int(input())
A = input()
B = input()
C = input()

ans = 0
for i in range(N):
    len_diff = len(set([A[i], B[i], C[i]]))
    if len_diff == 3:
        ans += 2
    elif len_diff == 2:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
n=int(input())
a=input()
b=input()
c=input()
i=0
ans=""
while i<len(a):
  tmp=[]
  tmp.append(a[i])
  tmp.append(b[i])
  tmp.append(c[i])
  tmp=Counter(tmp)
  ans+=tmp.most_common()[0][0]
  i+=1
diff=0
i=0
while i<len(a):
  if a[i]!=ans[i]:
    diff+=1
  if b[i]!=ans[i]:
    diff+=1
  if c[i]!=ans[i]:
    diff+=1
  i+=1
print(diff)

Submission status: Accepted

Solution code:
N = int(input())

A = [a for a in input()]

B = [b for b in input()]

C = [c for c in input()]

count = 0

for i in range(N):
	if ( A[i] == B[i] and A[i] != C[i] ) \
	or ( B[i] == C[i] and B[i] != A[i] ) \
	or ( C[i] == A[i] and C[i] != B[i] ):
		count += 1
	if  A[i] != B[i] \
	and B[i] != C[i] \
	and C[i] != A[i]:
		count += 2

print(count)

Submission status: Accepted

Solution code:
input()
a,b,c = [input() for i in range(3)]
sum=0
for i in range(len(a)):
    sum += len(set([a[i],b[i],c[i]])) - 1
print(sum)

Submission status: Accepted

Solution code:
input()
a,b,c=[input() for i in range(3)]

cnt=0
for a_,b_,c_ in zip(a,b,c):
    cnt += len(list({a_,b_,c_}))-1
    
print(cnt)

Submission status: Accepted

Solution code:
import numpy as np

N=int(input())
A=input()
B=input()
C=input()

S=set()
ans=0

for i in range(N):
    S.add(A[i])
    S.add(B[i])
    S.add(C[i])
    ans+=len(S)-1
    S.clear()
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = input()
b = input()
c = input()
ans = 0
for i in range(n):
    if a[i] == b[i] and b[i] == c[i]:
        pass
    elif a[i] == b[i] or b[i] == c[i] or c[i] == a[i]:
        ans += 1
    else:
        ans += 2
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
a=input()
b=input()
c=input()
def d(i):
    x=a[i]
    y=b[i]
    z=c[i]
    if x==y and y==z:
        return 0
    elif x==y or y==z or z==x:
        return 1
    else:
        return 2
r=0
for i in range(n):
    r += d(i)

print(r)

Submission status: Accepted

Solution code:
line = int(input())
a = list(input())
b = list(input())
c = list(input())
count = 0
for i in range(line):
    list =[]
    list.append(a[i])
    list.append(b[i])
    list.append(c[i])
    a_w = list.count(list[0])
    b_w = list.count(list[1])
    if a_w + b_w == 2:
        count+=2
    elif a_w + b_w == 3:
        count+=1
    elif a_w + b_w == 4:
        count+=1
print(count)

Submission status: Accepted

Solution code:
n = int(input())
words = []
for i in range(3):
  words.append(input())
w_T = [x for x in zip(*words)]
count = 0
for w in w_T:
  count += len(set(w))
print(count-n)

Submission status: Accepted

Solution code:
n= int(input())

a=  input()
b = input()
c = input()

totalcount=0
for i in range(n):
    count=2
    if a[i] == b[i]:
        count=1
        if  b[i]==c[i]:
            count=0
    elif a[i] == c[i]:
        count=1
    elif b[i]==c[i]:
        count=1
    totalcount+=count
print(totalcount)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    A = input()
    B = input()
    C = input()
    count = 0
    for i in range(n):
        a = A[i]
        b = B[i]
        c = C[i]
        if a == b == c:
            continue
        elif a == b or b == c or c == a:
            count += 1
        else:
            count += 2
    print(count)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
a,b,c = input(),input(),input()

ans = 0
for i in range(n):
  cnt = len(set([a[i],b[i],c[i]]))-1
  ans += cnt

print(ans)

Submission status: Accepted

Solution code:
N =int(input())
A,B,C =[input()for i in range(3)]
def check(a,b,c):
    n1 =[a,b,c].count(a)
    n2 =[a,b,c].count(b)
    n3 =[a,b,c].count(c)
    n =max(n1,n2,n3)
    return 3-n
ans = 0
for i in range(N):
    ans += check(A[i],B[i],C[i])
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = input()
b = input()
c = input()
count = 0

for i in range(n):
    if a[i] != b[i]:
        count += 1
    if b[i] != c[i]:
        if a[i] != c[i]:
            count += 1
print(count)

Submission status: Accepted

Solution code:
n = int(input())
a = input()
b = input()
c = input()

count = 0

for i in range(n):
    if a[i] != b[i] and b[i] != c[i] and c[i] != a[i]:
        count = count + 2
    elif a[i] == b[i] and b[i] == c[i]:
        count = count
    else:
        count = count + 1

print(count)

Submission status: Accepted

Solution code:
N=int(input())
A=input()
B=input()
C=input()
iC = 0
for i in range(N):
    a = A[i]
    b = B[i]
    c = C[i]
    if a != b and b != c and c != a :
        iC += 2
    elif a != b or b != c or c != a :
        iC += 1
print(iC)

Submission status: Accepted

Solution code:
N=int(input())
S=[input() for _ in range(3)]
ans=0
for a,b,c in zip(*S):
    same=0
    if a==b:same+=1
    if a==c:same+=1
    if b==c:same+=1
    ans+=max(2-same,0)
print(ans)

Submission status: Accepted

Solution code:
import math
import sys

# N, K = map(int, input().split())
# h = list(map(int, input().split()))

N = int(input())
A = str(input())
B = str(input())
C = str(input())

ans = 0
for i in range(N):
	if (A[i] != B[i] and B[i] != C[i] and A[i] != C[i]):
		ans += 2
	elif (A[i] != B[i] or B[i] != C[i] or A[i] != C[i]):
		ans += 1

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a,b,c = input(),input(),input()

count = 0
for i in range(n):
    count += len(set([a[i],b[i],c[i]]))-1
print(count)

Submission status: Accepted

Solution code:
def main():
    raw = []
    for i in range(4):
        raw.append(input())

    n = int(raw[0])
    a = raw[1]
    b = raw[2]
    c = raw[3]

    difference = [0] * n
    for i in range(n):
        n = {a[i], b[i], c[i]}
        difference[i] = len(n) - 1

    print(sum(difference))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n=int(input())
a=input()
b=input()
c=input()

ret = 0
for i in range(n):
    if a[i] == b[i] == c[i]:
        continue
    if a[i] == b[i] or b[i] == c[i] or a[i] == c[i] :
        ret += 1
    else:
        ret += 2

print(ret)

Submission status: Accepted

Solution code:
N = int(input())
A = input()
B = input()
C = input()

ans = 0
for i in range(N):
    if A[i]==B[i]==C[i]:
        continue
    elif A[i]==B[i] or B[i]==C[i] or C[i]==A[i]:
        ans += 1
    else:
        ans += 2

print(ans)

Submission status: Accepted

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

n = int(input())
a = input()
b = input()
c = input()

d = [{} for i in range(n)]

for i in range(n):
    for s in [a,b,c]:
        if s[i] in d[i]:
            d[i][s[i]] += 1
        else:
            d[i][s[i]] = 1

count = 0
for subd in d:
    if len(d) > 1:
        count += 3 - max(subd.values())

print(count)

Submission status: Accepted

Solution code:
n = int(input())
a = input()
b = input()
c = input()

res = 0
for i in range(n):
    res += len(set([a[i], b[i], c[i]])) -1 if len(set([a[i], b[i], c[i]])) != 1 else 0

print(res)

Submission status: Accepted

Solution code:
# _*_ coding:utf-8 _*_
#  Atcoder_nikkeitouitu_Contest-B
#  TODO https://atcoder.jp/contests/nikkei2019-qual/tasks/nikkei2019_qual_b
from collections import Counter

def solveProblem(strLength,strA,strB,strC):
	# 1文字目を見る→文字数をカウントする→最も多い文字が決まる→それ以外の文字を直す→n文字繰り返し
	answer = 0
	for i in range(0,strLength,+1):
		charList = [strA[i],strB[i],strC[i]]
		constructSet = set(charList) # 3つの文字の内重複しない文字の集合を出す
		constLen = len(constructSet)-1 # 集合の長さを求める＋ある一つの文字を指定して残りの文字を書き換えるため-1
		answer = answer+constLen
	return answer

if __name__ == '__main__':
	N = int(input().strip())
	A = str(input().strip())
	B =  str(input().strip())
	C = str(input().strip())
	solution = solveProblem(N,A,B,C)
	print("{}".format(solution))

Submission status: Accepted

Solution code:
I = int(input())
A = input()
B = input()
C = input()

count = 0
for i in range(I):
  if not (A[i]==B[i]==C[i]):
    count += 1 if A[i]==B[i] or B[i]== C[i] or A[i]==C[i] else 2

print(count)

Submission status: Accepted

Solution code:
N = int(input())
A = list(input())
B = list(input())
C = list(input())
cnt = 0

for i in range(N):
  if A[i] == B[i] == C[i]:
    cnt += 0
  elif A[i] == B[i] or B[i] == C[i] or C[i] == A[i]:
    cnt += 1
  else:
    cnt += 2

print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
A = input()
B = input()
C = input()

count=0

for (a, b, c) in zip(A, B, C):
    s={a, b, c}
    count+=len(s)-1

print(count)

Submission status: Accepted

Solution code:
N = int(input())
A = input()
B = input()
C = input()
 
 
def cal_chenge_num(a, b, c):
    if a==b:
        if a==c:
            return 0
        else:
            return 1
    else:
        if a==c or b==c:
            return 1
        else:
            return 2
 
num = 0
for i in range(N):
    num += cal_chenge_num(A[i], B[i], C[i])
print(num)

Submission status: Accepted

Solution code:
N = int(input())
A, B, C = input(), input(), input()

ans = 0
for i in range(N):
    abc = A[i], B[i], C[i]
    ans += len(set(abc)) - 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A, B, C = input(), input(), input()

ans = 0
for i in range(N):
    a, b, c = A[i], B[i], C[i]
    ans += len(set(tuple((a, b, c)))) - 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = input()
b = input()
c = input()
count = 0 
for i in range(n):
    if a[i] == b[i]:
        if b[i] != c[i]:
            count += 1
    else:
        if a[i] == c[i] or b[i] == c[i]:
            count += 1
        else:
            count += 2
print(count)

Submission status: Accepted

Solution code:
n,a,b,c = int(input()),input(),input(),input()
ans = 0
for i in range(n):
    al = set()
    al.add(a[i])
    al.add(b[i])
    al.add(c[i])
    ans += len(al)-1
print(ans)

Submission status: Accepted

Solution code:
import sys
import collections


def r(n, a, b, c):

    cnt = 0
    for i in range(len(a)):
        cn = collections.Counter([a[i], b[i], c[i]])
        cc = [k for k, v in cn.items() if v == 1]
        if len(cc) == 3:
            cnt += len(cc) - 1
        else:
            cnt += len(cc)

    return cnt

def main():
    input = sys.stdin.readline
    n = int(input())
    a = input()
    b = input()
    c = input()

    print(r(n, a, b, c))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
a=list(input())
b=list(input())
c=list(input())

ans=0

for i in range(n):

    s=[a[i],b[i],c[i]]
    buff=set(s)
    ans += len(buff)-1

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A, B, C = map(list, ([input(), input(), input()]))
cnt = 0
for i in range(N):
  a = 0
  if A[i] == B[i]:
    a += 1
  if B[i] == C[i]:
    a += 1
  if C[i] == A[i]:
    a += 1
  if a == 0:
    cnt += 2
  elif a == 1:
    cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
n, a, b, c = int(input()), input(), input(), input()
letters = dict()

count = 0
for i in range(n):
    letters[i] = {a[i], b[i], c[i]}
    count += len(letters[i]) - 1

print(count)

Submission status: Accepted

Solution code:
N = int(input())
A = list(input())
B = list(input())
C = list(input())
cnt = 0
for i in range(N):
    l = [A[i], B[i], C[i]]
    
    s = set(l)
    c = [l.count(s_) for s_ in s]
    cnt += 3- max(c)
print(cnt)

Submission status: Accepted

Solution code:
n=int(input())
a=input()
b=input()
c=input()
ans=0
for i in range(n):
    if a[i] != b[i] and b[i] != c[i] and c[i] != a[i]:
        ans += 2
    elif a[i] != b[i] or b[i]!=c[i] or c[i]!=a[i]:
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
def main(n,a,b,c):
    cnt=0
    for i in range(n):
        if a[i]==b[i]==c[i]:
            pass
        elif a[i]!=b[i] and b[i]!=c[i] and a[i]!=c[i]:
            cnt+=2
        else:
            cnt+=1
    return cnt
print(main(int(input()),[i for i in input()],[i for i in input()],[i for i in input()]))

Submission status: Accepted

Solution code:
N = int(input())
A = input()
B = input()
C = input()
count = 0
for i in range(N):
	
	if A[i] != B[i]:
		count+=1
		if A[i] != C[i] and B[i] != C[i]:
			count+=1

	elif A[i] != C[i]:
		count+=1

print(count)

Submission status: Accepted

Solution code:
n = int(input())
a = list(input())
b = list(input())
c = list(input())
ans = 0
for i in range(n):
    k = [a[i], b[i], c[i]]
    ans += len(set(k))-1

print(ans)

Submission status: Accepted

Solution code:
# coding:utf-8

import sys
# from collections import Counter, defaultdict

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

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


n = II()
src = [SI() for _ in range(3)]

ans = 0
for abc in zip(*src):
    ans += len(set(abc)) - 1

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = input()
B = input()
C = input()
ans = 0
for i in range(N):
    s = list(set([A[i],B[i],C[i]]))
    ans += len(s) - 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
a = [set() for i in range(N)]

for i in range(3):
  x = input()
  for j in range(N):
    a[j].add(x[j])

res = 0
for s in a:
  res += len(s) - 1

print(res)

Submission status: Accepted

Solution code:
input()
print(sum(len(set(_)) - 1 for _ in zip(*(input() for _ in range(3)))))

Submission status: Accepted

Solution code:
input()
print(sum(len(set(_)) - 1 for _ in zip(*[list(input()) for _ in range(3)])))

Submission status: Accepted

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


def main():
    n = int(input())
    a = input()
    b = input()
    c = input()
    ans = 0

    for i in range(n):
        s = set()
        s.add(a[i])
        s.add(b[i])
        s.add(c[i])

        if len(s) == 2:
            ans += 1
        elif len(s) == 3:
            ans += 2

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
a, b, c = input(), input(), input()
ans = 0
for i in range(n):
    ans += len(set([a[i], b[i], c[i]])) - 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a, b, c = input(), input(), input()
ans = 0
for i in range(n):
    if a[i] == b[i] and b[i] == c[i]:
        continue
    if a[i] == b[i] or b[i] == c[i] or c[i] == a[i]:
        ans += 1
    else:
        ans += 2
print(ans)

Submission status: Accepted

Solution code:
I=input;I();print(sum(len(set(s))-1for s in zip(I(),I(),I())))

Submission status: Accepted

Solution code:
n=int(input())
a,b,c=input(),input(),input()
ct=0
for i in range(n):
  if a[i]==b[i]==c[i]:ct+=0
  elif a[i]==b[i] or b[i]==c[i] or c[i]==a[i]:ct+=1
  else:ct+=2
print(ct)

Submission status: Accepted

Solution code:
n = int(input())
a = input()
b = input()
c = input()
ans = 0
for i,j,k in zip(a,b,c):
        if i == k and k == j:
                continue
        elif i == j or j== k or i == k:
                ans += 1
        else:
                ans+=2
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
p = input()
q = input()
r = input()
res = 0
for (a,b,c) in zip(p,q,r):
    if a == b == c:
        pass
    elif a == b or b == c or c == a:
        res += 1
    elif a != b and b != c and c != a:
        res += 2
    # print(res)
print(res)

Submission status: Accepted

Solution code:
N = int(input())
A = input()
B = input()
C = input()

count = 0
for i in range(N):
    if A[i] == B[i] == C[i]:
        pass
    elif A[i] == B[i] or B[i] == C[i] or C[i] == A[i]:
        count += 1
    else:
        count += 2

print(count)

Submission status: Accepted

Solution code:
n = int(input())
lst = [input() for i in range(3)]

cnt = 0

for i in range(n):
    a = lst[0][i]
    b = lst[1][i]
    c = lst[2][i]

    if a == b and b == c:
        pass
    elif a == b or b == c or c == a:
        cnt += 1
    else:
        cnt += 2

print(cnt)

Submission status: Accepted

Solution code:
n=int(input())
a,b,c=input(),input(),input()
ans=0
for i in range(n):
    if a[i]==b[i]==c[i]:
        continue
    if a[i]==b[i] or b[i]==c[i] or c[i]==a[i]:
        ans+=1
    else:
        ans+=2
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = list(input())
b = list(input())
c = list(input())

ans = 0
for x, y, z in zip(a, b, c):
    ans += len(set((x, y, z))) - 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = input()
b = input()
c = input()

changeCount = 0
for i in range(n):
    if a[i] == b[i] == c[i]:
      continue  
    elif (a[i] != b[i]) and (a[i] != c[i]) and (b[i] != c[i]):
        changeCount += 2
    else:
        changeCount += 1

print(changeCount)

Submission status: Accepted

Solution code:
N = int(input())
a, b, c = input(), input(), input()

ans = 0
for i in range(N):
    ans += len(set([a[i], b[i], c[i]])) - 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = input()
b = input()
c = input()


counter=0
for i in range(n):
    if (len(set((a[i], b[i], c[i]))) == 3):
        counter+=2
    elif(len(set((a[i], b[i], c[i]))) == 2):
        counter+=1
    else:
        counter+=0

print(counter)

Submission status: Accepted

Solution code:
n = int(input())

a = input()
b = input()
c = input()

ans = 0

for count in range(n):
    tmp = 0
    if a[count] == b[count]:
        if a[count] != c[count]:
            tmp += 1
    else:
        tmp += 1
        if (a[count] != c[count]) & (b[count] != c[count]):
            tmp += 1
    ans += tmp
    
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
ans=0
for a,b,c in zip(input(),input(),input()):ans+=len(set([a,b,c]))-1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = list(input())
B = list(input())
C = list(input())
score = 0

#val_arrayを作成
val_array = [{} for _ in range(N)]
for i in range(N):
    val_array[i][A[i]] = 0
    val_array[i][B[i]] = 0
    val_array[i][C[i]] = 0

#val_arrayに値を格納
for i in range(N):
    val_array[i][A[i]] += 1
    val_array[i][B[i]] += 1
    val_array[i][C[i]] += 1

#i文字目の候補の内,一番valueが大きいものを取り出し，3との差を取って評価値とする
for i in range(N):
    score += 3 - max(val_array[i].values())

print(score)

Submission status: Accepted

Solution code:
# coding: utf-8

import sys

lines = sys.stdin.readlines()

n,a,b,c = lines
n = int(n.strip('\n'))
a = str(a.strip('\n'))
b = str(b.strip('\n'))
c = str(c.strip('\n'))

num = 0
if not(n == a == b == c):
  for i in range(n):
    if not(a[i] == b[i] == c[i]):
      if a[i] == b[i] or b[i] == c[i] or c[i] == a[i]:
        num = num+1
      else:
        num = num+2

print(num)       

sys.exit(0)

Submission status: Accepted

Solution code:
from sys import stdin

a = []
for line in stdin:
    a.append(line.rstrip())

N, A, B, C = a


def split(X):
    arr = []
    for i in X:
        arr.append(i)
    return arr


def diff(X, Y, Z):
    sum = 0
    for i in range(0, int(N)):
        if(X[i] != Y[i] and X[i] != Z[i] and Y[i] != Z[i]):
            sum += 2
        elif(X[i] == Y[i] and X[i] == Z[i] and Y[i] == Z[i]):
            next
        elif(X[i] == Y[i] or X[i] == Z[i] or Y[i] == Z[i]):
            sum += 1
    return sum


spA = split(A)
spB = split(B)
spC = split(C)

diffSum = diff(A, B, C)

print(diffSum)

Submission status: Accepted

Solution code:
N = int(input())
A = input()
listA = list(A)
B = input()
listB = list(B)
C = input()
listC = list(C)
count = 0
for i in range(N):
    if listA[i] != listB[i] and listB[i] != listC[i] and listC[i] != listA[i]:
        count += 2
    elif listA[i] == listB[i] and listB[i] != listC[i]:
        count += 1
    elif listB[i] == listC[i] and listC[i] != listA[i]:
        count += 1
    elif listA[i] == listC[i] and listA[i] != listB[i]:
        count += 1
    elif listA[i] == listB[i] and listB[i] == listC[i] and listC[i] == listA[i]:
        count += 0
print(count)

Submission status: Accepted

Solution code:
import bisect
import sys

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def solve():
    N = ii()
    A = ii(str)
    B = ii(str)
    C = ii(str)
    ans = 0
    for i in range(N):
        t = A[i] != B[i]
        t += B[i] != C[i]
        t += C[i] != A[i]
        ans += max(t - 1, 0)
    return ans


if __name__ == "__main__":
    print(solve())

Submission status: Accepted

Solution code:
n = int(input())
a = input()
b = input()
c = input()

x = 0
for i in range(n):
    if a[i] == b[i] and b[i] == c[i]:
        continue
    if a[i] == b[i] or b[i] == c[i] or c[i] == a[i]:
        x = x + 1
    else:
        x = x + 2

print(x)

Submission status: Accepted

Solution code:
n=int(input())
a=str(input())
b=str(input())
c=str(input())
ans=0

for i in range(n):
  se = set([a[i],b[i],c[i]])
  ans=ans+len(se)-1

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = input()
B = input()
C = input()
target_list = []
for a, b, c in zip(A, B, C):
    if a==b and b==c and c==a:
        target_list.append(3)
    elif a==b or b==c or c==a: 
        target_list.append(2)
    else:
        target_list.append(1)
print(N*3 - sum(target_list))

Submission status: Accepted

Solution code:
N = int(input())
A = input()
B = input()
C = input()
ans = 0
for i in range(N):
  str = (A[i:i+1]+B[i:i+1]+C[i:i+1])
  ans += (len(set(str)) -1)
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = str(input())
B = str(input())
C = str(input())

ans = []
for i in range(N):
     L = [A[i],B[i],C[i]]
     if len(set(L)) == 2:
            ans.append(1)
     elif len(set(L)) == 3:
            ans.append(2)
     else:
            ans.append(0)
print(sum(ans))

Submission status: Accepted

Solution code:
N = input()
word = [["x"],["x"],["x"]]
for i in range(3):
    inp = input()
    word[i] = list(inp)

X = 0
for i in range(int(N)):
    _count = 0
    for j in range(2):
        for k in range(j+1,3):
            if word[j][i] == word[k][i]:
                _count += 1
    if _count == 1:
        count = 1
    elif _count == 0:
        count = 2
    else:
    	count = 0
    X += count



print (X)

Submission status: Accepted

Solution code:
n = input()
a = input()
b = input()
c = input()

la = list(a)
lb = list(b)
lc = list(c)

total = 0
for i in range(int(n)):
    count = 0
    if la[i] != lb[i]:
        count += 1
    if la[i] != lc[i]:
        count += 1
    if lb[i] != lc[i]:
        count += 1

    if count == 3:
        total += 2
    elif count == 2:
        total += 1
    elif count == 1:
        total += 1
    else:
        total += 0

print(total)

Submission status: Accepted

Solution code:
N = int(input())
A = input()
B = input()
C = input()

count = 0

for i in range(N) :
    if A[i] == B[i] and C[i] != A[i] :
        count = count + 1
    elif A[i] == C[i] and B[i] != C[i] :
        count = count + 1
    elif B[i] == C[i] and C[i] != A[i]:
        count = count + 1
    elif A[i] != B[i] and B[i] != C[i] and C[i] != A[i] :
        count = count + 2

print(count)

Submission status: Accepted

Solution code:
n=int(input())
a=input()
b=input()
c=input()
count=0
for i in range(n):
    if a[i]==b[i] and b[i]==c[i]:
        continue
    elif a[i]==b[i] or c[i]==b[i] or a[i]==c[i]:
        count += 1
    else:
        count += 2
print(count)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
 
import sys
import math

n = int(input())

s = []

for i in range(3):
    s.append(input())

num = 0
for i in range(n):
    if s[0][i] == s[1][i] == s[2][i]:
        num = num
    elif s[0][i] == s[1][i]:
        num += 1
    elif s[0][i] == s[2][i]:
        num += 1
    elif s[1][i] == s[2][i]:
        num += 1
    else:
        num += 2


print(num)

Submission status: Accepted

Solution code:
n = int(input())
a = input()
b = input()
c = input()

t = n * 2;

for i in range(n):
    if a[i] == b[i] : t -= 1
    if b[i] == c[i] : t -= 1
    if c[i] == a[i] : t -= 1
    
    if a[i] == b[i] and b[i] == c[i] and c[i] == a[i] : t += 1
    
print(t)

Submission status: Accepted

Solution code:
N = int(input())
list = [input(), input(), input()]
c = 0
for n in range(N):
    if list[0][n] == list[1][n]:
        if list[0][n] != list[2][n]:
            c += 1
        continue
    if list[0][n] == list[2][n]:
        if list[0][n] != list[1][n]:
            c += 1
        continue
    if list[1][n] == list[2][n]:
        if list[0][n] != list[1][n]:
            c += 1
        continue
    c += 2

print(c)

Submission status: Accepted

Solution code:
N = int(input())
A = list(input())
B = list(input())
C = list(input())
count = 0

for i in range(N):
    if(A[i]!=B[i] and A[i]!=C[i] and B[i]!=C[i]):
        count += 2
    elif(A[i]==B[i] or C[i]==B[i] or A[i]==C[i]):
        count += 1

for i in range(N):
    if(A[i]==B[i] and A[i]==C[i]):
        count -= 1


print(count)

Submission status: Accepted

Solution code:
n = int(input())
a = list(input())
b = list(input())
c = list(input())

count = 0

for i in range(n):
    if a[i] == b[i] and b[i] == c[i]:
        continue
    elif a[i] == b[i] or b[i] == c[i] or a[i] == c[i]:
        count += 1
    else:
        count += 2

print(count)

Submission status: Accepted

Solution code:
N = int(input())
A = str(input())
B = str(input())
C = str(input())

count = 0
sum = 0

for i in range(N):
    
    ilist = list([A[i], B[i], C[i]])
    iuniq = list(set(ilist))
    sum = sum + len(iuniq)-1

print(sum)

Submission status: Accepted

Solution code:
N = int(input().strip())
A = input().strip()
B = input().strip()
C = input().strip()


count = 0
for a, b, c in zip(A, B, C):
  if a is b:
    if a is c:
      continue
    else:
      count += 1
  else:
    if b is c:
      count += 1
    elif a is c:
      count += 1
    else:
      count += 2

print(count)

Submission status: Accepted

Solution code:
def main(N, A, B, C):
    tot = 0
    for i in range(N):
        fab = A[i] == B[i]
        fac = A[i] == C[i]
        fbc = B[i] == C[i]
        if fab and fac:
            continue
        elif fab or fac or fbc:
            tot += 1
        else:
            tot += 2
    print(tot)

if __name__ == "__main__":
    N = int(input())
    A = input()
    B = input()
    C = input()
    main(N, A, B, C)

Submission status: Accepted

Solution code:
N = int(input())
A = input()
B = input()
C = input()

ans = 0
for i in range(N):
    ans += len(set([A[i], B[i], C[i]])) - 1

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
a,b,c=[input() for i in range(3)]
cnt=0

a_=list(a)
b_=list(b)
c_=list(c)

for i in range(n):
  cnt += len(list({a_[i],b_[i],c_[i]}))-1

print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
A = input()
B = input()
C = input()
m = [0, 0, 1, 2]
op = 0
for i in range(N):
    chars = len({A[i], B[i], C[i]})
    op += m[chars]
print(op)

Submission status: Accepted

Solution code:
N = int(input())
A = input()
B = input()
C = input()

count = 0
for i in range(N):
    if A[i] == B[i]:
      if A[i] == C[i]:
        pass
      else:
        count += 1
    elif A[i] == C[i]:
      count += 1
    elif B[i] == C[i]:
      count += 1
    else:
      count += 2

print(count)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    n = int(input())
    a = list(input())
    b = list(input())
    c = list(input())
    count = 0
    for i in range(n):
        if a[i] == b[i] == c[i]:
            continue
        elif a[i] == b[i]:
            c[i] = a[i]
            count += 1
        elif a[i] == c[i]:
            b[i] = a[i]
            count += 1
        elif b[i] == c[i]:
            a[i] = b[i]
            count += 1
        else:
            b[i] = a[i]
            c[i] = a[i]
            count += 2
    print(count)

Submission status: Accepted

Solution code:
n=int(input())
s=[list(input()) for _ in range(3)]
cnt=0
for i in range(n):
  cnt+=len(set([s[0][i],s[1][i],s[2][i]]))-1
print(cnt)

Submission status: Accepted

Solution code:
n=int(input())
a=input()
b=input()
c=input()
abc=list('0'*n)
for i in range(n):
    if a[i]==b[i]:
        abc[i]=a[i]
    if b[i]==c[i]:
        abc[i]=b[i]
    if c[i]==a[i]:
        abc[i]=c[i]
    if abc[i]=='0':
        abc[i]=a[i]
count=0
for i in range(n):
    if a[i]!=abc[i]:
        count+=1
    if b[i]!=abc[i]:
        count+=1
    if c[i]!=abc[i]:
        count+=1
print(count)

Submission status: Accepted

Solution code:
n=int(input())
word=[]
word.append(input())
word.append(input())
word.append(input())
count=0
for i in range(len(word[0])):
    if word[0][i] != word[1][i] and word[1][i] != word[2][i] and word[0][i] != word[2][i]:
        count+=2
    elif word[0][i] != word[1][i] or word[1][i] != word[2][i]:
        count+=1
    else:
        pass
print(count)