Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[int(x) for x in input().split()]
A=[0]+A+[0]
dist=[0]*(N+1)
for i in range(N+1):
    dist[i]=abs(A[i]-A[i+1])
for i in range(1,N+1):
    if A[i]<min(A[i-1],A[i+1]) or A[i]>max(A[i-1],A[i+1]):
        print(sum(dist)-2*min(dist[i-1],dist[i]))
    else:
        print(sum(dist))

Fixed submission:
N=int(input())
A=[int(x) for x in input().split()]
A=[0]+A+[0]
dist=[0]*(N+1)
S=0
for i in range(N+1):
    S+=abs(A[i]-A[i+1])
for i in range(1,N+1):
    dist[i]=S+abs(A[i-1]-A[i+1])-(abs(A[i-1]-A[i])+abs(A[i]-A[i+1]))

for i in range(1,N+1):
    print(dist[i])
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
a=sorted(a)
b=list(set(a))
ans=0
for i in range(len(b)):
  if a.count(b[i])>=b[i]:
    ans+=a.count(b[i])-b[i]
  else:
    ans+=a.count(b[i])
print(ans)

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

a=sorted(a)
l=a[0]
cnt=0

b=[]
for i in range(N):
    if a[i]==l:
        cnt+=1
    else:
        b.append([l,cnt])
        l=a[i]
        cnt=1
if cnt>0:
    b.append([l,cnt])

ans=0
for i in range(len(b)):
    if b[i][0]>b[i][1]:
        ans+=b[i][1]
    else:
        ans+=b[i][1]-b[i][0]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
a=sorted(a)
b=list(set(a))
num=[]
for i in range(len(b)):
  if a.count(b[i])>b[i]:
    num.append(a.count(b[i])-b[i])
  elif a.count(b[i])<b[i]:
    num.append(a.count(b[i]))
print(sum(num))

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

a=sorted(a)
l=a[0]
cnt=0

b=[]
for i in range(N):
    if a[i]==l:
        cnt+=1
    else:
        b.append([l,cnt])
        l=a[i]
        cnt=1
if cnt>0:
    b.append([l,cnt])

ans=0
for i in range(len(b)):
    if b[i][0]>b[i][1]:
        ans+=b[i][1]
    else:
        ans+=b[i][1]-b[i][0]

print(ans)
Buggy python submission (verdict: Runtime Error):
S=input()
let=['a','b','c']
k=S.count('a')
l=S.count('b')
m=S.count('c')

if abs(k-l)<=1 and abs(l-m)<=1 and abs(m-k)<=1:
    print('YES')
else:
    pritn('NO')

Fixed submission:
S=input()
k=S.count('a')
l=S.count('b')
m=S.count('c')

if abs(k-l)<=1 and abs(l-m)<=1 and abs(m-k)<=1:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

N=int(input())
D=Counter((list(map(int,input().split()))))
M=int(input())
T=Counter((list(map(int,input().split()))))

for i in range(len(D)):
    x=sorted([i for i in D.items()])

for j in range(len(T)):
    y=sorted([j for j in T.items()])

if N<M or len(x)<len(y):
    print("NO")
else:
    cnt=0
    for i in range(len(x)):
        for j in range(len(y)):
            if x[i][0]==y[j][0] and x[i][1]>=y[j][1]:
                cnt+=1
    print("YES" if cnt==len(y) else "NO")

Fixed submission:
from collections import Counter

N=int(input())
D=Counter((list(map(int,input().split()))))
M=int(input())
T=Counter((list(map(int,input().split()))))

for difficult,count in T.items():
    if difficult in D and D[difficult]>=count:
        pass
    else:
        print("NO")
        exit()
print("YES")
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
w=sorted(list(set(A)))[::-1]
leng=[0]*2
k=0
for i in w:
    if A.count(i)==2 or A.count(i)==3:
        leng[k]=i
        k+=1
    elif A.count(i)>3 and k==1:
        leng[k]=i
        k+=1
    elif A.count(i)>3 and k==0:
        leng[k]=i
        leng[k+1]=i
        k+=2
    
    if k==2:
        break

print(leng[0]*leng[1])

Fixed submission:
from collections import Counter

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

x=sorted([i for i in A.items() if i[1]>=2])

if len(x)<2:
    print(0)
elif x[-1][1]>=4:
    print(x[-1][0]**2)
else:
    print(x[-1][0]*x[-2][0])
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
c1=[]
c2=[]
for i in range(M):
    a,b=map(int,input().split())
    if a==1:
        c1.append(b)
    if b==N:
        c2.append(a)
for i in c1:
    if i in c2:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')

