Harryxun/stf_run huggingface dataset:
from collections import defaultdict

def readInput():
	return [int(i) for i in input().split(" ")]

(R, C) = readInput()
N = int(input())
rowIdx = set() 
grid = defaultdict(lambda:None)
rowGrid = defaultdict(set)
for i in range(N):
	(r, c, a) = readInput()
	r -= 1
	c -= 1
	rowGrid[r].add(c)
	grid[(r, c)] = a 
	rowIdx.add(r)

pairIdx = rowIdx.copy	
for i in rowIdx:
	pairIdx.remove(i)
	for j in pairIdx:
		tempRow = rowGrid[i]
		tempPair = rowGrid[j]
		mark = 1
		for k in tempRow:
			if (grid[(j, k)] != None):
				diff = grid[(i, k)] - grid[(j, k)]
				mark = 0 
		if (mark is 1):
			continue
		for m in tempRow:
			anchor = grid[(i, m)]
			anchorP = grid[(j, m)]
			if (anchorP is None and anchor < diff):
				print('No')
				exit()
			elif (anchorP is not None and anchor - anchorP != diff):
				print('No')
				exit()
		for n in tempPair:
			anchor = grid[(j, n)]
			anchorP = grid[(i, n)]
			if (anchorP is None and anchor < -diff):
				print('No')
				exit()
print('Yes')

### FIXED CODE ###

from collections import defaultdict
import sys
sys.setrecursionlimit(10**6)

def ReadInput():
	return [int(i) for i in input().split(" ")]

(R, C) = ReadInput()
N = int(input())
VectorSet = set() 
Grid = defaultdict(list)
for i in range(N):
	(r, c, a) = ReadInput()
	Grid[("R", r)].append((("C", c), a))
	Grid[("C", c)].append((("R", r), a))
	VectorSet.add(("R", r))
	VectorSet.add(("C", c))

def iteration(vector):
	VectorSet.discard(vector)
	for (v, a) in Grid[vector]:
		temp = a - VectorCover[vector]
		if (v in VectorCover):
			if(temp != VectorCover[v]):
				print("No")
				exit()
		else:
			VectorCover[v] = temp
			iteration(v) 

while(len(VectorSet) != 0):
	vector = VectorSet.pop()
	VectorCover = dict() 
	VectorCover[vector] = 0
	iteration(vector)
	minR = min(a for (p, a) in VectorCover.items() if (p[0] == "R"))
	minC = min(a for (p, a) in VectorCover.items() if (p[0] == "C"))
	if (minR + minC < 0):
		print("No")
		exit()

print("Yes")
import sys
def input():
    return sys.stdin.readline()[:-1]


N, M = [int(i) for i in input().split()]
A = sorted([int(i) for i in input().split()])
for i in range(M):
    A[-1] = A[-1]//2
    A = sorted(A)
print(sum(A))

### FIXED CODE ###

s = input()
if s == "Sunny":
    print("Cloudy")
elif s == "Cloudy":
    print("Rainy")
else:
    print("Sunny")
N,k=map(int,input().split())
R=N-k
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
    
for i in range(1,k+1):
  a= cmb(k-1,i-1)
  b= cmb(R+1,i)
  print(a*b)

### FIXED CODE ###

s=list(input())
a='No'
if s[1]==s[2] and s[3]==s[0] and s[1]!=s[3] and s[1]!=s[0]:
  a='Yes'
elif s[1]==s[3] and s[2]==s[0] and s[1]!=s[2] and s[1]!=s[0]:
  a='Yes'
elif s[1]==s[0] and s[2]==s[3] and s[1]!=s[2] and s[1]!=s[3]:
  a='Yes'
print(a)
import math

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

x = ((360/12)*h+(360/12)*(m/60))
y = 360*(m/60)
z = math.radians(abs(x-y))
ans = ((a**2)+(b**2))-2*a*b*cos(z)

print(ans)

