criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include<iostream>
#include<string>
#define ll unsignd int
using namespace std;


ll gcd(ll a,ll b){
  if(a<b){
    return gcd(b,a);
  }
  ll r;
  while((r=a%b)){
    a=b;
    b=r;
  }
  return b;
}

void solve(){
  ll N,M;
  string S,T;
  cin >>N>>M;
  cin >>S;
  cin >>T;
  ll g=gcd(N,M);
  ll n=N/g;
  ll m=M/g;

  for(ll k=0;k<g ;k++){
    if(S[k*n]!=T[k*m]){
      cout <<-1<<endl;
      return ;
    }
  }


  cout <<m*n*g<<endl;
}

int main(){
  solve();

  return 0;
}

Compiler output:
a.cc:3:12: error: 'unsignd' does not name a type; did you mean 'unsigned'?
    3 | #define ll unsignd int
      |            ^~~~~~~
a.cc:7:1: note: in expansion of macro 'll'
    7 | ll gcd(ll a,ll b){
      | ^~
a.cc: In function 'void solve()':
a.cc:3:12: error: 'unsignd' was not declared in this scope; did you mean 'unsigned'?
    3 | #define ll unsignd int
      |            ^~~~~~~
a.cc:20:3: note: in expansion of macro 'll'
   20 |   ll N,M;
      |   ^~
a.cc:22:9: error: 'N' was not declared in this scope
   22 |   cin >>N>>M;
      |         ^
a.cc:22:12: error: 'M' was not declared in this scope
   22 |   cin >>N>>M;
      |            ^
a.cc:3:20: error: expected ';' before 'int'
    3 | #define ll unsignd int
      |                    ^~~
a.cc:25:3: note: in expansion of macro 'll'
   25 |   ll g=gcd(N,M);
      |   ^~
a.cc:3:20: error: expected ';' before 'int'
    3 | #define ll unsignd int
      |                    ^~~
a.cc:26:3: note: in expansion of macro 'll'
   26 |   ll n=N/g;
      |   ^~
a.cc:3:20: error: expected ';' before 'int'
    3 | #define ll unsignd int
      |                    ^~~
a.cc:27:3: note: in expansion of macro 'll'
   27 |   ll m=M/g;
      |   ^~
a.cc:3:20: error: expected ';' before 'int'
    3 | #define ll unsignd int
      |                    ^~~
a.cc:29:7: note: in expansion of macro 'll'
   29 |   for(ll k=0;k<g ;k++){
      |       ^~
a.cc:29:14: error: 'k' was not declared in this scope
   29 |   for(ll k=0;k<g ;k++){
      |              ^
a.cc:29:16: error: 'g' was not declared in this scope
   29 |   for(ll k=0;k<g ;k++){
      |                ^
a.cc:30:12: error: 'n' was not declared in this scope
   30 |     if(S[k*n]!=T[k*m]){
      |            ^
a.cc:30:20: error: 'm' was not declared in this scope
   30 |     if(S[k*n]!=T[k*m]){
      |                    ^
a.cc:37:10: error: 'm' was not declared in this scope
   37 |   cout <<m*n*g<<endl;
      |          ^
a.cc:37:12: error: 'n' was not declared in this scope
   37 |   cout <<m*n*g<<endl;
      |            ^
a.cc:37:14: error: 'g' was not declared in this scope
   37 |   cout <<m*n*g<<endl;
      |              ^
Language: C++

#include<iostream>
#include<string>
#define ll unsingd int
using namespace std;


ll gcd(ll a,ll b){
  if(a<b){
    return gcd(b,a);
  }
  ll r;
  while((r=a%b)){
    a=b;
    b=r;
  }
  return b;
}

void solve(){
  ll N,M;
  string S,T;
  cin >>N>>M;
  cin >>S;
  cin >>T;
  ll g=gcd(N,M);
  ll n=N/g;
  ll m=M/g;

  for(ll k=0;k<g ;k++){
    if(S[k*n]!=T[k*m]){
      cout <<-1<<endl;
      return ;
    }
  }


  cout <<m*n*g<<endl;
}

int main(){
  solve();

  return 0;
}


Compiler output:
a.cc:3:12: error: 'unsingd' does not name a type; did you mean 'unsigned'?
    3 | #define ll unsingd int
      |            ^~~~~~~
a.cc:7:1: note: in expansion of macro 'll'
    7 | ll gcd(ll a,ll b){
      | ^~
a.cc: In function 'void solve()':
a.cc:3:12: error: 'unsingd' was not declared in this scope; did you mean 'unsigned'?
    3 | #define ll unsingd int
      |            ^~~~~~~
a.cc:20:3: note: in expansion of macro 'll'
   20 |   ll N,M;
      |   ^~
a.cc:22:9: error: 'N' was not declared in this scope
   22 |   cin >>N>>M;
      |         ^
a.cc:22:12: error: 'M' was not declared in this scope
   22 |   cin >>N>>M;
      |            ^
a.cc:3:20: error: expected ';' before 'int'
    3 | #define ll unsingd int
      |                    ^~~
a.cc:25:3: note: in expansion of macro 'll'
   25 |   ll g=gcd(N,M);
      |   ^~
a.cc:3:20: error: expected ';' before 'int'
    3 | #define ll unsingd int
      |                    ^~~
a.cc:26:3: note: in expansion of macro 'll'
   26 |   ll n=N/g;
      |   ^~
a.cc:3:20: error: expected ';' before 'int'
    3 | #define ll unsingd int
      |                    ^~~
a.cc:27:3: note: in expansion of macro 'll'
   27 |   ll m=M/g;
      |   ^~
a.cc:3:20: error: expected ';' before 'int'
    3 | #define ll unsingd int
      |                    ^~~
a.cc:29:7: note: in expansion of macro 'll'
   29 |   for(ll k=0;k<g ;k++){
      |       ^~
a.cc:29:14: error: 'k' was not declared in this scope
   29 |   for(ll k=0;k<g ;k++){
      |              ^
a.cc:29:16: error: 'g' was not declared in this scope
   29 |   for(ll k=0;k<g ;k++){
      |                ^
a.cc:30:12: error: 'n' was not declared in this scope
   30 |     if(S[k*n]!=T[k*m]){
      |            ^
a.cc:30:20: error: 'm' was not declared in this scope
   30 |     if(S[k*n]!=T[k*m]){
      |                    ^
a.cc:37:10: error: 'm' was not declared in this scope
   37 |   cout <<m*n*g<<endl;
      |          ^
a.cc:37:12: error: 'n' was not declared in this scope
   37 |   cout <<m*n*g<<endl;
      |            ^
a.cc:37:14: error: 'g' was not declared in this scope
   37 |   cout <<m*n*g<<endl;
      |              ^
Language: C++

#include<iostream>
#include<string>
#define ll long long
using namespace std;


ll gcd(ll a,ll b){
  if(a<b){
    return gcd(b,a);
  }
  ll r;
  while((r=a%b)){
    a=b;
    b=r;
  }
  return b;
}

void solve(){
  ll N,M;
  string S,T;
  cin >>N>>M;
  cin >>S;
  cin >>T;
  ll g=gcd(N,M);
  ll n=N/g;
  ll m=M/g;

  for(ll k=0;k<g ;k++){
    if(S[k*n]!=T[k*m]){
      cout <<-1<<endl;
      return ;
    }
  }


  cout <<m*n*g<<endl;
}

ll main(){
  solve();

  return 0;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5;
int n,m;
char s[maxn+10];
char t[maxn+10];
int main()
{
    while(cin>>n>>m)
    {
        scanf("%s",s+1);
        scanf("%s",t+1);
        int d=__gcd(n,m);
        ll maxx=1LL*nn*mm*d;
        int nn=maxx/d;
        int mm=maxx/d;
        bool flag=true;
        if(s[1]!=t[1])
        {
            puts("-1");
            continue;
        }
        ll sum=1LL*nn*mm+1;
        ll ci=1LL*max(nn,mm);
        for(ll i=1;i<=ci;i++)
        {
            //cout<<sum<<endl;
            if((sum-1)/nn +1>1LL*n || (sum-1)/mm+1>1LL*m)
            {
                break;
            }
            if(s[(sum-1)/nn +1]!=t[(sum-1)/mm +1])
            {
                flag=false;
                break;
            }
            sum+=1LL*nn*mm;
        }
        if(flag)
            printf("%lld\n",maxx);
        else
            puts("-1");

    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:21: error: 'nn' was not declared in this scope; did you mean 'yn'?
   15 |         ll maxx=1LL*nn*mm*d;
      |                     ^~
      |                     yn
a.cc:15:24: error: 'mm' was not declared in this scope; did you mean 'tm'?
   15 |         ll maxx=1LL*nn*mm*d;
      |                        ^~
      |                        tm
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
#define mod 1e9 + 7;
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}


int main()
{
	ios_base::sync_with_stdio(false);
	ll a, b, c, d, n, m, ret = 0;
	string s, t;
	//char ans[(ll)1e5 + 1];
	map<ll, char> ans;
	cin >> n >> m >> s >> t;
	ll x = lcm(n, m);
	if (n == 1 || m == 1) {
		if (s[0] == t[0]) cout << max(n, m)) << endl;
		else cout << "-1" << endl;
		return 0;
	}
	ans[0] = s[0];
	REP(i, 1, n) {
		ans[(x / n) * i] = s[i];
	}
	//cout << ans << endl;
	if (ans[0] != t[0]) {
		cout << "-1" << endl;
		//ok1
	}
	else {
		REP(i, 1, n) {
			if (!ans[(x / m) * i])continue;
			else if (ans[(x / m) * i] != t[i]) {
				cout << "-1" << endl;
				//ok2
				return 0;
			}
		}
		cout << x << endl;
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:70:52: error: expected ';' before ')' token
   70 |                 if (s[0] == t[0]) cout << max(n, m)) << endl;
      |                                                    ^
      |                                                    ;
Language: C++

#include<iostream>
#include<string>
#define ll long long
using namespace std;


ll gcd(ll a,ll b){
  if(a<b){
    return gcd(b,a);
  }
  ll r;
  while((r=a%b)){
    a=b;
    b=r;
  }
  return b;
}

void solve(){
  ll N,M;
  string S,T;
  cin >>N>>M;
  cin >>S;
  cin >>T;
  ll g=gcd(N,M);
  ll n=N/g;
  ll m=M/g;

  for(ll k=0;k<g ;k++){
    if(S[k*n]!=T[k*m]){
      cout <<-1<<endl;
      return ;
    }
  }


Compiler output:
a.cc: In function 'void solve()':
a.cc:34:4: error: expected '}' at end of input
   34 |   }
      |    ^
a.cc:19:13: note: to match this '{'
   19 | void solve(){
      |             ^
Language: Java

import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        long n=sc.nextLong();
        long m=sc.nextLong();
        String s=sc.next();
        String t=sc.next();
        long lcm=n/gcd(n,m)*m;
        HashMap<Integer,Character> mapS=new HashMap<>();
        HashMap<Integer,Character> mapT=new HashMap<>();
        for (long i = 0; i < n; i++) {
            mapS.put((int)(i*lcm/n+1),s.charAt((int)i));
        }
        for (long i = 0; i < m; i++) {
            mapT.put((int)(i*lcm/m+1),t.charAt((int)i));
        }
        for (long i = 1; i <= lcm; i++) {
            if(mapS.get((int)i)!=null&&mapT.get((int)i)!=null&&mapS.get((int)i)!=mapT.get((int)i)){
                out.println(-1);
                exit(0);
            }
        }
        out.println(lcm);
    }
    static long gcd (long a, long b) {
        long temp;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return b;
    }


Compiler output:
Main.java:36: error: reached end of file while parsing
    }
     ^
1 error
Language: C++

#include <bits/stdc++.h>
using namespace std;
long long gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
int main() {
    long long n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;
    long long l, a, x, y;
    a = gcd(n, m);
    l = (n * m) / a;
    x = n / a;
    y = m / a;
    bool ans = 1;
    for (long long i = 0; i < a; i++) {
        long long c = x * i, d = y * i;
        if (s[c] != t[d]) ans = 0;
    }
    if (ans == 1)
        cout << l << endl;
    else
        cout << "-1" << endl;
}


Compiler output:
a.cc:3:15: error: 'll' was not declared in this scope
    3 | long long gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
      |               ^~
a.cc:3:21: error: 'll' was not declared in this scope
    3 | long long gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
      |                     ^~
a.cc:3:25: error: expression list treated as compound expression in initializer [-fpermissive]
    3 | long long gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
      |                         ^
a.cc: In function 'int main()':
a.cc:10:9: error: reference to 'gcd' is ambiguous
   10 |     a = gcd(n, m);
      |         ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:58,
                 from a.cc:1:
/usr/include/c++/14/numeric:173:5: note: candidates are: 'template<class _Mn, class _Nn> constexpr std::common_type_t<_Mn, _Nn> std::gcd(_Mn, _Nn)'
  173 |     gcd(_Mn __m, _Nn __n) noexcept
      |     ^~~
a.cc:3:11: note:                 'long long int gcd'
    3 | long long gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
      |           ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
func gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
int main() {
    long long n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;
    long long l, a, x, y;
    a = gcd(n, m);
    l = (n * m) / a;
    x = n / a;
    y = m / a;
    bool ans = 1;
    for (long long i = 0; i < a; i++) {
        long long c = x * i, d = y * i;
        if (s[c] != t[d]) ans = 0;
    }
    if (ans == 1)
        cout << l << endl;
    else
        cout << "-1" << endl;
}


Compiler output:
a.cc:3:1: error: 'func' does not name a type
    3 | func gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
      | ^~~~
Language: Java

import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        long n=sc.nextLong();
        long m=sc.nextLong();
        String s=sc.next();
        String t=sc.next();
        long g=gcd(n,m);
        long lcm=n*m/g;
        for (long i = 0; i < g; i++) {
            if(s.charAt(i*n/g)!=t.charAt(i*m/g)){
                out.println(-1);
                exit(0);
            }
        }
        out.println(lcm);
    }
    static long gcd(long a,long b){
        long temp;
        while((temp=a%b)!=0){
            a=b;
            b=temp;
        }
        return b;
    }
}


Compiler output:
Main.java:15: error: incompatible types: possible lossy conversion from long to int
            if(s.charAt(i*n/g)!=t.charAt(i*m/g)){
                           ^
Main.java:15: error: incompatible types: possible lossy conversion from long to int
            if(s.charAt(i*n/g)!=t.charAt(i*m/g)){
                                            ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
2 errors
Language: C++

#include<iostream>
using namespace std;
int main(){
  long int N,M,k,l;
  cin>>N>>M;
  long char s[N],t[M];
  int LCM,gameover=0;
  for(int i=0;i<N;i++)
  {
    cin>>s[i];
  }
  for(int i=0;i<M;i++)
  {
    cin>>t[i];
  }
  if(M>=N){
  k=M;
  l=N;
}else {
  k=N;
  l=M;
  }
  while(k!=0&&l!=0){
    if(k>=l){
      k=k%l;
    }else{
      l=l%k;
    }
    }
    if(k==0){
      LCM=l;
    }else{
      LCM=k;
    }
if(M==LCM&&N==LCM){
  for(int i=0;i<M;i++){
    if(s[i]!=t[i]){
      gameover=1;
      break;
    }
  }
}else if(M==LCM){
  for(int i=0;i<M;i++){
    if(s[i*(N/M)]!=t[i]){
      gameover=1;
      break;
  }
}
}else if(N==LCM){
      for(int i=0;i<N;i++){
        if(s[i]!=t[i*(M/N)]){
          gameover=1;
          break;
      }
    }

  }else {
    if(s[0]!=t[0]){
      gameover=1;
    }
  }
  if(gameover==1){
    std::cout<<-1<<std::endl;
  }else{
    std::cout<<M*N/LCM<<std::endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:6:3: error: 'long' specified with 'char'
    6 |   long char s[N],t[M];
      |   ^~~~
a.cc:6:3: error: 'long' specified with 'char'
Language: C

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int gcd(int,int);
int lcm(int,int);
int min(int,int);
int max(int,int);

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

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

  unsigned char s[1000000];
  unsigned char t[1000000];

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

  if(s[0]!=t[0]){
    l++;
  }
  q = gcd(n,m);
  p = lcm(n,m);

    for(i=0; i<=q; i++){
      if(s[i*n/q]!=t[i*m/q]){
        l++;
      }
    }

  if(l==0){
    printf("%lf\n",p);
  }else if(l>0){
    printf("-1\n");
  }

  return 0;
}

int min(int m, int n){
  if(m >= n){
    return n;
  }else {
    return m;
  }
}

int max(int m, int n){
  if(m >= n){
    return m;
  }else {
    return n;
  }
}

int gcd(int m,int n){
  int i;
  int x;
  int a;
  x = min(m,n);
  for(i=1; i<=x; i++){
    if(m%i==0 && n%i==0){
      a = i;
    }
  }
  return a;
}

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


Compiler output:
main.c: In function 'main':
main.c:14:11: error: expected ';' before 'int'
   14 |   double p
      |           ^
      |           ;
   15 |   int q;
      |   ~~~      
main.c:30:3: error: 'p' undeclared (first use in this function)
   30 |   p = lcm(n,m);
      |   ^
main.c:30:3: note: each undeclared identifier is reported only once for each function it appears in
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;
  cin >>T;
  int g=gcd(N,M);
  int n=N/g;
  int m=M/g;
  int ans=0;
  for(int k=0;k<g && k++){
    if(S[k*n]!=T[k*m]){
      ans=-1;
      break;
    }
  }

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

int main(){
  solve();

  return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:28:25: error: expected ';' before ')' token
   28 |   for(int k=0;k<g && k++){
      |                         ^
      |                         ;
Language: C++

#include<iostream>
#include<string>
using namespace std;
long long gcd(long long a,long long b){
	if(a<b){
		long long temp =a;
		a=b;
		b=temp;
	}
	long long r=a%b;
	while (r!=0){
		a=b;
		b=r;
		r=a%b;
	}
	return b;
}
long long main(){
	long long n,m;
	cin >> n>>m;
	string s,t;
	cin >> s>>t;
	long long l,a,x,y;
	a=gcd(n,m);
	//l=(n*m)/a;
	//x=n/a;
	//y=m/a;
	bool ans=1;
	for (long long i=0;i<a;i++){
		//long long c=n/a*i,d=m/a*i;
	if(s[n/a*i]=!t[m/a*i])ans=0;
	}
	if(ans==1)cout << (n*m)/a<<endl;
	else cout << "-1"<<endl;
}
	


Compiler output:
cc1plus: error: '::main' must return 'int'
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;
  cin >>T;
  int g=gcd(N,M);
  int n=N/g;
  int m=M/g;
  int ans=0;
  for(int k=0;k<g && k++){
    if(S[k*n]!=T[k*m]){
      ans=-1;
      break;
    }
  }

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

int main(){
  solve();

  return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:28:25: error: expected ';' before ')' token
   28 |   for(int k=0;k<g && k++){
      |                         ^
      |                         ;
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
ll gcd(ll a,ll b)return b?gcd(b,a%b):a;
main(){
    ll n,m;
    string s,t;
    cin>>n>>m>>s>>t;
    ll g=gcd(n,m);
    for(ll i=0;i<g;i++)if(s[i*n/g]!=t[i*m/g]){
        cout<<-1;
        return 0;
    }
    cout<<n*m/g;
}

Compiler output:
a.cc: In function 'll gcd(ll, ll)':
a.cc:4:18: error: named return values are no longer supported
    4 | ll gcd(ll a,ll b)return b?gcd(b,a%b):a;
      |                  ^~~~~~
a.cc:15:1: warning: control reaches end of non-void function [-Wreturn-type]
   15 | }
      | ^
Language: C++

#include<iostream>
#include<string>
using namespace std;
int gcd(int a,int b){
	if(a<b){
		int temp =a;
		a=b;
		b=temp;
	}
	int 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 l,a,x,y;
	a=gcd(n,m);
	l=(n*m)/a;
	x=n/a;
	y=m/a;
	bool ans=1;
	for (int i=0;i<a;i++){
		int c=x*i+1;
		int d=y*i+1;
	if(s[c]=!t.at[d])ans=0;
	}
	if(ans==1)cout << l<<endl;
	else cout << "-1"<<endl;
}
	

Compiler output:
a.cc: In function 'int main()':
a.cc:32:22: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   32 |         if(s[c]=!t.at[d])ans=0;
      |                      ^
Language: C++

int main() {
    char s[100001], t[100001];
    int n, m, i, j, ans, lc, mi, ma;
    cin >> n >> m;
    for (i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (i = 0; i < m; i++) {
        cin >> t[i];
    }
    lc = lcm(n, m);
    mi = min(n, m);
    int a, b;
    a = n / lc; b = m / lc;
    int x, y;
    x = 0; y = 0;
    while (x*a <= n - 1) {
        x++;
    }
    x = x - 1;
    while (y*b <= m - 1) {
        y++;
    }
    y = y - 1;
    ma = min(x, y);
    int check = 1;
    for (i = 0; i <= ma; i++) {
        if (s[i*a] == t[i*b])check=check*1;
        else check = check*0;
    }
    if (check == 0) cout << -1 << endl;
    else cout << lc * a*b << endl;

}
新着メッセージ


Compiler output:
a.cc: In function 'int main()':
a.cc:4:5: error: 'cin' was not declared in this scope
    4 |     cin >> n >> m;
      |     ^~~
a.cc:11:10: error: 'lcm' was not declared in this scope; did you mean 'lc'?
   11 |     lc = lcm(n, m);
      |          ^~~
      |          lc
a.cc:12:10: error: 'min' was not declared in this scope; did you mean 'mi'?
   12 |     mi = min(n, m);
      |          ^~~
      |          mi
a.cc:31:21: error: 'cout' was not declared in this scope
   31 |     if (check == 0) cout << -1 << endl;
      |                     ^~~~
a.cc:31:35: error: 'endl' was not declared in this scope
   31 |     if (check == 0) cout << -1 << endl;
      |                                   ^~~~
a.cc:32:10: error: 'cout' was not declared in this scope
   32 |     else cout << lc * a*b << endl;
      |          ^~~~
a.cc:32:30: error: 'endl' was not declared in this scope
   32 |     else cout << lc * a*b << endl;
      |                              ^~~~
a.cc: At global scope:
a.cc:35:1: error: '\U000065b0\U00007740\U000030e1\U000030c3\U000030bb\U000030fc\U000030b8' does not name a type
   35 | 新着メッセージ
      | ^~~~~~~~~~~~~~
Language: C

#include <stdio.h>

int gcd(int u, int v) {
  int r;
  while (0 != v) {
    r = u % v; u = v; v = r; /* swap */
  }
  return u;
}
int main(){
  // get input
  int N;
  int M;
  scanf("%d",&N);
  scanf("%d",&M);
  char S[1000000];
  char T[1000000];
  
  scanf("%s", S);
  scanf("%s", T);
  
  //puts(S);
  //puts(T);
  
  // get gcd of N,M
  int C = std::gcd(N, M);
  int n = N/C;
  int m = M/C;
  // test
  int test = 1;
  for(int i = 0; i < C; i++){
    if(S[n*i] != T[m*i]){
      test = 0;
      break;
    }
  }
  // print result
  if(test == 1){
    printf("%ld", (long)N*(long)M/(long)C);
  }
  else printf("-1");
  
  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:26:11: error: 'std' undeclared (first use in this function)
   26 |   int C = std::gcd(N, M);
      |           ^~~
main.c:26:11: note: each undeclared identifier is reported only once for each function it appears in
main.c:26:14: error: expected ',' or ';' before '::' token
   26 |   int C = std::gcd(N, M);
      |              ^~
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;
  cin >>T;
  int g=gcd(N,M);
  int n=N/g;
  int m=M/g;
  bool judge=true;
  int ans=-1;
  for(int i=0;i<N && i<M;i++){
    if(S[i*n]!=T[i*m]){
      judge=false;
      break;
    }
  }

  if(judge==true){
    ans=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++

import math
N,M= list(map(int,input().split()))
S =input()
T=input()


L = N*M//math.gcd(N,M)

d = dict()

for i in range(N):
    print(1+(L//N)*i)
    index = 1+(L//N)*i
    d[index] = S[i]

for j in range(M):
    index = (1+(L//M)*j)
    if index in d:
        if d[index]!=T[j]:
            print(-1)
            exit()
print(L)




Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import math
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
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;
  cin >>T;
  int g=gcd(N,M);
  int n=N/g;
  int m=M/g;
  bool judge=true;
  int ans=-1;
  for(int i=0;i<N && i<M;i++){
    if(S[k*i*n]!=T[k*i*m]){
      judge=false;
      break;
    }
  }

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

int main(){
  solve();

  return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:30:10: error: 'k' was not declared in this scope
   30 |     if(S[k*i*n]!=T[k*i*m]){
      |          ^
a.cc:37:9: error: 'k' was not declared in this scope
   37 |     ans=k*m*n*g;
      |         ^
Language: C++

import math
n,m = map(int, input().split(' '))
s = input()
t = input()
g = math.gcd(n,m)
Flag = True
for i in range(n):
    if (m*i)%n == 0:
        if s[i] != t[int((i*m)/n)]:
            Flag = False
if Flag:
    print(int((n*m)/g))
else:
    print(-1)

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import math
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: Java

import java.util.*;

public class Main2 {

	public static void main(String[] args) {
		int ans = -1;
		boolean flag = false;
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		String S = sc.next();
		String T = sc.next();
		
		outside:{
			for(int i = 0 ; i<M*N ; i++) {
				if((i%M)==0) {
					if((i%N)==0) {
						char c1 = S.charAt(i%M);
						char c2 = S.charAt(i%N);
						String s1 = String.valueOf(c1);
						String s2 = String.valueOf(c2);
						if(!(s1.equals(s2))) {
							break outside;
						}
						
					}
				}
				
			}
			flag = true;
		}
		
		if(flag) {
			int temp;
			while((temp = N%M)!=0) {
				N = M;
				M = temp;
			}
			ans =  (int)(N);
		}
		
		System.out.println(ans);
		sc.close();
		

	}

}

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

#include<stdio.h>

int main(){
long int a,b,i,j,len,r,tmp,x,least,most,flag = 0;
char s[10^5],t[10^5];
;
scanf("%ld%ld",&a,&b);
scanf("%s%s",&s,&t);
//printf("%ld%ld",a,b);
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;
}
least = x/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;
 }
most = b;
for(i=1;i<(least/most);i=i*most){
  if(s[i] != t[i]){
    flage = 1;
  }
}
//printf("%s%s",&s,&t);
if(s[0]==t[0]){
  if(flag = 0)printf("%ld",least);//最小公倍数
  return 0;
  }else{
    printf("-1");
    return 0;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:5:10: warning: result of '10^5' is 15; did you mean '1e5'? [-Wxor-used-as-pow]
    5 | char s[10^5],t[10^5];
      |          ^
      |        ---
      |        1e
a.cc:5:8: note: you can silence this warning by using a hexadecimal constant (0xa rather than 10)
    5 | char s[10^5],t[10^5];
      |        ^~
      |        0xa
a.cc:5:18: warning: result of '10^5' is 15; did you mean '1e5'? [-Wxor-used-as-pow]
    5 | char s[10^5],t[10^5];
      |                  ^
      |                ---
      |                1e
a.cc:5:16: note: you can silence this warning by using a hexadecimal constant (0xa rather than 10)
    5 | char s[10^5],t[10^5];
      |                ^~
      |                0xa
a.cc:42:5: error: 'flage' was not declared in this scope; did you mean 'flag'?
   42 |     flage = 1;
      |     ^~~~~
      |     flag
Language: C++

#include <iostream>
#include <string>
#include <numeric>
using namespace std;
int main() {
  int n,m = 0;
  string s,t;
  cin >> n >> m >> s >> t;
  int l = 0;
  l = lcm(n, m);
  if (s[0]==t[0] && l != 0){
    char x[l];
    int z = 0;
    for (int i=0;i<n;i++){
      int a = (i-1)*(l/i)+1;
      x[a] = s[i];
    }
    for (int j=0;j<m;j++){
      a = (j-1)*(l/j)+1;
      if(x[a]!=0){
        x[a] = t[j];
      }else{
        z = -1;
      }
    }
  }else{
    z = -1;
  }
  if (z == 0){
    cout << l << endl;
  }else {
    cout << z << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:7: error: 'a' was not declared in this scope
   19 |       a = (j-1)*(l/j)+1;
      |       ^
a.cc:27:5: error: 'z' was not declared in this scope
   27 |     z = -1;
      |     ^
a.cc:29:7: error: 'z' was not declared in this scope
   29 |   if (z == 0){
      |       ^
Language: C++

#include<stdio.h>

int main(){
long int a,b,i,j,len,r,tmp,x,least,most;
char s[10^5],t[10^5];
int bool flag = true;
scanf("%ld%ld",&a,&b);
scanf("%s%s",&s,&t);
//printf("%ld%ld",a,b);
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;
}
least = x/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;
 }
most = b;
for(i=1;i<(least/most);i=i*most){
  if(s[i] != t[i]){
    flage = false;
  }
}
//printf("%s%s",&s,&t);
if(s[0]==t[0]){
  if(flag = true)printf("%ld",least);//最小公倍数
  return 0;
  }else{
    printf("-1");
    return 0;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:5:10: warning: result of '10^5' is 15; did you mean '1e5'? [-Wxor-used-as-pow]
    5 | char s[10^5],t[10^5];
      |          ^
      |        ---
      |        1e
a.cc:5:8: note: you can silence this warning by using a hexadecimal constant (0xa rather than 10)
    5 | char s[10^5],t[10^5];
      |        ^~
      |        0xa
a.cc:5:18: warning: result of '10^5' is 15; did you mean '1e5'? [-Wxor-used-as-pow]
    5 | char s[10^5],t[10^5];
      |                  ^
      |                ---
      |                1e
a.cc:5:16: note: you can silence this warning by using a hexadecimal constant (0xa rather than 10)
    5 | char s[10^5],t[10^5];
      |                ^~
      |                0xa
a.cc:6:1: error: two or more data types in declaration of 'flag'
    6 | int bool flag = true;
      | ^~~
a.cc:42:5: error: 'flage' was not declared in this scope
   42 |     flage = false;
      |     ^~~~~
a.cc:47:6: error: 'flag' was not declared in this scope
   47 |   if(flag = true)printf("%ld",least);//最小公倍数
      |      ^~~~
Language: Java

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int M = scanner.nextInt();
        scanner.nextLine();
        String S = scanner.nextLine();
        String T = scanner.nextLine();

        long lcm = lcm(N, M);
        long n = lcm / N;
        long m = lcm / M;
        char[] sArray = S.toCharArray();
        char[] tArray = T.toCharArray();
        long nm = n * m;
        for (long i = 0; i < lcm; i+=nm) {
            if (sArray[i/n] != tArray[i/m]) {
                System.out.println(-1);
                return;
            }
        }

        System.out.println(lcm);
    }

    static long lcm (long a, long b) {
        long temp;
        long c = a;
        c *= b;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return (long)(c/b);
    }


}


Compiler output:
Main.java:21: error: incompatible types: possible lossy conversion from long to int
            if (sArray[i/n] != tArray[i/m]) {
                        ^
Main.java:21: error: incompatible types: possible lossy conversion from long to int
            if (sArray[i/n] != tArray[i/m]) {
                                       ^
2 errors
Language: C++

#include<stdio.h>

int main(){
long int a,b,i,j,len,r,tmp,x,least,most;
char s[10^5],t[10^5];
bool flag = true;
scanf("%ld%ld",&a,&b);
scanf("%s%s",&s,&t);
//printf("%ld%ld",a,b);
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;
}
least = x/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;
 }
most = b;
for(i=1;i<(least/most);i=i*most){
  if(s[i] != t[i]){
    flage = false;
  }
}
//printf("%s%s",&s,&t);
if(s[0]==t[0]){
  if(flag = true)printf("%ld",least);//最小公倍数
  return 0;
  }else{
    printf("-1");
    return 0;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:5:10: warning: result of '10^5' is 15; did you mean '1e5'? [-Wxor-used-as-pow]
    5 | char s[10^5],t[10^5];
      |          ^
      |        ---
      |        1e
a.cc:5:8: note: you can silence this warning by using a hexadecimal constant (0xa rather than 10)
    5 | char s[10^5],t[10^5];
      |        ^~
      |        0xa
a.cc:5:18: warning: result of '10^5' is 15; did you mean '1e5'? [-Wxor-used-as-pow]
    5 | char s[10^5],t[10^5];
      |                  ^
      |                ---
      |                1e
a.cc:5:16: note: you can silence this warning by using a hexadecimal constant (0xa rather than 10)
    5 | char s[10^5],t[10^5];
      |                ^~
      |                0xa
a.cc:42:5: error: 'flage' was not declared in this scope; did you mean 'flag'?
   42 |     flage = false;
      |     ^~~~~
      |     flag
Language: C

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int gcd(int,int);
int lcm(int,int);
int min(int,int);
int max(int,int);

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

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

  unsigned char s[100001];
  unsigned char t[100001];

  scanf("%s",s);
  scanf("%s",t);
  //printf("%s\n",s);

  if(s[0]!=t[0]){
    l++;
  }
  q = gcd(n,m);
  p = lcm(n,m);
  unsigned char x[1000001];

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

  if(l==0){

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

  return 0;
}

int min(int m, int n){
  if(m >= n){
    return n;
  }else {
    return m;
  }
}

int max(int m, int n){
  if(m >= n){
    return m;
  }else {
    return n;
  }
}

int gcd(int m,int n){
  int i;
  int x;
  int a;
  x = min(m,n);
  for(i=1; i<=x; i++){
    if(m%i==0 && n%i==0){
      a = i;
    }
  }
  return a;
}

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


Compiler output:
main.c: In function 'main':
main.c:32:17: error: conflicting types for 'x'; have 'unsigned char[1000001]'
   32 |   unsigned char x[1000001];
      |                 ^
main.c:12:7: note: previous declaration of 'x' with type 'int'
   12 |   int x,y;
      |       ^
Language: C++

#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define _printV(vec) for(int i = 0; i < SZ(vec); i++){cout << vec[i];if (i==SZ(vec)-1){cout<<endl;}else{cout << " ";}}
#define printV(vec) cout<<#vec<<":";_printV(vec)
#define _printA(arr,n) for(int i = 0; i < n; i++){cout << arr[i];if (i==n-1){cout<<endl;}else{cout << " ";}}
#define printA(arr) cout<<#arr<<":";_printA(arr,sizeof(arr)/sizeof(arr[0]))
#define LLINF = (1LL<<62)
#define puts(var) cout<<#var<<":"<<var<<" "
typedef long long ll;
int gcd(int a, int b) {
	if (a < b)swap(a, b);
	while (b) {
		a %= b;
		swap(a, b);
	}
	return a;
}
ll lcm( int m, int n )
{
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	return ((m / gcd(m, n)) * n);
}
 
 
int main()
{
  ll N,M;
  cin >> N >> M;
  string S;
  string T;
  cin >> S;
  cin >> T;
 
  ll L = lcm(N, M);
 
  ll step = gcd(N,M);
  // cout << step << endl;
  REP(i,step){
    // printf("===== i %d\n",i);
    // cout << L/M <<endl;
    // cout <<"S:" << S[i*N/step] << endl;
    // cout << L/N <<endl;
    // cout <<"T:" << T[i*M/step] << endl;
    if(S[i*L/M] != T[i*L/N]){
      printf("-1");
      return 0;
    }
  }
  // printf("%lld",L);
  printf("-1")
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:63:15: error: expected ';' before 'return'
   63 |   printf("-1")
      |               ^
      |               ;
   64 |   return 0;
      |   ~~~~~~
Language: C++

#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

bool num[10000000001] = {};

ll n, m;
string s, t;

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

int main() {
	cin >> n >> m;
	cin >> s >> t;

	ll L = lcm(n, m);
	for (int i = 0; i < n; i++) {
		num[i * L / n + 1] = true;
	}

	vector<int> a;
	for (int j = 0; j < m; j++) {
		if (num[j * L / m + 1]) {
			a.push_back(j * L / m + 1);
		}
	}

	for (int k = 0; k < (int)a.size(); k++) {
		int i = (n * (a[k] - 1)) / L;
		int j = (m * (a[k] - 1)) / L;
		if (s[i] != t[j]) {
			cout << -1 << endl;
			return 0;
		}
	}

	cout << L << endl;
	return 0;
}

Compiler output:
/tmp/ccci8mNt.o: in function `main':
a.cc:(.text+0x7d): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccci8mNt.o
a.cc:(.text+0x99): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/ccci8mNt.o
a.cc:(.text+0xab): relocation truncated to fit: R_X86_64_PC32 against symbol `s[abi:cxx11]' defined in .bss section in /tmp/ccci8mNt.o
a.cc:(.text+0xc7): relocation truncated to fit: R_X86_64_PC32 against symbol `t[abi:cxx11]' defined in .bss section in /tmp/ccci8mNt.o
a.cc:(.text+0xd9): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/ccci8mNt.o
a.cc:(.text+0xe0): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccci8mNt.o
a.cc:(.text+0x109): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccci8mNt.o
a.cc:(.text+0x12e): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccci8mNt.o
a.cc:(.text+0x159): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/ccci8mNt.o
a.cc:(.text+0x182): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/ccci8mNt.o
a.cc:(.text+0x1b1): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>

using namespace std;

void main()
{
	int n,m;

	cin >> n >> m;

	char *s, *t;
	s = new char[n];
	t = new char[m];

	cin >> s >> t;

	if (s[0] != t[0])
	{
		cout << -1 << endl;
	}
	else
	{
		int leastMulti = 1;
		int bigger;

		bigger = (n > m) ? n : m;

		int n_ = n, m_ = m;

		// 最小公倍数を求める
		for (int i = 2; i <= bigger; ++i)
		{
			bool notDivisor;
			do
			{
				notDivisor = true;
				if (n_ % i == 0)
				{
					n_ /= i;
					notDivisor = false;
				}
				if (m_ % i == 0)
				{
					m_ /= i;
					notDivisor = false;
				}
				if (!notDivisor)
					leastMulti *= i;
			} while (!notDivisor);
		}

		int l = leastMulti;
		int lPerN = l / n, lPerM = l / m;

		int i, j;
		i = j = 1;

		bool result = true;

		while (i < n && j < m)
		{
			while (i * lPerN != j * lPerM)
			{
				if (i * lPerN < j * lPerM)
					++i;
				else if(i * lPerN > j * lPerM)
					++j;
			}

			if (i < n&&j < m)
			{
				result = (s[i * lPerN] == t[j * lPerM]) ? true : false;
			}

			++i;
		}

		if (result)
			cout << leastMulti << endl;
		else
			cout << -1;
	}
  
  return 0;
}


Compiler output:
a.cc:5:1: error: '::main' must return 'int'
    5 | void main()
      | ^~~~
Language: C++

#include<stdio.h>

int main(){
long int a,b,i,j,len,r,tmp,x,least,most,;
char s[10^5],t[10^5];
scanf("%ld%ld",&a,&b);
scanf("%s%s",&s,&t);
//printf("%ld%ld",a,b);
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;
}
least = x/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;
 }
most = b;

//printf("%s%s",&s,&t);
if(s[0]==t[0]){
  printf("%ld",least);//最小公倍数
  return 0;   
  }else{
    printf("-1");
    return 0;
  } 
}


Compiler output:
a.cc: In function 'int main()':
a.cc:4:41: error: expected unqualified-id before ';' token
    4 | long int a,b,i,j,len,r,tmp,x,least,most,;
      |                                         ^
a.cc:5:10: warning: result of '10^5' is 15; did you mean '1e5'? [-Wxor-used-as-pow]
    5 | char s[10^5],t[10^5];
      |          ^
      |        ---
      |        1e
a.cc:5:8: note: you can silence this warning by using a hexadecimal constant (0xa rather than 10)
    5 | char s[10^5],t[10^5];
      |        ^~
      |        0xa
a.cc:5:18: warning: result of '10^5' is 15; did you mean '1e5'? [-Wxor-used-as-pow]
    5 | char s[10^5],t[10^5];
      |                  ^
      |                ---
      |                1e
a.cc:5:16: note: you can silence this warning by using a hexadecimal constant (0xa rather than 10)
    5 | char s[10^5],t[10^5];
      |                ^~
      |                0xa
Language: Java


public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int M = scanner.nextInt();
        scanner.nextLine();
        String S = scanner.nextLine();
        String T = scanner.nextLine();

        long lcm = lcm(N, M);
        int n = (int)(lcm / N);
        int m = (int)(lcm / M);

        for (int i = 0; i < lcm; i+=n) {
            if (i % m == 0) {
                if (S.charAt(i/n) != T.charAt(i/m)) {
                    System.out.println(-1);
                    return;
                }
            }
        }
        for (int i = 0; i < lcm; i+=m) {
            if (i % n == 0) {
                if (S.charAt(i/n) != T.charAt(i/m)) {
                    System.out.println(-1);
                    return;
                }
            }
        }

        System.out.println(lcm);
    }

    static long lcm (long a, long b) {
        long temp;
        long c = a;
        c *= b;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return (long)(c/b);
    }


}


Compiler output:
Main.java:5: error: cannot find symbol
        Scanner scanner = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Main
Main.java:5: error: cannot find symbol
        Scanner scanner = new Scanner(System.in);
                              ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: C++

    cin.tie();
    ios::sync_with_stdio(false);

    // input
    int N, M;
    string S, T;
    cin >> N >> M;
    cin >> S >> T;
    
    // calculation
    long long multi = lcm(N, M);
    //cout << multi << "\n";
    
    int i = 1;
    bool flag = false;
    int min_len = min(N, M);
    while (multi <= 10000000000) {
        vector<int> vec_s(min_len), vec_t(min_len);
        REP(j, min_len) {
            vec_s.at(j) = 1 + (multi/N) * j;
            vec_t.at(j) = 1 + (multi/M) * j;
        }
        
        // intersection
        std::vector<unsigned int> list_inter; //list1とlist2の両方にある値 (積集合)
        std::set_intersection(ALL(vec_s), ALL(vec_t), std::back_inserter(list_inter));
        int size = list_inter.size();
        
        // process
        if (S.at(0) != T.at(0)) {
            break;
        } else if (size > 0) {
            REP(ii, size) {
                int idx = list_inter.at(ii);
                auto iter_s = find(ALL(vec_s), idx), iter_t = find(ALL(vec_t), idx);
                size_t idx_s = distance(vec_s.begin(), iter_s), idx_t = distance(vec_t.begin(), iter_t);
                if (S.at(idx_s) != T.at(idx_t)) break;
                if (ii == size-1) {
                    flag = true;
                    break;
                }
            }
        } else {
            flag = true;
            break;
        }
        
        if (flag) {
            break;
        }
        
        // update
        i++;
        multi *= i;
        
    }
    
    if (flag) {
        cout << multi << "\n";
    } else{
        cout << -1 << "\n";
    }
    
    return 0;


Compiler output:
a.cc:1:5: error: 'cin' does not name a type
    1 |     cin.tie();
      |     ^~~
a.cc:2:5: error: 'ios' does not name a type
    2 |     ios::sync_with_stdio(false);
      |     ^~~
a.cc:6:5: error: 'string' does not name a type
    6 |     string S, T;
      |     ^~~~~~
a.cc:7:5: error: 'cin' does not name a type
    7 |     cin >> N >> M;
      |     ^~~
a.cc:8:5: error: 'cin' does not name a type
    8 |     cin >> S >> T;
      |     ^~~
a.cc:11:23: error: 'lcm' was not declared in this scope
   11 |     long long multi = lcm(N, M);
      |                       ^~~
a.cc:16:19: error: 'min' was not declared in this scope
   16 |     int min_len = min(N, M);
      |                   ^~~
a.cc:17:5: error: expected unqualified-id before 'while'
   17 |     while (multi <= 10000000000) {
      |     ^~~~~
a.cc:58:5: error: expected unqualified-id before 'if'
   58 |     if (flag) {
      |     ^~
a.cc:60:7: error: expected unqualified-id before 'else'
   60 |     } else{
      |       ^~~~
a.cc:64:5: error: expected unqualified-id before 'return'
   64 |     return 0;
      |     ^~~~~~
Language: C

#include <stdio.h>

int U(int x,int y){
	if(x>y){
		x=x-y;
		if(x==y){
			return x;
		}
		U(x,y);
	}else{
		y=y-x;
		if(x==y){
			return y;
		}
		U(x,y);
	}
}

int main(){
	int N,M,L,l;
	int flag=0;
	char S[100000],T[100000];
	int n,m,nm,n1,m1;
	int a,b;
	int i;
	scanf("%d%d",&N,&M);
	scanf("%s",S);
	scanf("%s",T);
	
	a=N;
	b=M;
	
	if(a<b){
		tmp = b;
		a = b;
		b = tmp;
	}
	
	r = a % b;
	while(r!=0){
		a = b;
		b = r;
		r = a % b;
	}
	l=r;

	
	L=N*M/l;
	n=N/l;
	m=M/l;
	
	
	n1=0;
	m1=0;
	
	
	for(;;){
		if(m1>=M){
			break;
		}
		
		if(n1>=N){
			break;
		}
		
		if(S[n1]==T[m1]){
			
		}else{
			flag=1;
			break;
		}
		n1=n1+n;
		m1=m1+m;
	}
	
	if(flag==0){
		printf("%d",L);
	}else{
		printf("-1");
	}
	
	return 0;
}



Compiler output:
main.c: In function 'main':
main.c:34:17: error: 'tmp' undeclared (first use in this function)
   34 |                 tmp = b;
      |                 ^~~
main.c:34:17: note: each undeclared identifier is reported only once for each function it appears in
main.c:39:9: error: 'r' undeclared (first use in this function)
   39 |         r = a % b;
      |         ^