func_code_string: #include <bits/stdc++.h>   std::string colors( RGBYW );   struct Card {     int color;     int number;     bool operator<(const Card& rhs) const {       if (color == rhs.color)         return (number < rhs.number);       else         return color < rhs.color;     }   };   int mapColor(char color) {     size_t pos = colors.find_first_of(color);     if (pos != std::string::npos) {       return pos;     }     return -1;   }   bool isNumberHinted(int number, long long hint) {     long long mask = (1 << number) << 5;     return hint & mask;   }   bool isColorHinted(int color, long long hint) {     long long mask = (1 << color);     return hint & mask;   }   int bitCount(long long n) {     int count = 0;     while (n > 0) {       count++;       n = n & (n - 1);     }     return count;   }   void codeforces442a() {     int n = 0;     int minAns = 10;     std::cin >> n;     std::set<Card> cards;     for (int i = 0; i < n; ++i) {       Card card;       char color;       char number;       std::cin >> color;       std::cin >> number;       card.color = mapColor(color);       card.number = number -  1 ;       cards.insert(card);     }     if (cards.size() == 1) {       std::cout <<  0 ;       return;     }     for (long long hint = 0; hint < (1 << 10); ++hint) {       if (bitCount(hint) >= minAns) continue;       bool isValid = true;       for (std::set<Card>::iterator i = cards.begin();            i != cards.end() && isValid; ++i)         for (std::set<Card>::iterator j = cards.begin();              j != cards.end() && isValid; ++j) {           if (i != j) {             bool areHintedAsDifferent = false;             Card firstCard = *i;             Card secondCard = *j;             if (firstCard.color == secondCard.color) {               areHintedAsDifferent = isNumberHinted(firstCard.number, hint) ||                                      isNumberHinted(secondCard.number, hint);             } else if (firstCard.number == secondCard.number) {               areHintedAsDifferent = isColorHinted(firstCard.color, hint) ||                                      isColorHinted(secondCard.color, hint);             } else {               areHintedAsDifferent = isNumberHinted(firstCard.number, hint) ||                                      isNumberHinted(secondCard.number, hint) ||                                      isColorHinted(firstCard.color, hint) ||                                      isColorHinted(secondCard.color, hint);             }             if (!areHintedAsDifferent) {               isValid = false;             }           }         }       if (isValid) {         int numHints = bitCount(hint);         if (minAns > numHints) {           minAns = numHints;         }       }     }     std::cout << minAns;   }   int main() {     codeforces442a();     return 0;   }   