Fixed submission:
N,M=map(int,input().split())
c1=[]
c2=[]
for i in range(M):
    a,b=map(int,input().split())
    if a==1:
        c1.append(b)
    if b==N:
        c2.append(a)
c1=set(c1)
c2=set(c2)
if c1&c2:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list((input().split()))
b=[]
for i in range(n):
    b.append(a[i])
    b=b[::-1]
print(' '.join(b))

Fixed submission:
from collections import deque
n=int(input())
a=list(map(int,input().split()))
b=deque([])
for i in range(n):
    if i%2==0:
        b.appendleft(a[i])
    else:
        b.append(a[i])

if n%2==0:
    b=list(b)[::-1]

print(*b)
Buggy python submission (verdict: Runtime Error):
from math import factorial
N,M=map(int,input().split())
ans=0
if abs(N-M)>1:
    ans=0
else:
    if N==M:
        a=N
        b=M
        ans=factorial(a)*factorial(b)*2
    else:
        a=max(N,M)
        b=min(N,M)
        ans=factorial(a)*facotrial(b)
print(ans%(10**9+7))

Fixed submission:
from math import factorial
N,M=map(int,input().split())
ans=0
if abs(N-M)>1:
    ans=0
else:
    if N==M:
        a=N
        b=M
        ans=factorial(a)*factorial(b)*2
    else:
        a=max(N,M)
        b=min(N,M)
        ans=factorial(a)*factorial(b)
print(ans%(10**9+7))
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
cnt=0
P=[]
for i in range(N):
    a,b=map(int,input().split())
    P.append((a,b))

P=sorted(P)
for i in range(N):
    cnt+=P[1]
    if cnt>=K:
        print(P[0])

Fixed submission:
N,K=map(int,input().split())
cnt=0
P=[]
for i in range(N):
    a,b=map(int,input().split())
    P.append((a,b))

P=sorted(P)
for i in range(N):
    cnt+=P[i][1]
    if cnt>=K:
        print(P[i][0])
        break
Buggy python submission (verdict: Runtime Error):
X=int(input())
for i in range(X):
    if X<=(i+1)*i//2:
        ans=i
        break
print(ans)

Fixed submission:
X=int(input())
i=0
while X>0:
    X-=i+1
    i+=1
print(i)

Buggy python submission (verdict: Runtime Error):
X=int(input())
dp=[0]*(X+1)
for i in range(1,10**5):
    if (i-1)*i//2<X<=i*(i+1)//2:
        print(i)
        break


Fixed submission:
X=int(input())
i=0
while X>0:
    X-=i+1
    i+=1
print(i)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
x=[]
for i in range(N):
    a,b=map(int,input().split())
    x.append([a,b])

x=x[::-1]

ans=0
for i in range(N):
    if x[i][0]%x[i][1]!=0:
        cnt=x[i][1]-x[i][0]%x[i][1]
        ans+=cnt
        for j in range(i+1,N):
            x[j][0]+=cnt
    cnt=0
print(ans)

Fixed submission:
N=int(input())
r=[]
bi=[]
for i in range(N):
    a,b=map(int,input().split())
    bi.append(b)
    if a%b==0:
        r.append(0)
    else:
        r.append(b-a%b)
push=0
bi=bi[::-1]
r=r[::-1]
for i in range(N):
    if i==0:
        push=r[i]
    else:
        push+=(r[i]-push)%bi[i]
print(push)
Buggy python submission (verdict: Time Limit Exceeded):
k,s=map(int,input().split())
ac=[]
nums=[]
for i in range(k+1):
  for j in range(i,k+1):
    for l in range(j,k+1):
      if i+j+l==s:
        ac.append((i,j,l))
for i in range(len(ac)):
  if len(set(ac[i]))==1:
    nums.append(1)
  elif len(set(ac[i]))==2:
    nums.append(3)
  else:
    nums.append(6)
print(sum(nums))

Fixed submission:
k,s=map(int,input().split())
count=0
for x in range(k+1):
  for y in range(k+1):
    z=s-x-y
    if 0<=z<=k:
      count+=1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
k,s=map(int,input().split())
count=0
for i in range(k+1):
  for j in range(k+1):
    for l in range(k+1):
      if i+j+l==s:
        count+=1
print(count)

Fixed submission:
k,s=map(int,input().split())
count=0
for x in range(k+1):
  for y in range(k+1):
    z=s-x-y
    if 0<=z<=k:
      count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
c=input()
if c in"aiueo"
  print("vowel")
else:
  print("consonant")

Fixed submission:
c=input()
if "a" in c or "i" in c or "u" in c or "e" in c or "o" in c:
  print("vowel")
else:
  print("consonant")
