jiahuimbzuai/CoQuIR huggingface dataset:
//  [java]
import java.util.*;
import java.io.*;

class Mod{
    static final int MOD = 1000_000_007;
    static final long[] fact = makeFactorialArray(1000000);
    static final long[] factInv = makeInversedArray(fact);

    public static long add(long a, long b){
        long tmp = (a+b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long sub(long a, long b){
        return add(a,-b);
    }
    public static long mult(long a, long b){
        long tmp = (a*b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long power(long a, long x){ //calculate a^x
        if(x<0)return 0;
        if(x==0)return 1;
        if(x%2==0) {
            long half = power(a,x/2);
            return mult(half,half);
        }
        return (a*power(a,x-1)) % MOD;
    }
    public static long inverse(long a){
        return power(a,MOD-2);
    }
    public static long div(long a, long b){
        return mult(a, inverse(b));
    }
    public static long[] makeFactorialArray(int size){
        long[] array = new long[size];
        array[0]=1;
        for(int i=1;i<size;i++){
            array[i]=mult(array[i-1],i);
        }
        return array;
    }
    public static long[] makeInversedArray(long[] original){
        long[] array = new long[original.length];
        for(int i=0;i<original.length;i++){
            array[i] = inverse(original[i]);
        }
        return array;
    }
    public static long combination(int n, int r){
        if(n<0 || r<0 || n<r) return 0;
        return mult(fact[n], mult(factInv[r],factInv[n-r]));
    }
    public static long gcd(long a, long b){
        if(a<b) return gcd(b,a);
        if(b==0) return a;
        if(a%b==0) return b;
        return gcd(b,a%b);
    }
    public static long lcm(long a, long b){
        return (a/gcd(a,b))*b;
    }

    public static List<Long> divisors(long N){
        LinkedList<Long> ans = new LinkedList<>();
        for(long n = (long)Math.sqrt(N)+1; n>0; n--){
            if(n*n>N) continue;
            if(n*n==N) ans.add(n);
            else if(N%n==0){
                ans.addFirst(n);
                ans.addLast(N/n);
            }
        }
        return ans;
    }

}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
        long D = Mod.gcd(A,B);

        List<Long> div = Mod.divisors(D);
        System.out.println(div.get(div.size()-K));
    }
}
//  [java]
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);

        int a = Integer.parseInt(s.next());
        int b = Integer.parseInt(s.next());
        int k = Integer.parseInt(s.next());

        int min = a < b ? a : b;
        List<Integer> list = new ArrayList<Integer>();
        for (int i = 1; i <= min; i++) {
            if (a % i == 0 && b % i == 0) {
                list.add(i);
            }
        }
        Optional<Integer> an = list.stream()
                .sorted(Comparator.reverseOrder())
                .skip(k - 1)
                .findFirst();

        System.out.println(an.orElse(0));
    }
}
//  [java]

import java.util.*;
import java.util.stream.*;
import java.util.function.*;

public class Main {
    public static void main(String[] args) throws Exception {
        System.out.println(new Main().solve());
    }
    
