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

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

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=list(input())
s=list(map(int,s))
stack=[]
tmp=1
flag=True
for i in range(1,len(s)):
  if s[i]!=s[i-1]:
    stack.append(tmp)
    tmp=1
  else:
    tmp+=1
stack.append(tmp)
left=[0]
right=[0]
tmp=0
if s[0]==0:
  flag=False
  if len(stack)%2==1:
    stack.append(0)
  if len(stack)//2<=k:
    print(len(s))
    exit()
else:
  flag=True
  if len(stack)%2==0:
    stack.append(0)
  if len(stack)//2<=k:
    print(len(s))
    exit()
for i in range(len(stack)):
  tmp+=stack[i]
  if i%2==0:
    if flag:
      right.append(tmp)
    else:
      left.append(tmp)
  else:
    if flag:
      left.append(tmp)
    else:
      right.append(tmp)
ans=0
for i in range(len(right)-k):
  ans=max(ans,right[i+k]-left[i])
print(ans)
Problem p03078 (python)

Fixed submission:
x,y,z,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=[]
ans2=[]
for i in range(x):
  for j in range(y):
    ans.append(a[i]+b[j])
if len(ans)>=k:
  ans.sort()
  ans.reverse()
  ans=ans[:k]
for i in range(len(ans)):
  for j in range(z):
    ans2.append(ans[i]+c[j])
ans2.sort()
ans2.reverse()
for i in range(k):
  print(ans2[i])

Buggy submission (verdict: Runtime Error):
x,y,z,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
a.reverse()
b.sort()
b.reverse()
c.sort()
c.reverse()
ans=[]
if x*y*z<=3000:
  for i in range(x):
    for j in range(y):
      for h in range(z):
        ans.append(a[i]+b[j]+c[h])
  ans.sort()
  ans.reverse()
  for i in range(k):
    print(ans[i])
  exit()
p=0
q=0
r=0
while (p+1)*(q+1)*(r+1)<k:
  if a[p]==min(a[p],b[q],c[r]) and p+1<len(a):
    p+=1
  elif b[q]==min(a[p],b[q],c[r]) and q+1<len(b):
    q+=1
  elif c[r]==min(a[p],b[q],c[r]) and r+1<len(c):
    p+=1
  else:
    if p+1<len(a):
      p+=1
    if q+1<len(b):
      q+=1
    if r+1<len(c):
      r+=1
for i in range(p+1):
  for j in range(q+1):
    for h in range(r+1):
      ans.append(a[i]+b[j]+c[h])
ans.sort()
ans.reverse()
for i in range(k):
  print(ans[i])

Buggy submission (verdict: Runtime Error):
x,y,z,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
a.reverse()
b.sort()
b.reverse()
c.sort()
c.reverse()
ans=[]
if x*y*z<=3000:
  for i in range(x):
    for j in range(y):
      for h in range(z):
        ans.append(a[i]+b[j]+c[h])
  ans.sort()
  ans.reverse()
  for i in range(k):
    print(ans[i])
  exit()
p=0
q=0
r=0
for i in range(k):
  ans.append(a[p]+[q]+[r])
  if p+1<len(a):
    a1=a[p]-a[p+1]
  else:
    a1=10**18
  if q+1<len(b):
    b1=b[q]-b[q+1]
  else:
    b1=10**18
  if r+1<len(c):
    c1=c[r]-c[r+1]
  else:
    c1=10**18
  if a1==min(a1,b1,c1):
    p+=1
  elif b1==min(a1,b1,c1):
    q+=1
  elif c1==min(a1,b1,c1):
    r+=1
for i in range(k):
  print(ans[i])
Problem p03081 (python)

Fixed submission:
import sys
n,q=map(int,input().split())
s=input()
l=[[i for i in l.split()] for l in sys.stdin]
def right_fallen(x):
  stack=x
  for i in range(q):
    if stack==n:
      return True
    if stack==-1:
      return False
    if l[i][0]==s[stack]:
      if l[i][1]=='R':
        stack+=1
      else:
        stack-=1
  if stack==n:
    return True
  return False
