Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
s = input(input())
A = list(map(int, input().split()))

a_1 = A[0] / s
b_1 = A[1] / s

if b_1 - a_1 > 1 :
    print('OK')
else :
    print('NG')

Fixed submission:
import math as M
k = int(input())
a, b = map(int, input().split())

a_1 = M.floor(a/k)
b_1 = M.floor(b/k)

if a%k == 0 or b%k == 0:
    print('OK')
elif b_1 - a_1 < 1:
    print('NG')

else :
    print('OK')

Buggy python submission (verdict: Runtime Error):
s = input(input())
a, b = map(int, input().split())

a_1 = a / s
b_1 = b / s

if b_1 - a_1 > 1 :
    print('OK')
else :
    print('NG')

Fixed submission:
import math as M
k = int(input())
a, b = map(int, input().split())

a_1 = M.floor(a/k)
b_1 = M.floor(b/k)

if a%k == 0 or b%k == 0:
    print('OK')
elif b_1 - a_1 < 1:
    print('NG')

else :
    print('OK')

Buggy python submission (verdict: Runtime Error):
s = input(input())
a, b = map(int, input())

a_1 = a / s
b_1 = b / s

if b_1 - a_1 > 1 :
    print('OK')
else :
    print('NG')

Fixed submission:
import math as M
k = int(input())
a, b = map(int, input().split())

a_1 = M.floor(a/k)
b_1 = M.floor(b/k)

if a%k == 0 or b%k == 0:
    print('OK')
elif b_1 - a_1 < 1:
    print('NG')

else :
    print('OK')
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
cnt = 0

while tp < b:
    tp += (a-1)
    cnt += 1

print(cnt)

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

t = 1
cnt = 0

while  t<b:
    t += (a-1)
    cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
n = list(range(1, int(input())))

print(sum(n))

Fixed submission:
n = int(input())
print((n-1)*n//2)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

ans=0
for i in range(n-1):
    ans += (i+1)
print(ans)

Fixed submission:
n = int(input())
print((n-1)*n//2)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
 
c = a * b
 
if c%2 == 1	:
  priint('Odd')
else :
  print('Even')

Fixed submission:
a, b = map(int, input().split())
 
c = a * b
 
if c%2 == 1	:
  print('Odd')
else :
  print('Even')

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

c = a + b

if c%2 == 1	:
  priint('Odd')
else :
  print('Even')




Fixed submission:
a, b = map(int, input().split())
 
c = a * b
 
if c%2 == 1	:
  print('Odd')
else :
  print('Even')

Buggy python submission (verdict: Runtime Error):
a, b = input().split()

c = a * b 

if c % 2 == 1 :
  print('Odd')
 
else :
  print('Even')



Fixed submission:
a, b = map(int, input().split())
 
c = a * b
 
if c%2 == 1	:
  print('Odd')
else :
  print('Even')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))

b = 1
n = 0
move = []

while True :
    move.append(b)
    b = a[b - 1]
    n += 1
    if b == 2 :
        print(n)
        exit(0)
    if b in move :
        print(-1)
        exit(0)

Fixed submission:
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))

b = 1
s = 0
move = []

while True :
    move.append(b)
    b = a[b - 1]
    s += 1
    if b == 2 :
        print(s)
        exit(0)
    if n < s :
        print(-1)
        exit(0)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

ans = 1

for i in range(1, n+1):
    ans *= i
ans %= 1000000007

print(ans)

Fixed submission:
n = int(input())

ans = 1

for i in range(1, n+1):
    ans *= i
    ans %= 1000000007

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
k,s = map(int, input().split())
cnt = 0

for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x+y+z == s :
                cnt += 1

print(cnt)


Fixed submission:
k,s = map(int, input().split())
cnt = 0

for x in range(k+1):
    for y in range(k+1):
        if 0 <= s-(x+y) <= k:
            cnt += 1




