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

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define MOD 1000000007ULL;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	int N,M;
    string S,T;
  	cin>>N>>M;
  	cin>>S;
  	cin>>T;
  	int lcm=N*M/gcd(N,M);
  	int good = 1;
  
  	if(S[i*N/gcd(N,M)]!=T[i*M/gcd(N,M)]) good=0; 
  	rep(i,gcd(N,M)-1){
     	if(S[i*N/gcd(N,M)]!=T[i*M/gcd(N,M)]) good=0; 
    }
  
  	if(good) cout<<lcm<<endl;
  	else cout<<-1<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:14: error: 'i' was not declared in this scope
   20 |         if(S[i*N/gcd(N,M)]!=T[i*M/gcd(N,M)]) good=0;
      |              ^
Language: C++

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

long long gcd(long long n, long long m) { return m ? GCD(m, n % m) : n; }

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

int main() {
    //
    long long n, m;
    string s, t;
    long long kekka;
    long long tmpN, tmpM;
    long long g;

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

    kekka = lcm(n, m);
    g = gcd(n, m);

    tmpN = n / g;
    tmpM = m / g;

    for (long long i = 0; i < g; i++) {
        if (s.at(i * tmpN) != t.at(i * tmpM)) {
            cout << -1;
            return 0;
        }
    }

    cout << kekka;
    //
}

Compiler output:
a.cc: In function 'long long int gcd(long long int, long long int)':
a.cc:4:54: error: 'GCD' was not declared in this scope
    4 | long long gcd(long long n, long long m) { return m ? GCD(m, n % m) : n; }
      |                                                      ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
long long counter;
counter=0;
long long counter2=0;
int N,M; cin>>N>>M;
string S,T; cin>>S>>T;
if(GCD__(N,M)==1){
if(S.at(0)==T.at(0)){
cout<<N*M<<endl;}
else
cout<<-1<<endl;}
else{

for(long long i=0; i<S.size();i++){
if(S.at(i)=='B'){
counter2++;}
else
counter+=counter2;}
cout<<counter<<endl;}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:4: error: 'GCD__' was not declared in this scope
    9 | if(GCD__(N,M)==1){
      |    ^~~~~
a.cc:21:22: error: expected '}' at end of input
   21 | cout<<counter<<endl;}
      |                      ^
a.cc:3:11: note: to match this '{'
    3 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int lcm(int a, int b) 
return a / gcd(a, b) * b;
}

int main(){
    ll n,m;
    cin >> n>> m;
    string s,t;
    cin >> s >> t;
    ll lms = N*M / gcd(N,M);
    ll p = lms / N, q= lms / M;
    for(ll i=0; i<N/q; i++){
        if(s[i*q] != t[i*p]){
            cout << -a << endl;
            return 0;
        }
    }
    cout << lms <<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int lcm(int, int)':
a.cc:6:1: error: named return values are no longer supported
    6 | return a / gcd(a, b) * b;
      | ^~~~~~
a.cc:14:14: error: 'N' was not declared in this scope
   14 |     ll lms = N*M / gcd(N,M);
      |              ^
a.cc:14:16: error: 'M' was not declared in this scope
   14 |     ll lms = N*M / gcd(N,M);
      |                ^
a.cc:16:21: error: 'q' was not declared in this scope
   16 |     for(ll i=0; i<N/q; i++){
      |                     ^
Language: C++

#include<bits/stdc++.h>
int gcd(int x,int y){
if(x==0 || y==0)
  return max(x,y);
  else{
   if(x<y)
     return gcd(x,y%x);
    else if(y<x)
      return gcd(y,x%y);
    else
      return x;
  
  }

}
using namespace std;
int main(){
int N,M;
  cin>>N>>M;
  string s,t;
  cin>>s>>t;
  int g=gcd(N,M);
  bool x=true;
  for(int i=0;i<g;i++){
  if(s.at(i*(N/g))!=t.at(i*(M/g))){
     x=false; break;
  }
    
  }if(x)
    cout<<(N*M)/g<<endl;
  else
    cout<<-1<<endl;
  
   return 0;
}

Compiler output:
a.cc: In function 'int gcd(int, int)':
a.cc:4:10: error: 'max' was not declared in this scope; did you mean 'std::max'?
    4 |   return max(x,y);
      |          ^~~
      |          std::max
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
Language: C++

#include<bits/stdc++.h>
int gcd(int x,int y){
if(x==0 || y==0)
  return max(x,y);
  else{
   if(x<y)
     ruturn gcd(x,y%x);
    else if(y<x)
      return gcd(y,x%y);
    else
      return x;
  
  }

}
using namespace std;
int main(){
int N,M;
  cin>>N>>M;
  string s,t;
  cin>>s>>t;
  int g=gcd(N,M);
  bool x=true;
  for(int i=0;i<g;i++){
  if(s.at(i*(N/g))!=t.at(i*(M/g))){
     x=false; break;
  }
    
  }if(x)
    cout<<(N*M)/g<<endl;
  else
    cout<<-1<<endl;
  
   return 0;
}

Compiler output:
a.cc: In function 'int gcd(int, int)':
a.cc:4:10: error: 'max' was not declared in this scope; did you mean 'std::max'?
    4 |   return max(x,y);
      |          ^~~
      |          std::max
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc:7:6: error: 'ruturn' was not declared in this scope
    7 |      ruturn gcd(x,y%x);
      |      ^~~~~~
Language: Java

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long m = sc.nextLong();
    String s = sc.next();
    String t = sc.next();
    long L = (n * m) / gcd(n, m);
    long nn = L / n;
    long mm = L / m;
    int p = 0;
    long ans = L;
    for(long i = 0; i < n; i++) {
      long a = (i * nn);
      if((a % mm) == 0) {
        long j = a / mm;
        if(s.charAt(i) != t.charAt(j)) {
          p++;
          break;
        }
      }
    }
    if(p > 0) ans = -1;
    System.out.println(ans);
  }

  public static long gcd(long x, long y) {
    if(y == 0) return x;
    return gcd(y, (x % y));
  }
}

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

