Harryxun/stf_run huggingface dataset:
n = int(input())

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

if a[0] != 0:
    b = [a[0]]
else:
    su += 1
    if b[1] > 0:
        b = [-1]
    else:
        b = [1]
su = 0
for i in range(n-1):
    b.append(b[-1]+a[1+i])
    if b[-1] * b[-2] > 0:
        su += abs(b[-1]) + 1
        if b[-2] > 0:
            b[-1] = -1
        else:
            b[-1] = 1
    else:
        if b[-1] == 0:
            su += 1
            if b[-2] > 0:
                b[-1] = -1
            else:
                b[-1] = 1
print(su)


### FIXED CODE ###

import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()

a = l()

po = [a[i] for i in range(n)]

for i in range(1,n):
    po[i] += po[i-1]

co = 0

ans = 0

for i in range(n):
    po[i] += co
    if i % 2 == 0:
        if po[i] > 0:
            continue
        else:
            co += abs(po[i]) + 1
            ans += abs(po[i]) + 1

    else:
        if po[i] < 0:
            continue
        else:
            co -= abs(po[i]) + 1
            ans += abs(po[i]) + 1
anss = 0
co = 0
po = [a[i] for i in range(n)]

for i in range(1,n):
    po[i] += po[i-1]

for i in range(n):
    po[i] += co
    if i % 2 != 0:
        if po[i] > 0:
            continue
        else:
            co += abs(po[i]) + 1
            anss += abs(po[i]) + 1

    else:
        if po[i] < 0:
            continue
        else:
            co -= abs(po[i]) + 1
            anss += abs(po[i]) + 1
