Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import collections
import sys
input=sys.stdin.readline

def divisors(n):
  ret=[]
  for i in range(2,int(n**0.5)+1):
    if n%i==0:
      ret.append(i)
      while n%i==0:
        n//=i
  return ret

def gcd(a,b):
  if b==0:
    return a
  else:
    return gcd(b,a%b)

n=int(input())
arr=list(map(int,input().split()))
cnt=[False]*(max(arr)+1)
is_pairwise=True
tmp=arr[0]
for val in arr:
  tmp=gcd(tmp,val)
  if is_pairwise==False:
    continue
  divisor=divisors(val)
  for val2 in divisor:
    if cnt[val2]==True
      is_pairwise=False
      break
    cnt[val2]=True
if tmp==1:
  is_setwise=True
else:
  is_setwise=False
if is_pairwise==True:
  print('pairwise coprime')
elif is_setwise==True:
  print('setwise coprime')
else:
  print('not coprime')

Fixed submission:
#!/usr/bin/env python3

import collections
import sys
input=sys.stdin.readline

def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)

def judge(n,arr):
    MAX=10**6
    table=[i for i in range(MAX+1)]
    for i in range(2,MAX+1):
        if table[i]<i:
            continue
        for j in range(i,MAX+1,i):
            table[j]=i
    cnt=collections.defaultdict(int)
    for val in arr:
        s=set()
        while val!=1:
            prime=table[val]
            s.add(prime)
            val//=prime
        for tmp in s:
            cnt[tmp]+=1
    for val in cnt.values():
        if val>=2:
            return False
    return True
    
n=int(input())
arr=list(map(int,input().split()))
tmp=arr[0]
for val in arr:
    tmp=gcd(tmp,val)
if tmp==1:
    is_setwise=True
else:
    is_setwise=False
is_pairwise=judge(n,arr)
if is_pairwise==True:
    print('pairwise coprime')
elif is_setwise==True:
    print('setwise coprime')
else:
    print('not coprime')
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

import sys
input=sys.stdin.readline

s=input()
ans=0
for c in s:
    ans+=int(c)
    ans%=9
if ans==0:
    print('Yes')
else:
    print('No')

Fixed submission:
s=input()
ans=0
for c in s:
    ans+=int(c)
    ans%=9
if ans==0:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
import collections
import sys
input=sys.stdin.readline

def calc(n):
  cnt_2=0
  cnt_5=0
  while n%2==0 and cnt_2<18:
    cnt_2+=1
    n//=2
  while n%5==0 and cnt_5<18:
    cnt_5+=1
    n//=5
  return [cnt_2,cnt_5]

n=int(input())
dic=collections.defaultdict(int)
ans=0
for _ in range(n):
  tmp=input()
  if '.' in tmp:
    pos=tmp.index('.')
    d=len(tmp)-(pos+1)
    tmp=tmp[:pos]+tmp[pos+1:]+'0'*(9-d)
  else:
    tmp+='0'*9
  tmp=int(tmp)
  cnt_2,cnt_5=calc(tmp)
  dic[(cnt_2,cnt_5)]+=1
  if 18<=min(cnt_2*2,cnt_5*2):
    ans-=1
for a1,b1 in dic.keys():
  for a2,b2 in dic.keys():
    if min(a1+a2,b1+b2)>=18:
      ans+=dic[(a1,b1)]*dic[(a2,b2)]
