prithivMLmods/Coder-Stat huggingface dataset:
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) {
  if (a > b)
    a = b;
}
template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) {
  if (a < b)
    a = b;
}

int main() {
  ll x, y;
  cin >> x >> y;
  for (ll i = 1; i <= 1e18 + 1; i++) {
    if (i % x == 0 && i % y != 0) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) {
  if (a > b)
    a = b;
}
template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) {
  if (a < b)
    a = b;
}

int main() {
  ll x, y;
  cin >> x >> y;
  if (x % y == 0)
    cout << -1 << endl;
  else
    cout << x << endl;
}
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm> // upper_bound(A, A+N, num):>, lower_bound(A, A+N, num):>=
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list> // push_front(x), push_back(x), pop_front(), pop_back(), insert(index, x)
#include <map>   // M[key],  insert(key, val), erase(key), find(key),
#include <queue> // push(x), front(), pop()
#include <set>   // insert(key), erase(key), find(key)
#include <sstream>
#include <stack> // push(x), top(), pop()
#include <string>
#include <vector> // V[i],  push_back(x), pop_back(), insert(index, x), erase(index), sort(v.begin(), v.end(), greater<int>())

using namespace std;
typedef long long ll;
// typedef pair<int, int> P;

#define pi 3.141592653589793)
#define mod 1000000007

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

void solve() {
  ll x, y;
  cin >> x >> y;
  if (x == y) {
    cout << -1 << endl;
    return;
  }
  ll ans = x;
  while (ans <= 1000000000000000000) {
    ans += x;
    if (ans < y || ans % y != 0) {
      cout << ans << endl;
      return;
    }
  }
  cout << -1 << endl;
}

int main() {
  solve();
  return 0;
}

Fixed submission:
#include <algorithm> // upper_bound(A, A+N, num):>, lower_bound(A, A+N, num):>=
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list> // push_front(x), push_back(x), pop_front(), pop_back(), insert(index, x)
#include <map>   // M[key],  insert(key, val), erase(key), find(key),
#include <queue> // push(x), front(), pop()
#include <set>   // insert(key), erase(key), find(key)
#include <sstream>
#include <stack> // push(x), top(), pop()
#include <string>
#include <vector> // V[i],  push_back(x), pop_back(), insert(index, x), erase(index), sort(v.begin(), v.end(), greater<int>())

using namespace std;
typedef long long ll;
// typedef pair<int, int> P;

#define pi 3.141592653589793)
#define mod 1000000007

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

void solve() {
  ll x, y;
  cin >> x >> y;
  int ans = -1;
  if (!(x >= y && x % y == 0))
    ans = x;
  cout << ans << endl;
}

int main() {
  solve();
  return 0;
}
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define out(S) cout << (S) << endl;
#define ShowAll(collection)                                                    \
  for (auto i : collection) {                                                  \
    out(i);                                                                    \
  }
#define beginend(v) v.begin(), v.end()
#define Foreach(item, collection) for (auto item : collection)

using pii = pair<int, int>;
using vb = vector<bool>;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvc = vector<vector<char>>;
using ti3 = tuple<int, int, int>;
using ulong = unsigned long;
template <typename T> void removeAt(vector<T> &v, int index) {
  v.erase(v.begin() + index);
}
#define OCB(c)                                                                 \
  (c & 1) | (c & 2) << 2 | (c & 4) << 4 | (c & 8) << 6 | (c & 16) << 8 |       \
      (c & 32) << 10 | (c & 64) << 12 | (c & 128) << 14

int main() {
  long X, Y;
  cin >> X >> Y;
  auto k = X;
  if (X == Y) {
    out(-1);
    return 0;
  }
  for (;; k += X) {
    if (k % Y != 0) {
      out(k);
      return 0;
    }
  }
}


Fixed submission:
#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define out(S) cout << (S) << endl;
#define ShowAll(collection)                                                    \
  for (auto i : collection) {                                                  \
    out(i);                                                                    \
  }
#define beginend(v) v.begin(), v.end()
#define Foreach(item, collection) for (auto item : collection)

using pii = pair<int, int>;
using vb = vector<bool>;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvc = vector<vector<char>>;
using ti3 = tuple<int, int, int>;
using ulong = unsigned long;
template <typename T> void removeAt(vector<T> &v, int index) {
  v.erase(v.begin() + index);
}
#define OCB(c)                                                                 \
  (c & 1) | (c & 2) << 2 | (c & 4) << 4 | (c & 8) << 6 | (c & 16) << 8 |       \
      (c & 32) << 10 | (c & 64) << 12 | (c & 128) << 14

