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 <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
using namespace std;


#define li			long long int
#define rep(i,to)	for(int i=0;i<((int)(to));i++)
#define repp(i,start,to)	for(int i=(int)(start);i<((int)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define F first
#define S second
#define p2(a,b)		cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		cout<<a<<"\t"<<b<<"\t"<<c<<endl

string yobi[7]={
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
"Sunday"
};

int main(){
	li m,d;
	li acum=3;
	li day[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	
	while(1){
		cin>>m>>d;
		if(min(m,d)==0)break;
		
		rep(i,m-1)acum+=day[i];
		acum+=d-1;
		cout<<yobi[acum%7]<<endl;
	}
	
	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,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 << s[o%7] << endl;cin>>a>>b;
  }
}

C++: //https://onlinejudge.u-aizu.ac.jp/problems/0027

#include <bits/stdc++.h>

using namespace std;

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

int main() {
    int m, d;

    while (true) {
        cin >> m >> d;
        if (m + d == 0) return 0;

        m--;
        d--;
        for (int i = 0; i < m; ++i) {
            d += months[i];
        }
        cout << day[d % 7] << endl;
    }
}

/*
 * 1/1から何日ずれるか数えて7で割る。
 */

C++: #include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
    int a, b;
    string date[7] = { "Wednesday", "Thursday", "Friday", "Saturday",
        "Sunday", "Monday", "Tuesday",};
    int day[12] = {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335};

    cin >> a >> b;

    while (a != 0 && b != 0) {
        b += day[a-1];
        cout << date[b%7] << endl;
        cin >> a >> b;
    }

    return 0;
}

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

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

int main() {
    int date[12][31];
    int cnt = 1;
    for (int i=0; i<12; ++i) {
        for (int j=0; j<day[i]; ++j) {
            if (i == 0 && j == 0) {
                date[i][j] = 3;
            } else if (j == 0) {
                date[i][j] = (date[i-1][day[i-1] - 1] + 1) % 7;
            } else {
                date[i][j] = (date[i][j-1] + 1) % 7;
            }
            cnt ++;
        }
    }

    int m, d;
    while (cin >> m >> d, m && d) {
        cout << dateString[date[m-1][d-1]] << endl;
    }
    return 0;
}

C++: #include <cstdio>

using namespace std;

int main() {
  int days[] = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
  const char* wdays[] = {
    "Wednesday",
    "Thursday",
    "Friday",
    "Saturday",
    "Sunday",
    "Monday",
    "Tuesday"
  };

  int month, day;
  while (true) {
    scanf("%d %d", &month, &day);
    if (month == 0) { break; }

    int acc_days = 0;
    for (int i = 0; i < month; ++i) { acc_days += days[i]; }
    acc_days += day;
    puts(wdays[acc_days % 7]);
  }

  return 0;
}

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

int zeller(int y , int m , int d){
	if(m==1 || m==2) m+=12; y-=1;
	return(y + y/4 - y/100 + y/400 + ((13*m+8)/5) + d )%7;
}

int main(){
	int m , d , w=4 , fw;
	while (cin >> m >> d, m){
		switch(zeller(2004,m,d)){
			case 0:
			cout << "Sunday" << endl;
			break;
			case 1:
			cout << "Monday" << endl;
			break;
			case 2:
			cout << "Tuesday" << endl;
			break;
			case 3:
			cout << "Wednesday" << endl;
			break;
			case 4:
			cout << "Thursday" << endl;
			break;
			case 5:
			cout << "Friday" << endl;
			break;
			case 6:
			cout << "Saturday" << endl;
		}
	}
	return 0; 
}

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

char const* data1[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
int data2[] = {3, 6, 0, 3, 5, 1, 3, 6, 2, 4, 0, 2};

int main(void)
{
    int m, d;
    while (cin >> m >> d && m!=0 && d!=0) {
        int a = (data2[m-1] + d-1)%7;
        cout << data1[a] << endl;;
    }
    return 0;
}

C++: #include <stdio.h>

int main(){
	int m,d;
	int i;
	
	int Days;
	
	
	while(1){
		Days = 0;
		scanf("%d %d",&m,&d);
		if(m == 0&&d == 0)break;
		for(i = 1,Days += d;i < m;i++){
			if(i == 2){
				Days += 29;
			}else if(i == 4||i == 6||i == 9||i == 11){
				Days += 30;
			}else{
				Days += 31;
			}
		}
		
		switch(Days%7){
			case 0:printf("Wednesday\n");
					break;
			case 1:printf("Thursday\n");
					break;
			case 2:printf("Friday\n");
					break;
			case 3:printf("Saturday\n");
					break;
			case 4:printf("Sunday\n");
					break;
			case 5:printf("Monday\n");
					break;
			case 6:printf("Tuesday\n");
					break;
		}
	}
	return 0;
}

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

C++: #include <stdio.h>

int main(void){
  int days[13] = {0,31,29,31,30,31,30,31,31,30,31,30,31};
  char youbi[7][100] = {"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
  int sum,m,d,i;
  while(1){
    sum = 0;
    scanf("%d %d",&m,&d);
    if (m == 0 || d == 0) break;
    for(i=0;i<m;i++){
      sum += days[i];
    }
    sum += d;
    printf("%s\n",youbi[sum%7]);
  }
  return 0;
}