Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
Mod = 10**9+7

def f(x):
  if x == 0:
    return 1
  elif x%2 == 1:
    return (3*f(x-1))%Mod
  else:
    return (f(x//2)**2)%Mod

def g(x):
  if x == 0:
    return 1
  elif x%2 == 1:
    return (2*g(x-1))%Mod
  else:
    return (g(x//2)**2)%Mod

l = [int(t) for t in list(input())]
n = len(l)

s = 0
k = 0
for i in range(n):
  if l[i] == 0:
    continue
  s = (s + f(n-1-i)*g(k))%Mod
  k += 1
s = (s + g(k))%Mod
print(s)

Fixed submission:
from functools import lru_cache
Mod = 10**9+7

l = [int(t) for t in list(input())]
n = len(l)

@lru_cache(maxsize=10000)
def f(x):
  if x == 0:
    return 1
  elif x%2 == 1:
    return (3*f(x-1))%Mod
  else:
    return (f(x//2)**2)%Mod

@lru_cache(maxsize=10000)
def g(x):
  if x == 0:
    return 1
  elif x%2 == 1:
    return (2*g(x-1))%Mod
  else:
    return (g(x//2)**2)%Mod



s = 0
k = 0
for i in range(n):
  if l[i] == 0:
    continue
  s = (s + f(n-1-i)*g(k))%Mod
  k += 1
s = (s + g(k))%Mod
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(map(int,input().split()))

ans = 0

for k in range(1,n):
  for c in range(1,n):
    a = (n-1) - c*k
    if a <= c:
      break
      #書き足す
    if a%c == 0 and a//c <= k:
      continue
    p = sum(s[a:a+k*c+1:c]) + sum(s[c:k*c+1:c])
    # print(a,c,k,p, sum(s[a:a+k*c+1:c]) , sum(s[c:k*c+1:c]) )
    ans = max(p,ans)
print(ans)

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

ans = 0

for c in range(1,n-1):
  if (n-1)%c == 0:
    p = ((n-1)//c-1)//2 
  else:
    p = (n-1)//c-1
    if p <= 0:
      break
  if p <= 0:
    continue
  m = 0
  k = 0
  for i in range(1,p+1):
    k += s[c*i] + s[n-1-c*i]
    m = max(m,k)
  ans = max(ans,m)
    
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
a,b,c,n = map(int,input().split())
d = fractions.gcd(b,c)
b = b//d
c = c//d
#print(d)
ans = 0
x,y,z = 0,0,0
while a*x <= n:
  m = n-a*x
  if m%d > 0:
    continue
  m = m//d
  y = 0
  f = 0
  while m-b*y>= 0 and y < c:
    if (m-b*y)%c == 0:
      f = 1
      break
    y += 1
  ans += f*((m-b*y)//c//b+1)
  x += 1
print(ans)

Fixed submission:
import fractions
z = [0,0,0]
z[0],z[1],z[2],n = map(int,input().split())
z.sort(reverse = 1)
a,b,c = z[2],z[1],z[0]
d = fractions.gcd(b,c)
b = b//d
c = c//d
#print(d)
ans = 0
x,y,z = 0,0,0
while a*x <= n:
  m = n-a*x
  if m%d > 0:
    continue
  m = m//d
  y = 0
  f = 0
  while m-b*y>= 0 and y < c:
    if (m-b*y)%c == 0:
      f = 1
      break
    y += 1
  ans += f*((m-b*y)//c//b+1)
  x += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
k = int(input())

c = s[k]
a = ""
for t in list(s):
 if t == c:
  a += c
 else:
  a += "*"
print(a) 

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

c = s[k-1]
a = ""
for t in list(s):
 if t == c:
  a += c
 else:
  a += "*"
print(a)
Buggy python submission (verdict: Runtime Error):
a = [0]*5
for i in range(3):
  x,y = map(int,input().split())
  a[x] += 1
  a[y] += 1
if sorted(a) = [0,1,1,2,2]:
  print("YES")
else:
  print("NO")

Fixed submission:
a = [0]*5
for i in range(3):
  x,y = map(int,input().split())
  a[x] += 1
  a[y] += 1
if sorted(a) == [0,1,1,2,2]:
  print("YES")
else:
  print("NO")

Buggy python submission (verdict: Runtime Error):
a = [0]*4
for i in range(3):
  x,y = map(int,input().split())
  a[x] += 1
  a[y] += 1
if sorted(a) = [1,1,2,2]:
  print("YES")
else:
  print("NO")

Fixed submission:
a = [0]*5
for i in range(3):
  x,y = map(int,input().split())
  a[x] += 1
  a[y] += 1
if sorted(a) == [0,1,1,2,2]:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
n,p = map(int,input().split())
if n == 1:
  print(p)
  exit()
a = 1
for i in range(1,1000001):
  if p< i**n:
    break
  if p%(i ** n) == 0:
    a = i
print(a)

Fixed submission:
n,p = map(int,input().split())
if n == 1:
  print(p)
  exit()
a = 1
for k in range(2,1000001):
  c = 0
  while p%k == 0:
    p = p//k
    c += 1
  a *= k**(c//n)
  if p == 1:
    break
print(a)

Buggy python submission (verdict: Time Limit Exceeded):
n,p = map(int,input().split())
if n == 1:
  print(p)
  exit()
a = 1
for i in range(1,1000001):
  if p%(i ** n) == 0:
    a = i
print(a)

Fixed submission:
n,p = map(int,input().split())
if n == 1:
  print(p)
  exit()
a = 1
for k in range(2,1000001):
  c = 0
  while p%k == 0:
    p = p//k
    c += 1
  a *= k**(c//n)
  if p == 1:
    break
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
d = dict()
p = [0]*m
y = [0]*m
for i in range(m):
  p[i], y[i] = map(int,input().split())
  if p[i] in d:
    d[p[i]] = d[p[i]] + [y[i]]
  else:
    d[p[i]] = [y[i]]
for x in d:
  d[x] = sorted(d[x])
  d[x] = dict([[d[x][j],j] for j in range(len(d[x]))])
for i in range(m):
  print("{0:06d}".format(p[i])+"{0:06d}".format(d[p[i]][y[i]]+1))

Fixed submission:
n,m = map(int,input().split())
d = dict()
p = [0]*m
y = [0]*m
c = [0]*m
a = []
for i in range(m):
  p[i], y[i] = map(int,input().split())
  a.append([y[i], i, p[i]])
a.sort()
for x in a:
  if x[2] in d:
    d[x[2]] =  d[x[2]] + 1
  else:
    d[x[2]] = 1
  c[x[1]] = d[x[2]]
for i in range(m):
  print("{0:06d}".format(p[i])+"{0:06d}".format(c[i]))

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
d = [[]]*(n+1)
q = [[]]*(n+1)
p = [0]*m
y = [0]*m
for i in range(m):
  p[i], y[i] = map(int,input().split())
  d[p[i]] = d[p[i]] + [y[i]]
for i in range(n+1):
  d[i] = sorted(d[i])
  d[i] = dict([[d[i][j],j] for j in range(len(d[i]))])
for i in range(m):
  print("{0:06d}".format(p[i])+"{0:06d}".format(d[p[i]][y[i]]+1))

Fixed submission:
n,m = map(int,input().split())
d = dict()
p = [0]*m
y = [0]*m
c = [0]*m
a = []
for i in range(m):
  p[i], y[i] = map(int,input().split())
  a.append([y[i], i, p[i]])
a.sort()
for x in a:
  if x[2] in d:
    d[x[2]] =  d[x[2]] + 1
  else:
    d[x[2]] = 1
  c[x[1]] = d[x[2]]
for i in range(m):
  print("{0:06d}".format(p[i])+"{0:06d}".format(c[i]))
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
while True:
  if m%n == 0:
    print(m//n)
    break
  n += 1

Fixed submission:
n,m = map(int, input().split())
if n*n <= m:
  k = n
  while k*k <= m:
    if m%k == 0:
      print(m//k)
      exit()
    k += 1
else:
  n = m//n

k = n
while True:
  if m%k == 0:
    print(k)
    exit()
  k -= 1

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
while n <= m:
  if m%n == 0:
    print(m//n)
    break
  n += 1

Fixed submission:
n,m = map(int, input().split())
if n*n <= m:
  k = n
  while k*k <= m:
    if m%k == 0:
      print(m//k)
      exit()
    k += 1
else:
  n = m//n

k = n
while True:
  if m%k == 0:
    print(k)
    exit()
  k -= 1

Buggy python submission (verdict: Runtime Error):
n,m = map(int,input())
while n <= m:
  if m%n == 0:
    print(m%n)
    break
  n += 1

Fixed submission:
n,m = map(int, input().split())
if n*n <= m:
  k = n
  while k*k <= m:
    if m%k == 0:
      print(m//k)
      exit()
    k += 1
else:
  n = m//n

k = n
while True:
  if m%k == 0:
    print(k)
    exit()
  k -= 1

Buggy python submission (verdict: Runtime Error):
n,m = map(int,input())
while n <= m:
  if m%n == 0:
    print(m%n)
  n += 1
break

Fixed submission:
n,m = map(int, input().split())
if n*n <= m:
  k = n
  while k*k <= m:
    if m%k == 0:
      print(m//k)
      exit()
    k += 1
else:
  n = m//n

k = n
while True:
  if m%k == 0:
    print(k)
    exit()
  k -= 1
Buggy python submission (verdict: Runtime Error):
n,m,x,y = map(int,input().split())
a = max(max(list(map(int,input().split())),x)
b = min(min(list(map(int,input().split())),y)
print("No War" if a<b else "War")

Fixed submission:
n,m,x,y = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
print("No War" if max(max(a),x)<min(min(b),y) else "War")
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
while s != "":
  x = s[0]
  y = t[0]
  for i in range(len(s)):
    if (s[i] == "x" and t[i] != "y") or (s[i] != "x" and t[i] == "y"):
      print("No")
      exit()
  s = s.replace(x,"")
  t = t.replace(y,"")
print("Yes")

Fixed submission:
s = input()
t = input()
while s != "":
  x = s[0]
  y = t[0]
  for i in range(len(s)):
    if (s[i] == x and t[i] != y) or (s[i] != x and t[i] == y):
      print("No")
      exit()
  s = s.replace(x,"")
  t = t.replace(y,"")
print("Yes")
Buggy python submission (verdict: Runtime Error):
n = input()
w = []
Flag = Trure 
for i in range(n):
  w.append(input())
for i in range(n-1):
  if w[i][-1] != w[i+1][0]:
    Flag = False
if len(w) = len(set(w)):
  Flag = False
print("Yes" if Flag else "No")

Fixed submission:
n = int(input())
w = []
Flag = True 
for i in range(n):
  w.append(input())
for i in range(n-1):
  if w[i][-1] != w[i+1][0]:
    Flag = False
if len(w) != len(set(w)):
  Flag = False
print("Yes" if Flag else "No")
Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
a = list(map(int, input().split()))
if 0 in a:
  a.remove(0)
  n -= 1
  k -= 1
m = 300000000
for i in range(n+1-k):
  if a[i+k-1] < 0:
    x = -a[i]
  if a[i] > 0:
    x = a[i+k-1]
  else:
    x = (a[i+k-1]-a[i]) + min(-a[i],a[i+k-1])
  m = min(m,x)
print(m)

Fixed submission:
n,k = map(int, input().split())
a = list(map(int, input().split()))
if 0 in a:
  a.remove(0)
  n -= 1
  k -= 1
if k == 0:
  print(0)
  exit()
m = 300000000
for i in range(n+1-k):
  if a[i+k-1] < 0:
    x = -a[i]
  elif a[i] > 0:
    x = a[i+k-1]
  else:
    x = (a[i+k-1]-a[i]) + min(-a[i],a[i+k-1])
  m = min(m,x)
print(m)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s =""
k = 0
while n!=0:
  if n%(2**(k+1)) == 2**k:
    if k%2 == 0:
      n -= 2**k
    else:
      n += 2**k
    s += "1"
  else:
    s += "0"
  k += 1

if s="":
  s="0"

print("".join(s))

Fixed submission:
n = int(input())
s = ""
k = 0
while n!=0:
  if n%(2**(k+1)) == 2**k:
    if k%2 == 0:
      n -= 2**k
    else:
      n += 2**k
    s = "1"+s
  else:
    s = "0"+s
  k += 1

if s=="":
  s="0"

print("".join(s))
Buggy python submission (verdict: Runtime Error):
r = input()
if r < 1200:
  print("ABC")
elif r < 2800:
  print("ARC")
else:
  print("AGC")
  

Fixed submission:
r = int(input())
if r < 1200:
  print("ABC")
elif r < 2800:
  print("ARC")
else:
  print("AGC")
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
flag = False
for i in range(len(i)):
  if s == t:
    flag = True
    break
  s = s[1:] + s[0]
print("Yes" if flag else "No")


Fixed submission:
s = input()
t = input()
flag = False
for i in range(len(s)):
  if s == t:
    flag = True
    break
  s = s[1:] + s[0]
print("Yes" if flag else "No")
Buggy python submission (verdict: Runtime Error):
s = input()
n = len(s)
k = int(input())
l = set()
for t in range(1,k+1):
  for i in range(n):
    if i+t>=n:
      break
    l.add(s[i:i+t])
a = list(l)
a.sort()
print(a[k-1])

Fixed submission:
s = input()
n = len(s)
k = int(input())
l = set()
for t in range(1,k+1):
  for i in range(max(n-t+1,0)):
    l.add(s[i:i+t])
a = list(l)
a.sort()
print(a[k-1])
Buggy python submission (verdict: Runtime Error):
n = int(input())
x = list(map(int, input().split()))
y = sorted(x)
a = y[n//2-1]
b = y[n//2+1]
for i in range(n):
  if x[i] <= a:
    print(b)
  else:
    print(a)

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

Buggy python submission (verdict: Runtime Error):
n = int(input())
x = list(map(int, input().split()))
a = x[n//2-1]
b = x[n//2+1]
for i in range(n):
  if x[i] <= a:
    print(b)
  else:
    print(a)

Fixed submission:
n = int(input())
x = list(map(int, input().split()))
y = sorted(x)
a = y[n//2-1]
b = y[n//2]
for i in range(n):
  if x[i] <= a:
    print(b)
  else:
    print(a)
Buggy python submission (verdict: Runtime Error):
a,b,k = map(int,input().split())
if b-a<2*k:
  for x in range(a,b+1):
    print(x)
else:
  for x in range(a,a+k)+range(b-k+1,b+1):
    print(x)


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

Buggy python submission (verdict: Time Limit Exceeded):
a,b,k = map(int,input().split())
for x in range(a,b+1):
  if x<a+k or x>b-k:
    print(x)

Fixed submission:
a,b,k = map(int,input().split())
if b-a<2*k:
  for x in range(a,b+1):
    print(x)
else:
  for x in range(a,a+k):
    print(x)
  for x in range(b-k+1,b+1):
    print(x)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())

p = [["."]*50 for _ in range(20)]
q = [["#"]*50 for _ in range(21)]

for t in range(b-1):
  p[t//25*2][t%25*2] = "#"
for t in range(a-1):
  q[t//25*2+1][t%25*2] = "."
  
print(41, 50)
for l in p+q:
  print("".join(l))
  


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

p = [["."]*100 for _ in range(20)]
q = [["#"]*100 for _ in range(21)]

for t in range(b-1):
  p[t//50*2][t%50*2] = "#"
for t in range(a-1):
  q[t//50*2+1][t%50*2] = "."
  
print(41, 100)
for l in p+q:
  print("".join(l))

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

p = [["."]*50 for _ in range(20)]
q = [["#"]*50 for _ in range(21)]

for t in range(b-1):
  p[t//25*2][t%25*2] = "#"
for t in range(a-1):
  q[t//25*2+1][t%25*2] = "."
  
print(41, 50)
for l in q:
  print("".join(l))
  


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

p = [["."]*100 for _ in range(20)]
q = [["#"]*100 for _ in range(21)]

for t in range(b-1):
  p[t//50*2][t%50*2] = "#"
for t in range(a-1):
  q[t//50*2+1][t%50*2] = "."
  
print(41, 100)
for l in p+q:
  print("".join(l))

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

p = [["."]*50 for _ in range(20)]
q = [["#"]*50 for _ in range(21)]

for t in range(b-1):
  p[t//25*2][t%25*2] = "#"
for t in range(a-1):
  q[t//25*2+1][t%25*2] = "."
  
print(41, 50)
for l in p + q:
  print(" ".join(l))
  

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

p = [["."]*100 for _ in range(20)]
q = [["#"]*100 for _ in range(21)]

for t in range(b-1):
  p[t//50*2][t%50*2] = "#"
for t in range(a-1):
  q[t//50*2+1][t%50*2] = "."
  
print(41, 100)
for l in p+q:
  print("".join(l))

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

p = [["."]*50 for _ in range(20)]
q = [["#"]*50 for _ in range(21)]

for t in range(b-1):
  p[t//25*2][t%25*2] = "#"
for t in range(a-1):
  q[t//25*2+1][t%25*2] = "."
for l in p:
  print(" ".join(l))

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

p = [["."]*100 for _ in range(20)]
q = [["#"]*100 for _ in range(21)]

for t in range(b-1):
  p[t//50*2][t%50*2] = "#"
for t in range(a-1):
  q[t//50*2+1][t%50*2] = "."
  
print(41, 100)
for l in p+q:
  print("".join(l))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(input())
flag = False
for i in range(n):
  if a[i] == "Y":
    flag = True

if flag == Ture:
  print("Four")
else:
  print("Three")

Fixed submission:
n = int(input())
a = list(input())
for i in range(n):
  if a[i] == "Y":
    print("Four")
    exit()
    
print("Three")
Buggy python submission (verdict: Runtime Error):
c = []
for _ in [0]*3:
  c += [list(map(int, input().split()))]

flag = True
for i in [0,1]:
  for j in [0,1]:
    if c[i][j] + c[i+1][j+1] != c[i+1][j] + c[i][j+1]:
      flag = False
print("Yes" if Flag else "No")

Fixed submission:
c = []
for _ in [0]*3:
  c += [list(map(int, input().split()))]

flag = True
for i in [0,1]:
  for j in [0,1]:
    if c[i][j] + c[i+1][j+1] != c[i+1][j] + c[i][j+1]:
      flag = False
print("Yes" if flag else "No")
Buggy python submission (verdict: Runtime Error):
print( (int(input())-int(input())) % input())

Fixed submission:
print( (int(input())-int(input())) % int(input()))
Buggy python submission (verdict: Time Limit Exceeded):
from queue import Queue

n,m = map(int,input().split())
e = []
for i in range(n+1):
  e.append([])

for i in range(m):
  l,r,d = map(int,input().split())
  e[l].append([r,d])
  e[r].append([l,-d])
#print(e)

c = [0]*(n+1) #チェック用
p = [0]*(n+1) #位置

flag = True
k = 1
while k < n:
  if c[k] == 2:
    k += 1
    continue
  q = Queue()
  q.put(k)
  p[k] = 0
  c[k] = 1
  while not q.empty():
    x = q.get()
    c[x] = 2
    for t in e[x]:
      y = t[0]
      d = t[1]
      if c[y] == 0:
        p[y] = p[x] + d
        c[y] = 1
        q.put(y)
      elif c[y] == 1:
        if not p[y] == p[x] + d:
          print("No")
          quit()
      else:
        w = 1
print("Yes")  

Fixed submission:
n,m = map(int,input().split())
c = list(range(n+1)) #色
a = [] #色ごとのリスト
for i in range(n+1):
  a.append([i])
b = [1]*(n+1) #色ごとの頂点数
p = [0]*(n+1) #位置
#print(a)
for i in range(m):
  x,y,d = map(int,input().split())
  u = c[x]
  v = c[y]
  if b[u] < b[v]:
    x,y = y,x
    u,v = v,u
    d = -d
  if u != v:
    l = d + p[x] - p[y]
    for t in a[v]:
      c[t] = u
      p[t] += l
    a[u] += a[v]
    a[v] = []
    b[u] += b[v]
    b[v] = 0
  else:
    if not p[y]-p[x] == d:
      #print(p)
      print("No")
      quit()
print("Yes")
Buggy python submission (verdict: Runtime Error):
import math
x = int(input()+input())
y = math.sqrt(x)
if y == int(y):
  print("Yes")
else:
  print("No")

Fixed submission:
import math
x0, x1 = input().split()
y = math.sqrt(int(x0+x1))
if y == int(y):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n, y = map(int, input().split())
y /= 1000
flag = 0

a = 0
while 10*a <= y:
  b = 0
  while 5*b + 10*a <=y:
    r = y - 10*a - 5*b
    if n == a + b + r:
      print(a, b, int(r))
      flag = 1
      break
    b += 1
  if flag == 1:
    break
  a += 1
  
if flag == 0:
  print(-1, -1, -1)
  
    
  

Fixed submission:
n,y = map(int,input().split())
y //= 1000
flag = False

for k in range(0,n+1):
  a = n-k
  b = y-10*k-a
  if b%4 == 0 and b <= 4*a and b>=0:
    flag = True
    break
    
if flag:
  print(k,b//4,a-b//4)
else:
  print(-1,-1,-1)

Buggy python submission (verdict: Time Limit Exceeded):
n, y = map(int, input().split())
y /= 1000
flag = 0

a = 0
while 10*a <= y:
  b = 0
  while 5*b + 10*a <=y:
    r = y - 10*a - 5*b
    if n == a + b + r:
      print(a, b, int(r))
      flag = 1
      break
    b += 1
  if flag == 1:
    break
  a += 1
  
if flag == 0:
  print(-1)
  print(-1)
  print(-1)
  
    
  

Fixed submission:
n,y = map(int,input().split())
y //= 1000
flag = False

for k in range(0,n+1):
  a = n-k
  b = y-10*k-a
  if b%4 == 0 and b <= 4*a and b>=0:
    flag = True
    break
    
if flag:
  print(k,b//4,a-b//4)
else:
  print(-1,-1,-1)

Buggy python submission (verdict: Runtime Error):
n, y = map(int, input().split())
y /= 1000
flag = 0

a = 0
while 10*a <= y:
  b = 0
  while 5*b + 10*a <=y:
    r = y - 10*a - 5*b
    if n = a + b + r:
      print(a)
      print(b)
      print(r)
      flag = 1
      break
    b += 1
  if flag = 1:
    break
  a += 1
  
if flag = 0:
  print(-1)
  print(-1)
  print(-1)
  
    
  

Fixed submission:
n,y = map(int,input().split())
y //= 1000
flag = False

for k in range(0,n+1):
  a = n-k
  b = y-10*k-a
  if b%4 == 0 and b <= 4*a and b>=0:
    flag = True
    break
    
if flag:
  print(k,b//4,a-b//4)
else:
  print(-1,-1,-1)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
s = input()
if s[a] == "-":
  s[a] = "0"
else:
  print("No")
  exit()
if s.isdigit():
  print("Yes")
else:
  print("No")

Fixed submission:
a, b = map(int,input().split())
s = list(input())
if s.pop(a) != "-":
  print("No")
  exit()
if "".join(s).isdigit():
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
p,q,r = [2],[],[]
k = 3
while k < 100000:
  flag = True
  for t in p:
    if t*t > k:
      break
    if k%t == 0:
      flag = False
  if flag:
    p.append(k)
  k += 2
for t in p[1:]:
  if (t+1)//2 in p:
    q.append(t)
q.append(100000+3)
k = 0
for i in range(99999//2+1):
  while q[k]<=2*i+1:
    k += 1
  r.append(k)
c = int(input())
while c>0:
  x,y = map(int,input().split())
  print(r[y//2]-r[max(x,3)//2-1])
  c -= 1
  

Fixed submission:
N = 10**5
p = [0]*(N+1)
q = [0]*(N+1)

p[2] = 1
primes = [2]

for i in range(3,N+1):
  f = 1
  for t in primes:
    if t*t > i:
      break
    if i%t == 0:
      f = 0
      break
  if f == 1:
    primes.append(i)
    p[i] = 1
    if p[(i+1)//2]:
      q[i] = 1
m = 0
s = [0]*(N+1)
for i in range(1,N+1):
  m += q[i]
  s[i] = m
  
for i in range(int(input())):
  l,r = map(int,input().split())
  print(s[r]-s[l-1])

Buggy python submission (verdict: Runtime Error):
p,q,r = [2],[],[]
k = 3
while k < 100000:
  flag = True
  for t in p:
    if t*t > k:
      break
    if k%t == 0:
      flag = False
  if flag:
    p.append(k)
  k += 2
for t in p[1:]:
  if (t+1)//2 in p:
    q.append(t)
q.append(100000+3)
k = 0
for i in range(99999//2):
  while q[k]<=2*i+1:
    k += 1
  r.append(k)
c = int(input())
while c>0:
  x,y = map(int,input().split())
  print(r[y//2]-r[max(x,3)//2-1])
  c -= 1
  

Fixed submission:
N = 10**5
p = [0]*(N+1)
q = [0]*(N+1)

p[2] = 1
primes = [2]

for i in range(3,N+1):
  f = 1
  for t in primes:
    if t*t > i:
      break
    if i%t == 0:
      f = 0
      break
  if f == 1:
    primes.append(i)
    p[i] = 1
    if p[(i+1)//2]:
      q[i] = 1
m = 0
s = [0]*(N+1)
for i in range(1,N+1):
  m += q[i]
  s[i] = m
  
for i in range(int(input())):
  l,r = map(int,input().split())
  print(s[r]-s[l-1])

Buggy python submission (verdict: Runtime Error):
k = 3
p,q,r = [2],[],[]
while k < 100000:
  flag = True
  for t in p:
    if t*t > k:
      break
    if k%t == 0:
      flag = False
  if flag:
    p.append(k)
  k += 2
for t in p[1:]:
  if (t+1)//2 in p:
    q.append(t)
q.append(100000+3)
k = 0
for i in range(99999//2):
  while q[k]<=2*i+1:
    k += 1
  r.append(k)
for _ in [0]*int(input()):
  x,y = map(int,input().split())
  print(r[y//2]-r[max(x,3)//2-1])
  

Fixed submission:
N = 10**5
p = [0]*(N+1)
q = [0]*(N+1)

p[2] = 1
primes = [2]

for i in range(3,N+1):
  f = 1
  for t in primes:
    if t*t > i:
      break
    if i%t == 0:
      f = 0
      break
  if f == 1:
    primes.append(i)
    p[i] = 1
    if p[(i+1)//2]:
      q[i] = 1
m = 0
s = [0]*(N+1)
for i in range(1,N+1):
  m += q[i]
  s[i] = m
  
for i in range(int(input())):
  l,r = map(int,input().split())
  print(s[r]-s[l-1])
Buggy python submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
c = 0
for k in range(a,b+1):
  if sum(list(map(int, list(str(k)))):
         c += 1
print(c)

Fixed submission:
n,a,b = map(int,input().split())
s = 0
for k in range(1,n+1):
  x = sum(list(map(int, list(str(k))))) 
  if x >= a and x <= b:
         s += k 
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())

a = []
k = 0
for z in s:
  if z == "T":
    a += [k]
    k = 0
  else:
    k += 1
a += [k]
# print(a)

l = [a[0]]
for k in a[2::2]:
  l = [t+k for t in l] + [t-k for t in l]

m = [0]
for k in a[1::2]:
  m = [t+k for t in m] + [t-k for t in m]

x,y = map(int,input().split())
print("Yes" if x in l and y in m else "No")


Fixed submission:
s = list(input())

a = []
k = 0
for z in s:
  if z == "T":
    a += [k]
    k = 0
  else:
    k += 1
a += [k]
# print(a)

l = [a[0]]
for k in a[2::2]:
  if k == 0:
    continue
  l = [t+k for t in l] + [t-k for t in l]
  l = list(set(l))

m = [0]
for k in a[1::2]:
  if k == 0:
    continue
  m = [t+k for t in m] + [t-k for t in m]
  m = list(set(m))

x,y = map(int,input().split())
print("Yes" if x in l and y in m else "No")
Buggy python submission (verdict: Runtime Error):
x = int(input(),16)-int(input(),16)
if x > 0:
  print(">")
elif x < 0:
  print("<")
else:
  print("=")

Fixed submission:
x, y = input().split()
d = int(x,16)-int(y,16)
if d > 0:
  print(">")
elif d < 0:
  print("<")
else:
  print("=")
Buggy python submission (verdict: Runtime Error):
print(int(sqrt(int(input())))^2)

Fixed submission:
import math
print(int(math.sqrt(int(input())))**2)