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

Fixed submission:
from collections import*
INF=10**18
n,d,a=map(int,input().split())
mon=[]
for _ in range(n):
  mon+=[list(map(int,input().split()))]
mon.sort()
ans=0
tot=0
q=deque()
for i in range(n):
  x,h=mon[i]
  while q and q[0][0]<x:
    tot-=q.popleft()[1]
  h-=tot
  if h>0:
    b=(h+a-1)//a
    tot+=b*a
    ans+=b
    q.append((x+2*d,b*a))
print(ans)

Buggy submission (verdict: Runtime Error):
from bisect import*
INF=10**18
n,d,a=map(int,input().split())
mon=[]
for _ in range(n):
  mon+=[list(map(int,input().split()))]
mon.sort()
i=0
ans=0
while i<n:
  j=bisect_left(mon,[mon[i][0]+2*d+1,INF])
  h=max(mon[i:j],key=lambda x:x[1])[1]
  if h!=mon[j-1][1] or i==j-1:
    ans+=(b+a-1)//a
    i=j
  else:
    h=max(mon[i:j-1],key=lambda x:x[1])[1]
    ans+=(h+a-1)//a
    mon[j-1][1]-=(h+a-1)//a*a
    if mon[j-1][1]>0:i=j-1
    else:i=j
print(ans)
Problem p02796 (python)

Fixed submission:
n=int(input())
itv=[]
for i in range(n):
  x,l=map(int,input().split())
  itv+=[(x+l,x-l)]
itv=sorted(itv)
l=-10**18
cnt=0
for t,s in itv:
  if l<=s:
    l=t
    cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[]
for i in range(n):
  x,l=map(int,input().split())
  a.append(list(range(x-l+1,x+l)))
ans=[]
while(len(a)):
  b=[]
  for i in a:
    b.append(i[-1])
  bi=b.index(min(b))
  bm=b.pop(bi)
  am=a.pop(bi)
  ans.append(am)
  for i in a:
    if bm in i:
      a.remove(i)
      
print(len(ans))
Problem p02814 (python)

Fixed submission:
from math import gcd
from functools import reduce
def lcm_base(x, y):
    return (x * y) // gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def evencount(n):
  cnt=0
  while n%2==0:
    cnt+=1
    n//=2
  return cnt
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
  a[i]//=2
