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

N = int(input())
S = [None] * N
for i in range(N):
    S[i] = input()

C = []
for s in S:
    C.append(sorted(s))

ans = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        if C[i] == C[j]:
            ans += 1

print(ans)

### FIXED CODE ###

N = int(input())
S = [None] * N
for i in range(N):
    S[i] = input()

C = []
for s in S:
    T = tuple(sorted(s))
    C.append(T)

dic = {}
for i in range(N):
    if C[i] in dic:
        dic[C[i]] += 1
    else:
        dic[C[i]] = 1

ans = 0
for x in dic.values():
    ans += x * (x - 1) // 2
print(ans)
### BUGGY CODE ###

from collections import deque

H, W, K = map(int,input().split())
S = []
for _ in range(H):
    S.append(list(input()))

D = [[1 for i in range(W)] for j in range(H)]

for x in range(H):
    for y in range(W):
        if S[x][y] == 'S':
            sx = x
            sy = y

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

ans = float('inf')

q = deque([[sx, sy, 0]])

while len(q) != 0:
    x, y, cnt = q.popleft()
    if cnt > K:
        break
    D[x][y] = 0
    tmp = min(x, y , H - x - 1, W - y - 1)
    if tmp != 0:
        tmp = (tmp - 1) // K
        tmp += 2
    else:
        tmp = 1
    ans = min(ans, tmp)
    for i in range(4):
        nx = x + dx[i]
        ny = y + dy[i]
        if 0 <= nx < H and 0 <= ny < W and S[nx][ny] != '#' and D[nx][ny]:
            q.append([nx, ny, cnt + 1])

print(ans)

### FIXED CODE ###

from collections import deque

H, W, K = map(int,input().split())
S = []
for _ in range(H):
    S.append(list(input()))

D = [[1 for i in range(W)] for j in range(H)]

for x in range(H):
    for y in range(W):
        if S[x][y] == 'S':
            sx = x
            sy = y

D[sx][sy] = 0

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

ans = float('inf')

q = deque([[sx, sy, 0]])

while len(q) != 0:
    x, y, cnt = q.popleft()
    if cnt > K:
        break
    tmp = min(x, y , H - x - 1, W - y - 1)
    if tmp != 0:
        tmp = (tmp - 1) // K
        tmp += 2
    else:
        tmp = 1
    ans = min(ans, tmp)
    for i in range(4):
        nx = x + dx[i]
        ny = y + dy[i]
        if 0 <= nx < H and 0 <= ny < W and S[nx][ny] != '#' and D[nx][ny]:
            D[nx][ny] = 0
            q.append([nx, ny, cnt + 1])

print(ans)
### BUGGY CODE ###

input()
A = list(map(int,input().split()))
count=0

while all(a%2==0 for a in A):
  count+=1
  
print(count)

### FIXED CODE ###

input()
A = list(map(int,input().split()))
count=0

while all(a%2==0 for a in A):
  A=[a/2 for a in A]
  count+=1
  
print(count)
### BUGGY CODE ###

import functools
from math import gcd
N = int(input())
A = list(map(int, input().split()))
MAX = 10 ** 6 + 10

prime_list = [i for i in range(MAX + 1)]
p = 2
while p * p <= MAX:
    if prime_list[p] == p:
        for q in range(2*p, MAX+1, p):
            if prime_list[q] == q:
                prime_list[q] = p
    p += 1

prime = set()
cnt = 0
for a in A:
    tmp = set()
    while a > 1:
        tmp.add(prime_list[a])
        a //= prime_list[a]
    prime = prime | tmp
    cnt += len(tmp)

if len(prime) == cnt:
    print("pairwise coprime")
elif functools.reduce(gcd, A) == 1:
    print("setwise coprime")
else:
    print("not coprime")


### FIXED CODE ###

import functools
from math import gcd
N = int(input())
A = list(map(int, input().split()))
MAX = 10 ** 6 + 10

if functools.reduce(gcd, A) != 1:
    print("not coprime")
    exit()