#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

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

//素因数分解
map<ll, ll>ins;
void facterize(ll n) {
	ll a = 2;
	while (n >= a * a) {
		if (n % a == 0) {
			ins[a]++;
			ins[a] = ins[a] % 1000000007;
			n /= a;
		}
		else {
			a++;
		}
	}
	ins[n]++;
}

vector<ll>relation[20], money(20, 1);
char s[110][110];
int dp[110][110];

int main() {
	ll n, m;
	cin >> n >> m;
	string s, t;
	cin >> s >> t;
	ll l = lcm(n, m);
	ll g = gcd(n, m);
	n /= g;
	m /= g;
	bool flag = true;
	rep(i, g) {
		if (s[i * n] != t[i * m]) {
			flag = false;
		}
	}
	if (flag) {
		cout << l << endl;
	}
	endl{
		cout << -1 << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:77:13: error: expected ';' before '{' token
   77 |         endl{
      |             ^
      |             ;
a.cc:79:9: error: statement cannot resolve address of overloaded function
   79 |         }
      |         ^
Language: C++

// 互いに素なら N * M
// それ以外、少なくとも LCM(N, M)
// 対応する文字が同じなら OK
// それ以外は NG ？

#include<iostream>
#include<vector>

using namespace std;

#define rep(i, n) for(int i = 0;i < (n);i++)

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

int main() {
    int N, M;
    string S, T;
    cin >> N >> M;
    cin >> S >> T;
    
    int g = __gcd(N, M);
    int l = N / g * M;


    int i = 0, j = 0;
    bool ok = true;
    while(i < N && j < M) {
        // cout << i << ", " << j << ": " << S[i] << ", " << T[j] << endl;
        if (S[i] != T[j]) ok = false;
        i += l / M;
        j += l / N;
    }

    if (ok) cout << l << endl;
    else cout << "-1" << endl;

    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:13: error: '__gcd' was not declared in this scope; did you mean 'gcd'?
   27 |     int g = __gcd(N, M);
      |             ^~~~~
      |             gcd
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main(void) {
  int N, M;
  cin >> N >> M;
  
  string N_str, M_str;
  cin >> N_str;
  cin >> M_str;
  
  long long L = lcm(N, M);
  
  vector<long long> n(N);
  vector<long long> m(M);
  for (int i = 0;i < N;i++) {
    n[i] = i * N / L + 1;
  }
  
  for (int i = 0;i < M;i++) {
    m[i] = i * M / L + 1;
  }
  
  for (int i = 0;i < N;i++) {
    for (int j = 0;j < M;j++) {
      if (N[i] == M[j]) {
        if(N_str[i] != M_str[j]) {
          cout << -1 << endl;
          return 0;
        }
      }
    }
  }
  
  cout << L << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:12: error: invalid types 'int[int]' for array subscript
   27 |       if (N[i] == M[j]) {
      |            ^
a.cc:27:20: error: invalid types 'int[int]' for array subscript
   27 |       if (N[i] == M[j]) {
      |                    ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main(void) {
  int N, M;
  cin >> N >> M;
  
  string N_str, M_str;
  cin >> N_str;
  cin >> M_str;
  
  long long L = lcm(N, M);
  
  vector<long long> n(N);
  vector<long long> m(M);
  for (int i = 0;i < N;i++) {
    n[i] = i * N / L + 1;
  }
  
  for (int i = 0;i < M;i++) {
    m[i] = i * M / L + 1;
  }
  
  for (int i = 0;i < N;i++) {
    for (int j = 0;j < M;j++) {
      if (N[i] == j[j]) {
        if(N_str[i] != M_str[j]) {
          cout << -1 << endl;
          return 0;
        }
      }
    }
  }
  
  cout << L << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:12: error: invalid types 'int[int]' for array subscript
   27 |       if (N[i] == j[j]) {
      |            ^
a.cc:27:20: error: invalid types 'int[int]' for array subscript
   27 |       if (N[i] == j[j]) {
      |                    ^
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;
}
int main() {
    ll N, M;string s, t;bool ok = true;
    cin >> N >> M >> s >> t;
    ll g = gcd(M, N),res = N / g * M;N /= g, M /= g;
    bool ok = true;
    for (ll i = 0; i < g; ++i) {
        if (s[i * N] != t[i * M]) ok = false;
    }
    if (ok) cout << res << endl;
    else cout << -1 << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:10: error: redeclaration of 'bool ok'
   11 |     bool ok = true;
      |          ^~
a.cc:8:30: note: 'bool ok' previously declared here
    8 |     ll N, M;string s, t;bool ok = true;
      |                              ^~
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;
}
int main() {
    ll N, M;string s, t;bool ok = true;
    cin >> N >> M >> s >> t;
    ll g = gcd(M, N),res = N / g * M;N /= g, M /= g;
    bool ok = true;
    for (lint i = 0; i < g; ++i) {
        if (s[i * N] != t[i * M]) ok = false;
    }
    if (ok) cout << res << endl;
    else cout << -1 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:10: error: redeclaration of 'bool ok'
   11 |     bool ok = true;
      |          ^~
a.cc:8:30: note: 'bool ok' previously declared here
    8 |     ll N, M;string s, t;bool ok = true;
      |                              ^~
a.cc:12:10: error: 'lint' was not declared in this scope; did you mean 'uint'?
   12 |     for (lint i = 0; i < g; ++i) {
      |          ^~~~
      |          uint
a.cc:12:22: error: 'i' was not declared in this scope
   12 |     for (lint i = 0; i < g; ++i) {
      |                      ^
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

ll gcd(ll m, ll n){
    ll tmp;
    while(m%n){
        tmp = n;
        n = m % n;
        m = tmp;
    }
    return n;
}

ll lcm(ll m, ll n){
    return m / gcd(m, n) * n;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

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

    ll l = lcm(n, m);

    ll ss = l/n;
    ll int st = l/m;
    ll ptr_s = 0;
    ll ptr_t = 0;
    while(ptr_s<l && ptr_t<l){
        if(ptr_s == ptr_t){
            if(s[ptr_s] != t[ptr_t]){
                cout << -1 << endl;
                return 0;
            }
            ptr_s += ss;
            ptr_t += st;
        }
        
        else if(ptr_s < ptr_t) ptr_s += ss;
        else ptr_t += st;
    }

    cout << l << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:5: error: two or more data types in declaration of 'st'
   35 |     ll int st = l/m;
      |     ^~
a.cc:45:22: error: 'st' was not declared in this scope; did you mean 'ss'?
   45 |             ptr_t += st;
      |                      ^~
      |                      ss
a.cc:49:23: error: 'st' was not declared in this scope; did you mean 'ss'?
   49 |         else ptr_t += st;
      |                       ^~
      |                       ss
Language: C++

#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, n) for(int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=pow(10,18);
const double inf=pow(10,10);
const ld pi=acosl(1);
const ll mod = 1000000007;
const ll dx[4]={0,0,1,-1};
const ll dy[4]={-1,1,0,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

ll count(string s){
  reverse(all(s));
  ll count=0;
  rep(i,s.size()){
    if(s[i]=='0')count++;
    else return count;
  }
  return count;
}

bool solve(){
  ll n,m;cin>>n>>m;
  string s,t;cin>>s>>t;
  ll ans=__detail::__lcm(s.size(),t.size());
  ll index=0;
  map<ll,char>mp;
  rep(i,s.size()){
    mp[index]=s[i];
    index+=ans/s.size();
  }
  index=0;
  rep(i,t.size()){
    if(mp[index]==0)continue;
    if(mp[index]!=t[i]){
      cout<<-1<<endl;return false;
    }
    index+=ans/t.size();
  }
  cout<<ans<<endl;

  return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed;
  return solve();
}


Compiler output:
a.cc: In function 'bool solve()':
a.cc:106:20: error: '__lcm' is not a member of 'std::__detail'
  106 |   ll ans=__detail::__lcm(s.size(),t.size());
      |                    ^~~~~
Language: C++

#include <bits/stdc++.h>
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;
}

int main(){
  int N,M;
  string S,T;
  cin >>N>>M;
  cin>>S;
  cin>>T;
  int L=N*M/gcd(N,M);
  char X[L];
  for(int i=0;i<L;i++){
    X[i]='X';
  }
  for (int i=0;i<N;i++){
    X[i*(L/N)+1]=S.at(i);
  }
  for (int i=0;i<M;i++){
    if(X[i*(L/M)+1]=='X'){
      continue;
    }
    else if(!(X[i*(L/M)+1]==T.at(i))){
      //cout<<X[0]<<X[1]<<X[2]<<X[3]<<X[4]<<X[5]<<endl;
      //cout<<X[i*(L/M)+1]<<" "<<T.at(i)<<endl;
      cout<<-1<<endl;
      return 0;
    }
  }
  cout<<setprecison(15)<<L<<endl;
  return 0;
}

  
  

Compiler output:
a.cc: In function 'int main()':
a.cc:39:9: error: 'setprecison' was not declared in this scope
   39 |   cout<<setprecison(15)<<L<<endl;
      |         ^~~~~~~~~~~
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<numeric>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int gcd ( int a, int b ) {
    if ( a % b == 0 ) return b;
    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;
//    if ( s[0] != t[0] ) {
//        cout << -1 << endl;
//        return 0;
//    }
    int lcm_num = lcm(n, m);
    int num = 0;
//    cout << lcd_num << endl;
    while(1) {
        if ( num > lcd_num ) break;
        if ( s[num * n / lcm_num] != t[num * m / lcm_num] ) {
//            cout << num << endl;
//            cout << s[num/n] << " " << t[num/m];
            cout << -1 << endl;
            return 0;
        }
        ++num;
    }
    cout << lcm_num << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:20: error: 'lcd_num' was not declared in this scope; did you mean 'lcm_num'?
   34 |         if ( num > lcd_num ) break;
      |                    ^~~~~~~
      |                    lcm_num
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,M; cin>>N>>M;
  string S,T; cin>>S>>T;
  map<int,char> M;
  int X=N*M/__gcd(N,M);
  rep(i,0,N) M[X/N*i+1]=S[i];
  int ans=X;
  rep(i,0,M){
    int Y=X/M*i+1;
    if(M.count(Y)&&M[Y]!=T[i]){
      ans=-1;
      break;
    }
  }
  cout<<ans<<endl;
  }



Compiler output:
a.cc: In function 'int main()':
a.cc:22:17: error: conflicting declaration 'std::map<long long int, char> M'
   22 |   map<int,char> M;
      |                 ^
a.cc:20:9: note: previous declaration as 'long long int M'
   20 |   int N,M; cin>>N>>M;
      |         ^
a.cc:24:15: error: invalid types 'long long int[long long int]' for array subscript
   24 |   rep(i,0,N) M[X/N*i+1]=S[i];
      |               ^
a.cc:28:10: error: request for member 'count' in 'M', which is of non-class type 'long long int'
   28 |     if(M.count(Y)&&M[Y]!=T[i]){
      |          ^~~~~
a.cc:28:21: error: invalid types 'long long int[long long int]' for array subscript
   28 |     if(M.count(Y)&&M[Y]!=T[i]){
      |                     ^
Language: C++

#include<bits/stdc++.h>


int main(void) {
    using namespace std;

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

    long g = __gcd(n, m);
    long l = n*m / g;
#include<bits/stdc++.h>


int main(void) {
    using namespace std;

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

    long g = __gcd(n, m);
    long l = n*m / g;

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

    cout << l << endl;
    return 0;
}

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

    cout << l << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:16: error: a function-definition is not allowed here before '{' token
   17 | int main(void) {
      |                ^
Language: C++

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz size
#define se second
#define fe first
#define mper make_pair
#define all(x) x.begin(), x.end()
#define mal ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define vl vector<ll>
#define vi vector<int>
#define vli vector <pair <ll, int> >
#define vll vector <pair <ll, ll> >
#define vii vector <pair <int, int> >
using namespace std;

ll n, m;
string a, b;

string nans1, nans2, mans1, mans2;

int main(){

mal

cin >> n >> m;
cin >> a >> b;

if(n == 1 || m == 1) {cout << -1;return;}

ll N = (n * m) / __gcd(n, m);


ll val1 = ((N / n) * (N / m) / __gcd((N / n), (N / m))) / (N / n);
//cout << val1;return 0;

for(int i = 0; i < a.sz() - 1; ++i) {

    if((i + 1) % val1 == 0) {nans1.pb(a[i]);}

}

for(int i = 1; i < a.sz(); ++i) {

    if(i % val1 == 0) {nans2.pb(a[i]);}

}

ll val2 = (N / n) * (N / m) / __gcd((N / n), (N / m)) / (N / m);

for(int i = 0; i < b.sz() - 1; ++i) {

    if((i + 1) % val2 == 0) {mans1.pb(b[i]);}

}

for(int i = 1; i < b.sz(); ++i) {

    if(i % val2 == 0) {mans2.pb(b[i]);}

}

if(nans1 == mans2 || nans1 == mans1 || nans2 == mans1 || nans2 == mans2) {cout << N;}
else {cout << -1;}

return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:34: error: return-statement with no value, in function returning 'int' [-fpermissive]
   29 | if(n == 1 || m == 1) {cout << -1;return;}
      |                                  ^~~~~~
Language: C++

#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


unsigned gcd(unsigned a, unsigned b) {
    if(a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r=a%b)) {
      a = b;
      b = r;
    }
    return b; //あまりが0ならそれが、最大公約数
}
//あまりが0になるまで a%b (a > bとする)
//あまりが0でなければ(あまりをrとし)、a = b; b = r         bと割ったあまり で　b%r する

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

int main(){
    //N:sの最初の長さ
    ll N,M;
    cin >> N >> M;
    string s,t;
    cin >> s >> t;

    ll l = lcm(N,M);
    // l = a * N; 
    // l = b * M; 
    ll a = l / N;
    ll b = l / M;

    ll l2 = lcm(a,b);

    for(int i = 0; i < l / l2; ++i)
    {
        if(s[i * l2 / a] != t[i * l2 / b])
        {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << l << endl;

    return 0;    
}



Compiler output:
a.cc: In function 'unsigned int gcd(unsigned int, unsigned int)':
a.cc:16:22: error: 'euclidean_gcd' was not declared in this scope
   16 |     if(a < b) return euclidean_gcd(b, a);
      |                      ^~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  ll n,m;
  cin>>n>>m;
  cout<<n/__gcd(n,m)*m<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:3: error: 'll' was not declared in this scope
    4 |   ll n,m;
      |   ^~
a.cc:5:8: error: 'n' was not declared in this scope; did you mean 'yn'?
    5 |   cin>>n>>m;
      |        ^
      |        yn
a.cc:5:11: error: 'm' was not declared in this scope; did you mean 'tm'?
    5 |   cin>>n>>m;
      |           ^
      |           tm
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  ll n=read(),m=read();
  cin>>n>>m;
  cout<<n/__gcd(n,m)*m<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:3: error: 'll' was not declared in this scope
    4 |   ll n=read(),m=read();
      |   ^~
a.cc:5:8: error: 'n' was not declared in this scope; did you mean 'yn'?
    5 |   cin>>n>>m;
      |        ^
      |        yn
a.cc:5:11: error: 'm' was not declared in this scope; did you mean 'tm'?
    5 |   cin>>n>>m;
      |           ^
      |           tm
Language: C++

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

typedef long long ll;
ll MOD = 1000000007;

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

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}


ll modpow(ll a,ll n,ll m){//modpow(a,n,m) := a ^ n (mod m)
  ll res = 1;
  while(n > 0){
    if(n & 1)res = res * a % m;
    a = a * a % m;
    n >>= 1;
  }
  return res;
}

ll modinv(ll a,ll p){//modinv(a,p) := pを法とするaの逆元(※pは素数でなければならない)
    ll res = modpow(a,p-2,p);
    return res;
}

int main(){
  ll N,M;
  string S,T;
  cin >> N >> M >> S >> T;
  if(N < M){
    swap(N,M);
    swap(S,T);//Nの方が常に大きい
  }
  if(S[0] != T[0]){
    cout << -1 << endl;
    return 0;
  }
  if(GCD(N,M) == 1){
    cout << N * M << endl;
    return 0;
  }
  if(GCD(N,M) == M){
    bool frag = 1;
    for(int i = 0;i < M;i++){
      if(S[i*N/M] != T[i]){
        frag = 0;
      }
    }
    if(frag){
      cout << N << endl;
    }else{
      cout << -1 << endl;
    }
    return 0;
  }
  bool frag = 1;
  for(int i = 0;i < GCD(N,M);i++){
    ll n = N / GCD(N,M),m = M/GCD(N,M);
    if(S[n * i] != T[m*i]){
      frag = 0;
    }
    if(frag){
      cout << GCD(N,M) * a * b << endl;
    }else{
      cout << -1 << endl;
    }
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:79:26: error: 'a' was not declared in this scope
   79 |       cout << GCD(N,M) * a * b << endl;
      |                          ^
a.cc:79:30: error: 'b' was not declared in this scope
   79 |       cout << GCD(N,M) * a * b << endl;
      |                              ^
Language: C++

#include <bits/stdc++.h>

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
//ここから書き始める

int main()
{
	cout <<setprecision(10);
	//例えば(N,M) (2,4)のとき、8文字にしても4文字にしても、被る（同じ要素番号）ところは変わらないので4のほうがいい。

	ll N , M ;
	cin >> N >> M;
	string S , T;
	cin >> S >> T; //S長さN, T長さM
	//最小公倍数
	ll G = __gcd(N,M);
	ll L = N*M / G;

	ll LongSize,ShortSize;
	string Long_String,Short_String;
	if(N>=M){
		LongSize = N;
		Long_String = S;
		ShortSize = M;
		Short_String = T;
	}else{
		LongSize = M;
		Long_String = T;
		ShortSize = N;
		Short_String = S;
	}
	//マップを作るのに使うのはShort <-文字列長いとたくさん作らないといけないので
	map<ll,char> ShortMap;
	rep(i,ShorSize){
		if(i==0){
			ShortMap[i] = Short_String[i];
		}
		else if(i % (L/ShortSize) == 0){
			ShortMap[i] = Short_String[i/(L/ShortSize)];
		}
	}
	if(ShortMap[0] == Long_String[0]){
		//ok
	}else{
		cout << -1 << endl;
		return 0;
	}
	//上の様な事を、一緒じゃなきゃいけないところに対してやっていく
	for(auto x:ShortMap){
		ll i = x.first ;// 
		if(i % (L / LongSize ) ==0){
			if(Long_String[i/(L/LongSize)] == x.second){
				//ok
			}else {
				cout << -1 << endl;
				return 0;
			}
		}

	}
	cout << L << endl;
	
}


Compiler output:
a.cc: In function 'bool coY()':
a.cc:19:32: warning: no return statement in function returning non-void [-Wreturn-type]
   19 | bool coY() {cout <<"Yes"<<endl;}
      |                                ^
a.cc: In function 'bool coN()':
a.cc:20:30: warning: no return statement in function returning non-void [-Wreturn-type]
   20 | bool coN(){cout <<"No"<<endl;}
      |                              ^
a.cc: In function 'int main()':
a.cc:53:15: error: 'ShorSize' was not declared in this scope; did you mean 'ShortSize'?
   53 |         rep(i,ShorSize){
      |               ^~~~~~~~
a.cc:13:48: note: in definition of macro 'For'
   13 | #define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
      |                                                ^
a.cc:53:9: note: in expansion of macro 'rep'
   53 |         rep(i,ShorSize){
      |         ^~~
Language: C++

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;

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

signed main() {
    int N,M;
    cin >> N >> M;
    string S,T;
    cin >> S >> T;
    if(N % M == 0 || M % N == 0 || S.at(0) != T.at(0)) {
        cout << -1 << endl;
    }
    else {
        L = N * M / gcd(N,M);
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:9: error: 'L' was not declared in this scope
   35 |         L = N * M / gcd(N,M);
      |         ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll gcd(ll x, ll y)
{
    ll temp;
    while (y != 0) {
        temp = y;
        y = x % y;
        x = temp;
    }
    return (x);
}

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

int main() {
  ll n,m;
  scanf("%lld%lld", &n,&m);
  string s,t;
  cin >> s >> t;

  ll ans = lcm(n,m);
  ll g = gcm(n,m);

  n /= g;
  m /= g;

  FOR(i,0,g-1){
    if(s[i*n]!=t[i*m]){
      cout << -1 << endl;
      return 0;
    }
  }

  cout << ans << endl;




}



Compiler output:
a.cc: In function 'int main()':
a.cc:44:10: error: 'gcm' was not declared in this scope; did you mean 'lcm'?
   44 |   ll g = gcm(n,m);
      |          ^~~
      |          lcm
Language: C++

#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
           
int main()
{
    int n, m;
    cin >> n >> m;
    string s, t;
    cin >> s;
    cin >> t;
    
    ll g = __gcd(n, m);
    ll L = n * m / g;
    ll step_s = n / g;
    ll step_t = m / g;

    bool is_ok = true;
    rep(i, 0, g)
    if (s[step_s * i] != t[step_t * i])
    {
        cout << -1 << endl;
        return;
    }
    
    // if (is_ok)
        cout << (ll) L << endl;
    // else
    //     cout << -1 << endl;
    return 0;
}

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

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

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

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

int main(){
  ll N,M; cin >> N >> M;
  string S,T; cin >> S >> T;
  ll L = lcm(N, M);
  bool flag = true;
while( i0 * b < N && i0 * a < M){
   if( T[ i0 * a] != S[i0 * b]){ flag = false;}}
   i0++;}

if( flag){ cout << L << endl;}
else{ cout << -1 << endl;}
 return 0;}
   

Compiler output:
a.cc: In function 'int main()':
a.cc:19:8: error: 'i0' was not declared in this scope; did you mean 'y0'?
   19 | while( i0 * b < N && i0 * a < M){
      |        ^~
      |        y0
a.cc:19:13: error: 'b' was not declared in this scope
   19 | while( i0 * b < N && i0 * a < M){
      |             ^
a.cc:19:27: error: 'a' was not declared in this scope
   19 | while( i0 * b < N && i0 * a < M){
      |                           ^
a.cc:21:4: error: 'i0' was not declared in this scope; did you mean 'y0'?
   21 |    i0++;}
      |    ^~
      |    y0
a.cc: At global scope:
a.cc:23:1: error: expected unqualified-id before 'if'
   23 | if( flag){ cout << L << endl;}
      | ^~
a.cc:24:1: error: expected unqualified-id before 'else'
   24 | else{ cout << -1 << endl;}
      | ^~~~
a.cc:25:2: error: expected unqualified-id before 'return'
   25 |  return 0;}
      |  ^~~~~~
a.cc:25:11: error: expected declaration before '}' token
   25 |  return 0;}
      |           ^
Language: C++

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1e18;

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 * b / g;
}
int main() {
  //
  ll n, m;
  cin >> n >> m;
  string s, t;
  cin >> s >> t;
  assert(s.size() == n && t.size() == m);

  ll l = lcm(n, m);
  ll nn = l / n;
  ll mm = l / m;
  vector<char> x(l, 0);
  for (int i = 0; i < n; i++) {
    x[i * nn] = s[i];
  }
  for (int i = 0; i < m; i++) {
    if (x[i * mm] == 0) continue;
    if (x[i * mm] != t[i]) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << l << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:47:3: error: 'assert' was not declared in this scope
   47 |   assert(s.size() == n && t.size() == m);
      |   ^~~~~~
a.cc:16:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
   15 | #include <unordered_set>
  +++ |+#include <cassert>
   16 | #include <vector>
Language: C++

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

long gcd(long a,long b)return (a%b==0)?b:gcd(b,a%b);
int main(){
  long i,N,M,p;
  cin>>N>>M;
  string s,t;
  cin>>s>>t;
  p=gcd(N,M);
  N/=p;M/=p;
  for(i=0;i<p;i++){
    if(s[i*N]!=t[i*M]){cout<<"-1"<<endl;return 0;}
  }
  cout<<N*M*p<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'long int gcd(long int, long int)':
a.cc:4:31: error: expected identifier before '(' token
    4 | long gcd(long a,long b)return (a%b==0)?b:gcd(b,a%b);
      |                               ^
a.cc:4:24: error: named return values are no longer supported
    4 | long gcd(long a,long b)return (a%b==0)?b:gcd(b,a%b);
      |                        ^~~~~~
Language: C++

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

int gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
int lcm(ll c,ll d){return c*d/gcd(c,d);}
int main(){
    ll n,m;
    cin>>n>>m;
    string s,t;
    cin>>s>>t;
    ll ans=lcm(n,m);
        bool flag=true;
    ll g=gcd(n,m);
    ll ans=n*m/g;
    n/=g;
    m/=g;
        for( i=0;i<g;i++){
            if(s[i*n]!=t[i*m])flag=false;
        }
        if(flag)cout<<ans<<endl;
        else cout<<-1<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:8: error: redeclaration of 'll ans'
   15 |     ll ans=n*m/g;
      |        ^~~
a.cc:12:8: note: 'll ans' previously declared here
   12 |     ll ans=lcm(n,m);
      |        ^~~
a.cc:18:14: error: 'i' was not declared in this scope
   18 |         for( i=0;i<g;i++){
      |              ^
Language: C++

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

int gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
int lcm(ll c,ll d){return c*d/gcd(c,d);}
int main(){
    ll n,m;
    cin>>n>>m;
    string s,t;
    cin>>s>>t;
    ll ans=lcm(n,m);
        bool flag=true;
    ll ans=lcm(n,m);
    ll g=gcd(n,m);
    n/=g;
    m/=g;
        for(ll i=0;i<g;i++){
            if(s.at(i*n)!=t.at(i*m))flag=false;
        }
        if(flag)cout<<ans<<endl;
        else cout<<-1<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:8: error: redeclaration of 'll ans'
   14 |     ll ans=lcm(n,m);
      |        ^~~
a.cc:12:8: note: 'll ans' previously declared here
   12 |     ll ans=lcm(n,m);
      |        ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
#define int long long

int GCD(int m,int n){
	if(n == 0) return m;
	else return GCD(n,m % n);
}

int LCM(int m,int n){
	int g = GCD(m,n);
	return m / g * n;
}

int main(){
	int n,m;
	cin >> n >> m;
	string s,t;
	cin >> s >> t;
	int g = GCD(n,m);
	int l = LCM(n,m);
	char mem[100100];
	int j = 0;
	for(int i = 0; i < n; i += (l / m)){
		mem[j] = s[i];
		j++;
	}
	j = 0;
	for(int i = 0; i < m; i += (l / n)){
		if(t[i] != mem[j]){
			cout << -1 << endl;
			return 0;
		}
		j++;
	}
	cout << l << endl;
}

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

#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define int ll
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<int,int>
const int M=100010;
const int MOD=1000000007;
const long long INF=1000000007;


int gcd(int N,int M){
	int tmp;
	if(N<M)return gcd(M,N);
	while(tmp=N%M){
		N=M;
		M=tmp;
	}
	return M;
}
int main(){
	int n,m;
	string s,t;
	cin>>n>>m;
	cin>>s>>t;
	int x=gcd(n,m);
	int ans=n*m/x;
	rep(i,0,x)
		if(s[i*n/x]!=t[i*m/x])
		{
			cout<<-1<<endl;
			return 0;
		}
	cout<<ans<<endl;
}

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

#include "bits/stdc++.h"
using namespace std;
using ll=long long;
using int long long;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<int,int>
const int M=100010;
const int MOD=1000000007;
const long long INF=1000000007;


int gcd(int N,int M){
	int tmp;
	if(N<M)return gcd(M,N);
	while(tmp=N%M){
		N=M;
		M=tmp;
	}
	return M;
}
int main(){
	int n,m;
	string s,t;
	cin>>n>>m;
	cin>>s>>t;
	int x=gcd(n,m);
	int ans=n*m/x;
	rep(i,0,x)
		if(s[i*n/x]!=t[i*m/x])
		{
			cout<<-1<<endl;
			return 0;
		}
	cout<<ans<<endl;
}

Compiler output:
a.cc:4:7: error: expected nested-name-specifier before 'int'
    4 | using int long long;
      |       ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main () {
  int N, M;
  string S, T;
  cin >> N >> M >> S >> T;
  int ans = (N * M)/ __gcd(N, M);
  vector<char> data(ans, ' ');
  int flag = 1;
  for(int i = 0; i < N; i++){
    data(i * (ans / N)) = S.at(i);
  }
  for(int i = 0; i < M; i++){
    if(data.at(i * (ans / M)) == ' '){
      data(i * (ans / M)) = T.at(i);
    } else {
      flag = 0;
      break;
    }
  }
  if(flag == 1)cout << ans << endl;
  else cout << -1 << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:9: error: no match for call to '(std::vector<char>) (int)'
   11 |     data(i * (ans / N)) = S.at(i);
      |     ~~~~^~~~~~~~~~~~~~~
a.cc:15:11: error: no match for call to '(std::vector<char>) (int)'
   15 |       data(i * (ans / M)) = T.at(i);
      |       ~~~~^~~~~~~~~~~~~~~
Language: C++


#include "pch.h"
#include <iostream>
#include <string>
long sc(long long x, long long y) {
	if (x < y) {
		int z = x;
		x = y;
		y = z;
	}
	if (x%y==0) return(y);
	return(sc(y, x%y));
}
using namespace std;
int main()
{	
	long long n, m,a,b,c;
	string s,t;
	cin >> n;
	cin >> m;
	getline(cin, s);
	getline(cin, s);
	getline(cin, t);
	c = sc(n,m);
	a = m / c;
	b = n / c;
	for (long long i = 0; i*a < n; i++) {
		if ((i*a) % b == 0) {
			if (s[i] != t[(i*a) / b]) {
				cout << -1;
				return 0;
			}
		}
	}
	cout << a*n;
	return 0;
}

Compiler output:
a.cc:2:10: fatal error: pch.h: No such file or directory
    2 | #include "pch.h"
      |          ^~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
//#define sz(x) int((x).size())

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


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


Compiler output:
a.cc: In function 'int main()':
a.cc:25:3: error: expected ',' or ';' before 'int'
   25 |   int n = N/GCD;
      |   ^~~
a.cc:29:12: error: 'n' was not declared in this scope
   29 |     if(S[i*n] != T[i*m]){
      |            ^
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>

using namespace std;
using ll = long long;

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

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

int main(){
    ll n,m;
    string s,t;
    cin >> n >> m;
    cin >> s;
    cin >> t;
    ll num=lcm(m,n);
    ll gcd=gcd(n,m);
    for(long int i=0;i<gcd;i++){
        if(s[i*n/gcd]!=t[i*m/gcd]){
            cout<<-1<<endl;
            return 0;
        }
  }
    cout << num << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:15: error: 'gcd' cannot be used as a function
   41 |     ll gcd=gcd(n,m);
      |            ~~~^~~~~
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>

using namespace std;
using ll = long long;

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

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

int main(){
    ll n,m;
    string s,t;
    cin >> n >> m;
    cin >> s >> t;
    num=lcm(m,n);
    if(num>=m+n)    cout << num;
    else    cout << -1;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:5: error: 'num' was not declared in this scope; did you mean 'enum'?
   39 |     num=lcm(m,n);
      |     ^~~
      |     enum
Language: C++

#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;
long long int gcd(long long int x,long long int y){
    long long int r;
    if(x == 0 || y == 0)  return 0;

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

int main(){
    long long int n,m;
    string s,t; cin >> n >> m >> s >> t;
    if(n<m){swap(s,t); swap(n,m);}
    ll lcm = (n * m) / gcd(n,m);
    if(lcm == n) assert(0)
    cout << 0 << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:49:5: error: expected ';' before 'cout'
   49 |     cout << 0 << endl;
      |     ^~~~
Language: C++

#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;
long long int gcd(long long int x,long long int y){
    long long int r;
    if(x == 0 || y == 0)  return 0;

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

int main(){
    long long int n,m;
    string s,t; cin >> n >> m >> s >> t;
    ll lcm = (n * m) / gcd(n,m);
   cout << lcm << endl;}
    return 0;
}

Compiler output:
a.cc:48:5: error: expected unqualified-id before 'return'
   48 |     return 0;
      |     ^~~~~~
a.cc:49:1: error: expected declaration before '}' token
   49 | }
      | ^
Language: C++

#include "pch.h"
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int gg(int a, int b) {
	if (a%b == 0)
		return b;
	else
		return gg(b, a%b);
}

int main() {
	int a, b, x;
	string s, t;
	bool ans = true;
	cin >> a >> b;
	cin >> s >> t;
	x = gg(a, b);
	a /= x;
	b /= x;
	for (int i = 0;i < x;i++) {
		if (s[a*i] != t[b*i]) {
			ans = false;
			break;
		}
	}
	if (ans)
		cout << x * a*b << endl;
	else
		cout << "-1" << endl;
}

Compiler output:
a.cc:1:10: fatal error: pch.h: No such file or directory
    1 | #include "pch.h"
      |          ^~~~~~~
compilation terminated.