Harryxun/stf_run huggingface dataset:
N, K = [int(_) for _ in input().split()]
t_and_d = [[int(_) for _ in input().split()] for _ in range(N)]

t_and_d.sort(key=lambda x: x[1], reverse=True)
over_stock = []
type_set = set()

for t_i, d_i in t_and_d[:K]:
    if t_i in type_set:
        over_stock += [d_i]
    else:
        type_set.add(t_i)

x = len(type_set)
point = sum([d for t, d in t_and_d[:K]]) + x ** 2
point_max = point

if not over_stock:
    print(point)
    quit()

for t_i, d_i in t_and_d[K:]:
    if t_i in type_set:
        continue
    else:
        diff = (x + 1) ** 2 - x ** 2 + d_i - over_stock.pop()
        type_set.add(t_i)
        x += 1
        point += diff
        point_max = max(point_max, point)

print(point_max)


### FIXED CODE ###

N, K = [int(_) for _ in input().split()]
t_and_d = [[int(_) for _ in input().split()] for _ in range(N)]
t_and_d.sort(key=lambda x: x[1], reverse=True)

over_stock = []
type_set = set()

for t_i, d_i in t_and_d[:K]:
    if t_i in type_set:
        over_stock += [d_i]
    else:
        type_set.add(t_i)

x = len(type_set)
point = sum([d for t, d in t_and_d[:K]]) + x ** 2
point_max = point

for t_i, d_i in t_and_d[K:]:
    if over_stock:
        if t_i in type_set:
            continue
        else:
            diff = (x + 1) ** 2 - x ** 2 + d_i - over_stock.pop()
            type_set.add(t_i)
            x += 1
            point += diff
            point_max = max(point_max, point)

print(point_max)
input(x)
print(x ** 3)

### FIXED CODE ###

x = int(input())
print(x ** 3)
n = int(input())
numbers = []
i = 0
while i <= n:
  numbers.append(int(input()))
  i += 1

j = 0
s = 0
while n >= j:
  s += 1/numbers[j]
  i += 1

print(1/s)

### FIXED CODE ###

a = int(input())
s = input()
if a >= 3200:
  print(s)
else:
  print("red")
n = int(input())
h = list(map(int, input().split()))
if n == 1:
    print("Yes")
    quit()
for i in range(n-1):
    if h[i] > h[i+1]:
        if i == 0:
            h[i] -= 1
            if h[i] > h[i+1]:
                print("No")
                quit()
        else:
            if h[i-1] >= h[i]:
                print("No")
                quit()
            else:
                h[i] -= 1
                if h[i] > h[i+1]:
                    print(No)
                    quit()

print("Yes")

### FIXED CODE ###

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

x = -999
h.reverse()
for i in range(n):
    if i == 0:
        continue
    if h[i] > h[i-1]:
        if h[i]-h[i-1] == 1:
            h[i] -= 1
        else:
            print("No")
            quit()
print("Yes")
def main():
    tenki = input()
    leng = len(tenki)

    count = 0
    lst = []
    for i in range(leng):
        if tenki[i] == "R":
            count += 1
        else:
            lst.append(count)
            count = 0
    
    print(max(lst))


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    tenki = input()
    leng = len(tenki)

    count = 0
    lst = []
    for i in range(leng):
        if tenki[i] == "R":
            count += 1
        else:
            lst.append(count)
            count = 0
    lst.append(count)
    count = 0
    print(max(lst))


if __name__ == '__main__':
    main()
n = int(import())
if n == 25:
  print("Christmas")
elif n == 24:
  print("Christmas Eve")
elif n == 23:
  print("Christmas Eve Eve")
else:
  print("Christmas Eve Eve Eve")

### FIXED CODE ###

n = int(input())
if n == 25:
    print("Christmas")
elif n == 24:
    print("Christmas Eve")
elif n == 23:
    print("Christmas Eve Eve")
else:
    print("Christmas Eve Eve Eve")
def main ():
	N = int(input())
	A = list(map(int,input(). split ()))
    if 0 in A:
    	print(0)
    	return
    prod = 1
      for a in A:
      prod *= a
      if prod > 1000000000000000000:
      print(-1)
      return
    print(prod)
