Harryxun/stf_run huggingface dataset:
import queue


h,w=map(int,input().split())

m=[input() for i in range(w)]

q=queue.Queue()


cnt=[[100000000 for i in range(h)] for j in range(w)]

if m[0][0]=="#":
    cnt[0][0]=1
else:
    cnt[0][0]=0

q.put([1,1])

c=[0,0]#[w,h]
while c!=[w,h]:
    c=q.get()
    if c[0]+1<=w:
        q.put([c[0]+1,c[1]])
        if m[c[0]][c[1]-1]=="#":
            cnt[c[0]][c[1]-1]=min(cnt[c[0]][c[1]-1],cnt[c[0]-1][c[1]-1]+1)
        else:
            cnt[c[0]][c[1]-1]=min(cnt[c[0]][c[1]-1],cnt[c[0]-1][c[1]-1])
    if c[1]+1<=h:
        q.put([c[0],c[1]+1])
        if m[c[0]-1][c[1]]=="#":
            cnt[c[0]-1][c[1]]=min(cnt[c[0]-1][c[1]],cnt[c[0]-1][c[1]-1]+1)
        else:
            cnt[c[0]-1][c[1]]=min(cnt[c[0]-1][c[1]],cnt[c[0]-1][c[1]-1])

print(cnt[h-1][w-1])

### FIXED CODE ###

h,w=map(int,input().split())

m=[input() for i in range(h)]


cnt=[[1000000 for i in range(w)] for j in range(h)]

if m[0][0]=="#":
    cnt[0][0]=1
else:
    cnt[0][0]=0

for y in range(h):
    for x in range(w):
        if x>0:
            if m[y][x-1]=="." and m[y][x]=="#":
                cnt[y][x]=min(cnt[y][x],cnt[y][x-1]+1)
            else:
                cnt[y][x]=min(cnt[y][x],cnt[y][x-1])
        if y>0:
            if m[y-1][x]=="." and m[y][x]=="#":
                cnt[y][x]=min(cnt[y][x],cnt[y-1][x]+1)
            else:
                cnt[y][x]=min(cnt[y][x],cnt[y-1][x])


print(cnt[h-1][w-1])
a = input()
t = input()
if a == "H" and t == "H":
  print("H")
elif a == "H" and t == "D":
  print("D")
elif a == "D" and t == "H":
  print("D")
elif a == "D" and t == "D"
  print("H")
else:
  pass

### FIXED CODE ###

a, t = input().split()
if a == t:
  print("H")
else:
  print("D")
# 入力
N, M = map(int, input().split())
A, B = zip(*(map(int, input().split()) for _ in range(M)))

# 隣接リスト表現のグラフに変換
E = [[] for _ in range(N + 1)]
for a, b in zip(A, B):
    E[a].append(b)
    E[b].append(a)

# 訪れたことがあるかどうかのフラグ
v = [i == 1 for i in range(N + 1)]


# 訪れたことのない頂点を深さ優先探索する
def dfs(i, p):
    for j in E[i]:
        if not v[j]:
            v[j] = True
            p.append(j)
            return dfs(j, p)
    else:
        return p


# Hamiltonish Path を求める
p = list(reversed(dfs(1, []))) + [1] + dfs(1, [])

# 出力
ans = '{}\n{}'.format(len(p), ' '.join(map(str, p)))
print(ans)


### FIXED CODE ###

import sys
sys.setrecursionlimit(2*10**5)

# 入力
N, M = map(int, input().split())
A, B = zip(*(map(int, input().split()) for _ in range(M)))

# 隣接リスト表現のグラフに変換
E = [[] for _ in range(N + 1)]
for a, b in zip(A, B):
    E[a].append(b)
    E[b].append(a)

# 訪れたことがあるかどうかのフラグ
v = [i == 1 for i in range(N + 1)]


# 訪れたことのない頂点を深さ優先探索する
def dfs(i, p):
    for j in E[i]:
        if not v[j]:
            v[j] = True
            p.append(j)
            return dfs(j, p)
    else:
        return p


# Hamiltonish Path を求める
p = list(reversed(dfs(1, []))) + [1] + dfs(1, [])

# 出力
ans = '{}\n{}'.format(len(p), ' '.join(map(str, p)))
print(ans)
a, b, c = map(int,raw_input().split())
if a==b and b!=c:
  print("Yes")
elif a==c and c!=b:
  print("Yes")
elif c==b and c!=a:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

