Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import itertools
n,m,q=list(map(int,input().split()))
q_l=[list(map(int,input().split())) for _ in range(q)]
#print(q_l)
#bar_l = [(i,j,k) for i in range(0,m+1) for j in range(i,m+1) for k in range(j,m+1)]
bar_m = [i for i in range(m)]
#print(bar_m)
bar_l = list(itertools.combinations_with_replacement(bar_m,m))
#print(bar_l)
score = 0
for bar in bar_l:
    score_tmp=0
    for queue in q_l:
        if bar[queue[1]-1]-bar[queue[0]-1]==queue[2]:
            score_tmp+=queue[3]
    #print(score_tmp)
    if score<score_tmp:
        score=score_tmp
print(score)


Fixed submission:
import itertools
n,m,q=list(map(int,input().split()))
q_l=[list(map(int,input().split())) for _ in range(q)]
#bar_l = [(i,j,k) for i in range(0,m+1) for j in range(i,m+1) for k in range(j,m+1)]
bar_m = [i for i in range(m)]
bar_l = list(itertools.combinations_with_replacement(bar_m,n))
score = 0
for bar in bar_l:
    score_tmp=0
    for queue in q_l:
        if bar[queue[1]-1]-bar[queue[0]-1]==queue[2]:
            score_tmp+=queue[3]
    #print(score_tmp)
    if score<=score_tmp:
        score=score_tmp
        #print(bar)
print(score)
Buggy python submission (verdict: Time Limit Exceeded):
import math
a,b,n = list(map(int,input().split()))

x=0
ans = (math.floor(a * x / b) - a * math.floor(x / b))
while(True):
    if x>=n:break
    x+=1
    ans_tmp = (math.floor(a * x / b) - a * math.floor(x / b))
    if ans>0 and ans_tmp==0: break
    else: ans=ans_tmp

print(ans)

Fixed submission:
import math
a,b,n = list(map(int,input().split()))
if b-1>=n:
    x=n
else:x=b-1
print(math.floor(a*x/b)-a*math.floor(x/b))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()

def make_num(x,y):
    return int(s[x:y])
l = [make_num(i,j) for i in range(len(s)-3) for j in range(i+4, len(s)+1) if make_num(i,j)%2019 ==0]
print(len(l))


Fixed submission:
S = input()
count = 0
l = [0] * 2019 #mod2019 は0~2018まで
l[0] = 1
mod = 2019
tmp = 0

for i in range(1, len(S) + 1):
    tmp = (tmp + int(S[len(S) - i]) * pow(10, i - 1, mod)) % mod
    #print(tmp)
    l[tmp] += 1

#print(l)
for j in range(2019):
    if l[j] >= 2:
        count += l[j] * (l[j] - 1) // 2

print(count)

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

def make_num(x,y):
    return int(s[x:y])

ans=0
for i in range(len(s)-3):
    for j in range(i+4, len(s)+1):
        if make_num(i,j)%2019==0:
            ans+=1
print(ans)

Fixed submission:
S = input()
count = 0
l = [0] * 2019 #mod2019 は0~2018まで
l[0] = 1
mod = 2019
tmp = 0

for i in range(1, len(S) + 1):
    tmp = (tmp + int(S[len(S) - i]) * pow(10, i - 1, mod)) % mod
    #print(tmp)
    l[tmp] += 1

#print(l)
for j in range(2019):
    if l[j] >= 2:
        count += l[j] * (l[j] - 1) // 2

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

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
ans_l = [0]*n
for i in A:
    ans_l[i-1]+=1
for i in ans_l:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
X,Y,A,B,C=map(int, input().split())
P=list(map(int, input().split()))
Q=list(map(int, input().split()))
R=list(map(int, input().split()))
R.sort(reverse=True)
if X > A:
    get_P= P.extend(R[:X-A+1])
    get_P.sort(reverse=True)
    R=R[X-A+1:]
else:
    P.sort(reverse=True)
    get_P=P[:X]
if Y > B:
    get_Q= Q.extend(Q[:Y-B+1])
    R=R[Y-B+1]
    get_Q.sort(reverse=True)
else:
    Q.sort(reverse=True)
    get_Q=Q[:Y]

while(min(P)<R[0] or min(Q)<R[0]):
    if min(get_P)<min(get_Q):
        get_P[get_P.index(min(get_P))] = R.pop(0)
    else:get_Q[get_Q.index(min(get_Q))] = R.pop(0)
    if R==[]:break
