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

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
    boolean answer = false;
    if(N%2==0){
      for(int i = 0;i<N%2;i++){
        if(S.charAt(i)==S.charAt(i+N)){
          if(i==N%2-1){
            answer = true;
          }
        }else{
          break;
        }
      }
    }
    if(answer){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}
//  [java]
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
    boolean answer = false;
    if(N%2==0){
      for(int i = 0;i<N%2;i++){
        if(S.charAt(i)==S.charAt(i+N)){
          if(i==N-1){
            answer = true;
          }
        }else{
          break;
        }
      }
    }
    if(answer){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}
//  [cpp]
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 200000
typedef long long i64;

int n;
char s[MAXN];

int input() {
	if (scanf("%d", &n) < 0) return 0;
	scanf("%s", s);
	return 1;
}

void init() {
}

int solve() {
	if (n%2) return 0;
	for (int i=0; i<n/2; i++)
		if (s[i] != s[i+n/2]) return 0;
	return 1;
}

void output(int ans) {
	printf("%s\n", ans? "Yes":"No");
}

void cleanup() {
}

int main() {
	//precalc();
	//int ca; scanf("%d", &ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}
//  [cpp]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define max 256

int main()
{
	int n, tmp, i;
	char s[max], t_1[max], t_2[max];
	char *p;

	scanf("%d", &n);
	scanf("%d", &tmp);

	fgets(s, max, stdin);
	p = strrchr(s, '\n');
	*p = '\0';

	if (n % 2 == 1)
	{
		printf("No\n");
	}

	else
	{
		for (i = 0; i < (n / 2); i++)
		{
			t_1[i] = s[i];
			t_2[i] = s[i + (n / 2)];
		}

		t_1[n / 2] = '\0';
		t_2[n / 2] = '\0';


		if (strcmp(t_1, t_2) == 0)
		{
			printf("Yes\n");
		}
		else
		{
			printf("No\n");
		}


	}
	return 0;


}
//  [cpp]
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include<math.h>
int main(){
    int n,cnt=0,cnt1=0;
    int k,l,e=0;
    scanf("%d",&n);
    char s[n],a[n/2],b[n/2];
    scanf("%s",&s);
      if(n%2!=0)
        printf("No");
    for(int k=0; k<n; k++){
    if(s[k]>='A' && s[k]<='Z'){
       cnt1++;}
    }
    if(cnt1==0){
    if(n%2==0){
    for(int i=0;i<n/2;i++){
        a[i]=s[i];}
    for(int j=n/2;j<n;j++){
        b[e++]=s[j];}

    for(k=0,l=0;k<n/2,l<n/2;k++,l++){
    if(a[k]==b[l])
        cnt++;
    else
        cnt=0;}
    if(cnt==n/2)
        printf("Yes");
    else
        printf("No");}}
    if(n%2==0 && cnt1>0)
        printf("No");
    return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < n / 2; i++) {
        if (s[i] == s[i + n / 2]) {
            ans++;
        }
    }
    if (n == 1) {
        cout << "No" << endl;
    } else if (n > 1 && ans == n / 2) {
        cout << "Yes" << endl;
    } else if (n > 1 && ans != n / 2) {
        cout << "No" << endl;
    }
    return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < n / 2; i++) {
        if (s[i] == s[i + n / 2]) {
            ans++;
        }
    }
    if (ans == n / 2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}
//  [cpp]
#include<bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<ll>>;

// dijkstra　
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<ll> d;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
    rep(i,V){
      d[i] = INF;
    }
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    rep(i,V){
      d[i] = INF;
    }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};
// dijkstra end


class UnionFind
{
public:
  ll par[100005];
  ll depth[100005];
  ll nGroup[100005];
 
  UnionFind(ll n) {
    init(n);
  }
 
  void init(ll n) {
    for(ll i=0; i<n; i++) {
      par[i] = i;
      depth[i] = 0;
      nGroup[i] = 1;
    }
  }
 
  ll root(ll x) {
    if(par[x] == x) {
      return x;
    } else {
      return par[x] = root(par[x]);
    }
  }
 
  bool same(ll x, ll y) {
    return root(x) == root(y);
  }
 
  void unite(ll x, ll y) {
    x = root(x);
    y = root(y);
    if(x == y) return;
 
    if(depth[x] < depth[y]) {
      par[x] = y;
      nGroup[y] += nGroup[x];
      nGroup[x] = 0;
    } else {
      par[y] = x;
      nGroup[x] += nGroup[y];
      nGroup[y] = 0;
      if(depth[x] == depth[y])
        depth[x]++;
    }
  }
};
// unionfind end

// nCr
const ll MAX = 500010;
ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// nCr end

