Harryxun/stf_run huggingface dataset:
import math
from functools import reduce

def gcd(numbers):
    return reduce(math.gcd, numbers)

N, X = map(int, input().split())
cities = list(map(int, input().split()))

ans = gcd([abs(c - X) for c in cities])


print(ans)


### FIXED CODE ###

from functools import reduce

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

def gcd_list(numbers):
    return reduce(gcd, numbers)

N, X = map(int, input().split())
cities = list(map(int, input().split()))

ans = gcd_list([abs(c - X) for c in cities])

print(ans)
import numpy as np
li = list(map(int,input().split()))
A = li[0]
B = li[1]
print(np.max(A+B,A-B,A*B))

### FIXED CODE ###

import numpy as np
li = list(map(int,input().split()))
A = li[0]
B = li[1]
print(np.max([A+B,A-B,A*B]))
n,m=map(int,input().split())
s=[[]]*m
for i in range(m):
  s[i]=list(map(int,input().split()))
  del s[0]
p=list(map(int,input().split()))

ans=0
for bit in range(1<<n):
  x=0
  for i in range(m):
    y=0
    for j in s[i]:
      if bit&(1<<(j-1)):
        y+=1
    if y%2==p[i]%2:
      x+=1
  if x==m:
    ans+=1

print(ans)

### FIXED CODE ###

n,m=map(int,input().split())
s=[[]]*m
for i in range(m):
  s[i]=list(map(int,input().split()))
  del s[i][0]
p=list(map(int,input().split()))

ans=0
for bit in range(1<<n):
  x=0
  for i in range(m):
    y=0
    for j in s[i]:
      if bit&(1<<(j-1)):
        y+=1
    if y%2==p[i]%2:
      x+=1
  if x==m:
    ans+=1

print(ans)
list_str2 = [0 for i in range(26)]

while(1):
	list_str1 = list(input())
	print(list_str1)
	if list_str1 == []:
		break
	for i in range(len(list_str1)):
		if 97 <= ord(list_str1[i].lower()) <= 122:
			list_str2[ord(list_str1[i].lower())-97] += 1

for i in range(26):
	print(chr(97+i)+' : '+str(list_str2[i]))

### FIXED CODE ###

str1 = input()
print(str1.swapcase())
n,k=map(int,input().split())
s=list(map(str,input().split()))

s[k-1]=s[k-1].lower()

print(s)



### FIXED CODE ###

n,k=map(int,input().split())
s=input()
print(s[:k-1]+s[k-1].lower()+s[k:])
a = int(input())
b = int(input())

print(a*b)

### FIXED CODE ###

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

print(a*b)
k = input()
a = input()
b = input()

b = (b / k) * k

if a <= b :
    print("OK")
else:
    print("NG")



### FIXED CODE ###

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

x = a//k
y = b//k

if y - x == 0:
    if a%k == 0:
        print('OK')
    else:
        print('NG')
else:
    print('OK')
N, M = list(map(int, input().split()))
S = input()
T = input()

from fractions import gcd
# L = (N * M) // gcd(N, M)
L = int((N * M) / gcd(N, M))

