Harryxun/stf_run huggingface dataset:
x, y, z, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
r = [0] * (x * y * z)
for i in range(x):
  for j in range(y):
    for l in range(z):
      r[l+j*y+i*x*y] = a[i] + b[j] + c[l]
r.sort()
for i in range(k):
  print(r[-(i+1)])

### FIXED CODE ###

import numpy as np

x, y, z, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
r = []
for i in range(x):
  for j in range(y):
    if (i + 1) * (j + 1) > k:
        break
    for l in range(z):
      if (i + 1) * (j + 1) * (l + 1) > k:
        break
      r.append(a[i] + b[j] + c[l])
r.sort()
for i in range(k):
  print(r[-(i+1)])
a, b, c = gets.split.map(&:to_i)
puts (a < b and b < c) ? "Yes" : "No"


### FIXED CODE ###

a,b,c=[int(x) for x in input().split()]
print("Yes" if a<b<c else "No")
A,B=map(input().split())
S=A+B
S**0.5=K
if K%1==0:
  print("Yes") 
else ("No")

### FIXED CODE ###


import math

a,b = input().split()
d = int(a + b)
if int(math.sqrt(d)) * int(math.sqrt(d)) == d :
	print('Yes')
else :
	print('No')
n = int(input())
ans = 0

for i in range(1:n+1):
  if i % 5 != 0 and i % 3 !=0:
    ans += i

print(ans)

### FIXED CODE ###

n = int(input())
ans = 0

for i in range(1,n+1):
  if i % 5 != 0 and i % 3 !=0:
    ans += i

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

if  (type(a)=b==int) and (-1000 <= a=b <=1000):
    print(max(a+b,a-b,a*b))


### FIXED CODE ###

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

if  (type(a)==int) and( type(b)==int) and (-1000 <= a and 1000>=a ) and (-1000 <= b and 1000>=b ):
    print(max(a+b,a-b,a*b))
X = list(map(int, input(),split())
         
for i in X:
	if i == 0:
         print(i+1)

### FIXED CODE ###

X = input().split()
         
for i,num in enumerate(X):
	if num == "0":
		print(int(i)+1)
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))

a4 = len(a[a % 4 == 0])
a2 = len(a[a % 2 == 0 and a % 4 != 0])
a4n = len(a[a % 4 != 0]) - a2 

if a2 != 0:
  print("Yes" if a4 + 1 >= a4n+1 else "No")

else:
  print("Yes" if a4 + 1 >= a4n else "No")

### FIXED CODE ###

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

a4, a4n, a2 = 0, 0, 0
for ai in a:
  if ai % 4 == 0:
    a4 += 1
  elif ai % 2 == 0:
    a2 += 1
  else:
    a4n += 1

if a2 != 0:
  print("Yes" if a4 + 1 >= a4n+1 else "No")

else:
  print("Yes" if a4 + 1 >= a4n else "No")
"""
問題文
    N段の階段があります。高橋君は現在、上り口(0段目)にいます。 高橋君は一歩で1段か2段上ることができます。
    ただし、a1,a2,a3,....aM段目の床は壊れており、その段に足を踏み入れることは危険です。
    壊れている床を踏まないようにしながら、最上段(N段目)にたどりつくまでの移動方法は何通りあるでしょうか？ 
    総数を1,000,000,007で割った余りを求めてください。

制約
    1≦N≦10^5
    0≦M≦N−1
    1≦a1<a2< ... <aM≦N−1
"""
#入力の受け取り
N, M = map(int, input().split())
hoal = [int(input()) for i in range(M)]

#listの初期化
dp = list()
dp = [0]*N
dp[0] = 1
dp[1] = 2
if 1 in hoal:
    dp[0] = 0
    dp[1] = 1

#実際に求める
#dp[i]<-i段までの移動方法の和
for i in range(N):
    if i>1:
        dp[i]=dp[i-1]+dp[i-2]
    if i+1 in hoal:
        dp[i]=0
    dp[i]=dp[i]%1000000007

print(dp[N-1])
    

