Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = []
for i in range(n):
    a.append(str(input()))
b = []
for i in range(m):
    b.append(str(input()))

f = [0]*m
count = 0
for j in range(m):
    f[j] = a[j].find(b[j])

while -1 in f: f.remove(-1)
if len(f) == 0:
    print('No')
else:
    flag = 1
    for i in range(len(f)):
        if (b[f[i]] in a[f[i]]) == False:
            flag =0
    if flag == 1:
        print('Yes')
    else:
        print('No')

Fixed submission:
n,m = map(int,input().split())
a = []
for i in range(n):
    a.append(str(input()))
b = []
for i in range(m):
    b.append(str(input()))

f = [0]*m
tmp = []
for j in range(m):
    f[j] = a[j].find(b[j])
    if f[j] != -1:
        tmp.append(j)
while -1 in f: f.remove(-1)

try:
    if len(f) == 0:
        print('No')
    else:
        count = 0
        for i in range(len(tmp)):
            count += 1
            if (b[tmp[i]] in a[tmp[i]]) == False:
                count = 0
        if count == m:
            print('Yes')
        else:
            print('No')
except:
    print('No')

Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = []
for i in range(n):
    a.append(str(input()))
b = []
for i in range(m):
    b.append(str(input()))

f = [0]*m
count = 0
for j in range(m):
    f[j] = a[j].find(b[j])

while -1 in f: f.remove(-1)
if len(f) == 0:
    print('No')
else:
    flag = 1
    for i in range(len(f)):
        if  b[f[i]] in a[f[i]]:
            pass
        else:
            flag =0
    if flag == 1:
        print('Yes')
    else:
        print('No')

Fixed submission:
n,m = map(int,input().split())
a = []
for i in range(n):
    a.append(str(input()))
b = []
for i in range(m):
    b.append(str(input()))

f = [0]*m
tmp = []
for j in range(m):
    f[j] = a[j].find(b[j])
    if f[j] != -1:
        tmp.append(j)
while -1 in f: f.remove(-1)

try:
    if len(f) == 0:
        print('No')
    else:
        count = 0
        for i in range(len(tmp)):
            count += 1
            if (b[tmp[i]] in a[tmp[i]]) == False:
                count = 0
        if count == m:
            print('Yes')
        else:
            print('No')
except:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding:utf-8 -*-
import numpy as np
def button(t):
    tmp = [1]*(t+1)
    tmp2 = [0]*(n-t-1)
    tmp3 = tmp+tmp2
    tmp3 = np.array(tmp3)
    global a
    a = a+tmp3
    return 0

n = int(input())
global a
a = [0]*n
b = [0]*n

for i in range(n):
    a[i],b[i] = map(int,input().split())
a = np.array(a)

count = 0
for i in range(n):
    while True:
        if a[n-1-i] % b[n-1-i] == 0:
            break
        else:
            button(n-1-i)
            count += 1

print(count)

Fixed submission:
n = int(input())
a = [0]*n
b = [0]*n

for i in range(n):
    a[i],b[i] = map(int,input().split())
