A - Hamming Distance
Source: atcoder
Difficulty: 100

Problem Statement
You are given a positive integer
N
and two strings
S
and
T
, each of length
N
and consisting of lowercase English letters.
Find the Hamming distance between
S
and
T
. That is, find the number of integers
i
such that
1 \leq i \leq N
and the
i
-th character of
S
is different from the
i
-th character of
T
.
Constraints
1\leq N \leq 100
N
is an integer.
Each of
S
and
T
is a string of length
N
consisting of lowercase English letters.
Input
The input is given from Standard Input in the following format:
N
S
T
Output
Print the answer.
Sample Input 1
6
abcarc
agcahc
Sample Output 1
2
S
and
T
differ in the 2nd and 5th characters, but not in other characters. Thus, the answer is
2
.
Sample Input 2
7
atcoder
contest
Sample Output 2
7
Sample Input 3
8
chokudai
chokudai
Sample Output 3
0
Sample Input 4
10
vexknuampx
vzxikuamlx
Sample Output 4
4

C++ solution:
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<ll> vll;

int main() {
  int n;
  string s, t;
  cin >> n >> s >> t;
  int result = 0;
  for (int i = 0; i < n; ++i) if (s[i] != t[i]) result++;
  cout << result << endl;

  return 0;
}

Go solution:
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
    scanner := bufio.NewScanner(os.Stdin)

    // 整数 n の読み取り
    scanner.Scan()
    nStr := scanner.Text()
    n, err := strconv.Atoi(nStr)
    if err != nil {
        fmt.Println("整数の読み取りに失敗しました:", err)
        return
    }

    // 文字列 s の読み取り
    scanner.Scan()
    s := scanner.Text()

    // 文字列 t の読み取り
    scanner.Scan()
    t := scanner.Text()

    // 異なる文字数のカウント
    diffCount := 0
    for i := 0; i < n; i++ {
        if s[i] != t[i] {
            diffCount++
        }
    }

    fmt.Println(diffCount)
}

Java solution:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer; 

public class Main {

    // メインの処理
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();

        // ここに解答ロジックを記述します
        int n = fs.nextInt(); // 整数 N を読み込む
        String s = fs.next(); // 文字列 S を読み込む
        String t = fs.next(); // 文字列 T を読み込む
        int total=0;
        
        // ここにハミング距離を計算するロジックを追加します（今回は入力処理のみ）
        for(int i = 0; i < n; i++){
            if(s.charAt(i) != t.charAt(i)) {
                total++;
            }
        }

        // 計算結果 total を出力
        fs.println(total);

        // 出力バッファをフラッシュして終了
        fs.flush();
    
    }

    
    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");
        PrintWriter out = new PrintWriter(System.out);

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        void print(Object obj) {
            out.print(obj);
        }

        void println(Object obj) {
            out.println(obj);
        }

        void flush() {
            out.flush();
        }
    }


}

JavaScript solution:
process.stdin.setEncoding('utf8');
let input = '';

process.stdin.on('data', chunk => input += chunk);

process.stdin.on('end', () => {
  input = input.split('\n');
  let idx = 0;
  const N = parseInt(input[idx++]);
  const S = input[idx++];
  const T = input[idx++];
  
  let result = 0;
  
  for (let i = 0; i < N; i++) {
    if (S[i] !== T[i]) result++;
  }
  
  console.log(result);
});

Python solution:
N = int(input())
S = input()
T = input()

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

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

print(cnt)

Ruby solution:
# frozen_string_literal: true

n = gets.to_i
s = gets.chomp
t = gets.chomp

distance = 0
n.times do |i|
  distance += 1 if s[i] != t[i]
end

puts distance