Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
list = []
for i in range(N):
    i = int(input())
    if i not in list:
        list.append(i)
    elif i in list:
        list.remove(i)
print(len(list))

Fixed submission:
N = int(input())
list = set()
for i in range(N):
    i = int(input())
    if i not in list:
        list.add(i)
    elif i in list:
        list.remove(i)
print(len(list))

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for i in range(N)]
for i in A:
    if A.count(i) >= 1:
        if A.count(i)%2 == 0: 
            A.remove(i)   
print(B)

Fixed submission:
N = int(input())
list = set()
for i in range(N):
    i = int(input())
    if i not in list:
        list.add(i)
    elif i in list:
        list.remove(i)
print(len(list))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for i in range(N)]
B = 0
for i in A:
    if A.count(i) >= 1:
        if A.count(i)%2 == 1:
            B += 1
    else :
        break
print(B)

Fixed submission:
N = int(input())
list = set()
for i in range(N):
    i = int(input())
    if i not in list:
        list.add(i)
    elif i in list:
        list.remove(i)
print(len(list))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for i in range(N)]
maxfigure = sorted(A)[-1]
B = 0
for i in A:
    if A.count(i)%2 == 1:
        B += 1
print(B)

Fixed submission:
N = int(input())
list = set()
for i in range(N):
    i = int(input())
    if i not in list:
        list.add(i)
    elif i in list:
        list.remove(i)
print(len(list))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for i in range(N)]
maxfigure = sorted(A)[-1]
B = 0
for i in range(maxfigure):
    if A.count(i)%2 == 1:
        B += 1
print(B)

Fixed submission:
N = int(input())
list = set()
for i in range(N):
    i = int(input())
    if i not in list:
        list.add(i)
    elif i in list:
        list.remove(i)
print(len(list))
Buggy python submission (verdict: Runtime Error):
X, t = map(int, inputa().split())
print(X-t if X >=t else '0')

Fixed submission:
X, t = map(int, input().split())
print(X-t if X >=t else '0')
Buggy python submission (verdict: Runtime Error):
list = set(input())
lists = set([chr(i) for i in range(ord('a'), ord('z')+1)])
ans = lists-list
print(min(ans) if len(list(ans)) == 0 else 'None')

Fixed submission:
S = list(input())
minal = ord('z')
for i in range(ord('a'), ord('z')+1):
    if i < minal and chr(i) not in S:
        minal = i
list = set(S)
print(chr(minal) if len(list)!=26 else 'None')

Buggy python submission (verdict: Runtime Error):
S = input()
list = []
for i in range(len(S)):
    list.append(S[i])
list = set(list)
lists = set([chr(i) for i in range(ord('a'), ord('z')+1)])
print(min(lists-list))

Fixed submission:
S = list(input())
minal = ord('z')
for i in range(ord('a'), ord('z')+1):
    if i < minal and chr(i) not in S:
        minal = i
list = set(S)
print(chr(minal) if len(list)!=26 else 'None')
Buggy python submission (verdict: Runtime Error):
N = int(input())
ans = 1
for i in range(7):
    if N >= 2**i
        ans = 2**i
print(ans)

Fixed submission:
N = int(input())
a = 1
for i in range(7):
    if N >= 2**i:
        a = 2**i
print(a)
Buggy python submission (verdict: Runtime Error):
#真に大切なのは中間点となる要素
N, M = map(int, input().split())
an = set()
nb = set()
for i in range(M):
    a, b = map(int, input().split())
    if a == 1:
        an.append(b)
    elif b == N:
        nb.append(a)

print('IMPOSSIBLE' if len(an&nb)==0 else 'POSSIBLE')

Fixed submission:
#真に大切なのは中間点となる要素
N, M = map(int, input().split())
an = set()
nb = set()
for i in range(M):
    a, b = map(int, input().split())
    if a == 1:
        an.add(b)
    elif b == N:
        nb.add(a)

print('IMPOSSIBLE' if len(an&nb)==0 else 'POSSIBLE')

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
ab = []
for i in range(M):
    a, b = map(int, input().split())
    if a == 1 or b == N:
        ab.append([int(a), int(b)])

flag = False
for i in range(len(ab)):
    for k in range(len(ab)-i):
        if ab[i][1] == ab[-k][0] or ab[i][0]==ab[-k][1]:
            print('POSSIBLE')
            flag = True
            break
    if flag:
        break
