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

Fixed submission:
n=int(input())
a=[int(j) for j in input().split()]
a.sort()
ans=[]
p=a[0]
q=a[-1]
for i in a[1:-1]:
    if i<0:
        ans.append([q,i])
        q-=i
    else:
        ans.append([p,i])
        p-=i
ans.append([q,p])
print(q-p)
for i,j in ans:
    print(i,j)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(i) for i in input().split()]
ans=0
a.sort()
a.reverse()
if n%2==0:
    p=n//2
else:
    p=n//2+1
c=1
lp=[]
lm=[]
for i in a:
    if i>0 and c<=p:
        ans+=i
        lp.append(i)
    else:
        ans-=i
        lm.append(i)
    c+=1
print(ans)
llp=len(lp)
llm=len(lm)
q=lm[0]
i=0
j=0
k=0
o=0

for i in range(llp-1):
    print(q,lp[i])
    q=q-lp[i]
print(lp[-1],q)
q=lp[-1]-q
for i in range(1,llm):
    print(q,lm[i])
    q=q-lm[i]

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(i) for i in input().split()]
ans=0
a.sort()
a.reverse()
if n%2==0:
    p=n//2
else:
    p=n//2+1
c=1
lp=[]
lm=[]
for i in a:
    if i>0 and c<=p:
        ans+=i
        lp.append(i)
    else:
        ans-=i
        lm.append(i)
    c+=1
print(ans)
llp=len(lp)
llm=len(lm)
q=[]
i=0
j=0
k=0
o=0
while o==0:
    if llp>llm:
        if lp!=[] and lm!=[]:
            lm.append(-lp[0]+lm[0])
            print(lm[0],lp[0])
            del lp[0]
            del lm[0]
        elif lm!=[]:
            print(lm[0],lm[-1])
            del lm[0]
            del lm[-1]
        else:
            o=1
    else:
        if lp!=[] and lm!=[]:
            lp.append(lp[0]-lm[0])
            print(lp[0],lm[0])
            del lp[0]
            del lm[0]
        elif lp!=[]:
            print(lp[0],lp[-1])
            del lp[0]
            del lp[-1]
        else:
            o=1
Problem p03032 (python)

Fixed submission:
n,k=map(int,input().split())
v=[int(i) for i in input().split()]
ans=[]

for i in range(min(n,k)+1):
    for j in range(min(n,k)-i+1):
        d=k-i-j
        l=v[0:i]
        r=v[n-j:n]
        p=r+l
        q=[]
        s=sum(p)
        for x in p:
            if x<0:
                q.append(x)
        q.sort()
        for x in range(min(len(q),d)):
            s-=q[x]
        ans.append(s)
        
print(max(ans))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
v=[int(i) for i in input().split()]
ans=[]

for i in range(min(n,k)+1):
    for j in range(min(n,k)-i+1):
        d=k-i-j
        l=v[0:i]
        r=v[n-j:n]
        p=r+l
        q=[]
        s=sum(p)
        for x in p:
            if x<0:
                q.append(x)
        q.sort()
        for x in range(d):
            s-=q[x]
        ans.append(s)
        
print(max(ans))
Problem p03128 (python)

Fixed submission:
n,m=map(int,input().split())
a=[int(i) for i in input().split()]
cost=[2,2,5,5,4,5,6,3,7,6]

dp=[0 for i in range(n+1)]

for i in range(1,n+1):
    p=0
    for j in a:
        if i-cost[j]>=0 and (dp[i-cost[j]]!=0 or i-cost[j]==0):
            p=max(p,int(dp[i-cost[j]]*10+j))
    dp[i]=p

print(dp[n])

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

c=[0,2,5,5,4,5,6,3,7,6]

dp=["" for i in range(n+10)]
for i in a:
    dp[c[i]]=str(i)

for i in range(n):
    for j in a:
        if dp[i]!="":
            dp[i+c[j]]=str(max(int(float(dp[i]+str(j))),int(float("0"+dp[i+c[j]]))))

print(int(dp[n]))
Problem p03157 (python)