### FIXED CODE ###

"""
問題文
    N段の階段があります。高橋君は現在、上り口(0段目)にいます。 高橋君は一歩で1段か2段上ることができます。
    ただし、a1,a2,a3,....aM段目の床は壊れており、その段に足を踏み入れることは危険です。
    壊れている床を踏まないようにしながら、最上段(N段目)にたどりつくまでの移動方法は何通りあるでしょうか？ 
    総数を1,000,000,007で割った余りを求めてください。

制約
    1≦N≦10^5
    0≦M≦N−1
    1≦a1<a2< ... <aM≦N−1
"""
#入力の受け取り
N, M = map(int, input().split())
hoal = [int(input()) for i in range(M)]

#listの初期化
dp = list()
dp = [0]*N

    
dp_check = list()
dp_check = [0]*N

for i in range(M):
    dp_check[hoal[i]-1]=1
    if dp_check[hoal[i]-1]==1 and dp_check[hoal[i]-2]==1:
        print("0")
        exit()

if N==1:
    if M==1:
        dp[0]=0
    else:
        dp[0]=1
    print(dp[N-1])
else:
    if dp_check[0]==1:
        dp[0]=0
        dp[1]=1
    elif dp_check[1]==1:
        dp[0]=1
        dp[1]=0
    else:
        dp[0] = 1
        dp[1] = 2
    #実際に求める
    #dp[i]<-i段までの移動方法の和
    for i in range(N):
        if i>1 and dp_check[i]==0:
            dp[i]=dp[i-1]+dp[i-2]

        dp[i]=dp[i]%1000000007

    print(dp[N-1])
N, M = map(int, input().split())
Alist = list(map(int, input().split()))
BClist = []
for i in range(M):
    B, C = map(int, input().split())
    BClist.append([B, C])
Alist.sort()
BClist.sort(reverse= True, key=lambda x: x[1])

num = 0
flag = True
for i in range(M):
    if not flag:
        break
    for j in range(BClist[i][0]):
        if num > len(Alist):
            flag = False
            break
        elif BClist[i][1] > Alist[num]:
            Alist[num] = BClist[i][1]
            num += 1
        elif BClist[i][1] <= Alist[num]:
            flag = False
            break

print(sum(Alist))

### FIXED CODE ###

N, M = map(int, input().split())
Alist = list(map(int, input().split()))
BClist = []
for i in range(M):
    B, C = map(int, input().split())
    BClist.append([B, C])
Alist.sort()
BClist.sort(reverse=True, key=lambda x: x[1])

num = 0
flag = True
for i in range(M):
    if not flag:
        break
    for j in range(BClist[i][0]):
        if num >= len(Alist):
            flag = False
            break
        elif BClist[i][1] > Alist[num]:
            Alist[num] = BClist[i][1]
            num += 1
        elif BClist[i][1] <= Alist[num]:
            flag = False
            break

print(sum(Alist))
N,M,K=map(int, input().split())
A=list(map(int, input().split()))
B=list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
a.append(a[i] + A[i])
for i in range(M):
b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
while b[j] > K - a[i]:
    j -= 1
    ans = max(ans, i + j)
print(ans)

### FIXED CODE ###

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

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)
19 123 143

### FIXED CODE ###

inp = list(map(lambda x:int(x), input().split()))

if inp[2] <= inp[0] + inp[1]:
    print("Yes")
else:
    print("No")
s=list(input())
t=list(input())
dp=[[0]*(30) for j in range(30)]
ans=[]
memo=-1
for i in range(len(s)):
    for j in range(len(t)):
        if s[i]==t[j]:
             dp[i+1][j+1] = dp[i][j]+1
             if memo < i:
                 ans.append(t[j])
                 memo = i

        else:
            dp[i+1][j+1] =max(dp[i][j+1],dp[i+1][j])

#print(dp[len(s)][len(t)])
answer=[]
i,j=len(s),len(t)
d=dp[i-1][j-1]
while i!=0 :
    if dp[i-1][j-1]!=dp[i][j]:
        answer.append(s[i-1])
        i-=1
        j-=1
    elif dp[i-1][j]==dp[i][j]:
        i-=1
    elif dp[i][j-1]==dp[i][j]:
        j-=1
