jiahuimbzuai/CoQuIR huggingface dataset:
//  [cpp]
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int debug = 0;

int main()
{
    deque<string> s;
    int q;
    int n, f;
    string c;

    string tmp1;
    cin >> tmp1;
    s.push_back(tmp1);

    cin >> q;
    vector<tuple<int, int, string>> op;

    rep(i,q){
        cin >> n;
        if(n==1){
            op.emplace_back(1, -1, "");
        }else{
            cin >> f >> c;
            op.emplace_back(2, f, c);
        }
    }    

    if(debug){
        for(auto x:op){
            cout << "<" << get<0>(x) << "," << get<1>(x) << "," << get<2>(x) << ">";
            cout << endl;
        }
    }


    bool rev = false;

    for(auto x:op){
        if(get<0>(x)==1){ // reverse
            //reverse(s.begin(), s.end());
            if(rev)
                rev = false;
            else
                rev = true;
        }else if(get<1>(x)==1){ // head
            if(rev) // tail
                s.push_back(get<2>(x)) ;
            else //head
                s.push_front(get<2>(x));

        }else if (get<1>(x) == 2){ // tail
            if(rev) // head
                s.push_front(get<2>(x));
            else // tail
                s.push_back(get<2>(x)) ;
        }
    }

    string tmp="";
    for(auto x:s){
        tmp = tmp + x;
    }

    if(rev){
        reverse(tmp.begin(), tmp.end());
        cout << tmp << endl;
    }else
        cout << tmp << endl;

    return 0;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
int main(){
    string s; cin >> s;
    int Q; cin >> Q;
    int cnt = 0;
    deque<string>str;
    str.push_back(s);
    for(int k = 0; k < Q; ++k){
        int query;  cin >> query;
        if(query == 1){
            ++cnt;
        } else {
            int f; cin >> f;
            string s_; cin >> s_;
            if(f == 1){
                if(cnt % 2 == 0)str.push_front(s_);
                else str.push_back(s_);
            } else {
                if(cnt % 2)str.push_front(s_);
                else str.push_back(s_);
            }
        }
    }
    string ans = accumulate(str.begin(), str.end(), ""s,[](string res,string t){return res += t;});
    if(cnt % 2)reverse(ans.begin(),ans.end());
    cout << ans  << endl;
}
//  [c]
#include<stdio.h>

#define S_SIZE 100001

char s[S_SIZE];

typedef struct{
  char c;
  struct Deque *prev;
  struct Deque *next;

} Deque;

int main(void) {
  int query_size;
  int reverse = 0;
  Deque *head,*tail,*tmp;
  head = (Deque *)malloc(sizeof(Deque));

  scanf("%s",s);
  scanf("%d",&query_size);

  head->c = s[0];
  head->next = NULL; head->prev = NULL;
  tail = head;

  for(int i = 1;i < strlen(s);i++) {
    tmp = (Deque *)malloc(sizeof(Deque));
    tmp->c = s[i];
    head->next = tmp;
    tmp->next = NULL;
    tmp->prev = head;
    head = tmp;
  };

  for(int i = 0;i < query_size;i++) {
    int t,f;
    char c;
    scanf("%d",&t);

    if(t==1) {
      reverse = (reverse == 0)? 1:0;
      continue;
    }
    scanf("%d %c",&f,&c);
    tmp = (Deque *)malloc(sizeof(Deque));
    tmp->c = c;
    if((f==1 && reverse == 1) || (f==2 && reverse == 0)) {
      // 末尾追加
      head->next = tmp;
      tmp->next = NULL;
      tmp->prev = head;
      head = tmp;
    } else {
      // 先頭追加
      tail->prev = tmp;
      tmp->next = tail;
      tmp->prev = NULL;
      tail = tmp;
    }
  }

  if(reverse == 0) {
    for(Deque *d = tail;d != NULL;d = d->next) {
      printf("%c",d->c);
    }
  } else {
    for(Deque *d = head;d != NULL;d = d->prev) {
      printf("%c",d->c);
    }
  }
}
//  [c]
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define num sizeof(a)/sizeof(int)
#define N 100000

int main(){
    char s[3*N],add[2],sagyou[3*N],emp[3*N];
    int q,size,t,f,number=0,i,ins,distin=0;
    scanf("%s%d",s,&q);
    s[N-1]='\0';
    strcpy(sagyou,s);
    for(size=0;s[size]!='\0';size++);

    while(q!=0){
        scanf("%d",&t);
        if(t==1){
            //hanntenn
            distin+=1;
            distin%=2;
        }else if(t==2){
            scanf("%d",&f);
            if((f==1 && distin%2==0) || (f==2 && distin%2)==1){
                //senntoutuika
                scanf("%s",add);
                strcat(emp,add);
                number++;
            }else if((f==2 && distin%2==0) || (f==1 && distin%2==1)){
                //matubituika
                scanf("%s",add);
                strcat(sagyou,add);
                size++;
            }
        }
        q--;
    }

    if(distin%2==0){
        for(i=number-1;i>=0;i--){
            putchar(emp[i]);
        }
        printf("%s\n",sagyou);
    }else{
        for(i=size-1;i>=0;i--){
            putchar(sagyou[i]);
        }
        printf("%s\n",emp);
    }
    return 0;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define num sizeof(a)/sizeof(int)
#define N 100000

int main(){
    char s[3*N],add[2],sagyou[3*N],emp[3*N];
    int q,size,t,f,number=0,i,ins,distin=0;
    scanf("%s%d",s,&q);
    s[N-1]='\0';
    strcpy(sagyou,s);
    for(size=0;s[size]!='\0';size++);

    while(q!=0){
        scanf("%d",&t);
        if(t==1){//反転
            distin+=1;
            distin%=2;
        }else if(t==2){//追加
            scanf("%d",&f);
            if((f==1 && distin%2==0) || (f==2 && distin%2)==1){
                //先頭追加(末尾追加でないと遅いので二つの配列を用いる)
                scanf("%s",add);
                strcat(emp,add);
                number++;
            }else if((f==2 && distin%2==0) || (f==1 && distin%2==1)){
                //末尾追加
                scanf("%s",add);
                strcat(sagyou,add);
                size++;
            }
        }
        q--;
    }

    if(distin%2==0){//後ろからか前からか
        for(i=number-1;i>=0;i--){
            putchar(emp[i]);
        }
        printf("%s\n",sagyou);
    }else{
        for(i=size-1;i>=0;i--){
            putchar(sagyou[i]);
        }
        printf("%s\n",emp);
    }
    return 0;
}
//  [javascript]
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var s = next(1);
  var q = next();
  var rev = 0;
  var a = [];
  s = s.split("");
  for(var i = 0; i < q; i++){
    if(next() === 1)rev ^= 1;
    else{
      var f = next(), c = next(1);
      if(rev)f = 3-f;
      if(f === 1)a.push(c);
      else s.push(c);
    }
  }
  if(rev)s = s.reverse().concat(a);
  else s = a.reverse().concat(s);
  return s.join("");
}
//  [javascript]
console.log((args=>{
  const [S,q,...tmp] = args.trim().split`\n`;
  const Q = q|0;
  const s = Array(Q).fill('').concat( S.split``, Array(Q).fill('') );
  let ol = Q-1, or = S.length+Q, r = false;
  for ( let i = 0; i < Q; i++ ) {
    const [cmd,f,c] = tmp[i].split` `;
    if ( cmd === '1' ) r = !r;
    else if (r^(f-1)) s[or++] = c;
    else s[ol--] = c;
  }
  if (r) s.reverse();
  return s.join``;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));
//  [go]
package main

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

const (
	initialBufSize = 64 * 1024
	maxBufSize     = 10000000
)

var (
	scanner = bufio.NewScanner(os.Stdin)
	writer  = bufio.NewWriter(os.Stdout)
)

func main() {
	scanner.Buffer(make([]byte, maxBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	s := scanText()
	q := scanInt()

	isReverse := false
	head, tail := "", ""
	for i := 0; i < q; i++ {

		if scanInt() == 1 {
			isReverse = !isReverse
			continue
		}

		if f := scanInt(); (f == 1 && !isReverse) || (f == 2 && isReverse) {
			head += scanText()
		} else {
			tail += scanText()
		}
	}

	ans := reverse(head) + s + tail

	if isReverse {
		fmt.Print(reverse(ans))
	} else {
		fmt.Print(ans)
	}
}

func reverse(s string) string {
	t := []byte(s)
	for i, j := 0, (len(s) - 1); i < j; i, j = i+1, j-1 {
		t[i], t[j] = t[j], t[i]
	}
	return string(t)
}

func scanInt() int {
	i, _ := strconv.Atoi(scanText())
	return i
}

func scanInts(size int) []int {
	ints := make([]int, size)
	for i := 0; i < size; i++ {
		ints[i] = scanInt()
	}
	return ints
}

func scanText() string {
	scanner.Scan()
	return scanner.Text()
}

func abs(n int) int {
	return int(math.Abs(float64(n)))
}

func pow(x, y int) int {
	return int(math.Pow(float64(x), float64(y)))
}
//  [go]
package main

import (
	"fmt"
)

func main() {
	var S string
	fmt.Scan(&S)
	center := make([]string, len(S))
	for i, c := range []rune(S) {
		center[i] = string(c)
	}
	var Q int
	fmt.Scan(&Q)
	pre, epi := []string{}, []string{}
	reverseCount := 0
	for i := 0; i < Q; i++ {
		var T int
		fmt.Scan(&T)
		if T == 1 {
			reverseCount += 1
		} else {
			var F int
			var C string
			fmt.Scan(&F, &C)
			if F == 1 {
				if reverseCount%2 == 0 {
					// preが前
					pre = append(pre, C)
				} else {
					// epiが前
					epi = append(epi, C)
				}
			} else {
				if reverseCount%2 == 1 {
					// preが前
					pre = append(pre, C)
				} else {
					// epiが前
					epi = append(epi, C)
				}
			}
		}
	}

	// 答え構築 反転を考慮に入れる
	if reverseCount%2 == 0 {
		oldSkoolFuckinAdHocReverseForAtCoderGolangVer(pre)
		for _, p := range pre {
			fmt.Print(p)
		}
		for _, c := range center {
			fmt.Print(c)
		}
		for _, e := range epi {
			fmt.Print(e)
		}
	} else {
		oldSkoolFuckinAdHocReverseForAtCoderGolangVer(epi)
		oldSkoolFuckinAdHocReverseForAtCoderGolangVer(center)
		for _, e := range epi {
			fmt.Print(e)
		}
		for _, c := range center {
			fmt.Print(c)
		}
		for _, p := range pre {
			fmt.Print(p)
		}
	}
	// atcoderでは改行を無視してくれるけど一応流儀に則って
	fmt.Println()
}

func oldSkoolFuckinAdHocReverseForAtCoderGolangVer(arr []string) {
	for i, j := 0, len(arr)-1; i < j; i, j = i+1, j-1 {
		arr[i], arr[j] = arr[j], arr[i]
	}
}
//  [go]
package main

import (
	"fmt"
)

func main() {
	var s string
	var q int
	fmt.Scanf("%s", &s)
	fmt.Scanf("%d", &q)

	prefix := []string{}
	postfix := []string{}
	rev := false
	for i := 0; i < q; i++ {
		var t, f, c string
		fmt.Scanf("%s", &t)
		if t == "1" {
			rev = !rev
		} else {
			fmt.Scanf("%s %s", &f, &c)
			if f == "1" == !rev {
				prefix = append(prefix, c)
			} else {
				postfix = append(postfix, c)
			}
		}
	}

	if !rev {
		for i, _ := range prefix {
			fmt.Print(prefix[len(prefix)-i-1])
		}
		fmt.Print(s)
		for _, c := range postfix {
			fmt.Print(c)
		}
	} else {
		for i, _ := range postfix {
			fmt.Print(postfix[len(postfix)-i-1])
		}
		r := []rune(s)
		for i, _ := range r {
			fmt.Print(string(r[len(r)-i-1]))
		}
		for _, c := range prefix {
			fmt.Print(c)
		}

	}
	fmt.Print("\n")
}
//  [ruby]
S = gets.chomp
Qn = gets.to_i
Q = readlines.map(&:split)

reversed = false
prefix = ''
suffix = ''

Q.each do |t,f,c|
  case t
  when '1'
    reversed ^= true
    prefix, suffix = suffix, prefix
  when '2'
    if reversed
      f == '1' ? prefix.concat(c) : suffix.insert(0, c)
    else
      f == '1' ? prefix.insert(0, c) : suffix.concat(c)
    end
  end
end
if reversed
  S.reverse!
  prefix.reverse!
  suffix.reverse!
end
puts prefix + S + suffix
//  [ruby]
s = gets.chomp.split("")
len = s.length
q = gets.to_i
t = Array.new(q)
f = Array.new(q)
c = Array.new(q)

for i in 0..(q-1)
  ln = gets.chomp.split("")
  if ln.length == 1
    t[i] = ln[0].to_i
    f[i] = 0
    c[i] = "."
  elsif ln.length == 5
    t[i] = ln[0].to_i
    f[i] = ln[2].to_i
    c[i] = ln[4]
  end
end

rev = 0
t.each{|tn| rev = (rev+(tn%2)) % 2}
enrev = rev
head = Array.new(0)
hn = 0
ends = Array.new(0)
en = 0

ps = 0
for i in 0..(q-1)
  if t[i] == 1
    rev = (rev+1) % 2
  elsif t[i] == 2
    f[i] = (f[i]+1) % 2 if rev == 1
    if f[i] == 1
      head.push(c[i])
      hn += 1
    elsif f[i] % 2 == 0
      ends.push(c[i])
      en += 1
    end
  end
end

s = s.reverse if enrev == 1
if hn > 0
  head = head.reverse
  head.each{|hc| print hc}
end
s.each{|ch| print ch}
ends.each{|ec| print ec} if en > 0
puts ""
//  [ruby]
S = gets.chomp
Q = gets.to_i
s1 = []
s2 = []
flag = 1

Q.times do
    Query = gets.split(" ")
    if Query[0] == "1"
        flag *= -1
    elsif Query[0] == "2"
        if Query[1] == "1"
            if flag == 1
                s1 << Query[2]
            else
                s2 << Query[2]
            end
        elsif Query[1] == "2"
            if flag == 1
                s2 << Query[2]
            else
                s1 << Query[2]
            end
        end
    end
end

if flag == 1
    puts s1.reverse.join + S + s2.join
else
    puts s2.reverse.join + S.reverse + s1.join
end
//  [rust]
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
  let s: String = read();
  let q: i32 = read();
  let mut rev : bool = false;
  let mut head: String = "".to_string();
  let mut tail: String = "".to_string();
//  println!("s={:?} q={:?}", s, q);
  for _i in 0..q {
    let t: i32 = read();
    if t == 1 {
      rev = !rev;
//      println!("t={:?}", t);
//      s = s.chars().rev().collect();
    } else if t == 2 {
      let f: i32 = read();
      let c: String = read();
//      println!("t={:?}, f={:?}, c={:?}", t, f, c);
      if f == 1 {
//        s = format!("{}{}", c, s);
        if !rev {
          head = format!("{}{}", head, c);
//          s = format!("{}{}", c, s);
        }
        else {
          tail = format!("{}{}", tail, c);
//          s = format!("{}{}", s, c);
        }
      }
      else if f == 2 {
        if !rev {
//          s = format!("{}{}", s, c);
          tail = format!("{}{}", tail, c);
        }
        else {
//          s = format!("{}{}", c, s);
          head = format!("{}{}", head, c);
        }
      }
      else {
        panic!("f is not 1 and 2");
      }
    }
    else {
      panic!("illegal input");
    }
  }
  if !rev {
    println!("{}{}{}", head.chars().rev().collect::<String>(), s, tail)
  }
  else {
    println!("{}{}{}", tail.chars().rev().collect::<String>(), s.chars().rev().collect::<String>(), head);
  }
}
//  [rust]
fn main() {
    let mut s = read::<String>();
    let qnum = read::<u32>();

    let mut rev = false;
    let mut qs = vec![];
    for _ in 0..qnum {
        let line = read_vec::<String>();
        if line[0] == "1" {
            rev = !rev;
        }
        qs.push(line);
    }

    //if rev {
    //        s = s.chars().rev().collect::<String>();
    //    }

    rev = false;
    for q in qs {
        let t: u32 = q[0].parse().ok().unwrap();
        if t == 1 {
            rev = !rev;
        } else {
            let f: u32 = q[1].parse().ok().unwrap();
            let c: char = q[2].clone().chars().collect::<Vec<_>>()[0];
            if f == 1 {
                if !rev {
                    s.insert(0, c);
                } else {
                    s.push(c);
                }
            } else {
                if !rev {
                    s.push(c);
                } else {
                    s.insert(0, c);
                }
            }
        }
    }
    if rev {
        s = s.chars().rev().collect::<String>();
    }
    println!("{}", s);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}
//  [rust]
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn readv<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

#[allow(dead_code)]
fn readvv<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| readv()).collect()
}

// #[derive(Debug)]
// enum Query {
//     Reverse,
//     Add(usize, String),
// }

fn main() {
    let s: String = read();
    let qn: usize = read();
    // let mut qq: Vec<Query> = vec![];

    let mut head: String = "".into();
    let mut tail: String = "".into();
    let mut reversed = false;
    for _ in 0..qn {
        // get query
        let tmp: String = read();
        let mut it = tmp.split_whitespace();
        let qtype: u64 = it.next().map(|v| v.parse().ok().unwrap()).unwrap();
        if qtype == 1 {
            reversed = !reversed;
        } else {
            let add_to_head = it.next().map(|v| v.parse::<u8>().ok().unwrap()).unwrap() == 1;
            let s = it.next().unwrap().to_string();
            let s = if reversed {
                s.chars().rev().collect()
            } else {
                s
            };

            match (reversed, add_to_head) {
                (false, true) => {
                    head = s + &head;
                },
                (true, true) => {
                    tail = tail + &s;
                },
                (false, false) => {
                    tail = tail + &s;
                },
                (true, false) => {
                    head = s + &head;
                }
            }
        }
        // qq.push(query);
    }

    let rtmp = head + &s + &tail;
    let result = if reversed {
        rtmp.chars().rev().collect()
    } else {
        rtmp
    };
    println!("{}", result);
    // println!("{:?}", qq);

}
        // let tmp: String = read();
        // let mut it = tmp.split_whitespace();
        // let qtype: u64 = it.next().map(|v| v.parse().ok().unwrap()).unwrap();
        // let query = if qtype == 1 {
        //     Query::Reverse
        // } else {
        //     let orient: usize = it.next().map(|v| v.parse().ok().unwrap()).unwrap();
        //     Query::Add(orient, it.next().unwrap().to_string())
        // };
//  [python]
t = input()
t = t.replace('?','D')
print(t)
//  [python]
T = input()
print(T.replace("?", "D"))
//  [python]
print(input().replace("?","D"))
//  [python]
w = input()
while "?" in w:
	p = w.rfind("?")
	try:
		if w[p+1] == "D":
			w = w.replace("?", "P", 1)
		else:
			w = w.replace("?", "D", 1)
	except IndexError:
		w = w.replace("?", "D", 1)
print(w)
//  [python]
# B
T = str(input())
try:
    for i in range(T.count("?")):
        index = T.index("?")
        if T[index - 1] == "P":
            T = T.replace("?","D",1)
        elif T[index + 1] == "D":
            T = T.replace("?","P",1)
        elif T[index + 1] == "?":
            T = T.replace("?","P",1)
        else:
            T = T.replace("?","D",1)
    print(T)
except:
    print(T.replace("?","D"))
//  [java]
import java.util.Scanner;

public class Main{
 public static void main(String[] args) {
   Scanner kbd =new Scanner(System.in);
   String T=kbd.next();
   String[] t = T.split("");

   for(int i=0;i<T.length()-1;i++){
   if(t[i].equals("P")&&t[i+1].equals("?"))
   t[i+1]="D";
   if(t[i].equals("?")&&t[i+1].equals("D"))
   t[i]="P";
 }
 for(int i=0;i<T.length();i++){
   if(t[i].equals("?"))
     t[i]="D";
 }
 for(int i=0;i<T.length();i++)
 System.out.print(t[i]);
 }
}
//  [java]
import java.util.Scanner;


public class Main {


//	final int MOD = 1000000007;

//	public static int min = 3000000;

	public static void main(String[] args) {

		int ans = 0;
		Scanner sc = new Scanner(System.in);
		boolean f = false;

//		long k = sc.nextLong();
//		int n = sc.nextInt();

		String string = sc.next();
		String[] s = string.split("");

//		int[] ans = new int[n];

		//-------------------------------------------------------------------------------------

		for(int i = 0; i < s.length; i++) {
			if(s[i].equals("?")) {
				if(i >= 1) {
					if(s[i-1].equals("P")) {
						s[i] = "D";
					}
				}
				if(!f) {
					s[i] = "D";
				}
			}
		}

		for(int i = 0; i < s.length; i++) {
			System.out.print(s[i]);
		}
		System.out.println();
		//-------------------------------------------------------------------------------------

//		if(f) {
//			System.out.println("Yes");
//		} else {
//			System.out.println("No");
//		}

//		System.out.println(ans);

		sc.close();
	}



}
//  [java]
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    String t = next();
    String[] ss = splitString(t);
    for(int i=0;i<ss.length;i++){
      if(ss[i].equals("?")){
        System.out.print("D");
      }
      else{
        System.out.print(ss[i]);
      }
    }



    //System.out.println();

  }

  static int lcm(int a,int b){
    return a*b*gcd(a,b);
  }

  static int gcd(int a,int b){
    if(a%b!=0){
      return gcd(b,a%b);
    }
    else{
      return b;
    }
  }

  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

  static int nextInt(){
    return Integer.parseInt(sc.next());
  }

  static long nextLong(){
    return Long.parseLong(sc.next());
  }

  static double nextDouble(){
    return Double.parseDouble(sc.next());
  }

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}
//  [cpp]
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	char S[200010];
	fread(S, 1, 200010, stdin);

	int L = 0, R = 200000;
	while (L + 1 < R) {
		int M = (L + R) / 2;
		if (S[M] >= '?') L = M;
		else R = M;
	}

	int r = R / 8 * 8;
	ll* kaki = (ll*)S;
	for (char* ci = S; ci < S + r; ci += 8) {
		ll tmp = *((ll*)ci);
		tmp += 0x0303030303030303;
		tmp ^= 0x0101010101010101;
		tmp += 0x0101010101010101;
		tmp &= 0xfcfcfcfcfcfcfcfc;
		*kaki++ = tmp;
	}
	for (int i = r; i < R; i++) {
		if (S[i] == '?') S[i] = 'D';
	}
	fwrite(S, 1, R, stdout);

	Would you please return 0;
}
//  [cpp]
#include<cstdio>
#include<algorithm>
using namespace std;
char p[201000];
int main(){
    scanf("%s",p);
    for(int i=0;p[i];i++){
        if(p[i]=='?')p[i]='D';
    }
    printf("%s\n",p);
}
//  [cpp]
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
char str[200005];
int main(){
	scanf(" %s",str);
	int i,n=strlen(str);
	for(i=0;i<n;i++)
		if(str[i]=='?')
			str[i]='D';
	puts(str);
}
//  [cpp]
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <cstdint>
#include <numeric>
#define INF 1000000000
#define LLINF 2000000000000000
#define MOD 1000000007
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long

