Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
N = int(input())

s = [] * 2
print(0)
sys.stdout.flush()
s[0] = input()
if s[0] == 'Vacant':
    sys.exit()

l, r = 0, N
while r - l > 2:
    m = (l + r) // 2
    print(m)
    sys.stdout.flush()
    s[1] = input()
    if s[1] != 'Vacant':
        sys.exit()

    if s[0] == s[1]:
        l, r = (l, m) if (m - l) % 2 == 1 else (m, r)
    else:
        l, r = (m, r) if (m - l) % 2 == 1 else (l, m)
    s[0] = s[1]
print((l + r) // 2)
sys.stdout.flush()
sys.exit()


### FIXED CODE ###

#!/usr/bin/env python3
N = int(input())

print(0, flush=True)
w0 = input()
if w0 == 'Vacant':
    exit()

l, r = 0, N
while True:
    m = (l + r) // 2
    print(m, flush=True)
    w1 = input()
    if w1 == 'Vacant':
        break
    if m % 2 == (w0 != w1):
        l = m
    else:
        r = m
### BUGGY CODE ###

a=input().split()
N=int(a[0])
M=int(a[1])
H_list=input().split()
H_list=[int(i) for i in H_list]
path_list=[]
for i in range(M) :
  b=input().split()
  path_list.append([int(b[0]),int(b[1])])
count=0


for i in range(N) :
  flag=True

  for path in path_list :
    s=H_list[path[1]-1]
    m=H_list[path[0]-1]
    if not ((path[0]==i+1 and s<m) or (path[1]==i+1 and m<s)) and  i+1 in path:
      flag=False
      break
  if flag :

    count+=1

print(count)

### FIXED CODE ###

a=input().split()
N=int(a[0])
M=int(a[1])
H_list=input().split()
H_list=[int(i) for i in H_list]
path_list=[]
for i in range(M) :
  b=input().split()
  path_list.append([int(b[0]),int(b[1])])
count=0


c=[]
for i in path_list :
    if H_list[i[0]-1]>H_list[i[1]-1] :
        c.append(i[1])
    elif H_list[i[0]-1]<H_list[i[1]-1]  :
        c.append(i[0])
    else :
        c.append(i[0])
        c.append(i[1])
k=list(set(c))
print(N-len(k))
### BUGGY CODE ###

N = int(input())
S =[]
c = 0
for i in range(N):
  s = input()
  t = [s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],s[8],s[9]]
  t.sort()
  for j in range(i):
    if S[j] == t:
      c += 1
  S.append(t)

print(c)

### FIXED CODE ###

N = int(input())
S = []
Y = {}
c = 0
for i in range(N):
  s = input()
  t = [s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],s[8],s[9]]
  t.sort()
  u = t[0]+t[1]+t[2]+t[3]+t[4]+t[5]+t[6]+t[7]+t[8]+t[9]
  if u not in Y:
    Y[u] = 1
  else :
    c += Y[u]
    Y[u] += 1
    


print(c)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))

ans = -10**15
for i in range(n, 2*n+1):
    a_front = a[0 : i]
    a_back = a[i : 3*n]
    a_front.sort(reverse=True)
    a_back.sort()
    tmp = sum(a_front[0:n]) - sum(a_back[0:n])
    if tmp > ans:
        ans = tmp

print(ans)    

### FIXED CODE ###

from heapq import heappop, heapify, heappush

n = int(input())
a = list(map(int, input().split()))

a_front = a[0 : n]
a_back = list(map(lambda x: -1*x, a[2*n : 3*n]))
heapify(a_front)
heapify(a_back)

sum_f = [0]*(n+1)
sum_b = [0]*(n+1)
sum_f[0] = sum(a_front)
sum_b[n] = sum(a_back)*-1

for i in range(n, 2*n):
    # 前半の処理
    heappush(a_front, a[i])
    sum_f[i-n+1] = sum_f[i-n] + a[i] - heappop(a_front)
    # 後半の処理
    heappush(a_back, -1 * a[3*n-i-1])
    sum_b[2*n-i-1] = sum_b[2*n-i] + a[3*n-i-1] + heappop(a_back)

ans = sum_f[0] - sum_b[0]
for i in range(1, n+1):
    tmp = sum_f[i] - sum_b[i]
    if tmp > ans:
        ans = tmp
        
print(ans)
### BUGGY CODE ###

