Harryxun/stf_run huggingface dataset:
Array = [list(map(str,input().split())) for _ in range(3)]
ArrayBingo = [[0,0,0][0,0,0,][0,0,0]]
N = int(input())
B = []
checkR = 0
checkG = 0
checkN = 0
for i in range (N):
    B.append(int(input()))
for j in range (3):
    for k in range (3):
        for l in range (N):
            if Array[j][k]==B[l]:
                ArrayBingo[j][k]=1
for i in range (3): 
    if [line[i] for line in ArrayBingo] != [1,1,1]:
        checkR=0
    else:
        checkR=1
for i in range (3):
    if [row[i] for row in ArrayBingo] != [1,1,1]:
        checkG=0
    else:
        checkG=1
if (ArrayBingo[1][1] == 1 and ArrayBingo[2][2] == 1 and ArrayBingo [3][3] == 1) or (ArrayBingo[1][3] == 1 and ArrayBingo[2][2] == 1 and ArrayBingo [3][1] == 1):
    checkN = 1
else:
    checkN = 0
if checkR==1 or checkG == 1 or checkN == 1:
    print(Yes)
else:
    print(No)


### FIXED CODE ###

A = []
A_1 = list(map(int,input().split()))
A_2 = list(map(int,input().split()))
A_3 = list(map(int,input().split()))
A.append(A_1)
A.append(A_2)
A.append(A_3)
B = []
check=0
BingocountR=0
BingocountG=0
N = int(input())
ArrayBingo =[[0,0,0],[0,0,0],[0,0,0]]
for i in range(N):
    B.append(int(input()))
for j in range (3):
    for k in range (3):
        for l in range (N):
            if A[j][k]==B[l]:
                ArrayBingo[j][k]=1
for i in range(3):
    for j in range(3):
        if ArrayBingo[j][i]==1:
            BingocountR+=1
            if BingocountR ==3:
                check+=1
    BingocountR = 0
for i in range(3):
    for j in range(3):
        if ArrayBingo[i][j]==1:
            BingocountG+=1
            if BingocountG ==3:
                check+=1
    BingocountG = 0
if (ArrayBingo[0][0] == 1 and ArrayBingo[1][1] == 1 and ArrayBingo [2][2] == 1) or (ArrayBingo[0][2] == 1 and ArrayBingo[1][1] == 1 and ArrayBingo [2][0] == 1):
    check += 1
if check>0:
    print('Yes')
else:
    print('No')
a = input()
if a.count(7)>=1:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

a = input()
if a[0]=='7' or a[1] == '7' or a[2] == '7':
  print('Yes')
else:
  print('No')
import sys

input = sys.stdin.readline


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def func(N, mod):
    F = [1]
    for i in range(1, N + 1):
        F.append(F[-1] * i % mod)
    return F


INV = {}


def inv(a, mod):
    if a in INV:
        return INV[a]
    r = pow(a, mod - 2, mod)
    INV[a] = r
    return r


def C(F, a, b, mod):
    return F[a] * inv(F[b], mod) * inv(F[a - b], mod) % mod


def main():
    N, W = read_values()
    I = [tuple(read_values()) for _ in range(N)]

    w0 = I[0][0]
    if w0 > W:
        print(0)
        return

    dp = [
        [[0 for _ in range(N * 3 + 100)] for __ in range(N + 10)]
        for ___ in range(N + 10)
    ]

    for i, (w1, v) in enumerate(I):
        w = w1 - w0
        for k in range(N):
            for j in range(N * 3 + 5):
                dp[i + 1][k][j] = max(dp[i][k][j], dp[i + 1][k][j])
                dp[i + 1][k + 1][j + w] = max(dp[i][k][j] + v, dp[i + 1][k + 1][j + w])

    res = 0
    for vdp in dp:
        for k in range(N + 1):
            for i in range(W - k * w0 + 1):
                res = max(res, vdp[k][i])
    print(res)


if __name__ == "__main__":
    main()



### FIXED CODE ###

import sys

