TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
a = A//K
# b = B//K
C = K * (a+1)

# if K > B:
    # print ("NG")


if C <= B:
    print ("OK")
else:
    print ("NG")

import math

# K = 1
# A, B = 11, 11

K = int(input())
A, B = map(int, input().split())

a = math.ceil(A/K)
# b = B//K
C = K * (a)

# if K > B:
    # print ("NG")


if C <= B:
    print ("OK")
else:
    print ("NG")

Verdicts: Runtime Error

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
K=int(input())
A,B=list(map(int,input().split()))
c=K
while c<=B:
  if c>=A and c<=B:
    print("OK")
    break
else:
  print("NG")

K=int(input())
A,B=list(map(int,input().split()))
c=K
while c<=B:
  if c>=A and c<=B:
    print("OK")
    break
  else:
    c += K
else:
  print("NG")


Verdicts: Time Limit Exceeded

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
import math
A,B,N = map(int,input().split())
maxn = 0
sec =False
for x in range(1,N+1):
    tmp = math.floor((A*x)/B)-A*(math.floor(x/B))
    if maxn < tmp:
        maxn = tmp
    if tmp == 0:
        if sec ==True:
            break
        else:
            sec =True
    
print(maxn)


N = int(input())
A,B = map(int,input().split())
ans =0

for x in range(A,B+1):
    if x%N ==0:
        ans =1
        break
if ans ==1:
    print("Yes")
else:
    print("No")

#A
N = int(input())
A,B = map(int,input().split())
ans =0

for x in range(A,B+1):
    if x%N ==0:
        ans =1
        break
if ans ==1:
    print("OK")
else:
    print("NG")


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
def solve():
    k=int(input())
    a,b=map(int,input().split())
    ans='NG'
    for i in range(a,b+1):
        if(k%i==0):
            ans="OK"
            break
    print(ans)
solve()


def solve():
    k=int(input())
    a,b=map(int,input().split())
    ans='NG'
    for i in range(a,b+1):
        if(i%k==0):
            ans="OK"
            break
    print(ans)
solve()

Verdicts: Wrong Answer

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
K=int(input())
ans=False
M,N = map(int,input().rstrip().split(" ")) 

for number in range(M,N+1):
    if number%K==0:
        ans=True
if ans:
    print("YES")
else:
    print("NG")

K=int(input())
ans = False
M,N = map(int,input().rstrip().split(" ")) 

for number in range(M,N+1):
    if number%K==0:
        ans = True
if ans:
    print("YES")
else:
    print("NG")

K=int(input())
M,N = map(int,input().rstrip().split(" ")) 

for number in range(M,N+1):
    if number%K==0:
        ans=True
if ans:
    print("YES")
else:
    print("NG")

K=int(input())
ans = False
M,N = map(int,input().rstrip().split(" ")) 

for number in range(M,N+1):
    if number%K==0:
        ans = True
if ans:
    print("OK")
else:
    print("NG")

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
k = input()
a, b = map(int, input().split())
if (b % k) - (a % k) <= 0 or b - a >= 0:
  print("OK")
else:print("NG")


k = input()
a, b = map(int, input().split())
ka = a // k
kb = b // k
if b - a >= k - 1:
  print("OK")
elif kb - ka > 0:
  print("OK")
else:
  print("NG")

k = input()
a, b = map(int, input().split())
if b//k - a//k <= 0 or b - a >= 0:
  print("OK")
else:print("NG")

k = int(input())
a, b = map(int, input().split())
ka = a // k
kb = b // k
if b - a >= k - 1:
  print("OK")
elif kb - ka > 0:
  print("OK")
elif a % k == 0 or b % k == 0:
  print("OK")
else:
  print("NG")


Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
x=int(input())
result=100
count=0
while x>result:
    count+=1
    result+=result//100
print(count)

k=int(input())
a,b=map(int,input.split())
if b-a>k:
    print('OK')
else:
    print('NG')

k=int(input())
a,b=map(int,input().split())
x=b%k
y=b-x
if b-a>k:
    print('OK')
elif y>a:
    print('OK')
elif a%k==0:
    print('OK')
else:
    print('NG')

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
k = int(input())
a, b = map(int, input().split())
cnt = 0

for i in range(a, b+1):
    if i % k == 0:
        print('OK!')
        cnt += 1
        break

if cnt == 0:
    print('NG')

k = int(input())
a, b = map(int, input().split())
cnt = 0

for i in range(a, b+1):
    if i % k == 0:
        print('OK')
        cnt += 1
        break

if cnt == 0:
    print('NG')

Verdicts: Wrong Answer

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
import itertools
N, M, Q = map(int, input().split())
a = [0]*Q
b = [0]*Q
c = [0]*Q
d = [0]*Q
for i in range(Q):
     a[i], b[i], c[i], d[i] = map(int, input().split())
ans = 0
for A in combinations_with_replacement(range(1, M+1), N):
    tmp = 0
    for i in range(Q):
        if A[b[i]-1] - A[a[i]-1] == c[i]:
            tmp += d[i]
    ans = max(ans, tmp)
