Go: package main

import (
        "fmt"
)

func main() {
        var weeks = []string{"Thursday",
                "Friday",
                "Saturday",
                "Sunday",
                "Monday",
                "Tuesday",
                "Wednesday"}

        for {
                var m, d int
                _, err := fmt.Scanf("%d %d", &m, &d)
                if err != nil || m + d == 0 {
                        break
                }
                var days int

                for {
                        lm, ld := getLastDay(m, d)
                        if lm + ld == 0 {
                                break
                        }
                        days++
                        m = lm
                        d = ld
                }
                fmt.Println(weeks[days%7])
        }
}

func getLastDay(m int, d int) (lm int, ld int) {
        if m == 1 && d == 1 {
                return 0, 0
        }

        if d > 1 {
                return m, d-1
        } else {
                if m == 3 {
                        return m-1, 29
                }
                if m == 3 || m == 5 || m == 7 || m == 10 || m == 12 {
                        return m-1, 30
                } else {
                        return m-1, 31
                }
        }
}

C++: #include <iostream>
using namespace std;

int main ()
{
	int m[13]={0,4,7,1,4,6,7,4,7,3,5,1,3};
	string a[7]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
	int M,D;
	while(cin>>M>>D&&M&&D)
	{
		int x=m[M]-2;
		cout<<a[(x+D)%7]<<endl;
		
	}
	
	
	
	
}

C++: #include <stdio.h>

int main()
{
  int y, d, m;
  int h;
  char *date[] = {"Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday"};

  for(;;)
    {
      int Y, C, G;
      y = 2004;
      scanf("%d %d", &m, &d);

      if(d == 0 || m == 0) break;
      if(m == 1 || m == 2)
	{
	  m += 12;
	  y--;
	}

      Y = y%100;
      C = y/100;
      G = 5*C + C/4;

      h = (d + (26*(m + 1)/10) + Y + Y/4 + G)%7;
      printf("%s\n", date[h]);
    }

  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  
  int a,b;
  cin >> a >> b;
  while(a != 0){
    
    for(int i = 1;i < a;i++){
      if(i==1 || i==3 || i==5 || i==7 || i==8 || i==10){
	b += 31;
      }
      else if(i==4 || i==6 || i==9 || i==11){
	b += 30;
      }
      else if(i == 2){
	b += 29;
      }
    }

    if(b%7 == 1) cout << "Thursday" << endl;
    else if(b%7 == 2) cout << "Friday" << endl;
    else if(b%7 == 3) cout << "Saturday" << endl;
    else if(b%7 == 4) cout << "Sunday" << endl;
    else if(b%7 == 5) cout << "Monday" << endl;
    else if(b%7 == 6) cout << "Tuesday" << endl;
    else cout << "Wednesday" << endl;
    cin >> a >> b;
  }
  return (0);
}

C++: #include <iostream>
#include <string>
using namespace std;
int main(void){
	const int DPM[] = {31,29,31,30,31,30,31,31,30,31,30,31};
	const string DAYS[] = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
	int month,date;
	while(cin >> month >> date){
		if(month==0)break;
		int day = 3;
		for(int i=1;i<month;++i) day += DPM[i-1];
		day = (day+date-1)%7;
		cout << DAYS[day] << "\n";
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>

int main(int argc, const char * argv[])
{
    int month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    int m, d;
    while (scanf("%d %d", &m, &d) != 0) {
        int cnt = 0;
        if (m == 0 && d == 0) {
            return 0;
        }
        for (int i = 0; i < m - 1; i++) {
            cnt += month[i];
        }
        cnt += d;

        if (cnt % 7 == 0) {
            printf("Wednesday\n");
        }
        if (cnt % 7 == 1) {
            printf("Thursday\n");
        }
        if (cnt % 7 == 2) {
            printf("Friday\n");
        }
        if (cnt % 7 == 3) {
            printf("Saturday\n");
        }
        if (cnt % 7 == 4) {
            printf("Sunday\n");
        }
        if (cnt % 7 == 5) {
            printf("Monday\n");
        }
        if (cnt % 7 == 6) {
            printf("Tuesday\n");
        }
    }
    return 0;
}

C++: #include <iostream>

auto initDays (int * a , int n , int & prev) -> void
{
    for (auto i = 1; i <= n; ++ i)
    {
        prev = (prev + 1) % 7;
        a [i] = prev;
    }
}

auto main () -> int
{
    const char * table [] =
    {
        "Monday" ,
        "Tuesday" ,
        "Wednesday" ,
        "Thursday" ,
        "Friday" ,
        "Saturday" ,
        "Sunday"
    };

    int day [13][32] = {{}};

    int p = 2;
    initDays (day [1] , 31, p);
    initDays (day [2] , 29, p);
    initDays (day [3] , 31, p);
    initDays (day [4] , 30, p);
    initDays (day [5] , 31, p);
    initDays (day [6] , 30, p);
    initDays (day [7] , 31, p);
    initDays (day [8] , 31, p);
    initDays (day [9] , 30, p);
    initDays (day [10] , 31, p);
    initDays (day [11] , 30, p);
    initDays (day [12] , 31, p);

    int m , d;
    while (std::cin >> m >> d && m && d)
    {
        std::cout << table [day [m] [d]] << std::endl;
    }
}

C++: #include <iostream>
#include <string>
using namespace std;
int countup_days(int m, int d) // m月d日が、1月1日から何日目か返す
{
    int         sum     = 0;
    const int   month[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,};
    for (int i=1; i<m; i++) {
        sum += month[i];
    }
    return sum + d -1;
}
string what_day(int days) // 1/1からdays日後は何曜日か文字列を返す
{
    string day[]   = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"};
    return day[days%7];
}
int main()
{
    int m, d;
    while (true) {
        cin >> m >> d;
        if (m==0 && d==0)
            break;
        cout << what_day(countup_days(m, d)) << endl;
    }
}

C++: #include <stdio.h>

int main(void) {
  int i, j, k, m, d, ans;
  int m0[13] = {0, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335};
  char w[7][25] = {
    "Wednesday",
    "Thursday",
    "Friday",
    "Saturday",
    "Sunday",
    "Monday",
    "Tuesday"
  };
  while( 1 ) {
    scanf("%d%d", &m, &d);
    if(!m && !d) break;
    ans = m0[m] + d;
    ans %= 7;
    printf("%s\n", w[ans]);
  }
  return 0;
}

C++: #include <iostream>
#include <string>

using namespace std;

int main() {
    int m, d, past;
    int day[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
    string week[] = { "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday" };
    while (cin >> m >> d, m != 0) {
        past = 0;
        for (int i = 0; i < m - 1; i++) {
            past += day[i];
        }
        past += d - 1;
        cout << week[past % 7] << endl;
    }

    return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.wdt", "r", stdin);
	// 2004/01/01 is Thursday
	const string week[] = {
	"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };
	const int days[] = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; 
	string str = "";
	
	while (getline (cin, str ) ){
		int day, month;		
		stringstream ss(str);
		ss >> month >> day;
		if (day == 0 && month == 0){
			break;
		} // end if
		int num = 0;
		int i;
		for (i = 0; i < month; ++i){
			num += days[i];
		} // end for
		num += day;
		cout << "num: " << num << endl;
		cout << week [( num - 1 ) % 7 + 3 ] << endl;
	} // end for
		
	return 0;
}