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>
#include<algorithm>
using namespace std;
int month[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
int main(){
int m,d;
while(scanf("%d %d",&m,&d),(m!=0)){
for(int i=0;i<m;i++){
d=d+month[i];
}
d=d%7;
switch(d){
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;
}
}
return 0;
}

C++: #include <iostream>

using namespace std;

int main(void){

  int month;
  int day;
  int day2;

  while(1){

    day2 = 0;

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

    for( int i = 1 ; i < month ; i++ ){
      switch(i){
      case 1:
      case 3:
      case 5:
      case 7:
      case 8:
      case 10:
      case 12:
	day2 += 31;
	break;
      case 2:
	day2 += 29;
	break;
      case 4:
      case 6:
      case 11:
	day2 += 30;
	break;
      }
    }
    day2 += day;
      switch(day2 % 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;
      case 0:
	cout << "Wednesday" << endl;
    }
  }
  return 0;
}

C++: #include<cstdio>

using namespace std;
int main(void)
{
	int a[13] = {0,31,29,31,30,31,30,31,31,30,31,30,31};
	int m,n;
	while(scanf("%d%d",&m,&n))
	{
		if(m == 0 && n == 0) break;
		for(int i = 0;i < m;i++)
		{
			n += a[i];
		}
		switch(n%7)
		{
		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;
		case 0:
			printf("Wednesday\n");
			break;
		}
	}
	return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	string week[7] = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
	int month[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
	int m,d,count_w, count_m;
	while(cin >> m >> d){
		if(m == 0) return 0;
		
		count_m = 1;
		count_w = 3;
		while(1){
			for(int i=1; i<=month[count_m-1]; i++, count_w++){
				if(m==count_m && d==i) break;
			}
			if(m == count_m) break;
			count_m++;
		}
		cout << week[count_w%7] << endl;
	}
}

C++: #include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string.h>
#include <queue>
#include <stack>
#include <utility>
#include <queue>
#include <cmath>
#define mp make_pair
#define pii pair<int,int> 
#define ff first
#define ss second

using namespace std;

int month[20]={0,31,29,31,30,31,30,31,31,30,31,30,31};
string days[10]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
int a,b,c,d;
int main()
{
	while(1)
	{
		scanf("%d %d",&a,&b);
		c=0;
		if(a==0&&b==0)
		{
			break;
		}
		for(int i=1;i<a;i++)
		{
			c+=month[i];
		}
		c+=b+2;
		d=c%7;
		//printf("%d\n",c);
		cout<<days[d]<<endl;
	}
	return 0;
}

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

int main()
{
	int date[13][32];
	for(int i = 1;i<=31;i++)date[1][i] = i;
	for(int i = 1;i<=28;i++)date[2][i] = i+3;
	for(int i = 1;i<=31;i++)date[3][i] = i+4;
	for(int i = 1;i<=31;i++)date[4][i] = i;
	for(int i = 1;i<=31;i++)date[5][i] = i+2;
	for(int i = 1;i<=31;i++)date[6][i] = i+5;
	for(int i = 1;i<=31;i++)date[7][i] = i;
	for(int i = 1;i<=31;i++)date[8][i] = i+3;
	for(int i = 1;i<=31;i++)date[9][i] = i+6;
	for(int i = 1;i<=31;i++)date[10][i] = i+1;
	for(int i = 1;i<=31;i++)date[11][i] = i+4;
	for(int i = 1;i<=31;i++)date[12][i] = i+6;
	
	int month,day;
	while(true)
	{
		cin >> month;
		cin >> day;
		if(month==0&&day==0)break;
		switch (date[month][day] % 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;
		}

	}

	return 0;
}

C++: #include<stdio.h>

int main()
{
	int x,y,d;
	while(scanf("%d %d",&x,&y))
	{
		if(x==0)
		{
			return 0;
		}
		else if(x==1||x==2)
		{
			d=(2003+2003/4-2003/100+2003/400+(13*(x+12)+8)/5+y)%7;
		}
		else if(x>=13)
		{
			d=7;
		}
		else
		{
			d=(2004+2004/4-2004/100+2004/400+(13*x+8)/5+y)%7;
		}

		if(d==0)
		{
			printf("Sunday\n");
		}
		else if(d==1)
		{
			printf("Monday\n");
		}
		else if(d==2)
		{
			printf("Tuesday\n");
		}
		else if(d==3)
		{
			printf("Wednesday\n");
		}
		else if(d==4)
		{
			printf("Thursday\n");
		}
		else if(d==5)
		{
			printf("Friday\n");
		}
		else if(d==6)
		{
			printf("Saturday\n");
		}
		else if(d==7)
		{
		}
	}
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <queue>
#include <vector>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <cctype>
#include <cstdlib>
using namespace std;

#define INF (1 << 20)
#define EPS (1e-10)
#define EQ(a,b) (fabs((a)-(b)) < EPS)

int main(){
	int dn[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	string youbi[7] = {"Monday", "Tuesday", "Wednesday", "Thursday",
		"Friday", "Saturday", "Sunday"};
	int m, d;
	while (cin >> m >> d) {
		if (m == 0) break;
		int sum = 0;
		for (int i = 1; i < m; ++i) {
			sum += dn[i];
		}
		sum += d;
		cout << youbi[sum % 7 + 2] << endl;
	}
	return 0;
}

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

int main() {
	string str[50];
	int f;
	for (int i = 0;; i++) {
		int a, b;
		cin >> a >> b;
		if (a == 0 && b == 0) {			
			f = i;
			break;
		}
		{
			if (a == 2) {
				b += 3;
			}
			if (a == 3) {
				b += 4;
			}
			if (a == 4) {
				b += 0;
			}
			if (a == 5) {
				b += 2;
			}
			if (a == 6) {
				b += 5;
			}
			if (a == 7) {
				b += 0;
			}
			if (a == 8) {
				b += 3;
			}
			if (a == 9) {
				b += 6;
			}
			if (a == 10) {
				b += 1;
			}
			if (a == 11) {
				b += 4;
			}
			if (a == 12) {
				b += 6;
			}
		}
		//?????\????±????(52???73)
		{
			if ((b & 7) == 0) {
				str[i] = "Wednesday";
			}
			if ((b & 7) == 1) {
				str[i] = "Thursday";
			}
			if ((b & 7) == 2) {
				str[i] = "Friday";
			}
			if ((b & 7) == 3) {
				str[i] = "Saturday";
			}
			if ((b & 7) == 4) {
				str[i] = "Sunday";
			}
			if ((b & 7) == 5) {
				str[i] = "Monday";
			}
			if ((b & 7) == 6) {
				str[i] = "Tuesday";
			}
		}
	}

	for (int i = 0; i < f; i++){
		if (str[i]=="Wednesday") {
			cout << "Wedne";
			cout << "sday" << endl;
		}else cout << str[i] << endl;
	}

	char c;
	cin >> c;

	return 0;
}

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

int main()
{
	int day[366];
	int month[12] = {0,31,60,91,121,152,182,213,244,274,305,335};
	int m,d;
	
	for(int i=0;i<366;++i)
		day[i] = i%7;
	
	while(cin >> m >> d){
		if(!m)
			break;

		switch(day[month[m-1] + d-1]){
		case 0:cout <<"Thursday"		<<endl;break;
		case 1:cout <<"Friday"			<<endl;break;
		case 2:cout <<"Saturday"		<<endl;break;
		case 3:cout <<"Sunday"			<<endl;break;
		case 4:cout <<"Monday"			<<endl;break;
		case 5:cout <<"Tuesday"			<<endl;break;
		case 6:cout <<"Wednesday"	<<endl;break;
		}

	}
	return 0;
}