Harryxun/stf_run huggingface dataset:
import sys
sys.setrecursionlimit(100000)

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

#初期値が0の辞書
from collections import defaultdict
xyz = defaultdict(lambda: set([]))
for _ in range(m):
    x,y,z=map(int,input().split())
    xyz[x].add(y)
    xyz[y].add(x)

no_checked=[0]*n

def DFS(x):
    global no_checked
    global xyz
    no_checked[x-1]=1
    for item in xyz[x]:
        if no_checked[item-1]==0:
            DFS(item)

cnt=0
for i in range(1,n+1):
    if no_checked[i-1]==0:
        cnt+=1
        DFS(i)

    #print(i,no_checked)
print(cnt)



### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

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

#初期値が0の辞書
from collections import defaultdict
xyz = defaultdict(lambda: set([]))
for _ in range(m):
    x,y,z=map(int,input().split())
    xyz[x].add(y)
    xyz[y].add(x)

no_checked=[0]*n

def DFS(x):
    global no_checked
    global xyz
    no_checked[x-1]=1
    for item in xyz[x]:
        if no_checked[item-1]==0:
            DFS(item)

cnt=0
for i in range(1,n+1):
    if no_checked[i-1]==0:
        cnt+=1
        DFS(i)

    #print(i,no_checked)
print(cnt)
a,b = map(raw_input().split())
 
if a>b:
  print 'a > b'
 
elif a<b:
  print 'a < b'
 
else:
  print 'a == b'
 

### FIXED CODE ###

a,b = map(int, raw_input().split())
 
if a > b:
  print 'a > b'
 
elif a < b:
  print 'a < b'
 
else:
  print 'a == b'
n,m = map(int, input().split())
while (n != 0 or m != 0):
    nlist = [0]
    mlist = [0]
    for i in range(n):
        nlist += [nlist[-1] + int(input())]
    for i in range(m):
        mlist += [mlist[-1] + int(input())]
    nsum = []
    msum = []
    count = 0
    for i in range(n):
        for k in range(i+1,n+1):
            c = nlist[k] - nlist[i]
            nsum.append(c)
    for i in range(m):
        for k in range(i+1,m+1):
            c = mlist[k] - mlist[i]
            if (c in nsum):
                count += nsum.count(c)
    print(count) 
    n,m = map(int, input().split())


### FIXED CODE ###

while True:
    n,m = map(int, input().split())
    if n == 0 and m == 0:
        break
    nlist = [0]
    mlist = [0]
    for i in range(n):
        nlist += [nlist[-1] + int(input())]
    for i in range(m):
        mlist += [mlist[-1] + int(input())]

    l = [0for i in range(1000*1501)]
    for i in range(n):
        t = 0
        for k in range(i+1,n+1):
            t = nlist[k] - nlist[i]
            l[t] += 1
    count = 0
    for i in range(m):
        for k in range(i+1,m+1):
            t = mlist[k] - mlist[i]
            count += l[t]
    
    print(count)
from collections import defaultdict
import sys
sys.setrecursionlimit(3*sys.getrecursionlimit())
V, E = map(int, input().split())
G = defaultdict(list)
T = defaultdict(list)
for i in range(E):
    s,t = map(int, input().split())
    G[s].append(t)
    G[t].append(s)

prenum = [float('inf')] * V
lowest = [float('inf')] * V
parent = [None] * V
visited = [False] * V

def dfs(g,s,c=0,p=None):    
    visited[s] = True
    prenum[s] = c
    lowest[s] = c
    c+=1    
    for v in g[s]:
        if not visited[v]:
            parent[v] = s
            T[v].append(s)
            T[s].append(v)
            dfs(g,v,c,s)
            lowest[s] = min( lowest[s], lowest[v] )
        elif v != p:
            lowest[s] = min( lowest[s], prenum[v] )

dfs(G,0)
k = []
if len(T[0]) > 1: k.append(0)
for u in range(V):
    p = parent[u]
    if p is None or p == 0: continue
    if prenum[p] <= lowest[u]: k.append(p)
for i in sorted(set(k)):
    print(i)

### FIXED CODE ###

