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

Fixed submission:
N=int(input())
count=0
for i in range(N+1):
    if i%2==1:
        count+=1

print(count/N)

Buggy submission (verdict: Runtime Error):
import math

divisor=[1]
stack=[]
#eiclidean algorithm
A,B=map(int,input().split())
p=max(A,B)
q=min(A,B)
int2=0
gcd=0
while True:
    int2=p%q
    if int2==0:
        gcd=q
        break
    else:
        p=q
        q=int2

stack.append(gcd)
for i in range(2,math.ceil(math.sqrt(gcd))+1):
    if gcd%i==0:
        p=gcd//i
        stack.append(p)
        for x in divisor:
            if i%x==0 and x!=1:
                break
        else:
            divisor+=[i]

while len(stack)!=0:
    p=stack.pop()
    for x in divisor:
        if i%x==0 and x!=1:
            break
    else:
        divisor+=[p]


print(len(divisor))

Buggy submission (verdict: Runtime Error):
import math

divisor=[1]
stack=[]
#eiclidean algorithm
A,B=map(int,input().split())
p=max(A,B)
q=min(A,B)
int2=0
gcd=0
while True:
    int2=p%q
    if int2==0:
        gcd=q
        break
    else:
        p=q
        q=int2

stack.append(gcd)
for i in range(2,math.ceil(math.sqrt(gcd))+1):
    if gcd%i==0:
        p=gcd//i
        stack.append(p)
        for x in divisor:
            if i%x==0 and x!=1:
                break
        else:
            divisor+=[i]

while len(stack)!=0:
    p=stack.pop()
    for x in divisor:
        if i%x==0 and x!=1:
            break
    else:
        divisor+=[p]


print(len(divisor))
Problem p02881 (python)

Fixed submission:
n=int(input())

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
p=make_divisors(n)

l=len(p)
if l%2==1:
  ans=p[l-1]*2-2
  
else:
  ans=p[l-1]+p[l-2]-2
  
print(ans)

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

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
p=make_divisors(n)

l=len(p)
if l%2==1:
  ans=p[l-1]*2-2
  
else:
  ans=p[l-1]+p[l-2]-2
  
print(ans)
Problem p02933 (python)

Fixed submission:
a=int(input())
s=input()

if a>=3200:
  print(s)
else:
  print('red')
#L=list(map(int,input().split()))
#a,b=map(int,input().split())
#A=[[0 for i in range()] for j in range()]
#l = [int(input()) for i in range(N)]

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

if a>=3200:
  print(s)
else:
  print('red')
#L=list(map(int,input().split()))
#a,b=map(int,input().split())
#A=[[0 for i in range()] for j in range()]
#l = [int(input()) for i in range(N)]
Problem p02954 (python)

Fixed submission:
s=list(input())
r=0
l=0
ans=[]
for i,x in enumerate(s):
  if s[i]=='R':
    if s[i-1]=='L'and i>0:
      migi=(r+1)//2+l//2
      hidari=r//2+(l+1)//2
      ans+=[0]*(r-1)+[migi,hidari]+[0]*(l-1)
      r=1
      l=0
    else:r+=1
  else:
    l+=1
migi=(r+1)//2+l//2
hidari=r//2+(l+1)//2
ans+=[0]*(r-1)+[migi,hidari]+[0]*(l-1)
    
print(*ans)

Buggy submission (verdict: Runtime Error):
s=list(map(input().split()))

ans=[]
Problem p02984 (python)

Fixed submission:
n=int(input())
L=list(map(int,input().split()))
ans=[0 for i in range(n)]

L=[i*2 for i in L]

m=n//2
a=L[m]