signed main(){
  string s;
  cin >> s;

  int pd[200000][2] = {};
  LOOP(i,s.length()){
    switch(s[i]){
      // case 'P':
      //   if(i!=0) pd[i][0] = pd[i-1][0];
      //   pd[i][0] = pd[i-1][0]++;
      //   pd[i][1] = -INF;
        break;

      case 'D':
        // if(i>0){
        //   pd[i][1] = max(pd[i-1][0]+1, pd[i-1][1]);
        // }
        // pd[i][0] = -INF;
        break;
      case '?':
        s[i] = 'D';
        if(i>0){
          pd[i][1] = max(pd[i-1][0]+1, pd[i-1][1]);
          pd[i][0] = max(pd[i-1][0]+1, pd[i-1][1]+1);
        }else{
          pd[i][1] = 0;
          pd[i][0] = 1;
        }
    }
    cerr << pd[i][0] << ":" << pd[i][1] << endl;
  }
  cout << s << endl;
}
//  [cpp]
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    string T;
    cin >> T;
    int T_size = int(T.length());
    int i;
    while(T.find("?") != string::npos){
        T.replace(T.find("?"), 1, "D");
    }

    cout << T << endl;
    

    return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,l,n) for(int i=l; i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(){
    string t; cin>>t;
    REP(i,t.size()){
        if(t.find("?")<t.size()) t.replace(t.find("?"),1,"D");
        else break;
    }
    cout << t << endl;
}
//  [c]
#include<stdio.h>
#include<string.h>
int main(void)
{
  char t[300000];
  scanf("%s",t);
  int len=strlen(t);
  for(int i=0;i<len;i++){
    if(t[i]=='?'){
      t[i]='D';
    }
  }
  printf("%s\n",t);
  return 0;
}
//  [c]
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar_unlocked(); while(c==' '||c=='\n') c=getchar_unlocked(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar_unlocked(); } *s='\0'; return len; }

