Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
# 積が負で絶対値が T 以上の組合せ数を求める
# A, B は昇順
def count1(T, A, B):
	return count1_by_binsearch(T, A, B)
	
	if T <= 0 or len(A) == 0 or len(B) == 0:
		return 0

	count, it = 0, -1
	for i in range(len(A) - 1, -1, -1):
		while it + 1 < len(B) and A[i] * B[it + 1] < T:
			it += 1

		# A[i] * B[it], A[i] * B[it + 1], ... は条件を満たす
		count += len(B) - it - 1
	return count


# 積が正で絶対値が T 以下の組合せ数を求める
# 絶対値が T より大きいものの組合せ数を求めてから全体から引く
# A は昇順
def count2(T, A):
	count_all = len(A) * (len(A) - 1) // 2
	count = count1(T + 1, A, A)

	# A[i] * A[i] が余計にカウントされた分を減らす．
	for e in A:
		if e * e >= T + 1:
			count -= 1

	count /= 2 # 同じ配列を渡しているため (i, j) == (j, i) が二回カウントされる

	return count_all - count


def count1_by_binsearch(T, A, B):
	if T <= 0 or len(A) == 0 or len(B) == 0:
		return 0

	count = 0
	for i in range(len(A)):
		if A[i] * B[-1] < T:
			continue;
			
		ok, ng = len(B) - 1, -1
		while abs(ok - ng) > 1:
			mid = (ok + ng) // 2

			if A[i] * B[mid] >= T:
				ok = mid
			else:
				ng = mid
		count += len(B) - ok

	return count

if __name__ == "__main__":
	N, K = map(int, input().split())
	A = list(map(int, input().split()))

	# X: 負の数の絶対値の配列
	# Y: 正の数の配列
	# Z: 0 の個数
	X, Y, Z = [], [], 0
	for e in A:
		if e < 0:
			X.append(-e)
		elif e > 0:
			Y.append(e)
		else:
			Z += 1
	X.sort()
	Y.sort()


	# 積が T 以下な組合せ数が K 未満か？
	def check(T):
		count = 0
		if T < 0:
			count += count1(abs(T), X, Y)
		else:
			count += len(X) * len(Y) # 結果が負
			count += Z * (Z - 1) // 2 + Z * (N - Z) # 結果が 0
			count += count2(T, X) + count2(T, Y)

		return count < K


	ok, ng = -10 ** 18, 10 ** 18
	while ng - ok > 1:
		mid = (ok + ng) // 2
		
		if check(mid):
			ok = mid
		else:
			ng = mid

	print(ok + 1)


Fixed submission:
# 積が負で絶対値が T 以上の組合せ数を求める
# A, B は昇順
def count1(T, A, B):
	if T <= 0 or len(A) == 0 or len(B) == 0:
		return 0

	count, it = 0, -1
	for i in range(len(A) - 1, -1, -1):
		while it + 1 < len(B) and A[i] * B[it + 1] < T:
			it += 1

		# A[i] * B[it], A[i] * B[it + 1], ... は条件を満たす
		count += len(B) - it - 1
	return count


# 積が正で絶対値が T 以下の組合せ数を求める
# 絶対値が T より大きいものの組合せ数を求めてから全体から引く
# A は昇順
def count2(T, A):
	count_all = len(A) * (len(A) - 1) // 2
	count = count1(T + 1, A, A)

	# A[i] * A[i] が余計にカウントされた分を減らす．
	for e in A:
		if e * e >= T + 1:
			count -= 1

	count /= 2 # 同じ配列を渡しているため (i, j) == (j, i) が二回カウントされる

	return count_all - count


if __name__ == "__main__":
	N, K = map(int, input().split())
	A = list(map(int, input().split()))

	# X: 負の数の絶対値の配列
	# Y: 正の数の配列
	# Z: 0 の個数
	X, Y, Z = [], [], 0
	for e in A:
		if e < 0:
			X.append(-e)
		elif e > 0:
			Y.append(e)
		else:
			Z += 1
	X.sort()
	Y.sort()


	# 積が T 以下な組合せ数が K 未満か？
	def check(T):
		count = 0
		if T < 0:
			count += count1(abs(T), X, Y)
		else:
			count += len(X) * len(Y) # 結果が負
			count += Z * (Z - 1) // 2 + Z * (N - Z) # 結果が 0
			count += count2(T, X) + count2(T, Y)

		return count < K


	ok, ng = -10 ** 18, 10 ** 18
	while ng - ok > 1:
		mid = (ok + ng) // 2
		
		if check(mid):
			ok = mid
		else:
			ng = mid

	print(ok + 1)