for i in range(1,(n+1)//2):
  a=L[m-i]+L[m+i]-a

ans[0]=a//2

for i in range(1,n):
  ans[i]=L[i-1]-ans[i-1]

print(*ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
L=list(map(int,input().split()))
ans=[0 for i in range(n)]

L=[i for i in L]


m=n//2
a=L[m]

for i in range(1,(n+1)/2):
  a=L[m-i]+L[m+1]-a

ans[0]=a/2

for i in range(1,n):
  ans[i]=L[i]-ans[i-1]
  
print(ans)
Problem p02987 (python)

Fixed submission:
s=list(input())
a=s[0]
b=s[1]
c=s[2]
d=s[3]


if a==b and c==d and a!=c:
  print('Yes')
elif a==c and b==d and a!=b:
  print('Yes')
elif a==d and c==b and a!=c:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())

a=n-k+1

for i in range(1,k+1):
  print(a)
  a=a*(n-k+1-i)*(k-i)//((i+1)*i)%1000000007

Buggy submission (verdict: Runtime Error):
n=int(input())
L=list(map(int,input().split()))
L.sort
d=L[int(n/2)-1]-L[int(n/2)]


print(d)
Problem p02989 (python)

Fixed submission:
n=int(input())
L=list(map(int,input().split()))
L.sort()
d=L[n//2]-L[n//2-1]

print(d)

Buggy submission (verdict: Runtime Error):
n=int(input())
L=list(map(int,input().split()))
L.sort
d=L[int(n/2)+1]-L[int(n/2)]


print(d)

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

d=L[int(n/2)+1]-L[int(n/2)]


print(d)

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

d=L[n/2+1]-L[n/2]


print(d)
Problem p03011 (python)

Fixed submission:
p,q,r=map(int,input().split())

ans=[p+q,q+r,r+p]
print(min(ans))

Buggy submission (verdict: Runtime Error):
MOD=10**9+7
n,m=map(int,input().split())
A=[1 for i in range(n)]
if n!=1:
  A[1]=2
  for i in range(m):
    A[int(input())-1]=0
  
  if A[0]==0 and A[1]!=0:
    A[1]=1


  for i in range(2,n):
    if A[i]!=0:
      A[i]=(A[i-1]+A[i-2])
      A[i]%=MOD

    
  print(A[n-1])
  
else:print(1)
Problem p03013 (python)

Fixed submission:
MOD=10**9+7
n,m=map(int,input().split())
A=[1 for i in range(n)]
if n!=1:
  A[1]=2
  for i in range(m):
    A[int(input())-1]=0
  
  if A[0]==0 and A[1]!=0:
    A[1]=1



  for i in range(2,n):
    if A[i]!=0:
      A[i]=(A[i-1]+A[i-2])
      A[i]%=MOD

    
  print(A[n-1])
  
else:print(1)

Buggy submission (verdict: Runtime Error):
=10**9+7
n,m=map(int,input().split())
A=[1 for i in range(n)]
if n!=1:
  A[1]=2
  for i in range(m):
    A[int(input())-1]=0
  
  if A[0]==0 and A[1]!=0:
    A[1]=1



  for i in range(2,n):
    if A[i]!=0:
      A[i]=(A[i-1]+A[i-2])
      A[i]%=MOD

    
  print(A[n-1])

Buggy submission (verdict: Runtime Error):
MOD=10**9+7
n,m=map(int,input().split())
A=[1 for i in range(n)]
A[1]=2
for i in range(m):
  A[int(input())-1]=0
if A[0]==0:
  A[1]=1


for i in range(2,n):
  if A[i]!=0:
    A[i]=(A[i-1]+A[i-2])
    A[i]%=MOD
    
    
print(A[n-1])

Buggy submission (verdict: Runtime Error):
MOD=10**9+7
n,m=map(int,input().split())
A=[1 for i in range(n)]
A[1]=2
for i in range(m):
  A[int(input())-1]=0
if A[0]==0:
  A[1]=1


for i in range(2,n):
  if A[i]!=0:
    A[i]=(A[i-1]+A[i-2])
    A[i]%=MOD
    
    
print(A)

Buggy submission (verdict: Runtime Error):
MOD=1000000007
n,m=map(int,input().split())
A=[1 for i in range(n)]
A[1]=2
for i in range(m):
  A[int(input())-1]=0
  


for i in range(2,n):
  if A[i]!=0:
    A[i]=(A[i-1]+A[i-2])%MOD
    
    
print(A[n-1])
Problem p03036 (python)

Fixed submission:
r,d,x=map(int,input().split())

for i in range(10):
  x= x*r-d
  print(x)

Buggy submission (verdict: Runtime Error):
r,d,x=int(input().split())

for i in range(11):
  x= x*r-d
  print(x)
Problem p03042 (python)

Fixed submission:
s=int(input())
x=s//100
y=s-x*100




if x>0 and x<13:
  if y>0 and y<13:
    print("AMBIGUOUS")
  else:
    print("MMYY")
     
else:
  if y>0 and y<13:
    print("YYMM")
  else:
    print("NA")

Buggy submission (verdict: Runtime Error):
s=int(input())
x=s//100
y=s-x*100

if x*y=0:
  print("NA")

else:
  if x<13:
    if y<13:
      print("AMBIGUOUS")
    else:
      print("MMYY")
     
  else:
    if y<13:
      print("YYMM")
    else:
      print("NA")
Problem p03075 (python)

Fixed submission:
import sys
L=[0 for i in range(5)]
for i in range(5):
  L[i]=int(input())
  
k=int(input())

for i in range(4):
  for j in range(i+1,5):
    if L[j]-L[i]>k:
      print(':(')
      sys.exit()
  
    if i==2 and j==3:
      print('Yay!')

Buggy submission (verdict: Runtime Error):
for i in range(5):
  L[i]=int(input())
  
k=int(input())

for i in range(4):
  if L[i+1]-L[i]>k:
    print(':(')
    break
  
  if i==3:
    print(Yay!)

Buggy submission (verdict: Runtime Error):
for i in range(5):
  L[i]=int(input())
  
k=int(input())

for i in range(4):
  if L[i+1]-L[i]>k:
    print(':(')
    break
  
  if i=3:
    print(Yay!)
Problem p03107 (python)

Fixed submission:
s=input()
l=len(s)
a=[0 for i in range(l)]

for i in range(l):
  a[i]=int(s[i])
  
ichi=0
zero=0

for i in range(l):
  if a[i]==1:
    ichi+=1
  else:
    zero+=1
    
print(2*min(ichi,zero))

Buggy submission (verdict: Runtime Error):
s=input()
l=len(s)
a=[0 for i in range(l)]

for i in range(l):
  a[i]=int(s[i])
  
ichi=0
zero=0

for i in range(l):
  if a[i]==1:
    ichi+=1
  else:
    zero+=1
    
print(2*min(ichi.zero))
Problem p03137 (python)

Fixed submission:
n,m=map(int,input().split())
L=list(map(int,input().split()))
L.sort()
if n>=m:
  print(0)
elif m!=1:

  d=[L[i+1]-L[i] for i in range(m-1)]
  d.sort()
  d.reverse()
  ans=L[-1]-L[0]


  ans-=sum(d[:n-1])
  print(ans)
  

else:
  print(0)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
L=list(map(int,input().split()))
L.sort()
if n>=m:
  print(0)
elif m!=1:

  d=[[L[i+1]-L[i],i] for i in range(m-1)]
  d.sort()
  d.reverse()
  ans=L[m-1]-L[0]

  for i in range(n-1):
    a=d[i][1]
    d[a]=0
    ans-=(L[a+1]-L[a])
  print(ans)
  

else:
  print(0)

Buggy submission (verdict: Runtime Error):

n,m=map(int,input().split())
L=list(map(int,input().split()))
L.sort()
if m!=1:

  d=[[L[i+1]-L[i],i] for i in range(m-1)]
  d.sort()
  d.reverse()
  ans=L[m-1]-L[0]

  for i in range(n-1):
    a=d[i][1]
    d[a]=0
    ans-=(L[a+1]-L[a])
  print(ans)
  

else:
  print(0)

Buggy submission (verdict: Runtime Error):

n,m=map(int,input().split())
L=list(map(int,input().split()))
L.sort()
if m!=1:

  d=[[L[i+1]-L[i],i] for i in range(m-1)]
  d.sort()
  d.reverse()
  ans=L[m-1]-L[0]

  for i in range(n-1):
    a=d[i][1]
    print(a)
    d[a]=0
    ans-=(L[a+1]-L[a])
  print(ans)
  

else:
  print(0)

Buggy submission (verdict: Runtime Error):

n,m=map(int,input().split())
L=list(map(int,input().split()))
L.sort()

#d=np.array([L[i+1]-L[i] for i in range(m-1)])
d=[L[i+1]-L[i] for i in range(m-1)]
ans=L[m-1]-L[0]

for i in range(n-1):
  #a=np.argmax(d)
  a=d.index(max(d))
  d[a]=0
  ans-=(L[a+1]-L[a])
  




print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
n,m=map(int,input().split())
L=list(map(int,input().split()))
L.sort()

d=np.array([L[i+1]-L[i] for i in range(m-1)])

ans=L[m-1]-L[0]

for i in range(n-1):
  a=np.argmax(d)
  d[a]=0
  ans-=(L[a+1]-L[a])
  




print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
n,m=map(int,input().split())
L=list(map(int,input().split()))
L.sort()

d=np.array([L[i+1]-L[i] for i in range(m-1)])

ans=L[m-1]-L[0]

for i in range(n-1):
  a=np.argmax(d)
  d[a]=0
  ans-=(L[a+1]-L[a])
  




print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
n,m=map(int,input().split())
L=list(map(int,input().split()))
L.sort()

d=np.array([L[i+1]-L[i] for i in range(m-1)])
ans=L[m-1]-L[0]

for i in range(n-1):
  a=argmax(d)
  ans-(L[a+1]-L[a])
  d[a]=0
  




print(ans)
Problem p03013 (python)

Fixed submission:
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
base = 1000000007

x = [0] * (N+1)
x[0] = 1
ai = 0
if ai >= M or 1 != a[ai]:
    x[1] = x[0]
else:
    ai += 1
for i in range(2, (N+1)):
    if ai >= M or i != a[ai]:
        x[i] = (x[i-1] + x[i-2]) % base
    else:
        ai += 1
print(x[N])

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
base = 1_000_000_007

x = [0] * (N+1)
x[0] = 1
ai = 0
if ai >= M or 1 != a[ai]:
    x[1] = x[0]
else:
    ai += 1
for i in range(2, (N+1)):
    if ai >= M or i != a[ai]:
        x[i] = (x[i-1] + x[i-2]) % base
    else:
        ai += 1
print(x[N])
Problem p03015 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7


def f(index, l):
    if index == len(l):
        return 1
    if l[index] == '1':
        return ( 3 ** (len(l)-1-index) + 2 * f(index+1, l) ) % MOD
    else:
        return f(index+1, l) % MOD


def main():
    l = input()
    n = len(l)
    one = 0
    ans = 0
    for i in range(n):
        if l[i] == '1':
            ans += pow(2, one, MOD) * pow(3, n-1-i, MOD)
            ans %= MOD
            one += 1
    ans += pow(2, one, MOD)
    ans %= MOD
    print(ans)

main()

Buggy submission (verdict: Runtime Error):
MOD = 10 ** 9 + 7


def f(index, l):
    if index == len(l):
        return 1
    if l[index] == '1':
        return (3 ** (len(l)-1-index) + 2 * f(index+1, l) ) % MOD
    else:
        return f(index+1, l) % MOD


def main():
    l = input()
    print(f(0, l))

main()
Problem p03038 (python)

Fixed submission:
import sys
input = sys.stdin.readline
N,M = map(int, input().split())
A = list(map(int, input().split()))  # -> li = [1,2,3,...n]
C = [[0,0] for _ in range(M)]
for i in range(M):
    b,c = map(int, input().split())
    C[i][0] = c
    C[i][1] = b
A = sorted(A, reverse=True)
C = sorted(C, reverse=True)
cnt = 0
s = 0
ai = 0
ci = 0
while cnt < N:
    aa = A[ai]
    if ci >= M:
        cc = 0
    else:
        cc = C[ci][0]
    if aa > cc:
        s += aa
        ai += 1
    else:
        s += cc
        C[ci][1] -= 1
        if C[ci][1] == 0:
            ci += 1
    cnt += 1
print(s)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N,M = map(int, input().split())
A = list(map(int, input().split()))  # -> li = [1,2,3,...n]
C = [[0,0] for _ in range(M)]
for i in range(M):
    b,c = map(int, input().split())
    C[i][0] = c
    C[i][1] = b
A = sorted(A, reverse=True)
C = sorted(C, reverse=True)
cnt = 0
s = 0
ai = 0
ci = 0
while cnt < N:
    aa = A[ai]
    cc = C[ci][0]
    if aa > cc:
        s += aa
        ai += 1
    else:
        s += cc
        C[ci][1] -= 1
        if C[ci][1] == 0:
            ci += 1
    cnt += 1
print(s)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N,M = map(int, input().split())
A = list(map(int, input().split()))  # -> li = [1,2,3,...n]
C = [[0,0] for _ in range(M)]
for i in range(M):
    b,c = map(int, input().split())
    C[i][0] = c
    C[i][1] = b
A = sorted(A, reverse=True)
C = sorted(C, reverse=True)
cnt = 0
s = 0
ai = 0
ci = 0
while cnt < N:
    aa = A[ai]
    cc = C[ci][0]
    if aa > cc:
        s += aa
        ai += 1
    else:
        s += cc
        C[ci][1] -= 1
        if C[ci][1] == 0:
            ci += 1
    cnt += 1
print(s)
Problem p03053 (python)

Fixed submission:
h,w= map(int, input().split())
a = []
x = []
for i in range(h):
    li = input()
    aa = []
    for j in range(w):
        aa.append(li[j])
        if aa[j] == '#':
            x.append((i, j))
    a.append(aa)
ans = 0
while True:
    xx = []
    for p in x:
        pp = [(p[0]-1, p[1]), (p[0]+1, p[1]), (p[0], p[1]-1), (p[0], p[1]+1)]
        for ppp in pp:
            if (0 <= ppp[0] < h) and (0 <= ppp[1] < w):
                if a[ppp[0]][ppp[1]] == '.':
                    a[ppp[0]][ppp[1]] = '#'
                    xx.append((ppp[0], ppp[1]))
    x = xx
    if len(x) == 0:
        break
    ans += 1
    # print(x)
print(ans)

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
q = []
a = {}
for i in range(H):
    l = input()
    for j in range(W):
        a[j, i] = l[j]
        if l[j] == '#':
            q.append((i,j))
ans = 0
for i in range(100000000):
    if len(q) == 0:
        break
    ans+=1
    tq = []
    for qq in q:
        if qq[0] > 0:
            if a[qq[0]-1, qq[1]] == '.':
                a[qq[0] - 1, qq[1]] = '#'
                tq.append((qq[0] - 1, qq[1]))
        if qq[0] < (W-1):
            if a[qq[0]+1, qq[1]] == '.':
                a[qq[0] + 1, qq[1]] = '#'
                tq.append((qq[0] + 1, qq[1]))
        if qq[1] > 0:
            if a[qq[0], qq[1]-1] == '.':
                a[qq[0], qq[1]-1] = '#'
                tq.append((qq[0], qq[1]-1))
        if qq[1] < (H-1):
            if a[qq[0], qq[1]+1] == '.':
                a[qq[0], qq[1]+1] = '#'
                tq.append((qq[0], qq[1]+1))
    q = tq
print(ans-1)

Buggy submission (verdict: Runtime Error):
h,w= map(int, input().split())
a = []
for i in range(h):
    li = input()
    a.append(li)
t = []
for i in range(h):
    t.append([-1]*w)
x = []
for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            t[i][j] = 0
            x.append((i,j))
ans = 0
y = ans
while True:
    # print("ans"+str(ans))
    y += 1
    xx = []
    for p in x:
        pp = [(p[0]-1, p[1]), (p[0]+1, p[1]), (p[0], p[1]-1), (p[0], p[1]+1)]
        for ppp in pp:
            if (0 <= ppp[0] < w) and (0 <= ppp[1] < h):
                if t[ppp[0]][ppp[1]] == -1:
                    t[ppp[0]][ppp[1]] = ans
                    xx.append((ppp[0], ppp[1]))
    x = xx
    if len(x) == 0:
        break
    ans += 1
    # print(x)
print(ans)
Problem p03077 (python)

Fixed submission:
n=int(input())
li = [int(input()) for _ in range(5)]  # li = ['hoge', 'bar', 'foo']

li.sort()
m = li[0]
ans = 0
if n % m == 0:
    ans += n//m
else:
    ans += n//m + 1
ans += 4
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
li = [int(input()) for _ in range(n)]  # li = ['hoge', 'bar', 'foo']

m = li.sort()[0]
ans = 0
if n % m == 0:
    ans += n//m
else:
    ans += n//m + 1
ans += 4
print(ans)
Problem p02881 (python)

Fixed submission:
N = int(input())

ans_lis = []
for i in range(1,10**7):
    if N%i==0:
        ans_lis.append(i+(N//i))
print(min(ans_lis)-2)

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

ans_lis = []
for i in range(1,10**6):
    if N%i==0:
        ans_lis.appe
        nd(i+(N//i))
print(min(ans_lis)-2)
Problem p02891 (python)

Fixed submission:
import re

def nchars(s, n):
    """文字列 s に、同じ文字が n 個以上連続している部分文字列を見つける
    """
    assert n > 0
    reg = re.compile("(.)\\1{%d,}" % (n - 1))  # カンマを取ると n 個ちょうどになる
    while True:
        m = reg.search(s)
        if not m:
            break
        yield m.group(0)
        s = s[m.end():]

S = input()
K = int(input())

con = list(nchars(S, 1))
#print(con)
if len(con)==1:
    print(int(len(S)*K/2))

else:
    cons = []
    for coni in con:
        cons.append(int(len(coni)/2))

    c1 = cons[0]

    c2 = 0
    for i in range(len(cons)):
        if i != 0 and i != len(cons)-1:
            c2 += cons[i]

    if con[0][0]==con[-1][0]:
        c3 = int(len(con[0]+con[-1])/2)
    else:
        c3 = int(len(con[0])/2) + int(len(con[-1])/2)

    c4 = int(cons[-1])

    print(int(c1 + c2*K + c3 *(K-1) + c4))

Buggy submission (verdict: Runtime Error):
import re

def nchars(s, n):
    """文字列 s に、同じ文字が n 個以上連続している部分文字列を見つける
    """
    assert n > 0
    reg = re.compile("(.)\\1{%d,}" % (n - 1))  # カンマを取ると n 個ちょうどになる
    while True:
        m = reg.search(s)
        if not m:
            break
        yield m.group(0)
        s = s[m.end():]

S = input()
K = int(input())

con = list(nchars(S, 1))
#print(con)
if len(con)==1:
    print(int(len(S*K)/2))

else:
    cons = []
    for coni in con:
        cons.append(int(len(coni)/2))

    c1 = cons[0]

    c2 = 0
    for i in range(len(cons)):
        if i != 0 and i != len(cons)-1:
            c2 += cons[i]

    if con[0][0]==con[-1][0]:
        c3 = int(len(con[0]+con[-1])/2)
    else:
        c3 = int(len(con[0])/2) + int(len(con[-1])/2)

    c4 = int(cons[-1])

    print(int(c1 + c2*K + c3 *(K-1) + c4))

Buggy submission (verdict: Runtime Error):
import re

def nchars(s, n):
    """文字列 s に、同じ文字が n 個以上連続している部分文字列を見つける
    """
    assert n > 0
    reg = re.compile("(.)\\1{%d,}" % (n - 1))  # カンマを取ると n 個ちょうどになる
    while True:
        m = reg.search(s)
        if not m:
            break
        yield m.group(0)
        s = s[m.end():]

S = input()
K = int(input())

con = list(nchars(S, 2))
cons = []
for coni in con:
    cons.append(int(len(coni)/2))

c1 = cons[0]

c2 = 0
for i in range(len(cons)):
    if i != 0 and i != len(cons)-1:
        c2 += consi[i]

c3 = int(cons[0]+cons[len(cons)-1])/2

c4 = int(cons[len(cons)-1])

print(int(c1 + c2*K + c3 *(K-1) + c4))
Problem p02990 (python)

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

def make_comb_dp(n):
    dp = [[0] * (n + 1) for i in range(n + 1)]
    for i in range(n + 1):
        dp[i][0] = 1
        dp[i][i] = 1
    for i in range(2, n + 1):
        for j in range(1, i):
            dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j]
    return dp

nCk = make_comb_dp(2000)
for i in range(1, K+1):
    print(int(nCk[N-K+1][i]*nCk[K-1][i-1])%(10 ** 9 + 7))

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

def binomial_coeffs1(n, k):
    #top down DP
    if (k == 0 or k == n):
        return 1
    if (memo[n][k] != -1):
        return memo[n][k]

    memo[n][k] = binomial_coeffs1(n-1, k-1) + binomial_coeffs1(n-1, k)
    return memo[n][k]

memo = [[-1 for i in range(2010)] for j in range(2010)]
for i in range(1, K+1):
    print(binomial_coeffs1(N-K+1, i)*binomial_coeffs1(K-1, i-1))
Problem p02880 (python)

Fixed submission:
x = int(input())

tmp = []

for i in range(1,10):
  for l in range(1,10):
    tmp.append(i*l)

cnt = 0
    
for n in tmp:
  if n == x:
    cnt += 1
    
if cnt == 0:
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):

tmp = []

for i in range(1,10):
  for l in range(1,10):
    tmp.append(i*l)

cnt = 0
    
for n in tmp:
  if n == x:
    cnt += 1
    
if cnt == 0:
  print("No")
else:
  print("Yes")
Problem p03805 (python)

Fixed submission:
N,M = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(M)]

adj = [[] for _ in range(N)]
for a,b in ab:
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)
    

def dfs(x,s,flags):
    vlist = adj[x]
    flags = list(flags)
    flags[x] = False
    flags = tuple(flags)
    if sum(flags) == 0:
        return 1
    s = 0
    for v in vlist:    
        if flags[v]:
            s += dfs(v,s,flags)
    return s        

Flag = [True] * N
Flag[0] = False
ans = dfs(0,0,tuple(Flag))
print(ans)

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

for i in x:
  y[int(i[0])-1].append(int(i[1])-1)
  y[int(i[1])-1].append(int(i[0])-1)

tmp = y[0]
ans = 0
cnt = 0

while True:
  if cnt != N - 1:
    tmp2 = []
    for l in tmp:
      if z[l] == 0:
        z[l] += 1
        for n in y[l]:
          tmp2.append(n)
    tmp = tmp2
    cnt += 1
  else:
    ans = len(tmp)
    break

print(ans)
Problem p02881 (python)

Fixed submission:
n = int(input())

divs = []

for i in range(1, int(n**0.5)+1):
  if n % i == 0:
      divs.append(i)
      divs.append(n // i)

max = len(divs) -1
print(divs[max] + divs[max-1] - 2)

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

divs = []

for i in range(m):
  if i == 0:
    continue
  mod = n % i
  if mod == 0:
    an = int(n/i)
    if i <= an:
      divs.append(i)
      divs.append(an)
    else:
      break

max = len(divs) -1
print(divs[max] + divs[max-1] - 2)
Problem p02912 (python)

Fixed submission:
# 最小金額を求める
# 一番高い商品に割引を適用して半額（小数点以下切り捨て）にする作業の繰り返し
# 問題詳細：https://atcoder.jp/contests/abc141/tasks/abc141_d
# 優先度付きキューを利用する
import heapq

def main():
  n, m = map(int, input().split())
  a = list(map(int, input().split()))
  pq = to_priorityqueue(a)
  pq = use_ticket(pq, m)
  print(-sum(pq))


# 優先度付きキューを作成
# heapqモジュールを利用
# pythonのheapqの場合、pop(取り出し)を行った際に最小のものから取り出される
# 今回は大きい順に取り出して利用したいため、-1を掛けてpushする（最大の値が最小になる）
def to_priorityqueue(list):
  rtn = []
  for el in list:
    heapq.heappush(rtn, -el)
  return rtn

# チケットの利用（割引の適用）
# チケットがなくなるまで、その時点で最も価格が高い商品にわりびきを適用する
# 最大まで割引を適用した結果できたキューを返す
def use_ticket(pq, t_num):
  while t_num and pq:
    el = -(heapq.heappop(pq))
    el //= 2
    heapq.heappush(pq, -el)
    t_num -= 1
  return pq

if __name__ == "__main__":
  main()

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = map(int, input().split())
a = sorted(a)
a.reverse()
min_sum = 0
ti = 0
if m % 2 == 1:
  ti = m // 2 + 1
else:
  ti = m // 2

for _a in a:
  if m > 0:
    min_sum += _a // (2 ** ti)
    ti -= 1
  else:
    min_sum += _a

print(min_sum)