Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

N = int(input())
S = str(input())
count = S.count("#.")
ans = 0

while count != 0:

    for i in range(count):
        bwindex = S.index("#.")
        S = list(S)
        S[bwindex+1] = "#"
        S = "".join(S)
        ans += 1

    count = S.count("#.")
    
print(ans)

### FIXED CODE ###

N = int(input())
S = str(input())
x = S.count(".")
ans = x
for i in range(N):
    if S[i]=="#":
        x += 1
    else:
        x -= 1
    ans = (min(ans,x))
print(ans)
### BUGGY CODE ###

n, k = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]

s = [float('inf')] * n
s[0] = 0
for i in range(n):
    for j in range(i+1, min(i+k+1, n)):
        s[j] = min(s[j], s[i] + abs(h[i]-h[j]))

print(s[n-1])

### FIXED CODE ###

n, k = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]

s = [float('inf')] * n
s[0] = 0
for i in range(n):
    for j in range(i+1, min(i+k+1, n)):
        s[j] = min(s[j], s[i] + abs(h[i]-h[j]))

print(s[n-1])
### BUGGY CODE ###

import sys, os, math, bisect, itertools, collections, heapq, queue
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    H, N = il()
    magic = [il() for _ in range(N)]
    dp = [0] * (H + 1)

    dp[0] = 0
    for h in range(1, H + 1):
        for n in range(N):
            if n == 0:
                if magic[n][0] <= h:
                    dp[h] = dp[h - magic[n][0]] + magic[n][1]
                else:
                    dp[h] = magic[n][1]
            else:
                if magic[n][0] <= h:
                    dp[h] = min(dp[h], dp[h - magic[n][0]] + magic[n][1])
                else:
                    dp[h] = min(dp[h], magic[n][1])
    print(dp[-1])


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    H, N = il()
    magic = [il() for _ in range(N)]
    dp = [0] * (H + 1)

    dp[0] = 0
    for h in range(1, H + 1):
        for n in range(N):
            if n == 0:
                if magic[n][0] <= h:
                    dp[h] = dp[h - magic[n][0]] + magic[n][1]
                else:
                    dp[h] = magic[n][1]
            else:
                if magic[n][0] <= h:
                    dp[h] = min(dp[h], dp[h - magic[n][0]] + magic[n][1])
                else:
                    dp[h] = min(dp[h], magic[n][1])
    print(dp[-1])


if __name__ == '__main__':
    main()
### BUGGY CODE ###

f=lambda:map(int,input().split())
n,k=f()
la=sorted(f())
INF=10**18+1
from bisect import *
tl=bisect_left(la,0)
tr=bisect(la,0)
tm,tz,tp=tl,tr-tl,n-tr
cm=tm*tp
cz=tz*(n*2-tz-1)//2
cp=(tm*(tm-1)+tp*(tp-1))//2
if 0<k-cm<=cz:
  print(0)
elif k<=cm:
  l,r=-INF,0
  while r-l>1:
    m=(l+r)//2
    s=0
    for i in range(tp):
      i=la[tr+i]
      li,ri=-1,tm
      while ri-li>1:
        mi=(li+ri)//2
        if i*la[mi]<m: li=mi
        else: ri=mi
      s+=ri
    if s<k: l=m
    else: r=m
  print(l)
else:
  l,r=0,INF
  while r-l>1:
    m=(l+r)//2
    s=0
    for i in range(tm):
      i=la[i]
      li,ri=-1,tm
      while ri-li>1:
        mi=(li+ri)//2
        if i*la[mi]<m: ri=mi
        else: li=mi
      s+=tm-ri
      if i*i<m: s-=1
    for i in range(tp):
      i=la[tr+i]
      li,ri=-1,tp
      while ri-li>1:
        mi=(li+ri)//2
        if i*la[tr+mi]<m: li=mi
        else: ri=mi
      s+=ri
      if i*i<m: s-=1
    if cm+cz+s//2<k: l=m
    else: r=m
  print(l)

### FIXED CODE ###

f=lambda:map(int,input().split())
n,k=f()
lm,lp=[],[]
for i in f():
  if i<0: lm.append(-i)
  else: lp.append(i)