print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    h,w,m=map(int,input().split())
    target=[tuple(map(int,input().split())) for i in range(m)]
    lines=[0]*w
    rows=[0]*h
    for th,tw in target:
        lines[tw-1]+=1
        rows[th-1]+=1
    max_lines=max(lines)
    max_rows=max(rows)
    max_wi=[i for i,wi in enumerate(lines) if wi==max_lines]
    max_hi=[i for i,hi in enumerate(rows) if hi==max_rows]
    flag=[]
    for wi in max_wi:
        for hi in max_hi:
            if (hi+1,wi+1) in target:
                flag.append(-1)
            else:
                flag.append(0)
    # print(max_rows,max_hi,max_lines,max_wi,flag)
    ans=max_lines+max_rows+max(flag)
    return ans

if __name__=='__main__':
    ans=main()
    print(ans)


Fixed submission:
def main():
    h,w,m=map(int,input().split())
    target=set()
    for i in range(m):
        th,tw=map(int,input().split())
        target.add((th-1,tw-1))
    lines=[0]*w
    rows=[0]*h
    for th,tw in target:
        lines[tw]+=1
        rows[th]+=1
    max_lines=max(lines)
    max_rows=max(rows)
    max_wi=[i for i,wi in enumerate(lines) if wi==max_lines]
    max_hi=[i for i,hi in enumerate(rows) if hi==max_rows]
    # print('rows\t',max_rows,max_hi,'\nlines\t',max_lines,max_wi)
    ans=max_lines+max_rows-1
    isLoop=True
    for wi in max_wi:
        if isLoop:
            for hi in max_hi:
                if not (hi,wi) in target:
                    ans+=1
                    isLoop=False
                    break
    return ans

if __name__=='__main__':
    ans=main()
    print(ans)
Buggy python submission (verdict: Runtime Error):
h,w,k=map(int,input().split())
c=''
for i in range(h):
    c+=input()
# print(c)
# row_dot_cnt=[c.count() for _ in range(h)]
# col_dot_cnt=[0]*w
ans=0
for i in range(2**h): # 行
    i_bin=format(i,'06b')
    for j in range(2**w): # 列
        j_bin=format(j,'06b')
        cnt=0
        # print(i_bin,j_bin)
        for s in range(h):
            if i_bin[5-s]=='0':
                for t in range(w):
                    if j_bin[5-t]=='0' and c[s*h+t]=='#':
                        # print(s,t)
                        cnt+=1
        if cnt==k:
            ans+=1
            # print(f'        {cnt}   {ans}')
print(ans)


Fixed submission:
h,w,k=map(int,input().split())
c=''
for i in range(h):
    c+=input()
# print(c)
# row_dot_cnt=[c.count() for _ in range(h)]
# col_dot_cnt=[0]*w
ans=0
for i in range(2**h): # 行
    i_bin=format(i,'06b')
    for j in range(2**w): # 列
        j_bin=format(j,'06b')
        cnt=0
        # print(i_bin,j_bin)
        for s in range(h):
            if i_bin[5-s]=='0':
                for t in range(w):
                    if j_bin[5-t]=='0' and c[s*w+t]=='#':
                        # print(s,t)
                        cnt+=1
        if cnt==k:
            ans+=1
            # print(f'        {cnt}   {ans}')
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
q=int(input())
bc=[tuple(map(int,input().split())) for _ in range(q)]
d={}
for ai in a:
    if ai not in d:
        d[ai]=0
    d[ai]+=1
# print(d)
for bi,ci in bc:
    if bi in d:
        tmp=d[bi]
        d[bi]=0
        if ci not in d:
            d[ci]=0
        d[ci]+=tmp
    ans=0
    for key in d:
        ans+=key*d[key]
    print(ans)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
q=int(input())
bc=[tuple(map(int,input().split())) for _ in range(q)]
d={}
for ai in a:
    if ai not in d:
        d[ai]=0
    d[ai]+=1
# print(d)

ans=0
for key in d:
    ans+=key*d[key]

