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

import math
N = int(input())
x = math.ceil(N)
ans = [0]*N

def f(x,y,z):
    return x**2+y**2+z**2+x*y+y*z+z*x

for i in range(1,x):
    for j in range(i,x):
        for k in range(j,x):
            s = f(i,j,k)
            t = len(set([i,j,k]))
            if N < s:
                pass
            else:
                if t == 3:
                    ans[s-1] += 6
                elif t == 2:
                    ans[s-1] += 3
                elif t ==1:
                    ans[s-1] += 1
for i in range(len(ans)):
    print(ans[i])

### FIXED CODE ###

import math
N = int(input())
x = math.ceil(math.sqrt(N))
ans = [0]*N

def f(x,y,z):
    return x**2+y**2+z**2+x*y+y*z+z*x

for i in range(1,x):
    for j in range(i,x):
        for k in range(j,x):
            s = f(i,j,k)
            t = len(set([i,j,k]))
            if N >= s:
                if t == 3:
                    ans[s-1] += 6
                elif t == 2:
                    ans[s-1] += 3
                elif t ==1:
                    ans[s-1] += 1
for i in range(len(ans)):
    print(ans[i])
### BUGGY CODE ###

A, B = map(int,input().split())
import fractions
_gcd = fractions.gcd(A, B)

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

l = make_divisors(_gcd)
if len(l)==1:
    print(1)
    quit()
l.sort()

l2 = l[:]
for i,x in enumerate(l):
    for y in l[i+1:]:
        if fractions.gcd(x, y) != 1 and y in l2:
            l2.remove(y)
print(len(l2))

### FIXED CODE ###

A, B = map(int,input().split())
import fractions
_gcd = fractions.gcd(A, B)

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

l = make_divisors(_gcd)
if len(l)==1:
    print(1)
    quit()
l.sort()
aa=False
for x in l:
    if x%2==0:
        aa=x
        break
if aa:
    l2 = [x for x in l if x%2]
    l2.append(aa)
else:
    l2 = l[:]
for i,x in enumerate(l2):
    for y in l2[i+1:]:
        if fractions.gcd(x, y) != 1 and y in l2:
            l2.remove(y)
print(len(l2))
### BUGGY CODE ###