int main(void){
	char c;
	while((c=getchar())!=10){
		putchar(c=='?'?'D':c);
	}
	putchar(10);
}
//  [c]
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long

char t[200010];

int main(){
  scanf("%s",t);
  int l=strlen(t);
  for(int i=0;i<l;i++){
    if(t[i]=='?'){
      t[i]='D';}}
  //printf("%lu\n",strlen(t));
  printf("%s\n",t);
  
  return 0;
}
//  [c]
#include <stdio.h>
#include <string.h>

int main() {
  char t[200002];
  scanf("%s", t);

  for(int i=0;i<strlen(t);i++){
    if(t[i]=='?') t[i]='D';
  }

  printf("%s", t);
  return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    int i;
    char s[200000]={};
    scanf("%s",&s);
    for(i=0;i<strlen(s);i++){
        if(s[i]=='?') printf("D");
        else printf("%c",s[i]);
    }    
    return 0;
}
//  [c]
#include<stdio.h>
#include<string.h>

typedef long long ll;

int main(){
    char s[200000];
    scanf("%s",s);
    for(int i=0;i<strlen(s);i++){
        if(s[i]=='?') s[i]='D';
    }
    printf("%s",s);

    return 0;
}
//  [javascript]
function main(input) {
    console.log(input.split('?').join("D"));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
'use strict'
function main(inp) {
  let ans = inp.split('?').join('D');
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
var input = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')
var T = input[0]
var pdReg = /[\?|P][\?|D]/g
var dReg = /\?/g
console.log(T.replace(pdReg, 'PD').replace(dReg, 'D'))
//  [javascript]
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var s = next();
	var mae = myconv(s,6);
	var ato = myconv(s,6);
	var len = s.length;
	/*for(var i = len - 1; i >= 0; i--){
		if(mae[i] == "?"){
			if(mae[i + 1] == "D"){
				mae[i] = "P";
			}else{
				mae[i] = "D";
			}
			
		}
	}*/
	for(var i = 0; i < len; i++){
		if(ato[i] == "?"){
			if(ato[i - 1] == "P"){
				ato[i] = "D";
			}else if(ato[i - 1] == "D" && (ato[i + 1] == "?" || ato[i + 1] == "D")){
				ato[i] = "P";
			}else{
				ato[i] = "D";
			}
			
		}
	}
	
	myout(myconv(ato,0));
}
//  [javascript]
"use strict";
var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.trim().split(/ |\n/), cid = 0;

function main() {
    let ans = cin[0].split("").map(x => x == '?' ? 'D' : x);
    console.log(ans.join(''));
}
main();
//  [go]
package main

import (
        "bufio"
        "fmt"
        "os"
)

func solution(T string) string {
        out := make([]byte, len(T))
        for i := 0; i < len(T); i++ {
                if T[i] == '?' {
                        out[i] = 'D'
                } else {
                        out[i] = T[i]
                }
        }
        return string(out)
}

func main() {
        var fp *os.File = os.Stdin
        reader := bufio.NewReaderSize(fp, 1024)
        T := readLine(reader)
        fmt.Println(solution(T))
}

func readLine(reader *bufio.Reader) string {
        buf := make([]byte, 0, 1024)

        for {
                l, p, _ := reader.ReadLine()
                buf = append(buf, l...)

                if !p {
                        break
                }
        }
        return string(buf)
}
//  [go]
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	//sc.Split(bufio.ScanWords)
	buf := make([]byte, 10000)
	sc.Buffer(buf, 200010)
	sc.Scan()
	t := sc.Text()
	//a := strings.Split(t, "")

	//if a[len(a)-1] == "?" { a[len(a)-1] = "D"}
	//if len(a) < 2 {
	//	fmt.Println(strings.Join(a, ""))
	//	return
	//}

	//for i := len(a)-2; i >= 0; i-- {
	//	if a[i] != "?" { continue }
	//	if a[i-1] == "D" {
	//		a[i] = "P"
	//	} else {
	//		a[i] = "D"
	//	}
	//}

	fmt.Println(strings.ReplaceAll(t, "?", "D"))
}

