peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
n,k=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
if k>1:
    s=p[0]+p[1]+p[2]
    print(s)
else:
    print(p[0])
# Judge status: Accepted
# -*- coding: utf-8 -*-
# E - Sequence Decomposing
import sys 
from bisect import bisect_right

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
A = list(map(int,read().split()))
X = [-1]*N
for a in A:
    i = bisect_right(X,a-1)-1
    X[i] = a
print(N - X.count(-1))
# Judge status: Accepted
import math
import itertools

N = int(input())
position = [list(map(int, input().split())) for _ in range(N)]
town = list(range(N))
distance =list2 = [[0 for i in range(N)] for j in range(N)]
average = 0

for i in range(N):
  for j in range(N):
    distance[i][j] = math.sqrt((position[i][0] - position[j][0])**2 
                               + (position[i][1] - position[j][1])**2)

for order in itertools.permutations(town, N):
  for i in range(N-1):
    average += distance[order[i]][order[i+1]]
average /= math.factorial(N)

print(average)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
sufficient = sum(b)
# print(sufficient)
for i in range(n-1):
    if a[i]+1 == a[i+1]:
        # print(i, c[a[i]-1])
        sufficient += c[a[i]-1]
print(sufficient)
# Judge status: Accepted
n=int(input())
l=[]
r=[]
ans=0
for i in range(n):
    a,b=map(int,input().split())
    l.append(a)
    r.append(b)