else:
    print('IMPOSSIBLE')

Fixed submission:
#真に大切なのは中間点となる要素
N, M = map(int, input().split())
an = set()
nb = set()
for i in range(M):
    a, b = map(int, input().split())
    if a == 1:
        an.add(b)
    elif b == N:
        nb.add(a)

print('IMPOSSIBLE' if len(an&nb)==0 else 'POSSIBLE')

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
ab = []
for i in range(M):
    a, b = map(int, input().split())
    if a == 1 or b == N:
        ab.append([int(a), int(b)])

flag = False
for i in range(len(ab)):
    for k in range(len(ab)):
        if ab[i][1] == ab[k][0] or ab[i][0]==ab[k][1]:
            print('POSSIBLE')
            flag = True
            break
    if flag:
        break
else:
    print('IMPOSSIBLE')

Fixed submission:
#真に大切なのは中間点となる要素
N, M = map(int, input().split())
an = set()
nb = set()
for i in range(M):
    a, b = map(int, input().split())
    if a == 1:
        an.add(b)
    elif b == N:
        nb.add(a)

print('IMPOSSIBLE' if len(an&nb)==0 else 'POSSIBLE')
Buggy python submission (verdict: Runtime Error):
S = input
while len(S)!=0:
    S.pop()
    if len(S)%2==0 and S[0:len(S)/2]==S[len(S)/2:]:
        print(len(S))
        exit()

Fixed submission:
S = list(input())
while len(S)!=0:
    S.pop()
    if len(S)%2==0 and S[:int(len(S)/2)]==S[int(len(S)/2):]:
        print(len(S))
        exit()
Buggy python submission (verdict: Runtime Error):
r, g, b = input().split()
num = r + g + b
print("YES" if num%4==0 else 'NO')

Fixed submission:
r, g, b = input().split()
num = int(r + g + b)
print("YES" if num%4==0 else 'NO')
Buggy python submission (verdict: Runtime Error):
O = input()
E = input()
a = str()
for i in range(len(O)):
    a += O[i] + E[i]
print(a)

Fixed submission:
O = input()
E = input()
a = str()
if len(O)==len(E):
    for i in range(len(O)):
        a += O[i] + E[i]
else :
    for i in range(len(O)-1):
        a += O[i] + E[i]
    a += O[-1]
print(a)
Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
print(math.factorial(N)/(10*9+7))

Fixed submission:
import math
N = int(input())
print(math.factorial(N)%(10**9+7))
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
print('Alice' if A>B or A==1 and B==2 else 'Draw' if A==B 'Bob')

Fixed submission:
A, B = map(int, input().split()) 
if A==B:
    print('Draw')
elif A==1:
    print('Alice')
elif B==1:
    print('Bob')
elif A>B:
    print('Alice')
else:
    print('Bob')

Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
print('Alice' if A>B or A==1 and B==2 'Draw' if A==B 'Bob')

Fixed submission:
A, B = map(int, input().split()) 
if A==B:
    print('Draw')
elif A==1:
    print('Alice')
elif B==1:
    print('Bob')
elif A>B:
    print('Alice')
else:
    print('Bob')

Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
print('Alice' if A>B or A==1 and B==2 else 'Draw' if A==B 'Bob')

Fixed submission:
A, B = map(int, input().split()) 
if A==B:
    print('Draw')
elif A==1:
    print('Alice')
elif B==1:
    print('Bob')
elif A>B:
    print('Alice')
else:
    print('Bob')

Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
print('Alice' if A>B or A==1 and B==2 elif A==B 'Draw' else 'Bob')

Fixed submission:
A, B = map(int, input().split()) 
if A==B:
    print('Draw')
elif A==1:
    print('Alice')
elif B==1:
    print('Bob')
elif A>B:
    print('Alice')
else:
    print('Bob')
