Harryxun/stf_run huggingface dataset:
if b >= 0 and d >= 0 and a <= 0 and c <= 0:
    e = b*d
    f = a*c
    if e > f:
        print(e)
    else:
        print(f)
else:
    e = abs(a)
    f = abs(b)
    g = abs(c)
    h = abs(d)
    l = [e,f,g,h]
    l.sort()
    print(-1*l[0]*l[1])

### FIXED CODE ###

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

if b >= 0 and d >= 0 and a <= 0 and c <= 0:# - + - + = +
    e = b*d
    f = a*c
    if e > f:
        print(e)
    else:
        print(f)
elif a >= 0 and b >= 0 and c >= 0 and d >= 0: #+ + + +
    print(b*d)
elif a <= 0 and b <= 0 and c <= 0 and d <= 0: #- - - - = -
    print(a*c)
elif a >= 0 and b >= 0 and c <= 0 and d <= 0: #+ + - -
    print(a*d)
elif a >= 0 and b >= 0 and c <= 0 and d >= 0: # + + - +
    print(b*d)
elif a <= 0 and b <= 0 and c >= 0 and d >= 0: # - - + +
    print(b*c)
elif a <= 0 and b <= 0 and c <= 0 and d >= 0: # - - - +
    print(a*c)
elif a <= 0 and b >= 0 and c >= 0 and d >= 0: # - + + +
    print(b*d)
elif a <= 0 and b >= 0 and c <= 0 and d <= 0: # - + - -
    print(a*c)
from collections import deque

H, W = map(int, input().split())
edges = ['#']*(W+2)
field = [edges]
dyx = [(0, 1), (0, -1), (1, 0), (-1, 0)]
bk = 0
for _ in range(H):
    line = list(input())
    bk += line.count('#')
    field.append(['#'] + line + ['#'])
field.append(edges)

steps = 1
q = deque()
field[1][1] = 1
q.append((1, 1, 1))

while q:
    cy, cx, lv = q.popleft()

    for dy, dx in dyx:
        ny, nx = dy+cy, dx+cx

        if field[ny][nx] == '.':
            field[ny][nx] = lv+1
            q.append((ny, nx, lv+1))
steps = field[H][W]

print(W*H-bk-steps)

### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())
edges = ['#']*(W+2)
field = [edges]
dyx = [(0, 1), (0, -1), (1, 0), (-1, 0)]
bk = 0
for _ in range(H):
    line = list(input())
    bk += line.count('#')
    field.append(['#'] + line + ['#'])
field.append(edges)

steps = 1
q = deque()
field[1][1] = 1
q.append((1, 1, 1))

while q:
    cy, cx, lv = q.popleft()

    for dy, dx in dyx:
        ny, nx = dy+cy, dx+cx

        if field[ny][nx] == '.':
            field[ny][nx] = lv+1
            q.append((ny, nx, lv+1))
steps = str(field[H][W])
if steps.isnumeric():
    print(W*H-bk-int(steps))
else:
    print(-1)
# -*- coding: utf-8 -*-
# abc127/abc127_c
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))


def main():
    N, M = i2nn()
    L, R = (0, N)
    for i in range(M):
        Li, Ri = i2nn()
        if L < Li:
            L = Li
        if Ri < R:
            R = Ri
    if L > R:
        print(0)
    else:
        print(R - L + 1)
    return

main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
# abc127/abc127_a
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    a,b = i2nn()
    if a >= 13:
        print(b)
    elif a >= 6:
        print(int(b / 2))
    else:
        print(0)

main()
s = list(input())
n = len(s)
k = ['R','U','D']
g = ['L','U','D']

for i in range(n):
    if i % 2 ==0:
        new2 = True if s[i] in k else False
    else:
        new1 =True if s[i] in g else False
       
if new2 == True and new1 == True:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

s = list(input())
n = len(s)
k = ['R','U','D']
g = ['L','U','D']
count =0

for i in range(n):
    if i % 2 ==0:
        if s[i] in k:
            count +=1
    else:
        if s[i] in g:
            count += 1
       
if count == n:
    print("Yes")
else:
    print("No")
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)


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


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


def lcm_list(numbers):
    x = 1
    for i in range(n):
        x = lcm_base(x, numbers[i])
        if x > 2*m:
            print(0)
            exit()

    return x


def count_two(x):
    count = 0
    while x%2 == 0:
        count += 1
        x //= 2
    return count