Fixed submission:
h,w=[int(j) for j in input().split()]
s=[input()for i in range(h)]
par=[-1 for i in range(h*w)]    #par<0なら自身が親で要素の個数、>0なら子で親の位置示す
def root(a):
    if par[a]<0:
        return a
    else:
        return root(par[a])

def size(a):
    return -par[root(a)]

def connect(a,b):
    a=root(a)
    b=root(b)
    if a==b:
        return False
    if size(a)<size(b):
        a,b=b,a
    par[a]+=par[b]
    par[b]=a
    return True

for i in range(h):
    for j in range(w):
        for x,y in [(1,0),(-1,0),(0,1),(0,-1)]:
            p,q=i+x,j+y
            if 0<=p<h and 0<=q<w:
                if s[p][q]!=s[i][j]:
                    if root(w*p+q)!=root(w*i+j):
                        connect(w*p+q,w*i+j)

from collections import Counter
c=Counter()
for i in range(h):
    for j in range(w):
        p=i*w+j
        q=root(p)
        if c[q]==0:
            c[q]=[0,0]
        if s[i][j]=="#":
            c[q][0]+=1
        else:
            c[q][1]+=1
ans=0
for i in c:
    ans+=c[i][0]*c[i][1]
print(ans)

Buggy submission (verdict: Runtime Error):
h,w=[int(j) for j in input().split()]
s=[input()for i in range(h)]
ans=0
def f(i,j,se):
    se.add((i,j))
    res=0
    b=True
    for x,y in [(1,0),(-1,0),(0,1),(0,-1)]:
        p,q=i+x,j+y
        if 0<=p<h and 0<=q<w:
            if s[p][q]!=s[i][j] and (p,q) not in se:
                b=False
                res+=f(p,q,se)
    if b:
        if s[i][j]==".":
            return 1
        else:
            return 0
    else:
        if s[i][j]==".":
            return res+1
        else:
            return res

for i in range(h):
    for j in range(w):
        if s[i][j]=="#":
            ans+=f(i,j,set())

print(ans)

Buggy submission (verdict: Runtime Error):
h,w=[int(j) for j in input().split()]
s=[input()for i in range(h)]
ans=0
def f(i,j,se):
    se.add((i,j))
    res=0
    b=True
    for x,y in [(1,0),(-1,0),(0,1),(0,-1)]:
        p,q=i+x,j+y
        if 0<=p<h and 0<=q<w:
            if s[p][q]!=s[i][j] and (p,q) not in se:
                b=False
                res+=f(p,q,se)
    if b:
        if s[i][j]==".":
            return 1
        else:
            return 0
    else:
        if s[i][j]==".":
            return res+1
        else:
            return res

for i in range(h):
    for j in range(w):
        if s[i][j]=="#":
            ans+=f(i,j,set())

print(ans)
Problem p03166 (python)

Fixed submission:
n,m=map(int,input().split())
l=[[] for i in range(n)]
for i in range(m):
    p=[int(j) for j in input().split()]
    l[p[1]-1].append(p[0]-1)

dp=[-1]*n
import sys
sys.setrecursionlimit(10**6)
def f(v):
    if dp[v]!=-1:
        return dp[v]
    p=0
    for i in l[v]:
        p=max(p,f(i)+1)
    dp[v]=p
    return dp[v]

for i in range(n):
    f(i)

print(max(dp))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=[[] for i in range(n)]
for i in range(m):
    p=[int(j) for j in input().split()]
    l[p[1]-1].append(p[0]-1)

dp=[-1 for i in range(n+1)]

def f(v):
    if dp[v]!=-1:
        return dp[v]
    p=0
    for i in l[v]:
        p=max(p,f(i)+1)
    dp[v]=p
    return dp[v]

for i in range(n):
    f(i)

print(max(dp))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=[[] for i in range(n)]
for i in range(m):
    p=[int(j) for j in input().split()]
    l[p[1]-1].append(p[0]-1)

dp=[-1 for i in range(n+1)]
from functools import lru_cache
@lru_cache(maxsize=1000000)
def f(v):
    if dp[v]!=-1:
        return dp[v]
    p=0
    for i in l[v]:
        p=max(p,f(i)+1)
    dp[v]=p
    return dp[v]

for i in range(n):
    f(i)

