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>
int main(){
	int m[12];
	char q;
	m[1]=31,m[2]=29,m[3]=31,m[4]=30,m[5]=31,m[6]=30,m[7]=31,m[8]=31,m[9]=30,m[10]=31,m[11]=30,m[12]=31;
	int mm,d;
	while(std::cin>>mm>>d&&mm!=0&&d!=0){
		int y=0;
		for(int a=1;a<mm;a++){
			y=y+m[a];
		}
		
		if((y+d)%7==1){
			std::cout<<"Thursday"<<std::endl;
		}if((y+d)%7==2){
		std::cout<<"Friday"<<std::endl;
		}
		if((y+d)%7==3){
		std::cout<<"Saturday"<<std::endl;
		}
		if((y+d)%7==4){
		std::cout<<"Sunday"<<std::endl;
		}
		if((y+d)%7==5){
		std::cout<<"Monday"<<std::endl;
		}
		if((y+d)%7==6){
		std::cout<<"Tuesday"<<std::endl;
		}
		if((y+d)%7==0){
			std::cout<<"Wednesday"<<std::endl;
		}
		
	}
	return 0;
}

C++: #include<cstdio>
#include<ctime>
int mtod(int month){
  int result=0;
  if(month>1) result+=31;
  if(month>2) result+=29;
  if(month>3) result+=31;
  if(month>4) result+=30;
  if(month>5) result+=31;
  if(month>6) result+=30;
  if(month>7) result+=31;
  if(month>8) result+=31;
  if(month>9) result+=30;
  if(month>10) result+=31;
  if(month>11) result+=30;
  return result;
}
int main(){
  for(;;){
    int m,d;
    scanf("%d %d",&m,&d);
    if(!(m|d)){break;}
    int diff=mtod(m)+d-1;
    switch(diff%7){
    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");break;
    }
  }
}

C++: #include <iostream>
int main(void){
    int month,day,chek;
    while(std::cin >> month >> day,month){ int year = 2004;
    if(month == 1 || month == 2){year--;month+=12;}
    chek = ((year+ year/4-year/100+year/400+(13*month+8)/5+day)%7);
    switch (chek) {case 0:puts("Sunday");break; case 1:puts("Monday");break; case 2:puts("Tuesday");break; case 3:puts("Wednesday");break;
        case 4:puts("Thursday");break; case 5:puts("Friday");break; case 6:puts("Saturday");break; }}return 0;}

C++: #include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <iostream>


using namespace std;

int main()
{
	int m, d;
	while (true)
	{
		scanf("%d %d", &m, &d);
		if (m == 0 && d == 0)
			break;

		int total = d;
		for (int i = 1; i < m; ++i)
		{
			if (i == 2)
				total += 29;
			else if (i & 1)
				total += 31;
			else
				total += 30;
		}
		char* days[] = { "Monday", "Tuesday", "Wednesday", "Thursday",
			"Friday", "Saturday", "Sunday" };
		puts(days[(total+2)%7]);
	}
	return 0;
}

C++: #include<stdio.h>
int main()
{
int p[12]={31,29,31,30,31,30,31,31,30,31,30,31};
int M,D,sum;
while(1)
{
sum=0;
scanf("%d",&M);
scanf("%d",&D);if(M==0)break;
if(M==0)break;
for(int i=0;i<M-1;i++)
sum+=p[i];

sum+=D;

switch(sum%7)
{
case 4:
printf("Sunday\n");break;
case 5:
printf("Monday\n");break;

case 6:
printf("Tuesday\n");break;

case 0:
printf("Wednesday\n");break;

case 1:
printf("Thursday\n");break;

case 2:
printf("Friday\n");break;

case 3:
printf("Saturday\n");break;
}
}
return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> pint;
#define rep(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

int day[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
int main(){
	int m,d;
	for(;cin>>m>>d,m;){
		for(int i=1;i<m;i++){
			d+=day[i];
		}
		switch(d%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<iostream>
using namespace std;
int main(){
int m,d,h,y;
char w[][7]={"Satur","Sun","Mon","Tues","Wednes","Thurs","Fri"};
for(;;){
y=4;
cin>>m>>d;
if(m==0)break;
if(m<3){m+=12;y--;}
h=(y+int(y/4)+int(2.6*(m+1))+d)%7;
cout<<h<<endl;
cout<<w[h]<<"day"<<endl;
}
return 0;
}

C++: #include <iostream>

using namespace std;

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

C++: #define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<list>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<map>
#include<queue>
#include<vector>
using namespace std;

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

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

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

C++: #include <iostream>
#include <string>
using namespace std;
 int main()
{
	//arrays with number of days in month and the days names
    int days[] = {31,29,31,30,31,30,31,31,30,31,30,31};
    string week[7] = {"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
    int month, day;
    while(cin >> month >> day, month||day)//entering day
	{
		
        int n = 0;
        for(int i=1; i<month; i++)
		{
            n += days[i-1];
        }
        n += day;
 
        n %= 7;
        cout << week[n] <<endl;//printing the day
 
    }
  return 0;
}

C++: #include <iostream>

using namespace std;

int main(void) {
  int month[13];
  month[1] = 31;
  month[2] = 29;
  month[3] = 31;
  month[4] = 30;
  month[5] = 31;
  month[6] = 30;
  month[7] = 31;
  month[8] = 31;
  month[9] = 30;
  month[10] = 31;
  month[11] = 30;
  month[12] = 31;

  int m, d, days;
  while(cin >> m >> d) {
    if(m == 0) break;
    
    days = d;
    for(int j = 1; j < m; j++) {
      days = days + month[j];
    }
    if(days%7 == 0) {
      cout << "Wednesday" << '\n';
    } else if(days%7 == 1) {
      cout << "Thursday" << '\n';
    } else if(days%7 == 2) {
      cout << "Friday" << '\n';
    } else if(days%7 == 3) {
      cout << "Saturday" << '\n';
    } else if(days%7 == 4) {
      cout << "Sunday" << '\n';
    } else if(days%7 == 5) {
      cout << "Monday" << '\n';
    } else if(days%7 == 6) {
      cout << "Tuesday" << '\n';
    }
  }

  return 0;
}