main ()

### FIXED CODE ###

def sol():
    n=int(input())
    a=list(map(int,input().split()))
    if 0 in a:
        print(0)
        return
    prod=1 
    for i in a:
        prod*=i 
        if prod>1000000000000000000:
            print(-1)
            return
    print(prod)
    
sol()
import sys, math, bisect



def solve(W_N, V_N, bombs, H, W):

    max_x = 1
    xs = []
    for i in range(W):
        if(W_N[i] > max_x):
            max_x = W_N[i]
            xs = [i]
        elif(W_N[i] == max_x):
            xs.append(i)
    max_y = 1
    ys = []
    for j in range(H):
        if(V_N[j] > max_y):
            max_y = V_N[j]
            ys = [j]
        elif(V_N[j] == max_y):
            ys.append(j)

    value = max_x + max_y

    for j in ys:

        bombs[j].sort()
        for i in xs:
            index = bisect.bisect_left(bombs[j], i)
            if( index < W and i != bombs[j][index] ):
            #if(  i != bombs[j][index] ):
                return value
    return value-1



if(__name__ == "__main__"):
    """
    N = int( input().strip() )
    Length = list( map(int, input().strip().split() ) )
    """
    H, W, N_bombs= map(int, input().strip().split() )


    V_N = [0] * H
    W_N = [0] * W
    bombs = [ [] for _ in range(H) ]


    for i in range(N_bombs):
        y, x = map(int, input().strip().split() )
        """
        W_N_bomb[x-1][0] += 1
        V_N_bomb[y-1][0] += 1
        """
        V_N[y-1] += 1
        W_N[x-1] += 1
        bombs[y-1].append(x-1)




    print( solve(W_N, V_N, bombs, H, W) )


### FIXED CODE ###

import sys, math, bisect



def solve(W_N, V_N, bombs, H, W):

    max_x = 1
    xs = []
    for i in range(W):
        if(W_N[i] > max_x):
            max_x = W_N[i]
            xs = [i]
        elif(W_N[i] == max_x):
            xs.append(i)
    max_y = 1
    ys = []
    for j in range(H):
        if(V_N[j] > max_y):
            max_y = V_N[j]
            ys = [j]
        elif(V_N[j] == max_y):
            ys.append(j)

    value = max_x + max_y

    for j in ys:

        bombs[j].sort()
        for i in xs:
            index = bisect.bisect_left(bombs[j], i)
            if(index == V_N[j] or i != bombs[j][index]):
                return value
            
    return value-1



if(__name__ == "__main__"):
    """
    N = int( input().strip() )
    Length = list( map(int, input().strip().split() ) )
    """
    H, W, N_bombs= map(int, input().strip().split() )


    V_N = [0] * H
    W_N = [0] * W
    bombs = [ [] for _ in range(H) ]


    for i in range(N_bombs):
        y, x = map(int, input().strip().split() )
        """
        W_N_bomb[x-1][0] += 1
        V_N_bomb[y-1][0] += 1
        """
        V_N[y-1] += 1
        W_N[x-1] += 1
        bombs[y-1].append(x-1)




    print( solve(W_N, V_N, bombs, H, W) )
n,m,l = map(int, input().split())
a = []
b = []
for i in range(n):
    a.append(list(map(int, input().split())))
for j in range(m):
    b.append(list(map(int, input().split())))
for k in range(n):
    for o in range(l):
        sum = 0
        for p in range(m):
            sum += (a[n][m] * b[m][l])
        print(sum, end = "")
        if o != l-1:
            print(" ", end = "")
    print()


### FIXED CODE ###

n,m,l = map(int, input().split())
a = []
b = []
for i in range(n):
    a.append(list(map(int, input().split())))
for j in range(m):
    b.append(list(map(int, input().split())))
for  k in range(n):
    for o in range(l):
        sum = 0
        for p in range(m):
            sum += (a[k][p] * b[p][o])
        print(sum, end = "")
        if o != l-1:
            print(" ", end = "")
    print()
n=int(input())
s=[]
for i in range(n):
    s.append(int(input()))
cho=int(input())
c=0
for i in range(cho-1,n-1):
    if(s[i]>s[i+1]):
        c+=1
    else:
        break