lm.sort()
lp.sort()
cm=len(lm)
cp=len(lp)
def cnt(x):
  c=0
  if x<0:
    r=cp
    for i in lm:
      while r and i*lp[r-1]>=-x: r-=1
      c+=cp-r
    return c
  r=cm
  for i in lm:
    while r and i*lm[r-1]>x: r-=1
    c+=r
    if i*i<=x: c-=1
  r=cp
  for i in lp:
    while r and i*lp[r-1]>x: r-=1
    c+=r
    if i*i<=x: c-=1
  return cm*cp+c//2
INF=10**18+1
l,r=-INF,INF
while r-l>1:
  m=l+r>>1
  if cnt(m)<k: l=m
  else: r=m
print(r)
### BUGGY CODE ###

N,A,B=list(map(int,input().split()))
S=list(input())
t=0
for i in range(N):
 if S[i]=='a':
     if t<A+B:
         t=t+1
         print("Yes")
     else:
         print("No")
 elif S[i]=='b':
     if t<A+B and B>S[:i].count('b'):
         t=t+1
         print('Yes')
     else:
         print('No')
 else:
     print('No')

### FIXED CODE ###

N,A,B=list(map(int,input().split()))
S=list(input())
t=0
u=0
for i in range(N):
 if S[i]=='a':
     if t<A+B:
         t=t+1
         print("Yes")
     else:
         print("No")
 elif S[i]=='b':
     if t<A+B and B>u:
         t=t+1
         u=u+1
         print('Yes')
     else:
         print('No')
 else:
     print('No')
### BUGGY CODE ###

import sys
# input = sys.stdin.readline
S = list(input())
p = 10 ** 9 + 7
# p = 10 ** 18

A = AB = ABC = 0
Q = 0
for i, Si in enumerate(S):
    # print("#", A, AB, ABC)
    if Si == 'A':
        A = (A + 1 * (3 ** Q)) % p
    elif Si == 'B':
        AB = (AB + A) % p
    elif Si == 'C':
        ABC = (ABC + AB) % p
    else:
        ABC = (3 * ABC + AB) % p
        AB = (3 * AB + A) % p
        A = (3 * A + 1 * (3 ** Q)) % p
        Q += 1

print(ABC)

### FIXED CODE ###

# encoding: utf-8
S = input()

A = 0
C = S.count("C") # N
q = 0

q_max = S.count("?") # N

ABC = 0
div = 10 ** 9 + 7
B_base = 3 ** (q_max - 2) % div
q_base = 3 ** (q_max - 3) % div
for si in S: # N
    if si == "A": A += 1
    elif si == "C": C -= 1
    elif si == "B":
        # ABC = (ABC + (A * C) * (3 ** q_max)) % div
        # ABC = (ABC + (q * C) * (3 ** (q_max - 1))) % div
        # ABC = (ABC + (A * (q_max - q)) * (3 ** (q_max - 1))) % div
        # ABC = (ABC + (q * (q_max - q)) * (3 ** (q_max - 2))) % div
        ABC = (ABC + (3 * A + q) * (3 * C + q_max - q) * B_base) % div
    else: # "?"
        # ABC = (ABC + (A * C) * (3 ** (q_max - 1))) % div
        # ABC = (ABC + (q * C) * (3 ** (q_max - 2))) % div
        # ABC = (ABC + (A * (q_max - q - 1)) * (3 ** (q_max - 2))) % div
        # ABC = (ABC + (q * (q_max - q - 1)) * (3 ** (q_max - 3))) % div        
        ABC = (ABC + (3 * A + q) * (3 * C + q_max - q - 1) * q_base) % div
        q += 1
    # print(si, ABC)
    
print(int(ABC))
### BUGGY CODE ###

N, M = map(int, input().split())
lis = []
for _ in range(N):
  a, b = map(int, input().split())
  for l in range(b):
    lis.append(a)
lis.sort()
total = 0
for i in range(M):
  total = total + lis[i]
print(total)  

### FIXED CODE ###

N, M = map(int, input().split())
lis = []
for _ in range(N):
  a, b = map(int, input().split())
  lis.append((a, b))
