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

count = 0

for i in range(n):
  if a[i] == b[i]:
    if a[i] != c[i]:
      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:
n = int(input())
a = input()
b = input()
c = input()

answer = 0

for i in range(n):
    int_w = len(set([a[i], b[i], c[i]]))

    if int_w == 3:
        answer += 2
    elif int_w == 2:
        answer += 1
    else:
        pass


print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A,B,C = [input() for _ in range(3)]

answer = 0
for a,b,c in zip(A,B,C):
  answer += len(set([a,b,c])) - 1

print(answer)

Submission status: Accepted

Solution code:
n = int(input())
abc = []
for _ in range(3):
    abc.append(str(input()))
cnt = 0
for i in range(n):
    if abc[0][i]==abc[1][i]==abc[2][i]:
        cnt += 0
    elif (abc[0][i]==abc[1][i]!=abc[2][i])\
        or (abc[1][i]==abc[2][i]!=abc[0][i])\
        or (abc[2][i]==abc[0][i]!=abc[1][i]):
        cnt += 1
    else:
        cnt += 2
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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


ans = 0

for i in range(N):
    if A[i] is B[i] and A[i] is C[i]:
        pass
    elif A[i] is B[i] and B[i] is not C[i] and A[i] is not C[i]:
        ans += 1
    elif B[i] is C[i] and B[i] is not A[i] and C[i] is not A[i]:
        ans += 1
    elif A[i] is C[i] and A[i] is not B[i] and C[i] is not B[i]:
        ans += 1
    else:
        ans += 2

print(ans)

Submission status: Accepted

Solution code:
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

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

ans = 0
for a, b, c in zip(A, B, C):
  ans += len(set((a,b,c)))-1

print(ans)

Submission status: Accepted

Solution code:
# PROXY

N = int(input())
A = list(input() + input() + input())
counter = 0
time = 0
while counter < N:
    if A[counter] == A[counter + N] and A[counter] == A[counter + N*2]:
        time += 2
        counter += 1
    elif A[counter] == A[counter + N]:
        time += 1
        counter += 1
    elif A[counter] == A[counter + N*2]:
        time += 1
        counter += 1
    elif A[counter + N] == A[counter + N*2]:
        time += 1
        counter += 1
    else:
        time += 0
        counter += 1
print(2*N - time)

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:
N = int(input())
ABC = [list(input()) for _ in range(3)]

print(sum([len(set(abc)) - 1 for abc in zip(*ABC)]))

Submission status: Accepted

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

print(sum([len(set([A[i],B[i],C[i]]))-1 for i in range(N)]))

Submission status: Accepted

Solution code:
N = int(input())
A = input()
B = input()
C = input()
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 C[i] != A[i]:
		cnt += 2
	else:
		cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
a = str(input())
b = str(input())
c = str(input())
d = 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 c[i] != a[i]:
        d += 2
    else:
        d += 1
print(d)

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]:
        pass
    elif A[i] != B[i] and B[i] != C[i] and C[i] != A[i]:
        ans += 2
    else:
        ans += 1
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] == c[i]:
        pass
    elif a[i] == b[i] or a[i] == c[i] or b[i] == c[i]:
        ans += 1
    else:
        ans += 2
print(ans)

Submission status: Accepted

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

ans = 0
for a, b, c in zip(A, B, C):
    xs = set([a, b, c])
    if len(xs) == 1:
        ans += 0
    elif len(xs) == 2:
        ans += 1
    else:
        ans += 2

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
A = input()
B = input()
C = input()
cnt = 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:
        cnt += 1
    else:
        cnt += 2
print(cnt)

Submission status: Accepted

Solution code:
if __name__=="__main__":
    n = input()
    A = input()
    B = input()
    C = input()
    ans = 0
    for a, b, c in zip(A, B, C):
        if a != b and a != c and b != c:
            ans += 2
        elif a == b and b == c :
            pass
        else:
            ans += 1
    print(ans)

Submission status: Accepted