    int solve() {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        
        List<Integer> divA = IntStream.rangeClosed(1, a).filter(i -> a % i == 0).boxed()
                        .sorted(Comparator.reverseOrder()).collect(Collectors.toList());
        List<Integer> divB = IntStream.rangeClosed(1, b).filter(i -> b % i == 0).boxed()
                        .sorted(Comparator.reverseOrder()).collect(Collectors.toList());
        divA.retainAll(divB);
        
        return divA.get(k - 1);
    }
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
 
int main() {

int a,b,c;cin>>a>>b>>c;
  
  int count=0;
  REP(i,1,9999999){if(a%i==0&&b%i==0){count++;}
  }
  int j=1,k=0;
  vector<int>d(count);
  while(k<count){ 
    if(a%j==0&&b%j==0){k++;d.at(k-1)=j;} j++;}
  
  cout<<d.at(count-c)<<endl;
  
  
}
//  [c]
#include<stdio.h>
int main()
{
    int a,b,c,i,sum=0,l;

    scanf("%d %d %d",&a,&b,&c);

    if(a>b)
    {
        for(i=b;i>0;i--)
    {
        if(a%i==0 && b%i==0) sum++;

        if(sum==c) l = i;

        if(sum==c) break;

        else continue;
    }
        printf("%d\n",l);

    }

     else if(a<b)
    {
        for(i=a;i>0;i--)
    {
        if(a%i==0 && b%i==0) sum++;

        if(sum==c) l = i;

        if(sum==c) break;

        else continue;
    }
        printf("%d\n",l);

    }

    else if(a==b)
    {
        for(i=a;i>0;i--)
    {
        if(a%i==0 && b%i==0) sum++;

        if(sum==c) l = i;

        if(sum==c) break;

        else continue;
    }
        printf("%d\n",l);

    }

return 0;
}
//  [c]
#include<stdio.h>

int main(void)
{
  int a,b,k;
  scanf("%d%d%d",&a,&b,&k);

  int i,c[100],j=0;
  for(i=1;(i<=a)||(i<=b);i++)
    if((a%i==0)&&(b%i==0)){
      j++;
      c[j]=i;
    }

  printf("%d\n",c[j-k+1]);
  return 0;
}
//  [c]
#include <stdio.h>

int main(void){

  int a,b,k,i;
  scanf("%d %d %d",&a,&b,&k);
  
  for(i=100;i>=1;--i){
  	if(a%i==0 && b%i==0){
    	k--;
      if(k==0){
    	printf("%d",i);
    }
    }
  }
  
  return 0;
}
//  [javascript]
module.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";var r=n(1);n(2)(r.readFileSync("/dev/stdin","utf8"))},function(t,e){t.exports=require("fs")},function(t,e,n){"use strict";var r=n(3),i=n(5);t.exports=function(t){var e=new r(t);i(e)}},function(t,e,n){"use strict";var r=n(4);t.exports=class{constructor(t){var e=t.trim().split(/\s+/g);this.inp=new r(e)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,n){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,n){"use strict";t.exports=function(t){for(var e=t.in(),n=t.in(),r=t.in(),i=[],s=1;s<=100;s++)e%s==0&&n%s==0&&i.push(s);i.sort(function(t,e){return e-t});var o=i[r-1];console.log(o)}}]);
//  [javascript]
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let [a,b,k] = nextIntArray()
    let large = a > b ? a:b
    let small = a < b ? a:b
    let arr = []
    for(let i = 1; i<=large; i++){
        if(a % i == 0 && b % i == 0) arr.push(i)
    }
    console.log(arr[arr.length-k])
}
Main()
//  [javascript]
function Main(input) {
  input = input.split("\n")[0].split(" ");
  var a = parseInt(input[0]);
  var b = parseInt(input[1]);
  var c = parseInt(input[2]);
  var arr = [];
  for(var i = parseInt(Math.max(a, b)); i >= 1;  i--) {
    if(a % i === 0 && b % i === 0) {
      arr.push(i);
    }
  }
  console.log(arr[c - 1]);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
//usr/bin/env go run $0 $@ ; exit

package main
 
import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)
 
func run() {
	n := nextInt()
	k := nextInt()
	s := nextInt()

	count := 0;
	for i := n; i >= 0 ; i-- {
		if(n % i == 0 && k % i ==0){
			count ++
		}
		if(s == count){
			Println(i)
			return
		}
	}

}

// --- template ---
// Thanks https://gist.github.com/halllllll/853ab587fd82ee3ffe6f7fb7fb499695
 
var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
 
// Caution: You will get unexpected result if a single token is larger than this size.
const BufferSize = 64 * 1024 * 1024
 
func Print(a ...interface{}) (n int, err error) {
	return fmt.Fprint(out, a...)
}
 
func Printf(format string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, format, a...)
}
 
func Println(a ...interface{}) (n int, err error) {
	return fmt.Fprintln(out, a...)
}
 
func next() string {
	sc.Scan()
	return sc.Text()
}
 
func nextInt() int {
	a, err := strconv.Atoi(next())
	if err != nil {
		log.Fatal(err)
	}
	return a
}
 
func nextFloat() float64 {
	a, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		log.Fatal(err)
	}
	return a
}

 
func main() {
	sc.Buffer(make([]byte, 0, BufferSize), BufferSize)
	sc.Split(bufio.ScanWords)
	run()
	out.Flush()
}
//  [go]
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	a := nextInt()
	b := nextInt()
	k := nextInt()
	l := make([]int, 100+1)

	for i := 1; i <= 100; i++ {
		if a%i == 0 && b%i == 0 {
			l[i] = i
		}
	}
	sort.Ints(l)

	fmt.Println(l[101-k])

}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}
//  [go]
package main

import (
	"fmt"
)