def solve(a_s) -> int:
  def get_ret_from_xs(xs) -> int:
    ret = 0
    for i, x in enumerate(xs):
      ret += 2**i * (x % 2)
      ret %= 10**9 + 7
    return ret

  # zeros = [1, 1] + [0] * 58  # 各要素 0 ~ n. 要素iは、下 i +1 桁目が0である A_? の個数
  # ones = [2, 2] + [0] * 58 # 各要素 0 ~ n. 要素iは、下 i +1 桁目が0である A_? の個数
  zeros = [0] * 60
  ones = [0] * 60

  for a in a_s:
    for i in range(len(zeros)):
      # a_bin = format(a, '060b')
      # a_i_digit_from_right = a_bin[60 - i - 1]
      # if a_i_digit_from_right == '0':
      #   zeros[i] += 1
      # else:
      #   ones[i] += 1

      a_i_digit_from_right = ((a & (2**i)) >> i) & 0b1
      if a_i_digit_from_right == 0:
        zeros[i] += 1
      else:
        ones[i] += 1

  # 繰り上がりのせいで、xsの要素数は60を超えることがあるので注意
  xs = []
  i = 0
  while True:
    x_i = 0
    if i <= 59:
      x_i = (zeros[i] * ones[i])
    if i >= 1:
      x_i += xs[i - 1] // 2
    xs.append(x_i)

    if i >= 60 and x_i // 2 == 0:
      break

    i += 1

  #xs = [2, 3, 1]
  return get_ret_from_xs(xs)


n = int(input().strip())
a_s = [int(s) for s in input().split()]

#a_s = [1, 2, 3]
#a_s = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3]
#a_s = [3, 14, 159, 2653, 58979, 323846, 2643383, 27950288, 419716939, 9375105820]

print(solve(a_s))


### FIXED CODE ###

def solve(a_s) -> int:
  # def get_ret_from_xs(xs) -> int:
  #   # 繰り上がり処理ありバージョン
  #   ret = 0
  #   for i, x in enumerate(xs):
  #     ret += 2**i * (x % 2)
  #     ret %= 10**9 + 7
  #   return ret
  #
  # def get_ret_from_xs2(xs) -> int:
  #   ret = 0
  #   for i, x in enumerate(xs):
  #     ret += 2**i * x
  #     ret %= 10**9 + 7
  #   return ret

  # zeros = [1, 1] + [0] * 58  # 各要素 0 ~ n. 要素iは、下 i +1 桁目が0である A_? の個数
  # ones = [2, 2] + [0] * 58 # 各要素 0 ~ n. 要素iは、下 i +1 桁目が0である A_? の個数
  zeros = [0] * 60

  ret = 0
  for i in range(60):
    ones = sum([(a >> i) & 0b1 for a in a_s])
    ret += 2**i * (ones * (len(a_s) - ones))
    ret %= 10**9 + 7
  return ret

  # for a in a_s:
  #   for i in range(len(zeros)):
  #     # a_bin = format(a, '060b')
  #     # a_i_digit_from_right = a_bin[60 - i - 1]
  #     # if a_i_digit_from_right == '0':
  #     #   zeros[i] += 1
  #     # else:
  #     #   ones[i] += 1
  #
  #     a_i_digit_from_right = (a >> i) & 0b1
  #     if a_i_digit_from_right == 0:
  #       zeros[i] += 1
  #
  # # 繰り上がり処理しないでも、各桁で収めてもいいんだ！
  # xs = [zeros[i] * (len(a_s) - zeros[i]) for i in range(60)]
  # return get_ret_from_xs2(xs)
  #
  #
  # # # 繰り上がりのせいで、xsの要素数は60を超えることがあるので注意
  # # xs = []
  # # i = 0
  # # while True:
  # #   x_i = 0
  # #   if i <= 59:
  # #     x_i = (zeros[i] * ones[i])
  # #   if i >= 1:
  # #     x_i += xs[i - 1] // 2
  # #   xs.append(x_i)
  # #
  # #   if i >= 60 and x_i // 2 == 0:
  # #     break
  # #
  # #   i += 1
  #
  # #xs = [2, 3, 1]
  # #return get_ret_from_xs(xs)


n = int(input().strip())
a_s = [int(s) for s in input().split()]

#a_s = [1, 2, 3]
#a_s = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3]
#a_s = [3, 14, 159, 2653, 58979, 323846, 2643383, 27950288, 419716939, 9375105820]

print(solve(a_s))
### BUGGY CODE ###

LIM=200002
L=[0]*LIM

def bin_sum(Y):
    S=bin(Y)[2:]
    count=0
    for i in range(len(S)):
        count+=int(S[i])
    return count

