Harryxun/stf_run huggingface dataset:
import sys
input = sys.stdin.readline
#from itertools import accumulate
#from itertools import combinations
N,K = map(int,input().split())
P = list(map(int,input().split()))
C = list(map(int,input().split()))

visited = [False]*(N+1)
loops = []
for v in range(1,N+1):
    if visited[v]:
        continue
    l = [v]
    while True:
        v = l[-1]
        visited[v] = True
        nv = P[v-1]
        if visited[nv]:
            break
        l.append(nv)
    loops.append(l)

cand = []
for loop in loops:
    temp = 0
    vals = [C[i-1] for i in loop]
    l = len(vals)
    vals2 = vals+vals[:-1]
    cumsum = [0]
    for v in vals2:
        cumsum.append(cumsum[-1] + v)
    #cumsum = [0] + list(accumulate(vals2))
    gh = []
    #print(vals)
    if K <= l:
        for left in range(0,2*l-K):
            for right in range(left+1,left+K+1):
                gh.append(cumsum[right] - cumsum[left])
        temp = max(gh)
    else:
        s = sum(vals)
        q, r = divmod(K,l)
        for left in range(0,2*l-r):
            for right in range(left+1,left+r+1):
                gh.append(cumsum[right] - cumsum[left])
        temp = max(gh)
        if s > 0:
            temp += q * s
    #print(temp)
    cand.append(temp)
print(max(cand))






### FIXED CODE ###

import sys
input = sys.stdin.readline
#from itertools import accumulate
#from itertools import combinations
N,K = map(int,input().split())
P = list(map(int,input().split()))
C = list(map(int,input().split()))

#N,K = 4,4
#P = [2,3,4,1]
#C = [-9,9,1,-1]
#N = 5000
#K = 10**8
#P = [i+1 for i in range(1,5000)] + [1]
#C = [10**9] * N

visited = [False]*(N+1)
loops = []
for v in range(1,N+1):
    if visited[v]:
        continue
    l = [v]
    while True:
        v = l[-1]
        visited[v] = True
        nv = P[v-1]
        if visited[nv]:
            break
        l.append(nv)
    loops.append(l)

cand = []
for loop in loops:
    temp = 0
    vals = [C[i-1] for i in loop]
    l = len(vals)
    vals3 = vals+vals+vals[:-1]
    cumsum = [0]
    for v in vals3:
        cumsum.append(cumsum[-1] + v)
    gh = []
    #print(vals)
    if K <= l:
        temp = 0
        ma = min(vals)
        for left in range(0,2*l-K):
            for right in range(left+1,left+K+1):
                ma = max(ma,(cumsum[right] - cumsum[left]))
        temp += ma
    else:
        temp = 0
        s = sum(vals)
        q, r = divmod(K,l)
        q -= 1
        r += l
        ma = min(vals)
        for left in range(0,3*l-r):
            for right in range(left+1,left+r+1):
                ma = max(ma,(cumsum[right] - cumsum[left]))
        temp += ma
        if s > 0:
            temp += q * s
    cand.append(temp)
print(max(cand))
N, M = map(int, input().split())

md = []
for i in range(0,N):
  d, m = map(int, input().split())
  md.append({"m":m, "d":d-1})

md = sorted(md, key=lambda x:x["m"], reverse=True)

def aa(sh, idx, M, x, ans):
  if idx >= M:
    return sh, ans, x
  elif sh[idx] == 0:
    sh[idx] = idx+1
    sh[x["d"]] = idx+1
    ans += x["m"]
    return sh, ans, x
  else:
    sh, ans, x = aa(sh, sh[idx], M, x, ans)
    sh[idx] = sh[x["d"]]
    idx = sh[idx]
    return sh, ans, x
  
sh = [0]*M
ans = 0
for x in md:
  idx = x["d"]
  sh, ans, x = aa(sh, idx, M, x, ans)
print(ans)

### FIXED CODE ###