// tree DP
vector<ll> depth;
vector<ll> g(10010,0);
ll c[10010];
void dfs(const Graph &G, ll v, ll p, ll &d) {
         g[v] = c[d-1];
    for (auto nv : G[v]) {
        if (nv == p) continue;
        d--;
        dfs(G, nv, v, d);
    }
}
// tree DP end
int main() {
  ll n; cin>>n;
  string s; cin>>s;
  if(n%2!=0){
    cout << "No" << endl;
    return 0;}
  string t = s.substr(1,n/2);
  string u = s.substr(n/2+1,n);
  if(t==u)cout << "Yes" << endl;
  else cout << "No" << endl;
}
//  [c]
#include<stdio.h>

int main ()
{
    int N,n,f=0,i;
    char s[1000] ;

    scanf("%d\n",&N) ;
    scanf("%s",&s) ;

    if(N%2!=0){
        printf("No\n") ;
    }
    else{
        n=N/2 ;

        for( i=0;i<n;i++){
            if(s[i]==s[i+n]){
               f=0;
            }
            else{
                f=1 ;
                break ;
            }
        }
        if(f==0){
            printf("Yes\n") ;
        }
        else{
            printf("No\n") ;
        }
    }

    return 0 ;
}
//  [c]
#include <stdio.h>
int main()
{
	int n,p=0;
  	char s[105];
  	scanf("%d %s",&n,s);
  	if(n%2==0)
    {
     	for(int i=0;i<(n/2);i++)
        {
          if(s[i] != s[(n/2)+i])
          {
           	p=1; 
            break;
          }
        }
      	if(p==0){printf("Yes\n");}
        else if(p==1){printf("No\n");}
    }
    else
    {
     	printf("No\n"); 
    }
     return 0;
}
//  [c]
char buf[1000];
i,len;

main(){
	gets(buf);
	gets(buf);
	if((len=strlen(buf))%2) return puts("No") && 0;
	
	for(i=0;i<len/2;i++) if(buf[i]!=buf[i+len/2]) return puts("No") && 0;
	puts("Yes");
}
//  [c]
#include<stdio.h>
#include<string.h>
int main()
{
    int n,t,c=0,r,i;
    char a[100];
    scanf("%d",&n);
    scanf("%s",a);
    if(n%2!=0)
    {
        printf("No");
    }
    else
    {
        r=n/2;
        for(i=0,t=r; i<r,t<n; i++,t++)
        {

            if(a[i]==a[t])
            {

                c++;
            }
        }
        if(c==r)
        {
            printf("yes");
        }
        else
            printf("No");
    }
}
//  [c]
#include<stdio.h>
#include<string.h>
int main()
{
    int n,t,c=0,r,i;
    char a[100];
    scanf("%d",&n);
    scanf("%s",a);
    if(n%2!=0)
    {
        printf("No");
    }
    else
    {
        r=n/2;
        for(i=0,t=r; i<r,t<n; i++,t++)
        {

            if(a[i]==a[t])
            {

                c++;
            }
        }
        if(c==r)
        {
            printf("yes");
        }
        else
            printf("no");
    }
}
//  [c]
#include<stdio.h>
#include<math.h>
#include<string.h>

int main()
{
    char s[101],t[101];
    int l,i,j,k,g;
    scanf("%d",&l);
    scanf("%s",s);

    if(l%2==0)
    {
        for(i=0;i<l/2;i++)
        {
            t[i]=s[i];

        }
        for(j=0,i=l/2;i<l,j<l/2;i++,j++)
        {
            t[i]=t[j];
        }
        t[l]='\0';

        g=strcmp(s,t);
        if(g==0)
            printf("YES\n");
        else
            printf("NO\n ");
    }
    else
        printf("NO\n");

}
//  [javascript]
"use strict";

