Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

N, C= map(int,input().split())
XV = sorted([list(map(int,input().split())) for _ in range(N)])
acmXV = []
dbl_acmXV = []
for i, xv in enumerate(XV):
  x,v = xv
  if i == 0:
    acmXV.append(v-x)
    dbl_acmXV.append(v-x*2)
  else:
    acmXV.append(v-(x-XV[i-1][0])+acmXV[i-1])
    dbl_acmXV.append(v-(x-XV[i-1][0])*2+dbl_acmXV[i-1])

acmXV_rev = [0 for _ in range(N)]
dbl_acmXV_rev = [0 for _ in range(N)]
for i in range(N-1, -1, -1):
  x,v = XV[i]
  if i == N-1:
    acmXV_rev[i] = v-(C-x)
    dbl_acmXV_rev[i] = v-(C-x)*2
  else:
    acmXV_rev[i] = (v-(XV[i+1][0]-XV[i][0])+acmXV_rev[i+1])
    dbl_acmXV_rev[i] = (v-(XV[i+1][0]-XV[i][0])*2+dbl_acmXV_rev[i+1])
    
ans = max(0,max(acmXV),max(acmXV_rev))
for i in range(N):
  for j in range(N-1,i,-1):
    #print(i,j,dbl_acmXV[i],acmXV_rev[N-1-j])
    ans = max(ans, dbl_acmXV[i]+acmXV_rev[j], acmXV[i]+dbl_acmXV_rev[j]) 
print(ans)

### FIXED CODE ###

import copy

N, C= map(int,input().split())
XV = sorted([list(map(int,input().split())) for _ in range(N)])
acmXV = []
dbl_acmXV = []

for i, xv in enumerate(XV):
  x,v = xv
  if i == 0:
    acmXV.append(v-x)
    dbl_acmXV.append(v-x*2)
  else:
    acmXV.append(v-(x-XV[i-1][0])+acmXV[i-1])
    dbl_acmXV.append(v-(x-XV[i-1][0])*2+dbl_acmXV[i-1])

acmXV_rev = [0 for _ in range(N)]
dbl_acmXV_rev = [0 for _ in range(N)]
for i in range(N-1, -1, -1):
  x,v = XV[i]
  if i == N-1:
    acmXV_rev[i] = v-(C-x)
    dbl_acmXV_rev[i] = v-(C-x)*2
  else:
    acmXV_rev[i] = (v-(XV[i+1][0]-XV[i][0])+acmXV_rev[i+1])
    dbl_acmXV_rev[i] = (v-(XV[i+1][0]-XV[i][0])*2+dbl_acmXV_rev[i+1])


max_acmXV_rev = copy.deepcopy(acmXV_rev)
max_dbl_acmXV_rev = copy.deepcopy(dbl_acmXV_rev)
for i in range(N-2,-1,-1):
  max_acmXV_rev[i] = max(max_acmXV_rev[i], max_acmXV_rev[i+1])
  max_dbl_acmXV_rev[i] = max(max_dbl_acmXV_rev[i],max_dbl_acmXV_rev[i+1])

ans = max(0,max(acmXV),max(acmXV_rev))
for i in range(N-1):
  ans = max(ans, dbl_acmXV[i]+max_acmXV_rev[i+1], acmXV[i]+max_dbl_acmXV_rev[i+1]) 
print(ans)
### BUGGY CODE ###

import math

N = int(input())

numbers_full = []
for _ in range(N):
  numbers_full.append(int(input()))

for i in range(N):
  numbers_minus1 = numbers_full.copy()
  del numbers_minus1[i]
  #print(numbers_full, numbers_minus1, str(max(numbers_minus1)))
  print(str(max(numbers_minus1)))

### FIXED CODE ###

N = int(input())
number_list = [int(input()) for _ in range(N)]

sorted_num = sorted(number_list)
number_max = sorted_num[-1]
number_second_max = sorted_num[-2]

if number_max == number_second_max:
  output_always_max = True
else:
  output_always_max = False

for number in number_list:
  if output_always_max:
    print(str(number_max))
  else:
    if number == number_max:
      print(str(number_second_max))
    else:
      print(str(number_max))