Buggy python submission (verdict: Runtime Error):
S = input()

if S[0] == S[1] && S[2] == S[3] && S[0] != S[2]:
  print('Yes')
elif S[0] == S[2] && S[1] == S[3] && S[0] != S[1]:
  print('Yes')
elif S[0] == S[3] && S[1] == S[2] && S[0] != S[1]:
  print('Yes')
else:
  print('No')

Fixed submission:
S = input()
 
if S[0] == S[1] and S[2] == S[3] and S[0] != S[2]:
  print('Yes')
elif S[0] == S[2] and S[1] == S[3] and S[0] != S[1]:
  print('Yes')
elif S[0] == S[3] and S[1] == S[2] and S[0] != S[1]:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
N, X = map(int, input().split())
L = list(map(int, input().split()))

point = 0
cnt = 1
while point<=X:
  point += L[cnt-1]
  if point <= X:
    cnt += 1
  else:
    break

print(cnt)

Fixed submission:
N, X = map(int, input().split())
L = list(map(int, input().split()))
 
point = 0
cnt = 1
while cnt<=N:
  point += L[cnt-1]
  if point <= X:
    cnt += 1
  else:
    break
 
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
MOD = 10 ** 9 + 7
broken = []
for i in range(0, M):
  broken.append(int(input()))

memo = [0] * (N+1)
memo[0] = 1
cnt = 1
while cnt <= N:
  if cnt in broken:
    memo[cnt] = 0
  elif cnt == 1:
    memo[cnt] = 1
  else:
    memo[cnt] = (memo[cnt-1] + memo[cnt-2])%MOD
  cnt += 1
  
print(memo[N])

Fixed submission:
N, M = map(int, input().split())
MOD = 10 ** 9 + 7
broken = []
for i in range(0, M):
  broken.append(int(input()))

memo = [1]
cnt = 1
while cnt <= N:
  if len(broken) > 0 and cnt == broken[0]:
    del broken[0]
    memo.append(0)
  elif cnt == 1:
    memo.append(1)
  else:
    memo.append((memo[-1] + memo[-2])%MOD)
  cnt += 1
  
print(memo[-1])
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
l = []
r = []
for _ in range(M):
  s, t = map(int, input().split())
  l.append(s)
  r.append(t)
  
lm = max(l)
rm = min(r)
print(max[rm - lm + 1, 0])

Fixed submission:
N, M = map(int, input().split())
l = []
r = []
for _ in range(M):
  s, t = map(int, input().split())
  l.append(s)
  r.append(t)
  
lm = max(l)
rm = min(r)
print(max([rm - lm + 1, 0]))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = list(map(int, input().split()))
mn = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

msort = lambda s: -s[0]

b = list(map(lambda i: [i, mn[i]], a))
b.sort(key = msort)
dp = [-100] * (N + 1)
dp[0] = 0
for i in range(2, N + 1):
  for n in b:
    if i >= n[1] and dp[i - n[1]] >= 0:
      dp[i] = max([dp[i], dp[i - n[1]] + 1])

match = N
ans = ''
while match > 0:
  for n in b:
    if dp[match] == dp[match - n[1]] + 1:
      ans += str(n[0])
      match -= n[1]
      break
    
print(ans)

Fixed submission:
N, M = map(int, input().split())
a = list(map(int, input().split()))
mn = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

msort = lambda s: -s[0]

b = list(map(lambda i: [i, mn[i]], a))
b.sort(key = msort)
dp = [-100] * (N + 1)
dp[0] = 0
for i in range(2, N + 1):
  for n in b:
    if i >= n[1] and dp[i - n[1]] >= 0:
      dp[i] = max([dp[i], dp[i - n[1]] + 1])

match = N
ans = ''
while match > 0:
  for n in b:
    if match >= n[1] and dp[match] == dp[match - n[1]] + 1:
      ans += str(n[0])
      match -= n[1]
      break
    
print(ans)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))

blist = [0] * 50
for i in range(N):
  bn = bin(A[i])
  for j in range(len(bn)):
    if bn[len(bn) - 1 - j] == '1':
      blist[j] += 1
      