def eval(data):
  return data[0]
lis.sort(key=eval)
total = 0
num = 0
mark = 0
for i in range(N):
  num = num + lis[i][1]
  total = total + lis[i][0]*lis[i][1]
  if num > M:
    mark = i
    total = total - lis[i][0]*lis[i][1]
    num = num - lis[i][1]
    break
total = total + (M - num)*lis[mark][0]
print(total)
### BUGGY CODE ###

n,q = map(int,input().split())
s = input()
l = []
r = []
tmp = ''
cnt = []
for i in range(q):
    _l,_r = [int(i) for i in input().split()]
    l.append(_l)
    r.append(_r)
for i in range(q):
    tmp = s[l[i]-1:r[i]]
    cnt.append(tmp.count('AC'))
for i in range(len(cnt)):
    print(cnt[i])


### FIXED CODE ###

import sys
input = sys.stdin.readline
n,q = map(int,input().split())
s = input()
t = [0] * (n+1)
for i in range(n):
    t[i+1] = t[i] + (1 if s[i:i+2]=='AC' else 0)
for i in range(q):
    l,r = map(int,input().split())
    print(t[r-1] - t[l-1])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15
Dy = (-1,0,1,0)
Dx = (0,1,0,-1)

from collections import deque,defaultdict,Counter
def main():
    H,W,K = map(int,input().split())
    sy,sx,gy,gx = map(int,input().split())
    sy -= 1; sx -= 1; gy -= 1;gx -= 1
    pond = [list(input()) for _ in range(H)]
    
    q = deque([(sy,sx)])
    dist = [[-1]*W for _ in range(H)]
    dist[sy][sx] = 0
    while q:
        oy,ox = q.popleft()
        for dy,dx in zip(Dy,Dx):
            y,x = oy,ox
            for _ in range(K):
                y += dy
                x += dx
                if y < 0 or y >= H:
                    break
                if x < 0 or x >= W:
                    break
                if pond[y][x] == '@':
                    break
                if dist[y][x] >= 0:
                    continue
                dist[y][x] = dist[oy][ox] + 1
                q.append((y,x))
                if (y,x) == (gy,gx):
                    break
    print(dist[gy][gx] if dist[gy][gx] >= 0 else -1) 
if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15
Dy = (-1,0,1,0)
Dx = (0,1,0,-1)

from collections import deque,defaultdict,Counter
def main():
    H,W,K = map(int,input().split())
    sy,sx,gy,gx = map(int,input().split())
    sy -= 1; sx -= 1; gy -= 1;gx -= 1
    pond = [list(input()) for _ in range(H)]
    
    q = deque([(sy,sx)])
    dist = [[-1]*W for _ in range(H)]
    dist[sy][sx] = 0
    while q:
        ny,nx = q.popleft()
        for dy,dx in zip(Dy,Dx):
            y,x = ny,nx
            for _ in range(K):
                y += dy
                x += dx
                if y < 0 or y >= H:
                    break
                if x < 0 or x >= W:
                    break
                if pond[y][x] == '@':
                    break
                if dist[y][x] >= 0 and dist[y][x] <= dist[ny][nx]:
                    break
                if dist[y][x] < 0:
                    dist[y][x] = dist[ny][nx] + 1
                    q.append((y,x))
                if (y,x) == (gy,gx):
                    break
    print(dist[gy][gx] if dist[gy][gx] >= 0 else -1) 
if __name__ == '__main__':
    main()
### BUGGY CODE ###

from heapq import heappush, heappop
import itertools
sx,sy,gx,gy=map(int,input().split())
n=int(input())
g = [[] for i in range(n+2)]
data=[(sx+sy*1j,0)]
for i in range(n):
    a,b,c=map(int,input().split())
    data.append((a+b*1j,c))
data.append((gx+gy*1j,0))

for i in range(n+2):
    for j in range(i+1,n+2):
        tmp=abs(data[i][0]-data[j][0])-data[i][1]-data[j][1]
        g[i].append((tmp,j))
        g[j].append((tmp,i))

