Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def get_order(numbers, originals):
    
    from math import factorial
    from copy import copy
    numbers = copy(numbers)
    originals = copy(originals)
    
    total = 0
    while numbers:
        number = numbers.pop(0)
        number_index = originals.index(number)
        originals.pop(number_index)
        count = (number_index ) * factorial(len(originals))
        total += count
    return total
        
def get_next_int():
    return int(float(input()))
def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])

def main(print=__builtins__.print):
    n = get_next_int()
    
    a = get_next_ints()
    b = get_next_ints()
    originals = list(map(int, range(n)))
    print(get_order(a, originals) - get_order(b, originals))

if __name__ == '__main__':
    main()
    

Fixed submission:
def get_order(numbers, originals):
    
    from math import factorial
    from copy import copy
    numbers = copy(numbers)
    originals = copy(originals)
    
    total = 0
    while numbers:
        number = numbers.pop(0)
        number_index = originals.index(number)
        originals.pop(number_index)
        count = (number_index ) * factorial(len(originals))
        total += count
    return total
        
def get_next_int():
    return int(float(input()))
def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])

def main(print=__builtins__.print):
    n = get_next_int()
    
    a = list(get_next_ints())
    b = list(get_next_ints())
    originals = list(map(int, range(1, n+1)))
    print(abs(get_order(a, originals) - get_order(b, originals)))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
a, b = [int(x) for x in input().rstrip().split(" ")]
if a >= 13:
  print(b)
elsif a < 6:
  print(0)
else:
  print(b // 2)


Fixed submission:
a, b = [int(x) for x in input().rstrip().split(" ")]
if a >= 13:
  print(b)
elif a < 6:
  print(0)
else:
  print(b // 2)
Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input().rstrip())
    sqrt_n = int(sqrt(n))

    total = 0
    for number in range(1,sqrt_n + 1):
        if n % number > 0:
            continue
        remain = n - number
        x, y = divmod(remain, number)
        #print(x, y, remain, number)
        if y == 0 and x > number:
            #print("○",number)
            total += x
        #elif y == 0:
        #    print("×",number)

    print(total)

if __name__ == "__main__":
  main()


Fixed submission:
from math import sqrt
def main():
    n = int(input().rstrip())
    sqrt_n = int(sqrt(n))

    total = 0
    for number in range(1,sqrt_n + 1):
        if n % number > 0:
            continue
        remain = n - number
        x, y = divmod(remain, number)
        #print(x, y, remain, number)
        if y == 0 and x > number:
            #print("○",number)
            total += x
        #elif y == 0:
        #    print("×",number)

    print(total)

if __name__ == "__main__":
  main()

Buggy python submission (verdict: Runtime Error):
from copy import copy
def main():
    n = int(input().rstrip())
    sqrt_n = int(sqrt(n))
    primes = get_primes(sqrt_n)
    
    candidates = [1]
    for prime in primes:
        count = 0
        remain = n
        while remain % prime == 0:
            count += 1
            remain = remain // prime
        if count > 0:
        
            next_candidates = copy(candidates)
            for candidate in candidates:
                temp_candidate = candidate
                for i in range(count):
                    temp_candidate *= prime
                    #if temp_candidate > sqrt_n:
                    #    break
                    next_candidates.append(temp_candidate)
            candidates = next_candidates
    
    total = 0
    for number in candidates:

        remain = n - number
        x, y = divmod(remain, number)
        #print(x, y, remain, number)
        if y == 0 and x > number:
            #print("○",number)
            total += x
        #elif y == 0:
        #    print("×",number)

    print(total)

if __name__ == "__main__":
  main()


Fixed submission:
from math import sqrt
def main():
    n = int(input().rstrip())
    sqrt_n = int(sqrt(n))

    total = 0
    for number in range(1,sqrt_n + 1):
        if n % number > 0:
            continue
        remain = n - number
        x, y = divmod(remain, number)
        #print(x, y, remain, number)
        if y == 0 and x > number:
            #print("○",number)
            total += x
        #elif y == 0:
        #    print("×",number)

    print(total)

if __name__ == "__main__":
  main()
Buggy python submission (verdict: Runtime Error):
def main():
    a, b, t = get_next_ints()
    
    n = t // a
    print(n * b)
    
if __name__ == '__main__':
    main()
    

Fixed submission:

def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])