int main() {
  long X, Y;
  cin >> X >> Y;
  auto k = X;
  if (X % Y == 0) {
    out(-1)
  } else {
    out(X);
  }
}
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  long long x, y;
  cin >> x >> y;
  int cnt = 2;
  long long kari = 0;
  long long tmp = x;
  if (x != y) {
    for (long long i = 0; true; i++) {
      kari = cnt * tmp;
      if (kari >= 1000000000000000000) {
        puts("-1\n");
        break;
      }
      if (kari % y != 0) {
        cout << kari << endl;
        break;
      }
      cnt++;
    }
  } else if (x == y)
    puts("-1\n");
  return 0;
}

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

int main() {
  long long x, y;
  cin >> x >> y;
  int cnt = 2;
  long long kari = 0;
  long long tmp = x;
  if (x != y) {
    for (long long i = 0; true; i++) {
      kari = cnt * tmp;
      if (kari >= 100000000000000) {
        puts("-1\n");
        break;
      }
      if (kari % y != 0) {
        cout << kari << endl;
        break;
      }
      cnt++;
    }
  } else if (x == y)
    puts("-1\n");
  return 0;
}
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
using namespace std;
const int MaxN = 1e5;

int main() {
  long long T, ans, x, y;
  while (~scanf("%lld %lld", &x, &y)) {
    T = x * y;
    for (int i = 1;; i++) {
      ans = x * i;
      if (ans > T) {
        ans = -1;
        break;
      }
      if (ans % y != 0)
        break;
    }
    printf("%lld\n", ans);
  }
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
using namespace std;
const int MaxN = 1e5;

int main() {
  long long T, ans, x, y;
  while (~scanf("%lld %lld", &x, &y)) {
    T = x * y;
    for (int i = 1;; i++) {
      ans = x * i;
      if (ans > T) {
        ans = -1;
        break;
      }
      if (ans % y != 0)
        break;
      if (x % y == 0) {
        ans = -1;
        break;
      }
    }
    printf("%lld\n", ans);
  }
  return 0;
}
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
#define int long long
using namespace std;
signed main() {
  int X, Y;
  cin >> X >> Y;

  for (int i = 0;; i++) {
    if (i % X == 0 && i % Y != 0 && i <= 1000000000000000000) {
      cout << i << endl;
    } else {
      cout << -1 << endl;
    }
  }
}

Fixed submission:
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
#define int long long
using namespace std;
signed main() {
  int X, Y;
  cin >> X >> Y;

  if (X % Y == 0) {
    cout << -1 << endl;
  } else {
    cout << X << endl;
  }
}
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
typedef unsigned int UINT;
using namespace std;

int main(void) {
  const long long MAX = 1000000000000000000;
  long long X, Y;
  long long ans;
  cin >> X >> Y;
  if (X == Y) {
    cout << -1 << endl;
    return 0;
  }

  while (ans < MAX) {
    ans += X;
    if (ans % Y != 0) {
      cout << ans << endl;
      return 0;
    }
  }
  cout << -1 << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
typedef unsigned int UINT;
using namespace std;

int main(void) {
  const long long MAX = 1000000000000000000;
  long long X, Y;
  long long ans;
  cin >> X >> Y;
  if (X == Y) {
    cout << -1 << endl;
    return 0;
  }
  if (X % Y == 0) {
    cout << -1 << endl;
    return 0;
  }

  while (ans < MAX) {
    ans += X;
    if (ans % Y != 0) {
      cout << ans << endl;
      return 0;
    }
  }
  cout << -1 << endl;

  return 0;
}
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t x, y;
  cin >> x >> y;
  int64_t ans = -1;

  int64_t a = 0;
  while (true) {
    a += x;
    if (x % y != 0) {
      ans = x;
      break;
    }
  }

  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t x, y;
  cin >> x >> y;
  int64_t ans = -1;

  int64_t a = 0;
  if (x % y == 0) {
    cout << -1 << endl;
    return 0;
  }
  while (true) {
    a += x;
    if (x % y != 0) {
      ans = x;
      break;
    }
  }

  cout << ans << endl;
}
Problem p03437 (Python)

Buggy submission (status: Time Limit Exceeded):
import sys

sys.setrecursionlimit(10**7)
input = sys.stdin.readline
f_inf = float("inf")
mod = 10**9 + 7


def resolve():
    x, y = map(int, input().split())

    if x == y:
        print(-1)
        exit()

    for res in range(x, 10**18, x):
        if res % y:
            print(res)
            break


if __name__ == "__main__":
    resolve()


Fixed submission:
import sys

sys.setrecursionlimit(10**7)
input = sys.stdin.readline
f_inf = float("inf")
mod = 10**9 + 7


def resolve():
    x, y = map(int, input().split())

    if x % y == 0:
        print(-1)
        exit()

    for res in range(x, 10**18, x):
        if res % y:
            print(res)
            break


if __name__ == "__main__":
    resolve()
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

#define M 100005
#define ll long long
#define PI atan(1.0) * 4
#define mst(x, v) memset(x, v, sizeof(x))
#define inf (int)1e9
#define rush()                                                                 \
  int T;                                                                       \
  scanf("%d", &T);                                                             \
  while (T--)

typedef pair<int, int> P;

int main() {

  ll x, y, temp;
  scanf("%lld %lld", &x, &y);

  temp = x;

  if (y == x) {
    puts("-1");
    return 0;
  }

  while (1) {
    x += temp;
    if (x % y != 0)
      break;
  }

  printf("%lld\n", x);
}


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

#define M 100005
#define ll long long
#define PI atan(1.0) * 4
#define mst(x, v) memset(x, v, sizeof(x))
#define inf (int)1e9
#define rush()                                                                 \
  int T;                                                                       \
  scanf("%d", &T);                                                             \
  while (T--)

typedef pair<int, int> P;

int main() {

  ll x, y, temp;
  scanf("%lld %lld", &x, &y);

  temp = x;

  if (x % y == 0) {
    puts("-1");
    return 0;
  }

  while (1) {
    x += temp;
    if (x % y != 0)
      break;
  }

  printf("%lld\n", x);
}
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

int main(void) {
  long long a, b;

  std::cin >> a >> b;

  std::vector<long long> primes(10000000);

  primes[0] = 2;
  int prime_i = 1;

  for (long long i = 3; i * i < 1000000000000LL; i++) {
    bool prime = true;
    for (long long j = 0; j < prime_i; j++) {
      if (i % primes[j] == 0) {
        prime = false;
        break;
      }
    }
    if (prime) {
      primes[prime_i] = i;
      prime_i++;
    }
  }

  for (int i = 0; i < prime_i; i++) {
    if ((a * primes[i]) % b != 0) {
      std::cout << a * primes[i] << std::endl;
      return 0;
    }
  }
  std::cout << -1 << std::endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

int main(void) {
  long long a, b;

  std::cin >> a >> b;

  std::vector<long long> primes(10000000);

  primes[0] = 2;
  int prime_i = 1;

  for (long long i = 3; i * i < 100000000LL; i++) {
    bool prime = true;
    for (long long j = 0; j < prime_i; j++) {
      if (i % primes[j] == 0) {
        prime = false;
        break;
      }
    }
    if (prime) {
      primes[prime_i] = i;
      prime_i++;
    }
  }

  for (int i = 0; i < prime_i; i++) {
    if ((a * primes[i]) % b != 0) {
      std::cout << a * primes[i] << std::endl;
      return 0;
    }
  }
  std::cout << -1 << std::endl;
  return 0;
}
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <stdio.h>
int main() {
  long long int x, y, i, p;
  scanf("%lld %lld", &x, &y);
  for (i = 2;; i++) {
    if (x == 0) {
      printf("0\n");
      break;
    }
    if (y == 0) {
      printf("%lld\n", x);
      break;
    }
    if (x == y) {
      printf("-1\n");
      break;
    }
    p = x * i;
    if (p % y != 0) {
      printf("%lld\n", p);
      break;
    }
  }
  return 0;
}


Fixed submission:
#include <stdio.h>
int main() {
  long long int x, y, i, p;
  scanf("%lld %lld", &x, &y);
  for (i = 2;; i++) {
    if (x == 0) {
      printf("0\n");
      break;
    }
    if (y == 0) {
      printf("%lld\n", x);
      break;
    }
    if (x == y || x % y == 0) {
      printf("-1\n");
      break;
    }
    p = x * i;
    if (p % y != 0) {
      printf("%lld\n", p);
      break;
    }
  }
  return 0;
}
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  long X, Y;
  cin >> X >> Y;
  if (X == Y || Y == 1) {
    cout << -1 << endl;
    return 0;
  }
  long ub = 1;
  for (int i = 0; i < 18; i++)
    ub *= 10;
  for (int i = 1; X * i <= ub; i++) {
    long x = X * i;
    if (x % Y != 0) {
      cout << x << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

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

int main() {
  long X, Y;
  cin >> X >> Y;
  if (X % Y) {
    long ub = 1;
    for (int i = 0; i < 18; i++)
      ub *= 10;
    for (int i = 1; X * i <= ub; i++) {
      long x = X * i;
      if (x % Y != 0) {
        cout << x << endl;
        return 0;
      }
    }
  }
  cout << -1 << endl;
}
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <exception>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define per(i, a, n) for (ll i = (a); i > (n); i--)
#define lep(i, a, n) for (ll i = (a); i <= (n); i++)
#define pel(i, a, n) for (ll i = (a); i >= (n); i--)
#define clr(a, b) memset((a), (b), sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+18;
ll n, m, l;
string s, t;
ll d[100000], dp[500][500];

int main() {
  cin >> n >> m;
  if (n % m == 0)
    puts("-1");
  else {
    bool f = true;
    rep(i, n / m + 2, n / m + 1000000000) {
      // print(n*i);
      if (n * i > INF)
        break;
      if ((n * i) % m != 0 && (n * i) > m) {
        print(n * i);
        f = false;
        break;
      }
      i += 1;
    }
    if (f)
      puts("-1");
  }
  return 0;
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <exception>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define per(i, a, n) for (ll i = (a); i > (n); i--)
#define lep(i, a, n) for (ll i = (a); i <= (n); i++)
#define pel(i, a, n) for (ll i = (a); i >= (n); i--)
#define clr(a, b) memset((a), (b), sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+18;
ll n, m, l;
string s, t;
ll d[100000], dp[500][500];

int main() {
  cin >> n >> m;
  if (n % m == 0)
    puts("-1");
  else {
    print(n * 100000007);
  }
  return 0;
}
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < b; i++)
#define Rep(i, a, b) for (int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(), (v).end()
using namespace std;

void solve() {
  ll x, y;
  cin >> x >> y;
  ll X = x;
  while (1) {
    X += x;
    if (X % y != 0) {
      cout << X << endl;
      return;
    }
    if (X > 1000000000000000000 || x == y) {
      cout << -1 << endl;
      return;
    }
  }
}

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

  solve();
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < b; i++)
#define Rep(i, a, b) for (int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(), (v).end()
using namespace std;

void solve() {
  ll x, y;
  cin >> x >> y;
  ll X = x;
  while (1) {
    X += x;
    if (X % y != 0) {
      cout << X << endl;
      return;
    }
    if (x % y == 0) {
      cout << -1 << endl;
      return;
    }
  }
}

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

  solve();
  return 0;
}
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int x, y;
  cin >> x >> y;
  int ans = -1;
  if (x != y) {
    for (int i = x * 2; i < 1000000000000000000; i + x) {
      if (i % y != 0) {
        ans = i;
        break;
      }
    }
    cout << ans << endl;
  } else {
    cout << ans << endl;
  }
}


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

int main() {
  int x, y;
  cin >> x >> y;
  cout << ((x % y == 0) ? -1 : x) << endl;
}
Problem p03437 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  long long X, Y, A = pow(10, 18);
  cin >> X >> Y;
  if (X %= 0) {
    cout << -1 << endl;
  } else {
    cout << X << endl;
  }
}

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

