Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# D
import numpy as np
N, K = map(int,input().split())
p = list(map(int,input().split()))

sums=np.cumsum([(s+1)/2 for s in p])

ans=np.max([ sums[i+K]-sums[i] for i in range(N-K)])

print(ans )

Fixed submission:
# D
import numpy as np
N, K = map(int,input().split())
p = list(map(int,input().split()))

sums=np.cumsum([(s+1)/2 for s in p])

ans=np.max([ sums[i+K]-sums[i] for i in range(N-K)]+[sums[K-1]])

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

if a<b:
    ans=f"{a}"*b
else:
    ans=f"{b}"*a
print(ans)

Fixed submission:
# ABC152
a,b = map(int, input().split())
 
if a<b:
    ans=str(a)*b
else:
    ans=str(b)*a
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int( input() )
A = list(map(int, input().split() ))
S = sum(A)
A.extend(A)
odds = range(0,N,2)
Ans=[-S + 2*sum([s for s,num in zip(A[i:i+N], range(N)) if num in odds] )
     for i in range(N) ]
print(" ".join(map(str,Ans) ))

Fixed submission:
N = int( input() )
A = list(map(int, input().split() ))
S = sum(A)
odds = range(0,N,2)
Ans=[]
Ans.append(-S + 2*sum([s for s,num in zip(A, range(N)) if num in odds] ) )
for i in range(1,N):
    Ans.append(2*A[i-1]-Ans[i-1])
print(" ".join(map(str,Ans) ))

Buggy python submission (verdict: Time Limit Exceeded):
N = int( input() )
A = list(map(int, input().split() ))
S = sum(A)
A.extend(A)
odds = [s for s in range(N) if s%2 ==0]
Ans=[-S + 2*sum([s for s,num in zip(A[i:i+N], range(N)) if num in odds] )
     for i in range(N) ]
print(" ".join(map(str,Ans) ))

Fixed submission:
N = int( input() )
A = list(map(int, input().split() ))
S = sum(A)
odds = range(0,N,2)
Ans=[]
Ans.append(-S + 2*sum([s for s,num in zip(A, range(N)) if num in odds] ) )
for i in range(1,N):
    Ans.append(2*A[i-1]-Ans[i-1])
print(" ".join(map(str,Ans) ))

Buggy python submission (verdict: Time Limit Exceeded):
N = int( input() )
A = list(map(int, input().split() ))
S = sum(A)
A.extend(A)
odds = [s for s in range(N) if s%2 ==0]
Ans=[]
for i in range(N):
    sum_i = sum([s for s,num in zip(A[i:i+N], range(N)) if num in odds] )

    Ans.append( 2*sum_i -S )    
print(" ".join(map(str,Ans) ))

Fixed submission:
N = int( input() )
A = list(map(int, input().split() ))
S = sum(A)
odds = range(0,N,2)
Ans=[]
Ans.append(-S + 2*sum([s for s,num in zip(A, range(N)) if num in odds] ) )
for i in range(1,N):
    Ans.append(2*A[i-1]-Ans[i-1])
print(" ".join(map(str,Ans) ))

Buggy python submission (verdict: Time Limit Exceeded):
N = int( input() )
A = list(map(int, input().split() ))
S = sum(A)
A.extend(A)
odds = [s for s in range(N) if s%2 ==0]
Ans=[]
for i in range(N):
    sum_i=0
    for odd in odds:
        sum_i += A[i+odd] 
    Ans.append( 2*sum_i -S )    
print(" ".join(map(str,Ans) ))

Fixed submission:
N = int( input() )
A = list(map(int, input().split() ))
S = sum(A)
odds = range(0,N,2)
Ans=[]
Ans.append(-S + 2*sum([s for s,num in zip(A, range(N)) if num in odds] ) )
for i in range(1,N):
    Ans.append(2*A[i-1]-Ans[i-1])
print(" ".join(map(str,Ans) ))
Buggy python submission (verdict: Runtime Error):
N = int(input() )
for i in range(N):
  C[i] = [map(int, input().split() ) ]
 
C.sort(key= lambda s:(s[1],s[0]) )
 
judge = "Yes"
time = 0
for i in range(N):
  time += C[i][0]
  if time > C[i][1]:
    judge = "No"
    break
