Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02722 (python)

Fixed submission:
N=int(input())
if N==2:
  print(1)
  exit()
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n//i)

    # divisors.sort()
  return divisors
#N-1の約数(1は除く)　Nそのもの
#2
d=make_divisors(N-1)
if not 2 in d:
  d.append(2)
#print(d)
d2=make_divisors(N)
#print(len(d))
for i in d2:
  if i!=N and i!=1 and i not in d:
    now=N
    while now%i==0:
      now/=i
    if now%i==1:
      d.append(i)
print(len(d))

Buggy submission (verdict: Runtime Error):
N=int(input())
if N%2==1:
  a=b
import numpy as np
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0:
        cnt+=1
        temp //= i
      arr.append([i, cnt])

  if temp!=1:
    arr.append([temp, 1])

  if arr==[]:
    arr.append([n, 1])

  return arr

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
d=np.array(make_divisors(N))
soin=factorization(N)
#print(d)
#(K: 314132908543,  )
#割り切れて１になる。。。。Nの一通り
#Kで割ってK+1になった 約数の差が１
# M*(x-K)=K+1
#(x-K)%K==1
#(x-K)/K=M:::1
#x-K=M*K+1
#N-1の約数
#２は必ず入る
#素因数分解して素数一つならそれも
count=0


#print(make_divisors(N-1))
S=make_divisors(N-1)
#print(soin)
#１除くN加える
ans=len(S)-1+1
if 2 not in S:
  ans+=1
if len(soin)==1 and soin[0][0]!=N:
  for i in range(1,soin[0][1]+1):
    if soin[0][1]%i==0 and (soin[0][0])**i not in S and (soin[0][0])**i not in [2,N]:
      ans+=1
      #print((soin[0][0])**i)
  
print(ans)
#print(S)
Problem p02744 (python)

Fixed submission:
N=int(input())
ABC=["a","b","c","d","e","f","g","h","i","j"]
def dfs(n,s):
  if len(s)==N:
    print(s)
    return
  
  for i in range(n+1):
    _s=s+ABC[i]
    dfs(max(n,i+1),_s)
    
dfs(0,"")

Buggy submission (verdict: Runtime Error):
N=int(input())
ABC=["A","B","C","D","E","F","G","H","I",,"J"]
def dfs(n,s):
  if len(s)==N:
    print(s)
    return
  
  for i in range(n+1):
    _s=s+ABC[i]
    dfs(max(n,i+1),_s)
    
dfs(0,"")
Problem p02761 (python)

Fixed submission:
N, M=map(int, input().split())

S=[list(map(int, input().split())) for i in range(M)]

num=["a"]*N
ans=True
for s in S:
  if (num[s[0]-1]!="a") and (num[s[0]-1]!=s[1]):
    ans=False
    break
  else:
    num[s[0]-1]=s[1]
    
if num[0]==0 and len(num)>1:
  ans=False
    
if ans:
  if len(num)==1:
    if num[0]=="a":
      print(0)
    else:
      print(num[0])
  else:
    for i in range(N):
      if num[i]=="a":
        if i==0:
          print(1, end="")
        else:
          print(0, end="")
      else:
        print(num[i], end="")
else:
  print(-1)

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

S=[list(map(int, input().split())) for i in range(M)]

num=["a"]*N
ans=True
for s in S:
  if (num[s[0]-1]!="a") and (num[s[0]-1]!=s[1]):
    ans=False
    break
  else:
    num[s[0]-1]=s[1]
    
if num[0]==0 and len(num)>1:
  ans=False
    
if ans:
  if len(num[0])==1:
    if num[0]=="a":
      print(0)
    else:
      print(num[0])
  else:
    for i in range(N):
      if num[i]=="a":
        if i==0:
          print(1, end="")
        else:
          print(0, end="")
      else:
        print(num[i], end="")
else:
  print(-1)
Problem p02778 (python)

Fixed submission:
S=input()
S=list(S)
for i in range(len(S)):
  print("x", end="")

Buggy submission (verdict: Runtime Error):
S=input()
S=list(S)
for i in len(S):
  print("x", end="")
Problem p02787 (python)

Fixed submission:
import numpy as np
H, N=map(int, input().split())
A=[]
B=[]
for i in range(N):
  a,b=map(int, input().split())
  A.append(a)
  B.append(b)