Buggy python submission (verdict: Runtime Error):
print(input().replace(',','')

Fixed submission:
print(*input().split(','))

Buggy python submission (verdict: Runtime Error):
print(s.replace(',', '')

Fixed submission:
print(*input().split(','))
Buggy python submission (verdict: Runtime Error):
K, S = map(int, input().split())
print(len([for X in range(K+1) for Y in range(K+1) if 0<=S-X-Y<=K]))

Fixed submission:
K, S = map(int, input().split())
count = 0
for X in range(K+1):
    for Y in range(K+1):
        if 0<=S-X-Y<=K: #X+Y+Z=S Z=S-X-Y,0<=Z<=K
            count += 1
print(count)

Buggy python submission (verdict: Runtime Error):
#リスト内方表記1,
K, S = map(int, input().split())
print(len([1 for X in range(K+1) for Y in range(K+1) if 0<=S-X=Y<=K]))

Fixed submission:
K, S = map(int, input().split())
count = 0
for X in range(K+1):
    for Y in range(K+1):
        if 0<=S-X-Y<=K: #X+Y+Z=S Z=S-X-Y,0<=Z<=K
            count += 1
print(count)

Buggy python submission (verdict: Runtime Error):
K, S = map(int, input().split())
print(len[1 for X in range(K+1) for Y in range(K+1) if 0<=S-X=Y<=K])

Fixed submission:
K, S = map(int, input().split())
count = 0
for X in range(K+1):
    for Y in range(K+1):
        if 0<=S-X-Y<=K: #X+Y+Z=S Z=S-X-Y,0<=Z<=K
            count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())
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:
K, S = map(int, input().split())
count = 0
for X in range(K+1):
    for Y in range(K+1):
        if 0<=S-X-Y<=K: #X+Y+Z=S Z=S-X-Y,0<=Z<=K
            count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
list = set(map(int, input().split()))
print(len(set))

Fixed submission:
list = list(map(int, input().split()))
print(len(set(list)))
Buggy python submission (verdict: Runtime Error):
while True:
    if len(SA)==0:
        print('A')
        break
    elif len(SB)==0:
        print('B')
        break
    elif len(SC)==0:
        print('C')
        break

    if card == 'a':
        SA = SA[1:]
        card = SA[0]
    elif card == 'b':
        SB = SB[1:]
        card = SB[0]
    elif card == 'c':
        SC =SC[1:]
        card = SC[0]

Fixed submission:
SA, SB, SC = [input() for i in range(3)]
SA = SA + '0'
SB = SB + '0'
SC = SC + '0'

card = SA[0]
SA = SA[1:]

for i in range(303):
    if SA == '0' and card == 'a':
        print('A')
        break
    elif SB == '0' and card == 'b':
        print('B')
        break
    elif SC == '0' and card == 'c':
        print('C')
        break
    
    if card == 'a':
        card = SA[0]
        SA = SA[1:]
    elif card == 'b':
        card = SB[0]
        SB = SB[1:]
    elif card == 'c':
        card = SC[0]
        SC = SC[1:]

Buggy python submission (verdict: Runtime Error):
SA = list(str(input())) 
SB = list(str(input())) 
SC = list(str(input())) 
card = 'a'

for i in range(400):

    if card == 'a':
        SA = SA[1:]
        card = SA[0]
    elif card == 'b':
        SB = SB[1:]
        card = SB[0]
    elif card == 'c':
        SC =SC[1:]
        card = SC[0]

    if len(SA)==1 and card=='a':
        print('A')
        break
    elif len(SB)==1 and card=='b':
        print('B')
        break
    elif len(SC)==1 and card=='c':
        print('C')
        break

Fixed submission:
SA, SB, SC = [input() for i in range(3)]
SA = SA + '0'
SB = SB + '0'
SC = SC + '0'

card = SA[0]
SA = SA[1:]

for i in range(303):
    if SA == '0' and card == 'a':
        print('A')
        break
    elif SB == '0' and card == 'b':
        print('B')
        break
    elif SC == '0' and card == 'c':
        print('C')
        break
    
    if card == 'a':
        card = SA[0]
        SA = SA[1:]
    elif card == 'b':
        card = SB[0]
        SB = SB[1:]
    elif card == 'c':
        card = SC[0]
        SC = SC[1:]

Buggy python submission (verdict: Runtime Error):
for i in range(400):

    if card == 'a':
        SA = SA[1:]
        card = SA[0]
    elif card == 'b':
        SB = SB[1:]
        card = SB[0]
    elif card == 'c':
        SC =SC[1:]
        card = SC[0]

    if len(SA)==1 and card=='a':
        print('A')
        break
    elif len(SB)==1 and card=='b':
        print('B')
        break
    elif len(SC)==1 and card=='c':
        print('C')
        break

Fixed submission:
SA, SB, SC = [input() for i in range(3)]
SA = SA + '0'
SB = SB + '0'
SC = SC + '0'

card = SA[0]
SA = SA[1:]

for i in range(303):
    if SA == '0' and card == 'a':
        print('A')
        break
    elif SB == '0' and card == 'b':
        print('B')
        break
    elif SC == '0' and card == 'c':
        print('C')
        break
    
    if card == 'a':
        card = SA[0]
        SA = SA[1:]
    elif card == 'b':
        card = SB[0]
        SB = SB[1:]
    elif card == 'c':
        card = SC[0]
        SC = SC[1:]
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

MAX = 10**18

res = 1
for a in A:
    res *= a

if res > MAX:
    print("-1")
else:
    print(res)


Fixed submission:
import sys

MAX = 10**18

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

if 0 in A:
    print("0")
else:
    res = 1
    for a in reversed(sorted(A)):
        if a == 1:
            break
        res *= a
        if res > MAX:
            print("-1")
            sys.exit()
    print(res)
Buggy python submission (verdict: Runtime Error):
import math
X = input().split(" ")
A = int(X[0])
B100 = float(X[1])*100
ab = math.floor(A*B)//100
print(str(ab))


Fixed submission:
X = input().split(" ")
A = int(X[0])
B = int( float(X[1])*1000 )

m = A * B
m = m // 1000

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

def check(i,j):
    a = abs(i-j)
    h = A[i] + A[j]
    if a == h:
        return True
    else:
        return False

res = 0
for i in range(N):
    for j in range(i+1,N):
       if check(i,j):
           res += 1 

print(res)


Fixed submission:
from collections import defaultdict

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

CNT = defaultdict(int)
ans = 0

for i, a in enumerate(A):
    ima = i-a
    if ima in CNT:
        ans += CNT[ima]

    CNT[i+a] += 1

print(ans)

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

setA = set(A)

def check(i,j):
    a = abs(i-j)
    h = A[i] + A[j]
    if a == h:
        return True
    else:
        return False

res = 0
for i in range(N):
    for j in range(i+1,N):
       if check(i,j):
           res += 1 

print(res)


Fixed submission:
from collections import defaultdict

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

CNT = defaultdict(int)
ans = 0

for i, a in enumerate(A):
    ima = i-a
    if ima in CNT:
        ans += CNT[ima]

    CNT[i+a] += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
L = int(input())
x = float(L/3)
print(x**3)

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

def cmb(n,r):
    if r > n:
        return 0
    if r == 0 or r == n:
        return 1
    if r == 1:
        return n
    return cmb(n-1,r) + cmb(n-1,r-1)

ret = cmb(N,2) + cmb(M,2)
print(ret)
Buggy python submission (verdict: Runtime Error):
L = input()
x = int(L/3)
print(x**3)

Fixed submission:
L = int(input())
x = float(L/3)
print(x**3)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split(" ")[0:2])
p = list(map(int,input().split(" ")))