print(judge)

Fixed submission:
S = input()
judge = "Good"
for num in range(3):
  if int(S[num]) == int(S[num + 1]):
    judge = "Bad"
    break
print(judge)

Buggy python submission (verdict: Runtime Error):
N = int(input() )
for i in range(N):
  C[i] = list(map(int, input().split() ) )

C.sort(key= lambda s:(s[1],s[0]) )


judge = "Yes"
time = 0
for i in range(N):
  time += C[i][0]
  if time > C[i][1]:
    judge = "No"
    break
print(judge)

Fixed submission:
S = input()
judge = "Good"
for num in range(3):
  if int(S[num]) == int(S[num + 1]):
    judge = "Bad"
    break
print(judge)

Buggy python submission (verdict: Runtime Error):
N, L = map(int, input().split())
 
if L > -1:
  N_eat = 1
elif N+L-1 < 1:
  N_eat = N
else:
  N_eat = 1-L
pie = N*N/2 +N*(L-1) - (L + N_eat-1) 
print(pie)

Fixed submission:
S = input()
judge = "Good"
for num in range(3):
  if int(S[num]) == int(S[num + 1]):
    judge = "Bad"
    break
print(judge)

Buggy python submission (verdict: Runtime Error):
S = input()
bad = 0
for num in range(2):
  if S[num] == S[num + 1]:
    print("Bad")
    break
    bad = 1
if bad == 0:
  print(Good)

Fixed submission:
S = input()
judge = "Good"
for num in range(3):
  if int(S[num]) == int(S[num + 1]):
    judge = "Bad"
    break
print(judge)
Buggy python submission (verdict: Runtime Error):
N, L = map(int, input().split())

if L >= 0:
  N_eat = 1
elif N+L-1 <= 0:
  N_eat = N
else:
  N_eat = 1-L
pie = double(N*N/2 +N*(L-1) - (L + N_eat-1) ) 
print(pie)


Fixed submission:
N, L = map(int, input().split())
 
if L > -1:
  N_eat = 1
elif N+L-1 < 1:
  N_eat = N
else:
  N_eat = 1-L
 
pie = N*(N+1)/2 +N*(L-1) - (L + N_eat-1) 
print(int(pie) )
Buggy python submission (verdict: Runtime Error):
N = int(input() )

for i in range(N):
  A, B = map(int, input().split() )
  C[i] = [A, B]
C.sort(key=lambda s:s[1] )
 
judge = "Yes"
time = 0
for i in range(N):
  time += C[i][0]
  if time > C[i][1]:
    judge = "No"
    break
print(judge)

Fixed submission:
N = int(input() )
C = []
for i in range(N):
  A, B = map(int, input().split() )
  C.append([A, B])
C.sort(key=lambda s:s[1] )
 
judge = "Yes"
time = 0
for i in range(N):
  time += C[i][0]
  if time > C[i][1]:
    judge = "No"
    break
print(judge)

Buggy python submission (verdict: Runtime Error):
N = int(input() )
for i in range(N):
  C[i] = (map(int, input().split() ) )
 
C.sort(key=lambda s:s[1] )
 
judge = "Yes"
time = 0
for i in range(N):
  time += C[i][0]
  if time > C[i][1]:
    judge = "No"
    break
print(judge)

Fixed submission:
N = int(input() )
C = []
for i in range(N):
  A, B = map(int, input().split() )
  C.append([A, B])
C.sort(key=lambda s:s[1] )
 
judge = "Yes"
time = 0
for i in range(N):
  time += C[i][0]
  if time > C[i][1]:
    judge = "No"
    break
print(judge)

Buggy python submission (verdict: Runtime Error):
N = int(input() )
for i in range(N):
  C[i] = [map(int, input().split() ) ]
 
C.sort(key= lambda s:(s[1],s[0]) )
 
judge = "Yes"
time = 0
for i in range(N):
  time += C[i][0]
  if time > C[i][1]:
    judge = "No"
    break
print(judge)

Fixed submission:
N = int(input() )
C = []
for i in range(N):
  A, B = map(int, input().split() )
  C.append([A, B])
C.sort(key=lambda s:s[1] )
 