print(ans)

K = int(input())
A, B =map(int, input().split())
num = 0

for i in range(A, B+1):
    if i%K ==0:
        num +=1

print('OK' if num >0 else 'NG')

Verdicts: Runtime Error

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
K = input()
(A, B) = map(int, input().split())
buf = True
for i in range(A, B + 1):
  if(i % K == 0):
    print("OK")
	return 
print("NG")

K = input()
(A, B) = map(int, input.split())
buf = True
for i in range(A, B + 1):
  if(i % K == 0):
    print("OK")
	return 
print("NG")

K = int(input())
(A, B) = map(int, input().split())
buf = True
for i in range(A, B + 1):
  if(i % K == 0):
    print("OK")
    buf = False
    break
if buf:
  print("NG")

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
K = int(input())
A, B = map(int, input().split())

i = B - A

for i in range(A, B + 1):
    if i % K == 0:
        c = 1

if c == 1:
    orint('OK')
else:
    print('NG')

K = int(input())
A, B = map(int, input().split())

i = B - A
c = 0

for i in range(A, B + 1):
    if i % K == 0:
        c = 1

if c == 1:
    print('OK')
else:
    print('NG')

Verdicts: Runtime Error

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
from inspect import k

K= map(int, input().split())
a,b = map(int, input().split())

for i in range(a,b):
    if i % k ==0:
        print('OK')
        break
else:
    print('NG')

k= int(input())
a,b = map(int, input().split())

for i in range(a,b+1):
    if i % k ==0:
        print('OK')
        break
else:
    print('NG')
       


Verdicts: Wrong Answer

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
K = int(input())
A,B = map(int,input().split())
if A == B:
  if K%A == 0:
    print('OK')
  else:
    print('NG')
else:
  if K//A == K//B:
    print('NG')
  else:
    print('OK')


K = int(input())
A,B = map(int,input().split())

if K//A == K//B:
  print('NG')
else:
  print('OK')

K = int(input())
A,B = map(int,input().split())
if A == B:
	if K//A == 0:
        print('OK')
	else:
        print('NG')
else:
	if K//A == K//B:
		print('NG')
	else:
		print('OK')


K = int(input())
A,B = map(int,input().split())
if A == B:
	if K//A == 0:
        print('OK')
    else:
		if K//A == K//B:
			print('NG')
		else:
			print('OK')

K = int(input())
A,B = map(int,input().split())

for i in range(1000):
  if K*i >= A and K*i <= B:
    print('OK')
    break
else:
  print('NG')

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
from math import ceil
from math import floor
k=int(input())
a,b=map(int,input().split())
l=ceil(a/k)
print(l)
r=floor(b/k)
print(r)
if l<=r:
    print('OK')
else:
    print('NG')

a=int(input())
b,c=map(int,input().split())
num=0
res=b//a
rem=b%a
if rem!=0:
  num=res+rem
  if num>b and num<c:
    print('OK')
elif((b+a)> b and (b+a)<c):
  print('OK')
else:
  print('NG')
    

