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

Fixed submission:
import fractions
import math
ans=1
a,b=map(int, input().split())
c=fractions.gcd(a,b)
d = []
for i in range(1, int(c**0.5)+1):
    if a % i == 0 and b % i == 0:
        d.append(i)
        if i != c // i :
            d.append(c//i)
def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True
for i in d:
    if is_prime(i):
        ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
import math
ans=1
a,b=map(int, input().split())
c=math.gcd(a,b)
d = []
for i in range(1, int(c**0.5)+1):
    if a % i == 0 and b % i == 0:
        d.append(i)
        if i != c // i :
            d.append(c//i)
def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True
for i in d:
    if is_prime(i):
        ans+=1
print(ans)
Problem p02923 (python)

Fixed submission:
n=int(input())
a=list(map(int, input().split()))
b=[0]*n
j=0
for i in range(n-1):
    if a[i]>=a[i+1]:
        b[j]+=1
    else:
        j+=1
b.sort(reverse=True)
print(b[0])

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int, input().split()))
b=[0]*(n-1)
j=0
for i in range(n-1):
    if a[i]>=a[i+1]:
        b[j]+=1
    else:
        j+=1
b.sort()
b.reverse()
print(b[0])

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int, input().split()))
b=[0]*(n-1)
j=0
for i in range(n-1):
    if a[i]>=a[i+1]:
        b[j]+=1
    else:
        j+=1
b.sort()
b.reverse()
print(b[0])

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int, input().split()))
b=[0]*(n-1)
j=0
for i in range(n-1):
    if a[i]>=a[i+1]:
        b[j]+=1
    else:
        j+=1
b.sort()
b.reverse()
print(b[0])
Problem p02945 (python)

Fixed submission:
a,b=map(int, input().split())
print(max(a+b,a-b,a*b))

Buggy submission (verdict: Runtime Error):
import heapq
n,m=map(int, input().split())
s = [list(map(int, input().split())) for i in range(n)]
q = []
ans=0
#ヒープソート
heapq.heapify(s)
for k in range(m-1,-1,-1):
    while True:
        if s!=[]:
            #最小値を返す
            p=heapq.heappop(s)
            if p[0]+k<=m:
                #heappush(list,item) listの葉にitemを追加して小さい要素を上に持ち上げる
                heapq.heappush(q,-p[1])
            else:
                heapq.heappush(s,p)
                break
        else:
            break
        if q!=[]:
            #最小値をヒープから取り出す
            p=heapq.heappop(q)
            ans+=-p
print(ans)

Buggy submission (verdict: Runtime Error):
import heapq
n,m=map(int, input().split())
s = [list(map(int, input().split())) for i in range(n)]
q = []
ans=0

for k in range(m-1,-1,-1):
    while True:
        if s!=[]:
            #最小値を返す
            p=heapq.heappop(s)
            if p[0]+k<=m:
                #heappush(list,item) listの葉にitemを追加して小さい要素を上に持ち上げる
                heapq.heappush(q,-p[1])
            else:
                heapq.heappush(s,p)
                break
        else:
            break
        if q!=[]:
            #最小値をヒープから取り出す
            p=heapq.heappop(q)
            ans+=-p
print(ans)

Buggy submission (verdict: Runtime Error):
import heapq
n,m=map(int, input().split())
s = [list(map(int, input().split())) for i in range(n)]
q = []
ans=0
#ヒープソート
heapq.heapify(s)
heapq.heapify(q)
for k in range(m-2,-1,-1):
    if s!=[]:
        #最小値を返す
        p=heapq.heappop(s)
        if p[0]+k<=m:
            #heappush(list,item) listの葉にitemを追加して小さい要素を上に持ち上げる
            heapq.heappush(q,-p[1])
        else:
            heapq.heappush(s,p)
            break
    else:
        break
    if q!=[]:
        #最小値をヒープから取り出す
        p=heapq.heappop(q)
        ans+=-p
print(ans)