int main() {
  long long X, Y, A = pow(10, 18);
  cin >> X >> Y;
  if (X % Y == 0) {
    cout << -1 << endl;
  } else {
    cout << X << endl;
  }
}
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  long long x, y;
  cin >> x >> y;
  if (y == x) {
    cout << -1 << endl;
    return 0;
  }

  int Maxv = (int)1e9;
  for (int i = 1; i <= Maxv; i++) {
    long long a = x * i;
    if (a % y != 0) {
      cout << a << endl;
      return 0;
    }
  }
}

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

int main() {
  long long x, y;
  cin >> x >> y;
  if (y == x) {
    cout << -1 << endl;
    return 0;
  }
  if (x > y && x % y == 0) {
    cout << -1 << endl;
    return 0;
  }

  int Maxv = (int)1e9;
  for (int i = 1; i <= Maxv; i++) {
    long long a = x * i;
    if (a % y != 0) {
      cout << a << endl;
      return 0;
    }
  }
}
Problem p03437 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
typedef long long ll;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
int main() {
#ifndef ONLINE_JUDGE
  freopen("in.txxt", "r", stdin);
#endif
  int a, b;
  cin >> a >> b;
  if (a % b == 0)
    cout << -1 << endl;
  else
    cout << lcm(a, b) - a << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
typedef long long ll;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
int main() {
  // #ifndef ONLINE_JUDGE
  // freopen("in.txxt","r",stdin);
  // #endif
  int a, b;
  cin >> a >> b;
  if (a % b == 0)
    cout << -1 << endl;
  else
    cout << lcm(a, b) - a << endl;
}
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int x, y;
  cin >> x >> y;

  if (x % y == 0) {
    cout << -1 << endl;
  } else {
    int i = 1;
    while (1) {
      if (i % x == 0 && i % y != 0) {
        cout << i << endl;
        break;
      }
      i++;
    }
  }
}


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

