peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n,x = map(int,input().split())
xi = list(map(int,input().split()))

xi.sort()
diff = []
for i in range(n):
    diff.append(abs(xi[i]-x))

import numpy
print(numpy.gcd.reduce(diff))
# Judge status: Wrong Answer
N = int(input())
H = list(map(int, input().split()))
ans = 0
temp = 0
for i in range(N-1):
  if H[i] >= H[i+1]:
    temp += 1
  else:
    if temp > ans:
      ans = temp
      temp = 0
if temp > ans:
  ans = temp
  
print(ans)
# Judge status: Accepted
n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(m)]

if m == 1:
  print("IMPOSSIBLE")

else:
  root = [[] for i in range(n)]
  for a, b in ab:
    root[a-1].append(b-1)
  
  flag = False
  for j in root[0]:
    if n-1 in root[j]:
      flag = True
      break

  print("POSSIBLE" if flag else "IMPOSSIBLE")
# Judge status: Accepted
S = input()

a = {'R', 'U', 'D'}
b = {'L', 'U', 'D'}
Odd = set(S[0::2])
Even = set(S[1::2])

if Even <= b and Odd <= a:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
A, B, C, K = map(int, input().split())

if K <= A:
    print(K)
elif K <= A + B:
    print(A)
else:
    print(A - (K - A - B))
# Judge status: Accepted
n,m = map(int,input().split())
ls = [list(map(int,input().split())) for i in range(n)]
for i in range(n):
    del ls[i][0]
Ls = []
for i in range(m):
    a = 0
    for j in range(n):
        a += ls[j].count(i+1)
    Ls.append(a)
print(Ls.count(n))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
s = 0
for i in range(n):
  s = s ^ a[i]
b = [0] * n
for i in range(n):
  b[i] = s ^ a[i]

print(*b)
# Judge status: Wrong Answer
from collections import Counter
N,M = map(int,input().split())
A = Counter(list(map(int,input().split())))
for i in range(M):
    b,c = map(int,input().split())
    if c in A.keys():
        A[c] += b
    else:
        A[c] = b
A = sorted(A.items(),reverse=True)
check = N
ans = 0
for i in A:
    if i[1]<check:
        check -= i[1]
        ans += (i[0] * i[1])
    else:
        ans += i[1] * check
print(ans)
# Judge status: Accepted
k = int(input())
a, b = map(int, input().split())
ans = 'NG'
for i in range(a, b+1):
  if i % k == 0:
    ans = 'OK'
    break
print(ans)
# Judge status: Accepted
s=input()
k=int(input())

for i in range(len(s)):
    if s[i]!="1":
        nextone=s[i]
        break
if s.count("1")==len(s):
    print(1)
elif i>=k:
    print(1)
else:
    print(nextone)
# Judge status: Accepted
s=input()
print('Yes' if len(set(s))==3 else 'No')
# Judge status: Accepted
A, B, C=map(int,input().split(' '))
if((A-C)*(B-C)<0):
  print('Yes')
else:
  print('No')
# Judge status: Accepted
n = int(input())
count = 0
for i in range(1, n + 1, 2):
    div = 0
    for j in range(1, i + 1):
        if i % j == 0:
            div += 1
    if div == 8:
        count += 1
print(count)
# Judge status: Accepted
w=input()
lst=[]
flag = 0
for i in w:
    lst.append(i)

for i in range(len(w)):
    if lst[i] == 99:
        continue
    c = 1
    j = i + 1
    while j < len(w):
        if lst[i] == lst[j]:
            lst[j] = 99
            c += 1
        j += 1
    if c % 2 != 0:
        print("No")
        flag = 1
        break

if flag == 0:
    print("Yes")
# Judge status: Accepted

n = int(input())
if n <= 999:
  answer = "ABC"
else:
  answer = "ABD"
print(answer)
# Judge status: Accepted
import math

n, k = map(int, input().split())