A=np.array(A)
B=np.array(B)
#n番目を1回は使う時の魔力最小値
dp=np.zeros((H+A.max()))
for i in range(1,H+1):
  dp[i]=(dp[i-A]+B).min()
  

      
      
print(int(dp[H]))

Buggy submission (verdict: Runtime Error):
import numpy as np
H, N=map(int, input().split())
A=[]
B=[]
for i in range(N):
  a,b=map(int, input().split())
  A.append(a)
  B.append(b)
A=np.array(A)
B=np.array(B)
#n番目を1回は使う時の魔力最小値
dp=np.zeros((H+1))
for i in range(1,H+1):
  dp[i]=(dp[i-A]+B).min()
  

      
      
print(int(dp[H]))
Problem p02791 (python)

Fixed submission:
n=int(input())
p=list(map(int, input().split()))
ans=1
l=[p[0]]
buf=p[0]
for i in range(1,n):
    l.append(p[i])
    if p[i]<=buf:
        ans+=1
        buf=p[i]
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N=int(input())
P=np.array(list(map(int, input().split())))



mini=1
count=1
index_min=P.argmin()
while P[0]>mini:
  if P==np.sort(a)[::-1]:
    count+=P.shape[0]
    break
  P=P[:index_min]
  mini=min(P)
  index_min=P.argmin()
  count+=1
"""
count=1
for i in range(1,N):
  if min(P[:i+1])==P[i]:
    count+=1
"""
print(count)

Buggy submission (verdict: Runtime Error):
import numpy as np
N=int(input())
P=np.array(list(map(int, input().split())))



mini=1
count=1
index_min=P.argmin()
while P[0]>mini:
  if P==P.sort()[::-1]:
    count+=P.shape[0]
    break
  P=P[:index_min]
  mini=min(P)
  index_min=P.argmin()
  count+=1
"""
count=1
for i in range(1,N):
  if min(P[:i+1])==P[i]:
    count+=1
"""
print(count)

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



mini=1
count=1
index_min=P.index(mini)
for i in range(N):
  P=P[:index_min]
  mini=min(P)
  index_min=P.index(mini)
  count+=1
  if mini==P[0]:
    break
  
"""
count=1
for i in range(1,N):
  if min(P[:i+1])==P[i]:
    count+=1
"""
print(count)

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



mini=1
count=1
index_min=P.index(mini)
for i in range(N):
  P=P[:index_min]
  mini=min(P)
  index_min=P.index(mini)
  count+=1
  if mini==P[0]:
    break
  
"""
count=1
for i in range(1,N):
  if min(P[:i+1])==P[i]:
    count+=1
"""
print(count)
Problem p02814 (python)