def main():
    a, b, t = get_next_ints()
    
    n = t // a
    print(n * b)
    
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    n = get_next_int()
    values = get_next_ints()
    costs = get_next_ints()
    
    total = 0
    for value, cost in zip(values, costs):
        if value > cost:
            total += (value - cost)
    
    print(total)
    
if __name__ == '__main__':
    main()

Fixed submission:
def get_next_int():
    return int(float(input()))
def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])

def main():
    n = get_next_int()
    values = get_next_ints()
    costs = get_next_ints()
    
    total = 0
    for value, cost in zip(values, costs):
        if value > cost:
            total += (value - cost)
    
    print(total)
    
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
s = input().rstrip("\n")
from collections import Counter
count = Counter(s)
print(min(counter.values()) * 2)

Fixed submission:
s = input().rstrip("\n")
from collections import Counter
count = Counter(s)
if len(count.values()) < 2:
  print(0)
else:
  print(min(count.values()) * 2)
Buggy python submission (verdict: Time Limit Exceeded):
def top(L, node):
    current = node
    while L[current] != current:
        current = L[current]
    return current


def main():
    n, m = map(int, input().rstrip("\n").split(" "))

    L = [0]
    counts = {}
    for i in range(1, n + 1):
        L.append(i)
        counts[i] = 1

    edges = []
    for j in range(m):
        a_b = map(int, input().rstrip("\n").split(" "))
        edges.append(a_b)

    total = n * (n - 1) // 2

    answers = [total]
    for a, b in reversed(edges):
        a_top = top(L, a)
        b_top = top(L, b)
        if a_top == b_top:
            answers.append(total)
        else:
            total -= counts[a_top] * counts[b_top]
            answers.append(total)
            L[b_top] = a_top
            counts[a_top] += counts[b_top]


    for answer in reversed(answers[:-1]):
        print(answer)

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    n, m = map(int, input().rstrip("\n").split(" "))

    L = [0]
    counts = {}
    for i in range(1, n + 1):
        L.append(i)
        counts[i] = 1

    edges = []
    for j in range(m):
        a_b = map(int, input().rstrip("\n").split(" "))
        edges.append(a_b)

    total = n * (n - 1) // 2

    answers = [total]
    for a, b in reversed(edges):
        current = a
        while L[current] != current:
            current = L[current]
        a_top = current
        current = b
        while L[current] != current:
            current = L[current]
        b_top = current
        if a_top == b_top:
            answers.append(total)
        else:
            total -= counts[a_top] * counts[b_top]
            answers.append(total)
            L[b_top] = a_top
            L[b] = a_top
            L[a] = a_top
            counts[a_top] += counts[b_top]

    for answer in reversed(answers[:-1]):
        print(answer)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
a, b = [int(x) for x in input().rstrip("\n").split(" ")]
 
if b % a == 0:
  print(b + a)
else:
  print(b -ab)


Fixed submission:
a, b = [int(x) for x in input().rstrip("\n").split(" ")]
 
if b % a == 0:
  print(b + a)
else:
  print(b - a)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, raw_input().rstrip("\n").split(" "))

answer = 0
if (n * 2) >= m:
  answer = m / 2
else:
  answer = n + (  m - (n *2) )  / 3)
print answer
print calc_scc(12345,678901), 175897




Fixed submission:
s, c = map(int, raw_input().rstrip("\n").split(" "))

def calc_scc(s, c):
  answer = 0
  if (s * 2) >= c:
    answer = c / 2
  else:
    answer = s + ((  c - (s * 2) )  / 4 )
  return answer

