Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
count = 0
ans = 1
m = 10**9 + 7
 
for i in range(N):
  if S[2*i] == "W":
    ans = (ans * ((2*i) - (count*2)))%m
    count += 1
  if S[2*i + 1] == "B":
    ans = (ans * ((2*i + 1) - (count*2)))%m
    count += 1
 
if count != N:
  print(0)
else:
  for o in range(1, N+1):
    ans *= o
    ans %= m
  print(ans % m)

Fixed submission:
M, D = map(int, input().split())
m_list = {m for m in range(1, M + 1)}
ans = 0
 
for d in range(11, D+1):
  d_10 = int(d/10)
  d_1 = d - (d_10 * 10)
  if (d_10 < 2) or (d_1 < 2):
    continue
  else:
    if (d_10 * d_1) in m_list:
      ans += 1
      
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
count = 0
ans = 1
m = 10**9 + 7
 
for i in range(N):
  if S[2*i] == "W":
    ans = ans * ((2*i) - (count*2))%m
    count += 1
  if S[2*i + 1] == "B":
    ans = ans * ((2*i + 1) - (count*2))%m
    count += 1
 
if count != N:
  print(0)
else:
  for o in range(1, N+1):
    ans *= o
    ans %= m
  print(ans % m)

Fixed submission:
M, D = map(int, input().split())
m_list = {m for m in range(1, M + 1)}
ans = 0
 
for d in range(11, D+1):
  d_10 = int(d/10)
  d_1 = d - (d_10 * 10)
  if (d_10 < 2) or (d_1 < 2):
    continue
  else:
    if (d_10 * d_1) in m_list:
      ans += 1
      
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
count = 0
ans = 1
m = 10**9 + 7
 
for i in range(N):
  if S[2*i] == "W":
    ans *= ((2*i) - (count*2))%m
    count += 1
  if S[2*i + 1] == "B":
    ans *= ((2*i + 1) - (count*2))%m
    count += 1
 
if count != N:
  print(0)
else:
  for o in range(1, N+1):
    ans *= o
    ans %= m
  print(ans % m)

Fixed submission:
M, D = map(int, input().split())
m_list = {m for m in range(1, M + 1)}
ans = 0
 
for d in range(11, D+1):
  d_10 = int(d/10)
  d_1 = d - (d_10 * 10)
  if (d_10 < 2) or (d_1 < 2):
    continue
  else:
    if (d_10 * d_1) in m_list:
      ans += 1
      
print(ans)

Buggy python submission (verdict: Runtime Error):
M, D = map(int, input().split())
m_list = {m for m in range(1, M + 1)}
ans = 0

for d in range(11, D+1):
  d_10 = int(d/10)
  d_1 = d - (d_10 * 10)
  if (d_10 < 2) or (d_1 < 2):
    continue
  elif:
    if (d_10 * d_1) in m_list:
      ans += 1
      
print(ans)
      

Fixed submission:
M, D = map(int, input().split())
m_list = {m for m in range(1, M + 1)}
ans = 0
 
for d in range(11, D+1):
  d_10 = int(d/10)
  d_1 = d - (d_10 * 10)
  if (d_10 < 2) or (d_1 < 2):
    continue
  else:
    if (d_10 * d_1) in m_list:
      ans += 1
      
print(ans)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A_list = list(map(int, input().split()))
same = 0
diff = 0

for i in range(N):
  for j in range(N):
    if N[i] > N[j]:
      if i < j:
        same += 1
        diff += 1
      elif i>j:
        diff += 1