const main = arg => {
  const n = parseInt(arg.split("\n")[0], 10)
  if (n % 2 !== 0) {
  	console.log("No")
    return
  }
  const s = arg.split("\n")[1]
  if (s.slice(0, n/2) == s.slice(n/2)) {
  	console.log("Yes")
  } else {
  	console.log("No")
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
"use strict"
function Main(input) {
  input = input.trim().split('\n');
  const N = Number(input[0]);
  const S = input[1];

  if(N%2 !== 0){
    console.log('No');
    return;
  }

  const pre = S.slice(0, N/2);
  const suf = S.slice(N/2, N);
  if(pre !== suf){
    console.log('No');
    return;
  }

  console.log('Yes');
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {
    var args = input.trim().split('\n');
    var half =  args[1].substr(0,args[1].length / 2);
    var res;
    if(half + half === args[1]) {
      res = 'Yes';
    } else {
      res = 'No';
    }
    console.log(res);
 }
 
/* var input = `9
abcdabcde`;
Main(input);
 */  
 Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
'use strict';
function main(input) {
  const arr = input.trim().split('\n');
  const a = arr[1];
  const length = a.length;
  let isDouble = true;

  if (a.length % 2 !== 0) {
    return isDouble = false;
  }

  for (let i = 0; i < (length / 2); i ++) {
    if (a[i] !== a[length / 2]) {
      return isDouble = false;
    }
  }
  
  console.log(isDouble ? 'Yes' : 'No');
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function main(input) {
    const args = input.split('\n');
    const N = parseInt(args[0], 10),
          S = args[1];
    let str = S.substr(0, N / 2);
    if (str + str == S) return "Yes";
    return "No";
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function main(input) {
    input = input.split('/n')
  var i = input[0]
  var j = input[1]
    if(i % 2 === 1) {
      console.log('No')
    } else {
      var result = true
    	var l = 0
      var r = i / 2
        while(r < i) {
        	if(j[l] !== j[r]) {
            	console.log("No")
              	result = false
              	break
            }
          l++
          r++
        }
        if(result) {
          console.log("Yes")
        }
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [go]
package main

import (
  "fmt"
)

func main() {
  res := "Yes"
  var n int
  var s string 
  fmt.Scan(&n, &s)
  if n & 1 == 1 {
    res = "No"
  } else {
    t := s[:n/2]
    if t + t != s {
      res = "No"
    }
  }
  fmt.Println(res)
  
}
//  [go]
package main

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

func main() {
	N := sc.nextInt()
	S := sc.next()
	if N%2 != 0 {
		no()
		return
	}
	if S[0:len(S)/2] == S[len(S)/2:len(S)] {
		yes()
	} else {
		no()
	}
}

var (
	sc scanner
)

func init() {
	sc = scanner{
		buf: make([]string, 0, 0),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 0)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}
func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}
func (s *scanner) resetCur() {
	s.cur = 0
}
func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}
func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}
func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur],
		64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i],
			64)
	}
	s.resetCur()
	return res
}
func digits(x int) int {
	return len(strconv.Itoa(x))
}
func powInt(x, p int) (result int) {
	result = 1
	for i := 0; i < p; i++ {
		result *= x
	}
	return
}
func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}
func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}
func abs(x int) int {
	return int(math.Abs(float64(x)))
}
func varDump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}
func yes() {
	fmt.Println("Yes")
}
func no() {
	fmt.Println("No")
}

// Pair a
type Pair struct {
	first  int
	second int
}

// Queue a
type Queue struct {
	v []Pair
}

// Push for queue
func (q *Queue) Push(v Pair) {
	q.v = append(q.v, v)
}

// Pop for queue
func (q *Queue) Pop() Pair {
	r := q.v[0]
	q.v = q.v[1:]
	return r
}

// Front for queue
func (q Queue) Front() Pair {
	return q.v[0]
}

// Empty return true if empty
func (q Queue) Empty() bool {
	return len(q.v) == 0
}
//  [go]
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	n := nextInt()
	s := nextString()

	ans := true
	if n%2 != 0 {
		ans = false
	} else {
		l := len(s)
		s1 := s[0 : l/2]
		s2 := s[l/2 : l]
		if !reflect.DeepEqual(s1, s2) {
			ans = false
		}
	}
	if ans {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}
//  [go]
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	N, err := strconv.Atoi(scanner.Text())
	if err != nil {
		log.Fatal(err)
	}

	scanner.Scan()

	S := scanner.Text()

	if N%2 != 0 {
		fmt.Println("No")
		os.Exit(0)
	}
	if S[0:N/2-1] != S[N/2:N-1] {
		fmt.Println("No")
		os.Exit(0)
	}

	fmt.Println("Yes")
}
//  [go]
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	N, err := strconv.Atoi(scanner.Text())
	if err != nil {
		log.Fatal(err)
	}

	if N%2 != 0 {
		fmt.Println("No")
		os.Exit(0)
	}

	scanner.Scan()

	S := scanner.Text()

	if S[0:N/2-1] != S[N/2:N-1] {
		fmt.Println("No")
		os.Exit(0)
	}

	fmt.Println("Yes")
}
//  [go]
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
)

func main() {
	N := getInt()
	S := getString()

	if N == 1 {
		fmt.Println("No")
		return
	}

	result := "Yes"
	for i := 0; i < N/2; i++ {
		if S[i] != S[N/2 + i] {
			result = "No"
			break
		}
	}

	fmt.Println(result)
}

type Graph struct {
	n     int
	edges [][]int
}

func NewGraph(n int) *Graph {
	g := &Graph{
		n:     n,
		edges: make([][]int, n),
	}
	return g
}

func (g *Graph) AddEdge(u, v int) {
	g.edges[v] = append(g.edges[v], u)
	g.edges[u] = append(g.edges[u], v)
}

func dfs(c int, edges [][]int, visited map[int]struct{}) {
	visited[c] = struct{}{}

	for _, v := range edges[c] {
		_, flag := visited[v]
		if flag {
			continue
		}
		dfs(v, edges, visited)
	}
}

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