func main() {
	var a, b, k int
	fmt.Scan(&a, &b, &k)
	var cnt int
	for i := min(a, b); i >= 1; i-- {
		if a%i == 0 && b%i == 0 {
			cnt++
			if cnt == k {
				fmt.Println(i)
				return
			}
		}
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
//  [ruby]
def main
  a,b,k = gets.chomp.split(" ").map(&:to_i)
  cnt = 0
  i = [a,b].min + 1
  while cnt < k
    i -= 1
    cnt += 1 if a % i == 0 && b % i == 0
  end
  puts i
end

main
//  [ruby]
#!/usr/bin/env ruby
a, b, k = gets.chomp.split.map(&:to_i)

n = [a, b].min

n.downto(1) do |i|
  if a % i == 0 && b % i == 0
    k -= 1

    if k == 0
      puts i
    end
  end
end
//  [ruby]
a,b,k = gets.strip.split.map(&:to_i)
n = a.gcd(b)
ary = []
i = 1
while i <= n
  if n%i==0
    ary << i
  end
  i += 1
end
puts ary.reverse[k-1]
//  [rust]
use proconio::{input, fastout};

macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn gcd(mut a: usize, mut b: usize) -> usize {
    if a<b {
        let mut tmp = a;
        a = b;
        b = tmp;
    } 
    let mut r = a % b;
    while r!=0 {
        a = b;
        b = r;
        r = a % b;
    }
    b
}

#[fastout]
fn main() {
    input!{
        mut a: usize,
        mut b: usize,
        k: usize,
    }

    let d = gcd(a,b);
    let mut cnt = 1;
    debug!(d);
    for i in (1..d+1).rev() {
        if d%i==0 {
            if cnt==k {
                println!("{}", i);
                return;
            }
            cnt += 1;
        }
    }
}
//  [rust]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        a: usize,
        b: usize,
        k: usize
    };

    let x1 = if a > b { a } else { b };
    let x2 = if a > b { b } else { a };

    let mut count = 0;
    let mut y = x1;

    while x1 > 0 {
        let z1 = x1 / y;
        let z2 = x2 / y;

        if z1 * y == x1 && z2 * y == x2 {
            count += 1;
        }
        if count == k {
            println!("{}", y);
            break;
        }

        y -= 1;
    }
}
//  [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 (a,b,k):(i64,i64,i64)=(read(),read(),read());
    let mut index:i64 =0;
    for i in (1..101).rev(){
        if (a%i==0) & (b%i==0) {
            index+=1;
        }
        if index==k{
            println!("{}",i);
            return;
        }
    }
}
//  [typescript]
namespace Coder {
  class Scanner {
    private buffer: string = '';
    private stdinQueue: any = [];

    constructor() {
      process.stdin.resume();
      process.stdin.setEncoding('utf8');
      process.stdin.on(
        'data',
        (chunk): void => {
          this.buffer += chunk;
          while (this.stdinQueue.length > 0) {
            const i = this.buffer.indexOf('\n');
            if (i < 0) {
              break;
            }
            let line = this.buffer.substr(0, i);
            if (line.endsWith('\r')) {
              line = line.slice(0, -1);
            }
            this.buffer = this.buffer.substr(i + 1);
            this.stdinQueue.shift()(line);
          }
        },
      );
    }
    public getLine(): Promise<string> {
      return new Promise((resolve, reject) => {
        const i = this.buffer.indexOf('\n');
        if (i >= 0 && this.stdinQueue.length === 0) {
          let line = this.buffer.substr(0, i);
          if (line.endsWith('\r')) {
            line = line.slice(0, -1);
          }
          this.buffer = this.buffer.substr(i + 1);
          resolve(line);
        } else {
          this.stdinQueue.push(resolve);
        }
      });
    }

    public close(): void {
      process.stdin.pause();
    }
  }
  async function solve() {
    const sc = new Scanner();
    const [A, B, K]: number[] = (await sc.getLine()).split(' ').map((x) => +x);
    const s = Math.max(A, B);
    let cnt = K;
    for (let i = s; i > 0; i -= 1) {
      if (A % i === 0 && B % i === 0) {
        cnt -= 1;
      }
      if (cnt === 0) {
        console.log(i);
        break;
      }
    }
    sc.close();
  }

  solve();
}
//  [typescript]
// @ts-ignore
require("fs").readFile("/dev/stdin", "utf8", (err, input) => {
  const [a, b, k] = input.split(" ")
  const m = Math.max(a, b)
  const r = Array.from(Array(m).keys())
    .map((_, i) => {
      return i + 1
    })
    .filter((i) => {
      return a % i == 0 && b % i == 0
    })
  console.log(r[r.length - parseInt(k)])
})
//  [typescript]
const main = (input: string) => {
  const [A, B, K] = input.split(" ").map(str => parseInt(str))
  let divisorList = [];

  for (let i = A; i > 0; i--) {
    if(A % i === 0 && B % i === 0) {
      divisorList.push(i)
    }
  }
  console.log(divisorList[K - 1])
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [python]
b = input()

if b == "A":
    print("T")
elif b == "T":
    print("A")
elif b == "G":
    print("C")
else:
    print("G")
//  [python]
a=input()
print("A" if a=="T" else "T" if a=="A" else "G" if a=="C" else "C")
//  [python]
b = input()
if b == "A":
    print("T")
elif b == "G":
    print("C")
elif b == "T":
    print("A")
elif b == "C":
    print("G")
//  [python]
import numpy as np

def main():
	b=input()
	result=''
	if(b=='A'):
		result='T'
	elif(b=='T'):
		result='A'
	elif(b=='G'):
		result='C'
	elif(b=='C'):
		result='G'
	
	print(result)

def inputList():
	a=list(map(int,input().split()))
	return a

def multisort(li,index):
	return sorted(li,key=lambda x: x[index])

if(__name__=='__main__'):
	main()
//  [python]
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())