for bi,ci in bc:
    if bi in d:
        tmp=d[bi]
        d[bi]=0
        ans-=bi*tmp
        if ci not in d:
            d[ci]=0
        d[ci]+=tmp
        ans+=ci*tmp
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from math import gcd as bltin_gcd
def coprime(a, b):
    return bltin_gcd(a, b) == 1

n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
    cnt=0
    for j in range(n):
        if i!=j:
            if a[i]%a[j]==0:
                cnt+=1
    if cnt==0:
        ans+=1
print(ans)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a.sort()
aMax=a[-1]
isAns=[0]*(aMax+1) ## 1=ans 2=multiple or plural
for ai in a:
    isAns[ai]+=1
    if isAns[ai]==1:
      for j in range(2*ai,aMax+1,ai):
        isAns[j]+=2

print(isAns.count(1))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
aSet=list(set(a))
if n%3!=0:
    if len(aSet)==1 and aSet[0]=0:
        print('Yes')
    else:
        print('No')
else:
    if len(aSet)==3:
        if (aSet[0]^aSet[1])==aSet[2]:
            print('Yes')
    elif len(aSet)<3:
        if 0 in aSet:
            print('Yes')
    else:
        print('No')


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
aDict={}
for key in set(a):
    aDict[key]=0
for ai in a:
    aDict[ai]+=1

canPuton=False
if len(aDict)==1:
    if 0 in aDict.keys():
        canPuton=True

elif len(aDict)==2:
    if 0 in aDict.keys():
        if n%3==0:
            canPuton=True
            for key in aDict:
                if key==0:
                    if aDict[key]!=n//3:
                        canPuton=False
                else:
                    if aDict[key]!=2*n//3:
                        canPuton=False

elif len(aDict)==3:
    a,b,c=aDict.keys()
    if n%3==0:
        if (a^b)==c:
            canPuton=True
            for key in aDict.keys():
                if aDict[key]!=n//3:
                    canPuton=False
if canPuton:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n=int(input())
a=list(map(int,input().split()))
sign=[1 if i%2==0 else -1 for i in range(n)]
a=np.array(a)
sign=np.array(sign)
plusA=a*sign
minusA=a*sign*-1
# print(plusA,minusA)
for i in range(n):
    if i%2==0:
        # print(minusA[:i],plusA[i:])
        print(np.sum(minusA[:i])+np.sum(plusA[i:]),end=' ')
    else:
        # print(plusA[:i],minusA[i:])
        print(np.sum(plusA[:i])+np.sum(minusA[i:]),end=' ')


Fixed submission:
import numpy as np
n=int(input())
a=list(map(int,input().split()))
sign=[1 if i%2==0 else -1 for i in range(n)]
a=np.array(a)
sign=np.array(sign)
plusA=a*sign
# minusA=a*sign*-1
ruisekiPlusA=[0 for i in range(n+1)]
for i in range(1,n+1):
    ruisekiPlusA[i]=ruisekiPlusA[i-1]+plusA[i-1]

# print(plusA,minusA)
for i in range(n):
    if i%2==0:
        # print(minusA[:i],plusA[i:])
        # print(np.sum(minusA[:i])+np.sum(plusA[i:]),end=' ')
        print(ruisekiPlusA[n]-2*ruisekiPlusA[i],end=' ')
    else:
        # print(plusA[:i],minusA[i:])
        # print(np.sum(plusA[:i])+np.sum(minusA[i:]),end=' ')
        print(2*ruisekiPlusA[i]-ruisekiPlusA[n],end=' ')

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n=int(input())
a=list(map(int,input().split()))
sign=[(-1)**i for i in range(n)]
ans=[0 for i in range(n)]
for i in range(n):
    tmp=0
    for j in range(n):
        tmp+=a[(i+j)%n]*sign[j]
    ans[i]=tmp
for ai in ans:
    print(ai, end=' ')