func slicePrint(s []int) {
	for i, v := range s {
		if i != 0 {
			fmt.Printf(" ")
		}
		fmt.Printf("%v", v)
	}
	fmt.Println("")
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}
//  [go]
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

//Main
var sc = bufio.NewScanner(os.Stdin)

var T string

func main() {
	sc.Split(bufio.ScanWords)
	fmt.Scanf("%s", &T)
	ans := ""
	for i := 0; i < len(T); i++ {
		if string(T[i]) == "?" {
			ans += "D"
		} else {
			ans += string(T[i])
		}
	}
	fmt.Println(ans)
}
//  [go]
package main

import "fmt"

func main(){
	var s,ans string
	fmt.Scan(&s)
	for i:=len(s)-1 ; i>=0 ; i-- {
//fmt.Println(s[i:i+1])
		if s[i:i+1] == "?"{
			ans = "D" +ans
			/*if i != len(s)-1 && ans[0:1] == "D" {
				//fmt.Printf("P")
				ans = "P" + ans
			} else {
//fmt.Printf("else %v",s[i:i+1])
				//fmt.Printf("D")
				ans = "D" + ans
			}*/
		} else {
			ans = s[i:i+1] + ans
			//fmt.Printf("%v",s[i:i+1])
		}
	}
	/*for i:=len(ans)-1 ; i>=0 ; i-- {
		fmt.Printf("%v",ans[i:i+1])
	}*/
	fmt.Println(ans)
}
//  [ruby]
puts gets.tr('?', 'D')
//  [ruby]
T = ARGF.gets.chomp