ans = 0
for i in range(1, n+1):
    if i > k:
        ans += 1/n
    else:
        x = math.ceil(math.log2(k/i))
        ans += 1/n/(2**x)

print(ans)
# Judge status: Accepted
from math import gcd

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

X = int(input())
print(lcm(X, 360) // X)
# Judge status: Wrong Answer
from sys import stdin
a,b,c=map(int,stdin.readline().split())
k=int(stdin.readline())
for i in range(k):
  if i%2!=0:
    c*=2
  if i%2==0:
    b*=2
if c>b and b>a:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
N = int(input())
res = N%1000

if N == 0:
  print(res)
else:
  print(1000-res)
# Judge status: Accepted
S,T=input().split()
#print(S)
A,B=map(int,input().split())

U=input()
if U==S:
    A-=1
else:
    B-=1
print(A,B)
# Judge status: Wrong Answer
N,K = map(int,input().split())
H = [int(i) for i in input().split()]

if K >= N:
  print(0)
else:
  I = sorted(H)
  a = 0
  for i in range(N-K):
    a += H[i]
  print(a)
# Judge status: Accepted
#!/usr/bin/env python3
import sys

def main():
    N, K = map(int,input().split())
    a = list(map(int,input().split()))

    answer = 0
    for i in range(N):
        if K + (i-1)*(K-1) >= N:
            answer = i
            break

    print(answer)
    return

if __name__ == '__main__':
    main()
# Judge status: Accepted
A, B = map(int, input().split())

ans = -1

for i in range(1250):
    if int(i * 0.08) == A and int(i * 0.10) == B:
        ans = i
        break

print(ans)
# Judge status: Accepted
#!/usr/bin/env python3
# import math
n = int(input())

ans = [-1]*(n+1)

ans[0] = 0
for i in range(1, n+1):
    num = i
    data = ans[i-1]+1
    for j in range(8):
        index = i-6**j
        if index < 0:
            break
        data = min(data, ans[index]+1)
    for j in range(8):
        index = i-9**j
        if index < 0:
            break
        data = min(data, ans[index]+1)
    ans[i] = data
print(ans[-1])
# Judge status: Wrong Answer
def main():
    s = input()
    for i in range(1, len(s)):
        r = s[:-i]
        q = len(s[:-i])
        if q % 2 != 0:
            continue
        if r[:q//2] == r[q//2:]:
            ans = q
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
N, M = map(int, input().split())
order = [i for i in range(2, N+1)]
reverse = order[::-1]
d = 0
for i in range(M):
    if N%4 == 0 and reverse[i] - order[i] == N//2:
        d = 1
    if N%2 == 0 and i == (N//2-1) //2:
        d = 1
    print(order[i+d], reverse[i])
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

m = 0
ab = []
for i in a:
    if i < 0:
        m+=1
        i = i*-1
    ab.append(i)

if m%2 == 0:
    print(sum(ab))
else:
    ab.sort()
    print(sum(ab[1:])-ab[0] )
# Judge status: Wrong Answer
n = int(input())
A = [0]*n
B = [0]*n
for i in range(n):
  A[i],B[i] = map(int,input().split())

ans = 0
for i in range(n):
  j = -1-i  
  if B[j] == 1:
    continue
  ans += B[j] - (A[j]+ans)%B[j]  
  
print(ans)
# Judge status: Accepted
N, M = [int(i) for i in input().split(" ")]
con = 0

for i in range(N):
    con += i

for j in range(M):
    con += j

print(con)
# Judge status: Wrong Answer
k = int(input())

n = k // 2
if k % 2 == 0:
  print(k**2)
else:
  print(k * (k + 1))
# Judge status: Accepted
n,m = map(int,input().split())
li = [list(map(int, input().split())) for _ in range(n)]
li.sort()
s = 0
money = 0
for i in range(len(li)):
  s+=li[i][1]
  if s>= m:
    s -=li[i][1]
    nokori = m-s
    money += li[i][0]*nokori
    break
  else:
    money += li[i][0]*li[i][1]
print(money)
# Judge status: Wrong Answer
N,M=map(int,input().split())

O = M//2

print( (N+O)//2 )
# Judge status: Wrong Answer
import math
n, d = map(int, input().split())
ans = 0
for _ in range(n):
  x, y = map(int, input().split())
  a = x**2 + y **2
  d = d**2
  if a <= d:
    ans+=1
print(ans)
# Judge status: Accepted
import string
atoz = string.ascii_lowercase
N = int(input())
azcount = {}
for i in range(N):
  s = input()
  for alph in atoz:
    if alph in azcount:
      azcount[alph] = min(s.count(alph), azcount[alph])
    else:
      azcount[alph] = s.count(alph)
res = ''

for alph in atoz:
  res += alph * azcount[alph]

print(res)
# Judge status: Wrong Answer
N, M = map(int, input().split())

A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

ans = None
for i in range(N-M):
  for j in range(N-M):
    try:
      for k in range(i, i+M):
        for l in range(j, j+M):
          if A[i+k][j+l] != B[k][l]:
            raise ""
      else:
        ans = 'Yes'
    except:
      pass

print(ans if ans else 'No')
# Judge status: Accepted
w, h, x, y = map(int, input().split())
print(w * h / 2, 1 if x == w / 2 and y == h / 2 else 0)
# Judge status: Accepted
abc = list(map(int, input().split()))

c = max(abc)
abc.remove(c)
a = abc[0]
b = abc[1]

#%%
d_ca = c - a
d_cb = c - b
if d_ca%2 == 0 and d_cb%2 == 0:
    ans = d_ca // 2 + d_cb // 2
elif d_ca%2 == 1 and d_cb%2 == 1:
    ans = d_ca // 2 + d_cb // 2 + 1
else:
    ans = d_ca // 2 + 1 + d_cb // 2 + 1

print(ans)
# Judge status: Wrong Answer
a,b=map(int,input().split())


print(a)
print(b)

if a%2!=0 and b%2!=0:
  print("Odd")
else:
  print("Even")
# Judge status: Accepted
n,m=map(int,input().split())
adj=[[]for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    a,b=a-1,b-1
    adj[a].append(b)
    adj[b].append(a)
for i in adj[0]:
    if n-1 in adj[i]:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")
# Judge status: Accepted
from collections import Counter as cnt
n =  int(input())
A = list(map(int, input().split()))
dic = cnt(A)
total = 0
for num in dic.values():
  if num >= 2:
    total += num * (num - 1) // 2
    
for num in A:
  target = dic[num]
  ans = total
  if target >= 2:
    ans -= target * (target - 1) // 2
    ans += (target - 1) * (target - 2) // 2
  print(ans)
# Judge status: Accepted
s = input()
l = len(s)
t = [0] * l
t[l - 1] = int(s[l - 1])
m = [0] * 2019
m[0] = 1
m[int(s[l - 1])] = 1
ten = 10
ans = 0

for i in range(l - 1, 0, -1):
    t[i - 1] = (t[i] + int(s[i - 1]) * ten) % 2019
    ten = ten * 10 % 2019
    m[t[i - 1]] += 1

for i in m:
    ans += i * (i - 1) // 2

print(ans)
# Judge status: Accepted
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    B = [int(i) for i in input().split()]
    op = sum(B) - sum(A)
    D = [(b-a+1)//2 if b > a else 0 for a, b in zip(A, B)]
    print("Yes" if op >= sum(D) else "No")


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
num_list = input().split()

i = 0
while True:
    if num_list[i] != i + 1:
        print(i + 1)
        break
    i += 1
# Judge status: Wrong Answer
n = int(input())
ab = [input().split() for _ in [0]*n]
a = [int(i) for i, j in ab][::-1]
b = [int(j) for i, j in ab][::-1]
ans = 0
for i in range(n):
    if b[i] == 1:
        continue
    ans += b[i] - ((a[i]+ans) % b[i])
print(ans)
# Judge status: Accepted
s = input()
rs = s[::-1]

a = s.index('A')
z = rs.index('Z')

print(len(s)-z - a )
# Judge status: Accepted
from collections import defaultdict

d = defaultdict(int)

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

ans = []
for i in a:
  d[i] += 1
  if d[i] == 2:
    d[i] = 0
    ans.append(i)
ans.sort(reverse=True)
if len(ans) >= 2:
  print(ans[0]*ans[1])
else:
  print(0)
# Judge status: Accepted
def LI():
    return list(map(int, input().split()))


pu = []
mi = []
N = int(input())
for _ in range(N):
    x, y = LI()
    pu.append(x+y)
    mi.append(x-y)
P = max(pu)
p = min(pu)
M = max(mi)
m = min(mi)
print(max(P-p, M-m))
# Judge status: Wrong Answer
a,b,k=map(int,input().split())

loop=0
if a<b:
    loop=a
else:
    loop=b
ans=0

for i in range(1,loop+1):
    if a%i==0 and b%i==0:
        k-=1
        if k==0:
            ans=i
            break

print(ans)
# Judge status: Accepted
n=input()
c=input()
print(c[:c.count("R")].count("W"))
# Judge status: Accepted
N = int(input())
L = list(map(int, input().split()))
ma = max(L)
mi = L.index(ma)
S = 0
nma = L[0]

for i in range(1, len(L)):
  if mi <= i:
    S += ma - L[i]
  else:
    nma = max(nma, L[i])
    S += nma - L[i]
print(S)
# Judge status: Accepted
N = int(input())
print((N//2 + N %2)/N)
# Judge status: Accepted
n = int(input())
if 400<=n<=599:
  print('8')
elif 600<=n<=799:
  print('7')
elif 800<=n<=999:
  print('6')
elif 1000<=n<=1199:
  print('5')
elif 1200<=n<=1399:
  print('4')  
elif 1400<=n<=1599:
  print('3')    
elif 1600<=n<=1799:
  print('2')  
elif 1800<=n<=1999:
  print('1')
# Judge status: Wrong Answer
n = int(input())
p = list(map(int, input().split()))
cnt = 0
for i in range(n-1):
  if p[i] == i+1:
    p[i],p[i+1] = p[i+1],p[i]
    cnt += 1
print (cnt)
# Judge status: Wrong Answer
n,k = map(int,input().split())
h = list(map(int,input().split())) + [0]*k
cost = [0] + [10000]*(n+k)
for i in range(n):
      for j in range(1,k+1):
            cost[i+j] = min(cost[i]+abs(h[i]-h[i+j]),cost[i+j])
print(cost[n])
# Judge status: Accepted
n,k,s = map(int,input().split())
if s%2 == 0:
    for i in range(k):
        print(s,end=" ")
    for i in range(n-k):
        if n-k-1 == i:
            print(11021021)
            break
        print(11021021,end=" ")
else:
    for i in range(k):
        print(s,end=" ")
    for i in range(n-k):
        if n-k-1 == i:
            print(11021021)
            break
        print(11021021,end=" ")
# Judge status: Accepted
x, y, z = map(int, input().split())
print(z,x,y)
# Judge status: Accepted
A, B = map(int, input().split())

if A <= B:
  print(A)
else:
  print(A-1)
# Judge status: Accepted
s, t = input().split()
a, b = map(int, input().split())
u = input()
if s == u:
  a -= 1
elif t == u:
  b -= 1
print(a,b)
# Judge status: Accepted
# もし全部が9なら、9*N
# 一桁目が9以外なら (一桁目-1) + (len(N)-1 * 9)
# 一桁目が9なら　一桁目が8 + len(N)-1 * 9
S = (input())

if S.count("9") == len(S):
    print(len(S)*9)

elif len(S) == 1:
    print(int(S))

elif S.count("9") == (len(S)-1) and (S[0]!="9"):
    print((int(S[0])) + (len(S)-1)*9)

elif S[0] == "9":
    print(8 + ((len(S)-1)*9))
else:
    print((int(S[0])-1) + (len(S)-1)*9)
# Judge status: Wrong Answer
a,b,c = input().split()
print(a[0],b[0],c[0])
# Judge status: Wrong Answer
S = input()

for i in range(len(S) - 2, 0, -2):
    l = i // 2
    if S[:l] == S[l:i]:
        print(i)
# Judge status: Accepted
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    a,b,c,d=MI()
    cc=b//c - (a-1)//c
    dd=b//d - (a-1)//d
    
    import math
    g=(c*d)//math.gcd(c,d)
    gg=b//g - (a-1)//g
    
    print(b-a+1 -cc-dd+gg)

main()
# Judge status: Accepted
N,M = map(int,input().split())
if N==M:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
S = input()

count={"a":0, "b":0, "c":0}
for i in range(len(S)):
  count[S[i]]+=1
  
a = count["a"]
b = count["b"]
c=count["c"]
if abs(a-b)<=1 and abs(b-c)<=1 and abs(c-a)<=1:
  print("YES")
else:
  print("NO")
# Judge status: Accepted
s = input().strip()
t = input().strip()
if t[:-1] == s:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
A,B,C,D = map(int,input().split())

while A>0 and C>0:
    C-=B
    if C<=0:
        print("Yes")
        break
    A-=D
    if A<=0:
        print("No")
        break
# Judge status: Accepted
a=int(input())
b=int(input())
h=int(input())
print(int((a+b)*h*1/2))
# Judge status: Accepted
n,w = map(int,input().split())
wv = [list(map(int,input().split())) for _ in range(n)]
dp = [[0]*(w+1) for _ in range(n+1)]
for i in range(n):
    wi, vi = wv[i]
    for j in range(w+1):
        if j<wi:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j], dp[i][j-wi]+vi)
            
print(dp[n][w])
# Judge status: Accepted
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [float('Inf')] * n
dp[0] = 0

for i in range(n):
    for j in range(i+1, i+k+1):
        if j < n:
            dp[j] = min(dp[j], dp[i]+abs(h[i]-h[j]))
            
print(dp[-1])
# Judge status: Wrong Answer
from functools import reduce
import fractions
N, M = map(int, input().split())
A = tuple(map(int, input().split()))

def lcm_base(x, y):
  return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
  return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
  return reduce(lcm_base, numbers, 1)


Ahalf = [a//2 for a in A]
lcmA = lcm_list(Ahalf)
#print(A)
#print(lcmA)
if lcmA % 2 == 0:
  print(0)
else:
  n = int(M / lcmA + 1) // 2
  print(n)
# Judge status: Wrong Answer
a = int(input())
s = input()
if a >=3200:
  print("red")
else:
  print(s)
# Judge status: Wrong Answer
def main():
    X = input()
    len_X = len(X)
    right_T = X.rfind("T")
    left_S = X.find("S")
    S_Count = X[left_S:right_T+1].count("S")
    T_Count = X[left_S:right_T+1].count("T")
    ans = len_X - min(T_Count, S_Count)*2
    print(ans)
if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
N = int(input())
CSF = [list(map(int, input().split())) for _ in range(N-1)]

ans = 0
memo = {}
memoset = set()
def dfs(i, time):
    if i==N-1:
        return time
    c, s, f = CSF[i]
    if time<s:
        time = s
    elif time%f!=0:
        time = time//f+1
    if (time, i) in memoset:
        return memo[(time, i)]
    T = dfs(i+1, time+c)
    memo[(time, i)] = T
    memoset.add((time, i))
    return T

for i in range(N-1):
    print(dfs(i, 0))
print(0)
# Judge status: Accepted
from collections import Counter

n=int(input())
d=list(map(int,input().split()))
dic=Counter(d)
MOD=998244353
ans=1
if d[0]!=0 or dic[0]!=1: print(0)
else:
    for i in range(1,max(dic.keys())+1):
        ans*=pow(dic[i-1],dic[i],MOD)
        ans%=MOD
    print(ans)
# Judge status: Accepted
k,x=map(int, input().split())
print("YNeos"[k*500<x::2])
# Judge status: Wrong Answer
S=input()
s=0
t=0
for i in range(len(S)):
  if i%2==0 and S[i]==0:
    s+=1
for j in range(len(S)):
  if i%2==0 and S[i]==1:
    t+=1
print(min(s,t))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

a.sort(reverse=True)

cnt = 1
ans = a[0]

if n == 2:
    print(ans)
    exit()

for i in range(1, n):
    cnt += 1
    ans += a[i]
    if cnt == n - 1:
        break
    else:
        cnt += 1
        ans += a[i]
    if cnt == n - 1:
        break

print(ans)
# Judge status: Wrong Answer
N = int(input())
p, score = 2, 0
while p ** 2 <= N:
  e = 1
  while N >= (p ** e) and N % (p ** e) == 0:
    N = N // (p ** e)
    score += 1
    e += 1
  else:
    p = p + 1 if p == 2 else p + 2
else:
  if N != 1 and sum([N % (n + 1) == 0 for n in range(N)]) == 2:
    score += 1
print(score)
# Judge status: Accepted
from collections import deque
n = int(input())
alist = list(map(int, input().split()))
d = deque()
for i in range(n):
    if i % 2 == 0:
        d.append(alist[i])
    else:
        d.appendleft(alist[i])
if i % 2 == 0:
    print(*reversed(d))
else:
    print(*d)
# Judge status: Accepted
o=input()
e=input()
n=len(e)
ans=""
for i in range(n):
    ans+=o[i]
    ans+=e[i]
if len(o)>n:
    ans+=o[-1]
print(ans)
# Judge status: Accepted
s = input()
t = input()
flag = True

for i in range(len(s)):
    s1 =  s[i:len(s)] + s[:i]
    
    if s1 == t:
        print("Yes")
        flag = False
        break

if flag:
    print('No')
# Judge status: Wrong Answer
n = int(input())
sum1 = 0
for i in range(len(str(n))):
    sum1 += int(str(n)[i])
    print(int(str(n)[i]))
if sum1 % 9 == 0:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
N = int(input())
A = []
for i in range(N):
    a,b=input().split()
    b=100-int(b)
    if b<10:
        A.append(a+'0'+str(b))
    else:
        A.append(a+str(b))
B=sorted(A)
for b in B:
    print(A.index(b)+1)
# Judge status: Accepted
print('cvoonwseoln a n t'[len(set(['a','i','u','e','o',input()]))==5::2])
# Judge status: Accepted
# from math import sqrt
# from heapq import heappush, heappop
# from collections import deque
# from functools import reduce

# a, b = [int(v) for v in input().split()]


def main():
    mod = 1000000007

    N = int(input())
    A = [int(v) for v in input().split()]

    dig = 60

    ans = 0
    for i in range(dig + 1):
        mask = 1 << i
        zero = sum(1 for a in A if a & mask == 0)
        ans += zero * (N - zero) * mask
        ans %= mod

    print(ans % mod)


main()
# Judge status: Accepted
import sys
readline=sys.stdin.readline

N,K = map(int,readline().split())
A=list(map(int,readline().split()))

# K + 1 ～ Nについて、i - K < iであればYes

for i in range(K, N):
  if A[i - K] < A[i]:
    print("Yes")
  else:
    print("No")
# Judge status: Accepted
h = int(input())
cnt = 0
while h>0:
    h = h//2
    cnt +=1
print(2**cnt-1)
# Judge status: Wrong Answer
a=int(input())
num=0
for i in range(1,a+1):
    i=str(i)
    for j in range(1,a+1):
        j=str(j)
        if i==j[::-1]:
            num+=1
        elif len(set(i+j))==1:
            num+=1
print(num)
# Judge status: Accepted
s,w = map(int,input().split())
if w >= s :
  print('unsafe')
else :
  print('safe')
# Judge status: Accepted
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())


cnt =0
i=0
while cnt<n:
    i+=1
    cnt +=i

diff = cnt -n

for num in range(1,i+1):
    if num==diff: continue
    print(num)
# Judge status: Accepted
# A - Colorful Transceivers

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

e = a - b
f = b - c
g = c - a

x = abs(e)
y = abs(f)
z = abs(g)

if x <= d and y <= d or z <= d:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import sys
readline = sys.stdin.readline

# 0-indexでやる

D = int(readline())

C = list(map(int,readline().split())) # 満足度の下がりやすさ

for i in range(D):
  S = list(map(int,readline().split()))
  for j in range(len(S)):
    S[j] = (S[j],j)
  S = sorted(S, key = lambda x:x[0], reverse = True)
  print(S[0][1] + 1)
# Judge status: Accepted
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N,K,*H = map(int,read().split())
dp = [0] *(N+K)
H = [H[0]]*K+H

for n in range(K,N+K):
  h = H[n]
  dp[n] = min(x+abs(y-h) for y,x in zip(H[n-K:n],dp[n-K:n]))
print(dp[-1])
# Judge status: Accepted
n,k=map(int,input().split())
A=list(map(int,input().split()))
high=max(A)
low=0
while high-low>1:
    cnt=0
    now=(low+high)//2
    for a in A:
        cnt+=max((a-1)//now,0)
        if cnt>k:
            break
    if cnt>k:
        low=now
    else:
        high=now
    #print(cnt,low,high)
print(high)
# Judge status: Accepted
H, N = map(int, input().split())
Attack = map(int, input().split())
print("Yes" if H - sum(Attack) <= 0 else "No")
# Judge status: Accepted
N, M, K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])

ans, j = 0, M
for i in range(N+1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i+j)

print(ans)
# Judge status: Wrong Answer
N, M = map(int, input().split())
kouho = {}
red = 1
Nlist = [1]*(N+1)
ans = 0
for i in range(M):
    x, y = map(int, input().split())
    if x == red:
        red = y
        kouho[y] = True
        Nlist[x] -= 1
        Nlist[y] += 1
    else:
        Nlist[x] -= 1
        Nlist[y] += 1

for i in range(1, N+1):
    if Nlist[i] == 0:
        continue
    if i in kouho:
        ans += 1

print(ans)
# Judge status: Wrong Answer
b, c = map(int, input().split())
a = list(map(int, input().split()))
d = sum(a)
new_a = list(reversed(sorted(a)))
e = 0
f = 0
g = 4*c
while new_a[e] >= d/g:
    e = e+1
    if e == b:
        break
    f = f+1
if f >= c:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
s=input()

s=s.replace("eraser","")
s=s.replace("erase","")
s=s.replace("dreamer","")
s=s.replace("dream","")
if s=="":
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
s=str(input())
print(sum(a!=b for a,b in zip(s,s[::-1])))
# Judge status: Accepted
a, b, c, d = map(int, input().split())
print('Yes') if (abs(a - c) <= d) | ((abs(a - b) <= d) & (abs(c - b) <= d)) else print('No')
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

maxans=0
for i in range(n):
  ans=sum(a[0:i+1]+b[i:n])
  maxans=max(ans,maxans)
  print(ans)
# Judge status: Accepted
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N = int(readline())
S = readline().decode("utf-8").rstrip()

res = ""
left_cnt = 0
for c in S:
    if '(' == c:
        left_cnt += 1
        res += '('
    elif ')' == c:
        if left_cnt > 0:
            res += ')'
            left_cnt -= 1
        else:
            res = '(' + res + ')'
if left_cnt != 0:
    res += ")" * left_cnt

print(res)