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

Fixed submission:
s = input()
if s[0]=='R':
  if s[1]=='R':
    if s[2]=='R':
      print(3)
    else:
      print(2)
  else:
    print(1)
elif s[0]=='S':
  if s[1]=='R':
    if s[2]=='R':
      print(2)
    else:
      print(1)
  else:
    if s[2]=='R':
      print(1)
    else:
      print(0)

Buggy submission (verdict: Runtime Error):
s = input()
if s[0]=='R':
  if s[1]=='R':
    if s[2]=='R':
      print(3)
    else:
      print(2)
  else:
    print(1)
elif s[0]=='S':
  if s[1]=='R':
    if s[2]=='R':
      print(2)
    else:
      print(1)
  elif:
    if s[2]=='R':
      print(1)
    else:
      print(0)
Problem p02630 (python)

Fixed submission:
import collections

n=int(input())
arr=list(map(int,input().split()))
cnt=collections.defaultdict(int)
for val in arr:
  cnt[val]+=1
sums=sum(arr)
q=int(input())
for a in range(q):
  b,c=map(int,input().split())
  diff=(c-b)*(cnt[b])
  sums+=diff
  print(sums)
  cnt[c]+=cnt[b]
  cnt[b]=0

Buggy submission (verdict: Runtime Error):
import numpy as np

def main():
  N = int(input())
  A = list(map(int,input().split()))
  A.sort()
  d = np.zeros(A[-1]+1, dtype=np.unit64)
  
  for i in range(N):
    a = A[i]
    a1 = A[i-1]
    if a != a1:
      if a != a1:
        d[a::a] += 1
      else:
        d[a] += 1
  print(np.count_nonzero(d[A] == 1))
  
main()
Problem p02631 (python)

Fixed submission:
n = int(input())
arr = list(map(int,input().split()))
xors = 0
for val in arr:
  xors^=val
ans = []
for i in range(n):
  ans.append(xors^arr[i])
  
