peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import math
n, d = map(int, input().split())
x = []
cnt = 0
for i in range(n):
    x.append(list(map(int, input().split())))
for i in range(n):
    for j in range(i+1, n):
        l = sum((x[i][k]-x[j][k])**2 for k in range(d))
        if math.sqrt(l).is_integer():
            cnt += 1
print(cnt)
# Judge status: Wrong Answer
a,b = map(int,input().split())
if a > 9 or b > 9:
  print(':(')
else:
  print('Yay!')
# Judge status: Wrong Answer
n = int(input())
a = int(input())

while n > 500:
    n -= 500

if n <= a:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]

for i in range(3):
  for j in range(3):
    if a[i][j] in b:
      a[i][j] == 0

c = [[a[0][0], a[1][1], a[2][2]], [a[0][2], a[1][1], a[2][0]]]

print("Yes" if any(i.count(0) == 3 for i in a) or any(i.count(0) == 3 or any(i.count(0) == 3 for i in c) for i in zip(*a)) else "No")
# Judge status: Wrong Answer
mod = 998244353
n = int(input())
d = list(map(int, input().split()))
d.sort()

if d[0] != 0:
    print(0)
    exit(0)

max_d = max(d)
cnt = [0] * (max_d + 1)

for num in d:
    cnt[num] += 1

if cnt[0] > 1:
    print(0)
    exit(0)

ans = 1

for i in range(1, len(cnt)):
    ans *= pow(cnt[i - 1], cnt[i], mod)

print(ans)
# Judge status: Accepted
X = input()
ans = len(X)
sc = 0
for x in X:
    if x == "S":
        sc += 1
    elif sc > 0:
        sc -= 1
        ans -= 2
print(ans)
# Judge status: Accepted
N = int(input())
S = input()
if N % 2 == 1:
    print('No')
