peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n=int(input())
ans=10e5
for a in range(1,n//2+1):
    b=n-a
    ans=min(ans,sum([int(i) for i in str(a)])+sum([int(i) for i in str(b)]))
    ans=min(ans,sum([int(i) for i in str(a)])+sum([int(i) for i in str(b)]))
print(int(ans))
# Judge status: Accepted
N = input()
 
flag =0
if N[0] == "7":
  flag = 1
if N[1] == "7":
  flag = 1
if N[2] == "7":
  flag = 1
  
if flag == 1:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().strip().split()))

import collections

c = sorted(collections.Counter(a).items(), reverse=True)

leng_1 = 0
for leng,count in c:
  if count >=4:
    print(leng**2)
  elif count >=2:
    if leng_1 != 0:
      print(leng_1*leng)
      exit()
    else:
      leng_1 = leng
print(0)
# Judge status: Wrong Answer
import math
n = int(input())
if n%2 != 0:
  print(0)
  exit()

x = 10
ans = 0
while x < n:
  ans += math.floor(n/x)
  x *= 5
print(ans)
# Judge status: Accepted
A,B,M=map(int,input().split())

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

minc=min(a)+min(b)

for i in range(M):
  x,y,c=map(int,input().split())
  cash=a[x-1]+b[y-1]-c

  if cash<minc:
    minc=cash

print(minc)
# Judge status: Accepted
n=int(input())
odd=0
for i in range(1,n+1):
    if i%2!=0:
        odd+=1
print(odd/n)
# Judge status: Accepted
a,b,c = map( int, input().split())
if a == b == c :
    print(1)
elif a!=b==c or b!=c==a or c!=a==b :
    print(2)
else:
    print(3)
# Judge status: Accepted
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    ans = 0
    pre = False
    for i, a in enumerate(A):
        if pre:
            pre = False
        elif i+1 == a:
            ans += 1
            pre = True
    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Accepted

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

S = input()

na = 0
nb = 0

for i in S:

    if i == "a" and na+nb < A+B:
        print ("Yes")
        na += 1
    elif i == "b" and na + nb < A+B and nb < B:
        print ("Yes")
        nb += 1
    else:
        print ("No")
# Judge status: Accepted
n = int(input())
an=[]
for _ in range(n):
    an.append(int(input()))
bn = sorted(an, reverse=True)
s = bn[0]
t= bn[1]
for i in an:
    if i == s:
        print(t)
    else:
        print(s)
# Judge status: Wrong Answer
import numpy as np

N = int(input())
n = list(range(1, N+1))
p = (np.prod(n) % (10**9+7))
print(p)
# Judge status: Wrong Answer
n = int(input())
p = [int(i) for i in input().split()]
ls = [0] * n
for i in range(n):
    if p[i] == i+1:
        ls[i] = 1
ans = 0
for i in range(n-1):
    if ls[i] == 1:
        ans += 1
        ls[i] = 0
        ls[i+1] = 0
        tmp = p[i]
        p[i] = p[i+1]
        p[i+1] = tmp
print(ans)
# Judge status: Accepted
a=list(input())
b=list("abc")
a.sort()
if a==b:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
s=input()
y=int(s[:4])
m=int(s[5:7])
d=int(s[8:])

if y<2018:
  ans='Heisei'
elif y==2019 and m<4:
  ans='Heisei'
elif y==2019 and m==4 and d<=30:
  ans='Heisei'
else:
  ans='TBD'