def pne(n):
    print(n,end='')

rem = pow(10,9)+7

#n = ip()                                     #入力整数1つ
#x,y= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
a = ["A","C","T","G"]
n =input()
l = a.index(n)
print(a[(l+2)%4])
//  [python]
import numpy as np

s=input()

if s=='A':
    print('T')

if s=='T':
    print('A')

if s=='G':
    print('C')

if s=='C':
    print('G')
//  [java]
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String line = reader.readLine();
		if (line.equals("A")) {
			System.out.println("T");
		}
		else if (line.equals("T")) {
			System.out.println("A");
		}
		else if (line.equals("C")) {
			System.out.println("G");
		}
		else if (line.equals("G")) {
			System.out.println("C");
		}
	}
}
//  [java]

import java.io.*;
import java.util.*;
 
public class Main{
	
	
	public void solve(){
		String str = next();
		Map<String, String> map = new HashMap<>();
		map.put("A", "T");
		map.put("C", "G");
		map.put("G", "C");
		map.put("T", "A");
		
		out.println(map.get(str));
	}
	
	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}
	
	
	
	public static int nextInt(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;
	}
	
	public static long nextLong(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}
	public static String next(){
		int c;
		while(!isAlNum(c = read())){}
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	
	
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
}
//  [java]
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String b = sc.next();
		sc.close();
		String ans[] = {"A", "G", "T", "C"};
		int a = 0;
		for(int i = 0;i < ans.length; ++i) 
			if(b.equals(ans[i]))a = i;
		a += 2;
		if(a > 3)a %= 2;
		System.out.println(ans[a]);
	}

}
//  [java]
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		String b=stdIn.next();
		if(b.equals("A"))
			System.out.println("T");
		if(b.equals("T"))
			System.out.println("A");
		if(b.equals("G"))
			System.out.println("C");
		if(b.equals("C"))
			System.out.println("G");
	}
}
//  [java]
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String b = sc.next();
		sc.close();
		sc = null;
		String ans = "";
		switch(b) {
		case "A":{ans="T";break;}
		case "T":{ans="A";break;}
		case "C":{ans="G";break;}
		case "G":{ans="C";break;}
		}
		System.out.println(ans);
	}
}
//  [cpp]
#include <cstdio>

int main(){
//  freopen("in.in", "r", stdin);
//  freopen("out.out", "w", stdout);
  char ch;
  ch = fgetc(stdin);
  if(ch == 'A')
    printf("T");
  else  if(ch == 'T')
    printf("A");
  else  if(ch == 'C')
    printf("G");
  else
    printf("C");
  return 0;
}
//  [cpp]
#include<cstdio>
#include<cctype>
inline int getint() {
	register char ch;
	while(!isdigit(ch=getchar()));
	register int x=ch^'0';
	while(isdigit(ch=getchar())) x=(((x<<2)+x)<<1)+(ch^'0');
	return x;
}
int main() {
	char ch;
	scanf("%c",&ch);
	if(ch=='A') putchar('T');
	if(ch=='T') putchar('A');
	if(ch=='C') putchar('G');
	if(ch=='G') putchar('C');
	return 0;
}
//  [cpp]
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
    char b;
    scanf("%c", &b);
    switch (b) {
        case 'A':
            printf("T\n"); break;
        case 'C':
            printf("G\n"); break;
        case 'G':
            printf("C\n"); break;
        case 'T':
            printf("A\n"); break;
    }
    return 0;
}
//  [cpp]
#include "bits/stdc++.h"
using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REP1(i, n) for(ll i = 1;i < n;i++)
#define REPR(i, n) for(ll i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)

#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())

#define ll long long
#define ALL(a)  (a).begin(),(a).end()

#define pb(a) push_back(a)

int now,n,k;