a.reverse()
b.reverse()
count = 0
for i in range(n):
    if (a[i]+count)%b[i] == 0:
        pass
    elif a[i]+count > b[i]:
        count += (b[i]*(((a[i]+count)//b[i])+1))-(a[i]+count)
    else:
        count += b[i] - (a[i]+count)
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
def button(t):
    for k in range(t+1):
        a[k] += 1
    return a

n = int(input())
a = [0]*n
b = [0]*n

for i in range(n):
    a[i],b[i] = map(int,input().split())

count = 0
for i in range(n):
    while True:
        if a[n-1-i] % b[n-1-i] == 0:
            break
        else:
            button(n-1-i)
            count += 1

print(count)

Fixed submission:
n = int(input())
a = [0]*n
b = [0]*n

for i in range(n):
    a[i],b[i] = map(int,input().split())
a.reverse()
b.reverse()
count = 0
for i in range(n):
    if (a[i]+count)%b[i] == 0:
        pass
    elif a[i]+count > b[i]:
        count += (b[i]*(((a[i]+count)//b[i])+1))-(a[i]+count)
    else:
        count += b[i] - (a[i]+count)
print(count)
Buggy python submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-
import math
import sys

def mark(s, x):
    for i in range(x + x, len(s), x):
        s[i] = False

def sieve(n):
    s = [True] * n
    for x in range(2, int(n**0.5) + 1):
        if s[x]: mark(s, x)
    return [i for i in range(0,n) if s[i] and i > 1]

n = int(input())
p = sieve(n)
arr = [0]*len(p)
n = math.factorial(n)

for i in range(len(p)):
    flag = 1
    k = p[i]
    while flag:
        if n%k == 0:
            k = k*p[i]
            arr[i] += 1
        else:
            flag = 0

x = 1
for i in range(len(arr)):
    if arr[i] != 0:
        x *= (arr[i]+1)
if ( n = 6):
    print(4)
else:
    print(x%(10**9+7))

Fixed submission:
a,b,c,d = map(int,input().split())
s1 = a*b
s2 = c*d
if s1 >= s2:
    print(s1)
else:
    print(s2)
Buggy python submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-
import math
import sys

def mark(s, x):
    for i in range(x + x, len(s), x):
        s[i] = False

def sieve(n):
    s = [True] * n
    for x in range(2, int(n**0.5) + 1):
        if s[x]: mark(s, x)
    return [i for i in range(0,n) if s[i] and i > 1]

n = int(input())
p = sieve(n)
arr = [0]*len(p)
n = math.factorial(n)

for i in range(len(p)):
    flag = 1
    k = p[i]
    while flag:
        if n%k == 0:
            k = k*p[i]
            arr[i] += 1
        else:
            flag = 0

x = 1
for i in range(len(arr)):
    if arr[i] != 0:
        x *= (arr[i]+1)
if ( n = 6):
    print(4)
else:
    print(x%(10**9+7))

Fixed submission:
n = int(input())

arr = [0] * (n+1)

for i in range(1,n+1):
    x = []
    while i % 2 == 0:
        x.append(2)
        i = i // 2
    f = 3
    while f * f <= i:
        if i % f == 0:
            x.append(f)
            i = i // f
        else:
            f += 2
    if i != 1:
        x.append(i)

    for k in range(len(x)):
        arr[x[k]] += 1

ans = 1
for i in range(len(arr)):
    ans *= (arr[i] + 1)
print(ans % (10**9 + 7))
Buggy python submission (verdict: Time Limit Exceeded):
n = input()
n = n.split()
K,S = map(int, n)
count = 0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x+y+z == S:
                count += 1
print(count)

Fixed submission:
arr = input().split()
k = int(arr[0])
s = int(arr[1])

count = 0
for x in range(k+1):
    for y in range(k+1):
        if s - x - y >= 0:
           z = s - x - y
           if z <= k:
               count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding:utf-8 -*-
n = input()
n = n.split()
K,S = map(int, n)

count = 0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x+y+z == S:
                count += 1
print(count)

Fixed submission:
arr = input().split()
k = int(arr[0])
s = int(arr[1])

count = 0
for x in range(k+1):
    for y in range(k+1):
        if s - x - y >= 0:
           z = s - x - y
           if z <= k:
               count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
arr = input().split()
arr = list(map(int,arr))
a = arr[0]
b = arr[1]
x = arr[2]

c = a
left = 0
while(True):
    if c % x == 0:
        left = c
        break
    else:
        c += 1

c = b
while(True):
    if c % x == 0:
        right = c
        break
    else:
        c -= 1

print((right - left) // x + 1)


Fixed submission:
arr = input().split()
arr = list(map(int,arr))
a = arr[0]
b = arr[1]
x = arr[2]

def f(n):
    if n == -1:
        return 0
    else:
        return n // x + 1

print(f(b) - f(a-1))
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**5)

n,m=map(int,input().split())
g=[[] for i in range(10**5+10)]
for i in range(m):
  a,b=map(lambda x:int(x)-1, input().split())
  g[a].append(b)
  g[b].append(a)
chk=[-1]*n

def dfs(s,v,cnt):
  for u in g[s]:
    if u==v: continue;
    chk[u]=cnt
    dfs(u,s,cnt)

cnt=0
for i in range(n):
  if chk[i]==-1:
    chk[i]=cnt
    dfs(i,-1,cnt)
    cnt+=1
    
print(max(chk))

Fixed submission:
import sys
sys.setrecursionlimit(10**5)

n,m=map(int,input().split())
g=[[] for i in range(10**5+10)]
for i in range(m):
  a,b=map(lambda x:int(x)-1, input().split())
  g[a].append(b)
  g[b].append(a)
chk=[-1]*n

def dfs(s,cnt):
  for u in g[s]:
    if chk[u]>-1: continue;
    chk[u]=cnt
    dfs(u,cnt)

cnt=0
for i in range(n):
  if chk[i]==-1:
    chk[i]=cnt
    dfs(i,cnt)
    cnt+=1
    
print(max(chk))
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=[int(input()) for i in range(n)]
subs=[[] for i in range(n)]

idx=0
for ai in a:
  for i in range(idx+1):
    if len(subs[i])==0:
      subs[i].append(ai)
      idx+=1
      break
    else:
      if abs(subs[i][-1]-ai)<=k:
        subs[i].append(ai)

ans=0
for i in range(idx):
  #print(subs[i])
  ans=max(ans,len(subs[i]))
print(ans)

Fixed submission:
n,k=map(int,input().split())
a=[int(input()) for _ in range(n)]
l=[[] for i in range(n)]

l[0].append(a[0])
ans=0
for ai in a[1:]:
  for i in reversed(range(ans+1)): # if can a_i put backword, add l[i+1]. because of maximum length answer 
    for li in l[i]:
      if -k<=(li-ai)<=k:
        ans=max(ans,i+1)
        l[i+1].append(ai)
        break
    else:
      continue
    break
  else:
    l[0].append(ai)

print(ans+1)
Buggy python submission (verdict: Time Limit Exceeded):
k=int(input())

if k%2==0:
  print(-1); exit()

cnt=num=0
while 1:
  num+=7*pow(10,cnt,k)
  num%=k
  cnt+=1
  if num==0:
    break
print(cnt)

Fixed submission:
K = int(input())

cnt=1
Num=7%K
while cnt<=K:
  if K%2==0:
    print('-1')
    break
  if Num%K==0:
    print(cnt)
    break
  else:
    Num = (10*Num + 7)%K
    cnt+=1
else:
  print('-1')

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

if k%2==0:
  print(-1); exit()

cnt=num=0
while 1:
  num+=7*pow(10,cnt,k)
  cnt+=1
  if num%k==0:
    break
print(cnt)

Fixed submission:
K = int(input())

cnt=1
Num=7%K
while cnt<=K:
  if K%2==0:
    print('-1')
    break
  if Num%K==0:
    print(cnt)
    break
  else:
    Num = (10*Num + 7)%K
    cnt+=1
else:
  print('-1')

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

cnt=1
Num=7
while True:
  if K%2==0:
    print('-1')
    break
  if Num%K==0:
    print(cnt)
    break
  else:
    Num+=7*10**cnt
    cnt+=1
    



Fixed submission:
K = int(input())

cnt=1
Num=7%K
while cnt<=K:
  if K%2==0:
    print('-1')
    break
  if Num%K==0:
    print(cnt)
    break
  else:
    Num = (10*Num + 7)%K
    cnt+=1
else:
  print('-1')
Buggy python submission (verdict: Runtime Error):
def main():
  l,r=0,10**9
  while r-l>1:
    m=(l+r)//2
    if sum([(i-1)//x for i in a])<=k: r=m;
    else: l=m;
  print(r)

if __name__=='__main__':
  n,k=map(int,input().split())
  a=list(map(int,input().split()))
  main()

Fixed submission:
def f(x):
  return sum([(i-1)//x for i in a])<=k

def main():
  l,r=0,10**9
  while r-l>1:
    m=(l+r)//2
    if f(m): r=m;
    else: l=m;
  print(r)

if __name__=='__main__':
  n,k=map(int,input().split())
  a=list(map(int,input().split()))
  main()
Buggy python submission (verdict: Time Limit Exceeded):
N, M, K = map(int, input().split())
A=list(map(int, input().split()))
B=list(map(int, input().split()))

Asum=[0]
Bsum=[0]
for i, a in enumerate(A):
  Asum.append(Asum[i]+a)
for i, b in enumerate(B):
  Bsum.append(Bsum[i]+b)

ans = 0 
for a, asum in enumerate(Asum):
  if asum > K:
    break
  b=M
  while Bsum[b]>K - asum:
    b-=1
  ans = max(ans, a+b)
print(ans)
 


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

Asum=[0]
Bsum=[0]
for i, a in enumerate(A):
  Asum.append(Asum[i]+a)
for i, b in enumerate(B):
  Bsum.append(Bsum[i]+b)

ans, b = 0, M
for a, asum in enumerate(Asum):
  if asum > K:
    break
  while Bsum[b]>K - asum:
    b-=1
  ans = max(ans, a+b)
print(ans)

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

Asum=[0]
Bsum=[0]
for i, a in enumerate(A):
  Asum.append(Asum[i]+a)
for i, b in enumerate(B):
  Bsum.append(Bsum[i]+b)

ans = 0 
for a, asum in enumerate(Asum):
  if asum > K:
    break
  b=M
  while Bsum[b]>K - asum:
    b-=1
  ans = max(ans, a+b)
print(ans)
 


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

Asum=[0]
Bsum=[0]
for i, a in enumerate(A):
  Asum.append(Asum[i]+a)
for i, b in enumerate(B):
  Bsum.append(Bsum[i]+b)

ans, b = 0, M
for a, asum in enumerate(Asum):
  if asum > K:
    break
  while Bsum[b]>K - asum:
    b-=1
  ans = max(ans, a+b)
print(ans)

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

t=0
newA=[]
for a in A:
  t += a
  newA.append(a)
  if t>LIMIT:
    newA.pop()
    break
    
newA=sorted(newA)
newAsum=[0]
for i, v in enumerate(newA):
  newAsum.append(newAsum[i]+v)

cnt=0
for i, a in enumerate(newAsum):
  j=0
  cnt2=i
  t = a
  for b in B:
    t += b
    if t>LIMIT:
      break
    cnt2+=1
  cnt = max(cnt, cnt2)
print(cnt)


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

Asum=[0]
Bsum=[0]
for i, a in enumerate(A):
  Asum.append(Asum[i]+a)
for i, b in enumerate(B):
  Bsum.append(Bsum[i]+b)

ans, b = 0, M
for a, asum in enumerate(Asum):
  if asum > K:
    break
  while Bsum[b]>K - asum:
    b-=1
  ans = max(ans, a+b)
print(ans)
Buggy python submission (verdict: Runtime Error):
X, N = map(int, input().split())

if N==0:
  print(X)
  exit(0)
  
p = [int(i) for i in input().split()]

for i in range(X+1):
  for s in [-1,1]:
    a = X + i*s
    if a not in p:
      print(a)
      exit(0)
  

Fixed submission:
print(input().split().index('0')+1)
Buggy python submission (verdict: Runtime Error):
A, B = int(input()), int(input())
print(A*B)

Fixed submission:
A, B = map(int, input().split())
print(A*B)
Buggy python submission (verdict: Runtime Error):
from collections import deque

N,M=map(int,input().split())
G=[[] for _ in range(N+1)]
for i in range(M):
  a,b=map(int,input().split())
  G[a].append(b)
  G[b].append(a)

ans=[0]*(N+1)
d=deque([1])
while d:
  c=d.popleft()
  for g in G[c]:
    if not ans[g]:
      d.append(g)
      ans[g]=c

print('Yes')
for i in range(2, N+1):
  print(ans[i])

Fixed submission:
import math

A, B, H, M = map(int, input().split())

# for one minute
A_deg=H*(360/12) + M*(360/12/60)
B_deg=M*(360/60)
deg=abs(A_deg-B_deg)

ans = math.sqrt(
  A**2+
  B**2-
  2*A*B*math.cos(math.radians(deg))
)

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
GACHA=set()
for n in range(N):
  GACHA.add(input())
print(len(GACHA))

Fixed submission:
import itertools

N, M, Q = map(int, input().split())
ABCD = [[int(x) for x in input().split()] for i in range(Q)]

ans=0
for A in itertools.combinations_with_replacement([m for m in range(1,M+1)], N):
  ans2=0
  for (a,b,c,d) in ABCD:
    if A[b-1]-A[a-1]==c:
      ans2+=d
  ans=max(ans, ans2)
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
GACHA=[input() for n in range(N)]
print(len(set(GACHA)))

Fixed submission:
import itertools

N, M, Q = map(int, input().split())
ABCD = [[int(x) for x in input().split()] for i in range(Q)]

ans=0
for A in itertools.combinations_with_replacement([m for m in range(1,M+1)], N):
  ans2=0
  for (a,b,c,d) in ABCD:
    if A[b-1]-A[a-1]==c:
      ans2+=d
  ans=max(ans, ans2)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s=input()[::-1]
n=len(s)
p=2019
S=[0 for i in range(n+1)]
ans=[0]*p

x10=1
for j, i in enumerate(s):
  S[j+1]=(S[j]+(x10*int(i)))%p
  x10*=10
  ans[S[j+1]]+=1

cnt=ans[0]
for a in ans:
  cnt+=(a*(a-1))//2
  
print(cnt)


Fixed submission:
s=input()[::-1]
p=2019
ans=[0]*p

x10, S=1, 0
for i in s:
  S+=x10*int(i)
  S%=p
  x10*=10
  x10%=p
  ans[S]+=1

cnt=ans[0]
for a in ans:
  cnt+=(a*(a-1))//2
  
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()[::-1]
n=len(s)
p=2019
S=[0 for i in range(n+1)]
ans=[0]*p

for j, i in enumerate(s):
  S[j+1]=(S[j]+(10**(j)*int(i)))%p
  ans[S[j+1]]+=1

cnt=ans[0]
for a in ans:
  cnt+=(a*(a-1))//2
  
print(cnt)


Fixed submission:
s=input()[::-1]
p=2019
ans=[0]*p

x10, S=1, 0
for i in s:
  S+=x10*int(i)
  S%=p
  x10*=10
  x10%=p
  ans[S]+=1

cnt=ans[0]
for a in ans:
  cnt+=(a*(a-1))//2
  
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()[::-1]
n=len(s)
p=2019
ans=[0]*p

x10=1
S=0
for i in s:
  S+=x10*int(i)
  S%=p
  x10*=10%p
  ans[S]+=1

cnt=ans[0]
for a in ans:
  cnt+=(a*(a-1))//2
  
print(cnt)


Fixed submission:
s=input()[::-1]
p=2019
ans=[0]*p

x10, S=1, 0
for i in s:
  S+=x10*int(i)
  S%=p
  x10*=10
  x10%=p
  ans[S]+=1

cnt=ans[0]
for a in ans:
  cnt+=(a*(a-1))//2
  
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()[::-1]
n=len(s)
p=2019
S=[0 for i in range(n+1)]
ans=[0]*p

for i in range(n):
  S[i+1]=(S[i]+(10**(i)*int(s[i]))%p)%p
  ans[S[i+1]]+=1

cnt=ans[0]
for i, a in enumerate(ans):
  cnt+=(a*(a-1))//2
  
print(cnt)


Fixed submission:
s=input()[::-1]
p=2019
ans=[0]*p

x10, S=1, 0
for i in s:
  S+=x10*int(i)
  S%=p
  x10*=10
  x10%=p
  ans[S]+=1

cnt=ans[0]
for a in ans:
  cnt+=(a*(a-1))//2
  
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()[::-1]
n=len(s)
p=2019
S=[0 for i in range(n+1)]
ans=[0]*p

for i in range(n):
  S[i+1]=(S[i]+(10**(i)*int(s[i]))%p)%p
  ans[S[i+1]]+=1

cnt=ans[0]
for i, a in enumerate(ans):
  if i:
  	cnt+=(a*(a-1))//2
  
print(cnt)


Fixed submission:
s=input()[::-1]
p=2019
ans=[0]*p

x10, S=1, 0
for i in s:
  S+=x10*int(i)
  S%=p
  x10*=10
  x10%=p
  ans[S]+=1

cnt=ans[0]
for a in ans:
  cnt+=(a*(a-1))//2
  
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()[::-1]
n=len(s)
p=2019
S=[0 for i in range(n+1)]
ans=[0]*p

for i in range(n):
  S[i+1]=(S[i]+(10**(i)*int(s[i])))%p
  ans[S[i+1]]+=1

cnt=ans[0]
for i, a in enumerate(ans):
  if i:
  	cnt+=(a*(a-1))//2
  
print(cnt)


Fixed submission:
s=input()[::-1]
p=2019
ans=[0]*p

x10, S=1, 0
for i in s:
  S+=x10*int(i)
  S%=p
  x10*=10
  x10%=p
  ans[S]+=1

cnt=ans[0]
for a in ans:
  cnt+=(a*(a-1))//2
  
print(cnt)
Buggy python submission (verdict: Runtime Error):
def main():
  N, K, C=map(int, input().split())
  S = input()
  
  S=S[::-1]
  R=set()
  n, k=0, 0
  while k < K:
    if S[n]=='o':
      R.add(N-n)
      k+=1
      n += C
    n+=1
  #print(R)
  
  S=S[::-1]
  n, k=0, 0
  while k < K:
    if S[n]=='o':
      if n+1 in R:
        print(n+1)
      k+=1
      n += C
    n+=1
  #print(L)
  

  
if __name__=='__main__':
  main()


Fixed submission:
from collections import deque

def main():
  N=int(input())
  for n in range(N):
    x=ans.popleft()
    if x%10!=0:
      ans.append(10*x+(x%10)-1) # x equal y-1
    ans.append(10*x+(x%10)) # x equal y
    if x%10!=9:
      ans.append(10*x+(x%10)+1) # x equal y+1
  print(x)
  
if __name__=='__main__':
  ans=deque([1,2,3,4,5,6,7,8,9])
  main()
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=[int(a) for a in input().split()]
Acnt=[A.count(n) for n in range(N)]
Aprob=[Acnt[n]*(Acnt[n]-1)//2 for n in range(N)]
sumA=sum(Aprob)  

for a in A:
  """
  ai=[]
  ai=A[:n]+A[n+1:]
  #print(ai)
  Adic[A[n]]-=1
  ans=0
  for i,v in Adic.items():
    ans+=v*(v-1)//2
  """
  ans=(Acnt[a]-1)*(Acnt[a]-2)//2
  print(ans+sumA-Aprob[a])
  
  



Fixed submission:
def main():
  N=int(input())
  A=[int(a) for a in input().split()]
  Acnt, Aprob={}, {}
  for a in A:
    Acnt[a] = Acnt.get(a, 0) + 1
  sumA=0
  for k, a in Acnt.items():
    Aprob[k]=a*(a-1)//2
    sumA+=Aprob[k]
  #Acnt=[A.count(n) for n in range(N+1)]
  #Aprob=[Acnt[n]*(Acnt[n]-1)//2 for n in range(N+1)]
  #sumA=sum(Aprob)

  for a in A:
    ans=(Acnt[a]-1)*(Acnt[a]-2)//2
    print(ans+sumA-Aprob[a])
  
main()
Buggy python submission (verdict: Runtime Error):
S=input()
print('No' if S=='AAA' or S==='BBB' else 'Yes')

Fixed submission:
S=input()
print('No' if S=='AAA' or S=='BBB' else 'Yes')
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
Query=[input().split() for q in range(Q)]

for i, q in enumerate(Query):
  if q[0]=='1':
    S=S[::-1]
  else:
    if q[1]=='1':
      S=q[2]+S
    else:
      S=S+q[2]
print(S)


Fixed submission:
def main():
  S = input()
  Q = int(input())
  Query=[input().split() for q in range(Q)]
  cnt=0
  prefix, suffix = '', ''
  for q in Query:
    if q[0]=='1':
      cnt=1^cnt
      prefix, suffix = suffix, prefix
      #print(cnt)
    else:
      if q[1]=='1':
        prefix=prefix+q[2]
      else:
        suffix=suffix+q[2]
  if cnt:
    S=S[::-1]
  print(prefix[::-1]+S+suffix)

main()
Buggy python submission (verdict: Runtime Error):
N, R = map(int, input().split())
print(R if N>=10 else R-100*(10-K))

Fixed submission:
N, R = map(int, input().split())
print(R if N>=10 else R+100*(10-N))
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
P = [(int(x)+1)/2 for x in input().split()]

total=ans=sum(P[:K])
for n in range(K,N):
  total+=P[n]-P[n-K]
  ans=max(ans, total)

print(ans)


Fixed submission:
a,b=input().split()
ST={}
ST[a], ST[b] = map(int, input().split())
ST[input()]-=1

for k,v in ST.items():
  print(v,end=' ')
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
print('Yes' if N==M else 'No)

Fixed submission:
N, M = map(int, input().split())
print('Yes' if N==M else 'No')
Buggy python submission (verdict: Runtime Error):
print('bust' if sum(list(map,input().split()))>=22 else 'win')

Fixed submission:
print('bust' if sum(list(map(int,input().split())))>=22 else 'win')
Buggy python submission (verdict: Runtime Error):
N=int(input())
XY=[[[]] for n in range(N)]
for n in range(1,N+1):
  a=int(input())
  XY[n]=[list(map(int, input().split())) for _ in range(a)]

maxH=0
for mask_i in range(1<<N):
  
  H=[0]*(N+1)
  for n in range(N):
    if mask_i>>n&1:
      H[n+1]=1
  #print(H[1:])
  
  for n in range(1,N+1):
    ok=True
    if H[n]==1:
      for x,y in XY[n]:
        if H[x]!=y:
          ok=False
          break
  if ok:
    maxH=max(maxH,sum(H))

print(maxH)


Fixed submission:
N=int(input())
XY=[[[]] for n in range(N+1)]
for n in range(1,N+1):
  a=int(input())
  XY[n]=[list(map(int, input().split())) for _ in range(a)]

maxH=0
for mask_i in range(1<<N):
  
  H=[0]*(N+1)
  for n in range(N):
    if mask_i>>n&1:
      H[n+1]=1
  #print(H[1:])
  
  ok=True
  for n in range(1,N+1):
    if H[n]==1:
      for x,y in XY[n]:
        if H[x]!=y:
          ok=False
          break
  if ok:
    maxH=max(maxH,sum(H))

print(maxH)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))

ans=0
for i in range(N-1):
  for j in range(i+1,N):
    ans+=A[i]^A[j]
print(ans%(10**9+7))

Fixed submission:
N=int(input())
M=10**9+7
A=[int(x) for x in input().split()]

ans=p=0
for i in range(60):
  one=sum([a>>p&1 for a in A])
  zero=N-one
  p+=1
  ans+=(one*zero)*2**i
  ans%=M
  #print(one,zero)
print(ans)
Buggy python submission (verdict: Runtime Error):
ans=0
for i in range(1,10):
  for j in range(1,10):
    if int(input())==i*j:
      ans=1
print('Yes' if ans else 'No')

Fixed submission:
n=int(input())
ans=0
for i in range(1,10):
  for j in range(1,10):
    if n==i*j:
      ans=1
print('Yes' if ans else 'No')