Harryxun/testdata huggingface dataset:
Buggy python 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])

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 python 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])

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 python 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])

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 python 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))
  
  

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 python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input()
for _ in range(q):
  l,r=map(int,input().split())
  sl=s[l-1:r]
  print(sl.count('AC'))

Fixed submission:
n,q=map(int,input().split())
s=input()
a=[0]
for i in range(1,len(s)):
  a.append(a[i-1]+s[i-1:i+1].count('AC'))
for i in range(q):
  l,r=map(int,input().split())
  print(a[r-1]-a[l-1])
Buggy python 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)

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 python submission (verdict: Time Limit Exceeded):
s=input()
c=0
n=1
while n>0 or m>0:
  n=s.count('01')
  s=s.replace('01','')
  c=c+n
  m=s.count('10')
  s=s.replace('10','')
  c=c+m
print(c*2)

Fixed submission:
s=input()
print(2*min(s.count('0'),s.count('1')))

Buggy python submission (verdict: Runtime Error):
s=input()
c=0
while n>0:
  n=s.count('01')
  s=s.replace('01','')
  c=c+n
  n=s.count('10')
  s=s.replace('10','')
  c=c+n
print(c)

Fixed submission:
s=input()
print(2*min(s.count('0'),s.count('1')))

Buggy python submission (verdict: Runtime Error):
s=input()
c=0
while n>0:
  n=s.count('01')
  s.replace('01','')
  c=c+n
  n=s.count('10')
  s.replace('10','')
  c=c+n
print(c)

Fixed submission:
s=input()
print(2*min(s.count('0'),s.count('1')))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
while len(a)>1:
  a.sort()
  for i in range(1,n):
    a[i]=a[i]%a[0]
  a.replace(0,'')
  n=len(a)
print(a[0])

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
while len(a)>1:
  a.sort()
  for i in range(1,n):
    a[i]=a[i]%a[0]
  a=[i for i in a if not i==0]
  n=len(a)
print(a[0])
Buggy python 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))

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 python 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))

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 python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if a+b>=c-1:
  print(b+c)
else:
  print(2b+a+1)

Fixed submission:
a,b,c=map(int,input().split())
if a+b>=c-1:
  print(b+c)
else:
  print(2*b+a+1)
Buggy python submission (verdict: Runtime Error):
print('Christmas'+' Eve'*(25-int(input)))

Fixed submission:
print('Christmas'+' Eve'*(25-int(input())))
Buggy python 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)


Fixed submission:
x,y=map(int,input().split())
print(x+int(y/2))
Buggy python 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()

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 python 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()

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 python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
l=m//n
p=1
for i in range(2,l+1):
  if m%i==0:
    if m//i>=n:
      p=i
print(p)

Fixed submission:
n,m=map(int,input().split())
p=1
for i in range(1,int(m**0.5)+1):
  if m%i==0:
    if m//i>=n:
      if i>=n:
        p=max(i,m//i,p)
      else:
        p=max(p,i)
print(p)

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
if m%n==0:
  print(m//n)
else:
  x=m//n
  for i in range(x,0,-1):
    if m%i==0 and m//i>=n:
      print(i)
      break

Fixed submission:
n,m=map(int,input().split())
p=1
for i in range(1,int(m**0.5)+1):
  if m%i==0:
    if m//i>=n:
      if i>=n:
        p=max(i,m//i,p)
      else:
        p=max(p,i)
print(p)
Buggy python 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)

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 python 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)

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 python 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)

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 python 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)

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 python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
p=0
for a in range(1,n+1):
  for b in range(1,n+1):
    for c in range(1,n+1):
      if (a+b)%k==0 and (b+c)%k==0 and (c+a)%k==0:
        p+=1
print(p)

Fixed submission:
n,k=map(int,input().split())
a=n//k
if k%2==0:
  b=0
  for i in range(1,n+1):
    if i%k==int(k/2):
      b+=1
  print(a**3+b**3)
else:
  print(a**3)
Buggy python 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)

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 python 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)

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 python submission (verdict: Runtime Error):
s=sum(list(input()))
print(10 if s==1 else s)

Fixed submission:
s=sum(list(map(int,list(input()))));print(10 if s==1 else s)
Buggy python 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)

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 python 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)

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 python 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)

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 python submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
print(min(a,b)+min(c,d))

Fixed submission:
x=[int(input()) for _ in range(4)]
print(min(x[0],x[1])+min(x[2],x[3]))
Buggy python submission (verdict: Runtime Error):
x=[list(input().split()) for _ in range(3)]
print(x[0][0]+x[1][1]+x[2][2])

Fixed submission:
x=input()
y=input()
z=input()
print(x[0]+y[1]+z[2])
Buggy python 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))
  

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 python 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))
  

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 python 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))
  

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 python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
x=0
for b in range(k+1,n+1):
  for i in range(k,b):
    x+=(n-i)//b+(i>0)
print(x)

Fixed submission:
n,k=map(int,input().split())
x=0
for b in range(k+1,n+1):
  r=n%b
  if r==0:
    x+=(n//b)*(b-k)
  else:  
    x+=(n//b+1)*max(0,(r-k+1))
    x+=(n//b)*max(0,(b-max(k,r+1)))
    if k==0:
      x-=1
print(x)
Buggy python 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)

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 python 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)

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 python 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])

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 python 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])

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 python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
f=set(a)
s=0
for i in f:
  c=a.count(i)
  if c>i:
    s=s+c-i
  elif c<i:
    s=s+c