if all(evencount(i) == evencount(a[0]) for i in a):
  d=lcm(*a)
  print((m+d)//2//d)
else:print(0)

Buggy submission (verdict: Runtime Error):
from math import gcd
from functools import reduce
def lcm_base(x, y):
    return (x * y) // gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def evencount(n):
  cnt=0
  while n%2==0:
    cnt+=1
    n//=2
  return cnt
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
  a[i]//=2
if all(evencount(i) == evencount(a[i]) for i in a):
  d=lcm(*a)
  print((m+d)//2//d)
else:print(0)

Buggy submission (verdict: Runtime Error):
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def evencount(n):
  cnt=0
  while n&1==0:
    cnt+=1
    i>>1
  return cnt
n,m=map(int,input().split())
a=list(map(int,input().split()))
if all(set([evencount(i) for i in a])):
  for i in range(n):
    a[i]//=2
  d=lcm(*a)
  print((m+d)//2//d)
else:print(0)
Problem p02844 (python)

Fixed submission:
n=int(input())
s=input()
cnt=0
for m in range(1000):
  m=str(m).zfill(3)
  j=0
  for i in m:
    if i not in s[j:]:break
    j+=s[j:].index(i)+1
  else:cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
cnt=0
a=[]
b=[]
for i in range(n):
  d=s[i]+s[j]
  if d in b:continue
  else:b.append(d)
  for j in range(i+1,n):
    for k in range(j+1,n):
      c=s[i]+s[j]+s[k]
      if c not in a:
        a.append(c)
        cnt+=1
print(cnt)
Problem p02845 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
m=10**9+7
b=[0]*3
ans=1
for i in a:
  ans*=b.count(i)
  ans%=m
  for j in range(3):
    if b[j]==i:
      b[j]+=1
      break
print(ans%m)

Buggy submission (verdict: Runtime Error):
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))
b=[0,0,0]
ans=1
for i in a:
  ans*=b.count(i)
  b[b.index(i)]+=1
print(ans%mod)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
m=10**9+7
b=[0]*3
ans=1
for i in a:
  ans*=b.count(i)
  ans%=m
  b[b.index(i)]+=1
print(ans%m)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
m=10**9+7
b=[-1]*3
ans=1
for i in a:
  ans*=b.count(i-1)
  ans%=m
  b[b.index(i-1)]+=1
print(ans%m)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
m=10**9+7
b=[-1]*3
ans=1
for i in a:
  ans*=b.count(i-1)
  ans%=m
  b[b.index(i-1)]+=1
print(ans%m)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
m=10**9+7
b=[-1]*3
ans=1
for i in range(0,n):
  j=a[i]
  ans*=(b.count(j-1))
  ans%=m
  b[b.index(j-1)]+=1
print(ans%m)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
m=10**9+7
b=[-1]*3
ans=1
for i in range(0,n):
  j=a[i]
  ans*=(b.count(j-1))
  b[b.index(j-1)]+=1
print(ans%m)
Problem p02922 (python)

Fixed submission:
a,b=map(int,input().split())
x=0
while True:
  if x*(a-1)+1>=b: break
  else: x+=1
print(x)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
x=0
while True:
  if x*(a-1)+1>=b: break
  else x=+1
print(x)
Problem p02936 (python)

Fixed submission:
import sys
sys.setrecursionlimit(2000)
n,q=map(int,input().split())
e=[[] for _ in range(n)]
cnt=[0]*n
for _ in range(n-1):
  a,b=map(int,input().split())
  e[a-1].append(b-1)
  e[b-1].append(a-1)
for _ in range(q):
  x,y=map(int,input().split())
  cnt[x-1]+=y
vis=[1]*n
queue=[0]
vis[0]=0
while queue:
  now=queue.pop()
  for i in e[now]:
    if vis[i]:
      queue.append(i)
      cnt[i]+=cnt[now]
      vis[i]=0
print(' '.join(map(str,cnt)))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(4000)

def dfs(now):
  v[now]=0
  for i in edge[now]:
    if v[i]:
      point[i]+=point[now]
      dfs(i)

n,q=map(int,input().split())
edge=[[] for _ in range(n)]
point=[0]*n
for i in range(n-1):
  a,b=map(int,input().split())
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)
for i in range(q):
  p,x=map(int,input().split())
  point[p-1]+=x
v=[1]*n
dfs(0)
print(*point)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(4000)

def dfs(now):
  for i in edge[now]:
    point[i]+=point[now]
    dfs(i)

n,q=map(int,input().split())
edge=[[] for _ in range(n)]
point=[0]*n
for i in range(n-1):
  a,b=map(int,input().split())
  edge[a-1].append(b-1)
for i in range(q):
  p,x=map(int,input().split())
  point[p-1]+=x
dfs(0)
print(*point)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2000)
n,q=map(int,input().split())
e=[[] for _ in range(n)]
cnt=[0]*n
for _ in range(n-1):
  a,b=map(int,input().split())
  e[a-1].append(b-1)
  e[b-1].append(a-1)
for _ in range(q):
  x,y=map(int,input().split())
  cnt[x-1]+=y

def dfs(now,vis):
  vis.append(now)
  for i in e[now]:
    if i not in vis:
      cnt[i]+=cnt[now]
      dfs(i,vis)
dfs(0,[])
print(' '.join(map(str,cnt)))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2000)
n,q=map(int,input().split())
e=[[] for _ in range(n)]
cnt=[0]*n
for _ in range(n-1):
  a,b=map(int,input().split())
  e[a-1].append(b-1)
  e[b-1].append(a-1)
for _ in range(q):
  x,y=map(int,input().split())
  cnt[x-1]+=y

def dfs(now,vis):
  vis.append(now)
  for i in e[now]:
    if i not in vis:
      cnt[i]+=cnt[now]
      dfs(i,vis)
dfs(0,[])
print(' '.join(map(str,cnt)))

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
e=[[] for _ in range(n)]
cnt=[0]*n
for i in range(n-1):
  a,b=map(int,input().split())
  e[a-1].append(b-1)
  e[b-1].append(a-1)
for _ in range(q):
  x,y=map(int,input().split())
  cnt[x-1]+=y

def dfs(now,vis):
  vis.append(now)
  for i in e[now]:
    if i not in vis:
      cnt[i]+=cnt[now]
      dfs(i,vis)