int main() {
  int x, y;
  cin >> x >> y;

  if (x % y == 0) {
    cout << -1 << endl;
  } else {
    int i = 1;
    while (1) {
      if (i % x == 0 && i % y != 0) {
        cout << i << endl;
        break;
      }
      i *= x;
    }
  }
}
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>

using namespace std;

int main() {
  int X, Y;
  cin >> X >> Y;
  int res = -1;
  for (int i = 1; i <= 1e9; ++i) {
    if (i % X == 0 && i % Y != 0) {
      res = i;
      break;
    }
  }
  cout << res << endl;
}

Fixed submission:
#include <bits/stdc++.h>

using namespace std;

int main() {
  int X, Y;
  cin >> X >> Y;
  if (X % Y == 0)
    cout << -1 << endl;
  else
    cout << X << endl;
}
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
// cin.sync_with_stdio(false);

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

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector> DVector;

int main(int argc, char const *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);

  ull x, y;
  cin >> x >> y;

  ull ans = 1;
  int check = -1;
  ull limit = pow(10, 18);
  // cout << "error_1" << endl;
  // cout << limit << endl;
  for (int i = 2; ans < limit; ++i) {
    // cout << "error_2" << endl;
    // cout << ans << endl;
    ans = x * i;
    if (ans % y != 0) {
      check = 0;
      break;
    }
  }
  // cout << "error_3" << endl;
  if (check == 0) {
    cout << ans << endl;
  } else {
    cout << check << endl;
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
// cin.sync_with_stdio(false);

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

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector> DVector;

int main(int argc, char const *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);

  ull x, y;
  cin >> x >> y;

  ull ans = 1;
  int check = -1;
  ull limit = pow(10, 18);
  // cout << "error_1" << endl;
  // cout << limit << endl;
  for (int i = 2; ans < limit; ++i) {
    // cout << "error_2" << endl;
    // cout << ans << endl;
    if (i == 2) {
      if (x % y == 0) {
        break;
      }
    }
    ans = x * i;
    if (ans % y != 0) {
      check = 0;
      break;
    }
  }
  // cout << "error_3" << endl;
  if (check == 0) {
    cout << ans << endl;
  } else {
    cout << check << endl;
  }
  return 0;
}
Problem p03437 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main() {
  ll X, Y;
  cin >> X >> Y;
  if (X % Y == 0) {
    return -1;
  } else {
    cout << X << endl;
  }
}