#print(get_P)
#print(get_Q)
print(sum(get_P)+sum(get_Q))

Fixed submission:
from collections import deque
import math
import sys

x,y,a,b,c = list(map(int,sys.stdin.readline().split()))
p = sorted(list(map(int,sys.stdin.readline().split())), reverse=True)
q = sorted(list(map(int,sys.stdin.readline().split())), reverse=True)
r = sorted(list(map(int,sys.stdin.readline().split())), reverse=True)
eat=[]

if x<len(p):
    [eat.append(red) for red in p[:x]]
else:
    [eat.append(red) for red in p]
if y<len(q):
    [eat.append(green) for green in q[:y]]
else:
    [eat.append(green) for green in q]
[eat.append(apple) for apple in r]
eat = sorted(eat, reverse=True)
#print(sum(eat[:x + y]))
ans = 0
for taste in eat[:x + y]:
    ans += taste 
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import collections

def c2c(n):
    return n*(n-1)//2

N = int(input())
A = list(map(int,input().split()))
c = collections.Counter(A)
c = c.most_common()
d = {}
for i in range(len(c)):
    d2 = 0
    for j in range(len(c)):
        if i==j:
            d2+=c2c(c[j][1]-1)
        else:
            d2+=c2c(c[j][1])
    d[c[i][0]]=d2

for i in range(len(A)):
    print(d[A[i]])

Fixed submission:
import collections

def c2c(n):
    return n*(n-1)//2

N = int(input())
A = list(map(int,input().split()))
c = collections.Counter(A)
c_l = list(c.values())
d2 = sum([c2c(i) for i in c_l])
#print(d2)

for i in range(len(A)):
    print(d2-(c[A[i]]-1))
Buggy python submission (verdict: Runtime Error):
import math
a,b,c = list(map(int,input().split()))
if c-a-b>0 and 4*a*b<(c-a-b)^2:
  print("Yes")
else:print("No")


Fixed submission:
# coding: utf-8
word=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
]
n = int(input())
print(word[n-1])

Buggy python submission (verdict: Runtime Error):
import math
a,b,c = list(map(int,input().split()))
print(math.sqrt(a))
print(math.sqrt(b))
print()
print(math.sqrt(a)+math.sqrt(b))
print(math.sqrt(c))

if c-a-b>0 and 4*a*b<(c-a-b)^2:
  print("Yes")
else:print("No")


Fixed submission:
# coding: utf-8
word=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
]
n = int(input())
print(word[n-1])

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
import math
H,W = list(map(int,input().split()))
ans = H/2
ans *= W
print(math.ceil(ans))

Fixed submission:
# coding: utf-8
word=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
]
n = int(input())
print(word[n-1])

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
word=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
n = int(input())
print(word[n])

Fixed submission:
# coding: utf-8
word=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
]
n = int(input())
print(word[n-1])
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
H,W = list(map(long,input().split()))
ans = H*W/2
if H*W%2==1:
    ans+=1
print("%d"%ans)

Fixed submission:
# coding: utf-8
import math
H,W = list(map(float,input().split()))
if H==1 or W==1:
  print("1")
else:
  ans = H*W/2
  print(math.ceil(ans))
Buggy python submission (verdict: Runtime Error):
import math
a,b,c = list(map(int,input().split()))
print(math.sqrt(a))
print(math.sqrt(b))
print()
print(math.sqrt(a)+math.sqrt(b))
print(math.sqrt(c))

if c-a-b>0 or 4ab<(c-a-b)^2:
  print("Yes")
else:print("No")


Fixed submission:
a,b,c = list(map(int,input().split()))
if c-a-b>0 and 4*a*b<(c-a-b)**2:
  print("Yes")
else:print("No")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
A,B,M = list(map(int,input().split()))

a = list(map(int,input().split()))
b = list(map(int,input().split()))

mini = min(a)+ min(b)

def check(Mlist, mini):
    if mini > a[Mlist[0]-1]+b[Mlist[1]-1]-Mlist[2]:
        return a[Mlist[0]-1]+b[Mlist[1]-1]-Mlist[2]
for i in range(M):
    mini = check(list(map(int,input().split())),mini)

print(mini)