dfs(0,[])
print(' '.join(map(str,cnt)))
Problem p02963 (python)

Fixed submission:
from math import*
def fact_p(n):
  m=n
  i=2
  a=0
  while n>1:
    if i>m**.5:
      a=n
      break
    while n%i==0:
      n//=i
      a=i
    i+=1  
  return a
n=int(input())
x2=y1=ceil(n**.5+.5) if ceil(n**.5+.5)<=10**9 else 10**9
x1=fact_p(x2*y1-n)
y2=(x2*y1-n)//x1 if x1 else 0
print(0,0,x1,y1,x2,y2)

Buggy submission (verdict: Runtime Error):
from math import*
def fact_p(n):
  m=n
  i=2
  while n>1:
    if i>m**.5:
      a=n
      break
    while n%i==0:
      n//=i
      a=i
    i+=1  
  return a
n=int(input())
x2=y1=ceil(n**.5+.5) if ceil(n**.5+.5)<=10**9 else 10**9
x1=fact_p(x2*y1-n)
y2=(x2*y1-n)//x1
print(0,0,x1,y1,x2,y2)
Problem p02975 (python)

Fixed submission:
from collections import*
n=int(input())
a=list(map(int,input().split()))
ans=a[0]
for i in a[1:]:
  ans^=i