print(c)

### FIXED CODE ###

n = int(input())
values = [float(s) for s in input().split(" ")]

start = 0
ans = 0

for i in range(1,n):
    if values[i] > values[i-1]:
        start = i
    ans = max(ans,i-start)
print(ans)
n,m=map(int,input().split())
MOD = 10**9+7
ans=1
def inv_mod(a, p=MOD):
    def inv_mod_sub(a, p):
        if a == 1:
            return 1, 0
        else:
            d, r = p//a, p%a
            x, y = inv_mod_sub(r, a)
            return y-d*x, x
    if p < 0: p = -p
    a %= p
    return inv_mod_sub(a,p)[0] % p

def comb_mod(n, k):
    if k < 0 or k > n:
        return 0
    else:
        return f_mod[n]*f_mod_inverse[k]*f_mod_inverse[n-k] % MOD
f_mod=[1]*(n+1)
f_mod_inverse=[1]*(n+1)
for i in range(1,n+1):
  f_mod[i]=f_mod[i-1]*i%MOD
  f_mod_inverse[i]=f_mod_inverse[i-1]*inv_mod(i) % MOD  
pf={}
for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pf[i]=pf.get(i,0)+1
        m//=i
if m>1:pf[m]=1
for i in pf.values():
  ans*=comb_mod(i+n-1,n-1)
print(ans%MOD)


### FIXED CODE ###

import sys
n,m=map(int,input().split())
MOD = 10**9+7
ans=1
if m==1:
  print(1)
  sys.exit()
def inv_mod(a, p=MOD):
    def inv_mod_sub(a, p):
        if a == 1:
            return 1, 0
        else:
            d, r = p//a, p%a
            x, y = inv_mod_sub(r, a)
            return y-d*x, x
    if p < 0: p = -p
    a %= p
    return inv_mod_sub(a,p)[0] % p

def comb_mod(n, k):
    if k < 0 or k > n:
        return 0
    else:
        return f_mod[n]*f_mod_inverse[k]*f_mod_inverse[n-k] % MOD
pf={}
for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pf[i]=pf.get(i,0)+1
        m//=i
if m>1:pf[m]=1
Max=max(list(pf.values()))
f_mod=[1]*(Max+n+1)
f_mod_inverse=[1]*(Max+n+1)
for i in range(1,Max+n+1):
  f_mod[i]=(f_mod[i-1]*i)%MOD
  f_mod_inverse[i]=(f_mod_inverse[i-1]*inv_mod(i)) % MOD  
for i in pf.values():
  ans*=comb_mod(i+n-1,n-1)
print(ans%MOD)
k=int(input())
a=list(map(int,input().split()))
l,r=1,10**18
def f(x,a):
    for i in a:
        x=max(0,x-x%i)
    return x
while r-l>1:
    t=(l+r)//2
    if f(t,a)>2:
        r=t
    else:
        l=t
p,q=1,10**18
while q-p>1:
    t=(p+q)//2
    if f(t,a)<=1:
        p=t
    else:
        q=t
print(*(q,l) if q<=l else -1)

### FIXED CODE ###

k=int(input())
a=list(map(int,input().split()))
s=2+k*max(a)
l,r=s+1,0
while l-r>1:
    t=(l+r)//2
    p=t
    for i in a:
        t-=t%i
    if t>=2:
        l=p
    else:
        r=p
e=l
l,r=s+1,0
while l-r>1:
    t=(l+r)//2
    p=t
    for i in a:
        t-=t%i
    if t>2:
        l=p
    else:
        r=p
print(str(max(e,2))+" "+str(r)if r>e or r<2 else -1)
n, k, x, y = int(input().split()) for _ in range(4)
print(k * x + (k - n) * y)

### FIXED CODE ###

n,k,x,y=(int(input()) for i in range(4))
if n - k > 0:
  ans = k * x + (n - k) * y
else:
  ans = n * x
print(ans)
def gcd(a, b):
    if a < b:
        a, b = b ,a
    while b > 0:
        a, b = b, a % b
    return a

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

N = int(input())
T = [int(input()) for i in range(N)]

ans = T[0]

for t in T[1:]:
    ans = lcm(ans, t)

