Harryxun/stf_run huggingface dataset:
import math
 
a,b,c = map(int,input().split())
 
if c > a+b+2*math.sqrt(a*b)
  print("Yes")
else:
  print("No")

### FIXED CODE ###

import math

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

if c-a-b>0 and 4*a*b < (c-a-b)*(c-a-b):
  print("Yes")
else:
  print("No")
def positive(n):
  for i in range(n-1):
    print(i+1,i+2)
N=int(input())
A=list(map(int,input().split()))
mina=min(A)
minin=A.index(mina)
maxa=max(A)
maxin=A.index(maxa)
if mina>=0:
  print(N-1)
  positive(N)
elif maxa<=0:
  print(N-1)
  negative(N)
elif maxa+mina>=0:
  print(2*N-1)
  for i in range(N):
    print(maxin+1, i+1)
  positive(N)
else:
  print(2*N-1)
  for i in range(N):
    print(minin+1, i+1)
  negative(N)

### FIXED CODE ###

def positive(n):
  for i in range(n-1):
    print(i+1,i+2)
def negative(n):
  for i in range(n-1):
    print(n-i,n-i-1)
N=int(input())
A=list(map(int,input().split()))
mina=min(A)
minin=A.index(mina)
maxa=max(A)
maxin=A.index(maxa)
if mina>=0:
  print(N-1)
  positive(N)
elif maxa<=0:
  print(N-1)
  negative(N)
elif maxa+mina>=0:
  print(2*N-1)
  for i in range(N):
    print(maxin+1, i+1)
  positive(N)
else:
  print(2*N-1)
  for i in range(N):
    print(minin+1, i+1)
  negative(N)
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10**9 + 7
N = 10**6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N+1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

x,y=map(int,input().split())
ans=0
x_3=x//3
y_3=y//3
kyo2=min(x_3,y_3)
xx=x-kyo2*3
yy=y-kyo2*3

#print(xx,yy,kyo2)
    
if (xx==0 and yy==0):
  ans=cmb(2*kyo2,kyo2,p)
  print(ans)
elif (xx/yy==2):
  ans=cmb(2*kyo2+yy,kyo2,p)
  print(ans)
elif (yy/xx==2):
  ans=cmb(2*kyo2+xx,kyo2,p)
  print(ans)
else:
  print(0)
  

### FIXED CODE ###

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10**9 + 7
N = 10**6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N+1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

    
x,y=map(int,input().split())
if ((x+y)%3!=0):
  print(0)
else:
  xx=(2*x-y)//3
  yy=(2*y-x)//3
  if (xx<0 or yy<0):
    print(0)
  else:
    ans=cmb(xx+yy,xx,p)
    print(ans)
import math
N = int(input())
num = 1
ans = 0
for i in range(1, N + 1):
    num *= i

maxx = int(math.sqrt(num)) + 2

for i in range(1, maxx + 1):
    if num % i == 0:
        ans += 1
print(ans)

### FIXED CODE ###

import math
import collections

N = int(input())
a = math.factorial(N)
check = []
ans = 1
i = 2

while a != 1:
    if a % i == 0:
        a //= i
        check.append(i)
    else:
        i += 1
        
check = collections.Counter(check).values()
for i in check:
    ans *= (i+1)
    ans %= 10**9+7
print(ans)
N = int(input())

n = N - int((len(str(N)) - 1) * '9')
tmp = (len(str(N)) - 1) * '9'
if len(tmp) > (len(str(N)) - 1):
    tmp = str(n)[0] + tmp

res = 0
for t in tmp:
    res += int(t)

print(res)


### FIXED CODE ###

N = input()

f = int(N[0])
res = (len(N) - 1) * 9 + f - 1
s = 0
for i in N:
    s += int(i)

print(max(res, s))
def main():
    n = int(input())
    h = list(map(int, input().split(' ')))
    l = [h[i] - h[i + 1] for i in range(n-1)]
    print('Yes' if check(l) else 'No')