k=int(input())
a,b=map(int,input().split())
largest=(b//k)*k
if a<=largest:
    print('OK')
else:
    print("NG")

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
k = int(input())
a, b = [int(i) for i in input().split()]

for i in range(a, b+1):
  if i % k == 0:
    print("OK")
else:
  print("NG")

k = int(input())
a, b = [int(i) for i in input().split()]
 
for i in range(a, b+1):
  if i % k == 0:
    print("OK")
    break
else:
  print("NG")

Verdicts: Wrong Answer

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
K = int(input())
A, B = map(int, input().split())
ans = 'NG'
for i in range(A, B+1):
    if i % K == 0:
        print('OK')
        break
    
print(ans)

K = int(input())
A, B = map(int, input().split())

for i in range(A, B+1):
    if i % K == 0:
        print('OK')
    else:
        print('NG')

K = int(input())
A, B = map(int, input().split())
ans = 'NG'
for i in range(A, B+1):
    if i % K == 0:
        print('OK')
        break
else:
    print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
# A
K = int(input())
A, B = map(int,input().split())

if(A%K==0 and B%K==0 and B-A=>K):
    print('OK')
else:
    print('NG')

# A
K = int(input())
A, B = map(int,input().split())

if(A%K==0 and B%K==0 and B-A>=K):
    print('OK')
else:
    print('NG')

# A
K = int(input())
A, B = map(int,input().split())

if(A%K==0 or B%K==0 or (B-A>=K and B!=A):
    print('OK')
else:
    print('NG')

# A
K = int(input())
A, B = map(int,input().split())

if(A%K==0 or B%K==0):
    print('OK')
elif(B-A >= K - A%K):
    print('OK')
else:
    print('NG')

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
def main():
  k = int(input())
  a, b = map(int,input().split())
  if a%k==0 or b%k==0 or b-a<k:
    print('OK')
  else:
    print('NG')

if __name__ == '__main__':
  main()


def main():
  k = int(input())
  a, b = map(int,input().split())
  if a%k==0 or b%k==0 or b-a >= abs(k-a%k):
    print('OK')
  else:
    print('NG')

if __name__ == '__main__':
  main()


Verdicts: Wrong Answer

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
import math

x = int(input())

print(math.ceil(math.log(x / 100, 1.01)))

import math

x = int(input())

i = 0
n = 100
while n < x:
    n = math.floor(n * 1.01)
    i += 1

print(i)

k = int(input())
a, b = [int(i) for i in input().split(" ")]

kk = k
ok = False
while not ok:
    if kk >= a and kk <= b:
        print("OK")
        ok = True
    if kk > b:
        print("NG")
        ok = True
    kk = kk + k

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
money = int(input())
kane = 100
years = 0

while kane <= money:

    kane = kane * 1.01 
    math.floor(kane)
    years = years + 1
print(years)

hage = input()
hoge = input()

renji = hoge[0] - hoge[1]

e = hage

while e <= hage[1];
  	if hoge[0] <= e and hage[1] >= e;
  		print("OK")
    	break
	e = e + hage
if e > hage[1] or e < hage[0];
	print("NG")
    
	

# coding: utf-8

hage = int(input())
hoge = input().split()
 
hoge[0] = int(hoge[0])
hoge[1] = int(hoge[1])

renji = int(hoge[0]) - int(hoge[1])
 
e = hage
 
while e <= hoge[1]:
    if hoge[0] <= e and hoge[1] >= e:
        print("OK")
        break
    e = e + hage
if e > hoge[1] or e < hoge[0]:
    print("NG")

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
K=int(input())
A,B=map(int,input().split())
for i in range(1001):
  K+=K
  if A<=K and K<=B:
    print("OK")
    break
  if 1000<K:
    print("No")
    break

K=int(input())
A,B=map(int,input().split())
for i in range(1001):
  s=i*K
  if A<=s and s<=B:
    print("OK")
    break
  if 1000<s:
    print("NG")
    break

Verdicts: Wrong Answer

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
x = int(input())
a, b = map(int, input().split())
ans=0
for i in range(a,b+1):
  if x%i==0:
    ans=1
    break
if ans==1:
  print('OK')
else:
  print('NG')

x = int(input())
a, b = map(int, input().split())
for i in range(a,b+1):
  if x%i==0:
    print('OK')
  else:
    print('NG')

K=int(input())
A,B=map(int,input().split)
c=B-A
d=c-K
if d>-2:
  print('OK')
else:
  print('NG')

x = int(input())
a, b = map(int, input().split())
ans=0
for i in range(a,b+1):
  if x%i==0:
    ans=1
if ans==1:
  print('OK')
else:
  print('NG')

x = int(input())
a, b = map(int, input().split())
ans=0
for i in range(a,b+1):
  if i%x==0:
    ans=1
    break
if ans==1:
  print('OK')
else:
  print('NG')

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
M,A,B=(int(x) for x in input().split())
if B//M-A//M>=1:
  print("OK")
elif A%M=0:
  print("OK")
else:
  print("NO")

M,A,B=(int(x) for x in input().split())
if B//M-A//M>=1:
  print("OK")
elif A%M=0:
  print("OK")
else:
  print("NG")

import sys
N=int(input())
a,b=map(int,input().split())
for i in range(a,b+1):
  if i%N==0:
    print("OK")
    sys.exit()
print("NG")

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
n=int(input())
a,b=map(int,input().split())
ans='NG'
for i in range(a,b+1):
  if i%k==0:
    ans='OK'
print(ans)

n=int(input())
a,b=map(int,input().split())
ans='NG'
for i in range(a,b+1):
  if i%n==0:
    ans='OK'
print(ans)

Verdicts: Runtime Error

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
k = int(input())
l = input().split()
A, B = int(l[0]), int(l[1])

i = 0
while i * k <= B:
  print(i*k)
  if A <= i*k <= B:
    print('OK')
    break
  i += 1
else:
  print('NG')

k = input()
l = input().split()
A, B = l[0], l[1]

i = 0
while i * k <= B:
  if A<= i*k <= B:
    print('OK')

print('NG')

k = int(input())
l = input().split()
A, B = int(l[0]), int(l[1])


i = 0
num = i*k
while i * k <= B:
  print(i*k)
  if A <= i*k <= B:
    print('OK')
    break
  i += 1
else:
  print('NG')


k = input()
l = input().split()
A, B = l[0], l[1]

i = 0
while i * k <= B:
  if A <= i*k <= B:
    print('OK')
    break
  i += 1
else:
  print('NG')

k = int(input())
l = input().split()
A, B = int(l[0]), int(l[1])

i = 0
while i * k <= B:
  if A <= i*k <= B:
    print('OK')
    break
  i += 1
else:
  print('NG')

Verdicts: Wrong Answer

Time Limit Exceeded

Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
k = int(input())
a, b = map(int, input().split())

for i in range(a, b + 1):
  if i % k == 0:
    print("OK")
print("NG")


k = int(input())
a, b = map(int, input().split())

for i in range(a, b):
  if i % k ==0:
    print("OK")
  else:
    print("NO")

k = int(input())
a, b = map(int, input().split())

for i range(a, b):
  if i % k ==0:
    print("OK")
  else:
    print("NO")

k=int(input())
a,b=map(int,input().split())
for n in range(a, b+1):
    if n%k==0:
        print('OK')
        exit()
print('NG')


Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
import random
import math
LI = lambda: list(map(int,input().split()))
MI = lambda: map(int,input().split())
yes = lambda: print("Yes")
no = lambda: print("No")
I = lambda: list(input())
J = lambda x: "".join(x)
II = lambda: int(input())
SI = lambda: input()
#---khan17---template
t = II()
a,b = MI()
boo = False
for i in range(a,b+1):
	if a%t == 0:
		boo = True
		break
print("OK" if boo else "NG")

import random
import math
LI = lambda: list(map(int,input().split()))
MI = lambda: map(int,input().split())
yes = lambda: print("Yes")
no = lambda: print("No")
I = lambda: list(input())
J = lambda x: "".join(x)
II = lambda: int(input())
SI = lambda: input()
#---khan17---template
t = II()
a,b = MI()
boo = False
for i in range(a,b+1):
	if i%t == 0:
		boo = True
		break
print("OK" if boo else "NG")

Verdicts: Wrong Answer

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
a, b, n = map(int, input().split())

temp_prev = 0
temp_curr = 0
x = min(n, b-1)

while x <= n:
    temp_prev = temp_curr
    temp_curr = int(a * x / b) - a * int(x / b)
    x += 1.0

    if temp_curr <= temp_prev:
        break

print(max(temp_curr, temp_prev))

k = int(input())
a, b = map(int, input().split())

flag = 0

i = 1
while i * k <= b:
    if i*k >= a and i*k <=b:
        flag = 1
    
    i += 1

if flag:
    print("OK")
else:
    print("NG") 

Verdicts: Runtime Error

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
k = int(input())
a, b = map(int, input().split())

r = "NG"
for i in range(a, b+1):
  if i % k == 0:
    r = "ok"

print(r)
print(k, a,b)

k = int(input())
a, b = map(int, input().split())

r = "NG"
for i in range(a, b+1):
  if i % k == 0:
    r = "ok"

print(r)

import math

k = int(input())
a,b=map(int, input().split())

largest = math.floor((b/k)) * k
if (a <= largest):
  print("OK")
else:
  print("NG")

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
# coding: utf-8
# Your code here!

k=int(input())
a,b=map(int,input().split())
c=a-b
if(c>=k-1):
    print("OK")
elif(a%k+c>=k):
    print("OK")
else:
    print("NG")


k=int(input())
a,b=map(int,input().split())
c=b-a
if(a%k+c>=k)or(a%k==0):
    print("OK")
else:
    print("NG")


Verdicts: Wrong Answer

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):

def main():
    K = int(input())
    A, B = map(int, input().split())

    if B-A+1 >= K:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()



def main():
    K = int(input())
    A, B = map(int, input().split())

    for num in range(0,B+1,K):
        if A<=num and num <=B:
            print("OK")
            return

    print("NG")


if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
k = int(input())
a,b = map(int,input().split())

ans = 'NG'

for i in range(a,k+1):
    if i % k == 0:
        ans = 'OK'
print(ans)


k = int(input())
a,b = map(int,input().split())

ans = 'NG'

for i in range(a,b+1):
    if i % k == 0:
        ans = 'OK'
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
k = int(input())
a,b = list(map(int,input().slplit()))
ret = ""
q = a//k
if a <= q*k or (q+1)*k <= b:
    ret = "OK"
else:
    ret ="NG"
print(ret)

k = int(input())
a,b = list(map(int,input().split()))
ret = ""
q = a//k
if a <= q*k or (q+1)*k <= b:
    ret = "OK"
else:
    ret ="NG"
print(ret)

Verdicts: Runtime Error

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
K = int(input())
a,b = map(int,input().split())
c = 'NG'
for i in range(a,b+1):
  if i % K == 0:
    c = 'OK'
  break
print(c)


K = int(input())
A,B = map(int,input().split())
for i in range(a,b+1)
if i%K == 0
  print('OK')
else:
  print('No')

K = int(input())
a,b = map(int,input().split())
c = 'NO'
for i in range(a,b+1):
  if i % K == 0:
    c = 'OK'
  break
print(c)

K = int(input())
a,b = map(int,input().split())
for i in range(a,b+1):
  if i%K == 0:
  print('OK')
  else:
  print('No')

K = int(input())
a,b = map(int,input().split())
for i in range(a,b+1)
if i%K == 0
  print('OK')
else:
  print('No')


K = int(input())
a,b = map(int,input().split())
for i in range(a,b+1):
  if i%K == 0:
  print('OK')
else:
  print('No')


K = int(input())
a,b = map(int,input().split())
c = 'NG'
for i in range(a,b+1):
  if i % K == 0:
    c = 'OK'
  break
print(c)


K = int(input())
a,b = map(int,input().split())
for i in range(a,b+1):
  if i%K == 0:
  print('OK')
  else:
  print('No')
  return

K = int(input())
a,b = map(int,input().split())
c = 'NG'
for i in range(a,b+1):
  if i % K == 0:
    c = 'OK'
    break
print(c)


Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
K = int(input())
A, B = map(int, input().split())

a = int(A/K)
if A <= a*K <= B:
    print('OK')
else:
    print('NG')


K = int(input())
A, B = map(int, input().split())

a = int(A/K)
if A <= (a+1)*K <= B or A <= a*K <=B:
    print('OK')
else:
    print('NG')



Verdicts: Wrong Answer

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
k = int(input())
a, b = [int(x) for x in input().split()]

c = a // k
c += 0 if c*k == a else 1
d = c * k

print(d)
if a <= d <= b:
	print('OK')
else:
	print('NG')

k = int(input())
a, b = [int(x) for x in input().split()]

c = a // k
c += 0 if c*k == a else 1
d = c * k

if a <= d <= b:
	print('OK')
else:
	print('NG')


Verdicts: Wrong Answer

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
K=int(input())
A,B=map(int,input().split())

for i in range(A,B+1):
    if i%K==0:
        print('OK')
    else:
        print('NG')  

K=int(input())
A,B=map(int,input().split())
n=0
for i in range(A,B+1):
    if i%K==0:
        n+=1

if n==0:
    print('NG')
else:
    print('OK')                   


Verdicts: Wrong Answer

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
k=int(input())
s=input().split()
a=int(s[0])
b=int(s[1])
for i in range(a,b+1):
  if i%k==0:
    print("OK")
    break
print("NG")

k=int(input())
s=input().split()
a=int(s[0])
b=int(s[1])
for i in range(a,b+1):
  if i%k==0:
    print("OK")
print("NG")

k=int(input())
s=input().split()
a=int(s[0])
b=int(s[1])
for i in range(a,b+1):
  if i%k==0:
    print("OK")
    exit()
print("NG")

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi the Jumbo will practice golf.  His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).  If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Submission attempts (in order):
a,b,n=map(int,input().split())
a1=int(a*n/b)-a*int(n/b)
print(a1)

