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

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
m=max(a)
alist=[0]*(m+1)
for i in a:
  for j in range(i,m+1,i):
    alist[j]+=1
cnt=0
for i in a:
  if alist[i]==1:
    cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
m=max(a)
alsit=[0]*(m+1)
for i in a:
  for j in range(i,m+1,i):
    alist[j]+=1
cnt=0
for i in a:
  if alist[i]==1:
    cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
alist=[0]*200001
for i in range(n):
  for j in range(a[i],200001,a[i]):
    alist[j]+=1
cnt=0
for i in range(n):
  if alist[a[i]]==1:
    cnt+=1
print(cnt)
Problem p02657 (python)

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

Buggy submission (verdict: Runtime Error):
A=int(input())
B=int(input())
print(A*B)

Buggy submission (verdict: Runtime Error):
A=int(input())
B=int(input())
print(A*B)
Problem p02684 (python)

Fixed submission:
n,k=map(int, input().split())
a=list(map(int, input().split()))
alist=[]
cnt=0
i=1
blist=[0]*(n+1)
while blist[a[i-1]]==0:
  i=a[i-1]
  alist.append(i)
  blist[i]=1
  cnt+=1
loop1=alist.index(a[i-1])
if k<loop1+1:
  print(alist[k-1])
else:
  print(alist[((k-loop1-1)%(cnt-loop1))+loop1])

Buggy submission (verdict: Runtime Error):
n,k=map(int, input().split())
a=list(map(int, input().split()))
alist=[]
i=1
while a[i-1] not in alist:
  i=a[i-1]
  alist.append(i)
loop1=alist.index(a[i-1])
if k<loop1+1:
  print(alist[k-1])
else:
  lenloop=len(alist)-loop1
  print(alist[((k-loop1-1)%lenroop)+loop1])
Problem p02730 (python)