Buggy submission (verdict: Runtime Error):
import heapq
n,m=map(int, input().split())
s = [list(map(int, input().split())) for i in range(n)]
q = []
ans=0
#ヒープソート
heapq.heapify(s)
for k in range(m-2,-1,-1):
    if s!=[]:
        #最小値を返す
        p=heapq.heappop(s)
        if p[0]+k<=m:
            #heappush(list,item) listの葉にitemを追加して小さい要素を上に持ち上げる
            heapq.heappush(q,-p[1])
        else:
            heapq.heappush(s,p)
            break
    else:
        break
    if q!=[]:
        #最小値をヒープから取り出す
        p=heapq.heappop(q)
        ans+=-p
print(ans)
Problem p02947 (python)

Fixed submission:
N=int(input())
l=[]
for x in range(0,N):
    l.append(input())
for x in range(N):
    k=list(l[x])
    k.sort()
    k=''.join(k)
    l[x]=k
l.sort()
k=1
ans=0
for i in range(N-1):
    if l[i]==l[i+1]:
        k+=1
    else:
        ans+=k*(k-1)//2
        k=1
ans+=k*(k-1)//2
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
l=[]
for x in range(0,N):
    l.append(input())
for x in range(0,N):
    l[x]=sorted(list(l[x]))
l=sorted[l]
x=0
y=0
for i in range(0,N):
    for j in range(i+1,N):
        if l[i]==l[j]:
            x=x+1
        else:
            y=y+sum(range(1,x+1))
            i=i+x+1
            break
print(y)
Problem p02953 (python)

Fixed submission:
N = int(input())
A=list(map(int,input().split()))
ask=0
#N-1~1までループ
for x in range(N-1,0,-1):
    if A[x]-A[x-1]<0:
        A[x-1]=A[x-1]-1
for x in range(1,N):
    if A[x]-A[x-1]<0:
        ask=1
        break
if ask==0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
A=list(map(int,input().split()))
i=0
ask=0
for x in A:
    if A[x+1]-A[x]<0:
        A[x]=A[x]-1
for x in A:
    if A[x]<0:
        ask=1
        break
if ask==0:
    print('Yes')
else:
    print('No')
Problem p02975 (python)

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

