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

Fixed submission:
n,m=map(int,input().split())

AC=[0]*n
WA=[0]*n

for i in range(m):
    t=input().split()
    p, s= int(t[0]), t[1]
    if s=='AC':
        AC[p-1]=1
    elif s=='WA' and AC[p-1]==0:
        WA[p-1]+=1

ac, wa=0,0

for i in range(n):
    if AC[i]:
        ac+=1
        wa+=WA[i]

print(ac, wa)

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

AC=[0]*n
WA=[0]*n

for i in range(m):
    t=input().split()
    p, s= int(t[0]), t[1]
    if s=='AC':
        AC[p-1]=1
    elif s=='WA' and AC[p-1]==0:
        WA[p-1]+=1

ac, wa=0,0

for i in range(n):
    if AC[i]:
        ac+=1
        wa+=WA[i]
        
print(ac, wa)
Problem p02882 (python)

Fixed submission:
import math
a, b, x = map(int, input().split())

if x == a**2*b:
    print(0)
elif 2*x <= (a**2)*b:
    print(math.degrees(math.atan((b**2)*a/(2*x))))
else :
    print(90-math.degrees(math.atan((a**3)/(2*((a**2)*b-x)))))

Buggy submission (verdict: Runtime Error):
import math
a, b, x = map(int, input().split())

if 2*x <= (a**2)*b:
    print(math.degrees(math.atan((b**2)*a/(2*x))))
else :
    print(90-math.degrees(math.atan((a**3)/(2*((a**2)*b-x)))))
Problem p02923 (python)

Fixed submission:
n = int(input())
H = list(map(int, input().split()))
dp = [0]*n
dp[0] = 1

if n == 1:
    print(0)
else:
    for i in range(1, n-1):
        if H[i] >= H[i+1]:
            dp[i] += dp[i-1]+1
        else:
            dp[i] = 0
    print(max(dp[1:]))

Buggy submission (verdict: Runtime Error):
n = int(input())
H = list(map(int, input().split()))
dp = [0]*n
dp[0] = 1
for i in range(1, n-1):
    if H[i] >= H[i+1]:
        dp[i] += dp[i-1]+1
    else:
        dp[i] = 0
print(max(dp[1:]))
Problem p03106 (python)

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

c=min(a,b)
d=max(a,b)
ans=[]

for i in range(c):
    if c%(i+1)==0 and d%(i+1)==0:
        ans.append(i+1)
            
print(ans[-k])

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

c=min(a,b)
d=max(a,b)
ans=[]

if a==b:
    ans.append(1)
else:
    for i in range(c):
        if c%(i+1)==0 and d%(i+1)==0:
            ans.append(i+1)
            
print(ans[-k])
Problem p03276 (python)

Fixed submission:
n, k = map(int, input().split())
x = list(map(int, input().split()))
m = 3*10**8

for i in range(n-k+1):
    a = x[i]
    b = x[i+k-1]
    t= min(abs(a)+abs(b-a), abs(b)+abs(b-a))
    if m > t:
        m = t
print(m)

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
import itertools

n, k = map(int, input().split())
x = list(map(int, input().split()))
X = []
m = 3*10**8

for v in itertools.combinations(x, k):
    X.append(list(v))

for i in range(comb(n, k, exact=True)):
    m0 = min(X[i])
    m1 = max(X[i])
    a = min(abs(abs(m0)+abs(m1-m0), abs(m1)+abs(m1-m0)))
    if m > a:
        m = a
print(m)
Problem p02585 (python)