print calc_scc(s, c)
#print calc_scc(12345, 678901), 175897
Buggy python submission (verdict: Time Limit Exceeded):
n = int(raw_input().rstrip("\n"))
piles = map(int, raw_input().rstrip("\n").split(" "))

limits = [(0, piles[0])]
from collections import defaultdict
counter = defaultdict(int)
for i , pile in enumerate(piles):
  count = pile
  for pile_index, limit in limits:
    if count <= limit:
      counter[pile_index] += count
      count = 0
    else:
      counter[pile_index] += limit
      count -= limit
    if count == 0:
      break
  if count > 0:
    limits.append((i, count))
    counter[i] += count

for i in xrange(n):
  print counter[i]


Fixed submission:
def binary_search(item, values):
  top = 0
  bottom = len(values) - 1
  length = bottom - top + 1
  middle = top + (length // 2)
  while length >= 1:
    middle_item = values[middle][1]
    if middle_item == item:
      break
    if middle_item < item:
      top = middle + 1
    else:
      bottom = middle - 1
    length = bottom - top + 1
    middle = top + (length // 2)
  if middle <= (len(values) - 1):
    return middle
  else:
    return -1

n = int(raw_input().rstrip("\n"))
piles = map(int, raw_input().rstrip("\n").split(" "))

limits = [(-1, 0)]
from collections import defaultdict
counter = defaultdict(int)
gaps = defaultdict(int)
for i , count in enumerate(piles):
  position = binary_search(count, limits)
  if position == -1:
    limits.append((i, count))
    counter[i] += 1
  else:
    limit_index, limit = limits[position]
    counter[limit_index] += 1
    gaps[limit_index] -= limit - count
    
results = defaultdict(int)
#print limits
total = 0
for position in xrange(len(limits)-1,0,-1):
  limit_index, limit = limits[position]
  #print (total + counter[limit_index]) ,  (limit - limits[position -1][1]) ,gaps[limit_index]
  results[limit_index] = (total + counter[limit_index]) * (limit - limits[position -1][1]) + gaps[limit_index]
  total += counter[limit_index]

for i in xrange(n):
  print results[i]
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
B = [True]*N
count = 0
A.sort()
for i in range(N):
    if B[i]:
        for j in range(i+1,N):
            if A[i]==A[j]:
                B[j] = False
                B[i] = False
            elif A[j]%A[i]==0:
                B[j] = False
    if B[i]:
        count+=1
print(count)

Fixed submission:
import sys
C = list(map(int, input().split()))
for n in range(len(C)):
  if C[n]==0:
    print(n+1)
    sys.exit()
Buggy python submission (verdict: Runtime Error):
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())
if B+W*T=<A+V*T or B<A:
    print("NO")
else:
    print("YES")

Fixed submission:
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())
if abs(B-A)<=(V-W)*T:
  print("YES")
else:
  print("NO")

Buggy python submission (verdict: Runtime Error):
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())
flag = False
for t in range(T+1)
    if (B+W*T==A+V*T):
        flag = True
if flag:
    print("NO")
else:
    print("YES")

Fixed submission:
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())
if abs(B-A)<=(V-W)*T:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
N = input()
A = list(map(int,input().split()))
total = 1
for a in A:
    total *= a
if total>10**18:
    print(-1)
    sys.exit()
print(total)

Fixed submission:
import sys
N = input()
A = list(map(int,input().split()))
B = False
total = 1
for a in A:
    if a == 0:
        print(0)
        sys.exit()
    elif total <=10**18:
        total *= a
    else:
        B = True
if B or total>10**18:
    print(-1)
else:
    print(total)
Buggy python submission (verdict: Runtime Error):
T = input()
S = []
if T[0] == "?" and T[1]=="D":
    S.append("P")
else:
    S.append(T[0])