puts T.tr("?", "D")
//  [ruby]
t = gets.strip
puts t.tr("\?",'D')
//  [ruby]
t = gets.chomp.split('')

PD = []
D = []

t.each do |i|
  if i == "?"
    PD << "P"
  elsif i != "?"
    PD << i
  end
end

t.each do |k|
  if k == "?"
    D << "D"
  elsif k != "?"
    D << k
  end
end

PD_count1 = PD.join.scan("PD").length
PD_count2 = PD.join.scan("D").length

D_count1 = D.join.scan("D").length
D_count2 = D.join.scan("PD").length

print (PD_count1 + PD_count2) >= (D_count1 + D_count2) ? PD.join : D.join
//  [ruby]
t = gets.chomp.chars
(t.length).times do |i|
    if t[i] == "?"
        t[i] = 'D'
    end
end
t.each do |n|
    printf("%c", n)
end
//  [ruby]
#!/usr/bin/env ruby
# require 'pry'

t = gets.chomp.split('')
t.push(nil).unshift(nil)
t.each.with_index do |ele, i|
  next if ele != '?'
  if t[i-1] == 'P'
    t[i] = 'D'
  elsif t[i+1] == 'D' || t[i+1] == '?'
    t[i] = 'P'
  else
    t[i] = 'D'
  end