def bin_sum2(Y):
    count=0
    for i in range(len(Y)):
        count+=int(Y[i])
    return count

for i in range(1,LIM):
    L[i]+=bin_sum(i)

def pop_num(N,b,L):
    if N==0:
        return 0
    v=N%b
    return pop_num(v,L[v],L)+1
    
def pop_num2(N,b,L,M):
    if N==0:
        return 0
    v=N%b
    return M[v]+1

M=[0]*200002
for i in range(1,200002):
    M[i]+=pop_num(i,L[i],L)
X=int(input())
Y=input()
d=bin_sum2(Y)+1
c=bin_sum2(Y)-1
e=int(Y,2)
for i in range(X):
    Y_i=Y[:i]+str(abs(int(Y[i])-1))+Y[i+1:]
    if Y_i[i]=="1":
        b=d
        f=e+2**(X-1-i)
    else:
        b=c
        f=e-2**(X-1-i)
    print(pop_num2(f,b,L,M))

### FIXED CODE ###

from collections import deque
LIM=200004
L=[0]*LIM

def bin_sum(Y):
    S=bin(Y)[2:]
    count=0
    for i in range(len(S)):
        count+=int(S[i])
    return count

def bin_sum2(Y):
    count=0
    for i in range(len(Y)):
        count+=int(Y[i])
    return count

for i in range(1,LIM):
    L[i]+=bin_sum(i)

def pop_num(N,b,L):
    if N==0:
        return 0
    v=N%b
    return pop_num(v,L[v],L)+1
    
M=[0]*200005
for i in range(1,200004):
    M[i]+=pop_num(i,L[i],L)
X=int(input())
Y=input()
d=bin_sum2(Y)
e=int(Y,2)%(d+1)
f=int(Y,2)%max(1,(d-1))
O=[1]*(X+2)
P=[1]*(X+2)
q=max(d-1,1)
for i in range(1,X+1):
    O[i]=O[i-1]*2%q
    P[i]=P[i-1]*2%(d+1)
for i in range(X):
    
    if int(Y[i])==1:
        b=max(d-1,1)
        flag=max(0,d-1)
        g=(f-O[X-1-i]+b)%b
    else:
        b=d+1
        flag=1
        g=(e+P[X-1-i])%b

    if flag==0:
        print(0)
    elif g==0:
        print(1)
    else:
        print(M[g]+1)
### BUGGY CODE ###

def calcDiv(n):
    d_list = [1, n]
    for i in range(2, int(n**(1/2))+1):
        if n%i == 0:
            d_list.append(i)
            d_list.append(int(n/i))
    return d_list


def isPrime(n):
    for i in range(2, n):
        if n % i == 0:
            return False
    return True


if __name__ == "__main__":    
    a, b = map(int, input().split())
    a_list = calcDiv(a)
    b_list = calcDiv(b)
    d_list = set(a_list) & set(b_list)
    cnt = 0
    for d in d_list:
        if isPrime(d):
            cnt += 1
    print(cnt)


### FIXED CODE ###

def calcDiv(n):
    d_list = []
    for i in range(1, int(n**(1/2))+1):
        if n%i == 0:
            d_list.append(i)
            d_list.append(int(n/i))
    return d_list


def isPrime(n):
    for i in range(2, int(n**(1/2))+1):
        if n % i == 0:
            return False
    return True


if __name__ == "__main__":    
    a, b = map(int, input().split())
    a_list = calcDiv(a)
    b_list = calcDiv(b)
    d_list = set(a_list) & set(b_list)
    cnt = 0
    for d in d_list:
        if isPrime(d):
            cnt += 1
    print(cnt)
### BUGGY CODE ###

n = int(input())

l = list(map(int, input().split()))
l = sorted(l)

res = 0
for i in range(n):
    for j in range(i, n):
        if i!=j:
            ab = l[i]+l[j]
            for k in range(j, n):
                if i!=k and j!=k and l[k] < ab:
                    res += 1
                else:
                    continue

print(res)

### FIXED CODE ###

from bisect import bisect_left
N = int(input())
L = list(map(int, input().split()))
L.sort()
res = 0
for i in range(N):
    for j in range(i+1, N):
        idx = bisect_left(L, L[i]+L[j])
        res += max(0,idx-(j+1))
print(res)
### BUGGY CODE ###

n, m = map(int, input().split())
a = [int(input()) for i in range(m)]

f = [0] * (n + 1)
f[0] = 1