prime_list = [i for i in range(MAX + 1)]
p = 2
while p * p <= MAX:
    if prime_list[p] == p:
        for q in range(2*p, MAX+1, p):
            if prime_list[q] == q:
                prime_list[q] = p
    p += 1

prime = set()
for a in A:
    tmp = set()
    while a > 1:
        tmp.add(prime_list[a])
        a //= prime_list[a]
    for p in tmp:
        if p in prime:
            print("setwise coprime")
            exit()
        prime.add(p)
else:
    print("pairwise coprime")
### BUGGY CODE ###

from bisect import bisect_left
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int,input().split())) for _ in range(M)]
BC = sorted(BC,key= lambda x: x[1],reverse=True)
A.sort()
bisec = bisect_left
ex = A.extend
for i in range(M):
    if BC[i][1]<A[0]:
        break
    B= BC[i][0]
    C = BC[i][1]
    b = bisec(A,C)
    if B>=b:
        ex([C for _ in range(b)])
        del A[:b]
    else:
        ex([C for _ in range(B)])
        del A[:B]
print(sum(A))

### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int,input().split())) for _ in range(M)]
BC = sorted(BC,key= lambda x: x[1],reverse=True)
A.sort()
n = 0
i = 0
m = 0
while A[i]<BC[n][1]:
    A[i] = BC[n][1]
    m = m+1
    if m >=BC[n][0]:
        m = 0
        n = n+1
    i += 1
    if n==M:
      break
    if i == N:
      break
print(sum(A))
### BUGGY CODE ###

import sys
import numpy

N, X = map(int, input().split())
x_list = list(map(int, input().split()))
x_list.insert(0, 0)

sum_x = numpy.cumsum(x_list)

