Harryxun/stf_run huggingface dataset:
class Common:

    problem = []
    index = 0

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            return self.problem[self.index]
            self.index += 1
        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(ABS_PATH + '/*.txt'):
                self.initialize(path)
                self.resolve()
        except NameError:
            self.resolve()

class A(Common):

    def resolve(self):

        q = [int(i) for i in self.input_data().split()]
        result = q[2] - q[0] +q[1]
        if result < 0:
            print('0')
        else:
            print(str(result))

solver = A()
solver.exec_resolve()

### FIXED CODE ###

import glob

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'

# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = 'ABC\\136'

# 絶対パス
ABS_PATH = TOP_PATH + '\\' + REL_PATH

#IS_TEST = 1


class Common:

    problem = []
    index = 0

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            return self.problem[self.index]
            self.index += 1
        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(ABS_PATH + '/*.txt'):
                self.initialize(path)
                self.resolve()
        except NameError:
            self.resolve()

class A(Common):

    def resolve(self):

        q = [int(i) for i in self.input_data().split()]
        result = q[2] - q[0] +q[1]
        if result < 0:
            print('0')
        else:
            print(str(result))

solver = A()
solver.exec_resolve()
S = input()
res = 0

if s[0] == s[1]:
  res += 1
if s[1] == s[2]:
  res += 1

print(res)
  

### FIXED CODE ###

s = input()
res = 1
 
if s[0] == "R" and s[1] == "R":
  res += 1
if s[1] == "R" and s[2] == "R":
  res += 1
  
if "R" in s:
  print(res)
else:
  print(0)
import itertools
from collections import defaultdict
import collections
import sys
sys.setrecursionlimit(200000)
mod = 1000000007

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

tf = [False] * (n + 1)
tf[1] = True
ss = [1]
cnt = 0
while cnt < n ** 2:
    if len(ss) != 1 and tf[a[ss[cnt] - 1]]:
        d = a[ss[cnt] - 1]
        break
    tf[a[ss[cnt] - 1]] = True
    ss.append(a[ss[cnt] - 1])
    cnt += 1

if len(ss) >= k:
    print(ss[k])
else:
    print(ss[ss.index(d)+(k -len(ss)) % (len(ss) - ss.index(d))])
    # print(ss.index(d))
    # print(ss[k % (len(ss) - ss.index(d))])

### FIXED CODE ###

import itertools
from collections import defaultdict
import collections
import sys
sys.setrecursionlimit(200000)
mod = 1000000007

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

tf = [False] * (n + 1)
tf[1] = True
ss = [1]
cnt = 0
while cnt < max(k,n ** 2):
    if len(ss) != 1 and tf[a[ss[cnt] - 1]]:
        d = a[ss[cnt] - 1]
        break
    tf[a[ss[cnt] - 1]] = True
    ss.append(a[ss[cnt] - 1])
    cnt += 1

if len(ss) > k:
    print(ss[k])
else:
    sss = ss.index(d)
    print(ss[sss+(k -len(ss)) % (len(ss) - sss)])
    # print(ss.index(d))
    # print(ss[k % (len(ss) - ss.index(d))])
N = int(input())

lastnum = N[-1]

if lastnum in [0,1,6,8]
print("pon")

elif lastnum in [3]
print("bon")

else
print("hon")


### FIXED CODE ###

def solve(n):
    p = n % 10
    if p in [2,4,5,7,9]:
        return "hon"
    elif p in [0,1,6,8]:
        return "pon"
    else:
        return "bon"

n = int(input())
print(solve(n))
j = [2,3,4,5,6,7,8,9,10,11,12,13,1]
a,b = [int(x) for x in input().split()]
if j.index(a) > j.rindex(b):
  print('Alice')
elif j.index(a) < j.index(b):
  print('Bob')
else:
  print('Draw')


### FIXED CODE ###

a,b = [int(x) for x in input().split()]
j = [2,3,4,5,6,7,8,9,10,11,12,13,1]
if j.index(a) > j.index(b):
  print('Alice')
elif j.index(a) < j.index(b):
  print('Bob')
else:
  print('Draw')
s = str(input())