Fixed submission:
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main() {
  ll X, Y;
  cin >> X >> Y;
  if (X % Y == 0) {
    cout << -1 << endl;
    ;
  } else {
    cout << X << endl;
  }
}
Problem p03437 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  int x, y;
  cin >> x >> y;
  if (x % y == 0)
    return puts("-1");
  for (int i = 2;; i++)
    if (y % i)
      return printf("%lld\n", 1LL * i * x), 0;
  puts("-1");
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  int x, y;
  cin >> x >> y;
  if (x % y == 0)
    return puts("-1"), 0;
  for (int i = 2;; i++)
    if (y % i)
      return printf("%lld\n", 1LL * i * x), 0;
  puts("-1");
  return 0;
}
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;

int x, y;

int main() {
  cin >> x >> y;
  if (x == y) {
    puts("-1");
  } else {
    for (LL i = 2;; ++i) {
      if (i * x % y) {
        printf("%lld\n", i * x);
        return 0;
      }
    }
  }
}

Fixed submission:
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;

int x, y;

int main() {
  cin >> x >> y;
  if (x % y == 0) {
    puts("-1");
  } else {
    for (LL i = 2;; ++i) {
      if (i * x % y) {
        printf("%lld\n", i * x);
        return 0;
      }
    }
  }
}
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
  ll x, y;
  cin >> x >> y;
  if (x % y == 0)
    puts("-1");
  else {
    ll i = x + 1;
    while (1) {
      if (i % x == 0 && i % y != 0) {
        cout << i << endl;
        return 0;
      }
      i++;
    }
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
  ll x, y;
  cin >> x >> y;
  if (x % y == 0)
    puts("-1");
  else
    cout << x << endl;
  return 0;
}
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
#define ms(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define eps 0.0000000001
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);
#define random(a, b) rand() * rand() % (b - a + 1) + a
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 1000000 + 10;
const int mod = 1000000007;
int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
#endif
  IOS LL a, b;
  cin >> a >> b;
  if (a == b || b == 1) {
    cout << -1 << endl;
    return 0;
  } else {
    for (LL i = a; i <= 1000000000000000000LL; i += a) {
      if (i % b != 0) {
        cout << i << endl;
        return 0;
      }
    }
    cout << -1 << endl;
  }
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
#define ms(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define eps 0.0000000001
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);
#define random(a, b) rand() * rand() % (b - a + 1) + a
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 1000000 + 10;
const int mod = 1000000007;
int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
#endif
  IOS LL a, b;
  cin >> a >> b;
  if (a == b || b == 1) {
    cout << -1 << endl;
    return 0;
  } else {
    for (LL i = a; i <= 1000000000000000000LL && i < a * b; i += a) {
      if (a % b != 0) {
        cout << i << endl;
        return 0;
      }
    }
    cout << -1 << endl;
  }
  return 0;
}
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
  fastIO;

  llint x, y;
  cin >> x >> y;
  if (x == y)
    cout << -1;
  else {
    for (llint i = 1;; i++) {
      llint p = x * i;
      if (p % x == 0 && p % y != 0) {
        cout << p;
        return 0;
      }
    }
  }
}

