Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
apple = []
for _ in range(n):
    a = str(input())
    if a not in apple:
        apple.append(a)
    else:
        apple.remove(a)
print(len(apple))

Fixed submission:
n = str(input())
print("Yes" if "9" in n else "No")

Buggy python submission (verdict: Runtime Error):
n = int(input())
apple = []
for _ in range(n):
    a = int(input())
    if a not in apple:
        apple.append(a)
    else:
        apple.remove(a)
print(len(apple))

Fixed submission:
n = str(input())
print("Yes" if "9" in n else "No")

Buggy python submission (verdict: Runtime Error):
n = int(input())
apple = []
for _ in range(n):
    a = int(input())
    if a not in apple:
        apple.append(a)
    else:
        apple.remove(a)
print(len(apple))

Fixed submission:
n = str(input())
print("Yes" if "9" in n else "No")
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
apple = [i + j + l for i in range(k + 1) for j in range(k + 1) for l in range(k + 1)]
print(apple.count(s))

Fixed submission:
k, s = map(int, input().split())
print(len([1 for z in range(k+1) for y in range(k+1) if 0 <= s-z-y <= k]))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = sorted(list(map(int, input().split())))[::-1]

ans = 0
while(len(a)):
    a_min = a.pop()
    if len(a) == 0:
        ans += 1
        break
    if a_min == a[-1]:
       ans -= 1 
    a = [el for el in a if el % a_min != 0]
    ans += 1
    
print(ans)

Fixed submission:
n = int(input())
a = sorted(list(map(int, input().split())))
max_a = a[-1]

q = [0] * (max_a + 1)
for i in a:
    if q[i] == 1 or q[i] == -1:
        q[i] = -1
        continue
    for j in range(2*i, max_a+1, i):
        q[j] = -1
    q[i] = 1

total = 0
for i in q:
    if i == 1:
        total += 1
print(total)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = sorted(list(map(int, input().split())))

ans = 0
while(len(a)):
    a_min = a.pop(0)
    if len(a) == 0:
        ans += 1
        break
    if a_min == a[0]:
       ans -= 1 
    a = [el for el in a if el % a_min != 0]
    ans += 1
    
print(ans)

Fixed submission:
n = int(input())
a = sorted(list(map(int, input().split())))
max_a = a[-1]

q = [0] * (max_a + 1)
for i in a:
    if q[i] == 1 or q[i] == -1:
        q[i] = -1
        continue
    for j in range(2*i, max_a+1, i):
        q[j] = -1
    q[i] = 1

total = 0
for i in q:
    if i == 1:
        total += 1
print(total)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = sorted(list(map(int, input().split())))

total = []
ans = 0
while(len(a)):
    a_min = a.pop(0)
    if len(a) == 0:
        total.append(a_min)
        break
    if a_min == a[0]:
       ans -= 1 
    a = [el for el in a if el % a_min != 0]
    total.append(a_min)
    
ans = ans + len(total)
print(ans)

Fixed submission:
n = int(input())
a = sorted(list(map(int, input().split())))
max_a = a[-1]

q = [0] * (max_a + 1)
for i in a:
    if q[i] == 1 or q[i] == -1:
        q[i] = -1
        continue
    for j in range(2*i, max_a+1, i):
        q[j] = -1
    q[i] = 1

total = 0
for i in q:
    if i == 1:
        total += 1
print(total)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    s = input()
    charlim = len(s)
    total = 0
    unit = 2019
    for charnum in range(5, charlim+1):
        for i in range(charlim-charnum+1):
            cand = int(s[i:i+charnum])
            if cand % 2019 == 0:
                total += 1
    print(total)

if __name__ == '__main__':
    main()

Fixed submission:
s = input()
p = 2019
mods = [0] * p
mods[0] = 1
current = 0
base = 1
cnt = 0

for c in map(int, s[::-1]):
    current = (current + base * int(c)) % p
    base = base * 10 % p
    mods[current] += 1