if n%3==0:
    for j in range(3):
        for i in range(j*(n//3),(j+1)*(n//3)-1):
            if a[i]!=a[i+1]:
                print("No")
                exit()
    if a[0]^a[n//3]==a[2*n//3]:
        print("Yes")
    else:
        print("No")
    exit()
for i in range(0,n-1):
    if a[i]!=a[i+1]:
        print("No")
        exit()
print("Yes")

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

if n%3==0:
    for j in range(3):
        for i in range(j*(n//3),(j+1)*(n//3)-1):
            if a[i]!=a[i+1]:
                print("No")
                exit()
    if x[0]^x[n//3]==x[2*n//3]:
        print("Yes")
    else:
        print("No")
    exit()
for i in range(0,n-1):
    if a[i]!=a[i+1]:
        print("No")
        exit()
print("Yes")
Problem p02999 (python)

Fixed submission:
x,a=map(int, input().split())
if x<a:
    print(0)
else:
    print(10)

Buggy submission (verdict: Runtime Error):
n,k=map(int, input().split())
a=list(map(int, input().split()))
ans=0
s=0
j=0
#尺取り法（未満）
for i in range(n):
    #どこまでいけるか
    while(j<n and s+a[j]<k):
        s+=a[j]
        j+=1
    #ずらす
    ans+=j-i
    s-=a[i]
print(n*(n+1)//2-ans)
Problem p03032 (python)

Fixed submission:
n,k=map(int,input().split())
v=list(map(int,input().split()))
def get(t,s): # t個のうち前からs個
    return sorted(v[:s]+v[n-(t-s):])

def f(t):
    res=0
    for i in range(t+1):
        a=get(min(t,n),min(i,n))
        tmp=sum(a)
        res=max(res,tmp)
        for j in range(min(k-t,t,n)):
            tmp-=a[j]
            res=max(res,tmp)
    return res

ans=0
for i in range(1,k+1):
    ans=max(ans,f(i))
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
v=list(map(int,input().split()))
def get(t,s): # t個のうち前からs個
    return sorted(v[:s]+v[n-(t-s):])

def f(t):
    res=0
    for i in range(t+1):
        a=get(min(t,n),min(i,n))
        tmp=sum(a)
        res=max(res,tmp)
        for j in range(min(k-t,t)):
            tmp-=a[j]
            res=max(res,tmp)
    return res

ans=0
for i in range(1,k+1):
    ans=max(ans,f(i))
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
v=list(map(int,input().split()))
def get(t,s): # t個のうち前からs個
    return sorted(v[:s]+v[n-(t-s):])

def f(t):
    res=0
    for i in range(t+1):
        if 2*t-k>=0:
            if i>n:
                a=get(t,n)
            else:
                a=get(t,i)
            tmp=sum(a)
            for j in range(min(k-t,t)):
                tmp-=a[j]
                res=max(res,tmp)
    return res

ans=0
for i in range(1,k+1):
    ans=max(ans,f(i))
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
v=list(map(int,input().split()))
def get(t,s): # t個のうち前からs個
    return sorted(v[:s]+v[n-(t-s):])

def f(t):
    res=0
    for i in range(t+1):
        if 2*t-k>=0:
            a=get(t,i)
            tmp=sum(a)
            for j in range(k-t):
                tmp-=a[j]
                res=max(res,tmp)
    return res

ans=0
for i in range(1,k+1):
    ans=max(ans,f(i))
print(ans)
Problem p03049 (python)

Fixed submission:
n=int(input())
ba,a,b,ab=0,0,0,0
for i in range(n):
    s=input()
    if s[0]=='B' and s[-1]=='A':
        ba+=1
    elif s[0]=='B':
        b+=1
    elif s[-1]=='A':
        a+=1
    for i in range(len(s)-1):
        if s[i]=='A' and s[i+1]=='B':
            ab+=1
if a==b and a==0 and ba!=0:
	ba-=1
print(min(a,b)+ba+ab)

Buggy submission (verdict: Runtime Error):
n=int(input())
ba,a,b,ab=0,0,0,0
for i in range(n):
    s=input()
    if s[0]=='B' and s[-1]=='A':
        ba+=1
    elif s[0]=='B':
        b+=1
    elif s[-1]=='A':
        a+=1
    for i in range(len(s)-1):
        if s[i]=='A' and s[i+1]=='B':
            ab+=1

print(min(a,b)+x+ab)
Problem p03150 (python)

Fixed submission:
s=input()
key="keyence"
n=len(s)
for i in range(n-1):
    for j in range(1,n):
        if s[:i]+s[j:]==key:
            print("YES")
            exit()
print("NO")

Buggy submission (verdict: Runtime Error):
s=input()
t="keyence"
k=0
for i in range(len(s)):
    if t[k]==s[i]:
        k+=1
if k==len(t):
    print("YES")
else:
    print("NO")
Problem p03160 (python)

Fixed submission:
n= int(input())
h= list(map(int, input().split()))
dp=[0]*n
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    dp[i]=min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2])
#print(dp)
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
"""
重さと価値がそれぞれw_i,v_iであるようなn個の品物がある.
これらの品物の中から, 重さの総和がWを超えないように選んだ時の,
価値の総和の最大値を求めよ.
1<=n<=100, 1<=w_i<=10^7, 1<=v_i<=100, 1<=limit_w<=10^9
"""
#-------------------------------------------------------------------------------

#入力
INF = 2000000000
"""
メモ : Pythonでは無限大を表す float('inf') があるが, 処理がかなり重たいので
       代わりにsum(v)より真に大きい 2*10^9 を INFとする.
       (https://atcoder.jp/contests/dp/tasks/dp_e において,PyPyを使用して,
        前者だと1060ms, 後者だと570msで2倍近く差が出ている.)
"""
n ,limit_w = map(int, input().split())
w = [0]*n
v = [0]*n
for i in range(n):
    w[i], v[i] = map(int, input().split())
sum_v = sum(v)
dp = [[INF for i in range(sum_v + 1)] for j in range(n + 1)] 
# dp[i][j]には重さが入る.
# dp[i][j]=(i番目までの品物から価値がちょうどｊになるための重さの最小値)

# ここからメイン
dp[0][0] = 0
for i in range(n):
    for j in range(sum_v + 1):
        if j < v[i]:
            dp[i + 1][j] = dp[i][j]
        else:
            dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i])
            
# n個まで使って,重さがlimit_wを超えないで価値が最大のものを求める.
ans = 0
for i in range(sum_v + 1):
    if dp[n][i] <= limit_w:
        ans = i
print(ans)
Problem p03161 (python)

Fixed submission:
n,k= map(int, input().split())
h= list(map(int, input().split()))
dp=[2000000000]*n
dp[0]=0
for i in range(1,min(n,k+1)):
    for j in range(0,i):
        dp[i]=min(abs(h[i]-h[0])+dp[j],dp[i])
if n>k:
    for i in range(k+1,n):
        for j in range(1,k+1):
            dp[i]=min(abs(h[i]-h[i-j])+dp[i-j],dp[i])
#print(dp)
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
n,k= map(int, input().split())
h= list(map(int, input().split()))
dp=[2000000000]*n
dp[0]=0
for i in range(1,k+1):
    for j in range(0,i):
        dp[i]=min(abs(h[i]-h[0])+dp[j],dp[i])
for i in range(k+1,n):
    for j in range(1,k+1):
        dp[i]=min(abs(h[i]-h[i-j])+dp[i-j],dp[i])
#print(dp)
print(dp[n-1])
Problem p03162 (python)

Fixed submission:
n=int(input())
a,b,c=map(int,input().split())
dp=[[a,b,c] for i in range(n)]
for i in range(1,n):
  a,b,c=map(int,input().split())
  dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a
  dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b
  dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c
print(max(dp[n-1]))

Buggy submission (verdict: Runtime Error):
n=int(input())
a,b,c=map(int,input().split())
dp=[[a,b,c] for i in range(n)]
for i in range(1,n):
  a,b,c=map(int,input().split()¥
  dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a
  dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b
  dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c
print(max(dp[n-1]))
Problem p03165 (python)

Fixed submission:
s=input()
t=input()
n=len(s)
m=len(t)
dp=[[0 for i in range(m+1)] for j in range(n+1)]
for i in range(n):
    for j in range(m):
        if s[i]==t[j]:
            dp[i+1][j+1]=dp[i][j]+1
        else:
            dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j])
ans = ''
while(dp[n][m]>0):
  if dp[n][m] == dp[n-1][m-1] +1 and dp[n][m] == dp[n-1][m] +1 and dp[n][m] == dp[n][m-1] +1:
    ans = ''.join([s[n-1],ans])
    n -= 1
    m -= 1
  elif dp[n-1][m] > dp[n][m-1]:
    n -= 1
  else:
    m -= 1
print(ans)

Buggy submission (verdict: Runtime Error):
def longest_common_subsequence(S, T):
    LS = len(S); LT = len(T)
    dp = [[0] * (LT + 1) for _ in range(LS + 1)]
    for i, s in enumerate(S):
        for j, t in enumerate(T):
            if s == t:
                dp[i + 1][j + 1] = dp[i][j] + 1
            else:
                dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j])
    return dp
    

