Problem:


Score: 100 points

Problem Statement

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.

Constraints

All values in input are integers.

1 \leq A \leq B \leq 1000

1 \leq K \leq 1000

Input

Input is given from Standard Input in the following format:

K
A B

Output

If he can achieve the objective, print OK; if he cannot, print NG.

Sample Input 1

7
500 600

Sample Output 1

OK

Among the multiples of 7, for example, 567 lies between 500 and 600.

Sample Input 2

4
5 7

Sample Output 2

NG

No multiple of 4 lies between 5 and 7.

Sample Input 3

1
11 11

Sample Output 3

OK



Sample input:
7
500 600


Sample output:
OK

Submission status: Runtime Error

Solution code:
import math
def equation(a,b,n):
  return math.floor((a*n)/b)-a*math.floor(n/b)
d,e,f = map(int,input().split())
K = min(e-1,f)
print(equation(K))

Submission status: Runtime Error

Solution code:
for j in range(A,B+1):
    if j//K==j/K:
        print("OK")
        break
    else:
        pass

Submission status: Runtime Error

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

if (a%k == 0 or b%k == 0):
  print('Yes')
elif (a//k != b//k):
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
k-int(input())
a,b=map(int,input().split())

if k==a or k==b:
    print("OK")
elif k<a and b-a>=k:
    print("OK")
else:
    print("NG")

Submission status: Runtime Error

Solution code:
import numpy as np
import math
import scipy
import itertools

def score(arr):
    hoge = 0
    for ai,bi,ci,di in zip(a, b, c, d):
        if arr[bi-1]-arr[ai-1] == ci:
            hoge += di
    return hoge

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

def solve():
    global a, b, c, d, n, m, q
    n, m, q = map(int, input().split())
    a, b, c, d = [0]*q, [0]*q, [0]*q, [0]*q
    for i in range(q):
        a[i], b[i], c[i], d[i] = map(int, input().split())
    print(dfs([]))
    return 0

if __name__ == "__main__":
    solve()

Submission status: Runtime Error

Solution code:
k = int(input())
a, b = map(int, input().split())
ans = 0
for i in range(1000):
  j = k*i - a
  if a <= j and j <= b:
    print('OK')
    break
  elif:
    print('NG')

Submission status: Runtime Error

Solution code:
from itertools import combinations_with_replacement
import numpy as np

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

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

ans = 0

# 可能な数列Aの全探索、そのままやとめちゃ多いからなんか工夫する？
# そもそもAの全探索方がいまいちわからん...

A = np.array(list(combinations_with_replacement(range(1, M + 1), N)))
scores = np.zeros(len(A))
for g in G:
    a, b, c, d = g
    cond = A[:, b - 1] - A[:, a - 1] == c
    scores += d * cond
print(scores.max())

Submission status: Runtime Error

Solution code:
k = int(input())
k_under, k_over = map(int,input(),split())
result　= 1
cnt = 0
while k * cnt > k_over:
	if k * cnt > k_under:
      print('OK')
      result = 0
    cnt += 1

if result == 1:
	print('NG')

Submission status: Runtime Error

Solution code:
def hoge(K, A, B):
    K = int(input())
    A, B = map(int, input().split())
    
    ans = 0
    for n in range(A, B+1):
        if n%K == 0:
            ans = 1
            return ans
    return ans

if hoge(K, A, B):
    print('OK')
else:
    print('NG')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
K = int(input())
A,B = map(int,input()split())
for i in range(A,B+1):
  if i%K==0:
    print("OK")
    exit()
print("No")

Submission status: Runtime Error

Solution code:
k = int(input())
a,b = map(int,input().split())
for i in range(a,b+1):
    if i%k == 0:
        han = True
if han == True:
    print("OK")
else:
    print("NG")

Submission status: Runtime Error

Solution code:
k = input()
a,b = map(int,input().split())
han = False
for i in range(a,b,1):
    if i%k == 0:
        han = True
if han == True:
    print("OK")
else:
    print("NG")

Submission status: Runtime Error

Solution code:
k = input()
a,b = map(int,input().split())
for i in range(a,b,1):
    if (i%k) == 0:
        han = True
if han == True:
    print("OK")
else:
    print("No")

Submission status: Runtime Error

Solution code:
k = input()
a,b = map(int,input().split())
for i in range(a,b,1):
    if i%k == 0:
        han = True
if han == True:
    print("OK")
else:
    print("No")

Submission status: Runtime Error

Solution code:
K=input("K=")
A=input("A=")
B=input("B=")

f="NG"
for i in range(int(A),int(B)):
    c=i%int(K)
    if c==0:
        f="OK"
print(f)

Submission status: Runtime Error

Solution code:
from sys import stdin
import sympy as sp

K = int(stdin.readline().rstrip())
[A, B] = [int(x) for x in input().rstrip().split()]


flag=0
K_temp=K
while(True):
    if(K_temp>B):
        break
    if(K_temp>=A and K_temp<=B):
        flag=1
        break
    else:
        K_temp+=K

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

Submission status: Runtime Error

Solution code:
from sys import stdin
import sympy as sp
K = int(stdin.readline().rstrip())
[A, B] = [int(x) for x in input().rstrip().split()]


flag=0
K_temp=K
while(True):
    if(K_temp>B):
        break
    if(K_temp>=A and K_temp<=B):
        flag=1
        break
    else:
        K_temp+=K

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
X = int(input())

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

flag = False
for x in range(A, B+1):
  if x % K == 0:
    flag = True
    
if flag:
  print("OK")
else: 
  print("NG")

Submission status: Runtime Error

Solution code:
X = int(input())

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

flag = False
for x in range(A, B+1):
  if x % K == 0:
    flag = True


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

Submission status: Runtime Error

Solution code:
#cording:utf-8

K=int(input())
A,B=list(int,input().split())
largest = (b//k)*k
if a <= largest:
    print("OK")
else:
    print("NG")

Submission status: Runtime Error

Solution code:
#cording:utf-8

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

Submission status: Runtime Error

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

while True:
    if a%k == 0:
        print("OK")
        break
    elif: b%k == 0:
        print("OK")
    elif b-a >= k:
        print("OK")
        break
    else:
        print("NG")
        break

Submission status: Runtime Error

Solution code:
#include<iostream>
#include<bits/stdc++.h>
#using namespace std;
#int search(int k,int a,int b){
#    int i=a;
#    while(i<=b){
#        if(i%k==0){
#            return true;
#            return 0;
#        }
#    }
#    return false;
#    return 0;
#}
#int main(){
#    int k,a,b;
#    cin>>k>>a>>b;
#    if(search(k,a,b))cout<<"OK";
#    else cout<<"NG";
#    return 0;
#}
k=int(input())
a=int(input())
b=int(input())
i=a
x=False
while i<=b:
    if i%k==0:
        x=True
if x==True:
    print('OK')
else:
    print('NG')

Submission status: Runtime Error

Solution code:
#include<iostream>
#include<bits/stdc++.h>
#using namespace std;
#int search(int k,int a,int b){
#    int i=a;
#    while(i<=b){
#        if(i%k==0){
#            return true;
#            return 0;
#        }
#    }
#    return false;
#    return 0;
#}
#int main(){
#    int k,a,b;
#    cin>>k>>a>>b;
#    if(search(k,a,b))cout<<"OK";
#    else cout<<"NG";
#    return 0;
#}
k=int(input())
a=int(input())
b=int(input())
i=a
while i<=b:
    if i%k==0:
        print('OK')
        break
print('NG')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
k = int(input())
a,b = map(int,input().split())
for i in range(a,b):
  if i % k == 0:
    ans = 'OK'
  else:
    ans = 'No'
print(ans)

Submission status: Runtime Error

Solution code:
k = int(input())
a,b = map(int,input().split())
for i in range(a,b):
  if i % k == 0:
    ans = 'OK'
    break
  else:
    ans = 'No'
print(ans)

Submission status: Runtime Error

Solution code:
k = int(input())
a, b = map(int, input())
if k == 1 or (a // k == a / k):
  print('OK')
else:
  n = a // k
  m = b // k
  if m - n >= 1:
    print('OK')
  else:
    print('NG')

Submission status: Runtime Error

Solution code:
c=0
if (b-a)>k+1:
  c=1
elif (a%k)-(b%k)>=0:
    c=1
else:
  c=0
if c==1:
  print('ok')
else:
  print('ng')

Submission status: Runtime Error

Solution code:
A,B,N = map(int, input().split())

def f(a, b, n):
    fl1 = (a * (n + 1)) // b
    fl2 = (n + 1) // b
    fl = fl1 - (a * fl2)
    return fl
   #return int(a * n / b) - a * int(n / b)

print(f(A, B, B-1) if N >= B-1 else f(A, B, N))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
n,m,q = map(int,input().split())
abcd = [list(map(int,input().split())) for _ in range(q)]
ans = 0
for a in range(1,11):
  for b in range(a,11):
    for c in range(b,11):
      for d in range(c,11):
        for e in range(d,11):
          for f in range(e,11):
            for g in range(f,11):
              for h in range(g,11):
                for i in range(h,11):
                  for j in range(i,11):
                    lst = [0,a,b,c,d,e,f,g,h,i,j]
                    print(lst)
                    s = 0
                    for l in range(q):
                      s += abcd[l][3]*(lst[abcd[l][1]]-lst[abcd[l][0]]==abcd[l][2])
                    ans = max(ans, s)
print(ans)

Submission status: Runtime Error

Solution code:
import sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

def main():
    k = i()
    a,b = i2()
    print("OK" if a =< k and b >= k else "NG")
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
A,B,N=map(int,input().split())

def g(t):
    return int(A*t/B)-A*int(t/B)

x=[i for i in range(0,N,1)]

y=[g(i) for i in x]

print(max(y))

Submission status: Runtime Error

Solution code:
from math import *
k=int(input())
a=int(input())
b=int(input())
m=0
while a<=b :
    if a%k==0:
        m=1
        break
    a=a+1
if m==1:
    print("OK")
else :
    print("NG")

Submission status: Runtime Error

Solution code:
from math import *
k=int(input())
a=int(input())
b=int(input())
m=0
while a<=b :
    if a%k==0:
        m=1
        break
    a+=1
if m==1:
    print("OK")
else :
    print("NG")

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
import bisect

INF = 10 ** 10

N = int(input())
As = list(map(int, input().split()))
edges = [tuple(map(int, input().split())) for _ in range(N-1)]

dfs_stack = [1]
ans = [-1] * N
lis = [INF] * (N+1)
rewinder = []

while dfs_stack:
    pos = dfs_stack.pop()
    for u, v in edges:
        if u == pos:
            if ans[v-1] == -1:
                dfs_stack.append(v)
            else:
                parent = v
        elif v == pos:
            if ans[u-1] == -1:
                dfs_stack.append(u)
            else:
                parent = u
    
    while rewinder:
        i, before, after = rewinder.pop()
        if after == As[parent-1]:
            rewinder.append( (i, before, after) )
            break
        else:
            lis[i] = before

    index = bisect.bisect_left(lis, As[pos-1])
    rewinder.append( (index, lis[index], As[pos-1]) )
    lis[index] = As[pos-1]
    ans[pos-1] = lis.index(INF)

print(*ans, sep = '\n')

Submission status: Runtime Error

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

#output
answer = "NG"
for i in range(A, B+1):
    if i % K == 0:
        answer = "OK"
    else:
        continue

print(answer)

Submission status: Runtime Error

Solution code:
k = list(input())
a, b =  map(int, input().split())
if a % k == 0 or b % k == 0:
    print('OK')
else:
    if (b-a) // k == 0:
        print('NG')
    else:
        print('OK')

Submission status: Runtime Error

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

if A//K == B//K:
  if A % K == 0:
    print("OK")
    else:
      print("NG")
      
  else:
    print("OK")

Submission status: Runtime Error

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

if A//K == A//K:
  if A % K == 0:
    print("OK")
    else:
      print("NG")
      
  else:
    print("OK")

Submission status: Runtime Error

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

if A//K == A//K:
  if A % K == 0:
    print("OK")
    else:
      print("NG")
else:
  print("OK")

Submission status: Runtime Error

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

if b//k == a//k:
  if a % k == 0:
    print("OK")
    else:
      print("NG")
else:
  print("OK")

Submission status: Runtime Error

Solution code:
k = int(input())
a, b = int(input())
if k<=b-a+1:
  print("OK")
  else:
    print("NG")

Submission status: Runtime Error

Solution code:
k = int(input())
a, b = int(input())
if k<=(B-A+1):
  print("OK")
  else:
    print("NG")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
k=input()
a,b=map(int,input().split())
len=b-a

if k <=len:
    print("OK")
else:
    print("NG")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import itertools
N, M, Q = map(int, input().split())
m = list()
res = -100
for i in range(Q):
    n = list(map(int, input().split()))
    m.append(n)
l = [x for x in range(1, M + 1)]
p = itertools.combinations_with_replacement(l, N)
for p in p:
    total = 0
    for i in range(Q):
        num = 0
        a = m[i][0]
        b = m[i][1]
        A = p[a - 1]
        B = p[b - 1]
        C = B - A
        if m[i][2] == C:
            num = num + m[i][3]
            total = total + num
    if res < total:
        res = total
print(res)

Submission status: Runtime Error

Solution code:
A,B,N = list(map(int, input().split()))
res = 0

for x in range(1,N+1):
    if A <= res:
        break
    else:
        res = int(A*x/B)- A* int(x/B)

print(res)

Submission status: Runtime Error

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

A_bai = int(A/K)
B_bai = int(B/K)

if A_bai != B_bai:
  print("OK")
else if (A%K == 0) || (B%K == 0):
  print("OK")
else:
  print("NG")

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

int main(){
  int k, a, b;
  cin >> k >> a >> b;

  int target = (b / k) * k;
  if(a <= target) cout << "OK" << endl;
  else {cout << "NG" << end;}
  return 0;
}

Submission status: Runtime Error

Solution code:

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

a_round = round(a / n)
b_round = round(b / n)
if k == 1 or a % n == 0 or b % n == 0:
  print("OK")
else:
  if a_round < b_round:
    print("OK")
  else:
    print("NG")

Submission status: Runtime Error

Solution code:
c=0
if (b-a)<+1:
  c=1
elif (a%k)-(b%k)>-1:
    c=1
else:
  c=0
if c==1:
  print('ok')
else:
  print('ng')

Submission status: Runtime Error

Solution code:
c=0
if (b-a)<k:
  c=1
elif (a%k)-(b%k)>0:
    c=1
else:
  c=0
if c=1:
  print(ok)
else:
  print(ng)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat May  2 14:48:19 2020

@author: ab
"""
import math
import sys
import os

def isDivisible(num1,num2):
    return num1%num2 == 0

def binary_search(n,m,k):
    if isDivisible(n,k) | isDivisible(m,k):
        return True
    elif abs(n-m) <=1:
        return False
    mid = math.ceil((n+m)/2)
    if(isDivisible(mid,k)):
        return True
    elif mid-n < k:
        return binary_search(mid+1,m,k)
    else:
        return binary_search(n,mid-1,k)
    

def solution(k,n,m):
    if k == 1:
        return True
    elif isDivisible(n,k) | isDivisible(m,k):
        return True
    elif abs(n-m) <=1:
        return False
    elif k>m:
        return False
    else:
        return binary_search(n,m,k)



input = sys.stdin
output = sys.stdout
while True:
    lineElements = input.readline().rstrip("/n").split(" ")
    if(lineElements[0] == ''):
        break;
    if len(lineElements) == 1:
        k = int(lineElements[0])
    else:
        n,m = lineElements
        n,m = int(n),int(m)
        if solution(k,n,m) == True:
            output.writeLine("OK")
        else:
            output.writeLine("NG")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
input = map(int, [input()] + input().split(' '))
[k,start,end] = input

for i in range(start, end + 1):
  if i % k == 0:
    return True
return False

Submission status: Runtime Error

Solution code:
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")

Submission status: Runtime Error

Solution code:
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")

Submission status: Runtime Error

Solution code:
k = int(input())
[start end] = input().split(' ')
start = int(start)
end = int(end)

for i in range(start, end):
  if i % k == 0:
    return True
return False

Submission status: Runtime Error

Solution code:
k = input()
[start,end] = input().split(' ')

for i in range(start,end+1):
  if i % k == 0:
    return True
return False

Submission status: Runtime Error

Solution code:
k = input("整数kを入力してください")
a = input("整数aを入力してください")
b = input("整数bを入力してください")
c = int(a)
d = int(b)
l = int(k)
e = d-d%l
if e>=c:
    print('ok')
else:
    print('ng')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
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')

Submission status: Runtime Error

Solution code:
K = int(input())
A, B = [int(s) for s in input().split()]
 
largest = B // K * K

print("OK" if largest >= a else "NG")

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter

from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#l=deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
#dequeを使うときはpython3を使う、pypyはダメ
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds

#mod = 10**9+7
#w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え
#start 4:00
N = int(input())
#N, K = map(int, input().split())
#L = [int(input()) for i in range(N)]
#A = list(map(int, input().split()))
#S = [list(map(int, input().split())) for i in range(N)]



A = list(map(int, input().split()))
edge = [[] for i in range(N)]
for i in range(N-1):
    x,y = map(int,input().split())
    edge[x-1].append(y-1)
    edge[y-1].append(x-1)


#始点sから各頂点への最短距離
inf=10**10
dp = [inf]*N
visited=[False]*N
q=[]
q=deque(q)
ans=[0]*N

def dfs(e):
    visited[e]=True
    a=A[e]
    ci=bisect_left(dp,a)
    q.append((ci,dp[ci]))
    dp[ci]=a
    ans[e]=bisect_left(dp,inf)
    #print(edge[e])
    for ne in edge[e]:
        if not visited[ne]:
            dfs(ne)
            pi,px=q.pop()
            dp[pi]=px


dfs(0)
    #print(d)
    
for x in ans:
    print(x)
#print(d[4])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math

n = list(map(int,input().split()))
x = min(b-1 , n[2])
if n[2] >= n[2]:
    print(math.floor(n[0] * x // n[1]))

Submission status: Runtime Error

Solution code:
import math
 
a,b,n = map(int,input().split())
 
ans = 0
pre = 0
for i in range(1, n+1):
  now = math.floor(a*i / b) - a * math.floor(i / b)
  if now > pre:
    ans = i
    pre = now
  elif not now == 0:
    break
    
print(pre)

Submission status: Runtime Error

Solution code:
import math
 
a,b,n = map(int,input().split())
 
ans = 0
pre = 0
for i in range(1, n+1):
  now = math.floor(a*i / b) - a * math.floor(i / b)
  if now > pre:
    ans = i
    pre = now
  else:
    break
    
print(pre)

Submission status: Runtime Error

Solution code:
k = input()
a = input()
b = input()

b = (b / k) * k

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

Submission status: Runtime Error

Solution code:
k = int(input())
 
a, b = map(int, input().split())
necounter = 0
for i in range(a, b+1):
  if i % k == 0:
    break
  else:
    ngcounter += 1
    
if ngcounter == b - a + 1:
  print("NG")
else :
  print("OK")

Submission status: Runtime Error

Solution code:
def carry(K,A,B):
    K=int(K)
    A=int(A)
    B=int(B)
    m=1
    while K*m < B:
       if A < K*m < B:
            return "OK"
        else:
            m = m + 1
    return "NG"
    
K= input()
A,B=input().split()
print (carry(K,A,B))

Submission status: Runtime Error

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


def f(x):
    return (a * x) // b - (a * x) // b


print(f(min(n,b-1)))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split()) 

ans = []
if M % 2 != 0:
    for i in range((M+1)//2):
        ans.append((1 + i,M - i))
        
    for j in range((M - 1)//2):
        ans.append((M + 1 + j, 2*M + 1 - j))
        
else:
    for i in range(M//2):
        ans.append((1 + i, M + 1 - i))
        ans.append((M + 2 + j, 2*M + 1 - j))
              
for i in range(M):
    print(*ans[i])

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split()) 
ans = []
if M % 2 != 0:
    for i in range((M+1)//2):
        ans.append((1 + i,M - i))
        
    for j in range((M - 1)//2):
        ans.append((M + 1 + j, 2*M + 1 - j))
else:
    for i in range(M//2):
        ans.append((1 + i, M + 1 - i))
        ans.append((M + 2 + j, 2*M + 1 - j))
              
for i in range(M):
    print(*ans[i])

Submission status: Runtime Error

Solution code:
target = int(input())
range_d = [int(i) for i in input().split()]
min_d = range_d[0]
max_d = range_d[1]

flag = False
if max_d < target:
  flag = 
else:
  for i in range(min_d,max_d+1):
    if i%target == 0:
      flag = True
      break
	print('OK') if flag else print('NG')

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
int A[101],B[101],C[101],D[101];
int ans;
int N,M,Q;
void dfs(vector<int> v)
{
    // cout<<" hi"<<"";
    if(v.size()==N)
    {
        int sum=0;
        for(int i=0;i<Q;i++)
        {
            if (v[B[i]-1]-v[A[i]-1]==C[i])
            {
                sum+=D[i];
            }
        }
        ans=max(ans,sum);
    }
    else
    {
        for(int i=v[v.size()-1];i<=M;i++)
        {
            vector<int> n=v;
            n.push_back(i);
            dfs(n);
        }
    }
}
int main() 
{  
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ans=INT_MIN;
    cin>>N>>M>>Q;
    for(int i=0;i<Q;i++)
    {
        cin>>A[i]>>B[i]>>C[i]>>D[i];
    }
    for(int i=1;i<=M;i++)
    {
        vector<int> v;
        v.push_back(i);
        dfs(v);
    }
    cout<<ans<<" ";
}

Submission status: Runtime Error

Solution code:
N,M,Q=map(int,input().split())
a=[]
b=[]
c=[]
d=[]
for i in range(Q):
  ta,tb,tc,td=map(int,input().split())
  a+=[ta]
  b+=[tb]
  c+=[tc]
  d+=[td]
maxs=0

def suuretu(n,m):#n桁m以上
  if n>1:
    A=[]
    for i in range(1,9):
      for j in suuretu(n-1,i):
        A+=[10*i+j]
    return A
  else:
    A=[i for i in range(m,10)]
    return A
B=suuretu(N,1)
answer=0
for i in B:
  ans=0
  s=str(i)
  tmpl=[int(s[j]) for j in range(N)]  
  for k in range(Q):
    if tmpl[a[k]-1]-tmpl[b[k]-1]==c[k]:
      ans+=d[i]
  answer=max(answer,ans)
print(answer)

Submission status: Runtime Error

Solution code:
N, M, Q = map(int, input().split())
l = []
for i in range(Q):
  l.append(list(map(int, input().split())))

A_N = [[i] for i in range(1, M+1)]
for i in range(N-1):
  a = []
  for j in range(len(A_N)):
    last = A_N[j][-1]
    for k in range(last, M+1):
      a.append(A_N[j] + [k])
  A_N = a

high_score = 0
for i in range(len(A_N)):
    A = A_N[i]
    score = 0
    for j in range(len(l)):
        aj, bj, cj, dj = l[j]
        if A[bj-1]-A[aj-1] == cj:
            score += dj
        high_score = max(high_score, score) 
        
print(high_score)

Submission status: Runtime Error

Solution code:
ｋ = int(input())
a,b = map(int,input().split())
n=0
while True:
    n+=k
    if n>=a and n=<b:
        print('OK')
        break
    if n>b:
        print('NG')

Submission status: Runtime Error

Solution code:
a,b,n = map(int, input().split())
def f(x):
    return int(a*x/b) - a*int(x/b)
Max = f(min(b-1,n))
print(Max)

Submission status: Runtime Error

Solution code:
import itertools

x = list(map(int, input().split()))
y = []

for i in range(x[2]):
    y.append(list(map(int, input().split())))

for i in range(len(y)):
    y[i][0] -= 1
    y[i][1] -= 1

def get_score(arr: list):
    score = 0
    for yy in y:
        if arr[yy[1]] - arr[yy[0]] == yy[2]:
            score += yy[3]
    return score

scores = []
for t in itertools.combinations_with_replacement(range(1, 11), x[0]):
    isError = False
    for i in range(x[0] -1):
        if t[i] > t[i+1]:
            isError = True
    if isError == True:
        continue
    scores.append(get_score(t))

print(max(scores))

Submission status: Runtime Error

Solution code:
k=input()
a,b = map(int, input().split())
ans="NG"
while a <= b:
  if a%k=0:
    ans ="OK"
  else:
    a=a+1
print(ans)

Submission status: Runtime Error

Solution code:
a,b,n=map(int,(input().split())
x = min(b-1,n)
print(int(a*x/b)-a*int(x/b))

Submission status: Runtime Error

Solution code:
import numpy as np
#from numba import jit

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

A = np.sort(np.random.randint(1,m+1,n))

#@jit
def calc_energy(A):
    energy = 0.
    for i in range(q):
        if (A[b[i]-1] - A[a[i]-1]) == c[i]:
            energy += d[i]
    return energy


T = 20000
temperature = 200
for t in range(T):
    A_prev = np.copy(A)
    energy_prev = calc_energy(A_prev)
    
    idx = np.random.randint(0, n)
    A[idx] = np.random.randint(1, m+1)
    energy = calc_energy(A)
    
    if np.random.rand() < (energy - energy_prev)/temperature:
        pass
    else:
        A = np.copy(A_prev)
    temperature *= 0.999

print(np.int(calc_energy(A)))

Submission status: Runtime Error

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

if b%k == 0: 
  print(“OK”)
else:
  tmp = b//k
  tmp *= k
  if tmp>=a:
    print("OK")
  else:
    print("NG")

Submission status: Runtime Error

Solution code:
n,m,q = map(int,input().split())
List = [list(map(int, input().split())) for i in range(q)]

p_max = 0
point =0
A = [1]*n
E = [m]*n

while A != E :

    #得点計算
    for j in range(q):
        if A[List[j][1]-1] - A[List[j][0]-1] == List[j][2]:
            point += List[j][3]


    #最大値の更新
    if p_max < point:
        p_max = point
    point = 0


    #Aの更新
    for i in reversed(range(0,n)):
        if A[i] < m:
            A[i] = A[i] + 1
            if i !=n-1:
                for k in range(i+1,n):
                    A[k] = A[i]
            break

print(p_max)

Submission status: Runtime Error

Solution code:
l=list(map(int,input().split()))
a=l[0]
b=l[1]
n=l[2]
if b-1<n:
  i=b-1
else:
  i=n
y=(((a*i)/b)//1)-(a*((i/b)//1))
print(int(y))

Submission status: Runtime Error

Solution code:
l=list(map(int,input().split()))
a=l[0]
b=l[1]
n=l[2]
x=0
if b-1<n:
  i=b-1
  y=(((a*i)/b)//1)-(a*((i/b)//1))
else:
  i=n
  y=(((a*i)/b)//1)-(a*((i/b)//1))
print(int(x))

Submission status: Runtime Error

Solution code:
n,m,s=map(int,input().split())
a=[]
q=[[0]]
while q:
  x=q.pop()
  if len(x)<=n:
    if x[-1]==0:
      for j in range(1,m+1):
        c=x+[j]
        q.append(c)
    else:
      for j in range(x[-1],m+1):
        c=x+[j]
        q.append(c)
  else:
    a.append(x)
li=[tuple(map(int,input().split())) for _ in  range(s)]

ans=0
for A in a:
  s=0
  for i,j,k,l in li:
    if A[j]-A[i]==k:
      s+=l
  ans=max(ans,s)
print(ans)

Submission status: Runtime Error

Solution code:
k = int(input())
n = list(map(int,input().split()))
d = 0
for i in range(a,b+1):
    if i % k == 0:
        
        d = 1
        break
if d == 0:
    print("NG")
else:
  print('NG')

Submission status: Runtime Error

Solution code:
k = int(input())
a,b = map(int,input())
d = 0	
for i in range(a,b+1):
  if i%k == 0:
    d = 3
    break
  else:
    d=0
if d == 3:
  print('OK')
else:
  print('NG')

Submission status: Runtime Error

Solution code:

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

Submission status: Runtime Error

Solution code:
k = int(input())
a,b = map(int,input())
d = 0
for i in range(a,b+1):
  if i%k == 0:
    d = 3
    break
  else:
    continue
if d == 3:
  print('OK')
else:
  print('NG')

Submission status: Runtime Error

Solution code:
k = int(input())
a,b = map(int,input())
d = 0
for i in range(a,b+1):
  if i%k == 0:
    d = 3
    break
if d == 3:
  print('OK')
else:
  print('NG')