end
puts t.join
//  [rust]
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(t:#));
    // ?はD
    t.chars()
        .map(|x| if x == '?' { 'D' } else { x })
        .collect::<String>()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}
tests! {
    test1: "PD?D??P\n" => "PDPDPDP\n",
    test2: "P?P?\n" => "PDPD\n",
}
//  [rust]
use proconio::input;

fn main() {
        input!{
                t: String
        }
        let s : String = t.chars().map(|c| if c == '?' {'D'} else {c}).collect();
        println!("{}", s);
}
//  [rust]
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let mut t: Vec<char> = iterator.next().unwrap().chars().collect();

    let mut result = String::new();
    for i in 0..t.len() {
        if t[i] == '?' {
            t[i] = 'D';
        }
        result.push(t[i]);
    }
    return result;
}
//  [swift]
import Foundation
var str = Array(readLine()!).map { String($0) }
for i in 0..<str.count {
  if str[i] == "?" {
    str[i] = "D"
  }
}
print(str.joined())
//  [swift]
import Foundation


let T = readLine()!
print(T.replacingOccurrences(of: "?", with: "D"))
//  [swift]

let question: Character = "?"
let D: Character = "D"
print(String(readLine()!.map({$0 == question ? D : $0})))
//  [typescript]
import { isRegExp } from "util";