Fixed submission:
# -*- coding: utf-8 -*-
A,B,M = list(map(int,input().split()))

a = list(map(int,input().split()))
b = list(map(int,input().split()))

mini = min(a)+ min(b)

def check(Mlist, mini):
    #print(Mlist)
    if mini > a[Mlist[0]-1]+b[Mlist[1]-1]-Mlist[2]:
        return a[Mlist[0]-1]+b[Mlist[1]-1]-Mlist[2]
    return mini
for i in range(M):
    mini = check(list(map(int,input().split())),mini)

print(mini)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
A,B,M = list(map(int,input().split()))

a = list(map(int,input().split()))
b = list(map(int,input().split()))

mini = min(a)+ min(b)

def check(Mlist, mini):
    if mini > a[Mlist[0]]+b[Mlist[1]]-Mlist[2]:
        return a[Mlist[0]]+b[Mlist[1]]-Mlist[2]
for i in range(M):
    mini = check(list(map(int,input().split())),mini)

print(mini)

Fixed submission:
# -*- coding: utf-8 -*-
A,B,M = list(map(int,input().split()))

a = list(map(int,input().split()))
b = list(map(int,input().split()))

mini = min(a)+ min(b)

def check(Mlist, mini):
    #print(Mlist)
    if mini > a[Mlist[0]-1]+b[Mlist[1]-1]-Mlist[2]:
        return a[Mlist[0]-1]+b[Mlist[1]-1]-Mlist[2]
    return mini
for i in range(M):
    mini = check(list(map(int,input().split())),mini)

print(mini)
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
#define INF 1050000000
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    string s, flag="No";
    cin >> s;
    rep(i, ARRAY_LENGTH(s)-1){
        if (s[i]!=s[i+1]) flag = "Yes";
    }
    cout <<flag<< endl;
    return 0;
}

Fixed submission:
S = list(input())
if S[0]==S[1] and S[1]==S[2]:
    print("No")
else:print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
from collections import deque
from collections import defaultdict

def comb(n, r, mod):
    X, Y = 1, 1
    for i in range(r):
        X = X * (n - i)
        Y = Y * (r - i)
    return X * pow(Y, mod-2, mod)

def main():
    n,a,b = list(map(int,sys.stdin.readline().split()))
    mod = 10**9 + 7
    ans = pow(2, n, mod) - 1
    ans = (ans - comb(n, a, mod) - comb(n, b, mod)) % mod
    print(ans)

    return 0

if __name__ == "__main__":
    main()

Fixed submission:
import sys
import math
from collections import deque
from collections import defaultdict

def comb(n, r, mod):
    X, Y = 1, 1
    for i in range(r):
        X = X * (n - i) % mod
        Y = Y * (r - i) % mod
    return X * pow(Y, mod-2, mod)

def main():
    n,a,b = list(map(int,sys.stdin.readline().split()))
    mod = 10**9 + 7
    ans = pow(2, n, mod) - 1
    ans = (ans - comb(n, a, mod) - comb(n, b, mod)) % mod
    print(ans)
    return 0

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
from collections import deque
from collections import defaultdict

def main():
    n, k = list(map(int,sys.stdin.readline().split()))
    p = list(map(int,sys.stdin.readline().split()))
    sum_max = 0
    max_idx = 0
    for i in range(n - k + 1):
        max_tmp = 0
        for j in range(k):
            max_tmp += p[i+j]
        if sum_max < max_tmp:
            max_idx = i
            sum_max = max_tmp
    #print(max_idx)
    ans = 0
    for i in range(max_idx, max_idx + k):
        ans += ((p[i] * (p[i] + 1)) / 2) / p[i]
    print("{:.12f}".format(ans))
    return 0

if __name__ == "__main__":
    main()

Fixed submission:
import sys
import math
from collections import deque
from collections import defaultdict

def main():
    n, k = list(map(int,sys.stdin.readline().split()))
    p = list(map(int,sys.stdin.readline().split()))
    sum_l = [0] * (n - k + 1)
    for i in range(k):
        sum_l[0] += p[i]
    for i in range(1,n - k + 1):
        sum_l[i] = sum_l[i - 1] - p[i - 1] + p[i + k - 1]
    #print(sum_l)
    max_idx = sum_l.index(max(sum_l))
    #print(max_idx)
    ans = 0
    for i in range(max_idx, max_idx + k):
        ans += ((p[i] * (p[i] + 1)) / 2) / p[i]
    print("{:.12f}".format(ans))
    return 0
    