for i in range(1, n + 1):
    if i in a:
        continue
    f[i] = (f[i - 1] + f[i - 2]) % 1000000007

print(f[n])


### FIXED CODE ###

def main():
    N, M, *a = map(int, open(0).read().split())
    div = 1000000007
    broken = set(a)
 
    comb_list = [0] * (N + 1)
    comb_list[0] = 1
    if 1 not in broken:
        comb_list[1] = 1
 
    for i in range(2, N + 1):
        if i in broken:
            continue
        comb_list[i] = (comb_list[i - 1] + comb_list[i - 2]) % div
 
    print(comb_list[-1])
 
 
if __name__ == "__main__":
    main()
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
c = [0] * (n + 1)
for i in range(n):
  c[i + 1] = c[i] + a[i]
result = 0
for i in range(1, n + 1):
  for j in range(i):
    if c[i] - c[j] == 0:
      result += 1
print(result)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
c = [0] * (n + 1)
for i in range(n):
  c[i + 1] = c[i] + a[i]
d = {}
for i in range(1, n + 1):
  if c[i] not in d:
    d[c[i]] = 0
  d[c[i]] += 1
result = 0
if 0 in d:
  result += d[0]
for k in d:
  if d[k] != 1:
    result += d[k] * (d[k] - 1) // 2
print(result)
### BUGGY CODE ###

N,K,Q = map(int, raw_input().split())
P = [K]*N
for i in range(Q):
    A = int(raw_input())
    P[A-1] += 1
    P = [p-1 for p in P]
    #print P

for p in P:
    if p > 0:
        print "Yes"
    else:
        print "No"

### FIXED CODE ###

N,K,Q = map(int, raw_input().split())
P = [K]*N
for i in range(Q):
    A = int(raw_input())
    P[A-1] += 1
    
P = [p-Q for p in P]

for p in P:
    if p > 0:
        print "Yes"
    else:
        print "No"
### BUGGY CODE ###

def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    uni = sorted(list(set(a)))
    dup = [x for x in set(a) if a.count(x) > 1]

    ans = 0
    for i in range(len(uni)):
        if uni[i] in dup:
            continue

        for j in range(len(uni)):
            if i == j: continue
            
            if uni[i] % uni[j] == 0:
                break
        else:
            ans += 1
 
    print(ans)
 
resolve()

### FIXED CODE ###

def resolve():
    n = int(input())
    A = list(map(int, input().split()))
    max_a = max(A)
    m = set()
    checked = set()
    duplicated = set()

    for a in A:
        if a in checked:
            duplicated.add(a)
            continue

        i = 2
        while a*i <= max_a:
            m.add(a*i)
            i += 1

        checked.add(a)

    ans = 0
    for a in A:
        if a in duplicated: continue

        if a not in m:
            ans += 1
    
    print(ans)
 
resolve()
### BUGGY CODE ###

###############################################################################

from bisect import bisect_left as binl

def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * sy) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


###############################################################################


def main():
    x, y, z, k = intin()
    alist = intina()
    blist = intina()
    clist = intina()

    ablist = []
    for a in alist:
        for b in blist:
            ablist.append(a + b)

    ablist.sort(reverse=True)

    abclist = []
    for ab in ablist[:(k+1)]:
        for c in clist:
            abclist.append(ab + c)

    abclist.sort(reverse=True)

    for i in range(k):
        print(abclist[i])


if __name__ == '__main__':
    main()


### FIXED CODE ###

###############################################################################

from bisect import bisect_left as binl

def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * sy) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


###############################################################################


def main():
    x, y, z, k = intin()
    alist = intina()
    blist = intina()
    clist = intina()

    ablist = []
    for a in alist:
        for b in blist:
            ablist.append(a + b)

    ablist.sort(reverse=True)

    abclist = []
    for ab in ablist[:(k+1)]:
        for c in clist:
            abclist.append(ab + c)

    abclist.sort(reverse=True)

    for i in range(k):
        print(abclist[i])


if __name__ == '__main__':
    main()
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10 ** 6)