ret = -1
for x in range(0,N-K+1):
    ret1 = (sum(p[x:x+K])+K)/2
    ret = ret if ret1 < ret else ret1

print(ret)

Fixed submission:
N,K = map(int,input().split(" ")[0:2])
p = list(map(int,input().split(" ")))

ret = []
s0 = sum(p[0:K-1])
for x in range(0,N-K+1):
    s0 = s0 + p[x+K-1]
    ret.append(s0)
    s0 = s0 - p[x]
print((max(ret)+K)/2)
Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
from operator import add, mul

a = [1, 2, 3, 4] # 適当なリスト

N = int(input()) # 1行, 単数
arg = list(map(int, input().split())) # 1行, 配列

m = reduce(mul, arg)
 
if m - 1000000000000000000 > 0:
  print(-1)
else:
  print(m)


Fixed submission:
# import math
# from collections import Counter

# N = int(input()) # 1行, 単数
# arg = list(map(int, input().split())) # 1行, 配列
# D = Counter(arg) # 出現数カウント

# print('Yes')
# print('No')
# print()


N = int(input()) # 1行, 単数

arg = list(map(int, input().split())) # 1行, 配列
m = 1

if 0 in arg:
  print(0)
else:
  for A in arg:
    m = A * m
    if m > 1000000000000000000:
      m = -1
      break;
  print(m)

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
from operator import add, mul

a = [1, 2, 3, 4] # 適当なリスト