K=int(input())
A,B=map(int,input().split())
for n in range(A,B+1):
    if n%K==0:
        print("OK")
        exit()
print("NG")


Verdicts: Runtime Error

Accepted
Problem: Given are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).  Consider a sequence A satisfying the following conditions:    * A is a sequence of N positive integers.   * 1 \leq A_1 \leq A_2 \le \cdots \leq A_N \leq M.  Let us define a score of this sequence as follows:    * The score is the sum of d_i over all indices i such that A_{b_i} - A_{a_i} = c_i. (If there is no such i, the score is 0.)  Find the maximum possible score of A.

Submission attempts (in order):
import math

a, b, n = map(int, input().split())
x = min(n, b-1)
print(math.floor(a*x/b)-a*math.floor(x/b))

import math

a, b, n = map(int, input().split())

if n>=b:
	n1 = n//b*b-1
	ans = max((a*n//b)-a*(n//b), (a*n1//b)-a*(n1//b))
else:
	ans = (a*n//b)-a*(n//b)
print(ans)

import itertools

n, m, q = map(int, input().split())

a = [0]*q
b = [0]*q
c = [0]*q
d = [0]*q

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

ans = 0

for comb in itertools.combinations_with_replacement(range(1, m+1), n):
	j = 0
	for i in range(q):
		if comb[b[i]-1]-comb[a[i]-1] == c[i]:
			j += d[i]
	#print('{} {}'.format(comb, j))
	ans = max(ans, j)

print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).  Consider a sequence A satisfying the following conditions:    * A is a sequence of N positive integers.   * 1 \leq A_1 \leq A_2 \le \cdots \leq A_N \leq M.  Let us define a score of this sequence as follows:    * The score is the sum of d_i over all indices i such that A_{b_i} - A_{a_i} = c_i. (If there is no such i, the score is 0.)  Find the maximum possible score of A.

Submission attempts (in order):
from itertools import combinations_with_replacement
n, m, q = map(int, input().split())
A = combinations_with_replacement(range(1, m), n)
L = []

for _ in range(q):
    L.append(list(map(int, input().split())))

r = 0
for a in A:
    t = 0
    for l in L:
        if a[l[1] - 1] - a[l[0] - 1] == l[2]:
            t += l[3]
    if t > r:
        r = t
print(r)


from itertools import combinations_with_replacement
n, m, q = map(int, input().split())
A = combinations_with_replacement(range(m), n)
L = []

for _ in range(q):
    L.append(list(map(int, input().split())))

r = 0
for a in A:
    t = 0
    for l in L:
        if a[l[1] - 1] - a[l[0] - 1] == l[2]:
            t += l[3]
    if t > r:
        r = t
print(r)


Verdicts: Wrong Answer

Accepted
Problem: Given are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).  Consider a sequence A satisfying the following conditions:    * A is a sequence of N positive integers.   * 1 \leq A_1 \leq A_2 \le \cdots \leq A_N \leq M.  Let us define a score of this sequence as follows:    * The score is the sum of d_i over all indices i such that A_{b_i} - A_{a_i} = c_i. (If there is no such i, the score is 0.)  Find the maximum possible score of A.

Submission attempts (in order):
import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M, Q = map(int, readline().split())



A = np.array(list(itertools.combinations_with_replacement(range(1, M + 1), N)))

n = len(A) 
score = np.zeros(n) 

m = map(int, read().split())
for a, b, c, d in zip(m, m, m, m):
    cond = A[:, b - 1] - A[:, a - 1] == c
    score += d * cond

print(score.max())


import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M, Q = map(int, readline().split())



A = np.array(list(itertools.combinations_with_replacement(range(1, M + 1), N)))

n = len(A) 
score = np.zeros(n) [0,0,...,0] 

m = map(int, read().split())
for a, b, c, d in zip(m, m, m, m):
    cond = A[:, b - 1] - A[:, a - 1] == c
    score += d * cond

print(score.max())

import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M, Q = map(int, readline().split())



A = np.array(list(itertools.combinations_with_replacement(range(1, M + 1), N)))

n = len(A) 
score = np.zeros(n, np.int32) 

m = map(int, read().split())
for a, b, c, d in zip(m, m, m, m):
    cond = A[:, b - 1] - A[:, a - 1] == c
    score += d * cond

print(score.max())

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: Given are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).  Consider a sequence A satisfying the following conditions:    * A is a sequence of N positive integers.   * 1 \leq A_1 \leq A_2 \le \cdots \leq A_N \leq M.  Let us define a score of this sequence as follows:    * The score is the sum of d_i over all indices i such that A_{b_i} - A_{a_i} = c_i. (If there is no such i, the score is 0.)  Find the maximum possible score of A.