print("".join(reversed(answer)))

### FIXED CODE ###

s=list(input())
t=list(input())
dp=[[0]*(3030) for j in range(3030)]
ans=[]
memo=-1
for i in range(len(s)):
    for j in range(len(t)):
        if s[i]==t[j]:
             dp[i+1][j+1] = dp[i][j]+1
             if memo < i:
                 ans.append(t[j])
                 memo = i

        else:
            dp[i+1][j+1] =max(dp[i][j+1],dp[i+1][j])

#print(dp[len(s)][len(t)])
answer=[]
i,j=len(s),len(t)
d=dp[i-1][j-1]
while i>=0 and j>=0:

    if dp[i-1][j]==dp[i][j]:
        i-=1
    elif dp[i][j-1]==dp[i][j]:
        j-=1
    else:
        answer.append(s[i - 1])
        i -= 1
        j -= 1
print("".join(reversed(answer)))
import numpy as np
from scipy.sparse.csgraph import shortest_path
from scipy.sparse import csr_matrix
import math
N=int(input())
tree=[[math.inf]*N for i in range(N)]
for i in range(N-1):
    a,b,c=map(int,input().split(' '))
    tree[a-1][b-1] = c
    tree[b-1][a-1] = c
tree = np.array(tree)
Q,K=map(int,input().split(' '))
csr = csr_matrix(tree)
ans = shortest_path(csr,indices=K-1)
for i in range(Q):
    s,e=map(int,input().split(' '))
    print(int(ans[s-1]+ans[e-1]))

### FIXED CODE ###

from collections import deque

N = int(input())
ABC=[map(int,input().split(' ')) for i in range(N-1)]
Q,K =  map(int,input().split(' '))
query = [map(int,input().split(' ')) for i in range(Q)]
tree = [[] for i in range(N+1)]
for a,b,c in ABC:
    tree[b].append((a,c))
    tree[a].append((b,c))
k_shortest = [0]*(N+1)
stack=deque([K])
while stack:
    k = stack.popleft()
    for v,d in tree[k]:
        if k_shortest[v] == 0:
            k_shortest[v] = k_shortest[k]+d
            stack.append(v)
for i,j in query:
    print(k_shortest[i]+k_shortest[j])
def find(i, ss, step):
        for j in range(step, len(ss)):
            #print(i, j, ss[j])
            if i == ss[j]:
                a = j
                return a, step
        return -1
     
     
    s = input().strip()
    #print(s)
    t = input().strip()
    #print(t)
    ss = s * 100
    #print(ss)
    step = 0
    for i in t:
        a = find(i, ss, step)
        if a == -1:
            print(-1)
            break
        else:
            #print(a)
            step = a[0] + 1
            #print(step)
    if a != -1:
        print(step)

### FIXED CODE ###

a = int(input())
s = input()
if a < 3200:
	print('red')
else:
	print(s)
import math
k=int(input())
list=[]
for a in range(1,k+1):
  for b in range(1,k+1):
    for c in range(1,k+1):
      list.append(math.gcd(gcd(a,b),c))
print(sum(list))

### FIXED CODE ###

import math
k=int(input())
list=[]
for a in range(1,k+1):
  for b in range(1,k+1):
    t=math.gcd(a,b)
    for c in range(1,k+1):
      list.append(math.gcd(t,c))
print(sum(list))
time_list = [int(input()) for i in range(5)]
amari = []