K = bin(K)[2::]
digit = len(K)
dp = [[0, 0] for i in range(digit)]
t = 0
for i in range(digit, 45):
  t += blist[i] * (2 ** i)
if K != '0':
  dp[digit - 1][0] = t + blist[digit - 1] * 2 ** (digit - 1)
  dp[digit - 1][1] = t + (N - blist[digit - 1]) * 2 ** (digit - 1)
else:
  dp[digit - 1] = [t, t]
for i in reversed(range(0, digit - 1)):
  if K[len(K) - i] == '1':
    dp[i][1] = dp[i + 1][1] + (N - blist[i]) * (2 ** i)
    dp[i][0] = max([dp[i + 1][1] + blist[i] * (2 ** i),
                    dp[i + 1][0] + max([blist[i], N - blist[i]]) * (2 ** i)])
  else:
    dp[i][1] = dp[i + 1][1] + blist[i] * (2 ** i)
    dp[i][0] = dp[i + 1][0] + max([blist[i], N - blist[i]]) * (2 ** i)
    
print(max(dp[0]))

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))

blist = [0] * 50
for i in range(N):
  bn = bin(A[i])
  for j in range(len(bn)):
    if bn[len(bn) - 1 - j] == '1':
      blist[j] += 1
      
K = bin(K)[2::]
digit = len(K)
dp = [[0, 0] for i in range(digit)]
t = 0
for i in range(digit, 45):
  t += blist[i] * (2 ** i)
if K != '0':
  dp[digit - 1][0] = t + blist[digit - 1] * 2 ** (digit - 1)
  dp[digit - 1][1] = t + (N - blist[digit - 1]) * 2 ** (digit - 1)
else:
  dp[digit - 1] = [t, t]
for i in reversed(range(0, digit - 1)):
  if K[len(K) - i - 1] == '1':
    dp[i][1] = dp[i + 1][1] + (N - blist[i]) * (2 ** i)
    dp[i][0] = max([dp[i + 1][1] + blist[i] * (2 ** i),
                    dp[i + 1][0] + max([blist[i], N - blist[i]]) * (2 ** i)])
  else:
    dp[i][1] = dp[i + 1][1] + blist[i] * (2 ** i)
    dp[i][0] = dp[i + 1][0] + max([blist[i], N - blist[i]]) * (2 ** i)
    
print(max(dp[0]))
Buggy python submission (verdict: Runtime Error):
#list(map(int,input().split()))
n,m=map(int,input().split())
it=[[0 for i in range(n)] for j in range(n)]
for i in range(n):
    j=input()
    for k in range(m):
        if j[k]=="#":
            it[i][k]=0
        else:
            it[i][k]=1
dp=[[0 for i in range(n)] for j in range(n)]
for i in range(n):
    for j in range(m):
        if it[i][j]==0:
            dp[i][j]=1
        if(i>0 or j>0):
            if(i==0):
                dp[i][j]+=dp[i][j-1]
            elif j==0:
                dp[i][j]+=dp[i-1][j]
            else:
                dp[i][j]+=min(dp[i-1][j],dp[i][j-1])
print(dp[n-1][m-1])


Fixed submission:
#list(map(int,input().split()))
n,m=map(int,input().split())
it=[[0 for i in range(m)] for j in range(n)]
for i in range(n):
    j=input()
    for k in range(m):
        if j[k]=="#":
            it[i][k]=0
        else:
            it[i][k]=1
dp=[[0 for i in range(m)] for j in range(n)]
for i in range(n):
    for j in range(m):
        
        if(i>0 or j>0):
            if(i==0):
                dp[i][j]=dp[i][j-1]
                if(it[i][j-1]==1 and it[i][j]==0):
                    dp[i][j]+=1
            elif j==0:
                dp[i][j]=dp[i-1][j]
                if(it[i][j]==0 and it[i-1][j]==1):
                    dp[i][j]+=1
            else:
                a=0
                b=0
                if(it[i][j]==0):
                    if(it[i-1][j]==1):
                        a=1
                    if(it[i][j-1]==1):
                        b=1
                dp[i][j]=min(dp[i-1][j]+a,dp[i][j-1]+b)
        else:
            if it[i][j]==0:
                dp[i][j]=1