max_robo = -(-1 * N // 2)
ans = sys.maxsize
for k in range(1, max_robo + 1):
    t_ans = 0
    t_ans += 5 * (sum_x[N] - sum_x[max(N - k * 2, 0)])
    for j in range(1, -(-(N - k) // k)):
        tmp = sum_x[N - (j + 1) * k] - sum_x[max(N - (j + 2) * k, 0)]
        t_ans += tmp * (2 * (j + 2) + 1)

    t_ans += (N + k) * X
    ans = min(ans, t_ans)


print(ans)

### FIXED CODE ###

import sys
# import numpy

N, X = map(int, input().split())
x_list = list(map(int, input().split()))
x_list.insert(0, 0)

tmp = 0
sum_x = []
for x in x_list:
    tmp += x
    sum_x.append(tmp)
# sum_x = numpy.cumsum(x_list)

max_robo = -(-1 * N // 2)
ans = sys.maxsize
for k in range(1, max_robo + 1):
    t_ans = (N + k) * X + 5 * sum_x[N]
    for j in range(1, -(-(N - k) // k)):
        t_ans += 2 * sum_x[N - (j + 1) * k]

    ans = min(ans, t_ans)

print(ans)
### BUGGY CODE ###

a,b,k = map(int,input().split())
for i in range(k):
    if a >= 1:
        a -= 1
    elif a < 1 and b >=1:
        b -= 1
print(a,b,end=" ")

### FIXED CODE ###

a,b,k = map(int,input().split())
if a + b <= k:
    print(0,0)
elif a <= k:
    print(0, a+b-k)
else:
    print(a-k,b)
### BUGGY CODE ###

# -*- coding: utf-8 -*-

def abc162d(n, s):

    r_arr = []
    g_arr = []
    b_arr = []

    for i in range(n):
        if s[i] == 'R':
            r_arr.append(i)
        elif s[i] == 'G':
            g_arr.append(i)
        else: # 'B'
            b_arr.append(i)

    min1_arr = r_arr
    min2_arr = g_arr
    max_arr = b_arr
    if len(r_arr) < len(g_arr) and len(b_arr) < len(g_arr):
        min1_arr = r_arr
        min2_arr = b_arr
        max_arr = g_arr
    elif len(g_arr) < len(r_arr) and len(b_arr) < len(r_arr):
        min1_arr = g_arr
        min2_arr = b_arr
        max_arr = r_arr

    except_num = 0
    for r_i in min1_arr:
        for g_i in min2_arr:
            min_i = r_i
            max_i = g_i
            if g_i < r_i:
                min_i = g_i
                max_i = r_i
            diff = max_i - min_i
            minmin = min_i - diff
            maxmax = max_i + diff
            exists_central = (max_i + min_i) % 2

            if minmin in max_arr:
                except_num += 1
            if maxmax in max_arr:
                except_num += 1
            if exists_central == 0:
                central = (max_i + min_i) / 2
                if central in max_arr:
                    except_num += 1

    ans = len(r_arr) * len(g_arr) * len(b_arr) - except_num
    return ans

###
# main
if(__name__ == '__main__'):
    # input
    n = int(input())
    s = input()
    
    ans = abc162d(n, s)
    
    # output
    print(ans)
# else:
    # do nothing


### FIXED CODE ###

# -*- coding: utf-8 -*-

def abc162d(n, s):

    r_arr = []
    g_arr = []
    b_arr = []

    for i in range(n):
        if s[i] == 'R':
            r_arr.append(i)
        elif s[i] == 'G':
            g_arr.append(i)
        else: # 'B'
            b_arr.append(i)

    min1_arr = r_arr
    min2_arr = g_arr
    max_arr = b_arr
    if len(r_arr) < len(g_arr) and len(b_arr) < len(g_arr):
        min1_arr = r_arr
        min2_arr = b_arr
        max_arr = g_arr
    elif len(g_arr) < len(r_arr) and len(b_arr) < len(r_arr):
        min1_arr = g_arr
        min2_arr = b_arr
        max_arr = r_arr

    max_dict = dict()
    for elem in max_arr:
        max_dict[elem] = 1

    except_num = 0
    for r_i in min1_arr:
        for g_i in min2_arr:
            min_i = r_i
            max_i = g_i
            if g_i < r_i:
                min_i = g_i
                max_i = r_i
            diff = max_i - min_i
            minmin = min_i - diff
            maxmax = max_i + diff
            exists_central = (max_i + min_i) % 2

            if minmin in max_dict:
                except_num += 1
            if maxmax in max_dict:
                except_num += 1
            if exists_central == 0:
                central = (max_i + min_i) / 2
                if central in max_dict:
                    except_num += 1

    ans = len(r_arr) * len(g_arr) * len(b_arr) - except_num
    return ans

###
# main
if(__name__ == '__main__'):
    # input
    n = int(input())
    s = input()
    
    ans = abc162d(n, s)
    
    # output
    print(ans)
# else:
    # do nothing
### BUGGY CODE ###

N = int(raw_input())
s = []
for i in range(0,N):
  K = (''.join(sorted(raw_input())))
  s.append(K)
ans = 0
for i in range(0,N-1):
  for j in range(i+1,N):
    if s[i] == s[j]:
      ans = ans + 1
print ans

### FIXED CODE ###

from collections import Counter

N = int(raw_input())
s = []
for i in range(0,N):
  K = (''.join(sorted(raw_input())))
  s.append(K)
ans = 0

for i in Counter(s).values():
  if i > 1:
    for j in range(1,i):
      ans = ans + j
print ans
### BUGGY CODE ###

def cs(x):
    ans = 0
    for i in range(len(x)-1):
        ans += abs(x[i+1]-x[i])
    return ans


n = int(input())
a = [0] + list(map(int, input().split())) + [0]

for i in range(1, len(a)-1):
    print(cs(a[:i] + a[i+1:]))

### FIXED CODE ###

def cs(x):
    ans = 0
    for i in range(len(x)-1):
        ans += abs(x[i+1]-x[i])
    return ans


n = int(input())
a = [0] + list(map(int, input().split())) + [0]

s = cs(a)

for i in range(1, len(a)-1):
    dif = abs(a[i]-a[i-1]) + abs(a[i+1]-a[i]) - abs(a[i+1]-a[i-1])
    print(s-dif)
### BUGGY CODE ###

if __name__ == '__main__':
    s = list(input())
    q = int(input())
    #ql = [list(input().split()) for _ in range(q)]

    for _ in range(q):
        ql = list(input().split())
        t = ql[0]
        #print(br)
        if t == "1":
            s = list(reversed(s))
            #print(s)
        elif t == "2":
            f = ql[1]
            c = list(ql[2])
            if f == "1":
                s = c + s
            elif f == "2":
                s = s + c
            
    print(''.join(s))


### FIXED CODE ###

from collections import deque

def msf(s,queries):
    queue = deque(s)
    addl = queue.appendleft
    addr = queue.append
    is_reversed = 0

    for query in queries:
        if query[0] == '1':
            is_reversed ^= 1
            addl,addr = addr,addl
        elif query[0] == '2':
            f = query[1]
            c = query[2]
            if f == '1':
                addl(c)
            elif f == '2':
                addr(c)
    return ''.join(queue) if not is_reversed else ''.join(reversed(queue))

if __name__ == '__main__':
    s = list(input())
    q = int(input())
    ql = [input().split() for i in range(q)]
    print(msf(s,ql))
### BUGGY CODE ###

MOD=10**9+7
K=int(input())
S=list(input())
len_S=len(S)

def invmod(a):
  return pow(a,MOD-2,MOD)
fact_dic={0:1}
fact_inv_dic={0:1}
fact_mod=1
for i in range(1,K+len_S+1):
  fact_mod=(fact_mod*i)%MOD
  fact_dic[i]=fact_mod
  fact_inv_dic[i]=invmod(fact_mod)
def comb_mod_table(n,r):
  if 0<=r<=n:
    return fact_dic[n]*fact_inv_dic[r]*fact_inv_dic[n-r]
  else:
    return 0
  
answer=0
for i in range(K+1):
  answer+=comb_mod_table(K+len_S-i-1,len_S-1)*pow(25,K-i,MOD)*pow(26,i,MOD)
  answer%=MOD
  
print(answer)

### FIXED CODE ###

MOD=10**9+7
K=int(input())
S=list(input())
len_S=len(S)

def invmod(a):
  return pow(a,MOD-2,MOD)
fact_dic={0:1}
fact_inv_dic={0:1}
fact_mod=1
for i in range(1,K+len_S+1):
  fact_mod=(fact_mod*i)%MOD
  fact_dic[i]=fact_mod
  fact_inv_dic[i]=invmod(fact_mod)
def comb_mod_table(n,r):
  if 0<=r<=n:
    return fact_dic[n]*fact_inv_dic[r]*fact_inv_dic[n-r]
  else:
    return 0
  
answer=pow(26,K+len_S,MOD)
pow25=pow(25,K+len_S,MOD)
inv25=invmod(25)
for i in range(len_S):
  answer-=comb_mod_table(K+len_S,i)*pow25
  pow25=pow25*inv25%MOD
  answer%=MOD
  
print(answer)
### BUGGY CODE ###

from numba import jit
import math
import numpy

@jit(cache=True)
def aaa(n):
    pl=[0]*(n+1)
    for i in range(1,n+1):
        for l in range (i,n+1,i):
            pl[l]+=1
    return(pl)

n=int(input())
p=numpy.array(list(range(n+1)))
pl=numpy.array(aaa(n))
q=numpy.dot(p,pl)
print(q)

### FIXED CODE ###

import math

def aaa(n):
    pl=[0]*(n+1)
    for i in range(1,n+1):
        for l in range (i,n+1,i):
            pl[l]+=1
    return(pl)

n=int(input())
p=(list(range(n+1)))
q=0
pl=aaa(n)
for i in range(n+1):
  q+=p[i]*pl[i]
print(q)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
INF = float('inf')

class MinSegTree:
    """
    0-indexed
    query : [L, R)
    """
    def __init__(self, size):
        self.size = 1 << (size.bit_length())  # 完全二分木にする
        self.data = [INF] * (2 * self.size - 1)

    def build(self, rawData):
        self.data[self.size - 1: self.size - 1 + len(rawData)] = rawData
        for i in range(self.size - 1)[:: -1]:
            self.data[i] = min(self.data[2 * i + 1], self.data[2 * i + 2])

    def update(self, index, value):
        index += self.size - 1
        self.data[index] = value
        while index >= 0:
            index = (index - 1) // 2
            self.data[index] = min(self.data[2 * index + 1], self.data[2 * index + 2])

    def query(self, left, right):
        L = left + self.size
        R = right + self.size
        ret = INF
        while L < R:
            if R & 1:
                R -= 1
                ret = min(ret, self.data[R - 1])
            if L & 1:
                ret = min(ret, self.data[L - 1])
                L += 1
            L >>= 1
            R >>= 1
        return ret

N, Q = map(int, input().split())

events = []
for i in range(N):
    S, T, X = map(int, input().split())
    events.append((S - X, 0, i, X))
    events.append((T - X, 1, i, X))

for _ in range(Q):
    events.append((int(input()), 2, 0, 0))
events.sort()

tree = MinSegTree(N)

ans = []
for t, flag, index, x in events:
    if flag == 0:
        tree.update(index, x)
    elif flag == 1:
        tree.update(index, INF)
    else:
        print(tree.data[0] if tree.data[0] != INF else -1)


### FIXED CODE ###

import sys
input = sys.stdin.readline
from collections import defaultdict
from heapq import heappop, heappush

N, Q = map(int, input().split())
INF = float('inf')

events = []
for i in range(N):
    S, T, X = map(int, input().split())
    events.append((S - X, 0, X))
    events.append((T - X, 1, X))

for _ in range(Q):
    events.append((int(input()), 2, 0))

events.sort()

cnt = defaultdict(int)
cnt[INF] += 1
que = [INF]

for t, flag, x in events:
    if flag == 0:
        if cnt[x] == 0:
            heappush(que, x)
        cnt[x] += 1
    elif flag == 1:
        cnt[x] -= 1
    else:
        while cnt[que[0]] == 0:
            heappop(que)
        print(que[0] if que[0] != INF else -1)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

class Factorization:	
	def __init__(self):
		# privateなインスタンス変数を作成
		self.__factors = dict()
		self.__n = 0
	
	
	def get_factors(self, n):
		# [summary] 素因数分解した結果を、辞書([素因数, 指数]...)で返す
		self.__factors.clear()
		self.__n = n
		
		if n < 2:
			# 2より小さい数の場合、素因数分解できない
			return { n:1 }
		else:
			self.__factorization()
			
			return self.__factors
	
	
	def get_divisors(self, n):
		# [summary] 約数をリストに列挙
		self.__factors.clear()
		self.__n = n
		
		if n < 2:
			return [1]
		else:
			self.__factorization()
			divisors = [1]
			
			for k, v in self.__factors.items():
				import copy
				copy_ = copy.deepcopy(divisors)
								
				for i in range(1, v + 1):
					for c in copy_:
						divisors.append(c * (k ** i))
			
			return divisors

				
	def count_divisors(self, n):
		# [summary] 約数の個数を返す
		self.__factors.clear()
		self.__n = n
		
		if n < 2:
			return 1
		else:
			self.__factorization()
			count = 1
			
			for v in self.__factors.values():
				count *= v + 1
			
			return count
	

	def	__factorization(self):
		# [summary]素因数分解した結果を、インスタンス変数に格納
		
		# 2,3,5で、割れなくなるまで割り続ける
		# (末尾に2,3,5のつく数は素数でないことが明白なので
		# 後続の処理で素数のリストに入れないように、先に処理する)
		self.__divide_with(2)
		self.__divide_with(3)
		self.__divide_with(5)
			
		# 平方根以下の素数で総当たりで試し割りする
		# (実際は、素数らしき数)
		import math
		sqrt_ = math.floor(math.sqrt(self.__n))
			
		primes = [7, 11, 13, 17, 19, 23, 29, 31]
		i = 0
		is_break = False
			
		while self.__n > 1:
			for p in primes:
				if p + i <= sqrt_:
					self.__divide_with(p + i)
				else:
					# 試し割りする数が平方根を超えたら、ループを抜ける
					is_break = True
						
					# 1が素因数に追加されることを防止
					if self.__n > 1:
						self.__factors.setdefault(self.__n, 1)
				
			if is_break:
				break
			else:
				i += 30
	
	
	def __divide_with(self, d):
		count = 0
		
		while self.__n % d == 0:
			self.__n //= d
			count += 1
		
		if count > 0:
			self.__factors.setdefault(d, count)


# D - Not Divisible
n = int(input())
a = list(map(int, input().split()))
dic = dict()

for ai in a:
	dic.setdefault(ai, 0)
	dic[ai] += 1

ans = 0
appeared = set()
lib = Factorization()

for k, v in sorted(dic.items(), key=lambda x:x[0]):
	if v == 1:
		divisors = lib.get_divisors(k)
		is_exist = False
		
		for d in divisors:
			if d in appeared:
				is_exist = True
				break

		if is_exist == False:
			ans += 1

	appeared.add(k)

print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

# D - Not Divisible
n = int(input())
a = list(map(int, input().split()))
dic = dict()

for ai in a:
	dic.setdefault(ai, 0)
	dic[ai] += 1

multiples = set()
upper = 10 ** 6

for k in dic.keys():
  i = 2
  
  while True:
    if k * i <= upper:
      multiples.add(k * i)
      i += 1
    else:
      break

ans = 0

for k, v in dic.items():
  if v == 1:
    if not k in multiples:
      ans += 1

print(ans)
### BUGGY CODE ###

S = input()
nQ_r = S.count('?')
nC_r = S.count('C')
nQ_l = 0
nA_l = 0
N = len(S)
mod = 10**9+7
ans = 0
for n, c in enumerate(S):
    if c=='C': nC_r-=1
    if c=='?': nQ_r-=1
    
    if n>0 and n<N-1 and (c=='B' or c=='?'):
        p = nQ_l*(3**(max(0, nQ_l-1) % (mod-1))) + nA_l*(3**(nQ_l % mod))
        q = nQ_r*(3**(max(0, nQ_r-1) % (mod-1))) + nC_r*(3**(nQ_r % mod))
        ans += p * q
        ans %= mod

    if c=='A': nA_l+=1
    if c=='?': nQ_l+=1

print(ans)

### FIXED CODE ###

S = input()
nQ_r = S.count('?')
nC_r = S.count('C')
nQ_l = 0
nA_l = 0
N = len(S)
mod = 10**9+7

pow3 = [1]*N
p = 1
for i in range(1,N):
    pow3[i] = p = p*3%mod

ans = 0
for n, c in enumerate(S):
    if c=='C': nC_r-=1
    if c=='?': nQ_r-=1
    
    if n>0 and n<N-1 and (c=='B' or c=='?'):
        p = ( nQ_l*pow3[max(0, nQ_l-1)] + nA_l*pow3[nQ_l] ) % mod
        q = ( nQ_r*pow3[max(0, nQ_r-1)] + nC_r*pow3[nQ_r] ) % mod
        ans += p * q
        ans %= mod

    if c=='A': nA_l+=1
    if c=='?': nQ_l+=1

print(ans)
### BUGGY CODE ###

n,q=map(int,input().split())
s=input()
count=[0]
for i in range(n-1):count.append(s[i:i+2]=="AC")
for i in range(q):
  a,b=map(int,input().split())
  print(sum(count[a:b]))

### FIXED CODE ###

n,q=map(int,input().split())
s=input()
count=[0]
for i in range(n-1):count.append(count[i]+(s[i:i+2]=="AC"))
for i in range(q):
  a,b=map(int,input().split())
  print(count[b-1]-count[a-1])
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
def f(x):
  c=[x[i-1]^x[i]for i in range(1,n)]
  k=[x[1:].count(1)%2]
  for i in c:
    k.append(k[-1]^i)
  return k
for i in range(31):
  t=1<<i
  x=[]
  for j in a:
    if t&j:x.append(1)
    else:x.append(0)
  m=f(x)
  for j in range(n):ans[j]+=t*m[j]
print(*ans)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
def f(x):
  c=[x[i-1]^x[i]for i in range(1,n)]
  k=[x[1:].count(1)%2]
  for i in c:
    k.append(k[-1]^i)
  return k
for i in range(31):
  t=1<<i
  x=[]
  for j in a:
    if t&j:x.append(1)
    else:x.append(0)
  m=f(x)
  for j in range(n):ans[j]+=t*m[j]
print(*ans)
### BUGGY CODE ###

k = int(input())
n = 7
cnt = 1
while 1:
    if n % k == 0:
        print(cnt)
        exit()
    elif n % k != 0 and cnt <1000000:
        cnt += 1
        n = (n*10 + 7) % k
    elif n % k != 0 and cnt > 1000000:
        print(-1)
        exit()


### FIXED CODE ###

k = int(input())

def cal(k):
    n = 7
    for i in range(1,10000000):
        if n % k == 0:
            return i
        else:
            n = (n *10 + 7) % k
    return -1

print(cal(k))
### BUGGY CODE ###

#!/usr/bin/env python3
# Knapsack問題

import numpy as np

# input
N,W = map(int, input().split())
w = np.zeros(N, dtype=int)
v = np.zeros(N, dtype=int)
for i in range(N):
  a,b = map(int ,input().split())
  w[i] = a 
  v[i] = b 

# calc
dp = [[0 for _ in range(W+1)] for _ in range(N+2)]
dp = np.array(dp, dtype=int)
for i in range(N):
   for j in range(W+1):
        if w[i] <= j:
            dp[i+1,j] = max(dp[i, j-w[i]]+v[i], dp[i,j])
        else:
            dp[i+1,j] = dp[i,j]

print(dp[N,W])


### FIXED CODE ###

# Knapsack問題

# input
N,W = map(int, input().split())
w = []
v = []
for _ in range(N):
    a,b = map(int ,input().split())
    w.append(a)
    v.append(b)

# calc
dp = [[0 for _ in range(W+1)] for _ in range(N+2)]

for i in range(N):
    for j in range(W+1):
        if w[i] <= j:
            dp[i+1][j] = max(dp[i][j-w[i]]+v[i], dp[i][j])
        else:
            dp[i+1][j] = dp[i][j]

print(dp[N][W])
### BUGGY CODE ###

n,m=(int(i) for i in input().split())

ans=set(int(i) for i in range(100000+10))

for i in range(m):
  a,b=(int(i) for i in input().split())
  myset=set()
  for i in range(a,b+1):
    myset.add(i)
  ans=ans&myset

print(len(ans))

### FIXED CODE ###

n,m=(int(i) for i in input().split())
list_a=[]
list_b=[]
for i in range(m):
  a,b=(int(i) for i in input().split())
  list_a.append(a)
  list_b.append(b)
  
max_a=max(list_a)
min_b=min(list_b)

if min_b-max_a+1>=0:
  print(min_b-max_a+1)
else:
  print(0)
### BUGGY CODE ###

import sys

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

if a == 0:
    print(0)
    sys.exit()

lst = []
is_blue = True
count = 0
for i in range(n):
    if is_blue:
        lst.append('b')
        count += 1
        if count == a:
            is_blue = False
            count = 0
    else:
        lst.append('r')
        count += 1
        if count == b:
            is_blue = True
            count = 0

result = list(filter(lambda x:x == 'b', lst))
print(len(result))

### FIXED CODE ###

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

ans = n // (a + b) * a
rem = n % (a + b)
ans += min(rem, a)
print(ans)