print(min(ans,anss))
if N%2==0:
    for i in range(N):
        if A[i]%2==1 and (A[i]-1)/2<=N/2:
            B[(A[i]-1)//2]+=1
        else:
            print(0)
            exit()
    for i in range(len(B)):
        if B[i]!=2:
            print(0)
            exit()
    print(int(pow(2,N/2)%(pow(10,9)+7)))
elif N%2==1:
    for i in range(N):
        if A[i]%2==0 and A[i]/2<=N+1/2:
            B[A[i]//2]+=1
        else:
            print(0)
            exit()
    if B[0]!=1:
        print(0)
        exit()
    for i in range(len(B)-1):
        if B[i+1]!=2:
            print(0)
            exit()
    print(int(pow(2,(N-1)/2)%(pow(10,9)+7)))
else:
    print(0)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
B=[0]*(N//2+N%2)
IndexCount=0
IndexRe=0
Divider=pow(10,9)+7
ans=1
if N%2==0:
    for i in range(N):
        if A[i]%2==1 and (A[i]+1)/2<=N/2:
            B[(A[i]-1)//2]+=1
        else:
            print(0)
            exit()
    for i in range((N//2+N%2)):
        if B[i]!=2:
            print(0)
            exit()
    IndexCount=int((N/2)//1000)
    IndexRe=int((N/2)%1000)
    for i in range(IndexCount):
        ans=(ans*(pow(2,1000)%Divider))%Divider
    ans=(ans*(pow(2,IndexRe)%Divider))%Divider
    print(ans)
elif N%2==1:
    for i in range(N):
        if A[i]%2==0 and A[i]/2<=(N-1)/2:
            B[A[i]//2]+=1
        else:
            print(0)
            exit()
    if B[0]!=1:
        print(0)
        exit()
    for i in range((N//2+N%2)-1):
        if B[i+1]!=2:
            print(0)
            exit()
    IndexCount=int(((N-1)/2)//1000)
    IndexRe=int(((N-1)/2)%1000)
    for i in range(IndexCount):
        ans=(ans*(pow(2,1000)%Divider))%Divider
    ans=(ans*(pow(2,IndexRe)%Divider))%Divider
    print(ans)
else:
    print(0)
s = input()
k = int(input())

if len(s) == 1:
    print(s[0])
    exit()

if k == 1:
    print(s[0])
else:
    i == 0
    while i <= k:
        if s[i] != '1':
            print(s[i])
            break
        elif i == k:
            print(s[i])
            break
        i += 1


### FIXED CODE ###

s = input()
k = int(input())

if len(s) == 1:
    print(s[0])
    exit()

if k == 1:
    print(s[0])
else:
    i = 1
    while i <= k:
        if s[i-1] != '1':
            print(s[i-1])
            break
        elif i == k:
            print(s[i-1])
            break
        i += 1
X,A,B=(int(i) for i in input().split())
c=int(B-A)
if c<0:
  print('delicious')
elif c<X+1:
  print('safe')
elif: c>X+1:
  print('dangerous')

### FIXED CODE ###

X,A,B=(int(i) for i in input().split())
c=int(B-A)
if c<=0:
  print('delicious')
elif 0<c<=X:
  print('safe')
elif c>X:
  print('dangerous')
N = input()

A=[]
for i in range(N):
    A.append(i)

B = []
for i in range(2**N):
    gokei = 0
    for j in range(N):
        if ((i >> j) & 1):
            gokei += A[j]
    gokei.append(B)

B.sort(reverse=True)

for i in B:
    if i%10 != 0:
        print(i)
        exit()

### FIXED CODE ###

N = int(input())

A=[]
for i in range(N):
    A.append(int(input()))

A.sort()

gokei = sum(A)

if gokei%10 != 0:
    print(gokei)
else:
    for i in range(N):
        if (gokei - A[i])%10 != 0:
            print(gokei - A[i])
            break
    else:
        print(0)
from collections import Counter
import itertools as it

N=int(input())
l=[]
for i in range(N):
    l.append(tuple(map(int,input().split())))
l.sort()

d=[(c[1][0]-c[0][0],c[1][1]-c[0][1]) for c in it.combinations(l,2)]
ans=N-max(dict(Counter(d)).values())

print(ans)

### FIXED CODE ###

from collections import Counter
import itertools as it

N=int(input())
l=[]
for i in range(N):
    l.append(tuple(map(int,input().split())))
l.sort()

if N==1:
    ans=1
else:
    d=[(c[1][0]-c[0][0],c[1][1]-c[0][1]) for c in it.combinations(l,2)]
    ans=N-max(dict(Counter(d)).values())

print(ans)
a,b = map(int,input().split())

if a == b:
    print(a)
    exit()
ansl = []
if a % 2 == 1:
    ansl.append(a)
    a += 1
if b % 2 == 0:
    ansl.append(b)
    b -= 1

k = b - a + 1
k = k // 2
if k % 2 == 1:
    ansl.append(1)
if len(ansl) == 0:
    print(0)
if len(ansl) == 1:
    print(ansl[0])
elif len(ansl) == 2:
    print(ansl[0] ^ ansl[1])
else:
    print(ansl[0] ^ ansl[1] ^ ansl[2])

### FIXED CODE ###

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

a1 = 0
b1 = 0
l = []
if a % 2 != 0:
   a1 = 1
if b % 2 == 0:
   b1 = 1
if a1 == 1:
   l.append(a)
one = b - a + 1 - a1 -b1
if one // 2 % 2 == 0:
   l.append(0)
if one // 2 % 2 == 1:
   l.append(1)
if b1 == 1:
   l.append(b)

if len(l) == 1:
   print(l[0])
if len(l) == 2:
   print(l[0]^l[1])
if len(l) == 3:
   print(l[0]^l[1]^l[2])
n = int(input())
s = list(input())
ans = s.count('R')*s.count('G')*s.count('B')

for i in range(n):
  if s[i] == 'R':
    s[i] = 1
  elif s[i] == 'G':
    s[i]
  elif s[i] = 4
  
for i in range(n):
  for j in range(i+1, n):
    k = 2*j - i
    if k >= n:
      continue
    if s[i]+s[j]+s[k]==7:
      ans-=1

print(ans)

### FIXED CODE ###

n = int(input())
s = list(input())
ans = s.count('R')*s.count('G')*s.count('B')

for i in range(n):
  if s[i] == 'R':
    s[i] = 1
  elif s[i] == 'G':
    s[i] = 2
  elif s[i] == 'B':
    s[i] = 4
  
for i in range(n):
  for j in range(i+1, n):
    k = 2*j - i
    if k >= n:
      continue
    if s[i]+s[j]+s[k]==7:
      ans-=1

print(ans)
a = p.strip()
l = a.split()
m = l.pop(0)
print(len(set(l)))


### FIXED CODE ###


a = int(input())
l = [input() for i in range(a)]
print(len(set(l)))
def main():
    input_string = list(map(int,input().split()))
    N = input_string[0]
    A = input_string[1]
    B = input_string[2]

    price1 = A*T
    price2 = B

    print(min(price1,price2))

main()


### FIXED CODE ###

def main():
    input_string = list(map(int,input().split()))
    N = input_string[0]
    A = input_string[1]
    B = input_string[2]

    price1 = A*N
    price2 = B

    print(min(price1,price2))

main()
a=int(input())
b=int(input())
c=int(input())
x=int(input())
cnt = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i+100*j+50*k == x:
        cnt +=1
print(cnt)


### FIXED CODE ###

x = int(input())
a = int(input())
b = int(input())

print((x-a)%b)
def resolve():
    '''
    code here
    '''
    H, W = [int(item) for item in input().split()]

    if H == 1 or W == 1:
        res = 1
    elif H % 2 == 1 and W % 2 == 1:
        res += H * W // 2 +1
    else:
        res = H * W // 2

    print(res)
if __name__ == "__main__":
    resolve()


### FIXED CODE ###

def resolve():
    '''
    code here
    '''
    H, W = [int(item) for item in input().split()]

    if H == 1 or W == 1:
        res = 1
    elif H % 2 == 1 and W % 2 == 1:
        res = H * W // 2 +1
    else:
        res = H * W // 2

    print(res)
if __name__ == "__main__":
    resolve()
N, M = map(int, input().split())
    a = [int(input()) for i in range(M)]
    inf = 10**9+7

    #動的計画法問題
    dp = [0] * (N+1)
    dp[0] = 1
    if 1 not in a:
        dp[1] = 1
    else:
        dp[1] = 0

    for i in range(2,N+1):
        if i in a:
            continue
        dp[i] = dp[i-1] + dp[i-2]
        
        dp[i] %= inf

    print(dp[N]) 

### FIXED CODE ###

N, M = map(int, input().split())
a = set([int(input()) for _ in range(M)])
INF = 1000000007

dp = [0] * (N + 1)
dp[0] = 1
if 1 not in a:
	dp[1] = 1
else:
	dp[1] = 0
for i in range(2, N + 1):
	if i in a:
		continue
	dp[i] = dp[i - 1] + dp[i - 2]
	dp[i] %= INF

print(dp[N])
x = input()
x = x.split()
x = [int(z) for z in x]
#y = x[1].split(" ")
#y = [int(z) for z in y]
cmax = ???1000000
cmin = 1000000
csum = 0
for z in x:
    if cmax < z:
        cmax = z
    if cmin > z:
        cmin = z
    csum += z
print("%d %d %d" % (cmin, cmax, csum))

### FIXED CODE ###

x = input()
x = input()
x = x.split(" ")
x = [int(z) for z in x]
cmax = -1000000
cmin = 1000000
csum = 0
for z in x:
    if cmax < z:
        cmax = z
    if cmin > z:
        cmin = z
    csum += z
print("%d %d %d" % (cmin, cmax, csum))
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 21 18:19:39 2020

@author: matsui
"""


N,W=map(int,input().split())
dp=[0]*(W+1)
L = sorted([list(map(int,input().split())) for i in range(N)])
s=0

for w, v in L:
    s+=w
    for j in range(min(W,s),w-1,-1):
        if dp[j-w]+v > dp[j]: dp[j]=dp[j-w]+v
    
print(max(dp))


### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Tue Jan 21 18:19:39 2020

@author: matsui
"""


N,W=map(int,input().split())
vi,wi=[],[]
for i in range(N):
    w,v=map(int,input().split())
    wi.append(w)
    vi.append(v)
    

#L = sorted([list(map(int,input().split())) for i in range(N)])

M=int(sum(vi))
dp=[W+1]*(M+1)
dp[0]=0
   
#L = sorted([list(map(int,input().split())) for i in range(N)])
s=0

for w, v in zip(wi,vi):
    s+=v
    for j in range(min(s,M),v-1,-1):
        if dp[j] > dp[j-v]+w: dp[j]=dp[j-v]+w
    #print(dp)

m=0
for i in range(M+1):
    if dp[i]<=W:
        m=i
print(m)
from typing import List
from preconditions import preconditions
import heapq


def solve(N: int, M: int, a: List[int], b: List[int]) -> int:
    q = []
    ret = 0
    conditions = sorted([(b[i], a[i]) for i in range(M)], key = lambda x: x[1])
    ci = 0
    for i in range(N+1):
        while ci < len(conditions) and i == conditions[ci][1]:
            heapq.heappush(q, conditions[ci])
            ci += 1
        if len(q) > 0 and i == q[0][0]-1:
            ret += 1
            q = []
    return ret





def main():
    N, M = list(map(int, input().split(' ')))
    a = []
    b = []
    for i in range(M):
        ai, bi = list(map(int, input().split(' ')))
        a.append(ai)
        b.append(bi)

    print(solve(N, M, a, b))



if __name__ == '__main__':
    main()

### FIXED CODE ###

import heapq


def solve(N, M, a, b):
    q = []
    ret = 0
    conditions = sorted([(b[i], a[i]) for i in range(M)], key = lambda x: x[1])
    ci = 0
    for i in range(N+1):
        while ci < len(conditions) and i == conditions[ci][1]:
            heapq.heappush(q, conditions[ci])
            ci += 1
        if len(q) > 0 and i == q[0][0]-1:
            ret += 1
            q = []
    return ret





def main():
    N, M = list(map(int, input().split(' ')))
    a = []
    b = []
    for i in range(M):
        ai, bi = list(map(int, input().split(' ')))
        a.append(ai)
        b.append(bi)

    print(solve(N, M, a, b))



if __name__ == '__main__':
    main()
print("ACL"*(int(input()))

### FIXED CODE ###

print("ACL"*(int(input())))
4
0 0
0 1
1 0
1 1


### FIXED CODE ###

import sys
from collections import defaultdict

# sys.stdin = open('e1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def solve():
    def collinear(x0, y0, x1, y1):
        return x0 * y1 == x1 * y0

    def aligned(i, j, k):
        return collinear(x[j] - x[i], y[j] - y[i], x[k] - x[i], y[k] - y[i])

    n = read_int()
    mod = 998244353
    res = pow(2, n, mod) - n - 1
    x, y = zip(*[read_int_list() for i in range(n)])
    lines = defaultdict(set)
    for i in range(n):
        for j in range(i + 1, n):
            a = y[i] - y[j]
            b = x[j] - x[i]
            g = gcd(a, b)
            a //= g
            b //= g
            if a < 0 or (a == 0 and b < 0):
                a, b = -a, -b
            c = -(a * x[i] + b * y[i])
            lines[(a, b, c)].add(i)
            lines[(a, b, c)].add(j)
    for k, v in lines.items():
        m = len(v)
        res -= pow(2, m, mod) - m - 1
    res %= mod
    return res


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()
import collections

N = int(input())
x_y = []
for _ in range(N):
    x_y.append(list(map(int, input().split())))

x_y.sort(key=lambda x: (x[0], x[1]))
pq_cand = []
for i in range(N):
    for j in range(i + 1, N):
        pq_cand.append((x_y[j][0] - x_y[i][0], x_y[j][1] - x_y[i][1]))

pqc = collections.Counter(pq_cand)
_, x = max(pqc.items(), key=lambda x: x[1])
print(N - 1 - x + 1)


### FIXED CODE ###

import collections

N = int(input())

if N == 1:
    print(1)
    exit()

x_y = []
for _ in range(N):
    x_y.append(list(map(int, input().split())))

x_y.sort(key=lambda x: (x[0], x[1]))
pq_cand = []
for i in range(N):
    for j in range(i + 1, N):
        pq_cand.append((x_y[j][0] - x_y[i][0], x_y[j][1] - x_y[i][1]))

pqc = collections.Counter(pq_cand)
_, x = max(pqc.items(), key=lambda x: x[1])
print(N - 1 - x + 1)
N = int(input())
S = str(input())
count = 0
for i in range(N):
  for i in range(i,N):
    for i in range(j,N):
      if S[i] != S[j] and S[i] != S[k] and S[j] != S[k] and j-i != k-j:
        count += 1

### FIXED CODE ###

N = int(input())
S = str(input())
count = S.count('R')*S.count('G')*S.count('B')
for i in range(N):
  for l in range(N):
    j = i + l
    k = j + l
    if k >= N:
      break
    if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
      count -= 1

print(count)
N = int(input())

lst = []
for _ in range(N):
    tmp = list(input())
    tmp.sort()
    lst.append(tmp)
lst.sort()
tmp = lst[0]
count = 1
ans = 0
for i in range(1, N):
    if tmp == lst[i]:
        count += 1
    else:
        ans = ans + (count * (count - 1))//2
        count = 1
        tmp = lst[i]
ans = ans + (count * (count - 1))//2
print (ans)


### FIXED CODE ###

#単一始点最短経路問題
#負の辺があっても動作する

#最短経路を求める
#計算量O(N * M)

INF = 10 ** 15
#入力
# N = int(input()) #頂点の数
# M = int(input()) #辺の数
N, M, P = map(int, input().split())

# 入力は1-index
# 内部で0-indexにして処理
G = []
for _ in range(M): #M個の辺の情報を受け取る
    l, r, s = map(int, input().split()) #lからrへ重みsの辺が存在
    G += [[l-1, r-1, -(s-P)]] #有向グラフのときはここだけ
    # G += [[r-1, l-1, s]] #無向グラフのときはこの行も必要


#メイン文
d = [0] * N #最短距離を記録しておくリスト
# prev = [-1] * N
def shortest_path(s): #S番目の頂点から各頂点への最短距離を求める
    s -= 1
    for i in range(N):
        d[i] = INF
    d[s] = 0
    count = 0
    while True:
        count += 1
        update = False
        for i in range(M): #無向グラフのときは辺は実質的には2倍
            e = G[i]
            if d[e[0]] != INF and d[e[1]] > d[e[0]] + e[2]:
                d[e[1]] = d[e[0]] + e[2]
                update = True
                # prev[e[1]] = e[0]
        if not update: #更新が終わったとき
            return True
        if count == N - 1: #永遠に更新が起きているとき
            tmp = d[N -1]
        if count == 2 * N:
            if d[N - 1] == tmp:
                return True #N-1の値が更新されていないとき
            else:
                return False #N + 2回目でもN - 1の値が小さくなっている-->得点が無限に大きくなる

#呼び出しスタート地点を入れる
if not shortest_path(1):
    print (-1)
    # print (d)
    exit()
# print (d)

print (max(0, -d[N - 1]))
import sys
input = sys.stdin.readline
# lines = open("tmp_in").readlines()

# def _input():
#     for ss in lines:
#         yield ss.rstrip()
# input = _input().__next__

s = input()
q = int(input())
turn = 0
# ともにSに近い方から並べる
before = "" 
after = ""
for _ in range(q):
    tmp = input()
    if tmp=="1":
        turn += 1
    else:
        _,f,c = tmp.split()
        f = int(f)
        if (turn + f) % 2 == 1:
            before += c
        else:
            after += c
if turn%2==0:
    out = before[::-1] + s + after
else:
    out = after[::-1] + s[::-1] + before
print(out)

### FIXED CODE ###


s = input()
q = int(input())
turn = 0
# ともにSに近い方から並べる
before = "" 
after = ""
for _ in range(q):
    tmp = input()
    if tmp=="1":
        turn += 1
    else:
        _,f,c = tmp.split()
        f = int(f)
        if (turn + f) % 2 == 1:
            before += c
        else:
            after += c
if turn%2==0:
    out = before[::-1] + s + after
else:
    out = after[::-1] + s[::-1] + before
print(out)
X = int(input())
if X = 7 or 5 or 3:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

X = int(input())
wk = (X-7)*(X-5)*(X-3)
if wk == 0:
    print("YES")
else:
    print("NO")
a, b, c =map(int, input().split())
print("Yes" if b-a=c-b else "No")

### FIXED CODE ###

a, b, c = map(int, input().split())
print("YES" if b-a==c-b else "NO")
N,S = map(int,input().split())
 
A = list(map(int,input().split()))

N,S = inputIL()
A = inputIL()

dp = [0] * (S+1)
ans = 0
mod = 998244353


for i in range(N):
 
    ndp = []
    for ll in dp:
        ndp.append(ll)
 
    if A[i] <= S:
        ndp[A[i]] += i+1
        ndp[A[i]] %= mod
 
    for j in range(S):
        if j+A[i] <= S:
            ndp[j+A[i]] += dp[j]
            ndp[j+A[i]] %= mod
 
    ans += ndp[S]
    ans %= mod
 
    dp = ndp

print(ans)


### FIXED CODE ###

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

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

"""
dpなのはそうだろう
普通に行けば、ナップサックdpでいける
S以下のみしか保持しなくていい

始点を保持してしまうと、Sになった時に…？
始点より左にあるやつの個数の和を記録しておけばいい！

連続してなくていいから
"""

dp = [0] * (S+1)
ans = 0
mod = 998244353

for i in range(N):

    ndp = []
    for ll in dp:
        ndp.append(ll)

    if A[i] <= S:
        ndp[A[i]] += i+1
        ndp[A[i]] %= mod

    for j in range(S):

        if j+A[i] <= S:
            ndp[j+A[i]] += dp[j]
            ndp[j+A[i]] %= mod

    ans += ndp[S]
    ans %= mod

    dp = ndp

    #print (dp)

    
print (ans)
a,b=map(int,input().split())

if a<b :
    print('a<b')
elif a>b :
    print('a>b')
else a=b :
    print('a==b')
    

### FIXED CODE ###

a,b=map(int,input().split())
print(a*b,(a+b)*2)
a,b,k = map(int,input().split())
tmp = list(range(a,b+1))
if a+k-1<b-k+1:
	ans = tmp[:k] + tmp[-k:]
else:
	ans = tmp
for i in sorted(set(ans)):
	print(i)

### FIXED CODE ###

a,b,k=map(int,input().split())
if a+k-1>=b-k+1:
    for i in range(a,b+1):
        print(i)
else:
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)
K = int(input())

if 7%K==0:
  print("1")
  exit(0)
if 77%==0:
  print("2")
  exit(0)
if 777%==0:
  print("3")
  exit(0)
if 7777%==0:
  print("4")
  exit(0)
if 77777%==0:
  print("5")
  exit(0)
if 777777%==0:
  print("6")
  exit(0)
if 7777777%==0:
  print("7")
  exit(0)
  
print("-1")

### FIXED CODE ###

def calc(k):
    cur = 0
    for i in range(1, 10 ** 7):
        cur *= 10
        cur += 7
        cur %= k
        if cur == 0:
            return i

    return -1


k = int(input())
print(calc(k))
s = input()
tmp = 700
if s[0] == o:
  tmp += 100
if s[1] == o:
  tmp += 100
if s[2] == o:
  tmp += 100
print(tmp)

### FIXED CODE ###

s = input()
tmp = 700
if s[0] == "o":
  tmp += 100
if s[1] == "o":
  tmp += 100
if s[2] == "o":
  tmp += 100
print(tmp)
n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = n

if a[0] % a[1] == 0:
    ans -= 1

for i in range(1,n):
    for j in range(i):
        if a[i] % a[j] == 0:
            ans -= 1
            break

print(ans)

### FIXED CODE ###

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

dp = [0]*(10**6 + 1)
ans = 0

for i in a:
    if dp[i] == 0:
        for j in range(1,10**6+1):
            if i * j > 10**6:
                break
            dp[i*j] += 1
    elif dp[i] == 1:
        dp[i] += 1

for i in a:
    if dp[i] == 1:
        ans += 1


print(ans)
print((int(input()-1)*90)

### FIXED CODE ###

a=int(input())
print(a*180-360)
n,k = map(int, input().split())
s = list(x for x in input())
ans = 0

if s[0] == 'R':
  s.insert(0, 'L')
if s[-1] == 'R':
  s.append('L')
s.append(0)
l = []
r = []


for i in range(len(s)-1):
  if s[i] == 'L':
    l.append(i)
    if s[i+1] == 'L':
      ans += 1
      
for i in range(len(l)-1):
  r.append(l[i+1] - l[i] - 1)

r.sort(reverse = True)

for i in range(k):
  if r[i] != 0:
    ans += r[i] + 1
  else:
    break

if n == 1:
  print(0)
elif n == 2:
  print(1)
elif ans == n:
  print(n-1)
else:
  print(ans)


### FIXED CODE ###

n,k = map(int, input().split())
s = input()
ans = 0
for i in range(len(s)-1):
	if s[i] == s[i+1]:
		ans += 1
ans += 2*k
 
print(min(ans, n-1))
h, n= list(map(int,input().split()))
a = []
b = []
for i in range(n):
    a_in, b_in = list(map(int,input().split()))
    a.append(a_in)
    b.append(b_in)

def ibis(h,a,b,n):
    if h <= 0:
        return 0
    else:
        c = [0]*n
        for i in range(n):
            c[i] = b[i] + ibis(h-a[i],a,b,n)
        return(min(c))
 
print(ibis(h,a,b,n))

### FIXED CODE ###

h, n= list(map(int,input().split()))
a = []
b = []
for i in range(n):
    a_in, b_in = list(map(int,input().split()))
    a.append(a_in)
    b.append(b_in)

if h == 1:
    print(min(b))
else:
    dp = [0]*h
    dp[0] = min(b)
    for i in range(2,h+1):
        c = [0]*n
        for j in range(n):
            if i > a[j]:
                c[j] = b[j] + dp[i-a[j]-1]
            else:
                c[j] = b[j]
        dp[i-1] = min(c)
    print(dp[h-1])
x=raw_input().split()

for i in range(len(x)):
print x[::-1],

### FIXED CODE ###

n = int(raw_input())
a = map(int,raw_input().split())
a.reverse()
for i in a:
    print i,
import math

def dist(x, y):
  math.sqrt(x ^ 2 + y ^ 2)

(n, d) = map(int, input().split())
res = 0

for _ in range(n):
  (x, y) = map(int, input().split())
  res += 1 if dist(x, y) <= d else 0
  
print(res)

### FIXED CODE ###

import math

def dist(x, y):
  return math.sqrt(x ** 2 + y ** 2)

(n, d) = map(int, input().split())
res = 0

for _ in range(n):
  (x, y) = map(int, input().split())
  res += 1 if dist(x, y) <= d else 0

print(res)
n=int(input())
a=sorted(list(map(int,input().split())))
ans='YES'
for i in range(n):
  if a[i]==a[i+1]:
    ans='NO'
  if ans=='NO':
    break
print(ans)

### FIXED CODE ###

n=int(input())
a=sorted(list(map(int,input().split())))
ans='YES'
for i in range(n-1):
  if a[i]==a[i+1]:
    ans='NO'
  if ans=='NO':
    break
print(ans)
n=int(input())
s=input()
word=""
for i in range(len(s)):
    if ord(i)+n>90:
        word+=chr(ord(i)+n-26)
    else:
        word+=chr(ord(i)+n)
print(word)


### FIXED CODE ###

n=int(input())
s=input()
word=""
for i in range(len(s)):
    if ord(s[i])+n>90:
        word+=chr(ord(s[i])+n-26)
    else:
        word+=chr(ord(s[i])+n)
print(word)