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

Fixed submission:
import math

n = int(input())
s = int(input())

ans = []

def f(b, n):
  if n < b:
    return n
  else:
    return f(b, n//b) + n % b

if n == s:
  ans.append(n+1) 
  
elif n < s:
  ans.append(-1)
  
else:
  rootn = int(math.sqrt(n))
  for b in range(2, rootn+2):
    if s == f(b, n):
      ans.append(b)
      break
      
  for p in range(1, rootn):
    b = (n-s)//p + 1
    if s == p + n%b:
      ans.append(b)
      
if not ans:
  ans.append(-1)

print(min(ans))

Buggy submission (verdict: Runtime Error):
import math

n = int(input())
s = int(input())

ans = []

def f(b, n):
  if n < b:
    return n
  else:
    return f(b, n//b) + n % b

if n == s:
  ans.append(n+1)

elif s == 1:
  ans.append(n)
  
else:
  rootn = int(math.sqrt(n))
  for b in range(2, rootn):
    if s == f(b, n):
      ans.append(b)
      break
      
  for p in range(1, rootn):
    b = (n-s)//p + 1
    if s == p*b + n%b:
      ans.append(b)
      
if not ans:
  ans.append(-1)

print(min(ans))

Buggy submission (verdict: Runtime Error):
import math

n = int(input())
s = int(input())

ans = -1

def f(b, n):
  if n < b:
    return n
  else:
    return f(b, n//b) + n % b

if n == s:
  ans = n+1

elif s == 1:
  ans = n
  
else:
  rootn = int(math.sqrt(n))
  for b in range(2, rootn):
    if s == f(b, n):
      ans = b
      break
  else:
    for p in range(1, rootn):
      b = (n-s)//p + 1
      if s == p*b + n%b:
        ans = b
        break

print(ans)

Buggy submission (verdict: Runtime Error):
import math

n = int(input())
s = int(input())

ans = -1

def f(b, n):
  if n < b:
    return n
  else:
    return f(b, n//b) + n % b
    
  

if n == s:
  ans = n+1
  
else:
  rootn = int(math.sqrt(n))
  for b in range(2, rootn):
    if s == f(b, n):
      ans = b
      break
  else:
    for p in range(1, rootn):
      b = (n-s)//p + 1
      if s == p*b + n%b:
        ans = b
        break

print(ans)
Problem p04032 (python)

Fixed submission:
import numpy as np

s = [ord(a)-ord('a') for a in input()]
n = len(s)

if n == 2:
    if s[0] == s[1]:
        print('1 2')
    else:
        print('-1 -1')
    exit()

cnt = np.array([0] * 26)
cum = [cnt.copy()]

for i, a in enumerate(s):
    cnt[a] += 1
    cum.append(cnt.copy())

def is_check(cum, n):
    i = 3
    d = 1
    for j in range(n-i+1):
        cum_ = cum[j+i] - cum[j]
        if cum_[cum_>1]:
            return j+1, j+i
    return -1, -1

print(' '.join(map(str, is_check(cum, len(s)))))

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

s = [ord(a)-ord('a') for a in input()]
n = len(s)

if n == 2:
    if s[0] == s[1]:
        print('1 2')
    else
        print('-1 -1')
    exit()

cnt = np.array([0] * 26)
cum = [cnt.copy()]

for i, a in enumerate(s):
    cnt[a] += 1
    cum.append(cnt.copy())

def is_check(cum, n):
    i = 3
    d = 1
    for j in range(n-i+1):
        for k in cum[j+i] - cum[j]:
            if k > d:
                return j+1, j+i
    return -1, -1

print(' '.join(map(str, is_check(cum, len(s)))))

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

s = [ord(a)-ord('a') for a in input()]
n = len(s)

if n == 2:
    if s[0] == s[1]:
        print('1 2')
    else
        print('-1 -1')
    exit()

cnt = np.array([0] * 26)
cum = [cnt.copy()]

for i, a in enumerate(s):
    cnt[a] += 1
    cum.append(cnt.copy())

def is_check(cum, n):
    for i in range(3, n+1, 2):
        d = i // 2
        for j in range(n-i+1):
            for k in cum[j+i] - cum[j]:
                if k > d:
                    return j+1, j+i
    return -1, -1

print(' '.join(map(str, is_check(cum, len(s)))))
Problem p04046 (python)

Fixed submission:
import scipy.misc as scm

h, w, a, b = [int(i) for i in input().split()]

p = 10**9 + 7
ans = 0

def fact(n, p=10**9 + 7):
    f = [1]
    for i in range(1, n+1):
        f.append(f[-1]*i%p)
    return f

def invfact(n, f, p=10**9 + 7):
    inv = [pow(f[n], p-2, p)]
    for i in range(n, 0, -1):
        inv.append(inv[-1]*i%p)
    return inv[::-1]

f = fact(h+w)
rf = invfact(h+w, f)

for i in range(w-b):
    wi = b + i
    ans += (f[h-a+wi-1] * rf[h-a-1] % p * rf[wi] % p) * (f[a+w-wi-2] * rf[a-1] % p * rf[w-wi-1] % p) % p
    ans %= p 

print(ans)

Buggy submission (verdict: Runtime Error):
h, w, a, b = [int(i) for i in input().split()]

p = 10 ** 9 + 7
s = 0

fact = [1]

for i in range(1, h+w-2):
    fact.append(fact[i-1] * i % p)

rfact = [(h+w-2) % p]

for i in range(h+w-1, 0, -1):
    rfact.append(rfact[-1] * i % p)

rfact.reverse()

def comb(n, r):
    return fact[n]//fact[n-r]//%pfact[r]%p

for i in range(w-b):
    s += comb(h+w-a-2-i, w-1-i) * comb(a-1+i, a-1)%p

print(s%p)

Buggy submission (verdict: Runtime Error):
import scipy.misc as scm

h, w, a, b = [int(i) for i in input().split()]

p = 10 * * 9 + 7
s = 0

for i in range(w-b):
    s += scm.comb(h+w-a-2-i, w-1-i, 1) * scm.comb(a-1+i, a-1, 1)

print(s%p)
Problem p02761 (python)

Fixed submission:
import sys
n,m=map(int,input().split())
l=[]
if m==0:
    if n==1:
        print(0)
        sys.exit()
    else:
        print(10**(n-1))
        sys.exit()
for i in range(m):
    l.append(list(map(int,input().split())))
sortfirst=lambda val:val[0]
l.sort()
l.sort(key=sortfirst)
for i in range(m-1):
    if l[i][0]==l[i+1][0] and l[i][1]!=l[i+1][1]:
        print(-1)
        sys.exit()
if l[0]==[1,0] and n>=2:
    print(-1)
    sys.exit()
ans=[1]+[0]*(n-1)
for i in range(m):
    ans[l[i][0]-1]=l[i][1]
print("".join(map(str,ans)))

Buggy submission (verdict: Runtime Error):
import sys
n,m=map(int,input().split())
l=[]
for i in range(m):
    l.append(list(map(int,input().split())))
sortfirst=lambda val:val[0]
l.sort(key=sortfirst)
for i in range(m-1):
    if l[i][0]==l[i+1][0] and l[i][1]!=l[i+1][1]:
        print(-1)
        sys.exit()
if l[0]==[1,0] and n>=2:
    print(-1)
    sys.exit()
ans=[0]*n
for i in range(m):
    ans[l[i][0]-1]=l[i][1]
print("".join(map(str,ans)))
Problem p02783 (python)

Fixed submission:
h,a=map(int,input().split())
if h%a!=0:
    print(h//a+1)
else:
    print(h//a)

Buggy submission (verdict: Runtime Error):
h,n=map(int,input().split())
INF=10**12
a=[]
b=[]
for i in range(n):
    A,B=map(int,input().split())
    a.append(A)
    b.append(B)
dp=[INF]*20010
dp[0]=0
for i in range(20010):
    for j in range(n):
        if i>=a[j]:
            dp[i]=min(dp[i],dp[i-a[j]]+b[j])
ans=min(dp[h:])
print(ans)
Problem p02946 (python)

Fixed submission:
k,x=map(int,input().split())
for i in range(x-k+1,x+k):
  if i<x+k-1:
    print(i,end=' ')
  else:
    print(i)

Buggy submission (verdict: Runtime Error):
k,x=map(int,input().split())
for i in range(x-k+1,x+k):
  if i<x+k-1:
    print(i,end' ')
  else:
    print(i)

Buggy submission (verdict: Runtime Error):
k,x=map(int,input().split())
for i in range(x-k+1,x+k):
  if i<x+k-1:
    print(i,end'')
  else:
    print(i)
Problem p02952 (python)

Fixed submission:
n=int(input())
if n<10:
  print(n)
elif n<100:
  print(9)
elif n<1000:
  print(n-90)
elif n<10000:
  print(909)
elif n<100000:
  print(n-9999+909)
else:
  print(90909)

Buggy submission (verdict: Runtime Error):
n=int(input())
list=filter(lambda x:x%2==1,range(1,n+1))
print(len(list))

Buggy submission (verdict: Runtime Error):
n=int(input())
list=filter(lambda x:x%2==1,range(1,n+1))
print(list.count())
Problem p02982 (python)

Fixed submission:
N,D=map(int,input().split())
X=[list(map(int,input().split())) for i in range(N)]
c=0
for i in range(N-1):
    for j in range(i+1,N):
        c += (sum((a-b)**2 for a,b in zip(X[i],X[j]))**0.5).is_integer()
print(c)

Buggy submission (verdict: Runtime Error):
N,D=map(int,input().split())
X=[list(map(int,input().split())) for i in range(N)]
c=0
for i in range(N-1):
    for j in range(i+1,N):
        c += (sum((a-b)**2) for a,b in zip(X[i],X[j]))**0.5.is_integer()
print(c)
Problem p03030 (python)

Fixed submission:
n=int(input())
a=[input().split() + [i+1] for i in range(n)]
for i in range(n):
  a[i][1]= -int(a[i][1])
a.sort()
for i in range(n):
  print(a[i][2])

Buggy submission (verdict: Runtime Error):
n=input()
a=[input().split() + [i+1] for i in range(n)]
for i in range(n):
  a[i][1]= -int(a[i][1])
a.sort()
for i in range(n):
  print(a[i][2])
Problem p03085 (python)

Fixed submission:
b=input()
if b=='A':
  print('T')
elif b=='T':
  print('A')
elif b=='G':
  print('C')
else:
  print('G')

Buggy submission (verdict: Runtime Error):
b=input()
if b='A':
  print('T')
elif b='T':
  print('A')
elif b='G':
  print('C')
else:
  print('G')
Problem p03086 (python)

Fixed submission:
s=input()
L=['A','T','G','C']
ans=0
M=0
for i in range(len(s)):
  if s[i] in L:
    ans += 1
  else:
      if ans > M:
          M = ans
          ans = 0
if ans > M:
    M = ans
    ans = 0
print(M)

Buggy submission (verdict: Runtime Error):
s=input()
L=['A','T','G','C']
ans=0
M=0
for i in range(s):
  if s[i] in L:
    ans += 1
  else:
    if ans > M:
      M = ans
    ans = 0
print(M)
Problem p03220 (python)

Fixed submission:
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
min = 1000
for i in range(n):
  T = t - h[i] * 0.006
  if abs(T-a) < min:
    min = abs(T-a)
    ans = i + 1
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
t,a=map(int,input().split())
h=map(int,input().split())
x=100000
ans=0
for i in h:
  if abs(t-i*0.006-a)<x:
    ans=index(i)
print(ans)
Problem p03238 (python)

Fixed submission:
n=int(input())
if n==1:
  print('Hello World')
else:
  a=int(input())
  b=int(input())
  print(a+b)

Buggy submission (verdict: Runtime Error):
n=input()
if n==1:
  print('Hello World')
else:
  a=input()
  b=input()
  print(a+b)
Problem p03308 (python)

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

Buggy submission (verdict: Runtime Error):
n=int(input())
a=map(int,input().split())
ans=0
while i in a:
  while s in a:
    x=abs(s-i)
    if x>ans:
      ans=x
print(ans)
Problem p03352 (python)

Fixed submission:
x = int(input())
c = 1
for b in range(2,x):
  for p in range(2,x):
    if b**p <= x:
      c = max(c,b**p)
    else:
      break
print(c)

Buggy submission (verdict: Runtime Error):
x = int(input())
c = 1
for b in range(2,x):
  for p in range(2,x):
    if b**p <= x:
      c = max(c,b**P)
    else:
      break
print(c)
Problem p03369 (python)

Fixed submission:
s=input()
print(700+100*s.count('o'))

Buggy submission (verdict: Runtime Error):
s=input()
print(700+100*s.count(o))
Problem p03399 (python)

Fixed submission:
a,b,c,d=[int(input()) for i in range(4)]
print(min(a,b)+min(c,d))

Buggy submission (verdict: Runtime Error):
for i in range(4):
  a,b,c,d=map(int,input().split())
print(min(a,b)+min(c,d))
Problem p03433 (python)

Fixed submission:
n=int(input())
a=int(input())
print('Yes' if n%500<=a else 'No')

Buggy submission (verdict: Runtime Error):
n=int(input())
li=map(int,input().split())
li=sorted(li)
A=0
B=0
for k in range(n//2):
  A += li[2*k]
  B += li[2*k+1]
if n % 2 ==1:
  A += li[n-1]
print(B-A)
Problem p03434 (python)

Fixed submission:
n=int(input())
li=map(int,input().split())
li=sorted(li)[::-1]
A=0
B=0
for k in range(n//2):
  A += li[2*k]
  B += li[2*k+1]
if n % 2 ==1:
  A += li[n-1]
print(A-B)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=sorted(list(map(int,input().split()))[::-1]
print(sum(a[::2])-sum(a[1::2]))

Buggy submission (verdict: Runtime Error):
n=int(input())
li=sorted[int(input()) for i in range(n)]
A=0
B=0
for k in range(n//2):
  A += li[2*k]
  B += li[2*k+1]
if n % 2 ==1:
  A += li[n-1]
print(B-A)
Problem p03477 (python)

Fixed submission:
a,b,c,d=map(int,input().split())
if (a+b)>(c+d):
  print('Left')
elif (a+b)==(c+d):
  print('Balanced')
else:
  print('Right')

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
if (a+b)>(c+d):
  print('Left')
elif (a+b)==(c+d):
  print('Balanced')
else:
  pritn('Right')
Problem p03493 (python)

Fixed submission:
n=input()
print(n.count('1'))

Buggy submission (verdict: Runtime Error):
n=input()
print(n.count('1')
Problem p03494 (python)

Fixed submission:
def how_many_times(n):
  ans=0
  while n%2==0:
    n=n/2
    ans=ans+1
  return ans

n=int(input())
a=map(int,input().split())
print(min(map(how_many_times,a)))

Buggy submission (verdict: Runtime Error):
def how_many_times(n):
  ans=0
  while n%2==0:
    n=n/2
    ans=ans+1
    return ans

n=int(input())
a=map(int,input().split())
print(min(map(how_many_times,a)))

Buggy submission (verdict: Runtime Error):
def how_many_times(n):
  ans=0
  while n%2==0:
    n=n/2
    ans=ans+1
    return ans

n=int(input())
a=map(int,input().split())
print(min(map(how_many_times(n),a)))
Problem p03502 (python)

Fixed submission:
n=input()
N=sum(list(map(int,n)))
print('Yes') if int(n)%N==0 else print('No')

Buggy submission (verdict: Runtime Error):
n=map(int,input())
print('Yes' if sum(n)%n==0 else 'No')
Problem p03547 (python)

Fixed submission:
x,y=input().split()
print('<' if x<y else '=' if x==y else '>')

Buggy submission (verdict: Runtime Error):
x,y=input().split()
print('<' if x<y '=' if x==y else '>')
Problem p03573 (python)

Fixed submission:
a,b,c=map(int,input().split())
print(c if a==b else b if a==c else a)

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
print(c if a==b else b if a==c else a if b==c)
Problem p03605 (python)

Fixed submission:
a=input()
if '9' in a:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
a=int(input())
if 9 in a:
  print('Yes')
else:
  print('No')
Problem p03623 (python)

Fixed submission:
x,a,b=map(int,input().split())
print('A' if min(abs(a-x),abs(b-x))==abs(a-x) else 'B')

Buggy submission (verdict: Runtime Error):
x,a,b=map(int,input().split())
print('A' if min(abs(a-x),abs(b-x)))==abs(a-x) else 'B')
Problem p03635 (python)

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

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=a-1
d=b-1
print(c*d)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=(a-1)
d=(b-1)
print(c*d)
Problem p03636 (python)

Fixed submission:
s=input()
print(s[0]+str(len(s)-2)+s[-1])

Buggy submission (verdict: Runtime Error):
s=input()
print(s[0]+len(s)+s[-1])
Problem p03694 (python)

Fixed submission:
input()
x=sorted(map(int,input().split()))
print(x[-1]-x[0])

Buggy submission (verdict: Runtime Error):
input()
x=map(int,input().split())
print(x[-1]-x[0])

Buggy submission (verdict: Runtime Error):

x=map(int,input().split())
print(x[-1]-x[0])

Buggy submission (verdict: Runtime Error):
n=input()
x=input().split()
print(x[-1]-x[0])

Buggy submission (verdict: Runtime Error):
n=input()
x=input().split()
print(x.[-1]-x.[0])
Problem p03729 (python)

Fixed submission:
a,b,c=input().split()
print('YES' if a[-1]==b[0] and b[-1]==c[0] else "NO")

Buggy submission (verdict: Runtime Error):
a,b,c=input().split()
print('YES' if a[-1]=b[0] and b[-1]=c[0] else "NO")

Buggy submission (verdict: Runtime Error):
a,b,c=map(input())
print('YES' if a[-1]=b[0] and b[-1]=c[0] else "NO")
Problem p03737 (python)

Fixed submission:
a,b,c=input().split()
print((a[0]+b[0]+c[0]).upper())

Buggy submission (verdict: Runtime Error):
a,b,c=input().split()
print((a[0],b[0],c[0],sep='').upper())

Buggy submission (verdict: Runtime Error):
a,b,c=input().split()
print((a[0],b[0],c[0],sep='').upper)
Problem p03796 (python)

Fixed submission:
a=int(input())
import math
print(math.factorial(a)%(10**9+7))

Buggy submission (verdict: Runtime Error):
a=int(input())
import math
print(math.fractional(a))
Problem p03813 (python)

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

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

Fixed submission:
a,op,b=input().split()
if op == '+':
  print(int(a)+int(b))
else:
  print(int(a)-int(b))

Buggy submission (verdict: Runtime Error):
a,op,b=input().split()
if op = '+':
  print(int(a)+int(b))
else:
  print(int(a)-int(b))
Problem p03943 (python)

Fixed submission:
a,b,c=sorted(map(int,input().split()))
print('Yes' if a+b==c else 'No')

Buggy submission (verdict: Runtime Error):
a,b,c=sorted(map(int,input().split()))
print('Yes' if x+y==z else 'No')

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
x,y,z=sorted(a,b,c)
print('Yes' if x+y==z else 'No')

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
x,y,z=sorted(a,b,c)
print('Yes' if x+y=z else 'No')
Problem p03998 (python)

Fixed submission:
S = {c:list(input()) for c in 'abc'}
s = 'a'
while S[s]:
  s=S[s].pop(0)
print(s.upper())

Buggy submission (verdict: Runtime Error):
S = {c:list(input()) for c in 'ABC'}
s = A
while S[s]:
  s=S[s].pop(0)
print(s)
Problem p02618 (python)

Fixed submission:
d=int(input())
c=list(map(int,input().split()))
c_days=[0]*26

fir_ans=0
for i in range(d):
    s=list(map(int,input().split()))
    ss=sorted(s, reverse=False)
    for k in range(26):
        num=ss[k]
        n=s.index(num)
        if c_days[n]==0:

            fir_ans+=num
            continue 
    c_days[n]=i+1
    print(n+1)
    '''
    for l in range(26):
        los=c[l]*(i+1-c_days[l])
        fir_ans-=los
    print(fir_ans)
    '''

Buggy submission (verdict: Runtime Error):
d=int(input())
for i in range(d):
   print(26%i+1)
Problem p02640 (python)

Fixed submission:
x,y=map(int,input().split())
if 2*x<=y and y%2==0 and 4*x>=y:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
x,y=map(int,input().solit())
if 2*x<=y and y%2==0 and 4*x>=y:
    print('Yes')
else:
    print('No')
Problem p02675 (python)

Fixed submission:
n=input()
if n[-1]=='3':
    print('bon')
elif n[-1]=='0' or n[-1]=='1' or n[-1]=='6' or n[-1]=='8':
    print('pon')
else:
    print('hon')

Buggy submission (verdict: Runtime Error):
import math
import sys
import numpy as np
a,b,h,m=map(int,input().split())
h=h*30+m*0.5
m=m*6
ma=max(h,m)
mi=min(h,m)
kakudo=abs(ma-mi)
if kakudo>180:
    kakudo=360-kakudo
elif kakudo == 0:
    print(abs(a-b))
    exit()
elif kakudo==180:
    print(a+b)
    exit()
c=math.cos(math.radians(kakudo))
#print(c)
ans=math.pow(a,2)+math.pow(b,2)-2*a*b*c
ans=math.sqrt(ans)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
a,b,h,m=map(int,input().split())
h=h*30+m*0.5
m=m*6
ma=max(h,m)
mi=min(h,m)
kakudo=abs(ma-mi)
if kakudo>180:
    kakudo-=180
elif kakudo ==0:
    print(abs(a-b))
    exit()
elif kakudo==180:
    print(a+b)
    exit()
#print(kakudo)
c=math.cos(math.radians(kakudo))
ans=a**2+b**2-2*a*b*c
ans=ans**0.5
print(ans)
Problem p02687 (python)

Fixed submission:
s=input()
if s=='ARC':
    print('ABC')
else:
    print('ARC')

Buggy submission (verdict: Runtime Error):
s=input()
if s=-'ARC':
    print('ABC')
else:
    print('ARC')
Problem p02717 (python)

Fixed submission:
x,y,z=map(int,input().split())
print('{} {} {}'.format(z,x,y))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
t=n%k
n=min(t,k)
print(n)
Problem p02842 (python)

Fixed submission:
import math
n=int(input())
num=math.ceil(n/1.08)
check=int(num*1.08)
if check==n:
    print(num)
else:
    print(':(')

Buggy submission (verdict: Runtime Error):
n=int(input())
num=round(n/1.08)
check=round(num*1.08)
if check==n
    print(num)
else:
    print(':(')
Problem p02899 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
for i in range(n):
    ans[a[i]-1]=i+1
print(*ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans=[]
for i in range(n):
    ans[a[i]-1]=i+1
print(*ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans=[]
for i in range(n+1):
    ans.append(a.index(i+1))
print(*ans)
Problem p02658 (python)

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

for i in a:
    ans *= i
    if ans > 10**18:
        ans = -1
        break

if a.count(0) > 0:
    ans = 0

print(ans)

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

for i in a:
    ans *= i
    if ans > 10**18:
    ans = -1
    break

print(ans)
Problem p02995 (python)

Fixed submission:
def gcd(a, b):
    if a < b:
        temp = a
        a = b
        b = temp

    r = a % b
    while r != 0:
        a = b
        b = r
        r = a % b

    return b


A, B, C, D = map(int, input().split())

c_st = (A-1) // C
c_end = B // C
c_num = c_end - c_st

d_st = (A-1) // D
d_end = B // D
d_num = d_end - d_st

E = (C * D) // gcd(C, D)
e_st = (A-1) // E
e_end = B // E
e_num = e_end - e_st

ans = B - A - c_num - d_num + e_num + 1

print(ans)

Buggy submission (verdict: Runtime Error):
import math

A, B, C, D = map(int, input().split())

c_st = (A-1) // C
c_end = B // C
c_num = c_end - c_st

d_st = (A-1) // D
d_end = B // D
d_num = d_end - d_st

E = (C * D) // math.gcd(C, D)
e_st = (A-1) // E
e_end = B // E
e_num = e_end - e_st

ans = B - A - c_num - d_num + e_num + 1
print(ans)
Problem p02573 (python)

Fixed submission:
#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

n, m = map(int,input().split())
#初期化
#根なら-size,子なら親の頂点
par = [-1]*n

for _ in range(m):
  a, b = map(int,input().split())
  a -= 1
  b -= 1
  unite(a,b)
  
print(-min(par))

Buggy submission (verdict: Runtime Error):
# データ構造: Union Find (素集合データ構造)
#  前提
#    グラフ（頂点と辺からなる集合）上の各頂点が、どの連結成分に属しているかを管理するときに使う
#    具体的には、各連結成分ごとに適当な1点を親として、同じ連結成分に属する他の点が子になるように配置する
#  できること
#    1, ある頂点の親を返す (つまり、どの連結成分に属するかがわかる)
#    2, 新たな辺が与えられた時、必要なら連結成分の統合を行う

# 以下、事前準備。(本処理は42行目から)
# 上記1,2を実現する関数を作成する。

# 0, 前提
par = [-1]*n
#  配列parの要素par[i]には、
#    頂点iが子の場合に 親頂点の番号
#    頂点iが親の場合に 属する連結成分の頂点数を格納する。(区別のため負数として表記)
#  例: par = [2, 2, -3, -1, 5, -1]
#    点0,1,2からなる連結成分、点3からなる連結成分、点4,5からなる連結成分がある場合。

# 1, 頂点xの親を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
      
# 2, 頂点xとyが属する連結成分を結合する
def unite(x,y):
    x = find(x)
    y = find(y) 
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

# 以下、本処理
# 求めるもの：各連結成分の頂点数のうち、最大のもの
n, m = map(int,input().split())
#初期化
#根なら-size,子なら親の頂点
par = [-1 for _ in range(n)]
 
for _ in range(m): #各辺について
  a, b = map(int,input().split())
  a -= 1
  b -= 1
  unite(a,b) #辺の両端(頂点aとb)が統合される
  
print(-min(par))
# 各連結成分の頂点数は、配列parの中に負数として記録されている。
# 連結成分の最大の頂点数を求めたければ、そのminをとって-1倍すればよい。
Problem p02615 (python)

Fixed submission:
from heapq import heapify,heappush,heappop
N = int(input())
A = list(map(int, input().split()))

A.sort()
a = A.pop()
q = []
heappush(q,-a)
ans = 0
while A:
  #print(A,q)
  b = A.pop()
  a = -heappop(q)
  ans += a
  heappush(q,-b)
  heappush(q,-b)
  
print(ans)

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

print(A.sum-A[-1])
Problem p02621 (python)

Fixed submission:
a = int(input())
print(a+a*a+a*a*a)

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

print(a+a*a+a*a*a)