jiahuimbzuai/CoQuIR huggingface dataset:
//  [c]
#include <stdio.h>
#define true 1
#define false 0

int loop(int a);
int abs(int a);

int main(void)
{
    int k=0,ans=0,count=0;
    scanf("%d",&k);

    for(int i=1;i<100000;i++){
        if(loop(i)==true){
            ans=i;
            count+=1;
            if(count==k) break;
        }
    }
    printf("%d",ans);
}

int loop(int a){
    int right=0,left=0;
    int flag=true;
    while(true){
        if(a-10<0) break;
        right=a%10;
        left=(a/10)%10;
        if(abs(right-left)<=1){
            a=a/10;
            loop(a);
        } else {
            flag=false;
            break;
        }
    }
    return flag;
}

int abs(int a){
    if(a<0) a=(-1)*a;
    return a;
}
//  [c]
#include <stdio.h>
#define true 1
#define false 0

int loop(int a);
int abs(int a);

int main(void)
{
    int k=0,ans=0,count=0;
    scanf("%d",&k);

    for(int i=1;i<100000;i++){
        if(loop(i)==true){
            ans=i;
            count+=1;
            if(count==k) break;
        }
    }
    printf("%d",ans);
}

int loop(int a){
    int right=0,left=0;
    int flag=true;
    while(true){
        if(a-10<0) break;
        right=a%10;
        left=(a/10)%10;
        if(abs(right-left)<=1){
            a=a/100;
            loop(a);
        } else {
            flag=false;
            break;
        }
    }
    return flag;
}

