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_str = input()
b_str = input()
c_str = input()

ans = 0
for a, b, c in zip(a_str, b_str, c_str):
    if a == b == c:
        continue
    elif a == b or b == c or c == a:
        ans += 1
    else:
        ans += 2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    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)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N = INT()
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=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()
count = 0
for x in range(N):
    count += len(set([A[x], B[x], C[x]])) - 1
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]: pass
  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:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache


#############
# Constants #
#############

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

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

N = I()
A,B,C = SLs(3)
res = 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]:
    res += 1
  else:
    res += 2
print(res)

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] 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]):
        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):
    x = a[i]
    y = b[i]
    z = c[i]

    if x == y == z:
        continue
    elif x != y and y != z and z != x:
        ans += 2
    else:
        ans += 1

print(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):
    abc = set([A[i],B[i],C[i]])
    ans += len(abc) - 1
print(ans)

Submission status: Accepted

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

nikkei19q_b()

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] 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= list(input())
B= list(input())
C= list(input())
ans=0
import collections
for i in range(N):
   l=[A[i],B[i],C[i]]
   l=collections.Counter(l).most_common()
   ans+=3-l[0][1]
print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = input().rstrip()
    B = input().rstrip()
    C = input().rstrip()

    res = 0
    for a, b, c in zip(A, B, C):
        res += 1 if len(set(a + b + c)) == 2 else 2 if len(set(a + b + c)) == 3 else 0

    print(res)


if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
a = input()
b = input()
c = input()
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 i in range(n):
  l = [a[i],b[i],c[i]]
  l=set(l)
  ans+=(len(l)-1)
print(ans)

Submission status: Accepted

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

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]) 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())
l = [input() for _ in range(3)]

ans = 0
for i in range(n):
    s = set()
    for x in l:
        s.add(x[i])

    ans += len(s) - 1

print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
import math
import re
import queue

input = stdin.readline

MOD = 1000000007
INF = 122337203685477580

def solve():
    N = int(input().rstrip())
    S1 = (input().rstrip())
    S2 = (input().rstrip())
    S3 = (input().rstrip())
    cnt = 0
    for x in range(N):
        ic = 0
        if(S1[x] == S2[x]):
            ic += 1
        if(S3[x] == S2[x]):
            ic += 1
        if(S1[x] == S3[x]):
            ic += 1    

        if(ic == 1):
            cnt += 1
        elif(ic < 1):
            cnt += 2
        else:
            cnt += 0
    
    print(cnt)

if __name__ == '__main__':
    solve()

Submission status: Accepted

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

ans = 0
for i in range(N):
    if a[0][i] != a[1][i] and a[1][i] != a[2][i] and a[0][i] != a[2][i]:
        ans += 2
    elif a[0][i] == a[1][i] and a[1][i] == a[2][i] and a[0][i] == a[2][i]:
        continue
    else:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


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

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


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

    ans = 0
    for a, b, c in zip(A, B, C):
        if a == b == c:
            pass
        elif a == b or b == c or c == a:
            ans += 1
        else:
            ans += 2

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n =int(input())
A = [x for x in list(str(input()))]
B = [x for x in list(str(input()))]
C = [x for x in list(str(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] and A[i] == C[i] and B[i] == C[i]:
        ans += 0
    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]:
        continue
    ans += len(set([A[i],B[i],C[i]])) - 1
print(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):
    ans += len({a[i], b[i], c[i]}) - 1

print(ans)
    
        
        

'''
west
east
wait

{'w', 'e', 'w'}
{'w', 'e'}
len → 2 
1文字は使って良い -1


'''

Submission status: Accepted

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

alphabet = [chr(i) for i in range(97, 97+26)]

ans = 0
for i in range(n):
    cnt = 200
    for j in range(26):
        cnt_tmp = 0
        if (a[i] != alphabet[j]):
            cnt_tmp += 1
        if (b[i] != alphabet[j]):
            cnt_tmp += 1
        if (c[i] != alphabet[j]):
            cnt_tmp += 1
        cnt = min(cnt, cnt_tmp)
    ans += cnt

print(ans)
    
        
        

'''
west
east
wait
'''

Submission status: Accepted

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

l = [[a, b, c] for a, b, c in zip(A, B, C)]

cnt = 0
for i in range(N):
    l_set = set(l[i])
    if len(l_set) == 1:
        pass
    elif len(l_set) == 2:
        cnt += 1
    else:
        cnt += 2

print(cnt)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


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

    print(ans)


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):
  if len(set([a[i],b[i],c[i]])) == 1:
    continue
  elif len(set([a[i],b[i],c[i]])) == 2:
    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):
  t=0
  if A[i]!=B[i]:
    t+=1
  if C[i]!=A[i] and C[i]!=B[i]:
    t+=1
  ans+=t
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]:
    ans += 0

  elif A[i] == B[i]:
    ans += 1

  elif A[i] == C[i]:
    ans += 1

  elif B[i] == C[i]:
    ans += 1

  elif A[i] != B[i] and B[i] != C[i]:
    ans += 2

print(ans)

Submission status: Accepted

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

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 = input()
B = input()
C = input()
ans = 0
for i in range(n):
  if A[i] == B[i]:
    ans += 1
  if B[i] == C[i]:
    ans += 1
  if C[i] == A[i]:
    ans += 1
  if A[i] == B[i] == C[i]:
    ans -= 1
print(n*2-ans)

Submission status: Accepted

Solution code:
n=int(input())
ab = []
for _ in range(3):
    s=list(input())
    ab.append(s)

ans = 0

for i in range(n):
    memo = []
    for j in range(3):
        memo.append(ab[j][i])
    ans += len(set(memo))-1
    
print(ans)

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):
    ans += len({i, j, k}) - 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

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