from collections import defaultdict
import sys
sys.setrecursionlimit(100*sys.getrecursionlimit())
V, E = map(int, input().split())
G = defaultdict(list)
T = defaultdict(list)
for i in range(E):
    s,t = map(int, input().split())
    G[s].append(t)
    G[t].append(s)

prenum = [float('inf')] * V
lowest = [float('inf')] * V
parent = [None] * V
visited = [False] * V

def dfs(g,s,c=0,p=None):    
    visited[s] = True
    prenum[s] = c
    lowest[s] = c
    c+=1    
    for v in g[s]:
        if not visited[v]:
            parent[v] = s
            T[v].append(s)
            T[s].append(v)
            dfs(g,v,c,s)
            lowest[s] = min( lowest[s], lowest[v] )
        elif v != p:
            lowest[s] = min( lowest[s], prenum[v] )

dfs(G,0)
k = []
if len(T[0]) > 1: k.append(0)
for u in range(V):
    p = parent[u]
    if p is None or p == 0: continue
    if prenum[p] <= lowest[u]: k.append(p)
for i in sorted(set(k)):
    print(i)
n=int(input())
s=[]
k=s[0]
ans=0
for i in range(n):
  a=int(input())
  s.append(a)
for j in range(n+1):
  if s[k]==2:
    ans+=1
    print(ans)
    exit()
  else:
    ans+=1
    k=s[s[k]]
print(-1)  

### FIXED CODE ###

n=int(input())
s=[]
ans=0
for i in range(n):
  a=int(input())
  s.append(a)
k=s[0]
for j in range(n+1):
  if k==2:
    ans+=1
    print(ans)
    exit()
  else:
    ans+=1
    k=s[k-1]
print(-1)
mod = 998244353
N, A, B, K = map(int, input().split())
def make_fact(n):#0~nの階乗を求める
    fact = [1]*(n+1)
    for i in range(1, n+1):
        fact[i] = fact[i-1]*i%mod
    return fact
fact = make_fact(N) #＠
def make_fact_inv(n):#0~nの階乗のmodに関する逆元を求める
    fact_inv = [1]*(n+1)
    fact_inv[n] = pow(fact[n], mod-2, mod)#フェルマーの小定理
    for i in range(n, 0, -1):
        fact_inv[i-1] = fact_inv[i]*i%mod
    return fact_inv
fact_inv = make_fact_inv(N)#＠
def comb(n, k):#nCk
    return fact[n]*fact_inv[k]*fact_inv[n-k]%mod
ans = 0
for k in range(N+1):
    r = K-k*A
    if r%B != 0 or r//B>N:
        continue
    l = r//B
    ans+=comb(N, k)*comb(N, l)
    ans%=mod
print(ans)



### FIXED CODE ###

mod = 998244353
N, A, B, K = map(int, input().split())
def make_fact(n):#0~nの階乗を求める
    fact = [1]*(n+1)
    for i in range(1, n+1):
        fact[i] = fact[i-1]*i%mod
    return fact
fact = make_fact(N) #＠
def make_fact_inv(n):#0~nの階乗のmodに関する逆元を求める
    fact_inv = [1]*(n+1)
    fact_inv[n] = pow(fact[n], mod-2, mod)#フェルマーの小定理
    for i in range(n, 0, -1):
        fact_inv[i-1] = fact_inv[i]*i%mod
    return fact_inv
fact_inv = make_fact_inv(N)#＠
def comb(n, k):#nCk
    return fact[n]*fact_inv[k]*fact_inv[n-k]%mod
ans = 0
for k in range(N+1):
    r = K-k*A
    if r<0 or r%B != 0 or r//B>N:
        continue
    l = r//B
    ans+=comb(N, k)*comb(N, l)
    ans%=mod
print(ans)
import numpy as np

n = int(input())
arr = np.array(map(int, input().split()))

mod = 10 ** 9 + 7

ans = 0
for i in range(60):
    c1 = np.count_nonzero(arr & 1)
    ans += 2 ** i * c1 * (n - c1)
    arr >>= 1

print(ans%mod)

### FIXED CODE ###