int abs(int a){
    if(a<0) a=(-1)*a;
    return a;
}
//  [javascript]
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.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(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[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((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));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 K = nextInt();
  var queue = [1,2,3,4,5,6,7,8,9];
  var last = 0;
  for(var i = 0; i < K; i++){
    var tmp = queue[i];
    last = tmp;
    switch(last % 10){
      case 0:
        queue.push(last * 10);
        queue.push(last * 10 + 1);
        break;
      case 9:
        queue.push(last * 10 + 8);
        queue.push(last * 10 + 9);
        break;
      default:
        queue.push(last * 10 + last % 10 - 1);
        queue.push(last * 10 + last % 10);
        queue.push(last * 10 + last % 10 + 1);
        break;
                    }
    
  }
  //myerr(queue);
  myout(queue[K - 1]);
}
//  [javascript]
function main(input) {
  const inputs = input.split('\n')
  const [K] = inputs[0].split(' ').map(Number)
  // console.log(K)
  const a = [1,2,3,4,5,6,7,8,9]
  let p = 0
  while(true) {
    // console.log(K, p, a.length, a)
    if (K <= a.length) {
      // console.log('OK:', K, a.length)
      console.log(a[K - 1])
      return 
    }
    const len = a.length
    for(let i = p; i < len; i++) {
      for (let j = -1; j <= 1; j++) {
        let k = String(a[i])
        let d = a[i] % 10 + j
        if (d < 10 && 0 <= d) {
          const nn = k + String((a[i] % 10) + j)
          a.push(Number(nn))
        }
      }
      p++
    }
  }
  // console.log(a)
  // console.log('finished')
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
"use strict";

const gen = function (first, digit) {
    if(first == 1 && digit == 1) return [1,2,3,4,5,6,7,8,9]
    let q = [[first]]
    let ans = []
    while (q.length > 0) {
        let tmp = q.shift()
        if (tmp.length == digit) {
            ans.push(Number(tmp.join("")))
            continue
        }
        const last = tmp[tmp.length - 1]
        if (last !== 0) q.push([...tmp, last - 1])
        q.push([...tmp, last])
        if (last !== 9) q.push([...tmp, last + 1])
    }
    return ans
}

const main = arg => {
    const input = arg.trim().split("\n");

    let K = parseInt(input[0].split(" ")[0]);
    let first = 1
    let digit = 1
    while(K > 0){
        let tmp = gen(first, digit)
        // console.log(K, first, digit, tmp)
        if(tmp.length >= K){
            console.log(tmp[K-1])
            return
        }
        K = K - tmp.length
        if(first==1 && digit == 1){
            digit++
        }else if(first !== 9){
            first++
        }else{
            first = 1
            digit++
        }
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
    function Main(input){
        k=parseInt(input);
        i=12;
        c=12;
        while(c<k){
            i++;
            a=parseInt(String(i).substr(0,1));
            b=parseInt(String(i).substr(1,1));
            if(a-b<-1){
                i=(parseInt(String(i).substr(0,1))+1)*(10**(String(i).length-1));
            }
            a=parseInt(String(i).substr(0,1));
            b=parseInt(String(i).substr(1,1));
            if(a-b>1){
                tmp=parseInt(String(i).substr(0,1))*(10**(String(i).length-1));
                tmp2=(parseInt(String(tmp).substr(0,1))-1)*(10**(String(i).length-2));
                tmp3=parseInt(String(i-tmp).substr(0,1))*(10**(String(i).length-2));
                i=tmp+tmp2+(i-tmp-tmp3);
            }
            p=true;
            for(ii=0;ii<String(i).length-1;ii++){
                a=parseInt(String(i).substr(ii,1));
                b=parseInt(String(i).substr(ii+1,1));
                if(Math.abs(a-b)>1){
                    p=false;
                    break;
                }
            }
            if(p==true){
                c++;
            }
        }
        if(k>=10){
            console.log(String(i));
        }else{
            console.log(String(k));
        }
    }
    Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
    function Main(input){
        k=parseInt(input);
        i=12;
        c=12;
        while(c<k){
            i++;
            a=parseInt(String(i).substr(0,1));
            b=parseInt(String(i).substr(1,1));
            if(a-b<-1){
                i=(parseInt(String(i).substr(0,1))+1)*(10**(String(i).length-1));
            }
            a=parseInt(String(i).substr(0,1));
            b=parseInt(String(i).substr(1,1));
            if(a-b>1){
                tmp=parseInt(String(i).substr(0,1))*(10**(String(i).length-1));
                tmp2=(parseInt(String(tmp).substr(0,1))-1)*(10**(String(i).length-2));
                tmp3=parseInt(String(i-tmp).substr(0,1))*(10**(String(i).length-2));
                i=tmp+tmp2+(i-tmp-tmp3);
            }
            p=true;
            for(ii=0;ii<String(i).length-1;ii++){
                a=parseInt(String(i).substr(ii,1));
                b=parseInt(String(i).substr(ii+1,1));
                if(Math.abs(a-b)>1){
                    p=false;
                    break;
                }
            }
            if(p==true){
                c++;
            }
        }
        if(k>=10){
            console.log(i);
        }else{
            console.log(k);
        }
    }
    Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

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

func main() {
	sc := NewScanner()

	k := sc.ReadInt()
	if k < 10 {
		fmt.Println(k)
		return
	}

	dpTable := make([][]int, 1)
	dpTable0 := make([]int, 12)
	dpTable[0] = dpTable0
	for i := 1; i <= 10; i++ {
		dpTable0[i] = 1
	}

	lunlunCount := 9
	rowI := 0
	colI := 1
	for lunlunCount < k {
		rowI++
		dpPrevRow := dpTable[rowI-1]
		dpRow := make([]int, 12)
		dpTable = append(dpTable, dpRow)
		for colI = 1; colI <= 10; colI++ {
			dpRowI := dpPrevRow[colI-1] + dpPrevRow[colI] + dpPrevRow[colI+1]
			dpRow[colI] = dpRowI
			if colI > 1 {
				lunlunCount += dpRowI
				if lunlunCount >= k {
					break
				}
			}
		}
	}
	restLunlunCount := k - (lunlunCount - dpTable[rowI][colI])

	answer := int64(colI - 1)
	for rowI > 0 {
		rowI--
		colI--
		checkedLunlunCount := 0
		for i := 0; i < 3; i++ {
			next := dpTable[rowI][colI]
			if checkedLunlunCount+next >= restLunlunCount {
				answer = answer*10 + int64(colI-1)
				restLunlunCount -= checkedLunlunCount
				break
			}
			checkedLunlunCount += next
			colI++
		}
	}

	fmt.Println(answer)
}

// util
// * math

func AbsInt(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func MinInt(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

// * io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}
//  [go]
package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	k := nextInt()

	for i := 1; i < 10; i++ {
		enq(i)
	}

	lidx := 0
	for queue.Len() > 0 {
		ei := deq()
		lidx++
		if lidx == k {
			fmt.Println("DBG HIT Kth") //! DBG
			fmt.Println(ei)
			return
		}

		eis := fmt.Sprintf("%d", ei)
		base := ei*10 + ei%10
		if eis[len(eis)-1] != '0' {
			enq(base - 1)
		}
		enq(base)
		if eis[len(eis)-1] != '9' {
			enq(base + 1)
		}
	}
}

// 正数の桁数を返す
func keta(n int) int {
	keta := 0
	if n == 0 {
		return 1
	}
	for n > 0 {
		keta++
		n /= 10
	}
	return keta
}

var queue = list.New()

func enq(a int) {
	queue.PushBack(a)
}
func deq() int {
	e := queue.Front()
	queue.Remove(e)
	return e.Value.(int) // 明示的キャストが必要
}

// DBGprintqueue print the queue
//! DBG
func DBGprintqueue() {
	fmt.Printf("DBGqueue: [")
	now := queue.Front()
	for now != nil {
		fmt.Printf("%d ", now.Value.(int))
		now = now.Next()
	}
	fmt.Printf(" ]")
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	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 (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	k := nextInt()
	lcnt := 0
	ans := 0
	for i := 1; i < 1000000; i++ {
		fl := true
		si := fmt.Sprintf("%d", i)
		for j := 0; j < len(si)-1; j++ {
			diff := abs(int(si[j]) - int(si[j+1]))
			if diff > 1 {
				fl = false
				break
			}
		}
		if fl == true {
			lcnt++
			if lcnt == k {
				ans = i
				break
			}
		}
	}

	fmt.Println(ans)
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	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 (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	var i int
	if sc.Scan() {
		if num, err := strconv.Atoi(sc.Text()); err == nil {
			i = num
		}
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	k := nextInt()
	var count int
	str := strconv.Itoa(k)
	maxDigit := len(str)
	var backLunluns []int

	for i := 1; i < 10; i++ {
		backLunluns = append(backLunluns, i)
		count++
		if count == k {
			fmt.Println(i)
			return
		}
	}
	for d := 2; d <= maxDigit; d++ {
		var lunluns []int
		for i := 0; i < len(backLunluns); i++ {
			str := strconv.Itoa(backLunluns[i])
			last := str[len(str)-1]
			num, _ := strconv.Atoi(string(last))
			v := backLunluns[i]*10 + num
			if v%10 == 0 {
				lunluns = append(lunluns, v)
				count++
				if count == k {
					fmt.Println(v)
					return
				}
				lunluns = append(lunluns, v+1)
				count++
				if count == k {
					fmt.Println(v + 1)
					return
				}
			} else {
				lunluns = append(lunluns, v-1)
				count++
				if count == k {
					fmt.Println(v - 1)
					return
				}
				lunluns = append(lunluns, v)
				count++
				if count == k {
					fmt.Println(v)
					return
				}
				lunluns = append(lunluns, v+1)
				count++
				if count == k {
					fmt.Println(v + 1)
					return
				}
			}
		}
		backLunluns = lunluns
	}
}
//  [ruby]
K = gets.to_i
DP_L = Array.new(11){ Array.new(11, 0) }
DP_S = Array.new(11){ Array.new(10, 0) }

(0 .. 9).each{|i| DP_L[1][i] = 1; DP_S[1][i] = i }

(2 .. 10).each do |n|
  (0 .. 9).each do |i|
    DP_L[n][i] = DP_L[n - 1][i - 1] + DP_L[n - 1][i] + DP_L[n - 1][i + 1]
  end
  DP_S[n][0] = DP_S[n - 1][9]
  (1 .. 9).each do |i| 
    DP_S[n][i] = DP_S[n][i - 1] + DP_L[n][i]
  end
  break if DP_S[n][9] >= K
end

def lunlun(n,i,k,a)
  return a if n == 1

  if DP_L[n - 1][i - 1] >= k
    lunlun(n - 1, i - 1, k, a * 10 + i - 1)
  elsif DP_L[n - 1][i - 1] +  DP_L[n - 1][i] >= k
    lunlun(n - 1, i, k - DP_L[n - 1][i - 1], a * 10 + i)
  elsif DP_L[n - 1][i - 1] + DP_L[n - 1][i] + DP_L[n - 1][i + 1] >= k
    lunlun(n - 1, i + 1, k - DP_L[n - 1][i - 1] - DP_L[n - 1][i], a * 10 + i + 1)
  else
    raise "illegal state"
  end
end

def answer(k)
  n = DP_S.index{|sum| sum[9] >= K }
  i = DP_S[n].index{|sum| sum >= K }
  lunlun(n, i, k - DP_S[n][i - 1], i)
end

puts answer(K)
//  [ruby]
K = gets.chomp.to_i

if K < 10
  puts K
  exit
end

def search(x, i, n, res = [])
  if x <= 1
    cs = [res[-1]-1, res[-1], res[-1]+1].select{|v| 0 <= v && v <= 9}
    res << cs[n-1]
    puts res.join
    exit
  end
  res << i
  nn = n
  cs = [i-1, i, i+1].select{|v| 0 <= v && v <= 9}
  cs.each do |j|
    if nn - PAT[x-1][j] <= 0
      return search(x-1, j, nn, res)
    end
    nn -= PAT[x-1][j]
  end
end

PAT = {}
PAT[1] = Hash.new(0)
0.upto(9) do |i|
  PAT[1][i] = [i-1, i, i+1].select{|v| 0 <= v && v <= 9}.size
end
k = 9


PAT[2] = Hash.new(0)
0.upto(9) do |i|
  PAT[2][i] = [i-1, i, i+1].select{|v| 0 <= v && v <= 9}.size
  if i > 0
    search(2, i, K-k) if k + PAT[2][i] >= K
    k += PAT[2][i]
  end
end

# x桁
3.upto(10) do |x|
  PAT[x] = Hash.new(0)
  0.upto(9) do |i|
    PAT[x][i] = PAT[x-1][i-1] + PAT[x-1][i] + PAT[x-1][i+1]
    if i > 0
      search(x, i, K-k) if k + PAT[x][i] >= K
      k += PAT[x][i]
    end
  end
end
//  [ruby]
k = gets.to_i

table = [
[1,2,5,13,35,96,267,750,2123,6046],
[1,3,8,22,61,171,483,1373,3923,11256],
[1,3,9,26,75,216,623,1800,5210,15104],
[1,3,9,27,80,236,694,2037,5971,17486],
[1,3,9,27,81,242,720,2134,6305,18581],
[1,3,9,27,81,242,720,2134,6305,18581],
[1,3,9,27,80,236,694,2037,5971,17486],
[1,3,9,26,75,216,623,1800,5210,15104],
[1,3,8,22,61,171,483,1373,3923,11256],
[1,2,5,13,35,96,267,750,2123,6046],
]

counts = 
[9,35,110,327,956,2782,8089,23527,68468,199368]

max = counts.index{ |x| x >= k}
if max > 0 then
	k -= counts[max - 1]
end

result = []

max.downto(0){ |keta|
	if keta == max then
		(1..9).each{ |i|
			if k > table[i][keta] then
				k -= table[i][keta]
			else
				result << i
				break
			end
		}
	else
		st = [result[-1] - 1, 0].max
		ed = [result[-1] + 1, 9].min
		
		(st..ed).each{ |i|
			if k > table[i][keta] then
				k -= table[i][keta]
			else
				result << i
				break
			end
		}
	end
}


puts result.join("")
//  [ruby]
def join(i1,i2)
	return (i1.to_s + i2.to_s).to_i
end

K = gets.chomp.to_i
queue = [1,2,3,4,5,6,7,8,9]
ix = 9

while ix < K
	f = queue.first
	
	if f % 10 > 0
		ix += 1
		queue.push(join(f,f%10-1))
	end
	if ix != K
		ix += 1
		queue.push(join(f,f))
	end
	
	if f % 10 < 9 && ix != K
		ix += 1
		queue.push(join(f,f%10+1))
	end
	queue.shift
end
if K < 10
	puts queue[K-1]
else
	puts queue.last
end
//  [ruby]
def lunlun?(string)
  c = string.chars
  ok = true
  c.each_index do |i|
    next if i == c.length - 1
    if (c[i].to_i - c[i + 1].to_i).abs > 1
      ok = false
    end
  end

  ok
end

k = gets.to_i

now = 0
while k > 0 do
  now += 1
  if lunlun?(now.to_s)
    k -= 1
  end
end

puts now
//  [ruby]
k=gets.to_i
z=*1..9
a=0
k.times{
  a=z.shift
  b=a%10
  z << a*10 + (a-1) if a != 0
  z << a*10 + a
  z << a*10 + (a+1) if a != 9
  }
p a
//  [rust]
#![allow(unused_imports)]






use std::cmp::{max, min};
use std::ops::Range;

const MAXDIGIT: usize = 15;

fn neighbor(i: usize) -> Range<usize> {
    let start = i.saturating_sub(1);
    let end = min(i + 2, 10);
    start..end
}

fn make_dp(mut n: usize) -> (Vec<Vec<usize>>, usize, usize, usize) {
    let mut dp = vec![vec![0; MAXDIGIT]; 10];

    for d in 1..MAXDIGIT {
        for i in 0..10 {
            if d == 1 {
                dp[i][d] = 1;
            } else {
                for l in neighbor(i) {
                    dp[i][d] += dp[l][d - 1];
                }
            }

            if i != 0 {
                if n <= dp[i][d] {
                    return (dp, n, i, d);
                }

                n -= dp[i][d];
            }
        }
    }

    unreachable!("too large query");
}


fn get_nth(dp: &Vec<Vec<usize>>, mut n: usize, i: usize, d: usize) -> String {
    
    if d == 1 {
        assert_eq!(n, 1);
        return i.to_string();
    }

    assert!(n <= dp[i][d]);

    for l in neighbor(i) {
        if dp[l][d - 1] >= n {
            return format!("{}{}", i, get_nth(dp, n, l, d - 1));
        }
        n -= dp[l][d - 1];
    }

    unreachable!("bug");
}

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let n = s.trim().parse::<usize>().unwrap();

    let (dp, n, i, d) = make_dp(n);
    

    println!("{}", get_nth(&dp, n, i, d));
}
//  [rust]
use std::io::*;
use std::str::FromStr;
use std::collections::VecDeque;

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 solve(n: u64) -> u64 {
    if n < 10 {
        return n;
    }

    let mut cnt = 0;
    let mut queue: VecDeque<u64> = VecDeque::new();
    for i in 1..10 {
        queue.push_back(i as u64);
        cnt += 1;
    }

    let mut ans = 0;
    loop {
        let num = queue.pop_front().unwrap();
        let n2 = num % 10;

        if n2 != 0 {
            ans = num * 10 + n2 - 1;
            queue.push_back(ans);
            cnt += 1;
        }
        if n == cnt {
            break
        }

        ans = num * 10 + n2;
        queue.push_back(ans);
        cnt += 1;
        if n == cnt {
            break
        }

        if n2 != 9 {
            ans = num * 10 + n2 + 1;
            queue.push_back(ans);
            cnt += 1;
        }
        if n == cnt {
            break
        }
    }

    return ans;
}

fn main() {
    let n: u64 = read();

    println!("{}", solve(n));
}
//  [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")
    };
}

use std::collections::vec_deque::VecDeque;

fn main() {
    input! {
        k: usize
    }
    let mut q: VecDeque<i64> = VecDeque::new();
    for i in 1..10 {
        q.push_back(i);
    }
    if k <= 9 {
        println!("{}", q[k-1]);
        return;
    }
    let mut cnt = q.len();
    loop {
        let x = *q.front().unwrap();
        q.pop_front();
        for i in &[-1,0,1] {
            let d = x % 10 + i;
            if d < 0 || 9 < d { continue; }
            let nx = x * 10 + d;
            q.push_back(nx);
            cnt += 1;
            if cnt == k {
                println!("{}", q.back().unwrap());
                return;
            }
        }
    }
}
//  [rust]
// -*- coding:utf-8-unix -*-

#[macro_use]
extern crate lazy_static;

// use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
// use std::convert::TryInto;
use libm::*;
use std::cmp::*;
use std::collections::BinaryHeap;
use std::io::*;
use std::str::FromStr;
use superslice::*;

pub 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")
}

//abc161-D
// #[fastout]
fn main() {
    input![n: usize];

    let mut is_rnrn = vec![false; 1000000];

    let mut count = 0;
    is_rnrn[0] = true;
    for i in 1..10 {
        count += 1;
        eprintln!("{}'s rnrn: {}", count, i);
        if n == count {
            println!("{}", i);
            return;
        }
        is_rnrn[i] = true;
    }

    for i in 10..(1000000) {
        let d = log10(i as f64) as u32;
        let a = 10i64.pow(d);
        let max_d = i as i64 / a as i64;
        let no2_d = i as i64 / (10i64.pow(d - 1)) % 10 as i64;
        let rest_digits = i - max_d * a;
        // eprintln!("{}, {}, {}, {}", i, max_d, no2_d, rest_digits);
        if !is_rnrn[rest_digits as usize] {
            is_rnrn[i as usize] = false;
        } else if fabs((max_d - no2_d) as f64) as usize <= 1 {
            count += 1;
            eprintln!("{}'s rnrn: {}", count, i);
            if n == count {
                println!("{}", i);
                break;
            }
            is_rnrn[i as usize] = true;
        } else {
            is_rnrn[i as usize] = false;
        }
    }
}

fn go(mid: usize, d: usize, use_num: usize, num753_cand: &mut Vec<usize>, n: usize) {}

// use lazy_static::lazy_static;
// use std::sync::Mutex;

// lazy_static! {
//     static ref VALUES: Mutex<Vec<i32>> = Mutex::default();
// }

// let mut values = VALUES.lock().unwrap();
// values.extend_from_slice(&[1, 2, 3, 4]);
// assert_eq!(&*values, &[1, 2, 3, 4]);
//  [rust]
// -*- coding:utf-8-unix -*-

#[macro_use]
extern crate lazy_static;

// use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
// use std::convert::TryInto;
use libm::*;
use std::cmp::*;
use std::collections::BinaryHeap;
use std::io::*;
use std::str::FromStr;
use superslice::*;

pub 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")
}

//abc161-D
// #[fastout]
fn main() {
    input![n: usize];

    let mut is_rnrn = vec![false; 1000000];

    let mut count = 0;
    is_rnrn[0] = true;
    for i in 1..10 {
        count += 1;
        eprintln!("{}'s rnrn: {}", count, i);
        if n == count {
            println!("{}", i);
            break;
        }
        is_rnrn[i] = true;
    }

    for i in 10..(1000000) {
        let d = log10(i as f64) as u32;
        let a = 10i64.pow(d);
        let max_d = i as i64 / a as i64;
        let no2_d = i as i64 / (10i64.pow(d - 1)) % 10 as i64;
        let rest_digits = i - max_d * a;
        // eprintln!("{}, {}, {}, {}", i, max_d, no2_d, rest_digits);
        if !is_rnrn[rest_digits as usize] {
            is_rnrn[i as usize] = false;
        } else if fabs((max_d - no2_d) as f64) as usize <= 1 {
            count += 1;
            eprintln!("{}'s rnrn: {}", count, i);
            if n == count {
                println!("{}", i);
                break;
            }
            is_rnrn[i as usize] = true;
        } else {
            is_rnrn[i as usize] = false;
        }
    }
}

fn go(mid: usize, d: usize, use_num: usize, num753_cand: &mut Vec<usize>, n: usize) {}

// use lazy_static::lazy_static;
// use std::sync::Mutex;

// lazy_static! {
//     static ref VALUES: Mutex<Vec<i32>> = Mutex::default();
// }

// let mut values = VALUES.lock().unwrap();
// values.extend_from_slice(&[1, 2, 3, 4]);
// assert_eq!(&*values, &[1, 2, 3, 4]);
//  [rust]
use proconio::input;
use std::collections::VecDeque;
 
#[fastout]
fn main() {
  input! { K: u32 }
  let mut queue:VecDeque<u32> = vec![1,2,3,4,5,6,7,8,9].into_iter().collect();
  let mut answer = 0;

  for _ in 0..K {
    let val = queue.pop_front().unwrap();
    answer = val;
    
    let next = val * 10 + val % 10;
    if next % 10 != 0 {
      queue.push_back(next - 1);
    }
    queue.push_back(next);
    if next % 10 != 9 {
      queue.push_back(next + 1);
    }
  }
  println!("{}", answer);
}
//  [swift]
// Lunlun Number

func main() {
    let k = Int(readLine()!)!
    var rest = k - 9

    var lunlun: [[Int]] = []

    var digits = 0
    lunlun.append([1,2,3,4,5,6,7,8,9])
    var count = 9

    while count < k {
        var currentLunlun: [Int] = []
        for i in lunlun[digits] {
            let lastNumber = i % 10
            switch lastNumber {
            case 0:
                currentLunlun.append(i * 10 + lastNumber)
                currentLunlun.append(i * 10 + lastNumber + 1)
            case 9:
                currentLunlun.append(i * 10 + lastNumber - 1)
                currentLunlun.append(i * 10 + lastNumber)
            default:
                currentLunlun.append(i * 10 + lastNumber - 1)
                currentLunlun.append(i * 10 + lastNumber)
                currentLunlun.append(i * 10 + lastNumber + 1)
            }
        }

        if rest <= currentLunlun.count {
            print(currentLunlun[rest-1])
            return
        }
        rest -= currentLunlun.count
        lunlun.append(currentLunlun)
        count += currentLunlun.count
        digits += 1
    }
    print(lunlun[0][k-1])
}

main()
//  [swift]
import Foundation
class Node {
  var val: Int64
  var next: Node?
  init(val: Int64) {
    self.val = val
  }
}

class Queue {
  var head: Node?
  var tail: Node?
  init(){}
  func enqueue(val: Int64) {
    let node = Node(val: val)
    if head == nil {
      head = node
      tail = head
    } else {
      tail!.next = node
      tail = node
    }
  }
  func dequeue() -> Int64 {
    let val = self.head!.val
    self.head = self.head!.next
    if self.head == nil {
      self.tail = nil
    }
    return val
  }
}
func solve(K: Int64) -> Int64 {
  if K < 10 {
    return K
  }
  let queue = Queue()
  for i in 1...9 {
    queue.enqueue(Int64(i))
  }
  var count: Int64 = 9
  var result: Int64 = -1
  while count < K {
    let top = queue.dequeue()
    let last = top % 10
    for start in last-1...last+1 {
      if start < 0 || start > 9 {
        continue
      }
      let next = top * 10 + start
      queue.enqueue(next)
      count += 1
      if count == K {
        result = next
        break
      }
    }
  }
  return result
}

let input = readLine()!
let info = input.componentsSeparatedByString(" ")
let K = Int64(info[0])!

print(solve(K))
//  [swift]
import Foundation

let K = (readLine()!)
var kArray = K
var stored: [Int] = [1,2,3,4,5,6,7,8,9]
var i = 10

while stored.count != (Int(K) ?? 0){
   let iArray = String(i).characters.flatMap { Int("\($0)") }
   for j in  0..<iArray.count-1{
     
     var bool1 = abs(((Int (iArray[j]) ?? 0) ) - (Int(iArray[j+1]) ?? 0)) == 1
     var bool2 = abs(((Int(iArray[j+1]) ?? 0  - (Int (iArray[j]) ?? 0) ))) == 1
     var bool3 = abs(((Int (iArray[j]) ?? 0) ) - (Int(iArray[j+1]) ?? 0)) == 0
     
     if !(bool1 || bool2 || bool3){
       break
     }  
     stored.append(i)
   } 
   i += 1
}
print(stored.last!)
//  [swift]
import Foundation

let K = (readLine()!)
var kArray = K
var stored: [Int] = [1,2,3,4,5,6,7,8,9]
var i = 10

while stored.count != (Int(K) ?? 0){
   let iArray = String(i).characters.flatMap { Int("\($0)") }
   for j in  0..<iArray.count-1{
     
     var bool1 = abs(((Int (iArray[j]) ?? 0) ) - (Int(iArray[j+1]) ?? 0)) == 1
     var bool2 = abs(((Int(iArray[j+1]) ?? 0  - (Int (iArray[j]) ?? 0) ))) == 1
     var bool3 = abs(((Int (iArray[j]) ?? 0) ) - (Int(iArray[j+1]) ?? 0)) == 0
     
     if bool1 || bool2 || bool3{
       stored.append(i)
     }  
     
   } 
  
   
   i += 1
}
print(stored)
//  [typescript]
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const [k]: number[] = tmp.shift().split(" ").map(int => parseInt(int));
    if (k < 10) {
      return `${k}`;
    }
    const cache = {
      1: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
      2: []
    };
    let count = 9;
    let keta = 2;
    let startNum = 1;
    while (true) {
      let count2 = count;
      if (startNum == 9) {
        cache[keta][0] = cache[keta - 1][0] + cache[keta - 1][1];
        cache[keta][9] = cache[keta - 1][8] + cache[keta - 1][9];
      } else {
        cache[keta][startNum] = cache[keta - 1][startNum - 1] + cache[keta - 1][startNum] + cache[keta - 1][startNum + 1];
      }
      count2 += cache[keta][startNum];
      if (count2 >= k) {
        break;
      }
      if (startNum == 9) {
        keta++;
        cache[keta] = [];
        startNum = 1;
      } else {
        startNum++;
      }
      count = count2;
    }
    let startNum2 = startNum;
    keta--;
    let result = `${startNum2}`;
    while (keta > 0) {
      let count2 = count;
      if (startNum2 == 0) {
        count2 += cache[keta][startNum2];
        if (count2 >= k) {
          result += `${startNum2}`;
          keta--;
          continue;
        }
        count = count2;
        startNum2  = startNum2 + 1;
        count2 += cache[keta][startNum2];
        result += `${startNum2}`;
        keta--;
      } else if (startNum2 == 9) {
        count2 += cache[keta][startNum2 - 1];
        if (count2 >= k) {
          startNum2  = startNum2 - 1;
          result += `${startNum2}`;
          keta--;
          continue;
        }
        count = count2;
        count2 += cache[keta][startNum2];
        result += `${startNum2}`;
        keta--;
      } else {
        count2 += cache[keta][startNum2 - 1];
        if (count2 >= k) {
          startNum2 = startNum2 - 1;
          result += `${startNum2}`;
          keta--;
          continue;
        }
        count = count2;
        count2 += cache[keta][startNum2];
        if (count2 >= k) {
          result += `${startNum2}`;
          keta--;
          continue;
        }
        count = count2;
        startNum2  = startNum2 + 1;
        count2 += cache[keta][startNum2];
        result += `${startNum2}`;
        keta--;
      }
    }
    return result;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));
//  [typescript]
import * as fs from 'fs';

const input: string = fs.readFileSync('/dev/stdin', 'utf8');
const args: string[][] = input.split('\n').map(l => l.split(' '));

const nextNumbers: number[][] = [];
for (let i = 0; i < 10; i++) {
  const tmp: number[] =
    [i + 9, i, i + 1]
      .map(x => x % 10)
      .filter(x => Math.abs(i - x) <= 1)
      .sort((x, y) => x - y);
  nextNumbers.push(tmp);
}

function getLunlun(n: number): number {
  let tmp = n - 1;
  let a: number[][] = [];
  for (let i = 1; i <= 9; i++) a.push([i]);
  if (tmp < a.length) return getNum(a[tmp])

  while (tmp >= a.length) {
    tmp -= a.length;
    let tmpArray: number[][] = [];
    a.forEach(array => {
      const nexts: number[] = nextNumbers[array[array.length - 1]];
      nexts.forEach(x => {
        const array2: number[] = [...array, x];
        tmpArray.push(array2);
      })
    });
    a = tmpArray;
  }
  return getNum(a[tmp])
}

function getNum(ns: number[]): number {
  return ns.reduce((x, y) => 10 * x + y)
}

const k = parseInt(args[0][0]);
console.log(getLunlun(k));
//  [typescript]
import * as fs from 'fs';

const input: string = fs.readFileSync('/dev/stdin', 'utf8');
const args: string[][] = input.split('\n').map(l => l.split(' '));

const k = parseInt(args[0][0]);
console.log(getLunlun(k));

function getLunlun(n: number): number {
  function getNum(ns: number[]): number {
    return ns.reduce((x, y) => 10 * x + y)
  }

  let tmp = n - 1;
  let a: number[][] = [];
  for (let i = 1; i <= 9; i++) a.push([i]);
  if (tmp < a.length) return getNum(a[tmp])

  const nextNumbers: number[][] =
    [...Array(10)]
      .map((_, i) => i)
      .map(i => [i + 9, i, i + 1])
      .map((array, i) =>
        array.map(x => x % 10)
          .filter(x => Math.abs(x - i) <= 1)
          .sort((x, y) => x - y));

  while (tmp >= a.length) {
    tmp -= a.length;

    a =
      a.map(
        array =>
          nextNumbers[array.length - 1]
            .map(x => [...array, x]))
        .flat();
  }
  return getNum(a[tmp])
}
//  [typescript]
import * as fs from 'fs';
import {arrayify} from "tslint/lib/utils";

const input: string = fs.readFileSync('/dev/stdin', 'utf8');
const args: string[][] = input.split('\n').map(l => l.split(' '));

const k = parseInt(args[0][0]);
console.log(getLunlun(k));

function getLunlun(n: number): number {
  function getNum(ns: number[]): number {
    return ns.reduce((x, y) => 10 * x + y)
  }

  let tmp = n - 1;
  let a: number[][] = [];
  for (let i = 1; i <= 9; i++) a.push([i]);
  if (tmp < a.length) return getNum(a[tmp])

  const nextNumbers: number[][] =
    [...Array(10)]
      .map((_, i) => i)
      .map(i => [i + 9, i, i + 1])
      .map((array, i) =>
        array.map(x => x % 10)
          .filter(x => Math.abs(x - i) <= 1)
          .sort((x, y) => x - y));

  while (tmp >= a.length) {
    tmp -= a.length;
    let tmpArray: number[][] = [];
    a.forEach(array => {
      const nexts: number[] = nextNumbers[array[array.length - 1]];
      nexts.forEach(x => {
        tmpArray.push([...array, x]);
      })
    });
    a = tmpArray;
  }
  return getNum(a[tmp])
}
//  [typescript]
process.stdin.resume();
process.stdin.setEncoding('utf8');

// 標準入力取込
let gInput = '';
process.stdin.on('data', (chunk) => (gInput += chunk));
process.stdin.on('end', () => main(gInput.split(/\r?\n/)));

// 解答
function main(inputs: string[]): void {
  const k = Number(inputs[0].split(' ')[0]);
  // 途中計算用配列
  let temp = [1, 2, 3, 4, 5, 6, 7, 8, 9];
  // 解答用配列
  let ans: number[] = [];

  while (ans.length <= k) {
    const num = temp[0];

    ans.push(num);

    const num1 = num % 10;
    const num2 = num * 10 + num1;

    // 一の位が0でない場合、num - 1の値もセット
    if (num1 !== 0) {
      temp.push(num2 - 1);
    }

    temp.push(num2);

    // 一の位が9でない場合、num + 1の値もセット
    if (num1 !== 9) {
      temp.push(num2 + 1);
    }

    // 途中計算用配列から先頭要素を削除
    temp.shift();
  }

  console.log(ans[k - 1]);
}
//  [python]
S = input()

#print('S=', S)

n = len(S)

#print('len(S)=', n)

list_S = list(S)

#print('list(S)=', list_S)

count = 0

for i in range((n-1)//2):
  if list_S[i] != list_S[n-1-i]:
    count += 1
if count > 0:
  print('No')
  exit()

list_left = list_S[0 : (n-1)//2]
#print('list_left=', list_left)
list_right = list_S[(n+3)//2-1 : n]
#print('list_right=', list_right)

n_edge = len(list_left)
#print('n_edge=', n_edge)

if n_edge % 2 == 1:
  for i in range((n_edge-1)//2):
    if list_left[i] != list_left[n_edge-1-i]:
      print('No')
      exit()

if n_edge % 2 == 0:
  for i in range(n_edge//2):
    if list_left[i] != list_left[n_edge-1-i]:
      print('No')
      exit()


print('Yes')
//  [python]
S=input()
N=len(S)
f=0
for i in range((N-1)//4):
    if S[i]!=S[(N-3)//2-i]:
        f=-1
        #print(i)
        break
for i in range((N+1)//2,(3*N+1)//4):
    if S[i]!=S[N-1-i]:
        f=-1
        #print(i)
        break
for i in range((N-1)//2):
    if S[i]!=S[N-1-i]:
        f=-1
        #print(i)
        break
if f==-1:
    print("No")
else:
    print("Yes")
//  [python]
s = input()
n = len(s)

a = s[0:int((n-1)/2)]
b = s[int((n+1)/2):n]

if s[::-1] == s and a[::-1] == a and b[::-1] == b:
  print('Yes')
else:
  print('No')
//  [python]
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
from operator import itemgetter
#from heapq import heappush, heappop
#import numpy as np
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix
#from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

def judge(S):
    for i in range(len(S) // 2):
        if S[i] != S[-(i+1)]:
            return False
    return True

S = ns()
N = len(S)
p = S[:(N-1)//2]
l = S[(N+3)//2 - 1:]
if judge(p) and judge(l):
    print('Yes')
else:
    print('No')
//  [python]
s=input()
n=len(s)
m=(n-1)//2
t=s[:m]

for i in range(m):
  #print(s[i],s[-i-1])
  if s[i]!=s[-i-1]:
    print('No')
    exit()

l=(m-1)//2
for i in range(l):
  #print(t[i],t[-i-1])
  if t[i]!=t[-i-1]:
    print('No')
    exit()
print('Yes')
//  [python]
s=input()
n=len(s)
m=(n-1)//2
t=s[:m]
if m%2==0:
  print('No')
  exit()

for i in range(m):
  #print(s[i],s[-i-1])
  if s[i]!=s[-i-1]:
    print('No')
    exit()

l=(m-1)//2
for i in range(l):
  #print(t[i],t[-i-1])
  if t[i]!=t[-i-1]:
    print('No')
    exit()
print('Yes')
//  [java]
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException{
    	// Solution sol = new Solution();
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	String s = br.readLine();
    	int N = s.length();
    	if(N%2==0)
    		System.out.println("No");
    	else if(checkPal(s)&&checkPal(s.substring(0,(N-1)/2))&&checkPal(s.substring((N+3)/2-1,N)))
    		System.out.println("Yes");
    	else
    		System.out.println("No");

    }

    public static boolean checkPal(String s){

    	for(int i=0; i<=s.length()/2; i++){
    		if(s.charAt(i)!=s.charAt(s.length()-1-i))
    			return false;
    	}
    	return true;
    }
}
//  [java]
import java.io.*;
import java.lang.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String s=br.readLine();
        int N=s.length();
        int mid=N/2;
        boolean flag=true;
        for(int i=0;i<=mid;i++){
            if(s.charAt(i)!=s.charAt(N-1-i)){
                flag=false;
                break;
            }
        }
        int mid1=mid/2;
        for(int i=0;flag && i<=mid1;i++){
            if(s.charAt(i)!=s.charAt(mid-1-i)) flag=false;
        }
        int mid2=mid/2+mid+1;
        for(int i=mid+1;flag && i<=mid2;i++){
            if(s.charAt(i)!=s.charAt(2*mid-i)) flag=false;
        }
        if(flag) System.out.println("Yes");
        else System.out.println("No");
    }
}
//  [java]
    import java.io.*;
    public class Main{ public static void main(String...args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String subString = br.readLine(); int len = subString.length();
        String r1 = new StringBuilder(subString).reverse().toString(); String s1 = subString.substring(0,(len-1)/2);
        String r2 = new StringBuffer(s1).reverse().toString(); String s2 = subString.substring(((len+3)/2)-1, len);
        String r3 = new StringBuffer(s2).reverse().toString();
        if(subString.equals(r1) && s1.equals(r2) && s2.equals(r3)) System.out.println("Yes");
      	else System.out.println("No");}
    }
//  [java]
import java.util.*;

public class Main {
  	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      String s = sc.next();
      int n = s.length();

      String a = s.substring(0, n/2);
      String b = s.substring(n/2+1, n);

      boolean ans = isKaibun(a) && isKaibun(b) && isKaibun(s);
      System.out.println(ans ? "Yes" : "No");

    }
}

private static boolean isKaibun(String s) {
  	boolean ans = true;
  	for (int i = 0; i < s.length() / 2; i++) {
    	if (s.charAt(i) != s.charAt(s.length() - 1 - i)) ans = false;
  	}
 	return ans;
	}
}
//  [java]
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            String S = sc.next();
            int N = S.length();
            System.out.println(isPalindrome(S) && isPalindrome(S.substring(0, (N - 1) / 2)) && isPalindrome(S.substring((N + 3) / 2 + 1, N)) ? "Yes" : "No");
        }
    }

    private static boolean isPalindrome(String s) {
        for (int l = 0, r = s.length() - 1; l < r; l++, r--) {
            if (s.charAt(l) != s.charAt(r)) {
                return false;
            }
        }
        return true;
    }
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
int n,m;
const int N = 1e5 + 5;
char s[N];
inline void rror() {
	puts("No");
	exit(0);
}
int main() {
	scanf("%s",s+1);	
	n = strlen(s+1);
	for(int i = 1;i <= n/2;++i)
		if(s[i] != s[1+n-i]) rror();
	m = n/2;
	for(int i = 1;i <= m/2;++i)
		if(s[i] != s[m+1-i] || s[m+1+i] != s[n+1-i]) rror();
	puts("Yes");
	return 0;
}
//  [cpp]
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	string ss;
	cin>>ss;
	ll x,y,z,n,ans=1;
	n=ss.size();
	char s[n+1];
	for(int a=0;a<n;a++)
	s[a+1]=ss[a];
	for(int a=1;a<=n;a++)
	{
		if(s[a]!=s[n+1-a])
		{
			ans=0;
			break;
		}
	}
	ll m=(n-1)/2;
	for(int a=1;a<=m;a++)
	{
		if(s[a]!=s[m+1-a])
		{
			ans=0;
			break;
		}
	}
	ll mm=(n+3)/2;
	for(int a=mm;a<=n;a++)
	{
		if(s[a]!=s[n+1-a])
		{
			ans=0;
			break;
		}
	}
	if(ans==0)
	cout<<"No";
	else 
	cout<<"Yes";
	return 0;
}
//  [cpp]
#include <bits/stdc++.h>
/**
*   author: j o s e m a g o
*   date:
**/
using namespace std;
#pragma GCC optimize ("Ofast")
#define f first
#define s second
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mset(a,v) memset(a,v,sizeof(a))
#define pb push_back
#define sz(x) ((int)(x).size())
#define rsz resize
#define ln "\n"

typedef double db;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const ld PI = 2*acos(0.0);
const int MOD = 1000000007;







int main(){

  //freopen("input.in","r",stdin);
  //freopen("input.out","w",stdout);

    ios_base::sync_with_stdio(0); cin.tie(0);


    string s;
    cin >> s;

    bool a = false,b = false,c = false;
    string aa,bb,cc;
    aa = s;
    reverse(aa.begin(),aa.end());
    if(aa == s) a = true;
    int n = s.size();

    for(int i = 0;i < (n-1)/2;i++){
        bb+=s[i];
    }
    string c_b = bb;
    reverse(c_b.begin(),c_b.end());
    if(c_b == bb) b = true;

    for(int i = ((n+3)/2)-1;i < n;i++){
        cc+=s[i];
    }
    string c_c = cc;
    reverse(c_c.begin(),c_c.end());
    if(cc == c_c) c = true;

    if(a && b && c) cout<<"Yes\n";
    else cout<<"No\n";










    return 0;
}
//  [cpp]
#include<iostream>
#include<string>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int n=s.size();
  int count=0;
  for(int i=0;i<n;i++){
    if(s[i]==s[n-1-i]){
      count++;
    }
  }
  if(count==n){
    int x=(n-1)/2;
    for(int i=0;i<x;i++){
      if(s[i]==s[x-1-i]){
        count++;
      }
    }
    int y=(n+3)/2;
    for(int i=0;i<n-y+1;i++){
      if(s[y-1+i]==s[n-1-i]){
        count++;
        y++;
      }
    }
    if(count==n+n+1+x-y){
      cout<<"Yes";
    }
    else{
      cout<<"No";
    }
  }
  else{
    cout<<"No";
  }
  
}
//  [cpp]
#include<iostream>
#include<string>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int n=s.size();
  int count=0;
  for(int i=0;i<n;i++){
    if(s[i]==s[n-1-i]){
      count++;
    }
  }
  if(count==n){
    int x=(n-1)/2;
    for(int i=0;i<x;i++){
      if(s[i]==s[x-1-i]){
        count++;
      }
    }
    int y=(n+3)/2;
    for(int i=0;i<n-y;i++){
      if(s[y-1+i]==s[n-1-i]){
        count++;
        y++;
      }
    }
    if(count==n+n+x-y){
      cout<<"Yes";
    }
    else{
      cout<<"No";
    }
  }
  else{
    cout<<"No";
  }
  
}
//  [cpp]
#include<iostream>
#include<string>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int n=s.size();
  int count=0;
  for(int i=0;i<n;i++){
    if(s[i]==s[n-1-i]){
      count++;
    }
  }
  if(count==n){
    int x=(n-1)/2;
    for(int i=0;i<x;i++){
      if(s[i]==s[x-1-i]){
        count++;
      }
    }
    int y=(n+3)/2;
    for(int i=0;i<n-y;i++){
      if(s[y-1]==s[n-1-i]){
        count++;
        y++;
      }
    }
    if(count==n+n+x-y){
      cout<<"Yes";
    }
    else{
      cout<<"No";
    }
  }
  else{
    cout<<"No";
  }
  
}
//  [c]
#include<stdio.h>
#include<string.h>
int main(void){
char s[100];
  scanf("%s",&s);
  char mae[50],ato[50];
  for(int i=0;i<50;i++){
	mae[i]=0;
    ato[i]=0;
  }
  for(int i=0;i<strlen(s)/2;i++){
	mae[i]=s[i];
    ato[i]=s[i+strlen(s)/2+1];
    //printf("%c %c\n",mae[i],ato[i]);
  }
  //printf("%d\n%d\n%d\n",strlen(s),strlen(mae),strlen(ato));
  for(int i=0;i<strlen(s)/2;i++){
    if(s[i]!=s[strlen(s)-1-i]){
      printf("No");
      return 0;
    }
    }
     for(int i=0;i<strlen(mae)/2;i++){
    if(mae[i]!=mae[strlen(mae)-1-i]){
      printf("No");
      return 0;
    }} 
       for(int i=0;i<strlen(ato)/2;i++){
    if(ato[i]!=ato[strlen(ato)-1-i]){
      printf("No");
      return 0;
    }}
         printf("Yes");
    //  printf("%d\n%d\n",strlen(mae),strlen(ato));
      return 0;
      }
//  [c]
#include<stdio.h>
#include<string.h>

int main(void){

    char S[100];
    int i,j,ans = 0,lenth,check_kaibun;

    scanf("%s",S);
    lenth = strlen(S);

    check_kaibun = 1;
    for(i = 0;i < lenth;i++){
        //printf("左から%d番目：%c 右から%d番目；%c\n",i,S[i],i,S[lenth - 1 - i]);
        if(S[i] != S[lenth - 1 - i]) check_kaibun = 0;
    }
    if(check_kaibun == 1){
        ans++;
        //printf("Condition1 Successed!\n");
    }else{
        //printf("Condition1 Failed!");
    }
    //printf("\n");

    check_kaibun = 1;
    int Condition2 = (lenth - 1)/2;
    for(i = 0;i < Condition2;i++){
        //printf("左から%d番目：%c 右から%d番目；%c\n",i,S[i],i,S[Condition2 - 1 - i]);
        if(S[i] != S[Condition2 - 1 - i])  check_kaibun = 0;
    }
    if(check_kaibun == 1){
        ans++;
        //printf("Condition2 Successed!\n");
    }else{
        //printf("Condition2 Failed!\n");
    }
    //printf("\n");

    check_kaibun = 1;
    int Condition3 = (lenth + 3)/2;
    for(i = Condition3 - 1;i < lenth;i++){
        //printf("左から%d番目：%c 右から%d番目：%c\n",i,S[i],i,S[lenth - 1 - i]);
        if(S[i] != S[lenth - 1 - i]) check_kaibun = 0;
    }
    if(check_kaibun == 1){
        ans++;
        //printf("Condition3 Successed!\n");
    }else{
        //printf("Condition3 Failed!\n");
    }
    //printf("\n");

    if(ans == 3) printf("Yes\n");
    else printf("No\n");
    return 0;
}