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

Fixed submission:
import sys,math
n=int(input())
a=list(map(int,input().split()))
sieve=[0]*(10**6+1)
numbers={}
flag=0
for i in range(n):
  if a[i] in numbers:
    numbers[a[i]]+=1
  else:
    numbers[a[i]]=1
pointer=2
while pointer<10**6+1:
  if sieve[pointer]==1:
    pointer+=1
    continue
  count=0
  pointer2=pointer
  while pointer2<10**6+1:
    if pointer2 in numbers:
      count+=numbers[pointer2]
    sieve[pointer2]=1
    pointer2+=pointer
  if count>=2:
    flag=1
    break
if flag==0:
  print('pairwise coprime')
  sys.exit()
ans=a[0]
for i in range(1,n):
  ans=math.gcd(a[i],ans)
if ans==1:
  print('setwise coprime')
else:
  print('not coprime')

Buggy submission (verdict: Runtime Error):
import sys,math
n=int(input())
a=list(map(int,input().split()))
numbers={}
flag=0
for i in range(n):
  if a[i] in numbers:
    numbers[a[i]]+=1
  else:
    numbers[a[i]]=1
while pointer in range(2,10**6+1):
  count=0
  pointer2=pointer
  while pointer2<10**6+1:
    if pointer2 in numbers:
      count+=numbers[pointer2]
    pointer2+=pointer
  if count>=2:
    flag=1
    break
if flag==0:
  print('pairwise coprime')
  sys.exit()
ans=a[0]
for i in range(1,n):
  ans=math.gcd(a[i],ans)
if ans==1:
  print('setwise coprime')
else:
  print('not coprime')
Problem p02657 (python)

Fixed submission:
a,b=map(int,input().split())
print(a*b)

Buggy submission (verdict: Runtime Error):
def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            a=n//i 
            if (a+1)*i<=n:
              a+=1
            n=a
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors
N=int(input())
a=prime_factors(N)
current=0
index=0
anslist=[]
for i in a:
  if i!=current:
    current=i
    anslist.append(1)
  else:
    anslist[-1]+=1
ans=0
for i in anslist:
  k=1
  while (k*(k+1))<=2*i:
    k+=1
  k-=1
  ans+=k
print(ans)
Problem p02686 (python)

Fixed submission:
import sys
n=int(input())
a=[]
b=[]
for i in range(n):
  s=input()
  overall=0
  minimum=0
  current=0
  for j in range(len(s)):
    if s[j]=='(':
      current+=1
    else:
      current-=1
    minimum=min(current,minimum)
  overall=current
  if overall>=0:
    a.append([overall,minimum])
  else:
    b.append([overall,minimum])
finalsum=0
a=sorted(a, key=lambda t:t[1])
a.reverse()
b=sorted(b, key=lambda t:t[0]-t[1])
b.reverse()
for i in a:
  if finalsum+i[1]<0:
    print('No')
    sys.exit()
  finalsum+=i[0]
for i in b:
  if finalsum+i[1]<0:
    print('No')
    sys.exit()
  finalsum+=i[0]
if finalsum==0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[]
b=[]
for i in range(n):
  s=input()
  overall=0
  minimum=0
  current=0
  for j in range(len(s)):
    if s[j]=='(':
      current+=1
    else:
      current-=1
    minimum=min(current,minimum)
  overall=current
  if overall>=0:
    a.append([overall,minimum])
  else:
    b.append([overall,minimum])
finalsum=0
a=sorted(a, key=lambda t:t[1])
a.reverse()
b=sorted(b, key=lambda t:t[1])
for i in a:
  if finalsum+i[1]<0:
    print('No')
    sys.exit()
  finalsum+=i[0]
for i in b:
  if finalsum+i[1]<0:
    print('No')
    sys.exit()
  finalsum+=i[0]
if finalsum==0:
  print('Yes')
else:
  print('No')
Problem p02697 (python)