for n in range(1,len(T)-1):
    if T[n] == "?" and S[n-1] == "P":
        S.append("D")
    elif T[n] == "?" and T[n+1] == "P":
        S.append("D")
    elif T[n] == "?":
        S.append("P")
    else:
        S.append(T[n])
if S[len(S)-1]=="P":
    S.append("D")
else:
    S.append("P")
print("".join(S))

Fixed submission:
T = input()
S = []
for n in range(0,len(T)):
    if T[n] == "?":
        S.append("D")
    else:
        S.append(T[n])
print("".join(S))
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
B = []
i = 0
B.append(1)
for n in range(N):
  B.append(A[i])
  i = A[i]-1
start = 0
num = 0
for j in range(len(B)):
  if B[len(B)-1] == B[j]:
    start = j-1
    break
for j in range(1,len(B)-start):
  if B[start+j] == B[start]:
    num = j
    break
print(B[((K-start)%num)+start])

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
B = []
i = 0
B.append(1)
for n in range(N):
  B.append(A[i])
  i = A[i]-1
if K>N:
  start = 0
  num = 0
  for j in range(len(B)):
    if B[len(B)-1] == B[j]:
      start = j
      break
  for j in range(1,len(B)-start):
    if B[start+j] == B[start]:
      num = j
      break
  print(B[((K-start)%num)+start])
else:
  print(B[K])
Buggy python submission (verdict: Runtime Error):
import math, sys
X = int(input())
for a in range(-200,200):
  a5 == a**5
  for b in range(-200,200):
    if a5-b**5==X:
      print(str(a)+" "+str(b))
      sys.exit()

Fixed submission:
import math, sys
X = int(input())
for a in range(-200,200):
  a5 = a**5
  for b in range(-200,200):
    if a5-b**5==X:
      print(str(a)+" "+str(b))
      sys.exit()
Buggy python submission (verdict: Runtime Error):
import sys
K = int(input())
A, B = [int(x) for x in input().split()]
for i in range(A, B+1):
  if i%k == 0:
    print("OK")
    sys.exit()
print("NG")

Fixed submission:
import sys
K = int(input())
A, B = [int(x) for x in input().split()]
for i in range(A, B+1):
  if i%K == 0:
    print("OK")
    sys.exit()
print("NG")
Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = [int(x) for x in input().split()]
max_val = 0
for x in range(N+1):
  if (A*x)//B -A*(x//B) > max_val:
    max_val = (A*x)//B -A*(x//B)
print(max_val)

Fixed submission:
A, B, N = [int(x) for x in input().split()]
max_val = 0
j = min(B-1,N)
x = (A*j)//B - A*(j//B)
print(x)

Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = [int(x) for x in input().split()]
max_val = 0
for x in range(N+1):
  if (A*x)//B -A*(x//B) > max_val:
    max_val = (A*x)//B -A*(x//B)
print(max_val)

Fixed submission:
A, B, N = [int(x) for x in input().split()]
max_val = 0
j = min(B-1,N)
x = (A*j)//B - A*(j//B)
print(x)
Buggy python submission (verdict: Runtime Error):
S = int(input())
total = 0
keta = len(str(S))
for i in range(keta):
  for j in range(i+3,keta):
    n = (S%10**(keta-i))//10**(keta-j-1)
    #print(n)
    if n % 2019 == 0:
      total += 1
print(total)



Fixed submission:
S,W = [int(x) for x in input().split()]
if S>W:
  print("safe")
else:
  print("unsafe")

Buggy python submission (verdict: Runtime Error):
S = int(input())
total = 0
S1 = str(S)
for i in range(0,S,2019):
  j = str(i)
  if j in S1:
    total+=1
print(total)

Fixed submission:
S,W = [int(x) for x in input().split()]
if S>W:
  print("safe")
else:
  print("unsafe")
Buggy python submission (verdict: Runtime Error):
A = int(input())
total = 0L
for x in range(A+1):
  if x%5!=0 and x%3!=0:
    total += x
