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

Fixed submission:
S = input()
T = input()
if S == T[:-1] and (len(S)+1)==len(T):
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
if S == T[:-1] and len(len(S)==len(T)+1):
  print('Yes')
else:
  print('No')
Problem p02683 (python)

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

min_value = -1
for i in range(2**N):
    sum = [0 for k in range(M+1)]
    for j in range(N):
        if (i >> j) & 1:
            sum = [x+y for x, y in zip(sum, book[j])]
    if min(sum[1:]) >= X and (min_value > sum[0] or min_value == -1):
        min_value = sum[0]

print(min_value)

Buggy submission (verdict: Runtime Error):
N, M, X = map(int, input().split())
book = [[map(int, input().split())] for i in range(N)]

min_value = -1
for i in range(2**N):
  sum = [0 for k in range(M+1)]
  for j in range(N):
    if (i >> j) & 1:
      sum = [x+y for x, y in zip(sum, book[N+1])]
  if min(sum[1:]) >= X and min_value > sum[0]:
    min_value = sum[0]

print(min_value)
Problem p02700 (python)

Fixed submission:
A, B, C, D = map(int, input().split())
 
while True:
  if C - B <= 0:
    print('Yes')
    break
  else:
    C = C - B
  if A - D <= 0:
    print('No')
    break
  else:
    A = A - D

Buggy submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())
 
while true:
  if C - B <= 0:
    print('Yes')
    break
  else:
    C = C - B
  if A - D <= 0:
    print('No')
    break
  else:
    A = A - D

Buggy submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())

while true:
  if C - B <= 0:
    print('Yes')
  else:
    C = C - B
  if A - D <= 0:
    print('No')
  else:
    A = A - D
Problem p02718 (python)

Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
 
mmin = sum(A) / (4*M)
A.sort(reverse=True)
 
if A[M-1] < mmin:
  print('No')
else:
  print('Yes')

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

mmin = sum(A) * (4*M)
A.sort()

if A[m-1] < mmin:
  print('No')
else:
  print('Yes')
Problem p02730 (python)

Fixed submission:
def is_kaibun(st):
  f = True
  for x,y in zip(st, st[::-1]):
    if x != y:
      f = False
      break
  return f
 
