Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
	"time"
)

var sc = bufio.NewScanner(os.Stdin)

//Sliceconvtoi ...
func Sliceconvtoi() []int {
	strs := strings.Split(sc.Text(), " ")

	var ints []int
	var x int

	for _, s := range strs {
		x, _ = strconv.Atoi(s)
		ints = append(ints, x)
	}

	return ints
}

func main() {
	for sc.Scan() {
		i := Sliceconvtoi()

		if i[0] == 0 && i[1] == 0 {
			break
		}

		m := time.Month(i[0])
		d := i[1]
		t := time.Date(2004, m, d, 0, 0, 0, 0, time.Local)
		fmt.Println(t.Weekday())
	}

}

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

int main() {
    int month, day;
    string weekday[7] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
    while (cin >> month >> day) {     
        time_t rawtime;
        struct tm * timeinfo;

        time(&rawtime);
        timeinfo = localtime(&rawtime);

        timeinfo->tm_year = 2004-1900;
        timeinfo->tm_mon = month - 1;
        timeinfo->tm_mday = day;
        
        mktime(timeinfo);

        cout << weekday[timeinfo->tm_wday] << endl;
    }
    return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(ll i=0;i<n;i++)
using namespace std;
typedef long long ll;

int main(){
  int a,b;
  string day[]={"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};
  int months[] = {31,29,31,30,31,30,31,31,30,31,30,31};
  while(cin>>a>>b,a,b){
    a--;b--;
    // --a;--b;
    // cout << a<<b;
    rep(i,a) b+=months[i];
    // cout<<b<<endl;
    cout<<day[b%7]<<endl;
    // rep(i,a) b+=months[i];
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

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

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1){
        int a,b;
        cin >> a >> b;
        if(a == 0) break;
        cout << s[zeller(2004, a, b)] << "\n";
    }
    return 0;
}

C++: #include <iostream>

const int days[12]={31,29,31,30,31,30,31,31,30,31,30,31};
const std::string str[7]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};

int m2d(int month)
{
	if(month==0)
		return 0;
	return days[month-1] + m2d(month-1);
}

int main(void)
{
	int m,d;
	while(true)
	{
		std::cin >> m >> d;
		if(!m)
			break;

		std::cout << str[(m2d(m-1)+d+4-1)%7] << std::endl;
	}
	return 0;
}

C++: #include <stdio.h>

int main(void){
	int month, day;
	int dday[12] = {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335};
	int answer;
	while(1){
		scanf("%d %d", &month, &day);
		if(month == 0) break;

		answer = (dday[month -1] + day-1) % 7;
		switch(answer){
		case 0:
			puts("Thursday");
			break;
		case 1:
			puts("Friday");
			break;
		case 2:
			puts("Saturday");
			break;
		case 3:
			puts("Sunday");
			break;
		case 4:
			puts("Monday");
			break;
		case 5:
			puts("Tuesday");
			break;
		case 6:
			puts("Wednesday");
		}
	}	
	return 0;
}

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

int main()
{
	string days[]={
		"Mon",
		"Tues",
		"Wednes",
		"Thurs",
		"Fri",
		"Satur",
		"Sun"
	};
	int cal[12][31]={{0}};
	int today=3;
	for (int i=0; i<12; i++) {
		for (int j=0; j<31; j++) {
			cal[i][j]=today;
			++today%=7;
			if (i==3 || i== 5 || i==8 || i==10) {
				if (j==29) {
					break;
				}
			}
			else if (i==1) {
				if (j==28) {
					break;
				}
			}
		}
	}
	int a,b;
	for (cin >> a >> b; a; cin >> a >> b) {
		cout << days[cal[a-1][b-1]] << "day" << endl;
	}	
}

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

#define rep(i,n) for(int i=0;i<int(n);++i)

int m,d;

int main(){
	
	while(cin>>m>>d,!(m==0&&d==0)){
		if(m==2){
			d+=31;
		}
		if(m==3){
			d+=60;
		}
		if(m==4){
			d+=91;
		}
		if(m==5){
			d+=121;
		}
		if(m==6){
			d+=152;
		}
		if(m==7){
			d+=182;
		}
		if(m==8){
			d+=213;
		}
		if(m==9){
			d+=246;
		}
		if(m==10){
			d+=276;
		}
		if(m==11){
			d+=307;
		}
		if(m==12){
			d+=337;
		}
		d = d%7;
		if(d==0) cout<<"Wednesday\n";
		if(d==1) cout<<"Thursday\n";
		if(d==2) cout<<"Friday\n";
		if(d==3) cout<<"Saturday\n";
		if(d==4) cout<<"Sunday\n";
		if(d==5) cout<<"Monday\n";
		if(d==6) cout<<"Tuesday\n";
	}
	return 0;
	
}

C++: #include <algorithm>
#include <cctype>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <functional>
#include <queue>
#include <string>
#include <map>
#include <vector>

using namespace std;

int main() {
  const char *ws[7] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
  int ms[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; 
  for (int i = 2; i <= 12; i++)
    ms[i] += ms[i-1];
  for (;;) {
    int m, d;
    cin >> m >> d;
    if (!m && !d) return 0;
    cout << ws[(2+ms[m-1]+d)%7] << endl;
  }
  return 0;
}

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

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

int main()
{
	int month,day,sum = 0;
    
    while(cin >> month >> day,month || day)
	{
		for(int i=0;i<month;i++)
		{
	        sum += months[i-1];
		}
        sum += day -1;
		cout << days[sum%7] <<endl;
    }
	return 0;
}

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

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

int main(void){
  int m, d;
  while(cin >> m >> d && m && d){
    int sd = d;
    for(int i = 1; i < m; i++) sd += nd[i];
    cout << wk[sd % 7] << endl;
  }
  return 0;
}