if __name__ == "__main__":
    main()

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

def main():
    n, k = list(map(int,sys.stdin.readline().split()))
    p = list(map(int,sys.stdin.readline().split()))
    sum_max = 0
    max_idx = 0
    for i in range(n - k + 1):
        max_tmp = 0
        for j in range(k):
            max_tmp += p[i+j]
        if sum_max < max_tmp:
            max_idx = i
            sum_max = max_tmp
    #print(max_idx)
    ans = 0
    sigma = [i for i in range(1,1000)]
    for i in range(max_idx, max_idx + k):
        ans += sum(sigma[:p[i]]) / p[i]
    print("{:.12f}".format(ans))
    return 0

if __name__ == "__main__":
    main()

Fixed submission:
import sys
import math
from collections import deque
from collections import defaultdict

def main():
    n, k = list(map(int,sys.stdin.readline().split()))
    p = list(map(int,sys.stdin.readline().split()))
    sum_l = [0] * (n - k + 1)
    for i in range(k):
        sum_l[0] += p[i]
    for i in range(1,n - k + 1):
        sum_l[i] = sum_l[i - 1] - p[i - 1] + p[i + k - 1]
    #print(sum_l)
    max_idx = sum_l.index(max(sum_l))
    #print(max_idx)
    ans = 0
    for i in range(max_idx, max_idx + k):
        ans += ((p[i] * (p[i] + 1)) / 2) / p[i]
    print("{:.12f}".format(ans))
    return 0
    
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
for i in range(N):
    print("{:}".format(A.index(i+1)+1),end=" ")

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
"""
for i in range(N):
    print("{:}".format(A.index(i+1)+1),end=" ")"""
a = list(range(1,N+1,1))
#print(a)
A_ = dict(zip(A,a))
#print(A_)

A__ = sorted(A_.items())
#print(A__)

for i in range(N):
    print("{:}".format(A__[i][1]),end=" ")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
count = 0
for i in range(N):
    count+=i
print(count)

Fixed submission:
N = int(input())
print(N*(N-1)//2)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))

ans = 0
for i in range(2**N):
    X=0
    Y=0
    for j in range(N):
        if((i>>j)&1):
            X+=V[j]
            Y+=C[j]
        if X-Y>ans:
            ans = X-Y
print(ans)

Fixed submission:
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))
V_C = [V[i]-C[i] for i in range(N)]
ans = 0
for i in range(N):
    if V_C[i]>0:
        ans += V_C[i]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
from functools import reduce

n = int(input())
a = list(map(int,input().split()))

#累積GCD
left = [0]
right = [0]
for i in range(n):
    left.append(fractions.gcd(left[i],a[i]))
    right.insert(0,fractions.gcd(right[0],a[n - 1 - i]))

ans = 0
for i in range(n):
    ans = max(ans,fractions.gcd(left[i],right[i + 1]))
print(ans)

Fixed submission:
import fractions
from functools import reduce
from collections import deque

n = int(input())
a = deque(map(int,input().split()))

#累積GCD
left = deque([0])
right = deque([0])
for i in range(n):
    left.append(fractions.gcd(left[i],a[i]))
    right.appendleft(fractions.gcd(right[0],a[n - 1 - i]))

ans = 0
for i in range(n):
    ans = max(ans,fractions.gcd(left[i],right[i + 1]))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=list(map(int, input().split()))
h=list(map(int, input().split()))
c=[0]
for i in range(n-1):
    if i+1<k:
        d = [c[i-j]+abs(h[i-j]-h[i+1]) for j in range(i+1)]
    else:
        d = [c[i-j]+abs(h[i-j]-h[i+1]) for j in range(k)]
    c.append(min(d))
print(c[-1])

Fixed submission:
N,K=list(map(int, input().split()))
H=list(map(int, input().split()))
"""c=[0]
for i in range(N-1):
    if i+1<K:
        d = [c[i-j]+abs(H[i-j]-H[i+1]) for j in range(i+1)]
    else:
        d = [c[i-j]+abs(H[i-j]-H[i+1]) for j in range(K)]
    c.appeNd(miN(d))
#print(c[-1])"""
H = [H[0]] * K + H
#print(H)
INF = 10**18
dp = [INF] *(K+N)
#print(dp)
dp[0]=0
#print(dp)
for i in range(K, N+K):
    h = H[i]
    costs = [x+abs(y-h) for x, y in zip(dp[i - K:i], H[i - K:i])]
    dp[i] = min(costs)