a=dict(Counter(a))
ak=list(a.keys())
if len(a)==1 and ak[0]!=0:ans=1
elif len(a)==2 and a.get(0)!=n//3:ans=1
elif len(a)==3 and not(a[ak[0]]==a[ak[1]]==a[ak[2]]==n//3):ans=1
elif len(a)>3:ans=1
print(['Yes','No'][ans>0])

Buggy submission (verdict: Runtime Error):
from collections import*
n=int(input())
a=list(map(int,input().split()))
ans=a[0]
for i in a[1:]:
  ans^=i
a=dict(Counter(a))
ak=list(a.keys())
if len(a)==1 and ak[0]!=0:ans=1
elif len(a)==2 and a.get(0)!=n//3:ans=1
elif len(a)==3 and not(a[ak[0]]==a[ak[1]]==a[ak[2]]==n//3):ans=1
elif len(a)>3:ans=1
print(['Yes','No'][ans])

Buggy submission (verdict: Runtime Error):
from collections import*
n=int(input())
a=dict(Counter(list(map(int,input().split()))))
flag=1
if n%3:flag=0
elif len(a)==1 and a.key()[0]!=0:flag=0
elif len(a)==2 and a.get(0)!=n//3:flag=0
elif len(a)==3 and not(a.key()[0]==a.key()[1]==a.key()[2]==n//3):flag==0
print(['No','Yes'][flag])
Problem p03001 (python)

Fixed submission:
w,h,x,y=map(int,input().split())
if (x,y)==(w/2,h/2):
  frag=1
else:frag=0
print(w*h/2,frag)

Buggy submission (verdict: Runtime Error):
w,h,x,y=map(int,input().split())
print(w*h/2,int(w/x==h/y==2))
Problem p03006 (python)

Fixed submission:
from collections import *
n=int(input())
x=[0]*n
y=[0]*n
for i in range(n):
  x[i],y[i]=map(int,input().split())
a=[]
for i in range(n):
  for j in range(n):
    if i==j:continue
    a+=[(x[i]-x[j],y[i]-y[j])]
c=list(Counter(a).values())
print(n-max(c) if c else n)

Buggy submission (verdict: Runtime Error):
from collections import *
n=int(input())
x=[0]*n
y=[0]*n
for i in range(n):
  x[i],y[i]=map(int,input().split())
a=[]
for i in range(n):
  for j in range(i+1,n):
    a+=[(x[i]-x[j],y[i]-y[j])]
print(n-max(list(Counter(a).values())))
Problem p03061 (python)

Fixed submission:
from math import*
n=int(input())
a=list(map(int,input().split()))
b=[a[0]]
c=[a[-1]]
for i in range(1,n):
  b+=[gcd(b[-1],a[i])]
  c+=[gcd(c[-1],a[-i-1])]
ans=0
c=c[::-1]
for i in range(n):
  if i==0:ans=max(ans,c[i+1])
  elif i==n-1:ans=max(ans,b[i-1])
  else:
    ans=max(ans,gcd(c[i+1],b[i-1]))
print(ans)

Buggy submission (verdict: Runtime Error):
from math import gcd
from functools import reduce
n=int(input())
a=list(map(int,input().split()))
ans=reduce(gcd,a[1:])
ans=max(ans,reduce(gcd,a[:n-1]))
for i in range(1,n-1):
  ans=max(gcd(reduce(gcd,a[:i]),reduce(gcd,a[i+1:])),ans)
print(ans*gc)
Problem p03068 (python)

Fixed submission:
n=int(input())
s=input()
k=int(input())
a=''
b=s[k-1]
for i in s:
  if i==b:a+=i
  else:a+='*'
print(a)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
k=int(input())
a=''
b=s[k-1]
for i in s:
  if i==b:a+=i
  else:a+=*
print(a)
Problem p03106 (python)

Fixed submission:
a,b,k=map(int,input().split())
i=min(a,b)+1
while(k):
  i-=1
  if max(a%i,b%i)==0:
    k-=1
print(i)

Buggy submission (verdict: Runtime Error):
a,b,x=map(int,input().split())
i=0
while(k):
  i+=1
  if max(a%i,a%i):
    pass
  else:
    k-=1
print(i)
Problem p03112 (python)

Fixed submission:
import bisect
INF=10**11
A,B,q=map(int,input().split())
a=[-INF]+[int(input()) for _ in range(A)]+[INF]
b=[-INF]+[int(input()) for _ in range(B)]+[INF]
for _ in range(q):
  x=int(input())
  i=bisect.bisect_left(a,x)
  j=bisect.bisect_left(b,x)
  ans=min(max(a[i],b[j])-x,x-min(a[i-1],b[j-1]),a[i]-b[j-1]+min(a[i]-x,x-b[j-1]),b[j]-a[i-1]+min(b[j]-x,x-a[i-1]))
  print(ans)

Buggy submission (verdict: Runtime Error):
import bisect
a,b,q=map(int,input().split())
INF=10**18
S=[-INF]+[int(input()) for _ in range(a)]+[INF]
T=[-INF]+[int(input()) for _ in range(b)]+[INF]
for i in range(q):
  x=int(input())
  i=bisect.bisect_left(S,x)
  j=bisect.bisect_left(T,x)
  d=INF
  for s in [S[i],S[i+1]]:
    for t in [T[i],T[j+1]]:
      d1=abs(s-x)+abs(t-s)
      d2=abs(t-x)+abs(t-s)
      d=min(d,d1,d2)
  print(d)
Problem p03166 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**5)
n,m=map(int,input().split())
edge=[[] for _ in range(n)]
dp=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  edge[a-1].append(b-1)

def dfs(s):
  if edge[s]:
    for i in edge[s]:
      if dp[i]:dp[s]=max(dp[s],dp[i]+1)
      else:dp[s]=max(dp[s],dfs(i)+1)
    return dp[s]
  else:return 0
for i in range(n):
  dfs(i)
print(max(dp))

Buggy submission (verdict: Runtime Error):
def dfs(now):
  if v[now]:return v[now]
  res=1
  for to in e[now]:
    res=max(res,dfs(to)+1)
  v[now]=res
  return res
n,m=map(int,input().split())
e=[[]for _ in range(n+1)]
for i in range(m):
  x,y=map(int,input().split())
  e[x]+=[y]
v=[0]*(n+1)
v[0]=1
ans=0
for i in range(n+1):
  ans=max(ans,dfs(i))
print(ans-1)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
edge=[[] for _ in range(n)]
dp=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  edge[a-1].append(b-1)

def dfs(s):
  if edge[s]:
    for i in edge[s]:
      if dp[i]:dp[s]=max(dp[s],dp[i]+1)
      else:dp[s]=max(dp[s],dfs(i)+1)
    return dp[s]
  else:return 0
for i in range(n):
  dfs(i)
print(max(dp))
Problem p03167 (python)

Fixed submission:
import queue
INF=10**8
R=10**9+7
h,w=map(int,input().split())
maze=[input() for _ in range(h)]
d=[[0 for i in range(h)] for _ in range(w)]
sx=0
sy=0
gx=w-1
gy=h-1
q=queue.Queue()
dx=[1,0]
dy=[0,1]
q.put((sx,sy))
d[sy][sx]=1
while not q.empty():
  x,y=q.get()
  if (x,y)==(gx,gy):break
  for i in range(2):
    nx=x+dx[i]
    ny=y+dy[i]
    if nx<w and ny<h:
      if maze[ny][nx]=='.':
        if d[nx][ny]==0:
          q.put((nx,ny))
          d[nx][ny]=d[x][y]
        else:d[nx][ny]+=d[x][y]
print(d[gx][gy]%R)

Buggy submission (verdict: Runtime Error):
import queue
INF=10**8
R=10**9+7
h,w=map(int,input().split())
maze=[input() for _ in range(h)]
d=[[0 for i in range(h)] for _ in range(w)]
sx=0
sy=0
gx=w-1
gy=h-1
q=queue.Queue()
dx=[1,0]
dy=[0,1]
q.put((sx,sy))
d[sy][sx]=1
while not q.empty():
  x,y=q.get()
  if (x,y)==(gx,gy):break
  for i in range(2):
    nx=x+dx[i]
    ny=y+dy[i]
    if nx<w and ny<h:
      if maze[ny][nx]=='.':
        if d[nx][ny]==0:
          q.put((nx,ny))
          d[nx][ny]=d[x][y]
        else:d[nx][ny]+=d[x][y]
print(d[gy][gx]%R)
Problem p03230 (python)

Fixed submission:
n=int(input())
for m in range(1,n+1):
  if m*(m+1)//2==n:break
else:
  print('No')
  exit()
a=[]
k=1
for i in range(m):
  b=[0]*m
  for j in range(i+1):
    b[j]=k
    k+=1
  a.append(b)
ans=[]
for i in range(m):
  b=[m]
  for j in range(i+1):
    b.append(a[i][j])
  for k in range(j+1,m):
    b.append(a[k][j])
  ans.append(b)
b=[m]
for i in range(m):
  b.append(a[i][i])
ans.append(b)
print('Yes')
print(len(ans))
for i in ans:
  print(*i)

Buggy submission (verdict: Runtime Error):
n=int(input())
for i in range(n):
  if i*(i+1)//2>n:
    print('No')
    exit()
  elif i*(i+1)//2==n:break
m=i
a=[[0]*m for _ in range(m)]
i=0
while n>0:
  for j in range(i+1):
    a[i][j]=n
    n-=1
  i+=1
a=a[::-1]
s=[[] for _ in range(m+1)]
for i in range(m):
  s[i]=a[i][:m-i]
  for j in range(i):
    s[i]+=[a[i-1-j][m-i-1]]
for i in range(m):
  s[-1]+=[a[i][m-i-1]]
print('Yes')
print(len(s))
for i in s:
  print(len(i),*i)
Problem p03263 (python)

Fixed submission:
h,w=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(h)]
ans=[]
for i in range(h):
  for j in range(w-1):
    if a[i][j]%2:
      a[i][j]-=1
      a[i][j+1]+=1
      ans+=[(i+1,j+1,i+1,j+2)]
for i in range(h-1):
  if a[i][w-1]%2:
    a[i][w-1]-=1
    a[i+1][w-1]+=1
    ans+=[(i+1,w,i+2,w)]
print(len(ans))
for i in ans:
  print(*i)

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(h)]
e=[]
flag=0
for i in range(h):
  if i%2:
    for j in range(w-1,-1,-1):
      if a[i][j]%2:
        flag=1
        break
  else:
    for j in range(w):
      if a[i][j]%2:
        flag=1
        break
  if flag:break
