Problem:


Score : 100 points

Problem Statement

You are given positive integers X and Y.
If there exists a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, choose one such integer and print it.
If it does not exist, print -1.

Constraints

1 ≤ X,Y ≤ 10^9

X and Y are integers.

Input

Input is given from Standard Input in the following format:

X Y

Output

Print a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, or print -1 if it does not exist.

Sample Input 1

8 6

Sample Output 1

16

For example, 16 is a multiple of 8 but not a multiple of 6.

Sample Input 2

3 3

Sample Output 2

-1

A multiple of 3 is a multiple of 3.



Sample input:
8 6


Sample output:
16

Submission status: Runtime Error

Solution code:
def main():
    _ = input()
    a_list = map(int, input().split())
    b_list = map(int, input().split())
    diffs = map(lambda a, b: b - a, a_list, b_list)
    total = 0
    count = 0
    for diff in diffs:
        if diff > 0:
            count += diff // 2
            total += diff % 2
        else:
            count += -diff
            total += diff
    if count <= total:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def main():
    _ = input()
    a_list = map(int, input().split())
    b_list = map(int, input().split())
    diffs = map(lambda a, b: b - a, a_list, b_list)
    total = 0
    count = 0
    for diff in diffs:
        if diff > 0:
            count += (diff + 1) // 2
            total += diff % 2
        else:
            count += -diff
            total += diff
    if count >= total:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
'''input
3 3
'''
from math import gcd
a, b = map(int, input().split())
if(gcd(a, b)==min(a, b)):
    print(-1)
else:
    print(2*(max(a, b)))

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
if(a==b):
    print(-1)
else:
    print(2*(min(a, b)))

Submission status: Runtime Error

Solution code:

a = -1
b = True

# for i in range(10**18):
for i in range(10**18):
    if i > 1:
        if ((X * i) % Y) != 0:
            a = (X * i)
            print(a)
            b = False
            break

if b:
    print(str(a))

Submission status: Runtime Error

Solution code:
X = int(input())
Y = int(input())
a = -1
b = True
for i in range(10**18):
    if i > 1:
        if ((X * i) % Y) != 0:
            a = (X * i)
            print(str(a))
            b = False
            break
if b:
    print(str(a))

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
src = list(map(int,input().split()))
es = [tuple(map(int,input().split())) for i in range(M)]

if N == 1:
    print(0)
    exit()
if M + N//2 < N-1:
    print('Impossible')
    exit()

parent = [i for i in range(N)]
rank = [0] * N
def root(a):
    if parent[a] == a:
        return a
    else:
        parent[a] = root(parent[a])
        return parent[a]
def same(a,b):
    return root(a) == root(b)
def unite(a,b):
    ra = root(a)
    rb = root(b)
    if ra == rb: return
    if rank[ra] < rank[rb]:
        parent[ra] = rb
    else:
        parent[rb] = ra
        if rank[ra] == rank[rb]: rank[ra] += 1

for a,b in es:
    unite(a,b)
trees = {}
for i in range(N):
    root(i)
for i in range(N):
    trees[root(i)] = False

costs = []
for i,c in enumerate(src):
    costs.append((c,i))
costs.sort()

used = [False] * N
ans = used_n = 0
for c,v in costs:
    t = root(v)
    if trees[t]:
        continue
    else:
        trees[t] = used[v] = True
        used_n += 1
        ans += c

for c,v in costs:
    if used_n == 2*(N-M-1): break
    if used[v]: continue
    used_n += 1
    ans += c
print(ans)

Submission status: Runtime Error

Solution code:
from math import gcd

X,Y = [int(i) for i in input().split()]

def lcm(a,b):
    return a*b/gcd(a,b)

i = 2
while True:
    if (X * i) % Y != 0:
        print(X*i)
        break
    elif (X * i) >= lcm(X,Y):
        print(-1)
        break
    else:
        i += 1

Submission status: Runtime Error

Solution code:
import sys