print(max(dp))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=[[] for i in range(n)]
for i in range(m):
    p=[int(j) for j in input().split()]
    l[p[1]-1].append(p[0]-1)

dp=[-1 for i in range(n+1)]
from functools import lru_cache
@lru_cache(maxsize=1000000)
def f(n):
    if dp[n]!=-1:
        return dp[n]
    p=0
    for i in l[n]:
        p=max(p,f(i)+1)
    dp[n]=p
    return dp[n]

for i in range(n):
    f(i)

print(max(dp))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=[[] for i in range(n)]
for i in range(m):
    p=[int(j) for j in input().split()]
    l[p[1]-1].append(p[0]-1)

dp=[0 for i in range(n)]
from functools import lru_cache
@lru_cache(maxsize=1000000)
def f(n):
    if dp[n]!=0:
        return dp[n]
    for i in l[n]:
        dp[n]=max(dp[n],f(i)+1)
    return dp[n]

for i in range(n):
    f(i)

print(max(dp))
Problem p03171 (python)

Fixed submission:
n=int(input())
a=[int(j) for j in input().split()]
dp=[[0]*(n+1) for i in range(n+1)]

for i in range(n)[::-1]:
    for j in range(i,n):
        if (n+i-j-1)%2==0:
            dp[i][j]=max(dp[i+1][j]+a[i],dp[i][j-1]+a[j])
        else:
            dp[i][j]=min(dp[i+1][j]-a[i],dp[i][j-1]-a[j])
print(dp[0][n-1])

Buggy submission (verdict: Runtime Error):
import subprocess as sp
import sys
code = r"""
n=int(input())
a=[int(j) for j in input().split()]
dp=[[0]*(n+1) for i in range(n+1)]

for i in range(n)[::-1]:
    for j in range(i,n):
        if (n+i-j-1)%2==0:
            dp[i][j]=max(dp[i+1][j]+a[i],dp[i][j-1]+a[j])
        else:
            dp[i][j]=min(dp[i+1][j]-a[i],dp[i][j-1]-a[j])
print(dp[0][n-1])

"""
with open("A.py","w") as f:
	f.write(code)
sp.Popen(['pypy','-std=pypy','-O2',"A.py"]).communicate()
sp.Popen(['./a.out'],stdin=sys.stdin,stdout=sys.stdout).communicate()
Problem p03173 (python)

Fixed submission:
def f():
    import sys
    import numpy as np
    input=sys.stdin.readline
    n=int(input())
    a=np.array([0]+[int(j) for j in input().split()])
    np.cumsum(a,out=a)
    dp=np.zeros((n,n+1),np.int64)

    for i in range(1,n):
        l=np.arange(n-i)
        r=np.arange(i+1,n+1)
        m=(np.arange(1,i+1)+l[:,np.newaxis]).T
        dp[l,r]=np.amin(dp[l,m]+dp[m,r],0)+a[r]-a[l]
    print(dp[0][n])
f()

Buggy submission (verdict: Runtime Error):
def f():
    import sys
    input=sys.stdin.readline
    n=int(input())
    a=[int(j) for j in input().split()]
    import numpy as np
    #dp=np.zeros((n,n,2),dtype=np.int64)
    dp=[[[0,0]for j in range(n)] for i in range(n)]

    for i in range(1,1+n):
        for j in range(n-i+1):
            #j~j+i-1
            if i==1:
                dp[j][j][1]=a[j]
                continue
            tmp=10**18
            for k in range(i-1):
                #j~j+k,j+k+1~j+i-1
                if sum(dp[j][j+k])+sum(dp[j+k+1][j+i-1])<tmp:
                    tmp=sum(dp[j][j+k])+sum(dp[j+k+1][j+i-1])
                    dp[j][j+i-1][0]=tmp
                    dp[j][j+i-1][1]=dp[j][j+k][1]+dp[j+k+1][j+i-1][1]
    print(dp[0][n-1][0])

f()
Problem p03174 (python)

Fixed submission:
import subprocess as sp
import sys
 
