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

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

long long GCD(long long A, long long B)
{
  long long a = A, b = B;
  while (a * b != 0  &&  a != 1  &&  b != 1)
  {
    if (a < b) b %= a;
    else a %= b;
  }
  if (a * b == 0) return max(a, b);
  else return 1;
}

long long LCM(long long A, long long B)
{
  return A * B / GCD(A, B);
}

long long main()
{
  long long N, M;
  string S, T;
  cin >> N >> M >> S >> T;
  
  long long G = GCD(N, M), L = LCM(N, M);
  long long n = N / G, m = M / G;
  long long ans = L;
  for (long long i = 0; i < G; i++)
  {
    if (S.at(n * i) != T.at(m * i))
    {
      ans = -1;
      break;
    }
  }
  
  cout << ans << endl;
}

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

#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

ll gcd(ll x,ll y){
if(x==0) return y;
return gcd(y%x, x);
}
ll lcm(ll x,ll y) {return x*y/gcd(x,y);}

int main() {
  ll n,m; cin>>n>>m;
  ll len=gcd(n,m);
  int zz[len]={0};
  string s,t;
  cin>>s>>t;
    bool clear=true;
  
  if(n>=m){
  for(int i=0;i<=n-1;i++){
    zz[1+i*len/n]=s[1+i*len/n];
  }
  for(int i=0;i<=m-1;i++){
    if(zz[1+i*len/m]!=0){
      if(zz[1+i*len/m]!=t[1+i*len/m]){
        clear=false;}
    }
  }
    
      else{
  for(int i=0;i<=m-1;i++){
    zz[1+i*len/m]=s[1+i*len/m];
  }
  for(int i=0;i<=n-1;i++){
    if(zz[1+i*len/n]!=0){
      if(zz[1+i*len/n]!=t[1+i*len/n]){
        clear=false;}
    }
  }
    
    
    
    
        if(clear)cout<<len<<endl;
  else cout<<-1<<endl;
   
  }
  
  
  
  
  

  
  
  
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:32:7: error: expected '}' before 'else'
   32 |       else{
      |       ^~~~
a.cc:21:11: note: to match this '{'
   21 |   if(n>=m){
      |           ^
Language: C++

#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

ll gcd(ll x,ll y){
if(x==0) return y;
return gcd(y%x, x);
}
ll lcm(ll x,ll y) {return x*y/gcd(x,y);}

int main() {
  ll n,m; cin>>n>>m;
  ll len=gcd(n,m);
  int zz[len]={0};
  string s,t;
  cin>>s>>t;
    bool clear=true;
  
  if(n>=m){
  for(int i=0,i<=n-1;i++){
    zz[1+i*len/n]=s[1+i*len/n];
  }
  for(int i=0,i<=m-1;i++){
    if(zz[1+i*len/m]!=0){
      if(zz[1+i*len/m]!=t[1+i*len/m]){
        clear=false;}
    }
  }
    
      else{
  for(int i=0,i<=m-1;i++){
    zz[1+i*len/m]=s[1+i*len/m];
  }
  for(int i=0,i<=n-1;i++){
    if(zz[1+i*len/n]!=0){
      if(zz[1+i*len/n]!=t[1+i*len/n]){
        clear=false;}
    }
  }
    
    
    
    
        if(clear)cout<<len<<endl;
  else cout<<-1<<endl;
   
  }
  
  
  
  
  

  
  
  
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:16: error: expected ';' before '<=' token
   22 |   for(int i=0,i<=n-1;i++){
      |                ^~
      |                ;
a.cc:22:16: error: expected primary-expression before '<=' token
   22 |   for(int i=0,i<=n-1;i++){
      |                ^~
a.cc:25:16: error: expected ';' before '<=' token
   25 |   for(int i=0,i<=m-1;i++){
      |                ^~
      |                ;
a.cc:25:16: error: expected primary-expression before '<=' token
   25 |   for(int i=0,i<=m-1;i++){
      |                ^~
a.cc:32:7: error: expected '}' before 'else'
   32 |       else{
      |       ^~~~
a.cc:21:11: note: to match this '{'
   21 |   if(n>=m){
      |           ^
a.cc:33:16: error: expected ';' before '<=' token
   33 |   for(int i=0,i<=m-1;i++){
      |                ^~
      |                ;
a.cc:33:16: error: expected primary-expression before '<=' token
   33 |   for(int i=0,i<=m-1;i++){
      |                ^~
a.cc:36:16: error: expected ';' before '<=' token
   36 |   for(int i=0,i<=n-1;i++){
      |                ^~
      |                ;
a.cc:36:16: error: expected primary-expression before '<=' token
   36 |   for(int i=0,i<=n-1;i++){
      |                ^~
Language: C++

#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define INF 1e9
typedef long long llong;
using namespace std;
#define int llong

int gcd(int x,int y){
	if(x>y) std::swap(x,y);
	return y%x==0?x:gcd(y%x,x);
}

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

int main(){
	int n,m;
	cin>>n>>m;
	string s,t;
	cin>>s>>t;
	
	int l=lcm(n,m);
	vector<pair<int,char> > ss,tt;
	for(int i=1;i<=n;++i){
		pair<int,char> tmp=make_pair((i-1)*(l/n)+1,s[i-1]);
		ss.push_back(tmp);
	}
	for(int i=1;i<=m;++i){
		pair<int,char> tmp=make_pair((i-1)*(l/m)+1,t[i-1]);
		tt.push_back(tmp);
	}

	ss.insert(ss.end(),ALL(tt));//point.
	sort(ALL(ss));
	bool jud=true;
	REP(i,ss.size()-1){
		if(ss[i].first==ss[i+1].first){
			if(ss[i].second!=ss[i+1].second){
				jud=false;
				break;
			}
		}
	}
	
	if(jud) cout<<l<<endl;
	else cout<<-1<<endl;
	return 0;
}//解説参考.

Compiler output:
a.cc:7:13: error: '::main' must return 'int'
    7 | #define int llong
      |             ^~~~~
a.cc:19:1: note: in expansion of macro 'int'
   19 | int main(){
      | ^~~
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cmath>
#include<iomanip>
#include<set>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
//const int inf = 1e9 + 7;
#define int ll
int gcd(int a, int b) {
    if (a < b) swap(a, 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; cin >> n >> m;
    string s, t; cin >> s >> t;
    string u; rep(i, lcm(n, m)) u += '1';
    int l = (int)u.size();
    int flg = 0;
    rep(i, n) if (u[l / n * i] == '1' || u[l / n * i] == s[i]) u[l / n * i] = s[i]; else {flg = 1; break;}
    rep(i, m) if (u[l / m * i] == '1' || u[l / m * i] == t[i]) u[l / m * i] = t[i]; else {flg = 1; break;}
    if (flg == 1) cout << -1 << endl;
    else cout << lcm(n, m) << endl;
}


Compiler output:
a.cc:16:13: error: '::main' must return 'int'
   16 | #define int ll
      |             ^~
a.cc:25:1: note: in expansion of macro 'int'
   25 | int main() {
      | ^~~
Language: C++

#include <iostream>
using namespace std;
#define int long long


int N,M;
string S,T;

int gcd(int u, int v){
	int r;
  	while (0 != v) {
    	r = u % v; u = v; v = r; 
  	}
  	return u;
}

int lcm(int u, int v){
	return u * v / gcd(u,v);
}

int solve(){
	int X = gcd(M,N);
	int Y = lcm(M,N);
	N /= X;
	M /= X;
	for(int i = 0; i < X; i++){
		if(S[N*i] != T[M*i]){
			cout << -1 << endl;
			return 0;
		}
	}
	cout << Y << endl;
	return 0;
}

int main(){
	cin >> N >> M;
	cin >> S;
	cin >> T;
	solve();
	return 0;
}

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

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

int gcd(int n, int m){
  int x;
  while(true){
      x = m;
      m = n%m;
      n = x;
      if (m == 0)
        break;
  }return n;
}

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

int main(){
  int n,m;
  char s,t;
  cin>>n>>m;
  cin>>s>>t;
  int l = lcm(n,m);
  int g = gcd(n,m);
  int n_g = n/g;
  int m_g = m/g;
  for (int i = 0; i<g;i++){
    if (s[i*n_g] != t[i*m_g]){
      l = -1;
      break;
    }
  }cout<<l<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:10: error: invalid types 'char[int]' for array subscript
   32 |     if (s[i*n_g] != t[i*m_g]){
      |          ^
a.cc:32:22: error: invalid types 'char[int]' for array subscript
   32 |     if (s[i*n_g] != t[i*m_g]){
      |                      ^
Language: C++

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
signed main() {
	int n, m;
	string s, t;
	cin >> n >> m >> s >> t;
	cout << lcm(n, m) << endl;
	getchar(); getchar(); return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:17: error: 'lcm' was not declared in this scope
   14 |         cout << lcm(n, m) << endl;
      |                 ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
  if(a<b) swap(a,b);
  if(a%b==0) return b;
  else gcd(b,a%b);
}
int main(){
  int n,m;
  string s,t;
  cin>>n>>m>>s>>t;
  int g=gcd(n,m);
  bool f=false;
  for(int i=0;i<n/g;i++){
    if(s[i+n/g*i]!=b[i+m/g*i]){
      f=true;
      break;
    }
  }
  if(f) cout<<-1;
  else cout<<n/g*m;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:20: error: 'b' was not declared in this scope
   15 |     if(s[i+n/g*i]!=b[i+m/g*i]){
      |                    ^
a.cc: In function 'int gcd(int, int)':
a.cc:6:11: warning: control reaches end of non-void function [-Wreturn-type]
    6 |   else gcd(b,a%b);
      |        ~~~^~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
  if(a<b) swap(a,b);
  if(a%b) return gcd(b,a%b);
  else return b;
}
int main(){
  int a,b;
  string s,t,c,d;
  cin>>a>>b>>s>>t;
  int g=gcd(a,b);
  for(int i=0;i<a;i+=a/g) c.push_back(s[i]);
  for(int j=0;j<b;j+=b/g) d.push_back(t[i]);
  cout<<(c==d?a/g*b:-1);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:41: error: 'i' was not declared in this scope
   14 |   for(int j=0;j<b;j+=b/g) d.push_back(t[i]);
      |                                         ^
Language: C++

#include <bits/stdc++.h>
#include <numeric>
using namespace std;
long int gcd(long int a, long int b){
  if(a<b){
    long int tmp = a;
    a = b;
    b = tmp;
  }
  long int r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  long int gcd = b;
  return gcd;
}

int main(){
  long int N,M;
  string S,T;
  cin >> N >> M >> S >> T;
  if(N != 1 && M != 1){
  long int cd = gcd(N, M);
  if(cd == 1){
    cout << N*M << endl;
  }else if{
    bool moji = true;
    long int n = N / cd;
    long int m = M / cd;
    for(long int i = 0;i < cd;i++){
      if(S[i*n] != T[i*m]) moji = false;
    }
    if(moji == true) cout << m*N << endl;
    else cout << -1 << endl;
  }
  }else if(N == 1){
     bool moji = true;
    for(long int i = 0;i < M;i++){
     if(S[0] != T[i]) moji = false;
    }
    if(moji == true) cout << M << endl;
    else cout << -1 << endl;
  }else if(M == 1){
    bool moji = true;
    for(long int i = 0;i < N;i++){
     if(T[0] != S[i]) moji = false;
    }
    if(moji == true) cout << N << endl;
    else cout << -1 << endl;
  }
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:28:11: error: expected '(' before '{' token
   28 |   }else if{
      |           ^
      |           (
Language: C++

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

/* gcd */
template<typename T>
T gcd(T a,T b)
{
	if(a==0 || b==0)return 0;
	T r;
	while(1)
	{
		r=a%b;
		if(r==0)break;
		a=b;
		b=r;
	}
	return b;
}

/* lcm */
template<typename T>
T lcm(T a,T b)
{
	if(a==0 || b==0)return 0;
	return a*b/gcd(a,b);
}

int main()
{
	lint N,M;
	lint G;
	string S,T;
	
	cin >> N >> M;
	cin >> S >> T;
	
	G=gcd(N,M);
	for(lint i=0;i<G;i++)
	{
		if(S[i*N/G]!=T[i*M/G])
		{
			cout << -1 << endl;
			return 0;
		}
	}
	cout << lcm(N,M) << endl;
	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:31:9: error: 'lint' was not declared in this scope; did you mean 'uint'?
   31 |         lint N,M;
      |         ^~~~
      |         uint
a.cc:32:13: error: expected ';' before 'G'
   32 |         lint G;
      |             ^~
      |             ;
a.cc:35:16: error: 'N' was not declared in this scope
   35 |         cin >> N >> M;
      |                ^
a.cc:35:21: error: 'M' was not declared in this scope
   35 |         cin >> N >> M;
      |                     ^
a.cc:38:9: error: 'G' was not declared in this scope
   38 |         G=gcd(N,M);
      |         ^
a.cc:39:17: error: expected ';' before 'i'
   39 |         for(lint i=0;i<G;i++)
      |                 ^~
      |                 ;
a.cc:39:22: error: 'i' was not declared in this scope
   39 |         for(lint i=0;i<G;i++)
      |                      ^
Language: C++

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

int gcd(int a, int b)
{
  if(a < b)
  {
    swap(a, b);
  }
  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 ch = 0;
  int lc = n * m / gcd(n, m);
  int i;
  for(i = 0; i < lc; i++)
  {
    if(i % (lc / n) == 0 && i % (lc / m) == 0)
    {
      if(s.at(i / (lc / n)) != t.at(i / (lc / m))
      {
        ch = 1;
        break;
      }
    }
  }
  if(ch == 0)
  {
    cout << lc << endl;
  }
  else
  {
    cout << -1 << endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:50: error: expected ')' before '{' token
   33 |       if(s.at(i / (lc / n)) != t.at(i / (lc / m))
      |         ~                                        ^
      |                                                  )
   34 |       {
      |       ~                                           
a.cc:38:5: error: expected primary-expression before '}' token
   38 |     }
      |     ^
Language: C++

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

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

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

int main()
{
  int n, m;
  cin >> n >> m;
  string s, t;
  cin >> s >> t;
  int ch = 0;
  int lc = lcm(n, m);
  int gc = gcd(n, m)
  int i;
  for(i = 0; i < lc; i += lc / n)
  {
    if(i % (lc / n) == 0 && i % (lc / m) == 0)
    {
      if(s.at(i * n / lc) != t.at(i * m / lc))
      {
        ch = 1;
        break;
      }
    }
  }
  if(ch == 0)
  {
    cout << lc << endl;
  }
  else
  {
    cout << -1 << endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:3: error: expected ',' or ';' before 'int'
   36 |   int i;
      |   ^~~
a.cc:37:7: error: 'i' was not declared in this scope
   37 |   for(i = 0; i < lc; i += lc / n)
      |       ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
#define int long long
//#define uint __int128_t
 
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define low(a,b) lower_bound(all(a),(b))-(a).begin()
#define upp(a,b) upper_bound(all(a),(b))-(a).begin()
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<vint> vvint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

int N,M;
string s,t;
int gcd(int x,int y)
{
	if(x==0) return y;
	return gcd(y%x,x);
}
int lcm(int x, int y)
{
    return (x * y / gcd(x, y));
}

signed main() {
    IOS();
    //(1ll<<N)シフト演算のオーバーフローに気をつける
    cin>>N>>M;
    cin>>s>>t;
    int x=lcm(N,M);
    int xx=n*m;
    rep(i,0,x/max(N,M)){
        if(s[i*(N/x)]!=t[i*(M/x)]){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<x<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:50:12: error: 'n' was not declared in this scope
   50 |     int xx=n*m;
      |            ^
a.cc:50:14: error: 'm' was not declared in this scope
   50 |     int xx=n*m;
      |              ^
Language: C++

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

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

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

int main()
{
  int n, m;
  cin >> n >> m;
  string s, t;
  cin >> s >> t;
  int ch = 0;
  int lcm = lcm(n, m);
  int i;
  for(i = 0; i < lcm; i++)
  {
    if(i % (lcm / n) == 0 && i % (lcm / m) == 0)
    {
      if(s.at(i * n / lcm) != t.at(i * m / lcm))
      {
        ch = 1;
        break;
      }
    }
  }
  if(ch == 0)
  {
    cout << lcm << endl;
  }
  else
  {
    cout << "-1" << endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:16: error: 'lcm' cannot be used as a function
   34 |   int lcm = lcm(n, m);
      |             ~~~^~~~~~
Language: Java

import java.util.*;

public class MAIN {
		public static void main(String[] args) {
			 
			Scanner sc = new Scanner(System.in);
	 
			long N = sc.nextInt();
			long M = sc.nextInt();
			char[] S = sc.next().toCharArray();
			char[] T = sc.next().toCharArray();
			long g = gcd(N,M);
			long L = (N * M) / g;
			boolean flag = true;
	 
			for(long i = 0;i<g;i++) {
				if(S[(int)(N/g * i)] != T[(int)(M/g *i)]) {
					flag = false;
				}
			}
	 
			if(flag) {
				System.out.println(L);
			}else {
				System.out.println("-1");
			}
		    sc.close();
		}
	 
	 
	    private static long gcd(long m, long n) {
	        if(m < n) return gcd(n, m);
	        if(n == 0) return m;
	        return gcd(n, m % n);
	    }
}


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

public class MAIN {
		public static void main(String[] args) {
			 
			Scanner sc = new Scanner(System.in);
	 
			long N = sc.nextInt();
			long M = sc.nextInt();
			char[] S = sc.next().toCharArray();
			char[] T = sc.next().toCharArray();
			long g = gcd(N,M);
			long L = (N * M) / g;
			boolean flag = true;
	 
			for(long i = 0;i<g;i++) {
				if(S[(int)(N/g * i)] != T[(int)(M/g *i)]) {
					flag = false;
				}
			}
	 
			if(flag) {
				System.out.println(L);
			}else {
				System.out.println("-1");
			}
		    sc.close();
		}
	 
	 
	    private static long gcd(long m, long n) {
	        if(m < n) return gcd(n, m);
	        if(n == 0) return m;
	        return gcd(n, m % n);
	    }
}

Compiler output:
Main.java:1: error: class MAIN is public, should be declared in a file named MAIN.java
public class MAIN {
       ^
Main.java:4: error: cannot find symbol
			Scanner sc = new Scanner(System.in);
			^
  symbol:   class Scanner
  location: class MAIN
Main.java:4: error: cannot find symbol
			Scanner sc = new Scanner(System.in);
			                 ^
  symbol:   class Scanner
  location: class MAIN
3 errors
Language: C++

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

int gcd(int a, int b)
{
  int m = max(a, b);
  int n = min(a, b);

  while (m != n) {
    int t = n;
    n = m - n;
    m = t;
  }

  return m;
}

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


int main()
{
  int n;  // sの長さ
  int m;  // tの長さ
  string s, t;
  int l;  // xの長さ
  int g;  // 最大公約数

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

  g = gcd(n, m);

  printf("gcd=%d\n", g);

  for (int i = 0; i < g; i++) {
    printf("%d %d\n", n / g * i, m / g * i);
    printf("%c %c\n", s[n / g * i], t[m / g * i]);
    if (s[n / g * i] != t[m / g * i]) {
      cout << -1 << endl;
      return 0;
    }
  }

  cout << lcm(n, m) << endl;

  return 0;
}

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <bits/stdc++.h>
      | ^~~~~~~
a.cc: In function 'int gcd(int, int)':
a.cc:6:11: error: 'max' was not declared in this scope
    6 |   int m = max(a, b);
      |           ^~~
a.cc:7:11: error: 'min' was not declared in this scope
    7 |   int n = min(a, b);
      |           ^~~
a.cc: In function 'int main()':
a.cc:28:3: error: 'string' was not declared in this scope
   28 |   string s, t;
      |   ^~~~~~
a.cc:32:3: error: 'cin' was not declared in this scope
   32 |   cin >> n >> m;
      |   ^~~
a.cc:33:10: error: 's' was not declared in this scope
   33 |   cin >> s;
      |          ^
a.cc:34:10: error: 't' was not declared in this scope
   34 |   cin >> t;
      |          ^
a.cc:38:3: error: 'printf' was not declared in this scope
   38 |   printf("gcd=%d\n", g);
      |   ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | include <bits/stdc++.h>
a.cc:44:7: error: 'cout' was not declared in this scope
   44 |       cout << -1 << endl;
      |       ^~~~
a.cc:44:21: error: 'endl' was not declared in this scope
   44 |       cout << -1 << endl;
      |                     ^~~~
a.cc:49:3: error: 'cout' was not declared in this scope
   49 |   cout << lcm(n, m) << endl;
      |   ^~~~
a.cc:49:24: error: 'endl' was not declared in this scope
   49 |   cout << lcm(n, m) << endl;
      |                        ^~~~
Language: C++

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

int ggd(int a, int b)
{
  int m = max(a, b);
  int n = min(a, b);

  while (m != n) {
    int t = n;
    n = m - n;
    m = t;
  }

  return m;
}

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


int main()
{
  int n;  // sの長さ
  int m;  // tの長さ
  string s, t;
  int l;  // xの長さ
  int g;  // 最大公約数

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

  l = lcm(n, m);

  g = ggd(n, m);

  for (int i = 0; i < l / min(n, m); i++) {
    if (s[i * (l / m)] != t[i * (l / n)]) {
      cout << -1 << endl;
      return 0;
    }
  }

  cout << l << endl;
}

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <bits/stdc++.h>
      | ^~~~~~~
a.cc: In function 'int ggd(int, int)':
a.cc:6:11: error: 'max' was not declared in this scope
    6 |   int m = max(a, b);
      |           ^~~
a.cc:7:11: error: 'min' was not declared in this scope
    7 |   int n = min(a, b);
      |           ^~~
a.cc: In function 'int main()':
a.cc:28:3: error: 'string' was not declared in this scope
   28 |   string s, t;
      |   ^~~~~~
a.cc:32:3: error: 'cin' was not declared in this scope
   32 |   cin >> n >> m;
      |   ^~~
a.cc:33:10: error: 's' was not declared in this scope
   33 |   cin >> s;
      |          ^
a.cc:34:10: error: 't' was not declared in this scope
   34 |   cin >> t;
      |          ^
a.cc:40:27: error: 'min' was not declared in this scope; did you mean 'main'?
   40 |   for (int i = 0; i < l / min(n, m); i++) {
      |                           ^~~
      |                           main
a.cc:42:7: error: 'cout' was not declared in this scope
   42 |       cout << -1 << endl;
      |       ^~~~
a.cc:42:21: error: 'endl' was not declared in this scope
   42 |       cout << -1 << endl;
      |                     ^~~~
a.cc:47:3: error: 'cout' was not declared in this scope
   47 |   cout << l << endl;
      |   ^~~~
a.cc:47:16: error: 'endl' was not declared in this scope
   47 |   cout << l << endl;
      |                ^~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define tr(container, it) \
    for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define ill(_x)  ll _x;scanf("%lld",&_x);
#define idb(_x)  double _x;scanf("%lf",&_x);
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vs vector<string>
#define in0(x, a, b)((x)>=a && (x)<=b    )
#define in1(x, a, b)((x)>a && (x)<b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define int ll
const double pi = 3.14159265358979323846;
const int INF = 0x3f3f3f3f;
const int MOD = (int) (1e9) + 7;

int tc, q;
map<int, int> factorize(long long n)
{
    map<int, int> factors;
    int count = 0;

    while (!(n % 2)) {
        n >>= 1;
        count++;
    }

    if(count)factors[2] = count;

    for (long long i = 3; i <= sqrt(n); i += 2) {
        count = 0;
        while (n % i == 0) {
            count++;
            n = n / i;
        }
        if (count)
            factors[i] = count;
    }

    if (n > 2)
        factors[n] = 1;
    return factors;
}



void _() {
    int n, m;
    cin >> n >> m;
    string s,t;
    cin >> s >>t;
    int l = n*m/ __gcd(n, m);
    for (int i = 0; i < __gcd(n, m); ++i) {
        if(s[i*n/__gcd(n,m)] != t[i*m/__gcd(n,m)]){
            cout << -1 ;return;
        }
    }
    cout << l;

};


void main() {
#if __MINGW32__
    freopen("C:\\Users\\hiroo\\CLionProjects\\competitive\\Input.txt", "r", stdin);
    freopen("C:\\Users\\hiroo\\CLionProjects\\competitive\\Output.txt", "w", stdout);

#endif

    _();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);


}

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

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define tr(container, it) \
    for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define ill(_x)  ll _x;scanf("%lld",&_x);
#define idb(_x)  double _x;scanf("%lf",&_x);
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vs vector<string>
#define in0(x, a, b)((x)>=a && (x)<=b    )
#define in1(x, a, b)((x)>a && (x)<b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define int long long
const double pi = 3.14159265358979323846;
const int INF = 0x3f3f3f3f;
const int MOD = (int) (1e9) + 7;

int tc, q;
map<int, int> factorize(long long n)
{
    map<int, int> factors;
    int count = 0;

    while (!(n % 2)) {
        n >>= 1;
        count++;
    }

    if(count)factors[2] = count;

    for (long long i = 3; i <= sqrt(n); i += 2) {
        count = 0;
        while (n % i == 0) {
            count++;
            n = n / i;
        }
        if (count)
            factors[i] = count;
    }

    if (n > 2)
        factors[n] = 1;
    return factors;
}



void _() {
    int n, m;
    cin >> n >> m;
    string s,t;
    cin >> s >>t;
    int l = n*m/ __gcd(n, m);
    for (int i = 0; i < __gcd(n, m); ++i) {
        if(s[i*n/__gcd(n,m)] != t[i*m/__gcd(n,m)]){
            cout << -1 ;return;
        }
    }
    cout << l;

};


void main() {
#if __MINGW32__
    freopen("C:\\Users\\hiroo\\CLionProjects\\competitive\\Input.txt", "r", stdin);
    freopen("C:\\Users\\hiroo\\CLionProjects\\competitive\\Output.txt", "w", stdout);

#endif

    _();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

 

}

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

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define tr(container, it) \
    for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define ill(_x)  ll _x;scanf("%lld",&_x);
#define idb(_x)  double _x;scanf("%lf",&_x);
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vs vector<string>
#define in0(x, a, b)((x)>=a && (x)<=b    )
#define in1(x, a, b)((x)>a && (x)<b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define int long long
const double pi = 3.14159265358979323846;
const int INF = 0x3f3f3f3f;
const int MOD = (int) (1e9) + 7;

int tc, q;
map<int, int> factorize(long long n)
{
    map<int, int> factors;
    int count = 0;

    while (!(n % 2)) {
        n >>= 1;
        count++;
    }

    if(count)factors[2] = count;

    for (long long i = 3; i <= sqrt(n); i += 2) {
        count = 0;
        while (n % i == 0) {
            count++;
            n = n / i;
        }
        if (count)
            factors[i] = count;
    }

    if (n > 2)
        factors[n] = 1;
    return factors;
}



void _() {
    int n, m;
    cin >> n >> m;
    string s,t;
    cin >> s >>t;
    int l = n*m/ __gcd(n, m);
    for (int i = 0; i < __gcd(n, m); ++i) {
        if(s[i*n/__gcd(n,m)] != t[i*m/__gcd(n,m)]){
            cout << -1 ;return;
        }
    }
    cout << l;

};


int main() {
#if __MINGW32__
    freopen("C:\\Users\\hiroo\\CLionProjects\\competitive\\Input.txt", "r", stdin);
    freopen("C:\\Users\\hiroo\\CLionProjects\\competitive\\Output.txt", "w", stdout);

#endif

    _();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    return 0;

}

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

#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pli pair<LL, int>
#define pii pair<int, int>
#define piii pair<pii, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);
//head

const int N = 1e5 + 10;
char s[N], t[N];
map<int, char> mp;
int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    scanf("%s", s+1);
    scanf("%s", t+1);
    int t = n /__gcd(n, m) * m;
    if(s[1] != t[1]) return 0*puts("-1");
    for (int d = t; d <= 10*t; d += t){
        for (int i = 1; i < n; i++) {
            if(mp.find(d/n*i) == mp.end()) {
                mp[d/n*i] = s[i+1];
            }
            else {
                if(mp[d/n*i] != s[i+1]) return 0*puts("-1");
            }
        }
        for (int i = 1; i < m; i++) {
            if(mp.find(d/m*i) == mp.end()) {
                mp[d/m*i] = t[i+1];
            }
            else {
                if(mp[d/m*i] != t[i+1]) return 0*puts("-1");
            }
        }
        return 0*printf("%d\n", d);
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:17: error: invalid types 'int[int]' for array subscript
   33 |     if(s[1] != t[1]) return 0*puts("-1");
      |                 ^
a.cc:45:30: error: invalid types 'int[int]' for array subscript
   45 |                 mp[d/m*i] = t[i+1];
      |                              ^
a.cc:48:34: error: invalid types 'int[int]' for array subscript
   48 |                 if(mp[d/m*i] != t[i+1]) return 0*puts("-1");
      |                                  ^
Language: C

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int gcd(int x, int y);
int main(void){
  long n,m,i,x,y,g=0;
  scanf("%ld %ld", &n, &m);
  if(n<m){
    i=n;
    n=m;
    m=i;
    g=1;
  }
  char s[n], t[m];
  if(g==1){
   scanf("%s", t);
   scanf("%s",s);
  }
  else {
   scanf("%s", s);
   scanf("%s", t);
  }
  g = gcd(n,m);
  x = n/g;
  y = m/g;
/*
  for(i=0; m >= y*i ; i++){
     
    if(*(s+x*i)==*(t+y*i)); 
    else{
     x=1;
     y=1;
     g=-1;
     break;
     }
   }:?
  printf("%ld",x*y*g);
  return 0;
}
int gcd(int x, int y){

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


Compiler output:
main.c: In function 'main':
main.c:26:1: error: unterminated comment
   26 | /*
      | ^
main.c:25:3: error: expected declaration or statement at end of input
   25 |   y = m/g;
      |   ^
Language: C

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int gcd(int x, int y);
int main(void){
  lomg n,m,i,x,y,g=0;
  scanf("%d %d", &n, &m);
  if(n<m){
    i=n;
    n=m;
    m=i;
    g=1;
  }
  char s[n], t[m];
  if(g==1){
   scanf("%s", t);
   scanf("%s",s);
  }
  else {
   scanf("%s", s);
   scanf("%s", t);
  }
  g = gcd(n,m);
  x = n/g;
  y = m/g;
  for(i=0; m >= y*i ; i++){
     
    if(*(s+x*i)==*(t+y*i)); 
    else{
     x=1;
     y=1;
     g=-1;
     break;
     }
   }
  printf("%d",x*y*g);
  return 0;
}
int gcd(int x, int y){

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


Compiler output:
main.c: In function 'main':
main.c:6:3: error: unknown type name 'lomg'; did you mean 'long'?
    6 |   lomg n,m,i,x,y,g=0;
      |   ^~~~
      |   long
Language: C

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int gcd(int x, int y);
int main(void){
  int n,m,i,x,y,g;
  scanf("%d %d", &n, &m);
  if(n<m){
    i=n;
    n=m;
    m=i;
    char s[n], t[m];
    scanf("%s", t);
    scanf("%s", s);
  }
  else {
   char s[n], t[m];
   scanf("%s", s);
   scanf("%s", t);
  }
  g = gcd(n,m);
  x = n/g;
  y = m/g;
  for(i=0; y > i; i++){ 
    if(*(s+x*i)==*(t+y*i));
    else{
     printf("-1");
     exit(0);
     }
   }
  printf("%d",x*y*g);
}
int gcd(int x, int y){

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


Compiler output:
main.c: In function 'main':
main.c:25:10: error: 's' undeclared (first use in this function)
   25 |     if(*(s+x*i)==*(t+y*i));
      |          ^
main.c:25:10: note: each undeclared identifier is reported only once for each function it appears in
main.c:25:20: error: 't' undeclared (first use in this function)
   25 |     if(*(s+x*i)==*(t+y*i));
      |                    ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main() {
#ifdef wxh010910
  freopen("input.txt", "r", stdin);
#endif
  int n, m;
  string s, t;
  cin >> n >> m >> s >> t;
  int gcd = __gcd(n, m);
  for (int i = 0, j = 0; i < n && j < m; i += n / gcd, j += m / gcd) {
    if (s[i] != t[j]) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << (long long)n * m / gcd << endl;
  return 0;
}

--------------------- 
作者：wxh010910 
来源：CSDN 
原文：https://blog.csdn.net/wxh010910/article/details/83065702 
版权声明：本文为博主原创文章，转载请附上博文链接！

Compiler output:
a.cc:23:1: error: expected unqualified-id before '--' token
   23 | ---------------------
      | ^~
Language: C++

#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<iostream>
#include<cstring>

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define debug(...) fprintf(stderr,__VA_ARGS__)

using namespace std;


inline char nc(){ return getchar();static char buf[100000] , *p1,*p2; return p1 == p2 && (p2 = (p1 = buf) + fread(buf,1,100000,stdin),p1 == p2) ? EOF : *p1++;}
template<class T>inline void rd(T & x){ x = 0;char ch = nc();for(;!isdigit(ch);ch = nc()); for(;isdigit(ch);ch = nc()) x = x * 10 - 48 + ch;} 
inline int rdstring(char * s){ int len = 0; char ch = nc(); for(;isspace(ch);ch = nc()); for(;!isspace(ch);ch = nc()) s[len++] = ch;return len;}
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}

const int maxn = 1e5 + 10;
typedef long long ll;
char a[maxn] , b[maxn];
int n,m;
ll check(){
	ll len = (ll) n * m / gcd(n,m);	
	ll stepa = len / n,stepb = len / m;
	ll step = (ll) stepa * stepb / gcd(stepa,stepb);
	for(int i = 1;i <= len;i += step){
		ll x = a[(i - 1) / stepa + 1;
		ll y = (i - 1) / stepb + 1;
		
		if(x > n || y > m) break;
		if(a[x] != b[x]) return -1;
	}
	return len;
}
int main(){
	rd(n); rd(m);
	rdstring(a + 1);
	rdstring(b + 1);
	printf("%lld\n",check());
}

Compiler output:
a.cc: In function 'll check()':
a.cc:31:45: error: expected ']' before ';' token
   31 |                 ll x = a[(i - 1) / stepa + 1;
      |                                             ^
      |                                             ]
Language: C++

#include <stdio.h>

int main(){
  
  int n,m;
  scanf("%d",&n);
  scanf("%d",&m);
  
  char s[n+1],t[m+1];
  scanf("%s",s);
  scanf("%s",t);
  
  int l=1;
  int nn=n,mm=m,rr=nn%mm;
  while(rr!=0){
    nn=mm;
    mm=rr;
    rr=nn%mm;
  }
  int ll=n*m/rr;
  int t;
  for(int q=1;l<10000000000;q++){
    l=q*ll;
    t=1;
    for(int i=0;i<n;i++){
      for(int w=0;w<m;w++){
        if(i*l/m+1==w*l/n+1){
          if(s[i]!=t[w]){
            t=-1;
            goto label:;
          }
        }
      }
    }label: ;
  }
  if(t==1) printf("%d\n",l);
  else printf("-1");
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:7: error: conflicting declaration 'int t'
   21 |   int t;
      |       ^
a.cc:9:15: note: previous declaration as 'char t [(m + 1)]'
    9 |   char s[n+1],t[m+1];
      |               ^
a.cc:24:6: error: incompatible types in assignment of 'int' to 'char [(m + 1)]'
   24 |     t=1;
      |     ~^~
a.cc:29:14: error: incompatible types in assignment of 'int' to 'char [(m + 1)]'
   29 |             t=-1;
      |             ~^~~
a.cc:30:23: error: expected ';' before ':' token
   30 |             goto label:;
      |                       ^
      |                       ;
a.cc:30:23: error: expected primary-expression before ':' token
a.cc:36:7: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   36 |   if(t==1) printf("%d\n",l);
      |      ~^~~
Language: C

#include <stdio.h>
#include <stdlib.h>
long min_l(long n, long m);

int main(void)
{
	long n, m, p1, p2, q1, q2, l;
	int err;
	char s[100000], t[100000];
	err=scanf("%ld%ld", &n, &m);
	if (err!=2) exit(1);
	s = (char *)malloc(sizeof(char)*(int)n);
	t = (char *)malloc(sizeof(char)*(int)m);
	err=scanf("%s\n%s", s, t);
	if (err!=2) exit(1);

	l=min_l(n, m);
	p1=l/n;
	q1=l/m;
	p2=0;
	q2=0;
	while((q2<n)&&(p2<m))
	{
		if (s[q2]!=t[p2])
		{
			printf("%d\n", -1);
			return 0;
		}
		p2+=p1;
		q2+=q1;
	}
	printf("%ld\n", l);
	free(s);
	free(t);
	return 0;
}

long min_l(long n, long m){
	long answer, a, b, r = 1;
	if (n >= m)
	{
		a = n;
		b = m;
	}else
	{
		a = m;
		b = n;
	}
	while (r != 0)
	{
		r = a%b;
		a = b;
		b = r;
	}
	answer = n * m / a;
	return answer;
}

Compiler output:
main.c: In function 'main':
main.c:12:11: error: assignment to expression with array type
   12 |         s = (char *)malloc(sizeof(char)*(int)n);
      |           ^
main.c:13:11: error: assignment to expression with array type
   13 |         t = (char *)malloc(sizeof(char)*(int)m);
      |           ^
Language: C

long min_l(long n, long m){
	long answer = 1, i = n;
	while (i >= 2)
	{
		if ((n%i==0) && (m%i==0))
		{
			answer *= i;
			n /= i;
			m /= i;
			i = n;
		}else
		{
			i--;
		}
	}
	answer = answer * n * m;
	return answer;
}

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;
	string s,t;
	cin >> n >> m;
	cin >> s;
	cin >> t;

  int x = n * m;
 
  /* 自然数 n > m を確認・入替 */
  if(n<m){
    int tmp = n;
		string tmpstr = s;
    n = m;
		s = t;
    m = tmp;
		t = tmpstr;
  }
  /* ユークリッドの互除法 */
  int r = n % m;
	int gcd = m;
  while(r!=0){
		int n1 = gcd;
		gcd = r;
    r = n1 % gcd;
  }
  /* 最小公倍数 */
	int lcm = x/gcd;

	if (s[0]!=t[0]) cout << -1 << endl;
	else if (n==m&&s!=t) cout << -1 << endl;
	else {
		for (int i=0; i<=gcd-1; i++) {
			if (s[n/gcd*i]!=t[m/gcd*i]) {
				cout << -1 << endl;
				break;
			}
			if (i==m/gcd-1) cout << lcm << endl;
		}
	} else cout << lcm << endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:44:11: error: 'else' without a previous 'if'
   44 |         } else cout << lcm << endl;
      |           ^~~~
Language: C++

#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
int main() {
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ll n, m;
	cin>>n>>m;
	string s, t;
	cin>>s>>t;
	ll g = __gcd(n, m);
	for (int i = 0; i < g; i++) {
		if (s[n / g * i] != t[m / g * i]) {
			cout << "-1\n";
			return 0;
		}
	}
	cout<<n * m / g;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:16: error: '__gcd' was not declared in this scope
   12 |         ll g = __gcd(n, m);
      |                ^~~~~
Language: C++

#include<cstdio>
#include<algorithm>
#define rep(i,s,t) for(register int i=s;i<=t;++i)
using namespace std;
const int N=1e6+11,mod=1e9+7;
int n,ans,a[N],inv[N];
int main(){
	cin>>n;
	rep(i,1,n)
		cin>>a[i];
	inv[1]=1;
	rep(i,2,n)
		inv[i]=mod-1ll*mod/i*inv[mod%i]%mod;
	rep(i,2,n)
		inv[i]=(inv[i]+inv[i-1])%mod;
	rep(i,1,n)
		ans=(ans+1ll*(inv[i]+inv[n-i+1]-1)*a[i])%mod;
	rep(i,1,n)
		ans=1ll*ans*i%mod;
	ans=(ans+mod)%mod;
	cout<<ans;}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:9: error: 'cin' was not declared in this scope
    8 |         cin>>n;
      |         ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include<algorithm>
  +++ |+#include <iostream>
    3 | #define rep(i,s,t) for(register int i=s;i<=t;++i)
a.cc:9:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    9 |         rep(i,1,n)
      |             ^
a.cc:3:37: note: in definition of macro 'rep'
    3 | #define rep(i,s,t) for(register int i=s;i<=t;++i)
      |                                     ^
a.cc:12:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   12 |         rep(i,2,n)
      |             ^
a.cc:3:37: note: in definition of macro 'rep'
    3 | #define rep(i,s,t) for(register int i=s;i<=t;++i)
      |                                     ^
a.cc:14:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   14 |         rep(i,2,n)
      |             ^
a.cc:3:37: note: in definition of macro 'rep'
    3 | #define rep(i,s,t) for(register int i=s;i<=t;++i)
      |                                     ^
a.cc:16:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   16 |         rep(i,1,n)
      |             ^
a.cc:3:37: note: in definition of macro 'rep'
    3 | #define rep(i,s,t) for(register int i=s;i<=t;++i)
      |                                     ^
a.cc:18:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   18 |         rep(i,1,n)
      |             ^
a.cc:3:37: note: in definition of macro 'rep'
    3 | #define rep(i,s,t) for(register int i=s;i<=t;++i)
      |                                     ^
a.cc:21:9: error: 'cout' was not declared in this scope
   21 |         cout<<ans;}
      |         ^~~~
a.cc:21:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
int main(void)
{

    int N;
    int M;

    scanf("%d %d", &N, &M);

    if(N < 1 || N > 100000 || M < 1 || M > 100000) {
        exit(0);
    }

    char S[N];
    char T[M];

    scanf("%s", S);
    scanf("%s", T);

    for(int i = 0;i < N;i++) {
        if((S[i] < 'a') || (S[i] > 'z')) {
            exit(0);
        }
    }

    for(int i = 0;i < M;i++) {
        if((T[i] < 'a') || (T[i] > 'z')) {
            exit(0);
        }
    }

    if(strlen(S) != N) {
        exit(0);
    }

    if(strlen(T) != M) {
        exit(0);
    }

    int hogeN = N;
    int hogeM = M;

    if(hogeM < hogeN) {
        tmp = hogeM;
        hogeM = hogeN;
        hogeN = tmp;
    }

    int r;
    int tmp;

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

    int saidai;
    int hoge;
    saidai = hogeN;

    int count = 1;
    int flag = 0;
    while(count / N < 1 || count / M < 1) {
        if(count % saidai != 0) {
            count++;
            continue;
        }
        hoge = count / N;
        for(int i = 1;i < N;i++) {
            if(S[i * hoge + i] != S[i]) {
                break;
            }
        }
        if(flag == 0) {
            count++;
            continue;
        }

        hoge = count / M;
        for(int i = 1;i < M;i++) {
            if(S[i * hoge + i] != S[i]) {
                break;
            }
        }

        if(flag == 0) {
            count++;
            continue;
        } else {
            flag = 1;
            break;
        }
    }

    if(flag == 1) {
        printf("%d", count);
    } else {
        printf("-1\n");
    }

    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:47:9: error: 'tmp' undeclared (first use in this function)
   47 |         tmp = hogeM;
      |         ^~~
main.c:47:9: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <stdio.h>
#include <stdlib.h>
 
int main(void)
{

    int N;
    int M;

    scanf("%d %d", &N, &M);

    if(N < 1 || N > 100000 || M < 1 || M > 100000) {
        exit(0);
    }

    char S[N];
    char T[M];

    scanf("%s", S);
    scanf("%s", T);

    for(int i = 0;i < N;i++) {
        if((S[i] < 'a') || (S[i] > 'z')) {
            exit(0);
        }
    }

    for(int i = 0;i < M;i++) {
        if((T[i] < 'a') || (T[i] > 'z')) {
            exit(0);
        }
    }

    if(strlen(S) != N) {
        exit(0);
    }

    if(strlen(T) != M) {
        exit(0);
    }

    int hogeN = N;
    int hogeM = M;

    if(hogeM < hogeN) {
        tmp = hogeM;
        hogeM = hogeN;
        hogeN = tmp;
    }

    int r;
    int tmp;

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

    int saidai;
    int hoge;
    saidai = hogeN;

    int count = 1;
    int flag = 0;
    while(count / N < 1 || count / M < 1) {
        if(count % saidai != 0) {
            count++;
            continue;
        }
        hoge = count / N;
        for(int i = 1;i < N;i++) {
            if(S[i * hoge + i] != S[i]) {
                break;
            }
        }
        if(flag == 0) {
            count++;
            continue;
        }

        hoge = count / M;
        for(int i = 1;i < M;i++) {
            if(S[i * hoge + i] != S[i]) {
                break;
            }
        }

        if(flag == 0) {
            count++;
            continue;
        } else {
            flag = 1;
            break;
        }
    }

    if(flag == 1) {
        printf("%d", count);
    } else {
        printf("-1\n");
    }

    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:34:8: error: implicit declaration of function 'strlen' [-Wimplicit-function-declaration]
   34 |     if(strlen(S) != N) {
      |        ^~~~~~
main.c:3:1: note: include '<string.h>' or provide a declaration of 'strlen'
    2 | #include <stdlib.h>
  +++ |+#include <string.h>
    3 | 
main.c:34:8: warning: incompatible implicit declaration of built-in function 'strlen' [-Wbuiltin-declaration-mismatch]
   34 |     if(strlen(S) != N) {
      |        ^~~~~~
main.c:34:8: note: include '<string.h>' or provide a declaration of 'strlen'
main.c:38:8: warning: incompatible implicit declaration of built-in function 'strlen' [-Wbuiltin-declaration-mismatch]
   38 |     if(strlen(T) != M) {
      |        ^~~~~~
main.c:38:8: note: include '<string.h>' or provide a declaration of 'strlen'
main.c:46:9: error: 'tmp' undeclared (first use in this function)
   46 |         tmp = hogeM;
      |         ^~~
main.c:46:9: note: each undeclared identifier is reported only once for each function it appears in