A - No Attacking
Source: atcoder
Difficulty: 400

Problem Statement
There is a chessboard with
N
rows and
N
columns. Let
(i, j)
denote the square at the
i
-th row from the top and the
j
-th column from the left.
You will now place pieces on the board. There are two types of pieces, called
rooks
and
pawns
.
A placement of pieces is called a
good arrangement
when it satisfies the following conditions:
Each square has zero or one piece placed on it.
If there is a rook at
(i, j)
, there is no piece at
(i, k)
for all
k
(1 \leq k \leq N)
where
k \neq j
.
If there is a rook at
(i, j)
, there is no piece at
(k, j)
for all
k
(1 \leq k \leq N)
where
k \neq i
.
If there is a pawn at
(i, j)
and
i \geq 2
, there is no piece at
(i-1, j)
.
Is it possible to place all
A
rooks and
B
pawns on the board in a good arrangement?
You are given
T
test cases; solve each of them.
Constraints
1 \leq T \leq 10^5
1 \leq N \leq 10^4
0 \leq A, B
1 \leq A + B \leq N^2
All input values are integers.
Input
The input is given from Standard Input in the following format. Here,
\mathrm{case}_i
represents the
i
-th case.
T
\mathrm{case}_1
\mathrm{case}_2
\vdots
\mathrm{case}_T
Each test case is given in the following format.
N
A
B
Output
Print
T
lines. The
i
-th line should contain the answer for the
i
-th test case.
For each test case, print
Yes
if it is possible to place the pieces in a good arrangement and
No
otherwise.
Sample Input 1
8
5 2 3
6 5 8
3 2 2
11 67 40
26 22 16
95 91 31
80 46 56
998 2 44353
Sample Output 1
Yes
No
No
No
Yes
No
Yes
Yes
In the first test case, for example, you can place rooks at
(1, 1)
and
(2, 4)
, and pawns at
(3, 3)
,
(4, 2)
, and
(5, 3)
to have all the pieces in a good arrangement.
In the second test case, it is impossible to place all the pieces in a good arrangement.

C++ solution:
#include <bits/stdc++.h>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()
using namespace std;
typedef long long ll;
const int mxN=500005;
const int MOD=998244353;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T;
    cin >> T;
    while(T--){
        ll N, A, B;
        cin >> N >> A >> B;
        if(A>N){
            cout << "No\n";
        } else if(A<=N/2){
            cout << (B<=(N-A)*(N-N/2) ? "Yes\n" : "No\n");
        } else {
            cout << (B<=(N-A)*(N-A) ? "Yes\n" : "No\n");
        }
    }
}

Go solution:
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var wr = bufio.NewWriter(os.Stdout)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func NextInt() int {
	sc.Scan()
	return Atoi(sc.Text())
}

func NextString() string {
	sc.Scan()
	return sc.Text()
}

func Atoi(s string) int {
	i, err := strconv.Atoi(s)
	if err != nil {
		panic(err)
	}
	return i
}

func Output(v ...interface{}) {
	_, err := fmt.Fprintln(wr, v...)
	if err != nil {
		panic(err)
	}
}

func Flush() {
	err := wr.Flush()
	if err != nil {
		panic(err)
	}
}

func main() {
	defer Flush()
	t := NextInt()
	for t > 0 {
		n, a, b := NextInt(), NextInt(), NextInt()
		if n < a {
			Output("No")
		} else {
			var tate int
			if a*2 <= n {
				tate = (n + 1) / 2
			} else {
				tate = n - a
			}
			yoko := n - a

			masu := tate * yoko
			if b <= masu {
				Output("Yes")
			} else {
				Output("No")
			}
		}

		t--
	}
	return
}

Java solution:
import java.io.*;

public class Main {
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
	static StreamTokenizer st = new StreamTokenizer(br);

	public static int readInt() throws IOException {
		st.nextToken();
		return (int) st.nval;
	}

	public static void main(String[] args) throws IOException {
		int T = readInt();
		while (T-- > 0) {
			int N = readInt();
			int A = readInt();
			int B = readInt();
			if (isPossible(N, A, B)) {
				pw.println("Yes");
			} else {
				pw.println("No");
			}
		}
		pw.flush();
		pw.close();
		br.close();
	}