class AtCoder {
  // 入力系
  input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);
  input_i=-1;

  n(){
    this.input_i++;
    return Number(this.input[this.input_i]);
  }
  nn(n:number):number[]{
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.n());
    }
    return a;
  }
  s(){
    this.input_i++;
    return String(this.input[this.input_i]);
  }
  ss(n:number):string[]{
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.s());
    }
    return a;
  }

  // コンソール
  o(...a:any){
    console.log(...a);
  }

  // Math
  abs(a:number){
    return Math.abs(a);
  }
  min(...a:number[]){
    return Math.min(...a);
  }
  max(...a:number[]){
    return Math.max(...a);
  }
  floor(a:number){
    return Math.floor(a);
  }
  ceil(a:number){
    return Math.ceil(a);
  }
  round(a:number){
    return Math.round(a);
  }

  // ソート
  asc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return a-b});
  }
  desc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return b-a});
  }

  // 自作
  gcd(...arr:number[]):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=x;
    }
    return arr[arr.length-1];
  };
  lcm(...arr:number[]):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=arr[i]*arr[i+1]/x;
    }
    return arr[arr.length-1];
  };
  isPrime(n:number):boolean{
    if(n < 2) return false;
    const suq=Math.sqrt(n);
    for(let i=2;i<=suq;i++){
      if(n%i==0){
        return false;
      }
    }return true;
  };
  deduplicate(a:any[]):any[]{
    return Array.from(new Set(a));
  };
  f(roop:number, callback:any){
    for(let i=0;i<roop;i++){
      callback(i);
    }
  };
  Yes(){
    console.log('Yes');
  }
  No(){
    console.log('No');
  }
  YES(){
    console.log('YES');
  }
  NO(){
    console.log('NO');
  }
}
const m = () => {
  const o = new AtCoder();
  let s=o.s()
  let ans= ''
  for(let i=0;i<s.length;i++){
    ans += (s[i] == '?' ? 'D' : s[i]);
  }
  o.o(ans)
}
m();
//  [typescript]
import * as fs from 'fs';

