Problem:
 Score : 600 points    Problem Statement 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.      Constraints  1 \leq T \leq 300  1 \leq A, B, C, D \leq 10^{18}  All values in input are integers.         Input Input is given from Standard Input in the following format:  T  A_1  B_1  C_1  D_1  A_2  B_2  C_2  D_2  :  A_T  B_T  C_T  D_T   In the i -th query, A = A_i, B = B_i, C = C_i, D = D_i .      Output Print T lines. The i -th line should contain Yes if Snuke can buy apple juice indefinitely in the i -th query; No otherwise.        Sample Input 1 14
9 7 5 9
9 7 6 9
14 10 7 12
14 10 8 12
14 10 9 12
14 10 7 11
14 10 8 11
14 10 9 11
9 10 5 10
10 10 5 10
11 10 5 10
16 10 5 10
1000000000000000000 17 14 999999999999999985
1000000000000000000 17 15 999999999999999985      Sample Output 1 No
Yes
No
Yes
Yes
No
No
Yes
No
Yes
Yes
No
No
Yes  In the first query, the number of cans of juice in stock changes as follows: (D represents daytime and N represents night.)  9  → D  2  → N  11  → D  4  → N  13  → D  6  → N  6  → D x  In the second query, the number of cans of juice in stock changes as follows:  9  → D  2  → N  11  → D  4  → N  13  → D  6  → N  15  → D  8  → N  8  → D  1  → N  10  → D  3  → N  12  → D  5  → N  14  → D  7  → N  7  → D  0  → N  9  → D  2  → N  11  → D …  and so on, thus Snuke can buy juice indefinitely.       Sample Input 2 24
1 2 3 4
1 2 4 3
1 3 2 4
1 3 4 2
1 4 2 3
1 4 3 2
2 1 3 4
2 1 4 3
2 3 1 4
2 3 4 1
2 4 1 3
2 4 3 1
3 1 2 4
3 1 4 2
3 2 1 4
3 2 4 1
3 4 1 2
3 4 2 1
4 1 2 3
4 1 3 2
4 2 1 3
4 2 3 1
4 3 1 2
4 3 2 1      Sample Output 2 No
No
No
No
No
No
Yes
Yes
No
No
No
No
Yes
Yes
Yes
No
No
No
Yes
Yes
Yes
No
No
No

Solution (Python):
import sys

iT = int(input())
aR = [[int(x) for x in sLine.split()] for sLine in sys.stdin.readlines()]

def fGcd(iX,iY):
    while iY:
        iX,iY= iY,iX%iY
    return iX

def fFunc(iA,iB,iC,iD):
    ig = fGcd(iB,iD)
    if iA < iB or iD < iB:
        return False
    elif iC >= iB :
        return True






    elif iB <= iC +ig - iA % ig  :
        return True
    else:
        return False

for eR in aR:
    if fFunc(*eR) :
        print("Yes")
    else:
        print("No")

Solution (Python):
from fractions import gcd
n = int(input())
A = [list(map(int, input().split())) for _ in range(n)]
for i in range(n):
    a,b,c,d = A[i]
    g = gcd(b,d)
    if a < b or b > d or b-g+(a%g)>c:
        print('No')
    else:
        print('Yes')

Solution (Python):
import sys

iT = int(input())
aR = [[int(x) for x in sLine.split()] for sLine in sys.stdin.readlines()]

def fGcd(iX,iY):
    while iY:
        iX,iY= iY,iX%iY
    return iX

def fFunc(iA,iB,iC,iD):
    ig = fGcd(iB,iD)
    if iA < iB or iD < iB:
        return False
    elif iC >= iB :
        return True
    elif iC < iA % iB :
        return False


    elif iB <= ig + iC :


        return True
    else:
        return False

for eR in aR:
    if fFunc(*eR) :
        print("Yes")
    else:
        print("No")

Solution (Python):
import sys

iT = int(input())
aR = [[int(x) for x in sLine.split()] for sLine in sys.stdin.readlines()]

def fGcd(iX,iY):
    while iY:
        iX,iY= iY,iX%iY
    return iX