### BUGGY CODE ###

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

parent=dict()
An=set(A)
parecou=0

for i in An:
    f=A.count(i)
    parent[i]=f
    parecou+=int((f*(f-1)/2))



#print(parecou)
for i in range(N):
    anko=parent[A[i]]
    #print(parecou-int((anko*(anko-1)/2))+int(((anko-2)*(anko-1)/2)))
    print(parecou-anko+1)


### FIXED CODE ###

from collections import Counter
N=int(input())
A=list(map(int,input().split()))

parent=dict()
An=set(A)
parecou=0
aaa=Counter(A)
for i in aaa.values():
    parecou+=int((i*(i-1)/2))
"""
for i in An:
    f=A.count(i)
    parent[i]=f
    parecou+=int((f*(f-1)/2))
"""


#print(parecou)
for i in range(N):
    anko=aaa[A[i]]
    print(parecou-int((anko*(anko-1)/2))+int(((anko-2)*(anko-1)/2)))
    #print(parecou-anko+1)
### BUGGY CODE ###

import numpy as np

def dice():
    n, k = map(int, input().split())
    p = np.asarray(list(map(int, input().split())))
    pp = np.zeros(n)
    for i in range(n):
      pp[i] = p[i]*(p[i]+1)/(2*p[i])

    ans = 0
    for i in range(n-k+1):
        tmp = sum(pp[i:i+k])
        if ans < tmp:
            ans = tmp
    print(ans)

if __name__ == '__main__':
    dice()

### FIXED CODE ###

import numpy as np

def dice():
    n, k = map(int, input().split())
    p = np.asarray(list(map(int, input().split())))
    pp = np.zeros(n)
    for i in range(n):
      pp[i] = p[i]*(p[i]+1)/(2*p[i])
    ans = sum(pp[0:k]) 
    tmp = sum(pp[0:k])
    for i in range(1, n-k+1):
        tmp = tmp - pp[i-1] + pp[i+k-1]
        if ans < tmp:
            ans = tmp
    print(ans)

if __name__ == '__main__':
    dice()
### BUGGY CODE ###

n,k = [int(i) for i in input().split()]
data = [int(i) for i in input().split()]

d = 1
count = 0
loop = []
route = [1]
data_len = len(data)

while count < data_len:
    d = data[d-1]
    if d in route:
        loop = route[route.index(d):]
        break
    else:
        route.append(d)
    count += 1
if len(loop) > 0:
    loop_len = len(loop)
    a = len(route) - loop_len
    if k < a:
        print(route[k])
    else:
        print(loop[(k-a)%loop_len])
else:
    print(route[k])

### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
visited = [0]
for _ in range(n):
    now = a[visited[-1]]-1
    visited.append(now)

if k < n:
    print(visited[k]+1)
else:
    p = visited.index(visited[-1])
    loop = visited[::-1][1:].index(visited[-1])+1
    x = (k-p-1)%loop
    print(visited[p+x+1]+1)
### BUGGY CODE ###

from collections import deque