	/**
	 * 判断是否符合题目条件
	 * 
	 * @param N
	 * @param A
	 * @param B
	 * @return true or false
	 */
	private static boolean isPossible(int N, int A, int B) {
		// 有效区域为放置所有车后，允许放置卒的最大数
		// 将N改为有效宽（有效区域宽只受车影响）
		N -= A;
		// 当有效宽度小于0时，必然不符合题目条件
		if (N < 0)
			return false;
		// 车偶数行放置，与之相邻余下奇数行的行数
		int a = Math.min(N, A + 1);
		// 放置完车与对应的卒后，剩下的行数，可放置卒的行数为剩下行数的一半
		int b = (N - a) / 2;
		// 求出有效区域的面积，判断是否能容纳所有卒
		B -= (a + b) * N;
		return B <= 0;
	}
}

JavaScript solution:
/// source code (in typescript)

// // @kariay1975/atcoder-tslib is a private package: 
// import {
//   Input,
//   InputStdin,
//   Output,
//   int,
//   isControlTag,
// } from '@kariya1975/atcoder-tslib';
// // use babel-plugin-macros for speed.
// import {
//   arrayWith,
//   enumerate,
//   range,
// } from '@kariya1975/atcoder-tslib/macro';
// 
// 
// const naive = (T: int, N: int[], A: int[], B: int[]): boolean[] => {
//   const f = (n: int, a: int, b: int): boolean => {
//     if (n < a) return false;
//     if (a < Math.floor(n / 2)) {
//       const k = n - a * 2;
//       return b <= a * (n - a) + Math.ceil(k / 2) * (n - a);
//     }
//     const k = n - a;
//     return b <= k * k;
//   }; 
// 
//   const result: boolean[] = [];
//   for (const i of range(T)) {
//     result.push(f(N[i], A[i], B[i]));
//   }
//   return result;
// };
// 
// const solve = (T: int, N: int[], A: int[], B: int[]): boolean[] => {
//   return naive(T, N, A, B);
// };
// 
// const main = (input: Input, output: Output): void => {
//   const T = input.getInt();
//   const N: int[] = [];
//   const A: int[] = [];
//   const B: int[] = [];
//   for (const _ of range(T)) {
//     const [n, a, b] = input.getInts(3);
//     N.push(n);
//     A.push(a);
//     B.push(b);
//   }
//   const result = solve(T, N, A, B);
//   for (const t of result) {
//     output.yesNo(t);
//   }
// };
// 
// const input = new InputStdin();
// input.setup().then(_ => {
//   const output = new Output();
//   try {
//     main(input, output);
//     output.print();
//   } catch (e) {
//     if (isControlTag(e, 'earlyExit')) {
//       output.print();
//     } else {
//       throw e;
//     }
//   }
// }).catch(e => {
//   console.error(e);
// });