print(*ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
arr = list(map(int,input().split()))
xors = 0
for val in arr:
  xors^=val
ans = []
for i in range(n):
  ans.append(xros^arr[i])
  
print(*ans)
Problem p02639 (python)

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

for i in range(0,5):
  if a[i] == 0:
    n = i + 1
      
print(n)

Buggy submission (verdict: Runtime Error):
import numpy as np

def main():
  N = int(input())
  A = list(map(int,input().split()))
  A.sort()
  d = np.zeros(A[-1]+1, dtype=np.unit64)
  
  for i in range(N):
    a = A[i]
    a1 = A[i-1]
    if a != a1:
      if a != a1:
        d[a::a] += 1
      else:
        d[a] += 1
  print(np.count_nonzero(d[A] == 1))
  
main()
Problem p02642 (python)

Fixed submission:
import numpy as np

def main():
  N = int(input())
  A = list(map(int,input().split()))
  A.sort()
  d = np.zeros(A[-1]+1, dtype=np.uint64)
  
  for i in range(N):
    a = A[i]
    a1 = A[i-1]
    if a != a1:
      d[a::a] += 1
    else:
      d[a] += 1
  print(np.count_nonzero(d[A] == 1))
  
main()

Buggy submission (verdict: Runtime Error):
import numpy as np

def main():
  N = int(input())
  A = list(map(int,input().split()))
  A.sort()
  d = np.zeros(A[-1]+1, dtype=np.unit64)
  
  for i in range(N):
    a = A[i]
    a1 = A[i-1]
    if a != a1:
      d[a::a] += 1
    else:
      d[a] += 1
  print(np.count_nonzero(d[A] == 1))
  
print(main())

Buggy submission (verdict: Runtime Error):
import numpy as np

def main():
  N = int(input())
  A = list(map(int,input().split()))
  A.sort()
  d = np.zeros(A[-1]+1, dtype=np.unit64)
  
  for i in range(N):
    a = A[i]
    a1 = A[i-1]
    if a != a1:
        d[a::a] += 1
      else:
        d[a] += 1
  print(np.count_nonzero(d[A] == 1))
  
main()

Buggy submission (verdict: Runtime Error):
import numpy as np

def main():
  N = int(input())
  A = list(map(int,input().split()))
  A.sort()
  d = np.zeros(A[-1]+1, dtype=np.unit64)
  
  for i in range(N):
    a = A[i]
    a1 = A[i-1]
    if a != a1:
      if a != a1:
        d[a::a] += 1
      else:
        d[a] += 1
  print(np.count_nonzero(d[A] == 1))
  
main()

Buggy submission (verdict: Runtime Error):
import numpy as np

def main():
  N = int(input())
  A = list(map(int,input().split()))
  A.sort()
  d = np.zeros(A[-1]+1, dtype=np.unit64)
  
  for i in range(N):
    a = A[i]
    a1 = A[i-1]
    if a != a1:
      if a != a1:
        d[a::a] += 1
      else:
        d[a] += 1
  print(np.count_nonzero(d[A] == 1))
  
print(main())
Problem p02708 (python)

Fixed submission:
n,k = map(int,input().split())
ans = 0

for i in range(k, n+2):
  a = 0.5* i* (i-1)
  b = 0.5* n* (n+1) - 0.5* (n-i)* (n-i+1)
  ans += int(b-a+1)
  
print(ans%(10**9+7))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
ans = 0

for i in range(k, n+2):
  a = 0.5* i* (i-1)
  b = 0.5* n* (n+1) - 0.5* (n-i)* (n-i+1)
  ans += int(b-a+1)
  
print(ans%(10**9+7)
Problem p02714 (python)

Fixed submission:
n = int(input())
s = list(input())
ans = s.count('R')*s.count('G')*s.count('B')

for i in range(n):
  if s[i] == 'R':
    s[i] = 1
  elif s[i] == 'G':
    s[i] = 2
  elif s[i] == 'B':
    s[i] = 4
  
for i in range(n):
  for j in range(i+1, n):
    k = 2*j - i
    if k >= n:
      continue
    if s[i]+s[j]+s[k]==7:
      ans-=1

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = list(input())
ans = s.count('R')*s.count('G')*s.count('B')

for i in range(n):
  if s[i] == 'R':
    s[i] = 1
  elif s[i] == 'G':
    s[i]
  elif s[i] == 'B':
    s[i] = 4
  
for i in range(n):
  for j in range(i+1, n):
    k = 2*j - i
    if k >= n:
      continue
    if s[i]+s[j]+s[k]==7:
      ans-=1

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = list(input())
ans = s.count('R')*s.count('G')*s.count('B')

for i in range(n):
  if s[i] == 'R':
    s[i] = 1
  elif s[i] == 'G':
    s[i]
  elif s[i] = 4
  
for i in range(n):
  for j in range(i+1, n):
    k = 2*j - i
    if k >= n:
      continue
    if s[i]+s[j]+s[k]==7:
      ans-=1

print(ans)
Problem p02732 (python)

Fixed submission:
import collections

n = int(input())
arr = list(map(int,input().split()))
cnt = collections.Counter(arr)
total = 0

for key in cnt.keys():
  total += cnt[key] * (cnt[key] - 1)//2
  
for i in range(n):
  tmp = total
  tmp -= cnt[arr[i]]*(cnt[arr[i]] - 1)//2
  tmp += (cnt[arr[i]] - 1)*(cnt[arr[i]] - 2)//2
  print(tmp)

Buggy submission (verdict: Runtime Error):
import collections

n = int(input())
arr = list(map(int,input().split()))
cnt = collectioms.Counter(arr)
total = 0

for key in cnt.keys():
  total += cnt[key] * (cnt[key] - 1)//2
  
for i in range(n):
  tmp = total
  tmp -= cnt[arr[i]]*(cnt[arr[i]] - 1)//2
  tmp += (cnt[arr[i]] - 1)*(cnt[arr[i]] - 2)//2
  print(tmp)
Problem p02755 (python)

Fixed submission:
a,b = map(int,input().split())
ans =-1
for i in range(10000,-1,-1):
  money0 = int(i*0.08)
  money1= int(i*0.1)
  if money0==a and money1==b:
    ans = i
print(ans)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
ans = int(input())
for i in range(1001,-1,-1):
  money0 = int(i*0.08)
  money1= int(i*0.1)
  if money0==a and money1==b:
    ans = i
print(ans)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
ans =-1
for i in range(10000,-1,-1):
  money0 = int(i*0.08)
  money1= int(i*0.1)
  if money0==a and money1==b:
    
print(ans)
Problem p02602 (python)

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))