L1 = [1]
L2 = [1]
for i in range(1, N):
    t = i * (L // N) + 1
    L1.append(t)

for i in range(1, M):
    t = i * (L // M) + 1
    L2.append(t)

LS = [None] * L
for i, li in enumerate(L1):
    ind = li-1
    LS[ind] = S[i]

ans = True
for i, li in enumerate(L2):
    ind = li-1
    if LS[ind] is not None:
        if LS[ind] != T[i]:
            ans = False

if ans:
    print(L)
else:
    print(-1)


# print(L1)
# print(L2)
# print(LS)

### FIXED CODE ###

from fractions import gcd

N, M = list(map(int, input().split()))
S = input()
T = input()

L = (N * M) // gcd(N, M)

L1 = [0]
L2 = [0]

from collections import Counter
c = Counter()

for i in range(1, N):
    t = i * (L // N) + 1
    L1.append(t-1)

for i in range(1, M):
    t = i * (L // M) + 1
    L2.append(t-1)


d = {}
for i, li in enumerate(L1):
    d[li] = S[i]

# print(d)

ans = True

for i, li in enumerate(L2):
    if not d.get(li):
        continue
    if d[li] != T[i]:
        ans = False

# print(L1)
# print(L2)
# print(common)
# print(dic)

if ans:
    print(L)
else:
    print(-1)
x=(H-h-)*(W-w)

### FIXED CODE ###

H,W=map(int,input().split())#標準入力を行う
h,w=map(int,input().split())#標準入力を行う
print((H-h)*(W-w))
n = int(input())
min_height = int(input())

height = []
for _ in range(n):
    height.append(int(input()))
height.sort(reverse=True)

cnt = 0
for h in height:
    if h < min_height:
        break
    cnt += 1
print(cnt)


### FIXED CODE ###

n, min_height = map(int, input().split())
height = list(map(int, input().split()))
height.sort(reverse=True)

cnt = 0
for h in height:
    if h < min_height:
        break
    cnt += 1
print(cnt)
S = raw_input()
if S[0] != S[1] && S[1] != S[2] && S[2] != S[0]:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

S = input()
if (S[0] == S[1]) or (S[1] == S[2]) or (S[2] == S[0]):
    print("No")
else:
    print("Yes")
N = int(input())
an = list(map(int, input().split()))
ans = 0
cnts = Counter(an)
for i in set(an):
    ans = max(ans, cnts[i] + cnts[i+1] + cnts[i-1])
print(ans)


### FIXED CODE ###

from collections import Counter
N = int(input())
an = list(map(int, input().split()))
ans = 0
cnts = Counter(an)
for i in set(an):
    ans = max(ans, cnts[i] + cnts[i+1] + cnts[i-1])
print(ans)
import math
a,b,n=(int(x) for x in input().split())
k =0
for x in range(0,n+1):
    c = math.floor((a*x)/b)-a*math.floor(x/b)
    if c  > k:
        k = c
print(k)

### FIXED CODE ###

k = int(input().strip())
a, b = input().strip().split()
a = int(a)
b = int(b)
c = 0
for i in range(1,1001):
    if i*k <= b and i*k >= a:
        print("OK")
        c = 1
        break
if c == 0:
    print("NG")
N = int(input())

x = N//1.08
if x * 1.08 == int(a):
  print(x)
  
else:
  print(':/')

### FIXED CODE ###

N = int(input())
ans=-1

for i in range(1,N+1):
       if int( i*1.08) == N:
            ans = i
            
if ans == -1:
    print(':(')
else:
    print(ans)
while 1
    x, y = map(int, raw_input().split())
    if x == 0 and y == 0:
        break
    print min(x, y) max(x, y)

### FIXED CODE ###

while 1:
    x, y = map(int, raw_input().split())
    if x == 0 and y == 0:
        break
    print min(x, y), 
    print max(x, y)
sols = []
while True:
    x = list(input().split())
    a = int(x[0])
    b = int(x[2])
    oprnd = x[1]
    if oprnd=="+":
        sols.append(a+b)
    elif oprnd=="-":
        sols.append(a-b)
    elif oprnd=="*":
        sols.append(a*b)
    elif oprnd=="/":
        sols.append(a/b)
    elif oprnd=="?":
        break
if len(sols==1):
    print(sols)
else:
    for i in len(sols):
        print(sols[i])

### FIXED CODE ###

import math
while True:
    x = input().split()
    a = int(x[0])
    b = int(x[2])
    oprnd = x[1]
    if oprnd=="+":
        print(a+b)
    elif oprnd=="-":
        print(a-b)
    elif oprnd=="*":
        print(a*b)
    elif oprnd=="/":
        print(math.floor(a/b))
    elif oprnd=="?":
        break
r=input()
print(r^2)

### FIXED CODE ###

r=int(input())
print(r*r)
def LI(): return [int(x) for x in input().split(" ")]
def LS(): return [str(x) for x in input().split(" ")]
def ItoS(L): return [str(x) for x in L]
def StoI(L): return [int(c) for c in L]


def solve():
    n, t = LI()
    T = LI()
    sentou = [0] * (T[-1] + t + 1)
    
    i = 0
    while i < len(T):
        sentou[T[i]] += 1
        sentou[T[i] + t] -= 1
        i += 1

    j = 1
    while j < len(sentou):
        sentou[j] += sentou[j - 1]
        j += 1

    print(n * t - (sum(sentou) - (sentou.count(1) + len(sentou) - sentou.count(1) - sentou.count(0))))

solve()

### FIXED CODE ###

def solve():
    A, B, C = list(map(str, input().split(" ")))
    if A[-1] == B[0] and B[-1] == C[0]:
        print("YES")
    else:
        print("NO")


solve()
import math
a, b, c, d = map(int, input().split())

def lcm(x,y):
	return (x*y)//math.gcd(x,y)
e = lcm(c,d)

f = (b//c + b//d) - b//e
g = ((a-1)//c + (a-1)//d) - (a-1)//e
print (b-a+1-(f-g))

### FIXED CODE ###

from fractions import gcd
a, b, c, d = map(int, input().split())
cnt = 0
def lcm(x, y):
	return (x*y) // gcd(x,y)
e = lcm(c,d)
x = b//c + b//d - b//e
y = (a-1)//c + (a-1)//d - (a-1)//e
print (b-a+1-(x-y))
import math

count = 0
m = 0
G = []

def insertion_sort(A, N, g):
    global count
    for i in range(g, N):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            count += 1
        A[j + g] = v

# h_(i+1) = 3h_i + 1 が最良の間隔 (らしい)
def shell_sort(A, N):
    global m, G
    m = math.floor(math.log(2*N+1, 3))
    G = [int((pow(3, i)-1)/2) for i in range(m, 0, -1)]

    for i in range(m):
        insertion_sort(A, N, G[i])


n = int(input())
A = [int(input()) for i in range(n)]
shell_sort(A, n)

print(m)
print(' '.join([str(h) for h in G]))
print(count)
for x in A:
    print(x)



### FIXED CODE ###

import math
import sys

count = 0
m = 0
G = []

def insertion_sort(A, N, g):
    global count
    for i in range(g, N):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            count += 1
        A[j + g] = v

# h_(i+1) = 3h_i + 1 が最良の間隔 (らしい)
def shell_sort(A, N):
    global m, G
    m = math.floor(math.log(2*N+1, 3))
    G = [int((pow(3, i)-1)/2) for i in range(m, 0, -1)]

    for i in range(m):
        insertion_sort(A, N, G[i])


n = int(input())
A = list(map(int, sys.stdin.readlines()))
shell_sort(A, n)

print(m)
print(' '.join([str(h) for h in G]))
print(count)
for x in A:
    print(x)
c = input()
d = input()

print("YES" c==c[::-1] and d==d[::-1] else "NO")


### FIXED CODE ###


c = input()
d = input()

print("YES" if c==d[::-1] else "NO")
from math import gcd

N, *A = map(int, open(0).read().split())

ans = A[0]
for v in A[1:]:
    ans = gcd(ans, v)
    
print(ans)

### FIXED CODE ###

def gcd(x, y):
  if x < y:
    a = y
    y = x
    x = a
  
  while y > 0:
    r = x % y
    x = y
    y = r
  
  return x

def main():
  N = int(input())
  a = list(map(int, input().split()))
  r = a[0]
  
  for i in range(1, len(a)):
    r = gcd(r, a[i])
    if r == 1:
      break

  print(r)
    

if __name__ == '__main__':
  main()
b = input()
a = ["A, T"]
c = ["C", "G"]
if b is a[0]:
  print(a[1])
if b is a[1]:
  print(a[0])
if b is c[0]:
  print(c[1])
if b is c[1]:
  print(c[0])

### FIXED CODE ###

b = input()
a = ["A", "T"]
c = ["C", "G"]
if b is a[0]:
  print(a[1])
if b is a[1]:
  print(a[0])
if b is c[0]:
  print(c[1])
if b is c[1]:
  print(c[0])
for i in range(len(S)-1):
    if S[i]==S[i+1]:
        idx=i        
idx=idx+1
sub_X=S[:idx]
sub_Y=S[idx:]
count=0
for str1 in sub_X:
    for str2 in sub_Y:
        if str1==str2:
            count+=1
            
print(int(count/2))

### FIXED CODE ###

N=int(input())
S=list(input())
a=[]

for i in range(1,N):
    x=set(S[:i-1:])
    y=set(S[i-1::])
    a.append(len(list(x&y)))
    
print(max(a))
a,b,c=map(int,input().split())
if a=b=c:
    print(1)
elif a=b!=c:
    print(2)
elif a!=b=c:
    print(2)
elif a=c!=b:
    print(2)
else:
    print(3)

### FIXED CODE ###

a=input().split()
a.sort()
cnt=0
while len(a)>0:
    i=a.count(a.pop(0))
    for j in range(i):
        a.pop(0)
    cnt+=1
print(cnt)
t="ABCDEFGHIJKLMNOPQRSTUVWXYZ"*2
n=int(input())
print(t[t.index(input())+n])

### FIXED CODE ###

n=int(input())
s=input()
t=list("ABCDEFGHIJKLMNOPQRSTUVWXYZ"*2)
a=""
for i in s:a+=t[t.index(i)+n]
print(a)
def main():
    n = int(input())
    ab_lst = [list(map(int, input().split())) for _ in range(n)]

    ba_lst = [0] * n
    for i in range(n):
        a = ab_lst[i][0]
        b = ab_lst[i][1]
        ba = [b, a]
        ba_lst[i] = ba
    ba_lst.sort()

    lst = []
    b = ba_lst[0][0]
    a = ba_lst[0][1]
    for i in range(n):
        b_tmp = ba_lst[i][0]
        a_tmp = ba_lst[i][1]

        if b == b_tmp:
            if i != 0:
                a += a_tmp
            if i == n - 1:
                lst.append([b, a])

        else:
            lst.append([b, a])
            b = b_tmp
            a = a_tmp

    if ba_lst[-1][0] != ba_lst[-2][0]:
        lst.append([ba_lst[-1][0], ba_lst[-1][1]])

    print(lst)

    accumulate = 0
    flag = True
    for i in range(len(lst)):
        accumulate += lst[i][1]
        if accumulate > lst[i][0]:
            flag = False
            break

    if flag:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    n = int(input())
    ab_lst = [list(map(int, input().split())) for _ in range(n)]

    ba_lst = [0] * n
    for i in range(n):
        a = ab_lst[i][0]
        b = ab_lst[i][1]
        ba = [b, a]
        ba_lst[i] = ba
    ba_lst.sort()

    lst = []
    b = ba_lst[0][0]
    a = ba_lst[0][1]
    for i in range(n):
        b_tmp = ba_lst[i][0]
        a_tmp = ba_lst[i][1]

        if b == b_tmp:
            if i != 0:
                a += a_tmp
            if i == n - 1:
                lst.append([b, a])

        else:
            lst.append([b, a])
            b = b_tmp
            a = a_tmp

    if len(lst) > 1:
        if ba_lst[-1][0] != ba_lst[-2][0]:
            lst.append([ba_lst[-1][0], ba_lst[-1][1]])


    accumulate = 0
    flag = True
    for i in range(len(lst)):
        accumulate += lst[i][1]
        if accumulate > lst[i][0]:
            flag = False
            break

    if flag:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()
N = int(input())
t = [int(input()) for x in range(N)]

def mcd(a, b) :
    if max(a, b) % min(a, b) == 0 :
        return min(a, b)
    else :
        return mcd(min(a, b), max(a, b) % min(a, b))

def lcm(a, b) :
    return int((a * b) / mcd(a, b))

t_s = sorted(t)

cur_lcm = t_s[0]
for i in range(1, len(t_s)) :
    cur_lcm = lcm(cur_lcm, t_s[i])
    
print(cur_lcm)
    

### FIXED CODE ###

N = int(input())

'''
def mcd(a, b) :
    if (a, b) in memo.keys() :
        return memo[(a, b)]
    else :
        if max(a, b) % min(a, b) == 0 :
            return min(a, b)
        else :
            memo[(a, b)] = mcd(min(a, b), max(a, b) % min(a, b))
            return memo[(a, b)]

def lcm(a, b) :
    return int((a * b) / mcd(a, b))
'''

def gcd(x, y) :
    if y == 0 : return x
    else : return gcd(y, x % y)

h = 1

for i in range(N) :
    n = int(input())
    
    h = n * h // gcd(n, h)
    
print(h)
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

def doku(li, K, time):
  cnt = 0
  tmp = 0
  for i in range(len(li)):
    if time+li[i] <= K:
      tmp += li[i]
      cnt += 1
    else:
      return cnt
  return cnt

ans = 0
time = 0
while time+min(A[0], B[0]) <= K:
  plus = min(A[0], B[0])
  time += plus
  ans += 1
  if A[0] <= B[0]:
    A.pop(0)
    if not A:
      ans += doku(B, K, time)
      print('A')
      break;
  else:
    B.pop(0)
    if not B:
      ans += doku(A, K, time)
      print('B')
      break;
  print(A, B, time, ans)
    
print(ans)

### FIXED CODE ###

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

a = [0]
b = [0]
for i in range(N):
  a.append(A[i] + a[i])
for i in range(M):
  b.append(B[i] + b[i])
  
ans = 0
j = M
for i in range(N+1):
  if a[i] > K:
    break;
  while b[j] > K-a[i]:
    j -= 1
  ans = max(ans, i+j)
  
print(ans)
R = int(input())
if R < 1200:
  print('ABC')
else if R < 2800:
  print('ARC')
else:
  print('AGC')

### FIXED CODE ###

R = int(input())
if R < 1200:
  print('ABC')
elif R < 2800:
  print('ARC')
else:
  print('AGC')
s = input()

def print_index(x,y):
    if y > len(s):
        return
    print(x,y)

def solve(s,index):
    if not s:
        return
    if s[0]=="1":
        print_index(index,index+1)
        return solve(s[1:],index+1)
    else:
        print_index(index,index+1)
        print_index(index,index+2)
        return solve(s[1:],index+1)


(solve(s,1))

### FIXED CODE ###

import bisect
s = input()
if s[-1] == "1" or s[0] == "0":
    print(-1)
    exit()

for i in range((len(s) - 1) // 2):
    # print(i,len(s)- i - 2)
    if s[i] != s[len(s) - i -2]:
        print(-1)
        exit()

sd = s[:-1] + '1'
plist = [i for i, v in enumerate(sd) if v == '1']
# print(plist)
for i,v in enumerate(s[:-1]):
    r = bisect.bisect(plist,i)
    print(i+1,plist[r] + 1)
import fractions
from functools import reduce

N, M = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse = True)#長さがN

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
  
def half_lcm_list(numbers):
    return reduce(lcm_base, numbers, 1) / 2

min_A = half_lcm_list(A)

#print(min_A)
ans = 0
if min_A > M:
  ans = 0
else:
  ans = 1
  ans += int((M - min_A) / (min_A * 2))
  
print(ans)
  



### FIXED CODE ###

import fractions
from functools import reduce

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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
  

N, M = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N):
  A[i] = A[i] // 2
  
p = 0
de_2 = 0
x = A[0]
while (p == 0):
  if x % 2 == 0:
    x = x // 2
    de_2 += 1
  else:
    p = 1
    
de = 2 ** de_2
for i in range(1, N):
  if A[i] % de == 0:
    if A[i] % (de * 2) != 0:
      continue
    else:
      print("0")
      quit()
  else:
    print("0")
    quit()
  
lcm = lcm_list(A)
p = M // lcm
if p % 2 == 0:
  ans = p // 2
else:
  ans = (p + 1) // 2
  
print(ans)
a,b,c,k = map(int,input().split())
l = [1]*a + [0]*b + [-1]*c
print(sum(l[0:k]))


### FIXED CODE ###

a,b,c,k = map(int,input().split())
if k <= a:
    print(k)
elif k <= a+b:
    print(a)
else:
    print(a-(k-(a+b)))
N, K = input().split()
K = int(K)
N[K-1].lower()
print(N)

### FIXED CODE ###

N, K = map(int, input().split())
S = input()
S = S[:K-1] + S[K-1].lower() + S[K:]
print(S)
a,b=map(int,input().split())
total=a*(a+2*b-1)//2
x=b
y=a+b-1
if (abs(x)<abs(y):
  z=x
else:
  z=y
if x<=0 and y>=0:
  print(total)
else:
  print(total-z)


### FIXED CODE ###

a,b=map(int,input().split())
total=a*(a+2*b-1)//2
x=b
y=a+b-1
if abs(x)<abs(y):
  z=x
else:
  z=y
if x<=0 and y>=0:
  print(total)
else:
  print(total-z)
n, m = map(int, input().split())

fact = []
for i in range(2, int(m**0.5)):
    if m%i==0:
        fact.append(i)
        fact.append(m//i)
fact.sort()

for i in fact:
    if n*i<=m: ans = i
print(ans)

### FIXED CODE ###

def prime_factor(a):
    ret = []
    for i in range(1, int(a**0.5)):
        if a%i==0:
            ret.append(i)
            ret.append(a//i)
    return ret

n, m = map(int, input().split())
ans = 1
for i in prime_factor(m):
    if i<=m/n: ans = max(ans, i)
print(ans)
import re
n = int(input())
s = input()
if not '#' in s:
    print(0)
else:
    s = '#.' + s.split('#.', 1)[-1] if '#.' in s else  s
    ptn = re.search(re.compile('\.#+?$'), s)
    if ptn:
        s = s[:ptn.end()]
    print(min(s.count('.'), s.count('#')))

### FIXED CODE ###

a,b,c = map(int, input().split())
lst = list(range(min(a,b), max(a,b)+1))
if c in lst:
    print('Yes')
else:
    print('No')
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
PY = [list(map(int, input().split())) for _ in range(m)]
def make_id(num):
  s = len(str(num))
  add_zero = '0'*(6-s)
  return add_zero + str(num)

P = [[] for _ in range(m)]
for i in range(len(PY)):
  P[PY[i][0]-1].append(PY[i][1])
  P[PY[i][0]-1].sort()
print(P)
for i in range(len(PY)):
  p,y=PY[i][0],PY[i][1]
  ord = P[p-1].index(y)+1
  print(make_id(p)+make_id(ord))


### FIXED CODE ###

N, M = map(int, input().split())
D = [[] for i in range(N)]
 
for i in range(M):
  p, y = map(int, input().split())
  D[p-1].append((y, i)) 

ans = [None]*M
 
for i, d in enumerate(D): 
  d.sort()
  for k, (y, j) in enumerate(d): 
    ans[j] = str(i+1).zfill(6) + str(k+1).zfill(6)
print(*ans, sep = '\n')
import bisect

n = int(input())
count = 0
a = [[0 for i in range(n)] for i in range(3)]

for i in range(3):
    a[i] = [int(x) for x in input().split()]
    a[i].sort()

# Binary Search
for i in a[1]:
    index0_left = bisect.bisect_left(a[0], i)
    index2_right = bisect.bisect_right(a[2], i)
    if ( i > a[0][index0_left-1] and a[2][index2_right+1] > i):
        count += (index0_left -1 + 1)*(n - index2_right)

print(count)


### FIXED CODE ###

import bisect

n = int(input())
count = 0
a = [[0 for i in range(n)] for i in range(3)]

for i in range(3):
    a[i] = [int(x) for x in input().split()]
    a[i].sort()

# Binary Search
for i in a[1]:
    index0_left = bisect.bisect_left(a[0], i)

    index2_right = bisect.bisect_right(a[2], i)

    count += (index0_left -1 + 1)*(n - index2_right)

print(count)
N = iter(list(input().split()))
  
if next(N) == "7":
  print("Yes")

else print("No")

### FIXED CODE ###

N = str(input())
print("Yes") if (any(list(map(lambda x: True if x == "7" else False, N)))) else print("No")
S = input()[::-1]
cur = 0
mods = Counter()
mods[0] += 1
MOD = 2019
for i,d in enumerate(S):
  cur += int(d) * pow(10, i, MOD)
  mods[cur%MOD] += 1

res = 0
for k,v in mods.items():
  res += (v * (v-1) // 2)

print(res)

### FIXED CODE ###

from collections import Counter
S = input()[::-1]
MOD = 2019
X = [0]
for i, s in enumerate(S):
  X.append((X[-1] + int(s)*pow(10,i,MOD)) % MOD)

C = Counter(X)
res = 0
for v in C.values():
  res += v*(v-1) // 2

print(res)
#!/usr/bin/env python
# -*- coding: utf-8 -*-

var = raw_input()
print str(var)
rect = int(var[0]) * int(var[1])
length = int(var[0]) * 2 + int(var[1]) * 2

print rect + " " + length

### FIXED CODE ###

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

var = raw_input().split()
rect = int(var[0]) * int(var[1])
length = int(var[0]) * 2 + int(var[1]) * 2

print str(rect) + " " + str(length)
import sys
input = sys.stdin.readline

from operator import itemgetter
n, m = map(int, input().split())
a = list(map(int, input().split()))
l = [list(map(int, input().split())) for _ in range(m)]
l = sorted(l, key=itemgetter(1), reverse=True)
a = sorted(a)
idx = 0
for b, c in l:
    cnt = 1
    while(cnt <= b):
        if a[idx] < c:
            a[idx] = c
            idx += 1
            cnt += 1
        else:
            break
print(sum(a))
        


### FIXED CODE ###

import sys
input = sys.stdin.readline
from operator import itemgetter
n, m = map(int, input().split())
a = list(map(int, input().split()))
l = [list(map(int, input().split())) for _ in range(m)]
l = sorted(l, key=itemgetter(1), reverse=True)
a = sorted(a)
idx = 0
cont_flag = 1
for b, c in l:
    cnt = 1
    while(cnt <= b and cont_flag):
        if a[idx] < c:
            a[idx] = c
            idx += 1
            cnt += 1
            if idx == n:
                cont_flag = 0
        else:
            break
    if not cont_flag:
        break
print(sum(a))