int main(){
  int ans=0;
  //cin >> n >> k;
  string s;cin>>s;
  n=1024*1024*244;
  vector<int> a(n);
  REP(i,n) a[i]=(int)(34526.1234/((int)(s[0])+i));

  //vector<vector<int>> vv = vector<vector<int>>(n, vector<int>(m, 0));
/*
  int sum = accumulate(a.begin(),a.begin() + a.size(), 0);
  v.pb(now);

  //ソートする必要があるのじゃ…
  vector<int> a = {1, 4, 4, 7, 7, 8, 8, 11, 13, 19};

  auto Iter1 = lower_bound(ALL(a), 6);
  cout << "Iter1 = " << Iter1 - a.begin() << endl; //Iter1 = 3

  auto Iter2 = upper_bound(ALL(a), 7);
  cout << "Iter2 = " << Iter2 - a.begin() << endl; //Iter2 = 5

  cout << binary_search(a.begin(), a.end(), 4) << endl; //True


*/
  char c=s[0]-65;
  int d=(c-3)*(1-((68-s[0])>=0)*2);
  ans=((1<<(d+1))-(1-d/2))*((68-s[0])>=0)+((68-s[0])<0)*((int)(log(d+1)/log(2)-0.99));
  ans=(3-(((1<<(d+1))-(1-d/2))*((68-s[0])>=0)+((68-s[0])<0)*((int)(log(d+1)/log(2)-0.99))))*((68-s[0])<0)+(3+ans)*((68-s[0])>=0);
  char st=ans+65;
  s[0]=st;
  cout<<s<<endl;
  return 0;
}
//  [cpp]

#include <bits/stdc++.h>
using namespace std;

#define ll long long int
#define str string

ll MOD = 1000000007,INFL = 1ll << 60,INF = 1 << 30;
pair <ll, ll> A[10000000] = {}, X[1000000] = {};
int dy[]={0, 0, 1, -1},dx[]={1, -1, 0, 0};
vector <ll> v;
ll a = 0,m = 0,c = 0,n = 0,sum = 0, max = INF;
str S;
int ans = 0;

int findDigits(int n) {
        int i = 0;
        while (n > 0) {

                sum += n%10;
                n /= 10;
                i++;
        }
        return i;
}


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

cin >> S;
if(S[0] == 'T')cout << "A" << endl;
if(S[0] == 'A')cout << "T" << endl;
if(S[0] == 'G')cout << "C" << endl;
if(S[0] == 'C')cout << "G" << endl;

  //Code Line
        return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int main(){
	char c;
	scanf("%c",&c);
	printf("%c",c=='A'?'T':c=='T'?'A':c=='G'?'C':'G');
}
//  [c]
#include<stdio.h>

int main(void){
	char c;
	scanf("%c",&c);
	if(c=='A') printf("T");
	if(c=='T') printf("A");
	if(c=='C') printf("G");
	if(c=='G') printf("C");
}
//  [c]
#include <stdio.h>
int main (){
char a;
scanf ("%c",&a);

if (a=='A'){
printf ("T");
}  
if (a=='T'){
printf ("A");
}
if (a=='C'){
printf ("G");
}
 if (a=='G'){
printf ("C");
}
return 0;
	}
