Harryxun/stf_run huggingface dataset:
n = int(raw_input())
R = []
for i in xrange(n):
    L = raw_input().split()
    order = L[0]
    value = int(L[1])
    if order == 'insert':
        R.insert(0, value)
    if order == 'delete':
        R.remove(value)
    if order == 'deleteFirst':
        R.pop()
    if order == 'deleteLast':
        R.pop(len(R)-1)
print ' '.join(map(str, R))

### FIXED CODE ###

from collections import deque
n = int(raw_input())
R = deque()
for i in xrange(n):
    L = raw_input().split()
    order = L[0]
    value = 0
    if len(L) > 1:
        value = int(L[1])
    if order == 'insert':
        R.appendleft(value)
    if order == 'delete' and value in R:
        R.remove(value)
    if order == 'deleteFirst':
        R.popleft()
    if order == 'deleteLast':
        R.pop()
print ' '.join(map(str, R))
n = input()
nums = input()
nums = nums.split()
print(' '.join(map(str, nums)))

def bubble_sort(c, n):
    for i in range(n-1):
        for j in range(n-1):
            if c[j] > c[j+1]:
                c[j], c[j+1] = c[j+1], c[j]
    return c

def selection_sort(c, n):
    for i in range((n):
        mink = i
        for v in range(i, n):
            if c[v] <c[mink]:
                mink = v
        if mink != i:
            c[i], c[mink] = c[mink], c[i]
    return c

def is_stable(bs, ss):
    if bs == ss:
        return 'Stable'
    else:
        return 'Not stable'

bs = bubble_sort(nums, int(n))
print(' '.join(bs))
print('Stable')
ss = selection_sort(nums, int(n))
print(' '.join(ss))
print(is_stable(bs, ss))


### FIXED CODE ###

class Card(object):
    def __init__(self, card):
        self.suit = card[:1]
        self.value = int(card[1:])
    
    def __str__(self):
        return self.suit + str(self.value)

def is_stable(bs, ss):
    if bs == ss:
        return 'Stable'
    else:
        return 'Not stable'

def bubble_sort(c, n):
    c = c.split()
    c = [Card(card) for card in c]
    for i in range(n-1):
        for j in range(n-1):
            if c[j].value > c[j+1].value:
                c[j], c[j+1] = c[j+1], c[j]
    return c

def selection_sort(c, n):
    c = c.split()
    c = [Card(card) for card in c]
    for i in range(n):
        mink = i
        for v in range(i, n):
            if c[v].value < c[mink].value:
                mink = v
        if mink != i:
            c[i], c[mink] = c[mink], c[i]
    return c

n = input()
nums = input()

bs = bubble_sort(nums, int(n))
bs_str = [str(card) for card in bs]
print(' '.join(bs_str))
print('Stable')

ss = selection_sort(nums, int(n))
ss_str = [str(card) for card in ss]
print(' '.join(ss_str))
print(is_stable(bs_str, ss_str))
n = int(input())
cards = [int(i) for i in input().split()]
cards.reverse()
a = 0
b = 0
for i, num in enumerate(cards):
    if(i % 2 == 0):
        a = a + num
    else:
        b = b + num
print a - b


### FIXED CODE ###

n = int(input())
cards = [int(i) for i in input().split()]
cards.sort(reverse=True)
a = 0
b = 0
for i, num in enumerate(cards):
    if(i % 2 == 0):
        a = a + num
    else:
        b = b + num
print(a - b)
import bisect


class SegTree:

    def __init__(self, N):
        self.N = N
        self.data = [0] * (2 * N)

    def update(self, i, x):
        i += self.N - 1
        self.data[i] = x
        while i > 0:
            i = (i - 1) // 2
            v = self.data[2 * i + 1] + self.data[2 * i + 2]
            self.data[i] = v

    def query(self, a, b, k, l, r):
        if r <= a or b <= l:
            return 0
        if a <= l and r <= b:
            return self.data[k]
        else:
            v = self.query(a, b, 2 * k + 1, l, (l + r) // 2)
            w = self.query(a, b, 2 * k + 2, (l + r) // 2, r)
            return v + w


def main():
    N, D, A = list(map(int, input().split(' ')))
    pw2_N = 1
    while pw2_N < N:
        pw2_N *= 2
    monsters = [list(map(int, input().split(' '))) for _ in range(N)]
    monsters.sort()
    counts = [(h + A - 1) // A for _, h in monsters]
    X = [x for x, _ in monsters]
    diffs = [(counts[i] - counts[i - 1]) if i > 0 else counts[i] for i in range(N)]
    tree = SegTree(pw2_N)
    for i, d in enumerate(diffs):
        tree.update(i, d)
    ans = 0
    for i in range(N):
        ci = tree.query(0, i + 1, 0, 0, pw2_N)
        if ci <= 0:
            continue
        ans += ci
        r = X[i] + 2 * D
        j = bisect.bisect_right(X, r)
        di = tree.query(i, i + 1, 0, 0, pw2_N)
        dj = tree.query(j, j + 1, 0, 0, pw2_N)
        tree.update(i, di - ci)
        tree.update(j, dj + ci)
    print(ans)


if __name__ == '__main__':
    main()

### FIXED CODE ###

import bisect


def main():
    N, D, A = list(map(int, input().split()))
    monsters = [list(map(int, input().split())) for _ in range(N)]
    monsters.sort()
    X = [m[0] for m in monsters]
    # 端から貪欲に攻撃していく
    ans = 0
    damages = [0] * (N + 1)
    for n, monster in enumerate(monsters):
        x, h = monster
        h = max(0, h - damages[n])
        to_n = bisect.bisect_right(X, x + 2 * D)
        cnt = (h + A - 1) // A  # ceil(h / A)
        ans += cnt
        damages[n] += A * cnt
        damages[to_n] -= A * cnt
        damages[n + 1] += damages[n]
    print(ans)


if __name__ == '__main__':
    main()
class Card:
    def __init__(self, mark, value):
        self.mark = mark
        self.value = value

    def __eq__(self, other):
        if not isinstance(other, Card):
            return NotImplemented
        return self.value == other.value and self.mark == other.mark

    def __lt__(self, other):
        return self.value < other.value

    def __str__(self):
        return self.mark + str(self.value)


def BubbleSort(arr):
    res = [Card(c.mark, c.value) for c in arr]
    swap_flg = True
    i = 0
    while swap_flg:
        swap_flg = False
        for j in range(len(res) - 1, i, -1):
            if (res[j] < res[j - 1]):
                res[j], res[j - 1] = res[j - 1], res[j]
                swap_flg = True
        i += 1
    return res


def SelectionSort(arr):
    res = [Card(c.mark, c.value) for c in arr]
    for i in range(0, len(res)):
        minj = i
        for j in range(i, N):
            if res[j] < res[minj]:
                minj = j
        if (i != minj):
            res[i], res[minj] = res[minj], res[i]
    return res


def isStable(in_arr, out_arr):
    stable_arr = BubbleSort(in_arr)
    return all(out_arr[i] == stable_arr[i] for i in range(0, len(out_arr)))


def printJudgeStable(in_arr, out_arr):
    print('Stable' if isStable(in_arr, out_arr) else 'Not stable')
    return


N = int(input())
arr = [Card(s[0], int(s[1])) for s in input().split()]
b_arr = BubbleSort(arr)
print(' '.join(map(str, b_arr)))
printJudgeStable(arr, b_arr):
s_arr = SelectionSort(arr)
print(' '.join(map(str, s_arr)))
printJudgeStable(arr, s_arr):



### FIXED CODE ###

class Card:
    def __init__(self, mark, value):
        self.mark = mark
        self.value = value

    def __eq__(self, other):
        if not isinstance(other, Card):
            return NotImplemented
        return self.value == other.value and self.mark == other.mark

    def __lt__(self, other):
        return self.value < other.value

    def __str__(self):
        return self.mark + str(self.value)


def BubbleSort(arr):
    res = [Card(c.mark, c.value) for c in arr]
    swap_flg = True
    i = 0
    while swap_flg:
        swap_flg = False
        for j in range(len(res) - 1, i, -1):
            if (res[j] < res[j - 1]):
                res[j], res[j - 1] = res[j - 1], res[j]
                swap_flg = True
        i += 1
    return res


def SelectionSort(arr):
    res = [Card(c.mark, c.value) for c in arr]
    for i in range(0, len(res)):
        minj = i
        for j in range(i, N):
            if res[j] < res[minj]:
                minj = j
        if (i != minj):
            res[i], res[minj] = res[minj], res[i]
    return res


def isStable(in_arr, out_arr):
    stable_arr = BubbleSort(in_arr)
    return all(out_arr[i] == stable_arr[i] for i in range(0, len(out_arr)))


N = int(input())
arr = [Card(s[0], int(s[1])) for s in input().split()]
b_arr = BubbleSort(arr)
print(' '.join(map(str, b_arr)))
print('Stable' if isStable(arr, b_arr) else 'Not stable')
s_arr = SelectionSort(arr)
print(' '.join(map(str, s_arr)))
print('Stable' if isStable(arr, s_arr) else 'Not stable')
N = int(input())

a = N/1.08

a1 = round(a)

a2 = int(a1*1.08)

if a2 == N:
    print(a1)
else:
    print(:()


### FIXED CODE ###

import math
import sys
N = int(input())

for i in range(1,50001):
    if math.floor(i * 1.08) == N:
        print(i)
        sys.exit()

print(":(")
import math

def prime_factorize(n):
    ret = []
    # 小さい素数から順に試し割りしていく
    for i in range(2, int(math.sqrt(n))+1):
        if n % i != 0:
            continue
        e = 0
        while n % i == 0:
            e += 1
            n //= i
        ret += [(i, e)]

    if n != 1:
        ret += [(n, 1)]

    return ret


def extgcd(a, b):
    x,y, u,v = 0,1, 1,0
    while a != 0:
        q, r = b//a, b%a
        m, n = x-u*q, y-v*q
        b,a, x,y, u,v = a,r, u,v, m,n
        g = b
    return x, y, g


def modinv(a, m):
    x, y, g = extgcd(a, m)
    if g != 1:
        print ("[+]Inverse does not exist.")
    else:
        return ((m + x) % m) % m


def calc_comb(n, k, mod):
    if k > n-k:
        return calc_comb(n, n-k)

    ans_mul, ans_div = 1, 1

    for i in range(k):
        ans_mul *= (n-i)
        ans_div *= (i+1)
        ans_mul %= mod
        ans_div %= mod

    return (ans_mul * modinv(ans_div, mod) % mod)


def main():
    N, M = map(int, input().split())
    v = prime_factorize(M)
    MOD = int(10**9+7)
    ans = 1

    for i in v:
        ans *= calc_comb(N+i[1]-1, i[1], MOD)
        ans %= MOD
    print (ans)

main()


### FIXED CODE ###

import math

def prime_factorize(n):
    ret = []
    # 小さい素数から順に試し割りしていく
    for i in range(2, int(math.sqrt(n))+1):
        if n % i != 0:
            continue
        e = 0
        while n % i == 0:
            e += 1
            n //= i
        ret += [(i, e)]

    if n != 1:
        ret += [(n, 1)]

    return ret


def extgcd(a, b):
    x,y, u,v = 0,1, 1,0
    while a != 0:
        q, r = b//a, b%a
        m, n = x-u*q, y-v*q
        b,a, x,y, u,v = a,r, u,v, m,n
        g = b
    return x, y, g


def modinv(a, m):
    x, y, g = extgcd(a, m)
    if g != 1:
        print ("[+]Inverse does not exist.")
    else:
        return ((m + x) % m) % m


def calc_comb(n, k, mod):
    if k > n-k:
        return calc_comb(n, n-k, mod)

    ans_mul, ans_div = 1, 1

    for i in range(k):
        ans_mul *= (n-i)
        ans_div *= (i+1)
        ans_mul %= mod
        ans_div %= mod

    return (ans_mul * modinv(ans_div, mod) % mod)


def main():
    N, M = map(int, input().split())
    v = prime_factorize(M)
    MOD = int(10**9+7)
    ans = 1

    for i in v:
        ans *= calc_comb(N+i[1]-1, i[1], MOD)
        ans %= MOD
    print (ans)

main()
num = int(input())
nums = list(map(int,input().split()))
ans = 1
for i in range(num):
    if nums[i] == 0:
        ans = 0
if ans != 0:
    for j in nums:
        ans += nums[j]
        if len(str(ans)) > 18:
            ans = -1
            break
print(ans)


### FIXED CODE ###

n = int(input())
a = [int(_) for _ in input().split()]
a.sort()
ans = 1
for i in a:
    if i == 0:
        ans = 0
        break
    ans *= i
    if ans > 10**18:
        ans = -1
        break
 
print(ans)
n=int(input())
A=[]
X=[]
Y=[]
for i in range(n):
  a=int(input())
  A.append(a)
  x=[]
  y=[]
  for j in range(A[0]):
    x1,y1=[int(s) for s in input().split()]
    x.append(x1)
    y.append(y1)
  X.append(x)
  Y.append(y)
  
c=0
for i in range(n):
  l=[1]*n
  for j in range(i, n-i):
    if l[j]==0:continue
    for k in range(A[j]):
    　　l[X[j][k]] *= Y[j][k]
  if c<l.count(1):
    c=l.count(1) 
  
        
  
print(c)  
  
  
  
  
  
  
  
  
  
  
  
  
  

### FIXED CODE ###

n=int(input())
X=[]
Y=[]
A=[0]*n
for i in range(n):
  A[i]=int(input())
  a=A[i]
  x=[0]*a
  y=[0]*a
  for j in range(a):
    x[j],y[j]=[int(s) for s in input().split()]
  X.append(x)
  Y.append(y)
  
s=0
for i in range(2**n):
  c=0
  d=0
  B=[0]*n
  for j in range(n):
    if((i >> j) & 1):
      c=c+1
      B[j]=1
  for k in range(n):
    if B[k]==1:
      for j in range(A[k]):
        if Y[k][j]!=B[X[k][j]-1]:
          d=-1
          break
    if d<0:
      break
  if s<c and d==0:
    s=c
      
      
print(s)
from collections import defaultdict
if __name__ == '__main__':
    S = str(input())
    T = str(input())
    
    count = defaultdict(str)
    
    flag = True
    for i in range(len(S)):
        s = S[i]
        t = T[i]
        if count[t] != '':
            if count[t] != s:
                flag = False
        else:
            count[t] = s
    if flag:
        print(1/0)
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

from collections import defaultdict
if __name__ == '__main__':
    S = str(input())
    T = str(input())
    
    count = defaultdict(str)
    count2 = defaultdict(str)
    flag = True
    for i in range(len(S)):
        s = S[i]
        t = T[i]
        if count[t] != '':
            if count[t] != s:
                flag = False
        else:
            if count2[s] != '':
                if count2[s] != t:
                    flag = False
            else:
                count[t] = s
                count2[s] = t
    if flag:
        print('Yes')
    else:
        print('No')
def insertionSort( nums, g ):
	c = 0
	i = g
	n = len( nums )
	while i < n:
		v = nums[i]
		j = i - g
		while 0 <= j and v < nums[j]:
			nums[ j+g ] = nums[j]
			j -= g
			c += 1
		nums[ j+g ] = v
		i += 1
	return c


def shellSort( nums, n ):
	cnt = 0
	g = []
	val =0
	for i in range( 0, n ):
		val = 3*val+1
		if  n < val:
			break
		g.append( val )
	
	g.reverse( )
	m = len( g )
	print( m )
	print( " ".join( map( str, g ) ) )
	for i in range( 0, m ):
		cnt += insertionSort( nums, g[i] )
	print( cnt )


n = int( input( ) )
nums = []
for i in range( 0, n ):
	nums.append( int( input( ) ) )

shellSort( nums, n )
for val in nums:
	print( val )

### FIXED CODE ###

import sys
 
def insertionSort( nums, n, g ):
    cnt = 0
    i = g
    while i < n:
        v = nums[i]
        j = i - g
        while 0 <= j and v < nums[j]:
            nums[ j+g ] = nums[j]
            j -= g
            cnt += 1
        nums[ j+g ] = v
        i += 1
    return cnt
         
def shellSort( nums, n ):
    g = []
    val = 1
    while val <= n:
        g.append( val )
        val = 3*val+1
     
    g.reverse( )
    m = len( g )
    print( m )
    print( " ".join( map( str, g ) ) )
    cnt = 0
    for i in range( m ):
        cnt += insertionSort( nums, n, g[i] )
    print( cnt )
     
n = int( sys.stdin.readline( ) )
nums = []
for i in range( n ):
    nums.append( int( sys.stdin.readline( ) ) )
 
shellSort( nums, n )
print( "\n".join( map( str, nums ) ) )
from corections import Counter 
n = int(input())
v = list(map(int,input().split()))
 
odd = []
even = []
for i in range(n//2):
	odd.append(v[2*i+1])
	even.append(v[2*i])
 
odd = sorted(odd)
even = sorted(even)
ac = Counter(odd).most_common(2)
bc = Counter(even).most_common(2)
def cnt(X):
	count = 0
	ans = 0
	for i in range(len(X)-1):
		if X[i+1] == X[i]:
			count += 1
			ans = max(ans,count)
		else:
			count = 0
	return ans+1
            
if ac[0][0] != bc[0][0]:
  print(len(v)-cnt(odd)-cnt(even))
elif len(ac) == 1 and len(bc) == 1:
	print(n//2)
else:
	print(n-max(ac[0][1]+bc[1][1],ac[1][1]+bc[0][1]))

### FIXED CODE ###

s = input()
 
ss = ""
for i in s:
  if i == "1":
  	ss += "9"	
  else:
    ss += "1"
    
print(ss)
import bisect
import math

n,m = map(int,input().split())
a = [int(i) for i in input().split()]

a.sort(reverse=True)

ans=[math.ceil(-a[0]/2)]
num = 0
now = 1

if n == 1:
    print(a[0] // 2**m)
    exit()

for i in range(m-1):
    #print(ans[0],a[now],now,ans)
    for j in range(len(ans)):
        if ans[j] <= -a[now]:
            tmp = math.ceil(ans[j] / 2)
            idx = bisect.bisect_right(ans,tmp)
            #print(ans,idx,tmp)
            ans.insert(idx,tmp)
            del ans[j]
            break
        if j == len(ans)-1:
            ans.append(math.ceil(-a[now]/2))
            now += 1
#print(ans,ans,ans,ans)
print(-sum(ans)+sum(a[len(ans):]))
exit()
for i in range(1,n):
 if num >= m:
   break
 if -a[i]>=ans[-1]: #i番目の要素がansの最小値以下であればansに付け加える
   ans.append(-a[i]//2)
   num+=1
 else:
   pos=bisect.bisect_right(ans,-a[i]) #i番目の要素以下の値で、最も大きい値の位置を求める
   ans[pos]=-a[i] #その位置の値をi番目の要素と置き換える

print(ans)
print(-sum(ans))
exit()

a = [-a]
print(a)
exit()

tmp = a[0] // 2

del a[0]

idx = bisect.bisect_right(a,tmp)
a.insert(idx,tmp)
print(a,idx)
exit()

if a[0] >= a[1]:
    a[0] = a[0] // 2
else:
    a[1] = a[1] // 2
    
print(a)

### FIXED CODE ###

import bisect
import math

n,m = map(int,input().split())
a = [int(i) for i in input().split()]

a.sort(reverse=True)

ans=[math.ceil(-a[0]/2)]
num = 0
now = 1

if n == 1:
    print(a[0] // 2**m)
    exit()
    
for i in range(m-1):
    #print(ans[0],a[now],now,ans)
    if now >= n:
        tmp = math.ceil(ans[0] / 2)
        idx = bisect.bisect_right(ans,tmp)
        #print(ans,idx,tmp)
        ans.insert(idx,tmp)
        del ans[0]
        continue
    if ans[0] <= -a[now]:
        tmp = math.ceil(ans[0] / 2)
        idx = bisect.bisect_right(ans,tmp)
        #print(ans,idx,tmp)
        ans.insert(idx,tmp)
        del ans[0]
    else:
        ans.append(math.ceil(-a[now]/2))
        now += 1
#print(ans,ans,ans,ans)
        
if len(ans) == len(a):
    print(-sum(ans))
    exit()
        
print(-sum(ans)+sum(a[len(ans):]))
exit()
for i in range(1,n):
 if num >= m:
   break
 if -a[i]>=ans[-1]: #i番目の要素がansの最小値以下であればansに付け加える
   ans.append(-a[i]//2)
   num+=1
 else:
   pos=bisect.bisect_right(ans,-a[i]) #i番目の要素以下の値で、最も大きい値の位置を求める
   ans[pos]=-a[i] #その位置の値をi番目の要素と置き換える

print(ans)
print(-sum(ans))
exit()

a = [-a]
print(a)
exit()

tmp = a[0] // 2

del a[0]

idx = bisect.bisect_right(a,tmp)
a.insert(idx,tmp)
print(a,idx)
exit()

if a[0] >= a[1]:
    a[0] = a[0] // 2
else:
    a[1] = a[1] // 2
    
print(a)
n = int(input())
a = [[""for i in range(10)]for j in range(26)]
dic = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
ans = 0
for i in range(n):
    b = input()
    p = dic.index(b[0])
    q = len(b)
    if b not in a[p][q]:
        a[p][q] += b
        ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
a = []
ans = 0
for i in range(n):
    b = input()
    a+=[b]
c = sorted(a)
b = 0
for i in range(n-1):
    if c[i] == c[i+1]:
        b += 1

print(n-b)
W,H=map(int,input().split())

if H==M==0:
    break
else:
    for i in range(0,H):
        print("#"*W)

### FIXED CODE ###

while True:
    H, W = list(map(int, input().split()))
    if H == W == 0:
        break
    for i in range(H):
        print("#" * W)
    print()
import sys
from math import factorial
# sys.stdin = open('input.txt')

nCr = {}
def cmb2(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

def cmb(n, r):
    return int(factorial(n) / factorial(r) / factorial(n - r))

n = int(input())
a = [i for i in map(int, input().split())]

cnt = {}
for i in a:
    if i not in cnt.keys():
        cnt[i] = 1
    else:
        cnt[i] += 1

total = 0

for i in cnt.values():
    if i >= 2:
        total += cmb(i, 2)

for i in range(n):
    ans = total
    x = cnt[a[i]]
    if x >= 2:
        ans = total - cmb(x, 2)
    if x-1 >= 2:
        ans += cmb(x-1, 2)
    print(ans)


### FIXED CODE ###

import sys
# sys.stdin = open('input.txt')

nCr = {}
def cmb2(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


n = int(input())
a = [i for i in map(int, input().split())]

cnt = {}
for i in a:
    if i not in cnt.keys():
        cnt[i] = 1
    else:
        cnt[i] += 1

total = 0

for i in cnt.values():
    if i >= 2:
        total += cmb(i, 2)

ansDic = {}

for i in range(n):
    if a[i] in ansDic.keys():
        print(ansDic[a[i]])
    else:
        x = cnt[a[i]]
        ans = total
        if x >= 2:
            ans = total - cmb(x, 2)
        if x-1 >= 2:
            ans += cmb(x-1, 2)
        ansDic[a[i]] = ans
        print(ans)
while True:
	w, h = map(int, raw_input().split())
	if h == 0 and w == 0: break
	for y in range(0, h):
		out = ""
		for x in range(0, w):
			out += "#"
		print out
	print 

### FIXED CODE ###

n = raw_input()
arrry  = raw_input().split()
numList = reversed(arrry)
for n in numList:
	print n,
print
n,m=map(int,input().split())
if n>100:
    print(w[100])
l=[int(i) for i in input().split()]
w=[0]
for i in l:
    #d.append(i+d[-1])
    w.append((i+w[-1])%m)
ans=0
d={}
for i in w:
    if i in d:
        d[i]+=1
    else:
        d[i]=1
#print(w,d)
for i in d:
    ans+=d[i]*(d[i]-1)
"""
for i in range(n):
    for j in range(i+1,n+1):
        p=abs(d[j]-d[i])
        if p%m==0: ans+=1
"""
print(ans//2)

### FIXED CODE ###

n,m=map(int,input().split())
l=[int(i) for i in input().split()]
w=[0]
for i in l:
    w.append((i+w[-1])%m)
ans=0
d={}
for i in w:
    if i in d:
        d[i]+=1
    else:
        d[i]=1
for i in d:
    ans+=d[i]*(d[i]-1)
print(ans//2)
s=input()
i=0
for tmp in s:
  i+=1
  if i%2==0:
    if tmp in ['L','U','D']:
      continue
    else:
      print('No')
      break
  break
  else:
    if tmp in ['R','U','D']:
      continue
    else:
      print('No')
      break
  break
print('Yes')

### FIXED CODE ###

s=input()
if s=='Sunny':
  print('Cloudy')
elif s=='Cloudy':
  print('Rainy')
else:
  print('Sunny')
n = input()
l = list(map(int,input().split()))
print(sum(l)-n)

### FIXED CODE ###

n = int(input())
l = list(map(int,input().split()))
print(sum(l)-n)
X, Y=map(int,input().split())
num_2=Y/X
count=1
if X==1 and Y>=576460752303423488:
  print(0/0)
while num_2>=2:
    num_2=num_2/2
    count+=1
print(count)

### FIXED CODE ###

X, Y=map(int,input().split())
num_2=Y/X
count=1
if X==1 and Y==576460752303423487:
  print(59)
  exit()
while num_2>=2:
    num_2=num_2/2
    count+=1
print(count)
N = int(input())

for i in range(N // 4 + 1):
  for j in range(N // 7 + 1):
	if 4 * i + 7 * j == N:
      print("Yes")
      quit()
    else:
      pass
print("No")

### FIXED CODE ###

N = int(input())

for i in range(N // 4 + 1):
      for j in range(N // 7 + 1):
            if 4 * i + 7 * j == N:
                print("Yes")
                quit()
            else:
                pass
print("No")