Submission attempts (in order):
import itertools
n, m, q = map(int, input().split())
abcd = [tuple(map(int, input().split())) for _ in range(q)]
Max = 0
for A in itertools.combinations_with_replacement(range(1, m + 1) n):
    #score = sum([d for a, b, c, d in abcd if C[b - 1] - C[a - 1] == c])
    score = 0
    for ai, bi, ci, di in abcd:
        if A[bi - 1] - A[ai - 1] == ci:
            score += di
    Max = max(Max, score)
    #print(C)
print(Max)

import itertools
n, m, q = map(int, input().split())
abcd = [tuple(map(int, input().split())) for _ in range(q)]
Max = 0
for A in itertools.combinations_with_replacement(range(1, m + 1), n):
    #score = sum([d for a, b, c, d in abcd if C[b - 1] - C[a - 1] == c])
    score = 0
    for ai, bi, ci, di in abcd:
        if A[bi - 1] - A[ai - 1] == ci:
            score += di
    Max = max(Max, score)
    #print(C)
print(Max)


Verdicts: Runtime Error

Accepted
Problem: Given are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).  Consider a sequence A satisfying the following conditions:    * A is a sequence of N positive integers.   * 1 \leq A_1 \leq A_2 \le \cdots \leq A_N \leq M.  Let us define a score of this sequence as follows:    * The score is the sum of d_i over all indices i such that A_{b_i} - A_{a_i} = c_i. (If there is no such i, the score is 0.)  Find the maximum possible score of A.

