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

Fixed submission:
h,w,k=map(int,input().split())
x=[list(input()) for i in range(h)]
a=[['*']*w]+[[0]*w for i in range(h)]
n=0
for i in range(1,h+1):
  f=False
  if '#' in x[i-1]:
    n+=1
    for j in range(w):
      if x[i-1][j]=='#':
        if f:
          n+=1
        else:
          f=True
      a[i][j]=n
  else:
    for j in range(w):
      a[i][j]=a[i-1][j]
if '#' not in x[0]:
  c=['*']*w
  for j in range(1,h+1):
    if a[j]!=c:
      for k in range(j-1,0,-1):
        for i in range(w):
          a[k][i]=a[k+1][i]
      break
for i in range(1,h+1):
  print(*a[i])

Buggy submission (verdict: Runtime Error):
h,w,k=map(int,input().split())
x=[list(input()) for i in range(h)]
a=[[1]*w]+[[0]*w for i in range(h)]
n=0
for i in range(1,h+1):
  f=False
  if '#' in x[i-1]:
    n+=1
    for j in range(w):
      if x[i-1][j]=='#':
        if f:
          n+=1
        else:
          f=True
      a[i][j]=n
  else:
    for j in range(w):
      a[i][j]=a[i-1][j]
if '#' not in x[0]:
  c=[1]*w
  for j in range(h,0,-1):
    if a[j]==c:
      for k in range(j,0,-1):
        for i in range(w):
          a[k][i]=a[k+1][i]
      break
for i in range(1,h+1):
  print(*a[i])
Problem p02882 (python)

Fixed submission:
a,b,x=map(int,input().split())
import math
if a*a*b==x:
  c=math.pi/2
elif a*a*b/2>=x:
  c=math.atan((2*x)/(a*b*b))
else:
  c=math.atan(a**3/(2*a*a*b-2*x))
d=math.degrees(c)
print(90-d)

Buggy submission (verdict: Runtime Error):
a,b,x=map(int,input().split())
import math
if a*a*b/2==x:
  c=math.pi/2
elif a*a*b/2>=x:
  c=math.atan((2*x)/(a*b*b))
else:
  c=math.atan(a**3/(2*a*a*b-2*x))
d=math.degrees(c)
print(90-d)

Buggy submission (verdict: Runtime Error):
a,b,x=map(int,input().split())
import math
if a*a*b/2>=x:
  c=math.atan((2*x)/(a*b*b))
else:
  c=math.atan(a**3/(2*a*a*b-2*x))
d=math.degrees(c)
print(90-d)
Problem p02923 (python)

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
a=[0]
i=0
c=0
while i<n-1:
  c=0
  while i<n-1:
    if h[i]>=h[i+1]:
      c+=1
      i+=1
    else:
      a.append(c)
      i+=1
      break
a.append(c)
print(max(a))

Buggy submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
a=[0]
i=0
while i<n-1:
  c=0
  while i<n-1:
    if h[i]>=h[i+1]:
      c+=1
      i+=1
    else:
      a.append(c)
      i+=1
      break
a.append(c)
print(max(a))
Problem p02936 (python)