else:
  print(0)
  exit()
flag=0
y,x=i,j
while True:
  nx,ny=x,y
  if y%2:
    if x:nx=x-1
    else:ny=y+1
  else:
    if x<w-1:nx=x+1
    else:ny=y+1
  if a[y][x]%2:flag=1-flag
  if flag:e.append((y+1,x+1,ny+1,nx+1))
  if h%2:
    if (ny,nx)==(h-1,w-1):break
  else:
    if (ny,nx)==(h-1,0):break
  x,y=nx,ny
print(len(e))
for i in e:
  print(*i)

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(h)]
e=[]
flag=0
for i in range(h):
  if i%2:
    for j in range(w-1,-1,-1):
      if a[i][j]%2:
        flag=1
        break
  else:
    for j in range(w):
      if a[i][j]%2:
        flag=1
        break
  if flag:break
else:
  exit()
flag=0
y,x=i,j
while True:
  nx,ny=x,y
  if y%2:
    if x:nx=x-1
    else:ny=y+1
  else:
    if x<w-1:nx=x+1
    else:ny=y+1
  if a[y][x]%2:flag=1-flag
  if flag:e.append((y+1,x+1,ny+1,nx+1))
  if h%2:
    if (ny,nx)==(h-1,w-1):break
  else:
    if (ny,nx)==(h-1,0):break
  x,y=nx,ny