n=int(input())
t=[1]*(n+1)
check=[False]*(n+1)
for i in range(2,n+1):
  if check[i]==True:
    continue
  check[i]=True
  for j in range(1,n//i+1):
    check[i*j]=True
    cnt=0
    k=i*j
    while k%i==0:
      k//=i
      cnt+=1
    t[i*j]*=(i**cnt)*(cnt+1)
print(sum(t[1:]))

### FIXED CODE ###

import sys
input=sys.stdin.readline

def calc():
  n=int(input())
  table=[1]*(n+1)
  check=[False]*(n+1)
  for i in range(2,n+1):
    if check[i]==True:
      continue
    check[i]=True
    for j in range(1,n//i+1):
      check[i*j]=True
      tmp=j
      cnt=1
      while tmp%i==0:
        tmp//=i
        cnt+=1
      table[i*j]*=(i**cnt)*(cnt+1)
  print(sum(table)-1)
calc()
### BUGGY CODE ###

# -*- coding: utf-8 -*-
n, k = map(int, input().split())
A = sorted([int(i) for i in input().split()])
F = sorted([int(i) for i in input().split()], reverse = True)

P = [A[i]*F[i] for i in range(n)]

if sum(A) <= k: print('0')
else:
    for j in range(k):
        max_value = max(P)
        max_index = P.index(max_value)
        A[max_index] -= 1
        P[max_index] = A[max_index]*F[max_index]
    print(max(P))

### FIXED CODE ###

# -*- coding: utf-8 -*-
 
n, k = map(int, input().split())
A = [int(i) for i in input().split()]
A.sort(reverse = True)
F = [int(i) for i in input().split()]
F.sort()
"""
n = 11
k = 14
A = [1,1,2,3,3,4,5,5,5,6,9]
F = [9,9,8,8,7,6,4,3,3,2,2]
"""

 
P = [A[i]*F[i] for i in range(n)]
sum_A = sum(A)
 
def b(p):
    result = 0
    for i in range(n):
        if P[i] > p:
            r = (P[i] - p) // F[i]
            if P[i] - r * F[i] > p:
                r += 1
            result += r
    return result
 
if sum_A <= k: print('0')
else: 
    left = 0
    right = max(P)
    middle = int((left + right) / 2)
    bm = b(middle)
    
    
    
    while right - left > 1:
        
        if bm > k: left = middle
        else: right = middle
            
        middle = int((left + right) / 2)
        bm = b(middle)
 
    if b(left) <= k: print(left)
    else: print(right)
### BUGGY CODE ###

import sys
from collections import deque

input = sys.stdin.readline

def main():
    N = int(input())
    visited = [False] * N
    E = [deque() for i in range(N)]
    nums = [set() for i in range(N)] 
    ans = [None] * (N-1)
    
    for i in range(N-1):
        a, b = map(int, input().split())
        E[a-1].append((b-1, i))
        E[b-1].append((a-1, i))
        
    ans_ = max([len(e) for e in E])
    G = set(i for i in range(ans_))
    
    q = deque([0])
    
    while q:
        v = q.popleft()
        
        if visited[v]: continue
    
        visited[v] = True
        
        use_nums = list(G - nums[v])
        for u, idx in E[v]:
            if visited[u]: continue
            
            n = use_nums.pop(0)
            ans[idx] = str(n+1)
            nums[u].add(n)
            q.append(u)
            
    print(ans_)
    print('\n'.join(ans))

if __name__ == '__main__':
    main()

### FIXED CODE ###

# -*- coding: utf-8 -*

import sys

input = sys.stdin.readline

def main():
    N = int(input())
    
    G = [[] for i in range(N)]
    ans = [None] * (N-1)
    
    for i in range(N-1):
        a, b = map(int, input().split())
        a, b = a-1, b-1
        
        G[a].append((b, i))
        G[b].append((a, i))
        
    q = [(0, -1)]
    
    visited = [False] * N
    cur = 0
    
    while q and cur < N:
        v, c = q.pop(0)
    
        if visited[v]: continue
        visited[v] = True
        cur += 1
        
        k = 0
        for u, idx in G[v]:
            if visited[u]: continue
            if c == k: k += 1
            
            ans[idx] = k
            q.append((u, k))
            k += 1
            
    print(max(ans)+1)
    for a in ans: print(a+1)
     
if __name__ == '__main__':
    main()
### BUGGY CODE ###

n,m,k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
readable = 0
for rx in range(1,n+m+1):
  for ra in range(0,rx+1):
    rb = rx - ra
    rt = 0
    if ra <= len(a) and rb <= len(b):
      if ra>0 :
        for i in range(0,ra):
          rt += a[i]
      if rb>0 :
        for i in range(0,rb):
          rt += b[i]
      if rt <= k: readable = rx
print(readable)

### FIXED CODE ###

n,m,k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
sa = [0] * (n+1)
sb = [0] * (m+1)
for i in range(n):
  sa[i+1] = sa[i] + a[i]
for i in range(m):
  sb[i+1] = sb[i] + b[i]
rx = 0
rb = m
for ra in range(0,n+1): 
  while (sb[rb] + sa[ra]) > k and rb>0 :
    rb-=1
  if (sb[rb] + sa[ra]) <= k:
    rx = max(rx,ra+rb)
print(rx)
### BUGGY CODE ###

from collections import defaultdict as d
p=d(str)
n=int(input())
print(0, flush = True)
s = input()
if s == "Vacant": exit()
else:
    print((n-1)//2,flush=True)
    t=input()
    if t == "Vacant": exit()
    else:
        p[0]=s
        p[(n-1)//2]=t
        l=0
        r=n-1
        while r-l>1:
            g=(l+r)//2
            if p[l]=="":
                print(l, flush = True)
                s = input()
                p[l]=s
                if s == "Vacant": exit()
                else:
                    s=p[l]
            if p[g]=="":
                print(g, flush = True)
                t = input()
                p[g]=t
                if t == "Vacant": exit()
                else:
                    t=p[g]
            if ((g-l)%2!=0 and s!=t) or ((g-l)%2!=1 and s==t):
                l=g
            else:
                r=g
        if p[l]=="":
            print(l, flush = True)
            s = input()
            if s == "Vacant": exit()
        if p[r]=="":
            print(r, flush = True)
            t = input()
            if t == "Vacant": exit()


### FIXED CODE ###

from collections import defaultdict as d
p=d(str)
n=int(input())
print(0, flush = True)
s = input()
if s == "Vacant": exit()
else:
    p[0]=s
    p[n]=s
    l=0
    r=n
    while 1:
        g=(l+r)//2
        print(g, flush = True)
        s = input()
        p[g]=s
        if s == "Vacant": break
        else:
            t=p[l]
            if ((g-l)%2!=0 and s!=t) or ((g-l)%2!=1 and s==t):
                l=g
            else:
                r=g
### BUGGY CODE ###

N,M=map(int,input().split())
A=[0]*M
import heapq
import collections
from itertools import permutations
table=collections.defaultdict(list)
AC=[[0,0] for i in range(M)]
C=[set() for i in range(M)]
for i in range(M):
  a,b=map(int,input().split())
  AC[i][0]=a
  tmp=set(map(int,input().split()))
  for x in tmp:
    AC[i][1] |= 1<<(x-1)
dp=[10**9]*(2**N)
dp[0]=0

for i in range(1,2**N):
  k=0
  s=set()
  for j in range(1,i):
    if i & j == j:
      dp[i]=min(dp[i],dp[j]+dp[i^j])
  for a,c in AC:
    if c&i == i:
      dp[i]=min(dp[i],a)
  #print(dp[i],bin(i))
  
if dp[-1]==10**9:
  print(-1)
else:
  print(dp[-1])
#print(dp)

  
  
#print(AC)

### FIXED CODE ###

N,M=map(int,input().split())
A=[0]*M
import heapq
import collections
from itertools import permutations
table=collections.defaultdict(list)
AC=[[0,0] for i in range(M)]
C=[set() for i in range(M)]
for i in range(M):
  a,b=map(int,input().split())
  AC[i][0]=a
  tmp=set(map(int,input().split()))
  for x in tmp:
    AC[i][1] |= 1<<(x-1)
dp=[10**9]*(2**N)
dp[0]=0

for i in range(1,2**N):
  k=0
  s=set()
  for j in range(1,i):
    if i & j == j:
      dp[i]=min(dp[i],dp[j]+dp[i^j])
  for a,c in AC:
    if c&i == i:
      dp[i]=min(dp[i],a)
  #print(dp[i],bin(i))
  
if dp[-1]==10**9:
  print(-1)
else:
  print(dp[-1])
#print(dp)

  
  
#print(AC)
### BUGGY CODE ###

N,K = map(int,input().split())
a = abs(N-K)
if N%K==0 and N > 100: print (0)
else:
    while True:
        c = abs(N-K)
        if c > a: break
        a = c
        N = c
    print(a)

### FIXED CODE ###

N,K = map(int, input().split())
N = N%K
absolute = abs(K-N)
print(absolute if absolute < N else N)
### BUGGY CODE ###

S = input()
mod = 13
amari = 5

import numpy as np
dp = np.zeros((len(S)+1,mod),dtype="uint64")
dp[0,0%mod] = 1
for i,s in enumerate(S[::-1]):
    if s == "?":
        for n in range(10):
            dp[i+1,:] += np.roll(dp[i],n*(10**i)%mod)
    else:
        dp[i+1,:] += np.roll(dp[i],int(s)*(10**i)%mod)
    dp = dp%(10**9+7)
print(dp[-1,amari])

### FIXED CODE ###

rotate = lambda x,y: x[-y:] + x[:-y]
S = input()
mod = 13
amari = 5
dp_tmp = [0]*13
dp_tmp[0] = 1
mul = 1
for s in S[::-1]:
    dp = [0]*13
    if s == "?":
        for n in range(10):
            dp_tmp_roll = rotate(dp_tmp,n*mul%mod)
            for k in range(13):
                dp[k] += dp_tmp_roll[k]
    else:
        dp_tmp_roll = rotate(dp_tmp,int(s)*mul%mod)
        for k in range(13):
            dp[k] += dp_tmp_roll[k]
    for n in range(13):
        dp[n] = dp[n]%(10**9+7)
    dp_tmp = dp
    mul = mul*10%13
print(dp[amari])
### BUGGY CODE ###

N,M = list(map(int,input().split()))
A = list(map(int,input().split()))
BC = [list(map(int,input().split())) for i in range(M)]

B = []
C = []

for i in range(M):
    B.append(BC[i][0])
    C.append(BC[i][1])
    
for i in range(M):
    A.sort()
    card = 0
    for j in range(N):
        if A[j] < C[i]:
            A[j] = C[i]
            card += 1
        if card == B[i]:
            break
            
print(sum(A))

### FIXED CODE ###

from operator import itemgetter

N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = []
for i in range(M):
    B,C = map(int,input().split())
    BC.append([B,C])

BC.sort(key = itemgetter(1),reverse=True)

change = []
for b,c in BC:
    change += [c] * b
    if len(change) > N:
        break
A += change
A.sort(reverse=True)
answer = sum(A[:N])
print(answer)
### BUGGY CODE ###

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


B = list(set(A))          

while B:                  
    b = max(B)            
    if A.count(b) >= 4:   
        print(b**2)       
        exit()            
    elif A.count(b) >=2:  
        B.remove(b)       
        while B:          
            c = max(B)    
            if  A.count(c) >= 2:                    
                print(b*c)                          
                exit()    
            else:         
                B.remove(c)                         
    else:                 
        B.remove(b)       

print(0)   

### FIXED CODE ###

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

x = 0
y = 0
S = set()

for a in A:
    if a in S:
        if a < x:
            continue
        elif a > y:
            x = y
            y = a
        else:
            x = a
        S.remove(a)
    else:
        S.add(a)

print(x*y)
### BUGGY CODE ###

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

from itertools import product

k_list = list(range(k+1))
count = 0
for x, y, z in product(k_list, k_list, k_list):
  if x+y+z==s:
    count+=1
print(count)

### FIXED CODE ###

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

from itertools import product

k_list = list(range(k+1))
count = 0
for x, y in product(k_list, k_list):
  # print(x, y, s-x-y)
  if 0<=s-x-y<=k:
    count+=1
print(count)
### BUGGY CODE ###

BIGMOD = 998244353

def modPow(x,n):
    ans = 1
    while n >= 1:
        if bin( n & 1)==bin(1):
            ans = (ans*x) % BIGMOD
        x = x * x % BIGMOD
        n = n>>1
    return ans % BIGMOD

def modFact(N):
    fact = []
    fact.append(1) #0! = 1
    for i in range(1,N+1):
        a = fact[i-1]*i % BIGMOD
        fact.append(a)
    return fact

def modInvFact(fact):
    invFact = []
    for i in range(1,N+2):
        a = modPow(fact[i-1],BIGMOD-2)
        invFact.append(a)
    return invFact

def modPlus(a,b):
    return (a + b) % BIGMOD

def modMinus(a,b):
    if a-b >= 0:
        return (a - b) % BIGMOD
    else:
        return (a - b + BIGMOD)
    
def modMulti(a,b):
    return a * b % BIGMOD

# fact(n),invFact(r),invFact(n-r)
def nCr(fact,invFact,n,r):
    return (fact[n] * invFact[r] * invFact[n-r] ) %BIGMOD

def nPr(fact,invFact,n,r):
    return(fact[n] * invFact[r])%BIGMOD

def fact(num):
    ans = 1
    for i in range(1,num+1):
        ans = ans*i%BIGMOD
    return ans

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

S = list(set(D))
S.sort()
if S[0]==0:
    S.pop(0)
ans = 1
before = 0
before_i = 0
for i in S:
    if i == 1:
        before = D.count(i)
        before_i = i
        continue
    ans = ans*modPow(before,D.count(i))%BIGMOD
    before = D.count(i)
    if i - before_i!=1:
        ans = 0
    before_i = i
if D[0] >0:
    print(0)
else:
    print(ans)

### FIXED CODE ###

BIGMOD = 998244353
 
def modPow(x,n):
    ans = 1
    while n >= 1:
        if bin( n & 1)==bin(1):
            ans = (ans*x) % BIGMOD
        x = x * x % BIGMOD
        n = n>>1
    return ans % BIGMOD
 
def modFact(N):
    fact = []
    fact.append(1) #0! = 1
    for i in range(1,N+1):
        a = fact[i-1]*i % BIGMOD
        fact.append(a)
    return fact
 
def modInvFact(fact):
    invFact = []
    for i in range(1,N+2):
        a = modPow(fact[i-1],BIGMOD-2)
        invFact.append(a)
    return invFact
 
def modPlus(a,b):
    return (a + b) % BIGMOD
 
def modMinus(a,b):
    if a-b >= 0:
        return (a - b) % BIGMOD
    else:
        return (a - b + BIGMOD)
    
def modMulti(a,b):
    return a * b % BIGMOD
 
# fact(n),invFact(r),invFact(n-r)
def nCr(fact,invFact,n,r):
    return (fact[n] * invFact[r] * invFact[n-r] ) %BIGMOD
 
def nPr(fact,invFact,n,r):
    return(fact[n] * invFact[r])%BIGMOD
 
def fact(num):
    ans = 1
    for i in range(1,num+1):
        ans = ans*i%BIGMOD
    return ans
 
import collections
 
N = int(input())
D = list(map(int,input().split()))
 
S = list(set(D))
S.sort()
if S[0]==0:
    S.pop(0)
ans = 1
before = 0
before_i = 0
c = collections.Counter(D)
if c[0] > 1:
  ans=0
for i in S:
    if i == 1:
        before = c[i]
        before_i = i
        continue
    ans = ans*modPow(before,c[i])%BIGMOD
    before = c[i]
    if i - before_i!=1:
        ans = 0
    before_i = i
if D[0] >0:
    print(0)
else:
    print(ans)
### BUGGY CODE ###

#DP D
n,W=map(int,input().split())
wv=[list(map(int,input().split())) for _ in range(n)]
def dp(i, j):
    w,v=wv[i]
    if i==-1:
        return 0
    elif j<w:
        return dp(i-1, j)
    else:
        return max(dp(i-1, j),dp(i-1, j-w)+v)
print(dp(n-1,W))

### FIXED CODE ###

#DP D
n,W=map(int,input().split())
wv=[list(map(int,input().split())) for _ in range(n)]
dp=[[0]*(W+1) for _ in range(n+1)]
for i in range(n):
    w,v=wv[i]
    for j in range(W+1):
        if j<w:
            dp[i+1][j]=dp[i][j]
        else:
            dp[i+1][j]=max(dp[i][j],dp[i][j-w]+v)
print(dp[-1][-1])
### BUGGY CODE ###

N, K = list(map(int, input().split()))
links = [list(map(int, input().split())) for _ in range(N-1)]

def perm(a, b):
    s = 1
    for i in range(a-b+1, a+1):
        s *= i
    return s

if N == 1:
    print(K)
elif K == 1:
    print(0)
else:
    mod = 1000000007
    d = {}
    for a, b in links:
        if a in d:
            d[a].append(b)
        else:
            d[a] = [b]
        if b in d:
            d[b].append(a)
        else:
            d[b] = [a]
    for j in d[1]:
        d[j].remove(1)
    ans = K * perm(K - 1, len(d[1]))
    root = d[1]
    a = K - 2
    while True:
        children = []
        for i in root:
            for j in d[i]:
                d[j].remove(i)
            b = len(d[i])
            if a < b:
                print(0)
                break
            if b == 0:
                continue
            ans *= perm(a, b)
            children.extend(d[i])
        else:
            if children == []:
                print(ans % mod)
                break
            root = children
            continue
        break

### FIXED CODE ###

N, K = list(map(int, input().split()))
l = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    l[a].append(b)
    l[b].append(a)

deg1 = [0] * (N + 1)
deg2 = [0] * (N + 1)
history = [True] * (N + 1)
stack = [1]
ans = 1

while stack:
    node = stack.pop()
    ans *= K - deg1[node] - deg2[node]
    ans %= 1000000007
    history[node] = False
    for child in l[node]:
        if history[child]:
            deg1[child] += 1
            deg2[child] += deg1[node]
            deg1[node] += 1
            stack.append(child)
            
print(ans)
### BUGGY CODE ###

number = int(input())
character = input()
count = 0
for i in range(number - 3):
    first_character = character[i]
    for j in range(i + 1, number -1):
        second_character = character[j]
        if first_character == second_character:
            continue
        for k in range(j + 1, number):
            if j  - i == k - j:
                continue
            third_character = character[k]
            if first_character == third_character or second_character == third_character:
                continue
            count += 1

print(count)

### FIXED CODE ###

number = int(input())
character = input()
rnumber = character.count('R')
gnumber = character.count('G')
bnumber = character.count('B')
count = rnumber*gnumber*bnumber

for j in range(1, number):
    for i in range(j):
        k = j + (j - i)
        if k >= number:
            continue    
        if character[i] ==character[j]:
            continue
        if character[i] == character[k]:
            continue
        if character[j] == character[k]:
            continue
        count -= 1


print(count)
### BUGGY CODE ###

s = input()
k = int(input())
sbst = set()
for i in range(1, len(s)+1):
    for j in range(len(s)-i+1):
        sbst.add(s[j:j+i])
sbstl = sorted(list(sbst))
print(sbstl[k-1])


### FIXED CODE ###

# 5000**2、5000**3
# 5文字以下だよ。辛いよ。
s = input()
k = int(input())
sbst = set()
for i in range(1, k+1):
    for j in range(len(s)-i+1):
        sbst.add(s[j:j+i])
sbstl = sorted(list(sbst))
print(sbstl[k-1])
### BUGGY CODE ###

N = int(input())
S = list(input().split()[0])
min = N

for i in range(N):
  cnt = 0
  for j in range(N):
    if j < i and S[j] == 'W':
      cnt += 1
    if i < j and S[j] == 'E':
      cnt += 1
  if min > cnt: min = cnt 

print(min)

### FIXED CODE ###

N = int(input())
S = input()
min = S[1:N].count('E')
now = S[1:N].count('E')

for i in range(1,N):
  if S[i-1] == 'E' and S[i] == 'E':
    now -= 1
  if S[i-1] == 'W' and S[i] == 'W':
    now += 1
  if now < min:
    min = now

print(min)
### BUGGY CODE ###

N=int(input())
a=[-1]*(N+1)
for i in range(1,N+1):
  a[i]=int(input())
pos = 1
prev=[1]  
while(pos!= 2):
  pos = a[pos]
  if pos in prev:
    print(-1)
    exit(0)
  else:
    prev.append(pos)
print(len(prev) - 1)

### FIXED CODE ###

N=int(input())
a=[-1]*(N+1)
for i in range(1,N+1):
  a[i]=int(input())
pos = 1
ans = 0
for _ in range(N):
  if pos == 2:
    print(ans)
    exit(0)
  pos = a[pos]
  ans += 1
  

print(- 1)
### BUGGY CODE ###

from bisect import bisect_left
N, M = list(map(int, input().split()))
As = list(map(int, input().split()))
cards = {}
for i in range(N):
    cards[As[i]] = cards.get(As[i], 0) + 1
sorted_keys = list(sorted(cards.keys()))

for i in range(M):
    b, c = list(map(int, input().split()))
    cnt = 0
    for k in sorted_keys[0:bisect_left(sorted_keys, c)]:
        for _ in range(cards.get(k,0)):
            cards[k] = cards[k] - 1
            if cards[k] == 0:
                del(cards[k])
                sorted_keys.remove(k)
            cards[c] = cards.get(c, 0) + 1
            if c not in sorted_keys:
                sorted_keys.insert(bisect_left(sorted_keys, c),c )
            cnt += 1
            # print('aaa:   ', b, c, cnt)
            if cnt >= b:
                break
        if cnt >= b:
            break
    # print()
    # print(cards)
    # print()

# print(list(cards.items()))
print(sum([k * cnt for k,cnt in cards.items()]))




### FIXED CODE ###

N, M  = map(int,input().split())
As = sorted(list(map(int,input().split())))
di = {}
for i in range(M):
    b, c = map(int,input().split())
    di[c] = di.get(c, 0) + b

keys = list(sorted(di.keys(), reverse=True))
ichi = 0
for i in range(N):
    try:
        if keys[ichi] > As[i]:
            As[i] = keys[ichi]
            di[keys[ichi]] -= 1
        else:
            break
        if di[keys[ichi]] == 0:
            ichi += 1
    except:
        pass
print(sum(As))
### BUGGY CODE ###

abc_s = input()
abc_a = abc_s.split(" ")
abc = [int(x) for x in abc_a]

sorted = False

while sorted == False:
  sorted == True
  if abc[0] > abc[1]:
    sorted == False
    tmp = abc[0]
    abc[0] = abc[1]
    abc[1] = tmp
  if abc[1] > abc[2]:
    sorted == False
    tmp = abc[1]
    abc[1] = abc[2]
    abc[2] = tmp

print("{0} {1} {2}".format(abc))


### FIXED CODE ###

abc_s = input()
abc_a = abc_s.split(" ")
abc = [int(x) for x in abc_a]
 
sorted = False
 
while sorted == False:
  sorted = True
  if abc[0] > abc[1]:
    sorted = False
    tmp = abc[0]
    abc[0] = abc[1]
    abc[1] = tmp
  if abc[1] > abc[2]:
    sorted = False
    tmp = abc[1]
    abc[1] = abc[2]
    abc[2] = tmp
 
print("{0[0]} {0[1]} {0[2]}".format(abc))