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

Fixed submission:
n = int(input())
rs = [list(map(int, input().split())) for _ in range(n)]
lr = [[x-l, x+l] for x, l in rs]
lr.sort(key=lambda x: x[1])

cnt = 0
reach = None
for l, r in lr:
    if reach is not None and l < reach:
        continue
    reach = r
    cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
rs = [list(map(int, input().split())) for _ in range(n)]
rs = np.array(rs)
mn_mx = np.stack([rs[:, 0] - rs[:, 1], rs[:, 0] + rs[:, 1]], axis=1)
mn_mx = mn_mx[np.argsort(mn_mx[:, 1])]

cnt = 0
reach = None
for mn, mx in mn_mx:
    if reach is not None and mn < reach:
        continue
    reach = mx
    cnt += 1
print(cnt)
Problem p02802 (python)

Fixed submission:
n, m = [int(i) for i in input().split()]
ans = [input().split() for _ in range(m)]

is_ac = [0 for i in range(n)]
cnt_wa = [0 for i in range(n)]
for p, s in ans:
  p = int(p) - 1
  if is_ac[p]:
    continue
  if s == 'AC':
    is_ac[p] = 1
  else:
    cnt_wa[p] += 1

cor = sum(is_ac)
pena = 0
for p, c in enumerate(is_ac):
  if c:
    pena += cnt_wa[p]

print(cor, pena)

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

n, m = [int(i) for i in input().split()]
ans = [input().split() for _ in range(m)]
ans = np.array(ans)

ps = ans[:, 0]
ss = ans[:, 1]
sub_ps = np.unique(ps)

cnt_c, cnt_w = 0, 0
for sp in sub_ps:
  indices = np.where(ps==sp)[0]
  s_sp = ss[indices]
  if np.all(s_sp == 'WA'):
    continue
  num_ws = np.where(s_sp == 'AC')[0][0]
  cnt_w += num_ws
  cnt_c += 1

print(cnt_c, cnt_w)

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

n, m = [int(i) for i in input().split()]
ans = [input().split() for _ in range(m)]
ans = np.array(ans)

ps = ans[:, 0]
ss = ans[:, 1]
sub_ps = np.unique(ps)

cnt_c, cnt_w = 0, 0
for sp in sub_ps:
  indices = np.where(ps==sp)[0]
  s_sp = ss[indices]
  if np.all(s_sp == 'WA'):
    continue
  num_ws = np.where(s_sp == 'AC')[0][0]
  cnt_w += num_ws
  cnt_c += 1

print(cnt_c, cnt_w)
Problem p02830 (python)

Fixed submission:
n = int(input())
S, T = [str(a) for a in input().split()]

ans = ''
for s, t in zip(S, T):
    ans += s
    ans += t

print(ans)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())

ans = [1, 2, 3]
ans.remove(a)
ans.remove(b)

print(ans[0])
Problem p02921 (python)

Fixed submission:
S = input()
T = input()

count = 0
for i in range(3):
    if S[i] == T[i]:
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
print(int((N * (N-1)) / 2))

