Problem:
Score : 100 points

Problem Statement

Two deer, AtCoDeer and TopCoDeer, are playing a game called Honest or Dishonest.
In this game, an honest player always tells the truth, and an dishonest player always tell lies.
You are given two characters a and b as the input. Each of them is either H or D, and carries the following information:

If a=H, AtCoDeer is honest; if a=D, AtCoDeer is dishonest.
If b=H, AtCoDeer is saying that TopCoDeer is honest; if b=D, AtCoDeer is saying that TopCoDeer is dishonest.

Given this information, determine whether TopCoDeer is honest.

Constraints

a=H or a=D.

b=H or b=D.

Input

The input is given from Standard Input in the following format:

a b

Output

If TopCoDeer is honest, print H. If he is dishonest, print D.

Sample Input 1

H H

Sample Output 1

H

In this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.

Sample Input 2

D H

Sample Output 2

D

In this input, AtCoDeer is dishonest. Hence, contrary to what he says, TopCoDeer is dishonest.

Sample Input 3

D D

Sample Output 3

H

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main()
{
    lli n, k;
    cin >> n >> k;
    if (n > 400)
        return 0;
    lli a[100005];
    lli ans = n;
    rep(i, n) cin >> a[i];
    rep(i, n)
    {
        bool used[2][100005] = {};
        used[0][0] = true;
        int cur = 0, nxt = 1;
        rep(j, n)
        {
            if (i == j)
                continue;
            for (int l = 0; l < k; l++) {
                if (used[cur][l]) {
                    //cout << "#j= " << j << " #l= " << l << endl;

                    if (l + a[j] < k) {
                        used[nxt][l + a[j]] = true;
                    }
                }
            }
            swap(cur, nxt);
        }
        rrep(j, k)
        {
            if (used[cur][j]) {
                //cout << "#i= " << i << "#j= " << j << endl;
                if (j + a[i] > k) {
                    ans--;
                }
                break;
            }
        }
    }
    cout << ans << endl;
}