def insertHeap(array, val):
    array.append(val)
    n = len(array)-1
    while n != 0:
        parent = int((n - 1) / 2)
        if array[n] > array[parent]:
            tmp = array[n]
            array[n] = array[parent]
            array[parent] = tmp
            n = parent
        else:
            break
    return array

def desertHeap(array):
    if array == []:
      return None
    array[0], array[-1] = array[-1], array[0]
    res = array.pop(-1)
    n = len(array)
    if n == 0 or n == 1: 
      return res
    parent = 0
    while True:
        child = 2 * parent + 1
        if child >= n: break
        if (child + 1 < n) and array[child] < array[child + 1]:
            child += 1
        if array[parent] < array[child]:
            array[child], array[parent] = array[parent], array[child]
            parent = child;
        else:
            break
    return res

n, m = map(int, input().split())
 
li = [[] for j in range(10**5+1)]
 
for _ in range(n):
  a, b = map(int, input().split())
  li[a].append(b)
 
ans = 0
jobsHeap = []
for i in range(1, m+1):
  for val in li[i]:
    jobsHeap = insertHeap(jobsHeap, val)
  
  if jobsHeap != []:
    res = desertHeap(jobsHeap)
    ans += res
print(ans)
l=[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(l[int(input())])

### FIXED CODE ###

l=[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(l[int(input())-1])
n, m = map(int, input().split())

if n % 2 == 0:
    i = 1
    while i <= m:
        if i < (n - 2) // 2
            a_i = str(i)
        else:
            a_i = str(i + 1)
        b_i = str(n - i)
        
        print(a_i)
        i += 1
        
elif n % 2 == 1:
    for i in range(1, m + 1):
        a_i = str(i)
        b_i = str(n - i)
        
        print(a_i + " " + b_i)


### FIXED CODE ###

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

if n % 2 == 0:
    i = 1
    while i <= m:
        a_i = str(i)
        
        if i <= (n - 2) // 4:
            b_i = str(n - i)
        else:
            b_i = str(n - i - 1)
        
        print(a_i + " " + b_i)
        i += 1
        
elif n % 2 == 1:
    for i in range(1, m + 1):
        a_i = str(i)
        b_i = str(n - i)
        
        print(a_i + " " + b_i)
import math

def A():
    a=int(input())
    b=int(input())
    c=int(input())
    A=math.sqrt(a)
    B=math.sqrt(b)
    C=math.sqrt(c)
    if A+B<C:
        print("Yes")
    else:
        print("No")

if __name__=='__main__':
    A()

### FIXED CODE ###

my_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]
N = input()
N = int(N)
print(my_list[N-1])
a,b = map(int,input())
ans = (a-1)
if a<=b:
  ans+=1
print(ans)

### FIXED CODE ###

a,b = map(int,input().split())
ans = a-1
if a<=b:
  ans+=1
print(ans)
S = input()
count = 0
res = []
for i in range(len(S)):
    try:
        if S[i] in ["A", "C", "G", "T"]:
            count += 1
        else:
            res.append(count)
            count = 0
    except:
        continue
print(max(res))

### FIXED CODE ###

s = input()
ans=0
now=0
for a in s:
    if a in ["A", "C", "G", "T"]:
        now+=1
    else:
        now=0
    ans=max(ans,now)
print(ans)
import math

def lcm(x,y):
  return (x*y) // math.gcd(x,y)

A,B,C,D = [int(x) for x in input().split(' ')]
a = (B - A + 1) 
b = ((B // C) - ((A-1) // C))
c = ((B // D) - ((A-1) // D))
CD = lcm(C,D)
d = ((B // (CD)) - ((A-1) // (CD)))
q = a - b - c + d
print(q)

### FIXED CODE ###

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
  
def lcm(a, b):
	return a * b // gcd (a, b)

A,B,C,D = [int(x) for x in input().split(' ')]
a = (B - A + 1) 
b = ((B // C) - ((A-1) // C))
c = ((B // D) - ((A-1) // D))
CD = lcm(C,D)
d = ((B // (CD)) - ((A-1) // (CD)))
q = a - b - c + d
print(q)
import math

a, b = map(int, input().split())
print(a / math.gcd(a, b) * b)


### FIXED CODE ###

import fractions

a, b = map(int, input().split())
print(a // fractions.gcd(a, b) * b)
w, h, x, y = map(int, input().split())
ans = []

ans.append('{:.7f}'.format(w*h/2))

if w % x == 0 and h % y == 0:
    ans.append(1)
else:
    ans.append(0)

print(*ans, sep=' ')

### FIXED CODE ###

w, h, x, y = map(int, input().split())
ans = []

if w == x*2 and h == y*2:
    ans.append('{:.7f}'.format(w*h/2))
    ans.append(1)
else:
    ans.append('{:.7f}'.format(w*h/2))
    ans.append(0)

print(*ans, sep=' ')
# -*- coding: utf-8 -*-
"""
Created on Mon Jan 21 20:39:09 2019

@author: Yamazaki Kenichi
"""

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

A.sort(reverse = True,key=lambda x:x[1])
ans = 0
eat,noteat =[],[]
a = [0 for i in range(N)]
k = K
for i in range(N):
    if k == -1:
        break    
    if a[A[i][0]] ==0:
        a[A[i][0]] = 1
        eat.append(A[i][1])
        k -= 1
    else:
        noteat.append(A[i][1])
ans += sum(eat)
ans += sum(noteat[:k])
ans += pow(K-k,2)

for i in range(1,min(K-k,len(noteat))):
    if pow(K-k,2)+eat[-i] < pow(K-k-i,2)+noteat[k:][i-1]:
        ans = ans-(pow(K-k,2)+eat[-i]) +(pow(K-k-i,2)+noteat[k:][i-1])
    else:
        break
print(ans)

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Mon Jan 21 20:39:09 2019

@author: Yamazaki Kenichi
"""

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

A.sort(reverse = True,key=lambda x:x[1])
eat,noteat =[],[]
a = [0 for i in range(N+1)]
k = K
for i in range(N):
    if k != 0:
        if a[A[i][0]] ==0:
            a[A[i][0]] = 1
            eat.append(A[i][1])
            k -= 1
        else:
            noteat.append(A[i][1])
    else:
        noteat.append(A[i][1])
        
ans = [0 for i in range(min(K-k,len(noteat))+2)]
ans[0] = sum(eat)+ sum(noteat[:k])+ pow(K-k,2)

for i in range(1,min(K-k,len(noteat[k:])+1)):
    ans[i] = ans[i-1]-(pow(K-k-(i-1),2)+eat[-i]) +(pow(K-k-i,2)+noteat[k+i-1])

print(max(ans))
#!/usr/bin/env python3
import sys
import numpy as np

def solve(N: int, A: "List[int]"):
    K = np.eye(N)
    for i in range(N-1):
        K[i, i+1] = 1
    K[N-1, 0] = 1
    A = [2 * a for a in A]
    B = np.dot(np.linalg.inv(K), np.array(A))
    s = ' '.join([str(int(b)) for b in B])
    print(s)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys

def solve(N: int, A: "List[int]"):
    X = []
    x1 = sum(A) - sum(A[1::2]) * 2
    X.append(x1)
    for i in range(1, N):
        X.append(2 * A[i-1] - X[i-1])
    s = ' '.join([str(x) for x in X])
    print(s)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()
s = int(input())
a = set(s)
p = s
n = 0
cnt = 0
while True:
  if n in a:
    print(cnt)
    exit()
  if p&1:
    n = 3*p +1
  else:
    n = p//2
  cnt += 1
  a.add(n)
  p = n


### FIXED CODE ###

s = int(input())
a = set([s])
p = s
n = 0
cnt = 1
while True:
  if n in a:
    print(cnt)
    exit()
  a.add(n)
  if p&1:
    n = 3*p +1
  else:
    n = p//2
  cnt += 1
  p = n
N = int(input())

ac, wa, tle, re = 0, 0, 0, 0

for _ in range(N):
    S = int(input())
    if S == 'AC':
        ac+=1
    elif S == 'WA':
        wa+=1
    elif S == 'TLE':
        tle+=1
    elif S == 'RE':
        re+=1

print('AC x %d'%ac)
print('WA x %d'%wa)
print('TLE x %d'%tle)
print('RE x %d'%re)

### FIXED CODE ###

N = int(input())

ac, wa, tle, re = 0, 0, 0, 0

for i in range(N):
  S = input()
  if S=='AC':
    ac+=1
  elif S=='WA':
    wa+=1
  elif S=='TLE':
    tle+=1
  elif S=='RE':
    re+=1

print('AC x %d'%ac)
print('WA x %d'%wa)
print('TLE x %d'%tle)
print('RE x %d'%re)
a, b = map(int, input().split())

if a = b:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

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

if a == b:
    print("Yes")
else:
    print("No")
import sys
input = sys.stdin.readline
mod = 10**9 + 7
n = int(input())
ab = [[int(x) for x in input().split()] for _ in range(n)]
from collections import defaultdict, Counter
import math
double_zero_cnt = 0
a_zero_cnt = 0
b_zero_cnt = 0
d = defaultdict(list) # [a, b] ngのそれぞれの個数
a_b = []
b_a = []
for a, b in ab:
    if a == 0 and b == 0:
        double_zero_cnt += 1
        continue
    elif a == 0:
        a_zero_cnt += 1
        continue
    elif b == 0:
        b_zero_cnt += 1
        continue
    g = math.gcd(a, b)
    a //= g
    b //= g
    if b < 0:
        b *= (-1)
        a *= (-1) # 必ずbは正
    a_b.append((a, b))
c = Counter(a_b)
key_list = list(c.keys())
for key in key_list:
    a, b = key
    if a < 0:
        a *= (-1)
        b *= (-1)
    if d[(-b, a)] != []:
        continue
    if c[(-b, a)] != 0:
        d[(a, b)] = [c[(a, b)], c[(-b, a)]]
ans = 1
used_cnt = double_zero_cnt
for key in d.keys():
    if d[key] == []:
        continue
    x, y = d[key]
    used_cnt += (x + y)
    mul = (pow(2, x, mod) + pow(2, y, mod) - 1) % mod
    ans *= mul
    ans %= mod
if a_zero_cnt > 0 or b_zero_cnt > 0:
    ans *= (pow(2, a_zero_cnt, mod) + pow(2, b_zero_cnt, mod) - 1)
    ans %= mod
    used_cnt += a_zero_cnt + b_zero_cnt
ans *= pow(2, n - (used_cnt), mod)
ans %= mod
ans -= 1
ans += double_zero_cnt
ans %= mod
print(ans)







### FIXED CODE ###

import sys
input = sys.stdin.readline
mod = 10**9 + 7
n = int(input())
ab = [[int(x) for x in input().split()] for _ in range(n)]
from collections import defaultdict, Counter
import math
double_zero_cnt = 0
a_zero_cnt = 0
b_zero_cnt = 0
d = defaultdict(list) # [a, b] ngのそれぞれの個数
a_b = []
for a, b in ab:
    if a == 0 and b == 0: 
        double_zero_cnt += 1
        continue
    elif a == 0:
        a_zero_cnt += 1
        continue
    elif b == 0:
        b_zero_cnt += 1
        continue
    g = math.gcd(a, b)
    a //= g
    b //= g
    if b < 0:
        b *= (-1)
        a *= (-1) # 必ずbは正
    a_b.append((a, b))
c = Counter(a_b)
key_list = list(c.keys())
for key in key_list:
    a, b = key
    if a < 0:
        a_ = a*(-1)
        b_ = b*(-1)
    else:
        a_ = a
        b_ = b
    if d[(-b_, a_)] != []:
        continue
    if c[(-b_, a_)] != 0:
        d[(a, b)] = [c[(a, b)], c[(-b_, a_)]]
ans = 1
used_cnt = double_zero_cnt
for key in d.keys():
    if d[key] == []:
        continue
    x, y = d[key]
    used_cnt += (x + y)
    mul = (pow(2, x, mod) + pow(2, y, mod) - 1) % mod
    ans *= mul
    ans %= mod
if a_zero_cnt > 0 and b_zero_cnt > 0:
    ans *= (pow(2, a_zero_cnt, mod) + pow(2, b_zero_cnt, mod) - 1)
    ans %= mod
    used_cnt += a_zero_cnt + b_zero_cnt
elif a_zero_cnt > 0:
    ans *= pow(2, a_zero_cnt, mod)
    ans %= mod
    used_cnt += a_zero_cnt
elif b_zero_cnt > 0:
    ans *= pow(2, b_zero_cnt, mod)
    ans %= mod
    used_cnt += b_zero_cnt
ans *= pow(2, n - (used_cnt), mod)
ans %= mod
ans -= 1
ans += double_zero_cnt
ans %= mod
print(ans)
import collections
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = []
C = []
for i in range(Q):
    input_q = list(map(int, input().split()))
    B.append(input_q[0])
    C.append(input_q[1])
    
A_sum = sum(A)
CONST_MAX = 100000
count_list = [0] * CONST_MAX

# for i in range(CONST_MAX):
#     count_list[i] = A.count(i)
c = collections.Counter(A)
for k, v in c.items():
    # print(k, v)
    count_list[k] = v


for i in range(Q):
    count_list[C[i]] += count_list[B[i]]
    A_sum += (C[i] - B[i]) * count_list[B[i]]
    count_list[B[i]] = 0
    # print(count_list)

    print(A_sum)


### FIXED CODE ###

import collections
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = []
C = []
for i in range(Q):
    input_q = list(map(int, input().split()))
    B.append(input_q[0])
    C.append(input_q[1])
    
A_sum = sum(A)
CONST_MAX = 100001
count_list = [0] * CONST_MAX

c = collections.Counter(A)
for k, v in c.items():
    # print(k, v)
    count_list[k] = v


for i in range(Q):
    count_list[C[i]] += count_list[B[i]]
    A_sum += (C[i] - B[i]) * count_list[B[i]]
    count_list[B[i]] = 0
    # print(count_list)

    print(A_sum)
def better(l, i, ready, ans):
    #print(l, i, ready, ans)
    if i==0:
        ready[0]=True
        ans[0]=0
        return l[0], 0
    if i==1:
        ready[1]=True
        ans[1]=abs(l[0]-l[1])
        return l[1], abs(l[0]-l[1])
    else:
        if ready[i]:
            return l[i], ans[i]
        else:
            last, val = better(l, i-1, ready, ans)
            last1, val1 = better(l, i-2, ready, ans)
            #print(last, val, last1, val1)
            xx = min([(abs(last-l[i])+val), (abs(last1-l[i])+val1)])
            ready[i]=True
            ans[i]=xx
            return l[i], xx
n = int(input())
l = list(map(int, input().split()))
if n==0:
    print(0)
    import sys
    sys.exit()
print(better(l, n-1, [False]*n, [0]*n)[1])

### FIXED CODE ###

import math
def better(l, ans):
    for i in range(2, n):
        ans[i] = min(ans[i - 1] + abs(l[i]-l[i - 1]), ans[i - 2] + abs(l[i]-l[i - 2]))
    return ans
n = int(input())
l = list(map(int, input().split()))
ans = [0] * n
ans[1] = abs(l[1]-l[0])
print(better(l, ans)[len(ans)-1])
N = int(input())
D = int(input())
an=0
for i in range(N):
  X, Y= map(int, input().split())
  if X**2+Y**2<=D**2:
    an +=1
print(an)   


### FIXED CODE ###

N, D = map(int, input().split())
an=0
for i in range(N):
  X, Y= map(int, input().split())
  if X**2+Y**2<=D**2:
    an +=1
print(an)
d,n=map(int,intput().split())
print(n*10**(2*d))

### FIXED CODE ###

d,n=map(int,input().split())
if n == 100: n = 101
print(n*10**(2*d))
s = int(input())
t = int(input())
a = 0
if s[0] == t[0]: a = a + 1
if s[1] == t[1]: a = a + 1
if s[2] == t[2]: a = a + 1
print(a)

### FIXED CODE ###

s = input()
t = input()
a = 0
if s[0] == t[0]: a = a + 1
if s[1] == t[1]: a = a + 1
if s[2] == t[2]: a = a + 1
print(a)
# cook your dish here
import sys
import math
# sys.stdin=open('input.txt','r')
# sys.stdout=open('output2.txt','w')
from sys import stdin,stdout
from collections import deque,defaultdict
from math import ceil,floor,inf,sqrt,factorial,gcd,log2
from copy import deepcopy
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
mod=1000000007
# print('hi')
n,m,k=iia()
arr=[input()for i in range(n)]
res=0
for i in range(2**n):
    for j in range(2**m):
        ans=0
        for ii in range(n):
            for jj in range(m):
                if i>>ii & 1 and j>>jj &1 and arr[ii][jj]=='#':
                    ans+=1
        if ans==k:
            res+=1
print(res)



### FIXED CODE ###

import sys
import math
# sys.stdin=open('input.txt','r')
# sys.stdout=open('output2.txt','w')
from sys import stdin,stdout
from collections import deque,defaultdict
from math import ceil,floor,inf,sqrt,factorial,gcd,log2
from copy import deepcopy
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
mod=1000000007

n=ii1()
ans=1000*(1+ n//1000)
if n%1000==0:
    print(0)
else:
    print(ans-n)
import math
inputs = input().split()
A, B, H, M = int(inputs[0]), int(inputs[1]), int(inputs[2]), int(inputs[3])
num_diff = H*5 - M
ans1=ans2=ans3=0
if num_diff > 30:
    ans = math.sqrt(A**2 + B**2 - 2 * A * B * math.cos(( (30 -(num_diff)) * 6 )/180 * math.pi) )
#    print('case 1')
#elif num_diff < 0:
#	ans = math.sqrt(A**2 + B**2 - 2 * A * B * math.cos(( (30 +(num_diff)) * 6 )/180 * math.pi) )
#	print('case 2')
else:
	if H <=6 and M <=30:
	    ans = math.sqrt(A**2 + B**2 - 2 * A * B * math.cos(( (num_diff) * 6 )/ 135 * math.pi) )
#	    print('case 3')
	elif H >=6 and M >= 30:
	    ans = math.sqrt(A**2 + B**2 - 2 * A * B * math.cos(( (num_diff) * 6 )/ 135 * math.pi) )
#	    print('case 4')

print(ans)

### FIXED CODE ###

import math
inputs = input().split()
A, B, H, M = int(inputs[0]), int(inputs[1]), int(inputs[2]), int(inputs[3])
num_diff = H*5+M/12 - M

ans = math.sqrt(A**2 + B**2 - 2 * A * B * math.cos(2 * math.pi * ( num_diff / 60 )))
print(ans)
o = input()
n1 = len(o)
e = input()
n2 = len(e)
for i in range(max(n1,n2)):
  print(o[i] + e[i], end = "")

### FIXED CODE ###

o = input()
n1 = len(o)
e = input()
n2 = len(e)
if n1 == n2:
  for i in range(n1):
    print(o[i] + e[i], end = "")
else:
  for i in range(n2):
    print(o[i] + e[i], end = "")
  print(o[n1 - 1])
import heapq as hq

def f():
    # N = int(input())
    N, M = map(int, input().split())
    A = sorted(list(map(int, input().split())))

    H = []
    for m in range(M):
        B, C = map(int, input().split())
        hq.heappush(H, (-C, B))

    index = 0
    res = sum(A)
    for n in range(M):
        c, b = hq.heappop(H)
        c *= -1

        for _ in range(b):
            if A[index] < c:
                res += (c - A[index])
                index += 1
            else:
                return res
    return res

print(f())


### FIXED CODE ###

import heapq as hq

def f():
    # N = int(input())
    N, M = map(int, input().split())
    A = sorted(list(map(int, input().split())))

    H = []
    for m in range(M):
        B, C = map(int, input().split())
        hq.heappush(H, (-C, B))

    index = 0
    res = sum(A)
    for n in range(M):
        c, b = hq.heappop(H)
        c *= -1

        for _ in range(b):
            if A[index] < c:
                res += (c - A[index])
                index += 1
                if index == N:
                    return res
            else:
                return res
    return res

print(f())
a_set = set()
while len(a_set) < N:
    for i in range(11, 55555, 10):
        if i in a_set:
            continue
        elif not is_prime_num(i):
            continue
        else:
            a_set.add(i)
            break

print(' '.join(map(str, a_set)))

### FIXED CODE ###

from math import sqrt, floor, ceil
from itertools import combinations


N = int(input())

# O(num^(1/2))
def is_prime_num(num):
    num_sqrted = floor(sqrt(num))
    for i in range(2, num_sqrted + 1):
        if num % i == 0:
            return False
    else:
        return True

a_set = set()
while len(a_set) < N:
    for i in range(11, 55555, 10):
        if i in a_set:
            continue
        elif not is_prime_num(i):
            continue
        else:
            a_set.add(i)
            break

print(' '.join(map(str, a_set)))
import sys
input = sys.stdin.readline

n = int(input())
al = list(map(int,input().split()))

from collections import defaultdict
G = defaultdict(list)

for _ in range(n-1):
    u,v = map(int,input().split())
    G[u-1].append(v-1)
    G[v-1].append(u-1)

import bisect
ansl = [0 for i in range(n)]
dp = [float("inf") for _ in range(n)]
used = [0 for i in range(n)]
used[0] = 1


stack = []
def dfs(pos, dp):
    idx = bisect.bisect_right(dp, al[pos])
    stack.append((idx, dp[idx]))
    dp[idx] = min(al[pos], dp[idx])
    ansl[pos] = bisect.bisect_left(dp, 10**18)
    for v in G[pos]:
        if used[v] == 0:
            used[v] = 1
            dfs(v, dp)
            idx, k = stack.pop()
            dp[idx] = k


dfs(0, dp)
flag = False
for i in range(n):
    print(ansl[i])




### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

import sys
input = sys.stdin.readline

n = int(input())
al = list(map(int,input().split()))

from collections import defaultdict
G = defaultdict(list)

for _ in range(n-1):
    u,v = map(int,input().split())
    G[u-1].append(v-1)
    G[v-1].append(u-1)

from bisect import bisect
ansl = [0 for i in range(n)]
dp = [float("inf") for _ in range(n+1)]
dp[0] = -1
used = [0 for i in range(n)]
used[0] = 1


stack = []
def dfs(pos):
    idx = bisect(dp, al[pos] - 1)
    stack.append((idx, dp[idx]))
    dp[idx] = min(al[pos], dp[idx])
    ansl[pos] = bisect(dp, 10**18) - 1
    for v in G[pos]:
        if used[v] == 0:
            used[v] = 1
            dfs(v)
            idx, k = stack.pop()
            dp[idx] = k


dfs(0)
flag = False
for i in range(n):
    print(ansl[i])
N = int(raw_input())
A = map(int, raw_input().split())
sum = 0
A.sort()
A = A[::2]
print sum(A)


### FIXED CODE ###

N = int(raw_input())
A = map(int, raw_input().split())
sum = 0
A.sort()
B = A[::2]
x = 0
for i in B:
    x = x + i
    pass
print x