def reconstruct_LCS(S, T, dp):
    tmp = []
    i, j = len(S), len(T)
    while i and j:
        if S[i - 1] == T[j - 1]:
            i, j = i - 1, j - 1
            tmp.append(S[i])
        elif dp[i][j] == dp[i - 1][j]:
            i -= 1
        else:
            j -= 1
    return ''.join(reversed(tmp))


s,t=input(), input()
print(reconstruct_LCS(s, t, LCS(s, t)))

Buggy submission (verdict: Runtime Error):
s=input()
t=input()
n=len(s)
m=len(t)
dp=[[0 for i in range(m+1)] for j in range(n+1)]
​
​
#メイン
​
#dp[i][j]:=s_1~s_iとt_1~t_jに対するLCSの長さ
for i in range(n):
    for j in range(m):
        if s[i]==t[j]:
            dp[i+1][j+1]=dp[i][j]+1 #同じならくっつけられる
        else:
            dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j])
#print(dp[n][m])
#dpを逆からたどって文字列を復元
ans = ''
while(dp[n][m]>0):
  if dp[n][m] == dp[n-1][m-1] +1 and dp[n][m] == dp[n-1][m] +1 and dp[n][m] == dp[n][m-1] +1:
    ans += s[n-1]
    n -= 1
    m -= 1
  elif dp[n-1][m] > dp[n][m-1]:
    n -= 1
  else:
    m -= 1