Solution code:
n=int(input())
arr=[input() for _ in range(3)]
ans=0
for i in range(n):
  if arr[0][i]==arr[1][i] and arr[1][i]==arr[2][i]:
    tmp=0
  elif arr[0][i]==arr[1][i] or arr[1][i]==arr[2][i] or arr[2][i]==arr[0][i]:
    tmp=1
  else:
    tmp=2
  ans+=tmp
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
for i in range(n):
  if s1[i] == s2[i] and s2[i] == s3[i]:
    pass
  elif s1[i] == s2[i] or s1[i] == s3[i] or s2[i] == s3[i]:
    ans += 1
  else:
    ans += 2
print(ans)

Submission status: Accepted

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


def solve(N: int, A: str, B: str, C: str):
    ret = 0
    for i in range(N):
        if A[i] == B[i] == C[i]:
            ret += 0
        elif A[i] == B[i] or B[i] == C[i] or A[i] == C[i]:
            ret += 1
        else:
            ret += 2
    print(ret)
    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
    A = next(tokens)  # type: str
    B = next(tokens)  # type: str
    C = next(tokens)  # type: str
    solve(N, A, B, C)

if __name__ == '__main__':
    main()

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]:
    if not b[i]==c[i]:
      ans+=1
  else:
    if b[i]==c[i]:
      ans+=1
    elif a[i]==c[i]:
      ans+=1
    else:
      ans+=2
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
A = input()
B = input()
C = input()
a = [0] * n
for i in range(n):
  if (A[i] == B[i] == C[i]):
    a[i] += 0
  elif (A[i] == B[i] or B[i] == C[i] or A[i] == C[i]):
    a[i] += 1
  else:
    a[i] += 2

print(sum(a))

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:
_,*t=open(0);print(sum(len(set(s))-1for s in zip(*t)))

Submission status: Accepted

Solution code:
n = int(input())
A = input()
B = input()
C = input()
a = [0] * n
for i in range(n):
  if (A[i] == B[i] and A[i] != C[i]):
    a[i] += 1
  elif (A[i] == C[i] and A[i] != B[i]):
    a[i] += 1
  elif (B[i] == C[i] and A[i] != B[i]):
    a[i] += 1
  elif (A[i] == B[i] and B[i] == C[i]):
    a[i] += 0
  else:
    a[i] += 2

print(sum(a))

Submission status: Accepted

Solution code:
n = int(input())
a = input().strip()
b = input().strip()
c = input().strip()
ans = 0
for _a, _b, _c in zip(a, b, c):
  if _a != _b and _b != _c and _a != _c:
    ans += 2
  elif _a == _b and _b == _c:
    continue
  else:
    ans += 1
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]: ans += 1
    if A[i] != B[i] and B[i] == C[i]: ans += 1
    if A[i] != B[i] and A[i] == C[i]: ans += 1
    if A[i] != B[i] and B[i] != C[i] and C[i] != A[i]: ans += 2

print( ans )

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input());aa=[input()for i in range(3)];ans=0
for i in range(n):
  a,b,c=aa[0][i],aa[1][i],aa[2][i]
  if not a==b==c:
    if a!=b!=c!=a:ans+=2
    else:ans+=1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
listA = list(input())
listB = list(input())
listC = list(input())


counter=0
index=0
while index < n:
    if listA[index] == listB[index] and listB[index] == listC[index]:
        pass
    elif listA[index] != listB[index] and listB[index] != listC[index] and listC[index]!=listA[index]:
        counter+=2
    else:
        counter+=1
    index+=1
print(counter)

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]:
        continue
    elif A[i] != B[i] and B[i] != C[i] and C[i] != A[i]:
        ans += 2
    else:
        ans += 1

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 A[i]!=C[i] and B[i]!=C[i]:
    ans += 2
  elif A[i]!=B[i] or A[i]!=C[i] or B[i]!=C[i]:
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
a = input()
b = input()
c = input()

count = 0
for i in range(n):
    co = Counter([a[i], b[i], c[i]])
    count += 3-max(co.values())

print(count)

Submission status: Accepted