judge = "Yes"
time = 0
for i in range(N):
  time += C[i][0]
  if time > C[i][1]:
    judge = "No"
    break
print(judge)

Buggy python submission (verdict: Runtime Error):
N = int(input() )
for i in range(N):
  C[i] = list(map(int, input().split() ) )
 
C.sort(key= lambda s:(s[1],s[0]) )
 
 
judge = "Yes"
time = 0
for i in range(N):
  time += C[i][0]
  if time > C[i][1]:
    judge = "No"
    break
print(judge)

Fixed submission:
N = int(input() )
C = []
for i in range(N):
  A, B = map(int, input().split() )
  C.append([A, B])
C.sort(key=lambda s:s[1] )
 
judge = "Yes"
time = 0
for i in range(N):
  time += C[i][0]
  if time > C[i][1]:
    judge = "No"
    break
print(judge)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))

for i in range(K):
  new = [0] * (N+1)
  for j in range(N):
    new[max(0, j-A[j])] += 1
    if j+A[j]+1 <= N-1:
      new[j+A[j]+1] -= 1
  A[0] = new[0]
  for j in range(1, N):
    new[j] += new[j-1]
    A[j] = new[j] 
  for ai in A:
    if ai != N:
      break
  else:
    break
    
print(' '.join([str(ai) for ai in A]))


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

for i in range(K):
  new = [0] * (N+1)
  for j in range(N):
    new[max(0, j-A[j])] += 1
    if j+A[j]+1 <= N-1:
      new[j+A[j]+1] -= 1
  A[0] = new[0]
  for j in range(1, N):
    new[j] += new[j-1]
    A[j] = new[j] 
  for ai in A:
    if ai != N:
      break
  else:
    break
    
print(' '.join([str(ai) for ai in A]))
Buggy python submission (verdict: Runtime Error):
from collections import deque

N, M = map(int, input().split())
G = [[] for _ in range(M)]
for i in range(M):
  A, B = map(int, input().split())
  G[A-1].append(B-1)
  G[B-1].append(A-1)

seen = [0 for _ in range(N)]
seen[0] = 1
shirube = [-1 for _ in range(N-1)]

stack = deque([0])
while stack:
  now = stack.popleft()
  for i in G[now]:
    if seen[i] == 0:
      seen[i] = 1
      stack.append(i)
      shirube[i-1] = now
    
for i in range(N):
  if seen[i] == 0:
    print('No')
    exit()
    
print('Yes')
for j in range(N-1):
  print(shirube[j]+1)


Fixed submission:
from collections import deque

N, M = map(int, input().split())
G = [[] for _ in range(N)]
for i in range(M):
  A, B = map(int, input().split())
  G[A-1].append(B-1)
  G[B-1].append(A-1)

seen = [0 for _ in range(N)]
seen[0] = 1
shirube = [-1 for _ in range(N-1)]

stack = deque([0])
while stack:
  now = stack.popleft()
  for i in G[now]:
    if seen[i] == 0:
      seen[i] = 1
      stack.append(i)
      shirube[i-1] = now
    
for i in range(N):
  if seen[i] == 0:
    print('No')
    exit()
    
print('Yes')
for j in range(N-1):
  print(shirube[j]+1)

Buggy python submission (verdict: Runtime Error):
from collections import deque

N, M = map(int, input().split())
G = [[] for _ in range(M)]
for i in range(M):
  A, B = map(int, input().split())
  G[A-1].append(B-1)
  G[B-1].append(A-1)

seen = [0 for _ in range(N)]
seen[0] = 1
shirube = [-1 for _ in range(N-1)]

stack = deque([0])
while stack:
  now = stack.popleft()
  for i in G[now]:
    if seen[i] == 0:
      seen[i] = 1
      stack.append(i)
      shirube[i-1] = now
    
for i in range(N):
  if seen[i] == 0:
    print('No')
    break
else:
  print('Yes')
  for j in range(N-1):
    print(shirube[j]+1)


Fixed submission:
from collections import deque

N, M = map(int, input().split())
G = [[] for _ in range(N)]
for i in range(M):
  A, B = map(int, input().split())
  G[A-1].append(B-1)
  G[B-1].append(A-1)