def left_fallen(x):
  stack=x
  for i in range(q):
    if stack==n:
      return False
    if stack==-1:
      return True
    if l[i][0]==s[stack]:
      if l[i][1]=='R':
        stack+=1
      else:
        stack-=1
  if stack==-1:
    return True
  return False
def binary_search():
  ok=n
  ng=-1
  while(abs(ok-ng)>1):
    mid=(ok+ng)//2
    if right_fallen(mid):
      ok=mid
    else:
      ng=mid
  return ok
def binary_search2():
  ok=-1
  ng=n
  while(abs(ok-ng)>1):
    mid=(ok+ng)//2
    if left_fallen(mid):
      ok=mid
    else:
      ng=mid
  return ok
print(binary_search()-binary_search2()-1)

Buggy submission (verdict: Runtime Error):
import sys
n,q=map(int,input().split())
s=input()
l=[[i for i in l.split()] for l in sys.stdin]
def right_fallen(x):
  stack=x
  for i in range(n):
    if stack==n:
      return True
    if stack==-1:
      return False
    if l[i][0]==s[stack]:
      if l[i][1]=='R':
        stack+=1
      else:
        stack-=1
  return False
def left_fallen(x):
  stack=x
  for i in range(n):
    if stack==n:
      return False
    if stack==-1:
      return True
    if l[i][0]==s[stack]:
      if l[i][1]=='R':
        stack+=1
      else:
        stack-=1
  return False
def binary_search():
  ok=n
  ng=-1
  while(abs(ok-ng)>1):
    mid=(ok+ng)//2
    if right_fallen(mid):
      ok=mid
    else:
      ng=mid
  return ok
def binary_search2():
  ok=-1
  ng=n
  while(abs(ok-ng)>1):
    mid=(ok+ng)//2
    if left_fallen(mid):
      ok=mid
    else:
      ng=mid
  return ok
print(binary_search()-binary_search2()-1)

Buggy submission (verdict: Runtime Error):
import sys
n,q=map(int,input().split())
s=input()
l=[[i for i in l.split()] for l in sys.stdin]
def right_fallen(x):
  stack=x
  for i in range(n):
    if stack==n:
      return True
    if stack==-1:
      return False
    if l[i][0]==x[stack]:
      if l[i][1]=='R':
        stack+=1
      else:
        stack-=1
  return False
def right_fallen(x):
  stack=x
  for i in range(n):
    if stack==n:
      return False
    if stack==-1:
      return True
    if l[i][0]==x[stack]:
      if l[i][1]=='R':
        stack+=1
      else:
        stack-=1
  return False
def binary_search():
  ok=n
  ng=-1
  while(abs(ok-ng)>1):
    mid=(ok+ng)//2
    if right_fallen(mid):
      ok=mid
    else:
      ng=mid
  return ok
def binary_search2():
  ok=-1
  ng=n
  while(abs(ok-ng)>1):
    mid=(ok+ng)//2
    if left_fallen(mid):
      ok=mid
    else:
      ng=mid
  return ok
print(binary_search-binarysearch2-1)
Problem p03087 (python)

Fixed submission:
n,q=map(int,input().split())
s=input()
Sum=[0]
sum=0
stack="Q"
for i in range(n):
  if stack=="A" and s[i]=="C":
    sum+=1
  stack=s[i]
  Sum.append(sum)
for i in range(q):
  l,r=map(int,input().split())
  print(Sum[r]-Sum[l])

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=input()
Sum=[0]
sum=0
for i in range(1,n+1):
  sum=s[:i].count("AC")
  Sum.append(sum)
for i in range(q):
  l.r=map(int,input().split())
  print(Sum[r]-Sum[l])
Problem p03096 (python)

Fixed submission:
import sys
n=int(input())
c=[int(i) for i in sys.stdin]
x=[0]*(200001)
c.append(0)
x[c[0]]+= 1
num=1
p=10**9 +7
for i in range(1,n):
  if c[i]-c[i-1]:
    x[c[i]]+= num
    x[c[i]]= x[c[i]]%p
  if c[i]-c[i+1]:
    num=x[c[i]]%p
  else:
    num=0