ans = (same*K) + (diff*((K * (K-1))//2))
print(ans%(10**9 + 7))
        

Fixed submission:
def tasu(a):
  out = (a*(a-1))//2 + a
  return out%(10**9 + 7)
    
  
N, K = map(int, input().split())
A_list = list(map(int, input().split()))
count = 0
count1 = 0

for i in range(N):
  for j in range(N):
    if i == j:
      continue
    elif (i<j) & (A_list[i] > A_list[j]):
      count += 1
    elif (i>j) & (A_list[i] > A_list[j]):
      count1 += 1

ans = (tasu(K) * count) + (tasu(K-1) * count1) 
print(ans%(10**9 + 7))

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)

def tasu(a):
  if a == 1:
    return 1
  else:
    return a + tasu(a-1)
  
N, K = map(int, input().split())
A_list = list(map(int, input().split()))
count = 0

for i in range(N):
  for j in range(N):
    if i == j:
      continue
    elif (i<j) & (A_list[i] > A_list[j]):
      count += tasu(K)
    elif (i>j) & (A_list[i] > A_list[j]):
      count += tasu(K - 1)
print(count%(10**9 + 7))

Fixed submission:
def tasu(a):
  out = (a*(a-1))//2 + a
  return out%(10**9 + 7)
    
  
N, K = map(int, input().split())
A_list = list(map(int, input().split()))
count = 0
count1 = 0

for i in range(N):
  for j in range(N):
    if i == j:
      continue
    elif (i<j) & (A_list[i] > A_list[j]):
      count += 1
    elif (i>j) & (A_list[i] > A_list[j]):
      count1 += 1

ans = (tasu(K) * count) + (tasu(K-1) * count1) 
print(ans%(10**9 + 7))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s_list = ["".join(sorted(input())) for _ in range(N)]
s_set = set(s_list)
ans = 0

for D in s_set:
  num = s_list.count(D) 
  ans += (num * (num-1)) // 2
  
print(ans)

Fixed submission:
N = int(input())
count = {}
ans = 0

for _ in range(N):
    ele = "".join(sorted(input()))
    if ele in count.keys():
        ans += count[ele]
        count[ele] += 1
    else:
        count[ele] = 1
  
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import heapq

N, M = map(int, input().split())
job_list = {}
ans = 0
kouho = []
for _ in range(N):
  A, B = map(int, input().split())
  B = B * (-1)
  if A in job_list.keys():
    job_list[A].append(B)
  else:
    job_list[A] = [B]

for day in range(1, M + 1):
  try: 
    kouho += job_list[day]
    heapq.heapify(kouho)
  except KeyError:
    pass
  if len(kouho) != 0:
    ans += heapq.heappop(kouho)

print(ans * (-1))

Fixed submission:
import heapq

N, M = map(int, input().split())
AB_list = []
[heapq.heappush(AB_list, list(map(int, input().split()))) for _ in range(N)]
ans = 0
kouho = []

for day in range(1, M + 1):
    if len(AB_list) != 0:
        while AB_list[0][0] <= day:           
            heapq.heappush(kouho, heapq.heappop(AB_list)[1]*(-1))
            if len(AB_list) == 0:
                break
    if len(kouho) != 0:
        ans += heapq.heappop(kouho)

print(ans * (-1))

Buggy python submission (verdict: Time Limit Exceeded):
import heapq

N, M = map(int, input().split())
job_list = {}
ans = 0
kouho = []
for _ in range(N):
  A, B = map(int, input().split())
  B = B * (-1)
  if A in job_list.keys():
    job_list[A].append(B)
  else:
    job_list[A] = [B]

for day in range(1, M + 1):
  try: 
    kouho += job_list[day]
    heapq.heapify(kouho)
  except KeyError:
    pass
  if len(kouho) != 0:
    ans += heapq.heappop(kouho)

print(ans * (-1))

Fixed submission:
import heapq

N, M = map(int, input().split())
AB_list = []
[heapq.heappush(AB_list, list(map(int, input().split()))) for _ in range(N)]
ans = 0
kouho = []

for day in range(1, M + 1):
    if len(AB_list) != 0:
        while AB_list[0][0] <= day:           
            heapq.heappush(kouho, heapq.heappop(AB_list)[1]*(-1))
            if len(AB_list) == 0:
                break
    if len(kouho) != 0:
        ans += heapq.heappop(kouho)

print(ans * (-1))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

N, M = map(int, input().split())
job_list = {}
kouho = deque()
ans = 0
for _ in range(N):
  A, B = map(int, input().split())
  if A in job_list.keys():
    job_list[A].append(B)
  else:
    job_list[A] = deque([B])
    
for day in range(1, M + 1):
  try: 
    kouho += job_list[day]

  except KeyError:
    pass
  if len(kouho) != 0:
    temp = max(kouho)
    ans += temp
    kouho.remove(temp)

print(ans)
    
  

Fixed submission:
import heapq

N, M = map(int, input().split())
AB_list = []
[heapq.heappush(AB_list, list(map(int, input().split()))) for _ in range(N)]
ans = 0
kouho = []

for day in range(1, M + 1):
    if len(AB_list) != 0:
        while AB_list[0][0] <= day:           
            heapq.heappush(kouho, heapq.heappop(AB_list)[1]*(-1))
            if len(AB_list) == 0:
                break
    if len(kouho) != 0:
        ans += heapq.heappop(kouho)

print(ans * (-1))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]
for i in A:
  AA = A.copy()
  AA.remove(i)
  print(max(AA))

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
B = sorted(A)
MAX1, MAX2 = B[-1], B[-2]