Submission attempts (in order):
import itertools
N, M, Q = input().split()
N = int(N)
M = int(M)
Q = int(Q)
num = [0]*Q
for i in range(Q):
  num[i] = [list(map(int,input().split()))]
num = list(range(1, M+1))
A = []
for v in itertools.combinations(num, N):
  A.append(list(v))
score = 0
for w in A:
  scoreX = 0
  for j in range(Q):
    b = num[j][1]
    a = num[j][0]
    if num[j][2] == w[b-1]-w[a-1]:
      scoreX += num[j][3]
  if scoreX > score:
    score = scoreX
print(str(score))

import itertools
N, M, Q = input().split()
N = int(N)
M = int(M)
Q = int(Q)
Num = [0 for i in range(Q)]
for i in range(Q):
  Num[i] = list(map(int,input().split()))
num = list(range(1, M+1))
A = []
for v in itertools.combinations_with_replacement(num, N):
  A.append(list(v))
score = 0
for w in A:
  scoreX = 0
  for j in range(Q):
    b = Num[j][1]
    a = Num[j][0]
    if Num[j][2] == w[b-1]-w[a-1]:
      scoreX += Num[j][3]
  if scoreX > score:
    score = scoreX
print(str(score))

Verdicts: Runtime Error

Accepted
Problem: Given are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).  Consider a sequence A satisfying the following conditions:    * A is a sequence of N positive integers.   * 1 \leq A_1 \leq A_2 \le \cdots \leq A_N \leq M.  Let us define a score of this sequence as follows:    * The score is the sum of d_i over all indices i such that A_{b_i} - A_{a_i} = c_i. (If there is no such i, the score is 0.)  Find the maximum possible score of A.

