{"problem":{"name":"±1 Operation 1","description":{"content":"You are given an integer $X$. The following action on this integer is called an _operation_. *   Choose and do one of the following.     *   Add $1$ to $X$.     *   Subtract $1$ from $X$. The terms ","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc255_c"},"statements":[{"statement_type":"Markdown","content":"You are given an integer $X$. The following action on this integer is called an _operation_.\n\n*   Choose and do one of the following.\n    *   Add $1$ to $X$.\n    *   Subtract $1$ from $X$.\n\nThe terms in the arithmetic progression $S$ with $N$ terms whose initial term is $A$ and whose common difference is $D$ are called _good numbers_.  \nConsider performing zero or more operations to make $X$ a good number. Find the minimum number of operations required to do so.\n\n## Constraints\n\n*   All values in input are integers.\n*   $-10^{18} \\le X,A \\le 10^{18}$\n*   $-10^6 \\le D \\le 10^6$\n*   $1 \\le N \\le 10^{12}$\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$X$ $A$ $D$ $N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc255_c","tags":[],"sample_group":[["6 2 3 3","1\n\nSince $A=2,D=3,N=3$, we have $S=(2,5,8)$.  \nYou can subtract $1$ from $X$ once to make $X=6$ a good number.  \nIt is impossible to make $X$ good in zero operations."],["0 0 0 1","0\n\nWe might have $D=0$. Additionally, no operation might be required."],["998244353 -10 -20 30","998244363"],["\\-555555555555555555 -1000000000000000000 1000000 1000000000000","444445"]],"created_at":"2026-03-03 11:01:14"}}