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>
#include<string>

int monthes[]={0,31,29,31,30,31,30,31,31,30,31,30,31};

std::string day[]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};

int main(void){
    int m,d,n;
    while(std::cin>>m>>d){
        if(m==0&&d==0) break;
        n=0;
        int i;
        for(i=1;i<m;i++) n+=monthes[i];
        n+=monthes[i]-d+1;
        std::cout<<day[n%7]<<std::endl;
    }
    return 0;
}

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

using namespace std;

int monthTable[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int date[13];
string dayTable[7] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"};

void initialize(){
    date[0] = 0;
    date[1] = monthTable[1];
    for ( int i = 2; i <= 12; i++ ){
	date[i] = date[i-1] + monthTable[i];
    }
}

main(){
    initialize();
    int month, day;
    while( cin >> month >> day && month){
	cout << dayTable[(date[month-1]+day-1)%7] << endl;
    }
}

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

int day(int m, int d){
	if(m==1)return d;
	if(m==2)return 31+d;
	if(m==3)return 60+d;
	if(m==4)return 91+d;
	if(m==5)return 121+d;
	if(m==6)return 152+d;
	if(m==7)return 182+d;
	if(m==8)return 213+d;
	if(m==9)return 244+d;
	if(m==10)return 274+d;
	if(m==11)return 305+d;
	if(m==12)return 366-d;
}

int main(){
	while(1){
		int m,d;
		std::cin>>m>>d;
		if(m==0)return 0;
		std::string s;
		if(day(m,d)%7==1)s="Thursday";
		if(day(m,d)%7==2)s="Friday";
		if(day(m,d)%7==3)s="Saturday";
		if(day(m,d)%7==4)s="Sunday";
		if(day(m,d)%7==5)s="Monday";
		if(day(m,d)%7==6)s="Tuesday";
		if(day(m,d)%7==0)s="Wednesday";
		std::cout<<s<<std::endl;
	}
}

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

int day[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string date[7] = {
    "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"
};

int main() {
    int m, d;
    while (cin >> m >> d, m && d) {
        int t = d + accumulate(day, day + m - 1, 0);
        cout << date[(t + 2) % 7] << endl;
    }
    return 0;
}

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

using namespace std;

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

int main()
{
  int month, day;
  while (scanf("%d %d ", &month, &day) == 2) {
    if (month == 0 && day == 0) {break;}
    int sumday = 0;
    for (int i = 0; i < month - 1; i++) {
      sumday += mday[i];
    }
    sumday += day;
    cout << cal[(sumday + 2) % 7] << endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

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

	while(cin >> month >> day)
	{
		if(month == 0 && day == 0)    break;

		int year = 2004;
		
		if(month == 1){
			year = 2003;
			month = 13;
		}
		if(month == 2){
			year = 2003;
			month = 14;
		}

		year %= 100;

		youbi = (day + ((26*(month+1))/10) + year + (year/4) - 2*(year/100) + (year/100)/4);

		switch(youbi%7)
		{
			case 1: cout << "Sunday" << endl; break;
			case 2: cout << "Monday" << endl; break;
			case 3: cout << "Tuesday" << endl; break;
			case 4: cout << "Wednesday" << endl; break;
			case 5: cout << "Thursday" << endl; break;
			case 6: cout << "Friday" << endl; break;
			case 0: cout << "Saturday" << endl; break;
		}
	}

	return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 99999999



int main(){
    int a,b;
    int month[]={0,0,31,29,31,30,31,30,31,31,30,31,30,31};
    for(int i=1;i<=12;i++)month[i]=month[i]+month[i-1];
    string w[]={"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};
    while(cin>>a>>b){
        if(a==0&&b==0)break;
        int sum=0;
        sum+=month[a];
        sum+=b-1;
        sum=sum%7;
        cout<<w[sum]<<endl;
    }
}

C++: #include <stdio.h>
int main()
{
	char yobi[7][10]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Sunday"};
	int month,day;
	while(1){
		scanf("%d %d",&month,&day);
		if(month==0)
			break;
		for(int i=0;i<month;i++){
			switch(i){
				case 2:
					day+=29;
				case 4:
				case 6:
				case 9:
				case 11:
					day+=30;
				default:
					day+=31;
			}
		}
		printf("%s\n",yobi[day%7]);
	}
	return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
  int d[]={31,29,31,30,31,30,31,31,30,31,30,31};
  string s[]={"Thursday",
	      "Friday","Saturday","Sunday","Monday","Tuesday","Wednesday",};
  int i,j;
  int a,b;
  cin>>a>>b;
  while(a!=0){
    int o=0;
    for(i=1;i<a;i++) o+=d[i-1];
    o+=b-1;
    //cout << o << endl;
    cout << s[o%7] << endl;
    cin>>a>>b;
  }
  return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
 
int main(){
  string y[7]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
  int num[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 && d == 0 ) break;
    while( m != 0 ){
      d += num[m-1];
      m--;
    }
    cout << y[d%7] << endl;
  }
 
  return 0;
}

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

int main() {
  while (true) {
    int m, d; cin >> m >> d;
    if (m == 0 && d == 0) break;
    int month[12] = {31,29,31,30,31,30,31,31,30,31,30,31};

    for (int i = 0; i < m - 1; i++) d += month[i];

    switch (d % 7) {
    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:
      cout << "Wednesday" << endl;
      break;
    }
  }

  return 0;
}