Submission attempts (in order):
n,m,q=map(int,input().split())
a=[]
b=[]
c=[]
d=[]
for i in range(q):
  A,B,C,D=map(int,input().split())
  a.append(A)
  b.append(B)
  c.append(C)
  d.append(D)
ans=0
M=[0,0,0,0,0,0,0,0,0,0,0]
for i in range(n):
  M[i]=1
cursor=n
breakflag=0
while True:
  ev=0
  for i in range(q):
    if M[b[i]-1]-M[a[i]-1]==c[i]:
      ev+=d[i]
  if ev>ans:
    ans=ev
  while True:
    if M[cursor-1]<m:
      M[cursor-1]+=1
      for i in range(cursor,n):
        M[i]=M[cursor-1]
      break
    cursor-=1
    if cursor==0:
      breakflag=1
      break
  if breakflag==1:
    break
print(ans)
    

n,m,q=map(int,input().split())
a=[]
b=[]
c=[]
d=[]
for i in range(q):
  A,B,C,D=map(int,input().split())
  a.append(A)
  b.append(B)
  c.append(C)
  d.append(D)
ans=0
M=[0,0,0,0,0,0,0,0,0,0,0]
for i in range(n):
  M[i]=1
cursor=n
breakflag=0
while True:
  ev=0
  for i in range(q):
    if M[b[i]-1]-M[a[i]-1]==c[i]:
      ev+=d[i]
  if ev>ans:
    ans=ev
  while True:
    if M[cursor-1]<m:
      M[cursor-1]+=1
      for i in range(cursor,n):
        M[i]=M[cursor-1]
      cursor=n
      break
    cursor-=1
    if cursor==0:
      breakflag=1
      break
  if breakflag==1:
    break
print(ans)
    
    

Verdicts: Wrong Answer

Accepted
Problem: Given are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).  Consider a sequence A satisfying the following conditions:    * A is a sequence of N positive integers.   * 1 \leq A_1 \leq A_2 \le \cdots \leq A_N \leq M.  Let us define a score of this sequence as follows:    * The score is the sum of d_i over all indices i such that A_{b_i} - A_{a_i} = c_i. (If there is no such i, the score is 0.)  Find the maximum possible score of A.

Submission attempts (in order):
n, m, q = map(int, input().split())
cnt = 0
for _ in range(q):
    a, b, c, d = list(map(int, input().split()))
for i in range(m-n+1):
    if b[i] - a[i] + (m-n) == c[i]:
        cnt += d[i]
print(cnt)

n, m, q = map(int, input().split())
a = [0]*q
b = [0]*q
c = [0]*q
d = [0]*q
for i in range(q):
    a[i],b[i],c[i],d[i] = map(int,input().split())
    a[i] -= 1
    b[i] -= 1

def score(A):
    tmp = 0
    for ai, bi, ci, di in zip(a, b, c, d):   
        if A[bi] - A[ai] == ci:               
            tmp += di                        
    return tmp                               
    
    #     if A[b[i]]-A[a[i]] == c[i]:
    #         tmp += d[i]
    # return tmp

def dfs(A):
    if len(A) == n:
        return score(A)   
    res = 0
    if len(A) > 0:                # prev_last = A[-1] if len(A) > 0 else 0
        prev_last = A[-1] 
    else:
        prev_last = 0
    for i in range(prev_last, m):
        A.append(i)
        res = max(res, dfs(A))    
        A.pop()
    return res

print(dfs([]))

Verdicts: Runtime Error

Accepted
Problem: Given are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).  Consider a sequence A satisfying the following conditions:    * A is a sequence of N positive integers.   * 1 \leq A_1 \leq A_2 \le \cdots \leq A_N \leq M.  Let us define a score of this sequence as follows:    * The score is the sum of d_i over all indices i such that A_{b_i} - A_{a_i} = c_i. (If there is no such i, the score is 0.)  Find the maximum possible score of A.

Submission attempts (in order):
# encoding:utf-8
import copy
import random
import bisect 
import fractions 
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) 

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))
N, M, Q = LI()

abcd = []
for i in range(Q):
    a, b, c, d = LI()
    a -= 1
    b -= 1
    abcd.append([a, b, c, d])
ans = 0
if Q <= 2:
    for q in range(Q):
        ans += abcd[q][-1]
    print(ans)
    sys.exit()

def cal_ans(A):
    ans = 0
    for i in range(Q):
        a, b, c, d = abcd[i]
        if A[b] - A[a] == c:
            ans += d
    return ans