print(ans)

### FIXED CODE ###

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

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

N = int(input())
T = [int(input()) for i in range(N)]

ans = T[0]

for t in T[1:]:
    ans = lcm(ans, t)

print(ans)
a,b,c = int(input()), int(input()), int(input())

if b - a == c - a:
    print('YES')
else:
    print('NO')

### FIXED CODE ###

a,b,c = map(int, input().split())
print('YES') if b - a == c - b else print('NO')
import math 

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

A,B=map(int,input().split())
counter=0
gcd=math.gcd(A,B)
for i in range(2,gcd):
    if is_prime(i) and gcd%i==0:
        counter+=1
print(counter+1)

### FIXED CODE ###

import math 
import fractions
import collections


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
A,B=map(int,input().split())
counter=0
gcd=fractions.gcd(A,B)
c = collections.Counter(prime_factorize(gcd))
print(len(c)+1)
import sys
sys.setrecursionlimit(10 ** 9)

n = int(input())
x = input()

p = [-1 for _ in range(2*(10**5)+10)]
cnt = x.count('1')

def calc(a):
  #print('a=',a)
  if p[a] != -1:
    return p[a]
  else:
    if a == 0:
      ret = 0
    else:
      b = bin(a).count('1')
      ret = 1+calc(a%b)
    p[a] = ret
    return ret

x0 = int(x,2)%(cnt-1)
x1 = int(x,2)%(cnt+1)
xx0 = [1]
for i in range(n+1):
  xx0.append((xx0[-1]*2)%(cnt-1))
xx1 = [1]
for i in range(n+1):
  xx1.append((xx1[-1]*2)%(cnt+1))
  
for i in range(n):
  y = list(x)
  if y[i] == '0':
    xx = xx1[n-i-1]
    print(calc((x1+xx)%(cnt+1))+1)
  else:
    xx = xx0[n-i-1]
    print(calc((x0-xx)%(cnt-1))+1)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 9)

n = int(input())
x = input()

p = [-1 for _ in range(2*(10**7)+1)]
cnt = x.count('1')

def calc(a):
  #print('a=',a)
  if 0 <= a <= 2*(10**7) and  p[a] != -1:
    return p[a]
  else:
    if a == 0:
      ret = 0
    else:
      b = bin(a).count('1')
      ret = 1+calc(a%b)
    if 0 <= a <= 2*(10**7):
      p[a] = ret
    return ret

if cnt > 1:
  x0 = int(x,2)%(cnt-1)
  xx0 = [1]
  for i in range(n+1):
    xx0.append((xx0[-1]*2)%(cnt-1))
x1 = int(x,2)%(cnt+1)
xx1 = [1]
for i in range(n+1):
  xx1.append((xx1[-1]*2)%(cnt+1))

y = list(x)  
for i in range(n):
  if y[i] == '0':
    xx = xx1[n-i-1]
    print(calc((x1+xx)%(cnt+1))+1)
  else:
    if cnt == 1:
      print(0)
    else:
      xx = xx0[n-i-1]
      print(calc((x0-xx)%(cnt-1))+1)
H,A=int(input())
  