def fFunc(iA,iB,iC,iD):
    if iA < iB or iD < iB:
        return False
    elif iC >= iB :
        return True
    elif iC < iA % iB :
        return False
    elif iB -iC - 1 < fGcd(iB,iD) :
        return True
    else:
        return False

for eR in aR:
    if fFunc(*eR) :
        print("Yes")
    else:
        print("No")

Solution (Python):


from math import ceil
from fractions import gcd

def solve(A, B, C, D):
    if A < B or D < B: return False
    if A % B > C: return False
    if D % B == 0: return True

    g = gcd(B, D)
    r = A % g  
    
    return not (C < B - g + r)

T = int(input())
for i in range(T):
    A, B, C, D = [int(t) for t in input().split()]
    print('Yes' if solve(A, B, C, D) else 'No')

Solution (Python):
n = int(input())
def gcd(x,y):
	if x%y: return gcd(y,x%y)
	else: return y
for _ in range(n):
	a,b,c,d = (int(i) for i in input().split())
	g = gcd(b,d)
	if a<b or b>d or b-g+(a%g)>c: print("No")
	else: print("Yes")

Solution (Python):
T  = int(input())
def gcd(a,b):
    if b==0: return a
    return gcd(b, a%b)
for _ in range(T):
    a,b,c,d =list( map(int, input().split()) )
    if a<b or d<b:
        print('No')
        continue
    a %= b
    d%=b
    d = gcd(d,b)
    if c>= b:
        print('Yes')
        continue
    x = (b-a)//d
    y = a+ x*d
    if y == b: y-=d
    if y>c:
        print('No')
    else:
        print('Yes')

Solution (Python):
t = int(input())
abcd = [tuple(int(x) for x in input().split()) for _ in range(t)]

def calc_gcd(x, y):
    if x < y:
        x, y = y, x
    if y == 0:
        return x
    z = x % y
    return calc_gcd(y, z)

for a,b,c,d in abcd:
    if b > a or b > d:
        print('No')
        continue
    elif c >= b:
        print('Yes')
        continue
    g = calc_gcd(b, d)
    if b - g + (a % g) > c:
        print('No')
    else:
        print('Yes')

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    t = I()
    aa = [LI() for _ in range(t)]
    rr = []
    for a,b,c,d in aa:
        if a < b or d < b:
            rr.append('No')
            continue
        if c >= b:
            rr.append('Yes')
            continue
        g = fractions.gcd(b, d)
        if g == 1:
            if b - c > 1:
                rr.append('No')
            else:
                rr.append('Yes')
            continue
        t = (a + d - c) % g
        if t == 0:
            t = g
        if b - c - t > 0:
            rr.append('No')
        else:
            rr.append('Yes')

    return '\n'.join(rr)




print(main())

Solution (Python):

import fractions
def solve(a, b, c, d):
    if a < b:
        return False
    if d < b:
        return False
    if b <= c:
        return True
    assert c < b <= min(a, d)
    g = fractions.gcd(b, d)
    return b - g + a % g <= c

t = int(input())
for _ in range(t):
    a, b, c, d = map(int, input().split())
    ans = solve(a, b, c, d)
    print(['No', 'Yes'][ans])

Solution (Python):
def gcd(X0,X1):
    Y0=max([X0,X1])
    Y1=min([X0,X1])
    if Y0%Y1==0:
        return Y1
    else:
        return gcd(Y1,Y0%Y1)

def canbuy(A,B,C,D):
    if B>A:
        return False
    elif B>D:
        return False
    elif C>=B:
        return True
    else:
        g=gcd(B,D)
        X=B-g+(A%g)
        if X>C:
            return False
        else:
            return True

T=int(input())
S=["" for i in range(T)]
for i in range(T):
    a,b,c,d=map(int,input().split())
    if canbuy(a,b,c,d):
        S[i]="Yes"
    else:
        S[i]="No"

for i in range(T):
    print(S[i])

Solution (Python):
t = int(input())

def gcd(x, y):
    if x > y:
        x, y = y, x
    while x > 0:
        x, y = y%x, x
    return y

