Harryxun/stf_run huggingface dataset:
n,k=map(int,input().split())
li=[list(map(int,input().split())) for i in range(n)]
gr=[0]*(n+1) #各グループの出現回数をメモする配列

from operator import itemgetter
li=sorted(li, key=itemgetter(1), reverse=True)

A=[] #大きい方からK個以内の配列で、2個以上あるやつの2番目以降のやつの大きさを記録

for i in range(k):
  if gr[li[i][0]]>=1:
    A.append(li[i][1])
  gr[li[i][0]]+=1

A.reverse()

B=[] #既に同じグループが登場してしまってない子の大きさを記録
for i in range(k,n):
  if gr[li[i][0]]==0:
    B.append(li[i][1])
  gr[li[i][0]]+=1

#現時点での種類数とポイントを測定
sp=set()
ans=0
for i in range(k):
  ans+=li[i][1]
  sp.add(li[i][0])
sp=len(sp)
ans+=sp*sp

koukan=[] #その交換で、累積でどの程度増減するか
zouka=0
for a,b in zip(A,B):
  zouka+=(sp+1)**2-sp**2-(a-b)
  #print(a,b,sp,zouka)
  koukan.append(zouka)
  sp+=1

#koukanの中で最大の増加を探して、ansに+する。
# print(A,B)
# print(koukan)
ans+=max(0,max(koukan))

print(ans)

### FIXED CODE ###

n,k=map(int,input().split())
li=[list(map(int,input().split())) for i in range(n)]
gr=[0]*(n+1) #各グループの出現回数をメモする配列

from operator import itemgetter
li=sorted(li, key=itemgetter(1), reverse=True)

A=[] #大きい方からK個以内の配列で、2個以上あるやつの2番目以降のやつの大きさを記録

for i in range(k):
  if gr[li[i][0]]>=1:
    A.append(li[i][1])
  gr[li[i][0]]+=1

A.reverse()

B=[] #既に同じグループが登場してしまってない子の大きさを記録
for i in range(k,n):
  if gr[li[i][0]]==0:
    B.append(li[i][1])
  gr[li[i][0]]+=1

#現時点での種類数とポイントを測定
sp=set()
ans=0
for i in range(k):
  ans+=li[i][1]
  sp.add(li[i][0])
sp=len(sp)
ans+=sp*sp

koukan=[] #その交換で、累積でどの程度増減するか
zouka=0
for a,b in zip(A,B):
  zouka+=(sp+1)**2-sp**2-(a-b)
  #print(a,b,sp,zouka)
  koukan.append(zouka)
  sp+=1

#koukanの中で最大の増加を探して、ansに+する。
# print(A,B)
# print(koukan)
if koukan:
  ans+=max(0,max(koukan))

print(ans)
n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())

def solve(i, m):
if m == 0:
   return True
if i >= n and m > sum(A)
   return False
res = solve(i + 1, m) or solve(i + 1, m - A[i])
return res

for m in M
   if solve(0,m):
      print 'yes'
   else:
      print 'no'

### FIXED CODE ###

n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())

def solve(i, m):
   if m == 0:
     return True
   if i >= n or m > sum(A):
     return False
   res = solve(i + 1, m) or solve(i + 1, m - A[i])
   return res

for m in M:
  if solve(0,m):
     print "yes"
  else:
     print "no"
N = int(input())
S = input()

s = []
L = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
L += L

for i in S:
  s += a[a.find(c) + N]
  
print(*s, sep="")

### FIXED CODE ###

N = int(input())
L = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
S = input()
res = ""

for i in S:
  n = ord(i)
  n = n + N
  if n > ord("Z"):
    n -= 26
  res += L[n - ord("A")]
  
print(res)
N,M=map(int,input().split())
A=list(map(int,input().split()))
aa = [0]*(N+1)
tbl = [0]*M
cnt = 0
for i in range(N):
  aa[i+1] = aa[i]+A[i]
  am = aa[i+1] % M
  tbl[am] += 1
  cnt += tbl[am]-1
am = aa[i+1] % M
tbl[am] += 1
cnt += tbl[am]-1
print(int(cnt))


### FIXED CODE ###