dist=[2828427127 for i in range(n+2)]
visited=[False for i in range(n+2)]
dist[0]=0
que=[]
heappush(que,(0,0))
while que:
    c,v=heappop(que)
    if visited[v]:
        continue
    visited[v]=True
    for x in g[v]:
        if visited[x[1]]:
            continue
        tmp=x[0]+c if not x[0]<0 else c
        if tmp<dist[x[1]]:
            dist[x[1]]=tmp
            heappush(que,(tmp,x[1]))
print(dist[n+1])


### FIXED CODE ###

from heapq import heappush, heappop
sx,sy,gx,gy=map(int,input().split())
n=int(input())
g = [[] for i in range(n+2)]
data=[(sx+sy*1j,0)]
for i in range(n):
    a,b,c=map(int,input().split())
    data.append((a+b*1j,c))
data.append((gx+gy*1j,0))

for i in range(n+2):
    for j in range(i+1,n+2):
        tmp=abs(data[i][0]-data[j][0])-data[i][1]-data[j][1]
        g[i].append((tmp,j))
        g[j].append((tmp,i))

dist=[2828427127 for i in range(n+2)]
visited=[False for i in range(n+2)]
dist[0]=0
que=[]
heappush(que,(0,0))

while que:
    c,v=heappop(que)
    if visited[v]:
        continue
    visited[v]=True
    for x in g[v]:
        if visited[x[1]]:
            continue
        tmp=x[0]+c if not x[0]<0 else c
        if tmp<dist[x[1]]:
            dist[x[1]]=tmp
            heappush(que,(tmp,x[1]))
print(dist[n+1])
### BUGGY CODE ###

# coding: utf-8
import array, bisect, collections, heapq, itertools, math, random, re, string, sys, time
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7
 
 
def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def IAI(LINE): return [ILI() for __ in range(LINE)]
def IDI(): return {key: value for key, value in ILI()}
 
 
def solve(N, W, w, v):
    dp = [[-1] * (N + 1) for __ in range(W + 1)]
    def throw(weight=W, num=0):
        if dp[weight][num] != -1:
            return dp[weight][num]
        
        if num == N:
            return 0
        elif weight < w[num]:
            res = throw(weight, num + 1)
        else:
            res = max(throw(weight, num + 1), throw(weight - w[num], num + 1) + v[num])
        
        dp[weight][num] = res
        return res
    
    ans = throw()
    return ans
    
 
def main():
    N, W = ILI()
    w, v = [], []
    for __ in range(N):
        x, y = ILI()
        w.append(x)
        v.append(y)
    print(solve(N, W, w, v))
 
 
if __name__ == "__main__":
    main()

### FIXED CODE ###

# coding: utf-8
import array, bisect, collections, heapq, itertools, math, random, re, string, sys, time

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7


def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def IAI(LINE): return [ILI() for __ in range(LINE)]
def IDI(): return {key: value for key, value in ILI()}


def solve(N, W, w_v):
    memo = collections.defaultdict(int)
    memo[0] = 0
    for w, v in w_v:
        for w_memo, v_memo in sorted(list(memo.items()), key=lambda x: -x[0]):
            if w + w_memo > W:
                continue
            if memo[w + w_memo] < v_memo + v:
                memo[w + w_memo] = v_memo + v

    return max(memo.values())


def main():
    N, W = ILI()
    w_v = IAI(N)
    print(solve(N, W, w_v))


if __name__ == "__main__":
    main()
### BUGGY CODE ###

X = int(input())