print((H // A)+1)

### FIXED CODE ###

H,A=map(int,input().split())

if H%A==0:
  print(H // A)
else:
  print((H // A)+1)
import numpy as np
N, K = map(int, input().split())
tmp = input().split(' ')
A = []
for i in range(N):
    A = A + [int(tmp[i])]

Z = np.array([[abs(j - i) for j in range(N)] for i in range(N)])

B = [0]*5
while K > 0:
    K = K - 1
    Ac = np.array([A]*N-Z)
    for i in range(N):
        B[i] = np.count_nonzero(Ac[i] >= 0)

    A[:] = B[:]

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

### FIXED CODE ###

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    Z = [N]*N

    while K > 0 and A != Z:
        K-=1
        B = [int(0)]*(N+1)
        for i in range(N):
            B[max(int(0),i-A[i])]+=1
            B[min(N-1,i+A[i])+1]-=1
        for i in range(1,N):
            B[i]+=B[i-1]

        A = B[0:N]

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

if __name__ == '__main__':
    main()
LIM=200001
L=[0]*LIM

def bin_sum(Y):
    S=bin(Y)[2:]
    count=0
    for i in range(len(S)):
        count+=int(S[i])
    return count

def bin_sum2(Y):
    count=0
    for i in range(len(Y)):
        count+=int(Y[i])
    return count

for i in range(LIM):
    L[i]+=bin_sum(i)

def pop_num(N,b):
    count=1
    N=N%b
    while N!=0:
        b=L[N]
        N=N%b
        count+=1
    return count
X=int(input())
Y=input()
d=bin_sum2(Y)+1
c=bin_sum2(Y)-1
for i in range(X):
    Y_i=Y[:i]+str(abs(int(Y[i])-1))+Y[i+1:]
    if Y_i[i]=="1":
        b=d
    else:
        b=c
    print(pop_num(int(Y_i,2),b))

### FIXED CODE ###

from collections import deque
LIM=200004
L=[0]*LIM

def bin_sum(Y):
    S=bin(Y)[2:]
    count=0
    for i in range(len(S)):
        count+=int(S[i])
    return count

def bin_sum2(Y):
    count=0
    for i in range(len(Y)):
        count+=int(Y[i])
    return count

for i in range(1,LIM):
    L[i]+=bin_sum(i)

def pop_num(N,b,L):
    if N==0:
        return 0
    v=N%b
    return pop_num(v,L[v],L)+1
    
M=[0]*200005
for i in range(1,200004):
    M[i]+=pop_num(i,L[i],L)
X=int(input())
Y=input()
d=bin_sum2(Y)
e=int(Y,2)%(d+1)
f=int(Y,2)%max(1,(d-1))
O=[1]*(X+2)
P=[1]*(X+2)
q=max(d-1,1)
for i in range(1,X+1):
    O[i]=O[i-1]*2%q
    P[i]=P[i-1]*2%(d+1)
for i in range(X):
    
    if int(Y[i])==1:
        b=max(d-1,1)
        flag=max(0,d-1)
        g=(f-O[X-1-i]+b)%b
    else:
        b=d+1
        flag=1
        g=(e+P[X-1-i])%b

    if flag==0:
        print(0)
    elif g==0:
        print(1)
    else:
        print(M[g]+1)
N, K = map(int,input().split())
A = list(map(int,input().split()))
A.insert(0,0)
list = []
replist = []
judge = [True] * (2 * 10 ** 5)
cnt = 1
pos = 1
owari = True
while cnt < 2 * 10 ** 5 and owari:
    judge[pos] = False
    list.append(pos)
    pos = A[pos]
    if not judge[pos]:
        while True:
            replist.append(pos)
            judge[pos] = True
            pos = A[pos]
            if judge[pos]:
                owari = False
                break
if K <= len(list)-1:
    print(list[K])
else:
    K = K - len(list) + 1
    print(replist[( K % len(replist) ) -1])



### FIXED CODE ###

N, K = map(int,input().split())
A = list(map(int,input().split()))
A.insert(0,0)
list = []
replist = []
judge = [True] * (2 * 10 ** 5 + 1)
pos = 1
owari = True
while owari:
    judge[pos] = False
    list.append(pos)
    pos = A[pos]
    if not judge[pos]:
        while True:
            replist.append(pos)
            judge[pos] = True
            pos = A[pos]
            if judge[pos]:
                owari = False
                break
if K <= len(list)-1:
    print(list[K])
else:
    K = K - len(list) + 1
    print(replist[( K % len(replist) ) -1])
N,W=map(int,input().split())
C=[0]*-~W
for _ in[0]*N:
 v,w=mpa(int,input().split())
 for i in range(W,w-1,-1):
  t=v+C[i-w]
  if t>C[i]:C[j]=t
print(C[W])


### FIXED CODE ###

import sys
def s():
 W=int(input().split()[1])
 C=[0]*-~W
 for e in sys.stdin:
  v,w=map(int,e.split())
  for i in range(W,w-1,-1):
   t=v+C[i-w]
   if t>C[i]:C[i]=t
 print(C[W])
s()
n , k = map(int, input().split())
p = list(map(int, input().split()))
for i in range(1,n+1):
  a_i = (1+p[i])/2
def sigma(a, b):
    s = 0
    for i in range(a, b+1):
        s += a_i
    return s
  
for i in range(n-k+1):
  r_i = sigma(i, i+k-1)
  
M = max(r_i for i in range(n-k+1))
print(M)



### FIXED CODE ###

N, K = map(int, input().split())
P = list(map(int, input().split()))
Q = [0]
for p in P:
    Q.append(Q[-1] + (p+1)/2)

print(max([Q[i+K]-Q[i] for i in range(N-K+1)]))
n, a, b = map(int, input().split())
count = 0

for i in range(1, n+1):
    if a <= sum(map(int,list(str(i)))) <= b:
        s += i
        
print(s)

### FIXED CODE ###

#B
n, a, b = map(int, input().split())
count = 0

for i in range(1, n+1):
    if a <= sum(map(int,list(str(i)))) <= b:
        count += i
        
print(count)
N, M = map(int, input().split())
A = list(map(int, input().split()))

def dp(n, i):
    if n == 0:
        return 0
    if n < 0:
        return None
    if i == len(CHOICES):
        return None
    
    ret1 = dp(n - CHOICES[i][1], i)
    if ret1 == None:
        ret1 = 0
    elif ret1 == 0:
        ret1 = int(str(CHOICES[i][0]))
    else:
        ret1 = int(str(CHOICES[i][0]) + str(ret1))

    ret2 = dp(n, i+1)
    if ret2 == None:
        ret2 = 0
    else:
        ret2 = ret2
        
    return max(ret1, ret2)



match = [-100,2,5,5,4,5,6,3,7,6]
CHOICES = []
for i in A:
    if (i == 6) and (9 in A):
        continue
    if (i == 3) and (5 in A):
        continue
    if (i == 2) and (3 in A or 5 in A):
        continue
    CHOICES.append([i, match[i]])

print(CHOICES)
ans = dp(N,0)
print(ans)
    


### FIXED CODE ###

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

import sys
INT_MIN = sys.maxsize * -1
match = [-100,2,5,5,4,5,6,3,7,6]
CHOICES = []
for i in A:
    if (i == 6) and (9 in A):
        continue
    if (i == 3) and (5 in A):
        continue
    if (i == 2) and (3 in A or 5 in A):
        continue
    CHOICES.append([i, match[i]])
CHOICES.sort(reverse=True)

ans = [0]
#print(CHOICES)
for i in range(1,N+1):
    ans.append(INT_MIN)
    for c in CHOICES:
        #if  i - c[1] == 0:
        #    ans[i] = max(ans[i], int(str(c[0])))
        #elif i - c[1] >= 0 and ans[i - c[1]] != INT_MIN:
        #    ans[i] = max(ans[i], int(str(c[0]) + str(ans[i - c[1]])))

        if i - c[1] >= 0 and ans[i - c[1]] != INT_MIN:
            ans[i] = max(ans[i], c[0] + ans[i - c[1]] * 10)

print(ans[N])
n = int(input())
v = [int(i) for i in input().split()]
v.sort()
ans = v[0]
for i in range(2, len(v)):
    ans = (ans + v[i]) / 2
print(ans)


### FIXED CODE ###

a = int(input())
s = input()
if a >= 3200:
    print(s)
else:
    print("red")
n, m = map(int, input().split())

li = [0]*n

for i in range(n):
    s, c = map(int, input().split())
    if li[s-1] != 0 and li[s-1] != c:
        print(-1)
        exit(0)
    if s==1 and c==0:
        print(-1)
        exit(0)
    li[s-1]=c

if li[0]==0:
    li[0]=1

for i in range(n):
    print(li[i], end="")

### FIXED CODE ###

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

li = [0]*n

for i in range(m):
    s, c = map(int, input().split())
    if li[s-1] != 0 and li[s-1] != c:
        print(-1)
        exit(0)
    if s==1 and c==0:
        if n>1:
            print(-1)
            exit(0)
    li[s-1]=c

if n>1 and li[0]==0:
    li[0]=1

for i in range(n):
    print(li[i], end="")
d = {'B':'R', 'R':'B'}
s = str(input())
s[1] = d[s[1]]
print(s)

### FIXED CODE ###

s = str(input())
if(s[1] == 'B'):
  print('ARC')
else:
  print('ABC')
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))


time = 0
ans = 0

while time <= k:
    if a[0] < b[0]:
        time += a.pop(0)
        a.append(200001)
    elif a[0] > b[0]:
        time += b.pop(0)
        b.append(200001)
    else:
        if a[1] < b[1]:
            time += a.pop(0)
            a.append(200001)
        else:
            time += b.pop(0)
            b.append(200001)
    
    if time <= k:
        ans += 1
    else:
        break

print(ans)

### FIXED CODE ###

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

A_cumsum, B_cumsum = [0], [0]

for i in range(n):
    A_cumsum.append(A_cumsum[i] + A[i])
    
for j in range(m):
    B_cumsum.append(B_cumsum[j] + B[j])
    
ans, j = 0, m

for i in range(n + 1): # 0を最初に代入した分
    if A_cumsum[i] > k:
        break
    while A_cumsum[i] + B_cumsum[j] > k:
        j -= 1
    ans = max(ans, i + j)

print(ans)
n, k, *v = map(int, open(0).read().split())

lrui = [0] + v + [0]
for i in range(n): lrui[i+1] += lrui[i]
rrui = [0] + v + [0]
for i in range(n, 0, -1): rrui[i] += rrui[i+1]

lminus = [[] for i in range(n+2)]
for i in range(n+1):
    lminus[i+1] = lminus[i].copy()
    if i<n and v[i]<=0: lminus[i+1].append(v[i])

rminus = [[] for i in range(n+2)]
for i in range(n, -1, -1):
    rminus[i] = rminus[i+1].copy()
    if i>=0 and v[i-1]<=0: rminus[i].append(v[i-1])

ans = 0
for i in range(min(n, k)+1):
    for j in range(n+1, n-k+i, -1):
        tmp = lrui[i] + rrui[j]
        st = sorted(lminus[i] or rminus[j])
        for l in range(min(k-(i+n-j+1), len(st))):
            tmp -= st[l]
            ans = max(ans, tmp)
print(ans)

### FIXED CODE ###

n, k, *v = map(int, open(0).read().split())

ans = 0
for i in range(n+1):
    for j in range(n+1):
        if i+j>k: continue
        cand = sorted([v[I] for I in range(n) if I<i or n-j<=I])
        cnt = sum(cand)
        ans = max(ans, cnt)
        for l in range(min(k-i-j, len(cand))):
            cnt -= cand[l]
            ans = max(ans, cnt)
print(ans)
S,T=input()
for i in range(0,len(S)):
  cr=0
  if S[i]==T[i]:
    cr+=1
print(cr)


### FIXED CODE ###

s=input()
t=input()
cr=0
for i in range(3):
  if s[i]==t[i]:
    cr+=1
print(cr)
n = int(input())

odd = (n + 1) // 2
ans = odd / n
print(f'{ans:.9f}')


### FIXED CODE ###

n = int(input())

odd = (n + 1) // 2
ans = odd / n
print('{:.9f}'.format(ans))
number=input()
list=number.split()
list.sort()
print list[0]+list[1]+list[2]


### FIXED CODE ###

number=input()
list=number.split()
list.sort()
print(list[0]+" "+list[1]+" "+list[2])
x, y = map(int, input().split())

if y % 2 == 0:
    turu = y // 2 - x
    kame = 2*x - y // 2
    if turu >= 0 and kame >= 0:
        print('Yes')
        sys.exit()
print('No')

### FIXED CODE ###

x, y = map(int, input().split())

ans = 'No'
if y % 2 == 0:
    turu = y // 2 - x
    kame = 2*x - y // 2
    if turu >= 0 and kame >= 0:
        ans = 'Yes'
print(ans)
a = int(input())
b = list(map(int, input().split()))
c = 1

if 0 in a:
    print(0)
    exit()

for n in b:
    c = c*n
    if c > 10**18:
        print(-1)
        exit()

print(c)

### FIXED CODE ###

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

if 0 in b:
    print(0)
    exit()

for n in b:
    c = c*n
    if c > 10**18:
        print(-1)
        exit()

print(c)