Fixed submission:
n,k=map(int,input().split())
p=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=[]
for i in range(n):
  ct=0
  score=0
  s=[]
  pos=i
  while ct<k:
    ct+=1
    pos=p[pos]-1
    score+=c[pos]
    s.append(score)
    if pos==i:
      break
  if s[-1]<0:
    ans.append(max(s))
  elif pos!=i:
    ans.append(max(s))
  elif k%len(s)==0:
    ans.append(s[-1]*(k//len(s)-1)+max(s))
  else:
    ans.append(max(s[-1]*(k//len(s)-1)+max(s),s[-1]*(k//len(s))+max(s[0:k%len(s)])))
print(max(ans))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
p=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=[]
for i in range(n):
  ct=0
  score=0
  s=[]
  pos=i
  while ct<k:
    ct+=1
    pos=p[pos]-1
    score+=c[pos]
    s.append(score)
    if pos==i:
      break
  if s[-1]<0:
    ans.append(max(s))
  elif pos!=i:
    ans.append(max(s))
  else:
    ans.append(max(s[-1]*(k//len(s)-1)+max(s),s[-1]*(k//len(s))+max(s[0:k%len(s)])))
print(max(ans))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
p=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=[]
for i in range(n):
  ct=0
  score=0
  s=[]
  pos=i
  while ct<k:
    ct+=1
    pos=p[pos]-1
    score+=c[pos]
    s.append(score)
    if pos==i:
      break
  if s[-1]<0:
    ans.append(max(s))
  elif pos!=i:
    ans.append(max(s))
  elif max(s)==max(s[0:k%len(s)]):
    ans.append(s[-1]*(k//len(s))+max(max(s[0:k%len(s)]),0))
  else:
    ans.append(s[-1]*(k//len(s)-1)+max(s))
print(max(ans))
Problem p02782 (python)

Fixed submission:
def cmb(n,r,mod):
  if r<0 or r>n:
    return 0
  r=min(r,n-r)
  return g1[n]*g2[r]*g2[n-r]%mod
 
r1,c1,r2,c2=map(int,input().split())
mod=10**9+7

g1=[1,1]
g2=[1,1]
inverse=[0,1]
 
for i in range(2,2*10**6+2):
  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):
  ans=0
  for i in range(1,c+1):
    ans+=cmb(r+i-1,i,mod)
  return ans

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

Buggy submission (verdict: Runtime Error):
def cmb(n,r,mod):
  if r<0 or r>n:
    return 0
  r=min(r,n-r)
  return g1[n]*g2[r]*g2[n-r]%mod
 
r1,c1,r2,c2=map(int,input().split())
mod=10**9+7

g1=[1,1]
g2=[1,1]
inverse=[0,1]
 
for i in range(2,10**6+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):
  ans=0
  for i in range(1,c+1):
    ans+=cmb(r+i-1,i,mod)
  return ans

print((g(r2+1,c2+1)-g(r2+1,c1)-g(r1,c2+1)+g(r1,c1)+mod)%mod)
Problem p02825 (python)

Fixed submission:
import sys
n=int(input())
if n==2:
  print(-1)
  sys.exit()
if n==3:
  print('aa.')
  print('..a')
  print('..a')
  sys.exit()

x=(n//4)-1
y=(n%4)+4

l=[[['a','a','b','c'],['d','d','b','c'],['b','c','a','a'],['b','c','d','d']],[['a','a','b','b','a'],['b','c','c','.','a'],['b','.','.','c','b'],['a','.','.','c','b'],['a','b','b','a','a']],[['a','a','b','c','.','.'],['d','d','b','c','.','.'],['.','.','a','a','b','c'],['.','.','d','d','b','c'],['b','c','.','.','a','a'],['b','c','.','.','d','d']],[['a','a','b','b','c','c','.'],['d','d','.','d','d','.','a'],['.','.','d','.','.','d','a'],['.','.','d','.','.','d','b'],['d','d','.','d','d','.','b'],['.','.','d','.','.','d','c'],['.','.','d','.','.','d','c']]]

if n<8:
  for i in range(n):
    print(''.join(l[n-4][i]))
  sys.exit()

ans=[]
for i in range(n):
  ans1=['.']*n
  ans.append(ans1)

for i in range(x):
  for j in range(4):
    for k in range(4):
      ans[i*4+j][i*4+k]=l[0][j][k]

for j in range(y):
  for k in range(y):
    ans[x*4+j][x*4+k]=l[y-4][j][k]

for i in range(n):
  print(''.join(ans[i]))

Buggy submission (verdict: Runtime Error):
import sys
n=int(input())
if n==2 or n==5:
  print(-1)
  sys.exit()
if n%3==0:
  a=[]
  b=[]
  for j in range(n//3):
    a.append('a')
    a.append('a')
    a.append('.')
    b.append('.')
    b.append('.')
    b.append('a')
  for i in range(n):
    if i%3==0:
      print(''.join(a))
    else:
      print(''.join(b))
  sys.exit()

elif n%4==0:
  a=[]
  b=[]
  c=[]
  d=[]
  for j in range(n//4):
    a.append('a')
    a.append('a')
    a.append('c')
    a.append('d')
    b.append('b')
    b.append('b')
    b.append('c')
    b.append('d')
    c.append('e')
    c.append('f')
    c.append('g')
    c.append('g')
    d.append('e')
    d.append('f')
    d.append('h')
    d.append('h')
  for i in range(n):
    if i%4==0:
      print(''.join(a))
    elif i%4==1:
      print(''.join(b))
    elif i%4==2:
      print(''.join(c))
    elif i%4==3:
      print(''.join(d))
  sys.exit()

for i in range(n//3):
   if (n-i*3)%4==0:
     x=i
     y=(n-i*3)//4
     break

ans=[]
for i in range(n):
  ans1=['.']*n
  ans.append(ans1)

for i in range(x):
  ans[i*3][i*3]='a'
  ans[i*3][i*3+1]='b'
  ans[i*3][i*3+2]='b'
  ans[i*3+1][i*3]='a'
  ans[i*3+1][i*3+2]='a'
  ans[i*3+2][i*3]='b'
  ans[i*3+2][i*3+1]='b'
  ans[i*3+2][i*3+2]='a'
for i in range(y):
  ans[x*3+i*4][x*3+i*3+i*4]='a'
  ans[x*3+i*4][x*3+i*3+i*4+1]='b'
  ans[x*3+i*4][x*3+i*3+i*4+2]='c'
  ans[x*3+i*4][x*3+i*3+i*4+3]='c'
  
  ans[x*3+i*4+1][x*3+i*3+i*4]='a'
  ans[x*3+i*4+1][x*3+i*3+i*4+1]='b'
  ans[x*3+i*4+1][x*3+i*3+i*4+2]='d'
  ans[x*3+i*4+1][x*3+i*3+i*4+3]='d'
  
  ans[x*3+i*4+2][x*3+i*3+i*4]='e'
  ans[x*3+i*4+2][x*3+i*3+i*4+1]='e'
  ans[x*3+i*4+2][x*3+i*3+i*4+2]='g'
  ans[x*3+i*4+2][x*3+i*3+i*4+3]='h'
  
  ans[x*3+i*4+3][x*3+i*3+i*4]='f'
  ans[x*3+i*4+3][x*3+i*3+i*4+1]='f'
  ans[x*3+i*4+3][x*3+i*3+i*4+2]='g'
  ans[x*3+i*4+3][x*3+i*3+i*4+3]='h'

for i in range(n):
  print(''.join(ans[i]))
Problem p02839 (python)

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

def main():
  h,w=map(int,input().split())
  a=[list(map(int,input().split())) for i in range(h)]
  b=[list(map(int,input().split())) for i in range(h)]
  dp=[[[0]*(80*(h+w+1)+1) for i in range(w)] for j in range(h)]
  dp[0][0][abs(a[0][0]-b[0][0])]=1
  for i in range(h):
    for j in range(w):
      c=abs(a[i][j]-b[i][j])
      if i!=0 or j!=0:
        for k in range(80*(i+j+1)+1):
          dp[i][j][k]=dp[i-1][j][abs(k-c)]|dp[i-1][j][k+c]|dp[i][j-1][abs(k-c)]|dp[i][j-1][k+c]
  for i in range(80*(h+w+1)+1):
    if dp[h-1][w-1][i]==1:
      print(i)
      break

if __name__=='__main__':
  main()

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

def main():
  h,w=map(int,input().split())
  a=[list(map(int,input().split())) for i in range(h)]
  b=[list(map(int,input().split())) for i in range(h)]
  
  dp=[[[] for i in range(w)] for j in range(h)]
  dp[0][0].append(abs(a[0][0]-b[0][0]))
  for i in range(h):
    for j in range(w):
      c[i][j]=abs(a[i][j]-b[i][j])
      for k in dp[i-1][j]:
        dp[i][j].append(abs(k-c[i][j]))
        dp[i][j].append(k+c[i][j])
      for k in dp[i][j-1]:
        dp[i][j].append(abs(k-c[i][j]))
        dp[i][j].append(k+c[i][j])
      dp[i][j]=list(set(dp[i][j]))
  print(min(dp[h-1][w-1]))

if __name__=='__main__':
  main()

Buggy submission (verdict: Runtime Error):
import copy
h,w=map(int,input().split())
a=[list(map(int,input().split())) for i in range(h)]
b=[list(map(int,input().split())) for i in range(h)]
c=[[0]*w for i in range(h)]
for i in range(h):
  for j in range(w):
    c[i][j]=abs(a[i][j]-b[i][j])
dp=[[[] for i in range(w)] for j in range(h)]
dp[0][0].append(c[0][0])
for i in range(h):
  for j in range(w):
    f=0
    if i<h-1:
      l=[]
      for k in range(len(dp[i][j])):
        if -80<=dp[i][j][k]+c[i+1][j]<=80:
          l.append(dp[i][j][k]+c[i+1][j])
        if -80<=l[k]-c[i+1][j]<=80:
          l.append(dp[i][j][k]-c[i+1][j])
      l=list(set(l))
      dp[i+1][j]=l+dp[i+1][j]
      dp[i+1][j]=list(set(dp[i+1][j]))
    f=0
    if j<w-1:
      l=[]
      for k in range(len(dp[i][j])):
        if -80<=dp[i][j][k]+c[i][j+1]<=80:
          l.append(dp[i][j][k]+c[i][j+1])
        if -80<=dp[i][j][k]-c[i][j+1]<=80:
          l.append(dp[i][j][k]-c[i][j+1])
      l=list(set(l))
      dp[i][j+1]=l+dp[i][j+1]
      dp[i][j+1]=list(set(dp[i][j+1]))
for i in range(len(dp[h-1][w-1])):
  dp[h-1][w-1][i]=abs(dp[h-1][w-1][i])
print(min(dp[h-1][w-1]))
Problem p02856 (python)

Fixed submission:
m=int(input())
l=[list(map(int,input().split())) for i in range(m)]
ct=0;sum=0
for i in range(m):
  ct+=l[i][0]*l[i][1]
  sum+=l[i][1]
print(sum-1+((ct-1)//9))

Buggy submission (verdict: Runtime Error):
m=int(input())
l=[list(map(int,input().split())) for i in range(m)]
ct=0;sum=0
for i in range(m):
  ct+=l[i][0]*l[i][1]
  sum+=l[i][1]
ans=sum-1
sct=str(ct)
if len(sct)>=2:
  for i in range(1,len(sct)):
    ans+=int(ct[0:i])
print(ans)
Problem p02918 (python)

Fixed submission:
import sys
n,k=map(int,input().split())
s=list(input())
ct=0
for i in range(n-1):
  if s[i]=='R' and s[i+1]=='L':ct+=1
if ct<=k-1:
  print(n-1)
  sys.exit()
ans=n-ct*2
ans+=2*k
if s[0]=='L':
  ans-=1
if s[n-1]=='R':
  ans-=1
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=list(input())
ct=0
for i in range(n-1):
  if s[i]=='R' and s[i+1]=='L':
    ct+=1
if s[0]==s[n-1]:
  x=ct
  ct-=min(ct,k)
  ct*=2
  ct+=1
  print(n-ct)
elif s[0]=='L':
  x=ct
  ct-=min(ct,k)
  ct*=2
  if x<k:
    ct-=1
  print(n-ct)
else:
  x=ct
  ct-=min(ct,k)
  ct*=2
  if x<=k
    ct+=1
  print(n-ct)
Problem p03006 (python)

Fixed submission:
class UF():
  def __init__(self, N):
    self._parent=[n for n in range(0, N)]
    self._size=[1] * N

  def find_root(self, x):
    if self._parent[x]==x:return x
    self._parent[x]=self.find_root(self._parent[x])
    return self._parent[x]

  def unite(self, x, y):
    gx=self.find_root(x)
    gy=self.find_root(y)
    if gx==gy:return

    if self._size[gx]<self._size[gy]:
      self._parent[gx]=gy
      self._size[gy]+=self._size[gx]
    else:
      self._parent[gy]=gx
      self._size[gx]+=self._size[gy]

  def size(self, x):
    return self._size[self.find_root(x)]

  def samegroup(self, x, y):
    return self.find_root(x)==self.find_root(y)

  def groupnum(self):
    N=len(self._parent)
    ans=0
    for i in range(N):
      if self.find_root(i)==i:
        ans+=1
    return ans

  def reset(self):
    self._parent=[n for n in range(0, n)]

n=int(input())
UF=UF(n)
l=[list(map(int,input().split())) for i in range(n)]
if n==1:
  print(1)
else:
  ans=[]
  for i in range(n):
    x1=l[i][0]
    y1=l[i][1]
    for j in range(n):
      if i!=j:
        x2=l[j][0]
        y2=l[j][1]
        p=x1-x2
        q=y1-y2
        for k1 in range(n):
          for k2 in range(n):
            if k1!=k2:
              if (l[k1][0]-p==l[k2][0] and l[k1][1]-q==l[k2][1]) or (l[k1][0]+p==l[k2][0] and l[k1][1]+q==l[k2][1]):
                UF.unite(k1,k2)
        ans.append(UF.groupnum())
        UF.reset()
  print(min(ans))

Buggy submission (verdict: Runtime Error):
import copy
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
ans=[]
for i in range(n):
  x1=l[i][0]
  y1=l[i][1]
  for j in range(n):
    if i!=j:
      x2=l[j][0]
      y2=l[j][1]
      if (x1-x2)!=0:
        p=(y1-y2)/(x1-x2)
        L=[]
        for k in range(n):
          L.append(round(l[k][1]-l[k][0]*p,9))
        ans.append(len(set(L)))
      else:
        L=[]
        for k in range(n):
          L.append(l[k][0])
        ans.append(len(set(L)))
print(min(ans))
Problem p03007 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a.sort()
A=[a[0]]
x=0
sum=sum(a)
sumL=-9999999999
if n==2:
  print(max(a)-min(a))
  print(max(a),min(a))
else:
  for i in range(1,n):
    A.append(A[i-1]+a[i])
  for i in range(1,n):
    if sumL<-A[i-1]+sum-A[i-1]:
      sumL=-A[i-1]+sum-A[i-1]
      x=i
  print(sumL)
  L1=a[0:x]
  L2=a[x:n]

  if x!=1:
    print(L2[0],L1[0])
    z=L2[0]-L1[0]
    for i in range(1,x-1):
      print(z,L1[i])
      z=z-L1[i]
  else:
    z=L2[0]

  if x!=n-1:
    print(L1[x-1],L2[1])
    y=L1[x-1]-L2[1]
    for i in range(2,len(L2)):
      print(y,L2[i])
      y=y-L2[i]
  else:
    y=L1[len(L1)-1]

  print(z,y)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort()
A=[a[0]]
x=0
sum=sum(a)
sumL=-9999999999
if n==2:
  print(max(a)-min(a))
  print(max(a),min(a))
else:
  for i in range(1,n):
    A.append(A[i-1]+a[i])
  for i in range(1,n):
    if sumL<-A[i-1]+sum-A[i-1]:
      sumL=-A[i-1]+sum-A[i-1]
      x=i
  print(sumL)
  L1=a[0:x]
  L2=a[x:n]

  if x!=1:
    print(L2[0],L1[0])
    z=L2[0]-L1[0]
    for i in range(1,x-1):
      print(z,L1[i])
      z=z-L1[i]
  else:
    z=L2[0]

  print(L1[x-1],L2[1])
  y=L1[x-1]-L2[1]
  for i in range(2,len(L2)):
    print(y,L2[i])
    y=y-L2[i]

  print(z,y)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort()
A=[a[0]]
x=0
sumL=-99999999
for i in range(1,n):
  A.append(a[i-1]+a[i])
for i in range(1,n):
  if sumL<-A[i-1]+sum(a)-A[i-1]:
    sumL=-A[i-1]+sum(a)-A[i-1]
    x=i
print(sumL)
L1=a[0:x]
L2=a[x:n]

if x!=1:
  print(L2[0],L1[0])
  z=L2[0]-L1[0]
  for i in range(1,x-1):
    print(z,L1[i])
    z=z-L1[i]
else:
  z=L2[0]

print(L1[x-1],L2[1])
y=L1[x-1]-L2[1]
for i in range(2,len(L2)):
  print(y,L2[i])
  y=y-L2[i]

print(z,y)
Problem p03050 (python)

Fixed submission:
n=int(input())
if n==1:
  print(0)
else:
  ct=0
  for i in range(1,int(n**0.5)):
    if (n-i)%i==0:
      ct+=(n-i)//i
  if (n-int(n**0.5))%int(n**0.5)==0:
    x=(n-int(n**0.5))//int(n**0.5)
    if n//x==n%x:ct+=x
  print(ct)

Buggy submission (verdict: Runtime Error):
n=int(input())
ct=0
for i in range(1,int(n**0.5)):
  if (n-i)%i==0:
    ct+=(n-i)//i
if (n-int(n**0.5))%int(n**0.5)==0:
  x=(n-int(n**0.5))//int(n**0.5)
  if n//x==n%x:ct+=x
print(ct)
Problem p03074 (python)

Fixed submission:
n,k=map(int,input().split())
s=input()
s='01'+s+'10'
S=[]
E=[]
ans=[]
for i in range(n+3):
  if s[i:i+2]=='01':
    S.append(i+1)
  if s[i:i+2]=='10':
    E.append(i)
if S==[] and E==[]:
  print(n)
else:
  for j in range(len(E)-k):
    ans.append(abs(S[j]-E[j+k]))
  if ans!=[]:
    ans[0]-=1
    ans[len(ans)-1]-=1
    print(max(ans)+1)
  else:
    print(n)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=input()
s='01'+s+'10'
S=[]
E=[]
ans=[]
for i in range(n+3):
  if s[i:i+2]=='01':
    S.append(i+1)
  if s[i:i+2]=='10':
    E.append(i)
if S==[] and E==[]:
  print(n)
else:
  for j in range(len(E)-k):
    ans.append(abs(S[j]-E[j+k]))
  ans[0]-=1
  ans[len(ans)-1]-=1
  print(max(ans)+1)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=input()
s='0'+s+'0'
S=[]
E=[]
ans=[]
for i in range(n+1):
  if s[i:i+2]=='01':
    S.append(i+1)
  if s[i:i+2]=='10':
    E.append(i)
if S==[] and E==[]:
  print(n)
else:
  for j in range(len(E)-k):
    ans.append(abs(S[j]-E[j+k]))
  if s[1]=='0':
    ans.append(E[k-1]-1)
  if s[n]=='0':
    ans.append(S[len(S)-k]-1)
  if ans==[]:
    print(E[0])
  else:
    print(max(ans)+1)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=input()
s='0'+s+'0'
S=[]
E=[]
ans=[]
for i in range(n+1):
  if s[i:i+2]=='01':
    S.append(i+1)
  if s[i:i+2]=='10':
    E.append(i)
for j in range(len(E)-k):
  ans.append(abs(S[j]-E[j+k]))
if ans==[]:
  print(E[0])
else:
  print(max(ans)+1)
Problem p03085 (python)

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

Buggy submission (verdict: Runtime Error):
print(s[3-'AGCT'.index(input())])
Problem p03086 (python)

Fixed submission:
s=input()
l=['A','C','G','T']
ans=[];ct=0
for i in range(len(s)):
  if s[i] in l:
    ct+=1
  else:
    ans.append(ct)
    ct=0
ans.append(ct)
print(max(ans))

Buggy submission (verdict: Runtime Error):
s=input()
l=['A','C','G','T']
ans=[];ct=0
for i in range(len(s)):
  if s[i] in l:
    ct+=1
  else:
    ans.append(ct)
print(max(ans))
Problem p03088 (python)

Fixed submission:
import sys
n=int(input())
if n==3:
  print(61)
  sys.exit()
mod=10**9+7
l=['A','C','G','T']
NG=['AGC','GAC','ACG']
NG2=['AAGC','ACGC','AGGC','ATGC','AGAC','AGCC','AGTC']
L=[]
for i1 in range(4):
  for i2 in range(4):
    for i3 in range(4):
      for i4 in range(4):
        L.append(l[i1]+l[i2]+l[i3]+l[i4])
dp=[[0 for i in range(256)] for j in range(n+1)]
for i in range(256):
  if L[i][1:4] in NG or L[i][0:3] in NG or L[i] in NG2:
    dp[4][i]=0
  else:
    dp[4][i]=1
for j in range(5,n+1):
  for i in range(256):
    if L[i][1:4] in NG or L[i][0:3] in NG or L[i] in NG2:
      dp[j][i]=0
    else:
      for i2 in range(256):
        if L[i2][1:4]==L[i][0:3]:
          dp[j][i]+=dp[j-1][i2]
    dp[j][i]%=mod
print(sum(dp[n])%mod)

Buggy submission (verdict: Runtime Error):
n=int(input())
mod=10**9+7
l=['A','C','G','T']
NG=['AGC','GAC','ACG']
NG2=['AAGC','ACGC','AGGC','ATGC','AGAC','AGCC','AGTC']
L=[]
for i1 in range(4):
  for i2 in range(4):
    for i3 in range(4):
      for i4 in range(4):
        L.append(l[i1]+l[i2]+l[i3]+l[i4])
dp=[[0 for i in range(256)] for j in range(n+1)]
for i in range(256):
  if L[i][1:4] in NG or L[i][0:3] in NG or L[i] in NG2:
    dp[4][i]=0
  else:
    dp[4][i]=1
for j in range(5,n+1):
  for i in range(256):
    if L[i][1:4] in NG or L[i][0:3] in NG or L[i] in NG2:
      dp[j][i]=0
    else:
      for i2 in range(256):
        if L[i2][1:4]==L[i][0:3]:
          dp[j][i]+=dp[j-1][i2]
    dp[j][i]%=mod
print(sum(dp[n])%mod)
Problem p03128 (python)

Fixed submission:
n,m=map(int,input().split())
a=list(map(int,input().split()))
x=[2,5,5,4,5,6,3,7,6]
dp=[0 for i in range(n+1)]
for i in range(1,n+1):
  l=[-99999999]
  for j in range(m):
    if i-x[a[j]-1]>=0:
      l.append(dp[i-x[a[j]-1]])
  dp[i]=max(l)+1
ans=[]
a.sort()
a.reverse()
y=n
for i in range(dp[n]):
  for j in range(m):
    if y-x[a[j]-1]>=0:
      if dp[y-x[a[j]-1]]==dp[y]-1:
        ans.append(str(a[j]))
        y-=x[a[j]-1]
        break
print(''.join(ans))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))
x=[2,5,5,4,5,6,3,7,6]
dp=[0 for i in range(n+1)]
for i in range(1,n+1):
  l=[-99999999]
  for j in range(m):
    if i-x[a[j]-1]>=0:
      l.append(dp[i-x[a[j]-1]])
  dp[i]=max(l)+1
ans=[]
a.sort()
a.reverse()
y=n
for i in range(dp[n]):
  for j in range(m):
    if dp[y-x[a[j]-1]]==dp[y]-1:
      ans.append(str(a[j]))
      y-=x[a[j]-1]
      break
print(''.join(ans))
Problem p03140 (python)

Fixed submission:
n=int(input())
a=input()
b=input()
c=input()
ct=0
for i in range(n):
  if a[i]==b[i] and b[i]==c[i]:ct+=0
  elif a[i]==b[i] or b[i]==c[i] or c[i]==a[i]:ct+=1
  else:ct+=2
print(ct)

Buggy submission (verdict: Runtime Error):
n=int(input())
a,b,c=input(),input(),input()
ct=0
for i in range(n):
  if a[i]==b[i]==c[i]:ct+=0
  elif a[i]==b[i] or b[i]==c[i] or c[i]==a[i]:ct+=1
  else:ct+=2
print(ct)​
Problem p03148 (python)

Fixed submission:
import heapq
from collections import deque
n,k=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]

for i in range(n):
  l[i].reverse()
  l[i][0]*=-1
heapq.heapify(l)

check=[0 for i in range(10**5+1)]
L=[]
L2=[]
L2=deque(L2)
ans=[]

for i in range(k):
  x=heapq.heappop(l)
  if check[x[1]]==0:
    L.append(-x[0])
    check[x[1]]=1
  else:
    L2.append(-x[0])
p=sum(check)
ans.append(sum(L)+sum(L2)+p**2)

y=n-k
while y!=0:
  x=heapq.heappop(l)
  if check[x[1]]==0:
    L.append(-x[0])
    check[x[1]]=1
    if len(L2)==0:
      break
    z=L2.pop()
    p+=1
    ans.append(ans[-1]-(p-1)**2-x[0]-z+p**2)
  y-=1

print(max(ans))

Buggy submission (verdict: Runtime Error):
import heapq
from collections import deque
n,k=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]

for i in range(n):
  l[i].reverse()
  l[i][0]*=-1
heapq.heapify(l)

check=[0 for i in range(10**5+1)]
L=[]
L2=[]
L2=deque(L2)
ans=[]

for i in range(k):
  x=heapq.heappop(l)
  if check[x[1]]==0:
    L.append(-x[0])
    check[x[1]]=1
  else:
    L2.append(-x[0])
p=sum(check)
ans.append(sum(L)+sum(L2)+p**2)

y=n-k
while y!=0:
  x=heapq.heappop(l)
  if check[x[1]]==0:
    L.append(-x[0])
    check[x[1]]=1
    z=L2.pop()
    p+=1
    ans.append(ans[-1]-(p-1)**2-x[0]-z+p**2)
  y-=1

print(max(ans))