for _ in range(t):
    a,b,c,d = map(int, input().split())

    if b > a or b > d:
        print("No")
        continue
    if c >= b:
        print("Yes")
        continue

    a %= b
    g = gcd(b, d)
    if b-g+(a % g) > c:
        print("No")
    else:
        print("Yes")

Solution (Python):
import fractions

def func(A,B,C,D):


	if A<B:
		print "No"
	elif B>D:
		print "No"
	elif B<=C:
		print "Yes"

	else:
		A%=B
		g=fractions.gcd(B,D)
		if g==B:
			if A>C:
				print "No"
			else:
				print "Yes"
		elif B-g>C:
			print "No"
		else:
			print "Yes"
T=input()

for i in range(T):
	a,b,c,d=map(int, raw_input().split())
	func(a,b,c,d)

Solution (Python):
from fractions import gcd
n=int(input())
for i in range(n):
  a,b,c,d=map(int,input().split())
  g = gcd(b,d)
  print('Yes' if (b//g-1)*g + (a % b) % g<=c and a>=b and d>=b else 'No')

Solution (Python):
import sys

def gcd(x, y):
    x, y = sorted([x, y])
    while y % x:
        y, x = x, y % x
    return x

t = int(sys.stdin.readline())
for _ in range(t):
    a, b, c, d = map(int, sys.stdin.readline().split())
    if a < b:
        print("No")
    elif d < b:
        print("No")
    elif c >= b:
        print("Yes")
    else:
        g = gcd(b, d)
        if b - g + (a % g) > c:
            print("No")
        else:
            print("Yes")

Solution (Python):
from fractions import gcd

Q = int(input())
qs = []
for _ in range(Q):
	qs.append(list(map(int, input().split())))

for q in qs:
	a, b, c, d = q[0], q[1], q[2], q[3]
	if a < b or b > d:
		print("No")
	elif b <= c:
		print("Yes")
	elif d % b == 0:
		if a % b > c:
			print("No")
		else:
			print("Yes")
	else:
		a = a % b
		d = d % b
		d = gcd(b, d)
		if a > c:
			print("No")
		elif (a + ((c - a) // d) * d + d) % b <= c:
			print("Yes")
		else:
			print("No")

Solution (Python):


def getInput():
    in_row = [ int(x) for x in input().split(" ") ]
    return in_row

def gcd(n1, n2):
    while n1 % n2 != 0:
        if n1 < n2:
            n1, n2 = n2, n1
        n1 %= n2
    return n2
            
def judgeTakahashi(in_row):
    A = in_row[0]
    B = in_row[1]
    C = in_row[2]
    D = in_row[3]
    g = gcd(B, D)

    if B > A:
        return False
    if B > D:
        return False
    if C >= B:
        return True
    
    if B-g+(A%g) > C:
        return False
    else:
        return True

if __name__ == "__main__":
    N = int(input())
    assert gcd(1071, 1029) == 21, "error"
    assert not(judgeTakahashi([1, 10, 1, 1])), "error"
    for i in range(N):
        in_row = getInput()
        result = "Yes" if judgeTakahashi(in_row) else "No"
        print(result)

Solution (Python):
def gcd( a, b):
    if b == 0:
        return a
    else:
        return gcd( b, a % b)

n = int(input())
list = [map(int, input().split()) for i in range(n)]
 
def check(num):
    a, b, c, d = list[num]
    if a < b:
        return False
    if a % b > c:
        return False
    if b > d:
        return False
    if c < b and d != b:
        if (b - ( a % b ) - 1) // gcd( b, d) != ((c - ( a % b ))) // gcd( b, d):
            return False
    return True
 
for i in range(n):
    if check(i):
        print('Yes')
    else:
        print('No')

Solution (Python):
from fractions import gcd
def F(a, b, c, d):
	if a < b or d < b:
		return False
	a -= c
	a %= gcd(b, d)
	if a == 0:
		a = gcd(b, d)
	return a - b >= -c
for t in range(input()):
	a, b, c, d = map(int, raw_input().split())
	print ['No', 'Yes'][F(a, b, c, d)]

Solution (Python):
def gcd(a,b):
    if b== 0:
        return a
    else:
        return gcd(b,a%b)

t = int(input())
abcd = []
ans = "No"
for i in range(0,t):
    ABCD = list(map(int,input().split()))
    abcd.append(ABCD)
for a,b,c,d in abcd:
    if a >= b and b==d and b <= c:
        ans = "Yes"
    if a >= b and d >= b and b > c and b - gcd(d,b) + a%gcd(d,b) <= c:
        ans = "Yes"
    if a >= b and d >= b and b <= c:
        ans = "Yes"
    print(ans)
    ans = "No"

Solution (Python):
def gcd(a, b):
    a, b  = max(a, b), min(a, b)
    while a%b != 0:
        a, b = b, a%b
    return b

T = int(input())
set = []
for i in range(T):
    set.append([int(j) for j in input().split()])
 
for i in range(T):
    if set[i][0] < set[i][1] or set[i][1] > set[i][3]:
        print("No")
    elif set[i][2] >= set[i][1]:
        print("Yes")
    else:
        g = gcd(set[i][1], set[i][3])
        amodg = set[i][0]%g
        if set[i][1] - g + amodg <= set[i][2]:
            print("Yes")
        else:
            print("No")

Solution (Python):
import fractions

def judge(A, B, C, D):
    if A < B:   
        return False
    if D < B:   
        return False
    if B <= C:  
        return True
    G = fractions.gcd(B, D)   
    R = A % G       
    if C + G - R - B  < 0:
        
        return False
    else:
        return True

T = int(input())
data = []
for _ in range(T):
    data.append([int(xi) for xi in input().split()])
for A, B, C, D in data:
    print('Yes') if judge(A, B, C, D) else print('No')

Solution (Python):
import fractions
T = int(input())

for i in range(T):
  a, b, c, d = map(int, input().split())

  if d<b or a<b:
    print('No')
    continue

  if b-1<=c:
    print('Yes')
    continue

  gcd=fractions.gcd(d,b)
  e=b-gcd+a%gcd
  if e>c:
    print('No')
  else:
    print('Yes')

Solution (Python):
T = int(input())
query = [list(map(int, input().split())) for i in range(T)]

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a


ans_list = []
for i in range(T):
    A = query[i][0]
    B = query[i][1]
    C = query[i][2]
    D = query[i][3]
    if A < B:
        ans_list.append("No")
        continue
    if B > D:
        ans_list.append("No")
        continue
    if C >= B:
        ans_list.append("Yes")
        continue
    g = gcd(B, D)
    max_modB = B - g + A%g
    if max_modB > C:
        ans_list.append("No")
    else:
        ans_list.append("Yes")
        

print('\n'.join(ans_list))

Solution (Python):
import fractions


def run(t, a, b, c, d):
    ret = []
    for i in range(t):
        ret.append(check(a[i], b[i], c[i], d[i]))
    return ret


def check(a, b, c, d):
    if a < b:
        return 'No'
    if d < b:
        return 'No'
    if c < b:
        g = fractions.gcd(b, d)
        amodb = a % b
        if g == 1:
            if b - 1 > c:
                return 'No'
        elif g == b:
            if amodb > c:
                return 'No'
        else:
            if (b - g) > c:
                return 'No'
    return 'Yes'


def read_line():
    t = int(input())
    a = []
    b = []
    c = []
    d = []
    for i in range(t):
        at, bt, ct, dt = list(map(int, input().split()))
        a.append(at)
        b.append(bt)
        c.append(ct)
        d.append(dt)
    return (t, a, b, c, d)


def main():
    t, a, b, c, d = read_line()
    ret = run(t, a, b, c, d)
    for i in range(t):
        print(ret[i])


if __name__ == '__main__':
    main()

Solution (Python):
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
t = int(input())
abcd_list = [[int(i) for i in input().split()] for _ in range(t)]

for i in range(len(abcd_list)):
    a, b, c, d = abcd_list[i]
    if b > a:
        print("No")
        continue
    if b > d:
        print("No")
        continue
    if c > b:
        print('Yes')
        continue
    g = gcd(b, d)
    max_mod_b = b - g + a % g
    if max_mod_b > c:
        print('No')
    else:
        print("Yes")

Solution (Python):


































import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def solve(A, B, C, D):
    if B > A:
        return "No"
    if B > D:
        return "No"
    if B <= C:
        return "Yes"

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


T = int(input())
for t in range(T):
    A, B, C, D = map(int, input().split())
    print(solve(A, B, C, D))

Solution (Python):
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
t=i1()
def gcd(a,b):
  while b:
    if a<b:
        c=b
        b=a
        a=c
    if b:a%=b
  return a
for i in range(t):
 [a,b,c,d]=i2()
 if a<b:
   print("No")
 else:
   if d<b:
      print("No")
   else:
      if c>=b:
         print("Yes")
      else:
         g=gcd(b,d)
         x=b-g+a%g
         if x>c:
           print("No")
         else:
           print("Yes")

Solution (Python):







import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a



def solve(A, B, C, D):
    if B > A:
        return "No"
    if B > D:
        return "No"
    if B <= C:
        return "Yes"

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


T = int(input())
for t in range(T):
    A, B, C, D = map(int, input().split())
    print(solve(A, B, C, D))

Solution (Python):
import fractions
N = int(input())
x = []
for i in range(N):
    a1,b1,c1,d1=[int(i) for i in input().split()]
    x.append([a1,b1,c1,d1])
for i in range(N):
  y = x[i]
  if y[0] < y[1]:
    print("No")
  elif y[1] > y[3]:
    print("No")
  elif y[1] > y[2]:
    ama = y[0] % y[1]
    mo = y[3] %  y[1]
    if mo == 0:
      if ama<= y[2]:
        print("Yes")
      else:
          print("No")
    elif mo <= y[1]-y[2]-1:
      print("No")
    else:
        to = y[1] % mo
        if to == 0:
          if ama<= y[2]:
            print("Yes")
          else:
              print("No")
        else:
          are = fractions.gcd(to, y[1])
          if are-ama%are <= y[1]-y[2]-1:
            print("No")
          else:
            print("Yes")
          
  else:
    print("Yes")

Solution (Python):
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
T=int(input())
 
Query=[]
for i in range(T):
  Query.append(list(map(int,input().split())))
 
for i in range(T):
  while(True):
    if Query[i][0]%Query[i][1]>Query[i][2] or Query[i][0]<Query[i][1] or Query[i][1]>Query[i][3]:
      print('No')
      break;
    G=gcd(Query[i][1],Query[i][3]) 
    '''
    A,B,C,DがQuery[i]の0,1,2,3に対応
    BmodG,DmodGは0(GはB,Dの約数であるため)よりmodGの世界で個数の増減はない。昼の購入で0個減少。夜の仕入れで0個増加。
    つまり、初期個数をAmodGとすると、個数は一定
    出現する可能性のあるBは買う個数であり、B-Gを考えると、買いきれない個数で出現しうる最大の個数が求まる。
    但し、初期個数を考える必要がある。
    初期個数によってループする幅が一緒でも取りうる値は異なる。
    
    例：
    B=24,C=19,D=36 この時,G=12
    
    A=31の場合 AmodG(本来の個数)
    7(31)→7(7)→7(43)→7(19)→7(31)→...
    A=30の場合 AmodG(本来の個数)
    6(30)→6(6)→6(42)→6(18)→6(30)→...
    
    Bを超えない最大数について、初期個数を考慮すると、B-G+AmodGとなる。
    G>AmodGであるため、この数が購入数Bを超えることはない
    つまり、B-G+AmodG>CならばNo,そうでなければYes
    '''
    if Query[i][1]-G+Query[i][0]%G>Query[i][2]:
      print('No')
      break;
    else:
      print('Yes')
      break;

Solution (Python):
from sys import stdin
from fractions import gcd
columns = int(stdin.readline().rstrip())
datas = [stdin.readline().rstrip().split() for _ in range(columns)]
for data in datas:
    A = int(data[0])
    B = int(data[1])
    C = int(data[2])
    D = int(data[3])
    if A < B:
        print("No")
        continue
    if D < B:
        print("No")
        continue
    if C > B:
        print("Yes")
        continue
    g = gcd(B,D)
    if (B - g + A % g) >C :
        print("No")
    else:
        print("Yes")

Solution (Python):
from fractions import gcd
T = int(input())
for i in range(T):
    A, B, C, D = map(int, input().split())

    
    if B > A:
        print("No")
        continue

    
    if B > D:
        print("No")
        continue

    
    if C >= B:
        print("Yes")
        continue
        
    if B - gcd(B, D) + (A % gcd(B, D)) <= C:
        print("Yes")
    else:
        print("No")

Solution (Python):
from fractions import gcd
t=int(input())
for i in range(t):
	a,b,c,d=map(int,input().split())
	if a<b or b>d:
		print("No")
	elif b<=c:
		print("Yes")
	else:
		g=gcd(b,d)
		if (g-a%g)>=b-c:
			print("Yes")
		else:
			print("No")

Solution (Python):

def findGCD(a,b):
    if a%b == 0:
        return b
    else:
        return findGCD(b,a%b)


def judge(a,b,c,d):
    if a<b or d<b:
        return False
    elif c >= b:
        return True
    else:
        g = findGCD(b,d)
        thr = b-g+a%g
        if thr > c:
            return False
        else:
            return True
        
T = int(input())
ABCD = []
for i in range(T):
    ABCD.append(list(map(int, input().split())))
        
for a,b,c,d in ABCD:
    if judge(a,b,c,d):
        print("Yes")
    else:
        print("No")

Solution (Python):
def gcd(x,y):
    if x < y:
        tmp = y
        y = x
        x = tmp

    while x % y != 0:
        r = x % y
        x = y
        y = r
    return y

n = int(input())
x = []
for i in range(n):
    a,b,c,d = map(int,input().split())
    x.append((a,b,c,d))

def f(a,b,c,d):
    if a < b:
        print("No")
    elif b > d:
        print("No")
    elif c >= b:
        print("Yes")
    else:
        g = gcd(b,d)
        if b-g+(a%g) > c:
            print("No")
        else:
            print("Yes")

for i in range(n):
    a,b,c,d = x[i][0],x[i][1],x[i][2],x[i][3]
    f(a,b,c,d)

Solution (Python):



from math import ceil

def gcd(a, b):
    assert a > 0 and b > 0
    while b > 0:
        r = a % b
        a = b
        b = r
    return a

def solve(A, B, C, D):
    if A < B or D < B: return False
    if A % B > C: return False
    if D % B == 0: return True

    g = gcd(B, D)
    r = A % g  
    
    return not (C < B - g + r)

T = int(input())
for i in range(T):
    A, B, C, D = [int(t) for t in input().split()]
    print('Yes' if solve(A, B, C, D) else 'No')

Solution (Python):
from fractions import gcd
t = int(input())
for i in range(t):
    a,b,c,d = map(int, input().split())
    if a < b:
        print('No')
        continue
    if d < b:
        print('No')
        continue
    if c >= b - 1:
        print('Yes')
        continue
    if c < a % b:
        print('No')
        continue
    if d % b == 0:
        print('Yes')
        continue
    g = gcd(b,d)
    if c % b < (b - g + (a % g)) % b:
        print('No')
        continue
    print('Yes')

Solution (Python):
def gcd(a, b): 
    if a == 0 :
        return b 
    return gcd(b%a, a)
for _ in range(int(input())):
    a,b,c,d=[int(x) for x in input().split()]
    if a<b:
        print("No")
        continue
    if d<b:
        print("No")
        continue
    if b<=c:
        print("Yes")
        continue
    g=gcd(b,d)
    if c>=b-g+a%g:
        print("Yes")
    else:
        print("No")

Solution (Python):
from fractions import gcd
n=int(input())
h=[]
for i in range(n):
    w=list(map(int,input().split()))
    h.append(w)
for i in range(n):
    a,b,c,d=h[i][0],h[i][1],h[i][2],h[i][3]
    if(b>a or b>d):
        print("No")
        continue
    if(b<=c):
        print("Yes")
        continue
    if(b-gcd(b,d)+a%gcd(b,d)<=c):print("Yes")
    else:print("No")
    continue

Solution (Python):
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

T=int(input())
Juice=[None]*T
for i in range(T):
    Juice[i]=list(map(int,input().split()))





def juicecheck(i):
    A=Juice[i][0]
    B=Juice[i][1]
    C=Juice[i][2]
    D=Juice[i][3]

    if A<B:
        print("No")
        return
    elif B>D:
        print("No")
        return
    elif B-1<=C:
        print("Yes")
        return
    else:
        x=A%B
        y=D%B
        

        z=gcd(B,D)

        if z==1 or B-(C+1)>=z or  (C+1)%z<=x%z<=(B-1)%z or ( (C+1)%z>B%z and ((C+1)%z<=x%z or x%z<B%z) ):
            print("No")
            return

        print("Yes")
        return
                
        

for i in range(T):
    juicecheck(i)

Solution (Python):
from fractions import gcd

t = int(input())
a = []
d = 0
for i in range(t):
  a.append(list(map(int,input().split())))
for j in a:
  if j[0] < j[1] or j[1] > j[3]:
    print("No")
  else:
    b = j[0] % j[1]
    k = gcd(j[1],j[3])
    c = j[0] % k
    d = j[2] % k
    if c > d:
      e = j[2] + c - d
    else:
      e = j[2] + k + c - d

    if j[1] > e:
      print("No")
    else:
      print("Yes")

Solution (Python):
def gcd(x, y):
	while y:
		x, y = y, x % y
	return x

t = int(input())
a = []
d = 0
for i in range(t):
  a.append(list(map(int,input().split())))
for j in a:
  if j[0] < j[1] or j[1] > j[3]:
    print("No")
  else:
    b = j[0] % j[1]
    k = gcd(j[1],j[3])
    c = j[0] % k
    d = j[2] % k
    if c > d:
      e = j[2] + c - d
    else:
      e = j[2] + k + c - d

    if j[1] > e:
      print("No")
    else:
      print("Yes")

Solution (Python):
from fractions import gcd
t = int(input())

for i in range(t):
    a,b,c,d = map(int, input().split())

    if a < b or b > d:
        print('No')
        continue

    if b <= c:
        print('Yes')
        continue

    g = gcd(b, d)
    if c >= b - g + (a % g):
        print('Yes')
    else:
        print('No')

Solution (Python):

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()

Solution (Python):
def gcd(a, b):
    if a == 0: return b
    else : return gcd(b % a, a)

def solve():
    a, b, c, d = map(int, input().split())
    if d < b:return "No"
    if a < b:return "No"
    if c >= b:return "Yes"
    g = gcd(d, b)
    a %= b
    if((c-a) // g != (b-a-1) // g):return "No"
    else: return "Yes"


for _ in range(int(input())):
    print (solve())

Solution (Python):
T = int(input())

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

def solve(A, B, C, D):
    if A < B:
        return False
    if D < B:
        return False
    if C >= B:
        return True
    s = A % B
    d = D % B
    n = B - C
    if d == 0:
        return s <= C
    else:
        g = gcd(d, B)
        n = (B - 1 - s) // g
        m = s + n * g
        return m <= C

ABCD = [[int(_) for _ in input().split()] for i in range(T)]

for A, B, C, D in ABCD:
    if solve(A, B, C, D):
        print("Yes")
    else:
        print("No")

Solution (Python):
def gcd(X,Y):
  if X < Y:
    tmp = X
    X = Y
    Y = tmp
  if Y == 0:
    return 0
  while X % Y != 0:
    r = X % Y
    X = Y
    Y = r
  return Y
T = int(raw_input())
Q = [map(int, raw_input().split()) for _ in range(T)]
for q in Q:
  A,B,C,D = q
  if B > A:
    print 'No'
  elif B > D:
    print 'No'
  elif B <= C:
    print 'Yes'
  else:
    A = A%B
    D = D%B
    g = gcd(B,D)
    maximum = A if g == 0 else B-g+A%g
    if maximum > C:
      print 'No'
    else:
      print 'Yes'

Solution (Python):
def gcd(a, b):
    r = a % b
    while r != 0:
        a, b, r = b, r, b % r
    return b

class query:
    def __init__(self, a, b, c, d):
        self.a = a
        self.b = b
        self.c = c
        self.d = d
    def isEternal(self):
        if self.a < self.b:
            return "No"
        if self.d < self.b:
            return "No"
        if self.b <= self.c:
            return "Yes"
        g = gcd(self.d, self.b)
        if self.b - g + self.a % g > self.c:
            return "No"
        return "Yes"

if __name__ == "__main__":
    t = int(input())
    querys = [query(*[int(s) for s in input().split()]) for _ in range(t)]
    for q in querys:
        print(q.isEternal())

Solution (Python):
import fractions
T = int(input())
for i in range(T):
  A, B, C, D = map(int, input().split())
  if (A < B):
    print('No')
  elif (B > D):
    print('No')
  elif (C >= B):
    print('Yes')
  elif (A % B > C):
    print('No')
  elif (D % B == 0):
    print('Yes')
  else:
    gcdBD = fractions.gcd(B, D)
    if (C + gcdBD >= B):
      print('Yes')
    else:
      print('No')

Solution (Python):



t = int(input())
qs=[list(map(int,input().split())) for i in range(t)]

def computeGCD(x, y):
   while(y):
       x, y = y, x % y
   return x

def aprime(a,b,c,d):
    app = a%b
    return(c+d-b - (c-app)%(d-b))


def ans(a,b,c,d):
    if d < b or a<b or (a%b > c and c<b):
        return('No')
    elif b == d or c > b:
        return('Yes')
    elif aprime(a,b,c,d) < b:
        return('No')
    else: return (ans2(aprime(a,b,c,d),b,c,d))

def ans2(a,b,c,d):
    b2 = b % (d-b)
    gcdbbd = abs(computeGCD(b2,b-d))
    aa = a - ((a-c)//gcdbbd)*gcdbbd
    if aa == c: aa = c+ gcdbbd
    if aa >= b: return('Yes')
    else: return('No')

for q in qs:
    print (ans(*q))

Solution (Python):

import sys

n = int(input())
a=[]
b=[]
c=[]
d=[]
for j in range(0,n):
    t1,t2,t3,t4 = (int(i) for i in input().split())  
    a.append(t1)
    b.append(t2)
    c.append(t3)
    d.append(t4)
    
for i in range(0,n):
    if a[i] < b[i]:
        print("No")
    elif d[i] < b[i]:
        print("No")
    else:
        p= b[i]
        q= d[i]
        while p%q :
            r=q
            q=p%q
            p=r
        if (b[i]-q)+a[i]%q > c[i]:
            print("No")
        else:
            print("Yes")

Solution (Python):
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a


T = int(input())
a = []
for i in range(T):
    a.append(list(map(int, input().split())))
for r in a:
    s, b, c, d = r[0], r[1], r[2], r[3]
    mod_list = []
    if (s < b) or (b>d):
        print('No')
        continue
    if (c>b):
        print('Yes')
        continue

    g = gcd(b,d)

    if b- g + s%g > c:
        print('No')
    else:
        print('Yes')

Solution (Python):
import fractions
T = int(input())

L = []
for i in range(0,T):
    L = list(map(int, input().split()))
    A = L[0]
    B = L[1]
    C = L[2]
    D = L[3]

    ans = "Yes"
    if A < B: 
        ans = "No"
    elif D < B: 
        ans = "No"
    elif B - C <= 1: 
        ans = "Yes"
    elif C < B-fractions.gcd(B,D)+(A%fractions.gcd(B,D)):
        ans = "No"


    print(ans)
    L = []

Solution (Python):

from fractions import gcd
T = int(input())
ABCD = [list(map(int,input().split())) for _ in range(T)]

for a,b,c,d in ABCD:
    if a < b:
        print('No')
        continue
    if d < b:
        print('No')
        continue
    tmp = a % b
    if tmp > c:
        print('No')
        continue
    if d % b == 0:
        print('Yes')
        continue
    if c >= b-1:
        print('Yes')
        continue
    if a%2 == 0 and b%2 == 0 and d %2 == 0 and b-c == 2:
        print('Yes')
        continue
    GCD = gcd(b,d)
    if b-GCD +(a%GCD) > c:
        print('No')
    else:
        print('Yes')