Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n, m, q = map(int, input().split())
l = [[int(i) for i in input().split()] for _ in range(q)]
m -= 1
As = []


def gen_A(x, y, A, c):
  global As
  if x == n and y == m:
    As.append(A)
    return
  if x < n:
    nA = A+str(c)
    gen_A(x+1, y, nA, c)
  if y < m:
    nc = c+1
    gen_A(x, y+1, A, nc)


gen_A(0, 0, "", 0)
mx = 0
for A in As:
  pts = 0
  for i in l:
    if int(A[i[1]-1])-int(A[i[0]-1]) == i[2]:
      pts += i[3]
  mx = max(mx, pts)
print(mx)

Fixed submission:
n, m, q = map(int, input().split())
l = [[int(i) for i in input().split()] for _ in range(q)]
m -= 1
mx = 0


def gen_A(x, y, A, c):
  global mx
  if x == n and y == m:
    pts = 0
    for i in l:
      if int(A[i[1]-1])-int(A[i[0]-1]) == i[2]:
        pts += i[3]
    mx = max(mx, pts)
    return
  if x < n:
    nA = A+str(c)
    gen_A(x+1, y, nA, c)
  if y < m:
    nc = c+1
    gen_A(x, y+1, A, nc)


gen_A(0, 0, "", 0)
print(mx)
Buggy python submission (verdict: Time Limit Exceeded):
a, b, n = map(int, input().split())
Max = 0
e = 1/b
for i in range(n):
  i += 1  
  Max = max(Max, int(a*i*e)-a*int(i*e))
  if Max != int(a*i*e)-a*int(i*e):
    print(Max)
    break
else:
  print(Max)

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

