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

Fixed submission:
a=[[] for _ in range(3)]
for i in range(3):
  a[i]=list(map(int,input().split()))
l=[]
N=int(input())
for i in range(N):
  n=int(input())
  for i in range(3):
    for j in range(3):
      if a[i][j]==n:
        l.append([i,j])

def judge(l):
  if len(l)<=2:
    return 'No'
  else:
    if [0,0] in l and [1,1] in l and [2,2] in l:
      return 'Yes'
    elif [0,2] in l and [1,1] in l and [2,0] in l:
      return 'Yes'
    else:
      dic1={}
      dic2={}
      for ij in l:
        i,j=ij[0],ij[1]
        if i not in dic1.keys():
          dic1[i]=1
        else:
          dic1[i]+=1
          if dic1[i]==3:
            return 'Yes'
        if j not in dic2.keys():
          dic2[j]=1
        else:
          dic2[j]+=1
          if dic2[j]==3:
            return 'Yes'
      return 'No'
print(judge(l))

Buggy submission (verdict: Runtime Error):
a=[[] for _ in range(3)]
for i in range(3):
  a[i]=list(map(int,input().split()))
l=[]
N=int(input())
for i in range(N):
  n=int(input())
  for i in range(3):
    for j in range(3):
      if a[i][j]==n:
        l.append([i,j])

def judge(l):
  if len(l)<=2:
    return 'No'
  else:
    if [0,0] in l and [1,1] in l and [2,2] in l:
      return 'Yes'
    else:
      dic1={}
      dic2={}
      for ij in l:
        i,j=ij[0],ij[1]
        if i not in dic1.keys():
          dic1[i]=1
        else:
          dic1[i]+=1
          if dci1[i]==3:
            return 'Yes'
        if j not in dic2.keys():
          dic2[j]=1
        else:
          dic2[j]+=1
          if dic2[j]==3:
            return 'Yes'
      return 'No'
print(judge(l))

Buggy submission (verdict: Runtime Error):
a=[[] for _ in range(3)]
for i in range(3):
  a[i]=list(map(int,input().split()))
l=[]
N=int(input())
for i in range(N):
  n=int(input())
  for i in range(3):
    for j in range(3):
      if a[i][j]==n:
        l.append([i,j])

def judge(l):
  if len(l)<=2:
    return 'No'
  else:
    if [0,0] in l and [1,1] in l and [2,2] in l:
      return 'Yes'
    else:
      dic1={}
      dic2={}
      for ij in l:
        i,j=l[0],l[1]
        if i not in dic1.keys():
          dic1[i]=1
        else:
          dic1[i]+=1
          if dci1[i]==3:
            return 'Yes'
        if j not in dic2.keys():
          dic2[j]=1
        else:
          dic2[j]+=1
          if dic2[j]==3:
            return 'Yes'
      return 'No'
print(judge(l))
Problem p02814 (python)

Fixed submission:
import sys
N,M=map(int,input().split())
a=list(map(int,input().split()))

def gcd(a,b):
  if a==b:
    return a
  a,b=max(a,b),min(a,b)
  if a%b==0:
    return b
  else:
    return gcd(b,a%b)
  
def lcm(a,b):
  return a*b//gcd(a,b)