N = int(input())
EhasV = [set() for x in range(N)]
EE = [0] * (N-1)
for i in range(N-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    EE[i] = {a,b}
    EhasV[a].add(i)
    EhasV[b].add(i)

K = len(max(EhasV,key=len))
Vcolor = [set(range(1,K+1)) for x in range(N)]

Ecolor = [-1] * (N-1)

q = deque()
q.append(0)
i = 1
while i:
    v1 = q.pop()
    i -= 1
    for e in EhasV[v1]:
        if Ecolor[e] != -1:
            continue
        color = Vcolor[v1].pop()
        Ecolor[e] = color
        edgeside = EE[e]
        edgeside.discard(v1)
        v2 = edgeside.pop()
        Vcolor[v2].discard(color)
        q.append(v2)
        i += 1

print(K)
i = 0
while i < N - 1:
    print(Ecolor[i])
    i += 1

### FIXED CODE ###

from collections import deque

N = int(input())
EhasV = [set() for x in range(N)]
EhasVnums = [0] * N
EE = [0] * (N-1)
for i in range(N-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    EE[i] = {a,b}
    EhasV[a].add(i)
    EhasV[b].add(i)
    EhasVnums[a] += 1
    EhasVnums[b] += 1

K = len(max(EhasV,key=len))
Vcolor = [set(range(1,EhasVnums[x]+1)) for x in range(N)]
Ecolor = [-1] * (N-1)

q = deque()
q.append(0)
while q:
    v1 = q.pop()
    for e in EhasV[v1]:
        if Ecolor[e] != -1:
            continue
        color = Vcolor[v1].pop()
        Ecolor[e] = color
        edgeside = EE[e]
        edgeside.discard(v1)
        v2 = edgeside.pop()
        Vcolor[v2].discard(color)
        q.append(v2)

print(*([K]+Ecolor),sep='\n')
### BUGGY CODE ###


S = input()
s = S

before_len = 0
while True:
    s = s.replace('0011', '').replace('1100', '').replace('0101', '').replace('1010', '').replace('01', '').replace('10', '')
    lens = len(s)
    if before_len == lens:
        break

    before_len = lens


print(len(S) - len(s))

### FIXED CODE ###


S = input()
print(2 * min(S.count('0'), S.count('1')))
### BUGGY CODE ###

def factorial(n, p):
    ret = 1
    for i in range(n, 0, -1):
        ret *= i
        ret %= p
    return ret


def comb(n, r, p):
    r = min(r, n - r)
    a = factorial(r, p)
    b = factorial(n - r, p)
    ret = factorial(n, p) * pow(a, p - 2, p) * pow(b, p - 2, p) % p
    return ret


mod = 10 ** 9 + 7
n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
ans = 0
sum_min = 0
for i in range(n - k + 1):
    cnt = comb(n - 1 - i, k - 1, mod)
    sum_min += a[i] * cnt
    sum_min %= mod

a_rev = a[::-1]
sum_max = 0
for i in range(n - k + 1):
    cnt = comb(n - 1 - i, k - 1, mod)
    sum_max += a_rev[i] * cnt
    sum_max %= mod
ans = (sum_max - sum_min) % mod
print(ans)


### FIXED CODE ###

def cmb(n, r, p):
    if r < 0 or n < r:
        return 0
    r = min(r, n - r)
    return fact[n] * fact_inv[r] * fact_inv[n - r] % p


n, k = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
p = 10 ** 9 + 7
fact = [1, 1]  # fact[n] = (n! mod p)
fact_inv = [1, 1]  # fact_inv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # fact_invの計算用

for i in range(2, n + 1):
    fact.append(fact[-1] * i % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    fact_inv.append(fact_inv[-1] * inv[-1] % p)

i = 0
sum_max = 0
sum_min = 0
while n - i - 1 >= k - 1:
    cnt = cmb(n - i - 1, k - 1, p)
    sum_max += a[i] * cnt
    sum_min += a[n - i - 1] * cnt
    # print(i, a[i] * cnt, a[n - i - 1] * cnt)
    i += 1
ans = (sum_max - sum_min) % p
print(ans)
### BUGGY CODE ###

def readInt():
    return int(input())
def readList():
    return list(map(int,input().split()))
def readMap():
	return map(int,input().split())
def readStr():
    return input()
inf=float('inf')
mod = 10**9+7
import math
from itertools import permutations
def solve(N):
    return sum(find_factors(i) for i in range(1,N))

def find_factors(num):
    i=1
    count=0
    while i*i<=num:
        if num%i==0:
            count+=1
            if num//i!=i:
                count+=1
        i+=1
    return count
N=readInt()
print(solve(N))

### FIXED CODE ###

def readInt():
    return int(input())
def readList():
    return list(map(int,input().split()))
def readMap():
	return map(int,input().split())
def readStr():
    return input()
inf=float('inf')
mod = 10**9+7
import math
from itertools import permutations
def solve(N):
    count=0
    for i in range(1,N):
        count+=(N-1)//i
    return count

N=readInt()
print(solve(N))
### BUGGY CODE ###

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

cnt = [0] * N
for i in range(N):
    for j in range(i, N-1):
        if H[j] >= H[j+1]:
            cnt[i] +=1
        else:
            break

print(max(cnt))

### FIXED CODE ###

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

cnts = 0
cnt = [0] * N
for i in range(1, N):
    if H[i-1] >= H[i]:
        cnts +=1
    else :
        cnts = 0
    cnt[i] = cnts

print(max(cnt))
### BUGGY CODE ###

num=int(input())
i = list(map(int, input().split()))
ans=1
for n in range(num):
    ans = ans*i[n]
if ans > 10**18:
    ans=-1
print(ans)

### FIXED CODE ###

num=int(input())
i = list(map(int, input().split()))
if 0 in i:
    print(0)
else:
    ans=1
    for n in range(num):
        ans=ans*i[n]
        if ans > 10**18:
            ans=-1
            break
    print(ans)
### BUGGY CODE ###

from fractions import Fraction
import math

n = int(input())


ab = []
ba = []

a0 = 0
b0 = 0
ab0 = 0

for i in range(n):
    a, b = map(int, input().split())
    if a != 0 and b != 0:
        ab.append(Fraction(a, b))
        ba.append(Fraction(-b, a))
    elif a == 0 and b == 0:
        ab0 += 1
    elif a == 0 and b != 0:
        a0 += 1
    elif a != 0 and b == 0:
        b0 += 1


d_ab = dict()
d_ba = dict()

# d_done = dict()

for i in range(len(ab)):
    cur = ab[i]
    if cur in d_ab:
        d_ab[cur] += 1
    else:
        d_ab[cur] = 1

    cur = ba[i]
    if cur in d_ba:
        d_ba[cur] += 1
    else:
        d_ba[cur] = 1

mod = 1000000007
ans = 1

d_done = set()

for k, v in d_ab.items():
    x = v
    if k in d_ba:
        if k in d_done:
            continue
        else:
            y = d_ba[k]
            kake = 0
            kake += ((2**x) % mod + (2**y) % mod - 1)
            ans *= kake
            ans %= mod
            # d_done[Fraction(-k.denominator, k.numerator)] = 1
            d_done.add(Fraction(-k.denominator, k.numerator))
    else:
        kake = (2**x) % mod
        ans *= kake
        ans %= mod

ans *= ((2**a0) % mod+(2**b0) % mod-1)
ans %= mod

ans -= 1

ans += ab0
ans %= mod

print(ans)


### FIXED CODE ###

from fractions import Fraction
import math

n = int(input())


ab = []
ba = []

a0 = 0
b0 = 0
ab0 = 0


def irr(a, b):
    gcd = math.gcd(a, b)
    a = a // gcd
    b = b // gcd

    if b < 0:
        return (-a, -b)
    else:
        return (a, b)


for i in range(n):
    a, b = map(int, input().split())
    if a != 0 and b != 0:
        ab.append(irr(a, b))
        ba.append(irr(-b, a))
    elif a == 0 and b == 0:
        ab0 += 1
    elif a == 0 and b != 0:
        a0 += 1
    elif a != 0 and b == 0:
        b0 += 1


d_ab = dict()
d_ba = dict()

# d_done = dict()

for i in range(len(ab)):
    cur = ab[i]
    if cur in d_ab:
        d_ab[cur] += 1
    else:
        d_ab[cur] = 1

    cur = ba[i]
    if cur in d_ba:
        d_ba[cur] += 1
    else:
        d_ba[cur] = 1

mod = 1000000007
ans = 1

d_done = set()

for k, v in d_ab.items():
    x = v
    if k in d_ba:
        if k in d_done:
            continue
        else:
            y = d_ba[k]
            kake = 0
            kake += ((2**x) % mod + (2**y) % mod - 1)
            ans *= kake
            ans %= mod
            # d_done[Fraction(-k.denominator, k.numerator)] = 1
            d_done.add(irr(-k[1], k[0]))
    else:
        kake = (2**x) % mod
        ans *= kake
        ans %= mod

ans *= ((2**a0) % mod+(2**b0) % mod-1)
ans %= mod

ans -= 1

ans += ab0
ans %= mod

print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

N = int(input())
ga, sa, ba = map(int, input().split())
gb, sb, bb = map(int, input().split())
A = [10**18] * 3
B = [10**18] * 3
dg = abs(ga - gb)
ds = abs(sa - sb)
db = abs(ba - bb)
if ga < gb:
    A[0] = ga
elif ga > gb:
    B[0] = gb
if sa < sb:
    A[1] = sa
elif sa > sb:
    B[1] = sb
if ba < bb:
    A[2] = ba
elif ba > bb:
    B[2] = bb

def calc(X):
    res = -1
    for i in range(N+1):
        if X[0] * i > N:
            break
        M = N - X[0] * i
        jj = M // X[1]
        x = 150
        for j in range(max(jj - x, 0), jj+1):
            k = (M - X[1] * j) // X[2]
            res = max(res, dg * i + ds * j + db * k)
        kk = M // X[2]
        for k in range(max(kk - x, 0), kk+1):
            j = (M - X[2] * k) // X[1]
            res = max(res, dg * i + ds * j + db * k)
    return res

N += calc(A)
N += calc(B)
print(N)

### FIXED CODE ###

import sys
input = sys.stdin.readline

N = int(input())
ga, sa, ba = map(int, input().split())
gb, sb, bb = map(int, input().split())
INF = 10**18
A = [INF] * 3
B = [INF] * 3
values = [abs(ga - gb), abs(sa - sb), abs(ba - bb)]
if ga < gb:
    A[0] = ga
elif ga > gb:
    B[0] = gb
if sa < sb:
    A[1] = sa
elif sa > sb:
    B[1] = sb
if ba < bb:
    A[2] = ba
elif ba > bb:
    B[2] = bb

def calc(X):
    dp = [0] * (N+1)
    dp[0] = 0
    for x, v in zip(X, values):
        for i in range(N+1-x):
            dp[i+x] = max(dp[i+x], dp[i] + v)
    return dp[-1]

N += calc(A)
N += calc(B)
print(N)
### BUGGY CODE ###

if __name__ == '__main__':
    s = input()
    q = int(input())
    ans = s
    rev_count = 0
    alist =[]

    for i in range(q):
        a = [i for i in input().split()]
        alist.append(a)
        if len(a) == 1:
            rev_count = rev_count +1

    if rev_count % 2 ==1:
        ans = ans[::-1]

    for i in alist:
        if len(i) == 1:
            rev_count = rev_count -1
        else:
            if int(i[1]) == 1:
                if rev_count % 2 == 1:
                    ans =  ans + i[2]
                else:
                    ans =  i[2] + ans

            else:
                if rev_count % 2 == 1:
                    ans =  i[2] + ans
                else:
                    ans = ans + i[2]

    print(ans)

### FIXED CODE ###

from collections import deque

if __name__ == '__main__':
    s = input()
    q = int(input())
    ans = s
    rev_count = 0
    leftList = deque()
    rightList =[]
    alist =[]

    for i in range(q):
        a = [i for i in input().split()]
        alist.append(a)
        if len(a) == 1:
            rev_count = rev_count +1

    if rev_count % 2 ==1:
        ans = ans[::-1]

    for i in alist:
        if len(i) == 1:
            rev_count = rev_count -1
        else:
            if int(i[1]) == 1:
                if rev_count % 2 == 1:
                    rightList.append(i[2])
                else:
                    leftList.appendleft(i[2])

            else:
                if rev_count % 2 == 1:
                    leftList.appendleft(i[2])
                else:
                    rightList.append(i[2])

    ans = ''.join(leftList)+ ans+''.join(rightList)

    print(ans)
### BUGGY CODE ###

mod = 10**9+7
import sys
from collections import Counter, defaultdict, deque
from itertools import product, permutations, combinations
from itertools import accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from math import ceil,floor
from copy import deepcopy
from heapq import heappop,heappush,heapify
import heapq


# l = ['a', 'a', 'a', 'a', 'b', 'c', 'c']
# c = Counter(l)

# d = defaultdict(int)

sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1

# リストの要素を改行を挟んで表示する
p2D = lambda x: print(*x, sep="\n")
# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())

def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())

# 入力全てを整数に変換したものの配列を受け取る
# def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI(): return list(map(lambda x:int(x), sys.stdin.readline().split()))
def HI(): return list(map(lambda x:int(x)*(-1), sys.stdin.readline().split()))



a,b,n = MI()
ans = 0
for i in range(1,n+1):
	tmp = floor((a*i)/b) - a*floor(i/b)
	ans=max(tmp,ans)
print(ans)
# n,m,q = MI()
# A =[]
# B = []
# C = []
# D = []

# for _ in rage(q):
# 	a,b,c,d = MI()
# 	A.append(a)
# 	B.append(b)
# 	C.append(c)
# 	D.append(d)

# for i in range(n):



### FIXED CODE ###

mod = 10**9+7
import sys
from collections import Counter, defaultdict, deque
from itertools import product, permutations, combinations
from itertools import accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from math import ceil,floor
from copy import deepcopy
from heapq import heappop,heappush,heapify
import heapq


# l = ['a', 'a', 'a', 'a', 'b', 'c', 'c']
# c = Counter(l)

# d = defaultdict(int)

sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1

# リストの要素を改行を挟んで表示する
p2D = lambda x: print(*x, sep="\n")
# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())

def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())

# 入力全てを整数に変換したものの配列を受け取る
# def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI(): return list(map(lambda x:int(x), sys.stdin.readline().split()))
def HI(): return list(map(lambda x:int(x)*(-1), sys.stdin.readline().split()))



a,b,n = MI()
i = min(n,b-1)
tmp = floor((a*i)/b) - a*floor(i/b)
print(tmp)

# n,m,q = MI()
# A =[]
# B = []
# C = []
# D = []

# for _ in rage(q):
# 	a,b,c,d = MI()
# 	A.append(a)
# 	B.append(b)
# 	C.append(c)
# 	D.append(d)

# for i in range(n):
### BUGGY CODE ###

def encode(s):
#  r = [0]*26
#  for n in range(len(s)):
#    r[ord(s[n]) - ord('a')] += 1
#  return r
#  r = list(s)
#  r.sort()
#  return r
  r = 0
  for n in range(len(s)):
    so = ord(s[n]) - ord('a')
    r += 11**so
  return r

N = int(input())

S = []

for n in range(N):
  s = str(input())
  S = S + [encode(s)]

S.sort()

ct = 0
M=1
ps=""
for cs in S:
  if cs==ps:
    M+=1
  else:
    ct += int((M**2-M)/2)
    M=1
    ps=cs
ct += int((M**2-M)/2)

print(ct)
      
  

### FIXED CODE ###

def encode(s):
#  r = [0]*26
#  for n in range(len(s)):
#    r[ord(s[n]) - ord('a')] += 1
#  return r
#  r = list(s)
#  r.sort()
#  return r
  r = 0
  for n in range(len(s)):
    so = ord(s[n]) - ord('a')
    r += 11**so
  return r

N = int(input())

S = [0]*N

for n in range(N):
  s = str(input())
  S[n] = encode(s)

S.sort()

ct = 0
M=1
ps=""
for cs in S:
  if cs==ps:
    M+=1
  else:
    ct += int((M**2-M)/2)
    M=1
    ps=cs
ct += int((M**2-M)/2)

print(ct)
### BUGGY CODE ###

H,W=map(int,input().split())
A=[list(input()) for _ in range(H)]

blacks=[]
whites=[]

#黒マス白マスをリストアップ
for w in range(W):
    for h in range(H):
        if A[h][w]=='#':
            blacks.append((h,w))
        else:
            whites.append((h,w))

ans=0
#各白マスについて黒マスとの最短距離を求め、その最大値を探す(マンハッタン距離)
for white in whites:
    dist=H+W+1
    for black in blacks:
        dist=min(dist,abs(black[0]-white[0])+abs(black[1]-white[1]))
    ans=max(ans,dist)

print(ans)

### FIXED CODE ###

from collections import deque
H,W=map(int,input().split())
A=[list(input()) for _ in range(H)]

q=deque()

#黒マスを探す
for w in range(W):
    for h in range(H):
        if A[h][w]=='#':
            q.append((h,w,0))

#BFS
ans=0
while q:
    h,w,d = q.popleft()
    ans=max(ans,d)
    for dh,dw in [(0,1),(1,0),(0,-1),(-1,0)]:
        nh,nw = h+dh, w+dw
        if nh<0 or nh>=H or nw<0 or nw>=W:
            continue
        if A[nh][nw]=='#':
            continue
        A[nh][nw]='#'
        q.append((nh,nw,d+1))

print(ans)
### BUGGY CODE ###

from collections import deque
from itertools import product

h, w = map(int, input().split())
c = tuple(map(lambda x: int(x)-1, input().split()))
d = tuple(map(lambda x: int(x)-1, input().split()))
s = list(input() for _ in range(h))

move_a_area = [(0, -1), (-1, 0), (1, 0), (0, 1)]
move_b_area = [(i, j) for i, j in product(range(-2, 3), repeat=2) if (i, j) not in [(0, 0)] + move_a_area]

INF = 10**12
cost = [[INF] * w for _ in range(h)]
cost[c[0]][c[1]] = 0
que = deque([(c[0], c[1], 0)])

while que:
    y, x, m = que.popleft()
    # Move A
    for dx, dy in move_a_area:
        ey, ex = y + dy, x + dx
        if 0 <= ey < h and 0 <= ex < w and s[ey][ex] == '.' and cost[ey][ex] > m:
            cost[ey][ex] = m
            que.append((ey, ex, m))
    # Move B
    for dx, dy in move_b_area:
        ey, ex = y + dy, x + dx
        if 0 <= ey < h and 0 <= ex < w and s[ey][ex] == '.' and cost[ey][ex] > m + 1:
            cost[ey][ex] = m + 1
            que.append((ey, ex, m + 1))

print(cost[d[0]][d[1]] if cost[d[0]][d[1]] < INF else -1)


### FIXED CODE ###

from collections import deque
from itertools import product

h, w = map(int, input().split())
c = tuple(map(lambda x: int(x)-1, input().split()))
d = tuple(map(lambda x: int(x)-1, input().split()))
s = list(input() for _ in range(h))

move_a_area = [(0, -1), (-1, 0), (1, 0), (0, 1)]
move_b_area = [(i, j) for i, j in product(range(-2, 3), repeat=2) if (i, j) not in [(0, 0)] + move_a_area]

cost = [[float('inf')] * w for _ in range(h)]
cost[c[0]][c[1]] = 0
que = deque([(c[0], c[1], 0)])

while que:
    y, x, m = que.popleft()
    # Move A
    for dx, dy in move_a_area:
        hh, ww = y + dy, x + dx
        if hh < 0 or h <= hh or ww < 0 or w <= ww or s[hh][ww] == '#' or cost[hh][ww] <= m:
            continue
        cost[hh][ww] = m
        que.appendleft((hh, ww, m))
    # Move B
    for dx, dy in move_b_area:
        hh, ww = y + dy, x + dx
        if hh < 0 or h <= hh or ww < 0 or w <= ww or s[hh][ww] == '#' or cost[hh][ww] <= m + 1:
            continue
        cost[hh][ww] = m + 1
        que.append((hh, ww, m + 1))

print(cost[d[0]][d[1]] if cost[d[0]][d[1]] < float('inf') else -1)
### BUGGY CODE ###

n = 50000
c = [1 for i in range(n)]
c[0] = 0
i = 2
while i**2 <= n:
    j = i*2
    while j <= n:
        c[j - 1] = 0
        j += i
    i += 1

while True:
    n = int(input())
    cnt = 0
    if n == 0:
        break
    elif n%2 == 0:
        for i in range(0, n//2, 2):
            if c[i] == 1 and c[n-i-2] == 1:
                cnt +=1
    print(cnt*2)



### FIXED CODE ###

n = 50001
is_prime = [i for i in range(n)]
is_prime[0] = is_prime[1] = 0
i = 2
while i**2 <= n:
    j = i*2
    while j < n:
        is_prime[j] = 0
        j += i
    i += 1

prime_set  = set(is_prime)
prime_set.remove(0)
prime_list = sorted(list(prime_set))

while True:
    cnt = 0
    n = int(input())
    if n == 0:
        break
    for i in prime_list:
        if i > n//2:
            break
        if n - i in prime_set:
            cnt += 1
    print(cnt)