a,b,c = map(int,input().split())
if (a==b and b!=c) or (a==c and c!=b) or (c==b and c!=a):
  print("Yes")
else:
  print("No")
h,a=map(int, input().split())
count = 0
while True:
  result = h - a
  if (result > 0):
    count += 1
  else:
  	break 
return count

### FIXED CODE ###

h,a=map(int, input().split())
count = 0
while True:
  h = h - a
  if (h > 0):
    count += 1
  else:
    break
print(count + 1)
S1 = raw.input()
S = int(S1)
a = S // 3600
b = S % 3600
c = b // 60
d = b % 60
print a + ":" + c + ":" + d

### FIXED CODE ###

S = input()
if S >= 0 and S <= 86400:
   a = S // 3600
   b = S % 3600
   c = b // 60
   d = b % 60
   print "%d:%d:%d" % (a, c, d)
a,b=map(int, input().split())

if a == b:
    print("Draw")
elif a > b:
    if b == 1:
        print("Bob")
        break
    print("Alice")
else:
    print("Bob")

### FIXED CODE ###

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

if a == b:
    print("Draw")
elif a > b:
    if b == 1:
        print("Bob")
    else:
        print("Alice")
else:
    if a == 1:
        print("Alice")
    else:
        print("Bob")
n=int(input())
lst=[]
a,b,c=map(int,input().split())
lst.append(a)
lst.append(b)
lst.append(c)
for i in range(0,n):
    if lst[i]%2==0:
        if lst[i]%3==0 or lst[i]%5==0:
            print("APPROVED")
        else:
            print("DENIED")

### FIXED CODE ###

n=int(input())
check=list(map(int,input().split()))
f=0
for i in range(n):
    if check[i]%2==0:
        if check[i]%3!=0 and check[i]%5!=0:
            f=1
                
if f==1:
    print("DENIED")
else:
    print("APPROVED")
import sys
f = sys.stdin

from collections import deque
import operator

func = {'+':operator.add,'-':operator.sub,'*':operator.mul,'/':operator.truediv }

for line in f:
    stack = deque()
    for element in line.strip().split():
        if element.isdigit():
            stack.append(float(element))
        else:
            b = stack.pop()
            a = stack.pop()
            stack.append(func[element](a, b))
    print('{:.6f}'.format(stack[0]))
        

### FIXED CODE ###

import sys
f = sys.stdin

from collections import deque
import operator

func = {'+':operator.add,'-':operator.sub,'*':operator.mul,'/':operator.truediv }

for line in f:
    stack = deque()
    for element in line.strip().split():
        if element in func:
            b = stack.pop()
            a = stack.pop()
            stack.append(func[element](a, b))
        else:
            stack.append(float(element))
    print('{:.6f}'.format(stack[0]))
l = map(int, open(0).read().split())
print("YNeos"[4 != sum(sum(l[j]-l[0]+l[i] == l[i+j] for i in [1,2]) for j in [3,6])::2])

### FIXED CODE ###

*l, = map(int, open(0).read().split())
print("YNeos"[4 != sum(sum(l[j]-l[0]+l[i] == l[i+j] for i in [1,2]) for j in [3,6])::2])
def cmb(n, k, mod):
    numerator = 1
    for i in range(k):
        numerator = (numerator * (n - i)) % mod

    denominator = 1
    for i in range(1, k + 1):
        denominator = (denominator * i) % mod

    return (numerator * pow(denominator, mod - 2, mod)) % mod


import sys
input = lambda: sys.stdin.readline().rstrip()

n = int(input())
a = list(map(int, input().split()))
freq = {}
for i in a:
    if i in freq:
        freq[i] += 1
    else:
        freq[i] = 1

inf = 1001001001
dp = [inf for _ in range(10005)]
dp2 = [inf for _ in range(10005)]
mod = 10**9 + 7

base = 0
for k, v in freq.items():
    dp[k] = cmb(v, 2, mod)
    dp2[k] = cmb(v - 1, 2, mod)
    base += dp[k]

# print(dp)

for i in a:
    print(base - dp[i] + dp2[i])

# for i in a:
#     if dp[i] == inf:
#         dp[i] = cmb(freq[i],2,mod)
#     print(dp[i])


### FIXED CODE ###

# def cmb(n, k, mod):
#     numerator = 1
#     for i in range(k):
#         numerator = (numerator * (n - i)) % mod

#     denominator = 1
#     for i in range(1, k + 1):
#         denominator = (denominator * i) % mod