Fixed submission:
n,q=map(int,input().split())
k=[[] for _ in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  k[a-1].append(b-1)
  k[b-1].append(a-1)
s=[0]*n
for i in range(q):
  p,x=map(int,input().split())
  s[p-1]+=x
from collections import deque
d=deque()
d.append(0)
v=[False]*n
v[0]=True
while d:
  g=d.popleft()
  for i in k[g]:
    if v[i]:
      continue
    d.append(i)
    v[i]=True
    s[i]+=s[g]
print(*s)

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
k=[[] for _ in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  k[a-1].append(b-1)
for i in range(q):
  p,x=map(int,input().split())
  s[p-1]+=x
from collections import deque
d=deque()
d.append(0)
v=[False]*n
v[0]=True
while d:
  g=d.popleft()
  for i in k[g]:
    if v[i]:
      continue
    d.append(i)
    v[i]=True
    s[i]+=s[g]
print(*s)
Problem p02946 (python)

Fixed submission:
k,x=map(int,input().split())
for i in range(x-k+1,x+k):
  print(i)

Buggy submission (verdict: Runtime Error):
k,x=map(int,input().split())
for i in range(x-k+1,x+K):
  print(i)
Problem p02947 (python)

Fixed submission:
from collections import Counter as co
n=int(input())
a=[str(sorted(input())) for _ in range(n)]
d=co(a)
l=d.values()
c=0
for i in l:
  c+=(i*(i-1))//2
print(c)

Buggy submission (verdict: Runtime Error):
n=int(input())
d={}
for i in range(n):
  a=sorted(input())
  if a in d.keys():
    d[a]+=1
  else:
    d[a]=1
l=list(d.values())
c=0
for i in l:
  c+=(i*(i-1))//2
print(c)
Problem p02982 (python)

Fixed submission:
n,d=map(int,input().split())
x=[list(map(int,input().split())) for _ in range(n)]
p=0
def c(i,j):
  global x
  s=0
  for k in range(d):
    s+=(x[i][k]-x[j][k])**2
  if (s**(1/2)).is_integer()==True:
    return 1
  else:
    return 0
for i in range(n):
  for j in range(i+1,n):
    p+=c(i,j)
print(p)

Buggy submission (verdict: Runtime Error):
n,d=map(int,input().split())
x=[list(map(int,input().split())) for _ in range(n)]
p=0
def c(i,j):
  global x
  s=0
  for k in range(d):
    s+=(x[i][d]-x[j][d])**2
  if s**(1/2).is_integer()==True:
    return 1
  else:
    return 0
for i in range(n):
  for j in range(i+1,n):
    p+=c(i,j)
print(p)
Problem p03006 (python)

Fixed submission:
n=int(input())
if n==1:
  print(1)
  exit()
l=[list(map(int,input().split())) for _ in range(n)]
d=[]
for i in range(n):
  for j in range(n):
    if i!=j:
      d.append((l[i][0]-l[j][0],l[i][1]-l[j][1]))
from collections import Counter as c
print(n-c(d).most_common()[0][1])

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
d=[]
for i in range(n):
  for j in range(n):
    if i!=j:
      d.append((l[i][0]-l[j][0],l[i][1]-l[j][1]))
from collections import Counter as c
print(n-c(d).most_common()[0][1])
Problem p03043 (python)

Fixed submission:
import math as m
n,k=map(int,input().split())
p=0
for i in range(1,min(n+1,k)):
  r=m.ceil(m.log(k/i,2))
  p+=1/(2**r)
for _ in range(k,n+1):
  p+=1
print(p/n)

Buggy submission (verdict: Runtime Error):
import math as m
n,k=map(int,input().split())
p=0
for i in range(1,k):
  r=m.ceil(m.log(k/i,2))
  p+=1/(2**r)
for _ in range(K,n+1):
  p+=1
print(p/n)

Buggy submission (verdict: Runtime Error):
import math as m
n,k=map(int,input().split())
p=0
for i in range(1,k):
  r=m.ceil(m.log(k/i,2))
  p+=1/(2**r)
for _ in range(K,N+1):
  p+=1
print(p/n)
Problem p03061 (python)

Fixed submission:
import fractions
n=int(input())
v=list(map(int,input().split()))
def g(a,b):
  if a==0:return b
  if b==0:return a
  return fractions.gcd(a,b)
l=[0]*(n+1)
r=[0]*(n+1)
for i in range(1,n+1):
  l[i]=g(l[i-1],v[i-1])
for i in range(n)[::-1]:
  r[i]=g(r[i+1],v[i])
x=0
for i in range(n):
  c=g(l[i],r[i+1])
  x=max(c,x)
print(x)

Buggy submission (verdict: Runtime Error):
import fractions
n=int(input())
v=list(map(int,input().split()))
def g(a,b):
  if a==0:return b
  if b==0:return a
  return fractions.gcd(a,b)
l=[0]*(n+1)
r=[0]*(n+1)
for i in range(1,n+1):
  l[i]=g(l[i-1],v[i-1])
for i in range(n)[::-1]:
  r[i]=g(r[i+1],v[i])
x=0
for i in range(n):
  c=g(l[i],r[i+1])
  x=max(c,x)
print(ans)
Problem p03062 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
c=0
for i in range(n):
  if a[i]<0:
    c+=1
    a[i]=a[i]*-1
if c%2==0 or 0 in a:
  print(sum(a))
else:
  a.sort()
  print(sum(a[1:])-a[0])

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=[]
for _ in range(n):
  if a[_]<0:
    b.append(a.pop(_)*(-1))
if 0 in a or len(b)%2==0:
  print(sum(a)+sum(b))
else:
  b.sort()
  print(sum(a)+sum(b)-(b[0]*2))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=[]
for _ in range(n):
  if a[_]<0:
    b.append(a.pop(_)*(-1))
if 0 in a or len(b)%2==0:
  print(sum(a)+sum(b))
else:
  b.sort()
  print(sum(a)+sum(b[1:])-b[0])
Problem p03076 (python)

Fixed submission:
x=[int(input()) for _ in range(5)]
y=[x[_]%10 for _ in range(5)]
y.sort()
s=0
a=0
for _ in range(5):
  if y[_]!=0:
    a=y[_]
    s=-1
    break
for _ in range(5):
  s=s-(-x[_] // 10)
print((s)*10+a)

Buggy submission (verdict: Runtime Error):
x=[int(input()) for _ in range(5)]
y=[x[_]%10 for _ in range(5)]
y.sort()
s=0
for _ in range(5):
  if y[_]!=0:
    a=y[_]
    s=-1
    break
for _ in range(5):
  s=s-(-x[_] // 10)
print((s)*10+a)
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()))
if [2,2,2,8]==[x,y,z,k]:
  e=[8,10,12,13,14,15,17,19]
else:
  d=[]
  for i in range(x):
    for j in range(y):
      d.append(a[i]+b[j])
  d.sort()
  d=d[x*y-k:]
  e=[]
  for i in range(z):
    for j in range(k):
      e.append(c[i]+d[j])
  e.sort()
  e=e[z*k-k:]
for i in range(k)[::-1]:
  print(e[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()))
d=[]
for i in range(x):
  for j in range(y):
    d.append(a[i]+b[j])
d.sort()
d=d[x*y-k:]
e=[]
for i in range(z):
  for j in range(k):
    e.append(c[i]+d[j])
e.sort()
e=e[z*k-k:]
for i in range(k)[::-1]:
  print(e[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()))
d=[]
for i in range(x):
  for j in range(y):
    d.append(a[i]+b[j])
d.sort()
d=d[x*y-k:]
e=[]
for i in range(z):
  for j in range(k):
    e.append(c[i]+d[j])
e.sort()
for i in range(k)[::-1]:
  print(e[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()))
d=[]
for i in range(x):
  for j in range(y):
    d.append(a[i]+b[j])
d.sort()
d=d[x*y-k:]
e=[]
for i in range(z):
  for j in range(k):
    e.append(c[z]+d[j])
e.sort()
for i in range(k)[::-1]:
  print(e[i])
Problem p03086 (python)

Fixed submission:
s=input()
x=['A','T','C','G']
a=[0]*len(s)
if s[0] in x:
  a[0]=1
for i in range(1,len(s)):
  if s[i] in x:
    a[i]=a[i-1]+1
print(max(a))

Buggy submission (verdict: Runtime Error):
s=input()
x=['A','T','C','G']
a=[0]*len(s)
a[0]=1 if s[0] in x
for i in range(1,len(s)):
  if s[i] in x:
    a[i]=a[i-1]+1
print(max(a))
Problem p03089 (python)

Fixed submission:
n=int(input())
b=list(map(int,input().split()))
a=[]
f=0
for _ in range(n):
  for i in range(len(b)-1,-1,-1):
    if b[i]==i+1:
      a.append(b.pop(i))
      break
    if i==0:
      f=1
if f==0:
  for i in range(n-1,-1,-1):
    print(a[i])
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
n=int(input())
b=list(map(int,input().split()))
l=len(b)
a=[]
f=0
for _ in range(n):
  for i in range(l-1,-1,-1):
    if b[i]==i+1:
      a.append(b.pop(i))
      break
    if i==0:
      f=1
if f==0:
  for i in range(l-1,-1,-1):
    print(a[i])
else:
  print(-1)
Problem p03140 (python)

Fixed submission:
n=int(input())
a=input();b=input();c=input()
x=0
for i in range(n):
  x+=len(list(set([a[i],b[i],c[i]])))-1
print(x)

Buggy submission (verdict: Runtime Error):
n=int(input())
a,b,c=input().split()
ab=0;bc=0;ca=0
for i in range(n):
  if a[i]!=b[i]:
    ab+=1
  if b[i]!=c[i]:
    bc+=1
  if c[i]!=a[i]:
    ca+=1
print(min(ab,bc,ca))

Buggy submission (verdict: Runtime Error):
n=int(input())
a,b,c=input().split()
ab,bc,ca=0,0,0
for i in range(n):
  if a[i]!=b[i]:
    ab+=1
  if b[i]!=c[i]:
    bc+=1
  if c[i]!=a[i]:
    ca+=1
print(min(ab,bc,ca))
Problem p03206 (python)

Fixed submission:
print('Christmas'+' Eve'*(25-int(input())))

Buggy submission (verdict: Runtime Error):
print('Christmas'+' Eve'*(25-int(input)))
Problem p03219 (python)

Fixed submission:
x,y=map(int,input().split())
print(x+int(y/2))

Buggy submission (verdict: Runtime Error):
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
for i in range(n):
  h[i]=t-h[i]*0.006
d=abs(a-h[0])
c=1
for i in range(1,n):
  if d>abs(a-h[i]):
    c=i+1
    d=abs(a-h[i])
print(c)
Problem p03240 (python)

Fixed submission:
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
a=[]
for x in range(101):
  for y in range(101):
    c=[]
    for t in l:
      if t[2]:
        c.append(t[2]+abs(x-t[0])+abs(y-t[1]))
    f=0
    if len(set(c))==1:
      f=1
      h=c[0]
      for t in l:
        if t[2]==0:
          if h-abs(x-t[0])-abs(y-t[1])>0:
            f=0
    if f:
      print(x,y,h)
      exit()

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
a=[]
for x in range(101):
  for y in range(101):
    c=[]
    for t in l:
      if t[2]:
        c.append(t[2]+abs(x-t[0])+abs(y-t[1]))
    f=0
    if len(set(c))==1:
      f=1
      h=c[0]
      for t in l:
        if l[2]==0:
          if h-abs(x-t[0])-abs(y-t[1])>0:
            f=0
    if f:
      print(x,y,h)
      exit()

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
a=[]
for x in range(101):
  for y in range(101):
    c=[]
    for t in l:
      if l[2]:
        c.append(t[2]+abs(x-t[0])+abs(y-t[1]))
    f=0
    if len(set(c))==1:
      f=1
      h=c[0]
      for t in l:
        if l[2]==0:
          if h-abs(x-t[0])-abs(y-t[1])>0:
            f=0
    if f:
      print(x,y,h)
      exit()
Problem p03244 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
o=[]
e=[]
for i in range(n):
  if i%2==0:
    o.append(a[i])
  else:
    e.append(a[i])
from collections import Counter as co
o=co(o)
e=co(e)
o['x']=0
e['x']=0
ov=o.values()
ev=e.values()
mo=max(ov)
me=max(ev)
if n==2:
  if a[0]==a[1]:
    print(1)
  else:
    print(0)
else:
  if max(o,key=o.get)==max(e,key=e.get):
    if mo>me:
      me=sorted(ev)[-2]
    elif mo<me:
      mo=sorted(ov)[-2]
    else:
      mo=max(sorted(ev)[-2],sorted(ov)[-2])
  print(n-mo-me)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
o=[]
e=[]
for i in range(n):
  if i%2==0:
    o.append(a[i])
  else:
    e.append(a[i])
from collections import Counter as co
o=co(o)
e=co(e)
o['x']=0
e['x']=0
ov=o.values()+[0]
ev=e.values()+[0]
mo=max(ov)
me=max(ev)
if n==2:
  if a[0]==a[1]:
    print(1)
  else:
    print(0)
else:
  if max(o,key=o.get)==max(e,key=e.get):
    if mo>me:
      me=sorted(ev)[-2]
    else:
      mo=sorted(ov)[-2]
  print(n-mo-me)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
o=[]
e=[]
for i in range(n):
  if i%2==0:
    o.append(a[i])
  else:
    e.append(a[i])
from collections import Counter as co
o=co(o)
e=co(e)
ov=o.values()+[0]
ev=e.values()+[0]
mo=max(ov)
me=max(ev)
if n==2:
  if a[0]==a[1]:
    print(1)
  else:
    print(0)
else:
  if max(o,key=o.get)==max(e,key=e.get):
    if mo>me:
      me=sorted(ev)[-2]
    else:
      mo=sorted(ov)[-2]
  print(n-mo-me)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
o=[]
e=[]
for i in range(n):
  if i%2==0:
    o.append(a[i])
  else:
    e.append(a[i])
from collections import Counter as co
o=co(o)
e=co(e)
ov=o.values()
ev=e.values()
mo=max(ov)
me=max(ev)
if n==2:
  if a[0]==a[1]:
    print(1)
  else:
    print(0)
else:
  if max(o,key=o.get)==max(e,key=e.get):
    if mo>me:
      me=sorted(ev)[n//2-2]
    else:
      mo=sorted(ov)[n//2-2]
  print(n-mo-me)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
o=[]
e=[]
for i in range(n):
  if i%2==0:
    o.append(a[i])
  else:
    e.append(a[i])
from collections import Counter as co
o=co(o)
e=co(e)
ov=o.values()
ev=e.values()
mo=max(ov)
me=max(ev)
if max(o,key=o.get)==max(e,key=e.get):
  if mo>me:
    me=sorted(ev)[n//2-2]
  else:
    mo=sorted(ov)[n//2-2]
print(n-mo-me)
Problem p03254 (python)

Fixed submission:
n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
for i in range(n):
  x=x-a[i]
  if x<0:
    break
if i==n-1 and x==0:
  i+=1
print(i)

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
s=a[0]
i=0
while s<=x and i<n:
  i+=1
  s+=a[i]
print(i)

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
s=a[0]
i=0
while s<=x:
  i+=1
  s+=a[i]
print(i)

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
s=a[0]
i=0
while s<x:
  i+=1
  s+=a[i]
print(i)

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
s=0
i=0
while s<x:
  s+=a[i]
  i+=1
print(i+1)
Problem p03281 (python)

Fixed submission:
n=int(input())
c=0
for j in range(105,n+1,2):
  d=[]
  for i in range(1,int(j**0.5)+1):
        if j%i==0:
            d.append(i)
            if i!=n//i:
                d.append(n//i)
  if len(d)==8:
    c+=1
print(c)

Buggy submission (verdict: Runtime Error):
n=int(input())
c=0
for j in range(105,n+1,2)  
  d=[]
  for i in range(1,int(j**0.5)+1):
        if j%i==0:
            d.append(i)
            if i!=n//i:
                d.append(n//i)
  if len(d)==8:
    c+=1
print(c)
Problem p03325 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
s=0
for _ in range(n):
  b=a[_]
  while b%2==0:
    b=b/2
    s+=1
print(s)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
s=0
for _ i range(n):
  b=a[_]
  while b%2==0:
    b=b/2
    s+=1
print(s)
Problem p03331 (python)

Fixed submission:
s=sum(list(map(int,list(input()))));print(10 if s==1 else s)

Buggy submission (verdict: Runtime Error):
s=sum(list(input()))
print(10 if s==1 else s)
Problem p03361 (python)

Fixed submission:
h,w=map(int,input().split())
a=[0]*(h+2)
a[0]='.'*(w+2)
a[h+1]=a[0]
for _ in range(1,h+1):
  j=input()
  a[_]='.'+j+'.'
x='Yes'
for i in range(1,h+1):
  for j in range(1,w+1):
    if a[i][j]=='#':
      if a[i-1][j]=='.' and a[i+1][j]=='.' and a[i][j-1]=='.' and a[i][j+1]=='.':
        x='No'
        break
print(x)

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
a=[0]*h+2
a[0]='.'*(w+2)
a[h+1]=a[0]
for _ in range(1,h+1):
  j=input()
  a[_]='.'+j+'.'
x='Yes'
for i in range(1,h+1):
  for j in range(1,w+1):
    if a[i][j]=='#':
      if a[i-1][j]=='.' and a[i+1][j]=='.' and a[i][j-1]=='.' and a[i][j+1]=='.':
        x='No'
print(x)

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
a=[0]*h+2
a[0]='.'*(w+2)
a[h+1]=a[0]
for _ in range(1,h+1):
  a[_]='.'+input()+'.'
x='Yes'
for i in range(1,h+1):
  for j in range(1,w+1):
    if a[i][j]=='#':
      if a[i-1][j]=='.' and a[i+1][j]=='.' and a[i][j-1]=='.' and a[i][j+1]=='.':
        x='No'
print(x)
Problem p03393 (python)

Fixed submission:
s=input()
a='abcdefghijklmnopqrstuvwxyz'
r='zyxwvutsrqponmlkjihgfedcba'
if len(s)!=26:
  for i in a:
    if i not in s:
      s=s+i
      break
elif s==r:
  s=-1
else:
  for i in range(25,0,-1):
    if i==1:
      s=chr(ord(s[0])+1)
      break
    if s[i]>s[i-1]:
      l=sorted(s[i:])
      for j in l:
        if j>s[i-1]:
          m=j
          break
      s=s[:i-1]+m
      break
print(s)

Buggy submission (verdict: Runtime Error):
s=input()
a='abcdefghijklmnopqrstuvwxyz'
r='zyxwvutsrqponmlkjihgfedcba'
if len(s)!=26:
  for i in a:
    if i not in s:
      s=s+i
      break
elif s==r:
  s=-1
else:
  for i in range(25,0,-1):
    if i==1:
      s=chr(ord(s[0])+1)
      break
    if s[i]>s[i-1]:
      l=sorted(s[i:])
      for i in l:
        if i>s[i-1]:
          m=i
          break
      s=s[:i-1]+m
      break
print(s)
Problem p03399 (python)

Fixed submission:
x=[int(input()) for _ in range(4)]
print(min(x[0],x[1])+min(x[2],x[3]))

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
print(min(a,b)+min(c,d))
Problem p03415 (python)

Fixed submission:
x=input()
y=input()
z=input()
print(x[0]+y[1]+z[2])

Buggy submission (verdict: Runtime Error):
x=[list(input().split()) for _ in range(3)]
print(x[0][0]+x[1][1]+x[2][2])
Problem p03416 (python)

Fixed submission:
a,b=input().split()
if a!='10000':
  a=str(int(a)-1)
def f(x):
  c=int(x[0])
  d=int(x[1])
  m=(c-1)*100+d*10
  e=int(x[2])
  g=int(x[3])*10+int(x[4])
  if g<d*10+c:
    m+=e
  else:
    m=m+e+1
  return m
print(f(b)-f(a))

Buggy submission (verdict: Runtime Error):
a,b=input().split()
a=str(int(a)-1)
def f(x):
  c=int(x[0])
  d=int(x[1])
  m=(c-1)*100+d*10
  e=int(x[2])
  g=int(x[3])*10+int(x[4])
  if g<d*10+c:
    m+=e
  else:
    m=m+e+1
  return m
print(f(b)-f(a))

Buggy submission (verdict: Runtime Error):
a,b=input().split()
a=str(int(a)-1)
def f(x):
  c=int(x[0])
  d=int(x[1])
  m=(c-1)*100+d*10
  e=int(x[2])
  g=int(x[4])*10+int(x[5])
  if g<d*10+c:
    m+=e
  else:
    m=m+e+1
  return m
print(f(b)-f(a))

Buggy submission (verdict: Runtime Error):
a,b=input().split()
a=str(int(a)-1)
def f(x):
  c=int(x[0])
  d=int(x[1])
  m=(c-1)*100+d*10
  e=int(x[2])
  g=int(x[4:6])
  if g<d*10+c:
    m+=e
  else:
    m=m+e+1
  return m
print(f(b)-f(a))
Problem p03425 (python)

Fixed submission:
n=int(input())
l=[0]*5
m='MARCH'
for i in range(n):
  s=input()
  f=s[0]
  for i in range(5):
    if f==m[i]:
      l[i]+=1
      break
a=[]
for i in l:
  if i!=0:
    a.append(i)
if len(a)<3:
  print(0)
elif len(a)==3:
  print(a[0]*a[1]*a[2])
elif len(a)==4:
  print(a[0]*a[1]*(a[2]+a[3])+a[2]*a[3]*(a[0]+a[1]))
else:
  x=0
  for i in range(3):
    for j in range(i+1,4):
      for k in range(j+1,5):
        x+=a[i]*a[j]*a[k]
  print(x)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[0]*5
m='MARCH'
for i in range(n):
  s=input()
  f=s[0]
  for i in range(5):
    if f==m[i]:
      l[i]+=1
      break
x=0
for i in range(3):
  for j in range(i+1,4):
    for k in range(j+1,5):
      x+=a[i]*a[j]*a[k]
print(x)
Problem p03457 (python)

Fixed submission:
n=int(input())
t=[0]*(n+1)
x=[0]*(n+1)
y=[0]*(n+1)
t[0],x[0],y[0]=0,0,0
for i in range(1,n+1):
  t[i],x[i],y[i]=map(int, input().split())
d='Yes'
for i in range(n):
  a=t[i+1]-t[i]-abs(x[i+1]-x[i])-abs(y[i+1]-y[i])
  if a<0 or a%2==1:
    d='No'
    break
print(d)

Buggy submission (verdict: Runtime Error):
n=int(input())
t=[0]*n+1
x=[0]*n+1
y=[0]*n+1
t[0],x[0],y[0]=0,0,0
for i in range(1,n+1):
  t[i],x[i],y[i]=map(int, input().split())
d='Yes'
for i in range(n):
  a=abs(x[i+1]-x[i])+abs(y[i+1]-y[i])-t[i+1]+t[i]
  if a<0 or a%2==1:
    d='No'
    break
print(d)
Problem p03471 (python)

Fixed submission:
n,y=map(int,input().split())
x=[-1,-1,-1]
for i in range(n+1):
  for j in range(n-i+1):
    if 10000*i+5000*j+1000*(n-i-j)==y:
      x=[i,j,n-i-j]
      break
for _ in range(3):
  print(x[_])

Buggy submission (verdict: Runtime Error):
n,y=map(int,input().split())
x=[-1,-1,-1]
for i in range(n+1):
  for j in range(n-i+1):
    if 10000*i+5000*j+1000*(n-i-j)==y:
      x=[i,j,n-i-j]
      break
for _ in range(3):
  print(x[i])
Problem p03476 (python)

Fixed submission:
n=100000
p=[0]*2+[1]*(n-1)
for i in range(2,n+1):
  if p[i]:
    for j in range(i*2,n+1,i):
      p[j]=0
for i in range(1,n+1)[::-1]:
  if p[i]:
    if p[(i+1)//2]:
      continue
    p[i]=0
p[2]=0
c=[0]*(n+1)
for i in range(1,n+1):
  c[i]=c[i-1]+p[i]
q=int(input())
for i in range(q):
  l,r=map(int,input().split())
  print(c[r]-c[l-1])

Buggy submission (verdict: Runtime Error):
n=100000
p=[0]*2+[1]*(n-1)
for i in range(2,n+1):
  if p[i]:
    for j in range(i*2,n+1,i):
      p[j]=0
for i in range(1,n+1)[::-1]:
  if p[i]:
    if p[(i+1)//2]:
      continue
    p[i]=0
p[2]=0
c=[0]*n
for i in range(1,n+1):
  c[i]=c[i-1]+p[i]
q=int(input())
for i in range(q):
  l,r=map(int,input().split())
  print(c[r]-c[l-1])
Problem p03502 (python)

Fixed submission:
n=input()
i=int(n)
m=sum(list(map(int,list(n))))
print('Yes' if i%m==0 else 'No')

Buggy submission (verdict: Runtime Error):
n=input()
i=int(n)
m=sum(list(n))
print('Yes' if i%m==0 else 'No')
Problem p03545 (python)

Fixed submission:
s=input()
a=int(s[0]);b=int(s[1]);c=int(s[2]);d=int(s[3])
if a+b+c+d==7:
  print('{}+{}+{}+{}=7'.format(a,b,c,d))
elif a+b+c-d==7:
  print('{}+{}+{}-{}=7'.format(a,b,c,d))
elif a+b-c+d==7:
  print('{}+{}-{}+{}=7'.format(a,b,c,d))
elif a-b+c+d==7:
  print('{}-{}+{}+{}=7'.format(a,b,c,d))
elif a+b-c-d==7:
  print('{}+{}-{}-{}=7'.format(a,b,c,d))
elif a-b+c-d==7:
  print('{}-{}+{}-{}=7'.format(a,b,c,d))
elif a-b-c+d==7:
  print('{}-{}-{}+{}=7'.format(a,b,c,d))
elif a-b-c-d==7:
  print('{}-{}-{}-{}=7'.format(a,b,c,d))

Buggy submission (verdict: Runtime Error):
s=input()
a=int(s[0]);b=int(s[1]);c=int(s[2]);d=int(s[3])
if a+b+c+d==7:
  print(f'{a}+{b}+{c}+{d}=7')
elif a+b+c-d==7:
  print(f'{a}+{b}+{c}-{d}=7')
elif a+b-c+d==7:
  print(f'{a}+{b}-{c}+{d}=7')
elif a-b+c+d==7:
  print(f'{a}-{b}+{c}+{d}=7')
elif a+b-c-d==7:
  print(f'{a}+{b}-{c}-{d}=7')
elif a-b+c-d==7:
  print(f'{a}-{b}+{c}-{d}=7')
elif a-b-c+d==7:
  print(f'{a}-{b}-{c}+{d}=7')
elif a-b-c-d==7:
  print(f'{a}-{b}-{c}-{d}=7')