//  [c]
#include<stdio.h>
#include<string.h>
int main()
{
    char a,b;
    while(scanf("%c",&a)==1)
    {
        if(a=='A')
            printf("T\n");
        else if(a=='T')
            printf("A\n");
        else if(a=='C')
            printf("G\n");
        else if(a=='G')
            printf("C\n");
    }

	return 0;
}
//  [c]
#include<stdio.h>
int main()
{
   char b,answer;
   scanf("%c",&b);
   if(b=='A')
   {
       answer='T';
   }else if(b=='T')
   {
       answer='A';
   }else if(b=='C')
   {
       answer='G';
   }else if(b=='G')
   {
       answer='C';
   }
   printf("%c",answer);
    return 0;
}
//  [c]
main(){system("tr ATGC TACG");}
//  [javascript]
function Main(input){
  
  var str = input.trim()
  
  if(str=="A"){
    console.log("T");
  }else if(str=="T"){
    console.log("A");
  }else if(str=="C"){
    console.log("G");
  }else if(str=="G"){
    console.log("C");
  }
 
}//function end
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
  	switch (input[0]){
      case 'A':
    	console.log('T');
        break;
      case 'C':
    	console.log('G');
        break;
      case 'G':
    	console.log('C');
        break;
      case 'T':
        console.log('A');
        break;
                 }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {
  var input = input.split("\n");
  var b = input[0];

  if(b == "A") {
    console.log("T");
  }
  if(b == "T") {
    console.log("A");
  }
  if(b == "C") {
    console.log("G");
  }
  if(b == "G") {
    console.log("C");
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
"use strict";
    
const main = arg => {
    const b = arg.split("\n")[0];
    
    if(b == "A") {
        console.log("T")
    } else if (b == "T") {
        console.log("A")
    } else if (b == "C") {
        console.log("G")
    } else if (b == "G") {
        console.log("C");
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function upper_bound(d,a,b,e){for(var c;1<b-a;)d[c=0|(a+b)/2]<=e?a=c:b=c;return d[a]<=e?b:a};

console.log(main());
function main(){
  var b = o.a(1);
  if(b === "A")return "T";
  if(b === "T")return "A";
  if(b === "C")return "G"
  return "C";
}
//  [go]
package main

import (
  "fmt"
)

func makePair() map[byte]byte {
  acgt := []byte("ACGT")
  pair := make(map[byte]byte)
  for i := 0; i < 4; i++ {
    pair[acgt[i]] = acgt[3-i]
  }
  return pair
}

func main() {
  pair := makePair()
  var b string
  fmt.Scan(&b)
  fmt.Println(string(pair[[]byte(b)[0]]))
}
//  [go]
package main

import (
    "fmt"
)

func main() {
	var b, ans string
	fmt.Scan(&b)
	if b == "A" {
		ans = "T"
	} else if b == "T" {
		ans = "A"
	} else if b == "C" {
		ans = "G"
	} else {
		ans = "C"
	}
	fmt.Println(ans)
}
//  [go]
package main

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

func Solve(stdin io.Reader, stdout io.Writer) {
	sc := bufio.NewScanner(stdin)

	/* 入力バッファが大きくなるならこれ */
	buf := make([]byte, 10000000)
	sc.Buffer(buf, 10000000)

	sc.Scan()
	b := sc.Text()

	if b[0] == 'A' {
		_, _ = fmt.Fprintf(stdout, "T\n")
	} else if b[0] == 'T' {
		_, _ = fmt.Fprintf(stdout, "A\n")
	} else if b[0] == 'C' {
		_, _ = fmt.Fprintf(stdout, "G\n")
	} else {
		_, _ = fmt.Fprintf(stdout, "C\n")
	}
}

func main() {
	Solve(os.Stdin, os.Stdout)
	return
}
//  [go]
package main

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

func main() {
	b := ReadString()
	switch b {
	case "A":
		fmt.Println("T")
	case "T":
		fmt.Println("A")
	case "C":
		fmt.Println("G")
	case "G":
		fmt.Println("C")
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadString() (s string) { Scan(&s); return }
//  [go]
package main

import (
	"fmt"
)

func main() {
	var v string
	fmt.Scan(&v)

	var a byte

	if v[0] == 'A' {
		a = 'T'
	} else if v[0] == 'T' {
		a = 'A'
	} else if v[0] == 'C' {
		a = 'G'
	} else if v[0] == 'G' {
		a = 'C'
	}
	fmt.Println(string(a))
}
//  [ruby]
b = gets.chomp
map = {
  'A' => 'T',
  'T' => 'A',
  'C' => 'G',
  'G' => 'C',
}

puts map[b]
//  [ruby]
a=gets.chomp
if a=='T'
  puts 'A'
elsif a=='A'
  puts 'T'
elsif a=='G'
  puts 'C'
elsif a=='C'
  puts 'G'
end
//  [ruby]
b = gets.chomp.to_s
if b == 'A'
    puts 'T'
elsif b == 'T'
    puts 'A'
elsif b == 'G'
    puts 'C'
elsif b == 'C'
    puts 'G'
end
//  [ruby]
s = gets.chomp
h = {}
h["A"] = "T"
h["T"] = "A"
h["G"] = "C"
h["C"] = "G"
puts h[s]
//  [ruby]
b = gets.chomp

list = {
  'A' => 'T',
  'T' => 'A',
  'C' => 'G',
  'G' => 'C',
}

puts list[b]
//  [ruby]
a=%w(A C G T)
b=%w(T G C A)
n=gets.chomp
for i in 0..3
  if n==a[i]
    puts b[i]
  end
end
//  [rust]
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let b = buf.trim();
	if b == "A" {
		println!("T");
	}else if b == "C" {
		println!("G");
	}else if b == "T" {
		println!("A");
	}else{
		println!("C");
	}
}
//  [rust]
use std::io::*;//Not mine.
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();
    if(s == "A"){
        println!("T");
    }
    else if(s == "T"){
        println!("A");
    }
    else if(s == "G"){
        println!("C");
    }
    else {
        println!("G");
    }
}
//  [rust]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        b: chars,
    }

    match b[0] {
        'A' => println!("T"),
        'T' => println!("A"),
        'C' => println!("G"),
        'G' => println!("C"),
        _ => return,
    }

}
//  [rust]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {b: char};

    if b == 'C' {
        println!("G")
    } else if b == 'G' {
        println!("C")
    } else if b == 'A' {
        println!("T")
    } else {
        println!("A")
    }
}
//  [rust]
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::iter::Iterator;
use std::collections::*;
use std::cmp::*;
use itertools::Itertools;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }
  
  #[allow(unused_macros)]
  macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
    b: char,
    }

    if b == 'A' {
      println!("T");
    }else if b == 'T' {
      println!("A");
    }else if b == 'C'{
      println!("G");
    }else {
      println!("C");
    }
    
}
//  [rust]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! { b: char }
    let ans = match b {
        'A' => 'T',
        'T' => 'A',
        'C' => 'G',
        'G' => 'C',
        _ => 'n',
    };
    println!("{}", ans);
}
//  [swift]
var b = readLine()!