#     return (numerator * pow(denominator, mod - 2, mod)) % mod


def ncr(n, r):
    r = min(r, n - r)
    if r == 0: return 1
    if r == 1: return n
    numerator = [n - r + i + 1 for i in range(r)]
    denominator = [i + 1 for i 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 *= numerator[k]
    return int(result)


import math


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


import sys
input = lambda: sys.stdin.readline().rstrip()
n = int(input())
a = list(map(int, input().split()))
freq = {}
for i in a:
    if i in freq:
        freq[i] += 1
    else:
        freq[i] = 1

inf = 1001001001
dp = [inf for _ in range(200005)]
dp2 = [inf for _ in range(200005)]
mod = 10**13 + 3

base = 0
for k, v in freq.items():
    if v > 2:
        dp[k] = ncr(v, 2)
        dp2[k] = ncr(v - 1, 2)
    elif v == 2:
        dp[k] = 1
        dp2[k] = 0
    else:
        dp[k] = 0
        dp2[k] = 0
    base += dp[k]

for i in a:
    print(base - dp[i] + dp2[i])
a = int(input())
b = int(input())

print("a * b" + " " + "a * 2 + b * 2")

### FIXED CODE ###

x = input().split()
a = int(x[0])
b = int(x[1])
print(a*b, (a+b)*2)
a = map(int, input().split())

b = a[0]*a[1] 
c = a[2]*a[3]
A = [b, c]
print(max(A))

### FIXED CODE ###

a = list(map(int, input().split()))
b = a[0]*a[1] 
c = a[2]*a[3]
A = [b, c]
print(max(A))
from collections import defaultdict


def eratosthenes_generator():
    yield 2
    n = 3
    h = {}
    while True:
        m = n
        if n in h:
            b = h[n]
            m += 2 * b
            while m in h:
                m += 2 * b
            h[m] = b
            del h[n]
        else:
            m += 2 * n
            while m in h:
                m += 2 * n
            h[m] = n
            yield n
        n += 2


def prepare(n, MOD):
    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return factorials, invs


def prime_factorize(n):
    f = defaultdict(lambda: 0)
    k = n
    for p in eratosthenes_generator():
        while True:
            d, m = divmod(k, p)
            if m == 0:
                f[p] += 1
                k = d
            else:
                break
        if k == 1:
            break
    return f


MOD = 1000000007
n, m = map(int, input().split())
pf = prime_factorize(m)
mx = max(pf.values())
f, r = prepare(n + mx, MOD)
ans = 1
for p, e in pf.items():
    ans *= f[n + e - 1] * r[n - 1]
    ans %= MOD
    ans *= r[e]
    ans %= MOD
print(ans)


### FIXED CODE ###

from collections import defaultdict


def prepare(n, MOD):
    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return factorials, invs


def prime_factorize(n):
    f = defaultdict(lambda: 0)
    f[2] = len(bin(n & -n)) - 3
    i = 3
    k = n >> f[2]
    while k > 1:
        while True:
            d, m = divmod(k, i)
            if m == 0:
                f[i] += 1
                k = d
            else:
                break
        i += 2
    return f


MOD = 1000000007
n, m = map(int, input().split())
pf = prime_factorize(m)
mx = max(pf.values())
f, r = prepare(n + mx, MOD)
ans = 1
for p, e in pf.items():
    ans *= f[n + e - 1] * r[n - 1]
    ans %= MOD
    ans *= r[e]
    ans %= MOD
print(ans)
import sys
from math import gcd
import numpy as np

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	k,q = MI()
	d = LI()
	d = np.array(d)
	for _ in range(q):
		n,x,m = MI()
		d_modm = d%m
		zero = (n//k)*np.sum(d_modm==0) + np.sum((d_modm==0)[:n%k-1])
		lst = x + (n//k)*np.sum(d_modm) + np.sum((d_modm)[:n%k-1])
		print(n-1-zero-(lst//m-x//m))
if __name__ == '__main__':
	main()

### FIXED CODE ###

import sys
import numpy as np

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	k,q = MI()
	d = LI()
	d = np.array(d)
	ans = [0]*q
	for i in range(q):
		n,x,m = MI()
		d_modm = d%m
		zero = ((n-1)//k)*np.sum(d_modm==0) + np.sum((d_modm==0)[:(n-1)%k])
		last = x + ((n-1)//k)*np.sum(d_modm) + np.sum((d_modm)[:(n-1)%k])
		ans[i]=(n-1)-zero-(last//m-x//m)
	printV(ans)

if __name__ == '__main__':
	main()
if __name__ == '__main__':
    n, m, x = list(map(int, input().split()))

    # 空のリストを作って、appendで追加していきます
    c = []  # 参考書の値段です
    a = []  # 各参考書に入る理解度です

    for i in range(n):
        c_temp, *a_temp = list(map(int, input().split()))  # こうすると、2つ目以降をリストで受け取れます
        c.append(c_temp)
        a.append(a_temp)

    INF = float("inf")
    ans = INF

    for bit in range(1 << n):
        price = calc_price(bit)  # 条件を満たすならそのときの値段、満たさないならINFが返ってきます
        ans = min(ans, price)  # 答えを更新します

    if ans == INF:
        print(-1)  # どうやっても条件を満たせなかった
    else:
        print(ans)
        
def calc_price(bit):
    price_total = 0  # 値段の合計
    learn_total = [0] * m  # 理解度

    for i in range(n):
        if (bit >> i) & 1:  # i桁目が0か1か見て、i冊目を買うか買わないか判定します
            price_total += c[i]  # 買うので、i冊目の値段を加算します
            learn = a[i]  # 「i冊目の参考書を読んで増える、各アルゴリズムの理解度」のリストです
            for j, la in enumerate(learn):  # 理解度を加算します enumerateを使うと、range(n)よりスマートです
                learn_total[j] += la

    # 条件を満たすか、check関数で確認します
    if check(learn_total):
        return price_total 　# 条件を満たすので、値段を返します
    else:
        return INF # 条件を満たさないので、INFを返します
     
  def check(learn_total):
    for i in range(m):
        if learn_total[i] < x:
            return False  # 1個でもx未満ならFalse
    return True # 全部x以上ならTrue

### FIXED CODE ###


N, M, X = map(int, input().split())
C = []
A = []
for  i in range(N):
    t = list(map(int, input().split()))
    C.append(t[0])
    A.append(t[1:])
    
result = -1
"""
<< bit演算に関する演算子
左辺の値を右辺の値だけ左へシフトすることを意味する

https://www.javadrive.jp/python/num/index4.html

下記の場合、1からNまで2真数でシフトしていく感じ
"""

for i in range(1 << N):
    #初期化
    t = [0] * M
    c = 0
    #print(i)
    for j in range(N):
        #print(j)
        if(i >> j ) & 1 == 0 :
            continue
        c += C[j]
        for k in range(M):
            t[k] += A[j][k]
    if all(x >= X for x in t):
        if result == -1:
            result = c
        else:
            result = min(result, c)
print(result)
a,b = mao(int,input().split())
print(a*b)

### FIXED CODE ###

a,b = map(int,input().split())
print(a*b)
N, K = list(map(int,input().split()))
move_list = list(map(int,input().split()))

  
test = 1
find_f = {}
for i in range(N):
  find_f[i+1]=[]

find_f[1].append(0)
for i in range(K):
  test = move_list[test-1]
  find_f[test].append(i+1)
  if len(find_f[test]) == 2:
    state ,f = test, find_f[test]
    break
  
K = K-f[0]
f = f[1]-f[0]
remain = K%f

for i in range(remain):
  state = move_list[state-1]
  
print(state)
#state = 1

#for i in range(K):
#  state = move_list[state][1]
  

### FIXED CODE ###

N, K = list(map(int,input().split()))
move_list = list(map(int,input().split()))
 
  
test = 1
find_f = {}
for i in range(N):
  find_f[i+1]=[]
 
find_f[1].append(0)
for i in range(K):
  test = move_list[test-1]
  find_f[test].append(i+1)
  if len(find_f[test]) == 2 and find_f[test][1]-find_f[test][0]<=1000000:
    state ,f = test, find_f[test]
    break
try:
  K = K-f[0]
  f = f[1]-f[0]
  remain = K%f
  for i in range(remain):
    state = move_list[state-1]
 
  print(state)
except:
  print(test)
#state = 1
A,B,C,D,E=map(int,input().split())
    if A == 0:
    print(1)
    elif B == 0:
    print(2)
    elif C == 0:
    print(3)
    elif D == 0:
    print(4)
    else E == 0:
    print(5)


### FIXED CODE ###

A,B,C,D,E=map(int,input().split())

if A == 0:
    print(1)
elif B == 0:
    print(2)
elif C == 0:
    print(3)
elif D == 0:
    print(4)
else:
    print(5)
line=str(input())
line=list(line)
a,b,c,d=line
o1='+'
o2='+'
o3='+'
for x in (a+b,a-b):
  for y in (c,-c):
    for z in (d,-d):
      if x+y+z==7:
        if x==a-b:
          o1='-'
        if y==-c:
          o2='-'
        if z==-d:
          o3='-'
print("{}{}{}{}{}{}{}=7".format(a,o1,b,o2,c,o3,d))


### FIXED CODE ###

line=str(input())
line=list(line)
line=list(map(int,line))
a=line[0]
b=line[1]
c=line[2]
d=line[3]
o1='+'
o2='+'
o3='+'
count=0
for x in (a+b,a-b):
  for y in (c,-c):
    for z in (d,-d):
      if x+y+z==7 and count==0:
        if x==a-b:
          o1='-'
        if y==-c:
          o2='-'
        if z==-d:
          o3='-'
        count+=1
print("{}{}{}{}{}{}{}=7".format(a,o1,b,o2,c,o3,d))
import sys
import math

def main():
    a, b, k = [int(x) for x in sys.stdin.readline().split()]
    query_range = list(range(a, b + 1))
    if k >= math.ceil((b - a + 1) / 2):
        res = query_range
    else:
        res = query_range[:k] + query_range[-k:]
    
    for i in res:
        print(i)
    
if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys

a, b, k = map(int, sys.stdin.readline().split())

def main():
    if k >= b - a + 1:
        res = list(range(a, b+1))
    else:
        res = set(range(a, a+k)) | set(range(b, b-k, -1))
        res = sorted(res)
    return res

if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')
from bisect import bisect_left

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

pos = bisect_left(x, 0)
if x[pos] == 0:
    k -= 1
else:
    x.insert(pos, 0)

l = pos
r = pos+k

if r >= len(x):
    diff = r-len(x) + 1
    l -= diff
    r -= diff

ans = min(abs(x[l]), x[r])*2 + max(abs(x[l]), x[r])

while r >= pos:
    if l < 0:
        break

    dist = min(abs(x[l]), x[r])*2 + max(abs(x[l]), x[r])
    if dist < ans:
        ans = dist

    l -= 1
    r -= 1

print(ans)

### FIXED CODE ###

from bisect import bisect_left

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

pos = bisect_left(x, 0)
if pos < len(x) and x[pos] == 0:
    k -= 1
else:
    x.insert(pos, 0)

l = pos
r = pos+k

if r >= len(x):
    diff = r-len(x) + 1
    l -= diff
    r -= diff

ans = min(abs(x[l]), x[r])*2 + max(abs(x[l]), x[r])

while r >= pos:
    if l < 0:
        break

    dist = min(abs(x[l]), x[r])*2 + max(abs(x[l]), x[r])
    if dist < ans:
        ans = dist

    l -= 1
    r -= 1

print(ans)
from collections import deque
h, w = map(int, input().split())
a = [input() for _ in range(h)]
if all(all(j=="." for j in list(a)) for i in a):
    print(0)
else:
    result = []
    for i in range(h):
        for j in range(w):
            if a[i][j] == ".":
                q = deque([[i, j]])
                visit = [[-1 for _ in range(w)] for __ in range(h)]
                visit[i][j] = 0
                check = False
                while q:
                    y, x = q.popleft()
                    for s, t in [[-1,0],[1,0],[0,-1],[0,1]]:
                        if 0<=y+s and y+s<h and 0<=x+t and x+t<w:
                            if a[y+s][x+t]=="#":
                                result.append(visit[y][x]+1)
                                q = 0
                                break
                            elif visit[y+s][x+t]<0:
                                visit[y+s][x+t] = visit[y][x]+1
                                q.append([y+s,x+t])
    print(max(result))

### FIXED CODE ###

from collections import deque
h, w = map(int, input().split())
a = [input() for _ in range(h)]
memo = [[-1 if j=="." else 0 for j in list(i)] for i in a]

q = []
for i in range(h):
    for j in range(w):
        if a[i][j]=="#":
            q.append([i, j])
q = deque(q)
while q:
    x, y = q.popleft()
    for s, t in [[1,0],[-1,0],[0,1],[0,-1]]:
        if 0<=x+s and 0<=y+t and x+s<h and y+t<w:
            if memo[x+s][y+t]<0:
                memo[x+s][y+t]=memo[x][y]+1
                q.append([x+s,y+t])
print(max(max(i) for i in memo))
import numpy as np

n = int(input())

a = np.array(list(map(int, input().split())))
d = [0] * n
s = {}

for i in a:
  d[i] += 1
  
sum = 0
for k in d:
  if k>1:
    sum += (k*(k-1))//2

for i in range(n):
  ans=sum-d[a[i]]+1
  print(ans)


### FIXED CODE ###

import numpy as np

n = int(input())

a = np.array(list(map(int, input().split())))
d = [0] * (n+1)
s = {}

for i in a:
  d[i] += 1
  
sum = 0
for k in d:
  if k>1:
    sum += (k*(k-1))//2

for i in range(n):
  ans=sum-d[a[i]]+1
  print(ans)
n = int(input())
a = 0
b = 0
for i in range(n):
	A,B = map(str,input().split())
	if A>B:
		a += 3
	elif B>A:
		b += 3
	else:
		a += 1
		b += 1
print('%d %d'.(a,b))


### FIXED CODE ###

n = int(input())
a = 0
b = 0
for i in range(n):
	A,B = map(str,input().split())
	if A>B:
		a += 3
	elif B>A:
		b += 3
	else:
		a += 1
		b += 1
print('%d %d' % (a,b))
n=int(input())
s=input()
t=input()
i=0
while i<n:
    print(s[i]+t[i],end="")
    i+=1

### FIXED CODE ###

n=int(input())
s,t=input().split()
i=0
while i<n:
    print(s[i]+t[i],end="")
    i+=1
lis = [int(input()) for _ in range(6)]
if lis[0] % min(lis[1:]) == 0:
  print(5)
else:
  print(lis[0]//min(lis[1:])+5)
  

### FIXED CODE ###

From0 = ['0','1']*(10**6)
From1 = ['1','0']*(10**6)
s = list(input())
F0 = From0[:len(s)]
F1 = From1[:len(s)]
count_0 = 0
count_1 = 0
for i in range(len(s)):
  if s[i] != F0[i]:
    count_0 += 1
for i in range(len(s)):
  if s[i] != F1[i]:
    count_1 += 1
print(min(count_0,count_1))
n, m = map(int, input().split())

adj = [[] for _ in range(n)] # adjacent list

for _ in range(m):
    u, v = map(int, input().split())
    adj[u].append(v)
    adj[v].append(u)

c = ['w']*n # color of each vertex
con = [0]*n
cnt = 0

   
def DFS_visit(u):
    global c 
    global con
    global cnt
    c[u] = 'g'
    con[u] = cnt
    for v in adj[u]:
        if c[v] == 'w':
            DFS_visit(v)
    c[u] = 'b'
        
for u in range(n):
    if c[u] == 'w':
        cnt += 1
        DFS_visit(u)
        
        
q = int(input())
for _ in range(q):
    u, v = map(int, input().split())
    ans = "yes" if (con[u] == con[v]) else "no"
    print(ans)


### FIXED CODE ###

from collections import deque
 
n, m = map(int, input().split())

adj = [[] for _ in range(n)] # adjacent list

for _ in range(m):
    u, v = map(int, input().split())
    adj[u].append(v)
    adj[v].append(u)

c = ['w']*n # color of each vertex
con = [0]*n
cnt = 0


def BFS_visit(s):
    global c
    global cnt
    global con
    
    c[s] = 'g'
    con[s] = cnt
    
    Q = deque()
    Q.append(s)
    while Q:
        u = Q.popleft()
        for v in adj[u]:
            if c[v] == 'w':
                c[v] = 'g'
                con[v] = cnt
                Q.append(v)
        c[u] = 'b'
        
for u in range(n):
    if c[u] == 'w':
        cnt += 1
        BFS_visit(u)
        
        
q = int(input())
for _ in range(q):
    u, v = map(int, input().split())
    ans = "yes" if (con[u] == con[v]) else "no"
    print(ans)
N, K = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)
ans = []

for i in range(K):
    ans.append(l[i])
    
print(sum(ans))

### FIXED CODE ###

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

if a%3 == 0 or b%3 == 0 or (a+b)%3 == 0:
    print('Possible')
else:
    print('Impossible')
n,k = map(int, input().split())

if n%k == 0:
    sabun == 0
else:
    min_mai = n//k
    max_mai = min_mai + n%k
    sabun = max_mai- min_mai
print(sabun)


### FIXED CODE ###

n,k = map(int, input().split())
 
if n%k == 0:
    sabun = 0
else:
    sabun = 1
print(sabun)