Problem:
Score : 100 points

Problem Statement

You are given a 4-character string S consisting of uppercase English letters.
Determine if S consists of exactly two kinds of characters which both appear twice in S.

Constraints

The length of S is 4.

S consists of uppercase English letters.

Input

Input is given from Standard Input in the following format:

S

Output

If S consists of exactly two kinds of characters which both appear twice in S, print Yes; otherwise, print No.

Sample Input 1

ASSA

Sample Output 1

Yes

S consists of A and S which both appear twice in S.

Sample Input 2

STOP

Sample Output 2

No

Sample Input 3

FFEE

Sample Output 3

Yes

Sample Input 4

FREE

Sample Output 4

No

Solution in C# (Mono 4.6.2.0) (judge verdict: Runtime Error)

using System;
using System.IO;
using System.Linq;
class sol
{
    static StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    static Scan sc = new Scan();

    static void Main(string[] args)
    {
        int n = sc.Int;
        var d = sc.IntArr;
        Array.Sort(d);
        foreach (int j in d)
        {
            //Console.WriteLine(j);
        }
        int ans = 0;
        int i = d.Count<int>();
        //Console.WriteLine(i);
        if(d[i/2-1] - d[i/2] == 0)
        {
            ans = 0;
        }
        else
        {
            ans = d[i/2] - d[i/2 - 1];
            //Console.WriteLine(d[i / 2] + "," + d[i / 2 -1]);
        }
        Prt(ans);
        sw.Flush();
    }
    static void Prt(string a) => sw.WriteLine(a);
    static void Prt(params object[] a) => Prt(string.Join(" ", a));
}

class Scan
{
    StreamReader sr;
    public Scan() { sr = new StreamReader(Console.OpenStandardInput()); }
    public string Str => sr.ReadLine().Trim();
    public int Int => int.Parse(Str);
    public string[] StrArr => Str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
    public int[] IntArr => StrArr.Select(int.Parse).ToArray();
    T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
    T cv<T>(string s) => ct<T, int>(int.Parse(s));
    public void Multi<T, U, V>(out T a, out U b, out V c)
    { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); }
}