N = int(input()) # 1行, 単数
arg = list(map(int, input().split())) # 1行, 配列

m = reduce(mul, arg)
 
if m - 1000000000000000000 > 0:
  print(-1)
else:
  print(m)


Fixed submission:
# import math
# from collections import Counter

# N = int(input()) # 1行, 単数
# arg = list(map(int, input().split())) # 1行, 配列
# D = Counter(arg) # 出現数カウント

# print('Yes')
# print('No')
# print()


N = int(input()) # 1行, 単数

arg = list(map(int, input().split())) # 1行, 配列
m = 1

if 0 in arg:
  print(0)
else:
  for A in arg:
    m = A * m
    if m > 1000000000000000000:
      m = -1
      break;
  print(m)

Buggy python submission (verdict: Time Limit Exceeded):
# import math
# from collections import Counter

# N = int(input()) # 1行, 単数
# arg = list(map(int, input().split())) # 1行, 配列
# D = Counter(arg) # 出現数カウント

# print('Yes')
# print('No')
# print()


N = int(input()) # 1行, 単数

arg = list(map(int, input().split())) # 1行, 配列
m = 1

for A in arg:
  m = A * m

if m - 1000000000000000000 > 0:
  print('-1')
else:
  print(m)


Fixed submission:
# import math
# from collections import Counter

# N = int(input()) # 1行, 単数
# arg = list(map(int, input().split())) # 1行, 配列
# D = Counter(arg) # 出現数カウント

# print('Yes')
# print('No')
# print()


N = int(input()) # 1行, 単数

arg = list(map(int, input().split())) # 1行, 配列
m = 1

if 0 in arg:
  print(0)
else:
  for A in arg:
    m = A * m
    if m > 1000000000000000000:
      m = -1
      break;
  print(m)
Buggy python submission (verdict: Time Limit Exceeded):
# import math
# from collections import Counter

# N = int(input()) # 1行, 単数
# arg = list(map(int, input().split())) # 1行, 配列
# D = Counter(arg) # 出現数カウント

# print('Yes')
# print('No')
# print()


NM = list(map(int, input().split())) # 1行, 配列

N = NM[0]
M = NM[1]
H = list(map(int, input().split())) # 1行, 配列

AB=[]
while True:
  try:
    AB.append(list(map(int,input().split())))

  except:
    break;

good = 0


# for load in AB:

A = []
B = []


for i, item in enumerate(H):
  targetLoad = []
  # targetLoad = [H[list(set(load) - set([i+1]))[0]-1] for load in AB if list(set(load) - set([i+1])) == 1]
  for load in AB:
    if load[0] == i+1:
      targetLoad.append(H[load[1]-1])
    if load[1] == i+1:
      targetLoad.append(H[load[0]-1])
    # t = list(set(load) - set([i+1]))
    # if len(t) == 1:
    #   targetLoad.append(H[t[0]-1])
  if len(targetLoad) == 0:
      good = good + 1
  else:
    if max(targetLoad) < item:
      good = good + 1

print(good)

Fixed submission:
# import math
# from collections import Counter

# N = int(input()) # 1行, 単数
# arg = list(map(int, input().split())) # 1行, 配列
# D = Counter(arg) # 出現数カウント

# print('Yes')
# print('No')
# print()


N,M = map(int, input().split()) # 1行, 配列
H = list(map(int, input().split())) # 1行, 配列

AB={}

while True:
  try:
    A,B = map(int, input().split())
    AB.setdefault(A, []).append(H[B-1])
    AB.setdefault(B, []).append(H[A-1])
  except:
    break;

good = 0

for i, item in enumerate(H):

  try:
    targetLoad = AB[i+1]
    if max(targetLoad) < item:
      good = good + 1
  except:
    good = good + 1

print(good)

Buggy python submission (verdict: Time Limit Exceeded):
# import math
# from collections import Counter

# N = int(input()) # 1行, 単数
# arg = list(map(int, input().split())) # 1行, 配列
# D = Counter(arg) # 出現数カウント

# print('Yes')
# print('No')
# print()


NM = list(map(int, input().split())) # 1行, 配列

N = NM[0]
M = NM[1]
H = list(map(int, input().split())) # 1行, 配列

AB=[]
while True:
  try:
    AB.append(list(map(int,input().split())))

  except:
    break;

good = 0