l.sort()
r.sort()
if n%2==0:
    ans=int(((r[n//2]+r[n//2-1])/2-(l[n//2]+l[n//2-1])/2)*2+1)
else:
    ans=r[n//2]-l[n//2]+1
print(ans)
# Judge status: Accepted
print((lambda x: (x[0]-1)//x[1]+1)(list(map(int,input().split()))))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
def find_min_fuka_idx(lst, e1, e2):
  ok = -1
  ng = len(lst)
  while abs(ok-ng)>1:
    mid = (ok+ng)//2
    e3 = lst[mid]
    if e1+e2 > e3 and e2+e3>e1 and e3+e1>e2:
      ok = mid
    else:
      ng = mid
  return ng
c = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    c += find_min_fuka_idx(a[j+1:], a[i], a[j])
print(c)
# Judge status: Wrong Answer
N = int(input())
a = list(map(int,input().split()))

def solve(l, K=0):
  if K+1 in l:
    pos = a.index(K+1)
    return solve(l[pos:],K+1)
  else:
    return K
  
def judge(x):
  if x == 0:
    return -1
  else:
    return N-x


print(judge(solve(a)))
# Judge status: Accepted
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
A = sorted(A)
for i in range(K):
    ans += A[i]
print(ans)
# Judge status: Wrong Answer
import random

s1 = random.randint(0,1)
s2 = random.randint(0,1)
s3 = random.randint(0,1)
masu_list = (str(s1), str(s2), str(s3))

print(masu_list.count('1'))
# Judge status: Accepted
w,h,n=map(int,input().split())
u,d,r,l=h,0,w,0
for _ in range(n):
    x,y,a=map(int,input().split())
    if a==1 and x>l: l=x
    if a==2 and x<r: r=x
    if a==3 and y>d: d=y
    if a==4 and y<u: u=y
if u>d and r>l: print((u-d)*(r-l))
else: print(0)
# Judge status: Accepted
from fractions import gcd
n = int(input())
lcm = list(map(int, input().split()))
ans = [1] * n
while len(lcm) < (1 << 14):
  lcm.append(1)
  ans.append(0)
for i in range(13, -1, -1):
  bit = 1 << i
  for j in range(bit):
    new = lcm[j] // gcd(lcm[j], lcm[j | bit]) * lcm[j | bit]
    ans[j] = new // lcm[j] * ans[j] + new // lcm[j | bit] * ans[j | bit]
    ans[j] %= 1000000007
    lcm[j] = new
print(ans[0])
# Judge status: Accepted
# abc150_c.py
'''
全パターン作ってソートで順番みる
'''
import itertools
N = int(input())
P = tuple(list(map(int,input().split())))
Q = tuple(list(map(int,input().split())))

l = [i+1 for i in range(N)]
target =  itertools.permutations(l)
cnt=0
pcnt = 0
qcnt = 0
for i in target:
    cnt += 1
    if i == P:
        pcnt=cnt
    if i == Q:
        qcnt=cnt

print(abs(pcnt-qcnt))
# Judge status: Accepted
n,l = map(int,input().split())
s = [input() for i in range(n)]

s.sort()

print(''.join(s))
# Judge status: Wrong Answer
from string import ascii_lowercase
from collections import defaultdict


N = int(input())
S = input().strip()

c = defaultdict(int)
for i in range(N):
    c[S[i]] += 1

ans = 1
for x in ascii_lowercase:
    ans *= c[x] + 1
ans -= 1
print(ans)
# Judge status: Accepted
s = input()
ans = 'keyence'
cnt = 0

for i in range(7):
    if s[i] != ans[i]:
        break
    cnt += 1

for i in range(7):
    if s[len(s) - i - 1] != ans[6 - i]:
        break
    cnt += 1

if cnt >= 7:
    ans = 'YES'
else:
    ans = 'NO'
print(ans)
# Judge status: Accepted
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

N,A,B,C,D = map(int,readline().split())
S = readline().rstrip()

if C < D:#抜かさなくて良い
    if "##" not in S[A-1:D]:
        print("Yes")
    else:
        print("No")
else:#抜かす必要がある
    if "..." in S[B-2:D+1] and "##" not in S[A-1:C]:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
#!/usr/bin/env python3
# -*- coding:utf-8 -*-

import sys
import numpy as np

def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    H = list(map(int, input().split()))
    H = np.array(H)
    #dp[i]:iまでくるのに最小のコスト
    dp = np.zeros(N, dtype = int)
    for i in range(1, N):
        hi = H[i]
        dp[i] = min(dp[max(0,i-K):i] + np.abs(hi-H[max(0,i-K):i]))
    print(dp[-1])

if __name__=='__main__':
    main()
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
flag = 0
cnt = 0
for i in range(n-1):
    if flag == 0:
        if a[i] > a[i+1]:
            flag = -1
        if a[i] < a[i+1]:
            flag = 1
    if flag == 1:
        if a[i] > a[i+1]:
            flag = 0
            cnt += 1
    if flag == -1:
        if a[i] < a[i+1]:
            flag = 0
            cnt += 1
print(cnt+1)
# Judge status: Accepted
def resolve():
    s=input()
    nen=int(s[:4])
    getu=0
    if s[5]==0:
        getu=int(s[6])
    else:
        getu=int(s[5:7])

    if nen>2019:
        print('TBD')
    elif nen==2019 and getu>=5:
        print('TBD')
    else:
        print('Heisei')
resolve()
# Judge status: Wrong Answer
input()
s=t=input()
l,r=o="()"
exec('s=s'+'.replace(o,"")'*50)
print(l*(c:=s.count)(l)+t+r*c(r))
# Judge status: Wrong Answer
s = int(input())
for i in range(0, s):
    for j in range(-s, s):
        if i**5-j**5 ==s:
            print(i, j)
            break
# Judge status: Accepted
V=0;
o=input().rstrip().split(' ')
p=input().rstrip().split(' ')
S=0;
for i in range(0,len(p)):
    S+=int(p[i])
D=(1/(4*int(o[1])))*100;
p.sort(key=int,reverse=True)
for i in range(0,int(o[1])):
    G = (int(p[i])/S)*100;
    if G >= D:
        continue;
    else:
        V=1;
        break;
#print(D,G)
if V==0:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
A,B,C = map(int,input().split(" "))
# 一番長い辺で切れば断面の数は最小
L = max(A,B,C)//2
print(abs((A*B*L)-(A*B*(C-L))))
# Judge status: Accepted
N,K=map(int,input().split())
P=list(map(int,input().split()))
for i in range(N):
  if i!=0:
    P[i]=P[i-1]+(P[i]+1)/2
  else:
    P[i]=(P[i]+1)/2
    
ans=P[K-1]
for i in range(N-K+1):
  ans=max(ans,P[i+K-1]-P[i-1])
    
print(ans)
# Judge status: Accepted
# B 
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
s=si()
n=len(s)
for i in range(n):
    for j in range(n-i+1):
        t=s
        t=t[:j]+t[j+i+1:]
        if t=='keyence':
            print('YES')
            exit()
print('NO')
# Judge status: Accepted
n, m = map(int,input().split())
ans = 0
ab = []
for i in range(n):
  ab.append(list(map(int,input().split())))
ab.sort()

i = 0
while m > 0:
  if m > ab[i][1]:
    ans = ans + ab[i][0]*ab[i][1]
  else:
    ans = ans + ab[i][0]*m
  m -= ab[i][1]
  i += 1

print(ans)
# Judge status: Accepted
a, b, k = map(int, input().split())

count = 0
target = min(a, b)
l = []
for i in range(1, target + 1):
  if a % i == 0 and b % i == 0:
    l.append(i)

print(l[len(l) - k])
# Judge status: Wrong Answer
import string
import collections

alphabet = string.ascii_lowercase
alphabet = list(alphabet)
ans_dic = {}
for i in alphabet:
    ans_dic[i] = float("inf")

n = int(input())

L = []

for _ in range(n):
    tmp = list(input())
    dic = collections.Counter(tmp)
    for k in ans_dic.keys():
        ans_dic[k] = min(dic[k],ans_dic[k])

ans_dic = sorted(ans_dic.items(),key=lambda x:x[1],reverse=True)

ans = ""

for k,v in ans_dic:
    if v != 0:
        ans += k*v

print(ans)
# Judge status: Accepted
import sys
import math
from collections import deque
from collections import defaultdict

def comb(n, r, mod):
    X, Y = 1, 1
    for i in range(r):
        X = X * (n - i) % mod
        Y = Y * (r - i) % mod
    return X * pow(Y, mod-2, mod)

def main():
    n,a,b = list(map(int,sys.stdin.readline().split()))
    mod = 10**9 + 7
    ans = pow(2, n, mod) - 1
    ans = (ans - comb(n, a, mod) - comb(n, b, mod)) % mod
    print(ans)
    return 0

if __name__ == "__main__":
    main()
# Judge status: Accepted
n = int(input())
s = []
for i in range(n):
  s.append(input())
print(len(set(s)))
# Judge status: Wrong Answer
from collections import Counter
n=int(input())
a=Counter(list(map(int,input().split()))).most_common()
x=[0,0]

for i in range(len(a)):
  if (x[1]<a[i][0] or x[0]<a[i][0]) and a[i][1]>=2:
    if x[0]<x[1]:
      x[0]=a[i][0]
    else:
      x[1]=a[i][0]
print(x[0]*x[1])
# Judge status: Accepted
N,M = map(int,input().split())
g = 0
for i in range(1,int(M**0.5)+1):
    if M%i==0:
        a = i
        b = M//i
        if a>=N:
            g = max(g,b)
        if b>=N:
            g = max(g,a)
print(g)
# Judge status: Accepted
N = list(input())

if N[0] == "7" or N[1] == "7" or N[2] == "7":
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
A,B,M = map(int,input().split())

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

discount = []
for i in [0]*M:
    discount.append(list(map(int,input().split())))

min_comb = min(a)+min(b)

for i in range(M):
    min_comb = min(min_comb,a[discount[i][0]-1]+b[discount[i][1]-1]-discount[i][2])
ans = 0
print(ans)
# Judge status: Wrong Answer
import math
n,k=map(int,input().split())
if n%k==0:
    print(0)
else:
    a=abs(n-k*(n//k))
    print(a)
# Judge status: Accepted
N,R = map(int,input().split())
if N >= 10:
    print(R)
else:
    print(R+100*(10-N))
# Judge status: Wrong Answer
def solve():
  n, m = map(int, input().split())
  a = list(map(int, input().split()))
  hoge = max(0, n-sum(a))
  if hoge > 0:
    print(a)
  else:
    print(-1)
  return 0
 
if __name__ == "__main__":
  solve()
# Judge status: Accepted
n, m = map(int,input().split())
ans = 0
if n*2 >= m:
    ans += m//2
else:
    ans += n
    m -= n*2
    ans += m//4
print(ans)
# Judge status: Accepted
import networkx as nx
n,m=map(int,input().split())
s=[list(map(int,input().split())) for i in range(m)]

g=nx.Graph()
g.add_edges_from(s)

print("Yes")
for x in sorted(nx.bfs_predecessors(g,1)):
    print(x[1])
# Judge status: Accepted
from collections import Counter


S = input()
C = Counter(S)
vs = sorted(list(C.values()))
if len(vs) == 1:
    print("YES") if vs[0] == 1 else print("NO")
elif len(vs) == 2:
    print("YES") if vs[0] == vs[1] and vs[0] == 1 else print("NO")
else:
    print("YES") if vs[2] - 1 <= vs[0] and vs[2] - 1 <= vs[1] else print("NO")
# Judge status: Accepted
n = int(input())
s = input()
x = 0
max = 0
for i in range(n):
    if s[i]=='I':
        x += 1
        if x > max:
            max = x
    else:
        x -= 1
print(max)
# Judge status: Accepted
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n,d=nii()
num=d*2+1
print((n+num-1)//num)
# Judge status: Accepted
import sys
input = sys.stdin.readline

x = input()
print('A' if x.isupper() else 'a')
# Judge status: Wrong Answer
def gcd(a, b):
    if(a == 0):
        return b
    return gcd(b % a, a)
def lcm(a, b):
    return int(a/(gcd(a, b) * b)) 
t = int(input())
ans = 1
while(t != 0):
    t -= 1
    n = int(input())
    ans = lcm(ans, n)
    ans = int(ans)
print(int(ans))
# Judge status: Wrong Answer
a,b = map(int,input().split())
mylist = input().split()
mylist.sort()
c = 0
print(mylist)
for i in range(b-1):
    c = c + int(mylist[i-1])
print(c)
# Judge status: Wrong Answer
a=int(input())
i=0
while i**2<=a:
  i=i+1
print((i-1)**2)
# Judge status: Accepted
import sys

def main():
    N, K = list(map(int,input().split()))
    h = [0] * N
    for i in range(N):
        h[i] = int(input())

    h = sorted(h)

    ave = []
    for j in range(0,N-K+1):
        ave.append(abs(h[j]-h[j+K-1]))

    print(min(ave))

main()
# Judge status: Wrong Answer
N,K = map(int, input().split())
h = list(map(int, input().split()))
dp = [float('inf')] * 10 ** 5

dp[0] = 0
for i in range(1, N):
  tmp = i
  if tmp > K:
    tmp = K
  for j in range(1,tmp + 1):
      dp[i] = dp[i - j] + abs(h[i - j] - h[i])

print(dp[N-1])
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
z=0
for i in range (1000):
  if c-a*i<0:
    break
  if (c-a*i)%b==0:
    Z=1
    break
print("Yes" if z==1 else "No")
# Judge status: Wrong Answer
n = int(input())

i = 0
ab = []
while i < n:
    a, b = map(int, input().split())
    ab.append((a, b)) 
    i += 1

ab.sort(key=lambda x: x[1], reverse=True)

limit = ab[0][1] - ab[0][0]

i = 1
ans = 'Yes'
while i < n:
    limit -= ab[i][0]
    if limit < 0:
        ans = 'No'
        break
    i += 1
    
print(ans)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
s = [0] * 13
for i in a:
  s[i // 400] += 1
ans = 0
for i in range(8):
  if s[i] > 0:
    ans += 1
print(max(1, ans), ans + sum(s[8:]))
# Judge status: Accepted
n = int(input())
if n//100*5 >= n%100:
    print(1)
else:
    print(0)
# Judge status: Accepted
a = list(map(int, input().split()))
if sum(a) >= 22:
    print("bust")
else:
    print("win")
# Judge status: Accepted
def resolve():
    N = int(input())
    A = sorted(list(map(int, input().split())))
    start, end = min(A), max(A)
    mincost = float("inf")
    for i in range(start, end+1):
        _cost = 0
        for a in A:
            _cost += abs(a-i)**2
        mincost = min(mincost, _cost)
    print(mincost)


if '__main__' == __name__:
    resolve()
# Judge status: Accepted
n,m = map(int,input().split())
ans = [int(0) for i in range(m+1)]
for i in range(n):
    k = list(map(int,input().split()))
    for j in range(1,k[0]+1):
        ans[k[j]] += 1
#print(ans)
cnt = 0
for i in range(1,len(ans)):
    if ans[i]==n:
        cnt += 1
print(cnt)
# Judge status: Wrong Answer
r = int(input())
print("r ** 2")
# Judge status: Wrong Answer
s=input()
print(s+'es'[s[-1]<'s':])
# Judge status: Accepted
n = int(input())
X = list(map(int,input().split()))

ans = 10000000
for p in range(1,101):
    s = 0
    for x in X:
        s += (x - p) ** 2
    ans = min(ans, s)
    
print(ans)
# Judge status: Accepted
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9

def main():
    S = input()

    weeks = ['SUN','MON','TUE','WED','THU','FRI','SAT']
    for i in range(len(weeks)):
        if weeks[i] == S:
            print(7-i)
            return


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
S = str(input())
ans = 0
if len(S) == 1:
    print('No')
    ans = 1
for i in range(len(S)-1):
    if S[i] == 'h' and S[i+1] != 'i':
        print('No')
        ans = 1
        break
if ans == 0:
    print('Yes')
# Judge status: Accepted

def main():

    L, R = [int(i) for i in input().split()]

    if (L//2019) < (R//2019):
        ans = 0
    else:
        ans = 10 ** 10
        for l in range(L, R+1):
            for r in range(l+1, R+1):
                ans = min(ans, (l*r)%2019)

    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
N = int(input())
al = [chr(ord('a') + i) for i in range(26)]
out = dict(zip(al,[100]*26))
for i in range(N):
    S = list(input())
    tmp = dict(zip(al,[0]*26))
    for T in S:
        tmp[T] += 1
    for key in out.keys():
        out[key]=min(out[key],tmp[key])
outS = ""
for key in out.keys():
    outS += key*out[key]
print(outS)
# Judge status: Accepted
n = int(input())
p_list = list(map(int,input().split()))
count = 0
for i in range(n):
    if i+1 != p_list[i]:
        count+=1
if count ==0 or count==2:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
A, B, K = map(int, input().split())
if K <= A:
    print(A-K, B)
elif K <= A+B:
    print(0, B-(K-A))
else:
    print(0, 0)
# Judge status: Accepted
N = int(input())

AB = []
for _ in range(N):
    A, B = map(int,input().split())
    AB.append([B,A])

AB.sort()

t = 0
for i in range(N):
    t += AB[i][1]
    if t > AB[i][0]:
        print("No")
        exit()

print("Yes")
# Judge status: Accepted
# 入力
D, T, S = input().split()

# 以下に回答を記入
D = int(D)
T = int(T)
S = int(S)

if D - T * S <= 0:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
N = int(input())
ans = N-1
for i in range(2, int(N**0.5)+1):
  if N%i == 0:  
    ans = min([ans, i+N//i-2])
    
print(ans)
# Judge status: Accepted
a,b = [int(i) for i in input().split()]
print("EOvdedn"[a*b%2::2])
# Judge status: Accepted
H,W = map(int,input().split())
if H == 1 or W == 1:
  print(1)
else:
  print((H*W+1)//2)
# Judge status: Accepted
import math  # noqa
import bisect  # noqa
import queue  # noqa


if __name__ == '__main__':
    N, M = map(int, input().split())
    A = list(map(int, input().split()))

    que = queue.PriorityQueue()
    for a in A:
        que.put(-a)

    while M > 0:
        M -= 1
        a = que.get()
        que.put(-(-a // 2))

    ans = 0
    while not que.empty():
        ans += -que.get()

    print(ans)
# Judge status: Wrong Answer
n=int(input())
s=input()
alpha=[chr(i) for i in range(ord("A"),ord("Z")+1)]
encode=alpha[n:]+alpha[:n]
text=[]
for c in s:
    text.append(encode[alpha.index(c)])
    print("".join)
# Judge status: Wrong Answer
n=int(input())
mod=10**9+7
p=n
for i in range(n):
    p*=i+1
    p=p%mod
print(p)
# Judge status: Accepted
N,L=map(int,input().split())
lst=[]
for _ in range(N):
  arg=input()
  lst.append(arg)
lst.sort()
print(''.join(lst))
# Judge status: Accepted
m,n = map(int,input().split())
l = list(map(int,input().split()))
s = 0
for i in range(n):
  s += l[i]
print(max(m-s,-1))
# Judge status: Accepted
X=int(input())
if X>=30:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
s=input()
n=int(input())
r=-1
for i in range(n):
    q=input().split()
    if q[0]=='1':
        r*=-1
    else:
        t=int(q[1])
        if t*r==(-1 or 2):
            s=q[2]+s
        else:
            s=s+q[2]
if r==1:
    s=s[::-1]
print(s)
# Judge status: Wrong Answer
ll=[list(map(int,input().split())) for i in range(3)]
for i in range(2):
  for j in range(i+1,3):
    for k in range(3):
      if ll[k][i]==ll[k][j]:
          if not all(ll[t][i]==ll[t][j] for t in range(3)):
            print('No')
            exit()
      if ll[i][k]==ll[j][k]:
        if not all(ll[i][t]==ll[j][t] for t in range(3)):
          print('No')
          exit()
print('Yes')
# Judge status: Accepted
n = int(input())
cont = [0 for i in range(10050)]

for x in range(1,105):
  for y in range(1,105):
    for z in range(1,105):
      v = x**2 + y**2 + z**2 + z*x + y*z + x*y
      if v <= 10001:
        cont[v]+=1

for i in range(1,n+1):
  print(cont[i])
# Judge status: Wrong Answer
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())
opt = {
    "r": "p",
    "s": "r",
    "p": "s"
}
ans = 0
prev = []
for i, x in enumerate(T):
    if i - K >= 0 and opt[x] == prev[i-K]:
        prev.append(x)
    else:
        prev.append(opt[x])

for i, x in enumerate(prev):
    if x == T[i]:
        pass
    else:
        ans += eval(x.upper())
print(ans)
# Judge status: Accepted
a,b,c,k=map(int,open(0).read().split())

if k<=a+b:
    print(min(a,k))
else:
    cntc=k-a-b
    print(a-cntc)
# Judge status: Accepted
import math
N = int(input())
S = [0]*N
lim = math.sqrt(N)
lim = math.floor(lim)
for i in range(1,lim):
  for j in range(1,lim):
    for k in range(1,lim):
        temp = int(i**2+ j**2 + k**2 + i*j + j*k + k*i)
        if temp <N+1:
          S[temp-1] += 1
for i in range(N):
  print(S[i])
# Judge status: Wrong Answer
def func(n):
    cnt = 0
    for x in range(1, 101):
        for y in range(1, 101):
            for z in range(1, 101):
                if x**2+y**2+z**3+x*y+y*z+z*x == n:
                    cnt += 1
    return(cnt)

n = int(input())
for i in range(1, n+1):
    print(func(i))
# Judge status: Accepted
n = int(input())
cur = 0
res = 0
for _ in range(n):
    x = int(input())
    if x == 0:
        res += cur // 2
        cur = 0
    else:
        cur += x
res += cur // 2
print(res)
# Judge status: Wrong Answer
n = int(input())
s = input()
ans = s[:-1] + chr((ord(s[-1])+n-1 - ord('A'))%26 + 1 + ord('A'))
print(ans)
# Judge status: Accepted
N = int(input())
S = input()

r = S.count('R')
g = S.count('G')
b = S.count('B')

ans = r*g*b

for i in range(0,N):
  for j in range(i,N):
    k = 2*j - i
    if j < k <= N-1:
      if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
        ans -= 1

print(ans)
# Judge status: Wrong Answer
x, y = map(int, input().split())

group_1 = [1, 3, 5, 7, 8, 10, 12]
group_2 = [4, 6, 9, 11]

if x == 2 or y == 2:
    print("No")
    exit()

else:
    if x in group_1 and y in group_1:
        print("Yes")

    elif x in group_2 and y in group_2:
        print("Yes")
# Judge status: Accepted
a = input()
b = input()


if a[::-1] == b:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
import math

math.gcd(2,10)
N =int(input())
total = 0
a=1
b=1
c=1
if N ==1:
	total =1
while a <=N:
	b=1
	while b <=N:
		c=1
		while c <=N:
			if math.gcd(a,b)==1:
				total += N
				break
			total += math.gcd(a,math.gcd(b,c))
			c+=1
		b+=1 
	a+=1
print(total)
# Judge status: Accepted
l = int(input())
x = l / 3
print(x ** 3)
# Judge status: Accepted
N = int(input())

L = [0 for i in range(N+1)]

if N == 1:
  print(1)

else:
  L[0] = 2
  L[1] = 1

  for n in range(2,N+1):
    L[n] = L[n-1] + L[n-2]
    
  print(L[N])
# Judge status: Accepted
N, A, B = map(int,input().split())
min = A * (N - 1) + B
max = B * (N - 1) + A
if (max - min) + 1 < 0:
    print("0")
else:
    print((max - min) + 1)
# Judge status: Wrong Answer
n=int(input())

maxx=0
maxn=0
for i in range(1,n+1):
  tmp=i
  cnt=0
  while 1:
    if tmp%2==0:
      tmp=tmp//2
      cnt+=1
    else:
      break
  if cnt > maxx:
    maxn=tmp
print(maxn)
# Judge status: Accepted
l,r,d=list(map(int,input().split()))

cnt=0

for i in range(l,r+1):
    if i%d==0:
        cnt+=1

print(cnt)
# Judge status: Wrong Answer
N=int(input())
ai=list(map(int,input().split()))
ai.sort()
ans1=ai[N:]
ans2=ans1[:N]

print(ans1)
print(ans2)

print(sum(ans2))
# Judge status: Accepted
X = int(input())
print(((X//2)+1)/X if X % 2 != 0 else 0.5)
# Judge status: Wrong Answer
n = set(input())
print(max(n)*3)
# Judge status: Accepted
f = lambda:map(int,input().split())
n,m = f()
d = {}
for i in range(n):
  d[i+1]=0
for _ in range(m):
  a,b = f()
  d[a] += 1
  d[b] += 1
for k in d:
  print(d[k])
# Judge status: Accepted
n=int(input())
L=[]
for _ in range(n-1):
    L.append(tuple(map(int,input().split())))
ans=[]
for i in range(n-1):
    c,t,f=L[i]
    t += c
    for j in range(i+1,n-1):
        cn,sn,fn=L[j]
        if t>sn:
            t=-int(-t//fn)*fn
        else:
            t=sn
        t += cn
    ans.append(t)
ans.append(0)
for i in ans:
    print(i)
# Judge status: Accepted
n,d=map(int,input().split())
if n%(2*d+1)!=0:
    a=n//(2*d+1)+1
else:
    a=n//(2*d+1)
print(a)
# Judge status: Wrong Answer
from collections import deque
import sys
input = sys.stdin.readline

S = input().rstrip()
Q = int(input())
FTC = [tuple(input().split()) for _ in range(Q)]

que = deque([S])
cnt = 0
for query in FTC:
    if query[0] == '1':
        cnt ^= 1
        continue

    sign = 0 if query[1] == '1' else 1

    if sign ^ cnt == 0:
        que.appendleft(query[2])
    else:
        que.append(query[2])

ans = ''
while que:
    ans += que.popleft() if cnt == 0 else que.pop()

print(ans)