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:
# Touitsu
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]:
        ans += 1
    else:
        if 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()

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

Submission status: Accepted

Solution code:
n = int(input())
a = input()
b= input()
c= input()
de_lis = [0]*n

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

print(sum(de_lis))

Submission status: Accepted

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

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] and C[i] != A[i]:
        count += 2
    else:
        count += 1
print(count)

Submission status: Accepted

Solution code:
from sys import stdin

def main():
    N = int(input())
    A, B, C = (input() for _ in [0] * 3)

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

input = lambda: stdin.readline().rstrip()
main()

Submission status: Accepted

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

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

print(count)

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

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 C[i] != A[i]:
            count += 1
    elif A[i] == C[i]:
        if B[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, b, c = [list(input()) for _ in range(3)]

print(sum([len({i, j, k}) - 1 for i, j, k in zip(a, b, c)]))

Submission status: Accepted

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

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
# import bisect
# import math
# import numpy as np


"""Template"""


class IP:
    """
    入力を取得するクラス
    """
    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: int
        """
        return int(self.input())

    def S(self):
        """
        1文字の取得(str
        :return: str
        """
        return self.input()

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]

    def SILS(self, n):
        """
        Some Int LineS
        横に複数、縦にも複数
        :param n: 行数
        :return: list
        """
        return [self.IL() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        # 参考
        # https://blog.rossywhite.com/2018/08/06/bit-search/
        # https://atcoder.jp/contests/abc105/submissions/4088632
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if self.bit_o(i, j):
                    """右からj+1番目のiが1かどうか判定"""
                    # output.append(a[j])
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val

    def SR(self, s):
        """
        昇順ソート（reverse書くのが面倒
        返り値はありません。注意して下さい。
        SR(s) と書いたらsが昇順ソートされるだけです。
        Sort Reverse
        :param s: ソートしたいリスト
        :return: None
        """
        s.sort(reverse=True)

    def bit_n(self, a, b):
        """
        bit探索で使います。0以上のときにTrue出します
        自然数だからn
        :param a: int
        :param b: int
        :return: bool
        """
        return bool((a >> b & 1) > 0)

    def bit_o(self, a, b):
        """
        bit探索で使います。1のときにTrue出すよ
        oneで1
        :param a: int
        :param b: int
        :return: bool
        """
        return bool(((a >> b) & 1) == 1)

    def ceil(self, x, y):
        """
        Round up
        小数点切り上げ割り算
        :param x: int
        :param y: int
        :return: int
        """
        return -(-x//y)

    def ave(self, a):
        """
        平均を求めます
        :param a: list
        :return: int
        """
        return sum(a) / len(a)


"""ここからメインコード"""


def main():
    # 1文字に省略
    r, e = range, enumerate
    ip = IP()
    id = Idea()

    """この下から書いてね"""
    n = ip.I()
    a = ip.S()
    b = ip.S()
    c = ip.S()
    ans = 0

    for j in r(n):
        if a[j] == b[j] and b[j] == c[j]:
            pass
        elif a[j] == b[j] or b[j] == c[j] or a[j] == c[j]:
            ans += 1
        else:
            ans += 2

    print(ans)


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] and b[i] == c[i]:
        continue
    elif (a[i] == b[i] and b[i] != c[i]) or (a[i] == c[i] and c[i] != b[i]) or (b[i] == c[i] and c[i] != a[i]):
        ans += 1
    elif a[i] != b[i] and b[i] != c[i]:
        ans += 2
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] == C[i]:
        count += 0
    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()
ans=0

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

Submission status: Accepted

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

Submission status: Accepted

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

list_word = [[] for j in range(3)]

list_word[0] = list(A)
list_word[1] = list(B)
list_word[2] = list(C)

word_length = N

sum_char_change = 0
for idx in range(N):
    A_char = list_word[0][idx]
    B_char = list_word[1][idx]
    C_char = list_word[2][idx]

    sum_char_change += len(set([A_char, B_char, C_char]))-1

    #print([A_char, B_char, C_char])

print(sum_char_change)

Submission status: Accepted

Solution code:
import collections
n = int(input())
l = []
kai = 0
for i in range(3):
    l.append(input())
for i in range(n):
    search = []
    for j in range(3):
        search.append(l[j][i])
        #print(search)
    cnt = collections.Counter(search).most_common()
    for i in range(len(cnt)-1):
        kai += cnt[i+1][1]
print(kai)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n = int(input())
a = input()
b = input()
c = input()
r=0

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

print(r)

Submission status: Accepted

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

ans=0

for i in range(n):
    x=[a[i],b[i],c[i]]
    d=collections.Counter(x)
    ans+=len(d)-1

print(ans)

Submission status: Accepted

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

import collections
ans = 0
for i in range(n):
    ans +=  3 - collections.Counter(a[i] + b[i] + c[i]).most_common()[0][1]
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
A=input()
B=input()
C=input()
cnt = 0
tmp=''
s = 0
for i in range(N):
    cnt = 0
    tmp = A[i]
    if tmp == B[i] or tmp == C[i] :
        cnt += 1
    if B[i] == C[i]:
        cnt += 1
    elif tmp != B[i] and tmp != C[i]:
        cnt += 2
    if tmp == B[i] and tmp == C[i]:
        cnt = 0
    s += cnt
print(s)

Submission status: Accepted

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

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

print(x)

Submission status: Accepted

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

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):
    count += max(len([i for i in [a!=b, a!=c, b!=c] if i]) -1, 0)

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]==c[i]:
    ans += 0
  elif a[i]!=b[i] and b[i]!=c[i] and a[i]!=c[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 a,b,c in zip(A, B, C):
    if a == b == c:
        continue
    if a == b:
        ans += 1
        continue
    if a == c:
        ans += 1
        continue
    if b == c:
        ans += 1
        continue
    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,b,c = A[i],B[i],C[i]
    if a == b and b == c:
        pass
    else:
        if 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 ai, bi, ci in zip(a, b, c):
    lst = [ai, bi, ci]
    ans += len(set(lst))-1
print(ans)

Submission status: Accepted

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

count=0

for i in range(n):
    if al[i]==bl[i]:
        if al[i]==cl[i]:
            plus=0
        else:
            plus=1
    elif bl[i]==cl[i]:
        plus=1
    elif al[i]==cl[i]:
        plus=1
    else:
        plus=2
        
    count+=plus
    
print(count)

Submission status: Accepted

Solution code:
# B
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
def zeros(n): return [0]*n
def db(x): 
    global debug
    if debug: print(x)
debug = True
N = getInt()
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
    else: count += 2
print(count)

Submission status: Accepted

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

Submission status: Accepted

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


main()

Submission status: Accepted

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

ret = 0
for i in range(n):
    cnt = {}
    cnt[a[i]] = 1
    if b[i] not in cnt:
        cnt[b[i]] = 0
    if c[i] not in cnt:
        cnt[c[i]] = 0
    cnt[b[i]] += 1
    cnt[c[i]] += 1
    ret += 3 - max(cnt.values())

print(ret)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(str,input()))
B = list(map(str,input()))
C = list(map(str,input()))
counter = 0

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

print(counter)

Submission status: Accepted

Solution code:
n = int(input())

s1 = input()
s2 = input()
s3 = input()

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


print ("{0:d}".format(sum) )

Submission status: Accepted

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

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

Submission status: Accepted

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

count = 0
for t_a,t_b,t_c in zip(a,b,c):
    count += len(set([t_a,t_b,t_c])) - 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] == C[i]:
        count += 0
    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,b,c = [input() for i in range(3)]
cnt = 0
for i in range(n):
    if a[i] == b[i] and a[i] == c[i]:
        cnt += 0
    if a[i] == b[i] and not a[i] == c[i]:
        cnt += 1
    if b[i] == c[i] and not a[i] == c[i]:
        cnt += 1
    if c[i] == a[i] and not b[i] == c[i]:
        cnt += 1
    if not a[i] == b[i] and not b[i] == c[i] and not a[i] == c[i]:
        cnt += 2
print(cnt)

Submission status: Accepted

Solution code:
def main():
    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] or b[i] == c[i] or c[i] == a[i]:
            cnt += 1
        else:
            cnt += 2

    print(cnt)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans=0
for u in zip(A,B,C):
	D=Counter(u)
	if len(D)==2: ans+=1
	elif len(D)==3: ans+=2

print ans

Submission status: Accepted

Solution code:
#A
"""
n, a, b = map(int, input().split())
ab = n / 2
ansa = min(a, b)
ansb = max((a+b)-n, 0)
print(ansa,ansb)
"""

#B
n = int(input())
a = input()
b = input()
c = input()
ans = 0
for i in range(n):
    bf = [a[i], b[i], c[i]]
    bf = set(bf)
    ans += len(bf) - 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]==C[i]:
        count+=0
    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
    elif (A[i]!=B[i]) and (B[i]!=C[i]):
        count+=2
print(count)

Submission status: Accepted

Solution code:
from statistics import mean, median,variance,stdev
import sys
import math
import fractions

def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

x = ip()                              #入力整数1つ
#n,k= (int(i) for i in input().split())      #入力整数横2つ
#x,y,z = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列

#jの変数はしようできないので注意
a =[]
for i in range(3):
    a.append(input())
sum = 0
for i in range(x):
    b = [a[0][i],a[1][i],a[2][i]]
    b.sort()
    if b[0] == b[1] or b[1]==b[2]:
        if b[0] == b[1] and b[1]==b[2]:
            f =0
        else: sum+=1
    else: sum+=2
print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
for i in range(n):
    s = a[i] + b[i] + c[i]
    ta = s.count(a[i])
    tb = s.count(b[i])
    tc = s.count(c[i])

    if ta == 3:
        continue
    elif ta == 1 and tb == 1 and tc == 1:
        ans += 2
    else:
        ans += 1

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):
	l = [A[i],B[i],C[i]]
	c = Counter(l)
	mode = c.most_common(1)[0][1]
	if mode == 1:
		ans += 2
	if mode == 2:
		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):
    s = { a[i], b[i], c[i] }
    ans += len(s) - 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 += 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())
A = input()
B = input()
C = input()

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
def diff(a, b, c):
    i = 0
    for aa, bb, cc in zip(a, b, c):
        if aa != bb and aa != cc and bb != cc:
            i += 2
        elif aa != bb or bb != cc:
            i += 1
    return i

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

print(diff(a, b, c))

Submission status: Accepted

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

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]:
        if B[i] != C[i]:
            count += 1
print(count)

Submission status: Accepted

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

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

print(tmp)

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

print(int(ans))

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A, B, C = [input() for i in range(3)]
ans = 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]:
        ans += 1
    else:
        ans += 2
print(ans)

Submission status: Accepted

Solution code:


def _main():
    N = int(input())
    A, B, C = input(), input(), input()

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

    print(count)


if __name__ == '__main__':
    _main()

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 i in range(n):
    tmp = set()
    for c in src:
        tmp.add(c[i])
    if len(tmp) == 3:
        ans += 2
    elif len(tmp) == 2:
        ans += 1

print(ans)

Submission status: Accepted

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

three_dif=0
two_same=0
all_same=0

for i in range(0,N):
    #３つとも違う
    #３つ中2つ同じ
    #3つ全て同じ
    if(a[i]==b[i] and b[i]==c[i]):
        all_same+=1
    elif(a[i]==b[i] or b[i]==c[i] or c[i]==a[i]):
        two_same+=1
    else:
        three_dif+=1
ans=two_same+2*three_dif
print(ans)

Submission status: Accepted

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

# 全国統一プログラミング王決定戦予選：B - Touitsu


def main():
    N = int(raw_input().strip())
    A = raw_input().strip()
    B = raw_input().strip()
    C = raw_input().strip()

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


if __name__ == '__main__':
    main()

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]:
        cnt += 2
    elif a[i] == b[i]:
        cnt += 1
    elif b[i] == c[i]:
        cnt += 1
    elif c[i] == a[i]:
        cnt += 1
    else:
        cnt += 0
print(2 * n - cnt)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = input()
a = input()
b = input()
c = input()

count = 0
for ai, bi, ci in zip(a, b, c):
    if ai == bi == ci:
        continue
    elif (ai == bi) or (ai == ci) or (bi == ci):
        count += 1
    else:
        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):
    A = a[i]
    B = b[i]
    C = c[i]
    if A == B:
        if B != C:
            ans += 1
    elif B == C:
        if B != A:
            ans += 1
    elif C == A:
        if A != B:
            ans += 1
    elif A != B and B != C and C != A:
        ans += 2
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
string_a = input()
string_b = input()
string_c = input()

ans = 0
for a, b, c in zip(string_a, string_b, string_c):
    if a == b:
        if a != c:
            ans += 1
    else:
        if a != c and b != c:
            ans += 2
        else:
            ans += 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 A[i] != C[i]:
			count += 1
	elif B[i] == C[i]:
		if B[i] != A[i]:
			count += 1
	elif C[i] == A[i]:
		if C[i] != B[i]:
			count += 1
	else:
		count += 2


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:
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

# いっこ入力
n =int(input())

# 空白区切りの数列をリストに代入
a = list(input())
b = list(input())
c = list(input())
answer = 0
for i in range(n):
    p = 0
    if a[i] == b[i]:
        p += 1
    if b[i] == c[i]:
        p += 1
    if c[i] == a[i]:
        p += 1
    if p == 0:
        answer += 2
    if p == 1:
        answer += 1
print(answer)

Submission status: Accepted

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

n = int(input())

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

ans = 0

for i in range(n):
    x = 0
    x += a[i]!=b[i]
    x += b[i]!=c[i]
    x += c[i]!=a[i]
    if x==2:
        ans+=1
    if x==3:
        ans+=2
        
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = input()
b = input()
c = input()
count = 0
for i in range(n):
    word = []
    word.append(a[i])
    word.append(b[i])
    word.append(c[i])
    word = list(set(word))
    count += len(word) - 1
    word.clear() 
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] 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):
    s = set([A[i],B[i],C[i]])
    ans += len(s)-1

print(ans)

Submission status: Accepted

Solution code:
#import numpy as np
N=int(input())
A=list(input())
B=list(input())
C=list(input())
def judge(a,b,c):
    if a==b and b==c:
        return 0
    elif (a==b or b==c or c==a):
        return 1
    else:
        return 2
counter=0
for i in range(N):
    counter+=judge(A[i],B[i],C[i])
print(counter)

Submission status: Accepted

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

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

print(result)

Submission status: Accepted

Solution code:
def solve(N, A, B, C):
  count = 0
  for i in range(N):
    a = A[i]
    b = B[i]
    c = C[i]
    if a == b:
      if a != c: count = count + 1
    else:
      if a == c: count = count + 1
      elif b == c: count = count + 1
      else: count = count + 2
  return count

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

print(solve(N, A, B, C))

Submission status: Accepted

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

a=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

L=[0 for i in range(N)]
same=0
for i in range(N):
    if A[i]==B[i] and B[i]==C[i] and C[i]==A[i]:
        same+=3
    elif A[i]==B[i] or B[i]==C[i] or C[i]==A[i]:
        same+=2
    else:
        same+=1
print(3*N-same)

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