print(''.join(reversed(list(ans))))
Problem p03176 (python)

Fixed submission:
# dp[i][j]=(i番目まで使って最後の高さがjであるようなものの美しさの最大値)
# dp[i][j]=max(dp[i-1][k])+a[i](h[i]==j,0<=k<j),dp[i-1][j](otherwise)

def segfunc(x,y):
    return max(x,y)


def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]    
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
    
def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res


N=int(input())
h=list(map(int,input().split()))
a=list(map(int,input().split()))
n=N+1
#####単位元######
ide_ele = 0 #変える
num =2**(n-1).bit_length()
seg=[ide_ele]*2*num
dp=[0]*n
init(dp)
for i in range(N):
    update(h[i],query(0,h[i])+a[i])
print(query(0,n))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
INF=10**9
d=[[INF]*n for i in range(n)]
for i in range(n):
    d[i][i]=0
for i in range(m):
    a,b=map(int,input().split())
    d[a-1][b-1]=1
    d[b-1][a-1]=1
for i in range(n):
    for j in range(n):
        for k in range(n):
            d[i][j]=min(d[i][j],d[i][k]+d[k][j])
for i in d:
    print(i.count(2))
Problem p03178 (python)

Fixed submission:
s,d=input(),int(input())
n=[int(i) for i in s]
l=len(s)
mod=10**9+7
dp=[[[0]*d,[0]*d] for i in range(l+1)]
dp[0][0][0]=1
for i in range(l):
    for smaller in range(2):
        for j in range(d):
            for x in range(10 if smaller else n[i]+1):
                dp[i+1][smaller or x<n[i]][(j+x)%d] += dp[i][smaller][j]
                dp[i+1][smaller or x<n[i]][(j+x)%d]%=mod
print((dp[l][0][0]+dp[l][1][0]-1)%mod)

Buggy submission (verdict: Runtime Error):
s,d=int(input()),input()
n=[int(i) for i in s]
l=len(s)
mod=10**9+7
dp=[[[0]*d,[0]*d] for i in range(l+1)]
dp[0][0][0]=1
for i in range(l):
    for smaller in range(2):
        for j in range(d):
            for x in range(10 if smaller else n[i]+1):
                dp[i+1][smaller or x<n[i]][(j+x)%d] += dp[i][smaller][j]
                dp[i+1][smaller or x<n[i]][(j+x)%d]%=mod
print((dp[l][0][0]+dp[l][1][0]-1)%mod)
Problem p03213 (python)

Fixed submission:
from collections import defaultdict
import numpy as np
from itertools import permutations, combinations
n=int(input())
d=defaultdict(int)
def factorization(n):
    temp = n
    for i in range(2, int(n**0.5)+1):
        if temp%i==0:
            while temp%i==0:
                d[i]+=1
                temp //= i

    if temp!=1:
        d[temp]+=1
for i in range(2,n+1):
    factorization(i)
d=np.array(list(d.values()))
ans=0
ans+=len(d[d>=74])
d1=d[d>=2]
d2=d[d>=4]
for x,y in permutations(d1,2):
    if y>=24:
        ans+=1
for x,y in permutations(d2,2):
    if y>=14:
        ans+=1
ans1=0
for x,y,z in permutations(d1,3):
    if y>=4 and z>=4:
        ans1+=1