seen = [0 for _ in range(N)]
seen[0] = 1
shirube = [-1 for _ in range(N-1)]

stack = deque([0])
while stack:
  now = stack.popleft()
  for i in G[now]:
    if seen[i] == 0:
      seen[i] = 1
      stack.append(i)
      shirube[i-1] = now
    
for i in range(N):
  if seen[i] == 0:
    print('No')
    exit()
    
print('Yes')
for j in range(N-1):
  print(shirube[j]+1)
Buggy python submission (verdict: Runtime Error):
import math
import bisect
N = int(input())
atans =  [0 for _ in range(N)]
for i in range(N):
  A, B = map(int, input().split())
  if A == 0:
    atans[i] = 90
  else:
    atans[i] = math.degrees(math.atan(A/B))

atans.sort()
index0 = bisect.bisect_left(atans, 0)
if (index0==0) or (index0==N):
  print(pow(2, N, 1000000007) -1)
  exit()

left = atans[:index0]
right = atans[index0:]
ans = 1

lenleft = index0
lenright = N - index0
now = -90
for i in range(index0):
  if left[i]==now:
    continue
  now = left[i]
  target = now+90
  same1 = bisect.bisect_right(right, target) - bisect.bisect_left(right, target)
  
  if same1 >= 1:
    lenright -= same1
    same2 = bisect.bisect_right(left, now) - bisect.bisect_left(left, now)
    ans = ans * (pow(2,same1,1000000007)+pow(2,same2,1000000007)-1) %1000000007
  else:
    ans = ans * 2 %1000000007

ans = (ans * pow(2, lenright, 1000000007) -1) % 1000000007
print(ans)

Fixed submission:
import math
import bisect
MOD = 1000000007

N = int(input())
ABs =  []

count00 = 0
for i in range(N):
  A, B = map(int, input().split())
  if A == 0:
    if B == 0:
      count00 += 1
    else:
      ABs.append([0, -1])
  elif B == 0:
    ABs.append([1, 0])
  else:
    mygcd = math.gcd(A, B)
    A, B = A//mygcd, B//mygcd
    if A < 0:
      ABs.append([-A, -B])
    else:
      ABs.append([A, B])
  
N2 = N - count00
if N2 == 0:
  print(count00)
  exit()

ABs.sort(key = lambda x:x[1])
Bs = [i[1] for i in ABs]
index0 = bisect.bisect_left(Bs, 0)

if (index0==0) or (index0==N2):
  print((pow(2, N2, MOD) +count00 -1) %MOD)
  exit()

btm = ABs[:index0]
top = ABs[index0:]

lenbtm = index0
lentop = N2 - index0
for i in range(lenbtm):
  btm[i] = [-btm[i][1], btm[i][0]]

btmdict = {}
topdict = {}
for i in btm:
  mykey = str(i[0]) + '-' + str(i[1])
  btmdict[mykey] = 0
  topdict[mykey] = 0
for j in top:
  mykey = str(j[0]) + '-' + str(j[1])
  btmdict[mykey] = 0
  topdict[mykey] = 0

for i in btm:
  mykey = str(i[0]) + '-' + str(i[1])
  btmdict[mykey] += 1
for j in top:
  mykey = str(j[0]) + '-' + str(j[1])
  topdict[mykey] += 1

ans = 1
for i in btmdict:
  btmi = btmdict[i]
  topi = topdict[i]
  if btmi*topi >= 1:
    ans = ans * (pow(2, btmi, MOD) +pow(2, topi, MOD) -1) %MOD
  elif btmi == 0:
    ans = ans * pow(2, topi, MOD) %MOD
  else:
    ans = ans * pow(2, btmi, MOD) %MOD

ans = (ans +count00 -1) %MOD
print(ans)
Buggy python submission (verdict: Runtime Error):
p = list(map(int, input()))
print(sum(p)-max(p))

Fixed submission:
p = list(map(int, input().split()))
print(sum(p)-max(p))
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
set0=set(range(1,n+1))
for i in range(m):
  l,r=map(int,input().split())
  id_set=set(range(l,r+1))
  set0=set0&id_set
print(len(set0))