S = input()
ans = False
if is_kaibun(S):
  if is_kaibun(S[:(len(S)-1)//2]):
    ans = is_kaibun(S[(len(S)+3)//2-1:])
if ans:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
def is_kaibun(st):
  f = True
  for x,y in zip(st, st[::-1]):
    if x != y:
      f = False
      break
  return f

S = input()
ans = False
if is_kaibun(S):
  if is_kaibun(S[:(len(S)-1)/2+1]):
    ans = is_kaibun(S[(len(S)+3)/2+1])
if ans:
  print('Yes')
else:
  print('No')
Problem p02786 (python)

Fixed submission:
H = int(input())

def f(H):
  if H == 1:
    return 1
  else:
    return 2*f(H//2)+1

print(f(H))

Buggy submission (verdict: Runtime Error):
H = [int(input().split())]

ans = 0
while len(H) == 0:
  ans += 1
  m = H.pop(0)
  if m == 1:
    continue
  else:
    H = H + [m//2, m//2]
print(ans)
Problem p02791 (python)

Fixed submission:
N = int(input())
P = list(map(int, input().split()))
 
mmin = P[0]
ans = 0
for i in range(N):
  if mmin < P[i]:
    continue
  else:
    mmin = P[i]
    ans += 1

print(ans)

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

mmin = P[0]
ans = 0
for i in range(N):
  if mmin < P[i]:
    continue
  else:
    mmin >= P[i]:
      mmin = P[i]
      ans += 1

print(ans)
Problem p02813 (python)

Fixed submission:
from itertools import permutations
 
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
 
l = list(permutations(range(1,N+1)))
 
print(abs(l.index(P)-l.index(Q)))

Buggy submission (verdict: Runtime Error):
from itertools import permutations

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

l = permutations(range(1,N+1))

print(abs(l.index(P)-l.index(Q)))
Problem p02861 (python)

Fixed submission:
import itertools
import math
 
N = int(input())
X = [list(map(int, input().split())) for _ in range(N)]

l = [i for i in range(N)]
ssum = 0
for v in itertools.permutations(l):
  distance = 0
  pre = X[v[0]]
  for n in v:
    distance += math.sqrt((pre[0]-X[n][0])**2+(pre[1]-X[n][1])**2)
    pre = X[n]
  ssum += distance

print(ssum/math.factorial(N))

Buggy submission (verdict: Runtime Error):
import itertools
import math

N = int(input())
X = [list(map(int, input().split)) for _ in range(N)]

l = [i for i in range(N)]
ssum = 0
for v in itertools.permutations(l):
  distance = 0
  pre = [0, 0]
  for n in v:
    distance += math.sqrt((pre[0]-X[n][0])**2+(pre[1]-X[n][1])**2)
    pre = X[n]
  ssum += distance

print(ssum/math.factorial(N))
Problem p02983 (python)

Fixed submission:
import sys
 
L, R = map(int, input().split())
 
if R-L >= 2019:
  print('0')
  sys.exit()
 
L = L % 2019
R = R % 2019
if L > R:
  print('0')
 
mmin = 2019
for i in range(L, R):
  for j in range(i+1, R+1):
    mmin = min(mmin, (i*j)%2019)
print(mmin)

Buggy submission (verdict: Runtime Error):
import sys

L, R = map(int, input().split())

if R-L >= 2019:
  print('0')
  sys.exit()

L = L % 2019
R = R % 2019
if L > R:
  print('0')

mmin = 2019
for i in range(L, R):
  for j in range(j, R+1):
    mmin = min(mmin, (i*j)%2019)
print(mmin)
Problem p03200 (python)

Fixed submission:
S = input()
W = []
 
for i, s in enumerate(S):
  if s == 'W':
    W.append(i)

idx = 0
ans = 0
for w in W:
  ans += w-idx
  idx += 1

print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
W = []

for i, s enumerate(S):
  if s == 'W':
    W.append(i)

idx = 0
ans = 0
for w in W:
  ans += w-idx
  idx += 1

print(ans)

Buggy submission (verdict: Runtime Error):
S = input()

f = True
cnt = 0
while f:
  f = False
  for i in range(len(S)-1):
    if S[i]=='B' and S[i+1]=='W':
      S[i] = 'W'
      S[i+1] = 'B'
      cnt += 1
      f = True
print(cnt)
Problem p03338 (python)

Fixed submission:
N = int(input())
S = input()

mmax = 0
for i in range(2, N-1):
  a = set(S[:i])
  b = set(S[i:])
  mmax = max(len(a&b), mmax)
print(mmax)

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

mmax = 0
for i in range(2, N-1):
  a = set(N[:i])
  b = set(N[i:])
  mmax = max(len(a&b), mmax)
print(mmax)
Problem p03361 (python)

Fixed submission:
H, W = map(int, input().split())
S = [input() for _ in range(H)]
 
f = False
for h in range(H):
  pre = '.'
  now = S[h][0]
  nxt = S[h][1]
  abv = '.' if h == 0 else S[h-1][0]
  blw = '.' if h == H-1 else S[h+1][0]
  for w in range(W):
    if now == '.':
      f = False
    elif now in [pre, nxt, abv, blw]:
      f = False
    else:
      f = True
    
    pre = now
    now = nxt
    nxt = '.' if w == W-1 else S[h][w+1]
    abv = '.' if h == 0 else S[h-1][w]
    blw = '.' if h == H-1 else S[h+1][w]
    
    if f:
      print('No')
      exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
S = [list(map(int, input().split())) for _ in range(H)]

f = False
for h in range(H):
  pre = '.'
  now = S[h][0]
  nxt = S[h][1]
  abv = '.' if h == 0 else S[h-1][0]
  blw = '.' if h == H-1 else S[h+1][0]
  for w in range(W):
    if now == '.':
      f = False
    elif now in [pre, nxt, abv, blw]:
      f = False
    else:
      f = True
    
    pre = now
    now = nxt
    nxt = '.' if w == W-1 else S[h][w+1]
    abv = '.' if h == 0 else S[h-1][w]
    blw = '.' if h == H-1 else S[h+1][w]
    
    if f:
      print('No')
      exit()
print('Yes')
Problem p03427 (python)

Fixed submission:
N = int(input())
K = len(str(N))
c = N // 10**(K-1)

print(c+9*(K-1) if N ==(c+1)*10**(K-1)-1 else c+9*(K-1)-1)

Buggy submission (verdict: Runtime Error):
def cal(N):
  strn = str(N)
  ans = 0
  for s in strn:
    ans += int(s)
  return ans

N = int(input())
mmax = 0
for i in range(1, N+1):
  mmax = max(cal(i), mmax)

return mmax
Problem p03699 (python)

Fixed submission:
N = int(input())
S = sorted([int(input()) for _ in range(N)])
 
m = 0
for s in S:
  if s % 10 != 0 and m == 0:
    m = s
    break
ans = sum(S)
if ans % 10 != 0:
  print(ans)
elif m != 0:
  print(ans-m)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = soted([int(input()) for _ in range(N)])

m = 0
for s in S:
  if s % 10 != 0 and m == 0:
    m = s
    break
ans = sum(S)
if ans % 10 != 0:
  print(ans)
elif m != 0:
  print(ans-m)
else:
  print(0)
Problem p02719 (python)

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

tmp = N // K

ans = N - K * tmp

ans = min(ans, abs(ans - K))

print(ans)

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

if N < K:
    k = K % N
    ans = abs(N - k)
    print(ans)
elif N > K:
    k = N % K
    ans = abs(K - k)
    if k == 0:
        print("0")
    else:
        print(ans)
else:
    print("0")
Problem p02730 (python)

Fixed submission:
from math import floor as f
S = list(input())
N = len(S)

hantei = True
for c in range(f(N / 2)):
    if S[c] == S[-1 * c - 1]:
        pass
    else:
        hantei = False
        break

for c in range(f((N - 1) / 4)):
    if S[c] == S[-1 * c + -1 * f(N / 2) - 2]:
        pass
    else:
        hantei = False
        break

if hantei:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
from math import floor as f
S = list(input())
N = len(S)


for c in range(f(N / 2)):
    if S[c] == S[-1 * c - 1]:
        pass
    else:
        exit("No")


for c in range(f((N - 1) / 4)):
    if S[c] == S[-1 * c + -1 * f(N / 2) - 2]:
        pass
    else:
        exit("No")



print("Yes")
Problem p02741 (python)

Fixed submission:
k = [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]

i = int(input())
print(k[i - 1])

Buggy submission (verdict: Runtime Error):
from math import sqrt as r
a, b, c = map(int, input().split())
n = r(a) + r(b)
if (a + b + 2 * r(a * b)) * a * b < a * b * c:
    print("Yes")
else:
    print("No")
#print(n)
#print(r(c))

Buggy submission (verdict: Runtime Error):
from sympy import *

Buggy submission (verdict: Runtime Error):
k = [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]

i = int(input())
print(k[i])
Problem p02802 (python)

Fixed submission:
N, M = map(int, input().split())
Q = [list(map(str, input().split())) for _ in range(M)]

ans = [0] * N
AC = 0
WA = 0

for P in Q:
    p = int(P[0])
    S = P[1]
    if ans[p - 1] == "END":
        continue
    if S == "WA":
        ans[p - 1] += 1
    if S == "AC":
        WA += ans[p - 1]
        AC += 1
        ans[p - 1] = "END"


print(AC, WA)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
p = []
S = []
for _ in range(M):
    a, b = input().split()
    p.append(int(a))
    S.append(b)

ans = [[] for i in range(N)]
WA, AC = 0, 0
for p, S in zip(p, S):
    if ans[p - 1].count("AC") != 0:
        pass
    else:
        ans[p - 1].append(S)
        if S == "WA":
            WA += 1
        if S == "AC"
            AC += 1

print(AC, WA)
Problem p02817 (python)

Fixed submission:
S, T = input().split()
print(T + S)

Buggy submission (verdict: Runtime Error):
S, T = map(int, input().split())
print(T + S)
Problem p02922 (python)

Fixed submission:
A, B = map(int, input().split())

ans = 0
taps = 1

while True:
	if taps >= B:
		print(ans)
		break
	taps += (A - 1)
	ans += 1

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

ans = 0
taps = 1

while True:
	if taps >= B:
		print(ans)
		break
	taps += (A - 1)
	ans += 1
A, B = map(int, input().split())

ans = 0
taps = 1

while True:
	if taps >= B:
		print(ans)
		break
	taps += (A - 1)
	ans += 1
Problem p03035 (python)

Fixed submission:
a, b = map(int, input().split(" "))

if 13 <= a:
    print(b)
elif 6 <= a:
    print(round(b /2))
else:
    print("0")

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split(" "))
r = [""] * m
for c in range(m):
    r[c] = list(map(int, input().split(" ")))

#print(r)
ac = 0
for c in range(n):
    num = c + 1 # num がカード番号
    for co in range(m): # co がゲート番号
        if r[co][0] <= num <= r[co][1]:
            #print("card{} is ok for gate{}".format(num, co))
            pass
        else:
            break
    else:
        ac += 1

print(ac)
Problem p03068 (python)

Fixed submission:
jhj = int(input())
moji = list(input())
k = int(input())
o = moji[k - 1]
for c in range(jhj):
    if moji[c] == o:
        pass
    else:
        moji[c] = "*"
print("".join(moji))

Buggy submission (verdict: Runtime Error):
jhj = input()
moji = list(input())
k = int(input())
o = moji[k]
for c in range(jhj):
    if moji[c] == o:
        pass
    else:
        moji[c] = "*"
print(join(moji))

Buggy submission (verdict: Runtime Error):
jhj = input()
moji = list(input())
k = int(input())
o = moji[k]
for c in range(jhj):
    if moji[c] == o:
        pass
    else:
        moji[c] = "*"
print(join(moji))
Problem p03071 (python)

Fixed submission:
a, b = map(int, input().split(" "))
if a == b:
  print(a * 2)
elif a < b:
  print(b * 2 - 1)
else:
  print(a * 2 - 1)

Buggy submission (verdict: Runtime Error):
hpi = input()
count = 1
k = list(map(int, input().split(" ")))
for c in range(int(hpi) - 1):
  jo = "yes"
  n = k[:c + 2]
  for co in range(len(n) - 1):
    if n[co] > k[c + 1]:
      jo = "no"
    else:
      pass
  if jo == "yes":
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
hpi = input()
k = list(map(int, input().split(" ")))
for c in range(int(hpi) - 1):
  jo = "yes"
  n = k[:c + 2]
  for co in range(len(n) - 1):
    if n[co] > k[c + 1]:
      jo = "no"
    else:
      pass
  if jo == "yes":
    count += 1
print(count + 1)
Problem p03086 (python)

Fixed submission:
S = list(input())

ans = [0]
ans_ = 0
for s in S:
    if s == "A" or s == "C" or s == "G" or s == "T":
        ans_ += 1
    else:
        ans.append(ans_)
        ans_ = 0
ans.append(ans_)
print(max(ans))

Buggy submission (verdict: Runtime Error):
S = list(input())

ans = []
ans_ = 0
for s in S:
    if s=="A" or s=="C" or s=="G" or s=="T":
        ans_ += 1
    else:
        ans.append(ans_)
        ans_ = 0
print(max(ans))
Problem p03434 (python)

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

alice = 0
bob = 0

for n in range(N):
    if len(a) == 0:
        break
    card = max(a)
    alice += card
    a.remove(card)
    if len(a) == 0:
        break
    card = max(a)
    bob += card
    a.remove(card)

print(alice - bob)

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

alice = 0
bob = 0

for n in range(N):
    card = max(a)
    alice += card
    a.remove(card)
    if len(a) == 0:
        break
    card = max(a)
    bob += card
    a.remove(card)

print(alice - bob)
Problem p03644 (python)

Fixed submission:
N = int(input())

ans = 0

kk = 1
for x in range(1, N + 1):
    ans_ = 0
    k = x
    for y in range(999):
        if x % 2 == 0:
            x /= 2
            ans_ += 1
        else:
            break
    if ans_ > ans:
        ans = ans_
        kk = k
print(kk)

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

ans = 0


for x in range(1, N + 1):
    ans_ = 0
    k = x
    for y in range(999):
        if x % 2 == 0:
            x /= 2
            ans_ += 1
        else:
            break
    if ans_ > ans:
        ans = ans_
        kk = k
print(kk)

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

ans = 0


for x in range(1, N + 1):
    ans_ = 0
    k = x
    for y in range(x):
        if x % 2 == 0:
            x /= 2
            ans_ += 1
        else:
            break
    if ans_ > ans:
        ans = ans_
        kk = k
print(kk)
Problem p02947 (python)

Fixed submission:
n=int(input())
d=dict()
a=0
for _ in range(n):
    s=''.join(sorted(input()))
    if s in d:
        a+=d[s]
        d[s]+=1
    else:
        d[s]=1
print(a)

Buggy submission (verdict: Runtime Error):
n=int(input())
ss=[''.join(sorted(input())) for _ in range(n)]
def p(n):
    if n<=1: return n
    return n+p(n-1)
c=0
for s in set(ss):
    c+=p(ss.count(s)-1)
print(c)
Problem p03309 (python)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
m=sorted([a-i for i,a in enumerate(l, start=1)])
b1,b2=m[n//2],m[n//2-1]
print(min(sum([abs(a-b1) for a in m]),sum([abs(a-b2) for a in m])))

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
m=sorted([a-i for i,a in enumerate(l, start=1)])
b=min(m[len(m)//2],m[len(m)//2+1])
print(sum([abs(a-b) for a in m]))
Problem p03328 (python)

Fixed submission:
a,b=map(int,input().split())
h=sum([i for i in range(1,b-a+1)])
print(h-b)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
def h(d):
    if d==1:
        return 1
    return h(d-1)+d
print(h(b-a)-b)
Problem p03455 (python)

Fixed submission:
a, b = map(int, input().split())
if(a*b%2 == 0):
    print("Even")
else:
    print("Odd")

Buggy submission (verdict: Runtime Error):
a, b = int(input().split())
if(a*b & 1 == 0):
    print("Even")
else:
    print("Odd")

Buggy submission (verdict: Runtime Error):
a, b = int(input().split())
if(a*b%2 == 0):
    print("Even")
else:
    print("Odd")
Problem p03797 (python)

Fixed submission:
n,m=map(int,input().split())
if m<2:
    print(0)
    exit()
if n>m//2:
    print(m//2)
    exit()
c=n%(m//2)
d=m-2*c
c+=d//4
print(c)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
c=n%(m//2)
d=m-2*c
c+=d//4
print(c)
Problem p03813 (python)

Fixed submission:
print('ABC'if int(input())<1200else'ARC')

Buggy submission (verdict: Runtime Error):
print('ABC'if x=int(input())<1200else'ARC')
Problem p03846 (python)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
mod=10**9+7
if n%2==0:
    d={i:2 for i in range(1,n,2)}
else:
    d={i:2 for i in range(0,n,2)}
    d[0]=1
for a in l:
    if a in d:
        d[a]-=1
    else:
        print(0)
        exit()
for i in d.values():
    if i!=0:
        print(0)
        exit()
print((2**(n//2))%mod)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
mod=10**9+7
if n%2==0:
    d={i:2 for i in range(1,n,2)}
else:
    d={i:2 for i in range(0,n,2)}
    d[0]=1
print('def:',d)
for a in l:
    if a in d:
        d[a]-=1
    else:
        print(0)
        exit()
    print(a,d)
for i in d.values():
    if i!=0:
        print(0)
        exit()
print((2**(n//2))%mod)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
mod=10**9+7
if n%2==0:
    d={i:2 for i in range(1,n,2)}
else:
    d={i:2 for i in range(0,n,2)}
    d[0]=1
print('def:',d)
for a in l:
    if a in d:
        d[a]-=1
    else:
        print(0)
        exit()
    print(a,d)
for i in d.values():
    if i!=0:
        print(0)
        exit()
print(2**(n//2)%mod)
Problem p03998 (python)

Fixed submission:
a=input()
b=input()
c=input()
i=0
j=0
k=0
t='a'
while 1:
    if t=='a':
        if i==len(a):
            print('A')
            break
        t=a[i]
        i+=1
    elif t=='b':
        if j==len(b):
            print('B')
            break
        t=b[j]
        j+=1
    elif t=='c':
        if k==len(c):
            print('C')
            break
        t=c[k]
        k+=1

Buggy submission (verdict: Runtime Error):
a=input()
b=input()
c=input()
i=1
j=0
k=0
p=a[0]
while 1:
    if p=='a':
        if i==len(a)-1:
            print('A')
            break
        i+=1
        p=a[i]
    elif p=='b':
        if j==len(b)-1:
            print('B')
            break
        j+=1
        p=b[j]
    elif p=='c':
        if k==len(c)-1:
            print('C')
            break
        k+=1
        p=c[k]
Problem p02588 (python)

Fixed submission:
N = int(input())
A = [0]*N
B = [[0]*19 for x in range(19)]
C = [0]*N
D = [0]*N
a,b,c,d,e,ans = 0,['0']*9,0,0,0,0
for i in range(N):
    c = (input()+'.0').split('.')
    b = ['0']*9
    for k,v in enumerate(c[1]):
        b[k] = v
    A[i] = int(c[0]+''.join(b))

# print(*A)

for i in range(N):
    d,e = 0,0
    while (A[i] % 2 == 0) and (d < 18):
        A[i] //= 2
        d += 1
    while (A[i] % 5 == 0) and (e < 18):
        A[i] //= 5
        e += 1
    C[i] = d
    D[i] = e
    B[d][e] += 1

for i in range(N):
    c = C[i]
    d = D[i]
    B[c][d] -= 1
    for j in range(18-c,19):
        for k in range(18-d,19):
            ans += B[j][k]

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [0]*N
B = [[0]*19 for x in range(19)]
C = [0]*N
D = [0]*N
a,b,c,d,e,ans = 0,['0']*9,0,0,0,0
for i in range(N):
    c = (input()+'.0').split('.')
    b = ['0']*9
    for k,v in enumerate(c[1]):
        b[k] = v
    A[i] = int(c[0]+''.join(b))

# print(*A)

for i in range(N):
    d,e = 0,0
    while (A[i] % 2 == 0) and (d <= 18):
        A[i] //= 2
        d += 1
    while (A[i] % 5 == 0) and (e <= 18):
        A[i] //= 5
        e += 1
    C[i] = d
    D[i] = e
    B[d][e] += 1

for i in range(N):
    c = C[i]
    d = D[i]
    B[c][d] -= 1
    for j in range(18-c,19):
        for k in range(18-d,19):
            ans += B[j][k]

print(ans)
Problem p02609 (python)

Fixed submission:
import math

A = [0]*200001
for i in range(18):
    for j in range(2**i,2**(i+1)):
        if j <= 200000:
            A[j] = i + 1

def bii(x):
    a = A[x]
    o = [0]*a
    for i in range(a):
        o[i] = x % 2
        x //= 2
    return o

def f(x):
    bi = bii(x)
    popcount = sum(bi)
    a = x % popcount
    if a == 0:
        return 1
    else:
        return f(a)+1

N = int(input())
X = list(map(int,list(input())))
X.reverse()

popc = sum(X)
D = dict()
E = dict()
for j in [popc-1,popc+1]:
    E[j] = 0
    D[j] = [0]*N
    b = 1
    if j == 0:
        continue
    for i in range(N):
        D[j][i] = b
        E[j] += X[i] * b
        E[j] %= j
        b *= 2
        b %= j

aaaa = []
for i in range(N):
    an = X[-(i+1)]
    bb = 1 - 2 * an
    #もしi桁目が1ならば、ビット反転によってpopcとXは減る
    #もしi桁目が0ならば、ビット反転によってpopcとXは増える
    if popc == 1 and an == 1:
        print(0)
        continue
    j = popc + bb
    su = (E[j] + bb * D[j][-(i+1)] + j) % j
    if su == 0:
        print(1)
        continue
    else:
        print(f(su)+1)
        continue

Buggy submission (verdict: Runtime Error):
import math

A = [0]*200001
for i in range(18):
    for j in range(2**i,2**(i+1)):
        if j <= 200000:
            A[j] = i + 1

def bii(x):
    a = A[x]
    o = [0]*a
    for i in range(a):
        o[i] = x % 2
        x //= 2
    return o

def f(x):
    bi = bii(x)
    popcount = sum(bi)
    a = x % popcount
    if a == 0:
        return 1
    else:
        return f(a)+1

N = int(input())
X = list(map(int,list(input())))
X.reverse()

popc = sum(X)
D = dict()
E = dict()
for j in [popc-1,popc+1]:
    E[j] = 0
    D[j] = [0]*N
    b = 1
    for i in range(N):
        D[j][i] = b
        E[j] += X[i] * b
        E[j] %= j
        b *= 2
        b %= j

aaaa = []
for i in range(N):
    an = X[-(i+1)]
    bb = 1 - 2 * an
    #もしi桁目が1ならば、ビット反転によってpopcとXは減る
    #もしi桁目が0ならば、ビット反転によってpopcとXは増える
    j = popc + bb
    su = (E[j] + bb * D[j][-(i+1)] + j) % j
    if su == 0:
        print(1)
    else:
        print(f(su)+1)
Problem p02684 (python)

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

P = [-1]*N
P[0] = 0

cnt = 0
NOW = 0
while True:
    NOW = A[NOW]
    cnt += 1
    if P[NOW] == -1:
        P[NOW] = cnt
        if cnt == K:
            print(NOW+1)
            exit()
    else:
        L = cnt - P[NOW]
        for i in range(P[NOW],P[NOW]+L):
            if K % L != i % L:
                continue
            for k,v in enumerate(P):
                if v == i:
                    print(k+1)
                    exit()

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

N,K = map(int,input().split())
a = np.matrix(np.zeros((N,N)))
for k,v in enumerate(map(int,input().split())):
    v -= 1
    a[k,v] = 1

b = np.matrix(np.zeros(N))
b[0,0] = 1

o = [0] * 63

def bi(x):
    i = 0
    while x != 0:
        o[i] = x%2
        x //= 2
        i += 1

bi(K)

for i in range(63):
    if i:
        a = a * a
    if o[i]:
        b = b * a

for i in range(N):
    if b[0,i]:
        print(i+1)