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

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]
h,w,k=map(int,input().split())
s = []
for i in range(h):
    str=input()
    tmp=[]
    for j in range(w):
        if str[j]=="0":
            tmp.append(0)
        else:
            tmp.append(1)
    s.append(tmp)

tdiv=2**(h-1)
#import numpy as np
#s = np.array(s)
ans = 100100100
for i in range(tdiv):
    lis=[]
    #tmp=np.zeros(w)
    #tmp+=s[0,:]
    tmp=[s[0][ii] for ii in range(w)]
    cnt = 0
    #print(tmp)
    for j in range(h-1):
        if (i>>j&1):
            #tmp+=s[j+1,:]
            tmp=[tmp[ii]+s[j+1][ii] for ii in range(w)]
        else:
            lis.append(tmp)
            #tmp=np.zeros(w)
            #tmp+=s[j+1,:]
            tmp=[s[j+1][ii] for ii in range(w)]
            cnt+=1
    lis.append(tmp)
    #lis = np.array(lis)
    #clis=np.zeros(cnt+1)
    clis=[0 for ii in range(cnt+1)]
    #print(lis,cnt)
    tmpcnt=cnt
    for ind in range(w):
        #if any(d>k for d in lis[:,ind]):
        #if lis[:,ind].max()>k:
        if max([lis[ii][ind] for ii in range(tmpcnt+1)])>k:
            cnt=10010010
            break
        clis=[lis[ii][ind]+clis[ii] for ii in range(tmpcnt+1)]
        #if clis.max()>k:
        if max(clis)>k:
            clis=[lis[ii][ind] for ii in range(tmpcnt+1)]
            cnt+=1
    #print(cnt)
    ans = min(ans,cnt)
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
def input():
    return sys.stdin.readline()[:-1]
h,w,k=map(int,input().split())
s = []
for i in range(h):
    str=input()
    tmp=[]
    for j in range(w):
        if str[j]=="0":
            tmp.append(0)
        else:
            tmp.append(1)
    s.append(tmp)


tdiv=2**(h-1)
import numpy as np
s = np.array(s)
ans = 100100100
for i in range(tdiv):
    lis=[]
    tmp=np.copy(s[0,:])
    cnt = 0
    #print(s)
    for j in range(h-1):
        if (i>>j&1):
            tmp+=s[j+1,:]
        else:
            lis.append(tmp)
            tmp=np.copy(s[j+1,:])
            cnt+=1
    lis.append(tmp)
    lis = np.array(lis)
    clis=np.zeros(cnt+1)
    #print(lis,cnt)
    for ind in range(w):
        if lis[:,ind].max()>k:
            cnt=10010010
            break
        clis+=lis[:,ind]
        if clis.max()>k:
            clis=lis[:,ind]
            cnt+=1
    #print(cnt)
    ans = min(ans,cnt)
print(ans)
Problem p02850 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)
N=int(input())
g = [[] for i in range(N)]
for i in range(N-1):
    a,b = map(int,input().split())
    g[a-1].append([b-1,i])
    g[b-1].append([a-1,i])

ans=[0 for i in range(N-1)]

def dfs(i,j,col):
    k=1
    for nec in g[i]:
        if nec[0]==j:continue
        if k==col:k+=1
        ans[nec[1]]=k
        dfs(nec[0],i,k)
        k+=1

dfs(0,-1,-1)
print(max(ans))
for i in range(N-1):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(20000)
N=int(input())
g = [[] for i in range(N)]
for i in range(N-1):
    a,b = map(int,input().split())
    g[a-1].append([b-1,i])
    g[b-1].append([a-1,i])

ans=[0 for i in range(N-1)]

def dfs(i,j,col):
    k=1
    for nec in g[i]:
        if nec[0]==j:continue
        if k==col:k+=1
        ans[nec[1]]=k
        dfs(nec[0],i,k)
        k+=1

dfs(0,-1,-1)
print(max(ans))
for i in range(N-1):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
N=int(input())
g = [[] for i in range(N)]
for i in range(N-1):
    a,b = map(int,input().split())
    g[a-1].append([b-1,i])
    g[b-1].append([a-1,i])

ans=[0 for i in range(N-1)]

def dfs(i,j,col):
    k=1
    for nec in g[i]:
        if nec[0]==j:continue
        if k==col:k+=1
        ans[nec[1]]=k
        dfs(nec[0],i,k)
        k+=1

