Go: package main

import "fmt"

func main() {
	days := [12]int{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
	weekday := [7]string{"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}

	for {
		var m, d int
		fmt.Scan(&m, &d)
		if m == 0 {
			break
		}

		for i := 0; i < m-1; i++ {
			d += days[i]
		}

		fmt.Println(weekday[d%7])
	}
}

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

int count_day(int a){
  int i;
 
  switch(a){
  case 1:
    i = 0;
    break;
  case 2:
    i = 31;
    break;
  case 3:
    i = 60;
    break;
  case 4:
    i = 91;
    break;
  case 5:
    i = 121;
    break;
  case 6:
    i = 152;
    break;
  case 7:
    i = 183;
  case 8:
    i = 213;
    break;
  case 9:
    i = 244;
    break;
  case 10:
    i = 274;
    break;
  case 11:
    i = 305;
    break;
  case 12:
    i = 335;
  default:
    i = 0;
  }

  return i;
}


int main(){
  int month, day, convert_day;

  while(scanf("%d %d", &month, &day) != EOF){

    if(month == 0) break;

    convert_day = count_day(month);
    day = convert_day + day;

  switch(day % 7){ //7で割り切れるやつが水曜日
  case 0:
    cout << "Wednesday" << endl;
    break;
  case 1:
    cout << "Thursday" << endl;
    break;
  case 2:
    cout << "Friday" << endl;
    break;
  case 3:
    cout << "Saturday" << endl;
    break;
  case 4:
    cout << "Sunday" << endl;
    break;
  case 5:
    cout << "Monday" << endl;
    break;
  case 6:
    cout << "Tuesday" << endl;
    break;
  default:
    break;
  }
  }


  return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
	
	int Md[12] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30}; 
	int month;
	int day;
		
	while( cin >> month >> day ) {
	
	if( month == 0 && day == 0)
	break;
	
	if( month == 1 && day == 1) {
		
	cout << "Thursday\n";
	continue;
	
	}
	if( month == 1 && day == 2) {
		
	cout << "Friday\n";
	continue;
	
	}
	if( month == 1 && day == 3) {
		
	cout << "Saturday\n";
	continue;
	
	}
	if( month == 1 && day == 4) {
		
	cout << "Sunday\n";
	continue;
	
	}
	for(int i=0;i<month;i++)
	day += Md[i];
	
	switch( (day - 4) % 7) {
		
		case 1:
		cout << "Monday\n";
		break;
		
		case 2:
		cout << "Tuesday\n";
		break;
		
		case 3:
		cout << "Wednesday\n";
		break;
		
		case 4:
		cout << "Thursday\n";
		break;
		
		case 5:
		cout << "Friday\n";
		break;
		
		case 6:
		cout << "Saturday\n";
		break;
		
		default:
		cout << "Sunday\n";
		break;
		
	}
	
	//cout << day; 
}
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
 
#define REP(i,b,n) for(int i=b;i<n;++i)
#define REPR(i,b,n) for(int i=n-1;i>=b;--i)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define EACH(i, c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define BIT(n, b) ((n>>b) & 1)
#define PI acos(-1.0)

using namespace std;

static const double EPS = 1e-9;
typedef pair<int, int> pii;
typedef long long ll;

int mday[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string week[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};

int main(){
		
	int m, d;
	
	while(cin>>m>>d, (m||d)){
		
		int dsum = d+2;
		
		for(int i = 0; i < m; ++i){
			dsum += mday[i];
		}
		
		cout << week[dsum%7] << endl;
	}
	
	return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <string>
using namespace std;

int main() {
	int m, d,n;
	while (1) {
		cin >> m >> d;
		if (m == 0)
			break;
		n = d-1;
		switch (m) {
		case 12:
			n += 30;
		case 11:
			n += 31;
		case 10 :
			n += 30;
		case 9:
			n += 31;
		case 8:
			n += 31;
		case 7:
			n += 30;
		case 6:
			n += 31;
		case 5 :
			n += 30;
		case 4:
			n += 31;
		case 3:
			n += 29;
		case 2:
			n += 31;
		}
		switch (n % 7) {
		case 0:
			cout << "Thursday\n";
			break;
		case 1:
			cout << "Friday\n";
			break;
		case 2:
			cout << "Saturday\n";
			break;
		case 3:
			cout << "Sunday\n";
			break;
		case 4:
			cout << "Monday\n";
			break;
		case 5:
			cout << "Tuesday\n";
			break;
		case 6:
			cout << "Wednesday\n";
			break;
		}
	}
}

C++: #include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
	const string day[]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
	const int month[]={31,31,29,31,30,31,30,31,31,30,31,30};
	int m,d;
	while(cin>>m>>d,m||d){
		int res=2;
		for(int i=1;i<m;++i){
			res+=month[i%12];
		}
		res+=d;
		cout<<day[res%7]<<endl;
	}
	return 0;
}

C++: #include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main()
{
  int days[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

  int month, day;
  while(true)
  {
    cin >> month >> day;
    if(!month && !day)
      break;
    switch((days[month - 1] + day) % 7)
    {
    case 1:
      cout << "Thursday";
      break;
    case 2:
      cout << "Friday";
      break;
    case 3:
      cout << "Saturday";
      break;
    case 4:
        cout << "Sunday";
      break;
    case 5:
      cout << "Monday";
      break;
    case 6:
      cout << "Tuesday";
      break;
    case 0:
      cout << "Wednesday";
    }
    cout << endl;
  }

  return 0;
}

C++: #include <cmath>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cstdio>
#include <cctype>
#include <queue>
#include <complex>
#include <climits>

typedef long long ll;

using namespace std;

int GetDayOfWeek(int nYear, int nMonth, int nDay)
{
	if (nMonth == 1 || nMonth == 2) {
		nYear--;
		nMonth += 12;
	}
	return (nYear + nYear / 4 - nYear / 100 + nYear / 400 + (13 * nMonth + 8) / 5 + nDay) % 7;
}


int main(){
	int a, b;
	while(cin >> a >> b){
		if(a == 0 && b == 0) break;
		string str;
		int s = GetDayOfWeek(2004, a, b);
		switch(s){
		case 0:
			str = "Sunday";
			break;
		case 1:
			str = "Monday";
			break;
		case 2:
			str = "Tuesday";
			break;
		case 3:
			str = "Wednesday";
			break;
		case 4:
			str = "Thursday";
			break;
		case 5:
			str = "Friday";
			break;
		case 6:
			str = "Saturday";
			break;
		}
	
	cout << str << endl;

	}

    return 0;
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<string.h>
#include<vector>
#include<math.h>
#include<queue>
#include <algorithm>
#include<functional>
#include<cstdlib>
#include<cmath>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

typedef pair<int, int> P;
typedef pair<long, long> LP;
typedef pair<int, P> PP;
typedef pair<long, LP> LPP;

int N;

int dy[] = { 0, 0, 1, -1, 0 };
int dx[] = { 1, -1, 0, 0, 0 };

int day = 0, month = 0;

void input(void) {
	CI day >> month;
	return;
}


int main(void) {
	int weekday = 0;
	int y = 2004;

	string dayname[] = { "Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday" };
	while (true) {
		input();
		if (day == 0) {
			break;
		}
		if (month < 3) {
			y--; month += 12;
		}
		weekday =  (y + y / 4 - y / 100 + y / 400 + (13 * month + 8) / 5 + day) % 7;
		y = 2004;
		CO dayname[weekday] E
	}
	
	return 0;
}