print(ans)
# Judge status: Wrong Answer
x = int(input())
print(360 // x)
# Judge status: Wrong Answer
import numpy as np

N, K = map(int, input().split())
An = list(map(int, input().split()))

#Sn = np.array([[0 for i in range(N)] for i in range(N)])
#for i in range(N):
#    Sn[i][max(0,i - An[i]): min(i + An[i] + 1, N)] = 1
#print(Sn)

thresh = np.array([[abs(i-j) for i in range(N)] for j in range(N)])

for i in range(K):
    buf = np.array(An-thresh)
    An = np.count_nonzero(buf >= 0, axis=1)
    #An = [sum((Ln<=i)&(i<=Hn)) for i in range(N)]
    
print(An)
# Judge status: Accepted
a = int(input())
mx = 1

for i in range(2,a):
    j=2
    while i**j <= a:
        mx = max(i**j,mx)
        j+=1

print(mx)
# Judge status: Accepted
n=int(input())
s=list(input())
for i in range(len(s)):
  if ord(s[i])+n<=90:
    s[i]=chr(ord(s[i])+n)
  else:
    s[i]=chr(ord(s[i])+n-26)
print("".join(s))
# Judge status: Wrong Answer
num, rank = map(int,input().split())
grid = []
for i in range(num):
    array = list(map(int, input().strip().split()))
    grid.append(array)

count = 0

for i in range(1,num+1):
    count += grid[i-1][1]
    if count >= rank:
        print(grid[i-1][0])
        break
    else:
        None
# Judge status: Accepted
s = input()
l = len(s)

for i in range(0 - -l//2):
    if s[i*2] == "L":
        print("No")
        exit()
for i in range(l//2):
    if s[i*2 + 1] == "R":
        print("No")
        exit()

print("Yes")
# Judge status: Wrong Answer
n=input()
ans=0
for i in n:
    ans+=int(i)
print(ans)
# Judge status: Accepted
n = int(input())
def main(n):
    if n == 1:
        return 2,0
    
    if n == 3:
        return 3,0
    m = n //2 
    for i in range(1,m+1):
        if i * (i + 1) <= 2*n < (i+1)*(i+2):
           right  = i + 1
           break
       
    diff = right * (right+1) //2 - n
       
    return right+1,diff


right,diff = main(n)

for i in range(1,right):
    if i != diff:
        print(i)
# Judge status: Accepted
A, B, C = map(int, input().split())
K = int(input())

for i in range(K):
  if A >= B:
    B *= 2
    continue
  if B >= C:
    C *= 2
    continue
    
if A < B and B < C:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
N, Y = map(int, input().split())
flag = False
for x in range(N, -1, -1):
    for y in range(N - x, -1, -1):
        z = N - x - y
        if 10000 * x + 5000 * y + 1000 * z == Y:
            print(x, y, z)
            bool = True
            exit()

if not flag:
    print(-1, -1, -1)
# Judge status: Accepted
S = str(input())

S = list(S)
ans = "Yes"

if S[0] == S[1] == S[2]:
    ans = "No"
print(ans)
# Judge status: Accepted
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

for _ in range(K):
    B = [0]*N
    for i in range(N):
        l = max(0,i-A[i])
        r = min(N-1, i+A[i])
        B[l] += 1
        if r+1 < N: B[r+1] -= 1
    for i in range(1,N):
        B[i] += B[i-1]
    B,A = A,B
    if min(A) == N:
        break
print(*A)
# Judge status: Accepted
d = int(input())
c = list(map(int,input().split()))
s = []
p = [1]*d
for i in range(d):
    s.append(list(map(int,input().split())))
x = [1]*26
for i in range(d):
    q = 1
    m = -1
    for j in range(26):
        n = s[i][j] + (x[j]+13)*(x[j]+14)*c[j]
        x[j] += 1
        if(m < n):
            m = n
            q = j
    x[q] *= 0
    p[i] = q+1
for i in range(d):
    print(p[i])
# Judge status: Wrong Answer
n=int(input())
a=[input() for i in range(n)]
t=max(a)
s=a.index(t)
a.pop(s)
u=max(a)
for i in range(n):
  if i!=s:
    print(171429)
  else:
    print(u)
# Judge status: Wrong Answer
#!/usr/bin/env python3
import collections
import itertools as it
import math
import numpy as np

# A = input()
# A = int(input())
H, W = map(int, input().split())
# A = list(map(int, input().split()))
# A = [int(input()) for i in range(N)]
#
# c = collections.Counter()

NMASU = H * W
if NMASU % 2 == 0:
    print(NMASU // 2)
elif NMASU == 1:
    print(1)
else:
    print(NMASU // 2 + 1)
# Judge status: Accepted
import math
N, M = map(int, input().split())

if N == M:
  ans = math.factorial(N) % (10**9+7)
  ans = (ans**2) % (10**9+7)
  ans = (ans*2) % (10**9+7)
elif N - M == 1:
  ans = math.factorial(M) % (10**9+7)
  ans = (ans**2) % (10**9+7)
  ans = (ans*N) % (10**9+7)
elif M - N == 1:
  ans = math.factorial(N) % (10**9+7)
  ans = (ans**2) % (10**9+7)
  ans = (ans*M) % (10**9+7)
else:
  ans = 0
  
print(ans)
# Judge status: Accepted
import math
n = int(input(""))
print(int(math.ceil(n/2)))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
s = sum(a)
d = [0] * (10 ** 5 + 1)
for x in a:
    d[x] += 1
q = int(input())
for _ in range(q):
    b, c = map(int, input().split())
    s += (c - b) * d[b]
    d[c] += d[b]
    d[b] = 0
    print(s)
# Judge status: Accepted
A, B = map(int, input().split())
print('Possible' if A%3==0 or B%3==0 or (A+B)%3==0 else 'Impossible')
# Judge status: Wrong Answer
x = raw_input()
if x < 1000:
    print "ABC"
if x > 999:
    print "ABD"
# Judge status: Accepted
a,b,c=map(int, input().split())
if b+c>=a:
  print(c-(a-b))
else:
  print(0)
# Judge status: Accepted
s ={}
n = int(input())
for _ in range(n):
    word = input()
    s[word] = s.get(word, 0)+1
m = int(input())
for _ in range(m):
    word = input()
    s[word] = s.get(word, 0)-1

ans = max(max(s[i],0) for i in s)
print(ans)
# Judge status: Wrong Answer
def main():
    N, M = map(int, input().split())
    if M % N == 0:
        print(M // N)
    else:
        print(M % N)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
import itertools

n = int(input())
c = 0
a = [i for i in range(3, n + 1)]

for r in range(len(a) + 1):
    p = itertools.permutations(a, r)
    b = list(p)
    for i in b:
        if sum(i) == n:
            c += 1
print(c)
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
def cout_dif(a, b):
    sum = 0
    for i in range(len(a)):
        if a[i] != b[i]:
            sum += 1
    return sum
    
def main():
    s = input()
    t = input()
    min = 10**5
    for i in range(len(s)-len(t)):
        sum = cout_dif(t, s[i:i+len(t)+1])
        if sum < min:
            min = sum
    print(min)

if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
wa = []
wa2 = []
#for i in range(n):
#    wa.append(sum(a[0:i+1]))
#    wa2.append(sum(a[-1:-(i+2):-1]))
s = 0
s1 = 0
for i in range(n):
    s +=a[i]
    wa.append(s)
    s1 +=a[-(i+1)]
    wa2.append(s1)

ans = 10**10
for i in range(n-1):
    if ans > abs(wa[i] - wa2[-(i+2)]):
        ans = abs(wa[i] - wa2[-(i+2)])
print(ans)
# Judge status: Accepted
a,b=map(int,input().split())
if a>=13:
  print(b)
elif 6<=a<=12:
  print(b//2)
else:
  print(0)
# Judge status: Wrong Answer
x = input()
x = '000'+x
z = x[:-2]
y = x[-2:]
s = 0
z = int(z)
y = int(y)
L = []
for i in range(1,z):
    s +=i
    if s>=y and z>=i:
        print(1)
        exit()
if z>=10:
    print(1)
    exit()
print(0)
# Judge status: Accepted
N, M = map(int, input().split())
S = sum([int(a) for a in input().split()])
print(-1 if S > N else N - S)
# Judge status: Accepted
def actual(n, W):
    # 重複があればアウト
    if len(set(W)) != len(W):
        return 'No'

    for i in range(len(W) - 1):
        word_now, word_next = W[i], W[i + 1]

        tail = word_now[-1]
        head = word_next[0]

        if tail != head:
            return 'No'

    return 'Yes'

N = int(input())
W = [input() for _ in range(N)]

print(actual(N, W))
# Judge status: Accepted
N, K = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
while True:
  if ans*K - ans + 1 >= N:
    print(ans)
    break
  else:
    ans += 1
# Judge status: Accepted
n = int(input())
v = list(map(int,input().split()))
v.sort()

for i in range(n-1):
  v[1] = (v[0]+v[1])/2
  del v[0]
  v.sort()

print(v[0])
# Judge status: Accepted
import sys
import itertools
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    n,x = IL()
    l = [0]+list(IL())
    l = list(itertools.accumulate(l))
    ans = 0
    for rep in l:
        if x<rep:   break
        ans += 1
    print(ans)
    return

if __name__=='__main__':
    Main()
# Judge status: Accepted
n,m=map(int,input().split())

if n==1 and m==1:
    print("1")
elif n==1 or m==1:
    print(n*m-2)
elif n==2 or m==2:
    print("0")
else:
    print((n*m)-(n*2+m*2-4))
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

max_A = max(A)
min_A = min(A)

ans = 10**9
for y in range(min_A, max_A+1):
    tmp = 0
    for a in A:
        xsuby = a - y
        tmp += xsuby ** 2
    ans = min(ans, tmp)

print(ans)
# Judge status: Accepted
"""
覚えておきたい
"""

n,*a=map(int,open(0).read().split())
ans=1
tmp=0
for i in range(1,n):
  if (a[i]-a[i-1])*tmp<0:
    ans+=1
    tmp=0
  elif not a[i]-a[i-1]==0:
    tmp=a[i]-a[i-1]
print(ans)
# Judge status: Accepted
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,k,s=map(int,input().split())
for i in range(k):
    print(s,end=" ")
if s!=10**9:
    C=10**9
else:
    C=3
for i in range(n-k):
    print(C,end=" ")
print("")
# Judge status: Accepted
from collections import deque
n=int(input())
a=list(map(int,input().split()))
b=deque()
for i in range(n):
    if i%2==0:
        b.append(a[i])
    if i%2==1:
        b.appendleft(a[i])

if n%2==1:
    c=deque()
    for i in range(n):
        d=b.pop()
        c.append(d)
    print(*c)
else:
    print(*b)
# Judge status: Accepted
from string import ascii_lowercase as al


def dfs(p, i):
    if len(p) == N:
        print("".join(p))
        return
    for j in range(i+1):
        if j == i:
            dfs(p + list(al[j]), i+1)
        else:
            dfs(p + list(al[j]), i)


N = int(input())
dfs([], 0)
# Judge status: Wrong Answer
import sys
import itertools
import copy

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():
    N, K = MI()
    index = 0
    mylist = []
    for i in range(N):
        a, b = MI()
        index += b
        mylist += [a]*b
        if index >= K:
            mylist.sort()
            print(mylist[K-1])
            sys.exit()

main()
# Judge status: Accepted
X=int(input())
p=360
cnt=0

while p%X !=0:
    p += 360

print(p//X)
# Judge status: Wrong Answer
x,a,b = map(int, input().split())
if abs(x-a) > abs(x-b):
  print("A")
else:
  print("B")
# Judge status: Wrong Answer
from heapq import heappop,heappush
n,m=map(int,input().split())
work=[set() for _ in range(m+1)]
for _ in range(n):
    a,b=map(int,input().split())
    if a<=m: work[a].add(b)

ans=0
q=[]
for i in range(1,m+1):
    for x in work[i]:
        heappush(q,-x)
    if q!=[]: ans+=heappop(q)
print(-ans)
# Judge status: Accepted
s = input()
zero = 0
one = 0
for i in s:
  zero += 1*(i=="0")
  one += 1*(i=="1")
print(min(zero,one)*2)
# Judge status: Wrong Answer
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush
import collections
import bisect

def main():
    S = input()

    l = 0
    r = 0
    for i in range(len(S)):
        if l==0 and S[i]=='A':
            l = i
        elif S[i]=='Z':
            r = i
    print(l, r)
    print(r - l + 1)


if __name__ == '__main__':
    main()
# Judge status: Accepted
string = input()
for i in range(len(string)):
    if i % 2 == 0:
        if string[i] == 'h':
            continue
        else:
            print('No')
            break
    elif i % 2 == 1:
        if string[i] == 'i':
            continue
        else:
            print('No')
            break
else:
    if len(string) % 2 == 1:
        print('No')
    else:
        print('Yes')
# Judge status: Accepted
D = int(input())
S = "Christmas"
T = " Eve"
for i in range(D,25):
    S += T
print(S)
# Judge status: Accepted
print('Yes' if 'AAA'<input()<'BBB' else 'No')
# Judge status: Wrong Answer
list=[]
list.append(input())
q=int(input())
for i in range(q):
	a=input()
	if a=="1":
		list.reverse()
	else:
		a,f,c = a.split()
		if f=="1":
			list.insert(0,c)
		else:
			list.append(c)
c="".join(list)
print(c)
# Judge status: Wrong Answer
s=['a','i','o','u','e']
x=input()
falg=0
for i in s:
    if (i==x):
        falg=1
        break
if falg==0:
    print('consonant.')
else:
    print("vowel.")
# Judge status: Accepted
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
import numpy as np
from collections import Counter,defaultdict
def main():
    n, *a = map(int, read().split())
    aa = Counter(a)
    d1 = defaultdict(int)
    d2 = defaultdict(int)
    for k, v in aa.items():
        d1[k] = v * (v - 1) // 2
        v -= 1
        d2[k] = v * (v - 1) // 2
    sumd1 = sum(d1.values())
    for ae in a:
        r = sumd1 - d1[ae] + d2[ae]
        print(r)

if __name__ == '__main__':
    main()
# Judge status: Accepted
L = []
R = []
N, M = map(int, input().split())
for i in range(M):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

ans = min(R)-max(L)+1
if ans>=1:
    print(ans)
else:
    print(0)
# Judge status: Accepted
a,b=map(int,input().split())
A=14 if a==1 else a
B=14 if b==1 else b
print('Draw' if A==B else 'Alice' if A>B else 'Bob')
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

ans = 0
x = 0
C = []
D = []
if N == 1:
    print(A[0] + B[0])
    exit()
for i in range(N):
    C = A[0:i]
    D = B[i - 1:N]
    x = sum(C) + sum(D)
    ans = max(ans, x)

print(ans)
# Judge status: Wrong Answer
n = int(input())
a_list = list(map(int, input().split()))

max_a = max(a_list)
half_max = max_a / 2
near = max_a
near_ori = max_a
for a in a_list:
    tmp = abs(a - half_max)
    if tmp < near:
        near = tmp
        near_ori = a
        
print(max_a, near_ori)
# Judge status: Wrong Answer
N,M=map(int,input().split())
if N==M:
  ans="Yes"
else:
  ans="No"
print("ans")
# Judge status: Accepted
import sys

N = input()
M = input()
M = M[:-1]
if( N == M):
  print('Yes')
  sys.exit()
print('No')
# Judge status: Wrong Answer
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    C = input()
    print('vowel' if C in ['a', 'e', 'i', 'o', 'o'] else 'consonant')


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
S, T = input().split()
A, B = map(int, input().split())
U = input()
C = 0
if S == U:
    C = A - 1
elif T == U:
    C = B - 1
else:
    A = A

print(C)
# Judge status: Accepted
import sys
stdin = sys.stdin
import itertools

mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

N = ni()
A = list()
for _ in range(N):
    A.append(ni())
cnt = 0
if N==1:
    print(A[0]//2)
    quit()
for i in range(N-1):
    ccnt = (A[i] + A[i+1]) //2
    A[i+1] -= max(0, ccnt*2 - A[i])
    A[i] = max(0, A[i]-ccnt*2)
    cnt += ccnt
print(cnt)
# Judge status: Wrong Answer
N = int(input())

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

cnt = 0

for n in array:
    if n < 0:
        cnt += 1
    calc_array.append(abs(n))
        
if cnt % 2 == 1:
    output = sum(calc_array) - min(calc_array)
else :
    output = sum(calc_array)
    
print(output)
# Judge status: Accepted
import math

a = int(input().replace(" ", ""))
b = 0
for i in range(1, 1000):
    if( a == i*i ): 
      print('Yes')
      b=1

if(b==0): print('No')
# Judge status: Accepted
N = int(input())
# {A:数列に0だけ存在しない集合, B:数列に9だけ存在しない集合}
# 全体集合 - (A + B) + A and B 
ans = (10 ** N - 9 ** N * 2 + 8 ** N) % (10 ** 9 + 7) 
print(ans)
# Judge status: Accepted
N,X,Y = map(int,input().split())

X,Y = X-1,Y-1
ans = [0]*N
for i in range(N):
    for j in range(i+1,N):
        d = j-i
        d = min(d,abs(X-i)+abs(Y-j)+1)
        ans[d] += 1
for out in ans[1:]:
    print(out)
# Judge status: Wrong Answer
x,y = map(int,input().split())
if x >= 0 and y >= 0:
    if x > y:
        print(1+x+y)
    else:
        print(y-x)
elif x >= 0 and y < 0:
    if x >= -y:
        print(1+x+y)
    else:
        print(1+x-y)
elif x < 0 and y >= 0:
    if -x >= y:
        print(1-y-x)
    else:
        print(1+x+y)
else:
    if -x > -y:
        print(y-x)
    else:
        print(2+x-y)
# Judge status: Accepted
N=int(input())
t=0
for i in range(N):
  t+=i+1
print(t)
# Judge status: Wrong Answer
a,b,x = map(int,input().split())
div,mod = divmod(b-a,x) #2,0
if a%x <= mod:
  print(div+1)
#elif a%x > mod:
#  print(div-1)
else:
  print(div)
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
if a*c<b:
  print(c)
elif a*c>b:
  print(b//a)
else:
  print(a//b)
# Judge status: Accepted
#B

n = int(input())
s = 0
for i in range(1,n+1):
    #print(i,i % 3,i % 5)
    if i % 3 != 0 and i % 5 != 0:
        s += i
    #print(s)
print(s)
# Judge status: Accepted
w,h,n=map(int,input().split())
answ=set(range(w+1)) 
ansh=set(range(w+1))
for i in range(n):
  x,y,a=map(int,input().split())
  if a==1:
    answ=answ & set(range(x,w+1))
  elif a==2:
    answ=answ & set(range(x+1))
  elif a==3:
    ansh=ansh & set(range(y,h+1))
  elif a==4:
    ansh=ansh & set(range(y+1))
if len(answ) == 0 or len(ansh)==0:
  print(0)
else:
  print((max(answ)-min(answ))*(max(ansh)-min(ansh)))
# Judge status: Wrong Answer
N, R = map(int,input().split())
if N >= 10:
  print(R)
else:
  print(R - 100*(10-N))
# Judge status: Accepted
import itertools


def solve():
    N, D = map(int, input().split())
    X = []
    for i in range(N):
        X.append(list(map(int, input().split())))
    ans = 0

    for i in itertools.combinations(range(N), 2):
        save = 0
        for d in range(D):
            save += (X[i[0]][d]-X[i[1]][d])**2
        if (save**0.5) % 1 == 0:
            ans += 1
    print(ans)


solve()
# Judge status: Wrong Answer
from collections import deque
n,m,k=map(int,input().split())
a=deque(list(map(int,input().split())))
b=deque(list(map(int,input().split())))
cost=0
ans=0
while (a and cost+a[0]<=k) or (b and cost+b[0]<=k):
	if a and b:
		if a[0]<b[0]:
			cost+=a[0]
			ans+=1
			a.popleft()
		else:
			cost+=b[0]
			ans+=1
			b.popleft()
	elif a:
		cost+=a[0]
		ans+=1
		a.popleft()
	else:
		cost+=b[0]
		ans+=1
		b.popleft()
print(ans)
# Judge status: Wrong Answer
def resolve():
    S=int(input())
    i,mod=divmod(S,10**9)
    print(0,0,10**9,mod,1,i)

resolve()
# Judge status: Wrong Answer
a,b,c = map(int,input().split())
 
if a<= c and c>=b:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
import sys

def solve():
      input = sys.stdin.readline
      S = input().strip("\n")
      T = input().strip("\n")
      minChange = len(T)
      for i in range(len(S) - len(T) + 1):
            c = 0
            for j in range(len(T)):
                  if S[i + j] != T[j]: c += 1
            minChange = min(minChange, c)
      print(minChange)

      return 0

if __name__ == "__main__":
      solve()
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
k = 0
num = sum(a)
import math

for i in range(n):
    reje = num - a[i]
    k += reje * a[i]

x = k//2
t = 10 ** 9 + 7
ans = x % t
print(ans)
# Judge status: Accepted
n,m = map(int,input().split())
ans = [1, n]

for _ in range(m):
    l,r = map(int,input().split())
    ans[0] = max(l, ans[0])
    ans[1] = min(r, ans[1])

if ans[1] - ans[0] >= 0:
    print(ans[1] - ans[0] + 1)
else:
    print(0)
# Judge status: Wrong Answer
S = input()
T = input()
L,l = len(S),len(T)
ans = 1000
for i in range(l,L):
    s = S[i-l:i]
    cnt = 0
    for j in range(l):
        if s[j] != T[j]:
            cnt += 1
    if ans > cnt:
        ans = cnt
print(ans)
# Judge status: Accepted
S = input()
A = ["A", "G", "C", "T"]
cnt = 0
Max = 0
for i in range(len(S)):
    if S[i] in A:
        cnt += 1
        Max = max(Max, cnt)
    else:
        cnt = 0
print(Max)
# Judge status: Accepted
A, B, C = [int(i) for i in input().split()]

if A == B and A == C:
    print('No')
elif A != B and A != C and B != C:
    print('No')
else :
    print('Yes')
# Judge status: Accepted
import fractions

def ceil(n, m):
    if n % m == 0:
        ans = n // m
    else:
        ans = (n + m) // m
    return ans

q = [0] * 3
nmul = [0] * 3

lower, upper, q[0], q[1] = [int(x) for x in input().split()]
q[2] = (q[0] * q[1]) // fractions.gcd(q[0], q[1])

for i in range(3):
    left = lower if (lower % q[i] == 0) else lower + q[i] - (lower % q[i])
    nmul[i] = ceil( upper - left + 1, q[i])

ans = upper - lower + 1 - nmul[0] - nmul[1] + nmul[2]

print(ans)
# Judge status: Wrong Answer
import math

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

print(math.floor(a * b))
# Judge status: Accepted
n=int(input())
li = list(map(int,input().split()))

ans = 0
ch = False
for i in range(n):
    if ch == True:
        ch = False
    elif li[i] == i + 1:
        ans += 1
        ch = True
print(ans)
# Judge status: Wrong Answer
n,d = map(int,input().split())
su = 0
for i in range(n):
  x,y = map(int,input().split())
  if d**2 <= x**2 +y**2:
    su +=1
  else:
    continue
print(su)