// /// The code above transpiles as follows:
var Z=Object.create;var D=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var et=Object.getOwnPropertyNames;var rt=Object.getPrototypeOf,it=Object.prototype.hasOwnProperty;var N=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports);var nt=(i,t,r,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of et(t))!it.call(i,n)&&n!==r&&D(i,n,{get:()=>t[n],enumerable:!(e=tt(t,n))||e.enumerable});return i};var E=(i,t,r)=>(r=i!=null?Z(rt(i)):{},nt(t||!i||!i.__esModule?D(r,"default",{value:i,enumerable:!0}):r,i));var B=N((Pt,O)=>{"use strict";var st=function(i,t){return i<t};function d(i){if(!(this instanceof d))return new d(i);this.array=[],this.size=0,this.compare=i||st}d.prototype.clone=function(){var i=new d(this.compare);return i.size=this.size,i.array=this.array.slice(0,this.size),i};d.prototype.add=function(i){var t=this.size;this.array[this.size]=i,this.size+=1;for(var r,e;t>0&&(r=t-1>>1,e=this.array[r],!!this.compare(i,e));)this.array[t]=e,t=r;this.array[t]=i};d.prototype.heapify=function(i){this.array=i,this.size=i.length;var t;for(t=this.size>>1;t>=0;t--)this._percolateDown(t)};d.prototype._percolateUp=function(i,t){for(var r=this.array[i],e,n;i>0&&(e=i-1>>1,n=this.array[e],!(!t&&!this.compare(r,n)));)this.array[i]=n,i=e;this.array[i]=r};d.prototype._percolateDown=function(i){for(var t=this.size,r=this.size>>>1,e=this.array[i],n,s,o;i<r&&(n=(i<<1)+1,s=n+1,o=this.array[n],s<t&&this.compare(this.array[s],o)&&(n=s,o=this.array[s]),!!this.compare(o,e));)this.array[i]=o,i=n;this.array[i]=e};d.prototype._removeAt=function(i){if(!(i>this.size-1||i<0))return this._percolateUp(i,!0),this.poll()};d.prototype.remove=function(i){for(var t=0;t<this.size;t++)if(!this.compare(this.array[t],i)&&!this.compare(i,this.array[t]))return this._removeAt(t),!0;return!1};d.prototype.removeOne=function(i){if(typeof i=="function"){for(var t=0;t<this.size;t++)if(i(this.array[t]))return this._removeAt(t)}};d.prototype.removeMany=function(i,t){if(typeof i!="function"||this.size<1)return[];t=t?Math.min(t,this.size):this.size;for(var r=0,e=new Array(t),n=0,s=new Array(this.size);r<t&&!this.isEmpty();){var o=this.poll();i(o)?e[r++]=o:s[n++]=o}e.length=r;for(var h=0;h<n;)this.add(s[h++]);return e};d.prototype.peek=function(){if(this.size!=0)return this.array[0]};d.prototype.poll=function(){if(this.size!=0){var i=this.array[0];return this.size>1?(this.array[0]=this.array[--this.size],this._percolateDown(0)):this.size-=1,i}};d.prototype.replaceTop=function(i){if(this.size!=0){var t=this.array[0];return this.array[0]=i,this._percolateDown(0),t}};d.prototype.trim=function(){this.array=this.array.slice(0,this.size)};d.prototype.isEmpty=function(){return this.size===0};d.prototype.forEach=function(i){if(!(this.isEmpty()||typeof i!="function"))for(var t=0,r=this.clone();!r.isEmpty();)i(r.poll(),t++)};d.prototype.kSmallest=function(i){if(this.size==0)return[];i=Math.min(this.size,i);var t=new d(this.compare);let r=Math.min((i>0?Math.pow(2,i-1):0)+1,this.size);t.size=r,t.array=this.array.slice(0,r);for(var e=new Array(i),n=0;n<i;n++)e[n]=t.poll();return e};O.exports=d});var $=N((Kt,R)=>{"use strict";function f(i){if(this._capacity=W(i),this._length=0,this._front=0,L(i)){for(var t=i.length,r=0;r<t;++r)this[r]=i[r];this._length=t}}f.prototype.toArray=function(){for(var t=this._length,r=new Array(t),e=this._front,n=this._capacity,s=0;s<t;++s)r[s]=this[e+s&n-1];return r};f.prototype.push=function(t){var r=arguments.length,e=this._length;if(r>1){var n=this._capacity;if(e+r>n){for(var o=0;o<r;++o){this._checkCapacity(e+1);var s=this._front+e&this._capacity-1;this[s]=arguments[o],e++,this._length=e}return e}else{for(var s=this._front,o=0;o<r;++o)this[s+e&n-1]=arguments[o],s++;return this._length=e+r,e+r}}if(r===0)return e;this._checkCapacity(e+1);var o=this._front+e&this._capacity-1;return this[o]=t,this._length=e+1,e+1};f.prototype.pop=function(){var t=this._length;if(t!==0){var r=this._front+t-1&this._capacity-1,e=this[r];return this[r]=void 0,this._length=t-1,e}};f.prototype.shift=function(){var t=this._length;if(t!==0){var r=this._front,e=this[r];return this[r]=void 0,this._front=r+1&this._capacity-1,this._length=t-1,e}};f.prototype.unshift=function(t){var r=this._length,e=arguments.length;if(e>1){var o=this._capacity;if(r+e>o){for(var h=e-1;h>=0;h--){this._checkCapacity(r+1);var o=this._capacity,n=(this._front-1&o-1^o)-o;this[n]=arguments[h],r++,this._length=r,this._front=n}return r}else{for(var s=this._front,h=e-1;h>=0;h--){var n=(s-1&o-1^o)-o;this[n]=arguments[h],s=n}return this._front=s,this._length=r+e,r+e}}if(e===0)return r;this._checkCapacity(r+1);var o=this._capacity,h=(this._front-1&o-1^o)-o;return this[h]=t,this._length=r+1,this._front=h,r+1};f.prototype.peekBack=function(){var t=this._length;if(t!==0){var r=this._front+t-1&this._capacity-1;return this[r]}};f.prototype.peekFront=function(){if(this._length!==0)return this[this._front]};f.prototype.get=function(t){var r=t;if(r===(r|0)){var e=this._length;if(r<0&&(r=r+e),!(r<0||r>=e))return this[this._front+r&this._capacity-1]}};f.prototype.isEmpty=function(){return this._length===0};f.prototype.clear=function(){for(var t=this._length,r=this._front,e=this._capacity,n=0;n<t;++n)this[r+n&e-1]=void 0;this._length=0,this._front=0};f.prototype.toString=function(){return this.toArray().toString()};f.prototype.valueOf=f.prototype.toString;f.prototype.removeFront=f.prototype.shift;f.prototype.removeBack=f.prototype.pop;f.prototype.insertFront=f.prototype.unshift;f.prototype.insertBack=f.prototype.push;f.prototype.enqueue=f.prototype.push;f.prototype.dequeue=f.prototype.shift;f.prototype.toJSON=f.prototype.toArray;Object.defineProperty(f.prototype,"length",{get:function(){return this._length},set:function(){throw new RangeError("")}});f.prototype._checkCapacity=function(t){this._capacity<t&&this._resizeTo(W(this._capacity*1.5+16))};f.prototype._resizeTo=function(t){var r=this._capacity;this._capacity=t;var e=this._front,n=this._length;if(e+n>r){var s=e+n&r-1;ft(this,0,this,r,s)}};var L=Array.isArray;function ft(i,t,r,e,n){for(var s=0;s<n;++s)r[s+e]=i[s+t],i[s+t]=void 0}function ct(i){return i=i>>>0,i=i-1,i=i|i>>1,i=i|i>>2,i=i|i>>4,i=i|i>>8,i=i|i>>16,i+1}function W(i){if(typeof i!="number")if(L(i))i=i.length;else return 16;return ct(Math.min(Math.max(16,i),1073741824))}R.exports=f});var H=N((Ie,Q)=>{"use strict";Q.exports=bt;var c=0,l=1;function v(i,t,r,e,n,s){this._color=i,this.key=t,this.value=r,this.left=e,this.right=n,this._count=s}function z(i){return new v(i._color,i.key,i.value,i.left,i.right,i._count)}function b(i,t){return new v(i,t.key,t.value,t.left,t.right,t._count)}function p(i){i._count=1+(i.left?i.left._count:0)+(i.right?i.right._count:0)}function S(i,t){this._compare=i,this.root=t}var y=S.prototype;Object.defineProperty(y,"keys",{get:function(){var i=[];return this.forEach(function(t,r){i.push(t)}),i}});Object.defineProperty(y,"values",{get:function(){var i=[];return this.forEach(function(t,r){i.push(r)}),i}});Object.defineProperty(y,"length",{get:function(){return this.root?this.root._count:0}});y.insert=function(i,t){for(var r=this._compare,e=this.root,n=[],s=[];e;){var o=r(i,e.key);n.push(e),s.push(o),o<=0?e=e.left:e=e.right}n.push(new v(c,i,t,null,null,1));for(var h=n.length-2;h>=0;--h){var e=n[h];s[h]<=0?n[h]=new v(e._color,e.key,e.value,n[h+1],e.right,e._count+1):n[h]=new v(e._color,e.key,e.value,e.left,n[h+1],e._count+1)}for(var h=n.length-1;h>1;--h){var u=n[h-1],e=n[h];if(u._color===l||e._color===l)break;var a=n[h-2];if(a.left===u)if(u.left===e){var m=a.right;if(m&&m._color===c)u._color=l,a.right=b(l,m),a._color=c,h-=1;else{if(a._color=c,a.left=u.right,u._color=l,u.right=a,n[h-2]=u,n[h-1]=e,p(a),p(u),h>=3){var _=n[h-3];_.left===a?_.left=u:_.right=u}break}}else{var m=a.right;if(m&&m._color===c)u._color=l,a.right=b(l,m),a._color=c,h-=1;else{if(u.right=e.left,a._color=c,a.left=e.right,e._color=l,e.left=u,e.right=a,n[h-2]=e,n[h-1]=u,p(a),p(u),p(e),h>=3){var _=n[h-3];_.left===a?_.left=e:_.right=e}break}}else if(u.right===e){var m=a.left;if(m&&m._color===c)u._color=l,a.left=b(l,m),a._color=c,h-=1;else{if(a._color=c,a.right=u.left,u._color=l,u.left=a,n[h-2]=u,n[h-1]=e,p(a),p(u),h>=3){var _=n[h-3];_.right===a?_.right=u:_.left=u}break}}else{var m=a.left;if(m&&m._color===c)u._color=l,a.left=b(l,m),a._color=c,h-=1;else{if(u.left=e.right,a._color=c,a.right=e.left,e._color=l,e.right=u,e.left=a,n[h-2]=e,n[h-1]=u,p(a),p(u),p(e),h>=3){var _=n[h-3];_.right===a?_.right=e:_.left=e}break}}}return n[0]._color=l,new S(r,n[0])};var yt=T(function i(t,r){if(r.left){var e=i(t,r.left);if(e)return e}var e=t(r.key,r.value);if(e)return e;if(r.right)return()=>i(t,r.right)}),vt=T(function i(t,r,e,n){var s=r(t,n.key);if(s<=0){if(n.left){var o=i(t,r,e,n.left);if(o)return o}var o=e(n.key,n.value);if(o)return o}if(n.right)return()=>i(t,r,e,n.right)}),wt=T(function i(t,r,e,n,s){var o=e(t,s.key),h=e(r,s.key),u;if(o<=0&&(s.left&&(u=i(t,r,e,n,s.left),u)||h>0&&(u=n(s.key,s.value),u)))return u;if(h>0&&s.right)return()=>i(t,r,e,n,s.right)});y.forEach=function(t,r,e){if(this.root)switch(arguments.length){case 1:return yt(t,this.root);case 2:return vt(r,this._compare,t,this.root);case 3:return this._compare(r,e)>=0?void 0:wt(r,e,this._compare,t,this.root)}};Object.defineProperty(y,"begin",{get:function(){for(var i=[],t=this.root;t;)i.push(t),t=t.left;return new w(this,i)}});Object.defineProperty(y,"end",{get:function(){for(var i=[],t=this.root;t;)i.push(t),t=t.right;return new w(this,i)}});y.at=function(i){if(i<0)return new w(this,[]);for(var t=this.root,r=[];;){if(r.push(t),t.left){if(i<t.left._count){t=t.left;continue}i-=t.left._count}if(!i)return new w(this,r);if(i-=1,t.right){if(i>=t.right._count)break;t=t.right}else break}return new w(this,[])};y.ge=function(i){for(var t=this._compare,r=this.root,e=[],n=0;r;){var s=t(i,r.key);e.push(r),s<=0&&(n=e.length),s<=0?r=r.left:r=r.right}return e.length=n,new w(this,e)};y.gt=function(i){for(var t=this._compare,r=this.root,e=[],n=0;r;){var s=t(i,r.key);e.push(r),s<0&&(n=e.length),s<0?r=r.left:r=r.right}return e.length=n,new w(this,e)};y.lt=function(i){for(var t=this._compare,r=this.root,e=[],n=0;r;){var s=t(i,r.key);e.push(r),s>0&&(n=e.length),s<=0?r=r.left:r=r.right}return e.length=n,new w(this,e)};y.le=function(i){for(var t=this._compare,r=this.root,e=[],n=0;r;){var s=t(i,r.key);e.push(r),s>=0&&(n=e.length),s<0?r=r.left:r=r.right}return e.length=n,new w(this,e)};y.find=function(i){for(var t=this._compare,r=this.root,e=[];r;){var n=t(i,r.key);if(e.push(r),n===0)return new w(this,e);n<=0?r=r.left:r=r.right}return new w(this,[])};y.remove=function(i){var t=this.find(i);return t?t.remove():this};y.get=function(i){for(var t=this._compare,r=this.root;r;){var e=t(i,r.key);if(e===0)return r.value;e<=0?r=r.left:r=r.right}};function w(i,t){this.tree=i,this._stack=t}var x=w.prototype;Object.defineProperty(x,"valid",{get:function(){return this._stack.length>0}});Object.defineProperty(x,"node",{get:function(){return this._stack.length>0?this._stack[this._stack.length-1]:null},enumerable:!0});x.clone=function(){return new w(this.tree,this._stack.slice())};function Y(i,t){i.key=t.key,i.value=t.value,i.left=t.left,i.right=t.right,i._color=t._color,i._count=t._count}function xt(i){for(var t,r,e,n,s=i.length-1;s>=0;--s){if(t=i[s],s===0){t._color=l;return}if(r=i[s-1],r.left===t){if(e=r.right,e.right&&e.right._color===c){if(e=r.right=z(e),n=e.right=z(e.right),r.right=e.left,e.left=r,e.right=n,e._color=r._color,t._color=l,r._color=l,n._color=l,p(r),p(e),s>1){var o=i[s-2];o.left===r?o.left=e:o.right=e}i[s-1]=e;return}else if(e.left&&e.left._color===c){if(e=r.right=z(e),n=e.left=z(e.left),r.right=n.left,e.left=n.right,n.left=r,n.right=e,n._color=r._color,r._color=l,e._color=l,t._color=l,p(r),p(e),p(n),s>1){var o=i[s-2];o.left===r?o.left=n:o.right=n}i[s-1]=n;return}if(e._color===l)if(r._color===c){r._color=l,r.right=b(c,e);return}else{r.right=b(c,e);continue}else{if(e=z(e),r.right=e.left,e.left=r,e._color=r._color,r._color=c,p(r),p(e),s>1){var o=i[s-2];o.left===r?o.left=e:o.right=e}i[s-1]=e,i[s]=r,s+1<i.length?i[s+1]=t:i.push(t),s=s+2}}else{if(e=r.left,e.left&&e.left._color===c){if(e=r.left=z(e),n=e.left=z(e.left),r.left=e.right,e.right=r,e.left=n,e._color=r._color,t._color=l,r._color=l,n._color=l,p(r),p(e),s>1){var o=i[s-2];o.right===r?o.right=e:o.left=e}i[s-1]=e;return}else if(e.right&&e.right._color===c){if(e=r.left=z(e),n=e.right=z(e.right),r.left=n.right,e.right=n.left,n.right=r,n.left=e,n._color=r._color,r._color=l,e._color=l,t._color=l,p(r),p(e),p(n),s>1){var o=i[s-2];o.right===r?o.right=n:o.left=n}i[s-1]=n;return}if(e._color===l)if(r._color===c){r._color=l,r.left=b(c,e);return}else{r.left=b(c,e);continue}else{if(e=z(e),r.left=e.right,e.right=r,e._color=r._color,r._color=c,p(r),p(e),s>1){var o=i[s-2];o.right===r?o.right=e:o.left=e}i[s-1]=e,i[s]=r,s+1<i.length?i[s+1]=t:i.push(t),s=s+2}}}}x.remove=function(){var i=this._stack;if(i.length===0)return this.tree;var t=new Array(i.length),r=i[i.length-1];t[t.length-1]=new v(r._color,r.key,r.value,r.left,r.right,r._count);for(var e=i.length-2;e>=0;--e){var r=i[e];r.left===i[e+1]?t[e]=new v(r._color,r.key,r.value,t[e+1],r.right,r._count):t[e]=new v(r._color,r.key,r.value,r.left,t[e+1],r._count)}if(r=t[t.length-1],r.left&&r.right){var n=t.length;for(r=r.left;r.right;)t.push(r),r=r.right;var s=t[n-1];t.push(new v(r._color,s.key,s.value,r.left,r.right,r._count)),t[n-1].key=r.key,t[n-1].value=r.value;for(var e=t.length-2;e>=n;--e)r=t[e],t[e]=new v(r._color,r.key,r.value,r.left,t[e+1],r._count);t[n-1].left=t[n]}if(r=t[t.length-1],r._color===c){var o=t[t.length-2];o.left===r?o.left=null:o.right===r&&(o.right=null),t.pop();for(var e=0;e<t.length;++e)t[e]._count--;return new S(this.tree._compare,t[0])}else if(r.left||r.right){r.left?Y(r,r.left):r.right&&Y(r,r.right),r._color=l;for(var e=0;e<t.length-1;++e)t[e]._count--;return new S(this.tree._compare,t[0])}else{if(t.length===1)return new S(this.tree._compare,null);for(var e=0;e<t.length;++e)t[e]._count--;var h=t[t.length-2];xt(t),h.left===r?h.left=null:h.right=null}return new S(this.tree._compare,t[0])};Object.defineProperty(x,"key",{get:function(){if(this._stack.length>0)return this._stack[this._stack.length-1].key},enumerable:!0});Object.defineProperty(x,"value",{get:function(){if(this._stack.length>0)return this._stack[this._stack.length-1].value},enumerable:!0});Object.defineProperty(x,"index",{get:function(){var i=0,t=this._stack;if(t.length===0){var r=this.tree.root;return r?r._count:0}else t[t.length-1].left&&(i=t[t.length-1].left._count);for(var e=t.length-2;e>=0;--e)t[e+1]===t[e].right&&(++i,t[e].left&&(i+=t[e].left._count));return i},enumerable:!0});x.next=function(){var i=this._stack;if(i.length!==0){var t=i[i.length-1];if(t.right)for(t=t.right;t;)i.push(t),t=t.left;else for(i.pop();i.length>0&&i[i.length-1].right===t;)t=i[i.length-1],i.pop()}};Object.defineProperty(x,"hasNext",{get:function(){var i=this._stack;if(i.length===0)return!1;if(i[i.length-1].right)return!0;for(var t=i.length-1;t>0;--t)if(i[t-1].left===i[t])return!0;return!1}});x.update=function(i){var t=this._stack;if(t.length===0)throw new Error("Can't update empty node!");var r=new Array(t.length),e=t[t.length-1];r[r.length-1]=new v(e._color,e.key,i,e.left,e.right,e._count);for(var n=t.length-2;n>=0;--n)e=t[n],e.left===t[n+1]?r[n]=new v(e._color,e.key,e.value,r[n+1],e.right,e._count):r[n]=new v(e._color,e.key,e.value,e.left,r[n+1],e._count);return new S(this.tree._compare,r[0])};x.prev=function(){var i=this._stack;if(i.length!==0){var t=i[i.length-1];if(t.left)for(t=t.left;t;)i.push(t),t=t.right;else for(i.pop();i.length>0&&i[i.length-1].left===t;)t=i[i.length-1],i.pop()}};Object.defineProperty(x,"hasPrev",{get:function(){var i=this._stack;if(i.length===0)return!1;if(i[i.length-1].left)return!0;for(var t=i.length-1;t>0;--t)if(i[t-1].right===i[t])return!0;return!1}});function zt(i,t){return i<t?-1:i>t?1:0}function bt(i){return new S(i||zt,null)}function T(i){return function(...r){let e=i(...r);for(;typeof e=="function";)e=e();return e}}});var I=require("fs"),k=class{constructor(t){this.data=t!=null?t:"",this.index=0}isSpace(t){return t===" "||t===`
`}getString(){for(;this.index<this.data.length&&this.isSpace(this.data[this.index]);)this.index++;let t=this.index;for(;this.index<this.data.length&&!this.isSpace(this.data[this.index]);)this.index++;let r=this.index;return this.data.slice(t,r)}getCharList(){let t=[];for(;this.index<this.data.length&&this.isSpace(this.data[this.index]);)this.index++;for(;this.index<this.data.length&&!this.isSpace(this.data[this.index]);)t.push(this.data[this.index]),this.index++;return t}getBigInt(){return BigInt(this.getString())}getInt(){return Number(this.getString())}getNumber(){return Number(this.getString())}getNumbers(t){let r=[];for(let e=0,n=t;e<n;++e)r.push(this.getNumber());return r}getBigInts(t){let r=[];for(let e=0,n=t;e<n;++e)r.push(this.getBigInt());return r}getInts(t){let r=Array(t);for(let e=0,n=t;e<n;++e)r[e]=this.getInt();return r}getStrings(t){let r=[];for(let e=0,n=t;e<n;++e)r.push(this.getString());return r}getMatrix(){let[t,r]=this.getInts(2),e=[];for(let n=0,s=t;n<s;++n)e.push(this.getInts(r));return[t,r,e]}getMatrixWithExtraData(t){let[r,e]=this.getInts(2),n=this.getInts(t),s=[];for(let o=0,h=r;o<h;++o)s.push(this.getInts(e));return[r,e,n,s]}getSquareMatrix(){let t=this.getInt(),r=[];for(let e=0,n=t;e<n;++e)r.push(this.getInts(t));return[t,r]}forEach(t){let r=this.getInt();for(let e=0,n=r;e<n;++e)t(e)}case(t){let r=this.getInt();if(!t.has(r))throw new Error(`unknown kind ${r}`);t.get(r)(r)}getSeries(){let t=this.getInt(),r=this.getInts(t);return[t,r]}getSeriesWithExtraData(t){let r=this.getInt(),e=this.getInts(t),n=this.getInts(r);return[[r,...e],n]}getGraphWithAdjList(){let[t,r]=this.getInts(2),e=g(t,()=>[]);for(let n=0,s=r;n<s;++n){let[o,h]=this.getInts(2);e[o-1].push(h-1),e[h-1].push(o-1)}return[t,r,e]}getGraphWithAdjMatrix(){let[t,r]=this.getInts(2),e=g(t,()=>g(t,()=>!1));for(let n=0,s=r;n<s;++n){let[o,h]=this.getInts(2);e[o-1][h-1]=!0,e[h-1][o-1]=!0}return[t,r,e]}},A=class extends k{constructor(){super(),(0,I.existsSync)("/dev/stdin")&&(super.data=(0,I.readFileSync)("/dev/stdin","utf-8"))}async setup(){if((0,I.existsSync)("/dev/stdin"))return;let t=[];for await(let n of process.stdin)t.push(n);let e=Buffer.concat(t).toString();super.data=e}};var ot=E(B());var pt=E($());var g=(i,t)=>{let r=new Array(i);for(let e=0;e<i;++e)r[e]=t(e);return r};var j=V((i,t)=>t===0?i:()=>j(t,i%t));var M=V((i,t)=>t===0n?i:()=>M(t,i%t));function V(i){return function(...r){let e=i(...r);for(;typeof e=="function";)e=e();return e}}var St=E(H());var It=X((i,t)=>{if(t.length===0)return i;let[r,...e]=t;return()=>It(i[r],e)}),At=X((i,t,r)=>{let[e,...n]=t;if(n.length>0)return()=>At(i[e],n,r);i[e]=r});function X(i){return function(...r){let e=i(...r);for(;typeof e=="function";)e=e();return e}}var q=class{buffer=[];constructor(){}push(t){this.buffer.push(t)}yesNo(t){this.push(t?"Yes":"No")}list(t){this.push(t.join(" "))}lists(t){this.push(t.length);for(let r of t)this.list(r)}print(){console.log(this.buffer.join(`
`))}earlyExitTag(){return"earlyExit"}isEarlyExitTag(t){return t==="earlyExit"}};var J=(i,t)=>i===t;var F=J;var Mt=(i,t,r,e)=>{let n=(o,h,u)=>{if(o<h)return!1;if(h<Math.floor(o/2)){let m=o-h*2;return u<=h*(o-h)+Math.ceil(m/2)*(o-h)}let a=o-h;return u<=a*a},s=[];for(let o=0,h=i;o<h;++o)s.push(n(t[o],r[o],e[o]));return s},Tt=(i,t,r,e)=>Mt(i,t,r,e),Ft=(i,t)=>{let r=i.getInt(),e=[],n=[],s=[];for(let h=0,u=r;h<u;++h){let[a,m,_]=i.getInts(3);e.push(a),n.push(m),s.push(_)}let o=Tt(r,e,n,s);for(let h of o)t.yesNo(h)},K=new A;K.setup().then(i=>{let t=new q;try{Ft(K,t),t.print()}catch(r){if(F(r,"earlyExit"))t.print();else throw r}}).catch(i=>{console.error(i)});

Python solution:
import sys

def main():
    input = sys.stdin.read().split()
    idx = 0
    T = int(input[idx])
    idx += 1
    for _ in range(T):
        N = int(input[idx])
        A = int(input[idx+1])
        B = int(input[idx+2])
        idx +=3
        
        if A > N:
            print("No")
            continue
        k = N - A
        if k == 0:
            if B == 0:
                print("Yes")
            else:
                print("No")
            continue
        s = min(k, (N + 1) // 2)
        B_max = k * s
        if B <= B_max:
            print("Yes")
        else:
            print("No")

if __name__ == '__main__':
    main()

Ruby solution:
# debug = true
# debug = false
YES = 'Yes'.freeze
NO = 'No'.freeze
N = gets.to_i
N.times do
  n, rooks_count, pones_count = gets.split.map(&:to_i) # 配列から多重代入
  free_column = n - rooks_count
  pones_row = ((n + 1) >> 1)
  pones_row = free_column if pones_row > free_column
  puts (free_column >= 0 && pones_count <= pones_row * free_column) ? YES : NO
end