print(len(e))
for i in e:
  print(*i)

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(h)]
e=[]
flag=0
for i in range(h):
  if i%2:
    for j in range(w-1,-1,-1):
      if a[i][j]%2:
        flag=1
        break
  else:
    for j in range(w):
      if a[i][j]%2:
        flag=1
        break
  if flag:break
else:
  exit()
flag=0
y,x=i,j
while True:
  nx,ny=x,y
  if y%2:
    if x:nx=x-1
    else:ny=y+1
  else:
    if x<w-1:nx=x+1
    else:ny=y+1
  if a[y][x]%2:flag=1-flag
  if flag:e.append((y,x,ny,nx))
  if h%2:
    if (ny,nx)==(h-1,w-1):break
  else:
    if (ny,nx)==(h-1,0):break
  x,y=nx,ny
print(len(e))
for i in e:
  print(*i)
Problem p03273 (python)

Fixed submission:
h,w=map(int,input().split())
s=[input() for i in range(h)]

ans=[]
for i in range(h):
  if s[i]!='.'*w:
    ans.append(s[i])

n=len(ans)
a=['' for i in range(n)]

for i in range(w):
  sm=''
  cnt=0
  for j in range(n):
    sm+=ans[j][i]
    if ans[j][i]!='.':
      cnt+=1
  if cnt!=0:
    for k in range(n):
      a[k]+=ans[k][i]
m=len(a)
for i in range(m):
  print(a[i])

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
s=[input() for i in range(h)]

ans=[]
for i in range(h):
  if s[i]!='.'*w:
    ans.append(s[i])

n=len(ans)
a=['' for i in range(n)]

for i in range(w):
  sm=''
  cnt=0
  for j in range(n):
    sm+=ans[j][i]
    if ans[j][i]!='.':
      cnt+=1
  if cnt!=0:
    for k in range(n):
      a[k]+=ans[k][i]
m=len(a[0])
for i in range(m):
  print(a[i])
Problem p03282 (python)

Fixed submission:
import sys
s=input()
k=int(input())
if k<=100:
  if s[:k]=='1'*k:
    print(1)
    sys.exit()
for i in s:
  if i!='1':
    print(i)
    break

Buggy submission (verdict: Runtime Error):
s=input()
k=int(input())
if s[:k]=='1'*k:
  print(1)
else:
  for i in s:
    if i!='1':
      print(i)
      break
Problem p03289 (python)

Fixed submission:
s=list(input())
if s[0]!='A':
  print("WA")
elif s[2:len(s)-1].count("C")!=1:
  print('WA')
else:
  s.remove('A')
  s.remove('C')
  ns=str(s)
  if ns.islower():
    print("AC")
  else:
    print("WA")

Buggy submission (verdict: Runtime Error):
s=list(input())
if s[0]!='A':
  print("WA")
elseif s[2:len(s)-1].count("C")!=1:
  print('WA')
else:
  s.remove('A')
  s.remove('C')
  ns=str(s)
  if ns.islower():
    print("AC")
  else:
    print("WA")
Problem p03294 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
m=1
for i in a:
  m*=i
f=0
m-=1
for i in a:
  f+=m%i  
print(f)

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

m=1
for i in a:
  m*=i
f=0
m-=1
for i in a:
  f+=m%i  
print(max(f))
Problem p03342 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=0
r,l=0,0
s,x=0,0
while l<n:
  while r<n and s+a[r]==x^a[r]:
    s+=a[r]
    x^=a[r]
    r+=1
  ans+=r-l
  s-=a[l]
  x^=a[l]
  if r==l:r+=1
  l+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans=0
r,l=0,0
s,x=0,0
while l<n:
  while r<n and s+a[r]==x^a[r]:
    s+=a[r]
    x^=a[r]
    r+=1
  ans+=r-l
  s-=a[l]
  x^=a[l]
  if r==l:r+=1
  l+=1
print(ans)