Submission status: Accepted

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

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):
  ans += len(set([i,j,k]))-1
print(ans)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
a = list(readline().rstrip().decode())
b = list(readline().rstrip().decode())
c = list(readline().rstrip().decode())
cnt = 0
for aa, bb, cc in zip(a, b, c):
    if aa == bb == cc:
        continue
    elif aa == bb or bb == cc or aa == cc:
        cnt += 1
    else:
        cnt += 2
print(cnt)

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

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

Submission status: Accepted

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

# B - Touitsu
N = int(input())
words = [input() for i in range(3)]
ans = 0

for i in range(N):
	dic = dict()
	
	for w in words:
		if w[i] in dic.keys():
			dic[w[i]] += 1
		else:
			dic[w[i]] = 1
	
	ans += (len(dic) - 1)

print(ans)

Submission status: Accepted

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

ans = 0
for x, y, z in zip(a, b, c):
    if x == y == z:
        continue
    elif x == y or y == z or z == x:
        ans += 1
    else:
        ans += 2

print(ans)

Submission status: Accepted

Solution code:
_, *a = open(0)
print(sum(len(set(i))-1 for i in zip(*a)))

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    a = input().rstrip()
    b = input().rstrip()
    c = input().rstrip()
    res = 0
    for i in range(n):
        d = [a[i], b[i], c[i]]
        res += len(set(d))-1
    print(res)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#coding:utf-8
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:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    a=input()
    b=input()
    c=input()
    ans=0
    for i in range(n):
        if a[i]!=b[i]:
            if b[i]!=c[i] and a[i]!=c[i]:
                ans+=2
            elif (b[i]!=c[i] and a[i]==c[i]) or b[i]==c[i]:
                ans+=1
        else:
            if b[i]!=c[i]:
                ans+=1
    print(ans)

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):
    l = [a[i], b[i], c[i]]
    ans += len(set(l)) - 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] == 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:
# coding: utf-8
import re
import math
import itertools
from copy import deepcopy
import random
from heapq import heappop,heappush
import time
import os
import queue
import sys
import datetime
from functools import lru_cache
readline=sys.stdin.readline
sys.setrecursionlimit(2000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
week=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_power(a,b):#aはbの累乗数か
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def facs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod_>0):A[a]%=mod_
    return A
def comb(n,r,mod_,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod_-2,mod_)*pow(fac[r],mod_-2,mod_))%mod_
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def floor_(n,x=1):
    return x*(n//x)
def ceil_(n,x=1):
    return x*((n+x-1)//x)
#################################### ########
# coding: utf-8
import re
import math
import itertools
from copy import deepcopy
import random
from heapq import heappop,heappush
import time
import os
import queue
import sys
import datetime
from functools import lru_cache
readline=sys.stdin.readline
sys.setrecursionlimit(2000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_power(a,b):#aはbの累乗数か
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def get_facs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def floor_(n,x=1):
    return x*(n//x)
def ceil_(n,x=1):
    return x*((n+x-1)//x)
###################################################
def main():
    N=int(input())
    A=input()
    B=input()
    C=input()
    ans=0
    for a in range(N):
        s=A[a]+B[a]+C[a]
        length=len(set(s))
        ans+=length-1
    print(ans)


main()

Submission status: Accepted

Solution code:
n = int(input())
A = input()
B = input()
C = input()
ans = 0
for abc in zip(A, B, C):
    ans += len(set(abc)) - 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = input()
B = input()
C = input()
ans = 0
for x, y, z in zip(A, B, C):
    x, y, z = sorted([x, y, z])
    if x != y and y != z:
        ans += 2
    elif x == y and y != z:
        ans += 1
    elif x != y and y == z:
        ans += 1
print(ans)

Submission status: Accepted

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

ans = 0
for a, b, c in zip(al, bl, cl):
    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())

ans = 0
for i in range(n):
  aa = a[i]
  bb = b[i]
  cc = c[i]
  if len(set([aa,bb,cc])) == 1:
    continue
  elif len(set([aa,bb,cc])) == 2:
    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):
    ans += len(set([a,b,c])) - 1

print(ans)

Submission status: Accepted

Solution code:
# Problem B - Touitsu

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

# initialization
min_count = 0
cur_char = ''

# string search
for i in range(N):
    tmp = []
    tmp.append(A[i])
    tmp.append(B[i])
    tmp.append(C[i])
    tmp = set(tmp)

    if len(tmp)>=3:
        min_count += 2
    elif len(tmp)==2:
        min_count += 1

# output
print(min_count)

Submission status: Accepted

Solution code:


import sys
from io import StringIO
# import bisect
from collections import Counter, deque
# from copy import copy, deepcopy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np
# from operator import xor
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():
    N=int(input())
    A=list(input())
    B=list(input())
    C=list(input())

    W=[[None]*3 for i in range(N)]
    for j in range(N):
        for i,k in zip([A,B,C],[0,1,2]):
            W[j][k]=i[j]

    val=0
    for k in W:
        mc=Counter(k).most_common()[0][1]
        val+=3-mc

    print(val)





resolve()

Submission status: Accepted

Solution code:
n = int(input())
a = input()
b = input()
c = input()
cnt = 0
for i in range(n):
    c1,c2,c3=0,0,0

    if b[i] ==a[i] and c[i]==b[i]:
        pass

    elif b[i] ==a[i] or c[i]==b[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()
ans = 0
c  ={}
for i in range(n):
    if a[i] not in c:  c[a[i]] = 1
    else:c[a[i] ] +=1
    if b[i] not in c:  c[b[i]] = 1
    else:c[b[i] ] +=1
    if C[i] not in c:  c[C[i]] = 1
    else:c[C[i]] +=1
    ans += len(c)-1
    c = {}
print(ans)