print(ans+ans1//2)

Buggy submission (verdict: Runtime Error):
import numpy as np
n=int(input())
d=[0]*101
def factorization(n):
    temp = n
    for i in range(2, int(n**0.5)+1):
        if temp%i==0:
            while temp%i==0:
                d[i]+=1
                temp //= i
    if temp!=1:
        d[temp]+=1
def cnt(k):
    return len(d[d>=k])
for i in range(2,n+1):
    factorization(i)
d=np.array(list(d.values()))
print(cnt(74)+cnt(24)*(cnt(2)-1)+cnt(14)*(cnt(4)-1)+cnt(4)*(cnt(4)-1)*(cnt(2)-2)//2)
Problem p03241 (python)

Fixed submission:
n,m=map(int,input().split())
d=[]
for i in range(1,int(m**0.5)+1):
  if m%i==0:
    d.append(i)
    d.append(m//i)
d.sort(reverse=True)
for i in d:
  if i*n<=m:
    print(i)
    exit()

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
d=[]
for i in range(1,int(m**0.5)+1):
  if m%i==0:
    d.append(i,m//i)
d.sort(reverse=True)
for i in d:
  if i*n<=m:
    print(i)
    exit()
Problem p03244 (python)

Fixed submission:
def list_count(my_list,n,x):
    dic={} #辞書型の宣言
    for i in range(x,n,2):
        if my_list[i] in dic: #もしnumがkeyとして辞書にあれば
            dic[my_list[i]]+=1 #valueに+1
        else: #なければ
            dic[my_list[i]]=1 #dicにnumというkeyを追加し、対応するvalueを1とする
    return dic

n=int(input())
v=list(map(int,input().split()))
dic0=list_count(v,n,0)
dic1=list_count(v,n,1)
a=[[0,0],[0,0]]
b=[[0,0],[0,0]]
for i in dic0.keys():
    if a[0][1]<=dic0[i]:
        a[1][0]=a[0][0]
        a[1][1]=a[0][1]
        a[0][0]=i
        a[0][1]=dic0[i]
    elif a[1][1]<dic0[i]:
        a[1][0]=i
        a[1][1]=dic0[i]
for i in dic1.keys():
    if b[0][1]<=dic1[i]:
        b[1][0]=b[0][0]
        b[1][1]=b[0][1]
        b[0][0]=i
        b[0][1]=dic1[i]
    elif b[1][1]<dic1[i]:
        b[1][0]=i
        b[1][1]=dic1[i]
if a[0][0]==b[0][0]:
    print(n-max(a[0][1]+b[1][1],a[1][1]+b[0][1]))
else:
    print(n-a[0][1]-b[0][1])

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(1000000000)
def list_count(my_list,n,x):
    dic={} #辞書型の宣言
    for i in range(x,n,2):
        if my_list[i] in dic: #もしnumがkeyとして辞書にあれば
            dic[my_list[i]]+=1 #valueに+1
        else: #なければ
            dic[my_list[i]]=1 #dicにnumというkeyを追加し、対応するvalueを1とする
    return dic

n=int(input())
v=list(map(int,input().split()))
dic0=list_count(v,n,0)
dic1=list_count(v,n,1)
a=[[0,0],[0,0]]
b=[[0,0],[0,0]]
for i in dic0.keys():
    if a[0][1]<=dic0[i]:
        a[1][0]=a[0][0]
        a[1][1]=a[0][1]
        a[0][0]=i
        a[0][1]=dic0[i]
    elif a[1][1]<dic0[1]:
        a[1][0]=i
        a[1][1]=dic0[i]
for i in dic1.keys():
    if b[0][1]<=dic1[i]:
        b[1][0]=b[0][0]
        b[1][1]=b[0][1]
        b[0][0]=i
        b[0][1]=dic1[i]
    elif b[1][1]<dic1[1]:
        b[1][0]=i
        b[1][1]=dic1[i]
if a[0][0]==b[0][0]:
    print(n-min(a[0][1]+b[1][1],a[1][1]+b[0][1]))
else:
    print(n-a[0][1]-b[0][1])

Buggy submission (verdict: Runtime Error):
def list_count(my_list,n,x):
    dic={} #辞書型の宣言
    for i in range(x,n,2):
        if my_list[i] in dic: #もしnumがkeyとして辞書にあれば
            dic[my_list[i]]+=1 #valueに+1
        else: #なければ
            dic[my_list[i]]=1 #dicにnumというkeyを追加し、対応するvalueを1とする
    return dic

n=int(input())
v=list(map(int,input().split()))
dic0=list_count(v,n,0)
dic1=list_count(v,n,1)
a=[[0,0],[0,0]]
b=[[0,0],[0,0]]
for i in dic0.keys():
    if a[0][1]<=dic0[i]:
        a[1][0]=a[0][0]
        a[1][1]=a[0][1]
        a[0][0]=i
        a[0][1]=dic0[i]
    elif a[1][1]<dic0[1]:
        a[1][0]=i
        a[1][1]=dic0[i]
for i in dic1.keys():
    if b[0][1]<=dic1[i]:
        b[1][0]=b[0][0]
        b[1][1]=b[0][1]
        b[0][0]=i
        b[0][1]=dic1[i]
    elif b[1][1]<dic1[1]:
        b[1][0]=i
        b[1][1]=dic1[i]
if a[0][0]==b[0][0]:
    print(n-min(a[0][1]+b[1][1],a[1][1]+b[0][1]))
else:
    print(n-a[0][1]-b[0][1])
Problem p03274 (python)

Fixed submission:
n,k= map(int, input().split())
x= list(map(int, input().split()))
s=0
cnt=0
while x[s]<0:
    s+=1
    if n==s+1:
        break
a=[]
if x[s]>=0:
    for i in range(s,min(s+k,n)):
        cnt+=1
        if i-k-1>=0:
            a.append(2*x[i]-x[i-k+1])
        if cnt==k:
            a.append(x[i])
    s-=1
cnt=0
for i in range(s,max(s-k,-1),-1):
    cnt+=1
    if i+k-1<n:
        a.append(-2*x[i]+x[i+k-1])
    if cnt==k:
        a.append(-x[i])
print(min(a))

Buggy submission (verdict: Runtime Error):
n,k= map(int, input().split())
x= list(map(int, input().split()))
s=0
cnt=0
while x[s]<0:
    s+=1
a=[]
for i in range(s,min(s+k,n)):
    cnt+=1
    if i-k-1>=0:
        a.append(2*x[i]-x[i-k+1])
    if cnt==k:
        a.append(x[i])
s-=1
cnt=0
for i in range(s,max(s-k,-1),-1):
    cnt+=1
    if i+k-1<n:
        a.append(-2*x[i]+x[i+k-1])
    if cnt==k:
        a.append(-x[i])
print(min(a))
Problem p03282 (python)

Fixed submission:
s=input()
k=int(input())
i=0
while True:
  if i<len(s) and s[i]=='1':
    i+=1
  else:
    break
if i==0:
  print(s[0])
  exit()
if i<k:
  print(s[i])
else:
  print(s[0])

Buggy submission (verdict: Runtime Error):
s=input()
k=int(input())
i=0
while True:
  if s[i]=='1' and i<len(s):
    i+=1
  else:
    break
if i<k-1 and len(s)>=2:
  print(s[1])
else:
  print(s[0])

Buggy submission (verdict: Runtime Error):
s=input()
k=int(input())
i=0
while True:
  if s[i]=='1' and i<len(s):
    i+=1
  else:
    break
if i<k-1:
  print(s[1])
else:
  print(1)

Buggy submission (verdict: Runtime Error):
s=input()
k=int(input())
i=0
while True:
  if s[i]=='1' or i<len(s):
    i+=1
  else:
    break
if i<k-1:
  print(s[1])
else:
  print(1)

Buggy submission (verdict: Runtime Error):
s=input()
k=int(input())-1
i=0
while True:
  if s[i]=='1':
    i+=1
  else:
    break
if i<k:
  print(s[1])
else:
  print(1)
Problem p03285 (python)

Fixed submission:
n=int(input())
for i in range(15):
  for j in range(26):
    if i*7+j*4==n:
      print('Yes')
      exit()
print('No')

Buggy submission (verdict: Runtime Error):
n=int(input())
for i in range(15):
  for j in range(26):
    if i*7+j*4=n:
      print('Yes')
      exit()
print('No')
Problem p03316 (python)

Fixed submission:
n=int(input())
m=list(str(n))
s=0
for i in range(len(m)):
  s+=int(m[i])
if n%s==0:
      print('Yes')
      exit()
print("No")

Buggy submission (verdict: Runtime Error):
n=int(input())
m=sum(map(int,list(str(n)))
if n%m==0:
      print('Yes')
      exit()
print("No")

Buggy submission (verdict: Runtime Error):
n=int(input())
m=sum(list(map(int,str(n)))
if n%m==0:
      print('Yes')
      exit()
print("No")