count = 0

for i in range(len(s)):
  if s[i] == "1":
    count++

print(count)

### FIXED CODE ###

s = str(input())

count = 0

for i in range(len(s)):
  if s[i] == "1":
    count += 1

print(count)
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, Q = MAP()

event = [None]*(2*N+Q)
Xl = [0]*N
for i in range(N):
	S, T, X = MAP()
	event[2*i] = (S-X, 1, X)
	event[2*i+1] = (T-X, 0, X)
	Xl[i] = X

t = 2*N
for i in range(Q):
	D = INT()
	event[t+i] = (D, 2, 0)

event.sort()
p = []
q = []
for t, c, x in event:
	if c == 0:
		heappush(p, x)
	elif c == 1:
		heappush(q, x)
	else:
        while q and p[0] == q[0]:
            heappop(p)
            heappop(q)
		print(-1 if not p else p[0])


### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, Q = MAP()

event = [None]*(2*N+Q)
Xl = [0]*N
for i in range(N):
    S, T, X = MAP()
    event[2*i] = (S-X, 1, X)
    event[2*i+1] = (T-X, 0, X)
    Xl[i] = X

t = 2*N
for i in range(Q):
    D = INT()
    event[t+i] = (D, 2, 0)


event.sort()
p = []
q = []
for t, c, x in event:
    if c == 0:
        heappush(q, x)
    elif c == 1:
        heappush(p, x)
    else:
        while q and p[0] == q[0]:
            heappop(p)
            heappop(q)
        print(-1 if not p else p[0])
N, M = map(int, input().split())
num_edges = M
edges = [list(map(int, input().split())) for i in range(num_edges)]
adj = [[] for i in range(N+1)]
for ed in edges:
    adj[ed[0]] += [[ed[1], ed[2]]]
    adj[ed[1]] += [[ed[0], ed[2]]]
col_list = [-1 for i in range(N+1)]

def recfun(v, col):
    col_list[v] = col #色を更新
    for ed in adj[v]: #隣接する頂点をみる
        if col_list[ed[0]] == -1: #更新していない場合
            recfun(ed[0], col) #同じ色でその先をみる
count = 0
for i in range(1, N+1):
    if col_list[i] == -1:
        count +=1
        recfun(i, count)
print(count)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)
N, M = map(int, input().split())
num_edges = M
edges = [list(map(int, input().split())) for i in range(num_edges)]
adj = [[] for i in range(N+1)]
for ed in edges:
    adj[ed[0]] += [[ed[1], ed[2]]]
    adj[ed[1]] += [[ed[0], ed[2]]]
col_list = [-1 for i in range(N+1)]

def recfun(v, col):
    col_list[v] = col #色を更新
    for ed in adj[v]: #隣接する頂点をみる
        if col_list[ed[0]] == -1: #更新していない場合
            recfun(ed[0], col) #同じ色でその先をみる
count = 0
for i in range(1, N+1):
    if col_list[i] == -1:
        count +=1
        recfun(i, count)
print(count)
N,T=map(int, input().split())
ct=[]
Nminimum=int(101)
output=str('TLE')
for i in range(N):
    ct.append(list(map(int, input().split())))
for i in range(N):
    if ct[i][1]<=T:
        if ct[i][0]<Nminimum:
            Nminimum=ct[i][0]
            output=Nminimum
print(output)

### FIXED CODE ###

N=int(input())
if N==1:
    output=str('Hello World')
else:
    A=int(input())
    B=int(input())
    output=A+B
print(output)
n=int(input())
a=[]

x,y,k=-1,-1,-1

for _ in range(n):
    s=list(map(int,input().split()))
    if s[2] != 0:
        a.append(s)
for i in range(101):
    for j in range(101):
        h=a[0][2]+abs(a[0][0]-i)+abs(a[0][1]-j)
        d=True

        for l in range(n):
            if a[l][2] > 0 and h != a[l][2]+abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            elif a[l][2]==0 and h>abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            
        if d:
            x,y,k=i,j,h
            print(x,y,k)
            exit()
            


### FIXED CODE ###

n=int(input())
xyh=[]