two_count = count_two(A[0])
for a in A[1:]:
    if two_count != count_two(a):
        print(0)
        exit()

LCM = lcm_list(A)
# print(LCM)
print((m - LCM//2)//LCM + 1)


### FIXED CODE ###

import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
# import math
from fractions import gcd

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)


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


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


def lcm_list(numbers):
    x = 1
    for i in range(n):
        x = lcm_base(x, numbers[i])
        if x > 2*m:
            print(0)
            exit()

    return x


def count_two(x):
    count = 0
    while x%2 == 0:
        count += 1
        x //= 2
    return count


two_count = count_two(A[0])
for a in A[1:]:
    if two_count != count_two(a):
        print(0)
        exit()

LCM = lcm_list(A)
# print(LCM)
print((m - LCM//2)//LCM + 1)
a,b,c,k = list(map(int,input().split()))
A = [1]*a
B = [0]*b
C = [-1]*c
new =A+B+C
print(sum(new[:k]))
  

### FIXED CODE ###

a,b,c,k = (map(int,input().split()))
if k<=a:
    print(k)
elif k <= a+b:
    print(a)
else:
    print(2*a+b-k)
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    n = int(input())
    N = list(str(n))
    
    tmp = 0
    for i in N:
        tmp += i
        
    if n % tmp == 0:
        print("Yes")
    else:
        print("No")
            	
if __name__ == "__main__":
	main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    n = int(input())
    N = list(str(n))
    
    tmp = 0
    for i in N:
        tmp += int(i)
        
    if n % tmp == 0:
        print("Yes")
    else:
        print("No")
            	
if __name__ == "__main__":
	main()
n,k = map(int,input().split())

if k==1 :
  ln=0
elif n>=k :
  if n//k==0:
    ln=0
else:
  while 1:
    ln = n
    n = abs(n-k)
    if ln<=n:
      break
print(ln)

### FIXED CODE ###

n,k = map(int,input().split())
 
if k==1 :
  ln=0
elif k==0 :
  ln=n
elif n>=k:
  a = n%k
  n=a
  while 1:
    ln = n
    n = abs(a-k)
    if ln<=n:
      break
else:
  while 1:
    ln = n
    n = abs(n-k)
    if ln<=n:
      break
print(ln)
k, s = list(map(int, input().split()))
count = 0
for i in range(k+1):
    for j in range(k+1):
        if (s-i-j <= k) and (0 <= s-i-j):
            count += 1
print(count)

### FIXED CODE ###

k, s = map(int,input().split())
count = 0
for i in range(k+1):
    for j in range(k+1):
            if 0<=(s-i-j)<=k:
                count += 1
print(count)
n = int(input())
sum = 0
for i in range(n):
    if i%5!=0 and i%3=0:
        sum = sum + 1
print(sum)

### FIXED CODE ###

n = int(input())
sum = 0
for i in range(1,n+1):
    if i%5!=0 and i%3!=0:
        sum = sum + i
print(sum)
x, y  = map(int, input().split())
mod = 10 ** 9 + 7
if (x + y) % 3 != 0:
    ans = 0
else:
    n, m = (2 * x - y) / 3, (2 * y - x) / 3
    if n >= 0 and m >= 0:
        n, m = int(n), int(m)
        ans = 1
        for i in range(min(m, n)):
            ans = ans * (n + m - i) % mod 
            ans *= pow(i + 1, mod - 2, mod)

print(ans % mod)

### FIXED CODE ###

x, y  = map(int, input().split())
mod = 10 ** 9 + 7
if (x + y) % 3 != 0:
    ans = 0
else:
    n, m = (2 * x - y) / 3, (2 * y - x) / 3
    ans = 0
    if n >= 0 and m >= 0:
        n, m = int(n), int(m)
        ans = 1
        for i in range(min(m, n)):
            ans = ans * (n + m - i) % mod 
            ans *= pow(i + 1, mod - 2, mod)

print(ans % mod)
n=map(ijnt,input().split())
k=int(input())
n.sort(reverse=True)
print(n[0]*k+n[1]+n[2])

### FIXED CODE ###

n=list(map(int,input().split()))
k=int(input())
n.sort(reverse=True)
print(n[0]*(2**k)+n[1]+n[2])
answer_list = [1, 1] + [None] * 43

def fib(num):
    ans = answer_list[num]
    if ans:
        return ans
    ans = fib(num - 1) + fib(num - 2)
    answer_list[num] = ans
    return ans


n = int(input)

print(fib(n))

### FIXED CODE ###

def deco_fibo(func):
    answer_list = [1, 1] + [None] * 43
    def main_fibo(i):
        ans = answer_list[i]
        if ans:
            return ans
        ans = func(i)
        answer_list[i] = ans
        return ans
    return main_fibo

@deco_fibo
def fibo(num):
    return fibo(num - 1) + fibo(num - 2)


n = int(input())

print(fibo(n))
N = int(input())
a_i = list(map(int, input().split('')))
 
x = []
y = []
 
if N%2==0:
    for j in range(int(N/2)):
        x.append(max(a_i))
        a_i.remove(max(a_i))
        y.append(max(a_i))
        a_i.remove(max(a_i))
 
else:
    for j in range(int((N/2)+1)):
        x.append(max(a_i))
        a_i.remove(max(a_i))
        if a_i == []:
            break
        y.append(max(a_i))
        a_i.remove(max(a_i))
 
X = sum(x)
Y = sum(y)
 
 
if X >= Y:
    print(X - Y)
 
else:
    print(Y - X)

### FIXED CODE ###

N = int(input())
a_i = list(map(int, input().split(" ")))
 
x = []
y = []
 
if N%2==0:
    for j in range(int(N/2)):
        x.append(max(a_i))
        a_i.remove(max(a_i))
        y.append(max(a_i))
        a_i.remove(max(a_i))
 
else:
    for j in range(int((N/2)+1)):
        x.append(max(a_i))
        a_i.remove(max(a_i))
        if a_i == []:
            break
        y.append(max(a_i))
        a_i.remove(max(a_i))
 
X = sum(x)
Y = sum(y)
 
 
if X >= Y:
    print(X - Y)
 
else:
    print(Y - X)
import math

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

def C(x, y):
    return math.factorial(x) // math.factorial(x - y) // math.factorial(y)

def calc(n, k, t):
    return C(n - k + 1, t) * C(k - 1, t - 1) % (10 ** 9 + 7)

for i in range(1, k + 1):
    print(calc(n, k, i))


### FIXED CODE ###

import math

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

ans_list = []

def C(x, y):
    return math.factorial(x) // math.factorial(x - y) // math.factorial(y)

def calc(n, k, t):
    return C(n - k + 1, t) * C(k - 1, t - 1) % (10 ** 9 + 7)

for i in range(1, k + 1):
    
    if n - k <= 0:
        if len(ans_list) == 0:
            ans_list.append(1)
        else:
            ans_list.append(0)
    else:
        if i > (n - k + 1):
            if len(ans_list) == 0:
                ans_list.append(1)
            else:
                ans_list.append(0)
        else:
            ans_list.append(calc(n, k, i))

for i in ans_list:
    print(i)
import sys

n1, n2 = [int(i) for i in input().split()]

na1 = []

for i1 in range(n2):
    na1.append(int(input()))

for i3 in range(n2):
    if i3 == 0:
        continue
    else:
        if na1[i3] == na1[i3 - 1] + 1:
            print("0")
            sys.exit()

if na1[n2 -1] == n1:
    print("0")
    sys.exit()
    

n3 = 0
n4 = 0
n5 = 0
n6 = 0
n7 = 0
r1 = 0
r2 = []
f1 = False
for i2 in range(n1 ):
    if len(na1) > n7 and (na1[n7] == i2 + 1 ):
        n3 = 0
        n4 = 0
        n6 = 0
        n7 += 1
        if r1 == 0:
            r1 = 1
        r2.append(r1)
        f1 = True

    else:
        if f1 == True:
            f1 = False
            continue
        if n4 == 0 :
            n4 = 1
            r1 = 1
        elif n3 == 0 :
            n3 = 1
            n4 = 2
            r1 = 2
        else:
            n6 = n3 + n4
            r1 = n6
            n3 = n4
            n4 = n6
    if i2 == (n1 - 1) :
        r2.append(r1)

r3 = 1
for i6 in range(len(r2)):
    r3 *= r2[i6]

print(r3 % 1000000007)


### FIXED CODE ###

import sys

n1, n2 = [int(i) for i in input().split()]

na1 = []

for i1 in range(n2):
    na1.append(int(input()))

for i3 in range(n2):
    if i3 == 0:
        continue
    else:
        if na1[i3] == na1[i3 - 1] + 1:
            print("0")
            sys.exit()

n3 = 0
n4 = 0
n5 = 0
n6 = 0
n7 = 0
r1 = 1
r2 = []
f1 = False
for i2 in range(n1):
    if len(na1) > n7 and (na1[n7] == i2 + 1 ):
        n3 = 0
        n4 = 0
        n6 = 0
        n7 += 1
        r2.append(r1)
        r1 = 1
        f1 = True

    else:
        if f1 == True:
            f1 = False
            continue
        if n4 == 0 :
            n4 = 1
            r1 = 1
        elif n3 == 0 :
            n3 = 1
            n4 = 2
            r1 = 2
        else:
            n6 = n3 + n4
            r1 = n6
            n3 = n4
            n4 = n6
    if i2 == (n1 - 1) :
        r2.append(r1)

r3 = 1
for i6 in range(len(r2)):
    r3 *= r2[i6]

print(r3 % 1000000007)
def solve(string):
    n, k, *td = map(int, string.split())
    td = sorted([(t, d) for t, d in zip(td[::2], td[1::2])], key=lambda x: x[1], reverse=True)
    max_variety = len(set([c[0] for c in td]))
    choice = td[:k]
    r = []
    variety = set([])
    ans = 0
    for _c in choice:
        ans += _c[1]
        if _c[0] in variety:
            r.append(_c[1])
        else:
            variety.add(_c[0])
    ans += len(variety)**2
    i = k
    while len(variety) < min(max_variety, k):
        while td[i][0] in variety:
            i += 1
        variety.add(td[i][0])
        ans.append(ans[-1] - r.pop() + td[i][1] + 2 * len(variety) - 1)
    return str(max(ans))


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(n)])))