for i, item in enumerate(H):
  targetLoad = []
  for load in AB:
    t = list(set(load) - set([i+1]))
    if len(t) == 1:
      targetLoad.append(H[t[0]-1])
  if len(targetLoad) == 0:
      good = good + 1
  else:
    if max(targetLoad) < item:
      good = good + 1

print(good)

Fixed submission:
# import math
# from collections import Counter

# N = int(input()) # 1行, 単数
# arg = list(map(int, input().split())) # 1行, 配列
# D = Counter(arg) # 出現数カウント

# print('Yes')
# print('No')
# print()


N,M = map(int, input().split()) # 1行, 配列
H = list(map(int, input().split())) # 1行, 配列

AB={}

while True:
  try:
    A,B = map(int, input().split())
    AB.setdefault(A, []).append(H[B-1])
    AB.setdefault(B, []).append(H[A-1])
  except:
    break;

good = 0

for i, item in enumerate(H):

  try:
    targetLoad = AB[i+1]
    if max(targetLoad) < item:
      good = good + 1
  except:
    good = good + 1

print(good)
Buggy python submission (verdict: Time Limit Exceeded):

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


for n in range(N):
   print(arg.count(n+1))


Fixed submission:
from collections import defaultdict, Counter

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

D = Counter(arg)

for n in range(N):
	print(D[n+1])

Buggy python submission (verdict: Time Limit Exceeded):

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


for n in range(N):
    print(len(list(filter(lambda x: x == n + 1, arg))))
    arg = list(filter(lambda x: x != n + 1, arg))


Fixed submission:
from collections import defaultdict, Counter

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

D = Counter(arg)

for n in range(N):
	print(D[n+1])

Buggy python submission (verdict: Time Limit Exceeded):

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


for n in range(N):
   print(len(list(filter(lambda x: x == n + 1, arg))))



Fixed submission:
from collections import defaultdict, Counter

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

D = Counter(arg)

for n in range(N):
	print(D[n+1])
Buggy python submission (verdict: Time Limit Exceeded):



import math
from functools import reduce

def f(*numbers):
    return reduce(math.gcd, numbers)
n=int(input())



def sigma2(frm, to):
    r = 0;
    for i in range(frm, to+1):
        for j in range(frm, to+1):
            for k in range(frm, to+1):
                r+=f(i,j,k)
    return r

print(sigma2(1,n))
# print(sum(sigma2(1,n)+sigma2(1,n)+sigma2(1,n)))


Fixed submission:



import math
from functools import reduce

def f(*numbers):
    return reduce(math.gcd, numbers)
n=int(input())



def sigma2(frm, to):
    r = 0;
    for i in range(frm, to+1):
        for j in range(frm, to+1):
            for k in range(frm, to+1):
                r+=f(i,j,k)
    return r

print(sigma2(1,n))
# print(sum(sigma2(1,n)+sigma2(1,n)+sigma2(1,n)))
Buggy python submission (verdict: Time Limit Exceeded):

n,k=map(int, input().split())
x=n
min=n

while True:
  if abs(x-k)>=min:
    break
  else:
    min=abs(x-k)
    x=abs(x-k)

print(min)

Fixed submission:

n,k=map(int, input().split())
min=n%k

while True:
  if abs(min-k)>=min:
    break
  else:
    min=abs(min-k)

print(min)
Buggy python submission (verdict: Runtime Error):

arg = list(map(int, input().split())) # 1行, 配列
N = arg[0]
K = arg[1]
S = list(map(int, input().split())) # 1行, 配列

dp = [float('inf')] * N
dp[0] = 0
for i in range(1, N):
  if i == 1:
    DP[i] = abs(S[i] - S[i-1])
    continue
  for j in range(K+1):
    if i - j < 0:
      continue
    DP[i] = min(DP[i] , DP[i-j] + abs(S[i] - S[i-j]))

print(DP[-1])

Fixed submission:


arg = list(map(int, input().split())) # 1行, 配列
N = arg[0]
K = arg[1]
S = list(map(int, input().split())) # 1行, 配列

DP = [float('inf')] * N
DP[0] = 0
for i in range(1, N):
  if i == 1:
    DP[i] = abs(S[i] - S[i-1])
    continue
  for j in range(K+1):
    if i - j < 0:
      continue
    DP[i] = min(DP[i] , DP[i-j] + abs(S[i] - S[i-j]))

print(DP[-1])