#print(dp)
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,k=list(map(int, input().split()))
h=list(map(int, input().split()))
c1 = abs(h[0]-h[1])
c=[0,c1]
for i in range(n-2):
    d = []
    if i+2<k:
        for j in range(i+2):
            d.append(c[i+1-j]+abs(h[i+1-j]-h[i+2]))
    else:
        for j in range(k):
            d.append(c[i+1-j]+abs(h[i+1-j]-h[i+2]))
    c.append(min(d))
print(c[-1])

Fixed submission:
N,K=list(map(int, input().split()))
H=list(map(int, input().split()))
"""c=[0]
for i in range(N-1):
    if i+1<K:
        d = [c[i-j]+abs(H[i-j]-H[i+1]) for j in range(i+1)]
    else:
        d = [c[i-j]+abs(H[i-j]-H[i+1]) for j in range(K)]
    c.appeNd(miN(d))
#print(c[-1])"""
H = [H[0]] * K + H
#print(H)
INF = 10**18
dp = [INF] *(K+N)
#print(dp)
dp[0]=0
#print(dp)
for i in range(K, N+K):
    h = H[i]
    costs = [x+abs(y-h) for x, y in zip(dp[i - K:i], H[i - K:i])]
    dp[i] = min(costs)
#print(dp)
print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
#dp[i]...i日間で得られる幸福度の最大値
INF = 10**18
dp =[]
for _ in range(N):
    dp.append([INF] * (N+1))
dp[0] = list(map(int,input().split()))
#print(dp)
for i in range(1, N):
    #変えたいのはdp[1][0〜2]
    day = list(map(int,input().split()))
    d_temp = [dp[i-1][k]+day[j] for j in range(3) for k in range(3) if k!=j]
    #print(d_temp)
    dp[i]=[max(d_temp[2*x:2*x+2]) for x in range(3)]
print(max(dp[N-1]))


Fixed submission:
N=int(input())
dp =[[0]*3 for _ in range(N)]
dp[0]= list(map(int,input().split()))
for i in range(1,N):
    a,b,c=map(int,input().split())
    dp[i][0] = a+max(dp[i-1][1], dp[i-1][2])
    dp[i][1] = b+max(dp[i-1][2], dp[i-1][0])
    dp[i][2] = c+max(dp[i-1][0], dp[i-1][1])
print(max(dp[N-1]))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

count = 0
for i in range(1, N):
  for j in range(1, N):
    if i * j < N:
      count += 1
    else:
      break
print(count)

Fixed submission:
N = int(input())

count = 0

for i in range(1, N):
  count += int(N / i)
  if N % i == 0:
    count -= 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
a, b, c, d = list(map(int, input().split()))

max_pro = -float("inf")
for i in range(a, b + 1):
  for j in range(c, d + 1):
    product = i * j
    if max_pro < product:
      max_pro = product

print(max_pro)

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

max_pro = -float("inf")
for i in range(2):
  for j in range(1,3):
    product = abcd[i] * abcd[-j]
    if max_pro < product:
      max_pro = product

print(max_pro)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

all_sum = 0
count = 1

for i in range(n - 1):
  all_sum += a[i] * sum(a[count:len(a)])
  count += 1

print(all_sum % (10 ** 9 + 7))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
s = sum(a)

all_sum = 0
count = 1

for i in range(n - 1):
  s -= a[i]
  all_sum += a[i] * s

print(all_sum % (10 ** 9 + 7))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

all_sum = 0
for i in range(n):
  for j in range(i + 1, n):
    all_sum += a[i] * a[j]

print(all_sum % (10 ** 9 + 7))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
s = sum(a)

all_sum = 0
count = 1

for i in range(n - 1):
  s -= a[i]
  all_sum += a[i] * s

print(all_sum % (10 ** 9 + 7))
Buggy python submission (verdict: Runtime Error):
from collections import Counter

n, m = map(int, input().split())
ab = [map(int, input().split()) for _ in range(m)]
a, b = [list(i) for i in zip(*ab)]

a.extend(b)
c = Counter(a)
most = c.most_common(1)[0][0]

