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



Sample input:
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:
No
Yes
No
Yes
Yes
No
No
Yes
No
Yes
Yes
No
No
Yes

Submission status: Wrong Answer

Solution code:
#A = 初期値　B = 一日の購入　C = 乳化のボーダー　D =在庫の増やす数

#A > B
#D % B >= B - C

size = int(input())
data = []
flag = 0

for i in range(size):
    ip = input().split()
    for j in ip:
        data.append(int(j))
    #定義
    store = data[0]
    buy = data[1]
    bord = data[2]
    charge = data[3]
    buf = []
    #最初の処理
    store = store % buy
    if store > bord:
        flag = 1
    #定常処理
    while store not in buf:
        buf.append(store)
        store = (store + charge) % buy
        if store > bord:
            flag = 1
            break

    #print(buf)
    if flag == 1:
        print("No")
        flag = 0
    else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
t = input()
result = []
hist = []
for i in range(int(t)):
	data = input().split()
	a = int(data[0])
	b = int(data[1])
	c = int(data[2])
	d = int(data[3])
	hist.clear()
	while True:
		if a < b:
			result.append("No")
			break
		n = int((a / b))
		a -= b * n
		if a <= c:
			a += d
		if a in hist:
			result.append("Yes")
			break
		else:
			hist.append(a)
			if len(hist) > 30:
				if min(hist) > a:
					result.append("No")
					break
			if len(hist) > 50:
				result.append("Yes")
				break
		if (len(hist) == 5) & (b < d) & (b < c):
			result.append("Yes")
			break
for i in range(int(t)):
	print(result[i])

Submission status: Wrong Answer

Solution code:
import numpy as np
def check(a,b,c,d):
    z = a
    ans = 'Yes'
    if a < b:
        ans = 'No'
        return ans
    z_list = [z]
    for k in range(10000000):
        print(z)
        x = (z - c)//b
        if x <= 0:
            x = 1
        z = z - b * x
        if z < 0:
            ans = 'No'
            break
        if z <= c:
            z += d
            if b > d:
                ans = 'No'
                break
            elif b == d:
                ans = 'Yes'
                break
            elif b < d:
                x = int(np.ceil((c - z)/(d - b))) + 1
                z = z + x * (d-b)
        
        if z in z_list:
            ans = 'Yes'
            break
        z_list.append(z)
#         print(z)
    return ans


t = int(input())
a = []
b = []
c = []
d = []
for k in range(t):
    aa,bb,cc,dd = list(map(int,input().split()))
    a.append(aa)
    b.append(bb)
    c.append(cc)
    d.append(dd)

aa = a
bb = b
cc = c
dd = d

for a,b,c,d in zip(aa,bb,cc,dd):
    ans = check(a,b,c,d)
    print(ans)

Submission status: Wrong Answer

Solution code:
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 = (ama + y[1]) % mo
        if to == 0:
          if ama<= y[2]:
            print("Yes")
          else:
              print("No")
        elif to <= y[1]-y[2]-1:
          print("No")
        else:
          print("Yes")
  else:
    print("Yes")

Submission status: Wrong Answer

Solution code:

def main():
    t = int(input())
    A=[]
    B=[]
    C=[]
    D=[]

    for i in range(t):
        a,b,c,d = map(int,input().split())
        A.append(a)
        B.append(b)
        C.append(c)
        D.append(d)

    for i in range(t):
        ans = "Yes"

        if A[i] < B[i] or B[i] > D[i]:
            print("No")
            continue

        if B[i]-1 <= C[i]:
            print("Yes")
            continue

        lst = []

        tmp = (A[i] + D[i]) % B[i]
        if tmp > C[i]:
                print("No")
                continue

        lst.append(tmp)

        for j in range(1,B[i]):
            tmp = (tmp + D[i]) % B[i]

            if tmp > C[i]:
                ans = "No"
                break

            if tmp in lst or len(lst) > 1000:
                break

            lst.append(tmp)

        print(ans)


if __name__ == "__main__":
        main()

Submission status: Wrong Answer

Solution code:
n = int(input())