Fixed submission:
import numpy as np
n=int(input())
a=list(map(int,input().split()))
sign=[1 if i%2==0 else -1 for i in range(n)]
a=np.array(a)
sign=np.array(sign)
plusA=a*sign
# minusA=a*sign*-1
ruisekiPlusA=[0 for i in range(n+1)]
for i in range(1,n+1):
    ruisekiPlusA[i]=ruisekiPlusA[i-1]+plusA[i-1]

# print(plusA,minusA)
for i in range(n):
    if i%2==0:
        # print(minusA[:i],plusA[i:])
        # print(np.sum(minusA[:i])+np.sum(plusA[i:]),end=' ')
        print(ruisekiPlusA[n]-2*ruisekiPlusA[i],end=' ')
    else:
        # print(plusA[:i],minusA[i:])
        # print(np.sum(plusA[:i])+np.sum(minusA[i:]),end=' ')
        print(2*ruisekiPlusA[i]-ruisekiPlusA[n],end=' ')
Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d=map(int,input().split())
a-=1
bIka=b-b//c-b//d+b//(c*d//math.gcd(c,d))
aMiman=a-a//c-a//d+a//(c*d//math.gcd(c,d))
print(bIka-aMiman)

Fixed submission:
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
a,b,c,d=map(int,input().split())
a-=1
bIka=b-b//c-b//d+b//(c*d//gcd(c,d))
aMiman=a-a//c-a//d+a//(c*d//gcd(c,d))
print(bIka-aMiman)

Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d=map(int,input().split())
a-=1
bIka=b-b//c-b//d+b//(c*d//math.gcd(c,d))
aMiman=a-a//c-a//d+a//(c*d//math.gcd(c,d))
print(bIka-aMiman)

Fixed submission:
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
a,b,c,d=map(int,input().split())
a-=1
bIka=b-b//c-b//d+b//(c*d//gcd(c,d))
aMiman=a-a//c-a//d+a//(c*d//gcd(c,d))
print(bIka-aMiman)
Buggy python submission (verdict: Runtime Error):
# 何本の数直線上にあるかを求める　1<=ans<=n-1
# 少なくとも2点を通る直線のみ調べれば良い
n=int(input())
xy=[list(map(int,input().split())) for _ in range(n)]
xy.sort(key=lambda x:(x[0],x[1]))
# print(xy)
if n<=2:
    print(1)
else:
    diff=[]
    for i in range(n):
        for j in range(i):
            diff.append((xy[i][0]-xy[j][0],xy[i][1]-xy[j][1]))

    ans=[]
    # print(set(diff))
    for p,q in set(diff):
        intercept=[]
        for i in range(n):
            qxHIKUpy=q*xy[i][0]-p*xy[i][1]
            intercept.append(qxHIKUpy)
        # print(q,'x-',p,'y=',intercept)
        intercepts=sorted(enumerate(intercept),key=lambda x:x[1])
        intercept=set(intercept)
        # print(intercepts)
        i=0
        cnt=len(intercept)
        for b in intercept:
            x=0
            if intercepts[i][1]==b:
                x=xy[intercepts[i][0]][0]
            i+=1
            while intercepts[i][1]==b:
                if x+p!=xy[intercepts[i][0]][0]:
                    cnt+=1
                x=xy[intercepts[i][0]][0]
                i+=1
                if i==n:
                    break

        ans.append(cnt)
    # print(ans)
    print(min(ans))


Fixed submission:
n=int(input())
xy=[list(map(int,input().split())) for _ in range(n)]
xy.sort(key=lambda x:(x[0],x[1]))
# print(xy)
if n<=2:
    print(1)
else:
    diff=[]
    for i in range(n):
        for j in range(i):
            diff.append((xy[i][0]-xy[j][0],xy[i][1]-xy[j][1]))

    ans=[]
    # print(set(diff))
    for p,q in set(diff):
        cnt=n
        for i in range(n):
            for j in range(i):
                if xy[i][0]-xy[j][0]==p and xy[i][1]-xy[j][1]==q:
                    cnt-=1
        ans.append(cnt)
    print(min(ans))