print(x)

Fixed submission:
A = int(input())
total = 0
for x in range(A+1):
  if x%5!=0 and x%3!=0:
    total += x
print(total)
Buggy python submission (verdict: Time Limit Exceeded):
def gdc(x,y):
  if x%y==0:
    return y
  return gdc(y, x%y)

def main():
  K = int(input())
  total = 0

  for a in range(K):
    for b in range(K):
      for c in range(K):
        total += gdc(c+1, gdc(b+1, a+1))
  print(total)
  
if __name__ == '__main__':
    main()

Fixed submission:
K = int(input())
total = 0

def gdc(x,y):
  if x%y==0:
    return y
  return gdc(y, x%y)

for a in range(K):
  for b in range(a,K):
    for c in range(b,K):
      if a==b and b==c:
        total += gdc(c+1, gdc(b+1, a+1))
      elif a==b or b==c or a==c:
        total += 3*gdc(c+1, gdc(b+1, a+1))
      else:
        total += 6*gdc(c+1, gdc(b+1, a+1))
print(total)

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
total = 0

def gdc(x,y):
  if x%y==0:
    return y
  return gdc(y, x%y)

for a in range(K):
  for b in range(K):
    for c in range(K):
      total += gdc(c+1, gdc(b+1, a+1))
print(total)


Fixed submission:
K = int(input())
total = 0

def gdc(x,y):
  if x%y==0:
    return y
  return gdc(y, x%y)

for a in range(K):
  for b in range(a,K):
    for c in range(b,K):
      if a==b and b==c:
        total += gdc(c+1, gdc(b+1, a+1))
      elif a==b or b==c or a==c:
        total += 3*gdc(c+1, gdc(b+1, a+1))
      else:
        total += 6*gdc(c+1, gdc(b+1, a+1))
print(total)

Buggy python submission (verdict: Runtime Error):
K = int(input())
total = 0

def gdc(x,y):
  if x%y==0:
    return y
  return gdc(y, x%y)

for a in range(K):
  for b in range(a,K):
    for c in range(b,K):
      if a==b and b==c:
        total += gdc(c+1, gdc(b+1, a+1))
      elif a==b or b==c or a==c:
        total += 3*gdc(c+1, gdc(b+1, a+1))
      eles:
        total += 6*gdc(c+1, gdc(b+1, a+1))
print(total)

Fixed submission:
K = int(input())
total = 0

def gdc(x,y):
  if x%y==0:
    return y
  return gdc(y, x%y)

for a in range(K):
  for b in range(a,K):
    for c in range(b,K):
      if a==b and b==c:
        total += gdc(c+1, gdc(b+1, a+1))
      elif a==b or b==c or a==c:
        total += 3*gdc(c+1, gdc(b+1, a+1))
      else:
        total += 6*gdc(c+1, gdc(b+1, a+1))
print(total)

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
total = 0

def gdc(x,y):
  if x%y==0:
    return y
  return gdc(y, x%y)

for a in range(K):
  for b in range(K):
    for c in range(K):
      tmp = [a+1,b+1,c+1]
      tmp.sort()
      total += gdc(c+1, gdc(b+1, a+1))
print(total)

Fixed submission:
K = int(input())
total = 0

def gdc(x,y):
  if x%y==0:
    return y
  return gdc(y, x%y)

for a in range(K):
  for b in range(a,K):
    for c in range(b,K):
      if a==b and b==c:
        total += gdc(c+1, gdc(b+1, a+1))
      elif a==b or b==c or a==c:
        total += 3*gdc(c+1, gdc(b+1, a+1))
      else:
        total += 6*gdc(c+1, gdc(b+1, a+1))
print(total)
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
S = list(input())
R = []
G = []
B = []
total = 0

for a in range(0,K):
  if S[a]=="R":
    R.append(a)
  elif S[a]=="G":
    G.append(a)
  else :
    B.append(a)