func getString() string {
	sc.Scan()
	return sc.Text()
}

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

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func powMod(n, p int) int {
	if p == 0 {
		return 1
	} else if p%2 == 0 {
		t := powMod(n, p/2)
		return calcMod(t * t)
	} else {
		return calcMod(n * powMod(n, p-1))
	}
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray)-1])
}

func calcMod(x int) int {
	return x % mod
}

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

func isPrime(n int) bool {
	if n < 2 {
		return false
	} else if n == 2 {
		return true
	} else if n % 2 == 0 {
		return false
	}

	sqrtN := int(math.Sqrt(float64(n)))
	for i := 3; i <= sqrtN; i += 2 {
		if n % i == 0 {
			return false
		}
	}

	return true
}
//  [ruby]
n = gets.to_i
st = gets.chomp.split("")

half = n / 2
i = 0
i2= half

if st.size % 2 != 0
  puts "No"
  exit
end

if st.size <= 1
  puts "No"
  exit
end

half.times do
  if st [i] != st[i2]
    puts "No"
    exit
  end
  i += 1
  i2 += 1
end

puts "Yes"
//  [ruby]
# n:文字列の長さ
n = gets.to_i
# s:文字列
s = gets.chomp

if n.odd?
  puts "No"
else
  if s[0, n / 2] == s[n / 2, n / 2]
    puts "Yes"
  else
    puts "No"
  end
end
//  [ruby]
N=gets.to_i
S=gets.chomp.to_s

t=S.slice(0,S.length/2.floor)

if S==t+t
    puts "Yes"
else
    puts "No"
end
//  [ruby]
n=gets.to_i
s=gets.chomp
if n%2==1
  ans=1
else
  n/2.times do|i|
    if s[i]!=s[i+n/2]
      ans=1
    end
  end
end
puts ans==1? :No : :Yes
//  [ruby]
n = gets.to_i
m = n / 2
st = gets.chomp
puts (n % 2 == 0 and st.slice(0, m - 1) == st.slice(m) ? 'Yes' : 'No')
//  [ruby]
n = gets.to_i
m = n / 2
st = gets.chomp
puts (n % 2 == 0 and st.slice(0, m) == st.slice(m, m) ? 'Yes' : 'No')
//  [rust]
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let n: usize = match buf.trim().to_string().parse() {
		Ok(m) => m,
		_ => panic!(""),
	};
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let s = String::from(buf.trim());
	if n%2 == 0 {
		let s1 = &s[..n/2];
		let s2 = &s[n/2..];
		if s1 == s2 {
			println!("Yes");
		}else{
			println!("No");
		}
	}else{
		println!("No");
	}
}
//  [rust]
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let n: usize = read().unwrap();
    let s: String = read().unwrap();

    if n == 1 {
        println!("No");
    } else {
        if &s[0..n / 2] == &s[n / 2..] {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}
//  [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!{
        n: usize,
        s: chars,
    }

    let mut flag: bool = true;
    if n % 2 != 0{
        flag = false;
    } else {
        for i in 0..n/2{
            if s[i] != s[i+n/2]{
                flag = false;
                break;
            }
        }
    }

    if flag==true{
        println!("Yes");
    } else {
        println!("No");
    }

}
//  [rust]
fn main() {
    let n: usize = read_line_as_value();
    let s: String = read_line_as_value();
    if n % 2 != 0 {
        println!("No");
    } else {
        let sub_len = n / 2;
        if s.get(0..sub_len) == s.get(sub_len..n) {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}
//  [rust]
use text_io::*;
use std::process::exit;
use im_rc::*;
use std::cmp::*;

fn main(){
    let mut n:usize = read!();
    let mut a:String = read!();
    let mut v:Vec<char> = a.chars().collect();
    for i in 0..v.len()/2 {
        if v[i]!=v[i+v.len()/2] {
            println!("No");
            exit(0);
        }
    }
    println!("Yes");
}
//  [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! {
        n: usize,
        s: String
    }
    let (t1,t2) = s.split_at(n/2);
    println!("{} {}", t1, t2);
    if t1 == t2 {
        println!("Yes");
    } else {
        println!("No");
    }
}
/* vim:set foldmethod=marker: */
//  [swift]
let n=Int(readLine()!)!
let s=readLine()!
let S=Array(s)
var k=0
if n%2==1{
  print("No")
}else{
  for i in 0...n/2-1{
    if S[i] != S[i+n/2]{
      k=1
    }
  }
  if k==1{
    print("No")
  }else{
    print("Yes")
  }
}
//  [swift]
let n=Int(readLine()!)!
let s=Array(readLine()!.characters)

var ret = "Yes"
if( n % 2 == 1 ) {
  ret = "No"
} else {
  for(var i=0;i<n/2;i++) {
	if(s[i] != s[i+n/2]) {
		ret = "No"
	}
  }
}