switch b {
case "A":
    b = "T"
case "T":
    b = "A"
case "C":
    b = "G"
case "G":
    b = "C"
default:
    break
}

print(b)
//  [typescript]
import * as fs  from 'fs';

//in
// A
//out
// T

//in
// G
//out
// C
const main = (inp: string) => {
    const tables :{[s:string]:string}= {
        A: 'T',
        T: 'A',
        G: 'C',
        C: 'G'
    };

    console.log(tables[inp]);
};

main(fs.readFileSync('/dev/stdin', 'utf8').trim());
//  [typescript]
const input = require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);
const nin=()=>{const r = input[0];input.shift();return Number(r)};
const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};
const sin=()=>{const r = input[0];input.shift();return String(r)}
const out=(...a)=>{console.log(...a)}
const floor=(a)=>{return Math.floor(a)}
const abs=(a)=>{return Math.abs(a)}
const min=(...a)=>{return Math.min(...a)}
const max=(...a)=>{return Math.max(...a)}
const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}}
const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};
const permutation = ({ result = [], pre = [], post, n = post.length }) => {
  if (n > 0) {
    post.forEach((_, i) => {
      const rest = [...post];
      const elem = rest.splice(i, 1);
      permutation({ result, pre: [...pre, ...elem], post: rest, n: n - 1});
    });
  } else {
    result.push(pre);
  }
  return result;
}
const main = ()=>{
  switch (sin()) {
    case 'A':
      out('T');
      break;
    case 'T':
      out('A');
      break;
    case 'C':
      out('G');
      break;
    case 'G':
      out('C');
      break;
  } 
}
main();
//  [typescript]
"use strict"
let fs = require('fs');
let input = fs.readFileSync("/dev/stdin", "utf8").split(/\s/);
console.log(
  input[0] == 'A' 
    ? 'T' 
    : input[0] == 'T'
      ? 'A'
      : input[0] == 'C'
        ? 'G'
        : 'C'):
//  [typescript]
namespace Coder {
  class Scanner {
    private buffer: string = '';
    private stdinQueue: any = [];

    constructor() {
      process.stdin.resume();
      process.stdin.setEncoding('utf8');
      process.stdin.on(
        'data',
        (chunk): void => {
          this.buffer += chunk;
          while (this.stdinQueue.length > 0) {
            const i = this.buffer.indexOf('\n');
            if (i < 0) {
              break;
            }
            let line = this.buffer.substr(0, i);
            if (line.endsWith('\r')) {
              line = line.slice(0, -1);
            }
            this.buffer = this.buffer.substr(i + 1);
            this.stdinQueue.shift()(line);
          }
        },
      );
    }
    public getLine(): Promise<string> {
      return new Promise((resolve, reject) => {
        const i = this.buffer.indexOf('\n');
        if (i >= 0 && this.stdinQueue.length === 0) {
          let line = this.buffer.substr(0, i);
          if (line.endsWith('\r')) {
            line = line.slice(0, -1);
          }
          this.buffer = this.buffer.substr(i + 1);
          resolve(line);
        } else {
          this.stdinQueue.push(resolve);
        }
      });
    }

    public close(): void {
      process.stdin.pause();
    }
  }

  async function solve() {
    const sc = new Scanner();
    const b: string = await sc.getLine();
    const ans: any = { A: 'T', T: 'A', C: 'G', G: 'C' };
    console.log(ans[b]);
    sc.close();
  }

  solve();
}
//  [typescript]
class Main {
    /**
     * main
     */
    public static main(input: string): void {
        const pair:Map<String,String> = new Map<String,String>();
        pair.set('A','T');
        pair.set('T','A');
        pair.set('C','G');
        pair.set('G','C');
        console.log(pair.get(input.trim()));    
    
    }
  }
  
  Main.main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
type Helix = "A" | "C" | "G" | "T";
const HelixCouple: Helix[] = ["A", "T", "C", "G"];
const getOtherHelix = function(helix: Helix) {
  const index = HelixCouple.indexOf(helix);
  return HelixCouple[index + (index%2 == 0 ? 1 : -1)]
}

const entryPoint = function(args: string[]) {
  console.log(getOtherHelix(args[0] as Helix));
}