print(dp[n-1][m-1])
Buggy python submission (verdict: Runtime Error):
s=input()
n=len(s)+1
ans=[-1 for i in range(n)]
st=False
for i in range(1,n):
    if s[i-1]=="<":
        if st:
            st=False
            ans[i-1]=0
    else:
        st=True
if s[0]=="<":
    ans[0]=0
else:
    d=0
    for i in range(1,n):
        if s[i]==">":
            d+=1
        else:
            break
    ans[0]=d
#print(ans)
co=0
for i in range(n-1,0,-1):
    if s[i-1]==">":
        ans[i]=co
        co+=1
    else:
        if co>0:
            ans[i]=co
        co=0
#print(ans)
for i in range(1,n):
    if s[i-1]=="<" and ans[i]==-1:
        ans[i]=ans[i-1]+1
    elif s[i-1]=="<" and ans[i]!=-1:
        ans[i]=max(ans[i],ans[i-1]+1)
print(sum(ans))












Fixed submission:
s=input()
n=len(s)+1
ans=[-1 for i in range(n)]
st=False
for i in range(1,n):
    if s[i-1]=="<":
        if st:
            st=False
            ans[i-1]=0
    else:
        st=True
if s[0]=="<":
    ans[0]=0
else:
    d=0
    for i in range(1,n):
        if s[i-1]==">":
            d+=1
        else:
            break
    ans[0]=d
#print(ans)
co=0
for i in range(n-1,0,-1):
    if s[i-1]==">":
        ans[i]=co
        co+=1
    else:
        if co>0:
            ans[i]=co
        co=0
#print(ans)
for i in range(1,n):
    if s[i-1]=="<" and ans[i]==-1:
        ans[i]=ans[i-1]+1
    elif s[i-1]=="<" and ans[i]!=-1:
        ans[i]=max(ans[i],ans[i-1]+1)
print(sum(ans))
Buggy python submission (verdict: Time Limit Exceeded):