print(s)


Fixed submission:
import collections as c
n=int(input())
a=list(map(int,input().split()))
d=c.Counter(a)
k=d.keys()
x=0
for i in k:
  if d[i]>i:
    x+=d[i]-i
  elif d[i]<i:
    x+=d[i]
print(x)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
m=max(a)
s=0
for i in range(1,m+1):
  c=a.count(i)
  if c>i:
    s=s+c-i
  elif c<i:
    s=s+c
print(s)

Fixed submission:
import collections as c
n=int(input())
a=list(map(int,input().split()))
d=c.Counter(a)
k=d.keys()
x=0
for i in k:
  if d[i]>i:
    x+=d[i]-i
  elif d[i]<i:
    x+=d[i]
print(x)
Buggy python submission (verdict: Runtime Error):
n=input()
i=int(n)
m=sum(list(n))
print('Yes' if i%m==0 else 'No')

Fixed submission:
n=input()
i=int(n)
m=sum(list(map(int,list(n))))
print('Yes' if i%m==0 else 'No')
Buggy python 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')

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 python submission (verdict: Runtime Error):
s=input()
t=input()
u='UNRESTORABLE'
a=[]
if len(s)>=len(t):
  for i in range(len(s)-len(t)+1):
    f=0
    for j in range(i,i+len(t)):
      if s[j]!='?' and s[j]!=t[j-i]:
        f=1
    if f==0:
      for j in range(i,i+len(t)):
        if s[j]=='?':
          m=s[:j]+t[j-i]+s[j+1:]
      m=m.replace('?','a')
      a.append(m)
if len(a)==0:
  print(u)
else:
  a.sort()
  print(a[0])

Fixed submission:
s=input()
t=input()
u='UNRESTORABLE'
a=[]
if len(s)>=len(t):
  for i in range(len(s)-len(t)+1):
    f=0
    for j in range(i,i+len(t)):
      if s[j]!='?' and s[j]!=t[j-i]:
        f=1
    if f==0:
      m=s[:i]+t+s[i+len(t):]
      m=m.replace('?','a',50)
      a.append(m)
if len(a)==0:
  print(u)
else:
  a.sort()
  print(a[0])

Buggy python submission (verdict: Runtime Error):
s=input()
t=input()
u=['UNRESTORABLE']
if len(s)>=len(t):
  for i in range(len(s)-len(t)+1):
    f=0
    for j in range(i,i+len(t)):
      if s[j]!='?' and s[j]!=t[j-i]:
        f=1
    if f==0:
      for j in range(i,i+len(t)):
        if s[j]=='?':
          m=s[:j]+t[j-i]+s[j+1:]
      m=m.replace('?','a')
      u.append(m)
u.sort()
print(u[0])

Fixed submission:
s=input()
t=input()
u='UNRESTORABLE'
a=[]
if len(s)>=len(t):
  for i in range(len(s)-len(t)+1):
    f=0
    for j in range(i,i+len(t)):
      if s[j]!='?' and s[j]!=t[j-i]:
        f=1
    if f==0:
      m=s[:i]+t+s[i+len(t):]
      m=m.replace('?','a',50)
      a.append(m)
if len(a)==0:
  print(u)
else:
  a.sort()
  print(a[0])

Buggy python submission (verdict: Runtime Error):
s=input()
t=input()
u=['UNRESTORABLE']
if len(s)>=len(t):
  for i in range(len(s)-len(t)+1):
    f=0
    for j in range(i,i+len(t)):
      if s[j]!='?' and s[j]!=t[j-i]:
        f=1
    if f==0:
      for j in range(i,i+len(t)):
        if s[j]=='?':
          m=s[:j]+t[j-i]+s[j+1:]
      m=m.replace('?','a')
      a.append(m)
u.sort()
print(u[0])

Fixed submission:
s=input()
t=input()
u='UNRESTORABLE'
a=[]
if len(s)>=len(t):
  for i in range(len(s)-len(t)+1):
    f=0
    for j in range(i,i+len(t)):
      if s[j]!='?' and s[j]!=t[j-i]:
        f=1
    if f==0:
      m=s[:i]+t+s[i+len(t):]
      m=m.replace('?','a',50)
      a.append(m)
if len(a)==0:
  print(u)
else:
  a.sort()
  print(a[0])
Buggy python submission (verdict: Runtime Error):
n=int(input())
for i in range(1,3501):
  for j in range(1,3501):
    if (n*i*j)%(4*i*j-n*i-n*j)==0:
      print(i,j,(n*i*j)//(4*i*j-n*i-n*j))
      exit()

Fixed submission:
n=int(input())
for i in range(1,3501):
  for j in range(1,3501):
    if 4*i*j-n*i-n*j>0:
      if (n*i*j)%(4*i*j-n*i-n*j)==0:
        print(i,j,(n*i*j)//(4*i*j-n*i-n*j))
        exit()
Buggy python submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
x='No'
for i in range(m+1)
  t=n*i
  if t==k:
    x='Yes'
    break
  for j in range(n):
    t+=m-2*i
    if t==k:
      x='Yes'
      break
print(x)

Fixed submission:
n,m,k=map(int,input().split())
x='No'
for i in range(m+1):
  t=n*i
  if t==k:
    x='Yes'
    break
  for j in range(n):
    t+=m-2*i
    if t==k:
      x='Yes'
      break
print(x)