Solution code:
n = int(input())
a = str(input())
b = str(input())
c = str(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 a[i]==c[i] or b[i]==c[i]:
    count += 1
  else:
    count+=2
print(count)

Submission status: Accepted

Solution code:
N=int(input())
A=input()
B=input()
C=input()
print(sum([0 if A[i]==B[i]==C[i] else 2 if A[i]!=B[i]!=C[i]!=A[i] else 1 for i in range(N)]))

Submission status: Accepted

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

res = 0

for i in range(N):
    set_num = len(set([A[i],B[i],C[i]]))
    if set_num == 3:
        res += 2
    elif set_num == 2:
        res += 1

print(res)

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] and b[i] == c[i] and c[i] == a[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())
s = [input() for _ in range(3)]
cnt = -n
for i in range(n):
  cnt += len(set([j[i] for j in s]))
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] is B[i]) & (A[i] is C[i]):
        ans += 0
    elif (A[i] is B[i]) | (B[i] is C[i]) | (A[i] is C[i]):
        ans += 1
    else:
        ans += 2
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
A = input()
B = input()
C = input()

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

Submission status: Accepted

Solution code:
import collections

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

ans = 0
for i in range(N):
    l = []
    l.append(A[i])
    l.append(B[i])
    l.append(C[i])
    c = collections.Counter(l)
    c_len = len(c)
    if c_len == 2:
        ans += 1
    elif c_len == 3:
        ans += 2

print(ans)

Submission status: Accepted

Solution code:
int(input())
a = str(input())
b = str(input())
c = str(input())
def f(a,b,c):
    ans = 0
    for i in range(len(a)):
        if a[i] != b[i]:
            ans += 1
        if a[i] != c[i] and c[i] != b[i]:
                ans += 1 
    return ans
ans = min(f(a,b,c),f(b,c,a),f(c,a,b))
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
a=input()
b=input()
c=input()
x=[[a[i],b[i],c[i]] for i in range(n)]
y=[max([t.count(t[0]),t.count(t[1]),t.count(t[2])]) for t in x]
print(3*n-sum(y))

Submission status: Accepted

Solution code:
"""
A - Subscribers
"""


def solve():
    N = int(input())
    A = input()
    B = input()
    C = input()
    change_count = 0
    for i in range(N):
        if A[i] == B[i] == C[i]:
            pass
        elif (A[i] == B[i] or
              A[i] == C[i] or
              B[i] == C[i]):
            change_count += 1
        else:
            change_count += 2
    print(change_count)


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

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

print(n)

Submission status: Accepted

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

operations = 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 C[i] == A[i]:
        operations += 1
    else:
        operations += 2

print(operations)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
input()
A, B, C = input(), input(), input()
print(sum([len(set([a, b, c])) - 1 for a, b, c in zip(A, B, C)]))

Submission status: Accepted

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

    if len(d) == 3:
        count += 2
    elif len(d) == 2:
        count += 1
    else:
        pass

print(count)

Submission status: Accepted

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

p = 0
for i in range(n):
    t = 0
    if(a[i] != b[i]):
        t += 1
    if(b[i] != c[i]):
        t += 1
    if(a[i] != c[i]):
        t += 1

    if(t == 3):
        p += 2
    elif(t == 0):
        pass
    else:
        p += 1
print(p)

Submission status: Accepted

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

num=0
for i in range(N):
    str=[]
    str.append(A[i])
    str.append(B[i])
    str.append(C[i])
    num=num+len(set(str))-1
print(num)

Submission status: Accepted

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

res = 0
for i in range(N):
  ab = (A[i] == B[i])
  bc = (B[i] == C[i])
  ca = (C[i] == A[i])
  s = ab*1 + bc*1 + ca*1

  if (0 == s):
    res += 2
  elif (1 == s):
    res += 1
print(res)

Submission status: Accepted

Solution code:
n=int(input())
a=[list(input())for i in range(3)]
cnt=0
for i in range(n):
    tmp=[]
    tmp.append(a[0][i])
    tmp.append(a[1][i])
    tmp.append(a[2][i])
    cnt+=len(list(set(tmp)))-1
print(cnt)

Submission status: Accepted

Solution code:
N=int(input())
A=input()
B=input()
C=input()
count=0
for i in range(0,N):
    if A[i]==B[i]==C[i]:
        count=count
    elif A[i]==B[i] or A[i]==C[i] or B[i]==C[i]:
        count=count+1
    else:
        count=count+2
print(count)

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]:
        ans += 1
    if a[i] != c[i] and b[i] != c[i]:
        ans += 1
        
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    N = int(input())
    A = input()
    B = input()
    C = input()

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