for _ in range(n):
    a , b, c, d = map(int, input().split())
    if a < b or d < b:
        print("No")
        continue
    if b <= c :
        print("Yes")
        continue
    s = a % b
    l = d % b
    if l == 0 :
        if s <= c:
            print("Yes")
            continue
        else :
            print("No")
            continue
    tmp = -((s- b) // l) 
    tmp = (tmp-1) * l + s
    if tmp <= c :
        print("Yes")
    else :
        print("No")

Submission status: Wrong Answer

Solution code:
t = input()
result = []
hist = []
for i in range(int(t)):
	data = input().split()
	a = int(data[0])
	b = int(data[1])
	c = int(data[2])
	d = int(data[3])
	hist.clear()
	while True:
		if a < b:
			result.append("No")
			break
		n = int((a / b))
		a -= b * n
		if a <= c:
			a += d
		if a in hist:
			result.append("Yes")
			break
		else:
			hist.append(a)
			if len(hist) > 30:
				if min(hist) > a:
					result.append("No")
					break
			if len(hist) > 40:
				result.append("Yes")
				break
		if (len(hist) == 5) & (b < d) & (b < c):
			result.append("Yes")
			break
for i in range(int(t)):
	print(result[i])

Submission status: Wrong Answer

Solution code:
t=int(input())
for i in range(t):
    a,b,c,d=map(int,input().split())
    if a<b:
        print('No')
    else:
        aa=a
        bb=b
        count=(aa-c)//bb
        e=aa-b*count
        for j in range(100):
            e=e-b
            if e>0 and e<c:
                e+=d
            elif e<0:
                print('No')
                break
            else:
                pass
            if j==99:
                print('Yes')
                break
            else:
                pass

Submission status: Wrong Answer

Solution code:
t = input()
result = []
hist = []
for i in range(int(t)):
	data = input().split()
	a = int(data[0])
	b = int(data[1])
	c = int(data[2])
	d = int(data[3])
	hist.clear()
	while True:
		if a < b:
			result.append("No")
			break
		n = int((a / b))
		a -= b * n
		if a <= c:
			a += d
		if a in hist:
			result.append("Yes")
			break
		else:
			hist.append(a)
			if len(hist) < 30:
				if min(hist) > a:
					result.append("No")
					break
			if len(hist) > 40:
				result.append("Yes")
				break
		if (len(hist) == 5) & (b < d) & (b < c):
			result.append("Yes")
			break
for i in range(int(t)):
	print(result[i])

Submission status: Wrong Answer

Solution code:
t = int(input())
for i in range(t):
    able = "Yes"
    a,b,c,d = map(int, input().split())
    if a - b < 0:
        able = "No"
    else:
        x = c+(a-c)%b
        if x <= c:
            x+=d
        for i in range(10000):
            x-=b
            if x >= 0:
                if x <= c:
                    x+=d
            else:
                able = "No"
                break
    print(able)

Submission status: Wrong Answer

Solution code:
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:
        print('Yes')
        continue

    if b - c == 1:
        print('Yes')
        continue
    if a % 2 == 0 and d % 2 == 0 and b % 2 == 0 and b - c == 2:
        print('Yes')
        continue
    print('No')

Submission status: Wrong Answer

Solution code:
t = int(input())
for i in range(t):
    able = "Yes"
    a,b,c,d = map(int, input().split())
    if a - b < 0:
        able = "No"
    else:
        x = c+(a-c)%b
        if x <= c:
            x+=d
        for i in range(5000):
            x-=b
            if x >= 0:
                if x <= c:
                    x+=d
            else:
                able = "No"
                break
    print(able)

Submission status: Wrong Answer

Solution code:
T = int(input())
a = []
for i in range(T):
    a.append(list(map(int, input().split())))
for r in a:
    a, b, c, d = r[0], r[1], r[2], r[3]
    s = a


    s_list = []
    while True:
        s_list.append(s)


        if s > 100:
            s -= b*((s//b)-1)
            while s <= c:
                s+= c
        s -= b
        if s in s_list:
            print('yes')
            break
        s_list.append(s)


        if s <0:
            print('No')
            break
        if s != s_list[-1]:
            if s in s_list:
                print('yes')
                break

        if s <= c:
            s += d
            s_list.append(s)
            if s != s_list[-1]:
                if s in s_list:
                    print('yes')
                    break

Submission status: Wrong Answer

Solution code:
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: #BとCの差が1より小さければ何が来てもOK
        ans = "Yes"
    elif A % B > C:
        ans = "No"
    elif D % B != 0:
        if ((C -(A%B)) % (D % B)) == 0 and D % B == B - C:
            ans = "Yes"
        elif ((C -(A%B)) % (D % B)) == 0 and D % B != B - C:
            ans = "No"
        elif B - C > (C -(A%B)) % (D % B):
            ans = "No"

    print(ans)
    L = []

Submission status: Wrong Answer

Solution code:
N = int(input())

def check_unique(list_tmp):
    L1 = len(list_tmp)
    L2 = len(list(set(list_tmp)))
    if L1 == L2:
        return True
    else:
        return False

def test(A,B,C,D):
    bottles = A
    bottles_log = []
    while bottles >0:
        bottles_log.append(bottles)
        #print(bottles)
        
        if check_unique(bottles_log):
            if bottles >= B:
                bottles = bottles -(A//B) * B
                if bottles <= C :
                    bottles += D 
            else:
                return("No")
            
        else:
            return("Yes")
        
    return("No")

for i in range (N):
    A,B,C,D =  map(int,input().split())
    print(test(A,B,C,D))

Submission status: Wrong Answer

Solution code:
t = int(input())
for i in range(t):
    able = "Yes"
    a,b,c,d = map(int, input().split())
    if a - b < 0:
        able = "No"
    else:
        x = c+(a-c)%b
        if x <= c:
            x+=d
        for i in range(2000):
            x-=b
            if x >= 0:
                if x <= c:
                    x+=d
            else:
                able = "No"
                break
    print(able)

Submission status: Wrong Answer

Solution code:
t = int(input())

for _ in range(t):
    a, b, c, d = map(int, input().split())
    cond = True
    
    if a < b or b > d or (a % b) > c:
        cond = False
    
    if b != d and b > (c + 1):
        tmp = (((c - (a % b)) // (d - b)) + 1) * (d - b) +  (a % b)
        if tmp > c and tmp < b:
            cond = False
        
    if cond:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding:utf-8 -*-

T = int(input())
L = []

for i in range(T):
     L.append(list(map(int, input().split())))
P=0
F=0
for i in range(T):
     A=L[i]
     #print(A)
     P=A[0]
     X = P%A[1]
     if A[0]<A[1]:
         F=1
         print("No")
     elif X>A[2]:
         F=1
         print("No")
     elif (A[2]+A[3]<A[0]):
         F=1
         print("No")
     P=X+A[3]
     for i in range(100):
         P=P-A[1]
         if (P<0) and (F==0):
             F=1
             print("No")
             break;
         if P<=A[2]:
             P = P+A[3]
     if F==0:
         print("Yes")
     P=0
     F=0

Submission status: Wrong Answer

Solution code:
def judge(a,b,c,d):
    #calc border
    if a-c<0:
        border = 0
    else:
        if (a-c)%b == 0:
            border = int((a-c)/b)
        else:           
            border = int((a-c)/b)+1
        
    start = a-border*b
    return start
    
def check(a,b,c,d):
    if a-b<0:
        return False
    
    ans = judge(a,b,c,d)
    b_list = []
    while not ans in b_list:
        b_list.append(ans)
        if ans <= c:
            a = ans+d
        else:
            a = ans
        ans = judge(a,b,c,d)
        if ans < 0:
            return False
    
    return True
 

N = int(input())
ABCD = []
for i in range(N):
    ABCD.append(map(int, input().split()))

for a,b,c,d in ABCD:
    if check(a,b,c,d):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
t=int(input())
for _ in range(t):
    a,b,c,d=map(int,input().split())
    e=b*(max((a-c)//b,1))
    a-=e
    while a>c:
        a-=b
    if a<0:
        print('No')
        continue
    if d<b:
        print('No')
        continue
    if c<=b and d>b:
        """
        while a<=c:
            a+=(d-b)
        """
        a+=(d-b)*(c//(d-b)-100)
        while a<=c:
            a+=(d-b)
        if a<b:
            print('No')
            continue
    print('Yes')

Submission status: Wrong Answer

Solution code:
t=int(input())
abcd=[list(map(int, input().split())) for _ in range(t)]
a=[abcd[i][0] for i in range(t)]
b=[abcd[i][1] for i in range(t)]
c=[abcd[i][2] for i in range(t)]
d=[abcd[i][3] for i in range(t)]
for i in range(t):
    if b[i]>d[i] or b[i]>a[i]:#簡単な破綻
        j='No'
    elif b[i]==d[i]:
        if ((a[i]-b[i])%d[i])>c[i] and ((a[i]-b[i])%d[i])<b[i]:
            j='No'
        else:
            j='Yes'
    else:
        if abs(2*b[i]-a[i])%(d[i]-b[i])==0:
            t=b[i]-abs(2*b[i]-a[i])%(d[i]-b[i])-(d[i]-b[i])
        else:
            t=b[i]-abs(2*b[i]-a[i])%(d[i]-b[i])
        if t>c[i]:
            j='No'
        else:
            j='Yes'    
    print(j)

Submission status: Wrong Answer

Solution code:
#A = 初期値　B = 一日の購入　C = 乳化のボーダー　D =在庫の増やす数

#A > B
#D % B >= B - C

size = int(input())
data = []
flag = 0

for i in range(size):
    ip = input().split()
    for j in ip:
        data.append(int(j))
    #定義
    store = data[0]
    buy = data[1]
    bord = data[2]
    charge = data[3]
    buf = []
    #最初の処理
    store = store % buy
    if store >= bord:
        flag = 1
    #定常処理
    while store not in buf:
        buf.append(store)
        store = (store + charge) % buy
        if store >= bord:
            flag = 1
            break

#    print(buf)
    if flag == 1:
        print("No")
        flag = 0
    else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
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:
        print('Yes')
        continue

    if b - c == 1:
        print('Yes')
        continue
    if d % 2 == 0 and b % 2 == 0 and b - c == 2:
        print('Yes')
        continue
    print('No')

Submission status: Wrong Answer

Solution code:
t=int(input())
abcd=[list(map(int, input().split())) for _ in range(t)]
a=[abcd[i][0] for i in range(t)]
b=[abcd[i][1] for i in range(t)]
c=[abcd[i][2] for i in range(t)]
d=[abcd[i][3] for i in range(t)]
for i in range(t):
    if b[i]>d[i] or b[i]>a[i]:#簡単な破綻
        j='No'
    elif b[i]==d[i]:
        if ((a[i]-b[i])%d[i])>c[i] and ((a[i]-b[i])%d[i])<b[i]:
            j='No'
        else:
            j='Yes'
    else:
        if abs(2*b[i]-a[i])%(d[i]-b[i])==0:
            t=b[i]-(2*b[i]-a[i])%(d[i]-b[i])-(d[i]-b[i])
        else:
            t=b[i]-(2*b[i]-a[i])%(d[i]-b[i])
        if t>c[i]:
            j='No'
        else:
            j='Yes'    
    print(j)

Submission status: Wrong Answer

Solution code:
t=int(input())
for _ in range(t):
    a,b,c,d=map(int,input().split())
    e=b*(max((a-c)//b,1))
    a-=e
    while a>c:
        a-=b
    if a<0:
        print('No')
        continue
    if d<b:
        print('No')
        continue
    if c<=b and d>b:
        """
        while a<=c:
            a+=(d-b)
        """
        a+=(d-b)*(c//(d-b)-10)
        while a<=c:
            a+=(d-b)
        if a<b:
            print('No')
            continue
    print('Yes')

Submission status: Wrong Answer

Solution code:
T=input()
for i in range(T):
	A,B,C,D=map(int,raw_input().split())
	if A<B:
		print "No"
	elif B>D:
		print "No"
	else:
		A=B+A%B
		D=B+D%B
		#print A,B,C,D
		if A==B==D:
			print "Yes"
		elif abs(B-C)-1>=1:
			if abs(B-C)-1==1 and ( A%2 or B%2 or D%2 )==0:
				print "Yes"
			elif A%B<=C and B==D:
				print "Yes"
			else:
				print "No"
		elif abs(B-C)-1==0:
			print "Yes"

Submission status: Wrong Answer

Solution code:
from sys import stdin

t = stdin.readline()
t_i = int(t)
data = [stdin.readline().rstrip().split() for _ in range(t_i)]
#print(data)
for i in range(t_i) :
    a = int(data[i][0])
    b = int(data[i][1])
    c = int(data[i][2])
    d = int(data[i][3])
    #print(a, b, c, d)
    if a < b :
        print("No")
    elif b > d :
        print("No")
    elif a % b > c and a % b < b :
        print("No")
    else :
        #print("Yes")
    
        stock = a
        count = 0
        while True :
            stock = stock - b
            if stock < 0 :
                print("No")
                break
            if stock <= c :
                stock = stock + d
            count = count + 1
            if count > 10000 :
                print("Yes")
                break

Submission status: Wrong Answer

Solution code:
t = int(input())
c = [list(map(int,input().split())) for i in range(t)]
for i in range(t):
    mem1 = c[i][0] % c[i][1]
    mem2 = c[i][3] % c[i][1]
    mem3 = mem1
    cnt = 0
    while 1 :
        if c[i][0] < c[i][1]:
            print("No")
            break; 
        elif c[i][3] < c[i][1]:
            print("No")
            break;      
        elif mem2 == 0 :
            if c[i][1] - c[i][2] > 1 and c[i][2] < mem1 < c[i][1]:
                print("No")    
                break;
            else :
                print("Yes")
                break;
        elif mem2 % 2 == 1 and c[i][1] - c[i][2] > 1:
            print("No")  
            break;          
        elif mem2 % 2 == 0 and mem1 % 2 == 0 and c[i][1] - c[i][2] == 2 and (c[i][1]-1)%2 == 1:
            print("Yes")  
            break;
        elif mem2 % 2 == 0 and mem1 % 2 == 1 and c[i][1] - c[i][2] == 2 and (c[i][1]-1)%2 == 0:
            print("Yes")  
            break;
        elif c[i][1] - c[i][2] == 1:
            print("Yes")  
            break;
        else :
            print("No")
            break;

Submission status: Wrong Answer

Solution code:
#A = 初期値　B = 一日の購入　C = 乳化のボーダー　D =在庫の増やす数

#A > B
#D % B >= B - C

size = int(input())
data = []
flag = 0

for i in range(size):
    ip = input().split()
    for j in ip:
        data.append(int(j))
    #定義
    store = data[0]
    buy = data[1]
    bord = data[2]
    charge = data[3]
    buf = []
    #最初の処理
    store = store % buy
    if store >= bord:
        flag = 1
    #定常処理
    while store not in buf:
        buf.append(store)
        store = (store + charge) % buy
        if store >= bord:
            flag = 1
            break

#    print(buf)
    if flag == 1:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
t=int(input())
for _ in range(t):
    a,b,c,d=map(int,input().split())
    e=b*(max((a-c)//b,1))
    a-=e
    while a>c:
        a-=b
    if a<0:
        print('No')
        continue
    if d<b:
        print('No')
        continue
    if c<=b and d>b:
        """
        while a<=c:
            a+=(d-b)
        """
        a+=(d-b)*(c//(d-b))-a
        while a<=c:
            a+=(d-b)
        if a<b:
            print('No')
            continue
    print('Yes')

Submission status: Wrong Answer

Solution code:
Y = "Yes"
N = "No"
T = int(input())
for _ in range(T):
	A, B, C, D = [int(x) for x in input().split()]
	if A < B or B > D:
		print(N)
	elif B <= C:
		print(Y)
	else:
		if A > C:
			A -= ((A-C)//B)*B
			if A > C:
				A -= B
		if A < 0:
			print(N)
			continue
		x = D-B
		if x == 0:
			print(Y)
			continue
		B-=A
		C-=A
		y = (B//x)*x
		if (y == B and B-x <= C) or y <= C:
			print(Y)
		else:
			print(N)

Submission status: Wrong Answer

Solution code:
from sys import stdin

t = stdin.readline()
t_i = int(t)
data = [stdin.readline().rstrip().split() for _ in range(t_i)]
#print(data)
for i in range(t_i) :
    a = int(data[i][0])
    b = int(data[i][1])
    c = int(data[i][2])
    d = int(data[i][3])
    #print(a, b, c, d)
    if a < b :
        print("No")
    elif b > d :
        print("No")
    elif a % b > c and a % b < b :
        print("No")
    else :
        #print("Yes")
    
        stock = a
        count = 0
        while True :
            stock = stock - b
            if stock < 0 :
                print("No")
                break
            if stock <= c :
                stock = stock + d
            count = count + 1
            if count > 20 :
                print("Yes")
                break

Submission status: Wrong Answer

Solution code:
T=int(input())

for cnt in range(T):
  A,B,C,D=map(int,input().split())
  if(B > D or A < B):
    print("No")
    continue
  if(B <= C):
    print("Yes")
    continue

  A = A % B + B
  Zaiko = A
  lista = []
  i = 0
  while(i < 100):
    Zaiko = Zaiko - B
    #print(Zaiko)
    if(Zaiko < 0):
      print("No")
      break
    if(Zaiko <= C):
      Zaiko += D
      Zaiko = Zaiko % B + B
    #if(Zaiko in lista ):
    #  print("Yes")
    #  break
    #lista.append(Zaiko)
    i += 1
    if(i == 100):
      if(C > B - D):
        print("Yes")
      else:
        print("No")
  #print(A,B,C,D)

Submission status: Wrong Answer

Solution code:
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 a % b > c:
        return 'No'
    if c < b:
        if d % b == 0:
            return 'Yes'
        if b % 2 == 1 or a % 2 == 1 or d % 2 == 1:
            if b - c > 1:
                return 'No'
        else:
            if b - c > 2:
                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()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding:utf-8 -*-

T = int(input())
L = []

for i in range(T):
     L.append(list(map(int, input().split())))
P=0
F=0
for i in range(T):
     A=L[i]
     #print(A)
     P=A[0]
     X = P%A[1]
     if A[0]<A[1]:
         F=1
         print("No")
     elif X>A[2]:
         F=1
         print("No")
     P=X+A[3]
     for i in range(100):
         P=P-A[1]
         if (P<0) and (F==0):
             F=1
             print("No")
             break;
         if P<=A[2]:
             P = P+A[3]
     if F==0:
         print("Yes")
     P=0
     F=0

Submission status: Wrong Answer

Solution code:
T=int(input())

for cnt in range(T):
  A,B,C,D=map(int,input().split())
  if(B > D or A < B):
    print("No")
    continue
  if(B <= C):
    print("Yes")
    continue

  A = A % B + B
  Zaiko = A
  lista = []
  i = 0
  while(i < 100):
    Zaiko = Zaiko - B
    #print(Zaiko)
    if(Zaiko < 0):
      print("No")
      break
    if(Zaiko <= C):
      Zaiko += D
      Zaiko = Zaiko % B + B
    if(Zaiko in lista ):
      print("Yes")
      break
    lista.append(Zaiko)
    i += 1
    if(i == 100):
      if(C >= B - D):
        print("Yes")
      else:
        print("No")
  #print(A,B,C,D)

Submission status: Wrong Answer

Solution code:
# 2
n = int(input())
a=[]
for i in range(n):
    a.append(list(map(int, input().split())))
# print(a)
for i in a:
    print('Yes' if i[0]>=i[1] & i[1]-1<i[2] & i[1]<=i[3] else 'No')

Submission status: Wrong Answer

Solution code:
T = int(input())
for t in range(T):
    [a, b, c, d] = list(map(int, input().split()))
    if (a < b):
        print("No")
        continue
    if (d < b):
        print("No")
        continue
    if (b <= c):
        print("Yes")
        continue
    if ((a % b) > c):
        print("No")
        continue
    if (d % b == 0):
        print("Yes")
        continue
    if (c % b == b - 1):
        print("Yes")
        continue
    if (b % (d % b) == 0):
        k = (c - (a % b) + b * b) % b / (d % b)
        A = a % b + (k + 1) * (d % b)
        if (A % b > c):
            print("No")
        else:
            print("Yes")
        continue
    print("No")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding:utf-8 -*-

T = int(input())
L = []

for i in range(T):
     L.append(list(map(int, input().split())))
P=0
F=0
for i in range(T):
     A=L[i]
     #print(A)
     P=A[0]
     X = P%A[1]
     if A[0]<A[1]:
         F=1
         print("No")
     elif X>A[2]:
         F=1
         print("No")
     P=X+A[3]
     for i in range(11):
         P=P-A[1]
         if (P<0) and (F==0):
             F=1
             print("No")
             break;
         if P<=A[2]:
             P = P+A[3]
     if F==0:
         print("Yes")
     P=0
     F=0

Submission status: Wrong Answer

Solution code:
t = int(input())

for _ in range(t):
    a, b, c, d = map(int, input().split())
    cond = True
    
    if a < b or b > d or (a % b) > c:
        cond = False
    
    if b != d and b > (c + 1):
        if (b - c) > (d - b):
            cond = False
        else:
            tmp = (((c - (a % b)) // (d - b)) + 1) * (d - b) +  (a % b)
            if tmp > c and tmp < b:
                cond = False
        
    if cond:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
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) // (d - b) != ((c - ( a % b ))) // (d - b):
            return False
    return True

for i in range(n):
    if check(i):
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:



aa=int(input())
N=[0 for i in range(aa)]
for i in range(aa):
  bb=input()
  #print(b)
  N[i]=bb.split()




def aaa(n):

  a=int(N[n][0])
  b=int(N[n][1])
  c=int(N[n][2])
  d=int(N[n][3])

  e=a-a//b*b
  f=d-d//b*b
  




  if a<b or d<b :
    return "No"
  else:

  
    if f!=0 :
      g=(b-e)//f
      e=e+f*g
      while e>c:
        if e<b :
          return "No"
          
        e-=f

        #print(e)
        #print(f)
  #print("while")
    else:
      if e>c :
        return "No"

  return "Yes"

for i in range(aa):
  print(aaa(i))

Submission status: Wrong Answer

Solution code:
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:
        print('Yes')
        continue

    if b - c == 1:
        print('Yes')
        continue
    if d % 2 == 0 and b - c == 2:
        print('Yes')
        continue
    print('No')

Submission status: Wrong Answer

Solution code:
t = int(input())
a = []
b = []
c = []
d = []
for i in range(t):
    tmp = list(map(int, input().split(" ")))
    a.append(tmp[0])
    b.append(tmp[1])
    c.append(tmp[2])
    d.append(tmp[3])

for i in range(t):
    if(a[i] < b[i]): print("No")
    elif(b[i] > d[i]): print("No")
    elif(b[i] <= c[i]): print("Yes")
    else:
        remain = a[i] - (a[i] // b[i]) * b[i]
        increase = d[i] - b[i]
        if(increase == 0):
            if(c[i] >= remain): print("Yes")
            elif(b[i] > remain): print("No")
            else: print("Yes")
        else:
            if(c[i] >= remain): remain += ((c[i] - remain) // increase) * increase
            if(c[i] >= remain): remain += increase
            if(remain < b[i]): print("No")
            else: print("Yes")

Submission status: Wrong Answer

Solution code:
t = int(input())
for i in range(t):
    able = "Yes"
    a,b,c,d = map(int, input().split())
    if a - b < 0:
        able = "No"
    else:
        x = c+(a-c)%b
        if x <= c:
            x+=d
        for i in range(1000):
            x-=b
            if x >= 0:
                if x <= c:
                    x+=d
            else:
                able = "No"
                break
    print(able)