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 <stdio.h>

int zeller(int y, int m, int d){
	if(m <= 2){
		y--;
		m += 12;
	}

	int J = (int)(y/100);
	int K = y - (int)(y/100)*100;

	return (d + (int)((m+1)*26/10) + K + (int)(K/4) + (int)(J/4) + 5 * J + 5) % 7;
}

int main(void){
	int y, m, d;
	y = 2004;
	char *wday[7] = {
		"Monday",
		"Tuesday",
		"Wednesday",
		"Thursday",
		"Friday",
		"Saturday",
		"Sunday",
	};
	while(true){
		scanf("%d %d", &m, &d);
		if(m == 0){ break; }
		int w = zeller(y, m , d);
		puts(wday[w]);
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(void){
	int m,d;
	string day[7]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday",};
	int box[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	int sum;
	int h;
	while(1){
		cin>>m>>d;
		if(m==0&&d==0)	break;
		sum=d;
		for(int i=0;i<m-1;i++){
			//cout<<i<<endl;
			sum+=box[i];
		}
		//cout<<sum<<endl;
		h=sum%7;
		cout<<day[h]<<endl;
	}
	return 0;
}

C++: #include <stdio.h>

static const char *days[7]=
{
    "Sunday",
    "Monday",
    "Tuesday",
    "Wednesday",
    "Thursday",
    "Friday",
    "Saturday",
    
};

int main(void)
{
    int base=4;
    int monthbase[12]=
    {0,3,4,0,2,5,0,3,6,1,4,6,};
    while(1)
    {
        int m,d;
        scanf("%d%d",&m,&d);
        if(m==0)
            break;
        puts(days[(base+monthbase[m-1]+d-1)%7]);
    }
    return 0;
}

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

using namespace std;

int min(){
	string y[7] = {"Wednesday", "Thrsday", "Frinday", "Saturday", "Sunday", "Monday", "Tuesday"};
	int mon[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

	while(1){
		int m, d;
		cin >> m >> d;
		if(m == 0) break;

		while(m != 0){
			d = d + mon[m-1];
		}
		cout << y[d%7] <<endl;
	}
}

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)
      break;
    switch((days[month - 1] + day - 1) % 7)
    {
    case 0:
      cout << "Thursday";
      break;
    case 1:
      cout << "Friday";
      break;
    case 2:
      cout << "Saturday";
      break;
    case 3:
        cout << "Sunday";
      break;
    case 4:
      cout << "Monday";
      break;
    case 5:
      cout << "Tuesday";
      break;
    case 6:
      cout << "Wednesday";
    }
    cout << endl;
  }

  return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
	string s[]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
	int d[]={31,29,31,30,31,30,31,31,30,31,30,31};
	int a,b;
	while(cin>>a>>b,a+b){
		int co=b;
		a--;
		while(a){a--;co+=d[a];}
		cout<<s[co%7]<<endl;
	}
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <set>

using namespace std;

int main()
{
	while (1)
	{
		int a = 0;
		int b = 0;
		cin >> a;
		cin >> b;
		if (a == 0)break;
		if (a == 2)b += 31;
		if (a == 3)b += 31 + 29;
		if (a == 4)b += 60 + 31;
		if (a == 5)b += 91 + 30;
		if (a == 6)b += 121 + 31;
		if (a == 7)b += 152 + 30;
		if (a == 8)b += 182 + 31;
		if (a == 9)b += 213 + 31;
		if (a == 10)b += 30 + 244;
		if (a == 11)b += 31 + 274;
		if (a == 12)b += 30 + 305;
		if (b % 7 == 1)cout << "Thursday" << endl;
		if (b % 7 == 1)cout << "Friday" << endl;
		if (b % 7 == 1)cout << "Saturday" << endl;
		if (b % 7 == 1)cout << "Sunday" << endl;
		if (b % 7 == 1)cout << "Monday" << endl;
		if (b % 7 == 1)cout << "Tuesday" << endl;
		if (b % 7 == 1)cout << "Wednesday" << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
using namespace std;

int main(){
	int m,d;
	while(cin >> m >> d){
		if(m == 0 && d == 0)break;
		int n = 0;
		for(int i = 1; i < m; i++){
			if(i == 2)n += 29;
			else if(i == 4 || i == 6 || i == 9 || i == 11)n += 30;
			else n += 31;
		}
		n += d;
		switch(n % 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;
		}
	}
}

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

int main()
{
	int monthday[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	const char *weekday[7] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"};
	
	int month, day;
	
	while(cin >> month >> day, month)
	{
		if(month == 0) break;
		
		int w = day - 1;
		for(int i = 1; i < month; i++)
		    w += monthday[i];
		cout << weekday[w % 7] << endl;
	}
	return 0;
}

C++: #include <iostream>

using std::cout;
using std::endl;

int getDays(int month, int day);

int main()
{
    int month, day;
    while (true) {
        std::cin >> month >> day;

        if (month == 0 && day == 0) {
            break;
        }

        int days = getDays(month, day);
        int mod = days % 7;
        switch (mod) {
        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;
        case 0:
            cout << "Wednesday" << endl;
            break;
        }
    }

    return 0;
}

int getDays(int month, int day)
{
    int days = 31 * (month - 1) + day;

    int minus = 0;
    if (month > 2) {
        minus += 2;
    }
    if (month > 4) {
        minus++;
    }
    if (month > 6) {
        minus++;
    }
    if (month > 9) {
        minus++;
    }
    if (month > 11) {
        minus++;
    }

    return (days -= minus);
}