### FIXED CODE ###

def solve(string):
    n, k, *td = map(int, string.split())
    td = sorted([(t, d) for t, d in zip(td[::2], td[1::2])], key=lambda x: x[1], reverse=True)
    max_variety = len(set([c[0] for c in td]))
    choice = td[:k]
    count = [0] * n
    r = []
    for _c in choice:
        if count[_c[0] - 1] > 0:
            r.append(_c[1])
        count[_c[0] - 1] += 1
    variety = set([c[0] for c in choice])
    ans = [len(variety)**2 + sum([c[1] for c in choice])]
    i_append = k
    while len(variety) < min(max_variety, k):
        while td[i_append][0] in variety:
            i_append += 1
        variety.add(td[i_append][0])
        ans.append(ans[-1] - r.pop() + td[i_append][1] + 2 * len(variety) - 1)
    return str(max(ans))


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(n)])))
a,b=int(input.split())
print(a-b+1)

### FIXED CODE ###

N,i=map(int,input().split())
print(N+1-i)
print('Christmas' - int(input()) % 5 * ' Eve')

### FIXED CODE ###

D = int(input())
s = ""
if D == 25:
    s = 'Christmas'
elif D == 24:
    s = 'Christmas Eve'
elif D == 23:
    s = 'Christmas Eve Eve'
