Go: package main

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

func main() {
	const S = "HEISEI"
	io := NewIo()
	defer io.Flush()
	for io.Next() == S {
		y, m, d := io.NextInt(), io.NextInt(), io.NextInt()
		if y > 31 || y == 31 && m > 4 {
			io.Println("?", y-30, m, d)
		} else {
			io.Println(S, y, m, d)
		}
	}
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}

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;
}