import numpy as np

n = int(input())
arr = np.array(list(map(int, input().split())))

mod = 10 ** 9 + 7

ans = 0
for i in range(60):
    c1 = np.count_nonzero(arr & 1)
    ans += 2 ** i * c1 * (n - c1)
    arr >>= 1

print(ans%mod)
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

A = ord('a') - 1
n = inp()
if n == 1:
    print(a)
c = 0
while n >= pow(26,c):
    c += 1
res = []
for i in range(c):
    now = c-i-1
    nnn,m = divmod(n,pow(26,now))
    res.append(chr(A + nnn))
    n = m
print(''.join(res))

### FIXED CODE ###

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
keta = 1
su = 0
while True:
    su += 26**keta
    if su >= n:
        break
    keta += 1
n -= su - pow(26,keta) + 1
# print(n)
res = []
for i in range(keta):
    now = keta-i-1
    d,m = divmod(n,pow(26,now))
    res.append(chr(ord('a') + d))
    n = m
print(''.join(res))
"""C."""

import sys

input = sys.stdin.readline  # noqa: A001

n = int(input())
a = list(map(int, input()[:-1].split(' ')))

result = 0

for i, v1 in enumerate(a):
    for j in range(i + 1, n + 1):
        result += v1 * a[j]
print(result)


### FIXED CODE ###

"""C."""

import sys

input = sys.stdin.readline  # noqa: A001

n = int(input())
a = list(map(int, input()[:-1].split(' ')))

MOD_VALUE = 10**9 + 7
result = 0

a_sum = sum(a)

for i, v in enumerate(a):
    result += v * (a_sum - v)
    a_sum -= v

if result < MOD_VALUE:
    print(result)
else:
    print(result % MOD_VALUE)
import sys
read_=sys.stdin.buffer.readline

N=int(input())
A=[0]
a=list(map(int,read_().split()))
a.append(0)
A.extend(a)

res=0

for i in range(1,N+2):
    res+=abs(A[i-1]-A[i])

for i in range(1,N+1):
    print(res+abs(A[i-1]-A[i+1])-(abs(A[i]-A[i-1])+abs(A[i]-A[i+1])))

### FIXED CODE ###

N=int(input())
A=[0]
a=list(map(int,input().split()))
a.append(0)
A.extend(a)

res=0

for i in range(1,N+2):
    res+=abs(A[i-1]-A[i])

for i in range(1,N+1):
    print(res+abs(A[i-1]-A[i+1])-(abs(A[i]-A[i-1])+abs(A[i]-A[i+1])))
n,m = map(int,input().split())

a = []
for i in range(m):
    a.append(int(input()))

d = [a[0]-1]
for j in range(1,m):
    d.append(a[j]-a[j-1]-2)

d.append(n-a[m-1]-1)

mm = max(d)

fiblist = [0] * (mm+1)
fiblist[0] = 1
fiblist[1] = 1

for p in range(2,mm+1):
    fiblist[p] = (fiblist[p-1]+fiblist[p-2]) % 1000000007

#print(d)

if -1 in d:
    print(0)
else:
    ans = 1
    for k in range(m+1):
        ans = (ans * fiblist[d[k]]) % 1000000007

    print(ans)


### FIXED CODE ###

fiblist = [0] * 100001
fiblist[0] = 1
fiblist[1] = 1
for p in range(2,100001):
    fiblist[p] = (fiblist[p-1]+fiblist[p-2]) % 1000000007

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

if m == 0:
    print(fiblist[n])
else:
    a = []
    for i in range(m):
        a.append(int(input()))

    d = [a[0]-1]
    for j in range(1,m):
        d.append(a[j]-a[j-1]-2)

    d.append(n-a[m-1]-1)




#print(d)

    if (-1 in d) or (-2 in d):
        print(0)
    else:
        ans = 1
        for k in range(m+1):
            ans = (ans * fiblist[d[k]]) % 1000000007

        print(ans)
from math import factorial