Fixed submission:
n,m=map(int,input().split())
if n%2==0:
  counter=0
  for i in range(min(m,n//4)):
    print(i+1)
    print(n-i)
    counter+=1
  if counter<m:
    for i in range(n//4,m):
      print(i+1)
      print(n-i-1)
else:
  for i in range(m):
    print(i+1)
    print(n-i)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input.split())
if n%2==0:
  counter=0
  for i in range(min(m,n//4)):
    print(i+1)
    print(n-i)
    counter+=1
  if counter<m:
    for i in range(n//4,m):
      print(i+1)
      print(n-i-1)
  else:
    for i in range(m):
      print(i+1)
      print(n-i)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input.split())
for i in range(m):
  print(m+1)
  print(n-m-1)
Problem p02718 (python)

Fixed submission:
N,M=map(int, input().split())
A=list(map(int, input().split()))
A.sort()
A.reverse()
K=sum(A)
answer=0
breakflag=0
for i in range(0,N):
  if  A[i]*M*4>=K:
    if i==N-1:
      breakflag=1
    continue
  else:
    answer=i
    break
if breakflag==1:
  answer=N
if answer>=M:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
A=list(map(int, input().split()))
A.sort()
A.reverse()
K=sum(A)
answer=0
breakflag=0
for i in range(0,N):
  if  A[i]*M*4>=K:
    if i==N-1:
      breakflag=1
    continue
  else:
    answer=i
    break
if breakflag==1:
  answer=N
if answer>=M:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N,M= map(int, input().split())
A=list(map(int, input().split()))
A.sort()
A.reverse()
K=sum(A)
answer=0
breakflag=0
for i in range(0,N):
    if  A[i]*M*4>=K:
    	if i==N-1:
        	breakflag=1
      	continue
    else:
      	answer=i
      	break
if breakflag==1:
  answer=N
if answer>=M:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N,M= map(int, input().split())
A=list(map(int, input().split()))
A.sort()
A.reverse()
K=sum(A)
for i in range(0,N):
    if  A[i]*M*4>=K:
        continue
    else:
        answer=i
        break
if answer>=M:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N,M= map(int, input().split())
A=list(map(int, input().split()))
A.sort()
A.reverse()
K=sum(A)
for i in range(0,N):
    if  A[i]>=K/(4*M):
        continue
    else:
        answer=i+1
        break
if answer>=M:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N,M= map(int, input().split())
A=list(map(int, input().split()))
A.sort()
A.reverse()
K=sum(A)
for i in range(0,N):
    if  A[i]>K/(4*M):
        continue
    else:
        answer=i+1
        break
if answer>=M:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N,M= map(int, raw_input().split())
A=list(map(int, raw_input().split()))
A.sort()
A.reverse()
K=sum(A)
for i in range(0,N):
    if  A[i]>K/(4*M):
        continue
    else:
        answer=i+1
        break
if answer>=M:
    print("Yes")
else:
    print("No")
Problem p02732 (python)

Fixed submission:
N=int(input())
m=list(map(int,input().split()))
t=[]
for i in range(N):
  t.append(0)
for i in range(N):
  t[m[i]-1]+=1
total=0
for i in range(N):
  total+=(t[i]*(t[i]-1))//2
for i in range(N):
  if t[m[i]-1]<2:
    print(total)
  else:
    print(total-(t[m[i]-1]-1))

Buggy submission (verdict: Runtime Error):
N=int(input())
m=list(map(ine,input().split()))
t=[]
for i in range(N):
  t.append(0)
for i in range(N):
  t[m[i]-1]+=1
total=0
for i in range(N):
  total+=(t[i]*(t[i]-1))//2
for i in range(N):
  if t[m[i]-1]<2:
    print(total)
  else:
    print(total-(t[m[i]-1]-1))
Problem p02885 (python)

Fixed submission:
N,M=map(int, input().split())
print(max(0,N-2*M))

Buggy submission (verdict: Runtime Error):
N,M=map(int,input90.split())
print(max(0,N-2*M))
Problem p02903 (python)

Fixed submission:
def convert(s): 
  
    # initialization of string to "" 
    new = "" 
  
    # traverse in the string  
    for x in s: 
        new += x  
  
    # return string  
    return new 

h,w,a,b=map(int,input().split())
k=[]
for i in range(a):
  k.append('0')
for i in range(w-a):
  k.append('1')
k=convert(k)
t=[]
for i in range(a):
  t.append('1')
for i in range(w-a):
  t.append('0')
t=convert(t)
for i in range(b):
  print(k)
for i in range(h-b):
  print(t)

Buggy submission (verdict: Runtime Error):
def convert(s): 
  
    # initialization of string to "" 
    new = "" 
  
    # traverse in the string  
    for x in s: 
        new += x  
  
    # return string  
    return new 
      
h,w,a,b=map(int,input().split())
k=[]
for i in range(a):
  k.append('0')
for i in range(w-a):
  k.append('1')
k=convert(k)
t=[]
for i in range(a):
  t.append('1')
for i in range(w-a):
  k.append('0')
t=convert(t)
for i in range(b):
  print(k)
for i in range(h-b):
  print(t)
Problem p02923 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=0
counter=0
for i in range(1,n):
  if a[i]>a[i-1]:
    counter=0
  else:
    counter+=1
    ans=max(ans,counter)
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
ans=0
counter=0
for i in range(1,n):
  if a[i]>a[i-1]:
    counter=0
  else:
    counter+=1
    ans=max(ans,counter)
print(ans)
Problem p02960 (python)

Fixed submission:
S=input()
n=len(S)
t=[]
for i in range(13):
  t.append(0)
t[0]=1
jkmap=[]
for j in range(10):
  jkmap.append([])
  for k in range(13):
    jkmap[j].append((10*k+j)%13)
for i in range(n):
  if S[i]=='?':
    tcopy=[0]*13
    for j in range(10):
      for k in range(13):
        tcopy[jkmap[j][k]]=(tcopy[jkmap[j][k]]+t[k])%(10**9+7)
    for j in range(13):
      t[j]=tcopy[j]
  else:
    j=int(S[i])
    tcopy=[0]*13
    for k in range(13):
      tcopy[jkmap[j][k]]=(tcopy[jkmap[j][k]]+t[k])%(10**9+7)
    for j in range(13):
      t[j]=tcopy[j]
print(t[5])

Buggy submission (verdict: Runtime Error):
S=input()
n=len(S)
t=[]
for i in range(13):
  t.append(0)
s=t.copy()

t[0]=1
jkmap=[]
for j in range(10):
  jkmap.append([])
  for k in range(13):
    jkmap[j].append((10*k+j)%13)
for i in range(n):
  if S[i]=='?':
    if i%2==0:
      for j in range(10):
        for k in range(13):
          s[jkmap[j][k]]=(t[jkmap[j][k]]+t[k])%(10**9+7)
    
  else:
    j=int(S[i])
    for k in range(13):
      t[jkmap[j][k]]=(s[jkmap[j][k]]+t[k])%(10**9+7)
print(t[5])

Buggy submission (verdict: Runtime Error):
S=input()
n=len(S)
t=[]
for i in range(13):
  t.append(0)
s=t.copy()
t[0]=1
jkmap=[]
for j in range(10):
  jkmap.append([])
  for k in range(13):
    jkmap[j].append((10*k+j)%13)
for i in range(n):
  if S[i]=='?':
    tcopy=s.copy()
    for j in range(10):
      for k in range(13):
        tcopy[jkmap[j][k]]=(tcopy[jkmap[j][k]]+t[k])%(10**9+7)
    t=tcopy.copy()
  else:
    j=int(S[i])
    tcopy=s.copy()
    for k in range(13):
      tcopy[jkmap[j][k]]=(tcopy[jkmap[j][k]]+t[k])%(10**9+7)
    t=tcopy.copy()
print(t[5])
Problem p03244 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[0]*100009
c=[0]*100009
for i in range(n//2):
  b[a[i*2]]+=1
  c[a[i*2+1]]+=1
t=max(b)
r=max(c)
s=b.index(t)
p=c.index(r)
if s==p:
  b[s]=0
  k=max(b)
  c[p]=0
  j=max(c)
  f=max(k+r,t+j)
else:
  f=t+r
print(n-f)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=[0]*10009
c=[0]*10009
for i in range(n//2):
  b[a[i*2]]+=1
  c[a[i*2+1]]+=1
t=max(b)
r=max(c)
s=b.index(t)
p=c.index(r)
if s==p:
  b[s]=0
  k=max(b)
  c[p]=0
  j=max(c)
  f=max(k+r,t+j)
else:
  f=t+r
print(n-f)
Problem p03485 (python)

Fixed submission:
a,b=map(int,input().split())
print((a+b+1)//2)

Buggy submission (verdict: Runtime Error):
s=input()
x,y=map(int,input().split())
xpossible=[0]
ypossible=[0]
j=0
while s[j]=='F':
  j+=1
  xpossible[0]+=1
  if j==len(s):
    break
counter=0
for i in range(j,len(s)):
  current=0
  while s[i]=='F':
    i+=1
    current+=1
    if i==len(s):
      break
  r=set()
  if counter==0:
    for j in xpossible:
      r.add(j+current)
      r.add(j-current)
    xpossible=[]
    for j in r:
      xpossible.append(j)
  else:
    for j in ypossible:
      r.add(j+current)
      r.add(j-current)
    ypossible=[]
    for j in r:
      ypossible.append(j)
  current=0
  while s[i]=='T':
    i+=1
    current+=1
    if i==len(s):
      break
  counter=(counter+current)%2
if x in xpossible and y in ypossible:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
s=input()
x,y=map(int,input().split())
xpossible=[0]
ypossible=[0]
j=0
while s[j]=='F':
  xpossible[0]+=1
  if j==len(s):
    break
counter=0
for i in range(j,len(s)):
  current=0
  while s[i]=='F':
    i+=1
    current+=1
    if i==len(s):
      break
  r=set()
  if counter==0:
    for j in xpossible:
      r.add(j+current)
      r.add(j-current)
    xpossible=[]
    for j in r:
      xpossible.append(j)
  else:
    for j in ypossible:
      r.add(j+current)
      r.add(j-current)
    ypossible=[]
    for j in r:
      ypossible.append(j)
  current=0
  while s[i]=='T':
    i+=1
    current+=1
    if i==len(s):
      break
  counter=(counter+current)%2
if x in xpossible and y in ypossible:
  print('Yes')
else:
  print('No')
Problem p03488 (python)

Fixed submission:
s=input()
x,y=map(int,input().split())
xpossible=[0]
ypossible=[0]
j=0
while s[j]=='F':
  j+=1
  xpossible[0]+=1
  if j==len(s):
    break
counter=0
i=j
while i<len(s):
  current=0
  while s[i]=='F':
    i+=1
    current+=1
    if i==len(s):
      break
  r=set()
  if counter==0:
    for j in xpossible:
      r.add(j+current)
      r.add(j-current)
    xpossible=[]
    for j in r:
      xpossible.append(j)
  else:
    for j in ypossible:
      r.add(j+current)
      r.add(j-current)
    ypossible=[]
    for j in r:
      ypossible.append(j)
  if i==len(s):
    break
  current=0
  while s[i]=='T':
    i+=1
    current+=1
    if i==len(s):
      break
  counter=(counter+current)%2
if x in xpossible and y in ypossible:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
s=input()
x,y=map(int,input().split())
xpossible=[0]
ypossible=[0]
j=0
while s[j]=='F':
  j+=1
  xpossible[0]+=1
  if j==len(s):
    break
counter=0
for i in range(j,len(s)):
  current=0
  while s[i]=='F':
    i+=1
    current+=1
    if i==len(s):
      break
  r=set()
  if counter==0:
    for j in xpossible:
      r.add(j+current)
      r.add(j-current)
    xpossible=[]
    for j in r:
      xpossible.append(j)
  else:
    for j in ypossible:
      r.add(j+current)
      r.add(j-current)
    ypossible=[]
    for j in r:
      ypossible.append(j)
  current=0
  while s[i]=='T':
    i+=1
    current+=1
    if i==len(s):
      break
  counter=(counter+current)%2
if x in xpossible and y in ypossible:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
s=input()
x,y=map(int,input().split())
xpossible=[0]
ypossible=[0]
j=0
while s[j]=='F':
  xpossible[0]+=1
  if j==len(s):
    break
counter=0
for i in range(j,len(s)):
  current=0
  while s[i]=='F':
    i+=1
    current+=1
    if i==len(s):
      break
  r=set()
  if counter==0:
    for j in xpossible:
      r.add(j+current)
      r.add(j-current)
    xpossible=[]
    for j in r:
      xpossible.append(j)
  else:
    for j in ypossible:
      r.add(j+current)
      r.add(j-current)
    ypossible=[]
    for j in r:
      ypossible.append(j)
  current=0
  while s[i]=='T':
    i+=1
    current+=1
    if i==len(s):
      break
  counter=(counter+current)%2
if x in xpossible and y in ypossible:
  print('Yes')
else:
  print('No')
Problem p03550 (python)

Fixed submission:
n,z,w=map(int,input().split())
a=list(map(int,input().split()))
ans=abs(a[-1]-w)
if n>1:
  ans=max(ans,abs(a[n-2]-a[n-1]))
print(ans)

Buggy submission (verdict: Runtime Error):
n,z,w=map(int,input().split())
a=list(map(int,input().split()))
print(max(abs(a[-1]-w),abs(a[-2]-a[-1])))
Problem p03730 (python)

Fixed submission:
def computeGCD(x, y): 
  
    if x > y: 
        small = y 
    else: 
        small = x 
    for i in range(1, small+1): 
        if((x % i == 0) and (y % i == 0)): 
            gcd = i 
              
    return gcd 
a,b,c=map(int,input().split())
r=computeGCD(a,b)
if c%r==0:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
import math
a,b,c=map(int,input().split())
if c%(math.gcd(a,b))==0:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
import math
a,b,c=map(int,input().split())
if math.gcd(a,b)%c==0:
  print('YES')
else:
  print('NO')
Problem p03944 (python)

Fixed submission:
w,h,n=map(int,input().split())
x1=0
x2=w
y1=0
y2=h
for i in range(n):
  x,y,a=map(int,input().split())
  if a==1:
    x1=max(x1,x)
  if a==2:
    x2=min(x2,x)
  if a==3:
    y1=max(y1,y)
  if a==4:
    y2=min(y2,y)
if x2<x1 or y2<y1:
  print(0)
else:
  print((x2-x1)*(y2-y1))

Buggy submission (verdict: Runtime Error):
w,h,n=map(int,input().split())
x1=0
x2=w
y1=0
y2=h
for i in range(n):
  x,y,a=map(int,input().split())
  if a==1:
    x1=max(x1,x)
  if a==2:
    x2=min(x2,x)
  if a==3:
    y1=max(y1,y)
  if a==4:
    y2=min(y2,y)
if x2<x1 or y2<y1
  print(0)
else:
  print((x2-x1)*(y2-y1))
Problem p03967 (python)

Fixed submission:
s=input()
counter=0
for i in range(len(s)):
  if s[i]=='p':
    counter+=1
print(len(s)//2-counter)

Buggy submission (verdict: Runtime Error):
s=input()
counter=0
for i in range(n):
  if s[i]=='p':
    counter+=1
print(len(s)//2-counter)
Problem p04012 (python)

Fixed submission:
s=input()
letters=[]
count=[]
for i in range(len(s)):
  if s[i] in letters:
    count[letters.index(s[i])]+=1
  else:
    count.append(1)
    letters.append(s[i])
failflag=0
for i in range(len(count)):
  if count[i]%2==1:
    failflag=1
if failflag==0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
s=input()
t=input()
letters=[]
count=[]
for i in range(len(s)):
  if s[i] in letters:
    count[letters.index(s[i])].append(i)
  else:
    count.append([i])
    letters.append(s[i])
failflag=0
for i in count:
  r=t[i[0]]
  for j in i:
    if t[j]!=r:
      failflag=1
letters=[]
count=[]
for i in range(len(s)):
  if t[i] in letters:
    count[letters.index(t[i])].append(i)
  else:
    count.append([i])
    letters.append(t[i])
for i in count:
  r=s[i[0]]
  for j in i:
    if s[j]!=r:
      failflag=1
if failflag==0:
  print('Yes')
else:
  print('No')
Problem p04015 (python)

Fixed submission:
n,a=map(int,input().split())
x=list(map(int,input().split()))
for i in range(n):
  x[i]-=a
dp=[]
for i in range(n+1):
  dp.append([])
  for i in range(6000):
    dp[-1].append(0)
dp[0][3000]=1
for i in range(n):
  for j in range(6000):
    if j+x[i]<6000 and j+x[i]>=0:
      dp[i+1][j+x[i]]+=dp[i][j]
      dp[i+1][j]+=dp[i][j]
print(dp[n][3000]-1)

Buggy submission (verdict: Runtime Error):
n,a=map(int,input().split())
x=list(map(int,input().split()))
dic={}
dic2=dic.copy()
for i in range(n):
  for j in dic:
    if j+x[i]-a in dic2:
      dic2[j+x[i]-a]+=dic[j]
    else:
      dic2[j+x[i]-a]=dic[j]
  if x[i]-a in dic:
    dic2[x[i]-a]+=1
  else:
    dic2[x[i]-a]=1
  dic=dic2.copy()
print(dic[0])
Problem p02658 (python)

Fixed submission:
def main():
    _ = input()
    lst = list(map(int, input().split()))
    ans = 1

    if 0 in lst:
        print(0)
        exit()
    for i in lst:
        ans *= i
        if ans > 10 ** 18:
            print(-1)
            exit()
    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    _ = input()
    lst = list(map(int, input().split()))
    ans = 1

    if 0 in lst:
        print(0)
        exit()
    for i in map(int, input().split()):
        ans *= i
        if ans > 10 ** 18:
            print(-1)
            exit()
    print(ans)


if __name__ == "__main__":
    main()
Problem p03000 (python)

Fixed submission:
def main():
    N, X = map(int, input().split())
    L = list(map(int, input().split()))
    D = 0

    for cnt in range(2, N + 2):
        D += L[cnt - 2]
        if D > X:
            cnt -= 1
            break

    print(cnt)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N, X = map(int, input().split())
    L = list(map(int, input().split()))
    cnt = 1
    D = 0

    while True:
        if D > X:
            cnt -= 1
            break
        if cnt > N + 1:
            cnt -= 1
            break
        D += L[cnt - 1]
        cnt += 1

    print(cnt)


if __name__ == "__main__":
    main()
Problem p03695 (python)

Fixed submission:
def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    rate_list = [0] * 9

    for a in a_list:
        rate = a // 400
        if rate < 8:
            rate_list[rate] += 1
        else:
            rate_list[-1] += 1

    min_cnt = 0
    for i in range(8):
        if rate_list[i] > 0:
            min_cnt += 1

    print(max(min_cnt, 1), min_cnt + rate_list[-1])


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    rate_list = [0] * 9

    for a in a_list:
        rate_list[a // 400] += 1

    min_cnt = 0
    for i in range(8):
        if rate_list[i] > 0:
            min_cnt += 1

    print(min_cnt, min_cnt + rate_list[-1])


if __name__ == "__main__":
    main()
Problem p03738 (python)

Fixed submission:
import numpy as np

def main():
    a=int(input())
    b=int(input())
    if(a>b):
        print("GREATER")
    elif(a<b):
        print("LESS")
    else:
        print("EQUAL")

def inputList():
    a=list(map(int,input().split()))
    return a

def multisort(li,index):
    return sorted(li,key=lambda x: x[index])

if(__name__=='__main__'):
    main()

Buggy submission (verdict: Runtime Error):
import numpy as np

def main():
    a=inputList()
    if(a[0]>a[1]):
        print("GREATER")
    elif(a[0]<a[1]):
        print("LESS")
    else:
        print("EQUAL")

def inputList():
    a=list(map(int,input().split()))
    return a

def multisort(li,index):
    return sorted(li,key=lambda x: x[index])

if(__name__=='__main__'):
    main()
Problem p02537 (python)

Fixed submission:
tmpn,k=map(int,input().split())
a=[int(input()) for _ in range(tmpn)]
n=3*10**5+1

def init_max(init_max_val):
    #set_val
    for i in range(n):
        seg_max[i+num_max-1]=init_max_val[i]    
    #built
    for i in range(num_max-2,-1,-1) :
        seg_max[i]=max(seg_max[2*i+1],seg_max[2*i+2]) 
    
def update_max(k,x):
    k += num_max-1
    seg_max[k] = x
    while k:
        k = (k-1)//2
        seg_max[k] = max(seg_max[k*2+1],seg_max[k*2+2])
    
def query_max(p,q):
    if q<=p:
        return ide_ele_max
    p += num_max-1
    q += num_max-2
    res=ide_ele_max
    while q-p>1:
        if p&1 == 0:
            res = max(res,seg_max[p])
        if q&1 == 1:
            res = max(res,seg_max[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = max(res,seg_max[p])
    else:
        res = max(max(res,seg_max[p]),seg_max[q])
    return res

#####単位元######
ide_ele_max = 0

#num_max:n以上の最小の2のべき乗
num_max =2**(n-1).bit_length()
seg_max=[ide_ele_max]*2*num_max

init_max([0]*n)

for aa in a:
    maxlen=query_max(max(0,aa-k),min(aa+k,n-1)+1)
    update_max(aa,maxlen+1)

print(query_max(0,n+1))

Buggy submission (verdict: Runtime Error):
tmpn,k=map(int,input().split())
a=[int(input()) for _ in range(tmpn)]
n=3*10**5+2

def init_max(init_max_val):
    #set_val
    for i in range(n):
        seg_max[i+num_max-1]=init_max_val[i]    
    #built
    for i in range(num_max-2,-1,-1) :
        seg_max[i]=max(seg_max[2*i+1],seg_max[2*i+2]) 
    
def update_max(k,x):
    k += num_max-1
    seg_max[k] = x
    while k:
        k = (k-1)//2
        seg_max[k] = max(seg_max[k*2+1],seg_max[k*2+2])
    
def query_max(p,q):
    if q<=p:
        return ide_ele_max
    p += num_max-1
    q += num_max-2
    res=ide_ele_max
    while q-p>1:
        if p&1 == 0:
            res = max(res,seg_max[p])
        if q&1 == 1:
            res = max(res,seg_max[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = max(res,seg_max[p])
    else:
        res = max(max(res,seg_max[p]),seg_max[q])
    return res

#####単位元######
ide_ele_max = 0

#num_max:n以上の最小の2のべき乗
num_max =2**(n-1).bit_length()
seg_max=[ide_ele_max]*2*num_max

init_max([0]*n)

for aa in a:
    aa+=1
    maxlen=query_max(aa-k,aa+k+1)
    update_max(aa,maxlen+1)

print(query_max(0,n+1))