def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    dp = [[None for _ in range(N)] for _ in range(N)]

    def rec(sign, left, right):
        ret = dp[left][right]
        if ret is not None:
            return ret
        if left == right:
            val = sign * A[left]
            dp[left][right] = val
            return val
        score_left = sign * A[left] + rec(- sign, left + 1, right)
        score_right = sign * A[right] + rec(- sign, left, right - 1)
        score = max([score_left, score_right]) if sign == 1 else min([score_left, score_right])
        dp[left][right] = score
        return score

    print(rec(1, 0, N - 1))


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    dp = [[0 for _ in range(N)] for _ in range(N)]
    for length in range(1, N + 1):
        for left in range(N - length + 1):
            right = left + length - 1
            val = 0
            if left == right:
                val = A[left]
            else:
                val = max([
                    A[left] - dp[left + 1][right],
                    A[right] - dp[left][right - 1]
                ])
            dp[left][right] = val
    print(dp[0][N - 1])


if __name__ == '__main__':
    main()
### BUGGY CODE ###

import sys, collections

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    son = [[] for i in range(N)]
    for i in range(M):
        u, v = map(int, input().split())
        son[u-1].append(v-1)
    S, T = map(int, input().split())

    graphB = [set() for i in range(N)] 
    for i in range(N):
        for s1 in son[i]:
            for s2 in son[s1]:
                graphB[i] |= set(son[s2])
    
    q = collections.deque()
    visited = [-1] * N
    q.append((0, S-1))
    while q:
        cost, now = q.popleft()
        if visited[now] == -1:
            visited[now] = cost
            for s in graphB[now]:
                if visited[s] == -1: q.append((cost + 1, s))

    print(visited[T-1])
    return 0

if __name__ == "__main__":
    solve()

### FIXED CODE ###

import sys, collections

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    son = [[] for i in range(N)] 
    for i in range(M):
        u, v = map(int, input().split())
        son[u-1].append(v-1)
    S, T = map(int, input().split())

    dist = [[-1, -1, -1] for i in range(N)]
    que = collections.deque()
    que.append((0, S-1, 0)) #k回目の移動, 場所, mod
    while que:
        cost, now, mod = que.popleft()
        if dist[now][mod] == -1:
            dist[now][mod] = cost
            if mod == 0:
                for s in son[now]:
                    if dist[s][1] == -1: que.append((cost + 1, s, 1))
            else:
                for s in son[now]:
                    if dist[s][(mod + 1) % 3] == -1: que.append((cost, s, (mod + 1) % 3))

    print(dist[T-1][0])  
    return 0

if __name__ == "__main__":
    solve()
### BUGGY CODE ###

import math
R, G, B, N = map(int, input().split())
rg_lis = []
ans = 0
cr = math.ceil(N/R)
cg = math.ceil(N/G)
cb = math.ceil(N/B)
for i in range(cr + 1):
    for j in range(cg + 1):
        tmp =  i * R + j * G
        if N - tmp >= 0:
            rg_lis.append(tmp)
for l in rg_lis:
    if (N - l )% B == 0:
        ans += 1
print(ans)


### FIXED CODE ###

import math
R, G, B, N = map(int, input().split())
ans = 0
cr = math.ceil(N/R)
cg = math.ceil(N/G)
cb = math.ceil(N/B)
for i in range(cr + 1):
    for j in range(cg + 1):
        tmp =  i * R + j * G
        if N - tmp >= 0 and (N - tmp) % B == 0:
           ans += 1
        elif N - tmp < 0:
          break
print(ans)
### BUGGY CODE ###

H, W = map(int, input().split())
s = [[c for c in input()] for i in range(H)]
s_vrt = [[s[i][j] for i in range(H)] for j in range(W)]

def count_light_place(i, j):
    line_lr = s[i]
    line_up = s_vrt[j]
    return count_light_line(i, line_up) + count_light_line(j, line_lr) - 1


def count_light_line(k, line):
    count = 0
    for dn in reversed(range(k)):
        if line[dn] == '#':
            break
        count += 1
 
    for up in range(k, len(line)):
        if line[up] == '#':
            break
        count += 1
    return count 


count_max = 0
for i in range(H):
    for j in range(W):
        if s[i][j] == '#':
            continue
        count = count_light_place(i, j)
        if count_max < count:
            count_max = count

print(count_max)

### FIXED CODE ###

import numpy as np


H, W = map(int, input().split())
s = np.array([[c for c in input()] for i in range(H)]) == '.'
s_t = s.transpose()

dp_l = np.zeros((W, H), dtype=int)
dp_r = np.zeros((W, H), dtype=int)
dp_u = np.zeros((H, W), dtype=int)
dp_d = np.zeros((H, W), dtype=int)

dp_l[0] = s_t[0]
dp_r[W-1] = s_t[W-1]
dp_u[0] = s[0]
dp_d[H-1] = s[H-1]