print(sum(el*(el-1)//2 for el in mods))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

total = 0

for i in range(n-3):
    a = s[i]
    for j in range(i+1, n-1):
        if s[j] == a:
            continue
        else:
            b = s[j]
            for k in range(j+1, n):
                if k-j != j-i:
                    if s[k] != a and s[k] != b:
                        total += 1
print(total)

Fixed submission:
n = int(input())
s = input()

# total number of pairs fullfilling first condition 
r = s.count('R')
g = s.count('G')
b = len(s) - r - g
total = r*g*b

# j-i = k-j
for p in range(1, (n-1)//2 + 1):
    for i in range(0, n-(2*p)):
        si, sj, sk = s[i], s[i+p], s[i+2*p]
        if si != sj and sj != sk and sk != si:
            total -=  1
print(total)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

total = 0

for i in range(n-3):
    a = s[i]
    for j in range(i+1, n-1):
        if s[j] == a:
            continue
        else:
            b = s[j]
            for k in range(j+1, n):
                if k-j != j-i:
                    if s[k] != a and s[k] != b:
                        total += 1
print(total)

Fixed submission:
n = int(input())
s = input()

# total number of pairs fullfilling first condition 
r = s.count('R')
g = s.count('G')
b = len(s) - r - g
total = r*g*b

# j-i = k-j
for p in range(1, (n-1)//2 + 1):
    for i in range(0, n-(2*p)):
        si, sj, sk = s[i], s[i+p], s[i+2*p]
        if si != sj and sj != sk and sk != si:
            total -=  1
print(total)
Buggy python submission (verdict: Time Limit Exceeded):
n, x, y = map(int, input().split())
distance = [0] * int(n*(n+1)/2)
cnt = 0
for i in range(1, n):
    for j in range(i+1, n+1):
        distance[cnt] = (min([abs(j-i), abs(x-i)+abs(y-j)+1]))
        cnt += 1

for k in range(1, n):
    print(distance.count(k))

Fixed submission:
n, x, y = map(int, input().split())
distance = [0] * n
for i in range(1, n):
    for j in range(i+1, n+1):
        distance[min([abs(j-i), abs(x-i)+abs(y-j)+1])] += 1

print('\n'.join(map(str, distance[1:])))

Buggy python submission (verdict: Time Limit Exceeded):
n, x, y = map(int, input().split())
distance = []
for i in range(1, n):
    for j in range(i+1, n+1):
        distance.append(min([abs(j-i), abs(x-i)+abs(y-j)+1]))

for k in range(1, n):
    print(distance.count(k))

Fixed submission:
n, x, y = map(int, input().split())
distance = [0] * n
for i in range(1, n):
    for j in range(i+1, n+1):
        distance[min([abs(j-i), abs(x-i)+abs(y-j)+1])] += 1

print('\n'.join(map(str, distance[1:])))
Buggy python submission (verdict: Time Limit Exceeded):
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

redpoints = p[:x]
greenpoints = q[:y]
points = redpoints + greenpoints
flag=True
while(flag):
    rep = min(points)
    if len(r) < 1:
        flag = False
    elif rep < r[0]:
        points[points.index(rep)] = r.pop(0)
    else:
        flag = False
print(sum(points))

Fixed submission:
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

sortp = sorted(p)[::-1]
sortq = sorted(q)[::-1]
redpoints = sortp[:x]
greenpoints = sortq[:y]
sortedpoints = sorted(redpoints+greenpoints+r)[::-1]
print(sum(sortedpoints[:x+y]))
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())

import math
if math.log((c-a-b)/2) - math.log(a*b)/2 > 0:
    print('Yes')
else:
    print('No')


Fixed submission:
a, b, c = map(int, input().split())
if c-a-b < 0:
  print('No')
elif (c-a-b)**2 > 4*a*b:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n, a, b = map(int, input().split())
total = 0
out = 0
if a == 0:
    pass
else:
    while True:
        total += a
        out += a
        if total >= n:
            out -= (total - n)
            break
        total += b
        if total >= n:
            break
print(out)

Fixed submission:
n, a, b = map(int, input().split())
q = n // (a + b)
mod = n % (a + b)
if mod > a:
    remain = a
else:
    remain = mod
    
print(q * a + remain)

Buggy python submission (verdict: Time Limit Exceeded):
n, a, b = map(int, input().split())
total = 0
out = 0
while True:
    total += a
    out += a
    if total >= n:
        out -= (total - n)
        break
    
    total += b
    if total >= n:
        break

print(out)

Fixed submission:
n, a, b = map(int, input().split())
q = n // (a + b)
mod = n % (a + b)
if mod > a:
    remain = a
else:
    remain = mod
    
print(q * a + remain)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a = list(map(int, input().split()))

b = [(abs(i), 1 if i >= 0 else -1) for i in a]

b = sorted(b)
b = list(reversed(b))

p = 1
for i in range(k):
	p *= b[i][0] * b[i][1]

mod = int(1e9 + 7)

if p >= 0:
	print(p % mod)
else:
	# choice between replacing the last positive by the next negative
	# and replacing the last negative by the next positive
	lastP, nextP, lastN, nextN = -1, -1, -1, -1
	for i in range(k):
		if b[i][0] * b[i][1] >= 0:
			lastP = i
		if b[i][0] * b[i][1] <= 0:
			lastN = i
	for i in range(k, n):
		if b[i][0] * b[i][1] >= 0:
			nextP = i
		if b[i][0] * b[i][1] <= 0:
			nextN = i
	ans = -1e50
	if lastP != -1 and nextN != -1:
		ans = max(ans, -(p // b[lastP][0]) * b[nextN][0])
	if lastN != -1 and nextP != -1:
		ans = max(Ans, -(p // b[lastN][0]) * b[nextP][0])
	
	if ans >= 0:
		print(ans % mod)
	else:
		# tout le monde est negatif
		a = list(reversed(sorted(a)))
		p = 1
		for i in range(k):
			p *= a[i]
		print(p % mod)


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

b = [(abs(i), 1 if i >= 0 else -1) for i in a]

b = sorted(b)
b = list(reversed(b))
mod = int(1e9 + 7)

def fp(x,y):
	res=1
	while y > 0:
		if y % 2 == 1:
			res *= x
		x *= x
		y //= 2
		x %= mod
		res %= mod
	return res

def inv(x):
	return fp(x,mod-2)

p = 1
signe = 1
for i in range(k):
	p *= b[i][0]
	p %= mod
	if b[i][0] == 0:
		signe = 0
	signe *= b[i][1]

if signe >= 0:
	print(p % mod)
else:
	# choice between replacing the last positive by the next negative
	# and replacing the last negative by the next positive
	lastP, nextP, lastN, nextN = -1, -1, -1, -1
	for i in range(k):
		if b[i][0] * b[i][1] >= 0:
			lastP = i
		if b[i][0] * b[i][1] <= 0:
			lastN = i
	for i in range(k, n):
		if b[i][0] * b[i][1] >= 0 and nextP==-1:
			nextP = i
		if b[i][0] * b[i][1] <= 0 and nextN==-1:
			nextN = i
	if (lastP!=-1 and nextN !=-1) and (lastN!=-1 and nextP!=-1):
		if b[nextN][0] * b[lastN][0] >= b[nextP][0] * b[lastP][0]:
			ans = p * inv(b[lastP][0]) * b[nextN][0]
			ans %= mod
			print(ans)
		else:
			ans = p * inv(b[lastN][0]) * b[nextP][0]
			ans %= mod
			print(ans)
	elif lastP!=-1 and nextN!=-1:
		ans = p * inv(b[lastP][0]) * b[nextN][0]
		ans %= mod
		print(ans)
	elif lastN!=-1 and nextP!=-1:
		ans = p * inv(b[lastN][0]) * b[nextP][0]
		ans %= mod
		print(ans)
	else:
		# tout le monde est negatif
		a = list(reversed(sorted(a)))
		p = 1
		for i in range(k):
			p *= a[i]
			p %= mod
		print(p)
Buggy python submission (verdict: Runtime Error):
ax, at = map(int, input().split(' '))
bx, bt = map(int, input().split(' '))
t = int(input())
 
a_l = ax + at*t
b_l = bx + bt*t
 
if a_l < b_l and at == bt:
	print("NO")
else:
	print("YES")

Fixed submission:
name = input()
print(name[0:3])

Buggy python submission (verdict: Runtime Error):
ax, a = map(int, input().split(' '))
bx, b = map(int, input().split(' '))
t = int(input())
 
a_l = ax + a*t
b_l = bx + b*t
 
if a_l < b_l and a == b:
	print("NO")
else:
	print("YES")

Fixed submission:
name = input()
print(name[0:3])

Buggy python submission (verdict: Runtime Error):
ax, at = map(int, input().split(' '))
bx, bt = map(int, input().split(' '))
t = int(input())

a_l = ax + at*t
b_l = bx + bt*t

if a_l <= b_l:
	print("NO")
else:
	print("YES")

Fixed submission:
name = input()
print(name[0:3])

Buggy python submission (verdict: Runtime Error):
import random

name = input()
n_len = len(name)
m = random.randrange(n_len-3)
print(name[m:m+3])

Fixed submission:
name = input()
print(name[0:3])
Buggy python submission (verdict: Runtime Error):
x1, v1 = map(int, input().split(' '))
x2, v2 = map(int, input().split(' '))
t = int(input())

if v1 == v2:
	print("NO")
else:
	s = abs(x2 - x1) / (v1 - v2)
	if s <= T:
		print("NO")
	else:
		print("YES")

Fixed submission:
x1, v1 = map(int, input().split(' '))
x2, v2 = map(int, input().split(' '))
t = int(input())

p = abs(x2 - x1)
q = (v1 - v2) * t
if p <= q:
	print("YES")
else:
	print("NO")

Buggy python submission (verdict: Runtime Error):
x1, v1 = map(int, input().split(' '))
x2, v2 = map(int, input().split(' '))
t = int(input())

if v1 == v2:
	print("NO")
else:
	s = abs(x2 - x1) / (v1 - v2)
	if s <= T:
		print("YES")
	else:
		print("NO")

Fixed submission:
x1, v1 = map(int, input().split(' '))
x2, v2 = map(int, input().split(' '))
t = int(input())

p = abs(x2 - x1)
q = (v1 - v2) * t
if p <= q:
	print("YES")
else:
	print("NO")

Buggy python submission (verdict: Runtime Error):
ax, at = map(int, input().split(' '))
bx, bt = map(int, input().split(' '))
t = int(input())
 
a_l = ax + at*t
b_l = bx + bt*t
 
if a_l < b_l and a == b:
	print("NO")
else:
	print("YES")


Fixed submission:
x1, v1 = map(int, input().split(' '))
x2, v2 = map(int, input().split(' '))
t = int(input())

p = abs(x2 - x1)
q = (v1 - v2) * t
if p <= q:
	print("YES")
else:
	print("NO")
Buggy python submission (verdict: Runtime Error):
n = input()
lines = input()
line = [int(i) for i in lines.split(' ')]
sum = 1
for i in line:
  if sum > 1.0 * 10^18:
    sum = -1
    break
   else:
    sum = sum * i
print(sum)


Fixed submission:
n = input()
lines = input()
lines = [int(i) for i in lines.split(' ')]
sum = 1
if 0 in lines:
	print(0)
else:
	for i in lines:
		sum = sum * i
		if sum > 10**18:
			sum = -1
			break
	print(sum)
Buggy python submission (verdict: Runtime Error):
x,n=map(int,input().split())
if n!=0:
  p=list(int(i) for i in input().split())

  for i in range(100):
    kouho1=x+i
    kouho2=x-i
    if kouho2 not in p:
      print(kouho2)
      break
    elif kouho1 not in p:
      print(kouho1)
      breaak
else:
  print(x)

Fixed submission:
x,n=map(int,input().split())
if n!=0:
  p=list(int(i) for i in input().split())

  for i in range(100):
    kouho1=x+i
    kouho2=x-i
    if kouho2 not in p:
      print(kouho2)
      break
    elif kouho1 not in p:
      print(kouho1)
      break
else:
  print(x)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))

b1=1
b2=0
b3=0
for i in range(n):
  b1*=a[i]
  b2*=a[i]
  b3*=a[i]
  if b1>=10**9:
    b2+=b1//(10**9)
    b1%=10**9
  if b2>=10**9:
    b3+=b2//(10**9)
    b2%=10**9
  
if b3>=1 and (b1!=0 or b2!=0):
  print(-1)
else:
  print(b3*(10**18)+b2*(10**9)+b1)

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

b1=1
b2=0
b3=0

if 0 in a:
  print(0)
else:
  for i in range(n):
    b1*=a[i]
    b2*=a[i]
    if b1>=10**9:
      b2+=b1//(10**9)
      b1%=10**9
    if b2>=10**9:
      b3+=b2//(10**9)
      b2%=10**9
      break
  
  if b3>=1 and (b1!=0 or b2!=0):
    print(-1)
  else:
    print(b3*(10**18)+b2*(10**9)+b1)

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

answer=1
for i in range(n):
  answer=answer*a[i]
  
if answer>10**18:
  print(-1)
else:
  print(answer)

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

b1=1
b2=0
b3=0

if 0 in a:
  print(0)
else:
  for i in range(n):
    b1*=a[i]
    b2*=a[i]
    if b1>=10**9:
      b2+=b1//(10**9)
      b1%=10**9
    if b2>=10**9:
      b3+=b2//(10**9)
      b2%=10**9
      break
  
  if b3>=1 and (b1!=0 or b2!=0):
    print(-1)
  else:
    print(b3*(10**18)+b2*(10**9)+b1)

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

answer1=1
answer2=0
for i in range(n):
  answer1=answer1*a[i]
  answer2=answer2*a[i]
  if answer1>=10**18:
    answer2=answer2+(answer1//(10**18))
    answer1=answer1%(10**18)
    
if answer2>=1 and answer1!=0:
  print(-1)
else:
  print(answer2*(10**18)+answer1)

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

b1=1
b2=0
b3=0

if 0 in a:
  print(0)
else:
  for i in range(n):
    b1*=a[i]
    b2*=a[i]
    if b1>=10**9:
      b2+=b1//(10**9)
      b1%=10**9
    if b2>=10**9:
      b3+=b2//(10**9)
      b2%=10**9
      break
  
  if b3>=1 and (b1!=0 or b2!=0):
    print(-1)
  else:
    print(b3*(10**18)+b2*(10**9)+b1)
Buggy python submission (verdict: Time Limit Exceeded):
s=[int(i) for i in input()]
s.reverse()

a=0
l=[0 for i in range(2019)]
l[0]=1
for i in range(len(s)):
  a+=s[i]*(10**i)
  a%=2019
  l[a]+=1

answer=0
for i in range(2019):
  answer+=l[i]*(l[i]-1)//2
  
print(answer)

Fixed submission:
s=[int(i) for i in input()]
s.reverse()

a=0
l=[0 for i in range(2019)]
l[0]=1
b=0.1
for i in range(len(s)):
  b=int(b*10)
  b%=2019
  a+=s[i]*b
  a%=2019
  l[a]+=1

answer=0
for i in range(2019):
  answer+=l[i]*(l[i]-1)//2
  
print(answer)

Buggy python submission (verdict: Runtime Error):
s=[int(i) for i in input()]
s.reverse()

a=0
l=[0 for i in range(2019)]
l[0]=1
for i in range(len(s)):
  a+=s[i]*(10**i)
  a%=2019
  l[b]+=1

answer=0
for i in range(2019):
  answer+=l[i]*(l[i]-1)//2
  
print(answer)

Fixed submission:
s=[int(i) for i in input()]
s.reverse()

a=0
l=[0 for i in range(2019)]
l[0]=1
b=0.1
for i in range(len(s)):
  b=int(b*10)
  b%=2019
  a+=s[i]*b
  a%=2019
  l[a]+=1

answer=0
for i in range(2019):
  answer+=l[i]*(l[i]-1)//2
  
print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
s=[int(i) for i in input()]
s.reverse()

a=0
l=[0 for i in range(2019)]
l[0]=1
for i in range(len(s)):
  a+=s[i]*(10**i)
  b=a%2019
  l[b]+=1

answer=0
for i in range(2019):
  answer+=l[i]*(l[i]-1)//2
  
print(answer)

Fixed submission:
s=[int(i) for i in input()]
s.reverse()

a=0
l=[0 for i in range(2019)]
l[0]=1
b=0.1
for i in range(len(s)):
  b=int(b*10)
  b%=2019
  a+=s[i]*b
  a%=2019
  l[a]+=1

answer=0
for i in range(2019):
  answer+=l[i]*(l[i]-1)//2
  
print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()

answer=0
for n in range(4,len(s)):
  for i in range(len(s)-n+1):
    a=s[i:i+n]
    b=int(a)
    if b%2019==0:
      answer=answer+1
        
print(answer)

Fixed submission:
s=[int(i) for i in input()]
s.reverse()

a=0
l=[0 for i in range(2019)]
l[0]=1
b=0.1
for i in range(len(s)):
  b=int(b*10)
  b%=2019
  a+=s[i]*b
  a%=2019
  l[a]+=1

answer=0
for i in range(2019):
  answer+=l[i]*(l[i]-1)//2
  
print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()

answer=0
for n in range(4,len(s)):
  for i in range(len(s)-n+1):
    a=s[i:i+n]
    b=int(a)
    if b%2019==0:
      answer=answer+1
        
print(answer)

Fixed submission:
s=[int(i) for i in input()]
s.reverse()

a=0
l=[0 for i in range(2019)]
l[0]=1
b=0.1
for i in range(len(s)):
  b=int(b*10)
  b%=2019
  a+=s[i]*b
  a%=2019
  l[a]+=1

answer=0
for i in range(2019):
  answer+=l[i]*(l[i]-1)//2
  
print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
s=[int(i) for i in input()]

answer=0
for n in range(4,len(s)): #n桁の数について考える
  for i in range(len(s)-n+1): #i番目から始まる
    a=0
    for l in range(n):
      a=a+s[i+l]*(10**(n-1-l))
    if a%2019==0:
      answer=answer+1
        
print(answer)

Fixed submission:
s=[int(i) for i in input()]
s.reverse()

a=0
l=[0 for i in range(2019)]
l[0]=1
b=0.1
for i in range(len(s)):
  b=int(b*10)
  b%=2019
  a+=s[i]*b
  a%=2019
  l[a]+=1

answer=0
for i in range(2019):
  answer+=l[i]*(l[i]-1)//2
  
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
k=int(input())

def gcd(l,m,n):
  f=min(l,m,n)
  while l%f!=0 or m%f!=0 or n%f!=0:
    f=f-1
  return f

sum=0
for l in range(1,k+1):
  for m in range(l,k+1):
    for n in range(m,k+1):
      if l==m==n:
        sum=sum+gcd(l,m,n)
      elif l==m or m==n:
        sum=sum+gcd(l,m,n)*3
      else:
        sum=sum+gcd(l,m,n)*6

print(sum)

Fixed submission:
k=int(input())
 
def gcd(l,m,n):
  f=min(l,m,n)
  while l%f!=0 or m%f!=0 or n%f!=0:
    f=f-1
  return f
 
sum=0
for l in range(1,k+1):
  for m in range(l,k+1):
    for n in range(m,k+1):
      if l==m==n:
        sum=sum+gcd(l,m,n)
      elif l==m or m==n:
        sum=sum+gcd(l,m,n)*3
      else:
        sum=sum+gcd(l,m,n)*6
 
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
k=int(input())

def gcd(l,m,n):
  f=min(l,m,n)
  while l%f!=0 or m%f!=0 or n%f!=0:
    f=f-1
  return f

sum=0
for l in range(1,k+1):
  for m in range(1,k+1):
    for n in range(1,k+1):
      sum=sum+gcd(l,m,n)

print(sum)

Fixed submission:
k=int(input())
 
def gcd(l,m,n):
  f=min(l,m,n)
  while l%f!=0 or m%f!=0 or n%f!=0:
    f=f-1
  return f
 
sum=0
for l in range(1,k+1):
  for m in range(l,k+1):
    for n in range(m,k+1):
      if l==m==n:
        sum=sum+gcd(l,m,n)
      elif l==m or m==n:
        sum=sum+gcd(l,m,n)*3
      else:
        sum=sum+gcd(l,m,n)*6
 
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[int(a) for a in input().split()]
ans=1
for i in range(len(A)):
    ans=ans*A[i]
if ans>10**18:
    print(-1)
    exit()
print(ans)


Fixed submission:
N=int(input())
A=[int(a) for a in input().split()]
ans=1
if 0 in A:
    print(0)
    exit()
for i in range(N):
    ans=ans*A[i]
    if ans>10**18:
        print(-1)
        exit()
print(ans)
Buggy python submission (verdict: Runtime Error):
A,B,C,K=map(int,input().split())
X=[1]*A
Y=[0]*B
Z=[-1]*C
ANS=X+Y+Z
cnt=0
for i in range(K):
    cnt+=ANS[i]
print(cnt)


Fixed submission:
A,B,C,K=map(int,input().split())
if A>=K:
    print(K)
elif A+B>=K:
    print(A)
else:
    print(A-(K-A-B))
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
H=[int(h) for h in input().split()]
AB=[]
cnt=0
for i in range(M):
    A,B=map(int,input().split())
    AB.append([A,B])
NUMBERS=[int(x) for x in range(1,N+1)]

for i in range(M):
    if AB[i][0] in NUMBERS or AB[i][1] in NUMBERS:
        if H[AB[i][0]-1]>H[AB[i][1]-1]:
            if AB[i][1] in NUMBERS:
                NUMBERS.remove(AB[i][1])
        elif H[AB[i][0]-1]==H[AB[i][1]-1]:
            if AB[i][0] in NUMBERS:
                NUMBERS.remove(AB[i][0])
            if AB[i][1] in NUMBERS:
                NUMBERS.remove(AB[i][1])
        else:
            if AB[i][0] in NUMBERS:
                NUMBERS.remove(AB[i][0])
print(len(NUMBERS))


Fixed submission:
N,M=map(int,input().split())
H=[int(h) for h in input().split()]
cnt=[0]*N
for i in range(M):
    a,b=map(int,input().split())
    if H[a-1]>H[b-1]:
        cnt[b-1]+=1
    elif H[a-1]==H[b-1]:
        cnt[a-1]+=1
        cnt[b-1]+=1
    else:
        cnt[a-1]+=1
print(cnt.count(0))

Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
H=[int(h) for h in input().split()]
AB=[]
cnt=0
for i in range(M):
    A,B=map(int,input().split())
    AB.append([A,B])
NUMBERS=[int(x) for x in range(1,N+1)]

for i in range(M):
    if H[AB[i][0]-1]>H[AB[i][1]-1]:
        if AB[i][1] in NUMBERS:
            NUMBERS.remove(AB[i][1])
    elif H[AB[i][0]-1]==H[AB[i][1]-1]:
        if AB[i][0] in NUMBERS:
            NUMBERS.remove(AB[i][0])
        if AB[i][1] in NUMBERS:
            NUMBERS.remove(AB[i][1])
    else:
        if AB[i][0] in NUMBERS:
            NUMBERS.remove(AB[i][0])
print(len(NUMBERS))


Fixed submission:
N,M=map(int,input().split())
H=[int(h) for h in input().split()]
cnt=[0]*N
for i in range(M):
    a,b=map(int,input().split())
    if H[a-1]>H[b-1]:
        cnt[b-1]+=1
    elif H[a-1]==H[b-1]:
        cnt[a-1]+=1
        cnt[b-1]+=1
    else:
        cnt[a-1]+=1
print(cnt.count(0))
Buggy python submission (verdict: Time Limit Exceeded):
X=int(input())
for i in range(-1500,1501):
    for j in range(-1500,1501):
        if (i**5)-(j**5)==X:
            print(i,j)
            exit()


Fixed submission:
X=int(input())
for i in range(-1000,1001):
    for j in range(-1000,1001):
        if (i**5)-(j**5)==X:
            print(i,j)
            exit()