code = r"""
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int add(int x,int y){return(x+=y)<mod?x:x-mod;}
int sub(int x,int y){return(x-=y)>= 0?x:x+mod;}
int dp[1<<21];
int n,a[21][21];
int main(){
  scanf("%d",&n);
  for(int i=0;i<n;++i){
    for(int j=0;j<n;++j){
      scanf("%d",&a[i][j]);
    }
  }
  dp[0]=1;
  for(int b=1;b<(1<<n);++b){
    int bc=__builtin_popcount(b)-1;
    for(int i=0;i<n;++i){
      if((b>>i&1)&&a[bc][i]){
        dp[b]=add(dp[b],dp[b^(1<<i)]);
      }
    }
  }
  printf("%d\n",dp[(1<<n)-1]);
}
"""
 
with open("A.cpp","w") as f:
	f.write(code)
    
sp.Popen(['g++','-std=c++11','-O2',"A.cpp"]).communicate()
sp.Popen(['./a.out'],stdin=sys.stdin,stdout=sys.stdout).communicate()

Buggy submission (verdict: Runtime Error):
from subprocess import*
with open('Main.cpp','w')as f:f.write(r"""
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int add(int x,int y){return(x+=y)<mod?x:x-mod;}
int sub(int x,int y){return(x-=y)>= 0?x:x+mod;}
int dp[1<<21];
int n,a[21][21];
int main(){
  scanf("%d",&n);
  for(int i=0;i<n;++i){
    for(int j=0;j<n;++j){
      scanf("%d",&a[i][j]);
    }
  }
  dp[0]=1;
  for(int b=1;b<(1<<n);++b){
    int bc=__builtin_popcount(b)-1;
    for(int i=0;i<n;++i){
      if((b>>i&1)&&a[bc][i]){
        dp[b]=add(dp[b],dp[b^(1<<i)]);
      }
    }
  }
  printf("%d\n",dp[(1<<n)-1]);
}
""")
call(('g++','Main.cpp'))
call(('./a'))
Problem p03175 (python)

Fixed submission:
import sys
input=sys.stdin.readline
mod=10**9+7

n=int(input())
e=[[] for i in range(n)]
dp=[[0,0] for i in range(n)]
for i in range(n-1):
    a,b=[int(j)-1 for j in input().split()]
    e[a].append(b)
    e[b].append(a)

par=[-1]*(n)
l=[]
from collections import deque
q=deque([0])
while q:
    p=q.pop()
    l.append(p)
    for i in e[p]:
        if i==par[p]:
            continue
        par[i]=p
        q.append(i)

dpw=[1]*(n+1)
dpb=[1]*(n+1)

for i in l[::-1]:
    w=dpw[i]
    b=dpb[i]
    p=par[i]
    dpw[p]*=(b+w)
    dpw[p]%=mod
    dpb[p]*=w
    dpb[p]%=mod

print((dpw[0]+dpb[0])%mod)

Buggy submission (verdict: Runtime Error):
n=int(input())
mod=10**9+7
l=[[]for i in range(n+1)]
for i in range(n-1):
    a,b=map(int,input().split())
    l[a].append(b)
    l[b].append(a)
def dp(x,par):
    res_w,res_t=1,1
    for y in l[x]:
        if y==par:
            continue
        w,t=dp(y,x)
        res_w=(res_w*w)%mod
        res_t=(res_t*t)%mod
    w,t=res_t,(res_t+res_w)%mod
    return w,t
print(dp(1,0)[1])
Problem p03229 (python)

Fixed submission:
n=int(input())
l=[]
for i in range(n):
    l.append(int(input()))