elif D == 22:
    s = 'Christmas Eve Eve Eve'

print(s)
n = int(input())
h = list(map(int,input().split()))

ans = "Yes"
for i in range(n-1):
    if h[i] - h[i + 1] >= 2:
        ans = "No"
        break;
    elif h[i] - h[i + 1] == 1:
        h[i] -= 1

for i in range(n-1):
    if h[i] > h[i + 1]:
        ans = "No" 

print(ans))

### FIXED CODE ###

def main():
    n = int(input())
    h_list = list(map(int, input().split()))
    for i in range(n - 1)[::-1]:
        if h_list[i] == h_list[i + 1] + 1:
            h_list[i] = h_list[i] - 1
        elif h_list[i] > h_list[i + 1] + 1:
            print("No")
            return
    print("Yes")

main()
n,m=map(int,input().split())
print(max([sum(sorted([i*l[0]+j*l[1]+k*l[2] for l in [list(map(int,input().split())) for i in range(n)]],reverse=True)[:m]) for i in [-1,1] for j in [-1,1] for k in [-1,1]]))

### FIXED CODE ###

n,m=map(int,input().split())
xyz=[list(map(int,input().split())) for i in range(n)]
ans=[]
for i in [-1,1]:
    for j in [-1,1]:
        for k in [-1,1]:
            ans.append(sum(sorted([i*l[0]+j*l[1]+k*l[2] for l in xyz],reverse=True)[:m]))