Buggy python submission (verdict: Time Limit Exceeded):
a,b,x=map(int,input().split())
ans=0
for i in range(a,b+1):
  if i%x==0:
    ans+=1
print(ans)

Fixed submission:
a,b,x=map(int,input().split())
print(b//x-(a-1)//x)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,x=map(int,input().split())
ans=0
for i in range(b-a+1):
  if (a+i)%x==0:
    ans+=1
print(ans)

Fixed submission:
a,b,x=map(int,input().split())
print(b//x-(a-1)//x)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


def solve(x: int):

    if x == 1:
        return print('0')

    elif x == 0:
        return print('1')1


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    x = int(next(tokens))  # type: int
    solve(x)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys


def solve(x: int):

    if x == 1:
        return print('0')

    elif x == 0:
        return print('1')


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    x = int(next(tokens))  # type: int
    solve(x)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int


def solve(N: int):
    return print((10**N - 2*9**N + 8**N))

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()
~                                                                                                                                        
~                    

Fixed submission:
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int


def solve(N: int):
    return print((10**N - 2*9**N + 8**N)%MOD)

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
from itertools import accumulate
MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]"):
    aa = list(accumulate(A))
    print(aa)
    x = sum(A)
    print(x)

    ans = 0

    for i in range(N):
        ans += A[i]*(aa[N-1]-aa[i])%MOD
        ans %= MOD
    return print(ans)


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Fixed submission:
D, T, S = map(int, input().split())

a = T * S - D
if a >= 0:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

number = 0
MOD = 1000000007

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


if number > MOD:
    print(number%MOD)
else:
    print(number)


Fixed submission:
D, T, S = map(int, input().split())

a = T * S - D
if a >= 0:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
S = str(input())
T = str(input())

suma=0
sumb=0
sumc=0

for i in range(len(T)):
    A = T[i:]
    B = T[:i+1]
    if A in S:
        pass
    else:
        suma+=1

    if B in S:
        pass
    else:
        sumb+=1

    if A in S:
        if B in S:
            pass
    else:
        sumc+=1


suma = min(suma, sumb)
suma = min(suma, sumc)
print(suma)
~             

Fixed submission:
#!/usr/bin/env python3
import sys


def solve(S: str, T: str):
    length = len(T)
    s_list =[]
    counter = length
    ans = 0

    for i in range(len(S)-length+1):
        s = S[i:i+length]
        for i in range(length):
            #print(s[i], T[i])
            if s[i] != T[i]:
                ans+=1

        counter = min(ans, counter)

        ans = 0

    return print(counter)


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)

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

number = 0
MOD = 1000000007

for i in range(N-1):
    for j in range(i+1, N):
#        print(A[i], A[j])
        number += A[i]*A[j]


if number > MOD:
    print(number%MOD)
else:
    print(number)


Fixed submission:
#!/usr/bin/env python3
import sys
from itertools import accumulate
MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]"):
    aa = list(accumulate(A))
    #print(aa)
    x = sum(A)
    #print(x)

    ans = 0

    for i in range(N):
        ans += A[i]*(aa[N-1]-aa[i])%MOD
        ans %= MOD
    return print(ans)


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


def solve(N: int, X: int, T: int):
    i = 0
    A = 0
    while:
        if A < 0:
            break
        A = N - X*i
        i+=1

    return print(i*T)


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    T = int(next(tokens))  # type: int
    solve(N, X, T)

if __name__ == '__main__':
    main()
~                 

Fixed submission:
#!/usr/bin/env python3
import sys


def solve(N: int, X: int, T: int):
    i = 1
    A = 0
    while(True):
        A = N - X*i

        if A <= 0:
            break

        i+=1

    return print(i*T)


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    T = int(next(tokens))  # type: int
    solve(N, X, T)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
val = input()

res = val + val ** 2 + val ** 3

print(res.astype(int))

Fixed submission:
val = int(input())

print(val + val **2 + val **3)

Buggy python submission (verdict: Runtime Error):
val = input()

print(val + val ** 2 + val ** 3)

Fixed submission:
val = int(input())

print(val + val **2 + val **3)
Buggy python submission (verdict: Runtime Error):
s = input()
w = input()

if int(s) > int(w):
  print('safe')
else:
  print('unsafe')

Fixed submission:
arg = input()
s = (arg.split())[0]
w = (arg.split())[1]


if int(s) > int(w):
  print('safe')
else:
  print('unsafe')
Buggy python submission (verdict: Runtime Error):
arg = input()
a = (int)(arg.split())[0]
b = (int)(arg.split())[1]
c = (int)(arg.split())[2]
d = (int)(arg.split())[3]