Fixed submission:
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
  fastIO;

  llint x, y;
  cin >> x >> y;
  if (x % y == 0)
    cout << -1;
  else {
    for (llint i = 1;; i++) {
      llint p = x * i;
      if (p % x == 0 && p % y != 0) {
        cout << p;
        return 0;
      }
    }
  }
}
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  long long x, y;
  cin >> x >> y;
  if (x == y || y == 1) {
    cout << "-1";
    return 0;
  }
  long long z = x;
  while (z % y == 0)
    z += x;
  cout << z;
  return 0;
}


Fixed submission:
#include <iostream>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  long long x, y;
  cin >> x >> y;
  if (x % y == 0 || y == 1) {
    cout << "-1";
    return 0;
  }
  long long z = x;
  while (z % y == 0)
    z += x;
  cout << z;
  return 0;
}
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main() {
  int x, y;
  cin >> x >> y;
  for (int i = x + 1; i <= 1000000000000; i++) {
    if (i % x == 0 && i % y != 0) {
      cout << i;
      return 0;
    }
  }
  cout << "-1";
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
int a, b;
main() {
  cin >> a >> b;
  if (a % b)
    cout << a << endl;
  else
    cout << "-1" << endl;
  return 0;
}
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <string>
using namespace std;

long long n, m;
int main() {
  scanf("%lld%lld", &n, &m);
  for (int i = 2; i <= 1000000000; i++) {
    if (n * i % m != 0) {
      printf("%lld\n", i * n);
      return 0;
    }
  }
  printf("-1\n");
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <string>
using namespace std;

long long n, m;
int main() {
  scanf("%lld%lld", &n, &m);
  for (int i = 2; i <= 10; i++) {
    if (n * i % m != 0) {
      printf("%lld\n", i * n);
      return 0;
    }
  }
  printf("-1\n");
}
Problem p03437 (Python)

Buggy submission (status: Time Limit Exceeded):
x, y = [int(i) for i in input().split()]
if x % y == 0:
    print(-1)
else:
    i = 2
    while True:
        if i * x % y != 0:
            print(i * x)
            break


Fixed submission:
x, y = [int(i) for i in input().split()]
if x % y == 0:
    print(-1)
else:
    i = 2
    while True:
        if i * x % y != 0:
            print(i * x)
            break
        i += 1
Problem p03437 (C++)

Buggy submission (status: Runtime Error):
#include <cstdio>
#include <iostream>
using namespace std;
int x, y;
int main() {
  if (x % y != 0)
    cout << x;
  else
    cout << -1;
  return 0;
}

Fixed submission:
#include <cstdio>
#include <iostream>
using namespace std;
int x, y;
int main() {
  cin >> x >> y;
  if (x % y != 0)
    cout << x;
  else
    cout << -1;
  return 0;
}
Problem p03437 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;
#define _for(i, j, N) for (int i = (j); i < (N); i++)
#define _rep(i, j, N) for (int i = (j); i <= (N); i++)
#define ALL(x) x.begin(), x.end()
#define LL long long

int get_int() {
  int x;
  scanf("%d", &x);
  return x;
}
LL get_long() {
  LL x;
  scanf("%lld", &x);
  return x;
}

int main() {
  LL a, b;
  scanf("%lld %lld", &a, &b);
  LL gd = __gcd(a, b);
  if (b == gd)
    return printf("%d\n", -1);
  else {
    printf("%lld\n", a);
  }

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>

using namespace std;
#define _for(i, j, N) for (int i = (j); i < (N); i++)
#define _rep(i, j, N) for (int i = (j); i <= (N); i++)
#define ALL(x) x.begin(), x.end()
#define LL long long

int get_int() {
  int x;
  scanf("%d", &x);
  return x;
}
LL get_long() {
  LL x;
  scanf("%lld", &x);
  return x;
}

int main() {
  LL a, b;
  scanf("%lld %lld", &a, &b);
  LL gd = __gcd(a, b);
  if (b == gd)
    printf("%d\n", -1);
  else {
    printf("%lld\n", a);
  }

  return 0;
}
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <string>

using namespace std;

typedef long long ll;
const int Maxn = 1e9 + 10;
const int N = 1e5 + 10;
const int INF = (0x7fffffff) / 2;

int main() {
  ll x, y;
  while (~scanf("%lld %lld", &x, &y)) {
    ll n = 0;
    for (ll i = 1; i <= 1e9; i++) {
      if ((i % x == 0) && (i % y != 0)) {
        n = x;
        break;
      }
    }
    if (n == 0)
      printf("-1\n");
    else
      printf("%lld\n", n);
  }
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <string>

using namespace std;

typedef long long ll;
const int Maxn = 1e9 + 10;
const int N = 1e5 + 10;
const int INF = (0x7fffffff) / 2;

int main() {
  ll x, y;
  while (~scanf("%lld %lld", &x, &y)) {
    ll n = 0;
    for (ll i = 1; i <= 1e8; i++) {
      ll c = i * x;
      if (c % y != 0) {
        n = c;
        break;
      }
    }
    if (n == 0)
      printf("-1\n");
    else
      printf("%lld\n", n);
  }
}
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <functional>
#include <initializer_list>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(t) t.begin(), t.end()
#define mat(type, row, col, init)                                              \
  vector<vector<type>>(row, vector<type>(col, init));

int main() {
  ull x, y;
  cin >> x >> y;

  ull xx = 2 * x;
  if (x % y == 0) {
    cout << -1;
    return 0;
  }
  while (xx <= 1e18) {
    if (xx % y != 0) {
      cout << xx;
      return 0;
    }
  }
  cout << -1;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <functional>
#include <initializer_list>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(t) t.begin(), t.end()
#define mat(type, row, col, init)                                              \
  vector<vector<type>>(row, vector<type>(col, init));

int main() {
  ull x, y;
  cin >> x >> y;

  ull xx = 2 * x;
  if (x % y == 0) {
    cout << -1;
    return 0;
  }
  while (xx <= 1e18) {
    if (xx % y != 0) {
      cout << xx;
      return 0;
    }
    xx += x;
  }
  cout << -1;
  return 0;
}
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <ctype.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

// #include<bits/stdc++.h>

int main() {
  long long int a, b;
  cin >> a >> b;

  for (long long int i = 1; i <= max(b, a); i++) {
    if (i % a == 0 && i % b) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Fixed submission:
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <ctype.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

// #include<bits/stdc++.h>

int main() {
  long long int a, b;
  cin >> a >> b;

  for (long long int i = 0; i <= max(b, a); i += a) {
    if (i % a == 0 && i % b) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < int(N); ++i)
int main() {
  ll X, Y;
  cin >> X >> Y;
  ll ans = -1;
  ll N = X;
  ll i = 1;
  if (X != Y) {
    while (N <= 1e18) {
      if (X * i % Y != 0) {
        ans = X * i;
        break;
      }
      i++;
    }
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < int(N); ++i)
int main() {
  ll X, Y;
  cin >> X >> Y;
  ll ans = -1;
  ll N = X;
  ll i = 1;
  if (X % Y != 0) {
    while (N <= 1e18) {
      if (X * i % Y != 0) {
        ans = X * i;
        break;
      }
      i++;
    }
  }
  cout << ans << endl;
}
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 100005;

LL X, Y;

int main() {
  while (scanf("%lld %lld", &X, &Y) != EOF) {
    if (X == Y || Y == 1)
      printf("-1\n");
    else {
      LL ans = 0;
      for (LL i = 2;; i++) {
        LL tmp = X * i;
        if (tmp % Y != 0) {
          ans = tmp;
          break;
        }
        if (tmp > INF) {
          ans = -1;
          break;
        }
      }
      printf("%lld\n", ans);
    }
  }
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 100005;

LL X, Y;

int main() {
  while (scanf("%lld %lld", &X, &Y) != EOF) {
    if (X == Y || Y == 1 || (X % Y == 0))
      printf("-1\n");
    else {
      LL ans = 0;
      for (LL i = 2;; i++) {
        LL tmp = X * i;
        if (tmp % Y != 0) {
          ans = tmp;
          break;
        }
        if (tmp > INF) {
          ans = -1;
          break;
        }
      }
      printf("%lld\n", ans);
    }
  }
  return 0;
}
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i > (b); --i)
#define SZ(a) a.size()
#define ll long long
#define ull unsigned long long
using namespace std;

int main() {

  int X = 0;
  int Y = 0;

  cin >> X >> Y;

  if (X % Y == 0) {
    cout << -1 << endl;
  } else {
    FOR(i, 1, pow(10, 18)) {
      if (i % X == 0 && i % Y != 0) {
        cout << i << endl;
        break;
      }
    }
  }

  system("pause");
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i > (b); --i)
#define SZ(a) a.size()
#define ll long long
#define ull unsigned long long
using namespace std;

int main() {

  int X = 0;
  int Y = 0;

  cin >> X >> Y;

  if (X % Y == 0) {
    cout << -1 << endl;
  } else {
    FOR(i, X, pow(10, 18)) {
      if (i % X == 0 && i % Y != 0) {
        cout << i << endl;
        break;
      }
    }
  }

  system("pause");
  return 0;
}
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  for (long long i = max(a, b) + 1; i <= 1000000000000000000; i++) {
    if (i % a == 0 && i % b != 0) {
      cout << i << endl;
      return 0;
    }
  }
  cout << "-1" << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  if (a % b == 0)
    cout << "-1";
  else
    cout << a;
  cout << endl;
  return 0;
}
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  long long int a, b;
  cin >> a >> b;
  if (a % b == 0) {
    cout << -1;
  }
  long long ans = a;
  while (ans % b == 0) {
    ans += a;
  }
  cout << ans;
  return 0;
}

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

int main() {
  long long int a, b;
  cin >> a >> b;
  if (a % b == 0) {
    cout << -1;
    return 0;
  }
  long long ans = a;
  while (ans % b == 0) {
    ans += a;
  }
  cout << ans;
  return 0;
}
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
using namespace std;
using ll = long long;

int main() {
  ll x, y;
  cin >> x >> y;

  ll ans = -1;
  ll i = 2;
  ll n = x * i;
  ll m = max(x, y);
  while (n <= m * m) {
    if (x == y) {
      break;
    }
    if (n % y != 0) {
      ans = n;
      break;
    }
    n = x * ++i;
  }

  cout << ans << endl;
}

Fixed submission:
#include <algorithm>
#include <iostream>
using namespace std;
using ll = long long;

int main() {
  ll x, y;
  cin >> x >> y;

  ll ans = -1;
  ll i = 2;
  ll n = x * i;
  ll m = max(x, y);
  while (n <= m * m) {
    if (x == y || x % y == 0) {
      break;
    }
    if (n % y != 0) {
      ans = n;
      break;
    }
    n = x * ++i;
  }

  cout << ans << endl;
}
Problem p03437 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  long long x, y, z;
  cin >> x >> y;

  bool exist = false;
  for (int i = 1; i <= y; i++) {
    z = x * i;
    if (z % y != 0) {
      exist = true;
      break;
    }
  }
  if (exist)
    cout << z << endl;
  else
    cout << -1 << endl;
  return 0;
}

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

int main() {
  long long x, y, z;
  cin >> x >> y;

  bool exist = false;
  for (int i = 1; i <= y; i++) {
    z = x * i;
    if (x % y == 0)
      break;
    if (z % y != 0) {
      exist = true;
      break;
    }
  }
  if (exist)
    cout << z << endl;
  else
    cout << -1 << endl;
  return 0;
}