c = []
for i in range(1, X+1):
    if i != 0 and X % i == 0:
        c.append([i, X//i])

for x1, x2 in c:
    for b in range(-1000, 1000):
        if b != 0:
            if (x1+b)**3 * (2*b+x1) + (b**2) * (x1**2 + 3*x1*b+3*(b**2)) == x2:
                print(x1+b, b)
                break

### FIXED CODE ###

X = int(input())

c = []
for i in range(1, int((X+1)**(1/2))+1):
    if i != 0 and X % i == 0:
        c.append([i, X//i])

for x1, x2 in c:
    for b in range(-1000, 1000):
        if b != 0:
            if (x1+b)**3 * (2*b+x1) + (b**2) * (x1**2 + 3*x1*b+3*(b**2)) == x2:
                print(x1+b, b)
                break
### BUGGY CODE ###

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations
    #from itertools import accumulate, product, permutations
    from math import floor, ceil

    #mod = 1000000007

    n,q = map(int, input().split())
    s = input()
    l = [0]*len(s)
    for i in range(len(s)):
        if s[i:i+2]=='AC':
            l[i]=1

    for _ in range(q):
        a, b = map(int, input().split())
        print(sum(l[a-1:b-1]))


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations
    #from itertools import accumulate, product, permutations
    from math import floor, ceil

    #mod = 1000000007

    n,q = map(int, input().split())
    s = input()
    l = [0]*(n+1)
    for i in range(n):
        if s[i:i+2]=='AC':
            l[i+1]=l[i] + 1
        else:
            l[i+1]=l[i]

    for _ in range(q):
        a, b = map(int, input().split())
        print(l[b-1]-l[a-1])


if __name__ == '__main__':
    main()
### BUGGY CODE ###

N=int(input())
dictionary={}
count=0
for i in range(N):
    s=str(sorted(input()))
    if s in dictionary:
        dictionary[s]+=1
        count+=dictionary[s]
    else:
        dictionary[s]=0
print(count)

### FIXED CODE ###

import collections
N = int(input())
A=[]
for i in range(N):
    x= str(sorted(input()))
    A.append(x)
B=collections.Counter(A)
ans = 0
for i in B.values():
    ans += i*(i-1)//2
print(ans)
### BUGGY CODE ###

N = int(input())
a = [int(input()) for _ in range(N)]
_a =[max(a[:i] + a[i+1:]) for i in range(N)]

for i in range(N):
  print(_a[i])
  

### FIXED CODE ###

N = int(input())
a = [int(input()) for _ in range(N)]
first = max(a)
f_id = a.index(max(a))
second = max(a[:f_id] + a[f_id+1:])

for i in range(N):
  if a[i] == first:
    print(second)
  else:
    print(first)
### BUGGY CODE ###

def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
n=int(input())
mod=1000000007
ans=0
sum=0
s=[int(n) for n in input().split()]
for i in range(0, n):
    k=s[i]
    if i==0:
        ans=k
    else:
        u=ans
        ans = ((u * k) // gcd(u, k))
for i in range(0, n):
    sum=(sum+ans//(s[i]))%mod
print(sum)


### FIXED CODE ###

n=int(input())
a=[int(j) for j in input().split()]
t=1
mod=10**9+7
from fractions import*
for i in a:
    t*=i//gcd(t,i)
print(sum(t//i for i in a)%mod)
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(n):
    if i%2==1:
        b=[a[i]]+b
    else:
        b+=[a[i]]
if n%2==0:
    print(*b)
else:
    print(*b[::-1])

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=a[1::2][::-1]+a[::2]
if n%2==0:
    print(*b)
else:
    print(*b[::-1])
### BUGGY CODE ###

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

dp = [0 for _ in range(n+1)]

def ans(dp, n, m) -> list:
    if m == 0:
        return [0, 0]

    answerd = []
    ac = 0
    wa = 0
    i = 0
    while i < m:
        q, r = input().split()
        q = int(q)

        if q in answerd:
            pass
        elif r == 'WA':
            dp[q] += 1
        elif r == 'AC':
            ac += 1
            wa += dp[q]
            answerd.append(q)

        i += 1

    return [ac, wa]

a = ans(dp, n, m)

print(*a)

### FIXED CODE ###

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

dp = [0 for _ in range(n+1)]

def ans(dp, n, m) -> list:
    if m == 0:
        return [0, 0]

    ac = 0
    wa = 0
    i = 0
    while i < m:
        q, r = input().split()
        q = int(q)

        if dp[q] == None:
            pass
        elif r == 'WA':
            dp[q] += 1
        elif r == 'AC':
            ac += 1
            wa += dp[q]
            dp[q] = None

        i += 1

    return [ac, wa]

a = ans(dp, n, m)

print(*a)
### BUGGY CODE ###

N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
import bisect
idx=bisect.bisect_left(A,K)
ans=0
A=A[:idx]
N=idx
from collections import defaultdict
def search(i):
    dp=defaultdict(int)
    dp[0]=1
    ai=A[i]
    for j in range(N):
        dpc=dp.copy()
        if i==j:continue
        for k in dpc.keys():
            if k+A[j]>=K or dpc[k]==0:
                continue
            if k+A[j]>=K-ai:
                return True
            dp[k+A[j]]=1
    return False
MinTrue=N
MaxFalse=-1
check=(1,2)
while MinTrue-MaxFalse>1:
    idx=N*check[0]//check[1]
    if search(idx):
        MinTrue=min(MinTrue,idx)
        check=(check[0]*2-1,check[1]*2)
    else:
        MaxFalse=max(MaxFalse,idx)
        check=(check[0]*2+1,check[1]*2)
print(MinTrue)

### FIXED CODE ###

N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
S=0
ans=0
for a in A:
    if S+a<K:
        S+=a
        ans+=1
    else:ans=0
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

INF = 10 ** 9 + 7
N = int(input())
a = list(map(int, input().split()))
cnt = [0] * 60
for i in a:
    for j in range(60):
        tmp = i >> j
        if tmp != 0:
            cnt[j] += tmp % 2
        else:
            break
ans = 0
for b in range(60):
    ans += cnt[b] * (N - cnt[b]) << b
    ans %= INF
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

INF = 10 ** 9 + 7
N = int(input())
a = list(map(int, input().split()))
cnt = [0] * 60
for i in a:
    for j in range(60):
        cnt[j] += (i >> j) % 2
ans = 0
for b in range(60):
    ans += cnt[b] * (N - cnt[b]) << b
    ans %= INF
print(ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = 1
flag =0
for i  in a:
    ans = ans*i
if ans >10**18:
 	print(-1)
else:
    print(ans)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = 1
flag =0
for i  in a:
    if i == 0:
        flag=2
        break
if flag!= 2:
    for i  in a:
        ans = ans*i
        if ans > 10 ** 18:
            flag=1
            break


if flag==1:
    print(-1)
elif flag ==2:
    print(0)
else:
    print(ans)
### BUGGY CODE ###

n = int(input())
s = list(input())

l = [0]*n
l[n-1] = s[:n-1].count('W')
for i in range(n-1):
  w_side = s[:i].count('W')
  e_side = s[i+1:].count('E')
  l[i] = w_side + e_side
  
print(min(l))


### FIXED CODE ###

import sys

n, s = sys.stdin.read().split()

def main():
    cnt = s.count('E')
    cur = 'E'
    res = [cnt]
    for c in s:
        if cur == 'W': cnt += 1
        if c == 'E': cnt -= 1
        res.append(cnt)
        cur = c
    print(min(res))
    
if __name__ ==  '__main__':
    main()
### BUGGY CODE ###

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

a=[int(input()) for i in range(q)]
points=[k for i in range(n)]
for j in a:
    points[j-1]=points[j-1]+1
    for k in range(n):
        points[k]-=1
        
for ans in points:
    if ans>0:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

import collections
n,k,q=map(int,input().split())
a=[int(input()) for i in range(q)]
points=['No' for i in range(n)]
c = collections.Counter(a)

zone=k-q


for v in c:
    
    if zone+c.get(v)>=1:
        points[v-1]='Yes'
if zone>=1:
    for h in points:
        print('Yes')
else:
    for h in points:
        print(h)
### BUGGY CODE ###

import fractions
K=int(input())
ans=0
 
for n in range(1,K+1):
    for m in range(1,K+1):
      gcd1=fractions.gcd(n,m)
      for l in range(1,K+1):
            gcd2=fractions.gcd(gcd1,l)
            
            ans+=gcd2
   
print(ans)

### FIXED CODE ###


import math
K=int(input())
ans=0
A=0

for n in range(1,K+1):
    for m in range(1,K+1):
        x=math.gcd(n,m)
        for l in range(1,K+1):
            A=math.gcd(x,l)    
            ans+=A
            
print(ans)