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

Fixed submission:
n,d=map(int,input().split())
X=[[]*d for i in range(n)]
for i in range(n):
  X[i]=list(map(int,input().split()))
b=0
for i in range(n-1):
  for j in range(i+1,n):
    a=0
    for k in range(d):
      a=a+(X[i][k]-X[j][k])**2
      a=float(a)
    if a**(1/2)==int(a**(1/2)):
      b=b+1
print(b)

Buggy submission (verdict: Runtime Error):
N,D=map(int,input().split())
X = []
for i in range(N):
  X.append(input().split())
c=0
for n in range(0,N-1):
  for m in range(n+1,N):
    a=0
    for j in range(0,D):
      a=a+int((int(X[n][j])-(int(X[m][j])**2)
    if (int(a**(1/2)))**2==a:
      c=c+1
print(c)
Problem p02993 (python)

Fixed submission:
s=int(input())
a=s//1000
b=(s-a*1000)//100
c=(s-a*1000-b*100)//10
d=s-a*1000-b*100-c*10
if a==b :
    print("Bad")
elif b==c:
    print("Bad")
elif c==d:
    print("Bad")
else:
    print("Good")

Buggy submission (verdict: Runtime Error):
N,L=map(int, input().split())
if N+L-1<=0:
  print(int(L*(N-1)+N*(N-1)/2-N+1))
elif L>=0:
  print(int(L*(N-1)+N*(N+1)/2-1-N+1))
else :
  print(int(L*N+N*(N+1)/2-N))

Buggy submission (verdict: Runtime Error):
s=input()
a=s//1000
b=(s-a*1000)//100
c=(s-a*1000-b*100)//10
d=s-a*1000-b*100-c*10
if a==b :
    print"Bad"
    elif b==c:
        print"Bad"
    elif c==d:
        print"Bad"
else:
    print"Good"
Problem p02994 (python)

Fixed submission:
N,L=map(int, input().split())
if N+L-1<=0:
  print(int(L*(N-1)+N*(N-1)/2-N+1))
elif L>=0:
  print(int(L*(N-1)+N*(N+1)/2-1-N+1))
else :
  print(int(L*N+N*(N+1)/2-N))

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
L = list(map(int, input().split()))
B=sum(L)
count=1
if X>=B:
  print(len(L)+1)
else:
  i=0
  H=0
  while H<=X:
    H=H+L[i]
    i=i+1
  print(i)
Problem p03021 (python)

Fixed submission:
from collections import deque
n=int(input())
S=list(input())
G=[[] for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  G[a-1].append(b-1)
  G[b-1].append(a-1)
ans=10**10
AAA=10**10
for i in range(n):#根
  D=deque([i])
  A=[i]
  V=[0]*n
  V[i]=1
  C=[[] for i in range(n)]
  while len(D)>0:
    x=D[0]
    D.popleft()
    for j in range(len(G[x])):
      if V[G[x][j]]==0:
        V[G[x][j]]=1
        D.append(G[x][j])
        A.append(G[x][j])
        C[x].append(G[x][j])
  A=A[::-1]
  Ans=[[0]*3 for i in range(n)]
  for v in A:
    if len(C[v])==1:
      vc=C[v][0]
      Ans[v]=[Ans[vc][0],Ans[vc][1]+Ans[vc][2],Ans[vc][2]]
    elif len(C[v])!=0:
      L=[]
      LL=[]
      cc=0
      s=0
      M=0
      MM=0
      for vc in C[v]:
        m=Ans[vc][1]+Ans[vc][2]
        if m>M:
          M=m
          MM=Ans[vc][0]
        L.append(Ans[vc][1]+Ans[vc][2])
        LL.append(2*Ans[vc][0]+Ans[vc][1]+Ans[vc][2])
        cc=cc+Ans[vc][2]
        s=s+Ans[vc][0]
      if sum(LL)-M-2*MM>=M:
        ss=sum(L)//2
      else:
        ss=sum(LL)-M-2*MM-s+MM
      Ans[v]=[s+ss,sum(L)-2*ss,cc]
    if S[v]=="1":
      Ans[v][2]+=1
  if Ans[i][1]==0:
    if Ans[i][0]<ans:
      ans=Ans[i][0]
if ans==10**10:
  print(-1)
else:
  print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque
n=int(input())
S=list(input())
G=[[] for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  G[a-1].append(b-1)
  G[b-1].append(a-1)
ans=10**10
for i in range(n):#根
  D=deque([i])
  A=[i]
  V=[0]*n
  V[i]=1
  C=[[] for i in range(n)]
  while len(D)>0:
    x=D[0]
    D.popleft()
    for j in range(len(G[x])):
      if V[G[x][j]]==0:
        V[G[x][j]]=1
        D.append(G[x][j])
        A.append(G[x][j])
        C[x].append(G[x][j])
  A=A[::-1]
  Ans=[[0]*3 for i in range(n)]
  for v in A:
    if len(C[v])==1:
      vc=C[v][0]
      Ans[v]=[Ans[vc][0],Ans[vc][1]+Ans[vc][2],Ans[vc][2]]
    elif len(C[v])!=0:
      L=[]
      LL=[]
      cc=0
      s=0
      M=0
      for vc in C[v]:
        m=Ans[vc][1]+Ans[vc][2]
        if m>M:
          M=m
          MM=Ans[vc][0]
        L.append(Ans[vc][1]+Ans[vc][2])
        LL.append(2*Ans[vc][0]+Ans[vc][1]+Ans[vc][2])
        cc=cc+Ans[vc][2]
        s=s+Ans[vc][0]
      if sum(LL)-M-2*MM>=M:
        ss=sum(L)//2
      else:
        ss=sum(LL)-M-2*MM-s
      Ans[v]=[s+ss,sum(L)-2*ss,cc]
    if S[v]=="1":
      Ans[v][2]+=1
  if Ans[i][1]==0:
    if Ans[i][0]<ans:
      ans=Ans[i][0]
if ans==10**10:
  print(-1)
else:
  print(ans)
Problem p03032 (python)

Fixed submission:
from collections import deque
import itertools
n,k=map(int,input().split())
v=deque(list(map(int,input().split())))
a=0
ans=0
while a<=n and a<=k:
  w=deque(itertools.islice(v,0,None))
  b=0
  A=deque([0])
  for i in range(a):
    p=w.popleft()
    A.append(p)
  while a+b<=n and a+b<=k:
    x=deque(itertools.islice(w,0,None))
    B=deque(itertools.islice(A,0,None))
    for j in range(b):
      B.append(x.pop())
    B=deque(sorted(B))
    c=0
    while c<k-a-b and B[0]<0 and c<a+b:
      B.popleft()
      c=c+1
    V=sum(B)
    if V>ans:
      ans=V
    b=b+1
  a=a+1
print(ans)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
V=list(map(int,input().split()))
A=0
s=0
S=0
while A<=K:
  B=0
  while B<=K-A:
    C=0
    while (C<=K-A-B and C<=A+B):
      if A==0:
        s=0
      else:
        for i in range(A):
          s=s+V[i]
      if B==0:
        s=s
      else:
        for j in range(B):
          s=s+V[N-j-1]
      left=[]
      for k in range(A):
        left.append(V[k])
      right=[]
      for l in range(B):
        right.append(V[N-l-1])
      v=left+right
      v=sorted(v)
      for m in range(C):
        s=s-v[m]
      print(v)
      print(s)
      C=C+1
    B=B+1
  A=A+1
Problem p03037 (python)

Fixed submission:
N,M=map(int,input().split())
L=[0]*M
R=[0]*M
for i in range(M):
    L[i],R[i]=map(int,input().split())
a=L[0]
for i in range(M):
  if L[i]>a:
    a=L[i]
  else:
    a=a
b=R[0]
for i in range(M):
  if R[i]<b:
    b=R[i]
  else:
    b=b
if b-a<0:
  print("0")
else:
  print(b-a+1)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
L=[0]*M
R=[0]*M
for i in range(M):
    L[i],R[i]=map(int,input().split())
def quick_sort(arr):
    left = []
    right = []
    if len(arr) <= 1:
        return arr

    # データの状態に左右されないためにrandom.choice()を用いることもある。
    # ref = random.choice(arr)
    ref = arr[0]
    ref_count = 0

    for ele in arr:
        if ele < ref:
            left.append(ele)
        elif ele > ref:
            right.append(ele)
        else:
            ref_count += 1
    left = quick_sort(left)
    right = quick_sort(right)
    return left + [ref] * ref_count + right
L=quick_sort(L)
R=quick_sort(R)
a=L[M-1]
b=R[0]
if a>b:
  print("0")
else:
  print(b-a+1)
Problem p03065 (python)

Fixed submission:
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

sosuu=[2];n=int(input())
for L in range(3,n+100):
    chk=True
    for L2 in sosuu:
        if L%L2 == 0:chk=False
    if chk==True:sosuu.append(L)
S=set(sosuu)



A=[0]*(n+1)
g=0
for i in range(n+1):
  A[i]=int(input())
P=[]
PP=factorization(abs(A[0]))
for i in range(len(PP)):
  P.append(PP[i][0])
if P==[1]:
  P=[]
P=set(P)
P=S|P
P=list(P)
P.sort()
for i in range(len(P)):
  p=P[i]
  B=A[0:n+2]
  b=0
  for j in range(n+1):
    if p+j<n+1:
      B[j+p-1]=(B[j+p-1]+B[j])%p
    else:
      if B[j]%p!=0:
        b=1
        break
  if b==0:
    print(p)

Buggy submission (verdict: Runtime Error):
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

sosuu=[2];A=10000
for L in range(3,A):
    chk=True
    for L2 in sosuu:
        if L%L2 == 0:chk=False
    if chk==True:sosuu.append(L)
S=set(sosuu)



n=int(input())
A=[0]*(n+1)
g=0
for i in range(n+1):
  A[i]=int(input())
P=[]
PP=factorization(A[0])
for i in range(len(PP)):
  P.append(PP[i][0])
if P==[1]:
  P=[]
P=set(P)
P=S|P
P=list(P)
P.sort()
for i in range(len(P)):
  p=P[i]
  B=A[0:n+2]
  b=0
  for j in range(n+1):
    if p+j<n+2:
      B[j+p-1]=(B[j+p-1]+B[j])%p
    else:
      if A[j]%p!=0:
        b=1
        break
  if b==0:
    print(p)

Buggy submission (verdict: Runtime Error):
import copy
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

n=int(input())
A=[0]*(n+1)
for i in range(n+1):
  A[i]=int(input())
P=[]
PP=factorization(A[-1])
for i in range(len(PP)):
  P.append(PP[i][0])
print(P)
for i in range(len(P)):
  p=P[i]
  B=copy.copy(A)
  for j in range(n+1):
    if p+j<n+2:
      B[j+p-1]=(B[j+p-1]+B[j])%p
      print(B)
    else:
      print(B)
      if A[j]%p!=0:
        break
  print(p)
Problem p03112 (python)

Fixed submission:
import bisect
a,b,q=map(int,input().split())
A=[-10**11]
for i in range(a):
  A.append(int(input()))
A.append(10**11)
B=[-10**11]
for i in range(b):
  B.append(int(input()))
B.append(10**11)
for i in range(q):
  x=int(input())
  c=bisect.bisect_left(A,x,hi=len(A))
  d=bisect.bisect_left(B,x,hi=len(B))
  ans=min(abs(A[c-1]-x)+abs(B[d-1]-A[c-1]),abs(A[c-1]-x)+abs(B[d]-A[c-1]),abs(A[c]-x)+abs(B[d-1]-A[c]),abs(A[c]-x)+abs(B[d]-A[c]),abs(B[d-1]-x)+abs(B[d-1]-A[c-1]),abs(B[d-1]-x)+abs(B[d-1]-A[c]),abs(B[d]-x)+abs(B[d]-A[c-1]),abs(B[d]-x)+abs(B[d]-A[c]))
  print(ans)

Buggy submission (verdict: Runtime Error):
import bisect
a,b,q=map(int,input().split())
A=[-10**11]
for i in range(a):
  A.append(int(input()))
A.append(10**11)
B=[-10**11]
for i in range(b):
  B.append(int(input()))
B.append(10**11)
for i in range(q):
  x=int(input())
  c=bisect.bisect_left(A,x,hi=len(A))
  d=bisect.bisect_left(B,x,hi=len(A))
  ans=min(abs(A[c-1]-x)+abs(B[d-1]-A[c-1]),abs(A[c-1]-x)+abs(B[d]-A[c-1]),abs(A[c]-x)+abs(B[d-1]-A[c]),abs(A[c]-x)+abs(B[d]-A[c]),abs(B[d-1]-x)+abs(B[d-1]-A[c-1]),abs(B[d-1]-x)+abs(B[d-1]-A[c]),abs(B[d]-x)+abs(B[d]-A[c-1]),abs(B[d]-x)+abs(B[d]-A[c]))
  print(ans)
Problem p03270 (python)

Fixed submission:
def cmb(n,r):
  if n<0:
    return 0
  if n==0:
    if r!=0:
      return 0
    else:
      return 1
  elif r<0:
    return 0
  elif r>n:
    return 0
  elif r==0:
    return 1
  elif r==n:
    return 1
  else:
    return A[n]*B[r]*B[n-r]%mod
mod=998244353
A=[1,1]
B=[1,1]
for i in range(2,4005):
  A.append(A[-1]*i%mod)
  B.append(B[-1]*pow(i,mod-2,mod)%mod)
k,n=map(int,input().split())
if k==1:
  print(0)
  exit()
ans=[0]*(2*k+1)
for i in range(2,k+3):#i,i+1(i%2=0,i<k(くらい))で同じとか自明か？？？？？
  if i%2==0:
    i=i+1
    for j in range(min(n+1,i//2+1)):
      ans[i-1]=(ans[i-1]+cmb(n+k-i,k-i+j)*cmb(i//2,j)*pow(2,j,mod))%mod
  else:
    ans[i]=ans[i-1]
for i in range(k+2,2*k+1):
  ans[i]=ans[2*k+2-i]
for i in range(2,2*k+1):
  print(ans[i])

Buggy submission (verdict: Runtime Error):
def cmb(n,r):
  if n<=0:
    return 0
  elif r<0:
    return 0
  elif r>n:
    return 0
  elif r==0:
    return 1
  elif r==n:
    return 1
  else:
    return A[n]*B[r]*B[n-r]%mod
mod=998244353
A=[1,1]
B=[1,1]
for i in range(2,4005):
  A.append(A[-1]*i%mod)
  B.append(B[-1]*pow(i,mod-2,mod))
k,n=map(int,input().split())
ans=[0]*(2*k+1)
for i in range(2,k+3):#i,i+1(i%2=0,i<k(くらい))で同じとか自明か？？？？？
  if i%2==0:
    i=i+1
    for j in range(min(n+1,i//2+1)):
      ans[i-1]=ans[i-1]+cmb(n+k-i,k-i+j)*cmb(i//2,j)*pow(2,j,mod)
  else:
    for j in range(min(n+1,i//2+1)):
      ans[i]=ans[i]+cmb(n+k-i,k-i+j)*cmb(i//2,j)*pow(2,j,mod)

for i in range(k+2,2*k+1):
  ans[i]=ans[2*k+2-i]
for i in range(2,2*k+1):
  print(ans[i])

Buggy submission (verdict: Runtime Error):
def cmb(n,r):
  if n<=0:
    return 0
  elif r<0:
    return 0
  elif r>n:
    return 0
  elif r==0:
    return 1
  elif r==n:
    return 1
  else:
    return A[n]*B[r]*B[n-r]%mod
mod=998244353
A=[1,1]
B=[1,1]
for i in range(2,4005):
  A.append(A[-1]*i%mod)
  B.append(B[-1]*pow(i,mod-2,mod))
k,n=map(int,input().split())
ans=[0]*(2*k+1)
for i in range(2,k+3):#i,i+1(i%2=0,i<k(くらい))で同じとか自明か？？？？？
  if i%2==0:
    i=i+1
    for j in range(min(n+1,i//2+1)):
      ans[i-1]=ans[i-1]+cmb(n+k-i,k-i+j)*cmb(i//2,j)*pow(2,j,mod)
  else:
    for j in range(min(n+1,i//2+1)):
      ans[i]=ans[i]+cmb(n+k-i,k-i+j)*cmb(i//2,j)*pow(2,j,mod)

for i in range(k+2,2*k+1):
  ans[i]=ans[2*k+2-i]
for i in range(2,2*k+1):
  print(ans[i])
Problem p03569 (python)

Fixed submission:
s=list(input())
s1=[]
for i in range(len(s)):
  if s[i]!="x":
    s1.append(s[i])
s2=s1[::-1]
if s1!=s2:
  print(-1)
  exit()
if s1==[]:
  print(0)
  exit()
A1=[0]*10**5
A2=[0]*10**5
i=0
j=0
while i<=len(s1)//2:
  if s[j]=="x":
    A1[i]+=1
    j=j+1
  else:
    i=i+1
    j=j+1
i=0
j=0
while i<=len(s1)//2:
  if s[-1-j]=="x":
    A2[i]+=1
    j=j+1
  else:
    i=i+1
    j=j+1
ans=0
for i in range(10**5):
  ans=ans+abs(A1[i]-A2[i])
print(ans)

Buggy submission (verdict: Runtime Error):
s=list(input())
s1=[]
for i in range(len(s)):
  if s[i]!="x":
    s1.append(s[i])
s2=s1[::-1]
if s1!=s2:
  print(-1)
  exit()
A1=[0]*10**5
A2=[0]*10**5
i=0
j=0
while i<=len(s1)//2:
  if s[j]=="x":
    A1[i]+=1
    j=j+1
  else:
    i=i+1
    j=j+1
i=0
j=0
while i<=len(s1)//2:
  if s[-1-j]=="x":
    A2[i]+=1
    j=j+1
  else:
    i=i+1
    j=j+1
ans=0
for i in range(10**5):
  ans=ans+abs(A1[i]-A2[i])
print(ans)
Problem p03575 (python)

Fixed submission:
from collections import deque
n,m=map(int,input().split())
A=[[0]*2 for i in range(m)]
for i in range(m):
  A[i]=list(map(int,input().split()))
ans=0
for i in range(m):
  B=[[] for i in range(n)]
  for j in range(m):
    if j==i:
      continue
    B[A[j][0]-1].append(A[j][1]-1)
    B[A[j][1]-1].append(A[j][0]-1)
  C=[0]*n
  C[0]=1
  D=deque([0])
  while len(D)>0:
    x=D[0]
    D.popleft()
    for j in range(len(B[x])):
      if C[B[x][j]]==0:
        D.append(B[x][j])
        C[B[x][j]]=1
  if C!=[1]*n:
    ans=ans+1
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque
n,m=map(int,input().split())
A=[[0]*2 for i in range(n)]
for i in range(m):
  A[i]=list(map(int,input().split()))
ans=0
for i in range(m):
  B=[[] for i in range(n)]
  for j in range(m):
    if j==i:
      continue
    B[A[j][0]-1].append(A[j][1]-1)
    B[A[j][1]-1].append(A[j][0]-1)
  C=[0]*n
  C[0]=1
  D=deque([0])
  while len(D)>0:
    x=D[0]
    D.popleft()
    for j in range(len(B[x])):
      if C[B[x][j]]==0:
        D.append(B[x][j])
        C[B[x][j]]=1
  if C!=[1]*n:
    ans=ans+1
print(ans)
Problem p03826 (python)

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

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
a=0
b=0
for i in range(n-1):
  if s[i]=="I":
    a=a+1
    if a>b:
      b=a
  else:
    a=a-1
print(b)
Problem p03828 (python)

Fixed submission:
n=int(input())
if n==1:
  print("1")
else:
  import numpy as np
  
  def seachPrimeNum(N):
      max = int(np.sqrt(N))
      seachList = [i for i in range(2,N+1)]
      primeNum = []
      while seachList[0] <= max:
          primeNum.append(seachList[0])
          tmp = seachList[0]
          seachList = [i for i in seachList if i % tmp != 0]
      primeNum.extend(seachList)
      return primeNum
    
  f=len(seachPrimeNum(n))
  g=seachPrimeNum(n)
  c=1
  
  for j in range(f):
    e=g[j]
    a=0
    b=n
    h=0
    while b>=e:
      b=b//e
      h=h+b
      a=a+1
    c=c*(h+1)
  print(c%(10**9+7))

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

import numpy as np

def seachPrimeNum(N):
    max = int(np.sqrt(N))
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum

if n=1:
  print("1")
else:
  f=len(seachPrimeNum(n))
  g=seachPrimeNum(n)
  c=1
  
  for j in range(f):
    e=g[j]
    a=0
    b=n
    h=0
    while b>=e:
      b=b//e
      h=h+b
      a=a+1
    c=c*(h+1)
  print(c%(10**9+7))

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

import numpy as np

def seachPrimeNum(N):
    max = int(np.sqrt(N))
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum

f=len(seachPrimeNum(n))
g=seachPrimeNum(n)
c=1

for j in range(f):
  e=g[j]
  a=0
  b=n
  h=0
  while b>=e:
    b=b//e
    h=h+b
    a=a+1
  c=c*(h+1)
print(c%(10**9+7))
Problem p04014 (python)

Fixed submission:
def D(n,d):
  r=0
  while n>0:
    r=r+n%d
    n=n//d
  return r

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=int(input())
s=int(input())
if n-s==0:
  print(n+1)
  exit()
if s>n:
  print(-1)
  exit()

A=make_divisors(n-s)
for i in range(len(A)):
  if D(n,A[i]+1)==s:
    print(A[i]+1)
    exit()
print(-1)

Buggy submission (verdict: Runtime Error):
def D(n,d):
  r=0
  while n>0:
    r=r+n%d
    n=n//d
  return r

n=int(input())
s=int(input())
if n-s==0:
  print(n+1)
  exit()

A=[]
for i in range(1,int((n-s)**(1/2))+1):
  if (n-s)%i==0:
    A.append(i)
for i in range(len(A)):
  if D(n,A[i]+1)==s:
    print(A[i]+1)
    exit()
print(-1)

Buggy submission (verdict: Runtime Error):
def D(n,d):
  r=0
  while n>0:
    r=r+n%d
    n=n//d
  return r

n=int(input())
s=int(input())
if n-s==-1:
  print(n)
  exit()
A=[]
for i in range(1,int((n-s)**(1/2))+3):
  if (n-s)%i==0:
    A.append(i)
for i in range(len(A)):
  if D(n,A[i]+1)==s:
    print(A[i]+1)
    exit()
print(-1)

Buggy submission (verdict: Runtime Error):
def D(n,d):
  r=0
  while n>0:
    r=r+n%d
    n=n//d
  return r

n=int(input())
s=int(input())
A=[]
for i in range(1,int((n-s)**(1/2))+3):
  if (n-s)%i==0:
    A.append(i)
for i in range(len(A)):
  if D(n,A[i]+1)==s:
    print(A[i]+1)
    exit()
print(-1)
Problem p02784 (python)

Fixed submission:
r=input().split()
H=int(r[0])
N=int(r[1])
data_pre=input().split()
data=[int(s) for s in data_pre]
if sum(data)>=H:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
r=input().split()
H=int(r[0])
N=int(r[1])
data=[int(s) for s in input().split()]
data.sort()
Data=data[::-1]
if Data[0]+Data[1]>=H:
    print("Yes")
else:
    print("No")
Problem p03030 (python)

Fixed submission:
N=int(input())
data=[input().split() for i in range(N)]
data_name=[]
for i in range(N):
    if data[i][0] in data_name:
        continue
    else:
        data_name.append(data[i][0])
data_name_sort=sorted(data_name)
#print(data_name_sort)
data_point=[]
for i in range(N):
    num=0
    for j in range(len(data_name_sort)):
        if data[i][0]==data_name_sort[j]:
            num+=(len(data_name)-j)*200+int(data[i][1])
        else:
            continue
    data_point.append(num)
#print(data_point)
data_sort=[i for i, _ in sorted(enumerate(data_point), key=lambda x:x[1])][::-1]
#print(data_sort)
for i in range(N):
    ans=int(data_sort[i])+1
    print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
data=[input().split() for i in range(N)]
data_name=[]
for i in range(N):
    if data[i][0] in data_name:
        continue
    else:
        data_name.append(data[i][0])
data_name_sort=sorted(data_name)
data_point=[]
for i in range(N):
    num=0
    for j in range(len(data_name_sort)):
        if data[i][0]==data_name_sort[j]:
            num+=(len(data_name)-j)*200+int(data[i][1])
        else:
            continue
    data_point.append(num)
data_sort=[i for i, _ in sorted(enumerate(data_point), key=lambda x:x[1])][::-1]
for i in range(N):
    ans=int(data_sort(i))+1
    print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
data=[input().split() for i in range(N)]
data_name=[]
for i in range(N):
    if data[i][0] in data_name:
        continue
    else:
        data_name.append(data[i][0])
data_name_sort=sorted(data_name)
#print(data_name_sort)
data_point=[]
for i in range(N):
    num=0
    for j in range(len(data_name_sort)):
        if data[i][0]==data_name_sort[j]:
            num+=(len(data_name)-j)*200+int(data[i][1])
        else:
            continue
    data_point.append(num)
#print(data_point)
data_sort=[i for i, _ in sorted(enumerate(data_point), key=lambda x:x[1])][::-1]
#print(data_sort)
for i in range(N):
    ans=int(data_sort(i))+1
    print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
data_pre=[input().split() for i in range(N)]
data_name=[]
for i in range(N):
    if data[i][0] in data_name:
        continue
    else:
        data_name.append(data[i][0])
data_name_sort=sorted(data_name)
data_point=[]
for i in range(N):
    num=0
    for j in range(len(data_name_sort)):
        if data[i][0]==data_name_sort[j]:
            num+=(len(data_name)-j)*100+int(data[i][1])
        else:
            continue
    data_point.append(num)
data_sort=[i for i, _ in sorted(enumerate(data_point), key=lambda x:x[1])][::-1]
for i in range(N):
    ans=int(data_sort.index(i))+1
    print(ans)
Problem p03037 (python)

Fixed submission:
data=input().split()
N=int(data[0])
M=int(data[1])
data_gate=[input().split() for i in range(M)]
data_min=[]
data_max=[]
for i in range(M):
    data_min.append(int(data_gate[i][0]))
    data_max.append(int(data_gate[i][1]))
m=max(data_min)
M=min(data_max)
if M>=m:
    ans=M-m+1
else:
    ans=0
print(ans)

Buggy submission (verdict: Runtime Error):
r=input().split()
N=int(r[0])
M=int(r[1])
data=[[int(s) for s in input().split()] for i in range(M)]
left=[]
right=[]
for i in range(M):
    left.append(data[i][0])
    right.append(data[i][1])
if min(right)-max(left)+1=<0:
    print(0)
else:
    print(min(right)-max(left)+1)
Problem p02918 (python)

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

hikkuri = 0

for i in range(len(S) - 1):
    if S[i] != S[i + 1]:
        hikkuri += 1

shiawase = len(S) - hikkuri - 1

for i in range(K):
    if hikkuri >= 2:
        shiawase += 2
        hikkuri -= 2
    elif hikkuri == 1:
        shiawase += 1
        break

print(shiawase)

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

hikkuri = 0

for i in range(len(S) - 1):
    if S[i] != S[i + 1]:
        hikkuri += 1

shiawase = len(S) - hikkuri - 1

for i in range(K):
    if hikkuri >= 2:
        shiawase += 2
        hikkuri -= 2
    elif hikkuri == 1:
        shiawase += 1
        break

print(shiawase)N, K = map(int, input().split())
S = list(input())

hikkuri = 0

for i in range(len(S) - 1):
    if S[i] != S[i + 1]:
        hikkuri += 1

shiawase = len(S) - hikkuri - 1

for i in range(K):
    if hikkuri >= 2:
        shiawase += 2
        hikkuri -= 2
    elif hikkuri == 1:
        shiawase += 1
        break

print(shiawase)
Problem p02969 (python)

Fixed submission:
r = int(input())
print(3*r*r)

Buggy submission (verdict: Runtime Error):
r = int(input())
print(3*a*a)
Problem p03061 (python)

Fixed submission:
from fractions import gcd

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

L = [0 for _ in range(N+1)]
R = [0 for _ in range(N+1)]


for i in range(N):
    L[i+1] = gcd(L[i], A[i])

for i in reversed(range(N)):
    R[i] = gcd(R[i+1], A[i])

M = [0 for _ in range(N)]

for i in range(N):
    M[i] = gcd(L[i], R[i+1])

print(max(M))

Buggy submission (verdict: Runtime Error):
# from fractions import gcd
from math import gcd

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

L = [0 for _ in range(N+1)]
R = [0 for _ in range(N+1)]


for i in range(N):
    L[i+1] = gcd(L[i], A[i])

for i in reversed(range(N)):
    R[i] = gcd(R[i+1], A[i])

M = [0 for _ in range(N)]

for i in range(N):
    M[i] = gcd(L[i], R[i+1])

print(max(M))