print(max(ans))
import sys
# Xはもっとも近い整数，Nは与えられるP
X,N = map(int, input().split())

if N == 0:
  print(X)
  sys.exit()

arr = list(map(int, input().split()))
mainasu = X 
purasu = X 

def saiki():
  mainasu = mainasu - 1
  purasu = purasu + 1
  if X in arr:
    if mainasu in arr:
      if purasu in arr:
        saiki()
      else:
        print(purasu)
    else:
      print(mainasu)
  else:
    print(X)

saiki()

### FIXED CODE ###

import sys

def saiki(l,r,lst):
  if (l - 1) not in lst:
      return (l - 1)
  
  if (r + 1) not in lst:
      return (r + 1)
  
  return saiki(l - 1, r + 1, lst)

def main():
  # Xはもっとも近い整数，Nは与えられるP
  X,N = map(int, input().split())

  arr = list(map(int, input().split()))

  if N == 0:
    print(X)
    sys.exit()

  if X not in arr:
    print(X)
    sys.exit()

  print(saiki(X,X,arr))

if __name__ == '__main__':
    main()
N, A, B, K = map(int, input().split())
mod = 998244353

def pow(n, i):
    if i == 1: return n
    else:
        if i % 2 == 0:
            return pow((n * n) % mod, i//2)
        else: return (pow((n * n) % mod, i//2) * n) % mod

factorial = [1] *(N+1)
revfactorial = [1] * (N+1)
for i in range(N):
    factorial[i+1] = (factorial[i] * (i+1)) % mod
revfactorial[N] = pow(factorial[N], mod-2) % mod
for i in reversed(range(1, N)):
    revfactorial[i] = (revfactorial[i+1] * (i+1)) % mod

ans = 0
for a in range(N+1):
    if K >= A * a:
        if (K - A * a) % B == 0:
            b = (K - A * a) // B
            apatt = (factorial[N] * revfactorial[N - a] * revfactorial[a]) % mod
            bpatt = (factorial[N] * revfactorial[N - b] * revfactorial[b]) % mod
            ans += (apatt * bpatt) % mod
            ans %= mod
print(ans)

### FIXED CODE ###

N, A, B, K = map(int, input().split())
mod = 998244353

def pow(n, i):
    if i == 0: return 1
    elif i == 1: return n
    elif i % 2 == 0: return pow((n * n) % mod, i//2)
    else: return (pow((n * n) % mod, i//2) * n) % mod

factorial = [1] *(N+1)
revfactorial = [1] * (N+1)
for i in range(N):
    factorial[i+1] = (factorial[i] * (i+1)) % mod
revfactorial[N] = pow(factorial[N], mod-2)
for i in reversed(range(1, N)):
    revfactorial[i] = (revfactorial[i+1] * (i+1)) % mod

ans = 0
for a in range(N+1):
    if K >= A * a:
        if (K - A * a) % B == 0:
            b = (K - A * a) // B
            apatt = (factorial[N] * revfactorial[N - a] * revfactorial[a]) % mod
            if b <= N: bpatt = (factorial[N] * revfactorial[N - b] * revfactorial[b]) % mod
            else: bpatt = 0
            ans += (apatt * bpatt) % mod
            ans %= mod
print(ans)
a,b = map(input().split())
print(a*b,2*a+2*b)

### FIXED CODE ###

a,b = map(int,input().split())
print(a*b,2*a+2*b)
N=int(input())
answer=0
for i in range(N):
  l,r = map(input().split())
  answer+=r-l+1
print(answer)

### FIXED CODE ###

N=int(input())
sl=[]
for i in range(N):
  sl.append(list(map(int,input().split())))
sl.sort()
sl_table = [True for i in range(len(sl))]

for i in range(N):
  for j in range(min(i+1,N),N):
    if sl[j][0]-sl[i][1]>0:
      break
    sl[i]=[min(min(sl[i]),min(sl[j])),max(max(sl[i]),max(sl[j]))]
    sl_table[j]=False

print(sum((s[1]-s[0]+1)*sl_table[i] for i,s in enumerate(sl)))
s = list(input())
try
    bs = s.index('B')
except:
    bs=-1

while bs != -1:
    if bs == 0:
        del s[bs]
    else:
        del s[bs-1]
        del s[bs-1]
    try:
        bs = s.index('B')
    except:
        bs = -1

print(''.join(s))


### FIXED CODE ###

s = list(input())
try:
    bs = s.index('B')
except:
    bs=-1

while bs != -1:
    if bs == 0:
        del s[bs]
    else:
        del s[bs-1]
        del s[bs-1]
    try:
        bs = s.index('B')
    except:
        bs = -1

print(''.join(s))
Q = int(input())
q = [list(map(int, input().split())) for _ in range(Q)]

def addT(n):
  k = 0
  while True:
    if T[k][0] >= n:
      T[k][1][1] += 1
      if T[k][1][0] == -1:
        T.append([n, [-1, 0], [-1, 0]])
        T[k][1][0] = t
        break
      else:
       k = T[k][1][0]
    else:
      T[k][2][1] += 1
      if T[k][2][0] == -1:
        T.append([n, [-1, 0], [-1, 0]])
        T[k][2][0] = t
        break
      else:
        k = T[k][2][0]

def getTmed(x, n):
  if T[x][1][1] == n - 1:
    return x
  elif T[x][1][1] > n - 1:
    return getTmed(T[x][1][0], n)
  else:
    return getTmed(T[x][2][0], n - (T[x][1][1] + 1))


T = []
b = 0
su = 0
for i in q:
  if T == []:
    T.append([i[1], [-1, 0], [-1, 0]])
    t = 1
    rk = i[1]
    b = i[2]
  elif i[0] == 2:
    k = getTmed(0, (t + 1) // 2)
    print(T[k][0], su + b)
  else:
    addT(i[1])
    k = getTmed(0, (t + 1) // 2)
    su += abs(T[k][0] - rk)
    rk = T[k][0]
    t += 1
    b += i[2]

### FIXED CODE ###

Q = int(input())
Query = [list(map(int, input().split())) for _ in range(Q)]
import heapq

L = []
R = []
pop = heapq.heappop
push = heapq.heappush
A, B, C = 0, 0, 0

def nasu(a):
  global A
  global C
  if len(R) == 0:
    push(R, a)
    C = a
    return
  if len(L) == 0:
    r = pop(R)
    push(L, -min(a, r))
    push(R, max(a, r))
    A += abs(a - r)
    C = min(a, r)
    return
  if len(L) < len(R):
    r = pop(R)
    l = -pop(L)
    push(L, -l)
    push(L, -min(a, r))
    push(R, max(a, r))
    A += abs(a - r)
    if a < l:
      C = l
    elif a < r:
      C = a
    return
  l = -pop(L)
  r = pop(R)
  if l <= a and a <= r:
    push(L, -l)
    push(R, r)
    push(R, a)
    C = a
  elif a < l:
    push(L, -a)
    push(R, r)
    push(R, l)
    A += abs(a - l)
    C = l
  else:
    push(L, -l)
    push(R, a)
    push(R, r)
    A += abs(a - r)
    C = r

for q in Query:
  if q[0] == 1:
    nasu(q[1])
    B += q[2]
  if q[0] == 2:
    print(C, A + B)
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, readline().split())
a = list(map(int, readline().split()))
memo = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = [''] * (n + 1)
for aa in a:
    if aa <= n:
        if dp[memo[aa]] < str(aa):
            dp[memo[aa]] = str(aa)
for i in range(n):
    if dp[i] == '':
        continue
    for aa in a:
        if i + memo[aa] <= n:
            v = str(aa) + dp[i]
            if len(dp[i + memo[aa]]) < len(v):
                dp[i + memo[aa]] = v
            else:
                dp[i + memo[aa]] = max(dp[i + memo[aa]], v)
print(dp[-1])


### FIXED CODE ###

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

n, m = map(int, readline().split())
a = list(map(int, readline().split()))
memo = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = [''] * (n + 1)
for aa in a:
    if memo[aa] <= n:
        dp[memo[aa]] = max(dp[memo[aa]], str(aa))
for i in range(n):
    if dp[i] == '':
        continue
    for aa in a:
        if i + memo[aa] <= n:
            v = str(aa) + dp[i]
            if len(dp[i + memo[aa]]) < len(v):
                dp[i + memo[aa]] = v
            else:
                dp[i + memo[aa]] = max(dp[i + memo[aa]], v)
print(dp[-1])