for i in range(1, W):
    dp_l[i] = s_t[i] * (dp_l[i-1] + 1)

for i in reversed(range(W-1)):
    dp_r[i] = s_t[i] * (dp_r[i+1] + 1)

for i in range(1, H):
    dp_u[i] = s[i] * (dp_u[i-1] + 1)

for i in reversed(range(H-1)):
    dp_d[i] = s[i] * (dp_d[i+1] + 1)

cnts = dp_l + dp_r + dp_d.transpose() + dp_u.transpose()
print(max(np.amax(cnts, 0)) - 3)
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
ans=1
if min(A)==0:
    ans=0
else:
    for a in A:
        ans=ans*a
    if ans > 10**18:
        ans = -1
print(ans)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
ans=1
if min(A)==0:
    ans=0
else:
    for a in A:
        ans=ans*a
        if ans > 10**18:
            ans = -1
            break
print(ans)
### BUGGY CODE ###

from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    S = input()
    cnt = 0
    start = 0
    while start+4 < len(S):
        for i in range(start+4,len(S)+1):
            if S[i-1] == 0:
                continue
            if int(S[start:i]) % 2019 == 0:
                cnt += 1
        start += 2
    print(cnt)
if __name__ == '__main__':
  main()


### FIXED CODE ###

S = input()
lenS = len(S)
count = [0] * 2019
count[0] = 1
num = 0
d = 1
for i in range(lenS):
    num += int(S[lenS - i - 1]) * d
    count[num%2019] += 1
    d *= 10
    d %= 2019
ans = 0
for i in count:
    ans += i*(i-1)//2
print(ans)
### BUGGY CODE ###

from collections import Counter
n = int(input())
dic = [Counter(input()) for i in range(n)]
cnt=0
for i in range(n):
  for j in range(i+1, n):
    if dic[i]==dic[j]:
      cnt+=1
print(cnt)

### FIXED CODE ###

from collections import Counter
n=int(input())
string_list=["".join(sorted(list(input()))) for i in range(n)]
counter=Counter(string_list)
cnt=0
for k, v in counter.items():
  cnt+=int(v*(v-1)/2)
print(cnt)
### BUGGY CODE ###

MOD = 10**9 + 7
N,M = map(int,input().split(' '))
broken_list = [int(input()) for i in range(M)]

ans = [0,1]

for n in range(1,N+1):
  if n in broken_list:
    ans.append(0)
  else:
    ans.append(ans[-2]+ans[-1])

print(ans[-1] % MOD)               

### FIXED CODE ###

MOD = 10**9 + 7
N,M = map(int,input().split(' '))
broken_list = set([int(input()) for i in range(M)])

ans = [0,1]

for n in range(1,N+1):
  if n in broken_list:
    ans.append(0)
  else:
    ans.append((ans[-2]+ans[-1]) % MOD)

print(ans[-1] % MOD)
### BUGGY CODE ###

n,t=map(int, input().split())
x=[]
y=[]
m=[]
for i in range(n):
    a,b=map(int, input().split())
    x.append(a)
    y.append(b)
    m.append([a,b])
x.sort()
y.sort()
ans=float('inf')
for i in range(n-1):
    for j in range(i,n):
        if i>=j:continue
        for k in range(n-1):
            for l in range(k,n):
                if k>=l:continue
                count=0
                for a,b in m:
                    if x[i]<=a<=x[j] and y[k]<=b<=y[l]:
                        count+=1
                if count>=t:
                    ans=min(ans,(x[j]-x[i])*(y[l]-y[k]))
print(ans)

### FIXED CODE ###

n,t=map(int, input().split())
x=[]
y=[]
m=[]
for i in range(n):
    a,b=map(int, input().split())
    x.append(a)
    y.append(b)
    m.append([a,b])
x.sort()
y.sort()
ans=float('inf')
for i in range(n-1):
    for j in range(i,n):
        if i>=j:continue
        for k in range(n-1):
            for l in range(k,n):
                if k>=l:continue
                count=0
                for a,b in m:
                    if x[i]<=a<=x[j] and y[k]<=b<=y[l]:
                        count+=1
                if count>=t:
                    ans=min(ans,(x[j]-x[i])*(y[l]-y[k]))
print(ans)
### BUGGY CODE ###

X, Y = map(int, input().split())

while True:
    if X % Y != 0:
        print(X)
    else:
        print(-1)

### FIXED CODE ###

X, Y = map(int, input().split())


if X % Y != 0:
    print(X)
else:
    print(-1)