Harryxun/stf_run huggingface dataset:
def main():
    N = int(input())

    #6**6=46656, 6**7=279936
    #9**5=59049, 9**6=531441
    list = [1]
    list.extend([6 ** i for i in range(1, 7)])
    list.extend([9 ** i for i in range(1, 6)])

    dp = [float("inf")] * 100000
    dp[0] = 0

    for i in range(N+1):
        for j in list:
            dp[i+j] = min(dp[i+j], dp[i]+1)

    print(dp[N])

if __name__ == "__main__":
    main()



### FIXED CODE ###

def main():
    N = int(input())

    #6**6=46656, 6**7=279936
    #9**5=59049, 9**6=531441
    list = [1]
    list.extend([6 ** i for i in range(1, 7)])
    list.extend([9 ** i for i in range(1, 6)])

    dp = [float("inf")] * 100001
    dp[0] = 0

    for i in range(N+1):
        for j in list:
            if i + j > 100000:
                continue
            else:
                dp[i+j] = min(dp[i+j], dp[i]+1)

    print(dp[N])

if __name__ == "__main__":
    main()
from math import gcd, floor

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

a = (B-A+1)
b = -(floor(B/C) + floor(B/D) - floor(B/(floor(C*D/gcd(C,D)))))
c = (floor((A-1)/C) + floor((A-1)/D) - floor((A-1)/(floor(C*D/gcd(C,D)))))

print(a+b+c)

### FIXED CODE ###

from fractions import gcd

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

