Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02891 (python)

Fixed submission:
s = str(input())
k = int(input())

def func(s, k):
    ans = 0
    n = len(s)
    s_list = list(s)
    for i in range(n - 1):
        if s_list[i] == s_list[i + 1]:
            ans += 1
            s_list[i + 1] = str(i + 1)
    ans *= k
    if s_list[0] == s_list[n - 1]:
        ans += k - 1
    return ans

ans1 = func(s, k)
s_inv = ''.join(list(reversed(s)))
ans2 = func(s_inv, k)

if len(s) % 2 == 1:
    check = True
    for i in range(len(s) - 1):
        if s[i] == s[i + 1]:
            pass
        else:
            check = False
            break
    if check:
        ans3 = len(s) * k // 2
    else:
        ans3 = ans1
else:
    ans3 = ans1

print(min(ans1, ans2, ans3))

Buggy submission (verdict: Runtime Error):
s = str(input())
k = int(input())

def func(s, k):
    ans = 0
    n = len(s)
    s_list = list(s)
    for i in range(n - 1):
        if s_list[i] == s_list[i + 1]:
            ans += 1
            s_list[i + 1] = str(i + 1)
    ans *= k
    if s_list[0] == s_list[n - 1]:
        ans += k - 1
    return ans

ans1 = func(s, k)
s_inv = ''.join(list(reversed(s)))
ans2 = func(s_inv, k)

if len(s) % 2 == 1:
    check = True
    for i in range(len(s) - 1):
        if s[i] == s[i + 1]:
            pass
        else:
            check = False
            break
if check:
    ans3 = len(s) * k // 2
else:
    ans3 = ans1

print(min(ans1, ans2, ans3))
Problem p03075 (python)

Fixed submission:
num_list = []
while True:
    try:
        element = input()
    except EOFError:
        break

    num_list.append(int(element))

limit = num_list[-1]

ans_string = "Yay!"
# for i in range(len(num_list) - 1):
#     print(num_list[i + 1] - num_list[i])
#     if num_list[i + 1] - num_list[i] > limit:
#         ans_string = ":("

for i in range(len(num_list) - 1):
    for j in range(i, len(num_list) - 1):
        if num_list[j] - num_list[i] > limit:
            ans_string = ":("

print(ans_string)

Buggy submission (verdict: Runtime Error):
num_list = []
while True:
    element = input()
    if element is None:
        break

    if element == '':
        break

    num_list.append(int(element))

limit = num_list[-1]

ans_string = "Yay!"
# for i in range(len(num_list) - 1):
#     print(num_list[i + 1] - num_list[i])
#     if num_list[i + 1] - num_list[i] > limit:
#         ans_string = ":("

for i in range(len(num_list) - 1):
    for j in range(i, len(num_list) - 1):
        if num_list[j] - num_list[i] > limit:
            ans_string = ":("

print(ans_string)
Problem p02990 (python)

Fixed submission:
from math import factorial

def combinations_count(n, r):
    ''' 組み合わせ '''
    return factorial(n) // (factorial(n - r) * factorial(r))

n,k=map(int,input().split())
mod=10**9+7
ans=[n-k+1]
for i in range(2,k+1):
        if n-k+1<i:
                ans.append(0)
        else:
                k_sep=(combinations_count(k-1,i-1))%mod
                if n-k==i-1:
                        l_sep=1
                elif n-k==i:
                        l_sep=n-k+1
                else:
                        l_sep=(combinations_count(n-k-1,i-2)+2*combinations_count(n-k-1,i-1)+combinations_count(n-k-1,i))%mod
                ans.append((k_sep*l_sep)%mod)
for ii in range(k):
        print(ans[ii])

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
n,k=map(int,input().split())
mod=10**9+7
ans=[n-k+1]
for i in range(2,k+1):
        if n-k+1<i:
                ans.append(0)
        else:
                k_sep=(comb(k-1,i-1,exact=True))%mod
                if n-k==i-1:
                        l_sep=1
                elif n-k==i:
                        l_sep=n-k+1
                else:
                        l_sep=(comb(n-k-1,i-2,exact=True)+2*comb(n-k-1,i-1,exact=True)+comb(n-k-1,i,exact=True))%mod
                ans.append(k_sep*l_sep)
for ii in range(k):
        print(ans[ii])
Problem p03011 (python)

Fixed submission:
a=list(map(int,input().split()))
print(sum(a)-max(a))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[]
for i in range(m):
  a.append(int(input()))