Fixed submission:
S=input()
N=len(S)
A=S[:(N-1)//2]
B=S[(N+3)//2-1:]
if S!=S[::-1] or A!=A[::-1] or B!=B[::-1]:
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
l=int(input())
print((l/3)**3)
Problem p03000 (python)

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

Buggy submission (verdict: Runtime Error):
n,x=map(int, input().split())
l=list(map(int, input().split()))
cnt=0
for i in range(n):
  if cnt+l[i]<=x:
    cnt+=1
    cnt+=l[i]
  else:
    break
print(ans)

Buggy submission (verdict: Runtime Error):
n,x=map(int, input().split())
l=list(map(int,input().split()))
cnt=0
zahyou=0
while zahyou<=x and cnt<=n:
  zahyou+=l[cnt]
  cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
n,x=map(int, input().split())
l=list(map(int,input().split()))
cnt=0
zahyou=0
while zahyou<=x:
  zahyou+=l[cnt]
  cnt+=1
print(cnt)
Problem p03061 (python)

Fixed submission:
import math
n=int(input())
a=list(map(int, input().split()))
alist=[]
gcd1=a[0]
for i in range(0,n):
  gcd1=math.gcd(gcd1,a[i])
  alist.append(gcd1)
blist=[]
gcd2=a[n-1]
for i in range(n-1,-1,-1):
  gcd2=math.gcd(gcd2,a[i])
  blist.append(gcd2)
clist=[alist[n-2],blist[n-2]]
for i in range(n-2):
  clist.append(math.gcd(alist[i],blist[n-i-3]))
print(max(clist))

Buggy submission (verdict: Runtime Error):
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
n=int(input())
a=list(map(int, input().split()))
a.sort()
num=a[1]
alist=[0]*(num+2)
for i in range(n):
  for j in make_divisors(a[i]):
    if j<=num:
      alist[j]+=1
ans=0
for i in range(num+2):
  if alist[i]>=n-1:
    ans=i
print(ans)
Problem p03240 (python)

Fixed submission:
n=int(input())
alist=[list(map(int, input().split())) for i in range(n)]
alist.sort(key=lambda x:x[2],reverse=True)
for i in range(101):
  for j in range(101):
    h=abs(alist[0][0]-i)+abs(alist[0][1]-j)+alist[0][2]
    ans=True
    for k in range(n):
      if max((h-abs(alist[k][0]-i)-abs(alist[k][1]-j)),0)!=alist[k][2]:
        ans=False 
    if ans:
      ansx=i
      ansy=j
      ansh=h
print(ansx,ansy,ansh)

Buggy submission (verdict: Runtime Error):
n=int(input())
x=[0]*n
y=[0]*n
h=[0]*n
for i in range(n):
  x[i],y[i],h[i]=map(int, input().split())
for i in range(101):
  for j in range(101):
    alist=[0]*n
    for k in range(n):
      if h[k]>0:
        alist[k]=(h[k]+abs(x[k]-i)+abs(y[k]-j))
    if len(set(alist))==1:
      ans=True
      for k in range(n):
        if h[k]==0:
          if alist[0]<(h[k]+abs(x[k]-i)+abs(y[k]-j)):
            ans=False
      if ans:
        ansx=i
        ansy=j
        ansh=alist[0]
print(ansx,ansy,ansh)

Buggy submission (verdict: Runtime Error):
n=int(input())
x=[0]*n
y=[0]*n
h=[0]*n
for i in range(n):
  x[i],y[i],h[i]=map(int, input().split())
for i in range(101):
  for j in range(101):
    alist=[0]*n
    for k in range(n):
      if h[k]>0:
        alist[k]=(h[k]+abs(x[k]-i)+abs(y[k]-j))
    if len(set(alist))==1:
      ans=True
      for k in range(n):
        if h[k]==0:
          if alist[0]>(h[k]+abs(x[k]-i)+abs(y[k]-j)):
            ans=False
      if ans:
        ansx=i
        ansy=j
        ansh=alist[0]
print(ansx,ansy,ansh)

Buggy submission (verdict: Runtime Error):
n=int(input())
x=[0]*n
y=[0]*n
h=[0]*n
for i in range(n):
  x[i],y[i],h[i]=map(int, input().split())
for i in range(101):
  for j in range(101):
    alist=[0]*n
    for k in range(n):
      alist[k]=(h[k]+abs(x[k]-i)+abs(y[k]-j))
    if len(set(alist))==1:
      ansx=i
      ansy=j
      ansh=alist[0]
print(ansx,ansy,ansh)
Problem p03274 (python)

Fixed submission:
n,k=map(int, input().split())
xlist=list(map(int, input().split()))
ans=10**20
for i in range(n-k+1):
  ans=min(abs(xlist[i]-xlist[i+k-1])+min(abs(xlist[i]),abs(xlist[i+k-1])),ans)
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int, input().split())
xlist=list(map(int, input().split()))
num0=0
nump=0
numm=0
for i in xlist:
  if i>0:
    nump+=1
  elif i<0:
    numm+=1
  else:
    num0+=1
listp=[0]*(nump+1)
listm=[0]*(numm+1)
for i in range(1,nump+1):
  listp[i]=xlist[numm+num0+i-1]
for i in range(1,numm+1):
  listm[i]=-xlist[numm-i]
cnt=k-num0
ans=10**30
for i in range(cnt):
  if i<=numm and cnt-i<=nump:
    ans=min(ans,listm[i]+listp[cnt-i]+min(listm[i],listp[cnt-i]))
if numm==0 and nump==0:
  ans=0
elif numm==0:
  ans=listp[cnt+1]
elif nump==0:
  ans=listm[cnt+1]
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int, input().split())
xlist=list(map(int, input().split()))
num0=0
nump=0
numm=0
for i in xlist:
  if i>0:
    nump+=1
  elif i<0:
    numm+=1
  else:
    num0+=1
listp=[0]*(nump+1)
listm=[0]*(numm+1)
for i in range(1,nump+1):
  listp[i]=xlist[numm+num0+i-1]