result = []
for i in range(K, N):
    if A[i] > A[i - K]:
        result.append('Yes')
    else:
        result.append('No')
print(*result, sep='\n')

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
A = list(map(int,input().split()))

b = 1
for i in A[0:K]:
    b *= i
for i in range(N-K):
    print(A[i+1])
    a = b/A[i+1]*A[i+3]
    print(a)
    if b < a :
        print("Yes")
    else:
        print("No")
    b = a
Problem p02553 (python)

Fixed submission:
a,b,c,d=map(int,input().split())
lists = []
lists.append(a*c)
lists.append(a*d)
lists.append(b*c)
lists.append(b*d)
print(max(lists))

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
x=list(range(a,b+1))
y=list(range(c,d+1))
for i in range(b-a+1):
    for j in range(d-c+1):
        e=[x[i]*y[j]]
print(max(e))
Problem p02639 (python)

Fixed submission:
lst = [int(i) for i in input().split()]
for i in range(len(lst)):
    if lst[i] == 0:
        ans = i+1
print(ans)

Buggy submission (verdict: Runtime Error):
lst = [int(i) for i in input().split()]
for i in range(lst):
    if lst[i] == 0:
        ans = i+1
print(ans)

Buggy submission (verdict: Runtime Error):
lst = [int(i) for i in input().split()]
for i in range(lst):
  if lst[i] == 0:
    ans = i+1
print(ans)
Problem p02658 (python)

Fixed submission:
n = int(input())
 
List = [int(i) for i in input().split()]
lst = sorted(List, reverse=True)
if lst[-1] == 0:
  print(0)
  exit()
total = 1
for i in lst:
  total = total*i
  if total > 1000000000000000000:
    print(-1)
    exit()
print(total)

Buggy submission (verdict: Runtime Error):
n = int(input())

total = 1
for i in range(n):
  x = int(input())
  total = total*x

if total <= 1000000000000000000:
  print(total)
else:
  print(-1)
Problem p02706 (python)

Fixed submission:
n, m = map(int, input().split())
lst = [ int(i) for i in input().split() ]

if n - sum(lst) >= 0:
  print(n-sum(lst))
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
lst = [ int(i) for i in input().split() ]

if n - lst.sum() >= 0:
  print(n-lst.sum())
else:
  print(-1)
Problem p02765 (python)

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

if n >= 10:
  print(r)
else:
  print(r+100*(10-n))

Buggy submission (verdict: Runtime Error):
n, r = map(int, input().split())
if n >= 10:
  print(r)
else:
  print(100(10-r))
Problem p02678 (python)

Fixed submission:
from queue import Queue
import sys

sys.setrecursionlimit(10 ** 6)

def main():
  n, m = map(int, input().split())

  edges = [[] for _ in range(n)]

  for _ in range(m):
    a, b = map(lambda x: int(x) - 1, input().split())
    edges[a].append(b)
    edges[b].append(a)

  visited = {0: -1}

  q = Queue()
  q.put(0)

  while not q.empty():
    current = q.get()
    for nxt in edges[current]:
      if nxt not in visited:
        visited[nxt] = current
        q.put(nxt)

  if len(visited) == n:
    print("Yes")
    for i in range(1, n):
      print(visited[i] + 1)
  else:
    print("No")


main()

Buggy submission (verdict: Runtime Error):
from queue import Queue
import sys

sys.setrecursionlimit(10 ** 6)