class UnionFind:
  def __init__(self, n):
    self.par = [-1 for _ in range(n)]
  def root(self, x):
    return x if self.par[x] < 0 else self.root(self.par[x])
  def unite(self, x, y):
    x, y = self.root(x), self.root(y)
    if x != y:
      if self.par[y] < self.par[x]:
        x, y = y, x
      self.par[x] += self.par[y]
      self.par[y] = x
    return x != y
  def find(self, x, y):
    return self.root(x) == self.root(y)
  def size(self, x):
    return -self.par[self.root(x)]

n, m = map(int, input().split())
tree = UnionFind(n)
b = []
for _ in range(m):
  a, c = map(int, input().split())
  b.append([a - 1, c - 1])
b.reverse()
ans = [sum(range(n))]
for i, p in enumerate(b):
  if not tree.find(p[0], p[1]):
    ans.append(ans[-1] - tree.size(p[0])*tree.size(p[1]))
    tree.unite(p[0], p[1])
  elif i != m - 1:
    ans.append(ans[-1])
for i in reversed(ans):
  print(i)

### FIXED CODE ###

s = input()
print(min(s.count('1'), s.count('0'))*2)
input_data = input()
if input_data <= 999:
    print(ABC)
else:
    print(ABD)

### FIXED CODE ###

input_data = int(input())
if input_data <= 999:
    print('ABC')
else:
    print('ABD')
S = input()
K = int(input())

