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

Fixed submission:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
from sys import flags
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
x=list(input())
cnt=Counter(x)
x2=int("".join(x),2)
one=cnt["1"]
# print(x)
# print(math.log2(2*10**5))
# print(cnt)
# print(x2,one)
lst=[0]*(2*10**5+10)
# lst[0]=-1
flaglst=[0,0]
if one-1!=0:
    flaglst[0]=x2%(one-1)
flaglst[1]=x2%(one+1)
# print(flaglst)

for i in range(2*10**5):
    now=i+1
    ans=0
    while now:
        cnt2=0
        m=0
        while now>=pow(2,m):
            if now&1<<m:
                cnt2+=1
            m+=1
        now%=cnt2
        ans+=1
    lst[i+1]=ans
# # print(lst[:100])

for i in range(n):
    tmp=0
    if x[i]=="1":
        tmp=flaglst[0]
        if one-1!=0:
            tmp-=pow(2,n-1-i,one-1)
            tmp%=one-1
        else:
            print(0)
            continue
    else:
        tmp=flaglst[1]
        tmp+=pow(2,n-1-i,one+1)
        tmp%=one+1
    # print(tmp,pow(2,n-1-i),one)

    print(lst[tmp]+1)

Buggy submission (verdict: Runtime Error):
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
x=list(input())
cnt=Counter(x)
# print(x)
# print(math.log2(2*10**5))

def wari(now):
    tmp=cnt["1"]
    if flag=="1":
        tmp-=1
    else:
        tmp+=1
    now%=tmp
    if now==0:
        return 1
    ans=1
    while now:
        cnt2=Counter(bin(now))
        now%=cnt2["1"]
        ans+=1
    return ans

for i in range(n):
    flag=x[i]
    if flag=="0":
        x[i]="1"
    else:
        x[i]="0"
    now=int("".join(x),2)
    # print(now)
    print(wari(now))
    x[i]=flag
Problem p02657 (python)

Fixed submission:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

Buggy submission (verdict: Runtime Error):
l

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[input() for i in range(n)]
 