input = sys.stdin.readline


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def func(N, mod):
    F = [1]
    for i in range(1, N + 1):
        F.append(F[-1] * i % mod)
    return F


INV = {}


def inv(a, mod):
    if a in INV:
        return INV[a]
    r = pow(a, mod - 2, mod)
    INV[a] = r
    return r


def C(F, a, b, mod):
    return F[a] * inv(F[b], mod) * inv(F[a - b], mod) % mod


def main():
    N, W = read_values()
    dp = [
        [[0 for _ in range(N * 3 + 10)] for __ in range(N + 10)]
        for ___ in range(N + 10)
    ]
    I = [tuple(read_values()) for _ in range(N)]

    w0 = I[0][0]
    if w0 > W:
        print(0)
        return

    for i, (w1, v) in enumerate(I):
        w = w1 - w0
        for k in range(N):
            for j in range(N * 3 + 5):
                dp[i + 1][k][j] = max(dp[i][k][j], dp[i + 1][k][j])
                dp[i + 1][k + 1][j + w] = max(dp[i][k][j] + v, dp[i + 1][k + 1][j + w])

    res = 0
    for k in range(N + 1):
        r = min(W - k * w0, 3 * N + 5)
        if r < 0:
            continue
        for i in range(r + 1):
            res = max(res, dp[N][k][i])
    print(res)


if __name__ == "__main__":
    main()
x,y=input.split()
res='='
if x<y:res='<'
if x>y:res='>'
print(res)

### FIXED CODE ###

x,y=input().split()
print('<'if x<y else'>'if x>y else'=')
O,E = input(),input()
ans = ''
for i in range(len(O)):
    ans += O[i] + E[i]
print(ans)

### FIXED CODE ###

O,E = input(),input()
ans = ''

if (len(O)+len(E))%2==0:
    for i in range(len(E)):
        ans += O[i] + E[i]
else:
    for i in range(len(E)):
        ans += O[i] + E[i]
    ans+=O[-1]
    
print(ans)
import sys
from bisect import insort_left
from collections import *

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

An_sorted_pos = deque(sorted([ a for a in An if a > 0]))
An_sorted_neg = deque(sorted([ a for a in An if a < 0]))
zero_exists = not all([ a != 0 for a in An ])

if zero_exists:
    print(sum(An_sorted_pos) - sum(An_sorted_neg))
    sys.exit(0)
    pass

if len(An_sorted_neg) == 0:
    print(sum(An_sorted_pos))
    sys.exit(0)
    pass

if len(An_sorted_pos) == 0:
    if len(An_sorted_neg) % 2 == 0:
        print(-sum(An_sorted_neg))
    else:
        print(-sum(An_sorted_neg)+max(An_sorted_neg))
        pass
    sys.exit(0)
    pass

while An_sorted_pos[0] < -An_sorted_neg[0]:
    pos = An_sorted_pos.popleft()
    neg = An_sorted_neg.popleft()
    idx_pos = insort_left(An_sorted_pos, -neg)
    idx_neg = insort_left(An_sorted_neg, -pos)
    pass

print(sum(An_sorted_pos) + sum(An_sorted_neg))



### FIXED CODE ###

from itertools import chain

N = int(input())
An = list(map(int, input().split()[0:N]))

An_pos = [ a for a in An if a >= 0]
An_neg = [ -a for a in An if a < 0]

ans = sum(An_pos) + sum(An_neg)

if len(An_neg) % 2 == 1:
    ans -= 2 * min(chain(An_pos, An_neg))
    pass

print(ans)
a,b,c = linst(map(int,input()))
if a*b < c:
  print(a*b)
else:
  print(c)


### FIXED CODE ###

n,a,b = map(int,input().split())
if a*n < b:
  print(a*n)
else:
  print(b)
import fractions
from functools import reduce
def gcd(i):
    return reduce(fractions.gcd, i)
def main():
    N = int(input())
    A = list(map(int, input().split()))
    tmp = 0
    if gcd(A) == max(A):
        print(gcd(A))
        exit()
    else:
        for i in range(N):
            if i == 0 :
                tmp=max(tmp,gcd(A[1:]))
            elif i == N-1:
                tmp=max(tmp,gcd(A[:N-1]))
            else:
                tmp=max(tmp,gcd(A[:i]+A[i+1:]))
    print(tmp)
 if __name__ == "__main__":
     main()