l.sort()
if n%2==0:
    ln=l[:n//2]
    lx=l[n//2:]
    print(2*(sum(lx)-sum(ln))-lx[0]+ln[-1])
else:
    ln=l[:n//2]
    lm=l[n//2]
    lx=l[n//2+1:]
    p=sum(lx)
    q=sum(ln)
    print(max(2*(p-q)+ln[-1]-lm,2*(p-q)-lx[0]+lm))

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

a=[]

for i in range(n):
    b=int(input())
    a.append(b)
    
a.sort()

ans=["" for i in range(n)]

ans[n//2]=a[-1]
a.remove(a[-1])
l=(n//2)-1
r=(n//2)+1
num=0
for i in range(n-1):
    if i%4==0:
        ans[l]=a[0]
        a.remove(a[0])
        num+=abs(ans[l+1]-ans[l])
        l-=1
    elif i%4==1:
        ans[r]=a[0]
        a.remove(a[0])
        num+=abs(ans[r]-ans[r-1])
        r+=1
    elif i%4==2:
        ans[l]=a[-1]
        a.remove(a[-1])
        num+=abs(ans[l+1]-ans[l])
        l-=1
    elif i%4==3:
        ans[r]=a[-1]
        a.remove(a[-1])
        num+=abs(ans[r]-ans[r-1])
        r-=1

ans.append(ans[0]) 
num+=abs(ans[-1]-ans[-2])    

num-=min(abs(ans[0]-ans[1]),abs(ans[-1]-ans[-2]),abs(ans[-2]-ans[-3]))
        
print(num)

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

a=[]

for i in range(n):
    b=int(input())
    a.append(b)
    
a.sort()

ans=["" for i in range(n)]

ans[n//2]=a[-1]
a.remove(a[-1])
l=(n//2)-1
r=(n//2)+1

for i in range(n-1):
    if i%4==0:
        ans[l]=a[0]
        a.remove(a[0])
        l-=1
    elif i%4==1:
        ans[r]=a[0]
        a.remove(a[0])
        r+=1
    elif i%4==2:
        ans[l]=a[-1]
        a.remove(a[-1])
        l-=1
    elif i%4==3:
        ans[r]=a[-1]
        a.remove(a[-1])
        r-=1

ans.append(ans[0])     
num=0
num2=0
num3=0


for i in range(n):
    num+=abs(ans[i]-ans[i+1])

num-=min(abs(ans[0]-ans[1]),abs(ans[-1]-ans[-2]),abs(ans[-2]-ans[-3]))
        
print(num)

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

a=[]

for i in range(n):
    b=int(input())
    a.append(b)
    
a.sort()

ans=["" for i in range(n)]

ans[n//2]=a[-1]
a.remove(a[-1])
l=(n//2)-1
r=(n//2)+1

for i in range(n-1):
    if i%4==0:
        ans[l]=a[0]
        a.remove(a[0])
        l-=1
    elif i%4==1:
        ans[r]=a[0]
        a.remove(a[0])
        r+=1
    elif i%4==2:
        ans[l]=a[-1]
        a.remove(a[-1])
        l-=1
    elif i%4==3:
        ans[r]=a[-1]
        a.remove(a[-1])
        r-=1

ans.append(ans[0])     
num=0
num2=0
num3=0


for i in range(n-1):
    num+=abs(ans[i]-ans[i+1])

for i in range(n-1):
    num2+=abs(ans[i+1]-ans[i+2])

for i in range(n-1):
    if i==0:
        num3+=abs(ans[-2]-ans[0])
    else:
        num3+=abs(ans[i]-ans[i-1])
        
print(max(num,num2,num3))
Problem p03240 (python)

Fixed submission:
n=int(input())
xyh=[]
h0=[]
for i in range(n):
    a=[int(j) for j in input().split()]
    xyh.append(a)

from operator import itemgetter
xyh.sort(key=itemgetter(2))
xyh.reverse()

for x in range(101):
    for y in range(101):
        p=0
        l=max(0,xyh[0][2]+abs(x-xyh[0][0])+abs(y-xyh[0][1]))
        for i in range(n):
            if xyh[i][2]==0:
                if l>abs(x-xyh[i][0])+abs(y-xyh[i][1]):
                    p=1
                    break
                else:
                    continue
            if l==max(0,xyh[i][2]+abs(x-xyh[i][0])+abs(y-xyh[i][1])):
                l=max(0,xyh[i][2]+abs(x-xyh[i][0])+abs(y-xyh[i][1]))
            else:
                p=1
                break
        if p==0:
            print(x,y,l)
            import sys
            sys.exit()

Buggy submission (verdict: Runtime Error):
n=int(input())
xyh=[]
h0=[]
for i in range(n):
    a=[int(j) for j in input().split()]
    xyh.append(a)

for x in range(101):
    for y in range(101):
        p=0
        l=max(0,xyh[0][2]+abs(x-xyh[0][0])+abs(y-xyh[0][1]))
        for i in range(n):
            if xyh[i][2]==0:
                if l>abs(x-xyh[i][0])+abs(y-xyh[i][1]:
                    p=1
                    break
                else:
                    continue
            if l==max(0,xyh[i][2]+abs(x-xyh[i][0])+abs(y-xyh[i][1])):
                l=max(0,xyh[i][2]+abs(x-xyh[i][0])+abs(y-xyh[i][1]))
            else:
                p=1
                break
        if p==0:
            print(x,y,l)
            import sys
            sys.exit()

Buggy submission (verdict: Runtime Error):
n=int(input())
xyh=[]
for i in range(n):
    a=[int(j) for j in input().split()]
    if a[2]!=0:
        xyh.append(a)

for x in range(101):
    for y in range(101):
        p=0
        l=max(0,xyh[0][2]+abs(x-xyh[0][0])+abs(y-xyh[0][1]))
        for i in range(n):
            if l==max(0,xyh[i][2]+abs(x-xyh[i][0])+abs(y-xyh[i][1])):
                l=max(0,xyh[i][2]+abs(x-xyh[i][0])+abs(y-xyh[i][1]))
            else:
                p=1
                break
        if p==0:
            print(x,y,l)
            import sys
            sys.exit()
Problem p03254 (python)

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

a=[int(i) for i in input().split()]

a.sort()
i=0
ans=0

while x>0 and i<n:
    if x-a[i]>=0:
        x-=a[i]
        ans+=1
    else:
        x=0
    if i==n-1:
        if x>0:
            ans-=1
    i+=1

print(ans)

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

a=[int(i) for i in input().split()]

a.sort()
i=0
ans=0

while x>0:
    if x-a[i]>=0:
        x-=a[i]
        ans+=1
    else:
        x=0
    i+=1

print(ans)
Problem p03262 (python)

Fixed submission:
def gcd(a, b):

	while b:

		a, b = b, a % b

	return a

n,xs=map(int,input().split())

x=[abs(int(i)-xs) for i in input().split()]

ans=x[0]
for i in range(n):
    ans=gcd(ans,x[i])

print(ans)

Buggy submission (verdict: Runtime Error):
import math

n,xs=map(int,input().split())

x=[abs(int(i)-xs) for i in input().split()]

a=x[0]
for i in range(n):
    a=math.gcd(a,x[i])

print(a)

Buggy submission (verdict: Runtime Error):
import math

n,xs=map(int,input().split())

x=[abs(int(i)-xs) for i in input().split()]


print(math.gcd(*x))

Buggy submission (verdict: Runtime Error):
import math
import reduce
n,xs=map(int,input().split())

x=[abs(int(i)-xs) for i in input().split()]

def gc(numbers):
    return reduce(math.gcd, numbers)

print(gc(x))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
n,xs=map(int,input().split())

x=[abs(int(i)-xs) for i in input().split()]

def gc(numbers):
    return reduce(math.gcd, numbers)

print(gc(x))
Problem p03273 (python)

Fixed submission:
import sys
h,w=map(int,input().split())

b=[]
d=[]
k=0
for i in range(w):
    d.append(i)

for i in range(h):
    a=input()
    if a!="."*w:
        b.append(a)
    else:
        h-=1
        
for i in range(w):
    c=0
    for j in range(h):
        if b[j][i]=="#":
            c+=1
    if c==0:
        del(d[k])
    else:
        k+=1
            
for i in range(h):
    for j in d:
       sys.stdout.write(b[i][j]) 
    print("")

Buggy submission (verdict: Runtime Error):
import sys
h,w=map(int,input().split())

b=[]
d=[]
for i in range(w):
    d.append(i)

for i in range(h):
    a=input()
    if a!="."*w:
        b.append(a)
    else:
        h-=1
        
for i in range(w):
    c=0
    for j in range(h):
        if b[j][i]=="#":
            c+=1
    if c==0:
        del(d[i])
            
for i in range(h):
    for j in d:
       sys.stdout.write(b[i][j]) 
    print("")
Problem p03280 (python)

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

print((a-1)*(b-1))

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())

print((a-1)*(b-1))
Problem p03282 (python)

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

st=str(s)
l=len(st)
i=0
a=0
n=0
m=0

while n<1:
    if int(st[m])==1:
        m+=1
        a+=1
    else:
        n=1
    if a==l:
        n=1

if a>=k:
    print(1)

else:
    while i<=l:
        if int(st[i])!=1:
            print(int(st[i]))
            i=l+1
        else:
            i+=1

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

st=str(s)
l=len(st)
i=0
a=0
n=0
m=0

while n<1:
    if int(st[m])==1:
        m+=1
        a+=1
    else:
        n=1

if a>=k:
    print(1)

else:
    while i<=l:
        if int(st[i])!=1:
            print(int(st[i]))
            i=l+1
        else:
            i+=1

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

st=str(s)
l=len(st)
i=0
a=0
n=0
m=0

while n<1:
    if int(st[m])==1:
        m+=1
        a+=1
    else:
        n=1

if a==k:
    print(1)

else:
    while i<=l:
        if int(st[i])!=1:
            print(int(st[i]))
            i=l+1
        else:
            i+=1
Problem p03283 (python)

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

l=[]
r=[]
for i in range(m):
    a,b=map(int,input().split())
    l.append(a)
    r.append(b)

p=[]
q=[]    
for i in range(Q):
    c,d=map(int,input().split())
    p.append(c)
    q.append(d)

grid=[[0]*(n+1) for i in range(n+1)]

for i in range(m):
    grid[l[i]][r[i]]+=1

for i in range(1,n+1):
    for j in range(1,n+1):
        grid[i][j]+=grid[i-1][j]
        grid[i][j]+=grid[i][j-1]
        grid[i][j]-=grid[i-1][j-1]
    
for i in range(Q):
    print(grid[q[i]][q[i]]-grid[q[i]][p[i]-1]-grid[p[i]-1][q[i]]+grid[p[i]-1][p[i]-1])

Buggy submission (verdict: Runtime Error):
l=[]
r=[]
for i in range(m):
    a,b=map(int,input().split())
    l.append(a)
    r.append(b)

p=[]
q=[]    
for i in range(Q):
    c,d=map(int,input().split())
    p.append(c)
    q.append(d)
    
for i in range(Q):
    answer=0
    for j in range(m):
        if p[i]<=l[j] and r[j]<=q[i]:
            answer+=1
    print(answer)

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

l=[]
r=[]
for i in range(m):
    a,b=map(int,input().split())
    l.append(a)
    r.append(b)

p=[]
q=[]    
for i in range(Q):
    c,d=map(int,input().split())
    p.append(c)
    q.append(d)

def ans(l,r,p,q):
    if p<=l and r<=q:
        return 1


for i in range(Q):
    answer=0
    for j in range(m):
        a=l[j]
        b=r[j]
        c=p[i]
        d=q[i]
        answer+=ans(a,b,c,d)  
    print(answer)
Problem p03284 (python)

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

if a%b==0:
    print(0)
else:
    print(1)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[]
k=0

if n==0:
    print(0)

while k<1:
    if n==0:
        k=1
    else:
        if n%2==0:
            a.append(0)
            n=n/(-2)
        else:
            a.append(1)
            n=(n-1)/(-2)
            
for i in (reversed(a)):
    print(i,end="")
Problem p03352 (python)

Fixed submission:
x=int(input())
import math
p=math.ceil(x**0.5)
ans=[1]
for i in range(2,p+1):
  j=2
  while True:
    if i**j<=x:
      ans.append(i**j)
    else:
      break
    j+=1
print(max(ans))

Buggy submission (verdict: Runtime Error):
x=int(input())
p=x**0.5
ans=[]
for i in range(1,p+1):
  j=2
  while True:
    if i**j<=x:
      ans.append(i**j)
    else:
      break
    j+=1
print(max(ans))

Buggy submission (verdict: Runtime Error):
x=int(input())
p=x**0.5
ans=[]
for i in range(1,p+1):
  j=2
  while True:
    if i**j<=p:
      ans.append(i**j)
    else:
      break
    j+=1
print(max(ans))