TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: Given are integers A, B, and N.  Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non- negative integer x not greater than N.  Here floor(t) denotes the greatest integer not greater than the real number t.

Submission attempts (in order):
a,b,n=map(int,input().split())
import math
x=b-1
m=[0]
while x<=n:
    f=math.floor(a*x/b)-a*(math.floor(x/b))
    m.append(f)
    x+=b
print(max(m))

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

a,b,n=map(int,input().split())
import math
if n<b-1:
    m=[math.floor(a*n/b)]
else:
    e=n//b
    n=b*e-1
    m=[math.floor(a*n/b)-a*(math.floor(n/b))]
print(m)

import sys
input=sys.stdin.readline
import math
a,b,n=map(int,input().split())
for x in range(n+1):
    f=math.floor(a*x/b)-a*math.floor(x/b)
    m.append(f)
print(max(m))

a,b,n=map(int,input().split())
import math
if n<b:
    m=math.floor(a*n/b)
else:
    e=b-1
    m=math.floor(a*e/b)
print(m)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: Given are integers A, B, and N.  Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non- negative integer x not greater than N.  Here floor(t) denotes the greatest integer not greater than the real number t.

Submission attempts (in order):
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

a,b,n=n1()
import math
if b<=n:
    i=b-1
else:
    i=n
m=math.floor((a*i)/b)-a*math.floor(i//b)
print(i,m)

def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
 
a,b,n=n1()
import math
if b<=n:
    i=b-1
else:
    i=n
m=math.floor((a*i)/b)-a*math.floor(i/b)
print(m)


Verdicts: Wrong Answer

Accepted
Problem: Given are integers A, B, and N.  Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non- negative integer x not greater than N.  Here floor(t) denotes the greatest integer not greater than the real number t.

Submission attempts (in order):
A, B, N = map(int, input().split())
f = [int(A*x/B)-(A * int(x/B)) for x range(N+1)]
print(max(f))

def f(a, b, x):
  return int(a*x/b) - (a*int(x/b))
A, B, N = map(int, input().split())
print(f(A, B, min(B-1, N))

A, B, N = map(int, input().split())
f = [int(A*x/B) - (A * int(x/B)) for x range(N+1)]
print(max(f))

A, B, N = map(int, input().split())
max = 0
imax = 0
for x in range(N+1):
  if int(A*x/B) - (A * int(x/B)) > max:
    imax = x
print(x)

A, B, N = map(int, input().split())
max = 0
for x in range(N+1):
  if int(A*x/B) - (A * int(x/B)) > max:
    max = int(A*x/B) - (A * int(x/B))

def f(a, b, x):
  return int(a*x/b) - (a*int(x/b))
A, B, N = map(int, input().split())
print(f(A, B, min(B-1, N)))

Verdicts: Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: Given are integers A, B, and N.  Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non- negative integer x not greater than N.  Here floor(t) denotes the greatest integer not greater than the real number t.

Submission attempts (in order):
A,B,N=list(map(int,input().split()))
list_ans=[]
for i in range(B-1,B):
  print(int(A*i/B)-A*int(i/B))
  
#print(list_ans)
#print(int(max(list_ans)))

A,B,N=list(map(int,input().split()))
list_ans=[]
minimum=min(B-1,N)
print(int(A*minimum/B)-A*int(minimum/B))

Verdicts: Wrong Answer

Accepted
Problem: Given are integers A, B, and N.  Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non- negative integer x not greater than N.  Here floor(t) denotes the greatest integer not greater than the real number t.

Submission attempts (in order):
A,B,N = map(int,input().split())
def f(x):
  f = int((A*x)/B)-A*int(x/B)
  return f
if(f(B-1) < f(N)):
  print(f(N))
else:
  print(f(B-1))

A,B,N = map(int,input().split())
def f(x):
  f = int(A*x/B)-A*int(x/B)
  return f
if(f(B-1)< f(N)):
  print(f(N))
else:
  print(f(B-1))

A,B,N = map(int,input().split())
def f(x):
  f = int((A*x)/B)-A*int(x/B)
  return f
if(B-1 < N):
  print(f(B-1))
else:
  print(f(N))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given are integers A, B, and N.  Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non- negative integer x not greater than N.  Here floor(t) denotes the greatest integer not greater than the real number t.

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

if b > n :
    print(n)
else:
    max = 0
    for i in range(1,int(n)+1,1):
        r = (int(a)*i // int(b)) - (int(a)* (i//int(b)))
        if r > max:
            max = r

    print(max)


a, b , n= input().split() 
a = int(a)
b = int(b)
n = int(n)
p = min(b,n)
if p % b ==0:
    print(int(a*(p-1)/b))
else:
    print(int(a*p/b))

Verdicts: Wrong Answer

Accepted
Problem: Given are integers A, B, and N.  Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non- negative integer x not greater than N.  Here floor(t) denotes the greatest integer not greater than the real number t.

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

a,b,n=map(int(input().split())
if b-1<=n:
  x=b-1
  print(int(a*x/b)-a*int(x/b))
else:
  x=n
  print(int(a*x/b)-a*int(x/b))

          
          

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

a,b,n=map(int,input().split())
if b==1:
  print(0)
else:
  print(int(a*(b-1)/b)-a*int((b-1)/b))

a,b,n=map(int,input().split())
if b-1<=n:
  x=b-1
  print(int(a*x/b)-a*int(x/b))
else:
  x=n
  print(int(a*x/b)-a*int(x/b))
 
          

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: Given are integers A, B, and N.  Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non- negative integer x not greater than N.  Here floor(t) denotes the greatest integer not greater than the real number t.

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

yuka = lambda a,b: (a-(a%b))//b

c = yuka(a,b)
'''
for x in range(b):
  score = (x%b)*c
  ans = max(ans,score)
'''
ans = (b-1)*c
print(ans)

a,b,n = map(int, input().split())
yuka = lambda a,b: (a-(a%b))//b

x = min(n,b-1)
score = yuka(a*(x%b),b)
ans = score

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given are integers A, B, and N.  Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non- negative integer x not greater than N.  Here floor(t) denotes the greatest integer not greater than the real number t.

Submission attempts (in order):
import math
A, B, N = map(int,input().split(' '))

def f(x):
    print(math.floor(A*x/B), A*math.floor(x/B))
    return math.floor(A*x/B)-A*math.floor(x/B)


def main():
    
    ans = 0
    i = 0
    while B > i and i <= N:
        fi = f(i)
        ans = f(i) if ans < fi else ans
        i += 1 
    
    print(ans)


if __name__ == "__main__":
    main()


import math
A, B, N = map(int,input().split(' '))

def f(x):
    return math.floor(A*x/B)-A*math.floor(x/B)


def main():
    if N >= B:
        print(f(B-1))
    else:
        print(f(N))

if __name__ == "__main__":
    main()


Verdicts: Wrong Answer

Accepted
Problem: Given are integers A, B, and N.  Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non- negative integer x not greater than N.  Here floor(t) denotes the greatest integer not greater than the real number t.

Submission attempts (in order):
import math
A,B,N=map(float,input().split())
if N = B:
    N = N-1
ans = math.floor((A*N/B)) - A*math.floor(N/B)
print(int(ans))

A,B,N=map(int,input().split())
if B==1 or A==1:
    ans = 0
elif A==10**6 and B ==10**12
    ans = 10**6
else:
    while N%B==0:
        N = N-1
    ans = (A*N)//B - A*(N//B)
print(ans)

A,B,N=map(float,input().split())
if B==1 or A==1:
    ans = 0
else:
    while N%B==0:
        N = N-1
    ans = (A*N)//B - A*(N//B)
print(ans)

import math
A,B,N=map(int,input().split())
if N >= B:
    N = B-1
ans = math.floor(A*N/B) - A*math.floor(N/B)
print(ans)


Verdicts: Runtime Error

Runtime Error

Wrong Answer

Accepted
Problem: Given are integers A, B, and N.  Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non- negative integer x not greater than N.  Here floor(t) denotes the greatest integer not greater than the real number t.

Submission attempts (in order):
a,b,c=map(int,input().split())
if c+1>=b:
    ans=int(a*(b-1)/b)
else:
    ans=(a*c/b)
print(ans)

a,b,c=map(int,input().split())
if c+1>=b:
    ans=int(a*(b-1)/b)
else:
    ans=int(a*c/b)
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given are integers A, B, and N.  Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non- negative integer x not greater than N.  Here floor(t) denotes the greatest integer not greater than the real number t.

Submission attempts (in order):
a,b,n=map(int,input().split())
import math
if b==1:
  print(0)
else:
  print(math.floor(a*(b-1)/b))

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

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

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given are integers A, B, and N.  Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non- negative integer x not greater than N.  Here floor(t) denotes the greatest integer not greater than the real number t.

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

# A, B, N = 11, 10, 9

maxR = -1
maxX = 0
for x in range(0, N+1):
    R = math.floor(A*x/B) - A * math.floor(x/B)
    if R >= maxR:
        maxR = R
        maxX = x
print (maxX)

import math                                                       
A, B, N = map(int, input().split())

# A, B, N = 11, 10, 9

maxR = -1
maxX = 0
for x in range(1, N+1):
    R = math.floor(A*x/B) - A * math.floor(x/B)
    if R > maxR:
        maxR = R
        maxX = x
print (maxX)

import math                                                       
A, B, N = map(int, input().split())

# A, B, N = 11, 10, 9

maxR = -1
maxX = 0
for x in range(1, N+1):
    R = math.floor(A*x/B) - A * math.floor(x/B)
    if R >= maxR:
        maxR = R
        maxX = x
print (maxX)

import math                                                       
A, B, N = map(int, input().split())

# A, B, N = 11, 10, 9
T = N//B
maxR = -1
maxT = 0
# for x in range(1, T+2):
    # t = min(x*B-1,N)
    
    # if R >= maxR:
    #     maxR = R
    #     maxT = t
t = min(B-1,N)
maxR = math.floor(A*t/B) - A * math.floor(t/B)
print (maxR)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Given are integers A, B, and N.  Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non- negative integer x not greater than N.  Here floor(t) denotes the greatest integer not greater than the real number t.

Submission attempts (in order):
A,B,N = map(int,input().split())
maxn =0
if A<B:
    if B/2 <N:
        t = math.ceil(B/2)-1
        ans = tmp = math.floor((A*t)/B)-A*(math.floor(t/B))
    else:
        ans = tmp = math.floor((A*N)/B)-A*(math.floor(N/B))
else:
    for x in range(1,B+1):
        tmp = math.floor((A*x)/B)-A*(math.floor(x/B))
        if maxn < tmp:
            maxn = tmp
    ans =maxn
print(ans)

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))
    print(tmp)
    if maxn < tmp:
        maxn = tmp
    if tmp == 0:
        if sec ==True:
            break
        else:
            sec =True
    
print(maxn)

import math
A,B,N = map(int,input().split())
s = min(B-1,N)
print(math.floor((A*s)/B)-A*(math.floor(s/B)))

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: Given are integers A, B, and N.  Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non- negative integer x not greater than N.  Here floor(t) denotes the greatest integer not greater than the real number t.

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

def f(n):
    d = int(A*n/B) - A*int(n/B)
    return d

if N < B==0:
    ans = int(A*N/B)
else:
    ans = A-1

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

def f(n):
    d = int(A*n/B) - A*int(n/B)
    return d

print(f(min(B-1,N)))


Verdicts: Wrong Answer

Accepted
Problem: Given are integers A, B, and N.  Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non- negative integer x not greater than N.  Here floor(t) denotes the greatest integer not greater than the real number t.

Submission attempts (in order):
import math
a, b, n = map(int, input().split())
if b>n:
    print(math.floor(a*n/b))
else:
  	x = b-1
    print(math.floor(a*x/b))

import math
a, b, n = map(int, input().split())
if b>n:
    print(math.floor(a*n/b))
else:
    x = b-1
    print(math.floor(a*x/b))

Verdicts: Runtime Error

Accepted
Problem: Given are integers A, B, and N.  Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non- negative integer x not greater than N.  Here floor(t) denotes the greatest integer not greater than the real number t.

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

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

def fnc(x):
    return int((a*x)/b)-a*int((x/b))

ans = []

for i in range(x):
    ans.append(fnc(i))

print(max(ans))

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

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: Given are integers A, B, and N.  Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non- negative integer x not greater than N.  Here floor(t) denotes the greatest integer not greater than the real number t.

Submission attempts (in order):
a, b, n = map(int, input().split())
ans1 = 0
for i in range(n+1):
  ans2 = int(a * i / b) - a * int(i / b)
  ans1 = max(ans1, ans2)
  if ans1 == ans2:
    x = i
print(x)

a, b, n = map(int, input().split())
if b > n:
  x = n
else:
  x = b - 1
print(int(a * x / b) - a * int(x / b))

Verdicts: Wrong Answer

Accepted
Problem: Given are integers A, B, and N.  Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non- negative integer x not greater than N.  Here floor(t) denotes the greatest integer not greater than the real number t.

Submission attempts (in order):
A,B,X = map(int,input().split())
print(min(B-1,N))

A,B,N = map(int,input().split())
x = min(B-1,N)
ans = int(A*x/B) - A*int(x/B)
print(ans)

Verdicts: Runtime Error

Accepted
Problem: Given are integers A, B, and N.  Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non- negative integer x not greater than N.  Here floor(t) denotes the greatest integer not greater than the real number t.

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

d = 0
ans = 0
for i in range(1, N+1):
    d = math.floor((A*i)/B) - A*math.floor(i/B)
    if ans <= d:
        ans = d
    else:
        print(ans)
        exit()


import math

A, B, N = map(int, input().split())
print(math.floor((A * min(B-1, N)) / B) - A * math.floor(min(B-1, N) / B))

Verdicts: Wrong Answer

Accepted
Problem: Given are integers A, B, and N.  Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non- negative integer x not greater than N.  Here floor(t) denotes the greatest integer not greater than the real number t.

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

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

if a <= n:
    print(a-1)
else:
    for i in range(n+1,n-a,-1):
        ans = max(ans,(a*i)//b - a*(i//b))
    print(ans)

a,b,n = map(int,input().split())
ans = 0
 
for i in range(n+1,n-4*a,-1):
    ans = max(ans,(a*i)//b - a*(i//b))
 
print(ans)



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

for i in range(n+1,n-a,-1):
    ans = max(ans,(a*i)//b - a*(i//b))

print(ans)



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

for i in range(n+1,n-10*a,-1):
    ans = max(ans,(a*i)//b - a*(i//b))

print(ans)



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

for i in range(n+1,n-a,-1):
    ans = max(ans,(a*i)//b) - a*(i//b))

print(ans)

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


for i in range(2*a):
    ans = max(ans,int((a*i)/b) - a*int(i/b))

print(ans)



a,b,n = map(int,input().split())
ans = 0
round=lambda x:(x*2+1)//2

for i in range(2*a):
    ans = max(ans,round((a*i)/b) - a * round(i/b))

print(ans)

a,b,n = map(int,input().split())
ans = 0
 
for i in range(n+1,n-2*a,-1):
    ans = max(ans,(a*i)//b - a*(i//b))
 
print(ans)

a,b,n = map(int,input().split())
i = min(b-1,n)
ans = a*i//b - a*(i//b)
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Given are integers A, B, and N.  Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non- negative integer x not greater than N.  Here floor(t) denotes the greatest integer not greater than the real number t.

Submission attempts (in order):
n, m, q = map(int, input().strip().split())
L = [list(map(int, input().split())) for _ in range(q)]

possibleA=[[i]*n for i in range(1,m+1)]
for i in range(n):
    for j in range(i+1,m+1):
        

import math
a, b, n = map(int, input().strip().split())
if b<n:
    x=n
elif n % b <= n%(b/a):
    x=n-n%b-1
elif (n%b-n%(b/a)+1)//(b/a)>a*b:
    x=n-n%b-1
else:
    x=n
print(math.floor(a*x/b)-a*math.floor(x/b))

import math
a, b, n = map(int, input().strip().split())
if b<n:
    x=n
elif (n % b - n%(b/a)+1)//(b/a)+1<a:
    x=n-n%b-1
# elif (n%b-n%(b/a)+1)<a:
#     x=n-n%b-1
else:
    x=n
print(math.floor(a*x/b)-a*math.floor(x/b))

import math
a, b, n = map(int, input().strip().split())
if b<n:
    x=n
elif n % b <= n%(b/a):
    x=n-n%b-1
elif (n%b-n%(b/a)+1)<a:
    x=n-n%b-1
else:
    x=n
print(math.floor(a*x/b)-a*math.floor(x/b))

import math
a, b, n = map(int, input().strip().split())
if b<n:
    x=n
elif n % b <= n%(b/a):
    x=n-n%b-1
elif (n % b - n%(b/a)+1)//(b/a)+1<a:#(n%b-n%(b/a)+1)<a:
    x=n-n%b-1
else:
    x=n
print(math.floor(a*x/b)-a*math.floor(x/b))

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

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Given are integers A, B, and N.  Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non- negative integer x not greater than N.  Here floor(t) denotes the greatest integer not greater than the real number t.

Submission attempts (in order):

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
msi = lambda: map(str, input().split())
lmii = lambda: list(map(int, input().split()))
lmsi = lambda: list(map(str, input().split()))
smii = lambda: sorted(map(int, input().split()))

# ----------

A, B, N = mii()

ans = 0
x = B
ans = max(ans, A*x//B - A*(x//B))
if N > 1:
    x -= 1
    ans = max(ans, A*x//B - A*(x//B))

print(ans)


si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
msi = lambda: map(str, input().split())
lmii = lambda: list(map(int, input().split()))
lmsi = lambda: list(map(str, input().split()))
smii = lambda: sorted(map(int, input().split()))

# ----------

A, B, N = mii()

ans = 0

x = B
ans = max(ans, A*x//B - A*(x//B))
x -= 1
ans = max(ans, A*x//B - A*(x//B))

print(ans)


si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
msi = lambda: map(str, input().split())
lmii = lambda: list(map(int, input().split()))
lmsi = lambda: list(map(str, input().split()))
smii = lambda: sorted(map(int, input().split()))

# ----------

A, B, N = mii()

ans = 0
x = B
ans = max(ans, A*x//B - A*(x//B))
if B > 1:
    x -= 1
    ans = max(ans, A*x//B - A*(x//B))

print(ans)



si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
msi = lambda: map(str, input().split())
lmii = lambda: list(map(int, input().split()))
lmsi = lambda: list(map(str, input().split()))
smii = lambda: sorted(map(int, input().split()))

# ----------


A, B, N = mii()

ans = 0
x = min(N, B)


ans = max(ans, A*x//B - A*(x//B))

if x > 1:
    x -= 1
    ans = max(ans, A*x//B - A*(x//B))

print(ans)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Given are integers A, B, and N.  Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non- negative integer x not greater than N.  Here floor(t) denotes the greatest integer not greater than the real number t.

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

ans = 0
T = 0
for i in range(1,n+1)[::-1]:
  t = (a*i)//b - a*(i//b)
  if T < t:
    T = t
    ans = i

print(ans)

a,b,n = list(map(int, input().split()))
t = 0
n = min(b-1,n)

print((a*n)//b - a*(n//b))

Verdicts: Wrong Answer

Accepted
Problem: Given are integers A, B, and N.  Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non- negative integer x not greater than N.  Here floor(t) denotes the greatest integer not greater than the real number t.

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

ans1 = (a*n)//b - a*(n//b)
ans2 = (a*(b-1))//b - a*((b-1)//b)

print(max(ans1,ans2))

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

if n < b-1:
    print(a*(n%b)//b)
else:
    print(a*((b-1)%b)//b)

Verdicts: Wrong Answer

Accepted
Problem: Given are integers A, B, and N.  Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non- negative integer x not greater than N.  Here floor(t) denotes the greatest integer not greater than the real number t.

Submission attempts (in order):
a,b,n = map(int, input().split())
if n < b:
    x = n
else:
    x = b-1
while x >= 0:
    val = (a*x)//b-a*(x//b)
    if val < com:
        pass
    else:
        com = val
    x -= 1
print(com)

from math import floor
a,b,n = map(int, input().split())
x = n
com = 0
while x >= 0:
    val = floor((a*x)/b)-a*floor(x/b)
    if val < com:
        pass
    else:
        com = val
    x-=1
    print("val = ",val,"   com = ",com)
print(com)

a,b,n = map(int, input().split())
com = 0
if n < b:
    x = n
else:
    x = b-1
val = (a*x)//b
print(val)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: Given are integers A, B, and N.  Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non- negative integer x not greater than N.  Here floor(t) denotes the greatest integer not greater than the real number t.

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

temp_prev = 0
temp_curr = 0
x = b-1.0
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))

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

temp_prev = 0
temp_curr = 0
if b <= 100:
    x = 0.0
else:
    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))

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

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given are integers A, B, and N.  Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non- negative integer x not greater than N.  Here floor(t) denotes the greatest integer not greater than the real number t.

Submission attempts (in order):

A,B,N = map(int,input().split())
x = max(B-1,N)
print(int(A*x/B))


A,B,N = map(int,input().split())
x = min(B-1,N)
print(int(A*x/B))

Verdicts: Wrong Answer

Accepted
Problem: Given are integers A, B, and N.  Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non- negative integer x not greater than N.  Here floor(t) denotes the greatest integer not greater than the real number t.

Submission attempts (in order):

def main():
    A, B, N = map(int, input().split())
    max = ((A*N)//B) - (A * (N//B))

    if B>=N:
        temp = ((A*(B-1))//B) - (A * ((B-1)//B))
        if max < temp:
            max = temp
    
    NN = N - A -1
    if NN < 0:
        NN = 0
    for index in (NN,N):
        temp = ((A*index)//B) - (A * (index//B))
        if max < temp:
            max = temp


    print(max)




if __name__ == '__main__':
    main()



def main():
    A, B, N = map(int, input().split())
    max = ((A*N)//B) - (A * (N//B))

    if B>=N:
        temp = ((A*(B-1))//B) - (A * ((B-1)//B))
        if max > temp:
            max = temp
    
    NN = N - A -1
    if NN < 0:
        NN = 0
    for index in (NN,N):
        temp = ((A*index)//B) - (A * (index//B))
        if max > temp:
            max = temp


    print(max)




if __name__ == '__main__':
    main()



def main():
    A, B, N = map(int, input().split())
    max = ((A*N)//B) - (A * (N//B))

    if B<=N:
        temp = ((A*(B-1))//B) - (A * ((B-1)//B))
        if max < temp:
            max = temp

    print(max)




if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given are integers A, B, and N.  Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non- negative integer x not greater than N.  Here floor(t) denotes the greatest integer not greater than the real number t.

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

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

Verdicts: Wrong Answer

Accepted
Problem: Given are integers A, B, and N.  Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non- negative integer x not greater than N.  Here floor(t) denotes the greatest integer not greater than the real number t.

Submission attempts (in order):
import math

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

l = [0]

for x in reversed(range(0,n+1)):
    ans = 0
    ans = math.floor(a*x/b) - a * math.floor(x/b)
    l.append(ans)
    if max(l) > ans:
        break
print(l)
print(max(l))

import math

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

l = [0]

for x in range(1,100):
    ans = 0
    ans = math.floor(a*x/b) - a * math.floor(x/b)
    l.append(ans)
    if l[x+1] > ans:
        break

print(ans)

A,B,N=map(int,input().split())
def f(x):
  return int(A*x/B)-A*int(x/B)

print(f(min(N,B-1)))


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: Given are integers A, B, and N.  Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non- negative integer x not greater than N.  Here floor(t) denotes the greatest integer not greater than the real number t.

Submission attempts (in order):
a,b,n=map(int,input().split())
nmax = (a*n)//b - a*(n//b)
x = b-1
xmax = (a*x)//b - a*(x//b)
print(max(nmax,xmax))

a,b,n=map(int,input().split())
s=n//b
nmax = (a*n)//b - a*(n//b)

#     x = b*i-1
#     t = (a*x)//b - a*(x//b)
#     if t > nmax:
#         nmax = t
# b_n = b

# while b_n <= n:
#     x = b_n -1
#     t = (a*x)//b - a*b_nn
#     if t > nmax:
#         nmax = t
#     b_n += b

x = b*s-1
t = (a*x)//b - a*b_nn
if t > nmax:
    nmax = t
print(nmax)

a,b,n=map(int,input().split())
nmax = (a*n)//b - a*(n//b)
x = b-1
xmax = (a*x)//b - a*(x//b)
print(max(nmax,xmax) if x < n else nmax)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: We have a tree with N vertices, whose i-th edge connects Vertex u_i and Vertex v_i. Vertex i has an integer a_i written on it. For every integer k from 1 through N, solve the following problem:    * We will make a sequence by lining up the integers written on the vertices along the shortest path from Vertex 1 to Vertex k, in the order they appear. Find the length of the longest increasing subsequence of this sequence.  Here, the longest increasing subsequence of a sequence A of length L is the subsequence A_{i_1} , A_{i_2} , ... , A_{i_M} with the greatest possible value of M such that 1 \leq i_1 < i_2 < ... < i_M \leq L and A_{i_1} < A_{i_2} < ... < A_{i_M}.

Submission attempts (in order):
from collections import deque
from bisect import bisect_right
from copy import deepcopy
n=int(input())
a=list(map(int,input().split()))
edge=[[] for _ in range(n)]
for _ in range(n-1):
    u,v=map(int,input().split())
    u-=1
    v-=1
    edge[u].append(v)
    edge[v].append(u)
visited=[True]*n
lis=[[] for _ in range(n)]
def dfs():
    stack=deque([0])
    visited[0]=False
    lis[0]=[a[0]]
    while stack:
        x=stack.pop()
        for nx in edge[x]:
            if visited[nx]:
                if a[nx]>lis[x][-1]:
                    lis[nx]=lis[x]+[a[nx]]
                else:
                    idx=bisect_right(cur,a[nx])
                    cur=deepcopy(lis[x])
                    cur[idx]=a[nx]
                    lis[nx]=cur
                visited[nx]=False
                stack.append(nx)
    return
dfs()
for i in range(n):
    print(len(lis[i]))

from collections import deque
from bisect import bisect_left
import sys
sys.setrecursionlimit(10**7)
n=int(input())
a=list(map(int,input().split()))
edge=[[] for _ in range(n)]
for _ in range(n-1):
    u,v=map(int,input().split())
    u-=1
    v-=1
    edge[u].append(v)
    edge[v].append(u)
stack=deque([])
inf=10**18
lis=[inf]*(n+1)
ans=[0 for _ in range(n)]
visited=[True]*n
#print(edge)
def dfs(s):
    visited[s]=False
    idx=bisect_left(lis,a[s])
    stack.append((idx,lis[idx]))
    lis[idx]=a[s]
    ans[s]=bisect_left(lis,inf)
    for x in edge[s]:
        if visited[x]:
            dfs(x)
    idx,val=stack.pop()
    lis[idx]=val
dfs(0)
#print(lis)
for i in range(n):
    print(ans[i])

Verdicts: Runtime Error

Accepted
Problem: We have a tree with N vertices, whose i-th edge connects Vertex u_i and Vertex v_i. Vertex i has an integer a_i written on it. For every integer k from 1 through N, solve the following problem:    * We will make a sequence by lining up the integers written on the vertices along the shortest path from Vertex 1 to Vertex k, in the order they appear. Find the length of the longest increasing subsequence of this sequence.  Here, the longest increasing subsequence of a sequence A of length L is the subsequence A_{i_1} , A_{i_2} , ... , A_{i_M} with the greatest possible value of M such that 1 \leq i_1 < i_2 < ... < i_M \leq L and A_{i_1} < A_{i_2} < ... < A_{i_M}.

Submission attempts (in order):
from bisect import bisect

N = int(input())
a = list(map(int,input().split()))
g = [[] for _ in range(N)]
for i in range(N-1):
    u,v = map(int,input().split())
    u -= 1
    v -= 1
    g[u].append(v)
    g[v].append(u)

ans = [0]*N
def dfs(t,f,l,seq):
    l = l.copy()
    seq = seq.copy()
    l.append(a[t])
    print(l,seq)
    i = bisect(seq,l[-1])
    if len(seq)==i:
        seq.append(l[-1])
    else:
        seq[i]=l[-1]
    ans[t] = len(seq)
    for v in g[t]:
        if v != f:
            dfs(v,t,l,seq)
dfs(0,0,[],[])
for i in range(N):
    print(ans[i])


from bisect import bisect_left as bisect
import sys
sys.setrecursionlimit(10**9)

N = int(input())
a = list(map(int,input().split()))
g = [[] for _ in range(N)]
for i in range(N-1):
    u,v = map(int,input().split())
    u -= 1
    v -= 1
    g[u].append(v)
    g[v].append(u)

ans = [0]*N
def dfs(t,f,l):
    res = 0
    i = bisect(l,a[t])
    if len(l)==i:
        l.append(a[t])
    else:
        res = [i,l[i]]
        l[i]=a[t]
    ans[t] = len(l)
    for v in g[t]:
        if v != f:
            back = dfs(v,t,l)
            if back:
                l[back[0]] = back[1]
            else:
                l.pop()
    return res
dfs(0,0,[])
for i in range(N):
    print(ans[i])

Verdicts: Runtime Error

Accepted
Problem: We have a tree with N vertices, whose i-th edge connects Vertex u_i and Vertex v_i. Vertex i has an integer a_i written on it. For every integer k from 1 through N, solve the following problem:    * We will make a sequence by lining up the integers written on the vertices along the shortest path from Vertex 1 to Vertex k, in the order they appear. Find the length of the longest increasing subsequence of this sequence.  Here, the longest increasing subsequence of a sequence A of length L is the subsequence A_{i_1} , A_{i_2} , ... , A_{i_M} with the greatest possible value of M such that 1 \leq i_1 < i_2 < ... < i_M \leq L and A_{i_1} < A_{i_2} < ... < A_{i_M}.

Submission attempts (in order):
import sys
sys.setrecursionlimit(1e6)
def dfs(vertex):
  visited[vertex] = True
  if vertex != 0:
    maxlen = 0
    x = a[vertex]
    for (L, z) in table:
      if z < x: # strict increasing
        maxlen = max(maxlen, L)
    table.append((maxlen+1, x))
  ans[vertex] = max(L for (L, _) in table)
  for node in adjacent[vertex]:
    if not visited[node]:
      dfs(node)
  table.pop()
  return
n = int(input())
a = list(map(int, input().split()))
adjacent = {i: [] for i in range(n)}
for _ in range(n-1):
  node1, node2 = map(int, input().split())
  node1 -= 1
  node2 -= 1
  adjacent[node1].append(node2)
  adjacent[node2].append(node1)
visited = [False]*n
ans = [0]*n
table = [(1, a[0])]
dfs(0)
[print(value) for value in ans]

def longest_subsequence(sequence):
  return 5

def true_longest_subsequence(sequence):
  table = [(1, sequence[0])]
  for x in sequence[1:]:
    maxlen = 0
    for (L, z) in table:
      if z < x: # strict increasing
        maxlen = max(maxlen, L)
    table.append((maxlen+1, x))
  return max(L for (L, _) in table)
def dfs(vertex):
  visited[vertex] = True
  node_sequence.append(a[vertex])
  ans[vertex] = longest_subsequence(node_sequence)
  for node in adjacent[vertex]:
    if not visited[node]:
      dfs(node)
  node_sequence.pop()
  return
n = int(input())
a = list(map(int, input().split()))
adjacent = {i: [] for i in range(n)}
for _ in range(n-1):
  node1, node2 = map(int, input().split())
  node1 -= 1
  node2 -= 1
  adjacent[node1].append(node2)
  adjacent[node2].append(node1)
node_sequence = list()
visited = [False]*n
ans = [0]*n
dfs(0)
[print(value) for value in ans]

import sys
sys.setrecursionlimit(1000000)
from bisect import bisect, bisect_left
def dfs(vertex):
  visited[vertex] = True
  value = a[vertex]
  j = bisect(dp, value)
  previous = dp[j]
  if dp[j-1] != value: # strict increasing
    dp[j] = value
  ans[vertex] = bisect_left(dp, float("inf"))-1
  for node in adjacent[vertex]:
    if not visited[node]:
      dfs(node)
  dp[j] = previous
  return
n = int(input())
a = list(map(int, input().split()))
adjacent = {i: [] for i in range(n)}
for _ in range(n-1):
  node1, node2 = map(int, input().split())
  node1 -= 1
  node2 -= 1
  adjacent[node1].append(node2)
  adjacent[node2].append(node1)
visited = [False]*n
ans = [0]*n
dp = [float("inf") for _ in range(n+1)]
dp[0] = float("-inf")
dfs(0)
[print(value) for value in ans]

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: We have a tree with N vertices, whose i-th edge connects Vertex u_i and Vertex v_i. Vertex i has an integer a_i written on it. For every integer k from 1 through N, solve the following problem:    * We will make a sequence by lining up the integers written on the vertices along the shortest path from Vertex 1 to Vertex k, in the order they appear. Find the length of the longest increasing subsequence of this sequence.  Here, the longest increasing subsequence of a sequence A of length L is the subsequence A_{i_1} , A_{i_2} , ... , A_{i_M} with the greatest possible value of M such that 1 \leq i_1 < i_2 < ... < i_M \leq L and A_{i_1} < A_{i_2} < ... < A_{i_M}.

Submission attempts (in order):
import sys
sys.setrecursionlimit(1000000)
def input():
    return sys.stdin.readline()
n = int(input())
a = [int(i) for i in input().split()]
e = [[] for _ in range(n)]
for _ in range(n - 1):
    aa, bb = [int(i) - 1 for i in input().split()]
    e[aa].append(bb)
    e[bb].append(aa)

ans = [0] * n
ans[0] = 1
ans2 = [0] * n
ans2[0] = 1


def dfs(i=0, r=-1, x=[], y=[]):
    if r == -1:
        x.append(a[i])
    else:
        if x[0] >= a[i]:
            ans[i] = 1
        else:
            mi = 0
            ma = len(x) - 1
            while mi != ma:
                mm = (mi + ma) // 2+1
                if x[mm] < a[i]:
                    mi = mm
                else:
                    ma = mm - 1
            ans[i] = ans[y[mi]]+1
        ans2[i] = max(ans2[r], ans[i])
        x.append(max(x[-1], a[i]))
    y.append(i)
    for j in e[i]:
        if j != r:
            dfs(j, i)
    y.pop()
    x.pop()


dfs()
for i in ans2:
    print(i)


import sys
sys.setrecursionlimit(1000000)


def input():
    return sys.stdin.readline()


n = int(input())
aa = [int(i) for i in input().split()]
e = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = [int(i) - 1 for i in input().split()]
    e[a].append(b)
    e[b].append(a)

dp = [10 ** 9] * (n + 10)
dp[0] = 0
ans1 = [0] * n
ans2 = [0] * n


def dfs(i=0, r=-1):
    global dp, ans1, ans2
    mi = 0
    ma = n
    while mi != ma:
        mm = (mi + ma) // 2
        if dp[mm] >= aa[i]:
            ma = mm
        else:
            mi = mm + 1

    be = dp[mi]
    dp[mi] = min(dp[mi], aa[i])
    ans1[i] = mi
    ans2[i] = max(ans1[i], ans2[r])

    for j in e[i]:
        if j == r:
            continue
        dfs(j, i)

    dp[mi] = be


dfs()
print("\n".join(map(str, ans2)))


Verdicts: Wrong Answer

Accepted
Problem: We have a tree with N vertices, whose i-th edge connects Vertex u_i and Vertex v_i. Vertex i has an integer a_i written on it. For every integer k from 1 through N, solve the following problem:    * We will make a sequence by lining up the integers written on the vertices along the shortest path from Vertex 1 to Vertex k, in the order they appear. Find the length of the longest increasing subsequence of this sequence.  Here, the longest increasing subsequence of a sequence A of length L is the subsequence A_{i_1} , A_{i_2} , ... , A_{i_M} with the greatest possible value of M such that 1 \leq i_1 < i_2 < ... < i_M \leq L and A_{i_1} < A_{i_2} < ... < A_{i_M}.

Submission attempts (in order):
# coding: utf-8
import sys
from bisect import bisect_left, bisect_right, insort
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = [0] + lr()  # 1-indexed
graph = [[] for _ in range(N+1)]  # 1-indexed
for _ in range(N-1):
    a, b = lr()
    graph[a].append(b)
    graph[b].append(a)

answer = [0] * (N+1)  # 1-indexed
INF = 10 ** 10
parent = [-1] * (N+1)

def dfs(n, arr):
    
    i = bisect_left(arr, INF)
    answer[n] = i
    print('n, i', n, i, arr[:5])
    for c in graph[n]:
        if c == parent[n]:
            continue
        parent[c] = n
        new = arr[:]
        i = bisect_left(new, A[c])
        new[i] = A[c]
        dfs(c, new)

B = [INF] * (N+1)
B[0] = A[1]
dfs(1, B)
for a in answer[1:]:
    print(a)


# coding: utf-8
import sys
from bisect import bisect_left, bisect_right, insort
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = [0] + lr()  # 1-indexed
graph = [[] for _ in range(N+1)]  # 1-indexed
for _ in range(N-1):
    a, b = lr()
    graph[a].append(b)
    graph[b].append(a)

answer = [0] * (N+1)  # 1-indexed
INF = 10 ** 10
parent = [-1] * (N+1)

def dfs(n):
    
    i = bisect_left(dp, INF)
    answer[n] = i
    for c in graph[n]:
        if c == parent[n]:
            continue
        parent[c] = n
        i = bisect_left(dp, A[c])
        old = dp[i]
        dp[i] = A[c]
        dfs(c)
        dp[i] = old

dp = [INF] * (N+1)
dp[0] = A[1]
dfs(1)
for a in answer[1:]:
    print(a)


Verdicts: Wrong Answer

Accepted
Problem: We have a tree with N vertices, whose i-th edge connects Vertex u_i and Vertex v_i. Vertex i has an integer a_i written on it. For every integer k from 1 through N, solve the following problem:    * We will make a sequence by lining up the integers written on the vertices along the shortest path from Vertex 1 to Vertex k, in the order they appear. Find the length of the longest increasing subsequence of this sequence.  Here, the longest increasing subsequence of a sequence A of length L is the subsequence A_{i_1} , A_{i_2} , ... , A_{i_M} with the greatest possible value of M such that 1 \leq i_1 < i_2 < ... < i_M \leq L and A_{i_1} < A_{i_2} < ... < A_{i_M}.

Submission attempts (in order):
from collections import defaultdict,deque
import bisect

N = int(input())
A = list(map(int,input().split()))
graph = defaultdict(deque)
for _ in range(0,N-1):
    u,v = map(int,input().split())
    graph[u].append(v)
    graph[v].append(u)

arrive = [False] * (N+1)
dp_dict = [None] * N
dp_dict[0] = [A[0]]

ans = [None] *(N+1)
def dfs(s):
    stack = deque([s])
    while stack:
        v = stack[-1]
        arrive[v] = True
        if graph[v]:
            w = graph[v].pop()
            if arrive[w] == False:
                tar = A[w-1]
                dp = dp_dict[v-1]
                if tar > dp[-1]:
                    dp.append(tar)
                else:
                    dp[bisect.bisect_left(dp, tar)] = tar
                ans[w] = len(dp)
                dp_dict[w-1] = dp
                stack.append(w)

        else:
            stack.pop()


dfs(1)
ans[1] = 1
for i in ans[1::]:
    print(i)

import bisect
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
 
N = int(input())
A = tuple(map(int, input().split()))
graph = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    x, y = map(int, input().split())
    graph[x].append(y)
    graph[y].append(x)
 
ans = [-1] * (N + 1)
inf = 10**18
LIS = [inf] * (N + 1)
 
def DFS(s, parent=0):
    a = A[s - 1]
    i = bisect.bisect_left(LIS, a)
    v = LIS[i]
    LIS[i] = a
    ans[s] = bisect.bisect_left(LIS, inf)
    for t in graph[s]:
        if t == parent:
            continue
        DFS(t, s)
    LIS[i] = v
    return
 
DFS(1)
print(*ans[1:], sep="\n")

Verdicts: Wrong Answer

Accepted
Problem: We have a tree with N vertices, whose i-th edge connects Vertex u_i and Vertex v_i. Vertex i has an integer a_i written on it. For every integer k from 1 through N, solve the following problem:    * We will make a sequence by lining up the integers written on the vertices along the shortest path from Vertex 1 to Vertex k, in the order they appear. Find the length of the longest increasing subsequence of this sequence.  Here, the longest increasing subsequence of a sequence A of length L is the subsequence A_{i_1} , A_{i_2} , ... , A_{i_M} with the greatest possible value of M such that 1 \leq i_1 < i_2 < ... < i_M \leq L and A_{i_1} < A_{i_2} < ... < A_{i_M}.

Submission attempts (in order):
from collections import deque
import bisect
import sys
def input(): return sys.stdin.readline().rstrip()
 
def main():
    n = int(input())
    graph = [[] for _ in range(n+1)]
 
    A = [0]+list(map(int, input().split()))
 
    for i in range(n-1):
        a, b = map(int, input().split())
        graph[a].append(b)
        graph[b].append(a)
 
    dist = [-1] * (n+1)
    dist[0] = 0
    dist[1] = 1
 
    d = deque()
    d.append((1, [0, A[1]]))
 
    while d:
        v, dp = d.popleft()
        for i in graph[v]:
            if dist[i] != -1:
                continue
            if dp[-1] < A[i]:
                dp.append(A[i])
                d.append((i, dp.copy()))
                dist[i] = len(dp)-1
                dp.pop()
            else:
                bis = bisect.bisect_left(dp, A[i])
                updatetask=dp[bis]
                dp[bis] = A[i]
                dist[i] = len(dp)-1
                d.append((i, dp))
                dp[bis]=updatetask
 
    print(*dist[1:], sep="\n")
 
if __name__ == '__main__':
    main()

from collections import deque
import sys
import bisect
def input(): return sys.stdin.readline().rstrip()

n=int(input())
A=[0]+list(map(int, input().split()))

graph = [[] for _ in range(n+1)]

for i in range(n-1):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

visited = [-1] * (n+1)
visited[0] = 0
visited[1] = 1

d = deque()
d.append(1)
dp=[10**10]*(n+1)
dp[0]=0
dp[1]=A[1]
update_task=[() for _ in range(n+1)]
update_task[1]=(1,0)
while d:
    v = d[-1]
    if graph[v] == []:
        d.pop()
        index,atai=update_task[v]
        dp[index]=atai
    else:
        i = graph[v].pop()
        if visited[i] != -1:
            continue
        bis = bisect.bisect_left(dp, A[i])
        update_task[i]=(bis,dp[bis])
        dp[bis] = A[i]
        visited[i] = bisect.bisect_left(dp, 10**10-100)-1
        d.append(i)

print(*visited[1:], sep="\n")

Verdicts: Wrong Answer

Accepted
Problem: We have a tree with N vertices, whose i-th edge connects Vertex u_i and Vertex v_i. Vertex i has an integer a_i written on it. For every integer k from 1 through N, solve the following problem:    * We will make a sequence by lining up the integers written on the vertices along the shortest path from Vertex 1 to Vertex k, in the order they appear. Find the length of the longest increasing subsequence of this sequence.  Here, the longest increasing subsequence of a sequence A of length L is the subsequence A_{i_1} , A_{i_2} , ... , A_{i_M} with the greatest possible value of M such that 1 \leq i_1 < i_2 < ... < i_M \leq L and A_{i_1} < A_{i_2} < ... < A_{i_M}.

Submission attempts (in order):
from bisect import bisect_left
import sys
sys.setrecursionlimit(1000000)



def dfs(p):
    ai = a[p]
    i = bisect_left(dp, ai)
    old = dp[i]
    dp[i] = ai
    ans[p] = bisect_left(dp, INF)-1
    for child in to[p]:
        if ans[child] is None:
            dfs(child)
    dp[i] = old
    
    
        

if __name__ == "__main__":
    n = int(input())
    a = [None] + list(map(int, input().split()))
    to = [[] for _ in range(n+1)]
    for _ in range(n-1):
        u, v = map(int, input().split())
        to[u].append(v)
        to[v].append(u)
    INF = 10**20
    dp = [INF]*(n+1)
    dp[0]= -INF
    q = deque([1])
    ans = [None]*(n+1)
    dfs(1)
    print("\n".join(list(map(str, ans[1:]))))

from bisect import bisect_left
import sys
sys.setrecursionlimit(1000000)



def dfs(p):
    ai = a[p]
    i = bisect_left(dp, ai)
    old = dp[i]
    dp[i] = ai
    ans[p] = bisect_left(dp, INF)-1
    for child in to[p]:
        if ans[child] is None:
            dfs(child)
    dp[i] = old
    
    
        

if __name__ == "__main__":
    n = int(input())
    a = [None] + list(map(int, input().split()))
    to = [[] for _ in range(n+1)]
    for _ in range(n-1):
        u, v = map(int, input().split())
        to[u].append(v)
        to[v].append(u)
    INF = 10**20
    dp = [INF]*(n+1)
    dp[0]= -INF
    ans = [None]*(n+1)
    dfs(1)
    print("\n".join(list(map(str, ans[1:]))))

Verdicts: Runtime Error

Accepted
Problem: There are S sheep and W wolves.  If the number of wolves is greater than or equal to that of sheep, the wolves will attack the sheep.  If the wolves will attack the sheep, print `unsafe`; otherwise, print `safe`.

Submission attempts (in order):
a,b=map(int,input().split())
if a=<b:
  print("unsafe")
else:
  print("safe")

a,b=map(int,input().split())
if a<=b:
  print("unsafe")
else:
  print("safe")

Verdicts: Runtime Error

Accepted
Problem: There are S sheep and W wolves.  If the number of wolves is greater than or equal to that of sheep, the wolves will attack the sheep.  If the wolves will attack the sheep, print `unsafe`; otherwise, print `safe`.

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

if a<b:
	print('safe')
else:
	print('unsafe')


a ,b = input().split()

a=int(a)
b=int(b)
if a<b:
	print('safe')
else:
	print('unsafe')


a , b , c , d = input().split()

a=int(a)
b=int(b)
c=int(c)
d=int(d)

while True:
  c -= b
  if c <= 0:
    print('Yes')
    break
  a -= d
  if a <= 0:
    print('No')
    break



a ,b = input().split()

a=int(a)
b=int(b)
if a>b:
	print('safe')
else:
	print('unsafe')


Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Accepted