criyle/codenet-compile-errors huggingface dataset:
Language: Java

import java.util.Scanner;

public class abbriviations {

	int n, m;
	String s, t;

	public static int gcd(int a, int b) {
		return b > 0 ? gcd(b, a % b) : a;
	}

	public static int lcm(int a, int b) {
		return a * b / gcd(a, b);
	}

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);

		String nm = sc.nextLine();
		String[] len = nm.split(" ");

		int n = Integer.parseInt(len[0]);
		int m = Integer.parseInt(len[1]);

		String s = sc.nextLine();
		String t = sc.nextLine();

		boolean flag = true;
		for (int i = 0; i < n; i++) {
			if ((m * i) % n == 0) {
				if (s.charAt(i) != t.charAt((m * i) / n)) {
					System.out.println("-1");
					flag = false;
					break;
				}
			}
		}

		if (flag) {
			System.out.println(lcm(n, m));
		}
	}
}

Compiler output:
Main.java:3: error: class abbriviations is public, should be declared in a file named abbriviations.java
public class abbriviations {
       ^
1 error
Language: C++

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>

using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
ll making_base(ll a, ll b) {
	ll  r, x, tmp;

	


	x = a * b;

	/* 自然数 a > b を確認・入替 */
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	/* ユークリッドの互除法 */
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return x / b;

}


int main()
{
	ll n, m;
	cin >> n >> m;
	
	string s,t;
	cin >> s >> t;
	if (m > n) {
		using std::swap;
		swap(n, m);
		swap(s, t);
	}
	ll base = making_base(n, m);
	ll up_one = base / m;
	ll down_one = base / n;
	
	if (s[0] != t[0]) {
		cout << -1 << endl;
	}
	for (ll i = 1; i*up_one < n; i++) {
		/*for (int j = 2; j < m; i++) {
			if ((i - 1)*m == (j - 1)*n) {
				if (s[n - 1] == t[m - 1]){
					if (i + 1 == n) {

					}
					continue;
				}
				else {
					cout << -1 << endl;
					return 0;
				}
			}
		}*/
		//cout << s[(up_one)*i] << " " << t[(down_one)*i] << endl;
		if (s[(up_one)*i] != t[(down_one)*i]) {
			cout << -1 << endl;
			return 0;
		}


	}
	
	cout << -1 << endl;




Compiler output:
a.cc: In function 'int main()':
a.cc:99:28: error: expected '}' at end of input
   99 |         cout << -1 << endl;
      |                            ^
a.cc:57:1: note: to match this '{'
   57 | {
      | ^
Language: C

#include <stdio.h>

int gf(int,int);




int main(void)
{
 int N,M,L;
  scanf("%d %d",&N,&M); 
 char S[N],T[M];
  scanf("%s",S);
  scanf("%s",T);
  L=N*M/gf(N,M);
 int k,flag,dS,dT;
   flag=0;
   dS=L/N;
   dT=L/M;
  
   for(k=0;k<N;k++)
   {
     if((k*dS)%dT==0)
     {
      if(S[k]!=T[k*dS/dT]){
        flag=1;}
     }
   } 
 }
 
 if(f==0){printf("-1");}
 if(f==1){printf("%d",L);}
 return 0;
}



int gf(int x,int y)
{
 int tmp,r;
 if(x<y){tmp=x;x=y;y=tmp;} 
  r=x%y;
 if(r==0)
 {return y;}
 if(r!=0)
 {return gf(y,r);}
}


Compiler output:
main.c:31:2: error: expected identifier or '(' before 'if'
   31 |  if(f==0){printf("-1");}
      |  ^~
main.c:32:2: error: expected identifier or '(' before 'if'
   32 |  if(f==1){printf("%d",L);}
      |  ^~
main.c:33:2: error: expected identifier or '(' before 'return'
   33 |  return 0;
      |  ^~~~~~
main.c:34:1: error: expected identifier or '(' before '}' token
   34 | }
      | ^
Language: C++

/*
  Code By RyeCatcher
*/
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cctype>
#include <vector>
#include <queue>
#include <utility>
#define ri register int
#define ll long long
#define ull unsigned long long
#define pb push_back
#define DEBUG freopen("dat.in","r",stdin);freopen("wa.out","w".stdout);
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define SIZE 23333
using std::min;
using std::max;
using std::pair;
using std::queue;
using std::priority_queue;
using std::vector;
inline char gc(){
    static char buf[SIZE],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,SIZE,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
template <class T>inline void read(T &x){
	x=0;int ne=0;char c;
    while((c=gc())>'9'||c<'0')ne=c=='-';x=c-48;
    while((c=gc())>='0'&&c<='9')x=(x<<3)+(x<<1)+c-48;x=ne?-x:x;return ;
}
const int maxn=1000005;
const int inf=0x7fffffff;
ll n,m;
ll o,oo;
char s[maxn],t[maxn];
ll gdd(ll a,ll b){return b?gcd(b,a%b):a;}
int main(){
	ll p;
	read(n),read(m);
	scanf("%s",s+1);scanf("%s",t+1);
	p=gcd(n,m);
	oo=n*m;
	o=1ll*oo/p;//lcm
	ll la,lb,gg,gp,ga,gb;
	for(ll k=o;k<=oo;k+=o){
		la=k/n;
		lb=k/m;
		gg=gcd(la,lb);
		//printf("%lld %lld %lld\n",la,lb,gg);
		ga=gb=1,gg=la*lb/gg;
		la=gg/la,lb=gg/lb;
		//printf("%lld %lld %lld\n",la,lb,gg);
		bool flag=1;
		while(ga<=n&&gb<=m){
			if(s[ga]==t[gb])ga+=la,gb+=lb;
			else {
				flag=0;
				break;
			}
		}
		if(flag==1){printf("%lld\n",k);exit(0);}
	}
	puts("-1");
	return 0;
}	


Compiler output:
a.cc: In function 'long long int gdd(long long int, long long int)':
a.cc:40:28: error: 'gcd' was not declared in this scope; did you mean 'gdd'?
   40 | ll gdd(ll a,ll b){return b?gcd(b,a%b):a;}
      |                            ^~~
      |                            gdd
a.cc: In function 'int main()':
a.cc:45:11: error: 'gcd' was not declared in this scope; did you mean 'gdd'?
   45 |         p=gcd(n,m);
      |           ^~~
      |           gdd
Language: C++

#include<ctype.h>
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
inline ll gcd(ll a,ll b){while(a)a^=b^=a^=b%=a;return b;}
inline ll read ( )
{
	ll o=0,fl=1;
	char ch=getchar();
	while(!isdigit(ch))o^=ch=='-',ch=getchar();
	while(isdigit(ch))o=10*o+ch-48,ch=getchar();
	return fl?o:-o;
}
ll n,m,p,q,k;
char s1[200010],s2[200010];
int main ( )
{
	n=read();m=read();
	gets(s1);gets(s2);
	p=n/gcd(n,m)*m;
	q=p/m;p=p/n;
	k=p/gcd(p,q)*q;
	int f=p;
	p=k/q,q=k/f;
	f=p;p=q;q=f;
	//printf("%lld %lld %lld %lld\n",n,m,p,q);
	for(int i=0;i<n/p;i++)
		if(s1[i*p]!=s2[i*q])
			return puts("-1")&0;
	printf("%lld",n/gcd(n,m)*m);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
   22 |         gets(s1);gets(s2);
      |         ^~~~
      |         getw
Language: C

#include <stdio.h>

int gf(int,int);

int main(void)
{
 int N,M,L;
  scanf("%d %d",&N,&M); 
 char S[N],T[M];
  scanf("%s",S);
  scanf("%s",T);
  L=N*M/gf(N,M);
 int i,k,flag,f,dS,dT;
  f=0;
 for(i=1;i<N*M;i++)
 { L=L*i;
   flag=0;
   dS=L/N;
   dT=L/M;
  
   for(k=0;k<N;k++)
   {
     if((k*dS)%dT==0)
     {
      if(S[k]!=T[k*dS/dT]){
        flag=1;
        break;}
     }
   } 
  
  if(flag==0)
  {f=1; break;}
  L=L/i;
 }
 

Compiler output:
main.c: In function 'main':
main.c:34:2: error: expected declaration or statement at end of input
   34 |  }
      |  ^
Language: C++

#include<ctype.h>
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
inline ll gcd(ll a,ll b){while(a)a^=b^=a^=b%=a;return b;}
inline ll read ( )
{
	ll o=0,fl=1;
	char ch=getchar();
	while(!isdigit(ch))o^=ch=='-',ch=getchar();
	while(isdigit(ch))o=10*o+ch-48,ch=getchar();
	return fl?o:-o;
}
ll n,m,p,q,k;
char s1[200010],s2[200010];
int main ( )
{
	n=read();m=read();
	gets(s1);gets(s2);
	p=n/gcd(n,m)*m;
	q=p/m;p=p/n;
	k=p/gcd(p,q)*q;
	int f=p;
	p=k/q,q=k/f;
	f=p;p=q;q=f;
	for(int i=0;i<n/p;i++)
		if(s1[i*p]!=s2[i*q])
			return puts("-1")&0;
	printf("%d",n/gcd(n,m)*m);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
   22 |         gets(s1);gets(s2);
      |         ^~~~
      |         getw
Language: C++

#include <iostream>

using namespace std;

long long gcd(long long  a, long long b)
{
	long long g = 1;
	const int odd = 1;

	while (a > 0)
	{
		if ((a & odd) == 0 && (b & odd) == 0)
		{
			a = a >> 1;
			b = b >> 1;
			g = 2 * g;
		}
		else if ((a & odd) == 0)
		{
			a = a >> 1;
		}
		else if ((b & odd) == 0)
		{
			b = b >> 1;
		}
		else
		{
			long long t = abs(a - b) >> 1;
			if (a >= b) a = t;
			else b = t;
		}
	}
	return g * b;
}

int main() {
	long long n, m, l;
	char s[100000], t[100000];

	cin >> n >> m >> s >> t;

	if (s[0] != t[0]) {
		cout << -1;
		return 0;
	}

	l = (n * m) / gcd(n, m);

	long long c, d;

	c = l / n;
	d = l / m;

	if (c * d < n && c * d < m) {
		#include <iostream>

using namespace std;

long long gcd(long long  a, long long b)
{
	long long g = 1;
	const int odd = 1;

	while (a > 0)
	{
		if ((a & odd) == 0 && (b & odd) == 0)
		{
			a = a >> 1;
			b = b >> 1;
			g = 2 * g;
		}
		else if ((a & odd) == 0)
		{
			a = a >> 1;
		}
		else if ((b & odd) == 0)
		{
			b = b >> 1;
		}
		else
		{
			long long t = abs(a - b) >> 1;
			if (a >= b) a = t;
			else b = t;
		}
	}
	return g * b;
}

int main() {
	long long n, m, l;
	char s[100000], t[100000];

	cin >> n >> m >> s >> t;

	if (s[0] != t[0]) {
		cout << -1;
		return 0;
	}

	l = (n * m) / gcd(n, m);

	long long c, d;

	c = l / n;
	d = l / m;

	if (c * d < n && c * d < m) {
		if (s[c * d] != t[c * d]) {
			cout << -1;
			return 0;
		}
	}

	/*if (n > m) {
		if (s[c * d] != t[c * d]) {
			cout << -1;
			return 0;
		}

		for (int i = 1; i < m; i++) {
			for (int j = 1; j < m; j++) {
				if ((i * c) == (j * d)) {
					if (s[i] != t[j]) {
						cout << -1;
						return 0;
					}
				}
			}
		}
	}
	else {
		for (int i = 0; i < n; i++) {
			for (int j = 1; j < n; j++) {
				if ((i * d) == (j * c)) {
					if (s[j] != t[i]) {
						cout << -1;
						return 0;
					}
				}
			}
		}
	}*/

	cout << l;
}
	}

	/*if (n > m) {
		if (s[c * d] != t[c * d]) {
			cout << -1;
			return 0;
		}

		for (int i = 1; i < m; i++) {
			for (int j = 1; j < m; j++) {
				if ((i * c) == (j * d)) {
					if (s[i] != t[j]) {
						cout << -1;
						return 0;
					}
				}
			}
		}
	}
	else {
		for (int i = 0; i < n; i++) {
			for (int j = 1; j < n; j++) {
				if ((i * d) == (j * c)) {
					if (s[j] != t[i]) {
						cout << -1;
						return 0;
					}
				}
			}
		}
	}*/

	cout << l;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:60:1: error: a function-definition is not allowed here before '{' token
   60 | {
      | ^
a.cc:90:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   90 | int main() {
      |         ^~
a.cc:90:9: note: remove parentheses to default-initialize a variable
   90 | int main() {
      |         ^~
      |         --
a.cc:90:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:90:12: error: a function-definition is not allowed here before '{' token
   90 | int main() {
      |            ^
Language: C++

#include <stdio.h>

int gf(int,int);

int main(void)
{
 int N,M,L;
  scanf("%d %d",&N,&M); 
 char S[N],T[M];
  scanf("%s",S);
  scanf("%s",T);
  L=N*M/gf(N,M);
 int i,k,flag,f,dS,dT;
  f=0;
 for(i=1;i<N*M;i++)
 { L=L*i;
   flag=0;
   dS=L/N;
   dT=L/M;
  
   for(k=0;k<N;k++)
   {
     if((k*dS)%dT==0)
     {
      if(S[k]!=T[k*dS/dT]){
        flag=1;
        break;}
     }
   } 
  
  if(flag==0)
  {f=1; break;}
  L=L/i;
 }
 

Compiler output:
a.cc: In function 'int main()':
a.cc:34:3: error: expected '}' at end of input
   34 |  }
      |   ^
a.cc:6:1: note: to match this '{'
    6 | {
      | ^
Language: C++

include <iostream>
using namespace std;

int main(){
  int N,M;
  cin>>N>>M;
  string a,b;
  cin>>a>>b;
  string s;
  int L;
  bool flag=true;
  int gcd=0;
  int S=min(N,M);
  for (int g=1;g<=10000;g++){
    if (N%g==0&&M%g==0){
      gcd=g;
    }
  }
  L=N*M/gcd;
  int k,l;
  k=L/N;
  l=L/M;
  for (int i=0;i<gcd;i++){
    if (a[l*i]==b[k*i]){
      flag=flag&&true;
    }
    else{
      flag=flag&&false;
    }
  }
  if (flag==true){
    cout<<L;
  }
  else {
    cout<<-1;
  }
  return 0;
}


Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <iostream>
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:6:3: error: 'cin' was not declared in this scope
    6 |   cin>>N>>M;
      |   ^~~
a.cc:7:3: error: 'string' was not declared in this scope
    7 |   string a,b;
      |   ^~~~~~
a.cc:8:8: error: 'a' was not declared in this scope
    8 |   cin>>a>>b;
      |        ^
a.cc:8:11: error: 'b' was not declared in this scope
    8 |   cin>>a>>b;
      |           ^
a.cc:9:9: error: expected ';' before 's'
    9 |   string s;
      |         ^~
      |         ;
a.cc:13:9: error: 'min' was not declared in this scope; did you mean 'main'?
   13 |   int S=min(N,M);
      |         ^~~
      |         main
a.cc:32:5: error: 'cout' was not declared in this scope
   32 |     cout<<L;
      |     ^~~~
a.cc:35:5: error: 'cout' was not declared in this scope
   35 |     cout<<-1;
      |     ^~~~
Language: C++

include <iostream>
using namespace std;

int main(){
  int N,M;
  cin>>N>>M;
  string a,b;
  cin>>a>>b;
  string s;
  int L;
  bool flag=true;
  int gcd=0;
  int S=min(N,M);
  for (int g=1;g<=10000;g++){
    if (N%g==0&&M%g==0){
      gcd=g;
    }
  }
  L=N*M/gcd;
  int k,l;
  k=L/N;
  l=L/M;
  for (int i=0;i<gcd;i++){
    if (a[l*i]==b[k*i]){
      flag=flag&&true;
    }
    else{
      flag=flag&&false;
    }
  }
  if (flag==true){
    cout<<L;
  }
  else {
    cout<<-1;
  }
  return 0;
}

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <iostream>
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:6:3: error: 'cin' was not declared in this scope
    6 |   cin>>N>>M;
      |   ^~~
a.cc:7:3: error: 'string' was not declared in this scope
    7 |   string a,b;
      |   ^~~~~~
a.cc:8:8: error: 'a' was not declared in this scope
    8 |   cin>>a>>b;
      |        ^
a.cc:8:11: error: 'b' was not declared in this scope
    8 |   cin>>a>>b;
      |           ^
a.cc:9:9: error: expected ';' before 's'
    9 |   string s;
      |         ^~
      |         ;
a.cc:13:9: error: 'min' was not declared in this scope; did you mean 'main'?
   13 |   int S=min(N,M);
      |         ^~~
      |         main
a.cc:32:5: error: 'cout' was not declared in this scope
   32 |     cout<<L;
      |     ^~~~
a.cc:35:5: error: 'cout' was not declared in this scope
   35 |     cout<<-1;
      |     ^~~~
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include <math.h>
#include<map>
using namespace std;

int gcd(int x, int y);
int lcm(int x, int y);

int main(int argc,char** argv)
{

	int n,m;
	cin >> n >> m;
	string s,t;
	cin >> s >> t;

	long long sizeans = (long long)lcm(n,m);
	long long  stmp = sizeans/n;
	long long ttmp = sizeans/m;
	long long koubai = lcm(stmp,ttmp);

	long long  sp=0,tp=0;
	for(long long i = 0; i < sizeans; i++){

		if((i+1)%koubai == 0 || i=0){
			if(s[sp]!=t[tp]){
				cout << -1 <<endl;
				return 0;
			}

		}
		if(i%stmp==0){
			sp++;
		}
		if(i%ttmp==0){
			tp++;
		}
	}
	//cout << sp <<' '<<tp<<endl;
	cout << sizeans <<endl;

	return 0;

}

int gcd(int x, int y)
{
    int  r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

int lcm(int x, int y)
{
    return (x * y / gcd(x, y));
}

Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:29:38: error: lvalue required as left operand of assignment
   29 |                 if((i+1)%koubai == 0 || i=0){
      |                    ~~~~~~~~~~~~~~~~~~^~~~
Language: C++

#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;
typedef long long ll;

ll gcd_euclid(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r; /* swap */
  }
  return u;
}

bool check(ll L,ll N,ll M, string S,string T){
	vector<char> X(L,0);
	X[0] = S[0];

	for(ll i(1);i<N;++i){
		X[L*i/N+1] = S[i];
	}
	for(ll i(1);i<M;++i){
		if(X[L*i/M+1] == 0){
			X[L*i/M+1] = T[i];
		}else if(X[L*i/M+1] != T[i]){
			return false;
		}
	}
	return true;
}

int main()
{
	ll N,M;
	cin >> N >> M;
	string S,T;
	cin >> S;
	cin >> T;
	if(S[0] != T[0]){
		 cout << -1 << endl;
		 return 0;
	}
	ll L((M/gcd_euclid(N,M)*N);
	if(check(L,N,M,S,T)){
		cout << L << endl;
		return 0;
	}
	cout << "-1" << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:45:35: error: expected ')' before ';' token
   45 |         ll L((M/gcd_euclid(N,M)*N);
      |             ~                     ^
      |                                   )
Language: Java

import java.util.*;

class Main {
 public static void main(String[] args) {
   Scanner in = new Scanner(System.in);
   int n = in.nextInt();
   int m = in.nextInt();
   String s = in.next();
   String t = in.next();
   
   int l = Math.max(n, m);
   while(true) {
     if(l % n != 0 || l & m != 0) {
        l++;
     } else {
        break; 
     }
   }
     
     if(l == Math.max(n, m)) {
       System.out.println(-1);
     } else {
       System.out.println(l); 
     }
 }
}

Compiler output:
Main.java:13: error: bad operand types for binary operator '&'
     if(l % n != 0 || l & m != 0) {
                        ^
  first type:  int
  second type: boolean
1 error
Language: C++

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

typedef long long ll;
typedef pair<ll,ll> P;

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

ll ds(ll a, ll b) {
  if (a > b) {
    swap(a, b);
  }
  // cout << a << b << endl;
  if !a
    return b;
  else
    return ds(a, b % a);
}

int main()
{
  ll N, M;
  cin >> N >> M;
  string S, T;
  cin >> S >> T;

  ll L = N * M / ds(N, M);
  // cout << L << endl;

  char LS[L];
  char LT[L];
  for (int i = 0; i < L; ++i) {
    LS[i] = ' ';
    LT[i] = ' ';
    if (i % (L / N) == 0) {
      LS[i] = S[i / (L / N)];
    }
    if (i % (L / M) == 0) {
      LT[i] = T[i / (L / M)];
    }
  }

  // cout << LS << endl << LT << endl;
  for (int i = 0; i < L; ++i) {
    if (LS[i] != LT[i] && LS[i] != ' ' && LT[i] != ' ') {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << L << endl;
  return 0;
}



Compiler output:
a.cc: In function 'll ds(ll, ll)':
a.cc:19:6: error: expected '(' before '!' token
   19 |   if !a
      |      ^
      |      (
a.cc:21:3: error: 'else' without a previous 'if'
   21 |   else
      |   ^~~~
Language: C++

#include<iostream>
#include<string>
using namespace std;


int gcd(int a,int b){
  if(a>b){
    return gcd(b,a);
  }
  int r;
  while(r=a%b){
    a=b;
    b=r;
  }
  return b;
}

void solve(){
  int N,M;
  string S,T;
  cin >>N>>M;
  cin >>S>>T;
  int g=gcd(N,M);
  int n=N/g;
  int m=M/g;
  bool judge=true;
  int ans=-1;
  int k=1;
  for(k;k*m*n<min(M,N);k++){
    for(int i=0;k*i*m*n<min(M,N);i++){
      if(S[k*i*m*n]!=T[k*i*m*n]){
        judge=false;
        break;
      }
    }
    if(!judge){
      break;
    }
  }

  if(judge){
    ans=k*m*n*g;
  }else{
    ans=-1;
  }
  cout <<ans<<endl;
};

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
#include<string>
using namespace std;
int main(){
  int N,M,X,r,s;
  string S,T;
  cin >> N >> M >> S >> T;
  s=N*M;
  if(N%2 == 1 || M%2 == 1){
    X=s;
  }else{
    if(M>N){
      swap(N,M);
    }
  }r=N%M;
    while(r!=0){
    N=M; M=r; r=N%M;
    }
  X=s/M;
  for(int i=0; i<)
  if(X < S.size()+T.size() || S[0] != T[0]){
    cout << "-1" << endl;
  }else{
  cout << X << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:18: error: expected primary-expression before ')' token
   20 |   for(int i=0; i<)
      |                  ^
a.cc:20:18: error: expected ';' before ')' token
   20 |   for(int i=0; i<)
      |                  ^
      |                  ;
Language: C

#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std;

long long int gcd(long long int n,long long int m){
    long long int temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;

}

int main(void){
 long long int N,M,tmp,k,l;
 long long int lcm=0;
 long long int ok=1;
 char s[100050];
 char t[100050];
 
 cin>>N>>M;
 cin>>s>>t;

 if(N>M){
   tmp=N;
   N=M;
   M=tmp;
 }
 
 lcm=N*M/gcd(N,M);
 vector<int> A(lcm+1,-1);

 for(int i=0; i<strlen(s); i++){
  l=1+(i*lcm/strlen(s));
  if(l>lcm){
	  std::cout<<"-1"<<std::endl;
	  return 0;
  }
  A[l]=s[i]-'a';
 }

 for(int i=0; i<strlen(t); i++){
   k=t[i]-'a';
   l=1+(i*lcm/strlen(t));
   if(l>lcm){
	   std::cout<<"-1"<<std::endl;
	   return 0;
   }
   if(A[l]==-1)A[l]=k;
   else{
    if(A[l]!=k){
	 ok=0;
	 break;
	}
   }
 }

 if(ok)std::cout<<lcm<<std::endl;
 else std::cout<<"-1"<<std::endl;
 return 0;
}

Compiler output:
main.c:1:9: fatal error: iostream: No such file or directory
    1 | #include<iostream>
      |         ^~~~~~~~~~
compilation terminated.
Language: C++

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

int main()
{
  int a,b;
  cin >> a >> b ;
  string s,t,u;
  cin >> s >> t;
  if(b>a){
    int c = a;
    a = b;
    b=c;
    u=s;
    s=t;
    t=u;
  }
  for(int i=0 ; i<a; i++){
    int n,m,x;
    if(a%i==0 && b%i==0){
      n=a%i;
      m=b%i;
      x=i;
    }
  }
  int l = n*m*x;
  for (int i = 0;i<x+1;i++){
    if(s.at(i*n)==t.at(i*m)){
      int y ++;
    }
  }
  if(y==x){
    coun<<l<<endl;
  }
  else{
    coun << -1<<endl;
  }
}
    

Compiler output:
a.cc: In function 'int main()':
a.cc:26:11: error: 'n' was not declared in this scope
   26 |   int l = n*m*x;
      |           ^
a.cc:26:13: error: 'm' was not declared in this scope
   26 |   int l = n*m*x;
      |             ^
a.cc:26:15: error: 'x' was not declared in this scope
   26 |   int l = n*m*x;
      |               ^
a.cc:29:13: error: expected initializer before '++' token
   29 |       int y ++;
      |             ^~
a.cc:32:6: error: 'y' was not declared in this scope
   32 |   if(y==x){
      |      ^
a.cc:33:5: error: 'coun' was not declared in this scope
   33 |     coun<<l<<endl;
      |     ^~~~
a.cc:36:5: error: 'coun' was not declared in this scope
   36 |     coun << -1<<endl;
      |     ^~~~
Language: C++

#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std;

long long int gcd(long long int n,long long int m){
    long long int temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;

}

int main(void){
 long long int N,M,tmp,k,l;
 long long int lcm=0;
 long long int ok=1;
 char s[100050];
 char t[100050];
 
 cin>>N>>M;
 cin>>s>>t;

 if(N>M){
   tmp=N;
   N=M;
   M=tmp;
 }
 
 lcm=N*M/gcd(N,M);
 vector<int> A(lcm+1,-1);

 for(int i=0; i<strlen(s); i++){
  l=1+(i*lcm/strlen(s));
  if(l>lcm){
	  std::cout<<"-1"<<std::endl;
	  return 0;
  }
  A[l]=s[i]-'a';
 }

 for(int i=0; i<strlen(t); i++){
   k=t[i]-'a';
   l=1+(i*lcm/strlen(t));
   if(l>lcm){
	   std::cout<<"-1"<<std::endl;
	   return 0;
   }
   if(A[l]==-1)A[l]=k;
   else{
    if(A[l]!=k){
	 ok=0;
	 break;
	}
   }
 }



Compiler output:
a.cc: In function 'int main()':
a.cc:65:3: error: expected '}' at end of input
   65 |  }
      |   ^
a.cc:23:15: note: to match this '{'
   23 | int main(void){
      |               ^
Language: C++

#include <iostream>
#include <string>
#include <cstdio>

using namespace std;

int main() {
  int n, m;
  cin >> n >> >> m;

  string s, t;
  cin >> s;
  cin >> t;

  /* 自然数 a > b を確認・入替 */
  int N,M;
  N=n;
  M=m;
if(N<M){
  int tmp = N;
  N = M;
  M = tmp;
}



/* ユークリッドの互除法 */
int r = N % M;
while(r!=0){
  N = M;
  M = r;
  r = N % M;
}
int y = n*m/M;

  int i1=0;
  int i2=0;
  while(true){
    int j=y/n*i1;
    int k=y/m*i2;

    if(j==k){
      //cout << s[j] << ", "  << t[k]<< endl;
      if(s[j]!=t[k]){
        cout << -1 <<endl;
        return -1;
      }
      i1++;
      i2++;
    }else if(j>k){
      i2++;
    }else{
      i1++;
    }
    //cout << j << ", "<< k<<endl;
    if(j>=n||k>=m){break;}
  }
  cout << y << endl;
  return y;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:15: error: expected primary-expression before '>>' token
    9 |   cin >> n >> >> m;
      |               ^~
Language: C

#include<stdio.h>
#include<string.h>
int qzxgbs(int a,int b)
{
	int r,t,j;
	j=a*b;
	if(a<b)
	{
		t=a;
		a=b;
		b=t;
	}
	while(b!=0)
	{
		r=a%b;
		a=b;
		b=r;
	}
	return j/a;
}
int main()
{
	char s[100001],t[100001],l[100001];
	int n,m,beishu;
	scanf("%d",&n);
	scanf("%d",&m);
	getchar();
	gets(s);
	gets(t);
	if(s[0]!=t[0])
	{
		printf("-1\n");
		return 0;
	}
	beishu=qzxgbs(n,m);
	if(n>m&&n%m==0)
	{
		
	}
	else if(m>n&&m%n==0)
	{
		strcmp(l,t);
		for(i=1;i<m;i++)
		{
			if(l[m/n*i]!=s[i])
			printf("-1\n");
			return 0;
		}
	}
	printf("%d",beishu);
	return 0;
	 
} 

Compiler output:
main.c: In function 'main':
main.c:28:9: error: implicit declaration of function 'gets'; did you mean 'fgets'? [-Wimplicit-function-declaration]
   28 |         gets(s);
      |         ^~~~
      |         fgets
main.c:43:21: error: 'i' undeclared (first use in this function)
   43 |                 for(i=1;i<m;i++)
      |                     ^
main.c:43:21: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

int gcd(int a,int b){
  if(b==0)return a;
  return gcd(b,a%b);
}

int lcm(int a,int b){
  return a*b/gcd(a,b);
}

int main(){
  int n,m;
  string s,t;
  cin >> n >> m >> s >> t;
  int l = lcm(n,m);
  bool can = true;
  int a = max(n,m), b = min(n,m);
  string c = (n==a?s:t), d = (m==b?t:s);
  vector<char> x(l,'');
  rep(i,b){
    x[l/b*i] = d[i];
  }
  rep(i,a){
    if((x[l/a*i] != '') && (x[l/a*i] != c[i])){
      can = false;
      break;
    }
  }
  cout << (can?l:-1) << endl;
}



Compiler output:
a.cc:27:20: error: empty character constant
   27 |   vector<char> x(l,'');
      |                    ^~
a.cc:32:21: error: empty character constant
   32 |     if((x[l/a*i] != '') && (x[l/a*i] != c[i])){
      |                     ^~
Language: Java

import java.util.*;

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

        int l = max(n, m);
        while(true) {
            if(l % n != 0 || l % m != 0) {
                l++;
            } else {
                break;
            }
        }

        boolean flag = true;
        int ln = l / n;
        int lm = l / m;
        String x = "";

        for(int i=0; i<l; i++) x.charAt(i) = ' ';

        for(int i=0; i<n; i++) {
            int d = i * ln + 1 - 1;
            x.charAt(d) = s.charAt(i);
        }

        for(int i=0; i<m; i++) {
            int e = i * lm + 1 - 1;
            char tc = t.charAt(i);
            if(x.charAt(e) == ' ' || x.charAt(e) == tc) {
                x.charAt(e) = t.charAt(i);
            } else {
                flag = false;
                break;
            }
        }

        if(flag) {
            System.out.println(l);
        } else {
            System.out.println(-1);
        }
    }
}

Compiler output:
Main.java:11: error: cannot find symbol
        int l = max(n, m);
                ^
  symbol:   method max(int,int)
  location: class Main
Main.java:25: error: unexpected type
        for(int i=0; i<l; i++) x.charAt(i) = ' ';
                                       ^
  required: variable
  found:    value
Main.java:29: error: unexpected type
            x.charAt(d) = s.charAt(i);
                    ^
  required: variable
  found:    value
Main.java:36: error: unexpected type
                x.charAt(e) = t.charAt(i);
                        ^
  required: variable
  found:    value
4 errors
Language: C++

#include<iostream>
#include<string> 
#include<algorithm>
using namespace std;
int T;
const int maxn=1e8;
string s1,s2;
int main(){
	int n,m;
	cin>>n>>m;
	cin>>s1>>s2;
	if(s1[0]!=s2[0]||n%m==0||m%n==0&&n!=m)
	{
		cout<<-1<<endl;
		return 0;
	}
	for(int i=1;i<=max(n*n,m*m)i++)
		if(i%n==0&&i%m==0)
		{
			cout<<i<<endl;
			return 0;
		}
	
	cout<<-1<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:36: error: expected ';' before 'i'
   17 |         for(int i=1;i<=max(n*n,m*m)i++)
      |                                    ^
      |                                    ;
Language: C++

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

int gcd(int a,int b)
{
 int r, tmp;
 if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

int main(){
	int n,m;
	cin >> n>>m;
	string s,t;
	cin >> s >> t;
	int g=gcd(n,m);
	bool ok = true;
	
	if(s[0] != t[0]) {
		cout << "-1" << endl;
		return;
	}
	int cs = n/g;
	int ct = m/g;
	for(int i = 1; (i*cs<n) &&(i*ct<m);i++) {
		if(s[i*cs] != t[i*ct]) {
			ok = false;
			break;
		}
	}
	long tt = (long)n*(long)m/g;
	if(ok) {
		cout << tt << endl;
	} else {
		cout << "-1" << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:17: error: return-statement with no value, in function returning 'int' [-fpermissive]
   32 |                 return;
      |                 ^~~~~~
Language: C++

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

const int MAXN = 1e5 + 10;
int N, M;
char S[MAXN], T[MAXN];

int main() {
	scanf("%d%d", &N, &M); if(N < M) swap(N, M);
	gets(S + 1), gets(T + 1);
	printf("%lld\n", 1ll * N * M / __gcd(N, M));
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
   14 |         gets(S + 1), gets(T + 1);
      |         ^~~~
      |         getw
Language: C


#include<iostream>
#include<string>
#include<algorithm>
#include<complex>
#include<vector>

//lcmを求める用---------
#include <cmath>
#include <limits>
#include <numeric>
//-----------------------
using namespace std;

int nx[]={0,1,0,-1};
int ny[]={0,1,0,-1};
//*****************************************

int n,m,check,ans;
string S,T;
string s_n,s_m;

int gcd( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd

int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
//	if ( ( 0 == m ) || ( 0 == n ) )
//		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm

int lcm_inquiry(int n,int m,string S,string T){
    int nm_lcm=lcm(n,m);
    int n_div=nm_lcm/n;
    int m_div=nm_lcm/m;
    int lcm_match=lcm(n_div,m_div);
    int n_match=lcm_match/n_div;
    int m_match=lcm_match/m_div;

    int n_m_lim=n/n_match;
    int m_m_lim=m/m_match;

    for(int i=0 ; i<min(m_m_lim,n_m_lim) ; i++){
        int n_num=i*n_match;
        int m_num=i*m_match;
        
        //動作確認用
        //cout << S[n_num] << endl;
        //cout << T[m_num]  << endl;
        
        if(S[n_num]!=T[m_num])
        {
            check++;
            break;
        }
    }
    
    if(check>0)
    {
        return -1;
    }
    else
    {
        return nm_lcm;
    }
}


int main(void){
    cin >> n >> m;
    cin >> S;
    cin >> T;
    ans=lcm_inquiry(n,m,S,T);

    cout << ans << endl;
    return 0;
}





Compiler output:
main.c:2:9: fatal error: iostream: No such file or directory
    2 | #include<iostream>
      |         ^~~~~~~~~~
compilation terminated.
Language: C++

#include <stdio.h>
 
int main(void) {
	int n,m,l,lcm,tmp,r,a,b,count,i,p,ans;
	char s[100001];
	char t[100001];
	char x[100001];
	scanf("%d %d",&n,&m);
	gets(s);
	gets(t);
	a=n;                    //ここからn,mの最小公倍数を求める
	b=m;
	lcm=a*b;
	for(i=0;i<100001;i++){
		x[i]="1";
	}
	if(a<b){
		tmp=a;
		a=b;
		b=tmp;
	}
	r=a%b;
	while (r!=0){
		a=b;
		b=r;
		r=a%b;
	}
	lcm=lcm/b;           //最小公倍数
	for(l=1;p<100001;l++){
		p=l*lcm;
		count=0;
		for(i=0;i<n;i++){
			x[i*p/n]=s[i];
		}
		for(i=0;i<m;i++){
			if((x[i*p/m] != "1")&&(x[i*p/m] !=t[i])){
				count++;
			}else if(x[i*p/m] == "1"){
				x[i*p/m]=t[i];
			}
		}
		if(count==0){
			break;
		}
	}
	while(1){
		ans++;
		if(x[ans] =='\0') break;
	}
	printf("%d",ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
    9 |         gets(s);
      |         ^~~~
      |         getw
a.cc:15:22: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   15 |                 x[i]="1";
      |                      ^~~
      |                      |
      |                      const char*
a.cc:36:38: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   36 |                         if((x[i*p/m] != "1")&&(x[i*p/m] !=t[i])){
      |                             ~~~~~~~~~^~~~~~
a.cc:38:43: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   38 |                         }else if(x[i*p/m] == "1"){
      |                                  ~~~~~~~~~^~~~~~
Language: C


#include<iostream>
#include<string>
#include<algorithm>
#include<complex>
#include<vector>

//lcmを求める用---------
#include <cmath>
#include <limits>
#include <numeric>
//-----------------------
using namespace std;

int nx[]={0,1,0,-1};
int ny[]={0,1,0,-1};
//*****************************************

int n,m,check,ans;
string S,T;
string s_n,s_m;

//int lcm( int m, int n )
//{
	// 引数に０がある場合は０を返す
//	if ( ( 0 == m ) || ( 0 == n ) )
//		return 0;
	
//	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
//}lcm

int lcm_inquiry(int n,int m,string S,string T){
    int nm_lcm=lcm(n,m);
    int n_div=nm_lcm/n;
    int m_div=nm_lcm/m;
    int lcm_match=lcm(n_div,m_div);
    int n_match=lcm_match/n_div;
    int m_match=lcm_match/m_div;

    int n_m_lim=n/n_match;
    int m_m_lim=m/m_match;

    for(int i=0 ; i<min(m_m_lim,n_m_lim) ; i++){
        int n_num=i*n_match;
        int m_num=i*m_match;
        
        //動作確認用
        //cout << S[n_num] << endl;
        //cout << T[m_num]  << endl;
        
        if(S[n_num]!=T[m_num])
        {
            check++;
            break;
        }
    }
    
    if(check>0)
    {
        return -1;
    }
    else
    {
        return nm_lcm;
    }
}


int main(void){
    cin >> n >> m;
    cin >> S;
    cin >> T;
    ans=lcm_inquiry(n,m,S,T);

    cout << ans << endl;
    return 0;
}





Compiler output:
main.c:2:9: fatal error: iostream: No such file or directory
    2 | #include<iostream>
      |         ^~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <algorithm>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <cmath>
#include <limits>

#define pv(val) cerr << #val << '=' << (val) << endl
#define pvn(name, val) cerr << name << '=' << (val) << endl
#define pl cerr << '@' << __LINE__ << endl

#define int long long int

using namespace std;

template <class T>
ostream& operator<<(ostream& os, vector<T> const& vec) {
    if (vec.empty()) {
        os << "{}";
    } else {
        os << '{';
        for (size_t i = 0; i < vec.size() - 1; i++) os << vec[i] << ", ";
        os << vec.back() << '}';
    }
    return os;
}

template <class T, size_t S>
ostream& operator<<(ostream& os, array<T, S> const& arr) {
    if (arr.empty()) {
        os << "{}";
    } else {
        os << '{';
        for (size_t i = 0; i < arr.size() - 1; i++) os << arr[i] << ", ";
        os << arr.back() << '}';
    }
    return os;
}

template<class T, class U>
ostream& operator<<(ostream& os, pair<T, U> const& p) {
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

namespace math {
    int lcm(int m, int n)
    {
        if ((0 == m) || (0 == n))
            return 0;

        return ((m / __gcd(m, n)) * n);
    }
}

int main(void) {
    int N, M;
    cin >> N >> M;

    string S, T;
    cin >> S;
    cin >> T;
    if (N < M) {
        swap(N, M);
        swap(S, T);
    }

    int L = math::lcm(N, M);

    int a = L / N;
    int b = L / M;
    int c = math::lcm(a, b);
    pv(L);
    pv(a);
    pv(b);
    pv(c);

    if (c != L) {
        int x = c / a;
        int y = c / b;
        pv(x);
        pv(y);
        for (int i = 0; i < L / c; i++) {
            if (S[x * i] != T[y * i]) {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    cout << L << endl;

    return 0;
}

Compiler output:
a.cc:17:23: error: '::main' must return 'int'
   17 | #define int long long int
      |                       ^~~
a.cc:61:1: note: in expansion of macro 'int'
   61 | int main(void) {
      | ^~~
Language: C

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
 
int euku(int,int);
 
int main(){
  int i;
  int n,m;
  int p;
  int l=0;
 
  scanf("%d %d",&n,&m);
 
  char s[200001];
  char t[200001];
 
  scanf("%s",s);
  scanf("%s",t);
 
  if(s[0]!=t[0]){
    l++;
  }
  p = n*m/euku(n,m);
  char x[200001];
 
  for(i=0; i<=p-1; i++){
    x[p]='!';
  }
 
  if(l==0){
    if(p!=n && p!=m){
      l=0;
    }else{
      if(n>=m){
        for(i=0; i<=n-1; i++){
          x[i*p/n+1]=s[i];
        }
        for(i=0; i<=m-1; i++){
          if(x[i*p/m+1]!=t[i] && x[i*p/m+1]!='!'){
            l++;
          }
        }
      }else if(n<m){
        for(i=0; i<=m-1; i++){
          x[i*p/m+1]=t[i];
        }
        for(i=0; i<=n-1; i++){
          if(x[i*p/n+1]!=s[i] && x[i*p/n+1]!='!'){
            l++;
          }
        }
      }
    }
  }
  if(l==0){
    printf("%d\n",p);
  }else if(l>0){
    printf("-1\n");
  }
 
  return 0;
}
 
int euku(int a,int b){
  int r;
  if(a>=b){
    r = a % b;
    while(r!=0){
      a = b;
      b = r;
      r = a % b;
    }
    return b;
  }else{
    r = b % a;
    while(r!=0){
      b = a;
      a = r;
      r = b % a;
    }
    return a;
  }
}
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int euku(int,int);

int main(){
  int i;
  int n,m;
  int p;
  int l=0;

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

  char s[200001];
  char t[200001];

  scanf("%s",s);
  scanf("%s",t);

  if(s[0]!=t[0]){
    l++;
  }
  p = n*m/euku(n,m);
  char x[200001];

  for(i=0; i<=p-1; i++){
    x[p]='!';
  }

  if(l==0){
    if(p!=n && p!=m){
      l=0;
    }else{
      if(n>=m){
        for(i=0; i<=n-1; i++){
          x[i*p/n+1]=s[i];
        }
        for(i=0; i<=m-1; i++){
          if(x[i*p/m+1]!=t[i] && x[i*p/m+1]!='!'){
            l++;
          }
        }
      }else if(n<m){
        for(i=0; i<=m-1; i++){
          x[i*p/m+1]=t[i];
        }
        for(i=0; i<=n-1; i++){
          if(x[i*p/n+1]!=s[i] && x[i*p/n+1]!='!'){
            l++;
          }
        }
      }
    }
  }
  if(l==0){
    printf("%d\n",p);
  }else if(l>0){
    printf("-1\n");
  }

  return 0;
}

int euku(int a,int b){
  int r;
  if(a>=b){
    r = a % b;
    while(r!=0){
      a = b;
      b = r;
      r = a % b;
    }
    return b;
  }else{
    r = b % a;
    while(r!=0){
      b = a;
      a = r;
      r = b % a;
    }
    return a;
  }
}


Compiler output:
main.c:93:5: error: redefinition of 'main'
   93 | int main(){
      |     ^~~~
main.c:8:5: note: previous definition of 'main' with type 'int()'
    8 | int main(){
      |     ^~~~
main.c:151:5: error: redefinition of 'euku'
  151 | int euku(int a,int b){
      |     ^~~~
main.c:66:5: note: previous definition of 'euku' with type 'int(int,  int)'
   66 | int euku(int a,int b){
      |     ^~~~
Language: C

#include <stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<complex>
#include<vector>

//lcmを求める用---------
#include <cmath>
#include <limits>
#include <numeric>
//-----------------------
using namespace std;

int nx[]={0,1,0,-1};
int ny[]={0,1,0,-1};
//*****************************************

int n,m,check,ans;
string S,T;
string s_n,s_m;



int lcm_inquiry(int n,int m,string S,string T){
    int nm_lcm=lcm(n,m);
    int n_div=nm_lcm/n;
    int m_div=nm_lcm/m;
    int lcm_match=lcm(n_div,m_div);
    int n_match=lcm_match/n_div;
    int m_match=lcm_match/m_div;

    int n_m_lim=n/n_match;
    int m_m_lim=m/m_match;

    for(int i=0 ; i<min(m_m_lim,n_m_lim) ; i++){
        int n_num=i*n_match;
        int m_num=i*m_match;
        
        //動作確認用
        //cout << S[n_num] << endl;
        //cout << T[m_num]  << endl;
        
        if(S[n_num]!=T[m_num])
        {
            check++;
            break;
        }
    }
    
    if(check>0)
    {
        return -1;
    }
    else
    {
        return nm_lcm;
    }
}


int main(void){
    cin >> n >> m;
    cin >> S;
    cin >> T;
    ans=lcm_inquiry(n,m,S,T);

    cout << ans << endl;
    return 0;
}





Compiler output:
main.c:2:9: fatal error: iostream: No such file or directory
    2 | #include<iostream>
      |         ^~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include <numeric>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

typedef long long int ll;


//ユークリッド互除法
int gcd(int x,int y){

    if(y == 0){
        return x;
    }else{
        return gcd(y,x % y);
    }
}

/*最小公倍数*/
int lcm(int x,int y){
    int tmp = gcd(x,y);
    return x*y/tmp;
}


int main(){

    ll n,m;
    cin >> n >> m;
    string s,t;
    cin >> s >> t;
    ll tmp = lcm(n,m);
    if(s[0] != t[0]){
        cout << "-1" << endl;
        return 0;
    }

    string str1(tmp,'#');
    string str2(tmp,'#');
    str1[0] = str2[0] = s[0];

    for(int i = 1;i < n;i++){
        str1[i*tmp/n] = s[i];
    }
    for(int i = 1;i < m;i++){
        str2[i*tmp/m] = t[i];
    }
    bool ans = true;

    for(int i = 0;i < str1.size();i++){
        if(str[i] == '#' || str2[i] == '#'){
            continue;
        }

        if(str1[i] != str2[i]){
            ans = false;
            break;
        }

    }


    if(ans){
        cout << tmp << endl;
    }else{
        cout << "-1" << endl;
    }
    
    
   
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:71:12: error: 'str' was not declared in this scope; did you mean 'str2'?
   71 |         if(str[i] == '#' || str2[i] == '#'){
      |            ^~~
      |            str2
Language: C

#include <stdio.h>
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<complex>
#include<vector>

//lcmを求める用---------
#include <cmath>
#include <limits>
#include <numeric>
//-----------------------
using namespace std;

int nx[]={0,1,0,-1};
int ny[]={0,1,0,-1};
//*****************************************

int n,m,check,ans;
string S,T;
string s_n,s_m;

int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	//if ( ( 0 == m ) || ( 0 == n ) )
	//	return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm

int lcm_inquiry(int n,int m,string S,string T){
    int nm_lcm=lcm(n,m);
    int n_div=nm_lcm/n;
    int m_div=nm_lcm/m;
    int lcm_match=lcm(n_div,m_div);
    int n_match=lcm_match/n_div;
    int m_match=lcm_match/m_div;

    int n_m_lim=n/n_match;
    int m_m_lim=m/m_match;

    for(int i=0 ; i<min(m_m_lim,n_m_lim) ; i++){
        int n_num=i*n_match;
        int m_num=i*m_match;
        
        //動作確認用
        //cout << S[n_num] << endl;
        //cout << T[m_num]  << endl;
        
        if(S[n_num]!=T[m_num])
        {
            check++;
            break;
        }
    }
    
    if(check>0)
    {
        return -1;
    }
    else
    {
        return nm_lcm;
    }
}


int main(void){
    cin >> n >> m;
    cin >> S;
    cin >> T;
    ans=lcm_inquiry(n,m,S,T);

    cout << ans << endl;
    return 0;
}





Compiler output:
main.c:2:9: fatal error: cstdio: No such file or directory
    2 | #include<cstdio>
      |         ^~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <string>
#include <vector>
typedef long long LL;
using namespace std;
LL gcd(LL u, LL v) {
  LL r;
  while (0 != v) {
	  r = u % v; 
	  u = v; 
	  v = r; /* swap */
  }
  return u;
}
LL lcm(LL a, LL b){
	return  a*b/gcd(a, b);
}
int main(int argc, char* argv[])
{
	LL N,M;
	LL i;
	cin>>N>>M;
	
	string S,T;
	cin>>S;
	cin>>T;
	if (S[0]!=T[0]){
		cout<<-1<<endl;
		return 0;
	}

	LL L=lcm(N,M);
	char *X=new char[L];
	memset(X,'0',L);
	X[0]=S[0];
	LL ln=L/N;
	for (i=1;i<=N-1;i++){
		X[i*ln]=S[i];
	}
	LL lm=L/M;
	for (i=1;i<=M-1;i++){
		LL j=i*lm;
		if (X[j]=='0'){
			X[j]=T[i];
		}else if (X[j]!=T[i]){
			cout<<-1<<endl;
			return 0;
		}
	}
	cout<<L<<endl;
	delete[] X;
	return 0;
}

Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:34:9: error: 'memset' was not declared in this scope
   34 |         memset(X,'0',L);
      |         ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <vector>
  +++ |+#include <cstring>
    4 | typedef long long LL;
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <time.h>
#include <stdio.h>
#include <vector>
#define int long long
#define end getchar();getchar();return 0
int inf = 1000000000;
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}
int Max(int x, int y) {
	if (x > y)return x;
	else return y;
}
int Min(int x, int y) {
	if (x < y)return x;
	else return y;
}
int kai(int x) {
	int cnt = 1;
	if (x == 0)return 1;
	cnt = kai(x - 1);
	return x * cnt;
}
int prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
void prime_factor(int n) {
	int cnt = 1;
	map<int, int>res;
	int m = n;
	for (int i = 2; i <= n; i++) {
		if (prime(i)) {
			while (m%i == 0) {
				++res[i];
				m /= i;
			}
		}
	}
	cout << n << ":" << endl;
	for (int i = 2; i <= n; i++) {
		if (res[i]) {
			cout << i << " " << res[i] << endl;
		}
	}
	cout << endl;
}
/*Library End!*/
int n, m;
string s, t;
char u[10000000005];
bool b[10000000005];
signed main() {
	cin >> n >> m >> s >> t;
	int siz = lcm(n, m);
	for (int i = 0; siz / n * i < siz; i++) {
		u[siz / n * i] = s[i];
		b[siz/n*i]=true;
	}
	for (int i = 0; siz / m * i < siz; i++) {
		if (u[siz / m * i] != t[i] &&b[siz/m*i]) {
			cout << -1 << endl;
			end;
		}
	}
	cout << siz << endl;
	end;
}


Compiler output:
/tmp/cceWzm6z.o: in function `main':
a.cc:(.text+0x489): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/cceWzm6z.o
a.cc:(.text+0x513): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/cceWzm6z.o
collect2: error: ld returned 1 exit status