for i in range(5):
    amari.append([time_list[i] // 10, time_list[i] % 10])
    
small = 9
for i in range(5):
    if amari[i][1] > 0 and amari[i][1] < small:
        small = amari[i][1]
        number = i
        
#print (amari)
total_time = 0
for i in range(5):
    if i != number:
        if amari[i][1] == 0:
            total_time += amari[i][0] * 10
        else:
            total_time += amari[i][0] * 10 + 10
    else:
        total_time += time_list[i]
        
print(total_time)
#print (amari)
# print(time_list)

### FIXED CODE ###

# coding: utf-8
# Your code here!
time_list = [int(input()) for i in range(5)]
amari = []

for i in range(5):
    amari.append([time_list[i] // 10, time_list[i] % 10])
    
small = 9
number = 0
for i in range(5):
    if amari[i][1] > 0 and amari[i][1] < small:
        small = amari[i][1]
        number = i
        
total_time = 0
for i in range(5):
    if i != number:
        if amari[i][1] == 0:
            total_time += amari[i][0] * 10
        else:
            total_time += amari[i][0] * 10 + 10
    else:
        total_time += time_list[i]
        
print(total_time)
a,b = raw_input().split(' ')

a = int(a)
b = float(b)

b0,b1 = b.split('.') if '.' in b else [int(b), 0]#

print a*b0 + a*b1/100 


### FIXED CODE ###


a,b = raw_input().split(' ')

a = int(a)


b0,b1 = b.split('.') if '.' in b else [int(b), 0]
b0 = int(b0)
b1 = int(b1)

print a*b0 + a*b1/100
N , R = tuple(input().split(' '))
if N >= 10:
    print(R)
else:
    print(10 - (R / 100))


### FIXED CODE ###

N , R = tuple(list(map(int, input().split(' '))))
if N >= 10:
    print(R)
else:
    print(R + 100 * (10 - N))
a = input().split()
n = int(a[0])
m = int(a[1])

a = input().split(' ')
a = [int(i) for i in a]

summatrix = [[0 for i in range(n)] for i in range(n)]
output = 0

for i in range(n):
	for j in range(i, n):
		if i != 0:
			summatrix[i][j] = (summatrix[i - 1][j - 1]%m + a[i]%m + a[j]%m)%m
		if i == 0 and j == 0:
			summatrix[0][0] = a[0] %m
		else:
			summatrix[i][j] = (summatrix[i][j - 1]%m + a[j]%m)% m
		if summatrix[i][j] == 0:
			output += 1
		
print (output)

### FIXED CODE ###

a = input().split(' ')
m = int(a[0])
n = int(a[1])

if m%n == 0:
	print (0)
else:
	print (1)
# Hello World program in Python
from collections import Counter as cn

d = int (input())
l = []
for k in range(d):
  r = input()
  p = cn(r)
  l.append(p)

oi = l[0]

for g in range(n):
    oi = oi & l[g]
    print(oi)
    
print("".join(sorted(oi.elements())))



### FIXED CODE ###

from collections import Counter
 
n = int(input())
l = []
 
for i in range(n):
    s = input()
    l.append(Counter(s))
    
cnt = l[0]
for i in range(1,n):
        cnt = cnt & l[i]
        
print("".join(sorted(cnt.elements())))
cnt = 0

def s(start, end):
    global cnt
    if(start==len(S)-1):
        return cnt
    numS = int(S[start:end])
    if(numS%2019==0):
        cnt += 1
    if(end==len(S)-1):
        end = start+2
        s(start+1, end)
        return
    s(start, end+1)



if __name__ == '__main__':
    S = input()
    s(0, 1)
    print(cnt)

### FIXED CODE ###

S = list(map(int, list(input())))[::-1]
N = len(S)
CNT = [0]*2019
CNT[0] = 1
num = 0
d = 0
for i in range(N):
    num += S[i]*pow(10, d, 2019)
    num %= 2019
    CNT[num] += 1
    d += 1
ans = 0 
for cnt in CNT:
    ans += (cnt*(cnt - 1)) // 2
print(ans)
line = input().split(" ")

N, A, B = int(line[0]), int(line[1]), int(line[2])

buff = []
for i in range(int(N/(A+B))+1):
    buff.extend([1]*A)
    buff.extend([0]*B)

print(sum(buff[:N]))


### FIXED CODE ###

line = input().split(" ")

N, A, B = int(line[0]), int(line[1]), int(line[2])

S = A + B
if S == 0:
    print(0)
    exit(0)
div, mod = divmod(N, S)

answer = div * A
answer += mod if mod < A else A
print(answer)
s=set(list(input()))
a=set(list('abcdefghijklmnopqrstuvwxyz'))

if s==a:
    print('None')
else:
    b=a-s
    print(b[0])


### FIXED CODE ###

s=set(list(input()))
a=set(list('abcdefghijklmnopqrstuvwxyz'))

if s==a:
    print('None')
else:
    b=sorted(list(a-s))
    print(str(b[0]))
import sys
N = map(int, '4'.split())
N = N[0]
for i in range(int(100/7)+1):
	for j in range(int(100/4)+1):
		a = i*7 + j*4
		if int(N) == a:
			print('Yes')
			sys.exit();

print('No')


### FIXED CODE ###

N = int(input())
res = 'No'
for i in range(int(100/7)+1):
	for j in range(int(100/4)+1):
		a = i*7 + j*4
		if int(N) == a:
			res='Yes'
print(res)
N, M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]

card = A.copy()
for B,C in BC:
    card += [C]*B

card.sort()
print(sum(card[:range(A)]))

### FIXED CODE ###

N, M = map(int,input().split())
A = [[1,int(a)] for a in input().split()]
BC = A + [list(map(int,input().split())) for _ in range(M)]

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

i = 0
ans = 0
for B,C in BC:
    if i + B <= N:
        ans += B*C
        i += B
    else:
        ans += (N - i) * C
        break

print(ans)
input = input().split()
count = 0
for num in input:
  if num == "7":
    count += 1

if count = 1:
  print("YES")
else:
  print("NO")


### FIXED CODE ###

input = input().split()
count = 0
for num in input:
  if num == "7":
    count += 1
 
if count == 1:
  print("YES")
else:
  print("NO")
n, m = map(int, input().split())
an = [0]*m

for i in range(m):
#    s = input()
    an[i] = int( input() )
#an[-1] = n

#an.sort()
disjoint = False
for i in range(len(an)-1):
    if an[i] + 1 == an[i+1]:
        disjoint = True





if disjoint:
    print(0)

else:

    mod = 10**9+7
    tab = [0]*(10**5+1)
    tab[0] = 0
    tab[1] = tab[2]= 1

    for i in range(3, len(tab)):
        tab[i] = tab[i-1]+tab[i-2]
#        if i<100:
#            print(tab[i])

    an.append(n)
    prev = 0
    ans = 1
    for a in an:
        index = a-prev + (1 if a == n else 0)
#        print(a,prev,index,tab[index])
        ans *= tab[index]
        ans %= mod
        prev = a+1

    #ans *= tab[n - prev]
    #ans %= 1000000007

    print(ans)



### FIXED CODE ###

n, m = map(int, input().split())
an = [0]*m

for i in range(m):
#    s = input()
    an[i] = int( input() )
#an[-1] = n

#an.sort()
disjoint = False
for i in range(len(an)-1):
    if an[i] + 1 == an[i+1]:
        disjoint = True


if disjoint:
    print(0)

else:

    mod = 10**9+7
    tab = [0]*(10**5+10)
    tab[0] = 0
    tab[1] = tab[2]= 1

    for i in range(3, len(tab)):
        tab[i] = tab[i-1]+tab[i-2]
#        if i<100:
#            print(tab[i])

    an.append(n)
    prev = 0
    ans = 1
    for a in an:
        index = a-prev + (1 if a == n else 0)
#        print(a,prev,index,tab[index])
        ans *= tab[index]
        ans %= mod
        prev = a+1

    #ans *= tab[n - prev]
    #ans %= 1000000007

    print(ans)
from sys import setrecursionlimit as SRL, stdin

SRL(10 ** 7)
rd = stdin.readline
rrd = lambda: map(int, rd().strip().split())
n, m = rrd()

e = [[] for _i in range(1 << 13)]

p = []
for i in range(m):
    a, b = rrd()
    lst = list(rrd())
    g = 0
    for j in lst:
        g |= 1 << (j - 1)
    p.append((a, g))

for i in range(1 << n):
    for j in p:
        e[i].append((i | j[1], j[0]))
from math import inf

dis = [inf] * (1 << 13)
vis = [0] * (1 << 13)
dis[0] = 0

from heapq import *

q = [(0, 0)]
while len(q):
    ds, now = heappop(q)
    if vis[now]:
        continue
    vis[now] = 1
    for next, cost in e[now]:
        if dis[next] > dis[now] + cost:
            dis[next] = dis[now] + cost
            heappush(q, (dis[next], next))

if dis[(1 << n) - 1] == inf:
    print(-1)
else:
    print(dis[(1 << n) - 1])


### FIXED CODE ###

from sys import setrecursionlimit as SRL, stdin

SRL(10 ** 7)
rd = stdin.readline
rrd = lambda: map(int, rd().strip().split())
n, m = rrd()

e = [[] for _i in range(1 << 13)]

p = []
for i in range(m):
    a, b = rrd()
    lst = list(rrd())
    g = 0
    for j in lst:
        g |= 1 << (j - 1)
    p.append((a, g))

for i in range(1 << n):
    for j in p:
        e[i].append((i | j[1], j[0]))
inf = 10**10

dis = [inf] * (1 << 13)
vis = [0] * (1 << 13)
dis[0] = 0

from heapq import *

q = [(0, 0)]
while len(q):
    ds, now = heappop(q)
    if vis[now]:
        continue
    vis[now] = 1
    for next, cost in e[now]:
        if dis[next] > dis[now] + cost:
            dis[next] = dis[now] + cost
            heappush(q, (dis[next], next))

if dis[(1 << n) - 1] == inf:
    print(-1)
else:
    print(dis[(1 << n) - 1])
S = input()
print("Yes" if all([S.count(e) % 2 == 0 for e in set(S)] else "No"))

### FIXED CODE ###

S = input()
S_elements = set(S)
for e in S_elements:
  if S.count(e) % 2 != 0:
    print("No")
    exit()
print("Yes")
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
x=[]
for i in range(n):
    x.append(abs(a-(t-h[i]*0.006)))
print(x.index(min(x))+1)

### FIXED CODE ###

x,y=map(int,input().split());print(x+y//2)
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

  
  
s=input()

for i in range(s-1)
	c = prime_factorize(s-i-1)
  	a = len(c)
    print(a)
    

### FIXED CODE ###

n = int(input())
ans = 0
for a in range(1, n):
  ans += (n - 1) // a
print(ans)
import math
import sys

for line in sys.stdin.readlines():
#for line in data.split('\n'):
	x,y = [int(s) for s in line.split(' ')]
	G = math.gcd(x,y)
	L = int(x*y/G)
	print(G,L)

### FIXED CODE ###

def pd(n):
    i = 2
    ans = []
    while i ** 2 <= n:
        while n % i == 0:
            n /= i
            ans.append(i)
        i += 1
    if n > 1:
        ans.append(n)
    return ans

def gcd(a, b):
    gcd = 1
    pd_a = pd(a)
    pd_b = pd(b)
    for i in pd_a:
        if i in pd_b:
            pd_b.remove(i)
            gcd *= i
    return int(gcd)

def lcm(a, b):
    lcm = a
    pd_a = pd(a)
    pd_b = pd(b)
    for i in pd_a:
        if i in pd_b:
            pd_b.remove(i)
    for j in pd_b:
        lcm *= j
    return int(lcm)

while True:
    try:
        s = input()
        a,b = [int(i) for i in s.split(' ')]
    except:
        break
    print(gcd(a, b), lcm(a, b))
#AtCoder

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

b = 'b'*A
r = 'r'*B

s = ''
while True:
    if len(s) >= N:
        break
    s += b
    s += r

print(s[:N].count('b'))
    

### FIXED CODE ###

#AtCoder

N, A, B = map(int, input().split())
q, mod = divmod(N,(A+B))
blue = (q*A)
blue += min(mod, A)

print(blue)
X, Y = map(int, input().split())

# 最終状態は(0,1), (1,1)のいずれか
# 最終状態の1手前は勝ち確状態、その1手前は負け確状態
# 1手前に戻すには片方の山からi個石を取り、もう片方の山に2i個加える
# 1手前に戻しつつ山の状態を列挙して、与えられた状態を探索する
# ただし、石の個数の合計が与えられた石の個数の合計を超えたら探索を打ち切る

# 山の状態を再帰的に探索する
def recur_search(x,y,Alice_win_flg):
    if x+y > X+Y or x < 0 or y < 0:
        return
    elif [x, y] in done_memo and Alice_win_flg == 0:
        return
    elif [x,y] == [X,Y] or [x,y] == [Y,X]:
        # 1つでも勝ちパターンがあるなら先手Aliceの勝利
        if Alice_win_flg == 1:
            print("Alice")
            exit()
        else:
            done_memo.append([x, y])
            done_memo.append([y, x])
            return
    else:
        for i in range(1, x+1):
            recur_search(x-i, y+2*i, 1^Alice_win_flg)
            recur_search(y+2*i, x-i, 1^Alice_win_flg)

done_memo = []
recur_search(1,0,0)
recur_search(1,1,0)
print("Brown")

### FIXED CODE ###

X, Y = map(int, input().split())
print("Alice" if abs(X-Y)>=2 else "Brown")
s=input()
for i in range(3):
    if s[i]==s[i+1]:
        ans=1
print("Bad" if ans==1 else "Good")


### FIXED CODE ###

s=input()
for i in range(3):
    if s[i]==s[i+1]:
        ans=1
        break
    else:
        ans=0
print("Bad" if ans==1 else "Good")
def main():
    # not use N
    _ = int(input().strip())

    n_399 = 0
    n_799 = 0
    n_1199 = 0
    n_1599 = 0
    n_1999 = 0
    n_2399 = 0
    n_2799 = 0
    n_3199 = 0
    n_free = 0
    rates = list(map(int, input().strip().split()))
    for r in rates:
        if r <= 399:
            n_399 = 1
        elif r <= 799:
            n_799 = 1
        elif r <= 1199:
            n_1199 = 1
        elif r <= 1599:
            n_1599 = 1
        elif r <= 1999:
            n_1999 = 1
        elif r <= 2399:
            n_2399 = 1
        elif r <= 2799:
            n_2799 = 1
        elif r <= 3199:
            n_3199 = 1
        else:
            n_free += 1

    n_min = n_399 + n_799 + n_1199 + n_1599 + n_1999 + n_2399 + n_2799 + n_3199
    if n_min == 0 and n_free > 0:
        n_min = 1

    if n_min + n_free >= 8:
        n_max = 8
    else:
        n_max = n_min + n_free

    print(n_min, n_max)

if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    r, g, b = list(map(int, input().strip().split()))
    v = r * 100 + g * 10 + b
    if v % 4 == 0:
        print("YES")
    else:
        print("NO")

if __name__ == '__main__':
    main()
# -*- coding: utf-8 -*-

def my_sort(word):
    sorted_word_list = sorted(word)
    sorted_word = ""
    for letter in sorted_word_list:
        sorted_word += letter
    return sorted_word

def func(x):
    if x < 1:
        return x
    return x + func(x-1)

n = int(input())
words = {}
for i in range(n):
    word = my_sort(input())
    if word in words.keys():
        words[word] += 1
    else:
        words[word] = 0

for key in words.keys():
    words[key] = func(words[key])

print(sum(words.values()))


### FIXED CODE ###

# -*- coding: utf-8 -*-

def my_sort(word):
    sorted_word_list = sorted(word)
    sorted_word = ""
    for letter in sorted_word_list:
        sorted_word += letter
    return sorted_word

n = int(input())
words = {}
for i in range(n):
    word = my_sort(input())
    if word in words.keys():
        words[word] += 1
    else:
        words[word] = 1

for key in words.keys():
    words[key] = max(words[key]*(words[key]-1)//2, 0)

print(sum(words.values()))