x,y,h=-1,-1,-1
nonzero=-1

for i in range(n):
    xyh.append(list(map(int,input().split())))
    if xyh[i][2] != 0:
        nonzero = i

for px in range(101):
    for py in range(101):
        nh = xyh[nonzero][2]+abs(xyh[nonzero][0]-px)+abs(xyh[nonzero][1]-py)
        ok = True

        for nn in range(n):
            if xyh[nn][2] > 0 and nh != xyh[nn][2]+abs(xyh[nn][0]-px) + abs(xyh[nn][1]-py):
                ok=False
            if xyh[nn][2] == 0 and nh > abs(xyh[nn][0]-px) +abs(xyh[nn][1]-py):
                ok=False
        
        if ok:
            x,y,h = px,py,nh
            print(x,y,h)
            exit()
l, r = map(int,input().split())

l_mod = l % 2019
r_mod = r % 2019
li = []

if r - l > 2018:
    ans = 0
else:
    for i in range(l,r):
        for j in range(i + 1,r + 1):
            li.append((i * j) % 2019)

ans = min(li)

print(ans)

### FIXED CODE ###

l, r = map(int,input().split())

li = []

if r - l > 2018:
    ans = 0
else:
    for i in range(l,r):
        for j in range(i + 1,r + 1):
            li.append((i * j) % 2019)
    ans = min(li)

print(ans)
A,B=list(map(int,input().split(' ')))
A={1, 3, 5, 7, 8, 10, 12}
B={4, 6, 9, 11}
print('Yes' if {x,y} <= A or {x,y} <= B else 'No')

### FIXED CODE ###

x,y = map(int, input().split())
A = {1, 3, 5, 7, 8, 10, 12}
B = {4, 6, 9, 11}
print("Yes" if {x, y} <= A or {x, y} <= B else "No")
#import random
n=int(input())

pnt=[]
for i in range(n):
  pnt.append(list(map(int,input().split())))
  #pnt.append([random.randint(int(-1e9),int(1e9)),random.randint(int(-1e9),int(1e9))])
pnt.sort(key=lambda x:abs(x[0])+abs(x[1]),reverse=True)
mn=list(reversed(pnt))
mx=0

for i in range(min(n,5000)):
  for j in range(i+1,min(n,5000)):
    mx=max(abs(pnt[i][0]-pnt[j][0])+abs(pnt[i][1]-pnt[j][1]),mx)
    mx=max(abs(pnt[i][0]-mn[j][0])+abs(pnt[i][1]-mn[j][1]),mx)
print(mx)


### FIXED CODE ###

n=int(input())
ans=0
mod=int((1e+9)+7)
def cmb(n,r):
  if r<0 or r>n:
    return 0
  r=min(r,n-r)
  return g[n]*gg[r]*gg[n-r]%mod