N = int(input())

w = [input() for i in range(3)]

c = 0

for i in range(N):
    if w[0][i]!=w[1][i]:
        c += 1
    
    if (w[0][i]!=w[2][i]) and (w[1][i]!=w[2][i]):
        c += 1

print(c)

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] != C[i] or A[i] != B[i] == C[i] or C[i] == A[i] != B[i]:
    ans += 1
  else:
    ans += 0
print(ans)

Submission status: Accepted

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

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18

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

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

print ans

Submission status: Accepted

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

answer = A
def calc_answer(answer):
    answer = answer
    for i in range(N):
        ver = [A[i], B[i], C[i]]
        same_index = get_same_index(ver)
        if same_index == (1,2):
            answer_lis = list(answer)
            answer_lis[i] = B[i]
            answer = ''
            for k in answer_lis:
                answer += k
    return answer

def get_same_index(lis):
    if lis[0] == lis[1] == lis[2]:
        return 0, 1, 2
    if lis[0] == lis[1]:
        return 0, 1
    if lis[1] == lis[2]:
        return 1, 2
    if lis[2] == lis[0]:
        return 0, 2
    else:
        return -1


def get_differency(answer):
    differency = 0
    answer = calc_answer(answer)
    for i in range(N):
        if answer[i] != A[i]:
            differency += 1
        if answer[i] != B[i]:
            differency += 1
        if answer[i] != C[i]:
            differency += 1
    return differency

differency = get_differency(answer)
print(differency)

Submission status: Accepted

Solution code:
N = int(input())
A = str(input())
B = str(input())
C = str(input())
count = 0
for i in range(0,N,1):
  if (A[i] != B[i] and A[i] != C[i] and B[i] != C[i]):
    count += 2
  elif (A[i] == B[i] and A[i] != C[i]) or \
       (A[i] == C[i] and A[i] != B[i]) or \
       (B[i] == C[i] and A[i] != B[i]):
    count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections
def get_ans(strings, n):
    ans = 0
    for i in range(n):
        counter = collections.defaultdict(int)
        for k in strings:
            counter[k[i]] += 1
        ans += len(strings) - max(counter.values())
    return ans

if __name__ == '__main__':
    n = int(input())
    strings = []
    for _ in range(3):
        strings.append(input())
    print(get_ans(strings, n))

Submission status: Accepted

Solution code:
N = int(input())
A = input()
A = [x for x in A]
B = input()
B = [x for x in B]
C = input()
C = [x for x in C]

total = 0

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

print(total)

Submission status: Accepted

Solution code:
n = int(input())
a = input()
b = input()
c = input()
cnt2 = 0
cnt3 = 0
for i in range(n):
  nsame = len(set([a[i], b[i], c[i]]))
  if nsame == 2:
    cnt2 += 1
  elif nsame == 1:
    cnt3 += 1
ans = 2*n - cnt2 - 2*cnt3
print(ans)

Submission status: Accepted

Solution code:
import collections
def func(a,b,c):
    g=0
    l=[a,b,c]
    d=collections.Counter(l)
    x=len(d)
    if x==3:
        g=2
    elif x==2:
        g=1
    return g
N=int(input())
A=input()
B=input()
C=input()
count=0
for i in range(N):
    count+=func(A[i],B[i],C[i])
print(count)

Submission status: Accepted

Solution code:
N = int(input())
l = []
for i in range(3):
    l.append(input())
res = 0
for i in range(len(l[0])):
    s = set()
    for j in range(3):
        s.add(l[j][i])
    if len(s) == 3:
        res += 2
    elif len(s) == 2:
        res += 1
print(res)

Submission status: Accepted

Solution code:
n=int(input())
a,b,c=list(input() for i in range(3))
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=list(input() for i in range(3))
ans=0
for i in range(n):
    if a[i]==b[i]:
        if b[i]!=c[i]:
            ans+=1
    elif b[i]!=c[i] and a[i]!=c[i]:
        ans+=2
    else:
        ans+=1
print(ans)

Submission status: Accepted

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

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

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

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

Submission status: Accepted

Solution code:
n = int(raw_input())
a = []
for _ in range(3):
  a.append(raw_input())