print(ret)
//  [swift]
let N = Int(readLine()!)!
let S = readLine()!.characters.map{$0}
print(S[0..<N/2]==S[N/2..<N] ? "Yes":"No")
//  [swift]
let n=Int(readLine()!)!
let s=readLine()!
let S=Array(s)
var k=1
if n%2==1{
  print("No")
}else{
  for i in 0...n/2-1{
    if S[i] != S[i+n/2]{
      k=1
    }
  }
  if k==1{
    print("No")
  }else{
    print("Yes")
  }
}
//  [swift]
let N = Int(readLine()!)!
let S = readLine()!.characters
print(String(S[0..<N/2])==String(S[N/2..<N]) ? "Yes":"No")
//  [swift]
let N = Int(readLine()!)!
let S = readLine()!.characters
print(S[0..<N/2]==S[N/2..<N] ? "Yes":"No")
//  [typescript]
{
  const main = (input: string) => {
    const r = reader(input)
    const n = r.n()
    const s = r.s()

    const a = s.substring(0, n / 2)
    const b = s.substring(n / 2)

    console.log(a === b ? 'Yes' : 'No')
  }

  const reader = (str: string) => {
    const lines = str.trim().split('\n')
    const s = () => lines.shift() || ''
    const n = () => Number(s())

    const ss = () => s().split(' ')
    const ns = () => ss().map(Number)
    const nls = () => lines.map(Number)

    return { lines, s, n, ss, ns, nls }
  }

  const getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')

  main(getInput())
}
//  [typescript]
export class Main {
  main(input: string): string {
    const tmp: string[] = input.split("\n");
    const num = parseInt(tmp[0]);
    const t = tmp[1];
    if (num % 2 != 0) {
      return 'No';
    }
    if (t.substring(0, num / 2) === t.substring(num / 2)) {
      return 'Yes';
    } else {
      return 'No';
    }
  }
}

console.log(new Main().main(require("fs").readFileSync("/dev/stdin", "utf8")));
//  [typescript]
import * as fs from 'fs';

//in
// 6
// abcabc
//out
// Yes
const main = (inp: string) => {

    const n: number = parseInt(inp.split('\n')[0]);
    const s: string = inp.split('\n')[1];

    if (n % 2 === 1) {
        console.log('No');
        return;
    }

    if (s.substr(0, n / 2) === s.substr(n / 2)) {
        console.log('Yes');
    } else {
        console.log('No');
    }
};

main(fs.readFileSync('/dev/stdin', 'utf8').trim());
//  [typescript]
import * as fs from "fs"

const input = fs.readFileSync('/dev/stdin', 'utf-8').split('\n')
const s = input[0]
const n = input[1]
const t = s.substr(0,parseInt(n)/2)

if (s === `${t}${t}`) {
    console.log("Yes")
} else {
    console.log("No")
}
//  [typescript]
const t={input:require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/),n:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.n())}return a}else{const a=t.input[0];t.input.shift();return Number(a)}},s:(arg:number=0):string|string[]=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.s())}return a}else{const a=t.input[0];t.input.shift();return String(a)}},c:(arg:number=0):string|string[]=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.c())}return a}else{let a=t.input[0].split('');const b=a[0];a.shift();if(a.length>0){t.input[0]=a.join('')}else{t.input.shift()}return String(b)}},o:(...arg)=>{console.log(...arg)},abs:(a)=>{return Math.abs(a)},min:(...a)=>{return Math.min(...a)},max:(...a)=>{return Math.max(...a)},floor:(a)=>{return Math.floor(a)},asc:(ar:number[])=>{return ar.sort((a,b)=>{return a-b})},desc:(ar:number[])=>{return ar.sort((a,b)=>{return b-a})},sw:(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]}};
const main=()=>{
  let a=t.s()
  let ans='Yes'
  if(a.length%2==0){
    for(let i=0;i<a.length;i++){
      if(a[i] != a[a.length/2+i]){ans='No';break;}
    }
  }else{
    ans='No'
  }
  t.o(ans)
}
main()
//  [typescript]
const t={input:require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/),n:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.n())}return a}else{const a=t.input[0];t.input.shift();return Number(a)}},s:(arg:number=0):string|string[]=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.s())}return a}else{const a=t.input[0];t.input.shift();return String(a)}},c:(arg:number=0):string|string[]=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.c())}return a}else{let a=t.input[0].split('');const b=a[0];a.shift();if(a.length>0){t.input[0]=a.join('')}else{t.input.shift()}return String(b)}},o:(...arg)=>{console.log(...arg)},abs:(a)=>{return Math.abs(a)},min:(...a)=>{return Math.min(...a)},max:(...a)=>{return Math.max(...a)},floor:(a)=>{return Math.floor(a)},asc:(ar:number[])=>{return ar.sort((a,b)=>{return a-b})},desc:(ar:number[])=>{return ar.sort((a,b)=>{return b-a})},sw:(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]}};
const main=()=>{
  let a=t.s()
  let ans='Yes'
  if(a.length%2==0){
    for(let i=0;i<a.length;i++){
      if(a[i] != a[a.length/2+i]){ans='No';return;}
    }
  }else{
    ans='No'
  }
  t.o(ans)
}
main()
//  [python]
n = int(input())
k = int(input())
x = int(input())
y = int(input())
print(x * min(k, n) + y * max(n - k, 0))
//  [python]
# coding: utf-8
n = int(input())
k = int(input())
x = int(input())
y = int(input())
if n > k:
    print(k * x + (n - k) * y)