g=[1,1]
gg=[1,1] 
inv=[0,1] 
for i in range(2,n+1):
  g.append((g[-1]*i)%mod)
  inv.append((-inv[mod%i]*(mod//i))%mod)
  gg.append((gg[-1]*inv[-1])%mod)

for i in range(n//3):
  x=n-(3*(i+1))
  ans+=cmb(x+i,i)

  ans%=mod
  
print(ans)
n,l=map(int,input().split())

taste = []
teste_zettaichi = []

for i in range(n):
    taste.append(l+i-1)
    teste_zettaichi.append(abs(taste[i]))

sum_taste = sum(taste)
min_zettaichi = min(teste_zettaichi)
print(sum_taste - min_zettaichi)

### FIXED CODE ###

num = input()
#num = str(code)

if num[0] == num[1] or num[1] == num[2] or num[2] == num[3]:
    print('Bad')
else:
    print('Good')
n = int(raw_input())
list_str = []
for count in range(0,n):
    list_str.append(raw_input())

for count in range(0,n-1):
    if count == 0:
        compare1 = set(list_str[count])
    else:
        compare1 = set(output)
    compare2 = set(list_str[count+1])
    output = list(compare1 & compare2)
output = ''.join(output)
print output

### FIXED CODE ###

a,b,c = map(int, raw_input().split())
if b-a == c-b:
	print "YES"
else:
	print "NO"
n = int(input())
nlist = list(map(int, input().split()))
def BubbleSort(C, n):
    c = 0
    for i in range(n-1):
        for w in range(i+1, n):
            j = n-k+i
            if (C[j] < C[j-1]):
                a = C[j]
                C[j] = C[j-1]
                C[j-1] = a
                c += 1
BubbleSort(nlist, n)
for i in range(n):
    if (i == n-1):
        print('{}'.format(nlist[i]), end = '')
    else : 
        print('{}'.format(nlist[i]), end = ' ')
print()
print(c)


### FIXED CODE ###

n = int(input())
nlist = list(map(int, input().split()))
def BubbleSort(C, n):
    c = 0
    for i in range(n-1):
        for w in range(i+1, n):
            j = n-w+i
            if (C[j] < C[j-1]):
                a = C[j]
                C[j] = C[j-1]
                C[j-1] = a
                c += 1
    C.append(c)
BubbleSort(nlist, n)
for i in range(n):
    if (i == n-1):
        print('{}'.format(nlist[i]), end = '')
    else : 
        print('{}'.format(nlist[i]), end = ' ')
print()
print(nlist[-1])
nk = list(map(int,input().split()))
h = np.array(list(map(int,input().split())))
n,k = nk[0], nk[1] #5,3
DP = np.array([0])
#DP[0] = 0
for i in range(1, n):#0~3 -> 1~4
  act = float("inf")
  for k_ in range(1, k+1):#0~2 -> 1~3
    if i-k_ < 0 : continue
    act = min(DP[i-k_] + abs(h[i-k_]-h[i]), act)#
  DP = np.append(DP, act)#[0,20,]
print(int(DP[-1]))

### FIXED CODE ###

N, K = map(int, input().split())
h = list(map(int, input().split()))
 
DP = [0]
for i in range(N-1):
    act = float("inf")
    for k in range(K):
        if i-k < 0 : continue
        act = min(DP[-1-k] + abs(h[i-k]-h[i+1]) , act)
    DP += [act]
 
print(DP[-1])
n=int(input())

if n%111==0:
  print(n)
else:
  while n%111>0:
    ans=n
    n+=1
print(ans+1)



### FIXED CODE ###

n=int(input())
ans=999
for i in range(n,1000):
  if i%111==0:
    if i<=ans:
      ans=i
      
print(ans)
def dfs(v,p): #点vについての処理。p：vの親
    if (p != -1): res[v] += res[p]
    
    for e in edges[v]:
        if (e == p): continue
        dfs(e,v)
#--------------------------------
N, Q = map(int, input().split())
edges = [[] for _ in range(N+1)]
for i in range(N-1):
    a,b = map(int, input().split())
    edges[a].append(b)
    edges[b].append(a)
#print(edges)
px = [list(map(int, input().split())) for _ in range(Q)]

res = [0]*(N+1) #点数リスト
for i in range(Q): #点数リストに初期値を格納
    p,x = px[i]
    res[p] += x

dfs(1,-1)
print(*res[1:])


### FIXED CODE ###

import collections,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,Q = LI()
ab = [LI() for _ in [None]*(N-1)]
px = [LI() for _ in [None]*(Q)]
ans = [0]*(N+1) #1_index
graph = [collections.deque() for _ in [None]*(N+1)] #1_index
for a,b in ab:
        graph[a].append(b)
        graph[b].append(a)
for p,x in px:
    ans[p] += x
seen = [0]*(N+1) #1_index
stack = []
def dfs():
    seen[1] = 1
    stack.append(1)
    while stack:
        s = stack.pop()
        if not graph[s]:
            continue
        for j in range(len(graph[s])):
            g_NO = graph[s].popleft()
            if seen[g_NO]:
                continue
            seen[g_NO] = 1
            stack.append(g_NO)
            ans[g_NO] += ans[s]
dfs()
print(*ans[1:])
def trans(g):
    gene = ['A', 'G', 'T', 'U']
    return gene[(gene.index(g)+2)%4]

b = input()
ans = ''

for i in b:
    ans += trans(i)

print(ans)

### FIXED CODE ###

def trans(g):
    gene = ['A', 'G', 'T', 'C']
    return gene[(gene.index(g)+2)%4]

b = input()
ans = ''

for i in b:
    ans += trans(i)

print(ans)
n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
for i,j in zip(v,c):
  ans += max(0, v-c)
print(ans)


### FIXED CODE ###

n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
for i,j in zip(v,c):
  ans += max(0, i-j)
print(ans)
def main():
    import heapq

    n, m, s = map(int, input().split())

    edges = [[] for _ in range(n)]
    max_cost = 0
    for _ in range(m):
        from_, to, cost, time = map(int, input().split())
        edges[from_-1].append((to-1, cost, time))
        edges[to-1].append((from_-1, cost, time))
        if cost > max_cost:
            max_cost = cost

    banks = []
    for i in range(n):
        coin, time = map(int, input().split())
        banks.append((coin, time))

    max_coin = max_cost * (n-1)
    if s > max_coin:
        s = max_coin

    INF = float('INF')
    DP = [[INF] * max_coin for _ in range(n)]
    DP[0][s] = 0
    ans = [INF] * n

    def push_todo(node, coin, time):
        if coin < 0:
            return
        if time >= DP[node][coin]:
            return
        heapq.heappush(todo, (time, node, coin))
        DP[node][coin] = time

    def charge(node, current_coin, current_time):
        coin, time = banks[node]
        new_coin = current_coin + coin
        if new_coin >= max_coin:
            new_coin = max_coin-1
        push_todo(node, new_coin, current_time+time)

    todo = [(0, 0, s)]  # time, node, coin
    while todo:
        current_time, node, current_coin = heapq.heappop(todo)
        if current_time > DP[node][current_coin]:
            continue

        if current_time < ans[node]:
            ans[node] = current_time

        charge(node, current_coin, current_time)

        for to, cost, time in edges[node]:
            push_todo(to, current_coin-cost, current_time+time)

    for a in ans[1:]:
        print(a)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import heapq


n, m, s = map(int, input().split())
if s >= 2500:
    s = 2499

edges = [[] for _ in range(n)]
for _ in range(m):
    from_, to, cost, time = map(int, input().split())
    edges[from_-1].append((to-1, cost, time))
    edges[to-1].append((from_-1, cost, time))

banks = [(0, 0) for _ in range(n)]
for i in range(n):
    coin, time = map(int, input().split())
    banks[i] = (coin, time)

INF = float('INF')
DP = [INF] * (n * 2500)
ans = [INF] * n


def to_one_dimension(node, coin):
    return node * 2500 + coin


def push_todo(node, coin, time):
    if coin < 0:
        return
    if time >= DP[to_one_dimension(node, coin)]:
        return
    heapq.heappush(todo, (time, node, coin))


def charge(node, current_coin, current_time):
    coin, time = banks[node]
    new_coin = current_coin + coin
    if new_coin >= 2500:
        new_coin = 2499
    push_todo(node, new_coin, current_time+time)


todo = [(0, 0, s)]
while todo:
    current_time, node, current_coin = heapq.heappop(todo)
    if current_time < ans[node]:
        ans[node] = current_time

    one_d_idx = to_one_dimension(node, current_coin)
    if current_time >= DP[one_d_idx]:
        continue

    DP[one_d_idx] = current_time
    charge(node, current_coin, current_time)

    for to, cost, time in edges[node]:
        push_todo(to, current_coin-cost, current_time+time)

for a in ans[1:]:
    print(a)
-(-int(input())) // 2import sys
input = sys.stdin.readline
print(-(-int(input()) // 2))

### FIXED CODE ###

import sys
input = sys.stdin.readline
print(-(-int(input()) // 2))
s=input()
k=int(input())
i=0
while s[i]=="1":
    i+=1
print(s[i])

### FIXED CODE ###

s=input()
k=int(input())-1
if s.count("1")==len(s):
    t=k
    print(1)
else:
    i=0
    while s[i]=="1":
        i+=1
    if k<i:
        print(1)
    else:
        print(s[i])
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,k=map(int,input().split())
amari=[0]*k
for i in range(n):
    i+=1
    amari[i%k]+=1
# print(amari)

ans=0
for i in range(n):
    i+=1
    am=i%k
    nokori=(k-am)%import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,k=map(int,input().split())
amari=[0]*k
for i in range(n):
    i+=1
    amari[i%k]+=1
# print(amari)

ans=0
for i in range(n):
    i+=1
    am=i%k
    nokori=(k-am)%k
    # print(am,nokori)
    if nokori*2%k==0:
        ans+=amari[nokori]**2
print(ans)
    # print(am,nokori)
    if nokori*2%k==0:
        ans+=amari[nokori]**2
print(ans)

### FIXED CODE ###

import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,k=map(int,input().split())
amari=[0]*k
for i in range(n):
    i+=1
    amari[i%k]+=1
# print(amari)

ans=0
for i in range(n):
    i+=1
    am=i%k
    nokori=(k-am)%k
    # print(am,nokori)
    if nokori*2%k==0:
        ans+=amari[nokori]**2
print(ans)
import math
b = list(map(int,input().split()))
ans=0
check=0
i=0
A=0
B=0
C=b[1]
max = b[2]//b[1]
if max==0:
    for i in range(b[2]+1):
        if b[2]-i <0:
            break
        check = math.floor((b[0]*(b[2]-i))/b[1]) - b[0]*math.floor((b[2]-i)/b[1])
        if check > ans:
            ans=check

else:
    for i in range(1,max+1):
        A=b[1]-1
        B=b[1]+1
        check = math.floor((b[0]*A)/C) - b[0]*math.floor(A/C)
        if check > ans:
            ans=check
        check = math.floor((b[0]*B)/C) - b[0]*math.floor(B/C)
        if check > ans:
            ans=check
        B[1]+=b[1]
print(ans)

### FIXED CODE ###

import math
b = list(map(int,input().split()))
ans=0
check=0
if b[2]>b[1]-1:
    check = math.floor((b[0]*(b[1]-1))/b[1]) - b[0]*math.floor((b[1]-1)/b[1])
else:
    check = math.floor((b[0]*b[2])/b[1]) - b[0]*math.floor(b[2]/b[1])
if check>ans:
    ans=check
print(ans)
def solve():
    w, h = [int(x) for x in input().split()]
    if w == h == 0:
        return False
    field = [[int(x) for x in input().split()] for _ in range(h)]

    ans = 0
    for x in range(w):
        for y in range(h):
            if field[y][x] > 0:
                mark(field, w, h, x, y)
                ans += 1
    print(ans)
    return True


def mark(field, w, h, x, y):
    if x < 0 or x >= w or y < 0 or y >= h:
        return

    if field[y][x] != 1:
        return

    field[y][x] = -1
    mark(field, w, h, x+1, y+1)
    mark(field, w, h, x+1, y)
    mark(field, w, h, x+1, y-1)
    mark(field, w, h, x, y+1)
    mark(field, w, h, x, y-1)
    mark(field, w, h, x-1, y+1)
    mark(field, w, h, x-1, y)
    mark(field, w, h, x-1, y-1)
    

while solve():
    pass

### FIXED CODE ###

def solve():
    w, h = [int(x) for x in input().split()]
    if w == h == 0:
        return False
    field = [[int(x) for x in input().split()] for _ in range(h)]

    ans = 0
    for x in range(w):
        for y in range(h):
            if field[y][x] > 0:
                stack = []
                mark(field, w, h, x, y, stack)
                while stack:
                    p, q = stack.pop()
                    mark(field, w, h, p, q, stack)
                    
                ans += 1
    print(ans)
    return True



def mark(field, w, h, x, y, stack):
    if x < 0 or x >= w or y < 0 or y >= h:
        return

    if field[y][x] != 1:
        return

    field[y][x] = -1

    stack.append((x+1, y+1))
    stack.append((x+1, y))
    stack.append((x+1, y-1))
    stack.append((x, y+1))
    stack.append((x, y))
    stack.append((x, y-1))
    stack.append((x-1, y+1))
    stack.append((x-1, y))
    stack.append((x-1, y-1))
    

while solve():
    pass