Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

//ConvReiwa ..
func ConvReiwa(sd []string) []string {
	var ne []string
	yr, _ := strconv.Atoi(sd[1])
	mn, _ := strconv.Atoi(sd[2])

	switch {
	case yr < 31:
		return sd
	case yr == 31 && mn < 5:
		return sd
	default:
		ne = append(ne, "?")
		ne = append(ne, strconv.Itoa(yr-30))
		ne = append(ne, sd[2])
		ne = append(ne, sd[3])
		return ne
	}
}

func main() {

	for sc.Scan() {

		str := sc.Text()

		if str == "#" {
			break
		}

		sdt := strings.Split(str, " ")
		ans := ConvReiwa(sdt)

		fmt.Printf("%s %s %s %s\n", ans[0], ans[1], ans[2], ans[3])
	}

}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

int num(string s,int& i);
int calc(string s,int& i);
int x;

bool isnum(char c){
    int y=c-'a';
    return (y>=0)&&(y<=3);
}
int calc(string s,int& i){
    if(isnum(s[i]))return num(s,i);
    i++;
    char op=s[i];
    i++;
    int ret=calc(s,i);
    int res=calc(s,i);
    i++;
    if(op=='+')return ret|res;
    if(op=='*')return ret&res;
    if(op=='^')return ret^res;
    return 0;
}

int num(string s,int& i){
    i++;
    if(s[i-1]=='a')return x/1000;
    if(s[i-1]=='b')return (x/100)%10;
    if(s[i-1]=='c')return (x/10)%10;
    if(s[i-1]=='d')return x%10;
    return 0;
}
int main(){
    string s;
    while(cin>>s,s!="."){
        map <int,int> mp; 
        rep(i,10000){
            x=i;
            int j=0;
            mp[calc(s,j)]++;
        }
        int n;cin>>n;
        x=n;
        int j=0;
        int ans=calc(s,j);
        cout<<ans<<" "<<mp[ans]<<endl;
    }
    return 0;
}

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

int main() {
    while (1) {
        string s;
        cin >> s;
        if (s == "#")
            break;

        int y, m, d;
        cin >> y >> m >> d;

        if (y >= 31) {
            if (y == 31 && m <= 4)
                ;
            else{
                s = "?";
                y -= 30;
            }
        }

        cout << s << " " << y << " " << m << " " << d << "\n";
    }

    return 0;
}

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

int main(){
  while(1){
    string a;
    int b,c,d;
    cin>>a;
    if(a=="#") break;
    cin>>b>>c>>d;
    if(b>31) cout<<"? "<<b-30<<" "<<c<<" "<<d<<endl;
    else if(b==31&&c>=5) cout<<"? "<<b-30<<" "<<c<<" "<<d<<endl;
    else
    cout<<"HEISEI "<<b<<" "<<c<<" "<<d<<endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main(){
	while(1){
		string s;
		cin>>s;
		if(s=="#") break;
		int y,m,d;
		cin>>y>>m>>d;
		if(y>31) s="?";
		if(y==31&&m>=5) s="?";
		if(s=="?") y-=30;
		cout<<s<<' '<<y<<' '<<m<<' '<<d<<endl;
	}
}

C++: 
Beta

  paiza.IO
 
Enter a title here
Main.cpp 
Success  
  
        
出力
入力
コメント 0
(0.00 sec)
 
HEISEI 1 1 8
HEISEI 31 4 30
? 1 5 1
? 69 12 31
? 8 8 30
? 68 2 22
HEISEI 2 3 26
HEISEI 28 4 23

C++: #include<iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  int y,m,d;
  while(s!="#"){
    cin >>y >>m>>d;
    if(y>=32||(y==31&&m>=5)){
      cout <<"? "<<y-30<<" "<<m<< " "<<d<<endl;
    }else{
      cout << s << " "<<y<<" "<<m<<" "<<d<<endl;
    }
    cin >> s;
  }
}

C++: #include<bits/stdc++.h>

using namespace std;

int main()
{
  string g;
  int y,m,d;
  string b("#");
  
  while(1){
    cin>>g;
    if(g == b){
      break;
    }

    cin>>y;
    cin>>m;
    cin>>d;

    if(y - 30 <= 0){
      cout<<g<<" "<<y<<" "<<m<<" "<<d<<endl;
    }
    else{
      if(y == 31 && m < 5){
        cout<<g<<" "<<y<<" "<<m<<" "<<d<<endl;
      }
      else{
        y = y - 30;
        cout<<"?"<<" "<<y<<" "<<m<<" "<<d<<endl;
      }
    }
  } 

  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int y, m, d;
vector<string> ans;

void HtoR()
{
    if (y > 31 || (y == 31 && m >= 5)) {
        ans.push_back("? " + to_string(y - 30) + " " + to_string(m) + " " + to_string(d));
        //cout<<"? "<<y - 30<<" "<<m<<" "<<d<<endl;
    } else {
        ans.push_back("HEISEI " + to_string(y) + " " + to_string(m) + " " + to_string(d));
        //cout<<"HEISEI "<<y<<" "<<m<<" "<<d<<endl;
    }
}

int main()
{
    string g;
    while (cin>>g, g != "#") {
        cin>>y>>m>>d;
        if (g == "HEISEI") HtoR();
        else exit(1);
    }
    REPALL(i,ans) cout<<ans[i]<<endl;
}

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

int main(){

    while(1){
        string s;
        int y,m,d;
        cin >> s;
        if(s=="#")break;
        cin >> y >> m >> d;
        if(y<=30){
            cout << s << " " << y << " " << m << " " << d << endl;
        }else{
            if(y==31&&m<5){
                cout << s << " " << y << " " << m << " " << d << endl;
            }else{
                cout << "?" << " " << y-30 << " " << m << " " << d << endl;
            }
        }
    }

    return 0;
}