else:
    print(n * x)
//  [python]
a = [int(input()) for _ in range(4)]
if a[0] <= a[1]:
  print(a[0]*a[2])
else:
  print(a[1]*a[2]+a[3]*(a[0]-a[1]))
//  [python]
N = int(input())
K = int(input())
X = int(input())
Y = int(input())

if N<=K:
  print(X*K)
else:
  print(K * X + (N - K) * Y)
//  [python]
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
price = 0
for i in range(K):
  price += X
if N <= K:
  print(price)
else:
  for i in range(N-K):
    price += Y
  print(price)
//  [python]
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
price = 0
for i in range(K):
  price += X
for i in range(N-K):
  price += Y
print(price)
//  [java]

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input =new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(input.readLine());
        int K = Integer.parseInt(input.readLine());
        int X = Integer.parseInt(input.readLine());
        int Y = Integer.parseInt(input.readLine());

        if (N>K) {
            System.out.println(X*K + Y*(N-K));
        } else {
            System.out.println(X*N);
        }
    }
}
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
    execute();
    }

    private static void execute() throws IOException {
        BufferedReader br =
                new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int k = Integer.parseInt(br.readLine());
        int x = Integer.parseInt(br.readLine());
        int y = Integer.parseInt(br.readLine());
        System.out.println(calcHotelFee(n, k, x, y));
    }

    public static int calcHotelFee(int stayNum, int feeChangeDays, int feeX, int feeY) {
        if (stayNum <= feeChangeDays) {
            return stayNum * feeX;
        }
        return feeChangeDays * feeX + (stayNum - feeChangeDays) * feeY;
    }
}
//  [java]


import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
import java.util.function.Predicate;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		int N_haku = scan.nextInt();
		int K_first = scan.nextInt();
		int X_yen = scan.nextInt();
		int Y_yen = scan.nextInt();

		int total = K_first * X_yen + (N_haku - K_first) * Y_yen;
		
		System.out.println(total);

	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}
//  [cpp]
#include <stdio.h>

int main(){
    int n,k,x,y;
    scanf("%d%d%d%d",&n,&k,&x,&y);
    int sum=0;
    for(int i=1;i<=n;i++){
        if(i<=k){
            sum+=x;
        }else{
            sum+=y;
        }
    }
    printf("%d\n",sum);
}
//  [cpp]
#include <stdio.h>
#include <limits.h>
 int main() { int t,x,y,z,p;
    scanf("%d%d%d%d",&x,&y,&z,&p);
    
    (x>y)? t=y*z+(x-y)*p:
    t=x*z;
    printf("%d",t);
    
    
 return 0; }
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int n, k, x, y;
  cin >> n >> k >> x >> y;
  int p = 0;
  if (n <= k) {
    p += x * n;
    cout << p << '\n';
  } else {
    p += k * x;
    p += (n - k) * y;
    cout << p << '\n';
  }
  return 0;
}
//  [cpp]
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<bitset>
 
#define Vsort(a) sort(a.begin(), a.end())
#define Vreverse(a) reverse(a.begin(), a.end())
#define Srep(n) for(int i = 0; i < (n); i++)
#define Lrep(i,a,n) for(int i = (a); i < (n); i++)
#define Brep(n) for(int bit = 0; bit < (1<<n); bit++)
#define rep2nd(n,m) Srep(n) Lrep(j,0,m)
#define vi vector<int>
#define vi64 vector<int64_t>
#define vvi vector<vector<int>>
#define vvi64 vector<vector<int64_t>>
#define P pair<int,int>
#define F first
#define S second

using namespace std;

int main(){
  int n,k,x,y,ans=0;
  cin >> n >> k >> x >> y;
  Srep(k){
    ans += x;
    n--;
    if(n == 0){
      cout << ans << endl;
      return 0;
    }
  }
  while(n > 0) ans += y;
  cout << ans << endl;
}
//  [cpp]
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <cassert>
#include <climits>

using namespace std;

int main()
{
    int n, k, x, y;
    cin >> n >> k >> x >> y;

    if (n >= k) {
        cout << (k * x) + ((n - k) * y);

    }
    else {
        cout << (k * x);
    }
    
}
//  [cpp]
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <cassert>
#include <climits>