ans = 0
for i in range(n):
  diff_chars = set()
  for j in range(3):
    diff_chars.add(a[j][i])
  ans += len(diff_chars) - 1
print ans

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] and a[i] != c[i]:
		count += 2
	elif a[i] != b[i] and b[i] == c[i] and a[i] != c[i]:
		count += 1
	elif a[i] != b[i] and b[i] != c[i] and a[i] == c[i]:
		count += 1
	elif a[i] == b[i] and b[i] != c[i] and a[i] != c[i]:
		count += 1
	else:
		continue

print(count)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    N = int(input())
    S = [input() for _ in range(3)]

    ans = 0
    for n in range(N):
        chars = [0 for _ in range(ord('z') - ord('a') + 1)]
        for s in S:
            chars[ord(s[n]) - ord('a')] += 1
        ans += sum(sorted(chars, reverse=True)[1:])
    print(ans)

Submission status: Accepted

Solution code:
import sys

n=int(sys.stdin.readline())
a=sys.stdin.readline()
b=sys.stdin.readline()
c=sys.stdin.readline()


cnt = 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]:
        cnt = cnt + 1
    else:
        cnt = cnt + 2
print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=input()
a,b,c=[raw_input() for _ in xrange(3)]
r=0
for i in xrange(n):
  l=set([a[i],b[i],c[i]])
  r+=len(l)-1
print r

Submission status: Accepted

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

if a == b == c:
  print(0)
  exit()

al = list(a)
bl = list(b)
cl = list(c)

cnt = 0
for i in range(n):
  # all match no count
  if al[i] == bl[i] == cl[i]:
    continue
  # two is match
  if al[i] == bl[i]:
    cnt += 1
    continue
  elif al[i] == cl[i]:
    cnt += 1
    continue
  elif bl[i] == cl[i]:
    cnt += 1
    continue
  cnt += 2
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
s = [input() for i in range(3)]
count = 0
for i in range(n):
    char = set()
    char.add(s[0][i])
    char.add(s[1][i])
    char.add(s[2][i])
    count += len(char)-1
print(count)

Submission status: Accepted

Solution code:

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

n = int(n)

def classify(a,b,c):
	if (a==b)and (b==c):
		return 0
	else:
		if (a==b):
			return 1
		elif (b==c):
			return 1
		elif (c==a):
			return 1
		else:
			return 2

ans_sum = 0
for i in range(n):
	ans = classify(a[i], b[i], c[i])
	ans_sum+=ans

print(ans_sum)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

count = 0
for i in range(N):
    dic = {A[i]: 1}
    if B[i] in dic:
        dic[B[i]] += 1
    else:
        dic[B[i]] = 1

    if C[i] in dic:
        dic[C[i]] += 1
    else:
        dic[C[i]] = 1

    if len(dic) == 3:
        count += 2
    elif len(dic) == 2:
        count += 1
    elif len(dic) == 1:
        pass

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, = [int(x) for x in input().split()]
A = input()
B = input()
C = input()
r = 0
for i in range(N):
  r += [0,0,1,2][len(set((A[i],B[i],C[i])))]
print(r)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
length = int(input())
a, b, c = [input() for i in range(3)]
ans = 0
for i in range(length):
  if a[i]==b[i]==c[i]: ans += 0
  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())
S1 = input()
S2 = input()
S3 = input()

ans = 0
for i in range(N):
    youso = set()
    youso.add(S1[i])
    youso.add(S2[i])
    youso.add(S3[i])
    ans += len(youso) - 1

print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
n=int(input())
a=input()
b=input()
c=input()
t=0
for i in range(0,n):
    t+=abs(Counter([a[i],b[i],c[i]]).most_common(1)[0][1] - 3)
print(t)

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

Solution code:
import sys
import collections

n = int(sys.stdin.readline().strip())
l = sys.stdin.readlines()
l = [x.strip() for x in l]

sum = 0

for i in range(n):
  l2 = [l[j][i] for j in range(3)]
  c = collections.Counter(l2)
  most = c.most_common()[0][1]
  if most == 1:
    # 2つ変える
    sum += 2
  elif most == 2:
    sum += 1

print(sum)