Buggy python submission (verdict: Runtime Error):
# 何本の数直線上にあるかを求める　1<=ans<=n-1
n=int(input())
xy=[list(map(int,input().split())) for _ in range(n)]
# xy.sort(key=lambda x:x[0])
# print(xy)
diff=[]
for i in range(n):
    for j in range(i):
        diff.append((xy[i][0]-xy[j][0],xy[i][1]-xy[j][1]))

ans=[]
# print(set(diff))
for p,q in set(diff):
    qxHIKUpy=[]
    for i in range(n):
        qxHIKUpy.append(q*xy[i][0]-p*xy[i][1])
    ans.append(len(set(qxHIKUpy)))
# print(ans)
print(min(ans))


Fixed submission:
n=int(input())
xy=[list(map(int,input().split())) for _ in range(n)]
xy.sort(key=lambda x:(x[0],x[1]))
# print(xy)
if n<=2:
    print(1)
else:
    diff=[]
    for i in range(n):
        for j in range(i):
            diff.append((xy[i][0]-xy[j][0],xy[i][1]-xy[j][1]))

    ans=[]
    # print(set(diff))
    for p,q in set(diff):
        cnt=n
        for i in range(n):
            for j in range(i):
                if xy[i][0]-xy[j][0]==p and xy[i][1]-xy[j][1]==q:
                    cnt-=1
        ans.append(cnt)
    print(min(ans))
Buggy python submission (verdict: Time Limit Exceeded):
def sousa(k,hand,v):
    if k==0:
        # print(k,sum(hand),hand,v)
        ans.append(sum(hand))
        return
    if len(v)>0:
        # 左から取る
        sousa(k-1,hand+[v[0]],v[1:])
        # 右から取る
        sousa(k-1,hand+[v[-1]],v[:-1])

    if len(hand)>0:
        # 右に入れる
        hand.sort()
        array=[hand[0]]
        sousa(k-1,hand[1:],v+array)
        # 左に入れる
        sousa(k-1,hand[1:],array+v)



n,k=map(int,input().split())
v=list(map(int,input().split()))
ans=[0]
sousa(k,[],v)
# print(ans)
print(max(ans))


Fixed submission:
n,k=map(int,input().split())
v=list(map(int,input().split()))
ans=[]
for lhs in range(k+1):
    for rhs in range(k-lhs+1):
        if lhs+rhs<=n:
            array=v[:lhs]+v[n-rhs:]
        else:
            array=v[:]
        # print(v[:lhs],v[n-rhs:])
        for i in range(k+1-lhs-rhs):
            array.sort()
            ans.append(sum(array[i:]))
# print(ans)
print(max(ans))
Buggy python submission (verdict: Runtime Error):
class UnionFind:
    def __init__(self,n):
        self.parent=[i for i in range(n)]
        self.rank=[0 for _ in range(n)]

    def find(self,x):
        if self.parent[x]==x:
            return x
        else:
            rootx=self.find(self.parent[x])
            self.parent[x]=rootx
            return rootx

    def union(self,x,y):
        rootx=self.find(x)
        rooty=self.find(y)
        if self.rank[rootx]<self.rank[rooty]:
            self.parent[rootx]=rooty
        else:
            self.parent[rooty]=rootx
            if self.rank[rootx]==self.rank[rooty]:
                self.rank[rootx]+=1

n,m=map(int,input().split())
xyz=[list(map(int,input().split())) for _ in range(m)]
uf=UnionFind(n)
for x,y,z in xyz:
    x,y=x-1,y-1
    uf.union(x,y)

# print(uf.parent)
for i in range(n):
    uf.find(n)
print(len(set(uf.parent)))