for i in range(1,numm+1):
  listm[i]=-xlist[numm-i]
cnt=k-num0
ans=10**30
for i in range(cnt):
  if i<=numm and cnt-i<=nump:
    ans=min(ans,listm[i]+listp[cnt-i]+min(listm[i],listp[cnt-i]))
if numm==0:
  ans=listp[cnt+1]
if nump==0:
  ans=listm[cnt+1]
print(ans)
Problem p03309 (python)

Fixed submission:
import statistics
n=int(input())
alist=list(map(int, input().split()))
blist=[]
for i in range(n):
  blist.append(alist[i]-i-1)
blist.sort()
median=statistics.median_high(blist)
ans=0
for i in range(n):
  ans+=abs(blist[i]-median)
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
alist=list(map(int, input().split()))
blist=[]
for i in range(n):
  blist.append(alist[i]-i-1)
blist.sort()
if n%2==1:
  cnt=0
  for i in range(n):
    cnt+=abs(blist[i]-blist[(i+1)//2])
  print(cnt)
else:
  cnt=0
  num=(blist[i//2]+blist[i//2+1])//2
  for i in range(n):
    cnt+=abs(blist[i]-num
  print(cnt,cnt2)
Problem p02765 (python)

Fixed submission:
n,r = map(int,input().split())
print(r+(100*(max(10-n,0))))

Buggy submission (verdict: Runtime Error):
n,r = map(int,input().split())
print(r-(100*(10-n))
Problem p03145 (python)

Fixed submission:
a,b,c = map(int,input().split())
print(min(a,b,c)*(sum([a,b,c])-min(a,b,c)-max(a,b,c))//2)

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
print(min(a,b,c)*(sum([a,b,c]-min(a,b,c)-max(a,b,c)))//2)
Problem p03273 (python)

Fixed submission:
h,w=map(int,input().split())
A=[list(input()) for i in range(h)]
answ=[]
ansh=[]
for i in range(h):
  if not all([a=="." for a in A[i]]):
    answ.append(i)
for j in range(w):
  if not all([A[i][j]=="." for i in range(h)]):
    ansh.append(j)
for i in answ:
  for j in ansh:
    print(A[i][j],end="")
  print("\n")

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
A=[list(input()) for i in range(w)]
answ=[]
ansh=[]
for i in range(w):
  if not all([a=="." for a in A[i]]):
    answ.append(i)
for j in range(h):
  if not all([A[i][j]=="." for i in range(w)]):
    ansh.append(j)
for i in answ:
  for j in ansh:
    print(A[i][j],end="")
  print("\n")
Problem p03555 (python)

Fixed submission:
S1 = input()
S2 = input()
if S1[::-1] == S2:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
S1 = input()
S2 = input()
if S1.reverse == S2:
  print("YES")
else:
  print("NO")
Problem p03607 (python)

Fixed submission:
n=int(input())
ans = {}
printed = 0
for i in range(n):
  a = int(input())
  if not a in ans:
    ans[a] = 1
    printed += 1
  else:
    ans[a] += 1
    if ans[a] % 2 == 0:
      printed -= 1
    else:
      printed += 1
print(printed)

Buggy submission (verdict: Runtime Error):
n=int(input())
L = [0]*(100001)
ans = 0
for  i in range(n):
  L[int(input())] += 1
print(sum([L[i]%2 for i in range(len(L))]))
Problem p03609 (python)

Fixed submission:
a,b=map(int,input().split())
print(max(0,a-b))

Buggy submission (verdict: Runtime Error):
print(max(0,int(input())-int(input())))

Buggy submission (verdict: Runtime Error):
print(max(0,int(input())-int(input())))
Problem p03636 (python)

Fixed submission:
S=input()
print(S[0]+str(len(S)-2)+S[-1])

Buggy submission (verdict: Runtime Error):
S=input()
print(S[0]+str(len(S-2))+S[-1])
Problem p03671 (python)

Fixed submission:
a,b,c=map(int,input().split())
print(sum([a,b,c])-max(a,b,c))

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
print(sum([a,b,c]-max(a,b,c)))
Problem p03680 (python)

Fixed submission:
def main():
  n=int(input())
  A=[int(input()) for i in range(n)]
  crt=1
  cnt=0
  for i in range(n):
    cnt += 1
    crt = A[crt-1]
    if crt == 2:
      print(cnt)
      break
  else:
    print(-1)
main()

Buggy submission (verdict: Runtime Error):
def main():
  n=int(input())
  A=[int(input()) for i in range(n)]
  crt=1
  for i in range(n):
    crt = A[crt-1]
    if crt == 2:
      print(len(L))
      break
  else:
    print(-1)
main()
Problem p03711 (python)

Fixed submission:
L=[1,0,1,2,1,2,1,1,2,1,2,1]
a,b=map(int,input().split())
if L[a-1]==L[b-1]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
L=[1,0,1,2,1,2,1,1,2,1,2,1]
a,b=map(int,input().split())
if L[a]==L[b]:
  print("Yes")
else:
  print("No")
Problem p03729 (python)

Fixed submission:
a,b,c=map(str,input().split())
if a[-1] == b[0] and b[-1] == c[0]:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if a[-1] == b[0] and b[-1] == c[0]:
  print("YES")
else:
  print("NO")
Problem p03997 (python)

Fixed submission:
a,b,c=[int(input()) for i in range(3)]
print((a+b)*c//2)

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
print((a+b)*c//2)
Problem p02731 (python)

Fixed submission:
n = int(input())
n = n/3
a = n**3
print(a)

Buggy submission (verdict: Runtime Error):
n = input()
n = n/3
a = n**3
print(a)
Problem p02641 (python)

Fixed submission:
from sys import stdin


X,N=[int(x) for x in stdin.readline().rstrip().split()]
P=[int(x) for x in stdin.readline().rstrip().split()]
l=[i for i in range(-1,102) if i not in P]
abslist = list(map(lambda a:abs(a-X),l))
print(l[abslist.index(min(abslist))])

Buggy submission (verdict: Runtime Error):
import math
from sys import stdin

X,N=[int(x) for x in stdin.readline().rstrip().split()]
P=[int(x) for x in stdin.readline().rstrip().split()]
l=[i for i in range(1,101) if i not in P]
abslist = list(map(lambda a:abs(a-X),l))
result = min(abslist)

print(l[abslist.index(result)])
Problem p02621 (python)

Fixed submission:
a = int(input())
print(a + a*a + a*a*a)

Buggy submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = sorted(a+b)
ans = 0
tmp = 0
for i in c:
  tmp += i
  if(tmp > k):print(ans);exit()
  ans+=1
else:print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
print(a + a*a + a*a*a)
Problem p02657 (python)

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

Buggy submission (verdict: Runtime Error):
n = int(input())
s = list(map(int, input().split())
ans = 1
for i in s:ans*=i
print(ans)
Problem p02755 (python)

Fixed submission:
a, b = map(int, input().split())
c = 1
while(True):
    if(int(c*0.08)==a and int(c*0.1)==b):
        print(c)
        exit()
    c+=1
    if(c==100000):
        print(-1)
        exit()

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
c = 1
while(True):
    if(int(c*0.08)==a and int(c*0.1)==b):
        print(c)
        exit()
    c+=1
    if(c=100000):
        print(-1)
        exit()
Problem p02761 (python)

Fixed submission:
a,b=map(int,input().split())
c2=10**a
if(a==1):c1=0
else:c1=c2//10
v = [-1]*b
for i in range(b):
  n,m=map(int,input().split())
  v[i] = [n,m]
#print(v) 

for i in range(c1,c2):
  p =str(i)
  t=True
  for j in v:
    
    if(int(p[j[0]-1]) != j[1]):
      t=False
      break
  
  if(t):print(i);exit()
  
print(-1)

Buggy submission (verdict: Runtime Error):
n, k =map(int, input().split())
data = []
for i in range(k):
    data.append(list(map(int, input().split())))
for i in range(0, 10**n):
    a = str(i)
    tmp = True
    if(len(a) != n):tmp = False
    for i in data:
        data1 = i[0]
        data2 = i[1]
        #print(data1, data2)
        if(a[data1-1] != str(data2)):
            tmp=False
    if(tmp):print(a);exit()
if(n==1):print(0)
else:print(-1)
Problem p02801 (python)

Fixed submission:
s = "abcdefghijklmnopqrstuvwxyz"
c = input()
print(s[s.index(c)+1])

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
a = []
m = n
for i in range(n):a.append(list(map(int, input().split())))

def distant(x1, y1, x2, y2):
    return math.sqrt(abs(x1-x2)**2+abs(y1-y2)**2)

ma = 0
while(m!=0):
    for i in range(m):
        if(i != m-1):
            p = distant(a[i][0], a[i][1], a[m - 1][0], a[m - 1][1])

            #print(p)
            #print(a[i][0], a[i][1], a[m-1][0], a[m-1][1])

            ma = max(ma, p)
    m = m - 1
print(ma/2)
Problem p02934 (python)

Fixed submission:
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm(x, y):
    return (x * y) // gcd(x, y)


n = int(input())
temp = 1
ans = 0
a = list(map(int, input().split()))
for i in a:
    temp = lcm(temp, i)

for i in a:
    ans +=  int(temp/i)

print(temp/ans)

Buggy submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
n = int(input())
temp = 1
ans = 0
a = list(map(int, input().split()))
for i in a:
    temp = lcm(temp, i)

for i in a:
    ans +=  int(temp/i)

print(temp/ans)
Problem p02969 (python)

Fixed submission:
#A
n = int(input())
print(3*n**2)
#B
#n, d = map(int, input().split())
#canseerange = 2*d+1
#if n % canseerange == 0:
#    print(int(n/canseerange))
#else:
#    print(int(n/canseerange)+1
#C
#n = int(input())
#ans = 0
#most1 = 0
#most2 = 0
#ed = False
#for i in range(n):
#    t = int(input())
#    ed = False
#    if most1 <= t:
#        most2 = most1
#        most1 = t
#        ans = i
#        ed = True
#    elif most2 <= t and ed == False:
#        most2 = t
#for i in range(n):
#    if i==ans:print(most2)
#    else:print(most1)
#D

Buggy submission (verdict: Runtime Error):
#A
#n = int(input())
#print(3*n**2)
#B
n, d = map(int, input().split())
canseerange = 2*d+1
if n % canseerange == 0:
    print(int(n/canseerange))
else:
    print(int(n/canseerange)+1
#C
#n = int(input())
#ans = 0
#most1 = 0
#most2 = 0
#ed = False
#for i in range(n):
#    t = int(input())
#    ed = False
#    if most1 <= t:
#        most2 = most1
#        most1 = t
#        ans = i
#        ed = True
#    elif most2 <= t and ed == False:
#        most2 = t
#for i in range(n):
#    if i==ans:print(most2)
#    else:print(most1)
#D
Problem p02995 (python)

Fixed submission:
import math
def lcm(x, y):return (x * y) // math.gcd(x, y)
a,b,c,d=map(int,input().split())

e = lcm(c,d)
print(b-a+1-(b//c-(a-1)//c)-(b//d-(a-1)//d)+(b//e-(a-1)//e))

Buggy submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
a, b, c, d = map(int, input().split())
sa = b-a+1
a1 = int((sa + a%c)/c)
a2 = int((sa + a%d)/d)
a3 = int((sa + a%(lcm(c, d)))/(lcm(c, d)))
print(sa-a1-a2+a3)
#print(a1)
#print(a2)
#print(a3)
#print(lcm(c, d))
#31
# 12 18 24 30 36
# 16 24 32 40
#3+2-1 = 4
#9-4+1 - 4
Problem p03085 (python)

Fixed submission:
s = input()
if s=='A':print('T')
elif s=='T':print('A')
elif s=='C':print('G')
elif s=='G':print('C')

Buggy submission (verdict: Runtime Error):
n, q = map(int, input().split())
s = input()
data = []
for i in range(q):data.append(list(map(int, input().split())))
for i in data:print(len(s[i[0]-1:i[1]].split('AC'))-1)
Problem p03210 (python)

Fixed submission:
x = int(input())
if x == 3 or x == 5 or x == 7:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
x = int(input())
if x == 3 or x == 5 or X == 7:
    print('YES')
else:
    print('NO')
Problem p03340 (python)

Fixed submission:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    x = 0
    s = 0
    r = 0
    res = 0
    for l in range(N):
        while N > r:
            if s & A[r] != 0: break
            s += A[r]
            r += 1

        s -= A[l]
        res += r - l

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

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split())
x=0
s=0
l=0
c=0
for r,b in enumerate(a):
  x^=b
  s+=b
  while x<s:
    x^=a[l]
    s-=a[l]
    l+=1
  c+=r-l+1
print(c)
Problem p03860 (python)

Fixed submission:
a, b, c = map(str, input().split())
print(a[0]+b[0]+c[0])

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
print(a[0]+b[0]+c[0])
Problem p02537 (python)

Fixed submission:
# Segment Treeを使う。一点更新，区間最大値

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

seglen = 1 << 19

segtree = [0 for _ in range(seglen * 2)]
# segtree[seglen + i] = Bの最後の値に i を使う時のlongest len

def segset(ind, val):
    segtree[ind] = val
    ind //= 2
    while ind != 0:
        segtree[ind] = max(segtree[ind*2], segtree[ind*2 + 1])
        ind //= 2
    return


def segmax(l, r):
    ret = 0

    while l < r:

        if l % 2 == 1:
            ret = max(ret, segtree[l])
            l += 1
        l //= 2

        if r % 2 == 1:
            ret = max(ret, segtree[r - 1])
            r -= 1
        r //= 2

    return ret

A = []
for _ in range(N):
    a = int(input())
    A.append(a)

ans = 0

for a in A:
    a_ind = seglen + a

    l = max(seglen, a_ind - K)
    r = min(seglen + 400000, a_ind + K + 1)

    longest = segmax(l, r)

    segset(a_ind, longest + 1)

    ans = max(ans, longest + 1)

print(ans)

Buggy submission (verdict: Runtime Error):
# Segment Treeを使う。一点更新，区間最大値

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

seglen = 1 << 19

segtree = [0 for _ in range(seglen * 2)]
# segtree[seglen + i] = Bの最後の値に i を使う時のlongest len

def segset(ind, val):
    segtree[ind] = val
    ind //= 2
    while ind != 0:
        segtree[ind] = max(segtree[ind*2], segtree[ind*2 + 1])
        ind //= 2
    return


def segmax(l, r):
    ret = 0

    while l < r:

        if l % 2 == 1:
            ret = max(ret, segtree[l])
            l += 1
        l //= 2

        if r % 2 == 1:
            ret = max(ret, segtree[r - 1])
            r -= 1
        r //= 2

    return ret

A = []
for _ in range(N):
    a = int(input())
    a -= 1
    A.append(a)

ans = 0

for a in A:
    a_ind = seglen + a

    l = max(seglen, a_ind - K)
    r = min(seglen + 4000000, a_ind + K + 1)

    longest = segmax(l, r)

    segset(a_ind, longest + 1)

    ans = max(ans, longest + 1)

print(ans)
Problem p02574 (python)

Fixed submission:
def gcc(x, y):
    if x == 0:return y
    return gcc(y % x, x)

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

g = 0

A.sort()

for item in A:
    g = gcc(g, item)

if g != 1:
    print("not coprime")
    exit()

primes = []

is_prime = [True] * 1100000

is_prime[0] = is_prime[1] = False

for i in range(2, 1100000):
    if not is_prime[i]:continue
    for j in range(i*i, 1100000, i):
        is_prime[j] = False

A_prime = [item for item in A if is_prime[item]]
A_notprime = [item for item in A if not is_prime[item]]

primes = [p for p in range(1100) if is_prime[p]]
used = [False] * 1100000

for item in A_prime:
    used[item] = True

for a in A_notprime:
    for p in primes:
        if a == 1:break
        if a % p != 0:continue

        if used[p]:
            print("setwise coprime")
            #互いに素でない（共通素因数pで割れる）ペアがAの中にあると，それはsetwise_coprime
            exit()

        used[p] = True

        while a % p == 0:
            a //= p

    if a > 1:
        if used[a]:
            print("setwise coprime")
            exit()
        used[a] = True


print("pairwise coprime")

Buggy submission (verdict: Runtime Error):
def gcc(x, y):
    if x == 0:return y
    return gcc(y % x, x)

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

g = 0

A.sort()

for item in A:
    g = gcc(g, item)

if g != 1:
    print("not coprime")
    exit()

primes = []

is_prime = [True] * 1100000
primes = []

is_prime[0] = is_prime[1] = False

for i in range(2, 1100000):
    if not is_prime[i]:continue
    for j in range(i*i, 1100000, i):
        is_prime[j] = False
    primes.append[i]

A_prime = [item for item in A if is_prime[item]]
A_notprime = [item for item in A if not is_prime[item]]

used = [False] * 1100000

for item in A_prime:
    used[item] = True

for a in A_notprime:
    for p in primes:
        if a == 1:break
        if a % p != 0:continue

        if used[p]:
            print("setwise coprime")
            #互いに素でない（共通素因数pで割れる）ペアがAの中にあると，それはsetwise_coprime
            exit()

        used[p] = True

        while a > p:
            a //= p

print("pairwise coprime")
Problem p02615 (python)

Fixed submission:
from collections import deque

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

A.sort(reverse=True)

a = deque(A)

arrival = 1
ans = 0

while arrival < N:
    score = a.popleft()
    if arrival == 1:
        ans += score
        arrival += 1
    else:
        ans += score*min(2, N - arrival)
        arrival += 2

print(ans)

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

a.sort(reverse=True)

arrival = 1
ans = 0

while arrival < N:
    score = a.popleft()
    if arrival == 1:
        ans += score
        arrival += 1
    else:
        ans += score*min(2, N - arrival)
        arrival += 2

print(ans)
Problem p02678 (python)

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

dist = [-1] * (N+1)
dist[1] = 0
connection = [[] for _ in range(N+1)]
ans = [-1] * (N+1)

for quel in range(M):
    a, b = map(int, input().split())
    connection[a].append(b)
    connection[b].append(a)

que = []
que.append(1)

while que:
    v = que.pop(0)

    for i in connection[v]:
        if dist[i] != -1:continue

        dist[i] = dist[v] + 1
        que.append(i)
        ans[i] = v

#print(dist)
print('Yes')
for j in range(2, N+1):
    print(ans[j])

Buggy submission (verdict: Runtime Error):
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra

N, M = map(int, input().split())
edge = np.array([input().split() for _ in range(M)], dtype = np.int64).T
ones = np.ones(M)
graph = csr_matrix((ones, (edge[:2] - 1)), (N, N))


distance_mat, processors = dijkstra(graph, directed = False, indices = 0, return_predecessors = True)

processors = processors + 1

'''
print ('点0からの最短距離')
print (distance_mat)


print ('各点の直前の点')
print (processors)
'''

print('Yes')
for i in range(1,N):
    print(processors[i])