using namespace std;

int main()
{
    int n, k, x, y;
    cin >> n >> k >> x >> y;

    cout << (k * x) + ((n - k) * y);
}
//  [c]
#include <stdio.h>
#include <math.h>


int main() 
{
    int n,k,x,y,e,f,g;
    
    scanf("%d",&n);
    scanf("%d",&k);
    scanf("%d",&x);
    scanf("%d",&y);
    if(k>n)
    {
        printf("%d",x*n);
    }else{
    
    e=k*x;
    f=n-k;
    g=f*y;
    
    
    printf("%d",g+e);
    }
    
   
}
//  [c]
#include<stdio.h>

int main(){
    int n,k,x,y;
    scanf("%d%d%d%d",&n,&k,&x,&y);

    if(n<=k){
        printf("%d\n",n*x);
    }
    else{
        printf("%d\n",k*x+(n-k)*y);
    }
    return 0;
}
//  [c]
#include <stdio.h>
int main() {
    int n, k, x, y, ans;
    scanf("%d %d %d %d", &n, &k, &x, &y);
    if (n > k) {
        ans = k * x + (n - k) * y;
    } else
        ans = n * x;
    printf("%d\n", ans);
    return 0;
}
//  [c]
#include <stdio.h>

int main(void){
	int N, K, X, Y;
	int pay;
	scanf("%d %d %d %d", &N, &K, &X, &Y);
	if (K < N) {
		pay = K * X + (N - K) * Y;
	}
	else {
		pay = N * K;
	}
	printf("%d", pay);
	return 0;
}
//  [c]
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n,k,x,y,c=0;
  cin >> n >> k >> x >> y;
  c = k * x + (n - k) * y;
  cout << c;
}
//  [c]
#include<stdio.h>

int main(){
    int n,k,x,y;
    scanf("%d%d%d%d",&n,&k,&x,&y);

    int sum=0;
    for(int i=0;i<n;i++){
        sum+=x;
    }
    if(n>k){
        for(int i=n;i<k;i++){
            sum+=y;
        }
    }
    printf("%d\n",sum);
    return 0;
}
//  [javascript]
"use strict";

function main(input){
  const nkxy = input.trim().split('\n').map(_=>parseInt(_, 10));
  const n = nkxy[0];
  const k = nkxy[1];
  const x = nkxy[2];
  const y = nkxy[3];
  
  if(n <= k) console.log(x*n); 
  else console.log(x*k + y*(n-k));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function main(input){
 input = input.split("\n");
 var n = parseInt(input[0],10);
 var k = parseInt(input[1],10);
 var x = parseInt(input[2],10);
 var y = parseInt(input[3],10);
 var sum = 0;
  
 for(var i=0; i<n; i++){
  if(i<k){
    sum += x;
  }else{
    sum += y; 
  }
 }
 console.log(sum);  
}

main(require("fs").readFileSync("/dev/stdin","utf8"));
//  [javascript]
'use strict';
function Main(input) {
  input = input.split("\n");
  var total = parseInt(input[0], 10);
  var first = parseInt(input[1], 10);
  var billF = parseInt(input[2], 10);
  var billA = parseInt(input[3], 10);
  if(total <= first){
     console.log(total * billF);
  }else{
    var last = total - first;
  	console.log((first * billF) + (last * billA));
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function main(input) {
  input = input.trim();
  const [a,b,c,d] = input.split('\n').map(Number);
  console.log(a-b>0 ? b*c+(a-b)*d : b*c);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function main(input) {
  input = input.trim();
  const [a,b,c,d] = input.split('\n');
  console.log(a>b ? b*c+(a-b)*d : b*c);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function main(input) {

  const [a,b,c,d] = input.split('\n').map(Number);
  console.log(a>b ? b*c+(a-b)*d : b*c);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [go]
package main

import (
  "fmt"
)

func main() {
  var n, k, x, y int
  fmt.Scan(&n, &k, &x, &y)
  var fee int
  if n <= k {fee = x * n} else {fee = x*k + y*(n-k)}
  fmt.Println(fee)
}
//  [go]
package main

import (
	"fmt"
)

func main() {
	var n, k, x, y float64
	fmt.Scan(&n, &k, &x, &y)
	if n > k {
		fmt.Println(x*k + y*(n-k))
	} else {
		fmt.Println(x * n)
	}
}
//  [go]
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, k, x, y float64
	fmt.Scan(&n, &k, &x, &y)
	fmt.Println(math.Min(n, k)*x + math.Max(0, n-k)*y)
}
//  [ruby]
a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i

if a > b
  p a * c - (c - d) * (a - b)
else
  p a * c
end
//  [ruby]
n = gets.to_i
k = gets.to_i
x = gets.to_i
y = gets.to_i
puts (n <= k) ? n * x : k * x + (n - k) * y
//  [ruby]
n = gets.to_i
k = gets.to_i
x = gets.to_i
y = gets.to_i
puts x * [n, k].min + y * [n - k, 0].max
//  [ruby]
n=gets.to_i
m=gets.to_i
a=gets.to_i
b=gets.to_i
ans= m*a
ans+=(m-n)*b if n>m
p ans
//  [ruby]
n=gets.to_i
m=gets.to_i
a=gets.to_i
b=gets.to_i
p m*a+(m-n)*b
//  [ruby]
n = gets.to_i
k = gets.to_i
x = gets.to_i
y = gets.to_i
puts x * k + (n - k) * y
//  [rust]
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let n = v[0];
	let v:Vec<i32> = procon_read();
	let k = v[0];
	let v:Vec<i32> = procon_read();
	let x = v[0];
	let v:Vec<i32> = procon_read();
	let y = v[0];
	if n <= k {
		println!("{}", n*x);
	}else{
		println!("{}", k*x + (n - k)*y);
	}
}
//  [rust]
use std::cmp::max;
use std::cmp::min;
use std::io::stdin;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let n: i64 = s.trim().parse().unwrap();
    s.clear();
    stdin().read_line(&mut s).ok();
    let k: i64 = s.trim().parse().unwrap();
    s.clear();
    stdin().read_line(&mut s).ok();
    let x: i64 = s.trim().parse().unwrap();
    s.clear();
    stdin().read_line(&mut s).ok();
    let y: i64 = s.trim().parse().unwrap();

    println!("{}", min(k, n) * x + max(0, n - k) * y);
}
//  [rust]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut 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::cmp;
fn main() {
    input!{
        n: i32,
        k: i32,
        x: i32,
        y: i32,
    }
    let ans = cmp::min(k,n) * x + cmp::max((n - k) * 9000,0);
    println!("{}",ans);
}
//  [rust]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut 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!{
        n: i32,
        k: i32,
        x: i32,
        y: i32,
    }
    let ans = cmp::min(k,n) * x + cmp::max((n - k) * 9000,0);
    println!("{}",ans);
}
//  [rust]
#![allow(non_snake_case)]
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
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")
    };
}