else:
    if S[:N//2] == S[N//2:]:
        print('Yes')
    else:
        print('No')
# Judge status: Accepted
N,M=map(int,input().split())
A=list(map(lambda x:int(x)*(-1),input().split()))

from heapq import heappop,heappush,heapify

heapify(A)
for _ in range(M):
    a=heappop(A)*(-1)
    a//=2
    heappush(A,a*(-1))

print(sum(A)*(-1))
# Judge status: Accepted
input()
A=list(map(int,input().split()))
count=0
while all(a%2==0 for a in A):
  A=[a/2 for a in A]
  count+=1
print(count)
# Judge status: Wrong Answer
n,k = map(int,input().split())
r,s,p = map(int,input().split())

t = []
for l in list(input()):
    if l=='r':
        t.append(p)
    if l=='s':
        t.append(r)
    if l=='p':
        t.append(s)

for i in range(k,n):
    if t[i-k]==t[i]:
        t[i]=0
print(sum(t))
# Judge status: Accepted
s=list(input())
t=list(input())
ans=[]
for i in range(len(s)-len(t)+1):
  ct=0
  for j in range(len(t)):
    if s[i+j]!=t[j]:
      ct+=1
  ans.append(ct)
print(min(ans))
# Judge status: Accepted
ns = input()
N=int(ns)

C = [[ 0 for _ in range(10)] for _ in range(10)]
for i in range(N+1):
  si = str(i)
  s = int(si[0])
  e = int(si[-1])
  C[s][e] += 1
ans = 0
for i in range(1,10):
  for j in range(1,10):
#    print(i,j,C[i][j])
    ans += (C[i][j] * C[j][i])
print(ans)
# Judge status: Accepted
a,b=map(int, input().split())
print(int(a+b/2))
# Judge status: Accepted
x,k,d=map(int,input().split())
X=abs(x)
print(X-k*d if X>k*d else abs(X%d-(k-X//d)%2*d))
# Judge status: Accepted
import sys
input = sys.stdin.readline
N, A, B = map(int, input().split())
print(max(0, (N - 1) * B + A - ((N - 1) * A + B) + 1))
# Judge status: Accepted
import math
H,A=map(int, input().split())
print(math.ceil(H/A))
# Judge status: Accepted
S = input()

ANS = ['hi', 'hihi', 'hihihi', 'hihihihi', 'hihihihihi']
if S in ANS:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
#答えは合ってるがWAにならない

C1 = input()
C2 = input()

C = list(C1)
D = list(C2)
D.reverse()

if C == D:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
n = int(input())
for i in range(1, n + 1):
    cnt = 0
    for x in range(1, 33):
        for y in range(1, 33):
            for z in range(1, 33):
                #if x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x == i:
                if (x+y+z)**2 - (x*y + y*z + z*x) == i:
                    cnt += 1
    print(cnt)
# Judge status: Accepted
print("Christmas"+" Eve"*(25-int(input())))
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))

b=[0]*n

for i in range(n-1,-1,-1):
    if not sum(b[i:n:i+1]) %2 and a[i]==1:
        b[i] = 1 

print(sum(b))
print(" ".join([str(i)  for i in b if i== 1]))
# Judge status: Accepted
import bisect, collections, copy, heapq, itertools, math, numpy, string
import sys
from bisect import bisect_left, bisect_right, insort
from collections import deque
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def MS(): return map(str, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
# N = I()
# A = [LI() for _ in range(N)]

import bisect


x,y = MI()
if y % 2 ==0 and 2 * x <= y <= 4*x:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
print("EOvdedn"[eval(input().replace(" ","*"))%2::2])
# Judge status: Wrong Answer


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
  
def main():
  mod = 10**9 +7
  n = int(input())
  ls = list(map(int,input().split()))
  
  t = 1
  for a in ls:
    t = gcd(t,a)
  
  ans = 0
  for a in ls:
    ans = (ans + t//a) % mod 
  print(ans)
  
if __name__ == '__main__':
  main()
# Judge status: Accepted
X, Y, Z = map(int, input().split())
print("{} {} {}".format(Z, X, Y))
# Judge status: Accepted
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
 
N = int(input())
A = [int(x) for x in input().split()]
cnt = [0] * N
for i in range(N-1):
    cnt[A[i]-1] += 1
for i in range(N):
    print(cnt[i])
# Judge status: Accepted
a,b,c,d=map(int,input().split())
A=""
for i in range(c-a):
  A=A+"R"
for i in range(d-b):
  A=A+"U"
for i in range(c-a):
  A=A+"L"
for i in range(d-b+1):
  A=A+"D"
for i in range(c-a+1):
  A=A+"R"
for i in range(d-b+1):
  A=A+"U"
A=A+"LU"
for i in range(c-a+1):
  A=A+"L"
for i in range(d-b+1):
  A=A+"D"
A=A+"R"
print(A)
# Judge status: Accepted
import sys
input = sys.stdin.readline


def read():
    N, A, B = map(int, input().strip().split())
    return N, A, B


def solve(N, A, B):
    low = (N-1) * A + B - 1
    high = A + (N-1) * B
    return max(high - low, 0)


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))
# Judge status: Accepted
x=int(input())
if x ==0:
  print(1)
if x ==1:
  print(0)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

dp = [0]*n
dp[0] = 1000

for i in range(1, n):
    dp[i] = dp[i-1]
    for j in range(i):
        s = dp[j] // a[j]
        m = dp[j] + (a[i] - a[j]) * s
        dp[i] = max(dp[i], m)

print(dp[n-1])
# Judge status: Wrong Answer
n,m = map(int,input().split())
x = [int(i) for i in input().split()]
x.sort()
memo = []
for i in range(m-1):
    memo.append(x[i+1]-x[i])
memo.sort()
print(sum(memo[:m-n]))
# Judge status: Accepted
n,l = map(int, input().split())
s = [input() for i in range(n)]
s.sort()
print("".join(s))
# Judge status: Wrong Answer
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
def main():
    n=int(input())
    D=[int(_) for _ in input().split()]
    dc=Counter(D)
    dci=list(dc.items())
    dci.sort()
    mod,ans=998244353,1
    if D[0]!=0:
        print(0)
        sys.exit()

    for i,dcii in enumerate(dci):
        if i>1:
            ans*=dci[i-1][1]**dci[i][1]%mod
    print(ans)

if __name__=='__main__':
    main()
# Judge status: Wrong Answer
N = int(input())
A = [int(i) for i in input().split()]
B = [i for i in A]
while len(set(B)) != 1:
    B = [B[i] ^ B[(i+1)%N] for i in range(N)]
print(" ".join(map(str, [A[i]^B[i] for i in range(N)])))
# Judge status: Wrong Answer
n,a,b=map(int,input().split())

count=0

for i in range(n+1):
    if a<=sum(map(int,str(i)))<=b:
        count+=1

print(count)
# Judge status: Accepted

from collections import defaultdict


def prime_factor(n):
    d = defaultdict(int)
    for i in range(2, n + 1):
        if i * i > n:
            break

        while n % i == 0:
            d[i] += 1
            n //= i

    if n != 1:
        d[n] += 1

    return d


A, B = map(int, input().split())
prime_a = prime_factor(A)
prime_b = prime_factor(B)
print(len(set(prime_a) & set(prime_b)) + 1)
# Judge status: Accepted
n, m = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(m)]
for i in range(1000):
    i = str(i)
    if len(i) != n:
        continue
    for [x, y] in lst:
        if i[x-1] != str(y):
            break
    else: 
        print(i)
        exit()

print(-1)
# Judge status: Wrong Answer
import collections
N,K = map(int,input().split())
N_List = list(map(int,input().split()))

Chou_List = collections.Counter(N_List)
if len(Chou_List) <= K:
    print(0)
else:
    Chou_List = list(Chou_List.values())
    print(sum(Chou_List[K:]))
# Judge status: Accepted
import itertools
N = int(input())
L = list(map(int, input().split()))
count =0
for v in itertools.combinations(L, 3):
    a=v[0]
    b=v[1]
    c=v[2]
    if a+b> c and b+c >a and c+a>b:
        if a!=b and b!=c and c!=a:
            count+=1

print(count)
# Judge status: Accepted
import math

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

n=int(input())
t=[int(input()) for i in range(n)]

LCM=t[0]
for i in range(1,n):
    LCM=lcm(LCM,t[i])

print(LCM)
# Judge status: Accepted
import collections

_, *a = map(int, open(0).read().split())
c=collections.Counter(a)
tmp=[]
for k,v in c.items():
    if v>3:
        tmp.append(k)
    if v>1:
        tmp.append(k)
tmp.sort()
print(tmp[-1]*tmp[-2] if len(tmp) >1 else 0)
# Judge status: Accepted
in_1 = input()
in_2 = input()

N = int(in_1)
a = in_2.split()

cnt = 0
for i, x in enumerate(a):
    if i % 2 == 0 and int(x) % 2 == 1:
        cnt += 1
    
print(cnt)
# Judge status: Accepted
s=int(input())
dp=[0]*2005
dp[0]=1

dp[3]=1
dp[4]=1
dp[5]=1
mod=1e9+7
for i in range(6,2004):
    dp[i]=dp[i-1]+dp[i-3]
    dp[i]%=mod

print(int(dp[s]))
# Judge status: Accepted
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
total = sum(a)
ans = 0
if x == total:
    ans = n
elif x > total:
    ans = n - 1
else:
    for v in a:
        x -= v
        if x < 0:
            break
        ans += 1
print(ans)
# Judge status: Wrong Answer
Ar =list(map(int,input().split()))

if Ar[0]>=Ar[1]:
  A=Ar[0]
  B=Ar[1]
else:
  A=Ar[1]
  B=Ar[0]
print(A,B)

r=None
while r!=0:
  r = (A%B)
  A = B
  B = r

Ans=int(Ar[0]*Ar[1]/A)
print(Ans)
# Judge status: Accepted
abc = list(map(int,input().split()))
print("YES" if sum(abc) == 17 and abc.count(5) else "NO")
# Judge status: Wrong Answer
def main():
    N = int(input())
    switches = [int(input()) for _ in range(N)]

    count = 0
    cur   = 0
    nxt   = 0

    for i in range(2*N):
        count += 1

        if switches[cur] == 2:
            print(count)
            break

        nxt = switches[cur] - 1

        if switches[nxt] - 1 == cur:
            print(-1)
            break

        cur = nxt

main()
# Judge status: Accepted
import math
a, b, x = map(int, input().split())
A, B = a**2, b**2
print(math.degrees(math.asin((B / ((2 * x / (a * b))**2 + B))**0.5) if 2 * x <=
                   a * a * b else math.acos((A / ((2 * (a * a * b - x) / A)**2 + A))**0.5)))
# Judge status: Accepted
N,K = map(int,input().split())
H = list(map(int,input().split()))
 
def main(N,K,H):
    dp = [0]*N
    for i in range(1,N):
        L = [dp[j]+abs(H[i]-H[j]) for j in range(max(0,i-K),i)]
        dp[i] = min(L)
    print(dp[-1])
main(N,K,H)
# Judge status: Wrong Answer
from sys import stdin
#from collections import deque
#from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin
def ii(): return int(stdin.readline())
def fi(): return float(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def fmi(): return map(float, stdin.readline().split())
def li(): return list(mi())
def lsi():
    x=list(stdin.readline())
    x.pop()
    return x
def si(): return stdin.readline()
############# CODE STARTS HERE #############
n=ii()
a, b, c=mi()
for _ in range(n-1):
    x, y, z=mi()
    a+=max(y, z)
    b+=max(x, z)
    c+=max(y, x)
print(max(a, b, c))
# Judge status: Accepted
import sys
sys.setrecursionlimit(10 ** 7)
ans = []
def solve(x, n, s):
    if len(s) == n:
        ans.append(s)
        return
    for i in range(x+2):
        solve(max(x, i), n, s + chr(ord("a") + i))

def main():
    n = int(input())
    solve(0, n, "a")
    ans.sort()
    for s in ans:
        print(s)

if __name__ == "__main__":
    main()
# Judge status: Accepted
a, b = map(int, input().split())
if (a + b) % 2 == 0:
    print((a + b) // 2)
else:
    print('IMPOSSIBLE')
# Judge status: Accepted
n,r=map(int,input().split())
if n>=10:
    print(r)
else:
    print(r+1000-100*n)
# Judge status: Accepted
A,B,C = map(int, input().split())
print("YNeos"[(B-C)*(C-A)<0::2])
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline
from itertools import chain

def readlines(*abc):
    for n in abc:
        yield list(map(int, input().split()))[:n]

def main():
    x, y, a, b, c = map(int, input().split())
    apples = sorted(chain(*readlines(a,b,c)), reverse=True)
    print(sum(apples[:x+y]))


main()
# Judge status: Accepted
a, b, x = map(int, input().split())

def f (n):
  if n == -1:
    return 0
  else:
    return n // x + 1

print(f(b) - f(a-1))
# Judge status: Accepted
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))

sa = sorted(a, reverse=True)

for i in range(n):
    if sa[0] == a[i]:
        print(sa[1])
    else:
        print(sa[0])
# Judge status: Accepted
a, b, x = map(int, input().split())

ans = b // x - (a - 1) // x
print(ans)
# Judge status: Accepted
n,m=map(int,input().split())
MOD=10**9+7
ans = 1
if abs(n-m) > 1:
  print(0)
  exit()
else:
  if abs(n-m) == 0:
    for i in range(1,n+1):
      ans = ans*i%MOD
    for i in range(1,m+1):
      ans = ans*i%MOD
    ans = ans*2%MOD
  else:
    for i in range(1,n+1):
      ans = ans*i%MOD
    for i in range(1,m+1):
      ans = ans*i%MOD
print(ans)
# Judge status: Accepted
a, b, x = map(int, input().split())
if a <= x <= a + b:
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
N, M = map(int, input().split())
arr = []
ans = [0] * N
for i in range(M):
    s, c = map(int, input().split())
    print(s, c)
    if s == 1 and c == 0 and N != 1:
        print(-1)
        exit(0)
    if s in arr and ans[s-1] != c:
        print(-1)
        exit(0)
    arr.append(s)
    ans[s-1] = c
print("".join([str(i) for i in ans]))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
a.sort()
res = a[0]
ma = a[-1]
for i in range(1, n-1):
    if min(a[i], ma-a[i]) >= min(res, ma-res):
        res = a[i]
print(ma, res)
# Judge status: Accepted
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり


N,K = MI()
A = LI()

from itertools import accumulate

for _ in range(min(K,41)):
    B = [0]*(N+1)
    for i in range(N):
        a = A[i]
        B[max(i-a,0)] += 1
        B[min(N,i+a+1)] -= 1
    C = list(accumulate(B))
    A = C

print(*[A[i] for i in range(N)])
# Judge status: Accepted
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

a,b = map(int,input().split())
print(a*b)
# Judge status: Accepted
s = "abcdefghijklmnopqrstuvwxyz"
C = input()
for i in range(len(s)):
  if(s[i] == C):
    print(s[i+1])
# Judge status: Accepted
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 19 20:18:57 2020

@author: liang
"""

N = int(input())
S = input()

tmp = 0

for i in range(1,N):
    if S[i] == "E":
        tmp += 1

ans = 10**6
for i in range(N):
    if ans > tmp:
        ans = tmp
    if i == N-1:
        break
    if S[i] == "W":
        tmp += 1
    if S[i+1] == "E":
        tmp -= 1
    #print(tmp)
        
print(ans)
# Judge status: Accepted
# 139 B  # nxt try

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

temp = 1
while temp < b:
    temp -= 1
    temp += a
    ans += 1

print(ans)
# Judge status: Accepted
n = int(input())
s = input()
x = 0
ans = 0

for i in range(len(s)):
    if(s[i] == 'I'):
        x += 1
        if(x > ans):
            ans = x
    else:
        x -= 1
print(ans)
# Judge status: Accepted
n,l=map(int,input().split())
if l>=0: print(sum(l+i for i in range(1,n)))
elif l+n-1>=0: print(sum(l+i for i in range(n)))
else: print(sum(l+i for i in range(n-1)))
# Judge status: Accepted
N = int(input())
mod = 10**9 + 7
if N < 2:
    print(0)
    exit()
all = pow(10, N, mod)

sabun = pow(9, N, mod) * 2 - pow(8, N, mod)
ans = ((all % mod) - sabun) % mod
print(ans)
# Judge status: Accepted
n=int(input())
cnt=n//100
if n%100<=cnt*5:
  print(1)
else:
  print(0)
# Judge status: Wrong Answer
b = input()
c =b.split(" ")
print(int(c[0])*c[1])
# Judge status: Wrong Answer
HK = list(map(int, input().split()))
M = list(map(int, input().split()))

M.sort(reverse=True)

k = HK[1]

while k > 0 | len(M) > 0:
    M.pop(0)
    k -= 1

damage = 0
for i in range(len(M)):
    damage += M[i]

print(damage)
# Judge status: Accepted
n, k = map(int, input().split())
S = input()

s = S[:k-1] + S[k-1].lower() + S[k:]
print(s)
# Judge status: Accepted
a, b, c, d = map(int, input().split())
al = set([i for i in range(a, b)])
bo = set([i for i in range(c, d)])
print(len(al&bo))
# Judge status: Accepted
#B - Good Distance
import math
N,D = map(int,input().split())
X = []
for _ in range(N):
    Xi = list(map(int,input().split()))
    X.append(Xi)
count = 0
for i in range(N):
    for k in range(i+1,N):
        D_sqrt = 0
        for j in range(D):
            D_sqrt += (X[i][j] - X[k][j])**2
        D_ans = math.sqrt(D_sqrt)
        if D_ans.is_integer():#float型が整数か判定するメソッド
            count += 1
print(count)
# Judge status: Wrong Answer
a,b = (int(x) for x in input().split())
if a > b:
  b = str(b)
  print(b * a)
else:
  a = str(a)
  print(a * b)
# Judge status: Accepted
n = int(input())
tasks=[]
for i in range(n):
    a,b = map(int, input().split())
    tasks.append([a, b])
tasks.sort(key=lambda x:x[1])

current_time = 0
for task in tasks:
    current_time+=task[0]
    if current_time>task[1]:
        print("No")
        exit()

print("Yes")
# Judge status: Accepted
n=int(input())
ans=0
A=sorted(list(map(int,input().split())))[::-1]
for i in range(n):
  if i % 2 == 0:
    ans += A[i]
  else:
    ans -= A[i]
print(ans)
# Judge status: Wrong Answer
s = input()
t = set(s)
print("yes" if len(s) == set(t) else "no")
# Judge status: Wrong Answer
N = int(input('number->'))
a = N % 10
if a == 2 or 4 or 5 or 7 or 9:
  print('hon')
elif a == 0 or 1 or 6 or 8:
  print('pon')
else:
  print('bon')
# Judge status: Accepted
S = list(input().split("/"))
if int(S[0]) > 2019:
    print("TBD")
else:
    if int(S[1]) > 4:
        print("TBD")
    else:
        print("Heisei")
# Judge status: Accepted
c=int(input().replace(" ",""))
print("Yes" if c==int(c**.5)**2 else "No")
# Judge status: Accepted
import math
import collections
import fractions
import itertools
import functools
import operator

def solve():
    x = int(input())
    dp = [0 for _ in range(x+106)]
    dp[0] = 1
    for i in range(x):
        if dp[i] == 1:
            for j in range(100, 106):
                dp[i+j] = 1
    print(dp[x])
    return 0

if __name__ == "__main__":
    solve()
# Judge status: Accepted
x,k,d=map(int, input().split())
x=abs(x)
if x/k >= d:
  print(x-d*k)
elif (k-int(x/d))%2==0:
  print(abs(x-int(x/d)*d))
else:
  print(abs(x-int(x/d)*d-d))
# Judge status: Accepted
n,d = map(int,input().split())
if n%(d*2+1) == 0:
    print(int(n/(d*2+1)))
    
else:
    print(int(n//(d*2+1))+1)
# Judge status: Accepted
import math

N=int(input())
NP=list(range(N+1)[1:])
NQ=list(range(N+1)[1:])
P=list(map(int,input().split()))
Q=list(map(int,input().split()))

a=0
b=0

for n in range(N):
    a+=(math.factorial(N-n-1))*NP.index(P[n])
    b+=(math.factorial(N-n-1))*NQ.index(Q[n])
    NP.pop(NP.index(P[n]))
    NQ.pop(NQ.index(Q[n]))

print(abs(a-b))
# Judge status: Accepted
S = input()

S = S.replace("eraser","")
S = S.replace("erase","")
S = S.replace("dreamer","")
S = S.replace("dream","")

if len(S) == 0:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
from math import ceil
N, D = map(int, input().split())
print(ceil(N / (D * 2 + 1)))
# Judge status: Accepted
import sys

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))

a,b = get_ints()
A = str(b)*a
B = str(a)*b
print(min(A,B))
# Judge status: Wrong Answer
N,x=map(int,input().split())
A=[int(x) for x in input().split()]
ans=0

for i in range(1,N):
  if A[i-1]+A[i]>x:
    ans +=A[i-1]+A[i]-x
    A[i] -=A[i-1]+A[i]-x
print(ans)
# Judge status: Wrong Answer

n = int(input())
k = int(input())
x = int(input())
y = int(input())

sum = 0
for i in range( n ):
    if i ==0 :
        sum += x
    else :
        sum += y
print(sum)
# Judge status: Wrong Answer
n = int(input())

works = list()
for num in range(n):
    a = list(map(int, input().split()))
    works.append(a)

works.sort(key = lambda x :x[1])

time = 0

counter = 0

for row in works:
    time += row[0]
    counter += 1
    if time >= row[1]:
        print("No")
        break
if counter == len(works):
	print("Yes")
# Judge status: Wrong Answer
H = int(input())
W = int(input())
N = int(input())

L = max(H,W)

print((N / L) if N % L == 0 else N // L + 1 )
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

sumA = sum(A)
half = sumA / 2

r = 0.0

t1 = 0.0
t2 = 0.0
for a in A:
    t2 = t1
    t1 += a

    if t1 >= half:
        r = min(abs(half - t1), abs(half - t2))
        break

print(int(r * 2))
# Judge status: Accepted
a=int(input())
s=input()
if a<3200:
	print("red")
else:
	print(s)
# Judge status: Accepted
n = int(input())
aaa = list(map(int, input().split()))
odd = 0
even = 0
even4 = 0
for a in aaa:
    if a % 4 == 0:
        even4 += 1
    elif a % 2 == 0:
        even += 1
    else:
        odd += 1
if odd == 0:
    print('Yes')
else:
    if even4 == 0:
        print('No')
    else:
        if even == 0:
            print('Yes' if even4 >= odd - 1 else 'No')
        else:
            print('Yes' if even4 >= odd else 'No')
# Judge status: Accepted
N = int(input())
print(800*N - 200*(N//15))
# Judge status: Wrong Answer
print('A'+str(input())[9]+'C')
# Judge status: Accepted
# import sys
# sys.setrecursionlimit(10**5)
# from collections import defaultdict
geta = lambda fn: list(map(fn, input().split()))
gete = lambda fn: fn(input())

def main():
    N = gete(int)
    cur = [0]*3 
    for _ in range(N):
        a = geta(int)
        cur = [max(cur[j-1], cur[j-2]) + a[j] for j in range(3)] 

    print(max(cur))

if __name__ == "__main__":
    main()
# Judge status: Accepted
import math
import numpy as np

N = int(input())
root_N = int(math.floor(math.sqrt(N))+1)

res = []
for a in range(1, root_N):
  if (N/a).is_integer():
    res.append(a + N/a - 2)

res = np.array(res)
print(int(res.min()))
# Judge status: Wrong Answer
n, a, b = map(int, input().split())

if a > b:
    print(0)
elif a != b and n == 1:
    print(0)
elif a == b and n != 1:
    print(0)
else:
    print((b * (n-1) + a) - (a * (n-1) + b) + 1)
# Judge status: Accepted
n,k= map(int,input().split())
h=list(map(int,input().split()))

x=[0]*n
for i in range(k):
    a,b = map(int, input().split())
    if h[a-1]>=h[b-1]:
      x[b-1] +=1
    if h[b-1]>=h[a-1]:
      x[a-1] +=1
print(x.count(0))
# Judge status: Accepted
n=int(input())
while(n>0): n-=1000
print(abs(n))
# Judge status: Accepted
N = int(input())
d = {0:0,1:0,2:0}
for a in list(map(int,input().split())):
  if a%2 == 0 :
    if a%4 == 0 :
      d[2]+=1
    else:
      d[1]+=1
  else:
    d[0]+=1

## 0と4だけの時はこれでok
if d[1] == 0:
  if d[0] <= d[2]+1:
    print("Yes")
  else:
    print("No")
else:
  if d[0] + (1 if d[1]>0 else 0 ) <= d[2]+1:
    print("Yes")
  else:
    print("No")
# Judge status: Accepted
n, k = list(map(int, input().split()))
s = input()

ans = s[:k-1] + s[k-1].swapcase() + s[k:]

print(ans)