tmp=""
for i in range(n//2):
    alpha=[0]*26
    for j in range(n):
        alpha[ord(a[i][j])-ord("a")]+=1
    for j in range(n):
        if alpha[ord(a[-1-i][j])-ord("a")]!=0:
            tmp+=a[-1-i][j]
            break
    else:
        print(-1)
        quit()
 
 
if n%2==1:
    tmp=tmp+a[n//2][0]+tmp[::-1]
else:
    tmp=tmp+tmp[::-1]
 
print(tmp)
Problem p02697 (python)

Fixed submission:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,m=map(int,input().split())
half=n//2
lst=[]
tmp=0
if n%2==0:
    tmp=1
for i in range(m):
    if i%2==1:
        lst.append([half-i//2,half+i//2+2])
    else:
        lst.append([1+i//2,n-i//2])

for i in range(m):
    print(*lst[i])

# dic=defaultdict(int)
# for i in range(m):
#     tmp=lst[i]
#     dic[tmp[1]-tmp[0]]+=1
#     dic[n-tmp[1]+tmp[0]]+=1
# print(dic)

Buggy submission (verdict: Runtime Error):
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,m=map(int,input().split())
if n%2==1:
    half=n//2
    if i%2==0:
            print(*[half-i//2,half+i//2+1])
        else:
            print(*[1+i//2,n-1+i//2])
    quit()
else:
    half=n//2
    for i in range(m-1):
        print(*[half-i,half+i+1])
    if n==4:
        print(*[2,3])
    else:
        print(*[1,n-1])
Problem p02698 (python)

Fixed submission:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(1000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
a=list(map(int,input().split()))
uv=[list(map(int,input().split())) for i in range(n-1)]
edge=defaultdict(list)
for i in range(n-1):
    u,v=uv[i]
    edge[u].append(v)
    edge[v].append(u)
# print(edge)

itta=[0]*(n+1)
# lislist=[0]*(n+1)

def dfs(now,lis):
    stk=0
    if a[now-1]>lis[-1]:
        lis.append(a[now-1])
        stk="pop"
    else:
        tmp=bisect.bisect_left(lis, a[now-1])
        stk=[tmp,lis[tmp]]
        lis[tmp]=a[now-1]
    
    # print(now,lis)
    itta[now]=len(lis)
    for i in edge[now]:
        if itta[i]==0:
            dfs(i,lis)
    
    if stk=="pop":
        lis.pop()
    else:
        lis[stk[0]]=stk[1]

dfs(1,[float('inf')])

# print(itta)
for i in range(n):
    print(itta[i+1])

Buggy submission (verdict: Runtime Error):
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
a=list(map(int,input().split()))
uv=[list(map(int,input().split())) for i in range(n-1)]
edge=defaultdict(list)
for i in range(n-1):
    u,v=uv[i]
    edge[u].append(v)
    edge[v].append(u)
# print(edge)

itta=[0]*(n+1)
# lislist=[0]*(n+1)

def dfs(now,lis):
    stk=0
    if a[now-1]>lis[-1]:
        lis.append(a[now-1])
        stk="pop"
    else:
        tmp=bisect.bisect_left(lis, a[now-1])
        stk=[tmp,lis[tmp]]
        lis[tmp]=a[now-1]
    
    # print(now,lis)
    itta[now]=len(lis)
    for i in edge[now]:
        if itta[i]==0:
            dfs(i,lis)
    
    if stk=="pop":
        lis.pop()
    else:
        lis[stk[0]]=stk[1]

dfs(1,[float('inf')])

# print(itta)
for i in range(n):
    print(itta[i+1])
Problem p02703 (python)

Fixed submission:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,m,s=map(int,input().split())
uvab=[list(map(int,input().split())) for i in range(m)]
cd=[list(map(int,input().split())) for i in range(n)]

def dijkstra(s,n):
    hq = [(0, s)]
    heapq.heapify(hq) # リストを優先度付きキューに変換
    cost = [float('inf')] * n # 行ったことのないところはinf
    cost[s] = 0 # 開始地点は0
    while hq:
        c, v = heapq.heappop(hq)
        if c > cost[v]: # コストが現在のコストよりも高ければスルー
            continue
        for d, u in e[v]:
            tmp = d + cost[v]
            if tmp < cost[u]:
                cost[u] = tmp
                heapq.heappush(hq, (tmp, u))
    return cost


e = [[] for _ in range(10000*(n+1))]
for i in range(n):
    c,d=cd[i]
    for j in range(2500):
        e[10000*i+j].append((d,10000*i+min(j+c,2500)))
    
for i in range(m):
    u,v,a,b=uvab[i]
    u,v = u-1, v-1
    for j in range(2500):
        if j-a>=0:
            e[10000*v+j].append((b,10000*u+j-a))
            e[10000*u+j].append((b,10000*v+j-a))
# print(e)
s=min(2499,s)
# print(s)
lst=dijkstra(s,10000*(n+1))
# print(lst)
for i in range(1,n):
    ans=float('inf')
    for j in range(2500):
        ans=min(ans,lst[10000*i+j])
    print(ans)

Buggy submission (verdict: Runtime Error):
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,m,s=map(int,input().split())
uvab=[list(map(int,input().split())) for i in range(m)]
cd=[list(map(int,input().split())) for i in range(n)]

def dijkstra(s,n):
    hq = [(0, s)]
    heapq.heapify(hq) # リストを優先度付きキューに変換
    cost = [float('inf')] * n # 行ったことのないところはinf
    cost[s] = 0 # 開始地点は0
    while hq:
        c, v = heapq.heappop(hq)
        if c > cost[v]: # コストが現在のコストよりも高ければスルー
            continue
        for d, u in e[v]:
            tmp = d + cost[v]
            if tmp < cost[u]:
                cost[u] = tmp
                heapq.heappush(hq, (tmp, u))
    return cost


e = [[] for _ in range(1000*(n+1))]
for i in range(n):
    c,d=cd[i]
    for j in range(250):
        e[1000*i+j].append((d,1000*i+min(j+c,250)))
    
for i in range(m):
    u,v,a,b=uvab[i]
    u,v = u-1, v-1
    for j in range(250):
        if j-a>=0:
            e[1000*v+j].append((b,1000*u+j-a))
            e[1000*u+j].append((b,1000*v+j-a))
# print(e)
lst=dijkstra(s,1000*(n+1))
# print(lst)
for i in range(1,n):
    ans=float('inf')
    for j in range(250):
        ans=min(ans,lst[1000*i+j])
    print(ans)
Problem p02714 (python)

Fixed submission:
import sys
from collections import *
import heapq
import math
from math import gcd
import bisect
import copy
from itertools import permutations,accumulate,combinations,product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
s=input()
dic={"R":[],"G":[],"B":[]}
for i in range(n):
    if not s[i] in dic:
        dic[s[i]]=[i]
    else:
        dic[s[i]].append(i)
# print(dic)
se=set(dic["B"])
# print(se)
ans=len(dic["R"])*len(dic["G"])*len(dic["B"])
for i in range(len(dic["R"])):
    for j in range(len(dic["G"])):
        l,r=min(dic["R"][i],dic["G"][j]),max(dic["R"][i],dic["G"][j])
        if r+(r-l) in se:
            ans-=1
        if l-(r-l) in se:
            ans-=1
        if (r-l)%2==0 and l+(r-l)//2 in se:
            ans-=1
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
from collections import *
import heapq
import math
from math import gcd
import bisect
import copy
from itertools import permutations,accumulate,combinations,product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
s=input()
dic={}
for i in range(n):
    if not s[i] in dic:
        dic[s[i]]=[i]
    else:
        dic[s[i]].append(i)
# print(dic)
se=set(dic["B"])
# print(se)
ans=len(dic["R"])*len(dic["G"])*len(dic["B"])
for i in range(len(dic["R"])):
    for j in range(len(dic["G"])):
        l,r=min(dic["R"][i],dic["G"][j]),max(dic["R"][i],dic["G"][j])
        if r+(r-l) in se:
            ans-=1
        if l-(r-l) in se:
            ans-=1
        if (r-l)%2==0 and l+(r-l)//2 in se:
            ans-=1
print(ans)
Problem p02775 (python)

Fixed submission:
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=pow(10,9)+7

n=input()
lst=[]
for i in range(len(n)):
    lst.append(int(n[i]))
# n=int(n)

keta=len(lst)
ans=0
lst.reverse()
# print(lst)
# dp=[[float('inf')]*2 for i in range(keta+1)]
dp=[]
for i in range(keta+1):
    dp.append([float('inf')]*2)
dp[0]=[0,1]
# print(dp)
for i in range(keta):
    dp[i+1][0]=min(dp[i][0]+lst[i],dp[i][1]+lst[i]+1)
    dp[i+1][1]=min(dp[i][0]+(10-lst[i]),dp[i][1]+(10-lst[i]-1))
# print(dp)
print(min(dp[-1][0],dp[-1][1]+1))

Buggy submission (verdict: Runtime Error):
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=pow(10,9)+7

lst=[int(n[i]) for i in range(len(n))]
n=int(n)

keta=len(lst)
ans=0
lst.reverse()
# print(lst)
dp=[[float('inf')]*2 for i in range(keta+1)]
dp[0]=[0,1]

for i in range(keta):
    dp[i+1][0]=min(dp[i][0]+lst[i],dp[i][1]+lst[i]+1)
    dp[i+1][1]=min(dp[i][0]+(10-lst[i]),dp[i][1]+(10-lst[i]-1))
# print(dp)
print(min(dp[-1][0],dp[-1][1]+1))

Buggy submission (verdict: Runtime Error):
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=pow(10,9)+7

lst=[int(n[i]) for i in range(n)]
n=int(n)

keta=len(lst)
ans=0
lst.reverse()
# print(lst)
dp=[[float('inf')]*2 for i in range(keta+1)]
dp[0]=[0,1]

for i in range(keta):
    dp[i+1][0]=min(dp[i][0]+lst[i],dp[i][1]+lst[i]+1)
    dp[i+1][1]=min(dp[i][0]+(10-lst[i]),dp[i][1]+(10-lst[i]-1))
# print(dp)
print(min(dp[-1][0],dp[-1][1]+1))

Buggy submission (verdict: Runtime Error):
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=pow(10,9)+7

lst=[n[i] for i in range(n)]
n=int(n)

keta=len(lst)
ans=0
lst.reverse()
# print(lst)
dp=[[float('inf')]*2 for i in range(keta+1)]
dp[0]=[0,1]

for i in range(keta):
    dp[i+1][0]=min(dp[i][0]+lst[i],dp[i][1]+lst[i]+1)
    dp[i+1][1]=min(dp[i][0]+(10-lst[i]),dp[i][1]+(10-lst[i]-1))
# print(dp)
print(min(dp[-1][0],dp[-1][1]+1))
Problem p02782 (python)

Fixed submission:
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7

r1,c1,r2,c2=map(int,input().split())

# MOD combination
def cmb(n, r, mod=10**9+7):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

N = 10**6*2+10
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

def g(r,c):
    tmp=0
    for i in range(1,r+2):
        tmp+=cmb(i+c,i)
        tmp%=mod
    return tmp

ans=0
ans+=g(r2,c2)
ans-=g(r2,c1-1)
ans-=g(r1-1,c2)
ans+=g(r1-1,c1-1)
ans%=mod
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7

r1,c1,r2,c2=map(int,input().split())

# MOD combination
def cmb(n, r, mod=10**9+7):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

N = 10**6*2+1
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

def g(r,c):
    tmp=cmb(r+1+c+1,r+1)-1
    return tmp%mod

ans=0
ans+=g(r2,c2)
ans-=g(r2,c1-1)
ans-=g(r1-1,c2)
ans+=g(r1-1,c1-1)
ans%=mod
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7

r1,c1,r2,c2=map(int,input().split())

# MOD combination
def cmb(n, r, mod=10**9+7):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

N = 10**6*2
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

def g(r,c):
    tmp=cmb(r+1+c+1,r+1)-1
    return tmp%mod

ans=0
ans+=g(r2,c2)
ans-=g(r2,c1-1)
ans-=g(r1-1,c2)
ans+=g(r1-1,c1-1)
ans%=mod
print(ans)
Problem p02783 (python)

Fixed submission:
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7

h,a=map(int,input().split())
print((h+a-1)//a)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
# スペース区切りの整数の入力
b, c = map(int, input().split())
# 文字列の入力
s = input()
# 出力
print("{} {}".format(a+b+c, s))
import fractions
fractions.gcd(a,b)
Problem p02789 (python)

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]
n,m=map(int,input().split())
if n==m:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import sys
import fractions
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7


ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])

cnt=0
b=[ans//a[i] for i in range(n)]
print(sum(b)%mod)

Buggy submission (verdict: Runtime Error):
import sys
import fractions
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7


ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])

cnt=0
b=[ans//a[i] for i in range(n)]
print(sum(b)%mod)
Problem p02796 (python)

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7
n=int(input())
xl=[list(map(int,input().split())) for i in range(n)]
from collections import deque
# for i in range(n):
#     right.append(xl[i][0]+xl[i][1])
#     left.append(xl[i][0]-xl[i][1])
ans=0
xl.sort()
# right.sort()
# left.sort()
d=deque(xl)
while d:
    tmp=d.popleft()
    while d:
        if tmp[0]+tmp[1]>d[0][0]-d[0][1]:
            ans+=1
            if tmp[0]+tmp[1]>d[0][0]+d[0][1]:
                # d.popleft()
                break
            elif tmp[0]-tmp[1]>d[0][0]-d[0][1]:
                d.popleft()
            else:
                d.popleft()
        else:
            break
if n==1:
    print(1)
    quit()

print(n-ans)

Buggy submission (verdict: Runtime Error):
import sys
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7
n=int(input())
xl=[list(map(int,input().split())) for i in range(n)]
ans=0
xl.sort()
if xl[0][0]+xl[0][1]>xl[1][0]-xl[1][1]:
    xl[1][0]=-1
    ans+=1

for i in range(1,n-1):
    if xl[i][0]==-1:
        continue
    else:
        if xl[i][0]+xl[i][1]>xl[i+1][0]-xl[i+1][1]:
            ans+=1
            xl[i+1][0]=-1
# print(xl)
print(n-ans)
Problem p02805 (python)

Fixed submission:
import math
N=int(input())
x=[0 for i in range(N)]
y=[0 for i in range(N)]
p=[]
for i in range(N):
    x[i],y[i]=map(int,input().split())
    p.append((x[i],y[i]))
def dist(p,q):
    a,b=p
    c,d=q
    return math.sqrt((a-c)**2+(b-d)**2)
def check(R):
    Q=[]
    for i in range(N):
        for j in range(i+1,N):
            d=dist(p[i],p[j])/2
            if R<d:
                return False
            h=math.sqrt(R*R-d*d)
            #print(d,h,R)
            nx,ny=(x[j]-x[i],y[j]-y[i])
            nr=math.sqrt(nx**2+ny**2)
            dx,dy=h*nx/nr,h*ny/nr
            mx,my=(x[i]+x[j])/2,(y[i]+y[j])/2
            #print(mx,my)
            #print(dx,dy)
            Q.append((mx+dy,my-dx))
            Q.append((mx-dy,my+dx))
    #print(Q,R)
    for pa in Q:
        flag=1
        for i in range(N):
            #print(pa,i,dist(pa,p[i]),R)
            if dist(pa,p[i])>R+9e-7:
                flag=0
                break
        if flag==1:
            return True
    return False

low=0
high=2000
for line in range(50):
    mid=(low+high)/2
    if check(mid):
        high=mid
    else:
        low=mid
print(mid)

Buggy submission (verdict: Runtime Error):
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
# from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

mi,ma=0,2000
com=list(combinations(range(n),2))

while ma-mi>10**(-9):
    half=(ma+mi)/2
    # print(ma,mi,half)
    lst=[]
    flag=1
    for co in com:
        a,b=co
        ax,ay=xy[a]
        bx,by=xy[b]
        kyori=((ax-bx)**2+(ay-by)**2)**0.5
        if kyori/2>half:
            mi=half
            break
        else:
            h=((kyori/2)**2-half**2)**0.5
            tyuuten=((ax+bx)/2,(ay+by)/2)
            tmp=h/2/kyori
            lst.append((tyuuten[0]+(ay-by)*tmp,tyuuten[1]-(ax-bx)*tmp))
            lst.append((tyuuten[0]-(ay-by)*tmp,tyuuten[1]+(ax-bx)*tmp))
            # print(((lst[-1][0]-ax)**2+(lst[-1][1]-ay)**2)**0.5,half)
    else:
        for co in lst:
            bx,by=co
            for i in range(n):
                ax,ay=xy[i]
                if (ax-bx)**2+(ay-by)**2+0.00000001>half**2:
                    break
            else:
                ma=half
                break
        else:
            mi=half
print(ma)
Problem p02852 (python)

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]

n,m=map(int,input().split())
s=input()
if m>n:
    m=n
tmp=-1
for i in range(m):
    if s[-i-2]=="0":
        tmp=-i-2
# print(tmp)
li=[]
for i in range(n):
    li.append(tmp)
    a=-i-2-m
    if a<-1-n:
        a=-1-n
    if s[a]=="0":
        tmp=a
ans=[]
i=-1
li.reverse()

while(i!=-n-1):

    if li[i]==i:
        print(-1)
        quit()
    ans.append(i-li[i])
    i=li[i]

ans.reverse()


for i in range(len(ans)):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
import sys
def input():
    return sys.stdin.readline()[:-1]
n,m=map(int,input().split())
s=input()
co=[[0,0] for i in range(n)]
tmp=0
for i in range(m):
    if s[i+1]=="0":
        tmp=i+1
# print(tmp)
li=[]
for i in range(n+1):
    li.append(tmp)
    a=i+1+m
    if a>n:
        a=n
    if s[a]=="0":
        tmp=a
# print(li)
i=0
while(li[i]!=i):
    print(li[i]-i)
    i=li[i]
    if i==n:
        quit()
print(-1)