if(S.count(S[0]) == len(S)):
    print((len(S)*K//2)
else:
    if(S[0] != S[-1]):
        cnt = 0
        lst = []
        tmp = S[0]
        for i in range(len(S)):
            if(tmp == S[i]):
                cnt += 1
            else:
                tmp = S[i]
                if(cnt > 1):
                    lst.append(cnt)
                cnt = 1   
        if(cnt > 1):
            lst.append(cnt)
        
        ans = 0
        for i in range(len(lst)):
            ans += K*(lst[i]//2)
        print(ans)
    else:
        cnt = 0
        lst = []
        tmp = S[0]
        for i in range(len(S)):
            if(tmp == S[i]):
                cnt += 1
            else:
                tmp = S[i]
                if(cnt > 1):
                    lst.append(cnt)
                cnt = 1
        if(cnt > 1):
            lst.append(cnt)
    
        ans = 0
        for i in range(len(lst)):
            ans += K*(lst[i]//2)
        a = 0
        b = 0
        tmp = S[0]
        for i in range(len(S)):
            if(tmp != S[i]):
                break
            a += 1
        for i in S[::-1]:
            if(tmp != i):
                break
            b += 1
        print(ans+((a+b)//2-(a//2+b//2)*(K-1))

### FIXED CODE ###

S = input()
K = int(input())

if(S.count(S[0]) == len(S)):
    print(len(S)*K//2)
else:
    cnt = 0
    lst = []
    tmp = S[0]
    for i in range(len(S)):
        if(tmp == S[i]):
            cnt += 1
        else:
            tmp = S[i]
            if(cnt > 1):
                lst.append(cnt)
            cnt = 1   
    if(cnt > 1):
        lst.append(cnt)
        
    ans = 0
    for i in lst:
        ans += K*(i//2)
    if(S[0] != S[-1]):
        print(ans)
    else:
        a = 0
        b = 0
        for i in range(len(S)):
            if(tmp != S[i]):
                break
            a += 1
        for i in S[::-1]:
            if(tmp != i):
                break
            b += 1
        print(ans+((a+b)//2-(a//2+b//2))*(K-1))
N = int(input())
# if N % 2 == 0:
#     print(0.5)
# else:
#     print((N + 1)/2 / N)

cnt = 0
for i in range(1, N+1):
    if i % 2 == 1:
        cnt += 1
print(cnt/n)

### FIXED CODE ###

N = int(input())
if N % 2 == 0:
    print(0.5)
else:
    print((N + 1)/2 / N)
a,b,k=map(int,input().split(' '))
if(a>k):
    a=a-k
elif (a<=k):
    aa=0
    b=b+a-k
print(str(aa)+' '+str(b))

### FIXED CODE ###

a,b,k=map(int,input().split(' '))
if(a>k):
    aa=a-k
elif (a<=k):
    aa=0
    b=max(b+a-k,0)
print(str(aa)+' '+str(b))
N, M = map(int, input().split())
As = [int(input()) for _ in range(M)]
mod = 10**9 +7
dp = [0]*(N+1)
dp[0] = 1
if As[0] != 1:
    dp[1] = 1
for i in range(2, N+1):
    if i in As:
        continue
    dp[i] = (dp[i-1]+dp[i-2])%mod
print(dp[N]%mod)



### FIXED CODE ###

N, M = map(int, input().split())
As = [int(input()) for _ in range(M)]+[0]
mod = 10**9 +7
dp = [0]*(N+1)
dp[0] = 1
j = 0
if As[j] != 1:
    dp[1] = 1
else:
    j += 1
for i in range(2, N+1):
    if i == As[j]:
        j += 1
        continue
    dp[i] = (dp[i-1]+dp[i-2])%mod
print(dp[N]%mod)
n = int(input())
a = list(map(int, input().split()))
colors = [0]*9
for i in a:
    colors[i//400] += 1

mi = 0
for i in range(8):
    if colors[i]>0:
        mi += 1

print(mi, min(mi+colors[-1], 8))

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
colors = [0]*9
for i in a:
    colors[min(i//400, 8)] += 1

mi = 0
for i in range(8):
    if colors[i]>0:
        mi += 1
if mi==0:
    mi = 1
    ma = colors[-1]
else:
    ma = mi+colors[-1]
print(mi, ma)
r=int(input())
prnt(2*r*3.14)

### FIXED CODE ###

r=int(input())
print(2*r*3.14)
from collections import deque
import numpy as np

H,W = map(int,input().split())
A = [list(input()) for _ in range(H)]
table = [[float('inf')]*(W) for _ in range(H)]
visited = [[False]*(W) for _ in range(H)]
start = []
for i in range(H):
    for j in range(W):
        if A[i][j] == '#':
            table[i][j] = 0
            start.append((i,j))
for (sy, sx) in start:
    visited[sy][sx] = True
    que = deque([(sx,sy)])
    while que:
        y,x = que.popleft()
        for dy, dx in ((1,0),(-1,0),(0,1),(0,-1)):
            ny,nx = y+dy, x+dx
            if 0<=ny<H and 0<=nx<W:
                if table[ny][nx] == float('inf'):
                    table[ny][nx] = table[y][x]+1
                    que.append((ny, nx))
print(np.array(table).max())

### FIXED CODE ###

from scipy.ndimage import distance_transform_cdt
H,W = map(int,input().split())
S = list(list(input()) for h in range(H))
for h in range(H):
    for w in range(W):
        if S[h][w] == '#':
            S[h][w] = 0
        else:
            S[h][w] = 1
print(distance_transform_cdt(S, metric='taxicab').max())
X = int(input())

result = [0, 0]
powers = [x**5 for x in range(101)]

end_flag = False
for i in range(101):
    a5 = powers[i]
    for j in range(i, 101):
        b5 = powers[j]
        x = a5 - b5
        if (x == X):
            result[0] = i
            result[1] = j
            end_flag = True
            break
        elif (-x == X):
            result[0] = -i
            result[1] = -j
            end_flag = True
            break
        x = a5 + b5
        if (x == X):
            result[0] = i
            result[1] = -j
            end_flag = True
            break
        elif (-x == X):
            result[0] = -i
            result[1] = j
            end_flag = True
            break
    if end_flag:
        break

A, B = result
if A*B == 0:
    raise "invalid X"

print(f"{A} {B}")


### FIXED CODE ###

X = int(input())

result = [0, 0]
powers = [x**5 for x in range(1001)]

end_flag = False
for i in range(1001):
    a5 = powers[i]
    for j in range(i, 1001):
        b5 = powers[j]
        x = a5 - b5
        if (x == X):
            result[0] = i
            result[1] = j
            end_flag = True
            break
        elif (-x == X):
            result[0] = -i
            result[1] = -j
            end_flag = True
            break
        x = a5 + b5
        if (x == X):
            result[0] = i
            result[1] = -j
            end_flag = True
            break
        elif (-x == X):
            result[0] = -i
            result[1] = j
            end_flag = True
            break
    if end_flag:
        break

A, B = result
print(f"{A} {B}")
n, sum = map(int, input().split())

for x in range(n + 1):
    for y in range(n + 1):
        for z in range(n + 1 - x - y):
            if x * 10000 + y * 5000 + z * 1000 == sum:
                print(f'{x} {y} {z}')
                exit()

print('-1 -1 -1')

### FIXED CODE ###

n=int(input())
d=list(map(int, [input() for i in range(n)]))
print(len(set(d)))
n = int(input())
c = list(input())
cFixed = [x for x in c]
cFixed.sort()
for i in range(n):
	if cFixed[i] == "R":
		lastR = i
ans = 0
for i in range(lastR+1):
	if c[i] == "W":
		ans += 1

print(ans)


### FIXED CODE ###

n = int(input())
c = list(input())
cFixed = [x for x in c]
cFixed.sort()
lastR = -1
for i in range(n):
	if cFixed[i] == "R":
		lastR = i
ans = 0
for i in range(lastR+1):
	if c[i] == "W":
		ans += 1

print(ans)
# B - Median Pyramid Easy
N,x = map(int,input().split())
if x==1 or x==2*N-1:
    print('No')
elif N==2:
    print('Yes')
    for x in range(1,4):
        print(x)
else:
    print('Yes')
    if x==2:
        num = num[4:]
        que = [3,2,1,4]
    else:
        num = list(range(1,2*N))
        que = []
        for _ in range(3):
            que.append(num.pop(x-2))
        que.append(num.pop(x-3))
    for i in range(2*N-1):
        if N-1<=i<=N+2:
            print(que.pop(0))
        else:
            print(num.pop(0))

### FIXED CODE ###

# B - Median Pyramid Easy
from collections import deque
N,x = map(int,input().split())
if x==1 or x==2*N-1:
    print('No')
elif N==2:
    print('Yes')
    for x in range(1,4):
        print(x)
else:
    print('Yes')
    if x==2:
        num = deque(list(range(5,2*N)))
        que = deque([3,2,1,4])
    else:
        num = deque(list(range(1,x-2))+list(range(x+2,2*N)))
        que = deque([x-1,x,x+1,x-2])
    for i in range(2*N-1):
        if N-2<=i<=N+1:
            print(que.popleft())
        else:
            print(num.popleft())
X=int(input())
Y=int(X**(0.2))
for i in range(Y,0,-1):
    for t in (-Y//2,Y,1):
        if (i**5)-(t**5)==X:
            S=i
            Z=t
            break
        else:
            continue
print(S,Z)

### FIXED CODE ###

X=int(input())
l=[]
for i in range(300):
    a=i**5
    l.append(a)
    l.append(-a)
for j in l:
    for s in l:
        if j-s==X and j!=s:
            ans=[]
            for i in [j,s]:
                aaa=abs(i)**(1/5)
                if i>=0:
                    ans.append(int(aaa))
                else:
                    ans.append(int(-aaa))
            print(*ans)
            exit()
def canbuy(n):
    for i in range(int(100/7)):
        tmp = (n-7*i)
        if tmp==0 or (tmp>3 and tmp%4==0):
            return 'Yes'
    return 'No'

n=int(input())
print(canbuy(n))


### FIXED CODE ###

def diff(n,k):
    if n%k==0:
        return 0
    else:
        return 1

n,k=[int(i) for i in input().split()]
print(diff(n,k))
N = input().split()

list = [int(x) for x in input().split()]

sortlist = list.sorted()

answer = 1

for a in sortlist:
    answer = answer*a
    if answer == 0:
        break
    if answer > 10^18:
        answer = -1
        break
    else:
        continue

print(answer)

### FIXED CODE ###

N = input().split()

list = [int(x) for x in input().split()]

list.sort()

answer = 1

for a in list:
    answer = answer*a
    if answer == 0:
        break
    if answer > 10**18:
        answer = -1
        break
    else:
        continue

print(answer)
A,B,H,M= list(map(int,input().split()))

kakudo_H = H*30 +M*0.5
kakudo_M = M*6
if M==0:
    kakudo_M=360

kakudo_sa=abs(kakudo_H-kakudo_M)
# cはまずは2条している値としてセット
c=A**2 +B**2-2*A*B*(math.cos(math.radians(kakudo_sa)))
C=c**0.5
print(C)

### FIXED CODE ###

import math
A,B,H,M=input().split()

A=int(A)
B=int(B)
H=int(H)
M=int(M)

kakudo_H = H*30 +M*0.5
kakudo_M = M*6
if M==0:
    kakudo_M=360

kakudo_sa=abs(kakudo_H-kakudo_M)
# cはまずは2条している値としてセット
c=A**2 +B**2-2*A*B*(math.cos(math.radians(kakudo_sa)))
C=c**0.5
print(C)
A, B = map(int, input().split())
print(max(A - 2 * B), 0)

### FIXED CODE ###

A, B = map(int, input().split())
print(max(A - 2 * B, 0))
import numpy as np
 
first_int = [int(k) for k in input().split()]
a = first_int[0]
b = first_int[1]
secound_list = [int(k) for k in input().split()]
 
all_sigm = [k for k in secound_list]
max_index = all_sigm.index(max(all_sigm))
print(sum(all_sigm[max_index:max_index+b]))

### FIXED CODE ###

a = input().split()
b = [int(k) for k in input().split()]
c = input()

if a[0] == c:
  b[0] -= 1
else:
  b[1] -= 1

print('{0} {1}'.format(b[0],b[1]))
N,X=map(int,input().split())
L=list(map(int,input().split()))
total=0
count=0
for i in range(N+1):
    if total<=X:
        total+=L[i]
        count+=1
print(count)

### FIXED CODE ###

N,X=map(int,input().split())
L=list(map(int,input().split()))
total=0
count=1
for i in range(N):
    total+=L[i]
    if total<=X:
        count+=1
print(count)
import math

N, X   = map(int, input().split())
x = list(map(int, input().split()))
assert len(x) == N

x.sort()

# distance between each two cities
dist = [x[i] - x[i-1] for i in range(1, len(x))]

# distance between the first city and the start point
dist.append(abs(x[0] - X))

def listgcd(xs):
    g = xs[0]
    for i in range(1, len(xs)):
        g = math.gcd(g, xs[i])
    return g

print(listgcd(dist))


### FIXED CODE ###

import fractions

N, X   = map(int, input().split())
x = list(map(int, input().split()))
assert len(x) == N

x.sort()

# distance between each two cities
dist = [x[i] - x[i-1] for i in range(1, len(x))]

# distance between the first city and the start point
dist.append(abs(x[0] - X))

def listgcd(xs):
    g = xs[0]
    for i in range(1, len(xs)):
        g = fractions.gcd(g, xs[i])
    return g

print(listgcd(dist))
for i in range(int(intput())):
  print('ACL', end ='')
print()

### FIXED CODE ###

for i in range(int(input())):
  print('ACL', end ='')
print()
n = int(input())
table = list[int(input()) for i in range(n)]
print("{} {} {}".format(min(table),max(table),sum(table)))



### FIXED CODE ###

n = input()
table = list(map(int,input().split()))
print("{} {} {}".format(min(table),max(table),sum(table)))
import re

S=input()
K=int(input())

if not re.search(r'[^1]',S).start():
  print(1)
elif re.search(r'[^1]',S).start() >= K:
  print(1)
else:
  print(S[re.search(r'[^1]',S).start()])

### FIXED CODE ###

import re

S=input()
K=int(input())

if not re.search(r'[^1]',S):
  print(1)
elif re.search(r'[^1]',S).start() >= K:
  print(1)
else:
  print(S[re.search(r'[^1]',S).start()])
a, b = map(int, input().split())
c, d = a-1, b-1
l = sorted[a,b,c,d][::-1]
print(l[0]+l[1])

### FIXED CODE ###

a, b = map(int, input().split())
c, d = a-1, b-1
l = sorted([a,b,c,d])[::-1]
print(l[0]+l[1])