Problem: Ringo Mart, a convenience store, sells apple juice.  On the opening day of Ringo Mart, there were A cans of juice in stock in the morning. Snuke buys B cans of juice here every day in the daytime. Then, the manager checks the number of cans of juice remaining in stock every night. If there are C or less cans, D new cans will be added to the stock by the next morning.  Determine if Snuke can buy juice indefinitely, that is, there is always B or more cans of juice in stock when he attempts to buy them. Nobody besides Snuke buy juice at this store.  Note that each test case in this problem consists of T queries.

Submission attempts (in order):
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def slv3(A, B, C, D):
    
    if A < B:
        
        return 'No'

    if D < B:
        
        return 'No'

    if C >= B:
        return 'Yes'

    s = set([])
    while True:
        error_print(A)
        if A in s:
            error_print('Yes')
            return 'Yes'
        s.add(A)
        if A < B:
            error_print('No')
            return 'No'

        A %= B
        if A <= C:
            A += D
    return 'Yes'


def slv2(A, B, C, D):
    
    if A < B:
        return 'No'

    if D < B:
        return 'No'

    if C >= B:

        return 'Yes'

    if D % B == 0 and A % B <= C:

        return 'Yes'
    elif D % B == 0:
        return 'No'

    if A % B <= C:
        pass
    else:
        return 'No'

    if C % (D % B) == 0:
        return 'Yes'
    else:
        return 'No'


@mt
def slv(T, Q):
    a = []
    for q in Q:
        a.append(slv2(*q))

    return '\n'.join(a)


def main():

    
    #     print(i)
    #     a = random.randint(1, 1000)
    #     b = random.randint(1, 1000)
    #     c = random.randint(1, 1000)
    #     d = random.randint(1, 1000)
    #     # a = 686
    #     # b = 387
    #     # c = 286
    #     # d = 388
    #     a = 732
    #     b = 582
    #     c = 213
    #     d = 781

    #     if slv2(a, b, c, d) != slv3(a, b, c, d):
    #         print(a, b, c, d)
    #         return

    T = read_int()
    Q = [read_int_n() for _ in range(T)]
    print(slv(T, Q))


if __name__ == '__main__':
    main()


# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(T, Q):

    def slv2(A, B, C, D):
        error_print(A, B, C, D)
        if A < B:
            
            return 'No'

        if D < B:
            
            return 'No'

        if C >= B:
            return 'Yes'

        if D % B == 0 and A % B <= C:
            return 'Yes'
        elif D % B == 0:
            return 'No'

        if C % (D % B) == 0:
            return 'Yes'
        else:
            return 'No'

    a = []
    for q in Q:
        a.append(slv2(*q))

    return '\n'.join(a)


def main():
    T = read_int()
    Q = [read_int_n() for _ in range(T)]
    print(slv(T, Q))


if __name__ == '__main__':
    main()


# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def gcd(a, b):
    if a < b:
        return gcd(b, a)
    if b == 0:
        return a
    return gcd(b, a % b)


def slv2(A, B, C, D):
    if A < B:
        return 'No'

    if D < B:
        return 'No'

    if C >= B:
        return 'Yes'

    g = gcd(B, D)
    if B - g + (A % g) > C:
        return 'No'

    return 'Yes'


@mt
def slv(T, Q):
    a = []
    for q in Q:
        a.append(slv2(*q))

    return '\n'.join(a)


def main():

    T = read_int()
    Q = [read_int_n() for _ in range(T)]
    print(slv(T, Q))


if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Wrong Answer

Accepted