const getStandardInput = function() {
  process.stdin.resume();
  process.stdin.setEncoding('utf8');
  let inputString = '';
  process.stdin.on('data', function(chunk) {
      inputString += chunk;
  });
  process.stdin.on('end', () => entryPoint(inputString.split("\n")));
}();
//  [python]
def main():
    Sd = input()
    T = input()

    i1 = [i for i, x in enumerate(Sd) if x == T[0]]
    i2 = [i for i, x in enumerate(Sd) if x == '?']
    indexes = (i1 + i2)[::-1]
    s = list(Sd)
    for i in indexes:
        for j in range(len(T)):
            if i + len(T) <= len(Sd):
                if s[i+j] == T[j] or s[i+j] == '?':
                    s[i+j] = T[j]
                    continue
            s = list(Sd)
            break
        else:
            ans = ''.join(s)
            ans = ans.replace('?', 'a')
            print(ans)
            exit()

    print('UNRESTORABLE')

main()
//  [python]
def main():
    S_p = input()
    T = input()
    N = len(T)

    str_list = [S_p[i:i+N] for i in range(len(S_p)-N+1)]
    str_candidate = []
    # itemはstr_listの中の一つ
    for i, item in enumerate(str_list):
        # Tとの比較を行い，等しければその部分を使った文字列をcandidateに入れる．
        for j, check_str in enumerate(item):
            if check_str == "?" or check_str == T[j]:
                pass
            else:
                break
            # 次の等式が満たせれば全ての文字が等しかったと判断
            if j+1 == N:
                str_candidate.append(S_p[:i]+T+S_p[i+N:])
    if len(str_candidate) == 0:
        print("UNRESTORABLE")
        return None
    str_result = []
    for item in str_candidate:
        str_result.append(item.replace("?", "a"))
    str_result.sort()
    print(str_result[0])
    return None

if __name__ == "__main__":
    main()
//  [python]
s = input()
t = input()

candidate = ("z" * len(s)) + "a"
for i in range(len(s) - len(t) + 1):
    if s[i] == t[0] or s[i] == '?':
        for j in range(len(t)):
            if s[i + j] != '?' and t[j] != s[i + j]:
                break
        else:
            candidate = min(s[0:i] + t + s[i+len(t):], candidate)
                
if candidate == ("z" * len(s)) + "a":
    print('UNRESTORABLE')
else:
    print(candidate.replace('?', 'a'))
//  [python]
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    s = S()
    sa = ''
    for c in s:
        if c == '?':
            sa += 'a'
        else:
            sa += c
    t = S()
    r = None
    l = len(t)
    for i in range(len(s)-l+1):
        f = True
        for j in range(l):
            if s[i+j] != '?' and s[i+j] != t[j]:
                f = False
                break
        if f:
            tr = sa[:i] + t + sa[i+j+1:]
            if not r or r > tr:
                r = tr

    if not r:
        return 'UNRESTORABLE'
    return r


print(main())
//  [python]
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string

S = input()
T = input()

slen = len(S)
tlen = len(T)

def can_fill(substr, T):
    for s, t in zip(substr, T):
        if s != '?' and s != t:
            return False
    return True

ans = None
for i in range(len(S) - tlen + 1):
    substr = S[i:i+tlen]
    if can_fill(substr, T):
        S2 = S[:i] + T + S[i+tlen:]
        S2 = S2.replace('?', 'a')
        if ans == None:
            ans = S2
        else:
            ans = min(ans, S2)

if ans is None:
    print('UNRESTORABLE')
else:
    print(ans)
//  [python]
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import fractions
from functools import reduce
import bisect
import sys
import logging
import heapq

#logging.basicConfig(level=logging.DEBUG)

input = sys.stdin.readline

setrecursionlimit(1000000)


def main():
	s = input()[:-1]
	t = input()[:-1]
	for i in reversed(range(len(s) - len(t) + 1)):
		flag = True
		for j in range(len(t)):
			if(s[i+j]  != '?' and s[i+j] != t[j]):
				flag = False
				break
		if flag:
			ans = []
			for j in s:
				ans.append(j)
			for j in range(i, i+len(t)):
				ans[j] = t[j-i]
			a = ''
			for i in ans:
				a += i
			print(a.replace('?','a'))
			return
	print('UNRESTORABLE')


def factorization(n):
	arr = []
	temp = n
	for i in range(2, int(-(-n**0.5//1))+1):
		if temp%i==0:
			cnt=0
			while temp%i==0:
				cnt+=1
				temp //= i
			arr.append([i, cnt])

	if temp!=1:
		arr.append([temp, 1])

	if arr==[]:
		arr.append([n, 1])

	return arr

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

class PriorityQueue():
	def __init__(self):
		self.queue = []
	def push(self,i):
		heapq.heappush(self.queue,-i)
	def pop(self):
		return -1 * heapq.heappop(self.queue)
	def sum(self):
		return -sum(self.queue)

main()