while true:
  a = a - d
  if a <= 0:
    print('No')
    break
  c = c - b
  if c <= 0:
	print('yes')
	break

Fixed submission:
arg = input()
a = int((arg.split())[0])
b = int((arg.split())[1])
c = int((arg.split())[2])
d = int((arg.split())[3])

while True:
    c -= b
    if c <= 0:
        print('Yes')
        break
    a -= d
    if a <= 0:
        print('No')
        break
Buggy python submission (verdict: Runtime Error):
import math
X, Y = map(int,input().split())
ans = "No"
for i in range(X):
  if(2*X+2*i==Y):
    ans = "Yes"
print(ans)

Fixed submission:
P = list(map(int,input().split()))
ans = 0
for i in range(5):
  if(P[i]==0):
    ans = i+1
print(ans)
Buggy python submission (verdict: Runtime Error):
A, B, C, K = map(int,input().split())
ans = 0
if(K<=A):
  ans = K
elif(K<=A+B):
  ans = A
else:
  ans = A-(K-A-B)
print(ans)

Fixed submission:
S = input()
T = input()
if(T[:-1]==S):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
A, B, C, K = map(int,input().split())
ans = 0
if(K<=A):
  ans = K
else if(K<=A+B):
  ans = A
else:
  ans = A-(K-A-B)
print(ans)

Fixed submission:
A, B, C, K = map(int,input().split())
ans = 0
if(K<=A):
  ans = K
elif(K<=A+B):
  ans = A
else:
  ans = A-(K-A-B)
print(ans)
Buggy python submission (verdict: Runtime Error):
A, B, C, D = map(int,input().split())
ans = "Yes"
curA = A
curC = C
for i in range(max(A,C)):
  curC  = curC-B
  if(curC<=0):
    ans = "Yes"
    break
  curA = curA-D
  if(curA<=0):
    ans = "No"
    break
print(ans)

Fixed submission:
S, W = map(int,input().split())
ans = "safe"
if(S<=W):
  ans = "unsafe"
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def d_friends():
    class UnionFind(object):
        def __init__(self, n):
            """要素番号は 0 スタートを前提とする"""
            self.num_element = n
            self.parents = [-1] * n  # 要素が根の場合は、-(グループの要素数) を格納

        def find(self, x):
            """要素 x が属するグループの根を返す"""
            if self.parents[x] < 0:
                return x
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

        def union(self, x, y):
            """要素 x が属するグループと要素 y が属するグループとを併合する"""
            u, v = self.find(x), self.find(y)

            if u == v:
                return

            # u のグループの方が要素数が少なかった (parents の 定義より)
            if self.parents[u] > self.parents[v]:
                u, v = v, u

            self.parents[u] += self.parents[v]  # u と同グループの要素数を増やす
            self.parents[v] = u  # v は u に繋げる

        def get_members(self, x):
            """要素 x が属するグループに属する要素をリストで返す"""
            root = self.find(x)
            return [i for i in range(self.num_element) if self.find(i) == root]

        def get_roots(self):
            """根となっている要素のすべてを返す"""
            return [i for i, x in enumerate(self.parents) if x < 0]

    N, M = [int(i) for i in input().split()]
    uf = UnionFind(N)
    for _ in range(M):
        a, b = [int(i) - 1 for i in input().split()]
        uf.union(a, b)
    return max([len(uf.get_members(r)) for r in uf.get_roots()])

print(d_friends())

Fixed submission:
def d_friends():
    class UnionFind(object):
        def __init__(self, n):
            """要素番号は 0 スタートを前提とする"""
            self.num_element = n
            self.parents = [-1] * n  # 要素が根の場合は、-(グループの要素数) を格納

        def find(self, x):
            """要素 x が属するグループの根を返す"""
            if self.parents[x] < 0:
                return x
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

        def union(self, x, y):
            """要素 x が属するグループと要素 y が属するグループとを併合する"""
            u, v = self.find(x), self.find(y)

            if u == v:
                return

            # u のグループの方が要素数が少なかった (parents の 定義より)
            if self.parents[u] > self.parents[v]:
                u, v = v, u

            self.parents[u] += self.parents[v]  # u と同グループの要素数を増やす
            self.parents[v] = u  # v は u に繋げる

        def get_size(self, x):
            """要素 x が属するグループの要素数を返す"""
            return -self.parents[self.find(x)]

    N, M = [int(i) for i in input().split()]
    uf = UnionFind(N)
    for _ in range(M):
        a, b = [int(i) - 1 for i in input().split()]
        uf.union(a, b)
    return max([uf.get_size(r) for r in range(N)])

print(d_friends())