n=int(input())
pre=[1]*(n//2+200)
pp=[1]*(n+1)
mod=998244353
for i in range(1,n//2+100):
    pre[i]=((pre[i-1]*2)%mod)
    
p=[1]*(n+1)
for i in range(n):
    p[i+1]=((p[i]*(i+1))%mod)
    pp[i+1]=pow(p[i+1],mod-2,mod)
tot=1
for i in range(n):
    tot*=3
    tot%=mod
#print(1)
#print(tot)
cc=0
for i in range(n//2+1,n+1):
    c=(((((p[n]*pp[i])%mod)*pp[n-i])%mod)*pre[n-i])%mod
    c%=mod
    cc+=c
tot-=cc
tot-=cc
tot%=mod
print(tot)


Fixed submission:

n=int(input())
pre=[1]*(n//2+200)
pp=[1]*(n+1)
mod=998244353
for i in range(1,n//2+100):
    pre[i]=((pre[i-1]*2)%mod)
    
p=[1]*(n+1)
for i in range(n):
    p[i+1]=((p[i]*(i+1))%mod)
pp[-1] = pow(p[-1], mod - 2, mod)
 
for i in range(2, n + 1):
	pp[-i] = int((pp[-i + 1] * (n + 2 - i)) % mod)
tot=1
for i in range(n):
    tot*=3
    tot%=mod
#print(1)
#print(tot)
cc=0
for i in range(n//2+1,n+1):
    c=(((((p[n]*pp[i])%mod)*pp[n-i])%mod)*pre[n-i])%mod
    c%=mod
    cc+=c
tot-=cc
tot-=cc
tot%=mod
print(tot)

Buggy python submission (verdict: Time Limit Exceeded):
def e(a,b,c):
    if b==0:
        return 1
    aa=1
    if b%2==1:
        aa=a
    return (aa*(e(a,b//2,c)**2))%mod
n=int(input())
pre=[1]
mod=998244353
for i in range(n//2+100):
    pre.append((pre[-1]*2)%mod)
p=[1]
for i in range(n):
    p.append((p[-1]*(i+1))%mod)
tot=1
for i in range(n):
    tot*=3
    tot%=mod
#print(1)
#print(tot)
for i in range(n//2+1,n+1):
    c=(p[n]*e(p[i],mod-2,mod)*e(p[n-i],mod-2,mod)*pre[n-i])%mod
    c%=mod
    tot-=c
    tot-=c
    tot%=mod
print(tot)

Fixed submission:

n=int(input())
pre=[1]*(n//2+200)
pp=[1]*(n+1)
mod=998244353
for i in range(1,n//2+100):
    pre[i]=((pre[i-1]*2)%mod)
    
p=[1]*(n+1)
for i in range(n):
    p[i+1]=((p[i]*(i+1))%mod)
pp[-1] = pow(p[-1], mod - 2, mod)
 
for i in range(2, n + 1):
	pp[-i] = int((pp[-i + 1] * (n + 2 - i)) % mod)
tot=1
for i in range(n):
    tot*=3
    tot%=mod
#print(1)
#print(tot)
cc=0
for i in range(n//2+1,n+1):
    c=(((((p[n]*pp[i])%mod)*pp[n-i])%mod)*pre[n-i])%mod
    c%=mod
    cc+=c
tot-=cc
tot-=cc
tot%=mod
print(tot)
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
t=input()
ma=0
a=[0,0]
dp=[[0 for i in range(len(t)+1)] for j in range(len(s)+1)]
pred=[[-1 for i in range(len(t)+1)] for j in range(len(s)+1)]
for i in range(1,len(s)+1):
    for j in range(1,len(t)+1):
        dp[i][j]=max(dp[i][j],dp[i-1][j])
        dp[i][j]=max(dp[i][j],dp[i][j-1])
        if s[i-1]==t[j-1]:
            dp[i][j]=max(dp[i][j],1+dp[i-1][j-1])
        if dp[i][j]==1+dp[i-1][j-1]:
            pred[i][j]=[i-1,j-1]
        if dp[i][j]==dp[i][j-1]:
            pred[i][j]=[i,j-1]
        if dp[i][j]==dp[i-1][j]:
            pred[i][j]=[i-1,j]
        if dp[i][j]>ma:
            ma=dp[i][j]
            a=[i,j]
b=a

ans=[b[:]]
while b!=-1:
    #print(b)
    b=pred[b[0]][b[1]]
    if b==-1:
        break
    if 0 in b:
        break
    if b!=-1:
        ans.append(b[:])


ss=""
for  i in ans:
    if s[i[0]-1]==t[i[1]-1]:
        ss+=s[i[0]-1]
ss=ss[-1::-1]
print(ss)
    


Fixed submission:
s=input()
t=input()
ma=0
a=[0,0]
dp=[[0 for i in range(len(t)+1)] for j in range(len(s)+1)]
for i in range(1,len(s)+1):
    for j in range(1,len(t)+1):
        dp[i][j]=max(dp[i-1][j],dp[i][j-1])
        if s[i-1]==t[j-1]:
            dp[i][j]=max(dp[i][j],1+dp[i-1][j-1])
i=len(s)
j=len(t)

ss=""
while i and j:
    if dp[i][j]==dp[i-1][j]:
        i-=1
    elif dp[i][j]==dp[i][j-1]:
        j-=1
    else:
        ss+=s[i-1]
        i-=1
        j-=1
ss=ss[-1::-1]
print(ss)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
t=input()
ma=0
dp=[[0 for i in range(len(t)+1)] for j in range(len(s)+1)]
pred=[[-1 for i in range(len(t)+1)] for j in range(len(s)+1)]
for i in range(1,len(s)+1):
    for j in range(1,len(t)+1):
        dp[i][j]=max(dp[i][j],dp[i-1][j])
        dp[i][j]=max(dp[i][j],dp[i][j-1])
        if s[i-1]==t[j-1]:
            dp[i][j]=max(dp[i][j],1+dp[i-1][j-1])
        if dp[i][j]==1+dp[i-1][j-1]:
            pred[i][j]=[i-1,j-1]
        if dp[i][j]==dp[i][j-1]:
            pred[i][j]=[i,j-1]
        if dp[i][j]==dp[i-1][j]:
            pred[i][j]=[i-1,j]
            

        ma=max(ma,dp[i][j])
ans=""
a=[-1,-1]
ma=-1
for i in range(1,len(s)+1):
    for j in range(1,len(t)+1):
        if dp[i][j]>ma:
            ma=dp[i][j]
            a=[i,j][:]
b=a[:]
ans=[b[:]]
while b!=-1:
    #print(b)
    b=pred[b[0]][b[1]][:]
    if 0 in b:
        break
    if b!=-1:
        ans.append(b)


ss=""
for  i in ans:
    if s[i[0]-1]==t[i[1]-1]:
        ss+=s[i[0]-1]
ss=ss[-1::-1]
print(ss)
    


Fixed submission:
s=input()
t=input()
ma=0
a=[0,0]
dp=[[0 for i in range(len(t)+1)] for j in range(len(s)+1)]
for i in range(1,len(s)+1):
    for j in range(1,len(t)+1):
        dp[i][j]=max(dp[i-1][j],dp[i][j-1])
        if s[i-1]==t[j-1]:
            dp[i][j]=max(dp[i][j],1+dp[i-1][j-1])
i=len(s)
j=len(t)

ss=""
while i and j:
    if dp[i][j]==dp[i-1][j]:
        i-=1
    elif dp[i][j]==dp[i][j-1]:
        j-=1
    else:
        ss+=s[i-1]
        i-=1
        j-=1
ss=ss[-1::-1]
print(ss)
Buggy python submission (verdict: Runtime Error):
N,M,C=map(int, input().split())
B = list(map(int,input().split()))

ans = 0
for i in range(N):
  A = list(map(int, input().split()))
  score = C
  for j in range(M):
    score += A[i] * B[i]
  if(score > 0):
    ans += 1
print(ans)

Fixed submission:
N,M,C=map(int, input().split())
B = list(map(int,input().split()))

ans = 0
for i in range(N):
  A = list(map(int, input().split()))
  score = C
  for j in range(M):
    score += A[j] * B[j]
  if(score > 0):
    ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
s=input().split()
n=int(s[0]);m=int(s[1]);c=int(s[2])
b=input().split();a=[];ans=0
for i in range n : a.append(input().split())
for i in range n :
  temp=0
  for j in range m : temp+=int(a[i][j])*int(b[j])
  if temp+c>0 : ans+=1
print(ans)

Fixed submission:
s=input().split()
n=int(s[0]);m=int(s[1]);c=int(s[2])
b=input().split();a=[];ans=0
for i in range(n) : a.append(input().split())
for i in range(n) :
  temp=0
  for j in range(m) : temp+=int(a[i][j])*int(b[j])
  if temp+c>0 : ans+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

ans = 0
for a in range(1, N ):
   for b in range(1, N // a + 1):
      if a * b < N:
         ans += 1

print(ans)
      

Fixed submission:
n = int(input())
ans = 0
for a in range(1, n):
  ans += (n - 1) // a
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

N = int(input())

ans = 0
for c in range(1, N-1): 
   ans += len(make_divisors(N - c))

print(ans + 1)

Fixed submission:
n = int(input())
ans = 0
for a in range(1, n):
  ans += (n - 1) // a
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
L = list(map(int,input().split()))
L = sorted(L)
ln = len(L)
ansl = []
nonans = 0

for i in range(ln-2):
   for j in range(1,ln -1):
      for k in range(2, ln):
         if L[i] + L[j] > L[k] and L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
            ansl.append([L[i], L[j], L[k]])

for i in range(ln-1):
   for j in range(i + 1, ln):
      if ansl[i] == ansl[j]:
         nonans += 1
            

print(len(ansl) - nonans -1)

Fixed submission:
N = int(input())
L = list(map(int,input().split()))

L = sorted(L)

ln = len(L)

ans = 0

for i in range(ln-2):
   for j in range(i+1, ln-1):
      for k in range(j + 1, ln):
         if L[i] + L[j] > L[k] and L[i] != L[j] and L[j] != L[k]:
             ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
X,  K,  D = list(map(int, input().split()))
L = X + D * K
 
if X >= 0:
   if K == 1 or D == 1:
      print(abs(X - D*K))
      exit()

elif X < 0:
   if K == 1 or D == 1:
      print(abs(X + D*K))
      exit()

elif L >= 0:
   if L / (2 * D) - int(L / (2 * D)) > 0.5:
      a = L // (2 * D) + 1
   else:
      a = L // (2 * D)
 
elif L < 0:
   if L / (2 * D) - int(L / (2 * D)) < -0.5:
      a = int(L / (2 * D)) - 1
   else:
      a = int(L / (2 * D)) 
print(abs(X-2*D*a+D*K))

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

a = (k * d - x) / (2 * d)

if abs(x) < k * d:
   if abs(int(a) + 1 - a) >= abs(int(a) - a):
      print(abs(x + 2 * int(a) * d - k * d))
   else:
      print(abs(x + 2 * (int(a) + 1) * d - k * d))

elif x < 0:
   print(abs(x + k * d))
else:
   print(x - k * d)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))

A = sorted(A, reverse = True)

la = len(A)

for i in range(la-1):
   ans += A[i]

print(ans)

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

A = sorted(A, reverse = True)

B = [A[0]] + [A[i] for i in range(1,N)] * 2

B = sorted(B, reverse = True)

ans = 0

for i in range(N - 1):
   ans +=  B[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
X, N = list(map(int,input().split()))
if N == 0:
  print(X)
  exit()
p = list(map(int,input().split()))
if N == 1:
  if p[0] == X:
    print(X-1)
  else:
    print(X)

MAX = 0
for i in range(N):
  if MAX < X - p[i]:
    MAX = X - p[i]
    
for i in range(MAX):
  if X - i not in p:
    ans = X - i
    break
for i in range(MAX):
  if X + i not in p:
    ans = min(X - ans, ans - X) + X
    break
print(ans)

Fixed submission:
X, N = map(int, input().split())
p = list(map(int, input().split()))

p = set(p)
for i in range(200):
    if X - i not in p:
        print(X - i)
        break
    if X + i not in p:
        print(X + i)
        break
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
A = sorted(A)
ans = 1
flag = 0
#第1項が割り切れる場合答えは0。割り切れるとしたら次の項で可能。
if A[0] % A[1] == 0:
  print(0)
  exit()
#第二項以降を考える。
for i in range(1,N):
  for j in range(i-1):
    if A[i] % A[j] == 0:
      flag += 1
  if flag == 0:
    ans += 1
  else:
    flag = 0
    
print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
A = sorted(A)

d = {}
for a in A:
  d.setdefault(a,0)
  d[a] += 1
  
A = sorted(set(A))
t = [True] * (10 ** 6 + 1)
for a in A:
    if d[a] > 1:
        t[a] = False
    for i in range(a + a, 10 ** 6 + 1, a):
        t[i] = False
print(sum(1 for a in A if t[a]))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
ans = 1
for i in range(N):
  ans *= A[i]
if ans > 10 ** 18:
  print(-1)
else:
  print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
ans = 1
A = sorted(A)
for i in range(N):
  ans *= A[i]
  if ans > 10 ** 18:
    ans = -1
    break
print(ans)
Buggy python submission (verdict: Runtime Error):
H1, M1, H2, M2, K = list(map(int,input().split()))
a = 60*H1 + M1
b = 60*H2 + M2
print(b - a - p)

Fixed submission:
H1, M1, H2, M2, K = list(map(int,input().split()))
a = 60*H1 + M1
b = 60*H2 + M2
print(b - a - K)
Buggy python submission (verdict: Runtime Error):
K = int(input())
S = input()
ls = list(S)
if len(S) >= K:
  ansl = ls[0:K-1]
print(''.join(ansl) + '...')

Fixed submission:
K = int(input())
S = input()
ls = list(S)
if len(S) > K:
  ansl = ls[0:K]
  print(''.join(ansl) + '...')
else:
  print(S)
Buggy python submission (verdict: Runtime Error):
A, B, N = list(map(int,input().split()))
MAX = float('inf')*(-1)
a = int(A/B)
b = B
if N < B:
    MAX = (A * N // B) - A * (N // B)
else:
    MAX = (A * (B-1) // B) - A * ((B-1) // B)
print(MAX)

Fixed submission:
K = int(input())
A,B = list(map(int,input().split()))
a = A // K
b = B // K
flag = 0
for i in range(a,b+1):
    if A <= K * i and K * i <= B:
        flag += 1
if flag != 0:
    print('OK')
else:
    print('NG')
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
B = [None for _ in range(N)]
for i in range(1,N+1):
  B[i] = A.count(i)
for j in range(N):
  print(B[j])

Fixed submission:
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
counter = np.bincount(A)
for i in range(1, N+1):
    if i < len(counter):
        print(counter[i])
    else:
        print(0)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
B = [None for i in range(N)]
for i in range(N):
    B[i] = A.count(i+1)
for i in range(N):
    print(B[i])

Fixed submission:
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
counter = np.bincount(A)
for i in range(1, N+1):
    if i < len(counter):
        print(counter[i])
    else:
        print(0)