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

Fixed submission:
from collections import deque
n=int(input())
l=["3","5","7"]
q=deque(["3","5","7"])
l1=["3","5","7"]
count=0
while q:
  a=q.popleft()
  for i in l:
    if int(i+a)<=n:
      q.append(i+a)
      l1.append(i+a)
for i in l1:
  if ("3" in i) and ("5" in i) and ("7" in i):
    count+=1
print(count)

Buggy submission (verdict: Runtime Error):
from collections import deque
n=int(input())
num=0
l=["3","5","7"]
q=deque(["3","5","7"])
count=0
while q:
  a=q.popleft()
  for i in l:
    if int(i+a)<n:
    count+=1
    q.append(i+a)
print(count)

Buggy submission (verdict: Runtime Error):
n1=int(input())
l1=len(str(n1))
count=0
def count1(n):
  l=len(str(n))-1
  l2=int(str(n)[0])
  if int(str(n)[0])>=8:
    return 3*(3**l+3-3*(2**l))
  elif int(str(n)[0])==7:
    return count(n-7*(10**(l-1)))+2*(3**l+3-3*(2**l))
  elif l2==6:
    return 2*(3**l+3-3*(2**l))
  elif l2==5:
    return count(n-5*(10**(l-1)))+(3**l+3-3*(2**l))
  elif l2==4:
    return (3**l+3-3*(2**l))
  elif l2==3:
    return count(n-3*(10**(l-1)))
  else:
    return 0
    
    
if l1<3:
  print(0)
else:
  if l1>=4:
    for i in range(3,l1):
      c+=3**i+3-3*(2**i)
  print(c+count1(n1))
Problem p03230 (python)

Fixed submission:
n=int(input())
count=1
index=1
while count<n:
  index+=1
  count+=index
if count!=n:
  print("No")
elif n==1:
  print("Yes")
  print(2)
  print("1 1")
  print("1 1")
else:
  print("Yes")
  print(index+1)
  l=[]
  now=1
  num=1
  while now<n:
    l.append(now)
    now+=num
    num+=1
  for i in range(index):
    l1=[str(index)]
    l1.append(str(l[i]))
    num=l[i]
    count1=0
    while count1<i:
      num+=1
      count1+=1
      l1.append(str(num))
    for j in range(1+i,index):
      num+=j
      l1.append(str(num))
    print(" ".join(l1))
  l1=[str(index),str(l[0])]
  num=0
  for j in range(2,index+1):
    num+=j
    l1.append(str(l[0]+num))
  print(" ".join(l1))

Buggy submission (verdict: Runtime Error):
n=int(input())
count=1
index=1
while count<n:
  index+=1
  count+=index
if count!=n:
  print("No")
else:
  print("Yes")
  print(index+1)
  l=[]
  now=1
  num=1
  while now<n:
    l.append(now)
    now+=num
    num+=1
  for i in range(index):
    l1=[str(index)]
    l1.append(str(l[i]))
    num=l[i]
    count1=0
    while count1<i:
      num+=1
      count1+=1
      l1.append(str(num))
    for j in range(1+i,index):
      num+=j
      l1.append(str(num))
    print(" ".join(l1))
  l1=[str(index),str(l[0])]
  num=0
  for j in range(2,index+1):
    num+=j
    l1.append(str(l[0]+num))
  print(" ".join(l1))
Problem p03238 (python)

Fixed submission:
i=input()
if i=="2":
  n=int(input())
  m=int(input())
  print(n+m)
else:
  print("Hello World")