print(num)

Buggy submission (verdict: Runtime Error):
import sys
n=int(input())
c=[int(i) for i in sys.stdin]
x=[0]*(200001)
c.append(0)
x[c[0]]+= 1
num=1
p=10**9 +7
for i in c:
  if c[i]-c[i-1]:
    x[c[i]]+= num
    x[c[i]]= x[c[i]]%p
  if c[i]-c[i+1]:
    num=x[c[i]]
  else:
    num=0
print(num)

Buggy submission (verdict: Runtime Error):
import sys
from collections import Counter
p=10**9 +7
n=int(input())
c=[int(i) for i in sys.stdin]
dic = dict()
for i in c:
    if i in dic:
        if dic[i]:
            dic[i] = False
    else:
        dic[i] = True
newline=[]
stack=0
for i in range(n):
  k=c.pop()
  if dic[k]:
    stack=k
    continue
  else:
    if stack!=k:
      newline.append(k)
    stack=k
result=sum([i-1 for i in Counter(newline).values()])%p
if result%2:
  print(pow(2,result//2 +1,p)-1)
else:
  print(pow(2,(result-1)//2,p)*3 -1)

Buggy submission (verdict: Runtime Error):
import sys
from collections import Counter
p=10**9 +7
n=int(input())
c=[int(i) for i in sys.stdin]
dic = dict()
for i in c:
    if i in dic:
        if dic[i]:
            dic[i] = False
    else:
        dic[i] = True
newline=[]
stack=0
for i in range(n):
  k=c.pop()
  if dic[k]:
    stack=k
    continue
  else:
    if stack!=k:
      newline.append(k)
    stack=k
result=sum([i-1 for i in Counter(newline).values()])%p
if result%2:
  print(pow(2,result//2 +1,p)-1)
else:
  print((pow(2,result-1//2 +1,p)-1)
Problem p03103 (python)

Fixed submission:
n,m=map(int,input().split())
potion=[]
for i in range(n):
    potion_R = list(map(int,input().split()))
    potion.append(potion_R)
potion.sort()
ans=0
number=m
for i in potion:
    if i[1]<=number:
        number-= i[1]
        ans+= i[0]*i[1]
    else:
        ans+= i[0]*number
        break
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
potion=[]
for i in range(n):
    potion_R = list(map(int,input().split())
    potion.append(potion_R)
potion.sort()
ans=0
number=m
for i in potion:
    if i[1]<=number:
        number-= i[1]
        ans+= i[0]*i[1]
    else:
        ans+= i[0]*number
        break
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
potion=[]
for i in range(N):
    potion_R = list(map(int,input().split())
    potion.append(potion_R)
potion.sort()
ans=0
number=m
for i in potion:
    if i[1]<=number:
        number-= i[1]
        ans+= i[0]*i[1]
    else:
        ans+= i[0]*number
        break
print(ans)
Problem p03125 (python)

Fixed submission:
a=list(map(int,input().split()))
if a[1]%a[0]==0:
    print(a[0]+a[1])
else:
    print(a[1]-a[0])

Buggy submission (verdict: Runtime Error):
a=map(int,input().split())
if a[1]%a[0]==0:
    print(a[0]+a[1])
else:
    print(a[1]-a[0])
Problem p03126 (python)

Fixed submission:
number=list(map(int,input().split()))
likes=[]
result=0
for i in range(number[0]):
    rawdata=list(map(int,input().split()))
    for k in range(rawdata[0]):
        likes.append(rawdata[k+1])
for i in range(number[1]):
    if likes.count(i+1)==number[0]:
        result+=1
print(result)

Buggy submission (verdict: Runtime Error):
number=list(map(int,input().split()))
likes=[]
result=0
for i in range(number[0]):
    for j in range(number[1]):
        rawdata=list(map(int,input().split()))
        for k in range(rawdata[0]):
            likes.append(rawdata[k+1])
for i in range(number[1]):
    if likes.count(i+1):
        result+=1
print(result)

Buggy submission (verdict: Runtime Error):
number=list(map(int,input().split()))
likes=[]
result=0
for i in number[0]:
    for j in number[1]:
        rawdata=list(map(int,input().split()))
        for k in rawdata[0]:
            likes.append(rawdata[k+1])
for i in number[1]:
    if likes.count(i+1):
        result+=1
print(result)
Problem p03128 (python)

Fixed submission:
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
a.reverse()
dp=[0]*(n+1)
ans=[0]*(n+1)
num=[0,2,5,5,4,5,6,3,7,6]
INF=10**18
for i in range(1,n+1):
  stack=[]
  chance=[]
  for j in a:
    if i-num[j]>=0:
      stack.append(dp[i-num[j]])
      chance.append([dp[i-num[j]],ans[i-num[j]]])
    else:
      stack.append(-INF)
      chance.append([-1,-1])
  dp[i]=max(stack)+1
  if dp[i]>0:
    for v in range(len(stack)):
      if stack[v]==max(stack):
        ans[i] += chance[v][1]+a[v]*10**(dp[i]-1)
        break
print(ans[n])

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))
dp=[0]*(n+1)
ans=[0]*(n+1)
num=[0,2,5,5,4,5,6,3,7,6]
INF=10**18
for i in range(1,n+1):
  stack=[]
  for j in m:
    if i-num[j]>=0:
      stack.append(dp[i-num[j]])
    else:
      stack.append(-INF)
  dp[i]=max(stack)+1
  if dp[i]>0:
    ans[i] += ans[i-num[stack.index(max(stack))]]+num[stack.index(max(stack))]*10**(dp[i]-1)
print(ans[n])
Problem p03136 (python)

Fixed submission:
n=int(input())
array=list(map(int,input().split()))
array.sort()
sum=0
for i in range(n-1):
  sum+=array[i]
if array[n-1]<sum:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n=int(input())
array=[]
for i in range(n):
  k=int(input())
  array.append(k)
array.sort()
sum=0
for i in range(n-1):
  sum+=array[i]
if array[n-1]<sum:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n=int(input())
array=[]
for i in range(n):
  k=int(input())
  array.append(k)
array.sorted()
sum=0
for i in range(n-1):
  sum+=array[i]
if array[n-1]<sum:
  print('Yes')
else:
  print('No')
Problem p03138 (python)

Fixed submission:
#入力
n,k=map(int,input().split())
a=list(map(int,input().split()))
bits=list(bin(k+1)[2:])
bits=list(map(int,bits))
stack=[0]*40
ans=0
#各bitごとの1の総数を保存
for i in a:
  num=bin(i)[2:]
  for j in range(len(num)):
    if num[j]=="1":
      stack[len(num)-j-1]+=1
#xがk+1より小さいならば、どこかのbitでxが0、k+1が1となるところがあるはず
#さらにそれより下位のbitでは1と0どちらにしても大小関係が変化しないので貪欲に求まる
for i in range(len(bits)):
  possible_ans=[q for q in bits]
  ans_stack=0
  #上からi番目のbitが変換点であると仮定
  #もしそのbitが0なら変換点にはなり得ない
  if possible_ans[i]==0:
    continue
  possible_ans[i]=0
  #stackは一番最初が一番小さいbitとなる
  #possible_ansのi桁目はstackのlen(bits)-i+1桁目に相当
  for j in range(40):
    if j<len(bits)-i-1:
      ans_stack+=max(stack[j]*2**j,(n-stack[j])*2**j)
    elif j<len(bits) and possible_ans[len(bits)-j-1]==1:
      ans_stack+=(n-stack[j])*2**j
    else:
      ans_stack+=stack[j]*2**j
  ans=max(ans,ans_stack)
#出力
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
if k==0:
  print(sum(a))
  exit()
count=[0]*41
for i in range(n):
  x=int(bin(a[i])[2:])
  for j in range(len(bin(a[i])[2:])):
    count[i]+=(x%10)
    x=x//10
ans=0
y=len(bin(max(a))[2:])
for i in range(len(bin(k)[2:])):
  if count[i]*2>=n:
    ans+=count[i]*(2**i)
  else:
    ans+=(n-count[i])*(2**i)
for i in range(len(bin(k)[2:]),y):
  ans+=count[i]*(2**i)
print(ans)
Problem p03147 (python)

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
count=0
while h.count(0)!=len(h):
  stack=[]
  substack=[]
  for i in range(len(h)):
    if h[i]!=0:
      substack.append(h[i])
    else:
      if len(substack)>0:
        stack.append(substack)
      stack.append([0])
      substack=[]
  if len(substack)>0:
    stack.append(substack)
  h=[]
  for i in range(len(stack)):
    if max(stack[i])==0:
      h+=stack[i]
      continue
    x=min(stack[i])
    count+=x
    for j in range(len(stack[i])):
      stack[i][j]-=x
    h+=stack[i]
print(count)

Buggy submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
count=0
while h.count(0)!=len(h):
  stack=[]
  substack=[]
  for i in range(len(h)):
    if h[i]!=0:
      substack.append(i)
    else:
      substack.append(i)
      stack.append(substack)
      substack=[]
  h=[]
  for i in range(len(stack)):
    count+=min(i)
    h+=i
print(count)
Problem p03212 (python)

Fixed submission:
n=int(input())
x=[0,3,5,7]
p=[]
flag=True
flag2=True
for c1 in x:
  for c2 in x:
    for c3 in x:
      for c4 in x:
        for c5 in x:
          for c6 in x:
            for c7 in x:
              for c8 in x:
                for c9 in x:
                  line=[c1,c2,c3,c4,c5,c6,c7,c8,c9]
                  sum_=0
                  if line.count(7)>0 and line.count(3)>0 and line.count(5)>0:
                    for i in range(9):
                      if flag==False and line[i] in [3,5,7]:
                        flag2=False
                        break
                      if line[i]==0:
                        flag=False
                      sum_+=line[i]*10**i
                    if flag2==False:
                      flag=True
                      flag2=True
                      continue
                    p.append(sum_)
                    flag=True
p.sort()
for i in range(len(p)):
  if p[i]>n:
    print(i)
    exit()
print(i+1)

Buggy submission (verdict: Runtime Error):
n=input()
x=[0,3,5,7]
p=[]
for c1 in x:
  for c2 in x:
    for c3 in x:
      for c4 in x:
        for c5 in x:
          for c6 in x:
            for c7 in x:
              for c8 in x:
                for c9 in x:
                  line=[c1,c2,c3,c4,c5,c6,c7,c8,c9]
                  sum_=0
                  if line.count(7)>0 and line.count(3)>0 and line.count(5)>0:
                    for i in range(9):
                      sum_+=line[i]*10**i
                    p.append(sum_)
p.sort()
for i in range(len(p)):
  if p[i]>n:
    print(i)
Problem p03238 (python)

Fixed submission:
n=int(input())
if n==1:
  print("Hello World")
else:
  a=int(input())
  b=int(input())
  print(a+b)

Buggy submission (verdict: Runtime Error):
import sys
n=int(input())
s=[[int(i) for i in l.split()] for l in sys.stdin]
for cx in range(101):
  for cy in range(101):
    flag=True
    flag2=True
    stack2==10**18
    for i in range(n):
      if flag==False:
        break
      x,y,h=s[i]
      H=abs(x-cx)+abs(y-cy)+h
      if h!=0 and flag2:
        stack=H
        flag2=False
      if h==0:
        stack2=min(stack2,H)
      if h!=0 and flag2==False:
        if stack!=H:
          flag=False
          break
    if flag and stack<=stack2:
      print(cx,cy,H)
      exit()
Problem p03255 (python)

Fixed submission:
n,x=map(int,input().split())
line=list(map(int,input().split()))
Sum=[0]
sum=0
for i in range(n):
  sum+=line.pop()
  Sum.append(sum)
Ans=10**18
for k in range(1,n):
  p=0
  for i in range(n+k-1//k):
    if i==0:
      if n>=k:
        p+= (Sum[k])*5
      else:
        p+=(Sum[n])*5
        break
    else:
      if n> (k*i +k):
        p+= (Sum[k*i +k]-Sum[k*(i-1) +k])*(2*i +3)
      else:
        p+= (Sum[n]-Sum[k*(i-1) +k])*(2*i +3)
        break
  ans=(n+k)*x + p
  Ans=min(Ans,ans)
print(Ans)

Buggy submission (verdict: Runtime Error):
#入力
n,x=map(int,input().split())
line=list(map(int,input().split()))
#累積和を計算しておく
#はじめに0を入れておくと、右からi番目で計算できる(i-1としなくて良い)
Sum=[0]
sum=0
#lineの後ろから値を取って、sumに足してlistに入れる
for i in range(n):
  sum+=line.pop()
  Sum.append(sum)
#大きい数で初期化(今回は小さい数の方が選ばれるので、十分大きい数で)
Ans=10**18
#それぞれのkについてコストを計算
for k in range(1,n):
  #pは純粋な移動のみのコスト
  p=0
  #kで割り切れる時は、n//k -1個のグループが出来る(最初は2kでグループを作る)
  #kで割り切れない時は、n//k 個のグループが出来る
  #よってn-1しておけばkで割り切れる時だけ-1出来る
  for i in range((n-1)//k):
    #はじめだけ処理が異なる
    if i==0:
      if n>=2k:
        p+= (Sum[k])*5
      #2kの長さがなければ最初から最後まで足して終わり
      else:
        p+=(Sum[n])*5
        break
    else:
      if n> (k*i +2*k):
        #(i+1)*k+1から(i+2)*kまでの座標の和に移動コストをかける
        p+= (Sum[k*i +2*k]-Sum[k*(i-1) +2*k])*(2*i +5)
      else:
        p+= (Sum[n]-Sum[k*(i-1) +2*k])*(2*i +5)
        break
  #n*xが1)のコスト、k*xが2)のコスト
  ans=(n+k)*x + p
  #小さい方をAnsに代入
  Ans=min(Ans,ans)
#答え
print(Ans)
Problem p03262 (python)

Fixed submission:
n,x=map(int,input().split())
X=list(map(int,input().split()))
for i in range(n):
  X[i]=abs(X[i]-x)
def gcd(p,q):
  if q==0:
    return p
  else:
    return gcd(q,p%q)
stack=X[0]
for i in range(n-1):
  stack=gcd(stack,X[i+1])
print(stack)

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
X=list(map(int,input().split()))
for i in range(n):
  X[i]=abs(X[i]-x)
def gcd(x,y):
  if y==0:
    return x
  else:
    return(y,x%y)
stack=X[0]
for i in range(n-1):
  stack=gcd(stack,X[i+1])
print(stack)

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
X=list(map(int,input().split()))
for i in X:
  i=abs(i-x)
def gcd(x,y):
  if y==0:
    return x
  else:
    return(y,x%y)
stack=X[0]
for i in range(n-1):
  stack=gcd(stack,X[i+1])
print(stack)
Problem p03273 (python)

Fixed submission:
h,w=map(int,input().split())
grid=[]
grid2=[]
grid3=[]
for i in range(h):
  grid.append(list(input().replace(" ","")))
for i in range(len(grid)):
  if grid[i].count('.')==len(grid[i]):
    pass
  else:
    grid2.append(grid[i])
for i in grid2:
  grid3.append([])
for j in range(len(grid2[0])):
  for i in range(len(grid2)):
    if grid2[i][j]=='#':
      for k in range(len(grid3)):
        grid3[k].append(grid2[k][j])
      break
for i in grid3:
  print(''.join(i))

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
grid=[]
for i in range(h):
  grid.append(list(map(int,input().split())))
for i in range(grid):
  if grid[i].count('.')==len(grid[i]):
    grid.pop(i)
for j in range(grid[0]):
  for i in range(len(grid)):
    if grid[i][j]!='#':
      break
  for i in range(len(grid)):
    grid[i].pop(j)
for i in grid:
  print(' '.join(map(str,i)))
Problem p03293 (python)

Fixed submission:
from collections import deque
s=list(input())
s=deque(s)
t=input()
for i in range(len(s)):
  if ''.join(s)==t:
    print("Yes")
    exit()
  s.append(s.popleft())
print("No")

Buggy submission (verdict: Runtime Error):
import deque from collections
s=list(input())
s=deque(s)
t=input()
fot i in range(len(s)):
  if ''.join(s)==t:
    print("Yes")
    exit()
  s.append(s.popleft())
print("No")
Problem p03296 (python)

Fixed submission:
n=int(input())
slime=list(map(int,input().split()))
stack=0
count=0
ans=0
for i in slime:
  if i!=stack:
    stack=i
    ans+=((count+1)//2)
    count=0
    continue
  count+=1
  stack=i
ans+=((count+1)//2)
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
slime=list(map(int,input().split()))
stack=0
ans=0
for i in slime:
  if i!=stack:
    stack=i
    ans+=(count+1//2)
    count=0
    continue
  count+=1
ans+=(count+1//2)
print(ans)
Problem p03297 (python)

Fixed submission:
t=int(input())
def gcd(x,y):
  if y==0:
    return x
  else:
    return gcd(y,x%y)
for i in range(t):
  a,b,c,d=map(int,input().split())
  if a<b:
    print("No")
  elif b>d:
    print("No")
  elif c>b:
    print("Yes")
  else:
    if b-gcd(b,d)+a%gcd(b,d)>c:
      print("No")
    else:
      print("Yes")

Buggy submission (verdict: Runtime Error):
t=int(input())
def gcd(x,y):
  if y==0:
    return x
  else:
    return gcd(y,x%y)
for i in range(t):
  a,b,c,d=map(int,input().split())
  if a<b:
    print("No")
  elif b>d:
    print("No")
  elif c>b:
    print("Yes")
  else:
    if b-gcd(b,d)+a%gcd(b,y)>c:
      print("No")
    else:
      print("Yes")

Buggy submission (verdict: Runtime Error):
t=int(input())
for i in range(t):
  a,b,c,d=map(int,input().split())
  if a<b:
    print("No")
  elif d<=b:
    if d<b:
      print("No")
    else:
      if a-(a//b)*b<=c:
        if d>b+c:
          p=0
        else:
          p= (c+b-d)//(d-b) +1
        if (d+(d-b)*p)%b<=c:
          print("Yes")
        else:
          print("No")
      else:
        print("No")
  else:
    if a>b+c:
      p=0
    else:
      p= (c+b-a)//(d-b) +1
    if (a+(d-b)*p)%b<=c:
      if d>b+c:
        p=0
      else:
        p= (c+b-d)//(d-b) +1
      if (d+(d-b)*p)%b<=c:
        print("Yes")
      else:
        print("No")
    else:
      print("No")

Buggy submission (verdict: Runtime Error):
t=int(input())
for i in range(t):
  a,b,c,d=map(int,input().split())
  if a<b:
    print("No")
  elif d<=b:
    if d<b:
      print("No")
    else:
      if a-(a//b)*b<=c:
        print("Yes")
      else:
        print("No")
  else:
    if a>b+c:
      p=0:
    else:
      p= (c+b-a)//(d-b) +1
    if (a+(d-b)*p)%b<=c:
      print("Yes")
    else:
      print("No")
Problem p03309 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[0]
c=[0]
d=[0]
e=[0]
count=0
count2=0
count3=0
count4=0
for i in range(n):
  a[i]-=i
a.sort()
for i in range(n-1):
  count+=a[i+1]-a[i]
  count3+=a[n-i-1]-a[n-i-2]
  b.append(count)
  d.append(count3)
for i in range(n-1):
  count2+=b[i+1]
  count4+=d[i+1]
  c.append(count2)
  e.append(count4)
ans=10**18
for i in range(n):
  ans=min(ans,c[-1]-c[i]-b[i]*(n-i-1)+e[-1]-e[n-i-1]-d[n-i-1]*i)
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
  a[n]-=i
x=sum(a)//n
ans=0
for i in a:
  ans+=abs(i-x)
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
  a[n]-=i
x=sum(a)//n
ans=0
for i in a:
  ans+=abs(i-x)
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
  a[n]-=i
x=sum(a)//n
ans=0
for i in a:
  ans+=abs(i-b)
print(ans)