#[allow(dead_code)]
const MOD: u64 = 1000000007;


fn main() {
    input!{
        N: isize, K: isize,
        X: isize, Y: isize,
    }

    println!("{}", K * X + (N - K) * Y);
}
//  [swift]
func i()->Int{return Int(readLine()!)!};let N=i(),K=i();print(min(N,K)*i()+max(N-K,0)*i())
//  [swift]
//func i()->Int{return Int(readLine()!)!};let N=i(),K=i();print(min(N,K)*i()+max(N-K,0)*i())
func i()->Int{return Int(readLine()!)!};let N=i(),K=i(),X=i();print(N>K ?K*X+(N-K)*i():N*X)
//  [swift]
var i:Int{return Int(readLine()!)!};let N=i,K=i,X=i;print(N>K ?K*X+(N-K)*i:N*X)
//  [swift]
//func i()->Int{return Int(readLine()!)!};let N=i(),K=i();print(min(N,K)*i()+max(N-K,0)*i())
func i()->Int{return Int(readLine()!)!};let N=i(),K=i(),X=i(),Y=i();print(N>K ?N*X:K*X+(N-K)*Y)
//  [swift]
//func i()->Int{return Int(readLine()!)!};let N=i(),K=i();print(min(N,K)*i()+max(N-K,0)*i())
func i()->Int{return Int(readLine()!)!};let N=i(),K=i(),X=i(),Y=i();print(N>K ?N*X:K*X+(N−K)*Y)
//  [swift]
func i()->Int{return Int(readLine()!)!};let N=i(),K=i();print(min(N,K)*i()+min(N-K,0)*i())
//  [typescript]
import * as fs from 'fs';
const input = fs.readFileSync("/dev/stdin", "utf8").split(/\n/);

// A - 高橋君とホテルイージー

const N = +input[0];
const K = +input[1];
const X = +input[2];
const Y = +input[3];
let result = 0;

for (let i = 0; i < N; i++) {
    if (i + 1 <= K) {
        result += X;
    } else {
        result += Y;
    }
}

console.log(result);
//  [typescript]
const main: number = (input) => {
  const input = input.split("\n");
  const N = parseInt(input[0], 10);
  const K = parseInt(input[1], 10);
  const X = parseInt(input[2], 10);
  const Y = parseInt(input[3], 10);
  
  if (N>K) {
      console.log(K*X+(N-K)*Y);
  }else{
    console.log(N*X);
  }
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const [n, k, x, y] = stdin.split('\n').map(Number)

console.log(n > k ? k * x + (n - k) * y : n * x)