dfs(0,-1,-1)
print(max(ans))
for i in range(N-1):
    print(ans[i])
Problem p02936 (python)

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]
sys.setrecursionlimit(1000000)
n,q=map(int,input().split())
g=[[]for i in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

lis = [0 for i in range(n)]
for i in range(q):
    p,x=map(int,input().split())
    lis[p-1]+=x

def dfs(i,j):
    nex=g[i]
    for d in nex:
        if d==j: continue
        #print(d)
        lis[d]+=lis[i]
        dfs(d,i)

dfs(0,-1)
print(*lis)

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
g=[[]for i in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

lis = [0 for i in range(n)]
for i in range(q):
    p,x=map(int,input().split())
    lis[p-1]+=x

def dfs(i,j,k):
    nex=g[i]
    lis[i]=k
    for d in nex:
        if d==j: continue
        nk=k+lis[d]
        dfs(d,i,nk)

dfs(0,-1,lis[0])
print(*lis)
Problem p02639 (python)

Fixed submission:
lst = list(map(int, input().split()))
print(lst.index(0) + 1)

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

# 解説の通りに実装
num_max = nums[-1]
exist_counts = [0] * (num_max + 1)
for num in nums:
  # すでにcountされてる場合、重複であることだけ残して抜ける
  if exist_counts[num]:
    exist_counts[num] = 2
    continue
  # はじめてのcountであれば、自分自身とその倍数にチェックをつける
  idx = num
  while idx < num_max:
    exist_counts[idx] += 1
    idx += num

# 各numについて、count=1ならば条件を満たしたということ
count = 0
for num in nums:
  if exist_counts[num] == 1:
    count += 1
print(count)
Problem p02614 (python)

Fixed submission:
import sys
input = sys.stdin.readline

if __name__ == '__main__':
  h,w,k=map(int,input().strip("\n").split())
  s=[]
  for i in range(h):
    s.append(list(input().strip("\n")))
  ans=0
  #print(s)
  # 2 -> 100 rangeだから11まで
  for iS in range(1<<h):
    # 3->1000=2^3=8
    for js in range(1<<w):
      #print(iS,js)
      cnt=0
      for i in range(h):
        for j in range(w):
          # 赤で塗る場合
          # ex)iS=01,i=0->i+1桁目が1か
          if iS>>i&1: continue
          if js>>j&1: continue
          if s[i][j]=='#': cnt+=1
      if cnt==k: ans+=1

  print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import copy
import numpy as np
sys.setrecursionlimit(2147483647)
input = sys.stdin.readline

if __name__ == '__main__':
#  cnt=0
  def dfs(C,t,hw,i):
    global k
    global h
    global w
    #print(t,k)
    #print(C)
    if t==k:
      return 1
    elif t<k:
      return 0
    if hw=='w' and i==w:
      return 0
    C1=copy.copy(C)
    C2=copy.copy(C)
    if hw=='h':
      #print(i,C1,np.zeros((1,w)))
      C1[i]=np.zeros((1,w))
      #print(C1)
      #exit(0)
      hw='w' if i==h-1 else 'h'
      i=0 if hw=='w' else i+1
      return dfs(C1,np.sum(C1),hw,i)+dfs(C2,np.sum(C2),hw,i)
    else:
      #print(C1)
      #C1[:][i]=np.zeros((h,1))
      for j in range(h):
        #tmp=C1[j]
        C1[j][i]=0
      #print(C1)
      #exit(0)
      i+=1
      return dfs(C1,np.sum(C1),hw,i)+dfs(C2,np.sum(C2),hw,i)

#  C=[[0 for _ in range(6)] for _ in range(6)]
  h,w,k=map(int,input().strip("\n").split())
  C=np.zeros((h,w))
  #print(C)
  for i in range(h):
    s=[1 if c=='#' else 0 for c in input().strip("\n")]
    #print(s)
    C[i]=np.array(s)
  #sprint(np.sum(C))
  print(dfs(copy.copy(C),np.sum(C),'h',0))
Problem p02630 (python)

Fixed submission:
import sys
input = sys.stdin.readline

if __name__ == '__main__':
  n=int(input())
  A_str=input().strip("\n")
  A=A_str.split()
  q=int(input())

  C={}
  for a in A:
    if a in C:
      C[a]+=1
    else:
      C[a]=1
  
  def rep(b,c):
    if c in C:
      C[c]+=C[b]
    else:
      C[c]=C[b] 
    C[b]=0
    #print(b,c,C)

  Ans=[]
  ans=''
  b,c=input().strip("\n").split()
  #tmp=eval(A_str.replace(b,c).replace(" ","+"))
  tmp=0
  hoge=map(int,A)
  for a in hoge:
    if str(a)==b:
      tmp+=int(c)
    else:
      tmp+=a
  #ans+=str(tmp)
  #ans+="\n"
  Ans.append(tmp)
  if b in C:
    rep(b,c)
  for i in range(1,q-1):
    b,c=input().strip("\n").split()
    if b in C:
      tmp+=(int(c)-int(b))*C[b]
      rep(b,c)
    #ans+=str(tmp)+"\n"
    Ans.append(tmp)
  b,c=input().strip("\n").split()
  if b in C:
    tmp+=(int(c)-int(b))*C[b]
  #ans+=str(tmp)
  Ans.append(tmp)
  #print(ans)
  for ans in Ans:
    print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

if __name__ == '__main__':
  n=int(input())
  A_str=input().strip("\n")
  A=A_str.split()
  q=int(input())

  C={}
  for a in A:
    if a in C:
      C[a]+=1
    else:
      C[a]=1
  
  def re(b,c):
    if c in C:
      C[c]+=C[b]
    else:
      C[c]=C[b] 
    C[b]=0
    #print(b,c,C)

  ans=''
  b,c=input().strip("\n").split()
  tmp=eval(A_str.replace(b,c).replace(" ","+"))
  ans+=str(tmp)
  ans+="\n"
  if b in C:
    re(b,c)
  for i in range(1,q-1):
    b,c=input().strip("\n").split()
    if b in C:
      tmp+=(int(c)-int(b))*C[b]
      re(b,c)
    ans+=str(tmp)+"\n"
  b,c=input().strip("\n").split()
  if b in C:
    tmp+=(int(c)-int(b))*C[b]
  ans+=str(tmp)
  print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

if __name__ == '__main__':
  n=int(input())
  #A=list(map(int,input().strip("\n").split()))
  A=input().strip("\n")
  q=int(input())
  Ans=[]
  for i in range(q):
    #b,c=map(int,input().strip("\n").split())
    b,c=input().strip("\n").split()
    A=A.replace(b,c)
    Ans.append(eval(A.replace(" ","+")))
  for ans in Ans:
    print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

if __name__ == '__main__':
  n=int(input())
  #A=list(map(int,input().strip("\n").split()))
  A=input().strip("\n")
  q=int(input())
  Ans=[]
  for i in range(q):
    #b,c=map(int,input().strip("\n").split())
    b,c=input().strip("\n").split()
    A=A.replace(b,c)
    Ans.append(eval(A.replace(" ","+")))
  for ans in Ans:
    print(ans)
Problem p02642 (python)

Fixed submission:
import sys
def input(): return sys.stdin.readline()

n=int(input())
A=list(map(int,input().split()))
cnt=[0]*(10**6+2)
ans=0
for a in A:
  if cnt[a]!=0:
    cnt[a]=2
    continue
  x=a
  while x<10**6+2:
    cnt[x]+=1
    x+=a
for a in A:
  #print(cnt[a])
  if cnt[a]==1:
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline()

n=int(input())
A=list(map(int,input().split()))
cnt=[0]*(10**6)
ans=0
for a in A:
  if cnt[a]!=0:
    cnt[a]=2
    continue
  x=a
  while x<10**6:
    cnt[x]+=1
    x+=a
for a in A:
  if cnt[a]==1:
    ans+=1
print(ans)

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

n=int(input())
a=np.array(list(map(int,input().split())))

ans=0
#print(a%(np.array([a for _ in range(n)])).transpose()==0)
b=(np.array([a for _ in range(n)])).transpose()%a==0

for i in range(n):
  #b=a[i]%a==0
  #print(b[i])
  #print(np.count_nonzero(b[i]))
  if np.count_nonzero(b[i])==1:
    ans+=1
print(ans)

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

n=int(input())
a=np.array(list(map(int,input().split())))
#print(a)

ans=0
for i in range(n):
  b=a[i]%a
  #print(b)
  #print(b==0)
  if np.count_nonzero(b==0)==1:
    ans+=1
print(ans)
Problem p02683 (python)

Fixed submission:
import numpy as np

def dfs(n,a,s):
  if n==0:
    return -1 if (a >= X).all()==False else s
  #print(a+A[n-1])
  x=dfs(n-1,a+A[n-1],s+C[n-1])
  y=dfs(n-1,a,s)
  return y if x==-1 else x if y==-1 else min(x,y)

N,M,X=map(int,input().split())
C=[]
A=[]
for i in range(N):
  c,*tmp=map(int,input().split())
  A.append(np.array(tmp))
  C.append(c)
#print(A)
print(dfs(N,np.array([0]*M),0))

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

def dfs(n,a,s):
  if n==0:
    return -1 if (a >= X).all()==False else s
  #print(a+A[n-1])
  x=dfs(n-1,a+A[n-1],s+C[n-1])
  y=dfs(n-1,a,s)
  return y if x==-1 else x if y==-1 else min(x,y)

N,M,X=map(int,input().split())
C=[]
A=[]
for i in range(N):
  c,*tmp=map(int,input().split())
  A.append(np.array(tmp))
  C.append(c)
#print(A)
print(dfs(N,np.array([0]*M),0))
Problem p02690 (python)

Fixed submission:
x=int(input())
# an = n^5 - (n - 1)^5
# a -> 120~-119 -> -118~119
# b -> 119~-120 -> -119~118
for i in range(-118,120):
  for j in range(-119,119):
    if i**5-j**5==x:
      print(i,j)
      exit()

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

for i in range(-118,120):
  for j in range(-119,119):
    if i**5-j**5==x:
      print(i,j)
      exit(1)

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

for i in range(-118,120):
  for j in range(-118,120):
    if i**2-j**2==x:
      print(i,j)
      exit(1)
Problem p02658 (python)

Fixed submission:
def main():
    n=int(input())
    a=list(map(int,input().split()))
    if 0 in a:
        print(0)
        return
    ans=1
    for i in a:
        ans=ans*i
        if ans>1000000000000000000:
            print(-1)
            return    
    print(ans)
    return
main()

Buggy submission (verdict: Runtime Error):
def main():
    n=int(input())
    a=list(map(int,input().split()))
    if 0 in a:
        print(0)
        return
    ans=1
    for i in a:
        ans=ans*i
        if pro>1000000000000000000:
            print(-1)
            return    
    print(ans)
    return
main()

Buggy submission (verdict: Runtime Error):
def main():
    n=int(input())
    a=list(map(int,input().split()))
    if 0 in a:
        print(0)
        return
    ans=1
    for i in a:
        pro=pro*i
        if pro>1000000000000000000:
            print(-1)
            return    
    print(ans)
    return
main()
Problem p02718 (python)

Fixed submission:
# -*- coding: utf-8 -*-

N, M = map(int, input().split())
A = list(map(int, input().split()))

th = 1.0 * sum(A) / (4 * M)

sorted_A = sorted(A, key=lambda x: -x)
if sorted_A[M - 1] < th:
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

N, M = map(int, input().split())
A = list(map(int, input().split()))

th = sum(A) // (4 * M)

sorted_A = sorted(A, key=lambda x: -x)
if sorted_A[M] < th:
    print("No")
else:
    print("Yes")
Problem p02727 (python)

Fixed submission:
# -*- coding: utf-8 -*-

X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

# all_apples = sorted(p + q + r, key=lambda x: -x)

p_rest = sorted(p + [0])
q_rest = sorted(q + [0])
r_rest = sorted(r + [0])

ans = 0
p_count = 0
q_count = 0
r_count = 0
while (p_count + q_count + r_count) < (X + Y):
    if p_count < X and q_count < Y:
        candidates = [p_rest[-1], q_rest[-1], r_rest[-1]]
    elif p_count < X and q_count == Y:
        candidates = [p_rest[-1], 0, r_rest[-1]]
    elif p_count == X and q_count < Y:
        candidates = [0, q_rest[-1], r_rest[-1]]

    wanna_eat = max(candidates)
    eat_idx = candidates.index(wanna_eat)

    if eat_idx == 0:
        p_count += 1
        ans += p_rest.pop()
    elif eat_idx == 1:
        q_count += 1
        ans += q_rest.pop()
    else:
        r_count += 1
        ans += r_rest.pop()
    # print(candidates, eat_idx, wanna_eat, p_count, q_count, r_count)

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

rest = [[0] + sorted(p),
        [0] + sorted(q),
        [0] + sorted(r)]

ans = 0
count = [0, 0, 0]
while sum(count) < (X + Y):

    candidates = [rest[i][-1] if count[i] == X else 0 for i in range(3)]

    wanna_eat = max(candidates)
    eat_idx = candidates.index(wanna_eat)

    count[eat_idx] += 1
    ans += rest[eat_idx].pop()

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

# all_apples = sorted(p + q + r, key=lambda x: -x)

p_rest = sorted(p)
q_rest = sorted(q)
r_rest = sorted(r)

ans = 0
p_count = 0
q_count = 0
r_count = 0
while (p_count + q_count + r_count) < (X + Y):
    if p_count < X and q_count < Y:
        candidates = [p_rest[-1], q_rest[-1], r_rest[-1]]
    elif p_count < X and q_count == Y:
        candidates = [p_rest[-1], 0, r_rest[-1]]
    elif p_count == X and q_count < Y:
        candidates = [0, q_rest[-1], r_rest[-1]]

    wanna_eat = max(candidates)
    eat_idx = candidates.index(wanna_eat)

    if eat_idx == 0:
        p_count += 1
        ans += p_rest.pop()
    elif eat_idx == 1:
        q_count += 1
        ans += q_rest.pop()
    else:
        r_count += 1
        ans += r_rest.pop()
    # print(candidates, eat_idx, wanna_eat, p_count, q_count, r_count)

print(ans)
Problem p02901 (python)

Fixed submission:
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

N, M = map(int, input().split())
a = [0] * M
keys = [0] * M
inf = 10 ** 12
for i in range(M):
    a[i], _ = map(int, input().split())
    c_list = list(map(int, input().split()))
    keys[i] = sum([2 ** j for j in range(N) if j + 1 in c_list])

dp = [inf] * (2 ** N)
dp[0] = 0

# print(keys)

for i in range(M):  # use key i
    for j in range(2 ** N):
        # print(dp, j, keys[i], dp[j | keys[i]], dp[j], a[i])
        dp[j | keys[i]] = min(dp[j] + a[i], dp[j | keys[i]])

ans = dp[-1]
if ans == inf:
    ans = -1
print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

N, M = map(int, input().split())
a = [0] * M
keys = [0] * M
inf = 10 ** 12
for i in range(M):
    a[i], _ = map(int, input().split())
    c_list = list(map(int, input().split()))
    keys[i] = sum([2 ** j for j in range(N) if j + 1 in c_list])

dp = [inf] * (N ** 2)
dp[0] = 0

# print(keys)

for i in range(M):  # use key i
    for j in range(N ** 2):
        dp[j | keys[i]] = min(dp[j] + a[i], dp[j | keys[i]])
        # print(dp, j, keys[i], dp[j | keys[i]], dp[j], a[i])

ans = dp[-1]
if ans == inf:
    ans = -1
print(ans)
Problem p02969 (python)

Fixed submission:
# -*- coding: utf-8 -*-

r = int(input())

ans = 3 * r * r

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

N = int(input())
A = [None] * N
for i in range(N):
    A[i] = int(input())

max_list = [-1]

for i in range(N):
    ok_list = [i for i, x in enumerate(max_list) if x < A[i]]
    if ok_list:
        max_list[ok_list[0]] = A[i]
    else:
        max_list.append(A[i])

ans = len(max_list)
print(ans)
Problem p02999 (python)

Fixed submission:
# -*- coding: utf-8 -*-

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

if x < a:
    print("0")
else:
    print("10")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

x, a = int(input()), int(input())

if x < a:
    print("0")
else:
    print("10")
Problem p03102 (python)

Fixed submission:
# -*- coding: utf-8 -*-

import numpy as np

N, M, C = map(int, input().split())
B = np.ndarray([M, 1])
B = list(map(int, input().split()))
A = np.ndarray([N, M])
for i in range(N):
    A[i, :] = list(map(int, input().split()))

ans = sum((np.dot(A,B) + C) > 0)

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import numpy as np

N, M, C = map(int, input().split())
B = np.ndarray([M, 1])
B = list(map(int, input().split()))
A = np.ndarray([N, M])
for i in range(N):
    A[i, :] = list(map(int, input().split()))

ans = sum((A @ B + C) > 0)

print(ans)
Problem p03854 (python)

Fixed submission:
# -*- coding: utf-8 -*-

S = input()
dream_set = {"dream", "dreamer", "erase", "eraser"}
# 感動的計画法やるぞ

while len(S) > 0:
    if S.endswith("dream") or S.endswith("erase"):
        S = S[:-5]
    elif S.endswith("eraser"):
        S = S[:-6]
    elif S.endswith("dreamer"):
        S = S[:-7]
    else:
        print("NO")
        exit()

print("YES")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

N = int(input())
A = list(map(int, input().split()))

ans = 0
new_a = A.copy()
while 1:
    new_a = [a // 2 if a % 2 == 0 else -1 for a in new_a]
    if -1 in new_a:
        print(ans)
        exit()
    ans += 1

print(ans)
Problem p02621 (python)

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

Buggy submission (verdict: Runtime Error):
n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
 
l = []
for i in range(min(n, m)):
  l.append(min(a[i], b[i]))
  l.append(max(a[i], b[i]))

for i in range(min(n, m), max(n, m)):
  if n > m:
    l.append(a[i])
  else:
    l.append(b[i])

total = 0
cnt = 0
for i in range(n+m):
  if total+l[i] > k:
    break
  total += l[i]
  cnt += 1
print(cnt)
Problem p02641 (python)

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

if n != 0:
  p = list(map(int, input().split()))
  lists = []
  for i in range(0, 102):
    if i in p:
      continue
    lists.append(i)

  ans = lists[0]
  mins = abs(lists[0] - x)
  for i in range(1, len(lists)):
    dist = abs(lists[i]-x)
    if mins > dist:
      ans = lists[i]
      mins = dist
      
  print(ans)
else:
  print(x)

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

if n != 0:
  p = list(map(int, input().split()))
  lists = []
  for i in range(1, 101):
    if i in p:
      continue
    lists.append(i)

  ans = lists[0]
  dist = abs(lists[0]-x)
  for i in range(len(lists)):
    if dist > abs(lists[i]-x):
      ans = lists[i]
      dist = abs(lists[i]-x)
  print(ans)
  
else:
  print(x)
Problem p02664 (python)

Fixed submission:
t = input()

l = ["" for i in range(len(t))]
for i in range(0, len(t)):
    if t[i] =="?":
        l[i] = "D"
    
    else:
        l[i] = t[i]

print("".join(l))

Buggy submission (verdict: Runtime Error):
t = input()

l = [_ for i in range(len(t))]
for i in range(0, len(t)):
    if t[i] =="?":
        l[i] = "D"
    
    else:
        l[i] = t[i]

print("".join(l))

Buggy submission (verdict: Runtime Error):
t = input()

l = [_ for i in range(len(t))]
r = [] * (len(t))
print(l)
for i in range(0, len(t)):
    print(i)
    if t[i] =="?":
        l[i] = "D"
    
    else:
        l[i] = t[i]

print("".join(l))
Problem p02713 (python)

Fixed submission:
from itertools import combinations
import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

n = int(input())

total = 0
for i in range(1, n+1):
    for j in range(i, n+1):
        for k in range(j, n+1):
            if  i == j and j == k and i == k:
                x = 1
            elif i != j and j != k and i != k:
                x = 6
            else:
                x = 3
            
            total += x * gcd_list([i, j, k])
        
print(total)

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

from functools import reduce
def gcd_list(numbers):
  return reduce(math.gcd, numbers)

total = 0
for i in range(1, k+1):
  for j in range(i, k+1):
    for k in range(j, k+1):
      if i == j and j == k and i == k:
        x = 1
      elif i != j and i != k and j != k:
        x = 6
      else:
        x = 3
        
      total += x * gcd_list([i, j, k])
print(total)
Problem p02761 (python)

Fixed submission:
from sys import stdin
import sys
import numpy as np
import collections
from functools import cmp_to_key
import heapq
 
##  input functions for me
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def rip(sep = ''):
    if sep == '' :
        return map(int, input().split()) 
    else: return map(int, input().split(sep))
def ria(sep = ''): 
    return list(rip(sep))
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##
def main():
    N, M = rip()
    S = [0] * M
    C = [0] * M
    for i in range(M):
        S[i], C[i] = rip()
 
    for i in range(1000):
        s = str(i)
        if len(s) != N: continue
        chk = True
        for j in range(M):
            chk &= s[S[j] - 1] == str(C[j])
        if chk:
            print(i)
            sys.exit(0)
    
    print(-1)
 
 
if __name__ == "__main__":
    main()

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

for i in range(0, 10**n):
  str_i = str(i)
  if len(str_i) != n: continue

  chk = True
  for s, c in sc:
    cnt &= str_i[s-1] == str(c)
  if chk:
    print(i)
    exit()

  print(-1)