a = (B-A+1)
b = -(B//C + B//D - B//(C*D//gcd(C,D)))
c = ((A-1)//C + (A-1)//D - (A-1)//(C*D//gcd(C,D)))

print(a+b+c)
def solve():
    h, w = map(int, input().split())
    S = list(input() + '#' for _ in range(h)) + ['#' * (w + 1)]
    H = [[0] * w for _ in range(h + 1)]
    W = [[0] * w for _ in range(h + 1)]
    def f(r, c, num):
        if W[r][c] == 0:
            if c < w and S[r][c + 1] == '.':
                W[r][c] = f(r, c + 1, num + 1)
            else:
                W[r][c] = num
        return W[r][c]
    def g(r, c, num):
        if H[r][c] == 0:
            if r < h and S[r + 1][c] == '.':
                H[r][c] = g(r + 1, c, num + 1)
            else:
                H[r][c] = num
        return H[r][c]
    ans = 0
    for r in range(h):
        for c in range(w):
            if S[r][c] == '.':
                ans = max(ans, f(r, c, 1) + g(r, c, 1) - 1)
    print(ans)
solve()


### FIXED CODE ###

def solve():
    h, w = map(int, input().split())
    S = list(input() + '#' for _ in range(h)) + ['#' * (w + 1)]
    H = [[0] * w for _ in range(h + 1)]
    W = [[0] * w for _ in range(h + 1)]
    for r in range(h):
        c = 0
        while c < w:
            if S[r][c] == '.':
                t = S[r][c:].find('#')
                for j in range(c, c + t):
                    W[r][j] = t
                c += t
            c += 1
    for c in range(w):
        r = 0
        while r < h:
            if S[r][c] == '.':
                t = r + 1
                cnt = 1
                while S[t][c] == '.':
                    t += 1
                    cnt += 1
                for i in range(r, t):
                    H[i][c] = cnt
                r = t
            r += 1
    ans = 0
    for r in range(h):
        for c in range(w):
            ans = max(ans, H[r][c] + W[r][c] - 1)
    print(ans)
solve()
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(a[k])

### FIXED CODE ###

k = int(input())
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[k-1])
import collections
N, K, L = map(int, input().split())
city = [{"road":{"Connected":[i],"group":-1,"seen":False},
         "rail":{"Connected":[i],"group":-1,"seen":False}} for i in range(N)]
def dfs(graph, v, way, num):
    graph[v][way]["seen"] = True
    graph[v][way]["group"] = num
    for next_v in graph[v][way]["Connected"]:
        if graph[next_v][way]["seen"]:
            continue
        dfs(graph, next_v, way, num)

for i in range(K):
    p, q = map(int, input().split())
    city[p-1]["road"]["Connected"].append(q-1)
    city[q-1]["road"]["Connected"].append(p-1)
for i in range(L):
    r, s = map(int, input().split())
    city[r-1]["rail"]["Connected"].append(s-1)
    city[s-1]["rail"]["Connected"].append(r-1)
for X in ["road", "rail"]:
    count = 0
    for v in range(N):
        if city[v][X]["seen"]:
            continue
        dfs(city, v, X, count)
        count += 1
List = [(city[i]["road"]["group"],city[i]["rail"]["group"]) for i in range(N)]
counter = collections.Counter(List)
for A in List:
    print(counter[A],end=" ")
        


### FIXED CODE ###

N, K, L = map(int, input().split())

def fp(x, parentList): #findParent
    if parentList[x] == x:
        return x
    else:
        parentList[x] = fp(parentList[x], parentList)
        return parentList[x]

#各ノードのparentをリストで表現(連結前は自身がparent)
road = [i for i in range(N)]
rail = [i for i in range(N)]

for _ in range(K):
    p, q = map(int, input().split())
    par_p, par_q = fp(p-1, road), fp(q-1, road) #p, qのparent 
    #連結する際、若い番号をparentとする
    if par_p < par_q:
        road[par_q] = par_p
    else:
        road[par_p] = par_q

#railについても同様
for _ in range(L):
    s, t = map(int, input().split())
    par_s, par_t = fp(s-1, rail), fp(t-1, rail)
    if par_s < par_t:
        rail[par_t] = par_s
    else:
        rail[par_s] = par_t

#連結成分の要素をカウント
cnt = {}
for i in range(N):
    key = (fp(i,road),fp(i,rail))
    if key in cnt:
        cnt[key] += 1
    else:
        cnt[key] = 1
#出力
for i in range(N):
    key = (fp(i,road),fp(i,rail))
    ans = cnt[key]
    print(ans, end=" ")
import numpy as np
N,K=map(int, input().split())
A =list(map(int,input().split()))
MOD = 10 ** 9 + 7

if N==K:
  ans0 = 1
  for a in A[0:N]:
    ans0 *= a
    ans0 %= MOD
  print(ans0)
  exit()
A=sorted(A)  
if (K%2==1 and A[-1]<0):
  ans1 = 1
  for a in A[N-K:N]:
    ans1 *= a
    ans1 %= MOD
  print(ans1)
  exit()

A=sorted(A, key=lambda x:abs(x), reverse=True)
AA=[np.sign(i) for i in A]

ansA = 1
for a in A[0:K]:
  ansA *= a
  ansA %= MOD
ansAA = AA[0:K].count(-1)%2
if ansA==0 or ansAA==0:
  print(ansA)
  exit()

while ansA>0:
  ansA-=MOD
B1=A[0:K]
B2=sorted(A[K:N])
Bp=[i for i in A[0:K] if i>0]
Bm=[i for i in A[0:K] if i<0]

if B2[0]>0:B2.insert(0,0)
if B2[-1]<0:B2.insert(-1,0)
#print(Bp,Bm,B2)

B1.remove(Bp[0])
B1.append(B2[0])
#print(B1)
ansB = 1
for a in B1[0:K]:
  ansB *= a
  ansB %= MOD

C1=A[0:K]
C1.remove(Bm[-1])
C1.append(B2[-1])

ansC = 1
for a in C1[0:K]:
  ansC *= a
  ansC %= MOD



print(max(ansB,ansC)%MOD)

### FIXED CODE ###

import numpy as np
N,K=map(int, input().split())
A =list(map(int,input().split()))
MOD = 10 ** 9 + 7
if N==K:
  ans0 = 1
  for a in A[0:N]:
    ans0 *= a
    ans0 %= MOD
  print(ans0)
  exit()
A=sorted(A)  
if (K%2==1 and A[-1]<0):
  ans1 = 1
  for a in A[N-K:N]:
    ans1 *= a
    ans1 %= MOD
  print(ans1)
  exit()
 
A=sorted(A, key=lambda x:abs(x), reverse=True)
AA=[np.sign(i) for i in A]
 
ansA = 1
for a in A[0:K]:
  ansA *= a
  ansA %= MOD
ansAA = AA[0:K].count(-1)%2
if ansA==0 or ansAA==0:
  print(ansA)
  exit()

while ansA>0:
  ansA-=MOD

B1=A[0:K]
C1=A[0:K]
B2=sorted(A[K:N])
Bp=[i for i in A[0:K] if i>0]
Bm=[i for i in A[0:K] if i<0]
 
if B2[0]>0:B2.insert(0,0)
if B2[-1]<0:B2.insert(-1,0)
if not Bp:Bp.insert(0,B1[-1])
if not Bm:Bm.insert(0,B1[0])
  
#print(Bp,Bm,B2)
#print(Bp[-1],B2[0])
B1.remove(Bp[-1])
B1.append(min(B2[0],0))
#print(B1)
ansB = 1
for a in B1[0:K]:
  ansB *= a
  ansB %= MOD
#print(Bm[-1],B2[-1])
C1.remove(Bm[-1])
C1.append(max(B2[-1],0))
 
ansC = 1
for a in C1[0:K]:
  ansC *= a
  ansC %= MOD
#print(B1,C1)
#print(ansB,ansC)
BB1=[np.sign(i) for i in B1]
ansBB1 = BB1[0:K].count(-1)%2
BB2=[np.sign(i) for i in C1]
ansBB2 = BB2[0:K].count(-1)%2
#print(ansBB1,ansBB2)
if ansBB1==1:
  print(ansC)
  exit()
if ansBB2==1:
  print(ansB)
  exit()
#print(B2[0]/Bp[-1],B2[-1]/Bm[-1])
#print(Bp[-1]*B2[-1],Bm[0]*B2[0])

#print(abs(Bp[-1]*B2[-1])-abs(Bm[-1]*B2[0]))
#print(ansB,ansC)
if abs(Bp[-1]*B2[-1])-abs(Bm[-1]*B2[0])>=0:
  print(ansC)
else: print(ansB)
a, b , c = map(input().split())
print(min(a*b, c))

### FIXED CODE ###

a, b , c = map(int, input().split())
print(min(a*b, c))
a,b = map(int, input().split())
ama1 = a % 2 
ama2 = b % 2

if ana1 == 1 and ama2 == 1 :
    print ("Odd")
else :
    print ("Even")

### FIXED CODE ###

a,b = map(int, input().split())
ama1 = a % 2 
ama2 = b % 2

if ama1 == 1 and ama2 == 1 :
    print ("Odd")
else :
    print ("Even")
# -*- coding: utf-8 -*-
import sys
n, m = map(int, input().split())
demands = [
    tuple(map(int,
              line.strip().split())) for line in sys.stdin.readlines()
]
demands.sort(key=lambda demand: demand[1])

bridge = -1
cnt = 0
for ai, bi in demands:

    if ai <= bridge:
        continue

    else:
        bridge = bi - 1
        cnt += 1

print(cnt)


### FIXED CODE ###

# -*- coding: utf-8 -*-
from itertools import permutations

ary = map(int, input().split())

min_val = float('inf')
for vals in permutations(ary):
    tmp_val = 0
    for i, val in enumerate(vals):
        if i > 0:
            tmp_val += abs(val - vals[i - 1])

    if min_val > tmp_val:
        min_val = tmp_val

print(min_val)
def main():
  _map = map
  _range = range
  _len = len
  _max = max
  _input = input
  _int = int
  n, m = _map(_int, _input().split())
  d1 = [None] * (m + 1)
  for _ in _range(n):
    a, b = _map(_int, _input().split())
    if d1[a] is None:
      d1[a] = [b]
    else:
      d1[a].append(b)
  result = 0
  d2 = {}
  maxb = -1
  for i in _range(1, m + 1):
    if d1[i] is None:
      if _len(d2) == 0:
        continue
    else:
      for j in d1[i]:
        if j not in d2:
          d2[j] = 1
        else:
          d2[j] += 1
        if j > maxb:
          maxb = j
    result += maxb
    d2[maxb] -= 1
    if d2[maxb] == 0:
      del d2[maxb]
      if _len(d2) == 0:
        maxb = -1
      else:
        maxb = _max(d2.keys())
  print(result)
main()

### FIXED CODE ###

n, m = map(int, input().split())
d1 = {}
for _ in range(n):
  a, b = map(int, input().split())
  if a in d1:
    d1[a].append(b)
  else:
    d1[a] = [b]
result = 0
d2 = {}
maxb = -1
for i in range(1, m + 1):
  if i in d1:
    for j in d1[i]:
      if j not in d2:
        d2[j] = 0
      d2[j] += 1
      if j > maxb:
        maxb = j
  else:
    if len(d2) == 0:
      continue
  result += maxb
  if d2[maxb] == 1:
    del d2[maxb]
    if len(d2) == 0:
      maxb = 0
    else:
      maxb = max(d2.keys())
  else:
    d2[maxb] -= 1
print(result)
a,b,c=map(int, input().split())

if a-b==0 
  print(int(c))
elif b-c==0:
  print(int(a))
elif c-a==0:
  print(int(b))

### FIXED CODE ###

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

if a+b==c or b+c==a or c+a==b:
  print("Yes")
else:
  print("No")
n=input()
maxn=0
maxcount=0
 
for i in range(n+1):
  count=0
  while n%2==0:
    n=n/2
    count+=1
  if maxcount < count:
    maxn=i
    maxcount=count
 
print(maxn)

### FIXED CODE ###

n=int(input())
i=1
while i*2<=n:
  i*=2
print(i)
#include <stdio.h>

int main(){
  int R, G, B, N, ans = 0;
  scanf("%d %d %d %d", &R, &G, &B, &N);
  for(int i = 0; i <= 3000; i++){
    for(int j = 0; j <= 3000; j++){
      int v = R * i + G * j;
      if(N >= v && (N - v) % B == 0) ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}


### FIXED CODE ###

R, G, B, N = map(int, input().split())
ans = 0

for r in range(min(3000, 3000 // R) + 1):
    if R * r <= N:
        for g in range(min(3000, 3000 // G) + 1):
            v = R * r + G * g
            if N >= v and (N - v) % B == 0:
                ans += 1

print(ans)
import numpy as np 
 
N,K = map(int, input().split())
 
A_array = np.array(list(map(int, input().split())))
 
if K > 1000:
   K = 1000

for k in range(K):
 
    B_list = list()
 
    inf_array = np.array(range(N)) + 0.5 - A_array
    sup_array = np.array(range(N)) + 1.5 + A_array
        
    B_list = [((inf_array <= m+1) & (m+1<=sup_array)).sum() for m in range(N)]
 
    A_array = np.array(B_list)
    
print(' '.join(map(str, A_array)))    

### FIXED CODE ###

S = input()
nick = str()
for n in range(3):
  nick = nick + S[n]    

print(nick)
s = print()
if s == "ABC":
    print("ARC")
else s == "ARC":
    print("ABC")


### FIXED CODE ###

s = input()
if s == "ABC":
    print("ARC")
else:
    print("ABC")
length=int(input())
list=list(map(int,input().split()))
list.sort()
max=list[-1]
dp=[True]*(max+1)
ret=0
for num in list:
    if dp[num]:
        if list.count(num)!=1:
            dp[num]=False
        else:
            ret=ret+1
            i=2
            num2=num*i
            while num2<max+1:
                if num2 in list:
                    dp[num2]=False
                i=i+1
                num2=num*i
print(ret)

### FIXED CODE ###

input=input()
x = input.split()
for i in range(5):
    if(x[i]=='0'):
        print(i+1)
        break
n,k=map(int,input().split())
a=list(map(int,input().split()))

lst=[0]*35


for i in a:
  for j in range(35):
    if (i>>j)%2==1:
      lst[j]+=1

k=bin(k)[2:]

dp=[[0]*2 for i in range(len(k)+1)]


for i in range(len(k)):
  if k[i]=='1':
    dp[i+1][0]=dp[i][0]+(n-lst[len(k)-i-1]*2)*2**(len(k)-i-1)
    dp[i+1][1]=dp[i][0]
  else:
    dp[i+1][0]=dp[i][0]

  if i==0:
      continue
  
  dp[i+1][1]=max(dp[i+1][1],dp[i][1],dp[i][1]+(n-lst[len(k)-i-1]*2)*2**(len(k)-i-1))


print(sum(a)+max(dp[-1][0],dp[-1][1]))

### FIXED CODE ###

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

lst=[0]*50


for i in a:
  for j in range(50):
    if (i>>j)%2==1:
      lst[j]+=1

k=bin(k)[2:]

dp=[[0]*2 for i in range(len(k)+1)]


for i in range(len(k)):
  if k[i]=='1':
    dp[i+1][0]=dp[i][0]+(n-lst[len(k)-i-1]*2)*(2**(len(k)-i-1))
    dp[i+1][1]=dp[i][0]
  else:
    dp[i+1][0]=dp[i][0]

  if i==0:
      continue
  
  dp[i+1][1]=max(dp[i+1][1],dp[i][1],dp[i][1]+(n-lst[len(k)-i-1]*2)*(2**(len(k)-i-1)))


print(sum(a)+max(dp[-1][0],dp[-1][1]))
a, b, c, d = map(int, input().split())
x = x1 - x2
y = y1 - y2
print(c - y, d + x, a - y, b + x)

### FIXED CODE ###

a, b, c, d = map(int, input().split())
x = c - a
y = d - b
print(c - y, d + x, a - y, b + x)
import math
n=int(input())
a=list(map(int,input().split()))

ra=list(reversed(a))

left=[]
right=[]
right.append(ra[0])
left.append(a[0])

if n>2:
  left.append(math.gcd(a[0],a[1]))
  for i in range(2,n-1):
    k=math.gcd(k,a[i])
    left.append(k)

  right.append(math.gcd(ra[0],ra[1]))
  for i in range(2,n-1):
    k=math.gcd(k,ra[i])
    right.append(k)

  ans=[right[-1]]
  for i in range(1,n-1):
    ans.append(math.gcd(left[i-1],right[len(left)-i-1]))
  ans.append(left[-1])
  print(max(ans))
else:
  print(max(ra[0],a[0]))

### FIXED CODE ###

import math
n=int(input())
a = list(map(int,input().split()))
a.sort()
lr=[0]*n
rl=[0]*n

for i in range(n):
  if i==0:
    g=a[0]
    lr[0]=g
  else:
    g=math.gcd(a[i],g)
    lr[i]=g
    
for i in range(n-1,0,-1):
  if n-1==i:
    g=a[n-1]
    rl[n-1]=g
  else:
    g=math.gcd(a[i],g)
    rl[i]=g  
hantei=0
ans=0
#print(lr)
#print(rl)
for i in range(n):
  if i==0:
    hantei=rl[1]
  elif i==n-1:
    hantei=lr[n-2]
  else:
    hantei=math.gcd(lr[i-1],rl[i+1])
  if ans<=hantei:
    ans=hantei
    
print(ans)
# -*- coding: utf-8 -*-
from scipy.misc import comb
import numpy as np

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

mod = int(10 ** 9 + 7)

for i in range(1, k + 1):
    if i > n - k + 1:
        print(0)
    else:
        print(int(np.ceil(comb(k - 1, i - 1))) * int(np.ceil(comb(n - k + 1, i))) % mod)

### FIXED CODE ###

# -*- coding: utf-8 -*-
n, k = map(int, input().split())

mod = int(10 ** 9 + 7)


def comb(n, k):
    res = 1
    for i in range(k):
        res *= n - i
    for i in range(k):
        res //= k - i
    return res

for i in range(1, k + 1):
    if i > n - k + 1:
        print(0)
    else:
        print(comb(k - 1, i - 1) * comb(n - k + 1, i) % mod)
def stringconcant(S,T):
    a = S
    b = T
    c = a+b
    return c

S= input()
T= input()
a = stringconcant(S,T)
print(a)

### FIXED CODE ###

str1 , str2 = input().split(" ")
str3 = str2+str1
print(str3)
import math

a, b, x = map(int, input().split())
maxv = a**2 * b
if x >= maxv / 2:
    t = 2*b - (2 * x) / a**2
    tan = a / t
    print(90 - math.degrees(math.atan(tan)))
else:
    t = 2*x / (a * b)
    tan = 1 / (b / t)
    print(90 - math.degrees(math.atan(tan)))

### FIXED CODE ###

import math
import sys

a, b, x = map(int, input().split())
maxv = a**2 * b

if maxv == x:
    print(0)
    sys.exit()

if x >= maxv / 2:
    t = 2*b - (2 * x) / a**2
    tan = a / t
    print(90 - math.degrees(math.atan(tan)))
else:
    t = 2*x / (a * b)
    tan = 1 / (b / t)
    print(90 - math.degrees(math.atan(tan)))
a, b = map(int, input().split())
if (a*b%2):
	printf("Even")
else:
	printf("Odd")

### FIXED CODE ###

a, b = map(int, input().split())
if (a*b%2):
	print("Odd")
else:
	print("Even")
import sys
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    N = int(inputs[0])
    [T, A] = string_to_int(inputs[1])
    H = string_to_int(inputs[2])

    min_diff = -1
    min_diff_i = -1
    for i, h in enumerate(H):
        t = T - h * 0.006
        diff = abs(A-t)
        if min_diff == -1 or diff < min_diff:
            min_diff = diff
            min_diff_i = i
    return min_diff_i


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


### FIXED CODE ###

import sys
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    N = int(inputs[0])
    [T, A] = string_to_int(inputs[1])
    H = string_to_int(inputs[2])

    min_diff = -1
    min_diff_i = -1
    for i, h in enumerate(H):
        t = T - h * 0.006
        diff = abs(A-t)
        if min_diff == -1 or diff < min_diff:
            min_diff = diff
            min_diff_i = i
    return min_diff_i + 1


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(3))
    print(ret)
import math
def lcm(a, b):
  return a * b / gcd(a, b)

A, B = map(int,input().split())
print(lcm(A,B))

### FIXED CODE ###

from fractions import gcd
def lcm(a, b):
  return a * b / gcd(a, b)
 
A, B = map(int,input().split())
print(int(lcm(A,B)))
S = list(input())

if s[2] == s[3] and s[4] == s:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

S = list(input())

if S[2] == S[3] and S[4] == S[5]:
    print("Yes")
else:
    print("No")
n, m = map(int, input().split())
a = list(map(int, input().split()))

A = sum(a)
a.sort(reverse=True)

if a[m-1] >= A/(4*m):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

a, b, c = input().split()

a1 = b
b1 = a
a2 = c
c1 = a1

print(a2, b1, c1)
W, H, N = map(int, input().split())
X = []
Y = []
A = []
for i in range(N):
    x, y, a = map(int, input().split())
    X.append(x)
    Y.append(y)
    A.append(a)

## 長方形のマスを塗りつぶしていって残ったマス目を数えるイメージ
# 0: 白, 1: 黒
square = []
for i in range(H):
    horizonatlArea = []
    for j in range(W):
        horizonatlArea.append(0)
    square.append(horizonatlArea)

# Aの要素の番号に応じてsquareに1を埋めていく
for n in range(N):
    if A[n] == 1:
        for i in range(X[n]):
            for j in range(H):
                square[j][i] = 1
    elif A[n] == 2:
        for i in range(X[n], W):
            for j in range(H):
                square[j][i] = 1
    elif A[n] == 3:
        for i in range(W):
            for j in range(y[n]):
                square[j][i] = 1
    elif A[n] == 4:
        for i in range(W):
            for j in range(Y[n], H):
                square[j][i] = 1

# square内の要素の数を数えて出力
cnt = 0
for j in range(H):
    cnt += square[j].count(0)

print(cnt)

### FIXED CODE ###

W, H, N = map(int, input().split())
X = []
Y = []
A = []
for i in range(N):
    x, y, a = map(int, input().split())
    X.append(x)
    Y.append(y)
    A.append(a)

## 長方形のマスを塗りつぶしていって残ったマス目を数えるイメージ
# 0: 白, 1: 黒
square = []
for i in range(H):
    horizonatlArea = []
    for j in range(W):
        horizonatlArea.append(0)
    square.append(horizonatlArea)

# Aの要素の番号に応じてsquareに1を埋めていく
for n in range(N):
    if A[n] == 1:
        for i in range(X[n]):
            for j in range(H):
                square[j][i] = 1
    elif A[n] == 2:
        for i in range(X[n], W):
            for j in range(H):
                square[j][i] = 1
    elif A[n] == 3:
        for i in range(W):
            for j in range(Y[n]):
                square[j][i] = 1
    elif A[n] == 4:
        for i in range(W):
            for j in range(Y[n], H):
                square[j][i] = 1

# square内の要素の数を数えて出力
cnt = 0
for j in range(H):
    cnt += square[j].count(0)

print(cnt)
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = input()
S = raw_input.split()
for i in range(N):
	if S[i] == 'Y':
		print('Four')
		N = -1
		break
if N == -1:
	print('Three')

### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = input()
S = raw_input().split()
for i in range(N):
	if S[i] == 'Y':
		print('Four')
		N = -1
		break
if N > -1:
	print('Three')
i=R*3.1415*2
return i

### FIXED CODE ###

R=int(input())
i=R*6.283184
print(i)
import sys
import math
from collections import deque
import copy

N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]
INF = 10 ** 9 + 7
dp = [[INF for _ in range(N * 300)] for _ in range(N)]

for i in range(wv[0][1]):
    dp[0][i] = wv[0][0]
for i in range(1, N):
    for l in range(N * 300):
        if l - wv[i - 1][1] >= 0:
            dp[i][l] = min(dp[i - 1][l], dp[i - 1][l - wv[i][1]] + wv[i][0])
        else:
            dp[i][l] = min(dp[i - 1][l], wv[i][0])
for i in range(N * 300 - 1):
    if dp[-1][i] <= W < dp[-1][i + 1]:
        print(i+1)
        break


### FIXED CODE ###

import sys
import math
from collections import deque
import copy

INF = 10 ** 9 + 7
N, W = map(int, input().split())
weight = []
value = []
for i in range(N):
    tempW, tempV = map(int, input().split())
    weight.append(tempW)
    value.append(tempV)

dp = [[INF for _ in range(N * 1000 + 1)] for _ in range(N + 1)]
dp[0][0] = 0

for i in range(1, N + 1):
    for l in range(N * 1000 + 1):
        if l - value[i - 1] >= 0:
            dp[i][l] = min(dp[i - 1][l], dp[i - 1][l - value[i - 1]] + weight[i - 1])
        else:
            dp[i][l] = dp[i - 1][l]
for i in range(N * 1000 + 1):
    if dp[N][i] <= W:
        ans = i
print(ans)
A = int(input())
B = int(input())

0<=A<=100
0<=B<=100

if A>B*2:
  print(A-B*2)

else:
  print(0)


### FIXED CODE ###

A, B = [int(i) for i in input().split()]
0<=A<=100
0<=B<=100

if A>B*2:
  print(A-B*2)

else:
  print(0)