def check(l):
    for i in range(len(l)):
        if l[i] >= 2:
            return False
        elif l[i] <= 0:
            continue
        else:
            if l[i + 1] >= 1:
                return False
            else:
                continue
    return True


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n = int(input())
    h = list(map(int, input().split(' ')))

    ans = True
    MAX = h[0]
    for i in range(n):
        if h[i] > MAX:
            MAX = h[i]
        elif h[i] < MAX - 1:
            ans = False
        else:
            continue
        
    print('Yes' if ans else 'No')


if __name__ == '__main__':
    main()
import fractions
mod=10**9+7
n=int(input())
a=tuple(list(map(int,input().split())))

def lcm(x, y):
    return (x * y) // fraction.gcd(x, y)

count=a[0]
for i in range(n-1):
    count=lcm(count,a[i+1])
ans=0
for i in range(n):
    ansa=count//a[i]
    ans+=ansa
    ans%=mod
print(ans)

### FIXED CODE ###

import fractions
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))

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

count=a[0]
for i in range(n-1):
    count=lcm(count,a[i+1])
ans=0
for i in range(n):
    ansa=count//a[i]
    ans+=ansa
    
print(ans%mod)
#!/usr/bin/env python
# -*- coding: utf-8 -*-


import sys

num = input()
for i in range(num):
  num1 = []
  s = input()
  t = input()
  u = s+u
  if len(str(u)) > 80 :
    print "overflow"
  else:
    print u

### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-


import sys

num = input()
for i in range(num):
  s = long(input())
  t = long(input())
  u = s+t
  if len(str(u)) > 80 :
    print "overflow"
  else:
    print u
N = int(input())

ball_position = []
for _ in range(N):
    i, j = map(int, input().split())
    ball_position.append((i, j))

def tuple_inverse(a):
    ai, aj = a
    if ai < 0:
        return (-ai, -aj)
    return(ai, aj)

def tup2_diff(a, b):
    ai, aj = a
    bi, bj = b
    return tuple_inverse((ai - bi , aj - bj))

calculation_list = []
for i in range(len(ball_position)):
    for j in range(i + 1, len(ball_position)):
        calculation_list.append(tup2_diff(ball_position[i], ball_position[j]))
        
import collections
c = collections.Counter(calculation_list).most_common(1)

print(N - calculation_list.count(c[0][0]))

### FIXED CODE ###

N = int(input())

ball_position = []
for _ in range(N):
    i, j = map(int, input().split())
    ball_position.append((i, j))

    
def tup2_diff(a, b):
    ai, aj = a
    bi, bj = b
    return ((ai - bi, aj - bj))
  
calculation_list = []
for i in range(len(ball_position)):
    for j in range(len(ball_position)):
        if i == j:
            continue
        else:
            x , y = tup2_diff(ball_position[i], ball_position[j])
            if x > 0 or (x == 0 and y > 0):
                calculation_list.append((x, y))
           
import collections

c = collections.Counter(calculation_list).most_common(1)
if N == 1:
    print(1)
else:
    print(N - calculation_list.count(c[0][0]))
A,B=map(int,input().Split())
K=int(input())

if A-K>0:
  print(A-K, B)
elif B-(K-A)>0:
  print(0, B-K+A)
else:
  print(0,0)

### FIXED CODE ###

A,B,K=map(int,input().split())
 
if A-K>0:
  print(A-K, B)
elif B-(K-A)>0:
  print(0, B-K+A)
else:
  print(0,0)
A, B = map(int, input().split())
print(int(A*B))

### FIXED CODE ###

def resolve():
    A, B = input().split()
    ans = int(A)*int(B[0])*100+int(A)*int(B[2:])
    print(str(ans)[:-2] if len(str(ans)) >= 3 else "0")
resolve()
import numpy as np

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

N = int(input())
A = prime_factorize(N)