Fixed submission:
N,M=map(int, input().split())
from collections import defaultdict
A=list(map(int, input().split()))
B=[]
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
# a 偶数
twos=0
D=defaultdict(int)
for i in range(N):
    B.append(A[i]//2)
    a=A[i]
    now=0
    while a%2==0:
        a//=2
        now+=1
    D[now]+=1
    twos=max(twos, now)
if len(set(D.values()))!=1:
    print(0)
    exit()
now=1
for i in range(N):
    now=lcm(now, B[i])

# 1.5 * 3 2*5
from math import ceil
ans=M//(now*pow(2,twos))+1
#res=now+now%(2**twos)
ans=ceil(M//now/2)
#if M-res>0:
#    ans-=int((M-res)//now/(2**twos))

print(ans)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
N, M=map(int, input().split())
A=list(map(int, input().split()))
#最上公倍数
def lcm(x, y):
  return (x * y) //gcd(x, y)
#最小半公倍数
def half_lcm(a,b):
  X=lcm(a,b)//2
  return X

S=[0]*(N-1)
now=A[0]
for i in range(1,N):
  now=lcm(now, A[i])
  S[i-1]=now
  
kobai=S[-1]
hkobai=kobai//2
print(int(1+(M-hkobai)//kobai))




#6*(2.5,7.5,12.5,17.5
#10*(1.5,4.5,7.5,10.5)
#15,45,75,105
#4 (2.5,)
#10(1,)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
N, M=map(int, input().split())
A=list(map(int, input().split()))
#最上公倍数
def lcm(x, y):
  return (x * y) //gcd(x, y)
#最小半公倍数
def half_lcm(a,b):
  X=lcm(a,b)//2
  return X

S=[0]*(N-1)
now=A[0]
for i in range(1,N):
  now=lcm(now, A[i])
  S[i-1]=now
  
kobai=S[-1]
hkobai=kobai//2
print(1+(M-hkobai)//kobai)




#6*(2.5,7.5,12.5,17.5
#10*(1.5,4.5,7.5,10.5)
#15,45,75,105
#4 (2.5,)
#10(1,)
Problem p02837 (python)

Fixed submission:
n = int(input())

g = [[-1 for j in range(n)] for i in range(n)]

for i in range(n):
	a = int(input())
	for _ in range(a):
		x, y = map(int, input().split())
		g[i][x-1] = y

ans = 0
for s in range(2**n):
	ok = True
	for i in range(n):
		if (s>>i&1) == 1:
			for j in range(n):
				if g[i][j] != -1 and (s>>j&1) != g[i][j]:
					ok = False
	if ok:
		ans = max(ans, bin(s).count("1"))

print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())

S=[[-1]*N for _ in range(N)]
for _ in range(N):
  A=int(input())
  for i in range(A):
    x, y=map(int, input().split())
    
for s in range(2**N):
  ok=True
  for i in range(N):
    #正直者について見ていく
    if (s<<i&1)==1:
      for j in range(N):
        #それぞれ正直者の証言が矛盾ないか
        if g[i][j]!=-1 and (s>>j&1)!=g[i][j]:
          ok=False
  if ok:
    ans=max(ans, bin(s).count("1"))
    
print(ans)
Problem p02838 (python)

Fixed submission:
import numpy as np
N=int(input())
A=np.array(list(map(int, input().split())))


mod = 10**9+7
ans = 0
#bitの60桁を見ていく
#桁ごとに分割して足していく
for i in range(60):
  #i桁目が1である要素数　N-b1はi桁目が0である要素数
  b1 = np.count_nonzero(A>>i&1)
  #bi * (N-b1) がxorを意味している
  ans += 2**i*b1*(N-b1)
  ans %= mod
print (ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
mod=10**9+7
N=int(input())
A=np.array(list(map(int, input().split())))
ans=0
for　i in range(60):
  b=np.count_nonzero(A>>i&1)
  ans+=(2**i)*b*(N-b)
  ans%=mod
  
print(ans)
Problem p02844 (python)

Fixed submission:
N=int(input())
S=input()
#初めて出てきたときのインデックスをめも
lmemo=[-1]*10
rmemo=[-1]*10
for i in range(N-2):
    ls=int(S[i])
    rs=int(S[-(i+1)])
    if lmemo[ls]==-1:
        lmemo[ls]=i
    if rmemo[rs]==-1:
        rmemo[rs]=N-(i+1)
ans=0
#print(lmemo,rmemo)
for l in lmemo:
    for r in rmemo:
        if l+1<r and l>=0 and r>=0:
            ans+=len(set(S[l+1:r]))


print(ans)

Buggy submission (verdict: Runtime Error):
S=input()
#初めて出てきたときのインデックスをめも
memo=[[-1]*10 for _ in range(10)]
ans=0
for i in range(N-2):
    for j in range(i+1,N-1):
        si=int(S[i])
        sj=int(S[j])
        if memo[si][sj]==-1:
            memo[si][sj]=0
            ans+=len(set(S[j+1:]))
print(ans)
Problem p02845 (python)

Fixed submission:
N=int(input())
A=list(map(int, input().split()))
mod=10**9+7
if A[0]!=0:
    print(0)
    exit()
L=[1,0,0]
ans=3
for i in range(1,N):
    a=A[i]
    count=0
    add=True
    for j,l in enumerate(L):
        if a==l:
            count+=1
            if add:
                L[j]+=1
                add=False

    ans*=count
    ans%=mod
print(ans)
#print(L)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int, input().split()))
mod=10**9+7
if A[0]!=0:
    print(0)
    break
L=[1,0,0]
ans=3
for i in range(1,N):
    a=A[i]
    count=0
    add=True
    for j,l in enumerate(L):
        if a==l:
            count+=1
            if add:
                L[j]+=1
                add=False

    ans*=count
    ans%=mod
print(ans)
#print(L)
Problem p02850 (python)

Fixed submission:
N=int(input())
#再起のlimitを上げる
import sys
sys.setrecursionlimit(4100000)
S=[[] for _ in range(N)]
for i in range(N-1):
  a,b=map(int, input().split())
  S[a-1].append((b-1, i))
  S[b-1].append((a-1, i))

L=[0]*(N-1)


def dfs(node, pre_col,pre_node):
  col=1
  for next_node, i in S[node]:
    if next_node==pre_node:
      continue
    if col==pre_col:
      col+=1
    L[i]=col
    dfs(next_node, col, node)
    col+=1

dfs(0,-1,-1)

print(max(L))
for l in L:
  print(l)

Buggy submission (verdict: Runtime Error):
N=int(input())

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

L=[0]*(N-1)


def dfs(node, pre_col,pre_node):
  col=1
  for next_node, i in S[node]:
    if next_node==pre_node:
      continue
    if col==pre_col:
      col+=1
    L[i]=col
    dfs(next_node, col, node)
    col+=1

dfs(0,-1,-1)

print(max(L))
for l in L:
  print(l)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=[[] for _ in range(N)]
for i in range(N-1):
  a,b=map(int, input().split())
  S[a-1].append((b-1, i))
  S[b-1].append((a-1, i))

L=[0]*(N-1)


def dfs(node, pre_col,pre_node):
  col=1
  for next_node, i in S[node]:
    if next_node==pre_node:
      continue
    if col==pre_col:
      col+=1
    L[i]=col
    dfs(next_node, col, node)
    col+=1

dfs(0,-1,-1)
"""
print(max(L))
for l in L:
  print(l)
"""

Buggy submission (verdict: Runtime Error):
N=int(input())
S=[[] for _ in range(N)]
for i in range(N-1):
  a,b=map(int, input().split())
  S[a-1].append((b-1, i))
  S[b-1].append((a-1, i))

L=[0]*(N-1)


def dfs(node, pre_col,pre_node):
  col=1
  for next_node, i in S[node]:
    if next_node==pre_node:
      continue
    if col==pre_col:
      col+=1
    L[i]=col
    dfs(next_node, col, node)
    col+=1

dfs(0,-1,-1)
print(max(L))
for l in L:
  print(l)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=[[] for _ in range(N)]
for i in range(N-1):
  a,b=map(int, input().split())
  S[a-1].append((b-1, i))
  S[b-1].append((a-1, i))

L=[0]*(N-1)


def dfs(node, pre_col,pre_node, L):
  col=1
  for next_node, i in S[node]:
    if next_node==pre_node:
      continue
    if col==pre_col:
      col+=1
    L[i]=col
    dfs(next_node, col, node, L)
    col+=1
  return

dfs(0,-1,-1,L)
print(max(L))
for l in L:
  print(l)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=[[] for _ in range(N-1)]

for i in range(N-1):
  a, b=map(int, input().split())
  S[a-1].append(b-1)
  S[b-1].append(a-1)
  
def dfs(start, pre, pre_col, S, ans):
  col=1
  for i, nex in enumerate(S[start-1]):
    if nex==pre:
      continue
    if col=pre_col:
      col+=1
    ans[nex]=col
    dfs(nex, start, col, S, ans)
    col+=1
    
ans=[0]*(N-1)
dfs(1, -1,-1,S, ans)
print(max(ans))
for a in ans:
  print(a)
Problem p02882 (python)

Fixed submission:
from math import atan,degrees
a,b,x=map(int, input().split())
ans=None
V=(a**2)*b
if x>=V/2:
  #S=(x/a**2*b)*a*b
  #S=0.5*a*y
  #y=2S/a
  #tan(ans)=y/a
  #atan(y/a)=ans
  S=((V-x)/V)*a*b
  y=2*S/a
  ans=degrees(atan(y/a))
  #print(S, y, ans)
else:
  #S=(x/a**2*b)*a*b
  #S=0.5*b*y
  #y=2S/b
  #ans=90-atan(y/b)
  S=(x/V)*a*b
  y=2*S/b
  ans=90-degrees(atan(y/b))
  
print(ans)

Buggy submission (verdict: Runtime Error):
from math import atan
a,b,x=map(int, input().split())
ans=None
V=(a**2)*b
if x>=V/2:
  #S=(x/a**2*b)*a*b
  #S=0.5*a*y
  #y=2S/a
  #tan(ans)=y/a
  #atan(y/a)=ans
  S=(x/a**2*b)*a*b
  y=2S/a
  ans=atan(y/a)
else:
  #S=(x/a**2*b)*a*b
  #S=0.5*b*y
  #y=2S/b
  #ans=90-atan(y/b)
  S=(x/a**2*b)*a*b
  y=2S/b
  ans=90-atan(y/b)
  
print(ans)
Problem p02898 (python)

Fixed submission:
N, K=map(int, input().split())
H=list(map(int, input().split()))

count=0
for i in H:
  if i>=K:
    count+=1
print(count)

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

count=0
for i in H:
  if H>=K:
    count+=1
print(count)
Problem p02900 (python)

Fixed submission:
from fractions import gcd
A, B=map(int, input().split())
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n//i)

  # divisors.sort()
  return divisors

import math

def is_prime(n):
  if n == 1: return False

  for k in range(2, int(math.sqrt(n)) + 1):
    if n % k == 0:
      return False

  return True
ans=0
for x in set(make_divisors(A))&set(make_divisors(B)):
  if is_prime(x):
    ans+=1

#print(set(make_divisors(A))&set(make_divisors(B)))
print(ans+1)

Buggy submission (verdict: Runtime Error):
from math import factorial
#a = factorial(n) / factorial(r) / factorial(n - r)

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

def cf(x1,x2):
    cf=[]
    cf.append(1)
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf
  
  
C=cf(A, B)
for i in range(len(C)-1):
  for j in range(i+1, len(C)):
    if len(cf(C[i], C[j]))!=1:
      C.remove(C[j])
n=len(C)
if n==1:
  print(1)
else:
  
  print(int(factorial(n) / factorial(2) / factorial(n - 2)))

Buggy submission (verdict: Runtime Error):
from math import factorial
#a = factorial(n) / factorial(r) / factorial(n - r)

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

def cf(x1,x2):
    cf=[]
    cf.append(1)
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf
  
  
C=cf(A, B)
for i in range(len(C)-1):
  for j in range(i+1, len(C)):
    if len(cf(C[i], C[j]))!=1:
      C.remove(C[j])
n=len(C)
print(int(factorial(n) / factorial(2) / factorial(n - 2)))
Problem p02901 (python)

Fixed submission:
n,m = map(int,input().split())
dp = [0]+[10**8+10]*(2**n-1)
for i in range(m):
  a,b = map(int,input().split())
  s = sum([2**(x-1) for x in list(map(int,input().split()))])
  for j in range(2**n):
    dp[j|s] = min(dp[j|s],dp[j]+a)
if dp[-1] <= 10**8:
  print(dp[-1])
else:
  print(-1)

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

A=[]
B=[]
C=[]
for i in range(N):
  a, b=map(int, input().split())
  c=list(map(int, input().split()))
  A.append(a)
  B.append(b)
  C.append(c)
  
print(A, B, C)
Problem p02923 (python)

Fixed submission:
N=int(input())

H=list(map(int,input().split()))
A=[0 for i in range(N)]
if N==1:
  print(0)
else:
  if H[0]>=H[1]:
  	A[0]+=1
  if N>=3:
    for i in range(1,N-1):
      if H[i]>=H[i+1]:
        A[i]+=A[i-1]+1
  print(max(A))

Buggy submission (verdict: Runtime Error):
N=int(input())

H=list(map(int,input().split()))
A=[0 for i in range(N)]
if H[0]>=H[1]:
  A[0]+=1
for i in range(1,N-1):
  if H[i]>=H[i+1]:
    A[i]+=A[i-1]+1
print(max(A))

Buggy submission (verdict: Runtime Error):
N=int(input())

H=list(input().split())
A=[0 for i in range(N)]
if H[0]>=H[1]:
  A[0]+=1
for i in range(1,N-1):
  if H[i]>=H[i+1]:
    A[i]+=A[i-1]+1
print(max(A))

Buggy submission (verdict: Runtime Error):
N=int(input())

H=list(input().split())

count_list=[]
for i in range(N-1):
  count=0
  a=i
  while H[a]>=H[a+1]:
    count+=1
    a+=1
    if a==N-1:
      break
  count_list.append(count)
print(max(count_list))
Problem p02928 (python)

Fixed submission:
N, K =map(int, input().split())

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

mod=10**9 +7
count=0
for i in range(N):
  for j in range(i+1, N):
    if A[i]>A[j]:
      count+=K
  for k in range(N):
    if A[i]>A[k]:
      count+=(K-1)*K//2
  

print(int(count%mod))

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

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

count=0
for i in range(N*K):
  for j in range(i, N*K):
    if B[i]>B[j]:
      count+=1

print(count)
Problem p02937 (python)

Fixed submission:
import bisect
from collections import Counter
from collections import defaultdict
s=input()
t=input()
#s="contest"
#t="antakuso"
sd=Counter(s)
td=Counter(t)
N=len(t)
Ns=len(s)
for ts in td:
    if ts not in sd:
        print(-1)
        exit()
D=defaultdict(list)
for i in range(Ns):
    D[s[i]].append(i)
ans=0
for i in range(N):
    if i==0:
        pre=min(D[t[i]])
    else:
        L=D[t[i]]
        idx=bisect.bisect(L,pre)
        if idx==len(L):
            ans+=Ns
            pre=min(L)
        else:
            pre=L[idx]
    if i==N-1:
        ans+=pre+1
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
t = input()

for i in list(t):
  if not i in list(s):
    print(-1)
    break
    
T = list(t)
count=0
while len(T)>0:
  for i,n in enumerate(list(s*len(T))):
    if T[0]==n:
      del T[0]
    if len(T)==0:
      print(i+1)
      break
Problem p02983 (python)

Fixed submission:
L,R=map(int, input().split())
#2019の倍数が入っていれば０→R-Lが２０１９以上
if R-L>=2019:
    print(0)
    exit()

ans=2019
for i in range(L,R):
    for j in range(i+1,R+1):
        ans=min(ans, (i*j)%2019)
print(ans)

Buggy submission (verdict: Runtime Error):
L, R=map(int, input().split())
mod=2019
A=[0]*(R-L+1)
for i in range(L, R+1):
  A[i-L]=i%mod
  
A=sorted(A)
print((A[0]*A[1])%mod)

Buggy submission (verdict: Runtime Error):
L, R=map(int, input().split())
mod=2019
A=[0]*(R-L+1)
for i in range(L, R+1):
  A[i]=i%mod
  
A=sorted(A)
print((A[0]*A[1])%mod)

Buggy submission (verdict: Runtime Error):
L, R=map(int, input().split())
mod=2019
A=[0]*(R-L+1)
for i in range(L. R+1):
  A[i]=i%mod
  
A=sorted(A)
print((A[0]*A[1])%mod)
Problem p03006 (python)

Fixed submission:
N=int(input())
L=[]
if N==1:
    print(1)
    exit()
for i in range(N):
    x,y=map(int, input().split())
    L.append((x,y))

D={}
for i in range(N-1):
    t1=L[i]
    L2=L[i+1:]
    for t2 in L2:
        x1,y1=t1
        x2,y2=t2
        d1=(x2-x1,y2-y1)
        d2=(x1-x2,y1-y2)
        if d1 in D:
            D[(x2-x1,y2-y1)]+=1
        else:
            D[(x2-x1,y2-y1)]=1
        if d2 in D:
            D[(x1-x2,y1-y2)]+=1
        else:
            D[(x1-x2,y1-y2)]=1

print(max(N-max(D.values()),0))

Buggy submission (verdict: Runtime Error):
N=int(input())
L=[]
for i in range(N):
    x,y=map(int, input().split())
    L.append((x,y))

D={}
for i in range(N-1):
    t1=L[i]
    L2=L[i+1:]
    for t2 in L2:
        x1,y1=t1
        x2,y2=t2
        d1=(x2-x1,y2-y1)
        d2=(x1-x2,y1-y2)
        if d1 in D:
            D[(x2-x1,y2-y1)]+=1
        else:
            D[(x2-x1,y2-y1)]=1
        if d2 in D:
            D[(x1-x2,y1-y2)]+=1
        else:
            D[(x1-x2,y1-y2)]=1

print(max(N-max(D.values()),0))
Problem p03014 (python)

Fixed submission:
import numpy as np
H, W=map(int, input().split())
S=np.array([list(input()) for _ in range(H)])
S=np.where(S==".",1,0 )

left=np.zeros((H, W))
right=np.zeros((H, W))
top=np.zeros((H, W))
bottom=np.zeros((H, W))

for i in range(W):
  if i==0:
    left[:,i]=S[:,i]
    right[:,-i-1]=S[:,-i-1]
  else:
    left[:,i]=(left[:,i-1]+1)*S[:,i]
    right[:,-i-1]=(right[:,-i]+1)*S[:,-i-1]
    
for i in range(H):
  if i==0:
    top[i,:]=S[i,:]
    bottom[-1-i,:]=S[-i-1,:]
  else:
    top[i,:]=(top[i-1,:]+1)*S[i,:]
    bottom[-1-i,:]=(bottom[-i,:]+1)*S[-i-1,:]
    
ans=left+top+right+bottom-3
    

print(int(ans.max()))

Buggy submission (verdict: Runtime Error):
import numpy as np
H, W=map(int, input().split())
S=np.array([list(input()) for _ in range(H)])
S=np.where(S==".",1,0 )

left=np.zeros((H, W))
right=np.zeros((H, W))
top=np.zeros((H, W))
bottom=np.zeros((H, W))

for i in range(W):
  if i==0:
    left[:,i]=S[:,i]
    right[:,-i-1]=S[:,-i-1]
  else:
    left[:,i]=(left[:,i-1]+1)*S[:,i]
    right[:,-i-1]=(right[-i]+1)*S[:,-i-1]
    
for i in range(H):
  if i==0:
    top[i,:]=S[i,:]
    bottom[-1-i,:]=S[-i-1,:]
  else:
    top[i,:]=(top[i-1,:]-S[i,:])
    bottom[-1-i,:]=(bottom[-i]+1)*S[-i-1,:]
    
ans=left+top+right+bottom-3
    
    
print(ans.max())
Problem p03043 (python)

Fixed submission:
from math import ceil
import numpy as np
N,K=map(int, input().split())
#サイコロを振る　１以上K未満→コイン　K以上ゲーム終了、す抜けのかち
#コイン　表なら２倍　裏なら０　０なったら負け
ans=max( (N-K+1),0) /N

#(K-1)/N
# M*(2**x)>=K M:サイコロの目
# x*log(2)>=log(K/M)
lim=min(K-1,N)
for i in range(1,lim+1):
    x=ceil(np.log(K/i)/np.log(2))
    ans+=(1/N)*((0.5)**x)
print(ans)

Buggy submission (verdict: Runtime Error):
from math import ceil
import numpy as np
N,K=map(int, input().split())
#サイコロを振る　１以上K未満→コイン　K以上ゲーム終了、す抜けのかち
#コイン　表なら２倍　裏なら０　０なったら負け
ans=max( (N-K+1),0) /N

#(K-1)/N
# M*(2**x)>=K M:サイコロの目
# x*log(2)>=log(K/M)
lim=min(K-1,N)
for i in range(1,lim+1):
    x=ceil(np.log(K/i)/np.log(2))
    ans+=(1/N)*((0.5)**x)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
import numpy as np
N, K=map(int, input().split())

p1=(N-K)/N
klist=list(range(1,K+1))

def calc(x, K):
  y=math.ceil((np.log(K)-np.log(x))/np.log(2))
  p=x*(0.5)**y
  
  return p

plist=map(calc, klist)
p2=sum(plist)
print(p1+p2)

Buggy submission (verdict: Runtime Error):
import math
import numpy as np
N, K=map(int, input().split())

p1=(N-K)/N
klist=list(range(1,K+1))

def calc(x, K):
  y=math.floor((np.log(K)-np.log(x))/np.log(2))
  p=x*(0.5)**y
  
  return p

plist=map(calc, klist)
p2=sum(plist)
print(p1+p2)