Fixed submission:
class UnionFind:
    def __init__(self,n):
        self.parent=[i for i in range(n)]
        self.rank=[0 for _ in range(n)]

    def find(self,x):
        if self.parent[x]==x:
            return x
        else:
            rootx=self.find(self.parent[x])
            self.parent[x]=rootx
            return rootx

    def union(self,x,y):
        rootx=self.find(x)
        rooty=self.find(y)
        if self.rank[rootx]<self.rank[rooty]:
            self.parent[rootx]=rooty
        else:
            self.parent[rooty]=rootx
            if self.rank[rootx]==self.rank[rooty]:
                self.rank[rootx]+=1

n,m=map(int,input().split())
xyz=[list(map(int,input().split())) for _ in range(m)]
uf=UnionFind(n)
for x,y,z in xyz:
    x,y=x-1,y-1
    uf.union(x,y)

# print(uf.parent)
for i in range(n):
    uf.find(i)
print(len(set(uf.parent)))
Buggy python submission (verdict: Time Limit Exceeded):
r,g,b,n=map(int,input().split())
ans=0
box=[r,g,b]
box.sort(key=lambda x:-x)
# print(box)
maxCnt=[n//box[i]+1 for i in range(3)]
# print(maxCnt)
cnt=[0,0,0]
for cnt0 in range(maxCnt[0]):
    for cnt1 in range(maxCnt[1]):
        reg=n-cnt0*box[0]-cnt1*box[1]
        if reg<0:
            break
        if reg%box[2]==0:
            ans+=1
print(ans)


Fixed submission:
r,g,b,n=map(int,input().split())
boxSize=[r,g,b]
boxSize.sort(key=lambda x:-x)
# print(boxSize)
maxCnt=[n//boxSize[i]+1 for i in range(3)]
# print(maxCnt)
ans=0
if boxSize[1]==1:
    for cnt0 in range(maxCnt[0]):
        ans+=n-cnt0*boxSize[0]+1
else:
    for cnt0 in range(maxCnt[0]):
        for cnt1 in range(maxCnt[1]):
            reg=n-cnt0*boxSize[0]-cnt1*boxSize[1]
            if reg<0:
                break
            if reg%boxSize[2]==0:
                ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
a=[int(input()) for _ in range(5)]
ar=[[i,a[i]%10] for i in range(5)]
ar.sort(key=lambda x:x[1])
i=0
while ar[i][1]==0:
    i+=1
k=ar[i][0]
time=0
for i in range(5):
    if i!=k:
        if a[i]%10==0:
            time+=a[i]
        else:
            time+=a[i]+10-a[i]%10
time+=a[k]
print(time)


Fixed submission:
a=[int(input()) for _ in range(5)]
ar=[[i,a[i]%10] for i in range(5)]
ar.sort(key=lambda x:x[1])
i=0
while ar[i][1]==0:
    i+=1
    if i==4:
        break
k=ar[i][0]
time=0
for i in range(5):
    if i!=k:
        time+=a[i]
        if a[i]%10!=0:
            time+=10-a[i]%10
time+=a[k]
print(time)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(input()) for _ in range(5)]
num=[n,0,0,0,0,0]
cnt=0
while num[5]<n:
    for i in range(4,-1,-1):
        move=min(num[i],a[i])
        num[i+1]+=move
        num[i]-=move
    cnt+=1
print(cnt)


Fixed submission:
import math
n=int(input())
a=[int(input()) for _ in range(5)]
print(math.ceil(n/min(a))+4)
Buggy python submission (verdict: Time Limit Exceeded):

s=input()
flag=1
length=len(s)
s_flag=[1 for _ in range(length)]
while flag:
    l=sum(s_flag)
    if l<=1:
        break
    comp=0
    while s_flag[comp]==0:
        comp+=1
    # print(s_flag,comp)
    for i in range(comp+1,length):
        if s_flag[i]:
            if s[comp]!=s[i]:
                s_flag[comp]=0
                s_flag[i]=0
                break
            else:
                comp=i
                if i==length-1:
                    flag=0
print(length-sum(s_flag))


Fixed submission:

s=input()
length=len(s)
cnt=[0,0]
for i in range(length):
    if s[i]=='0':
        cnt[0]+=1
    else:
        cnt[1]+=1
print(min(cnt)*2)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
flag=1
length=len(s)
s_flag=[1 for _ in range(length)]
while flag:
    l=sum(s_flag)
    if l<=1:
        break
    comp=0
    while s_flag[comp]==0:
        comp+=1
    for i in range(comp+1,length):
        if s_flag[i]:
            if s[comp]!=s[i]:
                s_flag[comp]=0
                s_flag[i]=0
                break
            elif i==length-1:
                flag=0
print(length-sum(s_flag))


Fixed submission:

s=input()
length=len(s)
cnt=[0,0]
for i in range(length):
    if s[i]=='0':
        cnt[0]+=1
    else:
        cnt[1]+=1
print(min(cnt)*2)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
flag=1
length=len(s)
while flag:
    l=len(s)
    if l<=1:
        break
    for i in range(1,l):
        if s[i-1]!=s[i]:
            s=s[:i-1]+s[i+1:]
            break
        elif i==l-1:
            flag=0
print(length-len(s))

Fixed submission:

s=input()
length=len(s)
cnt=[0,0]
for i in range(length):
    if s[i]=='0':
        cnt[0]+=1
    else:
        cnt[1]+=1
print(min(cnt)*2)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
flag=1
length=len(s)
while flag:
    l=len(s)
    if l<=1:
        break
    pre=s[0]
    for i in range(1,l):
        if pre!=s[i]:
            s=s[:i-1]+s[i+1:]
            break
        else:
            pre=s[i]
            if i==l-1:
                flag=0
print(length-len(s))


Fixed submission:

s=input()
length=len(s)
cnt=[0,0]
for i in range(length):
    if s[i]=='0':
        cnt[0]+=1
    else:
        cnt[1]+=1
print(min(cnt)*2)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n=int(input())
action=np.array([list(map(int,input().split())) for _ in range(n)])
# happy[i][j] i日目にaction j を選んだ場合の幸福度の最大値
happy=np.zeros((n+1,3))
for i in range(1,n+1):
    for j in range(3):
        for k in range(3):
            if j!=k:
                happy[i][j]=max(happy[i][j],happy[i-1][k]+action[i-1][j])
        # happy[i][j]=max(np.concatenate((happy[i-1][0:j]+action[i-1][j],happy[i-1][j+1:3]+action[i-1][j]),axis=None))
# print(happy)
print(int(max(happy[n])))


Fixed submission:
n=int(input())
action=[list(map(int,input().split())) for _ in range(n)]
# happy[i][j] i日目にaction j を選んだ場合の幸福度の最大値
happy=[[0,0,0]for _ in range(n+1)]
for i in range(1,n+1):
    for j in range(3):
        for k in range(3):
            if j!=k:
                happy[i][j]=max(happy[i][j],happy[i-1][k]+action[i-1][j])
# print(happy)
print(max(happy[n]))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n=int(input())
action=np.array([list(map(int,input().split())) for _ in range(n)])
# happy[i][j] i日目にaction j を選んだ場合の幸福度の最大値
happy=np.zeros((n+1,3))
for i in range(1,n+1):
    for j in range(3):
        happy[i][j]=max(np.concatenate((happy[i-1][0:j]+action[i-1][j],happy[i-1][j+1:3]+action[i-1][j]),axis=None))
# print(happy)
print(int(max(happy[n])))


Fixed submission:
n=int(input())
action=[list(map(int,input().split())) for _ in range(n)]
# happy[i][j] i日目にaction j を選んだ場合の幸福度の最大値
happy=[[0,0,0]for _ in range(n+1)]
for i in range(1,n+1):
    for j in range(3):
        for k in range(3):
            if j!=k:
                happy[i][j]=max(happy[i][j],happy[i-1][k]+action[i-1][j])
# print(happy)
print(max(happy[n]))