ans=0
for i in range(1,n+1):
  for j in range(i+1,n+2):
    p=0
    q=0
    for k in range(i,j):
      p+=c[k]
      q^=c[k]
    ans+=p==q
    if p==q:print(i-1,j-1)
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans=0
r,l=0,0
s,x=0,0
while l<n:
  while s+a[r]==x^a[r]:
    s+=a[r]
    x^=a[r]
    r+=1
  ans+=r-l
  s-=a[l]
  x^=a[l]
  if r==l:r+=1
  l+=1
print(ans)

ans=0
for i in range(1,n+1):
  for j in range(i+1,n+2):
    p=0
    q=0
    for k in range(i,j):
      p+=c[k]
      q^=c[k]
    ans+=p==q
    if p==q:print(i-1,j-1)
print(ans)
Problem p03434 (python)

Fixed submission:
n=int(input())
x=list(map(int,input().split()))
a=0
b=0
for i in range(n//2):
  a+=max(x)
  x.remove(max(x))
  b+=max(x)
  x.remove(max(x))

if n%2:
  a+=x[0]
dif=a-b
print(dif)

Buggy submission (verdict: Runtime Error):
n-int(input())
x=list(map(int,input().split()))
a=0
b=0
for i in range(n//2):
  a+=max(x)
  x.remove(max(x))
  b+=max(x)
  x.remove(max(x))

if n%2:
  a+=x[0]
dif=b-a
print(dif)
Problem p03502 (python)

Fixed submission:
n=int(input())
f=0
frag='No'
for i in range(8):
  f+=n%(10**(i+1))//10**i
if n%f==0:
  frag='Yes'
print(frag)

Buggy submission (verdict: Runtime Error):
n=int(input())
f=0
frag='No'
for i in 8:
  f+=n%(10**(i+1))//10**i
if n%f==0:
  frag='Yes'
print(frag)
Problem p03545 (python)

Fixed submission:
a=input()
for i in ('+','-'):
  for j in ('+','-'):
    for k in ('+','-'):
      sm=a[0]+i+a[1]+j+a[2]+k+a[3]
      if eval(sm)==7:
        print(sm+'=7')
        exit()

Buggy submission (verdict: Runtime Error):
n=input()
for i in ('+','-'):
  for j in ('+','-'):
    for k in ('+','-'):
      sm=a[0]+i+a[1]+j+a[2]+k+a[3]
      if eval(sm)==7:
        print(sm+'=7')
        exit()
Problem p03548 (python)

Fixed submission:
z,y,x=map(int,input().split())
z-=x*2+y
count=1
while(1):
  z-=y+x
  if z<0:
    break
  count+=1
print(count)

Buggy submission (verdict: Runtime Error):
z,y,x=map(int,input())
z-=x
count=1
while(1):
  z-=y+x
  if z<0:
    break
  count+=1
print(count)

Buggy submission (verdict: Runtime Error):
x,y,z=map(int,input())
z-=x
count=1
while(1):
  z-=y+x
  if z<0:
    break
  count+=1
print(count)
Problem p03556 (python)

Fixed submission:
n=int(input())
i=1
while True:
  if i**2>n:
    ans=(i-1)**2
    break
  i+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
for i in range(n):
  if i**2>n:
    ans=(i-1)**2
    break
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
for i in range(n):
  if i**2>n:
    ans=(i-1)**2
    break
print(ans)
Problem p03569 (python)

Fixed submission:
s=input()
t=s.replace('x','')
n=len(t)
if not(n==1 or t[:n//2]==t[(n+1)//2:][::-1]):
  print(-1)
  exit()
n=len(s)
r=n-1
l=0
ans=0
while r>l:
  nr,nl=r,l
  while s[r]=='x' and r>0:r-=1
  while s[l]=='x' and l<n-1:l+=1
  ans+=abs(nr-r+nl-l)
  while s[r]==s[l] and l<r:
    r-=1
    l+=1
print(ans)

Buggy submission (verdict: Runtime Error):
s=input()
t=s.replace('x','')
n=len(t)
if not(n==1 or t[:n//2]==t[(n+1)//2:][::-1]):
  print(-1)
  exit()
n=len(s)
r=n-1
l=0
ans=0
while r>l:
  nr,nl=r,l
  while s[r]=='x':r-=1
  while s[l]=='x':l+=1
  ans+=abs(nr-r-nl+l)
  while s[r]==s[l] and l<r:
    r-=1
    l+=1
print(ans)