for i in A:
  if i == MAX1:
    print(MAX2)
  else:
    print(MAX1)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
for i in range(N//2, -1, -1):
  sum = 0
  for o in range(1, (N//o)+1):
    sum += A[i*o-1]
  A[i] = sum%2
  
print(A.count(1))
ans = [str(q) for q,w in zip(range(N), A) if w == 1]
print(" ".join(ans))    

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
for i in range(N//2+1, 0, -1):
  sum = 0
  for o in range(1, (N//i)+1):
    sum += A[i*o-1]
  A[i-1] = sum%2
  
print(A.count(1))
ans = [str(q) for q,w in zip(range(1, N+1), A) if w == 1]
print(" ".join(ans))

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
A_0 = A[0]
for i in range(N, 0, -1):
    ans = A[i-1]
    for o in range(1, int(i ** 0.5) + 1):
        if i%o == 0:
            A[o-1]  = (A[o-1] + ans)//2
            if o != i//o:
                A[(i//o) - 1] = (A[(i//o) - 1] + ans)//2
if ans[0] != A_0:
    print(-1)
else:
    print(ans.count(1))
    [print(q) for q, w in zip(range(1, N+1), ans) if w == 1]

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
for i in range(N//2+1, 0, -1):
  sum = 0
  for o in range(1, (N//i)+1):
    sum += A[i*o-1]
  A[i-1] = sum%2
  
print(A.count(1))
ans = [str(q) for q,w in zip(range(1, N+1), A) if w == 1]
print(" ".join(ans))

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
A_0 = A[0]
for i in range(N, 0, -1):
    ans = A[i-1]
    for o in range(1, int(i ** 0.5) + 1):
        if i%o == 0:
            A[o-1]  = (A[o-1] + ans)//2
            if o != i//o:
                A[(i//o) - 1] = (A[(i//o) - 1] + ans)//2
 
if ans[0] != A_0:
    print(-1)
else:
    print(ans.count(1))
    [print(q) for q, w in zip(range(1, N+1), ans) if w == 1]

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
for i in range(N//2+1, 0, -1):
  sum = 0
  for o in range(1, (N//i)+1):
    sum += A[i*o-1]
  A[i-1] = sum%2
  
print(A.count(1))
ans = [str(q) for q,w in zip(range(1, N+1), A) if w == 1]
print(" ".join(ans))
Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input.split())
print(min(A*N, B))

Fixed submission:
N, A, B = map(int, input().split())
print(min(A*N, B))
Buggy python submission (verdict: Runtime Error):
ソースコード 

Copy
Copy
N = int(input())
count = 0
D = 0
task = [list(map(int, input().split())) for _ in range(N)]
task = sorted(task, key = lambda x:x[1])

for i in range(N):
  count += task[i][0]
  if count > task[i][1]:
    print("No")
    D = 1
    break
if D== 0:
  print("Yes")

Fixed submission:

N = int(input())
count = 0
D = 0
task = [list(map(int, input().split())) for _ in range(N)]
task = sorted(task, key = lambda x:x[1])
for i in range(N):
  count += task[i][0]
  if count > task[i][1]:
    print("No")
    D = 1
    break
if D== 0:
  print("Yes")

Buggy python submission (verdict: Runtime Error):
N = int(input())
A_list = []
B_list = []
count = 0
D = 0
for i in range(N):
  A,B = map(int, input().split())
  A_list.append(A)
  B_list.append(B)
c = zip(A, B)
c.sort(key = itemgetter(1))
A, B = zip(*c)
for o in range(N):
  count += A[i]
  if count > B[i]:
    print("No")
    D = 1
    break
if D== 0:
  print("Yes")
  
  
  

Fixed submission:

N = int(input())
count = 0
D = 0
task = [list(map(int, input().split())) for _ in range(N)]
task = sorted(task, key = lambda x:x[1])
for i in range(N):
  count += task[i][0]
  if count > task[i][1]:
    print("No")
    D = 1
    break
if D== 0:
  print("Yes")
Buggy python submission (verdict: Runtime Error):
N = int(input())
W = list(map(int, input().split()))
ans = [abs(W[0:i+1] - W[i+1:]) for i in range(N-1)]
print(min(ans))


Fixed submission:
N = int(input())
W = list(map(int, input().split()))
ww = []
for i in range(N):
  ww.append(sum(W[0:i+1]))
ans = [abs((2 * q) - ww[N-1]) for q in ww]
print(min(ans))

Buggy python submission (verdict: Runtime Error):
N = int(input())
W = list(map(int, input().split()))
ans = [abs(W[0:i+1] - W[i+1:]) for i in range(N)]
print(min(ans))


Fixed submission:
N = int(input())
W = list(map(int, input().split()))
ww = []
for i in range(N):
  ww.append(sum(W[0:i+1]))
ans = [abs((2 * q) - ww[N-1]) for q in ww]
print(min(ans))

Buggy python submission (verdict: Runtime Error):
N = int(input())
W = []
for i in range(N):
  w = int(input())
  if i == 0:
    W.append(w)
    continue
    
  W.append(w + W[i-1])
  
ans = [abs((2 * q) - W[N-1]) for q in W]
print(min(ans))


Fixed submission:
N = int(input())
W = list(map(int, input().split()))
ww = []
for i in range(N):
  ww.append(sum(W[0:i+1]))
ans = [abs((2 * q) - ww[N-1]) for q in ww]
print(min(ans))
Buggy python submission (verdict: Runtime Error):
A, P = map(int, input().split())
print((A*3 + p)//2)

Fixed submission:
A, P = map(int, input().split())
print((A*3 + P)//2)
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input.split())
if A>=13:
  print(B)
elif 6<=A<=12:
  print(B//2)
else:
  print(0)

Fixed submission:
A, B = map(int, input().split())
if A>=13:
  print(B)
elif 6<=A<=12:
  print(B//2)
else:
  print(0)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
R, G, B, N = map(int, sys.stdin.readline().split())
print(len([0 for r in range(N//R + 1) for g in range((N - (r*R))//G + 1) for b in range((N-(r * R + g * G))//B + 1) if  r*R + g*G + b*B == N]))

Fixed submission:
import sys
R, G, B, N = map(int, sys.stdin.readline().split())
print(len([0 for r in range(N//R + 1) for g in range((N - (r*R))//G + 1) if  (N -(r*R + g*G))%B == 0]))

Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())
ans = [0 for r in range(N//R + 1) for g in range((N - (r*R))//G + 1) for b in range((N-(r * R + g * G))//B + 1) if  r*R + g*G + b*B == N]
print(len(ans))

Fixed submission:
import sys
R, G, B, N = map(int, sys.stdin.readline().split())
print(len([0 for r in range(N//R + 1) for g in range((N - (r*R))//G + 1) if  (N -(r*R + g*G))%B == 0]))
Buggy python submission (verdict: Runtime Error):
B = [int(input()) for _ in range(5)]
A = [10-int(str(B[i])[-1]) for i in range(5) if str(B[i])[-1] != "0"]
A.remove(max(A))
print(sum(B)+sum(A))

Fixed submission:
B = [int(input()) for _ in range(5)]
A = [10-int(str(B[i])[-1]) for i in range(5) if str(B[i])[-1] != "0"]
if len(A) != 0:
	A.remove(max(A))
print(sum(B)+sum(A))

Buggy python submission (verdict: Runtime Error):
B = [int(input()) for _ in range(5)]
A = [str(B[i])[-1] for i in range(5)]
temp = A
last = A.index(min(temp.remove("0")))
diff = [10-int(A[o]) for o in range(5) if (A[o] != "0") and o != last]
print(sum(B)+sum(diff))


Fixed submission:
B = [int(input()) for _ in range(5)]
A = [10-int(str(B[i])[-1]) for i in range(5) if str(B[i])[-1] != "0"]
if len(A) != 0:
	A.remove(max(A))
print(sum(B)+sum(A))
Buggy python submission (verdict: Runtime Error):
import sys
N,Q = map(int,sys.stdin.readline().rstrip().split())
S = sys.stdin.readline().rstrip()
for _ in range(Q):
  l,r  = map(int,sys.stdin.readline().rstrip().split())
  print(S[l-1:r].count("AC"))
  del l
  del r

Fixed submission:
star = {"A":"T",
        "T":"A",
        "C":"G",
        "G":"C"}
print(star[input()])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
N,Q = map(int,sys.stdin.readline().rstrip().split())
S = sys.stdin.readline().rstrip()
lr = [list(map(int,sys.stdin.readline().rstrip().split())) for _ in range(Q)]
for i in lr:  
  print(S[i[0]-1:i[1]].count("AC"))


Fixed submission:
import sys
N,Q = map(int,sys.stdin.readline().rstrip().split())
S = sys.stdin.readline().rstrip()
D = [0]
DD = 0
for i in range(1,len(S)):
  if S[i-1] + S[i] == "AC":
    DD += 1
  D.append(DD)
for _ in range(Q):
  l,r  = map(int,sys.stdin.readline().rstrip().split())
  print(D[r-1]- D[l-1])
  del l
  del r

Buggy python submission (verdict: Time Limit Exceeded):
import sys
N,Q = map(int,sys.stdin.readline().rstrip().split())
S = sys.stdin.readline().rstrip()
for _ in range(Q):
  l,r  = map(int,sys.stdin.readline().rstrip().split())
  print(S[l-1:r].count("AC"))
  del l
  del r

Fixed submission:
import sys
N,Q = map(int,sys.stdin.readline().rstrip().split())
S = sys.stdin.readline().rstrip()
D = [0]
DD = 0
for i in range(1,len(S)):
  if S[i-1] + S[i] == "AC":
    DD += 1
  D.append(DD)
for _ in range(Q):
  l,r  = map(int,sys.stdin.readline().rstrip().split())
  print(D[r-1]- D[l-1])
  del l
  del r

Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int,input().split())
S = input()
for _ in range(Q):
  l,r  = map(int,input().split())
  print(S[l-1:r].count("AC"))

Fixed submission:
import sys
N,Q = map(int,sys.stdin.readline().rstrip().split())
S = sys.stdin.readline().rstrip()
D = [0]
DD = 0
for i in range(1,len(S)):
  if S[i-1] + S[i] == "AC":
    DD += 1
  D.append(DD)
for _ in range(Q):
  l,r  = map(int,sys.stdin.readline().rstrip().split())
  print(D[r-1]- D[l-1])
  del l
  del r
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int(),input().split())
print(min(B//A,C))

Fixed submission:
A, B, C = map(int,input().split())
print(min(B//A,C))
Buggy python submission (verdict: Runtime Error):
def gcd(a,b):
  return [i for i in range(1,min(a,b)+1) if a%i == 0 and b%i == 0]
   
A, B, K = map(int, input().split())
ans = gcd(A,B)
print(ans[K+1])

Fixed submission:
def gcd(a,b):
  return [i for i in range(1,min(a,b)+1) if a%i == 0 and b%i == 0]
   
A, B, K = map(int, input().split())
ans = gcd(A,B)
print(ans[-1*K])
Buggy python submission (verdict: Runtime Error):
import sys

A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())
if V <= W:
  print('NO')
  sys.exit()
if 0 < abs((B-A)//(V-W)) <= T:
  print('YES')import sys

A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())
if V <= W:
  print('NO')
  sys.exit()
t= abs(B-A)%(V-W)
if 0 < abs((B-A)//(V-W)) <= T:
  print('YES')
else:
  print('NO')



Fixed submission:
import sys

A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())
if V <= W:
  print('NO')
  sys.exit()
if 0 < abs((B-A))/(V-W) <= T:
  print('YES')
else:
  print('NO')

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

A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())
if V == W:
  print('NO')
  sys.exit()
t= (B-A)%(V-W)
if t == 0 abs(B-A)//(V-W) <= T::
  print('YES')
else:
  print('NO')
  

Fixed submission:
import sys

A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())
if V <= W:
  print('NO')
  sys.exit()
if 0 < abs((B-A))/(V-W) <= T:
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Runtime Error):
A,B = map(int,input().split())
print(int(A*B))

Fixed submission:
import sys
from decimal import Decimal
A,B= map(str,input().split())

A = Decimal(A)
B = Decimal(B)


print(int(A*B))
Buggy python submission (verdict: Time Limit Exceeded):
import sys

N = int(input())

A = list(map(int,input().split()))
L = []
R = []
for i in range(N):
  L.append(A[i]+i+1)
  R.append(i+1 - A[i])
L.sort()
R.sort()
i =0
j = 0
cnt = 0
while i<N and j <N:
  if L[i] == R[j]:
    k = j
    while k< N and R[k] == R[j]:
      k += 1
    cnt += k-j
    i += 1
    #j = min(k-1,N-1)
  else:
    if i == N-1:
      j += 1
    elif j == N-1:
      i += 1
    elif L[i] < R[j]:
      i += 1
    else:
      j += 1
print(cnt)

Fixed submission:
import sys
from collections import Counter
N = int(input())

A = list(map(int,input().split()))
L = []
R = []
for i in range(N):
  L.append(A[i]+i+1)
  R.append(i+1 - A[i])
L.sort()
R.sort()
R = Counter(R)

cnt = 0
for i in range(N):
  cnt += R[L[i]]

print(cnt)
Buggy python submission (verdict: Runtime Error):
import itertools

N,M,Q = map(int,input().split())
li = []

for i in range(Q):
  li.append(list(map(int,input().split())))
li.sort(key = lambda x:x[3])
num = [i for i in range(1,M+1)] 
l = list(itertools.combinations_with_replacement(num, M))
max_sum=-1
for i in range(len(l)):
  s = 0
  for j in range(Q):
    if l[i][li[j][1]-1] -  l[i][li[j][0]-1] == li[j][2]:
      s+= li[j][3]
      
  max_sum = max(max_sum,s)
print(max_sum)
    

Fixed submission:
import itertools

N,M,Q = map(int,input().split())
li = []

for i in range(Q):
  li.append(list(map(int,input().split())))
li.sort(key = lambda x:x[3])
num = [i for i in range(1,M+1)] 
l = list(itertools.combinations_with_replacement(num, N))
max_sum=-1
for i in range(len(l)):
  s = 0
  for j in range(Q):
    if l[i][li[j][1]-1] -  l[i][li[j][0]-1] == li[j][2]:
      s+= li[j][3]
      
  max_sum = max(max_sum,s)
print(max_sum)
Buggy python submission (verdict: Runtime Error):

import  numpy as np

arr = np.array([])
N = int(input())
for _ in range(N):
  arr = np.append(arr,input())
  
print(len(np.unique(arr)))

Fixed submission:

N = int(input())
ss = []
for i in range(N):
  ss.append(input())
  
print(len(set(ss)))

Buggy python submission (verdict: Time Limit Exceeded):

import  numpy as np

arr = np.array([])
N = int(input())
for _ in range(N):
  arr = np.append(arr,input())
  
print(len(np.unique(arr)))

Fixed submission:

N = int(input())
ss = []
for i in range(N):
  ss.append(input())
  
print(len(set(ss)))
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
  
K = int(input())
s = 0
for a in range(1,K+1):
  for b in range(1,K+1):
    for c in range(1,K+1):
      s+=gcd(a,b,c)
      
      
print(s)
      
  


Fixed submission:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
  
K = int(input())
s = 0
for a in range(1,K+1):
  for b in range(1,K+1):
    for c in range(1,K+1):
      s+=gcd(a,b,c)
      
      
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
l = list(map(int,input().split()))
c = collections.Counter(l)
li = []
for k,v in c.items():
    li.append(v*(v-1)//2)
    
for i in range(N):
  s = sum(li) - c[l[i]] + 1
  print(s)


Fixed submission:
import collections
N = int(input())
l = list(map(int,input().split()))
c = collections.Counter(l)
cnt = 0
for v in c.values():
    cnt += v*(v-1)//2
    
for i in range(N):
  print(cnt - c[l[i]] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
import copy
import collections

N = int(input())

l = list(map(int,input().split()))
lc = copy.copy(l)
for i in range(N):
  l.pop(i)
  c = collections.Counter(l)
  cnt = 0
  for v in c.values():
    cnt+=v*(v-1)//2
  l = copy.copy(lc)
  print(cnt)

Fixed submission:
import collections
N = int(input())
l = list(map(int,input().split()))
c = collections.Counter(l)
cnt = 0
for v in c.values():
    cnt += v*(v-1)//2
    
for i in range(N):
  print(cnt - c[l[i]] + 1)
Buggy python submission (verdict: Runtime Error):
h,w = (int(x) for x in input().split())



if h != 1 and w != 1:
    num = ((w // 2) + (w % 2))*( (h // 2) + ( h% 2) ) + ((w // 2) + (w % 2)-(w%2))*( (h // 2) + (h%2) -(h%2)) 
print(num)

Fixed submission:
h,w = (int(x) for x in input().split())


num  = 1
if h != 1 and w != 1:
    num = ((w // 2) + (w % 2))*( (h // 2) + ( h% 2) ) + ((w // 2) + (w % 2)-(w%2))*( (h // 2) + (h%2) -(h%2)) 
print(num)
Buggy python submission (verdict: Runtime Error):
a,b,c=int(input().splot())
if a == b:
    if a != c:
        print('yes')
    else:
        print("no")
elif a == c:
    if a != b:
        print('yes')
    else:
        print("no")
else:
    print("no")


Fixed submission:
a,b,c=input().split()
if a == b:
    if a != c:
        print('Yes')
    else:
        print("No")
elif a == c:
    if a != b:
        print('Yes')
    else:
        print("No")
elif b == c:
    if b != a:
        print('Yes')
    else:
        print("No")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
a,b,c=int(input().splot())
if a == b:
    if a != c:
        print('yes')
    else:
        print("no")
elif a == c:
    if (a != b:
        print('yes')
    else:
        print("no")
else:
    print("no")


Fixed submission:
a,b,c=input().split()
if a == b:
    if a != c:
        print('Yes')
    else:
        print("No")
elif a == c:
    if a != b:
        print('Yes')
    else:
        print("No")
elif b == c:
    if b != a:
        print('Yes')
    else:
        print("No")
else:
    print("No")