Buggy python submission (verdict: Time Limit Exceeded):
a, b, n = map(int, input().split())
Max = 0
for i in range(n):
  i += 1
  Max = max(Max, a*i//b-a*(i//b))
  if Max != a*i//b-a*(i//b):
    print(Max)
    break
else:
  print(Max)

Fixed submission:
a, b, n = map(int, input().split())
x = min(b-1, n)
print(int(a*(x)/b)-a*int(x/b))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ans = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    if s[i] != s[j]:
      for k in range(j+1, n):
        if s[j] != s[k] and s[k]!= s[i]:
          if j-i != k-j:
            ans +=1
print(ans)

Fixed submission:
import statistics as st
n = int(input())
s = input()
NGs = 0
r = set()
g = set()
b = set()
for i in range(n):
  if s[i] == "R":
    r.add(i)
  elif s[i] == "G":
    g.add(i)
  else:
    b.add(i)
for i in range(n-2):
  for d in range((n-i-1)//2+1):
    j = i+d
    k = j+d
    if i in r and j in g and k in b:
      NGs += 1
    elif i in r and j in b and k in g:
      NGs += 1
    elif i in g and j in r and k in b:
      NGs += 1
    elif i in g and j in b and k in r:
      NGs += 1
    elif i in b and j in r and k in g:
      NGs += 1
    elif i in b and j in g and k in r:
      NGs += 1
print(len(r)*len(g)*len(b)-NGs)

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
ans = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    if s[i] != s[j]:
    for k in range(j+1, n):
      if s[j] != s[k] and s[k]!= s[i]:
        if j-i != k-j:
          ans +=1
print(ans)

Fixed submission:
import statistics as st
n = int(input())
s = input()
NGs = 0
r = set()
g = set()
b = set()
for i in range(n):
  if s[i] == "R":
    r.add(i)
  elif s[i] == "G":
    g.add(i)
  else:
    b.add(i)
for i in range(n-2):
  for d in range((n-i-1)//2+1):
    j = i+d
    k = j+d
    if i in r and j in g and k in b:
      NGs += 1
    elif i in r and j in b and k in g:
      NGs += 1
    elif i in g and j in r and k in b:
      NGs += 1
    elif i in g and j in b and k in r:
      NGs += 1
    elif i in b and j in r and k in g:
      NGs += 1
    elif i in b and j in g and k in r:
      NGs += 1
print(len(r)*len(g)*len(b)-NGs)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ans = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    for k in range(j+1, n):
      if s[i] != s[j] and s[j] != s[k] and s[k]!= s[i]:
        if j-i != k-j:
          ans +=1
print(ans)

Fixed submission:
import statistics as st
n = int(input())
s = input()
NGs = 0
r = set()
g = set()
b = set()
for i in range(n):
  if s[i] == "R":
    r.add(i)
  elif s[i] == "G":
    g.add(i)
  else:
    b.add(i)
for i in range(n-2):
  for d in range((n-i-1)//2+1):
    j = i+d
    k = j+d
    if i in r and j in g and k in b:
      NGs += 1
    elif i in r and j in b and k in g:
      NGs += 1
    elif i in g and j in r and k in b:
      NGs += 1
    elif i in g and j in b and k in r:
      NGs += 1
    elif i in b and j in r and k in g:
      NGs += 1
    elif i in b and j in g and k in r:
      NGs += 1
print(len(r)*len(g)*len(b)-NGs)
Buggy python submission (verdict: Runtime Error):
s = input()
t = s[:int((len(s)-1)/2)]
u = s[(int(len(s)+3)/2-1):]
if s == s[::-1] and t == t[::-1] and u == u[::-1]:
  print("Yes")
else:
  print("No")

Fixed submission:
s = input()
t = s[:int((len(s)-1)/2)]
u = s[(int((len(s)+3)/2)-1):]
if s == s[::-1] and t == t[::-1] and u == u[::-1]:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
L = [int(i) for i in input().split()]
t = set(L)
dn = {}
dc = {}
All = 0
for i in L:
  dn[i] += 1
for i in t:
  dc[i] = int(dn[i]*(dn[i]-1)/2)
  All += dc[i]
for i in range(n):
  print(All-dc[L[i]] + int((dn[L[i]]-1)*(dn[L[i]]-2)/2))

Fixed submission:
n = int(input())
L = [int(i) for i in input().split()]
t = set(L)
dn = {}
dc = {}
All = 0
for i in t:
  dn[i] = 0
for i in L:
  dn[i] += 1
for i in t:
  dc[i] = int(dn[i]*(dn[i]-1)/2)
  All += dc[i]
for i in range(n):
  print(All-dc[L[i]] + int((dn[L[i]]-1)*(dn[L[i]]-2)/2))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
L = [int(i) for i in input().split()]
t = set(L)
dn = {}
dc = {}
All = 0
for i in t:
  dn[i] = L.count(i)
  dc[i] = int(dn[i]*(dn[i]-1)/2)
  All += dc[i]
for i in range(n):
  print(All-dc[L[i]] + int((dn[L[i]]-1)*(dn[L[i]]-2)/2))

Fixed submission:
n = int(input())
L = [int(i) for i in input().split()]
t = set(L)
dn = {}
dc = {}
All = 0
for i in t:
  dn[i] = 0
for i in L:
  dn[i] += 1
for i in t:
  dc[i] = int(dn[i]*(dn[i]-1)/2)
  All += dc[i]
for i in range(n):
  print(All-dc[L[i]] + int((dn[L[i]]-1)*(dn[L[i]]-2)/2))

Buggy python submission (verdict: Runtime Error):
n = int(input())
L = [int(i) for i in input().split()]
t = set(L)
dn = {}
dc = {}
All = 0
for i in t:
  dn[i] = L.count(i)
  dc[i] = int(dn[i]*(dn[i]-1)/2)
  All += dc[i]
for i in range(n):
  print(All-dc[L[i]] + int((dn[L[i]-1]-1)*(dn[L[i]-2])/2))

Fixed submission:
n = int(input())
L = [int(i) for i in input().split()]
t = set(L)
dn = {}
dc = {}
All = 0
for i in t:
  dn[i] = 0
for i in L:
  dn[i] += 1
for i in t:
  dc[i] = int(dn[i]*(dn[i]-1)/2)
  All += dc[i]
for i in range(n):
  print(All-dc[L[i]] + int((dn[L[i]]-1)*(dn[L[i]]-2)/2))
Buggy python submission (verdict: Runtime Error):
print(round(input()/2)-1)

Fixed submission:
print(int((int(input())-1)/2))
Buggy python submission (verdict: Runtime Error):
s = input()
print("2017/01/"+s[-2:]

Fixed submission:
s = input()
print("2018/01/"+s[-2:])
Buggy python submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split(""))
m = 100*a+10*b+c
n = 100*b+10*c+d
if m%111 == 0 or n%111 == 0:
  print("Yes")
else:
  print("No")

Fixed submission:
s = input()
l = [int(s[i]) for i in range(4)]
a, b, c, d = map(int, l)
m = 100*a+10*b+c
n = 100*b+10*c+d
if m%111 == 0 or n%111 == 0:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
a, b, c, d = map(int, input(),split())
print(max(a*b, c*d))

Fixed submission:
a, b, c, d = map(int, input().split())
print(max(a*b, c*d))
Buggy python submission (verdict: Runtime Error):
a, b, c = map(str, input().split())
if b == "+":
  print(int(a)+int(b))
else:
  print(int(a)-int(b))

Fixed submission:
a, b, c = map(str, input().split())
if b == "+":
  print(int(a)+int(c))
else:
  print(int(a)-int(c))
Buggy python submission (verdict: Runtime Error):
s = set([int(i) for i in input().split()])
if s.pop() == s.pop() + s.pop():
  print("Yes")
else:
  print("No")

Fixed submission:
l = sorted([int(i) for i in input().split()])
if l[2] == l[1] + l[0]:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
a = input()
b = input()
c = input()
Sa = [a[i] for i in range(len(a))]
Sb = [b[i] for i in range(len(b))]
Sc = [c[i] for i in range(len(c))]
turn = "a"
while True:
  if turn == "a":
    if len(Sa) == 0:
      print("A")
      break
    else:
      turn = Sa.pop(0)
  elif turn == "b":
    if len(Sb) == 0:
      print("B")
      break
    else:
      turn = Sb.pop(0)
  elif: turn == "c":
    if len(Sc) == 0:
      print("C")
      break
    else:
      turn = Sc.pop(0)

Fixed submission:
a = input()
b = input()
c = input()
Sa = [a[i] for i in range(len(a))]
Sb = [b[i] for i in range(len(b))]
Sc = [c[i] for i in range(len(c))]
turn = "a"
while True:
  if turn == "a":
    if len(Sa) == 0:
      print("A")
      break
    else:
      turn = Sa.pop(0)
  elif turn == "b":
    if len(Sb) == 0:
      print("B")
      break
    else:
      turn = Sb.pop(0)
  else:
    if len(Sc) == 0:
      print("C")
      break
    else:
      turn = Sc.pop(0)

Buggy python submission (verdict: Runtime Error):
a = input()
b = input()
c = input()
Sa = [a[i] for i in range(a)]
Sb = [b[i] for i in range(b)]
Sc = [c[i] for i in range(c)]
turn = "a"
while True:
  if turn == "a":
    if len(Sa) == 0:
      print("A")
      break
    else:
      turn = Sa.pop(0)
  elif turn == "b":
    if len(Sb) == 0:
      print("B")
      break
    else:
      turn = Sb.pop(0)
  else:
    if len(Sc) == 0:
      print("C")
      break
    else:
      turn = Sc.pop(0)

Fixed submission:
a = input()
b = input()
c = input()
Sa = [a[i] for i in range(len(a))]
Sb = [b[i] for i in range(len(b))]
Sc = [c[i] for i in range(len(c))]
turn = "a"
while True:
  if turn == "a":
    if len(Sa) == 0:
      print("A")
      break
    else:
      turn = Sa.pop(0)
  elif turn == "b":
    if len(Sb) == 0:
      print("B")
      break
    else:
      turn = Sb.pop(0)
  else:
    if len(Sc) == 0:
      print("C")
      break
    else:
      turn = Sc.pop(0)
Buggy python submission (verdict: Runtime Error):
N, L = map(int, input().split())
l = [input() for _ in range(L)]
l = sorted(l)
s = ""
for i in range(L):
  s += l[i]
print(s)

Fixed submission:
N, L = map(int, input().split())
l = [input() for _ in range(N)]
l = sorted(l)
s = ""
for i in range(N):
  s += l[i]
print(s)

Buggy python submission (verdict: Runtime Error):
N, L = map(int, input().split())
l = [input() for _ in range(L)]
l.sort()
s = ""
for i in range(L):
  s += l[i]
print(s)

Fixed submission:
N, L = map(int, input().split())
l = [input() for _ in range(N)]
l = sorted(l)
s = ""
for i in range(N):
  s += l[i]
print(s)
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
flag = True
if(len(s) = len(t)-1):
  x = len(s)
  for i in range(x):
    if s[i]!=t[i]:
      flag = False
if(flag):
  print("Yes")
else:
  print("No")

Fixed submission:
s = str(input())
t = str(input())
flag = True
if(len(s) == len(t)-1):
  x = len(s)
  for i in range(x):
    if s[i]!=t[i]:
      flag = False
else:
    flag = False
if(flag):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
import fractions
import math

N, M = map(int, input().split())
a = list(map(int, input().split()))
a_uniq = list(set(a))

len_a = len(a_uniq)

# find lcm
gcd_a = a_uniq[0]
for i in range(1, len_a):
    gcd_a = fractions.gcd(gcd_a, a_uniq[i])

lcm = 1
for j in range(len_a):
    lcm *= a_uniq[j]
    
lcm = lcm / gcd_a
lcm /= 2

print(math.ceil((M / lcm) / 2), lcm, M)

Fixed submission:
import math
import numpy as np

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

a = 1
a_list = list(np.arange(N) + 1)
for i in range(N - 1):
    a += a_list.index(P[i]) * math.factorial(N - (i + 1))
    a_list.remove(P[i])
    
b = 1
b_list = list(np.arange(N) + 1)
for j in range(N):
    b += b_list.index(Q[j]) * math.factorial(N - (j + 1))
    b_list.remove(Q[j])
    
print(abs(a - b))
Buggy python submission (verdict: Runtime Error):
import numpy as np

N = int(input())

for i in range(1, int(np.sqrt(N))):
    if N % i == 0:
        ans = (i - 1) + ((N / i) - 1)

print(int(ans))

Fixed submission:
import numpy as np

N = int(input())

for i in range(1, int(np.sqrt(N)) + 1):
    if N % i == 0:
        ans = (i - 1) + ((N / i) - 1)

print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input())
check_arr = np.zeros([N, 26])

for i in range(N):
    word = input()
    for j in range(len(word)):
        check_arr[i, ord(word[j])-ord('a')] += 1
count = 0
for l in range(N):
    for m in range(l+1, N):
        if (check_arr[l] - check_arr[m] == np.zeros(26)).all():
            count += 1
            
print(count)

Fixed submission:
N = int(input())
s_list = [input() for i in range(N)]

ans = 0
word= {}

for j in s_list:
#     a = ''.join(sorted(list(j)))
    a = ''.join(sorted(j))
    if a in word:
        ans += word[a]
        word[a] += 1
    else:
        word[a] = 1
    
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys

N = int(input())
H = list(map(int, input().split()))

for i in range(1, N):
    if H[i] >= H[i-1] - 1:
        H[i-1] -= 1
    elif H[i] < H[i-1] - 1:
        print("No")
        sys.exit()

if flag == 0:
    print("Yes")

Fixed submission:
import sys

N = int(input())
H = list(map(int, input().split()))

for i in range(1, N):
    if H[i] + 1 == H[i-1]:
        H[i] += 1
    elif H[i] + 1 < H[i-1]:
        print("No")
        sys.exit()
    
print("Yes")
Buggy python submission (verdict: Runtime Error):
N = int(input())
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
c = A[0]
d = 0
for i in range(N):
    d += max(0, c - B[i])
    c = max(0, A[i+1] + min(0, c - B[i]))
    
print(sum(A) - (d + c))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
d = 0
c = A[0]

for i in range(N):
    d += max(0, c - B[i])
    c = max(0, A[i+1] + min(0, c - B[i]))
            
            
print(sum(A) - (d + c))
Buggy python submission (verdict: Runtime Error):
N, L = map(int, input().split())

aji_sum = 1 / 2 * N * (N + 2*L - 1)

if L < 0 and L + N > 0:
    eat_a = 0
elif L < 0 and L + N < 0:
    eat_a = L + N
elif L > 0 and L + N > 0:
    eat_a = L
print(int(aji_sum - eat_a))

Fixed submission:
import numpy as np

N, L = map(int, input().split())

aji_sum = 1 / 2 * N * (N + 2*L - 1)
aji_arr = np.ones(N) * L
aji_arr += np.arange(N)

eat_a = aji_arr[np.argmin(np.abs(aji_arr))]
    
print(int(aji_sum - eat_a))
Buggy python submission (verdict: Runtime Error):
N = int(input())
W = list(map(int, input().split()))

diff = np.abs(np.sum(W[0]) - np.sum(W[0:]))
for i in range(N):
    S_1 = np.sum(W[:i])
    S_2 = np.sum(W[i:])
    if S_1 > S_2:
        if diff > np.abs(S_1 - S_2):
            print(np.abs(S_1 - S_2))
        else:
            print(diff)
        break
    elif S_1 == S_2:
        print(0)
    diff = np.abs(S_1 - S_2)

Fixed submission:
import numpy as np

N = int(input())
W = list(map(int, input().split()))

diff = np.abs(np.sum(W[0]) - np.sum(W[0:]))
for i in range(N):
    S_1 = np.sum(W[:i])
    S_2 = np.sum(W[i:])
    if S_1 > S_2:
        if diff > np.abs(S_1 - S_2):
            print(np.abs(S_1 - S_2))
        else:
            print(diff)
        break
    elif S_1 == S_2:
        print(0)
    diff = np.abs(S_1 - S_2)

Buggy python submission (verdict: Runtime Error):
N = int(input())
W = list(map(int, input().split()))

diff = np.abs(np.sum(W[0]) - np.sum(W[0:]))
for i in range(N):
    S_1 = np.sum(W[:i])
    S_2 = np.sum(W[i:])
    diff = np.abs(S_1 - S_2)
    if S_1 > S_2:
        if diff > np.abs(S_1 - S_2):
            print(np.abs(S_1 - S_2))
        else:
            print(diff)
        break
    elif S_1 == S_2:
        print(0)



Fixed submission:
import numpy as np

N = int(input())
W = list(map(int, input().split()))

diff = np.abs(np.sum(W[0]) - np.sum(W[0:]))
for i in range(N):
    S_1 = np.sum(W[:i])
    S_2 = np.sum(W[i:])
    if S_1 > S_2:
        if diff > np.abs(S_1 - S_2):
            print(np.abs(S_1 - S_2))
        else:
            print(diff)
        break
    elif S_1 == S_2:
        print(0)
    diff = np.abs(S_1 - S_2)

Buggy python submission (verdict: Runtime Error):
N = int(input())
W = list(map(int, input().split()))

diff = np.abs(np.sum(W[0]) - np.sum(W[0:]))
for i in range(N):
    S_1 = np.sum(W[:i])
    S_2 = np.sum(W[i:])
    diff = np.abs(S_1 - S_2)
    if S_1 > S_2:
        if diff > np.abs(S_1 - S_2):
            print(np.abs(S_1 - S_2))
        else:
            print(diff)
        break



Fixed submission:
import numpy as np

N = int(input())
W = list(map(int, input().split()))

diff = np.abs(np.sum(W[0]) - np.sum(W[0:]))
for i in range(N):
    S_1 = np.sum(W[:i])
    S_2 = np.sum(W[i:])
    if S_1 > S_2:
        if diff > np.abs(S_1 - S_2):
            print(np.abs(S_1 - S_2))
        else:
            print(diff)
        break
    elif S_1 == S_2:
        print(0)
    diff = np.abs(S_1 - S_2)
Buggy python submission (verdict: Runtime Error):
import numpy as np

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

ks_list = []
for i in range(M):
    ks = list(map(int, input().split()))
    ks_list.append(ks)
    
p = list(map(int, input().split()))
ans = 0

for x in range(2 ** N + 1):
#     print("===========", x, ans)
    for m in range(M):
        c = 0
        for k in range(1, ks_list[m][0]+1):
            ks_mk = -ks_list[m][k]
            if int(format(x,'b').zfill(10)[ks_mk]) == 1:
                c += 1
#             print(ks_list, ks_list[m][k], ks_mk, format(x,'b').zfill(10), format(x,'b').zfill(10)[ks_mk])
#         print(c, p[m])
        if c % 2 != p[m]:
#             print("break")
            break
        if m == M-1:
            ans += 1
#     print(ans, ks_list, c, p)

print(ans)

Fixed submission:
a_, p_ = input().split()
a = int(a_)
p = int(p_)

print( ((a * 3) + p) // 2)
Buggy python submission (verdict: Runtime Error):
for x in range(2 ** N + 1):
#     print("===========", x, ans)
    for m in range(M):
        c = 0
        for k in range(1, ks_list[m][0]+1):
            ks_mk = -ks_list[m][k]
            if int(format(x,'b').zfill(10)[ks_mk]) == 1:
                c += 1
#             print(ks_list, ks_list[m][k], ks_mk, format(x,'b').zfill(10), format(x,'b').zfill(10)[ks_mk])
#         print(c, p[m])
        if c % 2 != p[m]:
#             print("break")
            break
        if m == M-1:
            ans += 1
#     print(ans, ks_list, c, p)

print(ans)

Fixed submission:
N, M = map(int, input().split())
s = [list(map(lambda s: int(s) - 1, input().split()))[1:] for _ in range(M)]
p = list(map(int, input().split()))
# print(s)
# print(p)
ret = 0
for i in range(2 ** N):
    on = list(map(int, bin(i)[2:]))
#     print(on)
    on = ([0] * N + on)[-N:]
#     print(on)
    for si, pi in zip(s, p):
        if sum(on[sij] for sij in si) % 2 != pi:
            break
    else:
        ret += 1
print(ret)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
L_list = []
R_list = []

for i in range(M):
    l, r = map(int, input().split())
    L = max(L, l)
    R = min(R, r)

print(L - R + 1)

Fixed submission:
N, M = map(int, input().split())
L = 0
R = N
for i in range(M):
    l, r = map(int, input().split())
    L = max(L, l)
    R = min(R, r)

print(max(0, R - L + 1))
Buggy python submission (verdict: Runtime Error):
X = input()

X1 = 10*int(X[0]) + int(X[1])
X2 = 10*int(X[2]) + int(X[3])

if (1 <= X1 <= 12) and ((X2 > 12) or (X2 == 0)):
    print("MMYY")
elif ((X2 > 12) or (X2 == 0) and (1 <= X1 <= 12):
    print("YYMM")
elif (1 <= X1 <= 12) and (1 <= X2 <= 12):
    print("AMBIGUOUS")
else:
    print("NA")

Fixed submission:
X = input()

X1 = 10*int(X[0]) + int(X[1])
X2 = 10*int(X[2]) + int(X[3])
if (1 <= X1 <= 12) and ((X2 > 12) or (X2 == 0)):
    print("MMYY")
elif ((X1 > 12) or (X1 == 0)) and (1 <= X2 <= 12):
    print("YYMM")
elif (1 <= X1 <= 12) and (1 <= X2 <= 12):
    print("AMBIGUOUS")
else:
    print("NA")
Buggy python submission (verdict: Time Limit Exceeded):
import math
import decimal
decimal.getcontext().prec = 11

N, K = map(int, input().split())

ans = decimal.Decimal(0)

for i in range(1, N+1):
    ans += decimal.Decimal(1 / N * (1 / 2) ** (max(math.ceil(math.log(K / i, 2)), 0)))
print(ans)

Fixed submission:
import math

N, K = map(int, input().split())

P = 0
P_log2 = 1

for i in range(1, N+1):
    if i < K:
#         T = int(math.log2(K / i)) + 1
        T = math.ceil(math.log2(K / i))
        P += 1/ N * 1 / (2 ** T)
#         print(i, T)
    else:
        P += 1 / N
# P += 1/ N * 1 / (2 ** P_log2)
            
print(P)
Buggy python submission (verdict: Runtime Error):

import fractions
N = int(input())
A = list(map(int, input().split()))
L = [0]
R = [0]
for i in range(N-1):
    L.append(gcd(L[i], A[i]))
    R.append(gcd(R[i], A[-i-1]))
MAX = 0
for i in range(N):
    MAX = max(MAX, gcd(L[i], R[-i-1]))
print(MAX)



Fixed submission:
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
L = [0]
R = [0]
for i in range(N-1):
    L.append(gcd(L[i], A[i]))
    R.append(gcd(R[i], A[-i-1]))
MAX = 0
for i in range(N):
    MAX = max(MAX, gcd(L[i], R[-i-1]))
print(MAX)

Buggy python submission (verdict: Runtime Error):

import fractions
L = [0]
R = [0]
for i in range(N-1):
    L.append(gcd(L[i], A[i]))
    R.append(gcd(R[i], A[-i-1]))
MAX = 0
for i in range(N):
    MAX = max(MAX, gcd(L[i], R[-i-1]))
print(MAX)



Fixed submission:
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
L = [0]
R = [0]
for i in range(N-1):
    L.append(gcd(L[i], A[i]))
    R.append(gcd(R[i], A[-i-1]))
MAX = 0
for i in range(N):
    MAX = max(MAX, gcd(L[i], R[-i-1]))
print(MAX)

Buggy python submission (verdict: Time Limit Exceeded):
import functools
import math
import fractions
N = int(input())
A = list(map(int, input().split()))
gcd_max = 1
for i in range(N):
    gcd = functools.reduce(fractions.gcd, A[i+1:] + A[:i])
    if gcd > gcd_max:
        gcd_max = gcd

print(gcd_max)



Fixed submission:
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
L = [0]
R = [0]
for i in range(N-1):
    L.append(gcd(L[i], A[i]))
    R.append(gcd(R[i], A[-i-1]))
MAX = 0
for i in range(N):
    MAX = max(MAX, gcd(L[i], R[-i-1]))
print(MAX)

Buggy python submission (verdict: Runtime Error):
import functools
import math
N = int(input())
A = list(map(int, input().split()))
gcd_max = 1
for i in range(N):
    gcd = functools.reduce(math.gcd, A[i+1:] + A[:i])
    if gcd > gcd_max:
        gcd_max = gcd

print(gcd_max)



Fixed submission:
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
L = [0]
R = [0]
for i in range(N-1):
    L.append(gcd(L[i], A[i]))
    R.append(gcd(R[i], A[-i-1]))
MAX = 0
for i in range(N):
    MAX = max(MAX, gcd(L[i], R[-i-1]))
print(MAX)

Buggy python submission (verdict: Runtime Error):
import functools
import math
N = int(input())
A = list(map(int, input().split()))
gcd_max = 1
for i in range(N):
    gcd = functools.reduce(math.gcd, A[i+1:] + A[:i])
    if gcd > gcd_max:
        gcd_max = gcd
        i_max = i

print(gcd_max)



Fixed submission:
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
L = [0]
R = [0]
for i in range(N-1):
    L.append(gcd(L[i], A[i]))
    R.append(gcd(R[i], A[-i-1]))
MAX = 0
for i in range(N):
    MAX = max(MAX, gcd(L[i], R[-i-1]))
print(MAX)