temp = []
for i in range(m):
  if a[i] == most or b[i] == most:
    if a[i] == b[i]:
      continue
    temp.append(a[i])
    temp.append(b[i])
temp = list(set(temp))
print(len(temp))

Fixed submission:
import networkx as nx
n,m=map(int, input().split())
uf=nx.utils.UnionFind()
for _ in range(m):
    a,b=map(int, input().split())
    uf.union(a, b)
ans=1
for i in uf.to_sets():
    ans=max(ans,len(i))
print(ans)

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

n, m = map(int, input().split())
ab = [map(int, input().split()) for _ in range(m)]
a, b = [list(i) for i in zip(*ab)]

a.extend(b)
c = Counter(a)
most = c.most_common(1)[0][0]

temp = []
for i in range(m):
  if a[i] == most or b[i] == most:
    temp.append(a[i])
    temp.append(b[i])
temp = list(set(temp))
print(len(temp))

Fixed submission:
import networkx as nx
n,m=map(int, input().split())
uf=nx.utils.UnionFind()
for _ in range(m):
    a,b=map(int, input().split())
    uf.union(a, b)
ans=1
for i in uf.to_sets():
    ans=max(ans,len(i))
print(ans)
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())

sc = {}

def main():
    for i in range(M):
        s,c = input().split()
        s = int(s)
        if s not in sc:
            sc[s] = c
        else:
            if sc[s] != c:
                return -1
                break


    ans = ["0"] * N

    for k,n in sc.items():
        ans[k-1] = n

    result = ''.join(ans)
    if result[0] != '0' or result == '0':
        return result
    else:
        result[0] = '1'    
        return int(result)

FUCK = main()
print(FUCK)        

Fixed submission:
def main():
    sc = {}
    N,M = map(int,input().split())
    for _ in range(M):
        s,c = input().split()
        s = int(s)
        if s not in sc:
            sc[s] = c
        else:
            if sc[s] != c:
                return -1

    if 1 in sc and sc[1] == '0' and N != 1:
        return -1

    ans = ["0"] * N

    for k,n in sc.items():
        ans[k-1] = n

    result = ''.join(ans)
    if result[0] != '0' or result == '0':
        return result
    else:
        result = '1' + result[1:]    
        return int(result)


print(main())
Buggy python submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())
za=abs(a)
zb=abs(b)
zc=abs(c)
zd=abs(d)
if b>=0 and d>=0 :
  if a>0 or c>0:
    print(b*d)
  else:
    ans=max(a*c,b*d)
    print(ans)
elif b<0 and d<0 :
  x=max(za,zb)
  y=max(zc,zd)
  print(x*y)
else:
  if b>=0 and d<0 :
  	x=max(za,zb)
  	y=max(zc,zd)
  	print(x*y)
  else:
  	x=max(za,zb)
  	y=max(zc,zd)
  	print(x*y)



Fixed submission:
x=int(input())
if x ==1:
  print(0)
else:
  print(1)
Buggy python submission (verdict: Runtime Error):
N=int(input())
ans=[0 for a in range(1000)]
for i in range(1,101):
  for x in range(1,101):
    for y in range(1,101):
      v=x*x+y*y+i*i+x*y+y*i+i*x
      if v<=N:
        ans[v]+=1
for b in range(1,N+1):
  print(ans[b])

Fixed submission:
N=int(input())
ans=[0 for a in range(11000)]
for i in range(1,101):
  for x in range(1,101):
    for y in range(1,101):
      v=x*x+y*y+i*i+x*y+y*i+i*x
      if v<=N:
        ans[v]+=1
for b in range(1,N+1):
  print(ans[b])

Buggy python submission (verdict: Runtime Error):
N=int(input())
ans=[0 for a in range(100)]
for i in range(1,101):
  for x in range(1,101):
    for y in range(1,101):
      v=x*x+y*y+i*i+x*y+y*i+i*x
      if v<=N:
        ans[v]+=1
for b in range(1,N+1):
  print(ans[b])
      

Fixed submission:
N=int(input())
ans=[0 for a in range(11000)]
for i in range(1,101):
  for x in range(1,101):
    for y in range(1,101):
      v=x*x+y*y+i*i+x*y+y*i+i*x
      if v<=N:
        ans[v]+=1
for b in range(1,N+1):
  print(ans[b])