### FIXED CODE ###

import math
a, b, h, m = map(int, input().split())
     
mr = 6*m
hr = 360*(h/12+m/720)
r = math.radians(abs(mr-hr))
ans = math.sqrt((a**2)+(b**2)-2*a*b*math.cos(r))
print(ans)
N = int(input())
S = input()

alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

print(S.translate(str.maketrans(alphabet, alphabet[N:] + alphabet[:N])))

### FIXED CODE ###

n = input()
if n == 'SUN':
  print('7')
elif n == 'MON':
  print('6')
elif n == 'TUE':
  print('5')
elif n == 'WED':
  print('4')
elif n == 'THU':
  print('3')
elif n == 'FRI':
  print('2')
elif n == 'SAT':
  print('1')
import math
X, Y = map(int, input().split())
mod = 10**9 + 7


def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)


if X == Y // 2 or Y == X//2:
    print(1)

X, Y = max(X, Y), min(X, Y)

diff = X - Y
x = X - 2*(X-Y)
y = Y - (X-Y)

if x % 3 != 0:
    print(0)
else:
    k = x // 3


ans = math.factorial(2*k + X-Y) % mod * \
    modinv(math.factorial(k)) * modinv(math.factorial(k+X-Y))

print(ans % mod)


### FIXED CODE ###

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


def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


mod = 10**9+7
N = 10**6
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

if X == Y // 2 or Y == X//2:
    print(1)
    exit(0)

X, Y = max(X, Y), min(X, Y)

diff = X - Y
x = X - 2*diff

if x % 3 != 0:
    print(0)
    exit(0)