Fixed submission:
n,m=map(int,input().split())
l0,r0=1,n
for i in range(m):
  l,r=map(int,input().split())
  if l>r0 or r<l0:
    print(0)
    exit()
  else:
    l0=max(l0,l)
    r0=min(r0,r)
print(r0-l0+1)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
h = list(map(int, input().split()))

INF = sum(h)*2
dp = [0 for _ in range(N)]

for i in range(1, N):
  dp[i] = min([dp[i-j-1]+abs(h[i]-h[i-j-1]) for j in range(min(i,K))])

print(dp[N-1])


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

if N == 2:
  print(abs(h[1]-h[0]))
  exit()

dp = [0 for _ in range(N)]
dp[1] = abs(h[1] - h[0])
for i in range(2, N):
  dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]))

print(dp[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
h=list(map(int,input().split()))
dp=[0 for _ in range(N)]
for i in range(1,N):
  dp[i]=min([dp[i-j-1]+abs(h[i]-h[i-j-1]) for j in range(min(i,K))])
print(dp[-1])


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

dp = [0 for _ in range(N)]

for i in range(1, N):
  dp[i] = min([dp[i-j-1]+abs(h[i]-h[i-j-1]) for j in range(min(i,K))])

print(dp[N-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
h = list(map(int, input().split()))

dp = [0 for _ in range(N)]

for i in range(1, N):
  dp[i] = min([dp[i-j-1]+abs(h[i]-h[i-j-1]) for j in range(min(i,K))])

print(dp[N-1])


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

dp = [0 for _ in range(N)]

for i in range(1, N):
  dp[i] = min([dp[i-j-1]+abs(h[i]-h[i-j-1]) for j in range(min(i,K))])

print(dp[N-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
h = list(map(int, input().split()))

INF = sum(h)*2
dp = [0 for _ in range(N)]

for i in range(1, N):
  dp[i] = min([dp[i-j-1]+abs(h[i]-h[i-j-1]) for j in range(min(i,K))])

print(dp[N-1])


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

dp = [0 for _ in range(N)]

for i in range(1, N):
  dp[i] = min([dp[i-j-1]+abs(h[i]-h[i-j-1]) for j in range(min(i,K))])

print(dp[N-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
h = list(map(int, input().split()))

INF = sum(h)*2
dp = [INF for _ in range(N+K)]
dp[0] = 0
h = h + [INF]*K
for i in range(N-1):
  for j in range(1, K+1):
    dp[i+j] = min(dp[i+j], dp[i]+abs(h[i+j]-h[i]))

print(dp[N-1])


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

dp = [0 for _ in range(N)]

for i in range(1, N):
  dp[i] = min([dp[i-j-1]+abs(h[i]-h[i-j-1]) for j in range(min(i,K))])

print(dp[N-1])
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(H)]

N = 0
ans = []
for hi in range(H):
  for wi in range(W-1):
    if a[hi][wi]%2 == 1:
      N += 1
      a[hi][wi+1] += 1
      ans.append((hi+1, wi+1, hi+1, wi+2))
      
for hi in range(H-1):
  if a[hi][-1]%2 == 1:
    N += 1
    a[hi+1][wi] += 1
    ans.append((hi+1, W, hi+2, W))
    
print(N)
for y, x, yp, xp in ans:
  print(y, x, yp, xp)

Fixed submission:
H, W = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(H)]

N = 0
ans = []
for hi in range(H):
  for wi in range(W-1):
    if a[hi][wi]%2 == 1:
      N += 1
      a[hi][wi+1] += 1
      ans.append((hi+1, wi+1, hi+1, wi+2))
      
for hi in range(H-1):
  if a[hi][-1]%2 == 1:
    N += 1
    a[hi+1][-1] += 1
    ans.append((hi+1, W, hi+2, W))
    
print(N)
for y, x, yp, xp in ans:
  print(y, x, yp, xp)
Buggy python submission (verdict: Runtime Error):
31415 9265

Fixed submission:
n,k=map(int,input().split())
if k%2==1:
  print((n//k)**3)
else:
  m=n*2//k
  if m%2==1:
    print(((m-1)//2)**3+((m+1)//2)**3)
  else:
    print((m**3)//4)
Buggy python submission (verdict: Time Limit Exceeded):
n,m,qu = map(int,input().split())
l = [0 for _ in range(m)]
r = [0 for _ in range(m)]
p = [0 for _ in range(qu)]
q = [0 for _ in range(qu)]

for i in range(m):
  l[i],r[i] = map(int,input().split())

for i in range(qu):
  p[i],q[i] = map(int,input().split())

for i in range(qu):
  honsu=0
  for j in range(m):
    if l[j]>=p[i] and r[j]<=q[i]:
      honsu+=1
  print(honsu)

Fixed submission:
n,m,qu = map(int,input().split())
lr = [[0]*(n+1) for _ in range(n+1)]

for i in range(m):
  l,r = map(int,input().split())
  lr[l][r]+=1

for i in range(1,n+1):
  for j in range(i,n+1):
    lr[i][j]+=lr[i][j-1]
  
for i in range(1,n+1):
  for j in range(i):
    lr[i-j-1][i]+=lr[i-j][i]
    
for i in range(qu):
  p,q = map(int,input().split())
  print(lr[p][q])

Buggy python submission (verdict: Time Limit Exceeded):
n,m,qu=map(int,input().split())
l=[];r=[]
for i in range(m):
  l0,r0=map(int,input().split())
  l.append(l0);r.append(r0)

for i in range(qu):
  honsu=0
  p,q=map(int,input().split())
  for j in range(m):
    if l[j]>=p and r[j]<=q:
      honsu+=1
  print(honsu)

Fixed submission:
n,m,qu = map(int,input().split())
lr = [[0]*(n+1) for _ in range(n+1)]

for i in range(m):
  l,r = map(int,input().split())
  lr[l][r]+=1

for i in range(1,n+1):
  for j in range(i,n+1):
    lr[i][j]+=lr[i][j-1]
  
for i in range(1,n+1):
  for j in range(i):
    lr[i-j-1][i]+=lr[i-j][i]
    
for i in range(qu):
  p,q = map(int,input().split())
  print(lr[p][q])

Buggy python submission (verdict: Time Limit Exceeded):
n,m,qu=map(int,input().split())
l=[];r=[];p=[];q=[]
for i in range(m):
  l0,r0=map(int,input().split())
  l.append(l0);r.append(r0)
for i in range(qu):
  p0,q0=map(int,input().split())
  p.append(p0);q.append(q0)

for i in range(qu):
  honsu=0
  for j in range(m):
    if l[j]>=p[i] and r[j]<=q[i]:
      honsu+=1
  print(honsu)

Fixed submission:
n,m,qu = map(int,input().split())
lr = [[0]*(n+1) for _ in range(n+1)]

for i in range(m):
  l,r = map(int,input().split())
  lr[l][r]+=1

for i in range(1,n+1):
  for j in range(i,n+1):
    lr[i][j]+=lr[i][j-1]
  
for i in range(1,n+1):
  for j in range(i):
    lr[i-j-1][i]+=lr[i-j][i]
    
for i in range(qu):
  p,q = map(int,input().split())
  print(lr[p][q])
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=[]
for i in a:
  b.append(i%m)
combi=0
for i in range(len(b)):
  sum=0
  for j in range(len(b)-i):
    sum=(sum+b[i+j])%m
    if sum==0:
      combi+=1
print(combi)

Fixed submission:
from collections import Counter

N, M = map(int, input().split())
A = [int(i)%M for i in input().split()]

B = [0] * (N+1)
for i in range(N):
  B[i+1] = (B[i]+A[i]) % M
  
counter = dict(Counter(B))
ans = 0
for num in counter:
  ans += (counter[num]-1) * counter[num] // 2

print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()
if s[0:1]!='A':
  print('WA')
  exit()
t=s[2:len(s)-1]
countc=0
for i in range(len(t)):
  if t[i]=='C':
    countc+=1
if countc!=1:
  print('WA')
  exit()
for i in range(1,len(s)):
  if s[i:i+1]!='C' and s[i:i+1].isupper():
    print('WA')
    exit()
print('AC')

















for i in range(100*d):
  for j in range(d):
    if i+1==p[j]:
      tugi=max(tugi,j+1+c[j])
    elif i+1<p[j]:
      tugi=max(tugi,j+1)
  ten+=tugi
  tugi=0
  print(ten)
  if ten>=g:
    print(i+1)
    exit()

Fixed submission:
S = input()
abc = 'abcdefghijklmnopqrstuvwxyz'
if S[0] == 'A':
  if S[2:len(S)-1].count('C') == 1:
    for c in S:
      if (c!='A') and (c!='C') and (c not in abc):
        print('WA')
        exit()
    else:
      print('AC')
  else:
    print('WA')
else:
  print('WA')
Buggy python submission (verdict: Runtime Error):
n=int(input())
if n<=999:
  print('ABC'+'{0:03d}'.format(n))
else:
  n=n-999
  print('ABD'+{0:03d}'.format(n))

Fixed submission:
n=int(input())
if n<=999:
  print('ABC')
else:
  print('ABD')
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
c=0
for i in range(1,n):
    x, y = S[:i], S[i:]
    c = max(c, len(set(x) & set(y)))
print(c)


Fixed submission:
n=int(input())
s=input()
c=0
for i in range(1,n):
  x=set(s[:i])
  y=set(s[i:])
  a = len(x & y)
  if a > c:
    c = a
print(c)

Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
c=0
for i in range(1,N):
  x=set(s[:i])
  y=set(s[i:])
  a = len(x & y)
  if a > c:
    c = a
print(c)


Fixed submission:
n=int(input())
s=input()
c=0
for i in range(1,n):
  x=set(s[:i])
  y=set(s[i:])
  a = len(x & y)
  if a > c:
    c = a
print(c)

Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
c=0
for i in range(1,N):
  x=s[:i]
  y=s[i:]
  a = set(x) & set(y)
  an=len(a)
  if an>c:
    c=an
print(c)


Fixed submission:
n=int(input())
s=input()
c=0
for i in range(1,n):
  x=set(s[:i])
  y=set(s[i:])
  a = len(x & y)
  if a > c:
    c = a
print(c)

Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
c=0
for i in range(1,N):
  x=set(s[:i])
  y=set(s[i:])
  a = x & y
  an=len(a)
  if an>c:
    c=an
print(c)


Fixed submission:
n=int(input())
s=input()
c=0
for i in range(1,n):
  x=set(s[:i])
  y=set(s[i:])
  a = len(x & y)
  if a > c:
    c = a
print(c)

Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
c=0
for i in range(1,N):
  x=set(s[:i])
  y=set(s[i:])
  a=x&y
  an=len(a)
  if an>c:
    c=an
print(c)


Fixed submission:
n=int(input())
s=input()
c=0
for i in range(1,n):
  x=set(s[:i])
  y=set(s[i:])
  a = len(x & y)
  if a > c:
    c = a
print(c)

Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
c=0
for i in range(1,N):
  x=set(s[:i])
  y=set(s[i:])
  a=len(x&y)
  c=max(c,a)
print(c)


Fixed submission:
n=int(input())
s=input()
c=0
for i in range(1,n):
  x=set(s[:i])
  y=set(s[i:])
  a = len(x & y)
  if a > c:
    c = a
print(c)

Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
c=0
for i in range(1,N):
  x=set(s[:i])
  y=set(s[i:])
  len(a)=x&y
  c=max(c,a)
print(c)

Fixed submission:
n=int(input())
s=input()
c=0
for i in range(1,n):
  x=set(s[:i])
  y=set(s[i:])
  a = len(x & y)
  if a > c:
    c = a
print(c)

Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
c=0
for i in range(1,N):
  x=set(s[:i])
  y=set(s[i:])
  a=x&y
  c=max(c,a)
print(c)


Fixed submission:
n=int(input())
s=input()
c=0
for i in range(1,n):
  x=set(s[:i])
  y=set(s[i:])
  a = len(x & y)
  if a > c:
    c = a
print(c)

Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
c=0
for i in range(1,N):
  x=s[0:i]
  y=s[i:N]
  for j in range('a','z'+1):
    if j in x and j in y:
      c+=1
print(c)

Fixed submission:
n=int(input())
s=input()
c=0
for i in range(1,n):
  x=set(s[:i])
  y=set(s[i:])
  a = len(x & y)
  if a > c:
    c = a
print(c)