Problem:
Score : 200 points

Problem Statement

Given are a positive integer N and a string S of length N consisting of lowercase English letters.

Determine whether the string is a concatenation of two copies of some string.
That is, determine whether there is a string T such that S = T + T.

Constraints

1 \leq N \leq 100

S consists of lowercase English letters.

|S| = N

Input

Input is given from Standard Input in the following format:

N
S

Output

If S is a concatenation of two copies of some string, print Yes; otherwise, print No.

Sample Input 1

6
abcabc

Sample Output 1

Yes

Let T = abc, and S = T + T.

Sample Input 2

6
abcadc

Sample Output 2

No

Sample Input 3

1
z

Sample Output 3

No

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;

const int MAXN = 5;
int segmentTree[4 * MAXN + 1];

void buildSegmentTree(vector<int>& nums, int tl, int tr, int index) {
	if (tl == tr) {
		segmentTree[index] = nums[tl];
		return;
	}
	else {
		int tm = tl + (tr - tl) / 2;
		buildSegmentTree(nums, tl, tm, index * 2 + 1);
		buildSegmentTree(nums, tm + 1, tr, index * 2 + 2);
		segmentTree[index] = segmentTree[index * 2 + 1] + segmentTree[index * 2 + 2];
	}
}

int rangeSum(int index, int tl, int tr, int l, int r) {
	if (l > r) return 0;

	if (tl == l && tr == r) return segmentTree[index];
	
	int tm = tl + (tr - tl) / 2;

	return rangeSum(index * 2 + 1, tl, tm, l, min(tm, r)) + rangeSum(index * 2 + 2, tm + 1, tr, max(l, tm + 1), r);
}

void update(int index, int tl, int tr, int pos, int val) {
	if (tl == tr) {
		segmentTree[index] = val;
		return;
	}

	int tm = tl + (tr - tl) / 2;
	if (pos <= tm) {
		update(index * 2 + 1, tl, tm, pos, val);
	}
	else update(index * 2 + 2, tm + 1, tr, pos, val);

	segmentTree[index] = segmentTree[index * 2 + 1] + segmentTree[index * 2 + 2];
}

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;

	if (n % 2 == 1) {
		cout << "No";
	}
	else {
		int len = n / 2;

		string temp = "";

		for (int i = 0; i < len; i++) {
			temp += s[i];
		}

		int index = 0;

		bool isValid = true;

		for (int i = len; i < n; i++) {
			if (temp[index++] != s[i]) {
				isValid = false;
				break;
			}
		}

		if (isValid) cout << "Yes";
		else cout << "No";
	}
}