a=set(a)
dp=[0]*(n+1)
dp[0]=1
if 1 in a:
  dp[1]=0
else:
  dp[1]=1
for i in range(2,n+1):
  if i in a:
    dp[i]=0
  else:
    dp[i]=dp[i-1]+dp[i-2]
print(dp[n]%1000000007)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
mod=1000000007
dp=[1,1]
if 1 in a:
  dp[1]=0
for i in range(2,n+1):
  if i in a:
    dp.append(0)
  else:
    dp.append((dp[-1]+dp[-2])%mod)
print(dp[-1]%mod)
Problem p03013 (python)

Fixed submission:
n,m=map(int,input().split())
a=set([int(input()) for i in range(m)])
mod=1000000007
dp=[1,1]
if 1 in a:
  dp[1]=0
for i in range(2,n+1):
  if i in a:
    dp.append(0)
  else:
    dp.append((dp[-1]+dp[-2])%mod)
print(dp[-1]%mod)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[]
for i in range(m):
  a.append(int(input()))
f=[0]*100001
f[0]=0
f[1]=1
f[2]=2
for i in range(3,100001):
  f[i]=f[i-1]+f[i-2]
ans=max(f[a[0]-1],1)
for j in range(m-1):
  ans*=f[a[j+1]-a[j]-2]
print((ans*max(1,f[n-a[-1]-1]))%1000000007)
Problem p03075 (python)

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
if e-a<=k:
  print("Yay!")
else:
  print(":(")

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
if b-a<=k and c-b<=k and d-c<=k and e-d<=K:
  print(":(")
else:
  print("Yay!")
Problem p02723 (python)

Fixed submission:
S = input()
if (S[2] == S[3]) and (S[4] == S[5]):
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
S = input()
if S[2] == S[3] && S[4] == S[5]:
	print("Yes")
else:
	print("No")
Problem p02831 (python)

Fixed submission:
import fractions
import sys
input = sys.stdin.readline

A,B = (int(x) for x in input().split())