from collections import Counter
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.insert(0,0)
cnt = Counter()
for i in range(N): A[i+1] += A[i]
for i in range(N+1): cnt[A[i]%M] += 1
print(sum(n*(n-1)//2 for n in cnt.values()))
import math
MOD = 1e+9+7
N = int(input())

d_p = dict()
d_m = dict()
ans = 1
zz = 0

for n in range(N):
    a,b = map(int,input().split())

    if a==0 and b==0:
        zz += 1
        continue
    if a==0:
        n_sign = 0
        b = 0
    elif b==0:
        n_sign = 1
        a = 0

    else:    
        n_sign = ((a<0) + (b<0))%2
        a = abs(a)
        b = abs(b)
        gcd = math.gcd(a,b)
        a//=gcd
        b//=gcd

    if n_sign==1:
        s =str(b)+'/'+str(a)
        d_m[s] = d_m.get(s,0) + 1
    elif n_sign==0:
        s =str(a)+'/'+str(b)
        d_p[s] = d_p.get(s,0) + 1      

for k,v in d_m.items():
    if k in d_p:
        ans *= (2**v + 2**d_p[k] - 1)
        d_p.pop(k)
    else:
        ans *= 2**v
    ans %= MOD

for k,v in d_p.items():
    ans *= 2**v
    ans %= MOD
    
ans -= 1
ans += zz
ans %= MOD
print (ans)


### FIXED CODE ###

import math
MOD = 1000000007
N = int(input())
d_p = dict()
d_m = dict()
zz = 0
for n in range(N):
    a,b = map(int,input().split())

    if a==0 and b==0:
        zz += 1
        continue
    if a==0:
        n_sign = 1
        a=0
        b=0
    elif b==0:
        n_sign = 0
        a=0
        b=0  


    else:    
        n_sign = ((a<0) + (b<0))%2
        a = abs(a)
        b = abs(b)
        gcd = math.gcd(a,b)
        a//=gcd
        b//=gcd
        #print(n_sign,a,b)

    

    if n_sign==1:
        s =str(b)+'/'+str(a)
        d_m[s] = d_m.get(s,0) + 1
    elif n_sign==0:
        s =str(a)+'/'+str(b)
        d_p[s] = d_p.get(s,0) + 1      
    
#print (d_m,d_p)

ans = 1
for k,v in d_m.items():
    if k in d_p:
        ans *= (2**v + 2**d_p[k] - 1)
        
        d_p.pop(k)
    else:
        ans *= 2**v
    ans %= MOD

for k,v in d_p.items():
    ans *= 2**v
    ans %= MOD
ans -= 1
ans += zz
ans %= MOD
print (ans)
rint("a", ord("a"))
print("z", ord("z"))

s = input()
n = len(s)
ans = 1
if s[0] != "A":
    ans *= 0
if not (97 <= ord(s[1]) <= 122):
    ans *= 0
if not (97 <= ord(s[-1]) <= 122):
    ans *= 0

check = 0
for i in range(1, n - 1):
    if s[i] == "C":
        check += 1
print(["WA", "AC"][ans & (check == 1)])

### FIXED CODE ###

s = input()
n = len(s)
ans = 1
if s[0] != "A":
    ans *= 0
if not (97 <= ord(s[1]) <= 122):
    ans *= 0
if not (97 <= ord(s[-1]) <= 122):
    ans *= 0

check = 0
for i in range(1, n - 1):
    if s[i] == "C":
        check += 1
print(["WA", "AC"][ans & (check == 1)])
row = int(input())
item_list = [input() for i in range(row)]
result_list = []
for j in item_list:
  exist_in_item_list = False
  for k in result_list.len():
    if result_list[k] == item_list[j]:
      exist_in_item_list = True
      break
  if not exist_in_item_list:
    result_list.append(item_list[j])

print(result_list.len())


### FIXED CODE ###

row = int(input())
item_list = [input() for i in range(row)]
print(len(set(item_list)))
import math

n,d = map(int,input().split())
xy = [list(map(float,input().split())) for i in range(n)]
count = 0
for i in range(n):
  for j in range(i+1,n):
    dis=0
    for k in range(d):
      dis += (xy[i][k]-xy[j][k])**2
    dis = math.sqrt(dis)
    if dis.is_integer():
      count +=1
      
print(count)

### FIXED CODE ###

n,a,b = map(int,input().split())
if n*a>b:
  print(b)
else:
  print(a*n)
import itertools

inputs = input()
N = int(inputs)


inputs = input().split()
A = map(lambda x: int(x), inputs)

count = 1
for i in A:
    if i % 2 == 0:
        count = count * 2
        
print(3**N - count )

### FIXED CODE ###

inputs = input()

x = list(inputs)

flag = False
for i in range(len(x) - 1):
    if x[i] == 'A' and x[i+1] == 'C':
        flag = True

if flag:
    print('Yes')
else:
    print('No')
pair = [[1, 2], [2, 5], [3, 5], [4, 4], [5, 5], [6, 6], [7, 3], [8, 7], [9, 6]]
n, m = [int(x) for x in input().split()]
given = sorted([int(i) for i in input().split()])
given_pair = sorted([pair[x - 1] for x in given], reverse=True)

dp = (1 + n) * [0]
max_dp = 0
for i in range(n + 1):
    if i == 0:
        dp[i] = 0
    for j in range(m):
        if i - given_pair[j][1] >= 0:
            if dp[i - given_pair[j][1]] + 1 >= max_dp:
                max_dp = dp[i - given_pair[j][1]] + 1
    dp[i] = max_dp




def choice_list(x, index):
#    print("now_index", index)
#    print(given_pair[x][1])
#    print("now_dp_atai", dp[index - given_pair[x][1]])
    if dp[index - given_pair[x][1]] == dp[index] - 1:
        if dp[index - given_pair[x][1]] == 0:
            for j in given_pair:
                if index == j[1]:
                    return str(j[0])
            return ""
        elif index - given_pair[x][1] < 0:
            return "-1"
        else:
            return str(given_pair[x][0]) + choice_list(x, index - given_pair[x][1])

    else:
        return choice_list(x + 1, index)


print(choice_list(0, n))

### FIXED CODE ###

n, m = [int(i) for i in input().split()]
am = sorted([int(i) for i in input().split()],reverse=True)
c = [2, 5, 5, 4, 5, 6, 3, 7, 6]

dp = [-1 for i in range(n+1)]
dp[0]=0
for i in range(n+1):
    #max_tmp = -float("inf")
    for j in am:
        if i+c[j-1]<=n:
            dp[i+c[j-1]] = max(dp[i+c[j-1]], dp[i]+1)
#print(dp)
tmp_n = n
ans =""
for i in range(dp[n]):
    for j in range(m):
        if i==dp[n]-1 and tmp_n- c[am[j]-1] != 0:
            continue
        if tmp_n - c[am[j]-1] >= 0 and dp[tmp_n - c[am[j]-1]] == dp[tmp_n] -1:
            ans+=(str(am[j]))
            tmp_n -= c[am[j]-1]
            break


print(ans)
n = int(input())
nums = [int(input()) - 1 for i in range(n)]
count = 0
for i in range(n):
    if i == nums[nums[i]]:
        count += 1
print(count // 2)

### FIXED CODE ###

n = int(input())
nums = list(map(int,input().split(' ')))
count = 0
for i in range(n):
    if i + 1 == nums[nums[i] - 1]:
        count += 1
print(count // 2)
N=int(input())
A=list(map(int,input().split()))
ans = 1
if 0 in A:
	print(0)
	return
for a in A:
   	ans *= a
   	if ans > 1000000000000000000:
      	print(-1)
      	return
print(ans)


### FIXED CODE ###

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 ()
n=int(input())
h=[int(i) for i in input().split()]
memo=[-1]*(n+1)
def flog(n):
    if n<=0:
        memo[n]=0
        return 0
    if memo[n]!=-1:
        return memo[n]
    else:
        memo[n]=min(flog(n-1)+abs(h[n]-h[n-1]),flog(n-2)+abs(h[n]-h[n-2]))
        return memo[n]
print(flog(n-1))   


### FIXED CODE ###

n=int(input())
h=[int(i) for i in input().split()]
dp=[0]*n
dp[1]=abs(h[0]-h[1])
for i in range(2,n):
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = input()
S = raw_input.split()
for i in range(N):
	if S[i] == 'Y':
		print('Four')
		N = -1
		break
if N = -1:print('Three')

### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

X = input()
print X//3
import sys
readline = sys.stdin.readline
def MAIN():
    n, m = map(int, input().split())
    li = [i for i in range(n)]
    def f(a):
        if li[a] == a:
            return a
        li[a] = f(li[a])
        return li[a]
    def f2(a, b):
        if li[a] == a:
            li[a] = b
            return
        f2(li[a], b)
        li[a] = b
    for _ in range(m):
        x, y = map(int, readline().split())
        if f(x) > f(y):
            f2(x, li[y])
        elif f(x) < f(y):
            f2(y, li[x])
    for _ in range(int(input())):
        x, y = map(int, readline().split())
        print("yes" if f(a) == f(b) else "no")
MAIN()



### FIXED CODE ###

import sys
readline = sys.stdin.readline
def MAIN():
    n, m = map(int, input().split())
    li = [i for i in range(n)]
    def f(a):
        if li[a] == a:
            return a
        li[a] = f(li[a])
        return li[a]
    def f2(a, b):
        if li[a] == a:
            li[a] = b
        else:
            f2(li[a], b)
            li[a] = b
    def solve(a, b):
        if f(a) == f(b):
            return "yes"
        return "no"
    for _ in range(m):
        x, y = map(int, readline().split())
        if f(x) > f(y):
            f2(x, li[y])
        else:
            f2(y, li[x])
    for _ in range(int(input())):
        x, y = map(int, readline().split())
        print(solve(x, y))
MAIN()
n, x = map(int,input().split())

def rec(lv,ls):
    if lv == 0:
        return [1]
    else:
        ret = rec(lv-1,ls)
        for i in range(0,len(ret) -1):
            if ret[i]>0 and ret[i+1]>0:
                ret[i+1] += ret[i]
                ret[i] = 0  #deleted tag

        while 0 != ret.count(0):
            ret.remove(0)
        return [-1,*ret,1,*ret,-1]

#print( rec(n, list()) )


count = 0
for e in rec(n, list() ):
    abs_e = abs(e)

    if x == 0:
        break

    if x>=abs_e:
        x -= abs_e
        count += e if e>0 else 0
    else:
        count += x if e>0 else 0
        x = 0
    #print(x," ",count)

print(count)


### FIXED CODE ###


# This src was written after reading editional.pdf .

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


an, pn = [1], [1]

for i in range(n):
    an.append(2*an[i]+3)
    pn.append(2*pn[i]+1)

#print(an)

def f(n,x):

    #print(n,x)

    if n == 0:
        return 1 if 0<x else 0
    
    if x <= an[ n-1 ] + 1:
        return f( n-1, x-1 )

    else:# x <= 2*an[n-1] + 3:
        return f(n-1, x-an[n-1]-2) + pn[n-1] + 1


print(f(n,x))

    
#    else if: 
#        pass
import itertools

n,m,x = map(int,input().split())
ans = 0
tmp = 10 ** 7
ca = [[0]*m for i in range(n)]
nn = [i for i in range(n)]

for _ in range(n):
    ca[_] = list(map(int, input().split()))

xx = list(itertools.combinations(nn))

for ii in xx:
    ans = 0
    a = [0 for i in range(m)]

    for _ in ii:
        cost = ca[_][0]
        chk = 0
        for i in range(m):
            a[i] += ca[_][i+1]
            if a[i] < x:
                chk = 1

        ans += cost
        if chk == 0:
            if tmp > ans:
                tmp = ans
            break
    
    if tmp == 10 ** 7:
        print(-1)
        exit()

print(tmp)

### FIXED CODE ###

def main():
    n,m,x = map(int,input().split())
    a = [[] for _ in range(n)]
    c = [0] * n

    INF = 10 ** 9
    ans = INF

    for i in range(n):
        ca = list(map(int,input().split()))
        c[i],a[i] = ca[0],ca[1:]

    for s in range(0,1<<n):
        smart = [0] * m
        cost = 0
        for i in range(n):
            if(s>>i) % 2 == 0:continue
            cost += c[i]
            for j in range(m):
                smart[j] += a[i][j]
        ok = True
        for i in range(m):
            if smart[i] < x:
                ok = False
        if ok:
            ans = min(ans,cost)
    if ans == INF:
        ans = -1
    
    print(ans)

if __name__ == "__main__":
    main()
# An efficient Python3 program to compute
# sum of bitwise OR of all pair

# Returns sum of bitwise OR
# of all pairs
def sumXOR( arr,  n):
    sum = 0
    for i in range(0, 61):
        #  Count of zeros and ones
        zc = 0
        oc = 0
        # Individual sum at each bit position
        idsum = 0
        for j in range(0, n):
            if (arr[j] % 2 == 0):
                zc = zc + 1
            else:
                oc = oc + 1
            arr[j] = int(arr[j] / 2)
        # calculating individual bit sum
        idsum = oc * zc * (1 << i)
        # final sum
        sum = (sum + idsum)%(1e9+7);
    return sum



# driver function
sum = 0
n = int(input())
arr = []
for _ in range(n):
    arr.append(int(input())
sum = sumXOR(arr, n);
print (sum)


### FIXED CODE ###

import numpy as np

MAX_DIGIT = 60
MOD = 10**9 + 7

N = int(input())
A = np.array([int(a) for a in input().split()])

answer = 0
for d in range(MAX_DIGIT + 1):
    A, r = (A>>1), A % 2
    s = int(r.sum())
    base = (1<<d) % MOD #this may be key
    answer += (base * s * (N - s)) % MOD

answer %= MOD
print(answer)
n = int(input())
l = []
for i in range(n):
    s, p = input().split()
    l.append[(s, -int(p), i + 1])

l.sort()
for i in l:
    print(i[2])

### FIXED CODE ###

n = int(input())
l = []
for i in range(n):
    s, p = input().split()
    l.append((s, -int(p), i + 1))

l.sort()
for i in l:
    print(i[2])
A,B,C = map(int, input().split())
if A+B == C:
  print("Yes")
else:
  prin("No")

### FIXED CODE ###

A,B,C = map(int, input().split())
if A+B >= C:
  print("Yes")
else:
  print("No")
N, K = map(int, input().split())
*H, = map(int, input().split())
H.sort(reverse=True)
if len(H) - K <= 0:
    print(0)
else:
    print(sum(H[K:]))

### FIXED CODE ###

import sys
input = sys.stdin.readline
N = int(input())
A = [int(input()) for _ in range(N)]
B = sorted(A)
for x in A:
    if x == B[-1]:
        print(B[-2])
    else:
        print(B[-1])
import math
n=input().split()
a = int(n[0])
b=int(n[1]) *100

ans = a*b

print(ans/100)


### FIXED CODE ###

import math
from decimal import Decimal
n=input().split()
a = int(n[0])
b=Decimal(n[1])
ans = a*b

print(int(ans))
n,t = map(int,input().split())
data=[]

for i in range(n):
    data.append(list(map(int,input().split())))
    
data.sort(key=lambda x:x[1])

pos = 0
for i in range(len(data)):
    if data[i][1] >t:
        pos = i-1
        break
        
if pos==-1:
    print('TLE')
else:
    new = data[:pos]
    new.sort(key=lambda x:x[0])
    print(new[0][0])

### FIXED CODE ###

n,t = map(int,input().split())
data=[]

for i in range(n):
    data.append(list(map(int,input().split())))
    
data.sort(key=lambda x:x[1])

pos = len(data)
for i in range(len(data)):
    if data[i][1] >t:
        pos = i
        break
        
if pos==0:
    print('TLE')
else:
    new = data[:pos]
    new.sort(key=lambda x:x[0])
    print(new[0][0])
d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]
# t = []
# for _ in range(d):
#     t.append(int(input()))

cl = sum(c)
D = [0]*26
ans = [0]*d
T = [0]*d

for i in range(d):
    count = 0
    for j in range(26):
        D[j] += 1
    for j in range(d):
        sas = 0
        S = s[i][j-1]
        C = c[j-1]
        D[j-1] = 0
        dc = 0
        for k in range(26):
            dc += D[k]*c[k]
        sas = S - dc + sum(T[:i])
        if sas > count:
            count = sas
            ans[i] = j
            T[i] = sas
            
for i in ans:
    print(i)
        

### FIXED CODE ###

import copy
d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]

cl = sum(c)
D = [0]*26
ans = [0]*d
T = [0]*d

for i in range(d):
    count = 0
    for j in range(26):
        D[j] += 1
    for j in range(26):
        sas = 0
        S = s[i][j]
        C = c[j]
        Ds = copy.copy(D)
        Ds[j] = 0
        dc = 0
        for k in range(26):
            dc += Ds[k]*c[k]
        sas = S - dc + sum(T[:i])
        if sas > count:
            count = sas
            ans[i] = j+1
            T[i] = count

for i in ans:
    print(i)
import numpy as np
from itertools import product
INF = 10**9

N, M, X = map(int, input().split())
C = [None]*N
A = [None]*N
for i in range(N):
    line = list(map(int, input().split()))
    C[i] = line[0]
    A[i] = np.array(line[1:])

choose = [True, False]

min_price = INF

for s in product([True, False], repeat=N):
    price = 0
    knowledge = np.zeros(M)
    for i in range(N):
        if s >> i & 1:
            knowledge += A[i]
            price += C[i]
    if np.any(knowledge < X):
        continue
    if min_price == -1:
        min_price = price
    min_price = min(min_price, price)

if min_price == INF:
    print(-1)
else:
    print(min_price)


### FIXED CODE ###

from itertools import product
import numpy as np

N, M, X = map(int, input().split())
C = [None]*N
A = [None]*N
for i in range(N):
    line = list(map(int, input().split()))
    C[i] = line[0]
    A[i] = np.array(line[1:])

choose = [True, False]

min_price = -1

for books in product(choose, repeat=N):
    price = 0
    knowledge = np.zeros(M)
    for i in range(N):
        if books[i]:
            knowledge += A[i]
            price += C[i]
    if np.any(knowledge < X):
        continue
    if min_price == -1:
        min_price = price
    min_price = min(min_price, price)

if min_price == -1:
    print(-1)
else:
    print(min_price)
N, T = map(int,input().split())
ans = float("inf")

for i in range(N):
    c,t = map(int,input(),split())
    if t <= T:
        ans = min(num,c)

if ans == float("inf"):
    print("TLE")
else:
    print(ans)


### FIXED CODE ###

N, T = map(int,input().split())
ans = float("inf")

for i in range(N):
    c,t = map(int,input().split())
    if t <= T:
        ans = min(ans,c)

if ans == float("inf"):
    print("TLE")
else:
    print(ans)
n = int(input())
import math 
arr = []
for i in range(1,math.floor(n**0.5)):
  if n % i == 0:
    arr.append(i+n/i)
print(int(min(arr)-2))

### FIXED CODE ###

n = int(input())
import math 
arr = []
for i in range(1,n):
  if i > math.ceil(n**0.5):
    break
  if n % i == 0:
    arr.append(i+n/i-2)
print(int(min(arr)))
a,b=map(int,input().split())
print("1" if 1<=a,b<=9 else "-1")

### FIXED CODE ###

a,b=map(int,input().split())
f= 0<a<10 and 0<b<10
print(a*b if f is True else "-1")
while True:
 m,f,r = map(int, raw_input().split())
 m+f = s
 if m==-1 and f==-1 and r ==-1 : break
 elif m==-1 or f==-1 or r<30 : g=4
 elif 30 <= s and s <50 :
      if r <= 50: g=2
      else : g=3
 elif 50 <=s and s <65 : g=2
 elif 65 <=s and s<70 : g=1
 else: g=0
 print 'ABCDF'[g]


### FIXED CODE ###


while True:
    m,f,r = map(int, raw_input().split())
    s = m + f
    if m == -1 and f == -1 and r == -1: break
    elif m == -1 or f == -1 or s < 30: g=5
    elif 30 <= s and s < 50:
        if r >= 50: g=2
        else: g=3
    elif 50 <= s and s < 65: g=2
    elif 65 <= s and s < 80: g=1
    else: g=0
    print 'ABCDEF'[g]
N = int(input())
S = [input() for i in range(N)]

ac = 0
wa = 0
tle = 0
re = 0
for s in S:
  if s == 'AC': ac += 1
  elif s == 'WA': wa += 1
  elif s == 'TLE': tle += 1
  elif s == 'RE'; re += 1

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

### FIXED CODE ###

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

print('AC x ' + str(ac))
print('WA x ' + str(wa))
print('TLE x ' + str(tle))
print('RE x ' + str(re))
n = input()
a = list(map(int, input().split()))
for i in range(n):
    while True:
        a[i] *= 1/2
        if a[i]%2!=0 && a[i] < 0:
            break

print(min(a))


### FIXED CODE ###

print(input().count("1"))
if x==1 :
  print(0)
else print(1)

### FIXED CODE ###

x = int(input())
if x == 1 :
  print(0)
else :
  print(1)
from operator import mul
from functools import reduce
MOD = 10 ** 9 + 7

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

def cmb(n, r):
    r = min(r, n-r)
    if r == 0:
        return 1
    nume = reduce(mul, range(n, n-r, -1))
    deno = reduce(mul, range(1, r+1))
    
    return nume // deno % MOD

# 赤いボールの間と両端（N-K+1）の中からi個を選ぶ
for i in range(1, K+1):
    print(cmb((N-K+1), i) // cmb((K-1), i-1))

### FIXED CODE ###

from operator import mul
from functools import reduce

MOD = 10**9 + 7

def cmb(n, r):
    if n < r:
        return 0
    r = min(n-r, r)
    if r == 0:
        return 1
    numer = reduce(mul, range(n, n-r, -1))
    denom = reduce(mul, range(1, r+1))
    return numer // denom % MOD

N, K = map(int, input().split())
for i in range(1, K+1):
    print(cmb(K-1, i-1) * cmb(N-K+1, i) % MOD)
N = int(input())

chars = "0abcdefghijklmnopqrstuvwxyz"
a = ""
n = N

while True:
    x = N % 26

    if x == 0:
        x = 26

    a += chars[x]
    n -= x
    if n == 0:
        break

    n //= 26

print(n[::-1])

### FIXED CODE ###

n = int(input())
chars = "Xabcdefghijklmnopqrstuvwxyz"  

n_rem = n  
res = ""

while True:
    x = n_rem % 26
   
    if x == 0:
        x = 26
    res += chars[x]

    
    n_rem -= x

    
    if n_rem == 0:
        break

    n_rem //= 26


print(res[::-1])
L, R = map(int, input().split())

listX = []
sw = 0
i = 1
for i in range(1, 990590):
  listX.append(i*2019)

for n in range(len(listX)):
  if L < listX[n] and R > listX[n]:
    sw += 1

if sw > 0:
  print(0)

elif sw == 0:      
  L_1 = L % 2019
  R_1 = R % 2019
  
  idx1 = 0
  listA = []
  for idx1 in range(L_1, R_1):
    for idx2 in range(idx1 + 1, R_1 + 1):
      listA.append(idx1 * idx2)
 
  print(min(listA))

### FIXED CODE ###

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

if N*A < B:
  print(N*A)
else:
  print(B)
import numpy
a=[[0]*10]*12
n=int(input())
for i in range(n):
    b,f,r,v=map(int,input().split())
    a[ 3*b-4+f, r-1 ] = v
for i in range(12):
    if i > 0 and i%3==0:
        print('#'*20)
    print(*a[i,])

### FIXED CODE ###

towers = [
    [[0 for i in range(10)] for j in range(3)] for k in range(4)
]
floor = 3
 
n = int(input())
for i in range(n):
    b,f,r,v = list(map(int,input().split()))
    towers[b-1][f-1][r-1] += v
 
for b in towers:
    for f in b:
        for r in f:
            print(' ' + str(r), end='')
        print('')
    if floor:
        print('#'*20)
        floor -= 1