Language: C

#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((size_t *)a) < *((size_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
	uint64_t temp;

	while (m%n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}

	return n;
}

static char S[100001], T[100001];

int main(void) {
	uint64_t N, M;

	scanf("%"PRIu64" %"PRIu64"\n%s\n%s", &N, &M, S, T);

	const uint64_t commonMutliplier = M * N / gcd(M, N);

	if (commonMutliplier == N) {
		bool allMatched = true;
		for (uint64_t idx = 0; idx < M; idx++) {
			if (S[idx * N / M] != T[idx]) {
				allMatched = false;
				break;
			}
		}

		if (allMatched) {
			printf("%"PRIu64"\n", commonMutliplier);
		}
		else {
			puts("-1");
		}
	}
	else if (commonMutliplier == M) {
		bool allMatched = true;
		for (uint64_t idx = 0; idx < N; idx++) {
			if (T[idx * M / N] != S[idx]) {
				allMatched = false;
				break;
			}
		}

		if (allMatched) {
			printf("%"PRIu64"\n", commonMutliplier);
		}
		else {
			puts("-1");
		}
	}
	else {
		if (S[0] == T[0]) {
			printf("%"PRIu64"\n", commonMutliplier);
		}
		else {
			puts("-1");
		}
	}

	return 0;
}
#define _CRT_SECURE_NO_WARNINGS

#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((int64_t *)a) < *((int64_t *)b) ? -1 : 1;
}

int compare_f2(const void *a, const void *b) {
	return *((uint64_t *)a) > *((uint64_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
	uint64_t result = 1;

	for (uint64_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
	uint64_t temp;

	while (m%n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}

	return n;
}

int main(void) {
	size_t A, B, C;

	scanf("%zu %zu %zu", &A, &B, &C);

	if (C <= A + B + 1) {
		printf("%zu", B + C);
	}
	else {
		printf("%zu", A + 2 * B + 1);
	}

	return 0;
}


Compiler output:
main.c:115:5: error: redefinition of 'compare_f'
  115 | int compare_f(const void *a, const void *b) {
      |     ^~~~~~~~~
main.c:15:5: note: previous definition of 'compare_f' with type 'int(const void *, const void *)'
   15 | int compare_f(const void *a, const void *b) {
      |     ^~~~~~~~~
main.c:123:15: error: redefinition of 'comb'
  123 | static size_t comb(const size_t n, const size_t r) {
      |               ^~~~
main.c:19:15: note: previous definition of 'comb' with type 'size_t(const size_t,  const size_t)' {aka 'long unsigned int(const long unsigned int,  const long unsigned int)'}
   19 | static size_t comb(const size_t n, const size_t r) {
      |               ^~~~
main.c:145:17: error: redefinition of 'gcd'
  145 | static uint64_t gcd(uint64_t m, uint64_t n)
      |                 ^~~
main.c:30:17: note: previous definition of 'gcd' with type 'uint64_t(uint64_t,  uint64_t)' {aka 'long unsigned int(long unsigned int,  long unsigned int)'}
   30 | static uint64_t gcd(uint64_t m, uint64_t n)
      |                 ^~~
main.c:158:5: error: redefinition of 'main'
  158 | int main(void) {
      |     ^~~~
main.c:45:5: note: previous definition of 'main' with type 'int(void)'
   45 | int main(void) {
      |     ^~~~