print(A*B//fractions.gcd(A,B))

Buggy submission (verdict: Runtime Error):
import math
import sys
input = sys.stdin.readline

A,B = (int(x) for x in input().split())


print(A*B//math.gcd(A,B))
Problem p02833 (python)

Fixed submission:
# coding: utf-8
# Your code here!

import sys
input = sys.stdin.readline

def main():
    N = int(input())
    
    # 奇数は終わる
    if N%2:
        print('0')
        quit()
    
    def calc(x,ans):
        fl = 2*(5**x)
        if N >= fl:
            ans += N//fl
            return calc(x+1,ans)
        else:
            return ans
    
    print(calc(1, 0))
        
    
    
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
N = int(input())

if N%2:
    print(0)
else:
    t = N//10
    f = N//50
    
    ans = t+f+(N//200) - t//f
    print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N = int(input())

if N%2:
    print(0)
else:
    t = N//10
    f = N//50
    
    ans = t+f+(N//200) - t//f
    print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N = int(input())

if N%2:
    print(0)
else:

    ans = (N//10) + (N//50)+ (N//200) - ((N//10)//(N//50))
    print(ans)
Problem p02793 (python)

Fixed submission:
# from math import gcd
from fractions import gcd
from functools import reduce

def lcm_list(numbers):
    return reduce(lambda x, y: (x * y) // gcd(x, y), numbers, 1)

def main():
    n = int(input())
    a = [int(x) for x in input().split()]
    lcm = lcm_list(a)
    aa = []
    for i in range(len(a)):
        aa.append(lcm // a[i])
    ans = sum(aa) % 1000000007
    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from math import gcd
# from fractions import gcd
from functools import reduce

def lcm_list(numbers):
    return reduce(lambda x, y: (x * y) // gcd(x, y), numbers, 1)

def main():
    n = int(input())
    # a = [int(x) for x in input().split()]
    a = tuple(map(int, input().split()))
    lcm = lcm_list(a)
    aa = []
    for i in range(len(a)):
        aa.append(lcm // a[i])
    ans = sum(aa) % 1000000007
    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from math import gcd
# from fractions import gcd
from functools import reduce

n = int(input())
a = [int(x) for x in input().split()]

def lcm_list(numbers):
    return reduce(lambda x, y: (x * y) // gcd(x, y), numbers, 1)

lcm = lcm_list(a)
aa = []
for i in range(len(a)):
    aa.append(lcm // a[i])
ans = sum(aa) % 1000000007
print(ans)

Buggy submission (verdict: Runtime Error):
from fraction import gcd
from functools import reduce

n = int(input())
a = [int(x) for x in input().split()]

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

lcm = lcm_list(a)
aa = []
for i in range(len(a)):
    aa.append(lcm // a[i])
ans = sum(aa) % 1000000007
print(ans)
Problem p02754 (python)

Fixed submission:
N, A, B  = [int(x) for x in input().split(" ")]

print(int(N/(A+B))*A+int(min(N%(A+B),A)))

Buggy submission (verdict: Runtime Error):
N, A, B  = [int(x) for x in input().split(" ")]

print(int(N/(A+B))*A)+int(min(N%(A+B),A))

Buggy submission (verdict: Runtime Error):
N, A, B  = [int(x) for x in input().split(" ")]


if N%(A+B) == 0:
  print(int(N/(A+B))*A)
else:
  print(int(N/(A+B))*A)+int(min(N%(A+B),A))

Buggy submission (verdict: Runtime Error):
N, A, B  = [int(x) for x in input().split(" ")]

str = ""
b = 0
r = 0

while b + r <= N:
  for i in range(0,A):
    str = str + "b"*A
    b = b + A
    str = str + "r"*B
    r = r + B

print(list(str)[:N].count("b"))
Problem p02766 (python)

Fixed submission:
N, K = [int(x) for x in input().split(" ")]

i=1
x=K

while x <= N:
  x *= K
  i += 1

print(i)

Buggy submission (verdict: Runtime Error):
N, K = [int(x) for x in input().split(" ")]

i=1
x=K

while x =< N:
  x *= K
  i += 1

print(i)
Problem p02771 (python)

Fixed submission:
lst = [int(i) for i in input().split(" ")]

if len(set(lst)) == 2:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
if len(set([int(x) for x in input().split("")])) = 2:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
if len(set([int(x) for x in input().split("")])) = 2:
  print("yes")
else:
  print("No")
Problem p02785 (python)

Fixed submission:
HK = list(map(int,input().split(" ")))
HP = list(map(int,input().split(" ")))
H = HK[0]
K = HK[1]
HP.sort(reverse=True)
sum_a = sum(HP[K:])
print(sum_a)

Buggy submission (verdict: Runtime Error):
HK = list(map(int,input().split(" ")))
HP = list(map(int,input().split(" ")))
H = HK[0]
K = HK[1]
HP.sort(reverse=True)
sum_a = sum(HP[K:N])
print(sum_a)

Buggy submission (verdict: Runtime Error):
HK = list(map(int,input().split(" ")))
HP = list(map(int,input().split(" ")))
H = HK[0]
K = HK[1]
HP.sort(reverse=Ture)
sum_a = sum(HP[K:N])
print(sum_a)

Buggy submission (verdict: Runtime Error):
HK = list(map(int,input().split(" ")))
HP = list(map(int,input().split(" ")))
H = HK[0]
K = HK[1]
HP.reverse()
sum_a = sum(HP[K:N])
print(sum_a)

Buggy submission (verdict: Runtime Error):
HK = list(map(int,input().split(" ")))
HP = list(map(int,input().split(" ")))
H = HK[0]
K = HK[1]
HP.reverse()
sum_a = sum(HP[K:N])
print(sum_a)
Problem p02790 (python)

Fixed submission:
hoge = input().split(" ")
a=""
b=""
for i in range(int(hoge[1])):
  a += hoge[0]
for i in range(int(hoge[0])):
  b += hoge[1]
txt = [a,b]
txt.sort()
print(txt[0])

Buggy submission (verdict: Runtime Error):
inp = input().split("")
lis = [,]
for i in range(inp[0]):
  lis[1] += inp[1]
for i in range(inp[1]):
  lis[0] += inp[0]
lis.sort()
print(lis[0])

Buggy submission (verdict: Runtime Error):
hoge = input().split(" ")
for i in range(int(hoge[1])):
  a += hoge[0]
for i in range(int(hoge[0])):
  b += hoge[1]
txt = [a,b]
txt.sort
print(a[0])

Buggy submission (verdict: Runtime Error):
txt = input().split(" ")
txt.sort
print(a[0])
Problem p02880 (python)

Fixed submission:
N = int(input())

flag =0

for i in range(1,10):
  for j in range(1,10):
    if N == i*j:
      flag = 1

if flag == 1:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())

for i in range(1:10):
  for j in range(1:10):
    if N == i*j:
      print("Yes")
    elif i*j ==81:
      print("No")
Problem p03835 (python)

Fixed submission:
K, S = [int(n) for n in input().split(" ")]
 
cnt = 0
 
for x in range(K+1):
  for y in range(K+1):
      if S-x-y <= K and S-x-y >= 0:
            
        cnt +=1
 
print(cnt)

Buggy submission (verdict: Runtime Error):
K, S = int(input().split(" "))

cnt = 0

for x in range(K+1):
  for y in range(K+1):
    for z in range(K+1):
      if x+y+z == S:
        cnt +=1

print(cnt)
Problem p02729 (python)

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

ans = 0
if N > 1:
    ans += int(N*(N-1)/2)
if M > 1:
    ans += int(M*(M-1)/2)
print(ans)

Buggy submission (verdict: Runtime Error):
from scipy.special import comb

N,M = map(int, input().split())

print(comb(M, 2, exact=True) + comb(N, 2, exact=True))
Problem p02793 (python)

Fixed submission:
import sys
from fractions import gcd
from functools import reduce

sys.setrecursionlimit(2147483647)

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def main():
    N = int(input())
    A = list(map(int, input().split()))

    lcm = lcm_list(A)
    S = 0
    for i in range(N):
        S += lcm // A[i]

    print(round(S % (round(1e9) + 7)))

main()

Buggy submission (verdict: Runtime Error):
import sys
from fractions import gcd
from functools import reduce

sys.setrecursionlimit(2147483647)

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def main():
    N = int(input())
    A = list(map(int, input().split()))

    lcm = lcm_list(A)
    S = 0
    for i in range(N):
        S += lcm // A[i]

    print(round(S % (1e9 + 7)))

main()

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

from fractions import gcd
from functools import reduce

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def main():
    N = int(input())
    A = list(map(int, input().split()))

    lcm = lcm_list(A)
    S = 0
    for i in range(N):
        S += lcm // A[i]

    print(round(S % (1e9 + 7)))

main()

Buggy submission (verdict: Runtime Error):
from fractions import gcd
from functools import reduce

def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

def main():
    N = int(input())
    A = list(map(int, input().split()))

    v = lcm(A)
    S = 0
    for i in range(N):
        S += v // A[i]

    print(round(S % (1e9 + 7)))

main()

Buggy submission (verdict: Runtime Error):
from fractions import gcd
from functools import reduce

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

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

lcm = lcm_list(A)
S = 0
for i in range(N):
    S += lcm // A[i]

print(round(S % (1e9 + 7)))
Problem p02793 (python)

Fixed submission:
from fractions import gcd

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(numbers):
    t = 1
    for n in numbers:
        t = lcm_base(t, n)
    return t

N = int(input())
A = [int(x) for x in input().split()]

mod = 10**9+7
ans = 0
t = lcm(A)
t %= mod
for i in range(N):
    ans = (ans + t*pow(A[i],mod-2, mod))%mod

print(ans)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

N = int(input())
A = [int(x) for x in input().split()]
t = lcm(A)

mod = 10**9+7
ans = 0
for i in range(N):
    ans = (ans + t//A[i])%mod

print(ans)
Problem p02984 (python)

Fixed submission:
N=int(input())
X=list(map(int,input().split()))
Y=[0]*N
S=sum(X)

Y[0]=S-2*sum([X[i] for i in range(N) if i%2==1])

for i in range(N-1):
	Y[i+1]=2*X[i]-Y[i]

print(*Y)

Buggy submission (verdict: Runtime Error):
import numpy as np

N = int(input())

t = [int(x) for x in input().split()]

t = np.array(t).reshape(N, 1)
A = np.eye(N, N)
A[:-1, :] += A[1:, :]
A[N-1, 0] = 1

t = 2*np.dot(np.linalg.inv(A), t)

for i in range(N-1):
	print(int(t[i]), end=' ')
print(int(t[N-1]))

Buggy submission (verdict: Runtime Error):
import numpy as np

N = int(input())

t = [int(x) for x in input().split()]

t = np.array(t)

A = np.zeros((N, N))

for i in range(N-1):
	A[i, i] = 1
	A[i, i+1] = 1
A[N-1, N-1] = 1
A[N-1, 0] = 1

t = 2*np.dot(np.linalg.inv(A), t)

for i in range(N-1):
	print(int(t[i]), end=' ')
print(int(t[N-1]))
Problem p03013 (python)

Fixed submission:
N,M=map(int,input().split())
A=[int(input()) for i in range(M)]

dp=[-1]*(N+1)
idx=0
dp[0]=1
if idx<M:
    if A[idx]==1:
        dp[1]=0
        idx+=1
if dp[1]==-1:dp[1]=1

for i in range(2,N+1):
    if idx<M:
        if A[idx]==i:
            dp[i]=0
            idx+=1
    if dp[i]==-1:
        dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
print(dp[-1])

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=[int(input()) for i in range(M)]
dp=[0]*(N+1)
idx=0
dp[0]=1
if A[idx]==1:
    dp[1]=0
    if M>1:idx+=1
else:
    dp[1]=1

for i in range(2,N+1):
    if A[idx]==i:
        dp[i]=0
        if idx+1<M:idx+=1
    else:
        dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
print(dp[-1])

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=[int(input()) for i in range(M)]
dp=[0]*(N+1)
idx=0
dp[0]=1
if A[idx]==1:
    dp[1]=0
    if M>1:idx+=1
else:
    dp[1]=1

for i in range(2,N+1):
    if A[idx]==i:
        dp[i]=0
        if idx+1<M:idx+=1
    else:
        dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
print(dp[-1])
Problem p03265 (python)

Fixed submission:
import numpy as np

x1,y1,x2,y2 = map(int,input().split())

a=np.array([x1,y1])
b=np.array([x2,y2])

T = np.array([[0,-1],[1,0]])

c = b + np.dot(T,b-a)
d = c + np.dot(T,c-b)
print(*c, end=' ')
print(*d)

Buggy submission (verdict: Runtime Error):
import numpy as np

x1,y1,x2,y2 = map(int,input().split())

a=np.array([x1,y1])
b=np.array([x2,y2])

T = np.array([[0,-1],[1,0]])

c = b + np.dot(T,b-a)
d = c + np.dot(T,c-b)
print(*c,*d)
Problem p03634 (python)

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

N=int(input())

G=[[] for i in range(N)]
for i in range(N-1):
	a,b,c=map(lambda x:int(x)-1,input().split())
	G[a].append([b,c+1])
	G[b].append([a,c+1])

Q,K=map(int,input().split())
A=[list(map(int,input().split())) for i in range(Q)]


depth=[0 for i in range(N)]
depth[K-1]=0

def dfs(cur,p,d):
	for i,j in G[cur]:
		if i!=p:
			depth[i]=d+j
			dfs(i,cur,d+j)

dfs(K-1,-1,0)


for i,j in A:
	print(depth[i-1]+depth[j-1])

Buggy submission (verdict: Runtime Error):
N=int(input())

G=[[] for i in range(N)]
for i in range(N-1):
	a,b,c=map(lambda x:int(x)-1,input().split())
	G[a].append([b,c+1])
	G[b].append([a,c+1])

Q,K=map(int,input().split())
A=[list(map(int,input().split())) for i in range(Q)]


depth=[0 for i in range(N)]
depth[K-1]=0

def dfs(cur,p,d):
	for i,j in G[cur]:
		if i!=p:
			depth[i]=d+j
			dfs(i,cur,d+j)

dfs(K-1,-1,0)


for i,j in A:
	print(depth[i-1]+depth[j-1])
Problem p02762 (python)

Fixed submission:
from collections import deque

N,M,K = map(int,input().split())
friend = [list(map(int,input().split())) for _ in range(M)]
block = [list(map(int,input().split())) for _ in range(K)]

f = [set() for _ in range(N+1)]
b = [set() for _ in range(N+1)]

for i,j in friend:
    f[i].add(j)
    f[j].add(i)
for i,j in block:
    b[i].add(j)
    b[j].add(i)

stack=deque()
ans = [0]*(N+1)
visited = [0]*(N+1)

for i in range(1,N+1):
    if visited[i]:
        continue
    link = {i}
    visited[i] = 1 
    stack.append(i)
    while stack:
        n = stack.pop()
        for j in f[n]:
            if visited[j]==0:
                stack.append(j)
                visited[j] = 1
                link.add(j)
    for i in link:
        ans[i] = len(link) - len(link & f[i]) - len(link & b[i]) - 1
print(*ans[1:])

Buggy submission (verdict: Runtime Error):
from collections import deque
n,m,k = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]
cd = [list(map(int, input().split())) for _ in range(k)]

f1 = [set() for _ in range(0, n+1)]
b1 = [set() for _ in range(0, n+1)]
fb1 = [set() for _ in range(0, n+1)]
ans = [0]*(n+1)

for x,y in ab:
    f1[x].add(y)
    f1[y].add(x)
    fb1[x].add(y)
    fb1[y].add(x)

for x,y in cd:
    b1[x].add(y)
    b1[y].add(x)
    fb1[x].add(y)
    fb1[y].add(x)

stack = deque()
visited = [0]*(n+1)
links = []

for i in range(1, n+1):
    if visited[i]: continue
    link = {i}
    visited[i] = 1
    stack.append(i)
    while stack:
        n1 = stack.pop()
        for j in f1[n1]:
            if visited[j] == 0:
                stack.append(j)
                visited[j] = 1
                link.add(j)
    links.append(link)

for i in v0:
    leni = len(i)
    for j in i:
        ans[j] = leni - len(i & fb1[j]) - 1

print(*ans[1:])
Problem p02773 (python)

Fixed submission:
n = int(input())
s = [input() for _ in range(n)]
s.sort()

a = ""
tt = [[],[]]
for i in s:
    if a != i:
        a = i
        tt[0] += [i]
        tt[1] += [1]
    else:
        tt[1][-1] += 1
t = tt
m = max(t[1])
ans = []
for i in range(len(t[1])):
    if t[1][i] == m:
        ans += [t[0][i]]

for i in range(len(ans)): print(ans[i])

Buggy submission (verdict: Runtime Error):
n = int(input())
s = [input() for _ in range(n)]

import numpy as np
t = np.unique(np.array(s), return_counts=True)
m = max(t[1])
ans = []
for i in range(len(t[1])):
    if t[1][i] == m:
        ans += [t[0][i]]

for i in range(len(ans)): print(ans[i])

Buggy submission (verdict: Runtime Error):
n = int(input())
s = [input() for _ in range(n)]

import numpy as np
t = np.unique(np.array(s), return_counts=True)
m = max(t[1])
ans = []
for i in range(len(t[1])):
    if t[1][i] == m:
        ans += [t[0][i]]

for i in range(len(ans)): print(ans[i])
Problem p02891 (python)

Fixed submission:
import copy

s=list(str(input()))
n=int(input())
s_base = copy.deepcopy(s)
i0 = s[0]
count = 0
if len(s) == 1:
    ans = n//2
else:
    #r1 = n//2 + n%2
    #s

    for i, name in enumerate(s[1:]):
        if name == i0:
            i0 = -1
            count += 1
            s[i+1] = i0
        else:
            i0 = name
    if s[0] == s[-1]:
        al = n-1
        if s[1] == -1:
            s2 = copy.deepcopy(s)
            for i in s_base:
                s2.append(i)
            i0 = s2[0]
            count2 = copy.deepcopy(count)
            for i, name in enumerate(s2[1:]):
                if name == i0:
                    i0 = -1
                    count2 += 1
                    s2[i+1] = i0
                else:
                    i0 = name
            al = (count2 - count*2)*(n//2)
            if s2[0] == s2[-1]:
                al = (count2 - count * 2) * (n-1)
    else:
        al = 0
    ans = count*n + al
print(ans)

Buggy submission (verdict: Runtime Error):
s=list(str(input()))
n=int(input())
s_base = copy.deepcopy(s)
i0 = s[0]
count = 0
if len(s) == 1:
    ans = n//2
else:
    #r1 = n//2 + n%2
    #s

    for i, name in enumerate(s[1:]):
        if name == i0:
            i0 = -1
            count += 1
            s[i+1] = i0
        else:
            i0 = name
    if s[0] == s[-1]:
        al = n-1
        if s[1] == -1:
            s2 = copy.deepcopy(s)
            for i in s_base:
                s2.append(i)
            i0 = s2[0]
            count2 = copy.deepcopy(count)
            for i, name in enumerate(s2[1:]):
                if name == i0:
                    i0 = -1
                    count2 += 1
                    s2[i+1] = i0
                else:
                    i0 = name
            al = (count2 - count*2)*(n//2)
    else:
        al = 0
    ans = count*n + al
print(ans)
Problem p02933 (python)

Fixed submission:
n1 = int(input())
n2 = str(input())

if n1 >= 3200:
    print(n2)
else:
    print("red")

Buggy submission (verdict: Runtime Error):
n1 = int(input())
n2 = int(input())

if n1 >= 3200:
    print(n2)
else:
    print("red")