n = len(A)
ans = []
for i in range(1,2**n-1):
    a = [1]
    b = [1]
    for j in range(n):
        if (i >> j) & 1:
            a.append(A[j])
        else:
            b.append(A[j])
    ap, bp = np.prod(a), np.prod(b)
    ans.append(bp+ap)
print(min(ans)-2)

### FIXED CODE ###

import numpy as np

N = int(input())

U = 10**6 + 100
x = np.arange(1,U, dtype=np.int64)
div = x[N%x==0]
ans = (div + N//div).min() - 2
print(ans)
import sys
from collections import defaultdict
from collections import deque
import numpy as np
import heapq
from heapq import heappush, heappop
import itertools


#read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N = int(input())

PATH = []
#COLOR = [[None for _ in range(N+1)] for _ in range(N+1)]
COLOR = defaultdict(int)
PT = [[] for _ in range(N+1)]
cmax = 1
for i in range(N-1):
    a, b = map(int, input().split())
    PATH.append((a, b))
    PT[a].append(b)
    PT[b].append(a)

    la = len(PT[a])
    lb = len(PT[b])

    l = la if la > lb else lb
    if l > cmax:
        cmax = l


q = deque([(1, 0)])

while(q):
    a, ca = q.popleft()
    bs = PT[a]

    c = list(range(1, cmax+1))
    for b in bs:
        if b > a:
            na = a
            nb = b
        else:
            na = b
            nb = a

        if COLOR[(na, nb)] == 0:
            clr = c.pop()
            if clr == ca:
                clr = c.pop()

            COLOR[(na, nb)] = clr
            q.append((b, clr))

print(cmax)

clr = []
for a, b in PATH:
    clr.append(COLOR[(a, b)])

print("\n".join(clr))


### FIXED CODE ###

import sys
from collections import defaultdict
from collections import deque
import numpy as np
import heapq
from heapq import heappush, heappop
import itertools


#read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N = int(input())

PATH = []
#COLOR = [[None for _ in range(N+1)] for _ in range(N+1)]
COLOR = defaultdict(int)
PT = [[] for _ in range(N+1)]
cmax = 1
for i in range(N-1):
    a, b = map(int, input().split())
    PATH.append((a, b))
    PT[a].append(b)
    PT[b].append(a)

    '''
    la = len(PT[a])
    lb = len(PT[b])

    l = la if la > lb else lb
    if l > cmax:
        cmax = l
    '''

q = deque([(1, -1)])
while(q):
    a, ng = q.popleft()
    bs = PT[a]

    c = 1
    for b in bs:
        if b > a:
            na = a
            nb = b
        else:
            na = b
            nb = a

        cab = COLOR[(na, nb)]

        if cab == ng:
            continue

        if cab == 0:
            if c == ng:
                c += 1
            clr = c
            COLOR[(na, nb)] = clr
            q.append((b, clr))
            c += 1

print(max(COLOR.values()))

clr = []
for a, b in PATH:
    clr.append(COLOR[(a, b)])

print("\n".join(map(str, clr)))
# -*- coding: utf-8 -*-
import fractions

N, M = map(int, input().split())
a_list = list(set(map(int, input().split())))

a = [int(i/2) for i in a_list]
ans = a[0]
for i in range(1, len(a)):
    ans = ans * a[i] // fractions.gcd(ans, a[i])

if ans <= M:
    b = M // ans

    if b % 2 == 1:
        print(b // 2 + 1)
    else:
        print(b // 2)
else:
    print(0)


### FIXED CODE ###

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

a = list(map(int, input().split()))
print('Yes') if (500 * a[0] >= a[1]) else print('No')
import sys
n = int(input())
pos = [list(map(int,input().split())) for p in range(n)]
for i in range(1,en(pos)):
  diff = pos[i+1][0]-pos[i][0]
  num = abs(pos[i][1]-pos[i+1][1]) + abs(pos[i][2]-pos[i+1][2])
  if((pos[i][0]-pos[i-1][0])>=(abs(pos[i][1]-pos[i-1][1])+abs(pos[i][2]-pos[i-1][2])) and (pos[i][0]-pos[i-1][0])%2==(abs(pos[i-1][1]-pos[i][1])+abs(pos[i][2]-pos[i-1][2]))%2):
    pass
  else:
    print("No")
    sys.exit()      
print("Yes")
    


### FIXED CODE ###

n=int(input())
x,y=0,0
t=0
for i in range(n):
    T,X,Y=map(int,input().split())
    if((T-t)>=(abs(X-x)+abs(Y-y)) and (T-t)%2==(abs(x-X)+abs(Y-y))%2):
        x=X
        y=Y
        t=T
    else:
        print("No")
        exit()
print("Yes")
A,B = map(int,input().split())
    
ans = 0
if B / A == 1:
    ans = 1
else:
    ans = 1 + -(-(B - A) // (A - 1))
print(ans)

### FIXED CODE ###

S = input()
T = input()

ret = 0
for i in range(3):
    if S[i] == T[i]:
        ret += 1
print(ret)
H, W = map(int, input().split())
G = [list(map(int, input().split())) for i in range(H)]

N = 0
ans = []
for h in range(H):
    for w in range(W - 1):
        if G[h][w] % 2 == 1:
            N += 1
            ans.append((h, w, h, w + 1))
            G[h][w + 1] += 1
            G[h][w] -= 1

for h in range(H - 1):
    if G[h][W - 1] % 2 == 1:
        N += 1
        ans.append((h, w, h + 1, w))
        G[h + 1][W - 1] += 1
        G[h][W - 1] -= 1

print(N)
for y1, x1, y2, x2 in ans:
    print(y1 + 1, x1 + 1, y2 + 1, x2 + 1)


### FIXED CODE ###

H, W = map(int, input().split())
G = [list(map(int, input().split())) for i in range(H)]

N = 0
ans = []
# 奇数枚だけ右に寄せる(動かすのは1枚）、途中で奇数が見つかればそこで終わり
for h in range(H):
    for w in range(W-1):
        if G[h][w] % 2 == 1:
            G[h][w] -= 1  # 1枚だけ取り出す
            now_w = w
            for x in range(w+1, W):
                N += 1
                ans.append([h+1, now_w+1, h+1, x+1])
                now_w += 1
                #  奇数がみつかればそこに移動して終わり
                if G[h][x] % 2 == 1:
                    G[h][x] += 1
                    break
            else:
                G[h][W-1] += 1

# 右に集まったので同じように上から見ていく
for h in range(H):
    if G[h][W-1] % 2 == 1:
        G[h][W-1] -= 1
        now_h = h
        for y in range(h+1, H):
            N += 1
            ans.append([now_h+1, W, y+1, W])
            now_h = y
            #  奇数が見つかれば終わり
            if G[y][W-1] % 2 == 1:
                G[y][W-1] += 1
                break
        else:
            G[H-1][W-1] += 1

print(N)
for a in ans:
    print(" ".join(map(str, a)))
A,B=map(int, input().split())
s=input()

ng = 0
if !(s[0:A].isdecimal()):
  ng = 1
if s[A] != "-": ng = 1
if !(s[A+1:A+B+1].isdecimal()):
  ng = 1
if ng == 1:
  print("No")
else:
  print("Yes")
  

### FIXED CODE ###

A,B=map(int, input().split())
s=input()

ng = 0
if not (s[0:A].isdecimal()):
  ng = 1
if s[A] != "-": ng = 1
if not (s[A+1:A+B+1].isdecimal()):
  ng = 1
if ng == 1:
  print("No")
else:
  print("Yes")
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
# 整数の入力
b = int(input())
# 整数の入力
h = int(input())
# スペース区切りの整数の入力
 
# 出力
print("{}".format((a+b)*h/2)))

### FIXED CODE ###

# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
# 整数の入力
b = int(input())
# 整数の入力
h = int(input())
# スペース区切りの整数の入力

# 出力
print("{:.0f}".format((a+b)*h/2))
n = input()
max = -10**9
 
for i in range(0, n-1):
 R[i] = input()
 min = R[0]

for i in range(0, n-1):
 if R[i] <= min:
   min = R[i]
 if max <= R[i] - min:
  max = R[i] - min
 
print max

### FIXED CODE ###

n = input()
n_max = -(10**9)
n_min = input() 

for i in range(0, n-1):
 R = input()
 if n_max < R - n_min:
  n_max = R - n_min
 if R < n_min:
  n_min = R
 
print n_max
N = int(input())
x_1, y_1 = map(int, input().split(" "))
x_2, y_2 = map(int, input().split(" "))
p, q = (x_2 - x_1), (y_2 - y_1)
cost = 1
before_x, before_y = x_2, y_2
for i in range(2, N):
  x, y = map(int, input().split(" "))
  if (x - p != before_x) | (y - q != before_y):
    cost += 1
  before_x, before_y = x, y
  
print(cost)      

### FIXED CODE ###

N = int(input())
xlist = []
ylist = []
pqlist = []
pqcount = {}
for i in range(N):
  x, y = map(int, input().split(" "))
  xlist.append(x)
  ylist.append(y)

for i in range(N):
  for j in range(i+1, N):
    p = xlist[i] - xlist[j]
    q = ylist[i] - ylist[j]
    tuple_pq = (p, q,)
    if (-p, -q,) in pqlist:
      tuple_pq = (-p, -q)
    if not (tuple_pq in pqlist):
      pqlist.append(tuple_pq)
      pqcount[tuple_pq] = 1
    else:
      pqcount[tuple_pq] += 1

if N == 1:
  print(1)
else:
  print(N - max(pqcount.values()))
N,C=map(int,input().split())
D=[]
for i in range(C):
    Dlist=list(map(int,input().split()))
    D.append(Dlist)
c=[[0]*N*N for i in range(3)]
x=[]
X=[]
for i in range(N):
    x=list(map(int,input().split()))
    X.append(x)
for i in range(N):
    for j in range(N):
        x=X[i][j]
        c[(i+j)%3][x-1]+=1
def func(res):
    for i in range(C):
        for j in range(C):
            if i!=j:
                for k in range(C):
                    if i!=k and j!=k:
                        total=0
                        for l in range(C):                           
                            total+=D[l][i]*c[0][l]
                            total+=D[l][j]*c[1][l]
                            total+=D[l][k]*c[2][l]
                        if total<res:
                            res=total
    return res
y=10**6
res=func(y)
print(res) 

### FIXED CODE ###

N,C=map(int,input().split())
D=[]
for i in range(C):
    Dlist=list(map(int,input().split()))
    D.append(Dlist)
c=[[0]*(10**6) for i in range(3)]
x=[]
X=[]
for i in range(N):
    x=list(map(int,input().split()))
    X.append(x)
for i in range(N):
    for j in range(N):
        x=X[i][j]
        c[(i+j)%3][x-1]+=1
def func(res):
    for i in range(C):
        for j in range(C):
            if i!=j:
                for k in range(C):
                    if i!=k and j!=k:
                        total=0
                        for l in range(C):                           
                            total+=D[l][i]*c[0][l]
                            total+=D[l][j]*c[1][l]
                            total+=D[l][k]*c[2][l]
                        if total<res:
                            res=total
    return res
y=10**20
res=func(y)
print(res)
L = list(map(int, input().split()))

min_root = []
for i in L:
    for j in L:
        if i != j:
            min_root.append(i+j)
        else:
            continue

print(min(min_root))


### FIXED CODE ###

L = [int(i) for i in input().split()]

min_root = []
for i in L:
    for j in L:
        if i != j:
            min_root.append(i+j)
        else:
            continue
            
if len(min_root) > 0:
    print(min(min_root))
else:
    print(L[0]+L[1])
n=int(input())
a=list(map(int,input().split()))

x=0
for i in range(n):
    if a[i]!=0:
        x+=1
a=sum(a)

print(a//x if a%x==0 else a//x+1)

### FIXED CODE ###

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

n=int(input())

i=0
while True:
    if prime(n+i):
        print(n+i)
        exit()
    else:
        i+=1
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
print(A)

for i in range(M):
        B, C = map(int, input().split())
        if C <= A[0]:
                pass
        else:
                idx = 0
                for k in range(N):
                        if A[k] < C:
                                idx = k
                        else:
                                break
                print(idx)

                if idx + 1 <= B:
                        for l in range(idx+1):
                                A[l] = C
                else:
                        A = A[B:idx+1] + [C for i in range(B)] + A[idx+1:]

        print(A)

print(sum(A))

### FIXED CODE ###

from collections import deque

N, M = map(int, input().split())
A = list(map(int, input().split()))
A = [[1, A[i]] for i in range(N)]
A = deque(A)

BC = [list(map(int, input().split())) for i in range(M)]
A.extend(BC)
A = list(A)
A.sort(key=lambda x: x[1], reverse=1)


sum = 0
k = 0
for b, c in A:
        if k + b <= N:
                sum += b * c
                k += b
        elif k <= N:
                sum += (N - k) * c
                break

print(sum)
# ans

N = int(input())
A = list(map(int, input().split()))
cnt = [0] * 100000
for i in range(N):
  cnt[A[i]] += 1
Q = int(input())
S = sum(A)

for i in range(Q):
  B, C = map(int, input().split())
  diff = (C - B) * cnt[B]
  S += diff
  print(S)
  cnt[C] += cnt[B]
  cnt[B] = 0

### FIXED CODE ###

# ans

N = int(input())
A = list(map(int, input().split()))
cnt = [0] * 100001
for i in A:
  cnt[i] += 1
Q = int(input())
S = sum(A)

for i in range(Q):
  B, C = map(int, input().split())
  diff = (C - B) * cnt[B]
  S += diff
  print(S)
  cnt[C] += cnt[B]
  cnt[B] = 0
data = list(map(int,input().split()))

count = int(data[1]/data[0])

if count > data[2]:
    print(data[2])
else:
    print(count)


### FIXED CODE ###

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

if data[1]%data[0] == 0:
    print(sum(data))
else:
    print(data[1]-data[0])
x, a, b = map(int, input().split())
if (abs(x - a) < abs(x - b):
    print('A')
else:
    print('B')

### FIXED CODE ###

x, a, b = map(int, input().split())
if abs(x - a) < abs(x - b):
    print('A')
else:
    print('B')
"""
N = int(input())
A, B = map(int,input().split())
A = list(map(int,input().split())) ## 横一列
A = [int(input()) for _ in range(N)] ## 縦一列
lst = [list(map(int,input().split())) for i in range(M)] ## 二次元
"""

S = input()

if S == 'Sunny':
  ans = 'Cloudy'
elif S == 'Cloudy':
  ans = Rainy
else:
  ans ='Sunny'
  
print(ans)

### FIXED CODE ###

"""
N = int(input())
A, B = map(int,input().split())
A = list(map(int,input().split())) ## 横一列
A = [int(input()) for _ in range(N)] ## 縦一列
lst = [list(map(int,input().split())) for i in range(M)] ## 二次元
"""

S = input()

if S == 'Sunny':
  ans = 'Cloudy'
elif S == 'Cloudy':
  ans = 'Rainy'
else:
  ans ='Sunny'
  
print(ans)
n=int(input())
a=list(map(int, input().split()))
X=0
for i in a[2:]:X^=i
m=a[0]+a[1]-X
if m>a[0]or(m&X)!=0:exit(print(-1))
l=1<<max(x.bit_length(),m.bit_length())
while l > 0:
 if (m&l)!=0and(a|b)<=a[0]:a|=b
 b>>=1
print(a[0]-m if a!=0else-1)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
x=0
for i in a[2:]:x^=i
m=(a[0]+a[1]-x)//2
if a[0]+a[1]!=x+m*2or m>a[0]or(x&m)!=0:exit(print(-1))
l=1<<(max(x.bit_length(),m.bit_length())+1)
while l>0:
 if((x&l)!=0)and((m|l)<=a[0]):m|=l
 l>>=1
print(a[0]-m if m!=0else-1)
bilding = [[[0 for x in range(10)] for x in range(3)]for x in range(4)]

n = int(input())
for i in range(n)
    b, f, r, v = map(int, raw_input().split())
    bilding[b-1][f-1][r-1] += v

### FIXED CODE ###

bilding = [[[0 for x in range(10)] for x in range(3)]for x in range(4)] 
n = int(input())
for k in range(n):
    b, f, r, v = map(int, raw_input().split())
    bilding[b-1][f-1][r-1] += v

for b in range(4):
    for f in range(3):
        print(" "+" ".join(map(str, bilding[b][f])))
    if b != 3:
        print("#"*20)
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
count=0
for i in range(0,n-1):
  if a[i]+a[i+1]>x:
    ans=ans+a[i]+a[i+1]-x
    a[i+1]=a[i+1]-(a[i]+a[i+1]-x)
for i in range(n-1,0,-1):
  if a[i]+a[i+1]>x:
    count=count+a[i]+a[i+1]-x
    a[i]=a[i]-(a[i]+a[i+1]-x)
print(min(ans,count))

### FIXED CODE ###

N,x=map(int,input().split())
A=list(map(int,input().split()))+[0]
ans=0
for i in range(N):
  eated=max(0,A[i]+A[i-1]-x)
  ans+=eated
  A[i]-=eated
print(ans)
def main():

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

    K = 10**5+5
    INF = 10**18
    dp = [[-INF]*K for i in range(n+1)]
    dp[0][0] = 1000
    for i in range(n):
        for j in range(K):
            dp[i+1][j] = dp[i][j]
        # sell
        for j in range(K):
            if j == 0:
                continue
            if dp[i][j] >= 0:
                #if i == 2 and j == 10:
                    #print(dp[i+1][0], dp[i][j]+j*A[i])
                dp[i+1][0] = max(dp[i+1][0], dp[i][j]+j*A[i])
                #if i == 2 and j == 10:
                    #print(dp[i+1][0])

        # buy
        for j in range(K):
            if dp[i][j] >= 0:
                q, r = divmod(dp[i][j], A[i])
                dp[i+1][q] = max(r, dp[i+1][q])
    #print(dp[1])
    ans = -INF
    for j in range(K):
        ans = max(ans, dp[n][j])
    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():

    n = int(input())
    A = list(map(int, input().split()))
    INF = 19**18

    X = []
    Y = []
    A = [INF] + A
    for i in range(1, n):
        if len(X) == len(Y):
            if A[i-1] >= A[i] and A[i] < A[i+1]:
                X.append(i)
        if len(X) > len(Y):
            if  A[i-1] <= A[i] and A[i] > A[i+1]:
                Y.append(i)
    else:
        if len(X) > len(Y):
            Y.append(i+1)
    #print(X)
    #print(Y)

    cur = 1000
    for i, j in zip(X, Y):
        q, cur = divmod(cur, A[i])
        cur += q*A[j]
    print(cur)



if __name__ == '__main__':
    main()
a=int(print())
b=int(print())
c=int(print())
d=int(print())
e=int(print())
k=int(print())

x=[a,b,c,d,e]
y=max(x)-min(x)

if y>k:
  print(':(')
else:
  print('Yay!')


### FIXED CODE ###

a=[int(input()) for i in range(5)]
k=int(input())
x=max(a)-min(a)
if x<=k:
  print('Yay!')
else:
  print(':(')