B - Full House 3
Source: atcoder
Difficulty: 250

Problem Statement
We have seven cards.  The
i
-th card
(i=1,\ldots,7)
has an integer
A_i
written on it.
Determine whether it is possible to choose five of them so that the chosen cards form a full house.
A set of five cards is called a full house if and only if the following conditions are satisfied:
For different integers
x
and
y
, there are three cards with
x
and two cards with
y
.
Constraints
A_i
is an integer between
1
and
13
, inclusive.
Input
The input is given from Standard Input in the following format:
A_1
A_2
A_3
A_4
A_5
A_6
A_7
Output
If a full house can be formed by choosing five cards, print
Yes
; otherwise, print
No
.
Sample Input 1
1 4 1 4 2 1 3
Sample Output 1
Yes
For example, by choosing the cards
(1,1,1,4,4)
, we can form a full house.
Sample Input 2
11 12 13 10 13 12 11
Sample Output 2
No
No five cards chosen from the seven cards form a full house.
Sample Input 3
7 7 7 7 7 7 7
Sample Output 3
No
Note that five identical cards do not form a full house.
Sample Input 4
13 13 1 1 7 4 13
Sample Output 4
Yes

C++ solution:
#include <bits/stdc++.h>
#define x first
#define y second

using namespace std;
typedef long long i64;
typedef array<int, 3> arr;
typedef pair<int, int> PII;

signed main() {
	cin.tie(nullptr)->sync_with_stdio(false);
	
	map<int, int> mp;
	for (int i = 0; i < 7; i++) {
		int x;
		cin >> x;
		mp[x]++;
	}
	
	for (auto [x, xcnt] : mp) {
		for (auto [y, ycnt] : mp) if (x != y) {
			if (xcnt >= 3 && ycnt >= 2) {
				cout << "Yes\n";
				return 0;
			}
		}
	}
	
	cout << "No\n";
	
	return 0;
}

Go solution:
package main

import (
	"fmt"
)

func Solve() {
	var arr [14]int
	var tmp int
	for i := 0; i < 7; i++ {
		fmt.Scan(&tmp)
		arr[tmp]++
	}
	for i := 1; i <= 13; i++ {
		for j := 1; j <= 13; j++ {
			if i != j && arr[i] >= 3 && arr[j] >= 2 {
				fmt.Println("Yes")
				return
			}
		}
	}
	fmt.Println("No")
}

func main() {
	Solve()
}

Java solution:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception {
        try (var br = new BufferedReader(new InputStreamReader(System.in))) {
            String[] numbers = br.readLine().split(" ");
            Arrays.sort(numbers);

            int[] counts = new int[numbers.length];

            boolean hasThree = false;
            boolean hasTwo = false;
            
            String buffer = "";
            int stackIndex = 0;
            for (int i = 0; i < numbers.length; i++) {
                if (!numbers[i].equals(buffer)) {
                    buffer = numbers[i];
                    stackIndex = i;
                    counts[stackIndex]++;
                } else {
                    counts[stackIndex]++;
                }
            }

            // 3枚以上同じ値があるインデックス
            int threeId = -1;
            for (int i = 0; i < counts.length; i++) {
                if (counts[i] >= 3) {
                    threeId = i;
                    hasThree = true;
                }
            }
            for (int i = 0; i < counts.length; i++) {
                if (i != threeId && counts[i] >= 2) {
                    hasTwo = true;
                }
            }

            System.out.println(hasTwo && hasThree ? "Yes" : "No");
        }
    }
}

JavaScript solution:
const input = require("fs").readFileSync("/dev/stdin", "utf8");

main(input);

function main(input) {
  const A = input.trim().split(" ").map(n => Number(n)).sort();
  
  if (new Set(A).size === 1) {
    return console.log("No");
  }
  
  const kind = {};
  
  for (const a of A) {
    if (!kind[a]) {
      kind[a] = 1;
      continue;
    }
    
    kind[a]++;
  }
  
  const values = Object.values(kind).sort((a, b) => b - a);
  
  if (values[0] < 3 || values[1] < 2) {
    return console.log("No");
  }
  
  console.log("Yes");
}

Python solution:
a=list(map(int,input().split()))
count=[0 for i in range(14)]
for i in range(7):
    count[a[i]]+=1
count.sort(reverse=True)
if count[0]>2 and count[1]>1:
    print("Yes")          
else:
    print("No")

Ruby solution:
a=gets.split.map(&:to_i).tally
puts a.values.count{_1>2}>0&&a.values.count{_1>1}>1 ? "Yes" : "No"