if N==1:
  v=M//int(a[0]*0.5)
  if v%2==0:
    print(v//2)
  else:
    print(v//2+1)
  sys.exit()
  
for i in range(N-1):
  if i==0:
    tmp=lcm(a[i]//2,a[i+1]//2)
    devider=min(a[i]//2,a[i+1]//2)
    if (tmp//devider)%2==0:
      print(0)
      sys.exit()
  else:
    tmp=lcm(tmp,a[i+1]//2)
    devider=min(tmp,a[i+1]//2)
    if (tmp//devider)%2==0:
      print(0)
      sys.exit()

v=M//tmp
if v%2==1:
  print(v//2+1)
else:
  print(v//2)

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

def gcd(a,b):
  if a==b:
    return a
  a,b=max(a,b),min(a,b)
  if a%b==0:
    return b
  else:
    return gcd(b,a%b)
  
def lcm(a,b):
  return a*b//gcd(a,b)
  
for i in range(N-1):
  if i==0:
    tmp=lcm(a[i]//2,a[i+1]//2)
  else:
    tmp=lcm(tmp,a[i+1]//2)
v=M//tmp
if v%2==1:
  print(v//2+1)
else:
  print(v//2)
Problem p02845 (python)

Fixed submission:
import sys
N=int(input())
a=list(map(int,input().split()))
ans=1
l=[0,0,0]
mod=10**9+7
for i in range(N):
  ans*=(l.count(a[i]))
  if a[i] not in l:
    print(0)
    sys.exit()
  index=l.index(a[i])
  l[index]+=1
print(ans%mod)

Buggy submission (verdict: Runtime Error):
N=int(input())
a=list(map(int,input().split()))
ans=1
l=[0,0,0]
mod=10**9+7
for i in range(N):
  ans*=(l.count(a[i]))
  index=l.index(a[i])
  l[index]+=1
print(ans%mod)
Problem p02887 (python)

Fixed submission:
import sys
N=int(input())
s=list(str(input()))
i=0
ans=0
if N==1:
  print(1)
  sys.exit()
while i!=N-1:
  count=1
  ans+=1
  while i+count<=N-1 and s[i]==s[i+count]:
    count+=1
  i+=count
  if i==N:
    print(ans)
    sys.exit()
  elif i==N-1:
    if s[N-2]!=s[N-1]:
      ans+=1
    print(ans)
    sys.exit()
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
s=list(str(input()))

def dp(i,ans):
  if i==N-1:
    return ans+1
  if s[i]!=s[i+1]:
    ans+=1
    return dp(i+1,ans)
  else:
    count=2
    ans+=1
    while i+count<=N-1 and s[i]==s[i+count]:
      count+=1
    if i+count==N:
      return ans
    if i+count==N-1 and s[N-2]!=s[N-1]:
      ans+=1
      return ans
    return dp(i+count,ans)
  
ans=0
print(dp(0,ans))
Problem p02923 (python)

Fixed submission:
N=int(input())                                       
H=list(map(int,input().split()))
for i in range(N-1):
  if H[i]<H[i+1]:
    H[i]=0
  else:
    H[i]=1
H[-1]=0
zero=[]
for i in range(N):
  if H[i]==0:
    zero.append(i)
if len(zero)==N:
  print(0)
elif len(zero)==1:
  print(N-1)
else:
  ans=0
  for i in range(len(zero)-1):
    ans=max(ans,zero[i+1]-zero[i]-1)
  ans=max(ans,zero[-1]-zero[-2]-1) 
  print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
H=list(map(int,input().split()))
val1,val2=H[-1],H[-2]
for i in range(N-1):
  if H[i]<H[i+1]:
    H[i]=0
  else:
    H[i]=1
if val1<=val2:
  H[-1]=1
else:
  H[-1]=0
zero=[]
for i in range(N):
  if H[i]==0:
    zero.append(i)
if len(zero)==N:
  print(0)
elif len(zero)==0:
  print(N)
elif len(zero)==1:
  print(max(zero[0],N-zero[0]-2))
else:
  ans=0
  for i in range(len(zero)-1):
    ans=max(ans,zero[i+1]-zero[i]-1)
  ans=max(ans,zero[-1]-zero[-2]-1)
  if H[-1]==1:
    ans=max(ans,N-zero[-1]-2)
  else:
    pass
  print(ans)
Problem p02995 (python)

Fixed submission:
A,B,C,D=map(int,input().split())
c_dividable=B//C-(A-1)//C
d_dividable=B//D-(A-1)//D
def gcd(a,b):
  if a==b:
    return a
  else:
    if a%b==0:
      return b
    while a%b!=0:
      return gcd(b,a%b)
v=C*D//gcd(C,D)
cd_dividable=B//v-(A-1)//v
print(B-A+1-(c_dividable+d_dividable-cd_dividable))

Buggy submission (verdict: Runtime Error):
A,B,C,D=map(int,input().split())
c_dividable=B//C-(A-1)//C
d_dividable=B//D-(A-1)//D
def gcd(a,b):
  if a==b:
    return q
  else:
    if a%b==0:
      return b
    while a%b!=0:
      return gcd(b,a%b)
v=C*D//gcd(C,D)
cd_dividable=B//v-(A-1)//v
print(B-A+1-(c_dividable+d_dividable-cd_dividable))
Problem p03037 (python)

Fixed submission:
N,M=map(int,input().split())
lst=[[] for _ in range(M)]
dif=10**19
v1,v2=map(int,input().split())
for i in range(M-1):
  v_1,v_2=map(int,input().split())
  v1,v2=max(v1,v_1),min(v2,v_2)
if v2-v1+1<=0:
  print(0)
else:
  print(v2-v1+1)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
lst=[[] for _ in range(M)]
for i in range(M):
  lst[i]=list(map(int,input().split()))
ans=0
visited=[]
ini=lst.pop(0)
tmp=[i for i in range(ini[0],ini[1]+1)]

def f(tmp):
  if len(lst)==0:
    return len(tmp)
  else:
    l=lst.pop(0)
    v1,v2=l[0],l[1]
    if tmp==[]:
      return 0
    else:
      m1=v1
      M1=v2
      m2=min(tmp)
      M2=max(tmp)
      m,M=max(m1,m2),min(M1,M2)
      tmp=[i for i in range(m,M+1)]
      return f(tmp)
    
print(f(tmp))
Problem p03044 (python)

Fixed submission:
N=int(input())
E=[[] for _ in range(N)]
for i in range(N-1):
  u,v,w=map(int,input().split())
  u-=1
  v-=1
  E[u].append((v,w))
  E[v].append((u,w))
color=[-1]*N
color[0]=0
stack=[0]
while stack:
  u=stack.pop()
  for v,w in E[u]:
    if color[v]==-1:
      stack.append(v)
      if w%2==0:
        color[v]=color[u]
      else:
        color[v]=1 if color[u]==0 else 0
for i in range(N):
  print(color[i])

Buggy submission (verdict: Runtime Error):
from collections import deque,defaultdict
N=int(input())
lst=defaultdict(list)
for i in range(N-1):
  u,v,w=map(int,input().split())
  lst[u].append([v,w])
  lst[v].append([u,w])

def dfs(d,col):
  if len(d)==0:
    return col
  s=d.pop()
  for i in lst[s]:
    v,w=i[0],i[1]
    lst[v].remove([s,w])
    d.append(v)
    if w%2==0:
      if col[u]!=-1:
        col[v]=col[u]
      elif col[v]!=-1:
        col[u]=col[v]
      else:
        col[u]=0
        col[v]=0
    else:
      if col[u]!=-1:
        col[v]=(col[u]+1)%2
      elif col[v]!=-1:
        col[u]=(col[v]+1)%2
      else:
        col[u]=0
        col[v]=1
  return dfs(d,col)

d=deque([1])
col=defaultdict(int)
for i in range(1,N+1):
  if i==1:
    col[i]=0
  else:
    col[i]=-1
ans=dfs(d,col)
for i in range(1,N+1):
  print(ans[i])

Buggy submission (verdict: Runtime Error):
from collections import deque
N=int(input())
uvw=[[0,0,0] for _ in range(N-1)]
for i in range(N-1):
  u,v,w=list(map(int,input().split()))
  uvw[i]=[u,v,w]

d=deque()
d.append(1)
visited=[None]*N
visited[0]=0
def dfs(d,visited):
  l1=[]
  l2=[]
  s=d.pop()
  tmp=[]
  for i in range(len(uvw)):
    if uvw[i][0]==s:
      l1.append(i)
    if uvw[i][1]==s:
      l2.append(i)
  if l1!=[]:
    for i in l1:
      d.append(uvw[i][1])
      visited[uvw[i][1]-1]=(uvw[i][2]+visited[s-1])%2
      tmp.append([uvw[i][0],uvw[i][1],uvw[i][2]])
  if l2!=[]:
    for j in l2:
      d.append(uvw[j][0])
      visited[uvw[j][0]-1]=(uvw[j][2]+visited[s-1])%2
      tmp.append([uvw[j][0],uvw[j][1],uvw[j][2]])
  for lst in tmp:
    uvw.remove(lst)
  if len(d)==0 or (None not in visited):
    return visited
  return dfs(d,visited)

ans=dfs(d,visited)
for i in range(N):
  print(ans[i])
Problem p03076 (python)

Fixed submission:
import sys
lst=[]
ans=0
for i in range(5):
  a=int(input())
  if a%10==0:
    ans+=a
  else:
    lst.append(a)
if len(lst)!=0:
  C=[[] for _ in range(len(lst))]   
  for i in range(len(lst)):
    v=lst[i]
    c=v%10
    C[i]=[-c,v]
  C=sorted(C)
  for i in range(len(lst)-1):
    v=C[i][1]
    c=-C[i][0]
    ans+=(v+(10-c))
  print(ans+C[-1][1])
else:
  print(ans)

Buggy submission (verdict: Runtime Error):
import sys
lst=[]
ans=0
for i in range(5):
  a=int(input())
  if a%10==0:
    ans+=a
  else:
    lst.append(a)
C=[[] for _ in range(len(lst))]   
for i in range(len(lst)):
  v=lst[i]
  c=v%10
  C[i]=[-c,v]
C=sorted(C)
for i in range(len(lst)-1):
  v=C[i][1]
  c=-C[i][0]
  ans+=(v+(10-c))
print(ans+C[-1][1])
Problem p03147 (python)

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
zeros=[]
prev=0
for i in  range(n):
  if h[i]==0:
    if i==0:
      prev=i+1
    else:
      if prev<=i-1:
        zeros.append((prev,i-1))
      prev=i+1
if prev<=n-1:
  zeros.append((prev,n-1))
cnt=0
while zeros:
  l,r=zeros.pop()
  m=min(h[l:r+1])
  cnt+=m
  prev=l
  for i in range(l,r+1):
    h[i]-=m
    if h[i]==0:
      if i==l:
        prev=i+1
      else:
        if prev<=i-1:
          zeros.append((prev,i-1))
        prev=i+1
  if prev<=r:
    zeros.append((prev,r))
print(cnt)

Buggy submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
zeros=[]
prev=0
for i in  range(n):
  if h[i]==0:
    zeros.append((prev,i-1))
    prev=i+1
zeros.append((prev,n-1))
cnt=0
while zeros:
  l,r=zeros.pop()
  m=min(h[l:r+1])
  cnt+=m
  prev=l
  for i in range(l,r+1):
    h[i]-=m
    if h[i]==0:
      if i==l:
        prev=i+1
      else:
        if prev<=i-1:
          zeros.append((prev,i-1))
        prev=i+1
  if prev<=r:
    zeros.append((prev,r))
print(cnt)
Problem p03311 (python)

Fixed submission:
import copy
N=int(input())
lst=list(map(int,input().split()))
lst2=copy.copy(lst)
for i in range(1,N+1):
  lst2[i-1]-=i
lst2=sorted(lst2)
b=lst2[N//2]
ans=0
for i in range(N):
  ans+=abs(lst[i]-(b+i+1))
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
lst=list(map(int,input().split()))
lst_=sorted(lst)
def f(b):
  ans=0
  for i in range(1,N+1):
    ans+=abs(lst[i-1]-(b+i))
  return ans

if N%2==1:
  b=lst_[(N-1)//2]-((N-1)//2+1)
  print(f(b))
else:
  b1=lst_[N//2]-(N//2+1)
  b2=lst_[b1-1]-(b1+1)
  print(min(f(b1),f(b2)))
Problem p03472 (python)

Fixed submission:
N,H=map(int,input().split())
B=[]
index=-1
tmp=-1
for i in range(N):
  a,b=map(int,input().split())
  B.append(b)
  if a>tmp:
    index=i
    tmp=a
a_,b_=tmp,B[index]
cnt=0
B=sorted(B,reverse=True)
while H>0 and len(B)!=0:
  b=B.pop(0)
  if b<a_:
    break
  H-=b
  cnt+=1
if H<=0:
  print(cnt)
else:
  v=H//a_
  if H%a_==0:
    cnt+=v
  else:
    cnt+=(v+1)
  print(cnt)

Buggy submission (verdict: Runtime Error):
import sys
N,H=map(int,input().split())
B=[]
index=-1
tmp=-1
for i in range(N):
  a,b=map(int,input().split())
  B.append(b)
  if a>tmp:
    index=i
    tmp=a
a_,b_=tmp,B[index]
cnt=0
if sum(B)>=H:
  B=sorted(B,reverse=True)
  while H>0:
    cnt+=1
    b=B.pop(0)
    H-=b
  print(cnt)
else:
  B.remove(b_)
  B=sorted(B,reverse=True)
  while len(B)!=0 :
    b=B.pop(0)
    if b<=a_:
      break
    H-=b
    cnt+=1
  if H-b_<=0:
    print(cnt+1)
    sys.exit()
  v=(H-b_)//a_
  cnt+=v
  H-=a_*v
  if 0=<H<=b_:
    cnt+=1
  else:
    cnt+=2
  print(cnt)
Problem p03557 (python)

Fixed submission:
import bisect
N=int(input())
A=sorted(list(map(int,input().split())))
B=list(map(int,input().split()))
C=sorted(list(map(int,input().split())))
ans=0
for val in B:
  val1=bisect.bisect_left(A,val)
  val2=N-bisect.bisect_right(C,val)
  ans+=val1*val2
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=sorted(list(map(int,input().split())))
B=list(map(int,input().split()))
C=sorted(list(map(int,input().split())))
ans=0
for i in range(N):
  val=B[i]
  mid_a=A[N//2-1]
  mid_c=C[N//2-1]
  if mid_a<val:
    count1=0
    for i in range(N//2,N):
      if A[i]<val:
        count1+=1
      else:
        break
    val1=N//2+count1
  else:
    count2=0
    for i in range(N//2):
      if A[i]<val:
        count2+=1
      else:
        break
    val1=count2
  if mid_c>val:
    count3=0
    for i in range(N//2):
      if C[i]<val:
        count3+=1
      else:
        break
    val2=N-count3
  else:
    for i in range(N//2,N):
      if C[i]>val:
        val2=N-i
        break
      else:
        if i==N:
          val2=0
        else:
          pass
  ans+=val1*val2
print(ans)
Problem p03816 (python)

Fixed submission:
from collections import defaultdict
N=int(input())
h=[]
a=list(map(int,input().split()))
cnt_dic=defaultdict(int)
for i in range(N):
  cnt_dic[a[i]]+=1
cnt_l=sorted(cnt_dic.values(),reverse=True)
ans=len(cnt_l)
tmp=0
for i in range(ans):
  if cnt_l[i]%2==0:
    tmp+=1
if tmp%2==0:
  pass
else:
  ans-=1
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
h=[]
a=list(map(int,input().split()))
cnt_dic=defaultdict(int)
for i in range(N):
  cnt_dic[a[i]]+=1
cnt_l=sorted(cnt_dic.values(),reverse=True)
ans=len(cnt_l)
tmp=0
for i in range(ans):
  if cnt_l[i]%2==0:
    tmp+=1
if tmp%2==0:
  pass
else:
  ans-=1
print(ans)
Problem p02660 (python)

Fixed submission:
n = int(input())

i = 2
memo = []
while( i*i <= n ):
    x = 0
    while(n % i == 0):
        #print("n % i == 0 =",n,i,"n/i=",n/i,x+1)
        n = int(n / i);
        x = x + 1
    memo.append([i,x])
    i = i + 1

if not (n == 1):
    memo.append([n,1])

ans = 0
for i in memo:
    x = i[1]
    b = 1
    while b <= x:
        x = x - b
        b = b + 1
        ans = ans + 1

print(ans)

Buggy submission (verdict: Runtime Error):
import math

# 素数リスト生成　eratosthenes
def makePrime(m):
    p = [i for i in range(m + 1)]
    for i in p[3:]:
        if p[i] % 2 == 0: p[i] = 0

    root_m = m ** 0.5
    for i in range(3,m):
        if i > root_m: break
        if p[i] != 0:
            for j in range(i, m + 1, 2):
                if i * j >= m + 1: break
                p[i * j] = 0
    #return p
    return sorted(list(set(p)))[2:]


# 素数かどうか判定
def isPrime(x):
    if x <= 1:
        return False
    
    for i in range(2,math.floor(math.sqrt(x))+1):
        if (x % i) == 0:
            return False
    return True

# zの値を作成
def z_make(n,p):
    for prime in p:
        for i in range(1,100000000000):
            z = prime ** i
            
            if z >= n:
                break
            
            if not z in memo:
                memo.append(z)

def divGame2(n):
    for z in memo:
        global ans
        if n % z == 0:
            rem = n / z
            memo.remove(z)
            ans += 1
            #print("n=",n," z=",z,"rem=",rem," ans=",ans)
            return divGame2(rem)
        if n < z:
            break

memo = []  # memory
ans = 0    # answer
p = []     # Prime

n = int(input())

if isPrime(n): # 素数だったら１が答え
    print(1)
else:
  　p = makePrime(64000) #32000 87000でも、1898 msとぎりぎりのためこのコードはダメっぽい
    z_make(n,p)  # zの値を生成。memoができる
    memo.sort()  # 念のため並び替え

    divGame2(n)  # メイン実行
    print(ans)   # 答えの出力
Problem p02756 (python)

Fixed submission:
from collections import deque

revFlag = False

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

for i in range(q):
    a,b,c, *_ = input().split() + [None, None]
    
    if(a == '1'):
        revFlag = not revFlag
        
    else:
        b = int(b)
        if(revFlag):
            b = (int(b)%2)+1
        
        if(b == 1):
            s.appendleft(c)
        else:
            s.append(c)
            
    #print(_,*s, sep="")

if(revFlag):
    s.reverse()
    
print(*s, sep='')

Buggy submission (verdict: Runtime Error):
rflag = 0
s = [i for i in input()]
q = int(input())

for i in range(q):
    x = input().split()
    
    if(x[0] == '1'):
        rflag = rflag + 1
        # s = s[::-1]
    else:
        if((rflag % 2) == 0):
            rflag = 0
        else:
            s = s[::-1]
            rflag = 0
            
        s.insert(0,x[2]) if(x[1]=='1') else s.append(x[2])

s if((rflag % 2) == 0) else s = s[::-1]

print(''.join(s))

Buggy submission (verdict: Runtime Error):
def sr(x):
    y = ''
    for i in range(len(x)-1,-1,-1):
        y = '%s%s' %(y,x[i])
        print(y)
    print(y)    
    return y

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

for i in range(q):
    x = input().split()
    
    if (x[0] == '1'):
        #s = s[::-1]
        s = sr(s)
    else:
        s = '%s%s'%(x[2],s) if (x[1] == '1') else '%s%s'%(s,x[2])

print(s)
Problem p02584 (python)

Fixed submission:
x,k,d=map(int,input().split())
ans=0
if abs(x)>k*d:
    ans=(abs(x)-k*d)
else:
    temp=k-(x//d)
    if temp %2==0:
        ans=x%d
    else:
        ans=d-x%d
print(ans)

Buggy submission (verdict: Runtime Error):
x,k,d=map(int,input().split())
ans=0
if x>k*d:
    ans=(x-k*d)
else:
    temp=k-(n//d)
    if temp %2==0:
        ans=n%d
    else:
        ans=d-n%d
print(ans)
Problem p02640 (python)

Fixed submission:
x,y=map(int,input().strip().split())
if x*4<y or x*2>y:
  print("No")
elif y%2!=0:
  print("No")
else:
  print("Yes")

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

if x*4<b:
  print("No")
elif y%2!=0:
  print("No")
else:
  print("Yes")
Problem p02675 (python)

Fixed submission:
n = int(input())
a=int((str(n))[-1])
hon=[2,4,5,7,9]
pon=[0,1,6,8]
if a in hon:
  print("hon")
elif a in pon :
  print("pon")
else:
  print("bon")

Buggy submission (verdict: Runtime Error):
n = int(input())
a=int((str(n))[-1])
hon=[2,4,5,7,9]
pon=[0,1,6,8]
if a in hon:
  return "hon"
elif a in pon :
  return "pon"
else:
  return "bon"

Buggy submission (verdict: Runtime Error):

a=int(str(n)[-1])

if a == 2, 4, 5, 7, 9:
  return "hon"
elif a == 0, 1, 6 or 8:
  return "pon"
else:
  return "bon"

Buggy submission (verdict: Runtime Error):
n= int(input())
a=int(str(n)[-1])

if a == 2, 4, 5, 7, 9:
  return "hon"
elif a == 0, 1, 6 or 8:
  return "pon"
else:
  return "bon"
Problem p02767 (python)

Fixed submission:
n=int(input())
x=list(map(int,input().split()))
l=min(x)
r=max(x)
cost=[]
for i in range(l,r+1):
    curcost=0
    for j in range(n):
        curcost+=(x[j]-i)**2
    cost.append(curcost)
print(min(cost))

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
x=list(map(int,input().split()))
l=min(x)
r=max(x)
cost=[]
for i in range(l,r):
    curcost=0
    for j in range(n):
        curcost+=(x[j]-i)**2
    cost.append(curcost)
print(min(cost))
Problem p02922 (python)

Fixed submission:
import math
a,b=map(int,input().strip().split())
ans=0
sockets=1
while sockets<b:
  sockets-=1
  sockets+=a
  ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
import math
a,b=map(int,input().strip().split())
ans=0
sockets=1
while sockets<b:
  outlets-=1
  sockets+=a
  ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
import math
a,b=input.split(" ")
print(math.ceil(a/b))
Problem p02640 (python)

Fixed submission:
x, y = map(int, input().split())
if y%2 == 0 and (x*2 <= y) and (y<= x*4):
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
 x, y = map(int, input().split())
if y%2 == 0 and (x*2 <= y <= x*4):
  print('Yes')
else:
  print('No')
Problem p03032 (python)

Fixed submission:
import copy

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

mx = 0
for num_out in range(k+1):
	if num_out > n:
		num_out = n
		num_ret = min(k-n, n)
		out = copy.copy(v)
		out.sort()
		ret_value = 0
		for ret_v in out[:num_ret]:
			if ret_v < 0:
				ret_value += ret_v
			else:
				break
		val = sum(out) - ret_value
		if val > mx:
			mx = val
		continue
	
	num_ret = k-num_out
	for num_out_l in range(num_out+1):
		num_out_r = num_out - num_out_l
		out = v[:num_out_l] + v[n-num_out_r:]
		out.sort()
		ret_value = 0
		for ret_v in out[:num_ret]:
			if ret_v < 0:
				ret_value += ret_v
			else:
				break
		val = sum(out) - ret_value
		if val > mx:
			mx = val
			# mx_out = out

print(mx)
# print(mx_out)

Buggy submission (verdict: Runtime Error):
import copy

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

mx = 0
for num_out in range(k+1):
	if num_out > n:
		num_out = n
		num_ret = min(k-n, n)
		out = copy.deepcopy(v).sort()
		ret_value = 0
		for ret_v in out[:num_ret]:
			if ret_v < 0:
				ret_value += ret_v
			else:
				break
		val = sum(out) - ret_value
		if val > mx:
			mx = val
		continue
	
	num_ret = k-num_out
	for num_out_l in range(num_out+1):
		num_out_r = num_out - num_out_l
		out = v[:num_out_l] + v[n-num_out_r:]
		out.sort()
		ret_value = 0
		for ret_v in out[:num_ret]:
			if ret_v < 0:
				ret_value += ret_v
			else:
				break
		val = sum(out) - ret_value
		if val > mx:
			mx = val
			# mx_out = out

print(mx)
# print(mx_out)

Buggy submission (verdict: Runtime Error):
import copy

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

mx = 0
for num_out in range(k+1):
	if num_out > n:
		num_out = n
		num_ret = min(k-n, n)
		out = copy.deepcopy(v).sort()
		for ret_v in out[:num_ret]:
			if ret_v < 0:
				ret_value += ret_v
			else:
				break
		val = sum(out) - ret_value
		if val > mx:
			mx = val
		continue
	
	num_ret = k-num_out
	for num_out_l in range(num_out+1):
		num_out_r = num_out - num_out_l
		out = v[:num_out_l] + v[n-num_out_r:]
		out.sort()
		ret_value = 0
		for ret_v in out[:num_ret]:
			if ret_v < 0:
				ret_value += ret_v
			else:
				break
		val = sum(out) - ret_value
		if val > mx:
			mx = val
			# mx_out = out

print(mx)
# print(mx_out)

Buggy submission (verdict: Runtime Error):
import copy

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

mx = 0
for num_out in range(k+1):
	num_ret = k-num_out
	if num_out > n:
		out = copy.deepcopy(v).sort()
		for ret_v in out[:num_ret]:
			if ret_v < 0:
				ret_value += ret_v
			else:
				break
		val = sum(out) - ret_value
		if val > mx:
			mx = val
		continue

	for num_out_l in range(num_out+1):
		num_out_r = num_out - num_out_l
		out = v[:num_out_l] + v[n-num_out_r:]
		out.sort()
		ret_value = 0
		for ret_v in out[:num_ret]:
			if ret_v < 0:
				ret_value += ret_v
			else:
				break
		val = sum(out) - ret_value
		if val > mx:
			mx = val
			
print(mx)