const readString = (() => {
  const input = fs.readFileSync(0).toString();
  const words = input.split(/[ \n]/);
  let i = 0;
  return () => words[i++] || '';
})();
const readInt = () => parseInt(readString(), 10);
const readBigInt = () => BigInt(readString());

const gcd = (a: bigint, b: bigint) => {
  const _gcd = (a: bigint, b: bigint): bigint => {
    const q = a % b;
    return q === 0n ? b : _gcd(b, q);
  };
  return a > b ? _gcd(a, b) : _gcd(b, a);
};

const MOD = 1000000007;
const MOD_BIGINT = BigInt(MOD);
class ModBigInt {
  constructor(public v: bigint) {}

  static of(n: number | bigint) {
    return new ModBigInt(ModBigInt.toBigInt(n));
  }

  static toBigInt(other: number | bigint | ModBigInt) {
    if (typeof other === 'bigint') return other;
    if (typeof other === 'number') return BigInt(other);
    return other.v;
  }

  clone = () => new ModBigInt(this.v);
  plus = (other: number | bigint | ModBigInt) => {
    this.v = (this.v + ModBigInt.toBigInt(other)) % MOD_BIGINT;
    return this;
  };
  minus = (other: number | bigint | ModBigInt) => {
    this.v = (this.v + MOD_BIGINT - ModBigInt.toBigInt(other)) % MOD_BIGINT;
    return this;
  };
  multiply = (other: number | bigint | ModBigInt) => {
    this.v = (this.v * ModBigInt.toBigInt(other)) % MOD_BIGINT;
    return this;
  };
  pow = (other: number) => {
    const v = mod(1);
    for (let i = 0; i < other; i++) v.multiply(this.v);
    return v;
  };
}

const mod = ModBigInt.of;

const abs = (a: bigint) => (a > 0n ? a : -a);

(function main() {
  const T = readString();
  console.log(T.replace(/\?/g, 'D'));
})();
//  [python]
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    n = int(input().strip())
    n=n%10
    if n==3:
        print("bon")
    elif n==0 or n== 1 or n== 6 or n==8:
        print("pon")
    else:
        print("hon")


if __name__ == '__main__':
    main()
//  [python]
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    if(N%10 in (2,4,5,7,9)):
        print("hon")
    elif(N%10 in (0,1,6,8)):
        print("pon")
    else:
        print("bon")
if __name__ == '__main__':
    main()
//  [java]
import java.util.*;
public class Main{

	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.next());
		n %= 10;
		if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9){
			System.out.print("hon");
		}else if (n == 3){
			System.out.print("bon");
		}else{
			System.out.print("pon");
		}
	}
}
//  [java]
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String ans = "bon";
        switch (N % 10) {
            case 2:
            case 4:
            case 5:
            case 7:
            case 9:
                ans = "hon";
                break;
            case 0:
            case 1:
            case 6:
            case 8:
                ans = "pon";
                break;
        }
        System.out.println(ans);
    }
}
//  [java]
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int I = sc.nextInt();
    	String S = Integer.toString(I);
    	char s = S.charAt(S.length()-1);
    	if (s == '3') {
    		System.out.println("bon");
    	} else if (s == '0' || s == '1' || s == '6' || s =='8') {
    		System.out.println("pon");
    	} else {
    		System.out.println("hon");
    	}
    }
}
//  [cpp]
#include <iostream>
#include <vector>
#define fo(i,n) for(int i  = 0 ; i<n;i++)
#define p(x) push_back(x)
#define lld long long int
#define v<lld>  vector <lld>
using namespace std;
vector <lld> t[1000000];
vector <lld> tcount[1000000];
vector <lld> input(1000000,0);

void inp(int k){
	fo(jjj, k){
			lld temp;
			cin >> temp;
			input[jjj] = (temp);
			}
}


int main(){	
		string input;
		lld t,s,n,n1,n2,n3,k;
		cin >> n;
		
		n = n%10;
		
		if(n == 1 || n == 0 ||n == 6 ||n == 8 ){
		cout << "pon";	
		}
		if(n == 3){
		cout << "bon";	
		}
		
		if(n == 2 || n == 4 ||n ==5 ||n == 7 || n==9 ){
		cout << "hon";	
		}
		
		
		
}
//  [c]
#include<stdio.h>
int main(void) {
    int n, rem=0;
    scanf("%d", &n);
    rem = n % 10;
    if (rem == 3) {
        printf("bon");
    }
    else if ((rem ==0 ) || (rem == 1) || (rem ==6 )||(rem==8)) {
        printf("pon");
    }
    else {
        printf("hon");
    }
    return 0;
}