def n2kdigit(n, k):
    bi=''
    before = 1
    while n!=0:
        if before <= (n % k):
            # print(n)
            bi+=str(n%abs(k))
            before = n % k
            if k<0:n=-(-n//k)
            else:n=n//k
        else:
            return None
    if len(bi[::-1]) < N:
        return None
    return bi
ans = 0
for i in range(M ** (N)):
    A = n2kdigit(i, M)
    if A is not None:
        ans = max(ans, cal_ans([int(i) for i in A]))
ans = max(ans, cal_ans([0 for i in range(N)]))
print(ans)

# encoding:utf-8
import copy
import random
import bisect 
import fractions 
import math
import sys
import itertools
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) 

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))
N, M, Q = LI()

abcd = []

all = 0
for i in range(Q):
    a, b, c, d = LI()
    a -= 1
    b -= 1
    abcd.append([a, b, c, d])
    all += d

abcd = sorted(abcd, key= lambda x:x[3], reverse= True)
ans = 0
if Q <= 2:
    for q in range(Q):
        ans += abcd[q][-1]
    print(ans)
    sys.exit()

def cal_ans(A):
    ans = 0
    for i in range(Q):
        a, b, c, d = abcd[i]
        if A[b] - A[a] == c:
            ans += d
    return ans

def n2kdigit(n, k):
    bi=''
    before = 1
    while n!=0:
        if before <= (n % k):
            # print(n)
            bi+=str(n%abs(k))
            before = n % k
            if k<0:n=-(-n//k)
            else:n=n//k
        else:
            return None
    if len(bi) < N:
        return None
    return bi
ans = 0

for i in itertools.combinations_with_replacement(range(1, M+1), N):
    # print(i)
    ans = max(ans, cal_ans(i))
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).  Consider a sequence A satisfying the following conditions:    * A is a sequence of N positive integers.   * 1 \leq A_1 \leq A_2 \le \cdots \leq A_N \leq M.  Let us define a score of this sequence as follows:    * The score is the sum of d_i over all indices i such that A_{b_i} - A_{a_i} = c_i. (If there is no such i, the score is 0.)  Find the maximum possible score of A.

Submission attempts (in order):
#c
import itertools

n, m, q = map(int, input().split())
lslist = []

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

# n=3
# m=4

# ls1 = [1, 3, 3, 100]
# ls2 = [1, 2, 2, 10]
# ls3 = [1, 1, 0, 1000]
# lslist = [ls1, ls2, ls3]

acomn = list(itertools.combinations_with_replacement(list(range(m)), n))

def tensu(ls, a):
    if a[ls[1]-1] - a[ls[0]-1] == ls[2]:
        return ls[3]
    else:
        return 0

def tensu2(lslist, a):
    return sum(list(map(lambda x: tensu(x, a), lslist)))

print(max(list(map(lambda a: tensu2(lslist, a), acomn))))

#c
import itertools

n, m, q = map(int, input().split())
lslist = []

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

# n=3
# m=4

# ls1 = [1, 3, 3, 100]
# ls2 = [1, 2, 2, 10]
# ls3 = [1, 1, 0, 1000]
# lslist = [ls1, ls2, ls3]

acomn = list(itertools.combinations_with_replacement(list(range(m)), n))

def tensu(ls, a):
    if a[ls[1]-1] - a[ls[0]-1] == ls[2]:
        return ls[3]
    else:
        return 0

def tensu2(lslist, a):
    return sum(list(map(lambda x: tensu(x, a), lslist)))

print(max(list(map(lambda a: tensu2(lslist, a), acomn))))

Verdicts: Wrong Answer

Accepted
Problem: Given are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).  Consider a sequence A satisfying the following conditions:    * A is a sequence of N positive integers.   * 1 \leq A_1 \leq A_2 \le \cdots \leq A_N \leq M.  Let us define a score of this sequence as follows:    * The score is the sum of d_i over all indices i such that A_{b_i} - A_{a_i} = c_i. (If there is no such i, the score is 0.)  Find the maximum possible score of A.

Submission attempts (in order):
# -*- coding: utf-8 -*-
"""
Created on Sat May  2 20:59:14 2020
"""

import sys
#import numpy as np
import itertools
sys.setrecursionlimit(10 ** 9)

N, M, Q = map(int,input().split())
abcd = [list(map(int,input().split())) for _ in range(Q)]

A = itertools.combinations_with_replacement([i for i in range(1,M)],N)

ans = 0
for l in A:
    tmp = 0
    for a,b,c,d in abcd:
        if l[b-1] - l[a-1] == c:
            tmp += d
    ans = max(ans, tmp)
print(ans)



# -*- coding: utf-8 -*-
"""
Created on Sat May  2 20:59:14 2020
"""

import sys
#import numpy as np
import itertools
sys.setrecursionlimit(10 ** 9)

N, M, Q = map(int,input().split())
abcd = [list(map(int,input().split())) for _ in range(Q)]

A = itertools.combinations_with_replacement([i for i in range(1,M+1)],N)

ans = 0
for l in A:
    tmp = 0
    for a,b,c,d in abcd:
        if l[b-1] - l[a-1] == c:
            tmp += d
    ans = max(ans, tmp)
print(ans)



Verdicts: Wrong Answer

Accepted