else:
    k = x // 3
    for i in range(2, N + 1):
        g1.append((g1[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        g2.append((g2[-1] * inverse[-1]) % mod)

    ans = cmb(2*k+diff, k, mod)
    print(ans)
import sys
input = sys.stdin.readline

def li():
    return [int(x) for x in input().split()]


N, K = li()
P = [0] + li()
C = [0] + li()
max_scores = [-10**12] * (N+10)
for init_i in range(1, N+1):
    i = init_i
    scores = [-10**9] * (10**5)
    scores[0] = 0
    for l in range(1, K+1):
        i = P[i]
        scores[l] = scores[l-1] + C[i]
    scores[0] = -10**12
    max_scores[i] = max(scores)
print(max(max_scores))

### FIXED CODE ###

def li():
    return [int(x) for x in input().split()]

N, K = li()
P = [0] + li()
C = [0] + li()

def get_cycle(start_i):
    cycle = []
    i = start_i
    while True:
        i = P[i]
        if i == start_i:
            break
        cycle.append(i)
    cycle.append(start_i)
    return cycle

def get_cycle_scores(cycle):
    score = 0
    scores = [score]
    for i in cycle:
        score += C[i]
        scores.append(score)
    return scores

max_scores = []
for start_i in range(1,N+1):
    cycle = get_cycle(start_i)
    scores = get_cycle_scores(cycle)
    cycle_len = len(cycle)
    score_per_cycle = scores[cycle_len]
    # 1cycle以下の場合は全て調べればよし
    if K <= len(cycle):
        max_score = max(scores[move] for move in range(1, K+1))
        max_scores.append(max_score)
        continue
    # 1サイクルごとのスコアがマイナスならサイクルを回らないのがハイスコア
    if score_per_cycle <= 0:
        max_score = max(scores[move] for move in range(1, cycle_len+1))
        max_scores.append(max_score)
        continue
    # 1サイクルごとのスコアがプラスなら限界までサイクルを回るのがハイスコア
    # ラスト1cycleのスコアを調べる
    scores_last_cycle = []
    for move in range(K-cycle_len+1, K+1):
        # 何周したか
        loop_cnt = move // cycle_len
        # あまり
        rest_move = move % cycle_len
        # スコア = 1周ごとのスコア * 何周したか + あまり
        score = loop_cnt * score_per_cycle + scores[rest_move]
        scores_last_cycle.append(score)

    max_scores.append(max(scores_last_cycle))

print(max(max_scores))
x, y = input().split(" ")
a = int(x)
b = int(y)

ans = {1, 2, 3}
not_ans = {a, b}

z = ans.difference(not_ans)

print(z)

### FIXED CODE ###

a = int(input())
b = int(input())

ans = {1, 2, 3}
not_ans = {a, b}

for data in ans.difference(not_ans):
    print(data)
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
cnt1 = 0
cnt2 = 0
while i <= N:
  if i in A:
    cnt1 += 1
  i += 1
while i >= 0:
  if i in A:
    cnt2 += 1
  i -= 1
print(min(cnt1, cnt2))

### FIXED CODE ###

N, M, X = map(int, input().split())
A = list(map(int, input().split()))
cnt1 = 0
cnt2 = 0
i = X
j = X
while i <= N:
  if i in A:
    cnt1 += 1
  i += 1
while j >= 0:
  if j in A:
    cnt2 += 1
  j -= 1
print(min(cnt1, cnt2))
import math
b,a = map(int,input().split())
print(math.ceil((b-1)/(a-1)))

### FIXED CODE ###

import math
A, B = map(int, input().split())
print(1+math.ceil((B-A)/(A-1)))
n , k = map(int, input().split())
a = list(map(int, input().split()))
neg = []
pos = []
mod = 10**9+7
for i in range(n):
    if a[i] >= 0:
        pos.append(a[i])
    else:
        neg.append(a[i])
neg.sort()
pos.sort(reverse = True)
min_num = -1
good_num = -1
if k % 2 == 1 and len(pos) == 0:
    ans = 1
    neg.sort(reverse = True)
    for i in range(k):
        ans *= neg[i]
        ans %= mod
    print(ans)
else:
    #最大化するとき
    for i in range(0,k+1,2):
        #i個だけnegから取る。
        if i > len(neg) or k - i > len(pos):
            continue
        m = 0
        if i >= 0:
            m = abs(neg[i-1])
        if k-i-1 >= 0:
            m = min(m, pos[k-i-1])
        if m > min_num:
            min_num = m
            good_num = i
    ans = 1
    for i in range(good_num):
        ans *= neg[i]
        ans %= mod
    for i in range(k - good_num):
        ans *= pos[i]
        ans %= mod
    print(ans % mod)

### FIXED CODE ###

n , k = map(int, input().split())
a = list(map(int, input().split()))
neg = []
pos = []
mod = 10**9+7
for i in range(n):
    if a[i] >= 0:
        pos.append(a[i])
    else:
        neg.append(a[i])
neg.sort()
pos.sort(reverse = True)
if (len(pos) == 0 and k % 2 == 1) or n == k:
    ans = 1
    a.sort(reverse = True)
    for i in range(k):
        ans *= a[i]
        ans %= mod
    print(ans % mod)
else:
    #最大化するとき
    from collections import deque
    ans = 1
    neg_new = []
    for i in range(0, len(neg)//2):
        neg_new.append(neg[2*i] * neg[2*i+1])
    neg_new = deque(sorted(neg_new, reverse = True))
    pos = deque(pos)
    if k % 2 == 1:
        k -= 1
        ans = pos.popleft()
    else:
        ans = 1
    while k > 0:
        if len(pos) >= 2 and len(neg_new) >= 1:
            if pos[0] * pos[1] > neg_new[0]:
                ans *= pos.popleft() * pos.popleft()
            else:
                ans *= neg_new.popleft()
        elif len(pos) >= 2:
            ans *= pos.popleft() * pos.popleft()
        else:
            ans *= neg_new.popleft()
        k -= 2
        ans %= mod
    print(ans % mod)
#!/usr/bin/env python
# -*- coding: utf-8 -*-

n=int(input())
l=list(map(int,str(bin(n))[2:]))
for i in range(1,len(l)+3): 
    if l[-i] == 2: #2のとき繰上げ
        l[-i] = 0
        try:
            l[-(i+1)]+=1
        except:
            l.insert(0,1)
    if i%2==0 and l[-i]==1: #-2^nが-2のとき01→11に変換
        try: 
            l[-(i+1)]+=1
        except:
            l.insert(0,1)
s = ''.join([str(x) for x in l])
print(s)

### FIXED CODE ###

n=int(input())
flg = 0
if n < 0:
    n *= -1
    flg = 1
l=list(map(int,str(bin(n))[2:]))
for i in range(1,len(l)+3): 
    try:
        if l[-i] == 2:
            l[-i] = 0
            if i == len(l):
                l.insert(0,1)
            else:
                l[-(i+1)]+=1
        if i%2==flg and l[-i]==1:
            if i == len(l):
                l.insert(0,1)
            else:
                l[-(i+1)]+=1
    except:
        pass
s = ''.join([str(x) for x in l])
print(s)
l = list(map(int,input().split()))
count = 0
while True:
    if l[0] == l[1] == l[2]:
        if l[1]%2 == 0:
            print(-1)
            exit(9)
    for i in range(3):
        if l[i]%2 == 1:
            print(count)
            exit()
    count += 1
    l[0],l[1],l[2] = (l[1]+l[2])//2,(l[0]+l[2])//2,(l[1]+l[0])//2
             
            


### FIXED CODE ###

l = list(map(int,input().split()))
count = 0
while True:
    if l[0] == l[1] == l[2]:
        if l[1]%2 == 0:
            print(-1)
            exit()
    for i in range(3):
        if l[i]%2 == 1:
            print(count)
            exit()
    count += 1
    l[0],l[1],l[2] = (l[1]+l[2])//2,(l[0]+l[2])//2,(l[1]+l[0])//2
a = int(input())
c = list(map(int,input().split()))
c1=c2=c4=0
for i in c:
    if c%2==1:
        c1+=1
    elif c%4==0:
        c4+=1
    else:c2+=1
if c1+1>c4:print("No")
elif c1+c2-c4==1:print("Yes")
elif c1<=c4:print("Yes")

### FIXED CODE ###

a = int(input())
c = list(map(int,input().split()))
c1=c2=c4=0
for i in c:
    if i%2==1:
        c1+=1
    elif i%4==0:
        c4+=1
    else:c2+=1
if c1+c2-c4==1:print("Yes")
elif c1<=c4:print("Yes")
else:print("No")
from math import sqrt
N = int(input())
ans = []
for i in range(1, int(sqrt(N)) + 1):
    if i * (N // i) == N:
        ans.append(max(len(str(i)), len(str(N // i)))
print(min(ans))

### FIXED CODE ###

from math import sqrt
N = int(input())
ans = []
for i in range(1, int(sqrt(N)) + 1):
    if i * (N // i) == N:
        ans.append(max(len(str(i)), len(str(N // i))))
print(min(ans))
a = list(map(int,input()))
b = a[0]*a[1]

if b%2==0:
  print("Even")
else:
  print("Odd")

### FIXED CODE ###

a = list(map(int,input().split()))
b = a[0]*a[1]

if b%2==0:
  print("Even")
else:
  print("Odd")
l = int(input())
ans = []
for i in range(1, l//3+1):
    for j in range(1, l//3+1):
        ans.append(i*j*(l-i-j))
print(max(ans))

### FIXED CODE ###

print((int(input())/3)**3)
r,g,b,n = map(int,input().split())
ans = 0
for i in range(n//r+1):
  for j in range(n//g+1):
    for k in range(n//b+1):
      if i*r + j*g + k*b = n:
        ans += 1
print(ans)


### FIXED CODE ###

R,G,B,N = map(int,input().split())
count = 0
for i in range(3001):
	for j in range (3001):
		if i*R+j*G<=N:
			tmp = N-(i*R+j*G)
			if tmp % B == 0:
				count += 1
print(count)
N, *D = map(int, open('0').read().split())
D.append(0)
used = [0]*(N+1)
cnt = N
while True:
  ls = []
  for i in range(N+1):
    for j in range(N+1):
      if i==j:
        continue
      a,b = min(D[i],D[j]),max(D[i],D[j])
      d = b-a
      ls.append((min(d,24-d),i,j))
  ls.sort(key=lambda x:x[0])
  d,a,b = ls[0]
  if used[a]==0 and used[b]==0:
    used[a] = 1
    used[b] = 1
    da = (24-D[a])%24
    ma = 100
    for i in range(N+1):
      if i==a:
        continue
      x = abs(da-D[i])
      ma = min(ma,x,24-x)
    db = (24-D[b])%24
    mb = 100
    for i in range(N+1):
      if i==b:
        continue
      x = abs(db-D[i])
      mb = min(mb,x,24-x)
    if ma<mb:
      if d>=mb:
        print(d)
        break
      D[b] = db
    else:
      if d>=ma:
        print(d)
        break
      D[a] = da
  elif used[a]==0:
    used[a] = 1
    da = (24-D[a])%24
    ma = 100
    for i in range(N+1):
      if i==a:
        continue
      x = abs(da-D[i])
      ma = min(ma,x,24-x)
    if d>=ma:
      print(d)
      break
    else:
      D[a] = da
  elif used[b]==0:
    used[b] = 1
    db = (24-D[b])%24
    mb = 100
    for i in range(N+1):
      if i==b:
        continue
      x = abs(db-D[i])
      mb = min(mb,x,24-x)
    if d>=mb:
      print(d)
      break
    else:
      D[b] = mb
  else:
    print(d)
    break

### FIXED CODE ###

N, *D = map(int, open(0).read().split())
D.append(0)
used = [0]*(N+1)
cnt = N
while True:
  ls = []
  for i in range(N+1):
    for j in range(N+1):
      if i==j:
        continue
      a,b = min(D[i],D[j]),max(D[i],D[j])
      d = b-a
      ls.append((min(d,24-d),i,j))
  ls.sort(key=lambda x:x[0])
  d,a,b = ls[0]
  if used[a]==0 and used[b]==0:
    da = (24-D[a])%24
    ma = 100
    for i in range(N+1):
      if i==a:
        continue
      x = abs(da-D[i])
      ma = min(ma,x,24-x)
    db = (24-D[b])%24
    mb = 100
    for i in range(N+1):
      if i==b:
        continue
      x = abs(db-D[i])
      mb = min(mb,x,24-x)
    if ma<mb:
      if d>=mb:
        print(d)
        break
      D[b] = db
      used[b] = 1
    else:
      if d>=ma:
        print(d)
        break
      D[a] = da
      used[a] = 1
  elif used[a]==0:
    used[a] = 1
    da = (24-D[a])%24
    ma = 100
    for i in range(N+1):
      if i==a:
        continue
      x = abs(da-D[i])
      ma = min(ma,x,24-x)
    if d>=ma:
      print(d)
      break
    D[a] = da
  elif used[b]==0:
    used[b] = 1
    db = (24-D[b])%24
    mb = 100
    for i in range(N+1):
      if i==b:
        continue
      x = abs(db-D[i])
      mb = min(mb,x,24-x)
    if d>=mb:
      print(d)
      break
    D[b] = mb
  else:
    print(d)
    break
s1,s2,s3 = map(int,input().split())
print(s1[0].capitalize() + s2[0].capitalize() + s3[0]capitalize())

### FIXED CODE ###

s1,s2,s3 = input().split()
print(s1[0].capitalize() + s2[0].capitalize() + s3[0].capitalize())
import math
N = int(input())
n = round((N//2) ** 0.5)
a,b = n+2, n+3
if a*(a+1)//2 > abs(a*(a+1)//2 - N):
    number = abs(a*(a+1)//2 - N)
    n = a
elif b*(b+1)//2 >= abs(b*(b+1)//2 - N):
    number = abs(b*(b+1)//2 - N)
    n = b

for i in range(1, n+1):
    if i == number: continue
    print(i)

### FIXED CODE ###

N = int(input())
cnt = 0
for i in range(1, N+1):
  if i * (1 + i) // 2 >= N:
    cnt = i
    break
for i in range(cnt, 0, -1):
  if i <= N:
    print(i)
    N -= i
N,K = map(int,input().stlip())
H = map(int,input().stlip())

ans = 0
for h in H:
    if h >= K:
        ans += 1
print(ans)

### FIXED CODE ###

N,K = map(int,input().split())
H = map(int,input().split())
ans = 0
for h in H:
    if h >= K:
        ans += 1
print(ans)
N,M = list(map(int, sys.stdin.readline().rstrip().split())) 
A = list(map(int, sys.stdin.readline().rstrip().split())) 

s = 0
for n in range(M):
  s += A[n]
  
s -= N
if s < 0:
  print(-1)
else:
  print(s)

### FIXED CODE ###

import sys
N,M = list(map(int, sys.stdin.readline().rstrip().split())) 
A = list(map(int, sys.stdin.readline().rstrip().split())) 

s = 0
for n in range(M):
  s += A[n]
  
s = N - s
if s < 0:
  print(-1)
else:
  print(s)
def dfs(G, C, id, color):
    S = []
    S.append(id)
    C[id] = color

    while S:
        u = S[-1]  # ?????¨?¨????????????????????????°??????
        S = S[:-1]  # pop
        for i in range(len(G[u])):
            v = G[u][i]
            if C[v] == -1:
                C[v] = color
                S.append(v)


if __name__ == '__main__':
    # ??????????????\???
    num_of_users, num_of_links = [int(x) for x in input().split(' ')]
    links = []
    for _ in range(num_of_links):
        links.append(list(map(int, input().split(' '))))
    num_of_queries = int(input())
    queries = []
    for _ in range(num_of_queries):
        queries.append(list(map(int, input().split(' '))))

    # ???????????????
    G = [[] for _ in range(11)]
    C = [-1] * 11
    for f, t in links:
        G[f].append(t)
        G[t].append(f)

    color = 1
    for id in range(num_of_users):
        if C[id] == -1:
            dfs(G, C, id, color)
        color += 1

    # ???????????????
    for x, y in queries:
        if C[x] == C[y]:
            print('yes')
        else:
            print('no')

### FIXED CODE ###

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

"""

import sys
sys.setrecursionlimit(1000000)


n,m=[int(i) for i in input().split()]
graph=[[] for i in range(n)]

for i in range(m):
    relation=[int(j) for j in input().split()]
    graph[relation[0]].append(relation[1])
    graph[relation[1]].append(relation[0])


check=[0 for i in range(n)]
rabel=0
stack=[]

#深さ優先探索
def dfs(graph,i):
    global stack
    global n
    global rabel

    if check[i]==0:

        #行った足跡をつける
        check[i]=rabel

        #今いる場所の情報
        now=graph[i]

        #スタックに入れる
        stack.append(now)

        #今いる場所から到達できる地点のうち、まだ行っていないとこ全部でdfs
        for j in now:
            if check[j]==0:
                dfs(graph,j)

        stack.pop()

for i in range(n):
    if check[i]==0:
        rabel+=1
        dfs(graph,i)
# print(check)



num=int(input())
for i in range(num):
    a,b=[int(j) for j in input().split()]
    if check[a]==check[b]:
        print("yes")
    else:
        print("no")
α = int(input())
 
if α == α.upper():
  return print('A')
elif α == α.lower():
  return print('a')

### FIXED CODE ###

α = input()
 
if α == α.upper():
  print('A')
elif α == α.lower():
  print('a')
X = int(input())
plus = [i**5 for i in range(100)]

for num in plus:
  if abs(X - num) in plus:
    break
    
if (X - num) in plus:
  print(plus.index(num), -1*plus.index(X-num))
else:
  print(plus.index(num), plus.index(num-X))

### FIXED CODE ###

X = int(input())
plus = [i**5 for i in range(1000)]

for num in plus:
  if abs(X - num) in plus:
    break
    
if (X - num) in plus:
  print(plus.index(num), -1*plus.index(X-num))
else:
  print(plus.index(num), plus.index(num-X))
from franctions import gcd

n = int(input())
A = list(map(int,input().split()))
num = 1
ans = 0
for i in A:
  num = i // gcd(i,num) * num

for i in A:
  ans += num//i
  ans %= 1000000007
  
print(int(ans))

### FIXED CODE ###

from fractions import gcd


n = int(input())
A = list(map(int,input().split()))
num = 1
ans = 0
for i in A:
  num = i // gcd(i,num) * num

for i in A:
  ans += num//i
  
print(int(ans%1000000007))
a=input()
if a==A:
  print(T)
elif a==T:
  print(A)
elif a==C:
  print(G)
else:
  print(C)


### FIXED CODE ###

a=input()
if a=="A":
  print("T")
elif a=="T":
  print("A")
elif a=="C":
  print("G")
else:
  print("C")
import numpy as np

N,M = map(int,input().split())
A = np.array(input().split(), dtype=np.int64)
np.cumsum(A, out = A)
A %= M

counter = np.bincount(A)
counter[0] += 1 # empty
answer = (counter * (counter-1)).sum() // 2
print(answer)


### FIXED CODE ###

import numpy as np
from collections import Counter

N,M = map(int,input().split())
A = np.array([0]+[int(x) for x in input().split()],dtype=np.int64)
A_cum = np.mod(A.cumsum(),M)

c = Counter(A_cum)

answer = 0
for x in c.values():
  answer += x*(x-1)//2
print(answer)
a = 0
x = int(input())

while True:
  b = (x-a**5) ** (1/5)
  if b.is_integer() :
    print(a, int(b))
    break
  b = (a**5-x) ** (1/5)
  if b.is_integer() :
    print(a, int(b))
    break
  
  a += 1

### FIXED CODE ###

x = int(input())

flg = False
for a in range(-118, 120):
  for b in range(-118, 120):
    if a**5 - b**5 == x:
      print(a, b)
      flg = True
      break
  if flg:
    break
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = [tuple(map(int, input().split())) for _ in range(M)]

minP = min(a) + min(b)
for x, y, c in xyc:
    minP = min(a[x-1]+b[x-1]-c, minP)
print(minP)

### FIXED CODE ###

A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = [tuple(map(int, input().split())) for _ in range(M)]

minP = min(a) + min(b)
for x, y, c in xyc:
    minP = min(a[x-1]+b[y-1]-c, minP)
print(minP)
a=input()
print(a%1000)

### FIXED CODE ###

a=int(input())
if(a%1000==0):
  print(a%1000)
else:
  print(1000-a%1000)
import math
a,b = list(map(int, input().split()))

def gcd( x, y ):
    while y != 0:
        x, y = y, x%y

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))

### FIXED CODE ###

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

def gcd( x, y ):
    while y != 0:
        x, y = y, x%y
    return x

def lcm(x, y):
    return (x * y) // gcd(x, y)

print(lcm(a, b))
N = int(input())
A = list(map(int, input().split()))

A.sort(reverse=TRUE)
print(sum(A[0::2]) - sum(A[1::2]))

### FIXED CODE ###

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

a.sort(reverse=True)
print(sum(a[0::2]) - sum(a[1::2]))