if __name__ == "__main__":
    N = int(input())
    A = list(map(int, (input().split(' '))))
    B = list(map(int, (input().split(' '))))

    a_sum = 0
    for x in A:
        a_sum += x
    b_sum = 0
    for x in B:
        b_sum += x
    if a_sum > b_sum:
        print('No')
        sys.exit()
    if (a_sum + N) < b_sum:
        print('No')
        sys.exit()
    a_plus = 0
    b_plus = 0
    a_plus_cnt = 0
    b_plus_cnt = 0
    A_list = []
    B_list = []
    for i in range(N):
        if A[i] < B[i]:
            a_plus += (B[i] - A[i])
            if A[i] < B[i] - 1:
                a_plus_cnt += ((B[i] - A[i]) // 2)
        elif A[i] > B[i]:
            b_plus += (A[i] - B[i])
            b_plus_cnt += (A[i] - B[i])
    if a_plus < b_plus * 2:
        print('No')
        sys.exit()
    if a_plus_cnt < b_plus_cnt:
        print('No')
        sys.exit()
#    if a_plus // 2 > N:
#        print('No')
#        sys.exit()
#    if a_plus_cnt != b_plus_cnt:
#        print('No')
#        sys.exit()
    print('Yes')

Submission status: Runtime Error

Solution code:
N = int(input())
print(0)
now = input()
old = now
che = N//2+1
nowi = 0
print(nowi+che)
nowi = N//2+1
first = True
ische = (che%2==0)
for i in range(18):
    now = input()
    if now==old:
        if che%2==0:
            pass
        elif che%2==1:
            first = not first
    elif now!=old:
        if che%2==0:
            first = not first
        elif che%2==1:
            pass
        che-=che//2+1
        nowi = nowi+che
    if first:
        print(nowi+che)
        nowi+=che
    else:
        print(nowi-che)
        nowi-=che
    old = now

Submission status: Runtime Error

Solution code:
import sys

if __name__ == "__main__":
    N = int(input())
    A = list(map(int, (input().split(' '))))
    B = list(map(int, (input().split(' '))))

    a_sum = 0
    for x in A:
        a_sum += x
    b_sum = 0
    for x in B:
        b_sum += x
    if a_sum > b_sum:
        print('No')
        sys.exit()
    if (a_sum + N) < b_sum:
        print('No')
        sys.exit()
    a_plus = 0
    b_plus = 0
    for i in range(N):
        if A[i] < B[i]:
            a_plus += (B[i] - A[i])
        else:
            b_plus += (A[i] - B[i])
    if a_plus < b_plus * 2:
        print('No')
        sys.exit()
    print('Yes')

Submission status: Runtime Error

Solution code:
X, Y = map(int, input().split())

for i in range(10**18ss):
    s = X * (i+2)
    if s % Y != 0 & s <= 10**18:
        print(s)
        break
    else:
        print(-1)
        break

Submission status: Runtime Error

Solution code:
from functools import reduce

from math import gcd

x, y = list(map(int, input().split()))


def lcm(*numbers):
    def lcm(a, b):
        return (a * b) // gcd(a, b)

    return reduce(lcm, numbers, 1)


a = lcm(x, y) - x

print(-1 if a == 0 else a)

Submission status: Runtime Error

Solution code:
inp = input().split()

i = 1
x = 0
while i <= pow(10,18):
	if i % int(inp[0])  == 0 and i % int(inp[1]) != 0:
		print(i)
                x = 1
		break
	i *= int(inp[0])


if x == 0:
	print(-1)

Submission status: Runtime Error

Solution code:
x,y = map(int, input().split())
temp = x
if x == y:
    print(-1)
    sys.exit()
while True:
    temp **= 2
    if temp % y != 0:
        print(temp)
        sys.exit()
    elif temp > 100000000000000000:
        print(-1)
        sys.exit()

Submission status: Runtime Error

Solution code:
X,Y = map(int,input().split())
if x%y > 0 or y%x > 0:
	print(-1)
	exit()
if 2*x % y == 0:
	print(2*x)
	exit()
else:
	print(-1)

Submission status: Runtime Error

Solution code:
from fractions import gcd
from math import factorial, ceil, sqrt, atan2, log, pi, e, asin,acos, cos, sin
from itertools import *
from fractions import Fraction
import string
import copy
import random
import bisect
from decimal import *
def id_generator(size=20, chars=string.digits):
    return ''.join(random.choice(chars) for _ in range(size))
 
def mp():
    return map(int,str(raw_input()).split())

a,b=mp()
if a>b:
    if gcd(a,b)==1:
    	print a
	elif a%b==0:
		print -1
	else:
		print a
else:
	if gcd(a,b)==1:
    	print b
	elif b%a==0:
		print -1
	else:
		print b

Submission status: Runtime Error

Solution code:
import sys
a,b = map(int,input().split())
if(a%b==0):
    print(-1)
    sys.exit(-1)
for i in range(10**18):
    if(i%a==0 and i%b):
        print(i)
        sys.exit(0)
print(-1)

Submission status: Runtime Error

Solution code:
import math
a,b = map(int,input().split())
if a % b == 0:
    print("-1")
else:
    c = math.gcd(a,b)
    print(c * a)

Submission status: Runtime Error

Solution code:
import math
a,b = map(int,input().split())
if a % b == 0:
    print("-1")
else:
    c =  math.gcd(a,b)
    print(c * a)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import math

def main():
    X, Y = map(int, input().split())

    d = math.gcd(X, Y)

    if d == Y:
        print(-1)
    else:
        print(X)

if __name__ == "__main__": main()

Submission status: Runtime Error

Solution code:
x,y=map(int,input().split())
if x==y:
    print('-1')
    break
for i in range(x,10**9//x,x):
    if i%y!=0:
        print(i)
        break

Submission status: Runtime Error

Solution code:
l = [int(a) for a in raw_input().split(' ')]
a = l[0]
b = l[1]
if a % b == 0:
	print(-1)
else:
	print(a)

Submission status: Runtime Error

Solution code:
if Y != 1:
	print(X * (Y-1))
else:
	print(-1)