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

import bisect


def make_divisors(n):
    lower_divisors, upper_divisors = set(), set()
    tmp = 1
    while tmp * tmp <= n:
        if n % tmp == 0:
            lower_divisors.add(tmp)
            if tmp != n // tmp:
                upper_divisors.add(n // tmp)
        tmp += 1
    return lower_divisors | upper_divisors


n = int(input())
*A, = map(int, input().split())
A.sort()
setA = set(A)
cnt = 0
for i, a in enumerate(A):
    if bisect.bisect_right(A, a) - bisect.bisect_left(A, a) != 1:
        cnt += 1
        continue
    X = make_divisors(a)
    if len(X & setA) != 1:
        cnt += 1
print(n - cnt)


### FIXED CODE ###

n = int(input())
*A, = map(int, input().split())
maxA = max(A)
# C[a] = A内のaの個数
C = {a: 0 for a in range(1, maxA + 1)}
for a in A:
    C[a] += 1
# D[a]=1: Aにaより小さいaの約数が存在する
D = {a: 0 for a in range(1, maxA + 1)}
for a in A:
    if C[a] > 0:
        tmp = 2
        while a * tmp <= maxA:
            D[a * tmp] = 1
            tmp += 1
ans = 0
for a in A:
    if C[a] == 1 and D[a] == 0:
        ans += 1
print(ans)
### BUGGY CODE ###

N, M, Q = list(map(int, input().strip().split()))
pattern_list = []
shortest = 0
for _ in range(Q):
	pattern = tuple(map(int, input().strip().split()))
	shortest = max([shortest, pattern[0], pattern[1]])
	pattern_list.append(pattern)

def create(N,M):
	S = [[] for _ in range(N+1)]
	for m in range(1,M+1):
		S[1].append([m])
	for n in range(1,N):
		for s in S[n]:
			Max = s[-1]
			for i in range(Max, M+1):
				S[n+1].append(s+[i])
	return S

highest = 0
for n, n_letters in enumerate(create(N, M)):
	if n < shortest: continue
	for letters in n_letters:
		point = 0
		for a,b,c,d in pattern_list:
			if int(c) == letters[int(b-1)]-letters[int(a-1)]:
				point += d
		highest = max([highest, point])

print(highest)

### FIXED CODE ###

N, M, Q = list(map(int, input().strip().split()))
pattern_list = []
for _ in range(Q):
    pattern = tuple(map(int, input().strip().split()))
    pattern_list.append(pattern)

def create(N,M):
    S = [[] for _ in range(N+1)]
    for m in range(1,M+1):
        S[1].append([m])
    for n in range(1,N):
        for s in S[n]:
            Max = s[-1]
            for i in range(Max, M+1):
                S[n+1].append(s+[i])
    return S

highest = 0
for letters in create(N,M)[N]:
    point = 0
    for a,b,c,d in pattern_list:
        if c == letters[b-1]-letters[a-1]:
            point += d
    highest = max([highest, point])

print(highest)
### BUGGY CODE ###

K, S = map(int,input().split())

c = 0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if i + j + k == S:
                c += 1
                break


print(c)

### FIXED CODE ###

k, s = map(int, input().split())
c = 0

for i in range(k+1):
    for j in range(k+1):
        z = s - i - j
        if z >= 0 and z <= k:
            c += 1
print(c)
### BUGGY CODE ###

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

l=[]
while len(l) < n:
    for i in range(a):
        if len(l) < n:
            l.append('b')
    for j in range(b):
        if len(l) < n:
            l.append('r')

print(l.count('b'))

### FIXED CODE ###

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

q=n//(a+b)
mod=n%(a+b)
ans=a*q
if a < mod:
    ans+=a
else:
    ans+=mod
print(ans)
### BUGGY CODE ###

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


def cf(x1, x2):
    cf = []
    for i in range(1, min(x1, x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf


c = cf(a, b)
len_c = len(c)
d = []
f = 0
for i in range(len(c)):
    for j in range(1, i-f):
        if c[i-f] % c[j] == 0:
            d.append(c[i-f])
            del(c[i-f])
            f += 1
            break
print(len_c - len(d))

### FIXED CODE ###

import math


def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct


a, b = map(int, input().split())
c = gcd(a, b)
d = factorize(c)
print(len(set(d))+1)
### BUGGY CODE ###

mod=10**9+7
n,k=map(int,raw_input().split())
a=map(int,raw_input().split())
dp=[[[0]*(1<<8) for _ in xrange(n+1)] for _ in xrange(n+1)]
for i in xrange(n):
    dp[i+1][1][a[i]]=1
for i in xrange(n):
    for j in xrange(n):
        for l in xrange(1<<8):
            dp[i+1][j+1][a[i]^l]+=(j+1)*dp[i][j][l]%mod
            dp[i+1][j][l]+=dp[i][j][l]%mod
ans=0
for j in xrange(1,n+1):
    ans=(ans+dp[n][j][k])%mod
print(ans)

### FIXED CODE ###

mod=10**9+7
n,k=map(int,raw_input().split())
a=map(int,raw_input().split())
dp=[[[0]*(1<<8) for _ in xrange(n+1)] for _ in xrange(n+1)]
for i in xrange(n):
    dp[i+1][1][a[i]]=1
for i in xrange(n):
    for j in xrange(n):
        for l in xrange(1<<8):
            dp[i+1][j+1][a[i]^l]+=(j+1)*dp[i][j][l]%mod
            dp[i+1][j][l]+=dp[i][j][l]%mod
ans=0
for j in xrange(1,n+1):
    ans=(ans+dp[n][j][k])%mod
print(ans)
### BUGGY CODE ###

import math
k=int(input())
ans=0
for i in range(1,k+1):
    for j in range(1,k+1):
        for l in range(1,k+1):
            ans+=math.gcd(math.gcd(i,j),l)
print(ans)

### FIXED CODE ###

import math
import collections
k=int(input())
ans=0
a=[]
for i in range(1,k+1):
    for j in range(1,k+1):
        a.append(math.gcd(i,j))
a=collections.Counter(a)
for key,value in a.items():
    for i in range(1,k+1):
        ans+=math.gcd(i,key)*value
print(ans)
### BUGGY CODE ###

# import numpy as np
# import scipy as sp
# print(a,b,c,sep="") # 半角スペースなしで出力(abc)
# n=int(input())  #数値入力 「N」だけの入力のとき
# a,b=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
# c=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
# s=[list(map(int,list(input()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
# import sys ; sys.exit() # プログラム終了
# from copy import deepcopy ; b=deepcopy(a)
# chr(ord('a') + 1)
# s.sort(key=lambda x: x[1], reverse=False) # 2番目の要素で昇順にソート（Trueなら降順）
#
from copy import deepcopy
from collections import deque

d = deque()
h, w = map(int, input().split())
s = [list(map(str, list(input()))) for i in range(h)]
used = [[True for j in range(w)] for i in range(h)]
for i in range(h):
    for j in range(w):
        if (s[i][j] == "#"):
            d.append([i, j])

ans = -1
while (d):
    tmp = deque()
    while(d):
        i, j = d.popleft()
        used[i][j] = False

        if i+1 < h and used[i+1][j]:
            s[i+1][j] = "#"
            tmp.append([i+1, j])

        if i-1 >= 0 and used[i-1][j]:
            s[i-1][j] = "#"
            tmp.append([i-1, j])

        if j+1 < w and used[i][j+1]:
            s[i][j+1] = "#"
            tmp.append([i, j+1])

        if j-1 >= 0 and used[i][j-1]:
            s[i][j-1] = "#"
            tmp.append([i, j-1])

    d = deepcopy(tmp)
    ans += 1

print(ans)


### FIXED CODE ###

# import numpy as np
# import scipy as sp
# print(a,b,c,sep="") # 半角スペースなしで出力(abc)
# n=int(input())  #数値入力 「N」だけの入力のとき
# a,b=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
# c=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
# s=[list(map(int,list(input()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
# import sys ; sys.exit() # プログラム終了
# from copy import deepcopy ; b=deepcopy(a)
# chr(ord('a') + 1)
# s.sort(key=lambda x: x[1], reverse=False) # 2番目の要素で昇順にソート（Trueなら降順）
#
from copy import deepcopy
from collections import deque

d = deque()
h, w = map(int, input().split())
s = [list(map(str, list(input()))) for i in range(h)]
used = [[True for j in range(w)] for i in range(h)]
# used = [[True]*w]*h
for i in range(h):
    for j in range(w):
        if (s[i][j] == "#"):
            d.append([i, j])
            used[i][j] = False


ans = -1
while (d):

    tmp = deque()
    while(d):
        i, j = d.popleft()

        if i+1 < h and used[i+1][j]:
            s[i+1][j] = "#"
            tmp.append([i+1, j])
            used[i+1][j] = False

        if i-1 >= 0 and used[i-1][j]:
            s[i-1][j] = "#"
            tmp.append([i-1, j])
            used[i-1][j] = False

        if j+1 < w and used[i][j+1]:
            s[i][j+1] = "#"
            tmp.append([i, j+1])
            used[i][j+1] = False

        if j-1 >= 0 and used[i][j-1]:
            s[i][j-1] = "#"
            tmp.append([i, j-1])
            used[i][j-1] = False

    d = tmp
    ans += 1

print(ans)
### BUGGY CODE ###

n=int(input())
s=input()
r=[]
g=[]
b=[]
cnt=0
for i in range(n):
  if s[i]=="R":
    r.append(i)
  elif s[i]=="G":
    g.append(i)
  else:
    b.append(i)
for i in r:
  for j in range(i,n):
    if s[j]=="G":
      if 2*j-i<=n-1:
        if s[2*j-i]=="B":
          cnt+=(sum(x>j for x in b)-1)
        elif s[2*j-i]!="B":
          cnt+=sum(x>j for x in b)
      else:
        cnt+=sum(x>j for x in b)
    elif s[j]=="B":
      if 2*j-i<=n-1:
        if s[2*j-i]=="G":
          cnt+=(sum(x>j for x in g)-1)
        elif s[2*j-i]!="G":
          cnt+=sum(x>j for x in g)
      else:
        cnt+=sum(x>j for x in g)

for i in g:
  for j in range(i,n):
    if s[j]=="R":
      if 2*j-i<=n-1:
        if s[2*j-i]=="B":
          cnt+=(sum(x>j for x in b)-1)
        elif s[2*j-i]!="B":
          cnt+=sum(x>j for x in b)
      else:
        cnt+=sum(x>j for x in b)
    elif s[j]=="B":
      if 2*j-i<=n-1:
        if s[2*j-i]=="R":
          cnt+=(sum(x>j for x in r)-1)
        elif s[2*j-i]!="R":
          cnt+=sum(x>j for x in r)
      else:
        cnt+=sum(x>j for x in r)

for i in b:
  for j in range(i,n):
    if s[j]=="G":
      if 2*j-i<=n-1:
        if s[2*j-i]=="R":
          cnt+=(sum(x>j for x in r)-1)
        elif s[2*j-i]!="R":
          cnt+=sum(x>j for x in r)
      else:
        cnt+=sum(x>j for x in r)
    elif s[j]=="R":
      if 2*j-i<=n-1:
        if s[2*j-i]=="G":
          cnt+=(sum(x>j for x in g)-1)
        elif s[2*j-i]!="G":
          cnt+=sum(x>j for x in g)
      else:
        cnt+=sum(x>j for x in g)
print(cnt)

### FIXED CODE ###

n=int(input())
s=input()
t=s.count("R")*s.count("G")*s.count("B")
cnt=0
for i in range(n):
  for j in range(i,n):
    if 2*j-i>=n:
      break
    else:
      if s[i]!=s[j]!=s[2*j-i]!=s[i]:
        cnt+=1
print(t-cnt)
### BUGGY CODE ###

import sys
import math
mod = 1000000007

n = int(input())
ab = {}
for i in range(n):
    a,b = map(int,sys.stdin.readline().rstrip().split())
    if a == 0 and b == 0:
        pass
    elif a == 0:
        b = 1
    else:
        gcd = math.gcd(a,b)
        a //= gcd
        b //= gcd
        if a < 0:
            a = -a
            b = -b
    ab.setdefault((a,b),0)
    ab[(a,b)]+=1
ans = 0
pairs=[]
s = list(set(ab.keys()))
for i in ab:
    a = i[0];b = i[1]
    if a == 0 and b == 0:
        ans = ab[(0,0)]
        n -= ans
    else:
        if (-b, a) in s:
            pairs.append([ab[(a,b)],ab[(-b,a)]])
select = 1
for pair in pairs:
    select*= (pow(2,pair[0],mod) + pow(2,pair[1],mod) -1)
    n -= (pair[0]+pair[1])
all_ans = (pow(2,n,mod) * select) % mod + ans -1
all_ans %= mod
print(all_ans)

### FIXED CODE ###

import math
 
n = int(input())
mod = 10 ** 9 + 7
 
ab = {}
for i in range(n):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        pass
    elif a == 0:
        b = 1
    else:
        gcd = math.gcd(a, b)
        a //= gcd
        b //= gcd
        if a < 0:
            a, b = -a, -b
    num = (a, b)
    ab.setdefault(num, 0)
    ab[num] += 1
ans = 0
if (0, 0) in ab.keys():
    temp2 = ab[(0, 0)]
    ans += temp2
    n -= temp2
s = set(ab.keys())
pairs = []
for i in ab.keys():
    if i == (0, 0):
        continue
    else:
        a, b = i[0], i[1]
        if (-b, a) in s:
            pairs.append([ab[(a, b)], ab[(-b, a)]])
temp3 = 1
for i in range(len(pairs)):
    num2 = pairs[i][0]
    num3 = pairs[i][1]
    temp3 *= (pow(2, num2, mod) + pow(2, num3, mod) - 1)
    n = n- num2 - num3
    temp3 %= mod
temp3 *= pow(2, n, mod)
temp3 -= 1
temp3 %= mod
ans += temp3
ans %= mod
print(ans)
### BUGGY CODE ###

N= int(input())
S= [s for s in input()]
correct = ["RGB","RBG","GBR","GRB","BRG","BGR"]

cnt = 0
for i in range(N):
	for j in range(i+1,N):
		for k in range(j+1,N):
			if (j-i)!=(k-j):
				if "%s%s%s"%(S[i],S[j],S[k]) in correct:
					cnt+=1

print(cnt)
					



### FIXED CODE ###

N=int(input())
S=input()

ans = S.count("R")*S.count("G")*S.count("B")

for i in range(N):
	for j in range(N-i):
		if i+2*j>=N:
			break
		elif S[i]!=S[i+j] and S[i]!=S[i+2*j] and S[i+j]!=S[i+2*j]:
			ans-=1
print(ans)
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
ans=[]
for i in range(len(A)):
    if A[i] in ans:
        print("NO")
        break
    else:
        ans.append(A[i])
else:
    print("YES")

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
if len(set(A))==len(A):
    print('YES')
else:
    print('NO')
### BUGGY CODE ###

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

### FIXED CODE ###

import sys

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

if 0 in A:
    print(0)
    sys.exit();

ans = 1
for a in sorted(A, reverse=True):
    ans *= a
    if ans > 10**18:
        print(-1)
        break
else:
    print(ans)
### BUGGY CODE ###

N = int(input())
S = list(input())
R = []
G = []
B = []
for i in range(N):
    if S[i] == 'R':
        R.append(i + 1)
    elif S[i] == 'G':
        G.append(i + 1)
    else:
        B.append(i + 1)

ans = 0
for r in R:
    for g in G:
        for b in B:
            if abs(r - g) == abs(r - b):
                pass
            elif abs(r - g) == abs(g - b):
                pass
            elif abs(r - b) == abs(g - b):
                pass
            else:
                ans += 1

print(ans)


### FIXED CODE ###

from sys import stdin

N = int(stdin.readline())
S = list(input())
R = set()
G = set()
B = set()
for i, s in enumerate(S, 1):
    if s == 'R':
        R.add(i)
    elif s == 'G':
        G.add(i)
    else:
        B.add(i)

b = len(B)
ans = 0
for r in R:
    for g in G:
        M = max(r, g)
        m = min(r, g)
        if 2 * m - M in B:
            ans -= 1
        if 2 * M - m in B:
            ans -= 1
        if (M + m) / 2 in B:
            ans -= 1
        ans += b

print(ans)
### BUGGY CODE ###

#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_B&lang=jp
def merge(l,r):
    global count
    l_index = 0
    r_index = 0
    merge_list = []
    l.append(pow(10,9) + 1)
    r.append(pow(10,9) + 1)

    for k in range(len(l) + len(r) - 2):
        count += 1
        if l[l_index] < r[r_index]:
            merge_list.append(l[l_index])
            l_index += 1
        else:
            merge_list.append(r[r_index])
            r_index += 1

    return merge_list
    
def merge_sort(target_list):
    if len(target_list) == 1:
        return target_list
    
    mid = int(len(target_list) / 2)
    
    r = merge_sort(target_list[mid:])
    l = merge_sort(target_list[:mid])
    
    return merge(l, r)
    
if __name__ == "__main__":
    l = input()
    target_list = [int(a) for a in input().split()]
    global count
    count = 0
    print(" ".join([str(n) for n in merge_sort(target_list)]))
    print(count)

### FIXED CODE ###

#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_B&lang=jp
sentinel = pow(10,9) + 1
def merge(target_list, left_index, mid_index,right_index):
    
    l = target_list[left_index:mid_index] + [sentinel]
    r = target_list[mid_index:right_index] + [sentinel]
    l_target, r_target, count = 0, 0, 0
    #print(left_index, right_index, mid_index, l,r)
    for k in range(left_index, right_index):
        if l[l_target] < r[r_target]:
            target_list[k] = l[l_target]
            l_target += 1
        else:
            target_list[k] = r[r_target]
            r_target += 1

    return l_target + r_target
    #print(target_list)
            
def merge_sort(target_list, left_index, right_index):
    count = 0
    if left_index + 1 < right_index:
        mid_index = (left_index + right_index) // 2

        count += merge_sort(target_list, left_index, mid_index)
        count += merge_sort(target_list, mid_index, right_index)
        count += merge(target_list, left_index, mid_index,right_index)
        
    return count
if __name__ == "__main__":
    l = input()
    target_list = [int(a) for a in input().split()]
    count = merge_sort(target_list, 0, len(target_list))
    print(" ".join([str(n) for n in target_list]))
    print(count)
### BUGGY CODE ###

def main():
    import sys
    from collections import Counter

    input = sys.stdin.readline

    s = int(input())
    li = []
    f = 0
    mi = 0
    li_append = li.append

    cm = {}
    for i in range(1,2*(10 ** 5)):
        cm[i] = i * (i - 1) // 2
    cm[0] = 0
    num_old = -1



    for i in range(1, len(str(s))+1):
        num = s % (10 ** i)
        li_append(int(num) % 2019)
        if num_old == num:
            f += 1
        else:
            mi += cm[f+1]
            f = 0
        num_old = num

    co = Counter(li)
    co_1 = Counter(co.values())
    ans_1 = 0

    for x in co_1.keys():
        if x != 1:
            ans_1 += cm[x]* co_1[x]
    ans2 = 0
    if 0 in co:
        ans2 = co[0]
    print(ans_1 + ans2 - mi)

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    import sys
    from collections import defaultdict
    dic = defaultdict(int)

    input = sys.stdin.readline

    s = str(input().rstrip())
    m = 0
    before_m = 0.1

    for i in range(1, len(s) + 1):
        before_m = int(before_m*10)%2019
        m_ad = (int(s[-i]) * before_m) % 2019
        m = (m_ad + m) % 2019
        dic[m] += 1

    ans1 = 0

    for x in dic.values():
        if x > 1:
            ans1 += x * (x - 1) // 2
    ans2 = dic[0]

    print(ans1 + ans2)

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

import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
inp = sys.stdin.buffer.readline

import numpy as np
def resolve():
    N, K = map(int, inp().split())
    A = np.array(list(map(int, inp().split())), np.int64)

    for _ in range(K):
        imos_table = np.zeros(N + 1, np.int64)
        for i, a in enumerate(A):
            # 配列の個数を超えないように注意
            imos_table[max(i - a, 0)] += 1
            imos_table[min(i + a + 1, N)] -= 1
        A = np.cumsum(imos_table)[:-1]
        if np.all(A == N):
            print(*A)
            return
    else:
        print(*A)

if __name__ == "__main__":
    resolve()

### FIXED CODE ###


from itertools import accumulate
def resolve():

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

    for _ in range(K):
        imos_table = [0]*(N+1)
        for i, a in enumerate(A):
            # 配列の個数を超えないように注意
            imos_table[max(i - a, 0)] += 1
            imos_table[min(i + a + 1, N)] -= 1
        A = list(accumulate(imos_table))[:-1]
        if all([True if a == N else False for a in A]):
            print(*A)
            return
    else:
        print(*A)

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

def resolve():
    N,M=map(int,input().split())
    l, r = map(int, input().split())
    s = {i for i in range(l, r + 1)}
    for i in range(1,M):
        l,r=map(int,input().split())
        s=s&{i for i in range(l,r+1)}

    print(len(s))


resolve()

### FIXED CODE ###

# input = sys.stdin.readline

def resolve():
    N,M=map(int,input().split())
    l, r = map(int, input().split())
    for i in range(1,M):
        ll,rr=map(int,input().split())
        l=max(l,ll)
        r=min(r,rr)

    print(r-l+1 if r-l+1>=0 else 0)


resolve()
### BUGGY CODE ###

import functools
import operator

n = functools.partial(functools.reduce, operator.mul)
N,K = map(int,input().split())
A = list(map(int,input().split()))
# print(n(A))
S = [0] * K
s = 0
for i in range(K,len(A)+ 1):
    # print(i)
    # S.append(n(A[(i-1)-(K-1):i]))
    # print(n(A[(i-1)-(K-1):i]))
    if i == K:
        s = n(A[(i-1)-(K-1):i])
        continue
    else:
        if s < n(A[(i-1)-(K-1):i]):
            print("Yes")
            s = n(A[(i-1)-(K-1):i])
        else:
            print("No")
            s = n(A[(i-1)-(K-1):i])

        



### FIXED CODE ###

import functools
import operator

n = functools.partial(functools.reduce, operator.mul)
N,K = map(int,input().split())
A = list(map(int,input().split()))
# print(n(A))
for i in range(K,N):
    if A[i-K] < A[i]:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

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

h = []
v = []
for i in range(H):
    a = 0
    h.append([])
    v.append([])
    for j in range(W):
        if S[i][j] == '#':
            a = 0
        else:
            a += 1
        h[i].append(a)
    for j in range(W - 1, -1, -1):
        if S[i][j] == '#':
            a = 0
        else:
            if a == 0:
                a = h[i][j]
            h[i][j] = a

for i in range(W):
    a = 0
    for j in range(H):
        if S[j][i] == '#':
            a = 0
        else:
            a += 1
        v[j].append(a)
    for j in range(H - 1, -1, -1):
        if S[j][i] == '#':
            a = 0
        else:
            if a == 0:
                a = v[j][i]
            v[j][i] = a

ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, h[i][j] + v[i][j])
print(ans - 1)


### FIXED CODE ###

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

h = []
v = []
for i in range(H):
    a = 0
    h.append([])
    v.append([])
    for j in range(W):
        if S[i][j] == '#':
            a = 0
        else:
            a += 1
        h[i].append(a)
    for j in range(W - 1, -1, -1):
        if S[i][j] == '#':
            a = 0
        else:
            if a == 0:
                a = h[i][j]
            h[i][j] = a

for i in range(W):
    a = 0
    for j in range(H):
        if S[j][i] == '#':
            a = 0
        else:
            a += 1
        v[j].append(a)
    for j in range(H - 1, -1, -1):
        if S[j][i] == '#':
            a = 0
        else:
            if a == 0:
                a = v[j][i]
            v[j][i] = a

ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, h[i][j] + v[i][j])
print(ans - 1)
### BUGGY CODE ###

N = int(input())
A = (list(map(int, input().split(' '))))
D = [0]*(10**6+1)
ans = 0
for i in A:
    D[i] += 1
for i in A:
    flg = True
    if D[i] > 1:
        continue
    for j in range(1,int(i**0.5)+2):
        if not i%j:
            if D[j] and i != j:
                flg = False
                break
            if j != i//j and D[i//j] and i//j != i: 
                    flg = False
                    break
    if flg:
        ans += 1
print(ans)

### FIXED CODE ###

from collections import Counter
N = int(input())
A = Counter(list(map(int,input().split(' '))))
ans = 0
m = max(A.keys())
L = [1]*(10**6+1)
for i in sorted(A.keys()):
    if not L[i]:
        continue
    if A[i] == 1:
        ans += 1
    for j in range(i,m+1,i):
        L[j] = 0
print(ans)
### BUGGY CODE ###

import heapq
n, m = map(int, input().split())
A = list(map(int, input().split()))
heapq.heapify(A)
for _ in range(m):
  b, c = map(int, input().split())
  for i in range(b):
    t = heapq.heappop(A)
    heapq.heappush(A, max(c, t))
print(sum(A))

### FIXED CODE ###

from operator import itemgetter
n, m = map(int, input().split())
A = [(1, i) for i in map(int, input().split())]
BC = [ tuple(map(int, input().split())) for _ in range(m) ]
XY = sorted(A + BC, reverse=True, key=itemgetter(1))
c = n
now = 0
ans = 0
while c > 0 and now < n+m:
  x, y = XY[now]
  t = min(c, x)
  ans += y*t
  c -= t
  now += 1
print(ans)