def main():
  n, m = map(int, input().split())

  edges = [[] for _ in range(m)]

  for _ in range(m):
    a, b = map(lambda x: int(x) - 1, input().split())
    edges[a].append(b)
    edges[b].append(a)

  visited = {0: -1}

  q = Queue()
  q.put(0)

  while not q.empty():
    current = q.get()
    for nxt in edges[current]:
      if nxt not in visited:
        visited[nxt] = current
        q.put(nxt)

  if len(visited) == n:
    print("Yes")
    for i in range(1, n):
      print(visited[i] + 1)
  else:
    print("No")


main()

Buggy submission (verdict: Runtime Error):
from queue import Queue

def main():
  n, m = map(int, input().split())

  edges = [[] for _ in range(m)]

  for _ in range(m):
    a, b = map(lambda x: int(x) - 1, input().split())
    edges[a].append(b)
    edges[b].append(a)

  visited = {}

  q = Queue()
  q.put(0)

  while q.qsize() > 0:
    current = q.get()
    for nxt in edges[current]:
      if nxt not in visited:
        visited[nxt] = current
        q.put(nxt)

  if len(visited) == n:
    print("Yes")
    for i in range(1, n):
      print(visited[i] + 1)
  else:
    print("No")


main()

Buggy submission (verdict: Runtime Error):
from queue import Queue

def main():
  n, m = map(int, input().split())

  edges = [[] for _ in range(m)]

  for _ in range(m):
    a, b = map(lambda x: int(x) - 1, input().split())

    edges[a].append(b)
    edges[b].append(a)

  visited = {}

  q = Queue()
  q.put((0, -1))

  while q.qsize() > 0:
    (current, prev) = q.get()
    if current in visited:
      continue

    visited[current] = prev

    for nxt in edges[current]:
      q.put((nxt, current))

  if len(visited) == n:
    print("Yes")
    for i in range(1, n):
      print(visited[i] + 1)
  else:
    print("No")


main()
Problem p02756 (python)

Fixed submission:

s = input()
q = int(input())

is_reverse = False
before = ""
after = ""

for _ in range(q):
  lst = input().split()
  if lst[0] == "1":
    is_reverse = not is_reverse
  else:
    _, f, c = lst
    if f == "1":
      if not is_reverse:
        before = c + before
      else:
        after = after + c
    else:
      if not is_reverse:
        after = after + c
      else:
        before = c + before

if is_reverse:
  s = s[::-1]
  before, after = after[::-1], before[::-1]

print(before + s + after)

Buggy submission (verdict: Runtime Error):

s = input()
q = int(input())

is_reverse = False
before = ""
after = ""

for _ in range(q):
  lst = input().split()
  if lst[0] == "1":
    is_reverse = not is_reverse
  else:
    _, f, c = lst
    if f == "1":
      if not is_reverse:
        before = c + before
      else:
        after = after + c
    else:
      if not is_reverse:
        after = after + c
      else:
        before = c + before

if is_reverse:
  before, after = after.reverse, before.reverse