Buggy submission (verdict: Runtime Error):
def make_divisors(n,m):
    divisors = []
    i=1
    while i*i<m:
      if m % i == 0:
          divisors.append(i)
          if i != m // i and m//i<=m//n:
              divisors.append(m//i)
      i+=1
    return divisors
n,m=map(int,input().split())
print(max(make_divisors(n,m)))

Buggy submission (verdict: Runtime Error):
def make_divisors(n,m):
    divisors = []
    for i in range(1, (m//n)+1):
        if m % i == 0:
            divisors.append(i)
            if i != m // i and m//i<=m//n:
                divisors.append(m//i)
    return divisors
n,m=map(int,input().split())
print(max(make_divisors(n,m)))
Problem p03239 (python)

Fixed submission:
n,t=map(int,input().split())
l=[]
for i in range(1,n+1):
  p,q=map(int,input().split())
  if q<=t:
    l.append(p)
  else:
    pass
if len(l)==0:
  print("TLE")
else:
  print(min(l))

Buggy submission (verdict: Runtime Error):
n,t=map(int,input().split())
l=[]
m=[]
for i in range(1,n+1):
  p,q=map(int,input().split())
  if q<=t:
    l[i]=p
    m[i]=q
  else:
    pass
if len(l)==0:
  print("TLE")
else:
  print(min(l))

Buggy submission (verdict: Runtime Error):
n,t=map(int,input().split())
l=[]
m=[]
for i in range(1,n+1):
  p,q=map(int,input().split())
  if q<=t:
    l[i]=p
    m[i]=q
  else:
    pass
if l==[]:
  print("TLE")
else:
  print(min(l))
Problem p03240 (python)

Fixed submission:
n=int(input())
l=[]
l1=[]
for i in range(n):
  l1=list(map(int,input().split()))
  l1=l1[::-1]
  l.append(l1)      
l=sorted(l)
for i in range(101):
  for j in range(101):
    b=True
    h=abs(i-l[-1][2])+abs(j-l[-1][1])+l[-1][0]
    for k in range(n-1):
      if max(h-abs(i-l[-2-k][2])-abs(j-l[-2-k][1]),0)!=l[-2-k][0]:
        b=False
    if b:
      print(i,j,h)
      break

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[]
for i in range(n):
  l.append(reversed(list(map(int,input().split()))))
l=sorted(l)
for i in range(101):
  for j in range(101):
    b=True
    h=abs(i-l[-1][2])+abs(j-l[-1][1])+l[-1][0]
    for i in range(n-1):
      if max(h-abs(i-l[-2-i][2])-abs(j-l[-2-i][1]),0)!=l[-2-i][0]:
        b=False
    if b:
      print(i,j,h)
      break
Problem p03241 (python)

Fixed submission:
def make_divisors(n,m):
    divisors = []
    for i in range(1,min(int(m**(1/2))+1,int(m//n)+1)):
      if m % i == 0:
          divisors.append(i)
          if i != m // i and m//i<=m//n:
              divisors.append(m//i)
    return divisors
n,m=map(int,input().split())
print(max(make_divisors(n,m)))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
def yak1(n,m):
  l=[]
  for i in range(1,min(int((m)**1/2),m//n)+1):
    if m%i==0:
      l.append(i)
      if m//i!=i and m//i<=m//n:
        l.append(m//i)
  return l
print(max(yak1(n,m)))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
def yak1(n,m):
  l=[]
  for i in range(1,min(int((m)**1/2),m//n)+1):
    if m%i==0:
      l.append(i)
      if m//(m//i)!=m/i and m//i<=m/n:
        l.append(m//i)
  return l
print(max(yak1(n,m)))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
def yak1(n,m):
  l=[]
  for i in range(1,min(int((m)**1/2),m//n)+1):
    if m%i==0:
      l.append(i)
      if m//(m//i)!=m/i and m//(m//i)>=m/n:
        l.append(m//i)
  return l
print(max(yak1(n,m)))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
def yak1(n,m):
  l=[]
  for i in range(1,min(int((m)**1/2+1)),m//n+1):
    if m%i==0:
      l.append(i)
      if m//(m//i)!=m/i and m//(m//i)<=m//n:
        l.append(m//i)
  return l
print(min(yak1(n,m)))

Buggy submission (verdict: Runtime Error):
def make_divisors(n,m):
    divisors = []
    i=1
    while i*i<m:
      if m % i == 0:
          divisors.append(i)
          if i != m // i and m//i<=m//n:
              divisors.append(m//i)
      i+=1
    return divisors
n,m=map(int,input().split())
print(max(make_divisors(n,m)))

Buggy submission (verdict: Runtime Error):
def make_divisors(n,m):
    divisors = []
    for i in range(1, (n//m)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
n,m=map(int,input().split())
print(max(make_divisors(n,m)))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=[]
for i in range(1,m//n+1):
  if m%i==0:
    l.append(i)
print(max(i))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=[]
for i in range(1,int(m**1/2)+1):
  if m%i==0:
    l.append(i)
    if m//i!=i:
      l.append(m//i)
for i in range(1,len(l)+1):
  if l[len(l)-i]*n>m:
    del l[len(l)-i]
print(max(l))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
def divisor_gen(n,m):
  l=[]
  o=[]
  for i in range(2, int(n*(1/2)+1):
    if n%i == 0:
      l.append(i)
  l.append(m)
  for i in l:
    if n>=m/i:
      o.append(i)
  print(max(o))
divisor_gen(n,m)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=[]
o=[]
for i in range(1,m+1):
  if m%i==0:
    l.append(i)
for i in l:
  if n>=m/l[i]:
    o.append(l[i])
print(max(o))
Problem p03243 (python)

Fixed submission:
k=int(input())
l=[]
p=[]
for i in range(1,10):
  l.append(111*i)
for i in l:
  if i-k>=0:
    p.append(i)
print(min(p))

Buggy submission (verdict: Runtime Error):
k=int(input())
l=[]
p=[]
for i in range(1,10):
  l.append(111*i)
for i in l:
  if i-k>=0:
    p.aapend(i)
print(min(p))
Problem p03260 (python)

Fixed submission:
a,s=map(int,input().split())
if a*s%2==0:
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
i=int(input())
l=[]
c=True
for k in range(1,i+1):
  l.append(list(input())
if len(l)==len(set(l)):
  for k in range(0,i):
    if l[k][-1]!=l[k+1][0]:
       c=False
       break
else:
  c=False
if c==False:
  print("No")
else:
  print("Yes")
Problem p03261 (python)

Fixed submission:
n=int(input())
b=True
l=[]
w=input()
l.append(w)
for i in range(n-1):
  w=input()
  if w in l or w[0]!=l[-1][-1]:
    b=False
    break
  else:
    l.append(w)
if b:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[list(input())]
b=True
for i in range(n-1):
  w=list(input())
  if l[-1][-1]==w[0]:
    l.append(w)
  else:
    b=False
    break
if len(set(l))==n and b==True:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[list(input())]
b=True
for i in range(n-1):
  w=list(input())
  if l[-1][-1]==w[0]:
    l.append(w)
  else:
    b=False
    break
if len(set(l))=n and b==True:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
i=int(input())
l=[]
c=True
for k in range(1,i+1):
  l.append(list(input())
if len(l)==len(set(l)):
  for k in range(0,i):
    if l[k][-1]!=l[k+1][0]:
       c=False
       break
else:
  c=False
if c==False:
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
i=int(input())
l=[]
c=True
for k in range(1,i+1):
  l.append(list(input())
if len(l)==set(l):
  for k in range(0,i):
    if l[k][-1]!=l[k+1][0]:
       c=False
       break
else:
  c=False
if c==False:
  print("No")
else:
  print("Yes")
Problem p03262 (python)

Fixed submission:
n,x=map(int,input().split())
l=list(map(int,input().split()))
def gcd(n,m):
  a=max(n,m)
  b=min(n,m)
  while b!=0:
    a,b=b,a%b
  return a
a=abs(l[0]-x)
for i in range(n):
  a=gcd(a,abs(l[i]-x))
print(a)

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
l=list(map(int,input().split()))
def gcd(n,m):
  a=max(n,m)
  b=min(n,m)
  while b!=0:
    a,b=b,a%b
  return a
a=abs(l[0]-x)
for i in range(l):
  a=gcd(a,abs(l[i]-x))
print(a)
Problem p03274 (python)

Fixed submission:
n,m=map(int,input().split())
l=list(map(int,input().split()))
l1=[]
for i in range(n-m+1):
  if l[i]>=0:
    l1.append(l[i+m-1])
  elif l[i]<=0<=l[i+m-1]:
    l1.append(l[i+m-1]-l[i]+min(abs(l[i]),abs(l[i+m-1])))
  else:
    l1.append(abs(l[i]))
print(min(l1))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=list(map(int,input().split()))
l1=[]
for i in range(n-m+1):
  if l[i]>=0:
    l1.append(l[i+m]-l[i])
  elif l[i]<=0<=l[i+m]:
    l1.append(l[i+m]-l[i]+min(l[i],l[i+m]))
  else:
    l1.append(l[i+m]-l[i])
print(min(l1))
Problem p03280 (python)

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

Buggy submission (verdict: Runtime Error):
n=int(input())
l=0
for i in range(1,n+1):
  if i%2==1:    
    p=0
    for k in range(1,i+1):
      if i%k==0:
        p+=1
    if p==8:
      l+=1
print(l)
Problem p03282 (python)

Fixed submission:
n=list(input())
m=int(input())
i=0
for t in range(len(n)):
  if n[t]!="1":
    i=t+1
    break
if m<i:
  print(1)
else:
  print(int(n[i-1]))

Buggy submission (verdict: Runtime Error):
n=list(input())
m=int(input())
i=0
for t in range(len(n)):
  if n[t]!="1":
    i=t+1
    break
if m<i:
  print(1)
else:
  print(int(n[i]))

Buggy submission (verdict: Runtime Error):
n=list(input())
m=int(input())
i=0
for t in range(len(n)):
  if n[t]=="1":
    pass
  else:
    i=t+1
    break
if m>=i:
  print(int(n[i]))
else:
  print(1)

Buggy submission (verdict: Runtime Error):
n=list(input())
m=int(input())
i=0
for t in range(100):
  if n[t]=="1":
    pass
  else:
    i=t+1
if m=>i:
  print(str(n[i]))
else:
  print(1)
Problem p03309 (python)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
for i in range(n):
  l[i]=l[i]-i-1
l=sorted(l)
if n%2==0:
  mid=(l[n//2-1]+l[n//2])//2
else:
  mid=l[(n-1)//2]
sum=0
for i in range(n):
  sum+=abs(l[i]-mid)
print(sum)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
for i in range(n):
  l[i]=l[i]-i-1
l=sorted(l)
if n%2==0:
  mid=(l[n/2-1]+l[n/2])
else:
  mid=l[n/2]
sum=0
for i in range(n):
  sum+=abs(l[i]-mid)
print(sum)
Problem p03325 (python)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
c=0
for i in l:
  while i%2==0:    
    c+=1
    i=i//2
print(c)

Buggy submission (verdict: Runtime Error):
n=input()
l=list(map(int,input().split()))
count=0
for i in range(n):
  num=l[i]
  while num%2==0:
    count+=1
    num=num//2
print(count)
Problem p03330 (python)

Fixed submission:
n,c=map(int,input().split())
d=[]
for i in range(c):
  d.append(list(map(int,input().split())))
col=[]
for i in range(n):
  col.append(list(map(int,input().split())))
lc1=[]
lc2=[]
lc3=[]
for i in range(c):
  ccount1=0
  ccount2=0
  ccount3=0
  for j in range(n):
    for k in range(n):
      if (j+k)%3==0:
        ccount1+=d[col[j][k]-1][i]
      elif (j+k)%3==1:
        ccount2+=d[col[j][k]-1][i]
      else:
        ccount3+=d[col[j][k]-1][i]
  lc1.append(ccount1)
  lc2.append(ccount2)
  lc3.append(ccount3)
min=10**10
for i in range(c):
  for j in range(c):
    for k in range(c):
      if i==j or j==k or i==k:
        pass
      else:
        if min>lc1[i]+lc2[j]+lc3[k]:
          min=lc1[i]+lc2[j]+lc3[k]
print(min)

Buggy submission (verdict: Runtime Error):
n,c=map(int,input().split())
d=[]
for i in range(c):
  d.append(list(map(int,input().split())))
col=[]
for i in range(n):
  col.append(list(map(int,input().split())))
lc1=[]
lc2=[]
lc3=[]
for i in range(c):
  ccount1=0
  ccount2=0
  ccount3=0
  for j in range(n):
    for k in range(n):
      if (j+k)%3==0:
        ccount1+=d[col[j][k]][i]
      elif (j+k)%3==1:
        ccount2+=d[col[j][k]][i]
      else:
        ccount3+=d[col[j][k]][i]
  lc1.append(ccount1)
  lc2.append(ccount2)
  lc3.append(ccount3)
min=10**10
for i in range(c):
  for j in range(c):
    for k in range(c):
      if i==j or j==k or i==k:
        pass
      else:
        if min>lc1[i]+lc2[j]+lc3[k]:
          min=lc1[i]+lc2[j]+lc3[k]
print(min)
Problem p03354 (python)

Fixed submission:
import sys
from collections import defaultdict
import bisect
sys.setrecursionlimit(1000000)
d1=defaultdict(list)
d2=defaultdict(list)
n,m=map(int,input().split())
l=list(map(int,input().split()))
la=[[] for i in range(n+1)]
for i in range(m):
  a,b=map(int,input().split())
  la[a].append(b)
  la[b].append(a)
lb=[0 for i in range(n+1)]
def dfs(x,y):
  if lb[x]!=0:
    return
  else:
    lb[x]=y
    s=la[x]
    if s==[]:
      pass
    else:
      for i in s:
        dfs(i,y)
c=1
for i in range(1,n+1):
  dfs(i,c)
  c+=1
lc=set(lb)
for i in range(1,n+1):
  d1[lb[i]]+=[i]
  d2[lb[i]]+=[l[i-1]]
ans=0
for i in d1:
  d11=d1[i]
  d12=d2[i]
  for j in d12:
    index=bisect.bisect_right(d11,j)
    if d11[index-1]==j:
      ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
import bisect
d1=defaultdict(list)
d2=defaultdict(list)
n,m=map(int,input().split())
l=list(map(int,input().split()))
la=[[] for i in range(n+1)]
for i in range(m):
  a,b=map(int,input().split())
  la[a].append(b)
  la[b].append(a)
lb=[0 for i in range(n+1)]
def dfs(x,y):
  if lb[x]!=0:
    return
  else:
    lb[x]=y
    s=la[x]
    if s==[]:
      pass
    else:
      for i in s:
        dfs(i,y)
c=1
for i in range(1,n+1):
  dfs(i,c)
  c+=1
lc=set(lb)
for i in range(1,n+1):
  d1[lb[i]]+=[i]
  d2[lb[i]]+=[l[i-1]]
ans=0
for i in d1:
  d11=d1[i]
  d12=d2[i]
  for j in d12:
    index=bisect.bisect_right(d11,j)
    if d11[index-1]==j:
      ans+=1
print(ans)
Problem p03379 (python)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
l1=sorted(l)
for i in range(1,n+1):
  if l[i-1]<=l1[n//2-1]:
    print(l1[n//2])
  else:
    print(l1[(n-2)//2])

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
l1=sorted(l)
for i in range(1,n+1):
  if l1.index(l[i])<=n//2:
    print(l1[(n+2)//2])
  else:
    print(l1[n//2])
Problem p03386 (python)

Fixed submission:
a,b,k=map(int,input().split())
if a+k-1>=b-k+1:
  for i in range(a,b+1):
    print(i)
else:
  for i in range(k):
    print(a+i)
  for i in range(k):
    print(b-k+1+i)

Buggy submission (verdict: Runtime Error):
a,s,d=map(int,input().split())
if s-a<2*d:
  for i in range(a,s+1):
    print(i)
else:
  for i in range(a,a+k+1):
    print(i)
  for i in range(s-k+1,s+1):
    print(i)
Problem p03387 (python)

Fixed submission:
l=list(map(int,input().split()))
l=sorted(l)
a=l[0]
b=l[1]
c=l[2]
count=0
count+=c-b
if (b-a)%2==0:
  count+=(b-a)//2
else:
  count+=(b-a+1)//2+1
print(count)

Buggy submission (verdict: Runtime Error):
l=list(map(int(input().split())))
l=sorted(l)
a=l[0]
b=l[1]
c=l[2]
count=0
count+=c-b
if (b-a)%2==0:
  count+=(b-a)//2
else:
  count+=(b-a+1)//2+1
print(count)
Problem p03415 (python)

Fixed submission:
a=input()
f=input()
j=input()
print(a[0]+f[1]+j[2])

Buggy submission (verdict: Runtime Error):
a,s,d=input().split()
f,g,h=input().split()
j,k,l=input().split()
print(a+g+k)
Problem p03435 (python)

Fixed submission:
l1=list(map(int,input().split()))
l2=list(map(int,input().split()))
l3=list(map(int,input().split()))
a1=l1[0]
b2=l1[1]-a1
b3=l1[2]-a1
a2=l2[0]
a3=l3[0]
if a2+b2==l2[1] and a2+b3==l2[2] and a3+b2==l3[1] and a3+b3==l3[2]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
l1=list(map(int,input().split()))
l2=list(map(int,input().split()))
l3=list(map(int,input().split()))
a1=l1[0]
b2=l1[1]-a1
b3=l1[2]-a1
a2=l2[0]
a3=l3[0]
if a2+b2==l2[1] and a2+b3==l2[2] and a3+b2==l3[1] and a3+b3==l3[2];:
  print("Yes")
else:
  print("No")
Problem p03447 (python)

Fixed submission:
a=int(input())
s=int(input())
d=int(input())
print(a-s-(a-s)//d*d)

Buggy submission (verdict: Runtime Error):
a=int(input())
s=int(input())
d=int(input())
print(a-s-(a-s)//b*b)
Problem p03457 (python)

Fixed submission:
n=int(input())
l=[]
for i in range(n):
  l.append(list(map(int,input().split())))
l1=[0,0,0]
b=True
for i in range(n):
  if abs(l[i][1]-l1[1])+abs(l1[2]-l[i][2])>l[i][0]-l1[0]:
    b=False
    break
  elif (abs(l[i][1]-l1[1])+abs(l1[2]-l[i][2]))%2!=(l[i][0]-l1[0])%2:
    b=False
    break
  else:
    l1=l[i]
if b:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[]
for i in range(n):
  l.append(list(map(int,input().split())))
l1=[0,0,0]
b=True
for i in l:
  if abs(l[i][1]-l1[1])+abs(l1[2]-l[i][2])>l[i][0]-l1[0]:
    b=False
    break
  elif (abs(l[i][1]-l1[1])+abs(l1[2]-l[i][2]))%2!=(l[i][0]-l1[0])%2:
    b=False
    break
  else:
    l1=l[i]
if b:
  print("Yes")
else:
  print("No")
Problem p03476 (python)

Fixed submission:
def prime(n):
  if n==1:
    return False
  elif n==2:
    return True
  else:
    for i in range(2,int((n)**(1/2))+1):
      if n%i==0:
        return False
    return True
list=[True]*100001
for i in range(1,100001):
  if not prime(i):
    list[i]=False
list1=[0]
count=0
for i in range(1,100001):
  if i%2==1:
    if list[i] and list[(i+1)//2]:
      count+=1
  list1.append(count)
n=int(input())
for i in range(n):
  a,b=map(int,input().split())
  print(list1[b]-list1[a-1])

Buggy submission (verdict: Runtime Error):
q=int(input())
l=[0]
c=0
def prime(n):
  if n==2:
    return True
  elif n==1:
    return False
  else:
    return pow(2,n-1,n)==1
for i in range(1,100001):
  if prime(n)==True and prime((n+1)//2)=True:
    c+=1
  l.append(c)
for i in range(q):
  a,b=map(int,input().split())
  print(l[b]-l[a-1])
Problem p03478 (python)

Fixed submission:
n,a,b=map(int,input().split())
c=0
for i in range(1,n+1):
  w=str(i)
  d=0
  for j in range(len(w)):
    d+=int(w[j])
  if a<=d<=b:
    c+=i
print(c)

Buggy submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
c=0
for i in range(1,n+1):
  w=str(i)
  d
  for j in range(len(w)):
    d+=int(w[j])
  if a<=d<=b:
    c+=1
print(c)
Problem p03556 (python)

Fixed submission:
n=int(input())
num=int((n)**(1/2))
print((num)**2)

Buggy submission (verdict: Runtime Error):
print((int((input())**(1/2)))**2)
Problem p03557 (python)

Fixed submission:
import bisect
n=int(input())
la=sorted(map(int,input().split()))
lb=sorted(map(int,input().split()))
lc=sorted(map(int,input().split()))
countb=[]
count1=0
for i in range(n):
  index=bisect.bisect_left(la,lb[i])
  countb.append(index)
countb2=[]
sum=0
for i in range(n):
  sum+=countb[i]
  countb2.append(sum)
ans=0
for i in range(n):
  index=bisect.bisect_left(lb,lc[i])
  if index==0:
    pass
  else:
    ans+=countb2[index-1]
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
la=sorted(list(map(int,input().split())))
lb=list(map(int,input().split()))
lc=sorted(list(map(int,input().split())))
def lower(n,l):
  left=-1
  right=len(l)
  while right>left+1:
    mid=left+right
    mid=mid//2
    if n>l[mid]:
      left=mid
    elif n<l[mid]:
      right=mid
  return left+1
def upper(n,l):
  def lower(n,l):
  left=-1
  right=len(l)
  while right>left+1:
    mid=left+right
    mid=mid//2
    if n>l[mid]:
      left=mid
    elif n<l[mid]:
      right=mid
  return len(l)-right
c=0
for i in lb:
  c+=lower(i,la)*upper(i,lb)
print(c)

Buggy submission (verdict: Runtime Error):
n=int(input())
la=sorted(list(map(int,input().split())))
lb=sorted(list(map(int,input().split())))
lc=sorted(list(map(int,input().split())))
def nib1(x,l):
  right=len(l)-1
  left=0
  mid=(right+left)//2
  while left<=right:
    mid=(right+left)//2
    if x<l[mid]:
      right=mid-1
    elif x>l[mid]:
      left=mid+1
    else:
      return mid
  mid=(right+left)//2
  return mid
c=0 
for i in range(n):
  c+=nib1(lb[i],la)*(n-1-nib(lb[i],lc))
print(c)
Problem p03564 (python)

Fixed submission:
n=int(input())
m=int(input())
num=1
for i in range(n):
  if num<m:
    num*=2
  else:
    num+=m
print(num)

Buggy submission (verdict: Runtime Error):
n=int(input())
m=int(input())
num=1
for i in range(n):
  if num<k:
    num*=2
  else:
    num+=k
print(num)
Problem p03593 (python)

Fixed submission:
n,m=map(int,input().split())
#n,mの偶奇で場合分け
#n,mがともに偶数の時は全部４の倍数個なきゃダメ
#n,mの片方のみ奇数の時は、例えばnが奇数の時は個数が偶数だが４の倍数でない組みがm//2組みまで許される
#n,mがともに奇数の時は個数が偶数だが４の倍数でない組みが(n+m)//2組み許され、ただ一つ奇数が必要
l=[]
for i in range(n):
  l.append(list(input()))
from collections import defaultdict
d=defaultdict(int)
for i in range(n):
  for j in range(m):
    d[l[i][j]]+=1
b=True
count2=0
count1=0
for i in d:
  if d[i]%4==0:
    pass
  elif d[i]%2==0:
    count2+=1
  else:
    if count1!=0:
      b=False
    else:
      count1=1
if not b:#奇数個あるのが２組以上
  print("No")
else:
  if n%2==0 and m%2==0:
    if count2>0 or count1>0:
      print("No")
    else:
      print("Yes")
  elif n%2==0 and m%2==1:
    if count1>0 or count2>n//2:
      print("No")
    else:
      print("Yes")
  elif n%2==1 and m%2==0:
    if count1>0 or count2>m//2:
      print("No")
    else:
      print("Yes")
  else:
    if (count1-1)%4==2:
      count2+=1
    if count2>(n+m-2)//2:
      print("No")
    else:
      print("Yes")

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
#n,mの偶奇で場合分け
#n,mがともに偶数の時は全部４の倍数個なきゃダメ
#n,mの片方のみ奇数の時は、例えばnが奇数の時は個数が偶数だが４の倍数でない組みがm//2組みまで許される
#n,mがともに奇数の時は個数が偶数だが４の倍数でない組みが(n+m)//2組み許され、ただ一つ奇数が必要
l=[]
for i in range(n):
  l.append(list(input()))
from collections import defaultdict
d=defaultdict(int)
for i in range(n):
  for j in range(m):
    d[l[i][j]]+=1
b=True
count2=0
count1=0
for i in d:
  if d[i]%4==0:
    pass
  elif d[i]%2==0:
    count2+=1
  else:
    if count1!=0:
      b=False
    else:
      count1=1
      index=d[i]
if not b:#奇数個あるのが２組以上
  print("No")
else:
  if n%2==0 and m%2==0:
    if count2>0 or count1>0:
      print("No")
    else:
      print("Yes")
  if n%2==0 and m%2==1:
    if count1>0 or count2>n//2:
      print("No")
    else:
      print("Yes")
  if n%2==1 and m%2==0:
    if count1>0 or count2>m//2:
      print("No")
    else:
      print("Yes")
  else:
    if (index-1)%4==2:
      count2+=1
    if count2>(n+m-2)//2:
      print("No")
    else:
      print("Yes")