print(ans//2)

Fixed submission:
import collections

def calc(n):
  cnt_2=0
  cnt_5=0
  while n%2==0:
    cnt_2+=1
    n//=2
  while n%5==0:
    cnt_5+=1
    n//=5
  if cnt_2>18:
    cnt_2=18
  if cnt_5>18:
    cnt_5=18
  return [cnt_2,cnt_5]

n=int(input())
dic=collections.defaultdict(int)
ans=0
for _ in range(n):
  tmp=input()
  if '.' in tmp:
    pos=tmp.index('.')
    d=len(tmp)-(pos+1)
    tmp=tmp[:pos]+tmp[pos+1:]
  else:
    d=0
  tmp=int(tmp)
  cnt_2,cnt_5=calc(tmp)
  dic[(cnt_2,cnt_5,d)]+=1
  if 2*d<=min(cnt_2*2,cnt_5*2):
    ans-=1
for a1,b1,d1 in dic.keys():
  for a2,b2,d2 in dic.keys():
    if min(a1+a2,b1+b2)>=d1+d2:
      ans+=dic[(a1,b1,d1)]*dic[(a2,b2,d2)]
print(ans//2)
Buggy python submission (verdict: Runtime Error):
import numpy 
 
def convolve(g, h):
  s=len(g)+len(h)+1
  n=1
  while n<s:
    n*=2
  gg=numpy.fft.fft(g+[0]*(n-len(g)))
  hh=numpy.fft.fft(h+[0]*(n-len(h)))
  ff=[gg[i]*hh[i] for i in range(n)]
  ff=numpy.fft.ifft(ff)
  ans=[int(ff[i].real+0.5) for i in range(n)]
  return ans

p=200003
n=int(input())
arr=list(map(int,input().split()))
pos={}
tmp=1
for i in range(p):
  pos[tmp]=i
  tmp*=2
  tmp%=p
cnt1=[0]*p
cnt2=[0]*p
for val in arr:
  if val!=0:
    cnt1[pos[val]]+=1
    cnt2[pos[val]]+=1
ans=convolve(cnt1,cnt2)
for val in arr:
  ans[pos[val]*2]-=1
total=0
for i in range(len(ans)):
  if ans[i]!=0:
    total+=(ans[i]//2)*pow(2,i,p)
print(total)

Fixed submission:
import numpy 
 
def convolve(g, h):
  s=len(g)+len(h)+1
  n=1
  while n<s:
    n*=2
  gg=numpy.fft.fft(g+[0]*(n-len(g)))
  hh=numpy.fft.fft(h+[0]*(n-len(h)))
  ff=[gg[i]*hh[i] for i in range(n)]
  ff=numpy.fft.ifft(ff)
  ans=[int(ff[i].real+0.5) for i in range(n)]
  return ans

p=200003
n=int(input())
arr=list(map(int,input().split()))
g=2
order=[1]
while g!=1:
  order.append(g)
  g*=2
  g%=p
pos=[0]*p
for i in range(len(order)):
  pos[order[i]]=i
cnt1=[0]*p
cnt2=[0]*p
coef=[0]*p
for val in arr:
  if val!=0:
    cnt1[pos[val]]+=1
    cnt2[pos[val]]+=1
    coef[(val*val)%p]-=1
ans=convolve(cnt1,cnt2)
for i in range(len(ans)):
  if ans[i]!=0:
    prod=order[i%(p-1)]
    coef[prod]+=ans[i]
total=0
for i in range(p):
  total+=(coef[i]//2)*i
print(total)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

import sys
input=sys.stdin.readline

n,k=map(int,input().split())
arr=list(map(int,input().split()))
l=-1
r=max(arr)+1
while r-l!=1:
    persuit=(r+l)//2
    cnt=0
    for val in arr:
        if val<=persuit:
            continue
        if val%persuit==0:
            cnt+=val//persuit-1
        else:
            cnt+=val//persuit
    if cnt<=k:
        r=persuit
    else:
        l=persuit
print(r)

Fixed submission:
#!/usr/bin/env python3

import sys
input=sys.stdin.readline

n,k=map(int,input().split())
arr=list(map(int,input().split()))
l=0
r=max(arr)+1
while r-l!=1:
    persuit=(r+l)//2
    cnt=0
    for val in arr:
        if val<=persuit:
            continue
        if val%persuit==0:
            cnt+=val//persuit-1
        else:
            cnt+=val//persuit
    if cnt<=k:
        r=persuit
    else:
        l=persuit
print(r)
Buggy python submission (verdict: Runtime Error):
n=int(input())
if n%1000=0:
  print(0)
else:
  print(1000-n%1000)

Fixed submission:
n=int(input())
if n%1000==0:
  print(0)
else:
  print(1000-n%1000)
Buggy python submission (verdict: Runtime Error):
n=int(input())
arr=list(map(int,input().split()))
arr=sorted(ans,reverse=True)
ans=0
for i in range(1,n):
  ans+=arr[i//2]
print(ans)

Fixed submission:
import heapq

n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr,reverse=True)
ans=0
q=[]
heapq.heappush(q,-arr[0])
for i in range(1,n):
  ans+=-heapq.heappop(q)
  heapq.heappush(q,-arr[i])
  heapq.heappush(q,-arr[i])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def calc():
  n=int(input())
  table=[i for i in range(n+1)]
  for i in range(2,n+1):
    if table[i]<i:
      continue
    for j in range(i,n+1,i):
      table[j]=i
  ans=0
  for i in range(1,n+1):
    cnt={}
    tmp=i
    while tmp!=1:
      if table[tmp] in cnt:
        cnt[table[tmp]]+=1
      else:
        cnt[table[tmp]]=1
      tmp//=table[tmp]
    tmp=i
    for val in cnt.values():
      tmp*=val+1
    ans+=tmp
  print(ans)
calc()

Fixed submission:
import sys
input=sys.stdin.readline

def calc():
  n=int(input())
  table=[1]*(n+1)
  check=[False]*(n+1)
  for i in range(2,n+1):
    if check[i]==True:
      continue
    check[i]=True
    for j in range(1,n//i+1):
      check[i*j]=True
      tmp=j
      cnt=1
      while tmp%i==0:
        tmp//=i
        cnt+=1
      table[i*j]*=(i**cnt)*(cnt+1)
  print(sum(table)-1)
calc()

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
t=[1]*(n+1)
check=[False]*(n+1)
for i in range(2,n+1):
  if check[i]==True:
    continue
  check[i]=True
  for j in range(1,n//i+1):
    check[i*j]=True
    cnt=0
    k=i*j
    while k%i==0:
      k//=i
      cnt+=1
    t[i*j]*=(i**cnt)*(cnt+1)
print(sum(t[1:]))

Fixed submission:
import sys
input=sys.stdin.readline

def calc():
  n=int(input())
  table=[1]*(n+1)
  check=[False]*(n+1)
  for i in range(2,n+1):
    if check[i]==True:
      continue
    check[i]=True
    for j in range(1,n//i+1):
      check[i*j]=True
      tmp=j
      cnt=1
      while tmp%i==0:
        tmp//=i
        cnt+=1
      table[i*j]*=(i**cnt)*(cnt+1)
  print(sum(table)-1)
calc()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**7)

INF=10**18
def calc(a,b,xor):
  if (a&1)^(b&1)!=(xor&1):
    return INF
  if xor==0:
    if a<b:
      return INF
    else:
      return (a-b)//2
  x=2*calc(a//2,b//2,xor//2)
  y=2*calc((a-1)//2,(b+1)//2,xor//2)+1
  return min(x,y)

n=int(input())
arr=list(map(int,input().split()))
a,b=arr[0],arr[1]
xor=0
for i in range(2,n):
  xor^=arr[i]
ans=calc(a,b,xor)
if ans>=a:
  print(-1)
else:
  print(ans)

Fixed submission:
INF=10**18
def calc(a,b,xor):
  if (a,b,xor) in memo:
    return memo[(a,b,xor)]
  if (a&1)^(b&1)!=(xor&1):
    return INF
  if xor==0:
    if a<b:
      return INF
    else:
      return (a-b)//2
  x=2*calc(a//2,b//2,xor//2)
  y=2*calc((a-1)//2,(b+1)//2,xor//2)+1
  memo[(a,b,xor)]=min(x,y)
  return memo[(a,b,xor)]

n=int(input())
arr=list(map(int,input().split()))
a,b=arr[0],arr[1]
xor=0
for i in range(2,n):
  xor^=arr[i]
memo={}
ans=calc(a,b,xor)
if ans>=a:
  print(-1)
else:
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
INF=10**18
def calc(a,b,xor):
  if (a&1)^(b&1)!=(xor&1):
    return INF
  if xor==0:
    if a<b:
      return INF
    else:
      return (a-b)//2
  x=2*calc(a//2,b//2,xor//2)
  y=2*calc((a-1)//2,(b+1)//2,xor//2)+1
  return min(x,y)

n=int(input())
arr=list(map(int,input().split()))
a,b=arr[0],arr[1]
xor=0
for i in range(2,n):
  xor^=arr[i]
ans=calc(a,b,xor)
if ans>=a:
  print(-1)
else:
  print(ans)

Fixed submission:
INF=10**18
def calc(a,b,xor):
  if (a,b,xor) in memo:
    return memo[(a,b,xor)]
  if (a&1)^(b&1)!=(xor&1):
    return INF
  if xor==0:
    if a<b:
      return INF
    else:
      return (a-b)//2
  x=2*calc(a//2,b//2,xor//2)
  y=2*calc((a-1)//2,(b+1)//2,xor//2)+1
  memo[(a,b,xor)]=min(x,y)
  return memo[(a,b,xor)]

n=int(input())
arr=list(map(int,input().split()))
a,b=arr[0],arr[1]
xor=0
for i in range(2,n):
  xor^=arr[i]
memo={}
ans=calc(a,b,xor)
if ans>=a:
  print(-1)
else:
  print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
ans=''
check='abcdefghijklmnopqrstuvwxyz'
while n!=0:
  n-=1
  ans+=check[n%26]
  n//=26
print(ans[::-1]

Fixed submission:
def calc():
  n=int(input())
  arr=[]
  check='abcdefghijklmnopqrstuvwxyz'
  while n!=0:
    n-=1
    arr.append(check[n%26])
    n//=26
  arr=arr[::-1]
  print(''.join(map(str,arr)))
  
calc()
Buggy python submission (verdict: Time Limit Exceeded):
import collections

n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr)
s=set()
cnt=collections.Counter(arr)
for i in range(n):
  if arr[i] in s:
    continue
  for j in range(2,10**6//arr[i]+1):
    s.add(arr[i]*j)
ans=0
for i in range(n):
  if arr[i] in s:
    continue
  if cnt[arr[i]]>=2:
    continue
  ans+=1
print(ans)

Fixed submission:
import collections

n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr)
s=set()
cnt=collections.Counter(arr)
for i in range(n):
  if arr[i] in s:
    continue
  if cnt[arr[i]]>=2:
    s.add(arr[i])
  for j in range(2,10**6//arr[i]+1):
    s.add(arr[i]*j)
ans=0
for i in range(n):
  if arr[i] in s:
    continue
  if cnt[arr[i]]>=2:
    continue
  ans+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def gauss_jordan(A):
  m=len(A)
  n=len(A[0])
  rank=0
  for col in range(n):
    pivot=-1
    for row in range(rank,m):
      if A[row][col]!=0:
        pivot=row
        break
    if pivot==-1:
      continue
    A[pivot],A[rank]=A[rank],A[pivot]
    for row in range(m):
      if row!=rank and A[row][col]!=0:
        for col2 in range(n):
          A[row][col2]^=A[rank][col2]      
    rank+=1
  if rank==len(A):
    return True
  else:
    return False

def make_vector(val):
  ret=[]
  for i in range(60,-1,-1):
    if val&(1<<i):
      ret.append(1)
    else:
      ret.append(0)
  return ret

t=int(input())
for _ in range(t):
  n=int(input())
  arr=list(map(int,input().split()))
  s=input()
  if s[-1]=='1':
    print(1)
    continue
  A=[make_vector(arr[-1])]
  for i in range(n-2,-1,-1):
    vector=make_vector(arr[i])
    if gauss_jordan(A+[vector]):
      if s[i]=='1':
        print(1)
        break
      if s[i]=='0':
        A.append(vector)
  else:
    print(0)

Fixed submission:
def gauss_jordan(A):
  m=len(A)
  n=len(A[0])
  rank=0
  for col in range(n):
    pivot=-1
    for row in range(rank,m):
      if A[row][col]!=0:
        pivot=row
        break
    if pivot==-1:
      continue
    A[pivot],A[rank]=A[rank],A[pivot]
    for row in range(m):
      if row!=rank and A[row][col]!=0:
        for col2 in range(n):
          A[row][col2]^=A[rank][col2]      
    rank+=1
  if rank==len(A):
    return True
  else:
    return False

def make_vector(val):
  ret=[]
  for i in range(60,-1,-1):
    if val&(1<<i):
      ret.append(1)
    else:
      ret.append(0)
  return ret

t=int(input())
for _ in range(t):
  n=int(input())
  arr=list(map(int,input().split()))
  s=input()
  if s[-1]=='1':
    print(1)
    continue
  A=[make_vector(arr[-1])]
  for i in range(n-2,-1,-1):
    vector=make_vector(arr[i])
    if gauss_jordan(A+[vector]):
      if s[i]=='1':
        print(1)
        break
      if s[i]=='0':
        A.append(vector)
  else:
    print(0)
Buggy python submission (verdict: Runtime Error):
n=int(input())
arr1=[]
arr2=[]
for _ in range(n):
  a,b=map(int,input().split())
  arr1.append(a)
  arr2.append(b)
arr1=sorted(arr1)
arr2=sorted(arr2)
if n%2==1:
  l=arr1[n//2]
  r=arr2[n//2]
else:
  l=arr1[n//2]+arr1[n//2+1]
  r=arr2[n//2]+arr2[n//2+1]
print(r-l+1)

Fixed submission:
n=int(input())
arr=[list(map(int,input().split())) for _ in range(n)]
if n%2==0:
  l=0
  r=10**9+1
  while r-l!=1:
    mid=(l+r)//2
    cnt1=0
    cnt2=0
    cnt3=0
    for a,b in arr:
      if mid<a:
        cnt1+=1
      elif mid>b:
        cnt2+=1
      else:
        cnt3+=1
    if cnt1>n//2:
      l=mid
    elif cnt2>n//2-1:
      r=mid
    else:
      l=mid
  r1=l
  l=0
  r=r1+1
  while r-l!=1:
    mid=(l+r)//2
    cnt1=0
    cnt2=0
    cnt3=0
    for a,b in arr:
      if mid<a:
        cnt1+=1
      elif mid>b:
        cnt2+=1
      else:
        cnt3+=1
    if cnt1>n//2:
      l=mid
    elif cnt2>n//2-1:
      r=mid
    else:
      r=mid
  l1=r
  l=0
  r=10**9+1
  while r-l!=1:
    mid=(l+r)//2
    cnt1=0
    cnt2=0
    cnt3=0
    for a,b in arr:
      if mid<a:
        cnt1+=1
      elif mid>b:
        cnt2+=1
      else:
        cnt3+=1
    if cnt1>n//2-1:
      l=mid
    elif cnt2>n//2:
      r=mid
    else:
      l=mid
  r2=l
  l=0
  r=r2+1
  while r-l!=1:
    mid=(l+r)//2
    cnt1=0
    cnt2=0
    cnt3=0
    for a,b in arr:
      if mid<a:
        cnt1+=1
      elif mid>b:
        cnt2+=1
      else:
        cnt3+=1
    if cnt1>n//2-1:
      l=mid
    elif cnt2>n//2:
      r=mid
    else:
      r=mid
  l2=r
  print((r1+r2)-(l1+l2)+1)  
elif n%2==1:
  l=0
  r=10**9+1
  while r-l!=1:
    mid=(l+r)//2
    cnt1=0
    cnt2=0
    cnt3=0
    for a,b in arr:
      if mid<a:
        cnt1+=1
      elif mid>b:
        cnt2+=1
      else:
        cnt3+=1
    if cnt1>n//2:
      l=mid
    elif cnt2>n//2:
      r=mid
    else:
      l=mid
  l1=l
  r1=r
  l=0
  r=l1+1
  while r-l!=1:
    mid=(l+r)//2
    cnt1=0
    cnt2=0
    cnt3=0
    for a,b in arr:
      if mid<a:
        cnt1+=1
      elif mid>b:
        cnt2+=1
      else:
        cnt3+=1
    if cnt1>n//2:
      l=mid
    elif cnt2>n//2:
      r=mid
    else:
      r=mid
  l2=l
  r2=r
  print(l1-r2+1)
Buggy python submission (verdict: Runtime Error):
n=int(input())
arr=list(map(int,input().split()))
if n==0:
  if arr[0]==1:
    print(1)
  else:
    print(-1)
acum=[arr[0]]
for i in range(1,n+1):
  acum.append(acum[-1]+arr[i])
b=[0]*n
b[0]=1-arr[0]
b[0]=min(b[0],acum[n]-b[0])
for i in range(1,n):
  b[i]=2*b[i-1]-arr[i]
  b[i]=min(b[i],acum[n]-acum[i])
for i in range(n):
  if b[i]<=0:
    print(-1)
    exit()
ans=sum(arr)+sum(b)
print(ans)

Fixed submission:
n=int(input())
arr=list(map(int,input().split()))
ans=sum(arr)
if n==0:
  if arr[0]==1:
    print(1)
  else:
    print(-1)
  exit()
for i in range(n):
  if i<=30 and arr[i]>=2**i:
    print(-1)
    exit()
if n<=30 and arr[n]>2**n:
  print(-1)
  exit()
maxs=[0]*(n+1)
maxs[0]=1
for i in range(1,n):
  maxs[i]=2*maxs[i-1]-arr[i]
tmp=arr[n]
for i in range(n-1,-1,-1):
  maxs[i]=min(maxs[i],tmp)
  tmp+=arr[i]
mins=[0]*(n+1)
for i in range(n-1,-1,-1):
  mins[i]=(mins[i+1]+arr[i+1]+1)//2
for i in range(n):
  if maxs[i]<mins[i]:
    print(-1)
    exit()
ans+=sum(maxs)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
arr=list(map(int,input().split()))
for i in range(n):
  arr[i]-=1
flag=format(k,'b')
flag=flag[::-1]
pos=0
for i in range(len(flag)):
  if flag[i]=='1':
    pos=arr[pos]
  tmp=[]
  for j in range(n):
    tmp.append(arr[arr[j]])
  arr=tmp
print(pos+1)

Fixed submission:
n,k=map(int,input().split())
arr=list(map(int,input().split()))
for i in range(n):
  arr[i]-=1
flag=format(k,'b')
flag=flag[::-1]
pos=0
for i in range(len(flag)):
  if flag[i]=='1':
    pos=arr[pos]
  tmp=[]
  for j in range(n):
    tmp.append(arr[arr[j]])
  arr=tmp
print(pos+1)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
arr1=[]
arr2=[]
for _ in range(n):
  s=input()
  cnt1=0
  cnt2=0
  for i in range(len(s)):
    if s[i]=='(':
      cnt1+=1
    else:
      if cnt1==0:
        cnt2+=1
      else:
        cnt1-=1
  if cnt1-cnt2>=0:
    arr1.append([cnt1,cnt2])
  else:
    arr2.append([cnt1,cnt2])
arr1=sorted(arr1,key=lambda x:x[1])
arr2=sorted(arr2,reverse=True,key=lambda x:x[0])
arr=arr1+arr2
cnt=0
for a,b in arr:
  if b>cnt:
    print('No')
    break
  else:
    cnt+=a-b
else:
  if cnt==0:
    print('Yes')
  else:
    print('No')

Fixed submission:
n=int(input())
arr1=[]
arr2=[]
for _ in range(n):
  s=input()
  cnt1=0
  cnt2=0
  for i in range(len(s)):
    if s[i]=='(':
      cnt1+=1
    else:
      if cnt1==0:
        cnt2+=1
      else:
        cnt1-=1
  if cnt1-cnt2>=0:
    arr1.append([cnt1,cnt2])
  else:
    arr2.append([cnt1,cnt2])
arr1=sorted(arr1,key=lambda x:x[1])
arr2=sorted(arr2,reverse=True,key=lambda x:x[0])
arr=arr1+arr2
cnt=0
for a,b in arr:
  if b>cnt:
    print('No')
    break
  else:
    cnt+=a-b
else:
  if cnt==0:
    print('Yes')
  else:
    print('No')
Buggy python submission (verdict: Runtime Error):
k=int(input())
a,b=int(input())
if b//k-(a-1)//k>=1:
  print('OK')
else:
  print('NG')

Fixed submission:
k=int(input())
a,b=map(int,input().split())
if b//k-(a-1)//k>=1:
  print('OK')
else:
  print('NG')
Buggy python submission (verdict: Runtime Error):
x=input()
tmp=100
for i in range(10000):
  if tmp>=x:
    print(i)
    break
  tmp+=tmp//100

Fixed submission:
x=int(input())
tmp=100
for i in range(10000):
  if tmp>=x:
    print(i)
    break
  tmp+=tmp//100
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
arr=list(map(int,input().split()))
arr=[[arr[i],i] for i in range(n)]
arr=sorted(arr,reverse=True,key=lambda x:x[0])
dp=[[-1]*(n+1) for _ in range(n+1)]
dp[0][0]=0
for i in range(n):
  for j in range(n):
    if dp[i][j]==-1:
      continue
    dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+arr[i][0]*abs(arr[i][1]-j))
    dp[i+1][j]=max(dp[i+1][j],dp[i][j]+arr[i][0]*abs(n-1-(i-j)-arr[i][1]))
print(max(dp[-1]))

Fixed submission:
n=int(input())
arr=list(map(int,input().split()))
arr=[[arr[i],i] for i in range(n)]
arr=sorted(arr,reverse=True,key=lambda x:x[0])
dp=[[-1]*(n+1) for _ in range(n+1)]
dp[0][0]=0
for i in range(n):
  for j in range(n):
    if dp[i][j]==-1:
      continue
    dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+arr[i][0]*abs(arr[i][1]-j))
    dp[i+1][j]=max(dp[i+1][j],dp[i][j]+arr[i][0]*abs(n-1-(i-j)-arr[i][1]))
print(max(dp[-1]))
Buggy python submission (verdict: Time Limit Exceeded):
def calc():
  n=int(input())
  arr=list(map(int,input().split()))
  acum1=[0]
  acum2=[0]
  for i in range(n):
    if i%2==0:
      acum1.append(acum1[-1]+arr[i])
      acum2.append(acum2[-1]+0)
    else:
      acum1.append(acum1[-1]+0)
      acum2.append(acum2[-1]+arr[i])
  if n%2==0:
    ans=max(acum1[n-1],acum2[n])
    for i in range(1,n+1,2):
      if i+3>n:
        continue
      tmp=(acum1[i]-acum1[0])+(acum2[n]-acum2[i+2])
      ans=max(ans,tmp)
  else:
    ans=max(acum1[n-2]-acum1[0],acum2[n-1]-acum2[1],acum1[n]-acum1[2])
    for i in range(1,n+1,2):
      if i+3>n-1:
        continue
      tmp=(acum1[i]-acum1[0])+(acum2[n-1]-acum2[i+2])
      ans=max(ans,tmp)
    for i in range(2,n+1,2):
      if i+3>n:
        continue
      tmp=(acum2[i]-acum2[1])+(acum1[n]-acum1[i+2])
      ans=max(ans,tmp)
    for i in range(1,n+1,2):
      if i+4>n:
        continue
      tmp=(acum1[i]-acum1[0])+(acum1[n]-acum1[i+3])
      ans=max(ans,tmp)
    for i in range(1,n+1,2):
      for j in range(i+3,n+1,2):
        if j+3>n:
          continue
        tmp=(acum1[i]-acum1[0]-acum2[i+2])+(acum2[j]+acum1[n]-acum1[j+2])
        ans=max(ans,tmp)
  print(ans)
calc()

Fixed submission:
n=int(input())
arr=list(map(int,input().split()))
if n<=3:
  print(max(arr))
  exit()
lim=n%2+2
dp=[[0]*lim for _ in range(n+1)]
for i in range(n):
  dp[i+1][0]=dp[i-1][0]+arr[i]
  dp[i+1][1]=max(dp[i-1][1]+arr[i],dp[i-2][0]+arr[i])
  if lim==3:
    dp[i+1][2]=max(dp[i-1][2]+arr[i],dp[i-2][1]+arr[i],dp[i-3][0]+arr[i])
print(max(dp[-1][:lim]))
Buggy python submission (verdict: Runtime Error):
n,k,c=map(int,input().split())
s=input()
l=len(s)
cand=[]
for i in range(l):
  if s[i]=='o':
    cand.append(i)
cnt1=[0]*n
cnt2=[0]*n
prev=0
cnt=0
for i in range(l):
  if s[i]=='o' and i>=prev:
    cnt+=1
    cnt1[i]=cnt
    prev=i+(c+1)
  else:
    cnt1[i]=cnt
prev=l-1
cnt=0
for i in range(l-1,-1,-1):
  if s[i]=='o' and i<=prev:
    cnt+=1
    cnt2[i]=cnt
    prev=i-(c+1)
  else:
    cnt2[i]=cnt
ans=[]
for i in range(len(cand)):
  if i==0:
    if cnt2[cand[i]+1]<k:
      ans.append(cand[i]+1)
  elif i==len(cand)-1:
    if cnt1[cand[i]-1]<k:
      ans.append(cand[i]+1)
  else:
    if cnt1[cand[i]-1]+cnt2[cand[i]+1]<k:
      ans.append(cand[i]+1)
for val in ans:
  print(val)

Fixed submission:
n,k,c=map(int,input().split())
s=input()
l=len(s)
cand=[]
for i in range(l):
  if s[i]=='o':
    cand.append(i)
if len(cand)==k:
  for val in cand:
    print(val+1)
else:
  cnt1=[0]*n
  cnt2=[0]*n
  prev=0
  cnt=0
  for i in range(l):
    if s[i]=='o' and i>=prev:
      cnt+=1
      cnt1[i]=cnt
      prev=i+(c+1)
    else:
      cnt1[i]=cnt
  prev=l-1
  cnt=0
  for i in range(l-1,-1,-1):
    if s[i]=='o' and i<=prev:
      cnt+=1
      cnt2[i]=cnt
      prev=i-(c+1)
    else:
      cnt2[i]=cnt
  ans=[]
  for i in range(len(cand)):
    if i==0:
      if cnt2[cand[i]+1]<k:
        ans.append(cand[i]+1)
    elif i==len(cand)-1:
      if cnt1[cand[i]-1]<k:
        ans.append(cand[i]+1)
    else:
      if cnt1[cand[i]-1]+cnt2[cand[i]+1]<k:
        ans.append(cand[i]+1)
  for val in ans:
    print(val)
Buggy python submission (verdict: Runtime Error):
def divisors(n):
  ret=[]
  for i in range(2,int(n**0.5)+1):
    if n%i==0:
      ret.append(i)
      if n//i!=i:
        ret.append(n//i)
  return ret

n=int(input())
divs1=divisors(n)
divs2=divisors(n-1)
print(divs1)
print(divs2)
cand=divs2
for val in divs2:
  cand.add(val)
for val in divs1:
  tmp=n
  while tmp%val==0:
    tmp=tmp//val
  if tmp%val==1:
    cand.append(val)
if n not in cand:
  cand.append(n)
if n-1!=1 and n-1 not in cand:
  cand.append(n-1)
print(cand)
print(len(cand))

Fixed submission:
def divisors(n):
  ret=[]
  for i in range(2,int(n**0.5)+1):
    if n%i==0:
      ret.append(i)
      if n//i!=i:
        ret.append(n//i)
  return ret

n=int(input())
if n==2:
  print(1)
else:
  divs1=divisors(n)
  divs2=divisors(n-1)
  cand=divs2
  for val in divs1:
    tmp=n
    while tmp%val==0:
      tmp=tmp//val
    if tmp%val==1:
      cand.append(val)
  if n not in cand:
    cand.append(n)
  if n-1 not in cand:
    cand.append(n-1)
  print(len(cand))
Buggy python submission (verdict: Runtime Error):
s=int(input())
if s[2]==s[3] and s[4]==s[5]:
  print('Yes')
else:
  print('No')

Fixed submission:
s=input()
if s[2]==s[3] and s[4]==s[5]:
  print('Yes')
else:
  print('No')