### FIXED CODE ###

import fractions
from functools import reduce
def gcd(*i):
    return reduce(fractions.gcd, i)
def main():
    N = int(input())
    A = list(map(int, input().split()))
    L=[0]
    R=[0]
    for i in range(N):
        L.append(gcd(L[i],A[i]))
        R.append(gcd(R[i],A[-(i+1)]))
    R=R[::-1]
    ans=[]
    for i in range(N):
        ans.append(gcd(L[i],R[i+1]))
    print(max(ans))
if __name__ == "__main__":
    main()
A,B = [int(x) for x in input().split()]
S = input()
flag = True
for ind,i in enumerate(S):
  if(ind!=A):
      if(ord(i)<48 or 57<ord(i):
         flag = False
         break
  else:
      if(i!='-'):
         flag = False
         break
if(flag):
         print('Yes')
else:
         print('No')

### FIXED CODE ###

A,B = [int(x) for x in input().split()]
S = input()
flag = True
for ind,i in enumerate(S):
  if(ind!=A):
      if(ord(i)<48 or 57<ord(i)):
         flag = False
         break
  else:
      if(i!='-'):
         flag = False
         break
if(flag):
     print('Yes')
else:
     print('No')
X = int(input())
y =2*10**2
a ={i**5 for i in range(-y,y)}
ans_a =0
ans_b =0
for b in range(-y,y):
    if X +b**5 in a:
        #ans_a =int( (X +b**5 +1)**0.2 )
        ans_a =int( (X +b**5 )**0.2 )
        ans_b =b
        break
print(ans_a,ans_b)

### FIXED CODE ###

# 初期入力
import sys
import math
#input = sys.stdin.readline
X = int(input())
limit =10**5
a=0
b=0
for b in range(-1*limit ,limit):
    a5 =X+pow(b,5)
    if 0 <= a5: 
        a=math.pow(a5,0.2)
        a_int =int(a)
        dif =a_int**5 -b**5 -X
        if abs(dif)<10**(-5):
            break
    else:
        continue
print(a_int,b)
import re
from sys import stdin
N=(stdin.readline().rstrip())
for i in range(7):
    mae="keyence"[0:i+1]
    ato="keyence"[i+1:8]
    if (re.sub('.*keyence', '', N)=="")==True:
        print("YES")
        break
    if (re.sub('keyence.*', '', N)=="")==True:
        print("YES")
        break
    if re.match("%s.*%s"%(mae, ato),N):
        print("YES")
        cnt+=1
        break
if i==6:
    print("NO")

### FIXED CODE ###

import re
from sys import stdin
N=(stdin.readline().rstrip())
for i in range(7):
    mae="keyence"[0:i+1]
    ato="keyence"[i+1:8]
    if re.search(".*keyencekeyence",N):
        if (re.sub('.*keyencekeyence', '', N)=="")==True:
            print("YES")
            break
    if re.search("keyencekeyence.*",N):
        if (re.sub('keyencekeyence.*', '', N)=="")==True:
            print("YES")
            break
    if (re.sub('.*keyence', '', N)=="")==True:
        print("YES")
        break
    if (re.sub('keyence.*', '', N)=="")==True:
        print("YES")
        break
    if re.match("%s.*%s"%(mae, ato),N):
        if (re.sub('%s.*%s'%(mae,ato) ,"", N)=="")==True:
            print("YES")
            break
if i==6:
    print("NO")
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    S = list(lines.pop(0))
    S.sort()
    S = ''.join(S)
    if S == 'abc':
        print('Yes')
    else:
        print('No')

#
# main
#
lines = contents.split('\n')

# 2. use stdin

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    S = list(lines.pop(0))
    S.sort()
    S = ''.join(S)
    if S == 'abc':
        print('Yes')
    else:
        print('No')

#
# main
#
lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
import sys

sys.setrecursionlimit(50000)

n,q = nm()

tval = [0]*n
t = [[] for _ in range(n)]

for i in range(n-1):
    a = nl()
    aa, bb = sorted(a)
    t[aa-1].append(bb-1)

for i in range(q):
    p,x = nm()
    tval[p-1] += x

ans = [0]*n
def dfs(num,val):
    now = val+tval[num]
    ans[num] = now
    for nn in t[num]:
        dfs(nn,now)

dfs(0,0)

for i in ans:
    print(i)


### FIXED CODE ###

ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
import sys

sys.setrecursionlimit(500000)

visited = set()

n,q = nm()

tval = [0]*n
t = [[] for _ in range(n)]

for i in range(n-1):
    a,b = nm()
    t[a-1].append(b-1)
    t[b-1].append(a-1)

for i in range(q):
    p,x = nm()
    tval[p-1] += x

ans = [0]*n
def dfs(num,val):
    visited.add(num)
    now = val+tval[num]
    ans[num] = now
    for nn in t[num]:
        if nn not in visited:
            dfs(nn,now)

dfs(0,0)

for i in ans:
    print(i)
N,D = map(int,input().split())

array = [[0 for i in range(2)] for j in range(N)]
for i in range(0,N):
    array[i][0],array[i][1] = map(int,input().split())

dis = []
ans = 0
for i in range(0,N):
    if ((array[i][0]**2) + (array[i][1]**2)) not in dis:
        dis.append(((array[i][0]**2) + (array[i][1]**2)))

for i in dis
    if D**2 >= i:
        ans += 1
print(ans)

### FIXED CODE ###

N,D = map(int,input().split())

ans = 0
for i in range(N):
	X,Y = map(int,input().split())
	if D**2 >= X**2 + Y**2:
		ans += 1
print(ans)
import math
from decimal import *

a,b,c=map(Decimal,input().split())

A=math.sqrt(a)
B=math.sqrt(b)
C=math.sqrt(c)


if   A+B<C:
    print("Yes")
else :
    print("No")

### FIXED CODE ###

N=int(input())

list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(list[N-1])
def LI():
  return [int(s) for s in input().split()]

A,B = LI()

print(max(A+B,A-B,int(A*B))

### FIXED CODE ###

def LI():
  return [int(s) for s in input().split()]
 
A,B = LI()
 
print(max([A+B,A-B,int(A*B)]))
import sys
n=int(input())
lst=[]
for i in range(n):
  T,X,Y=map(int,input().split())
  lst.append([T,X,Y])
lst.sort(reverse=False,lambda x:x[0])
for j in range(n-1):
  if abs(lst[j][1]-lst[j+1][1])==1:
    if lst[j][2]==lst[j+1][2]:
      pass
    else:
      print('No')
      sys.exit()
  if abs(lst[j][2]-lst[j+1][2])==1:
    if lst[j][1]==lst[j+1][1]:
      pass
    else:
      print('No')
      sys.exit()    
  else:
    print('No')
    sys.exit()
print('Yes')


### FIXED CODE ###

import sys
n=int(input())
lst=[]
for i in range(n):
  T,X,Y=map(int,input().split())
  lst.append([T,X,Y])
if (abs(lst[0][1])+abs(lst[0][2]))%2==lst[0][0]%2:
  if abs(lst[0][1])+abs(lst[0][2])<=lst[0][0]:
    pass
  else:
    print('No')
    sys.exit()
else:
  print('No')
  sys.exit()

for j in range(n-1):
  if (abs(lst[j][1]-lst[j+1][1])+abs(lst[j][2]-lst[j+1][2]))%2==(lst[j+1][0]-lst[j][0])%2:
    if abs(lst[j][1]-lst[j+1][1])+abs(lst[j][2]-lst[j+1][2])<=(lst[j+1][0]-lst[j][0]):
      pass
    else:
      print('No')
      sys.exit()
  else:
    print('No')
    sys.exit()
print('Yes')
a = list(map(int, input()))
print(len(set(a)))

### FIXED CODE ###

a = list(map(int, input().split()))
print(len(set(a)))
def solv_quadratic_equation(a, b, c):
    D = (b**2 - 4*a*c) ** (1/2)
    if isinstance(D, float) == True:
      x_1 = (-b + D) / (2 * a)
      x_2 = (-b - D) / (2 * a)
      return x_1,x_2
    else:
      return 0.1,0.1

n = int(input())
a,ch = n // 10,0
while ch == 0:
    s,t,u = a,-pow(a,3),(pow(a,5) -n)/5
    v,w = solv_quadratic_equation(s,t,u)
    if v.is_integer() == True:
        e,f = solv_quadratic_equation(1,-a,v)
        if e.is_integer() == True & f.is_integer() == True:
            if abs(int(e)) >= abs(int(f)):
                print(int(e),int(-f))
            else:
                print(int(f),int(-e))
            ch = 1
    if w.is_integer() == True:
        e,f = solv_quadratic_equation(1,-a,w)
        if e.is_integer() == True & f.is_integer() == True:
            if abs(int(e)) >= abs(int(f)):
                print(int(e),int(-f))
            else:
                print(int(f),int(-e))
            ch = 1
    a += 10

### FIXED CODE ###

def check(a, b):
    return pow(a,5) - pow(b,5)

n = int(input())
a = 0
for i in range(0,120):
    for j in range(-119,i):
      if a == 0:
        if n == check(i,j):
          print(i,j)
          a = 1
h, w = map(int, raw_input().split())
x = h*w
print x/=2 if x % 2 != 0 x = (x/2)+1

### FIXED CODE ###

h, w = map(int, raw_input().split())
x = 1 if h == 1 or w == 1 else h * w 
if x == 1:
  print x
elif x % 2 == 0:
  print x / 2
else:
  print x / 2 + 1
N,M = map(int,input())

if N>=2:
  gyu = N*(N-1)//2
else:
  gyu = 0
  
if M>=2:
  ki = M*(M-1)//2
else:
  ki = 0

print(gyu+ki)

### FIXED CODE ###

N,M = map(int,input().split())
 
if N>=2:
  gyu = N*(N-1)//2
else:
  gyu = 0
  
if M>=2:
  ki = M*(M-1)//2
else:
  ki = 0
 
print(gyu+ki)
N = int(input())
if(N == 1):
  print("Hello World")
else:
  a,b = [int(i) for i in input().split()]
  print(a + b)

### FIXED CODE ###

N = int(input())
if(N == 1):
  print("Hello World")
else:
  a = int(input())
  b = int(input())
  print(a + b)
A,B,C=map(int,input().split())

print (int(C,A,B).split=())


### FIXED CODE ###

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

print (C,A,B)
def eratosthenes(n):
    is_prime = [True for i in range(n+1)]
    is_prime[0], is_prime[1] = False, False
    prime = []
    for i in range(2, n+1):
        if is_prime[i]:
            prime.append(i)
            for j in range(2*i, n+1, i):
                is_prime[j] = False
    return prime
    

Q = int(input())
N = 10**5

prime = eratosthenes(N)
prime_num = [0 for i in range(N+1)]
for p in prime:
    prime_num[p] = 1
    
count = 0
ans = [0 for i in range(N+1)]
for i in range(1, N+1, 2):
    if prime_num[i] == 1 and prime_num[(i+1)//2] == 1:
        count += 1
    ans[i] = count
    
for i in range(Q):
    l, r = map(int, input().split())
    print(ans[r+2] - ans[l-2])

### FIXED CODE ###

def eratosthenes(n):
    is_prime = [True for i in range(n+1)]
    is_prime[0], is_prime[1] = False, False
    prime = []
    for i in range(2, n+1):
        if is_prime[i]:
            prime.append(i)
            for j in range(2*i, n+1, i):
                is_prime[j] = False
    return prime
    

Q = int(input())
N = 10**5

prime = eratosthenes(N)
prime_num = [0 for i in range(N+1)]
for p in prime:
    prime_num[p] = 1
    
count = 0
ans = [0 for i in range(N+1)]
for i in range(1, N+1, 2):
    if prime_num[i] == 1 and prime_num[(i+1)//2] == 1:
        count += 1
    ans[i] = count
    
for i in range(Q):
    l, r = map(int, input().split())
    print(ans[r] - ans[l-2])
from queue import Queue

def bfs(H, W, s):
    inf = 10 ** 20
    d = [[inf for i in range(W)] for j in range(H)]
    q = Queue()

    d[0][0] = 1
    q.put([0, 0])

    dx = (0, -1, 1, 0)
    dy = (-1, 0, 0, 1)

    while not q.empty():
        p = q.get()
        x = p[0]
        y = p[1]
        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]
            if(nx >= 0 and nx < H and ny >= 0 and ny < W):
                if(s[nx][ny] == '.' and d[x][y] + 1 < d[nx][ny]):
                    d[nx][ny] = d[x][y] + 1
                    q.put([nx, ny])

    return d[H-1][W-1]

H, W = map(int, input().split())
s = []
wnum = 0
for i in range(H):
    s.append(input())
    for j in range(W):
        if(s[i][j] == "."):
            wnum += 1
d = bfs(H, W, s)
if(d == INF):
    print("-1")
else:
    print(wnum - d)


### FIXED CODE ###

from queue import Queue

inf = 10 ** 20

def bfs(H, W, s):
    d = [[inf for i in range(W)] for j in range(H)]
    q = Queue()

    d[0][0] = 1
    q.put([0, 0])

    dx = (0, -1, 1, 0)
    dy = (-1, 0, 0, 1)

    while not q.empty():
        p = q.get()
        x = p[0]
        y = p[1]
        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]
            if(nx >= 0 and nx < H and ny >= 0 and ny < W):
                if(s[nx][ny] == '.' and d[x][y] + 1 < d[nx][ny]):
                    d[nx][ny] = d[x][y] + 1
                    q.put([nx, ny])

    return d[H-1][W-1]

H, W = map(int, input().split())
s = []
wnum = 0
for i in range(H):
    s.append(input())
    for j in range(W):
        if(s[i][j] == "."):
            wnum += 1
d = bfs(H, W, s)
if(d == inf):
    print("-1")
else:
    print(wnum - d)
x,y,a,b,c=map(int,input().split())

p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p=sorted(p,reverse=True)[:x]
q=sorted(q,reverse=True)[:y]
r=sorted(r)

p.extend(q)
p=sorted(p)

ans=0
for i in range(x+y):
    if p[-1]<r[-1]:
        ans+=r[-1]
        r.pop(-1)
    else:
        ans+=p[-1]
        p.pop(-1)
        
print(ans)



### FIXED CODE ###

x,y,a,b,c=map(int,input().split())

p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p=sorted(p,reverse=True)[:x]
q=sorted(q,reverse=True)[:y]
r=sorted(r)

p.extend(q)
p=sorted(p)

ans=0
for i in range(x+y):
    if len(r)>0:
        if p[-1]<r[-1]:
            ans+=r[-1]
            r.pop(-1)
        else:
            ans+=p[-1]
            p.pop(-1)
    else:
        ans+=p[-1]
        p.pop(-1)
        
print(ans)
import sys
# import math
# import bisect
import numpy as np


# import copy
# import heapq
# from collections import deque
# import decimal

# sys.setrecursionlimit(100001)
# INF = sys.maxsize
# MOD = 10 ** 9 + 7

# ===CODE===
def main():
    n,m,q = map(int,input().split())
    ruisekiwa_s = [0 for _ in range(n+1)]
    ruisekiwa_t = [0 for _ in range(n+1)]
    for _ in range(m):
        l,r = map(int, input().split())
        ruisekiwa_s[l]+=1
        ruisekiwa_t[r]+=1

    for i in range(1, n+1):
        ruisekiwa_s[i] += ruisekiwa_s[i-1]
        ruisekiwa_t[i] += ruisekiwa_t[i-1]

    for _ in range(q):
        s,t = map(int,input().split())
        ans = ruisekiwa_t[t] - ruisekiwa_s[s-1]
        print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys


# import math
# import bisect

# import copy
# import heapq
# from collections import deque
# import decimal

# sys.setrecursionlimit(100001)
# INF = sys.maxsize
# MOD = 10 ** 9 + 7

# ===CODE===
def main():
    n, m, z = map(int, input().split())
    ruisekiwa = [[0 for i in range(n + 1)] for j in range(n + 1)]

    d = []
    for i in range(m):
        l, r = map(int, input().split())
        ruisekiwa[r][l] += 1

    for i in range(n):
        for j in range(n):
            ruisekiwa[i + 1][j + 1] += ruisekiwa[i][j + 1] + ruisekiwa[i + 1][j] - ruisekiwa[i][j]

    for _ in range(z):
        p, q = map(int, sys.stdin.readline().split())
        ans = ruisekiwa[q][q] - ruisekiwa[p - 1][q] - ruisekiwa[q][p - 1] + ruisekiwa[p - 1][p - 1]
        print(ans)


if __name__ == '__main__':
    main()
from sys import stdin
import math
import itertools


def makeIntMatrix(lines):
    intMatrix = []
    for a in makeStringMatrix(lines):
        intMatrix.append([int(b) for b in a])
    return intMatrix
 
 
def makeStringMatrix(lines):
    stringMatrix = [line.split() for line in lines]
    return stringMatrix
 
 
def makeInt(line):
    return int(line.rstrip())
 
 
def makeMultiInteger(line):
    return [int(x) for x in line.rstrip().split()]


def solve(input_string):
    N, M = makeMultiInteger(input_string[0])
    A = makeMultiInteger(input_string[1])
    _S = makeIntMatrix(input_string[2:])
    cards = sorted(A)
    S = sorted(_S, key=lambda x: x[1])
    for i in range(1, len(S)):
        b = S[i][0]
        c = S[i][1]
        if S[i-1][1] == c:
            S[i-1][0] += b
            S[i][0] = 0
            S[i][1] = 0

    for s in S:
        b = s[0]
        c = s[1]
        if c > cards[0]:
            for i in range(b):
                if c > cards[i]:
                    cards[i] = c
                else:
                    break
            cards = sorted(cards)
        else:
            break
    return sum(cards)
    #else:
    #    return len(ra)



def main():
    input_lines = stdin.readlines()
    answer = solve(input_lines)
    print(answer)


if __name__ == '__main__':
    main()


### FIXED CODE ###

# from sys import exit
N, M = [int(n) for n in input().split()]
# N = int(input())
a = [(int(n), 1) for n in input().split()]
B = [0 for _ in range(M)]
C = [0 for _ in range(M)]
for i in range(M):
    B[i], C[i] = [int(n) for n in input().split()]
    a.append((C[i], B[i]))

a = sorted(a, key=lambda x: -x[0])
i = 0
ans = 0
# print(a)
while(N != 0):
    num = min(N, a[i][1])
    ans += num*a[i][0]
    # print(num*a[i][0])
    N -= num
    i += 1

print(ans)
import fractions
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int,input().split()))
a.sort()
gcd_list = []
ans = 0
for i in range(1,n):
  gcd_list.append(fractions.gcd(a[0],a[i]))
gcd_list.sort()
gcd_list.remove(gcd_list[0])
for j in range(1,n-2):
  ans = max(ans,fractions.gcd(gcd_list[0],gcd_list[i]))
print(ans)

### FIXED CODE ###

import fractions
n = int(input())
a = list(map(int,input().split()))
m = []
l = [0]
r = [0]
for i in range(n):
  l.append(fractions.gcd(l[i],a[i]))
  r.append(fractions.gcd(r[i],a[-i-1]))
r.reverse()
for i in range(n):
  m.append(fractions.gcd(l[i],r[i+1]))
print(max(m))
While True:
   try:
      print(len(str(sum(list(map(int,input().split()))))))
   except:
      bereak
   

### FIXED CODE ###

while True:
   try:
      print(len(str(sum(list(map(int,input().split()))))))
   except:
      break