Buggy submission (verdict: Runtime Error):
N = int(input())
print(int(N * (N-1) // 2))
Problem p02969 (python)

Fixed submission:
r = int(input())
print(3*r**2)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = [int(i) for i in input().split()]
A.insert(0, 0)

balls = list()
sums = dict()
# for i, a in enumerate(reversed(A)):
for bn in range(n, 0, -1):
    a = A[bn]
    if 2*bn > n:
        sums[bn] = a
        if a == 1:
            balls.append(str(bn))
    else:
        a2_sum = sums[2*bn]
        if a2_sum % 2 == a:
            # not
            sums[bn] = a2_sum
        else:
            # in
            sums[bn] = a2_sum + 1
            balls.append(str(bn))

all_balls = len(balls)
if all_balls % 2 != A[1]:
    print(-1)
else:
    print(all_balls)
    print(' '.join(balls))
Problem p02972 (python)

Fixed submission:
n = int(input())
A = [int(i) for i in input().split()]
A.insert(0, 0)

boxes = dict()
have_balls = list()
for bn in range(n, 0, -1):
    a = A[bn]
    s = 0
    for t in range(2, n+1):
        if bn * t > n:
            break
        s += boxes[bn*t]

    if s % 2 == a:
        boxes[bn] = 0
    else:
        boxes[bn] = 1
        have_balls.append(str(bn))

print(len(have_balls))
print(' '.join(have_balls))

Buggy submission (verdict: Runtime Error):
n = int(input())
A = [int(i) for i in input().split()]
A.insert(0, 0)

balls = list()
sums = dict()
# for i, a in enumerate(reversed(A)):
for bn in range(n, 0, -1):
    a = A[bn]
    if 2*bn > n:
        sums[bn] = a
        if a == 1:
            balls.append(str(bn))
    else:
        a2_sum = sums[2*bn]
        if a2_sum % 2 == a:
            # not
            sums[bn] = a2_sum
        else:
            # in
            sums[bn] = a2_sum + 1
            balls.append(str(bn))

# all_balls = len(balls)
# if all_balls % 2 != A[0]:
#     print(-1)
# else:
#     print(all_balls)
#     print(' '.join(balls))
print(all_balls)
print(' '.join(balls))
Problem p02995 (python)

Fixed submission:
a, b, c, d = [int(i) for i in input().split()]


def get_num(i):
    return b // i - (a-1) // i


def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


all_num = b - a + 1
c_num = get_num(c)
d_num = get_num(d)
lcm = lcm(c, d)
lcm_num = get_num(lcm)

print(all_num - c_num - d_num + lcm_num)

Buggy submission (verdict: Runtime Error):
import math


def get_num(i):
    return int(b / i) - int((a-1) / i)


a, b, c, d = [int(i) for i in input().split()]

all_num = b - a + 1
c_num = get_num(c)
d_num = get_num(d)
lcm = int(c * d / math.gcd(c, d))
lcm_num = get_num(lcm) 

print(all_num - c_num - d_num + lcm_num)
Problem p02681 (python)

Fixed submission:
S = input()
T = input()
if len(S)+1 ==len(T) and S ==T[:-1]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import itertools
import numpy as np
N,M,X=map(int, input().split())
book = []
for _ in range(N):
    book.append(list(map(int, input().split())))
book = np.array(book)
money=pow(10,7)
for i in itertools.product([0,1], repeat=N):
    book2=book
    dellist = []
    for n,l in enumerate(i):
        if l==0:
            dellist.append(n)
    book2=np.delete(book2, dellist, 0)
    ansar = np.sum(book2,axis=0)
    if np.sum(ansar[1:]>=X)==M:
        if money>ansar[0]:
            money = ansar[0]
if money == pow(10,6):
    print(-1)
else:
    print(money)
Problem p02683 (python)

Fixed submission:
import itertools
import numpy as np
N,M,X=map(int, input().split())
book = []
for _ in range(N):
    book.append(list(map(int, input().split())))
book = np.array(book)
money=pow(10,7)
for i in itertools.product([0,1], repeat=N):
    book2=book
    dellist = []
    for n,l in enumerate(i):
        if l==0:
            dellist.append(n)
    book2=np.delete(book2, dellist, 0)
    ansar = np.sum(book2,axis=0)
    if np.sum(ansar[1:]>=X)==M:
        if money>ansar[0]:
            money = ansar[0]
if money == pow(10,7):
    print(-1)
else:
    print(money)

Buggy submission (verdict: Runtime Error):
import itertools
import numpy as np
N,M,X=map(int, input().split())
book = []
for _ in range(N):
    book.append(list(map(int, input().split())))
book = np.array(book)
money=pow(10,6)
for i in itertools.product([0,1], repeat=N):
    book2=book
    dellist = []
    for n,l in enumerate(i):
        if l==0:
            dellist.append(n)
    book2=np.delete(book2, dellist, 0)
    ansar = np.sum(book2,axis=0)
    if np.sum(ansar[1:]>=X)==M:
        if money>ansar[0]:
            money = ansar[0]
if money == pow(10,6):
    print(-1)
else:
    print(money)

Buggy submission (verdict: Runtime Error):
import itertools
import numpy as np
N,M,X=map(int, input().split())
book = []
for _ in range(N):
    book.append(list(map(int, input().split())))
book = np.array(book)
money=pow(10,6)
for i in itertools.product([0,1], repeat=N):
    book2=book
    dellist = []
    for n,l in enumerate(i):
        if l==0:
            dellist.append(n)
    book2=np.delete(book2, dellist, 0)
    ansar = np.sum(book2,axis=0)
    if np.sum(ansar[1:]>=X)==M:
        if money>ansar[0]:
            money = ansar[0]
if money == pow(10,6):
    print(-1)
else:
    print(money)
Problem p02702 (python)

Fixed submission:
S = input()
from collections import defaultdict
d = defaultdict(int)
before = 0
for i in range(1,len(S)+1):
    now = (int(S[-i])*pow(10,i,2019)+before) % 2019
    d[now] += 1
    before = now
d[0] += 1
ans = 0
for i in d.values():
    ans += i*(i-1)//2
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
Scount = 0
for i in range(len(S)-1):
    for j in range(1,len(S)):
        if (i+j)<=len(S):
            part_S = S[i:i+j]
            num = int(part_S)
            if num % 673 == 0:
                num = int(num/673)
                if num % 3 ==0:
                    Scount += 1
print(Scount)

Buggy submission (verdict: Runtime Error):
def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)
S = input()
Scount = 0
for i in range(len(S)):
    for j in range(1,len(S)):
        if (i+j)<len(S):
            part_S = S[i:i+j]
            num = int(part_S)
            if num % 673 == 0:
                num = int(num/673)
                sum3 = digitSum(num)
                while sum3 != digitSum(sum3):
                    sum3 = digitSum(sum3)
                if sum3 == 3 or sum3 == 6 or sum3 ==9:
                    Scount += 1
print(Scount)

Buggy submission (verdict: Runtime Error):
def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)
S = input()
Scount = 0
for i in range(len(S)):
    for j in range(1,len(S)):
        if (i+j)<=len(S):
            part_S = S[i:i+j]
            num = int(part_S)
            if num % 673 == 0:
                num = int(num/673)
                sum3 = digitSum(num)
                while sum3 != digitSum(sum3):
                    sum3 = digitSum(sum3)
                if sum3 == 3 or sum3 == 6 or sum3 ==9:
                    Scount += 1
