Problem:
Score : 100 points

Problem Statement

Given is a string S representing the day of the week today.

S is SUN, MON, TUE, WED, THU, FRI, or SAT, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively.

After how many days is the next Sunday (tomorrow or later)?

Constraints

S is SUN, MON, TUE, WED, THU, FRI, or SAT.

Input

Input is given from Standard Input in the following format:

S

Output

Print the number of days before the next Sunday.

Sample Input 1

SAT

Sample Output 1

1

It is Saturday today, and tomorrow will be Sunday.

Sample Input 2

SUN

Sample Output 2

7

It is Sunday today, and seven days later, it will be Sunday again.

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

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <list>
#include <queue>
#include <string>
#include <vector>
using namespace std;

#define ll long long

template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

const ll INF = 1LL << 60;
const ll MAX = 100100;
const ll MAX_N = 100100;
const ll MAX_M = 100100;

void aprint(vector<int> &a, int N) {
    for(int i = 0; i < N; i++) {
        if(i)
            cout << " ";
        cout << a[i];
    }
    cout << endl;
}

void MergeCompare(vector<int> &a, int left, int mid, int right) {
    vector<int> buf;

    for(int i = left; i < mid; i++) {
        buf.push_back(a[i]);
    }
    for(int i = right - 1; i >= mid; i--) {
        buf.push_back(a[i]);
    }

    int iterator_left = 0;
    int iterator_right = (int)buf.size() - 1;
    for(int i = left; i < right; i++) {
        if(buf[iterator_left] <= buf[iterator_right]) {
            a[i] = buf[iterator_left];
            iterator_left++;
        } else {
            a[i] = buf[iterator_right];
            iterator_right--;
        }
    }
}

void MergeSort(vector<int> &a, int left, int right) {
    int N = a.size();
    if(right - left == 1) {
        return;
    }
    int mid = left + (right - left) / 2;
    // cout << "left: " << left << endl;
    // cout << "mid: " << mid << endl;
    // cout << "right: " << right << endl;
    MergeSort(a, left, mid);
    MergeSort(a, mid, right);

    MergeCompare(a, left, mid, right);
    aprint(a, N);
}

int main() {
    string s;
    int ans = 0;
    cin >> s;
    if(s == "SUN") {
        ans = 7;
    } else if(s == "MON") {
        ans = 6;
    } else if(s == "TUE") {
        ans = 5;
    } else if(s == "WED") {
        ans = 4;
    } else if(s == "THU") {
        ans = 3;
    } else if(s == "FRI") {
        ans = 2;
    } else if(s == "SAT") {
        ans = 1;
    }
    cout << ans << endl;
}