Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse = True)
it = 0
for i in range(M):
    A[it]=A[it]//2
    if it<N-1:
        if A[0]<=A[it+1] and A[it]<=A[it+1]:
            it+=1
        else: it = 0
    if it == N-1:
        it = 0
    print(A)
print(sum(A))

Fixed submission:
N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse = True)
it = 0
for i in range(M):
    A[it]=A[it]//2
    if it<N-1:
        if A[it]<A[it+1] and A[0]<A[it+1]:
            it+=1
        else:
            A.sort(reverse = True)
            it = 0
    if it == N-1:
        A.sort(reverse = True)
        it = 0
print(sum(A))
Buggy python submission (verdict: Time Limit Exceeded):
N =int(input())
s = sorted(sorted(input()) for i in range(N))
cnt = 0
i = 0
while i <= N-1:
    grnm=(s[i+1:]).count(s[i])
    if grnm == 0:
        i+=1
    else:
        cnt += int(grnm*(grnm+1)/2)
        i+=(grnm+1)
print(cnt)

Fixed submission:
import collections

N =int(input())
s = ["".join(sorted(input())) for _ in range(N)]
c = collections.Counter(s)
cnt = 0
ans =0
for i in set(s):
    cnt = c[i]
    ans += cnt*(cnt-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N =int(input())
s = sorted((sorted(input()) for i in range(N)))
cnt = 0
for i in range(N):
    cnt+=(s[i+1:]).count(s[i])
print(cnt)

Fixed submission:
import collections

N =int(input())
s = ["".join(sorted(input())) for _ in range(N)]
c = collections.Counter(s)
cnt = 0
ans =0
for i in set(s):
    cnt = c[i]
    ans += cnt*(cnt-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N =int(input())
s = sorted(list(sorted(input()) for i in range(N)))
cnt = 0
for i in range(N):
    for j in range(i+1,N):
        if s[i]==s[j]:
            cnt+=1
        else: break
print(cnt)

Fixed submission:
import collections

N =int(input())
s = ["".join(sorted(input())) for _ in range(N)]
c = collections.Counter(s)
cnt = 0
ans =0
for i in set(s):
    cnt = c[i]
    ans += cnt*(cnt-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N =int(input())
s = list(sorted(input()) for i in range(N))
cnt = 0
for i in range(N):
    cnt+=(s[i+1:]).count(s[i])
print(cnt)

Fixed submission:
import collections

N =int(input())
s = ["".join(sorted(input())) for _ in range(N)]
c = collections.Counter(s)
cnt = 0
ans =0
for i in set(s):
    cnt = c[i]
    ans += cnt*(cnt-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N =int(input())
s = list(sorted(input()) for i in range(N))
cnt = 0
for i in range(N):
    for j in range(i+1,N):
        if s[i]==s[j]:
            cnt+=1
print(cnt)

Fixed submission:
import collections

N =int(input())
s = ["".join(sorted(input())) for _ in range(N)]
c = collections.Counter(s)
cnt = 0
ans =0
for i in set(s):
    cnt = c[i]
    ans += cnt*(cnt-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N =int(input())
s = list(sorted(input()) for i in range(N))
cnt = 0
for i in range(N):
    for j in range(i+1,N):
        if s[i]==s[j]:
            cnt+=1
print(cnt)

Fixed submission:
import collections

N =int(input())
s = ["".join(sorted(input())) for _ in range(N)]
c = collections.Counter(s)
cnt = 0
ans =0
for i in set(s):
    cnt = c[i]
    ans += cnt*(cnt-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N =int(input())
s = list(sorted(input()) for i in range(N))
cnt = 0
for i in range(N):
    for j in range(N):
        if s[i]==s[j]:
            cnt+=1
print(int((cnt-N)/2))

Fixed submission:
import collections

N =int(input())
s = ["".join(sorted(input())) for _ in range(N)]
c = collections.Counter(s)
cnt = 0
ans =0
for i in set(s):
    cnt = c[i]
    ans += cnt*(cnt-1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int,input().split())
print(max(C-(A-B),0)

Fixed submission:
A, B, C = map(int,input().split())
print(max(C-(A-B),0))
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int,input().split()))
ans ="Yes"
highest = H[0]
for i in range(N-1):
    if H[i+1]<highest-1:
        ans ="No"
        break
    highest = max(highest,H[i+1])

print(ans)

Fixed submission:
A, B = map(int,input().split())

if (A+B)%2 == 0:
    print((A+B)//2)
else:
    print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
S = list(input())
if S[0]==S[1]orS[1]==S[2]orS[2]==S[3]:
  print("Bad")
else: print("Good")

Fixed submission:
S=list(input())
if S[0]==S[1] or S[1]==S[2] or S[2]==S[3]:
    print("Bad")
else: print("Good")
Buggy python submission (verdict: Runtime Error):
A,B,C,D = map(int,input().split())
print(B-A+1-(CntMultiples(A, B, C) + CntMultiples(A, B, D) - CntMultiples(A, B, (C*D)//math.gcd(C, D))))

import math
def CntMultiples(a, b, n):
    return b//n - a//n + int(a%n==0)

Fixed submission:
import fractions
def CntMultiples(a, b, n):
    return b//n - a//n + int(a%n==0)

A,B,C,D = map(int,input().split())
print(B-A+1-(CntMultiples(A, B, C) + CntMultiples(A, B, D) - \
             CntMultiples(A, B, (C*D)//(fractions.gcd(C, D)))))

Buggy python submission (verdict: Runtime Error):
import math

def CntMultiples(a, b, n):
    return b//n - a//n + int(a%n==0)

A,B,C,D = map(int,input().split())
print(B-A+1-(CntMultiples(A, B, C) + CntMultiples(A, B, D) - CntMultiples(A, B, (C*D)//math.gcd(C, D))))

Fixed submission:
import fractions
def CntMultiples(a, b, n):
    return b//n - a//n + int(a%n==0)

A,B,C,D = map(int,input().split())
print(B-A+1-(CntMultiples(A, B, C) + CntMultiples(A, B, D) - \
             CntMultiples(A, B, (C*D)//(fractions.gcd(C, D)))))

Buggy python submission (verdict: Runtime Error):
import math

def CntMultiples(a, b, n):
    return b//n - a//n + int(a%n==0)

A,B,C,D = map(int,input().split())
print(B-A+1-(CntMultiples(A, B, C) + CntMultiples(A, B, D) - CntMultiples(A, B, (C*D)//math.gcd(C, D))))

Fixed submission:
import fractions
def CntMultiples(a, b, n):
    return b//n - a//n + int(a%n==0)

A,B,C,D = map(int,input().split())
print(B-A+1-(CntMultiples(A, B, C) + CntMultiples(A, B, D) - \
             CntMultiples(A, B, (C*D)//(fractions.gcd(C, D)))))

Buggy python submission (verdict: Time Limit Exceeded):
A,B,C,D = map(int,input().split())

ans = 0
for i in range (A, B+1):
    if (i%C)*(i%D) != 0:
        ans +=1
print(ans)

Fixed submission:
import fractions
def CntMultiples(a, b, n):
    return b//n - a//n + int(a%n==0)

A,B,C,D = map(int,input().split())
print(B-A+1-(CntMultiples(A, B, C) + CntMultiples(A, B, D) - \
             CntMultiples(A, B, (C*D)//(fractions.gcd(C, D)))))
Buggy python submission (verdict: Runtime Error):
X, A = map(int,input().split())
if A//X ==0:
    print(0)
else: print(10)

Fixed submission:
X, A = map(int,input().split())
print(int(X>=A)*10)

Buggy python submission (verdict: Runtime Error):
X, A = map(int,input().split())
if A//X ==0:
  print(0)
else: print(10)

Fixed submission:
X, A = map(int,input().split())
print(int(X>=A)*10)
Buggy python submission (verdict: Runtime Error):
N, X = map(int,input().split())
L = list(map(int,input().split()))
ans = 1
D = L[0]
while D<=X and ans<N+1:
    D+=L[ans]
    ans+=1
print(ans)


Fixed submission:
N, X = map(int,input().split())
L = list(map(int,input().split()))
ans = 1
D = L[0]
while D<=X and ans<N+1:
    ans+=1
    if ans < N+1: #N+1回以降ははねない
        D+=L[ans-1]
print(ans)

Buggy python submission (verdict: Runtime Error):
N, X = map(int,input().split())
L = list(map(int,input().split()))
D = 0
ans = 0
while D<=X and ans<N+1:
    D+=L[ans]
    ans+=1
print(ans)

Fixed submission:
N, X = map(int,input().split())
L = list(map(int,input().split()))
ans = 1
D = L[0]
while D<=X and ans<N+1:
    ans+=1
    if ans < N+1: #N+1回以降ははねない
        D+=L[ans-1]
print(ans)
Buggy python submission (verdict: Runtime Error):
import fractions
N = int(input())
A = list(map(int,input().split()))
minflg = 0
mingcd = A[1]
for i in range(N):
    gcd = fractions.gcd(mingcd,A[i])
    if gcd < mingcd:
        mingcd = gcd
        minflg = i
if minflg == 0 and N > 2:
    if fractions.gcd(A[0],A[2]) > math.fractions(A[1],A[2]):
        minflg = 1
if minflg > 0:
    mingcd = A[minflg-1]
else: mingcd = A[minflg+1]
    
for i in range(N):
    if i != minflg:
        gcd = fractions.gcd(mingcd,A[i])
        if gcd < mingcd:
            mingcd = gcd
print(mingcd)
    

Fixed submission:
from fractions import gcd
N = int(input())
A = list(map(int,input().split()))
if N == 2:
    ans = max(A)
else:
    GCDF, GCDB = [0]*N, [0]*N
    GCDF[1],GCDB[-2] = A[0], A[N-1]
    for i in range(2, N):
        GCDF[i] = gcd(GCDF[i-1],A[i-1])
        GCDB[-(i+1)] = gcd(GCDB[-i], A[-i])
    GCDm = [0]*N
    GCDm[0] = GCDB[0]
    GCDm[N-1] = GCDF[N-1]
    for i in range(1, N-1):
        GCDm[i] = gcd(GCDF[i],GCDB[i])
    ans = max(GCDm)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, Q =map(int,input().split())
S =input()
LR = [list(map(int,input().split())) for i in range(Q)]
isACinit =[0]*N
for i in range(N-1):
    if S[i]=="A" and S[i+1]=="C":
        isACinit[i] = 1
#ans = [0]*Q
#print(isACinit)
ACsum = sum(isACinit)
for i in range(Q):
    if LR[i][1]-LR[i][0]<N//2:
        print(sum(isACinit[LR[i][0]-1:LR[i][1]-1]))
    else:
        print(ACsum-sum(isACinit[:LR[i][0]-1])-sum(isACinit[LR[i][1]-1:]))

Fixed submission:
N, Q =map(int,input().split())
S =input()
LR = [list(map(int,input().split())) for i in range(Q)]
ACnum =[0]*(N+1)
Sofar = 0
for i in range(N-1):
    if S[i]=="A" and S[i+1]=="C":
        Sofar+=1
    ACnum[i+1] = Sofar
ACnum[N]=Sofar
#print(ACnum)
for i in range(Q):
    print(ACnum[LR[i][1]-1]-ACnum[LR[i][0]-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q =map(int,input().split())
S =input()
LR = [list(map(int,input().split())) for i in range(Q)]
isACinit =[0]*N
for i in range(N-1):
    if S[i]=="A" and S[i+1]=="C":
        isACinit[i] = 1
#ans = [0]*Q
#print(isACinit)
ACsum = sum(isACinit)
for i in range(Q):
    if LR[i][1]-LR[i][0]<N//2:
        print(sum(isACinit[LR[i][0]-1:LR[i][1]-1]))
    else:
        print(ACsum-sum(isACinit[:LR[i][0]-1])-sum(isACinit[LR[i][1]-1:]))

Fixed submission:
N, Q =map(int,input().split())
S =input()
LR = [list(map(int,input().split())) for i in range(Q)]
ACnum =[0]*(N+1)
Sofar = 0
for i in range(N-1):
    if S[i]=="A" and S[i+1]=="C":
        Sofar+=1
    ACnum[i+1] = Sofar
ACnum[N]=Sofar
#print(ACnum)
for i in range(Q):
    print(ACnum[LR[i][1]-1]-ACnum[LR[i][0]-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q =map(int,input().split())
S =input()
LR = [list(map(int,input().split())) for i in range(Q)]
isACinit =[0]*N
for i in range(N-1):
    if S[i]=="A" and S[i+1]=="C":
        isACinit[i] = 1
#ans = [0]*Q
#print(isACinit)
ACsum = sum(isACinit)
for i in range(Q):
    if LR[i][1]-LR[i][0]>N//2:
        print(sum(isACinit[LR[i][0]-1:LR[i][1]-1]))
    else:
        print(ACsum-sum(isACinit[:LR[i][0]-1])-sum(isACinit[LR[i][1]-1:]))

Fixed submission:
N, Q =map(int,input().split())
S =input()
LR = [list(map(int,input().split())) for i in range(Q)]
ACnum =[0]*(N+1)
Sofar = 0
for i in range(N-1):
    if S[i]=="A" and S[i+1]=="C":
        Sofar+=1
    ACnum[i+1] = Sofar
ACnum[N]=Sofar
#print(ACnum)
for i in range(Q):
    print(ACnum[LR[i][1]-1]-ACnum[LR[i][0]-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q =map(int,input().split())
S =input()
LR = [list(map(int,input().split())) for i in range(Q)]
isACinit =[0]*N
for i in range(N-1):
    if S[i]=="A" and S[i+1]=="C":
        isACinit[i] = 1
#ans = [0]*Q
#print(isACinit)
for i in range(Q):
#    ans[i] = sum(isACinit[LR[i][0]:LR[i][1]])
    print(sum(isACinit[LR[i][0]-1:LR[i][1]-1]))

Fixed submission:
N, Q =map(int,input().split())
S =input()
LR = [list(map(int,input().split())) for i in range(Q)]
ACnum =[0]*(N+1)
Sofar = 0
for i in range(N-1):
    if S[i]=="A" and S[i+1]=="C":
        Sofar+=1
    ACnum[i+1] = Sofar
ACnum[N]=Sofar
#print(ACnum)
for i in range(Q):
    print(ACnum[LR[i][1]-1]-ACnum[LR[i][0]-1])
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
InitL = len(S)
for i in range(len(S)):
    if S.count("01")+S.count("10")==0:
        break
    S = S.replace("01", "")
    S = S.replace("10", "")
print(InitL - len(S))

Fixed submission:
S = input()
ans = 2*min(S.count("0"), S.count("1"))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
InitL = len(S)
while S.count("01")+S.count("10")>0:
    S = S.replace("01", "")
    S = S.replace("10", "")
print(InitL - len(S))

Fixed submission:
S = input()
ans = 2*min(S.count("0"), S.count("1"))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S = str(input())
ans = 0
while True:
    S = S.replace("01", "R")
    S = S.replace("10", "L")
    if S.count("R") + S.count("L") > 0:
        ans +=(S.count("R") + S.count("L"))*2
        S = S.replace("R", "")
        S = S.replace("L","")
    else:
        break
print(ans)

Fixed submission:
S = input()
ans = 2*min(S.count("0"), S.count("1"))
print(ans)
Buggy python submission (verdict: Runtime Error):
Copy
a, b, c = map(int,input().split())
print(int(min(a*b/2,b*c/2,c*a/2)))

Fixed submission:
a, b, c = map(int,input().split())
print(int(min(a*b/2,b*c/2,c*a/2)))
Buggy python submission (verdict: Runtime Error):
Age = int(input())
if Age ==1:
  	print("Hello World")
else:
	AB = [int(input()) for i in range(2)]
    print(AB[0]+AB[1])

Fixed submission:
Age = int(input())
if Age ==1:
    print("Hello World")
else:
    AB = [int(input()) for i in range(2)]
    print(AB[0]+AB[1])