print(Scount)
Problem p02705 (python)

Fixed submission:
R = int(input())
print(R*2*3.141)

Buggy submission (verdict: Runtime Error):
R = input()
print(R*2*3.141)
Problem p02814 (python)

Fixed submission:
from fractions import gcd
from functools import reduce
import sys

N, M = map(int, input().split())
alist = list(map(lambda k: int(k) // 2, input().split()))

numdic = {}

def lcm(x, y):
    return (x * y) // gcd(x,y)

def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

lcmnum = lcm_list(alist)

for i in alist:
    if (lcmnum//i)%2==0:
        print(0)
        sys.exit()

pmax = M // lcmnum
pmax = pmax - 1 if pmax % 2 == 0 else pmax

print((pmax+1)//2)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
from functools import reduce

N, M = map(int, input().split())
alist = list(map(lambda k: int(k) // 2, input().split()))

numdic = {}

def lcm(x, y):
    return (x * y) // gcd(x,y)

def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

lcmnum = lcm_list(alist)

for i in alist:
    if (lcmnum//i)%2==0:
        print(0)
        sys.exit()

pmax = M // lcmnum
pmax = pmax - 1 if pmax % 2 == 0 else pmax

print((pmax+1)//2)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

N, M = map(int, input().split())
alist = list(map(lambda k: int(k) // 2, input().split()))

numdic = {}

def lcm(x, y):
    return (x * y) // math.gcd(x,y)

def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

lcmnum = lcm_list(alist)

pmax = M // lcmnum
pmax = pmax - 1 if pmax % 2 == 0 else pmax

print((pmax+1)//2)
Problem p02609 (python)

Fixed submission:
# D Anything Goes to Zero

n = int(input())
x = input()

original_pop_count = x.count("1")
one_pop_count = original_pop_count - 1
zero_pop_count = original_pop_count + 1

one_mod = 0
zero_mod = 0
for b in x:
  if one_pop_count != 0:
    one_mod = (one_mod * 2 + int(b)) % one_pop_count
  zero_mod = (zero_mod * 2 + int(b)) % zero_pop_count

#fの前計算
f = [0] * 220000
pop_count = [0] * 220000
for i in range(1, 220000):
  pop_count[i] = pop_count[i//2] + i % 2
  f[i] = f[i % pop_count[i]] + 1

#pow2の前計算
one_pow2 = [1] * 220000
zero_pow2 = [1] * 220000
for i in range(1, 220000):
  if one_pop_count != 0:
    one_pow2[i] = one_pow2[i-1] * 2 % one_pop_count
  zero_pow2[i] = zero_pow2[i-1] * 2 % zero_pop_count

for i in range(n-1, -1, -1):
  if x[n-1-i] == "1":
    if one_pop_count != 0:
      nxt = one_mod
      nxt -= one_pow2[i]
      nxt %= one_pop_count
      print(f[nxt] + 1)
    else:
      print(0)
  if x[n-1-i] == "0":
    nxt = zero_mod
    nxt += zero_pow2[i]
    nxt %= zero_pop_count
    print(f[nxt] + 1)

Buggy submission (verdict: Runtime Error):
# D Anything Goes to Zero

n = int(input())
x = input()

ori_cnt = x.count("1")
for i in range(n):
  xi = int(x, 2)
  if x[i] == "1":
    new_cnt = ori_cnt - 1
  elif x[i] == "0":
    new_cnt = ori_cnt + 1
  xi = xi ^ (1 << n-i-1)
  if xi != 0:
    xi = xi % new_cnt
    ans = 1
  else:
    print(0)

  while xi != 0:
    xi = xi % bin(xi).count("1")
    ans += 1
  print(ans)
Problem p02628 (python)

Fixed submission:
inp1 = input()
inp2 = input()

lists1 = inp1.split()
lists2 = inp2.split()

N = int(lists1[0])
K = int(lists1[1])
values = sorted([int(i) for i in lists2])

result = sum(values[:K])

print(result)

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

p.sort()

ans = p[:k].sum()
  
print(ans)
Problem p02675 (python)

Fixed submission:
# A Therefore

n = input()

if n[-1] in ["2", "4", "5", "7", "9"]:
  print("hon")
elif n[-1] in ["0", "1", "6", "8"]:
  print("pon")
else:
  print("bon")

Buggy submission (verdict: Runtime Error):
# A Therefore

n = input()

if n[2] in ["2", "4", "5", "7", "9"]:
  print("hon")
elif n[2] in ["0", "1", "6", "8"]:
  print("pon")
else:
  print("bon")
Problem p02576 (python)

Fixed submission:
import math
N,X,T=map(int,input().split())
n=math.ceil(N/X)
print(n*T)

Buggy submission (verdict: Runtime Error):
H,W,M=map(int,input().split())
row_boms=[0 for i in range(H)]
col_boms=[0 for i in range(W)]

boms=[[0 for j in range(W)] for i in range(H)]
for i in range(M):
  h,w=map(int,input().split())
  boms[h-1][w-1]=1
  row_boms[h-1]+=1
  col_boms[w-1]+=1

row_max=max(row_boms)
col_max=max(col_boms)

rowmax_h=[]
colmax_w=[]
for i in range(H):
  if row_boms[i]==row_max:
    rowmax_h+=[i]
for i in range(W):
  if col_boms[i]==col_max:
    colmax_w+=[i]
rows=len(rowmax_h)
cols=len(colmax_w)
tf=0
for i in rowmax_h:
  for j in colmax_w:
    if boms[i][j]==0:
      tf=1
      break

if tf==1:
  print(row_max+col_max)
else:
  print(row_max+col_max-1)

Buggy submission (verdict: Runtime Error):
H,W,M=map(int,input().split())
row_boms=[0 for i in range(H)]
col_boms=[0 for i in range(W)]

boms=[[0 for j in range(W)] for i in range(H)]
for i in range(M):
  h,w=map(int,input().split())
  boms[h-1][w-1]=1
  row_boms[h-1]+=1
  col_boms[w-1]+=1

row_max=max(row_boms)
col_max=max(col_boms)

rowmax_h=[]
colmax_w=[]
for i in range(H):
  if row_boms[i]==row_max:
    rowmax_h+=[i]
for i in range(W):
  if col_boms[i]==col_max:
    colmax_w+=[i]
rows=len(rowmax_h)
cols=len(colmax_w)
tf=0
for i in rowmax_h:
  for j in colmax_w:
    if boms[i][j]==0:
      tf=1
      break

if tf==1:
  print(row_max+col_max)
else:
  print(row_max+col_max-1)
Problem p02584 (python)

Fixed submission:
X,K,D=map(int,input().split())
if D*K<abs(X):
  print(abs(X)-D*K)
else:
  K2=abs(X)//D
  if K2>K:
    K2=K
  if (K-K2)%2==0:
    print(abs(X)-K2*D)
  else:
    ans=min(abs(X)-(K2-1)*D, (K2+1)*D-abs(X))
    print(ans)

Buggy submission (verdict: Runtime Error):
X,K,D=map(int,input().split())
if D*K<:abs(X):
  print(abs(X)-D*K)
else:
  K2=abs(X)//D
  if (K-K2)%2==0:
    print(abs(X)-K2*D)
  else:
    K2=K2-1
    print(abs(X)-K2*D)
Problem p02585 (python)

Fixed submission:
n,k=map(int,input().split())
p=list(map(int,input().split()))
c=list(map(int,input().split()))
for i in range(n):
    p[i]-=1
ans=max(c)
for i in range(n):
    f=i
    r=0
    l=[]
    while True:
        f=p[f]
        l.append(c[f])
        r+=c[f]
        if f==i:
            break
    t=0
    for j in range(len(l)):
        t+=l[j]
        ret=t
        if r>0:
            e=(k-j-1)//len(l)
            ret+=r*e
        ans=max(ans,ret)
print(ans)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
P=list(map(int,input().split()))
C=list(map(int,input().split()))
points=[[] for i in range(N)]
for i in range(N):
  tmpl=[0]
  loc=i
  for j in range(1,N+1):
    tmpl+=[tmpl[j-1]+C[loc]]
    loc=P[loc]-1
  points[i]=tmpl
repeat=K//N
left=K%N
maxlist=[]
for i in range(N):
  if points[i][N]<0:
    maxlist+=[max(points[i][1:left+1])]
  else:
    tmp=repeat*points[i][N]+max(points[i][1:left+1])
    maxlist+=[tmp]
print(max(maxlist))

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
P=list(map(int,input().split()))
C=list(map(int,input().split()))
points=[[] for i in range(N)]
for i in range(N):
  tmpl=[0]
  loc=i
  for j in range(1,N+1):
    tmpl+=[tmpl[j-1]+C[loc]]
    loc=P[loc]-1
  points[i]=tmpl
repeat=K//N
left=K%N
maxlist=[]
for i in range(N):
  if points[i][N]<0:
    maxlist+=[max(points[i][1:left+1])]
  else:
    tmp=repeat*points[i][N]+max(points[i][1:left+1])
    maxlist+=[tmp]
print(max(maxlist))

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
P=list(map(int,input().split()))
C=list(map(int,input().split()))
points=[[] for i in range(N)]
for i in range(N):
  tmpl=[0]
  loc=i
  for j in range(1,N+1):
    tmpl+=[tmpl[j-1]+C[i]]
    loc=P[i]
  points[i]=tmpl
repeat=K//N
left=K%N
ans=-float('inf')
maxlist=[]
for i in range(N):
  if points[i][N]<0:
    maxlist+=[max(points[i][1:left+1])]
  else:
    tmp=repeat*points[i][N]+max(points[i][1:left+1])
    maxlist+=[tmp]
print(max(maxlist))

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
P=list(map(int,input().split()))
C=list(map(int,input().split()))
points=[[] for i in range(N)]
for i in range(N):
  tmpl=[0]
  loc=i
  for j in range(1,N+1):
    tmpl+=[tmpl[j-1]+C[i]]
    loc=P[i]
  points[i]=tmpl
repeat=K//N
left=K%N
ans=-float('inf')
maxlist=[]
for i in range(N):
  if points[i][N]<0:
    maxlist+=[max(points[i][1:left+1])]
  else:
    tmp=repeat*points[i][N]+max(points[i][1:left+1])
    maxlist+=[tmp]
print(max(maxlist))
Problem p02683 (python)

Fixed submission:
N,M,X=map(int,input().split())
C=[]
A=[[] for  _  in range(N)]
for i in range(N):
  tmpA=list(map(int,input().split()))
  C+=[tmpA[0]]
  A[i]=tmpA[1:]

costmin=float('inf')
for k in range(2**N):
  tansaku=k
  koubai=[0 for i in range(N)]
  rikaido=[0 for i in range(M)]
  cost=0
  for i in range(N-1):
    koubai[i]=tansaku//(2**(N-i-1))
    tansaku=tansaku%(2**(N-i-1))
  koubai[-1]=tansaku
  for i in range(N):
    if koubai[i]==1:
      cost+=C[i]
      for j in range(M):
        rikaido[j]+=A[i][j]
  for i in range(M):
    if rikaido[i]<X:
      break
  else:
    costmin=min(costmin,cost)
if costmin!=float('inf'):
  print(costmin)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
N,M,X=map(int,input().split())
C=[]
A=[[] for  _  in range(N)]
for i in range(N):
  tmpA=list(map(int,input().split()))
  C+=[tmpA[0]]
  A[i]=tmpA[1:]

costmin=float('inf')
for k in range(2**N):
  tansaku=k
  koubai=[0 for i in range(N)]
  rikaido=[0 for i in range(N)]
  cost=0
  for i in range(N-1):
    koubai[i]=tansaku//(2**(N-i-1))
    tansaku=tansaku%(2**(N-i-1))
  koubai[-1]=tansaku
  for i in range(N):
    if koubai[i]==1:
      cost+=C[i]
      for j in range(M):
        rikaido[j]+=A[i][j]
  for i in range(M):
    if rikaido[i]<X:
      break
  else:
    costmin=min(costmin,cost)
if costmin!=float('inf'):
  print(costmin)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
N,M,X=map(int,input().split())
C=[]
A=[[] for  _  in range(N)]
for i in range(N):
  tmpA=list(map(int,input().split()))
  C+=[tmpA[0]]
  A[i]=tmpA[1:]
tf=1
for i in range(M):
  s=0
  for j in range(N):
    s+=A[j][i]
  if s<X:
    tf=0
    break
if tf==0:
  print(-1)
else:
  costmin=float('inf')
  for k in range(2**N):
    tansaku=k
    koubai=[0 for i in range(N)]
    rikaido=[0 for i in range(N)]
    cost=0
    for i in range(N-1):
      koubai[i]=tansaku//(2**(N-i-1))
      tansaku=tansaku%(2**(N-i-1))
    koubai[-1]=tansaku
    for i in range(N):
      if koubai[i]==1:
        cost+=C[i]
        for j in range(M):
          rikaido[j]+=A[i][j]
    for i in range(M):
      if rikaido[i]<X:
        break
    else:
      costmin=min(costmin,cost)
Problem p02687 (python)

Fixed submission:
S=input()
if S=="ARC":
  print("ABC")
else:
  print("ARC")

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
H=list(map(int,input().split()))
tunagari=[[] for i in range(N)]
for i in range(M):
  A,B=map(int,input().split())
  tunagari[A-1]+=[B-1]
  tunagari[B-1]+=[A-1]

nums=[0 for i in range(N)]
t=0
for i in range(N):
  tmpl=tunagari[i]
  mini=min(tmpl)
  if mini<i:
    nums[i]=nums[mini]
    continue
  nums[i]=t
  t+=1
maxn=max(nums)
groups=[[] for i in range(maxn+1)]
print(maxn+1)
for i in range(N):
  groups[nums[i]]+=[i]
ans=0

for i in range(maxn):
  tmpl=groups[i]
  tmpl2=[]
  for i in tmpl:
    tmpl2+=[H[i]]
  n=len(tmpl)
  if n==1:
    ans+=1
  else:
    tmpl2.sort()
    if tmpl2[-1]!=tmpl2[-2]:
      ans+=1
Problem p02690 (python)

Fixed submission:
X=int(input())
for i in range(-150,150):
  for j in range(-150,150):
    if i**5-j**5==X:
      A=i
      B=j
print(*[A,B])

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
H=list(map(int,input().split()))
tunagari=[[] for i in range(N)]
for i in range(M):
  A,B=map(int,input().split())
  tunagari[A-1]+=[B-1]
  tunagari[B-1]+=[A-1]

nums=[0 for i in range(N)]
t=0
for i in range(N):
  tmpl=tunagari[i]
  mini=min(tmpl)
  if mini<i:
    nums[i]=nums[mini]
    continue
  nums[i]=t
  t+=1
maxn=max(nums)
groups=[[] for i in range(maxn+1)]
print(maxn+1)
for i in range(N):
  groups[nums[i]]+=[i]
ans=0

for i in range(maxn):
  tmpl=groups[i]
  tmpl2=[]
  for i in tmpl:
    tmpl2+=[H[i]]
  n=len(tmpl)
  if n==1:
    ans+=1
  else:
    tmpl2.sort()
    if tmpl2[-1]!=tmpl2[-2]:
      ans+=1
Problem p02702 (python)

Fixed submission:
S=input()
N=len(S)
Slis=[]
for i in range(N):
  Slis+=[int(S[i])]
T=[0 for i in range(N+1)]#T[i]はi桁より右側の数字


ten=1

for i in range(N):
  T[N-i-1]=(T[N-i]+ten*Slis[N-i-1])%2019
  ten=(ten*10)%2019

MOD=[0 for i in range(2019)]
for i in range(N+1):
  tmp=T[i]%2019
  MOD[tmp]+=1


  
ans=0

for i in range(2019):
  tmp=MOD[i]
  ans+=tmp*(tmp-1)//2
print(ans)

Buggy submission (verdict: Runtime Error):
S=input()
N=len(S)
Slis=[]
for i in range(N):
  Slis+=[int(S[i])]
T=[int(S[i:]) for i in range(N)]
MOD=[0 for i i range(2019)]
for i in range(N):
  tmp=T[i]%2019
  MOD[tmp]+=1
ans=0
for i in range(2019):
  tmp=T[i]
  ans+=tmp*(tmp-1)//2
print(ans)

Buggy submission (verdict: Runtime Error):
S=str(input())
if len(S)<4:
  print(0)
else:
  t=0
  for i in range(N-3):
    for j in range(i+3,N):
      if int(S[i:j])%2019==0:
        t+=1
  print(t)
Problem p02721 (python)

Fixed submission:
N,K,C=map(int,input().split())
S=input()
L=[0 for i in range(K)]
R=[0 for i in range(K)]
n=0
rc=0
lc=0
while True:
  if lc==K:
    break
  if S[n]=="o":
    L[lc]=n+1
    n+=C+1
    lc+=1
  else:
    n+=1
n=N-1
while True:
  if rc==K:
    break
  if S[n]=="o":
    R[K-1-rc]=n+1
    n-=C+1
    rc+=1
  else:
    n-=1
for i in range(K):
  if R[i]==L[i]:
    print(R[i])

Buggy submission (verdict: Runtime Error):
N,K,C=map(int,input().split())
S=input()
L=[0 for i in range(K)]
R=[0 for i in range(K)]
n=0
rc=0
lc=0
while True:
  if lc==K:
    break
  if S[n]=="o":
    L[lc]=n+1
    n+=C+1
    lc+=1
  else:
    n+=1
n=N-1
while True:
  if rc==K:
    break
  if S[n]=="o":
    R[N-1-rc]=n+1
    n-=C+1
    rc+=1
  else:
    n-=1
for i in range(K):
  if R[i]==L[i]:
    print(R[i])