print(before + s + after)
Problem p02717 (python)

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

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

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
a,b = b,a
a,c = c,a
print(a," ",b,"
Problem p02718 (python)

Fixed submission:
n,m = map(int,input().split())
a = list(map(int, input().split()))
popular = list(filter(lambda e: e>=(1/(4*m))*sum(a),a))
print("Yes" if len(popular) >= m else "No")

Buggy submission (verdict: Runtime Error):
a,b,c = list(map(int,input().split()))
a,b = b,a
a,c = c,a
print(a," ",b," ",c)
Problem p02972 (python)

Fixed submission:

n = int(input())

an = list( map(int,input().split()) )

#mid = n//2 + n%2

#print(* range(10)[::2] )

ans = [0]*(n+1)

for _ in range(n):# 0 ... n-1
    i = n-_ # n ... 1

    ta = sum(ans[i::i])
    ans[i] = 0 if ta%2 == an[i-1] else 1

#    print(i, an[i-1::i])


m = sum(ans)
print(m)

if m > 0:
    print(*[i for i, x in enumerate(ans) if x >0])

Buggy submission (verdict: Runtime Error):

n = int(input())

an = list( map(int,input().split()) )

#mid = n//2 + n%2

ans = [0]*n
for i, a in enumerate(an[::-1]):

#    ta = [x for ii,x in enumerate(an[i:]) if i % (n-(ii+i)) == 0]
#    t = sum(ta)
#    print(ta,t,i,a)
#    ans[-i] = t%2

    ans[-i] = sum([x for ii, x in enumerate(an[i::i]) if i % (n-(ii+i)) == 0])%2

m = sum(ans)
print(m)

if m > 0:
    print(*[x for x in ans if x >0])
Problem p02995 (python)

Fixed submission:

import fractions

a, b, c, d = map(int, input().split())
c, d = min(c,d), max(c, d)

ans = b - a + 1 

if d%c == 0:#4 8 4 2
    ans -= b//c - a//c + (0 if a%c != 0 else 1)

else:
    x = b // c - a//c + (0 if a%c != 0 else 1)
    y = b // d - a//d + (0 if a%d != 0 else 1)

    lcm = c*d // fractions.gcd(c,d)
    t = b //lcm - a//lcm + (1 if a >= lcm and a%lcm ==0 else 0)

    ans = ans -x-y+t
#    print(x,y,t,lcm,ans)

#    ans += t 


print(ans)

Buggy submission (verdict: Runtime Error):

import math

a, b, c, d = map(int, input().split())
c, d = min(c,d), max(c, d)

ans = b - a + 1 

if d%c == 0:#4 8 4 2
    ans -= b//c - a//c + (0 if a%c != 0 else 1)

else:
    x = b // c - a//c + (0 if a%c != 0 else 1)
    y = b // d - a//d + (0 if a%d != 0 else 1)

    lcm = c*d//math.gcd(c,d)
    t = b //lcm - a//lcm + (1 if a >= lcm and a%lcm ==0 else 0)

    ans = ans -x-y+t
#    print(x,y,t,lcm,ans)

#    ans += t 


print(ans)
Problem p03000 (python)

Fixed submission:

n, x = map(int, input().split())

Ln = list( map(int, input().split()) )


curpos = 0
times = 1
while curpos <= x and times < n+1:
    curpos += Ln[times-1]
    if curpos>x:
        break
    
    times += 1


print(times)

Buggy submission (verdict: Runtime Error):

n, x = map(int, input().split())

Ln = list( map(int, input().split()) )


curpos = 0
times = 1
while curpos <= x and times <= n+1:
    curpos += Ln[times-1]
    if curpos>x:
        break
    
    times += 1


print(times)
Problem p03026 (python)

Fixed submission:


# https://atcoder.jp/contests/m-solutions2019/submissions/5738704


from collections import deque, _heapq

n = int(input())

g = [{"num":0,"neighber":[]} for _ in range(n+1) ]

for _ in range(n-1):

    a, b = map(int, input().split())

    g[a]["neighber"].append(b)
    g[b]["neighber"].append(a)


c = sorted( map(int, input().split()) )

# sum(c[:-1]) 
print( sum(c) - c[-1] )


i = 0
s = [(0,1)]

while i < len(s):
    
    pre, cur = s[i]
    i += 1

    g[cur]["num"] = c.pop()

    for e in g[cur]["neighber"]:
        if e == pre:
            continue

        s.append( (cur,e) )

ans = ''
for i in range(1,n+1):
    ans += str( g[i]["num"] ) + " "



print( ans[:-1] )

Buggy submission (verdict: Runtime Error):


# https://atcoder.jp/contests/m-solutions2019/submissions/5738704


from collections import deque, heapq

n = int(input())

g = [{"num":0,"neighber":[]} for _ in range(n+1) ]

for _ in range(n-1):

    a, b = map(int, input().split())

    g[a]["neighber"].append(b)
    g[b]["neighber"].append(a)


c = sorted( map(int, input().split()) )

# sum(c[:-1]) 
print( sum(c) - c[-1] )


i = 0
s = [(0,1)]

while i < len(s):
    
    pre, cur = s[i]
    i += 1

    g[cur]["num"] = c.pop()

    for e in g[cur]["neighber"]:
        if e == pre:
            continue

        s.append((cur,e))

print(" ".join(str(g[i]["num"])) for i in range(1,n+1))
Problem p03212 (python)

Fixed submission:

# post-placed for
# counter for counter in iterator
#  

#Shiti Go San
def sgs(s:str)->bool:
    return True if all( s.count(c)>0 for c in "753") else False





n = int( input() )


def recursive(s:str)->int:
    if n < int(s):
        return 0

    ret = 1 if sgs(s) else 0

    for x in "753":
       ret += recursive( s + x )
    
    return ret

print( recursive('0') )

Buggy submission (verdict: Runtime Error):

n, x = map(int,input().split())

def rec(lv,ls):
    if lv == 0:
        return [1]
    else:
        ret = rec(lv-1,ls)
        for i in range(0,len(ret) -1):
            if ret[i]>0 and ret[i+1]>0:
                ret[i+1] += ret[i]
                ret[i] = 0  #deleted tag

        while 0 != ret.count(0):
            ret.remove(0)
        return [-1,*ret,1,*ret,-1]

#print( rec(n, list()) )


count = 0
for e in rec(n, list() ):
    abs_e = abs(e)

    if x == 0:
        break

    if x>=abs_e:
        x -= abs_e
        count += e if e>0 else 0
    else:
        count += x if e>0 else 0
        x = 0
    #print(x," ",count)

print(count)
Problem p03418 (python)

Fixed submission:

n, k = map(int, input().split())


ans = 0

# N = pb + r

for b in range(k+1,n+1):
    p = n//b
    r = n%b
    ans += p * max(0,b-k) + max(0, r-k+1)


if k==0:
    ans -= n

print(ans)

Buggy submission (verdict: Runtime Error):

n, k = map(int, input().split())


ans = 0

# N = pb + r

for b in range(k+1,n+1):
    p = n//b
    r = n%b
    ans += p * max(0,b-k) + max(0, r-k+1)


if k==0:
    ans -= n

print(
Problem p03471 (python)

Fixed submission:


n,y = map(int, input().split())

y //= 1000
a,b,c = -1,-1,-1

for ai in range(n+1):

    if ai*10> y:
        break

    if ai  == y:
        a,b,c = ai,0,0
        break

    remain = n-ai
    for bi in range(remain+1):
        ci = remain - bi
        
        if y == ai *10  + bi * 5 + ci :
            a,b,c = ai,bi,ci


print('{} {} {}'.format(a,b,c))

Buggy submission (verdict: Runtime Error):
 
n,y = map(int, input().split())
 
 
a,b,c = -1,-1,-1
 
for ai in range(n+1):
 
    if ai*1000>y:
        break
 
#    if ai * 1000 == y:
#        a,b,c = ai,0,0
#        break
 
    remain = n-ai
    for bi in range(remain+1):
        ci = remain - bi
        
        if y == ai * 1000 + bi * 5000 + ci * 10000:
            a,b,c = ai,bi,ci
 
print('{} {} {}'.format(c,b,a))
 

n,y = map(int, input().split())


a,b,c = -1,-1,-1

for ai in range(n+1):

    if ai*1000>y:
        break

    if ai * 1000 == y:
        a,b,c = ai,0,0
        break

    remain = n-ai
    for bi in range(remain+1):
        ci = remain - bi
        
        if y == ai * 1000 + bi * 5000 + ci * 10000:
            a,b,c = ai,bi,ci

print('{} {} {}'.format(c,b,a))

Buggy submission (verdict: Runtime Error):
 
n,y = map(int, input().split())
 
 
a,b,c = -1,-1,-1
 
for ai in range(n+1):
 
    if ai*1000>y:
        break
 
    if ai * 1000 == y:
        a,b,c = ai,0,0
        break
 
    remain = n-ai
    for bi in range(remain+1):
        ci = remain - bi
        
        if y == ai * 1000 + bi * 5000 + ci * 10000:
            a,b,c = ai,bi,ci
 
print('{} {} {}'.format(c,b,a))
 

n,y = map(int, input().split())


a,b,c = -1,-1,-1

for ai in range(n+1):

    if ai*1000>y:
        break

#    if ai * 1000 == y:
#        a,b,c = ai,0,0
#        break

    remain = n-ai
    for bi in range(remain+1):
        ci = remain - bi
        
        if y == ai * 1000 + bi * 5000 + ci * 10000:
            a,b,c = ai,bi,ci

print('{} {} {}'.format(c,b,a))

提出情報
Problem p03475 (python)

Fixed submission:

n = int(input())


csf =  [tuple(map(int,input().split())) for _ in range(n-1)]

# print(csf)

for i in range(n-1):

    ans = csf[i][0] + csf[i][1]

    for j in range(i+1,n-1):
        here = csf[j]
        
        ans = max(ans,here[1])
        
        rm = ans % here[2]
        if rm != 0:
            ans += here[2] - rm
            
        ans += here[0]

#        print(ans)
    print(ans)

print(0)

Buggy submission (verdict: Runtime Error):

import math
import bisect


prime = [2,3,5,7,11,13,17,19]
for i in range(prime[-1]+2,100,2):

    x = int( math.sqrt(i) )
    x += 1 if x%2 == 0 else 0

    found = False
    for p in prime:
        if p>x:
            break;

        if i % p == 0:
            found = True
                
    if not found:
        prime.append(i)

#print(prime)


q = int(input())
for _ in range(q):
    l, r = map(int,input().split())
    l += 1 if l%2 == 0 else 0

#    print((l,r))

    ans = 0
    for i in range( l , r+1, 2):

        #si = bisect.bisect_left(prime,i)
        xi = bisect.bisect_right(prime, i)
        yi = bisect.bisect_right(prime, (i+1)//2)
        ans += 1 if prime[xi-1] == i and prime[yi-1] == (i+1)//2 else 0

    print(ans)
Problem p03476 (python)

Fixed submission:

import math
import bisect


prime = [2]

tab = [False]*100001
tab[2] = True
for i in range(3,100000+1,2):

    x = int( math.sqrt(i) )
    x += 1 if x%2 == 0 else 0

    found = False
    for p in prime:
        if x < p:
            break;

        if i % p == 0:
            found = True
            break
                
    if not found:
        prime.append(i)
        tab[i] = True

#print(prime[0:10])
#print(tab[0:10])
q = int(input())

ac = [0] * len(tab)

for i in range(1,len(ac)):
    ac[i] = ac[i-1] + (1 if tab[i] and tab[(i+1)//2] else 0)

#print(ac)
for _ in range(q):

    l, r = map(int,input().split())
    
    ans = ac[r] - ac[l-1]

    print(ans)

Buggy submission (verdict: Runtime Error):

import math
import bisect


prime = [2,3,5,7,11,13,17,19]
for i in range(prime[-1]+2,100000,2):

    x = int( math.sqrt(i) )
    x += 1 if x%2 == 0 else 0

    found = False
    for p in prime:
        if x < p:
            break;

        if i % p == 0:
            found = True
            break
                
    if not found:
        prime.append(i)


#print(prime)
#import matplotlib.pyplot as plt
#size = 10000
#plt.scatter(range(0,size),prime[0:size])
#plt.plot(prime)
#plt.show()

for i in range(len(prime)):
#    if 2.5*i - 1< prime[i]:
#       continue

    if prime[i] <11 *i + 3:
        continue

    print(prime[i])



q = int(input())

def low(x:int)->int:
    x = (x -3)// 11
    return x if x>0 else 0

def hi(x:int)->int:
    return int( (x+1)//2.5) + 1

for _ in range(q):

    l, r = map(int,input().split())
 #   l += 1 if l%2 == 0 else 0

#    print((l,r))

    ans = 0
    for i in range( l , r+1, 2):

        low_1 = low(i)
        hi_1 = hi(i)

        #print((low_1,hi_1))
        xi = bisect.bisect_right(prime, i,lo = low_1,hi = hi_1)
        #print(xi)
        p1 = prime[xi-1]
        if p1 != i:
            continue

        i2 = (i+1)//2
        low_2 = low(i2)
        hi_2 = hi(i2)

        yi = bisect.bisect_right(prime, i2,lo = low_2, hi = min(hi_2,xi) )
        if prime[yi-1] != i2:
            continue

        ans += 1

    print(ans)