for a in R:
  for b in G:
    for c in B:
      tmp = [a,b,c]
      tmp.sort()
      if tmp[1]-tmp[0] != tmp[2]-tmp[1]:
        total += 1
        #print(tmp)
print(total)

Fixed submission:
K = int(input())
S = list(input())
total = 0
R,G,B = 0,0,0

for a in range(0,K):
  if S[a]=="R":
    R += 1
  elif S[a]=="G":
    G += 1
  else :
    B += 1
    
total = R*G*B

for i in range(0,K):
  for j in range(i,K):
    k = 2*j-i
    if k<K:
      if S[i] != S[k] and S[i] != S[j] and S[j] != S[k]:
        total -= 1
print(total)

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
S = list(input())
total = 0

for a in range(0,K-2):
  for b in range(a+1,K-1):
    if S[a] != S[b]:
      for c in range(b+1,K):
        if S[c] != S[b] and S[c] != S[a] and b-a != c-b:
          total += 1
print(total)

Fixed submission:
K = int(input())
S = list(input())
total = 0
R,G,B = 0,0,0

for a in range(0,K):
  if S[a]=="R":
    R += 1
  elif S[a]=="G":
    G += 1
  else :
    B += 1
    
total = R*G*B

for i in range(0,K):
  for j in range(i,K):
    k = 2*j-i
    if k<K:
      if S[i] != S[k] and S[i] != S[j] and S[j] != S[k]:
        total -= 1
print(total)
Buggy python submission (verdict: Time Limit Exceeded):
a = int(input())

N = [1,2,3,4,5,6,7,8,9]

for x in range(a-1):
  tmp = N.pop(0)
  if tmp%10 != 0:
    N.append(tmp*10+tmp%10-1)
  N.append(tmp*10+tmp%10)
  if tmp%10 != 9:
    N.append(tmp*10+tmp%10+1)
print(N.pop(0))

Fixed submission:
a = int(input())

N = [1,2,3,4,5,6,7,8,9]

for x in range(a):
  tmp = N[x]
  if tmp%10 != 0:
    N.append(tmp*10+tmp%10-1)
  N.append(tmp*10+tmp%10)
  if tmp%10 != 9:
    N.append(tmp*10+tmp%10+1)
print(N[a-1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(x) for x in input().split()]
B = [0]*N
for n in range(N):
  B[A[n]-1] +=1
result = [0]*N
for n in range(N):
  total=0
  for m in range(N):
    if m==A[n]:
      total+= (B[m-1]-2)*(B[m-1]-1)//2
    else:
      total+= B[m-1]*(B[m-1]-1)//2
  result[n]=total
for n in range(N):
  print(result[n])

Fixed submission:
N = int(input())
A = [int(x) for x in input().split()]
B = [0]*N
for n in range(N):
  B[A[n]-1] +=1
max_val = 0
for m in range(N):
  max_val+= B[m-1]*(B[m-1]-1)//2
result = [max_val]*N
for n in range(N):
  result[n] -= B[A[n]-1]-1
for n in range(N):
  print(result[n])
Buggy python submission (verdict: Runtime Error):
import sys

flag =Fale
A, B = [int(x) for x in input().split()]
for x in range((A+1)*9,(B+1)*10+1):
  if A == x*8//100 and B == x//10:
    print(x)
    flag=True
    break
if not flag:
  print(-1)

Fixed submission:
import sys
A, B = [int(x) for x in input().split()]
for x in range(1010):
  if A == x*8//100 and B == x//10:
    print(x)
    sys.exit()
print(-1)
Buggy python submission (verdict: Runtime Error):
import sys
N = int(input())
for n in renge(N//1.08,N):
  if n*1.08//1 == N:
    print(927)
    sys.exit()

Fixed submission:
import sys
N = int(input())
for n in range(N*100//110,N+1):
  if n*1.08//1 == N:
    print(n)
    sys.exit()
print(":(")