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

Fixed submission:
from collections import*
input=open(0).readline
n=int(input())
e=[[]for _ in range(n)]
for _ in range(n-1):
    a,b=map(int,input().split())
    e[a-1].append(b-1)
    e[b-1].append(a-1)
f=[0]*n
v=[1]+[0]*~-n
q=deque([(0,0)])
while q:
    t,c=q.pop()
    v[t]=1
    f[t]=c
    for i in e[t]:
        if not v[i]:
            q.append((i,c+1))
s=[0]*n
v=[0]*~-n+[1]
q=deque([(n-1,0)])
while q:
    t,c=q.pop()
    v[t]=1
    s[t]=c
    for i in e[t]:
        if not v[i]:
            q.append((i,c+1))
a=b=0
for i,j in zip(f,s):
    if i<=j:
        a+=1
    else:
        b+=1
if a>b:
    print('Fennec')
else:
    print('Snuke')

Buggy submission (verdict: Runtime Error):
from networkx import*
N,*t=map(str.split,open(0))
s=shortest_path_length
x=s(G:=Graph(t),'1')
y=s(G,N)
print('FSennunkeec'[sum(x[k]>y[k]for k in x)*2>=int(*N)::2])
Problem p03666 (python)

Fixed submission:
n,a,b,c,d=map(int,input().split())
f=0
for i in range(n):f|=i*c-(~i+n)*d<=b-a<=i*d-(~i+n)*c
print('NYOE S'[f::2])

Buggy submission (verdict: Runtime Error):
n,a,b,c,d=map(int,input().split());print('NYOE S'[any(i*c-(~i+n)*d<=b-a<=i*d-(~i+n)*cfor i in range(n))::2])
Problem p03712 (python)

Fixed submission:
_,w,*s=open(0).read().split();t=['#'*(int(w)+2)];a=t+['#'+t+'#'for t in s]+t;print(*a,sep='\n')

Buggy submission (verdict: Runtime Error):
_,w,*s=open(0).read().split();t=['#'*(int(w)+2)];print(t,*['#'+t+'#'for t in s],t)
Problem p03720 (python)

Fixed submission:
n,_,*r=map(int,open(0).read().split())
for i in range(n):print(r.count(-~i))

Buggy submission (verdict: Runtime Error):
n,_,*r=map(int,open(0).read().split());for i in range(n):print(r.count(-~i))
Problem p03729 (python)

Fixed submission:
a,b,c=input().split();print('YNEOS'[a[::-1][0]!=b[0]or b[::-1][0]!=c[0]::2])

Buggy submission (verdict: Runtime Error):
import re;a,b=re.findall('. .',input());print('YNEOS'[a[0]+b[2]!=a[2]+b[0]::2])

Buggy submission (verdict: Runtime Error):
s=input().find;i=s(' ');j=s(' ',i);print('YNEOS'[s[i-1]+s[j+1]!=s[i+1]+s[j-1]::2])

Buggy submission (verdict: Runtime Error):
a,b,c=input().split();print('YNEOS'[a[-1]+c[0]!=b[::len(b)-1]::2])
Problem p03730 (python)

Fixed submission:
from fractions import*;a,b,c=map(int,input().split());print('YNEOS'[c%gcd(a,b)>0::2])

Buggy submission (verdict: Runtime Error):
from numpy import*;a,b,c=int_(input().split());print('YNEOS'[c%gcd(a,b)>0::2])
Problem p03737 (python)

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

Buggy submission (verdict: Runtime Error):
print([*zip(*input().split())][0].upper())

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

Fixed submission:
n,m,*t=map(int,open(0).read().split())
e=[[]for _ in range(n+1)]
for a,b in zip(t[::2],t[1::2]):
    e[a].append(b)
    e[b].append(a)
f=[0]*-~n
f[1]=1
a=[1]
while 1:
    for v in e[a[-1]]:
        if not f[v]:
            f[v]=1
            a.append(v)
            break
    else:
        break
b=[1]
while 1:
    for v in e[b[-1]]:
        if not f[v]:
            f[v]=1
            b.append(v)
            break
    else:
        break
a=a[:0:-1]+b
print(len(a),*a)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)
def solve(v):
    t=[]
    for u in e[v]:
        if not f[u]:
            f[u]=1
            t=solve(u)+t
            break
    return [v]+t
n,m,*t=map(int,open(0).read().split())
e=[[]for _ in range(n+1)]
for a,b in zip(t[::2],t[1::2]):
    e[a].append(b)
    e[b].append(a)
f=[0]*-~n
f[1]=1
a=solve(1)[:0:-1]+solve(1)
print(len(a),*a)

Buggy submission (verdict: Runtime Error):
def solve(v):
    t=[]
    for u in e[v]:
        if not f[u]:
            f[u]=1
            t=solve(u)+t
            break
    return [v]+t
n,m,*t=map(int,open(0).read().split())
e=[[]for _ in range(n+1)]
for a,b in zip(t[::2],t[1::2]):
    e[a].append(b)
    e[b].append(a)
f=[0]*-~n
f[1]=1
a=solve(1)[:0:-1]+solve(1)
print(len(a),*a)
Problem p03795 (python)

Fixed submission:
n=int(input());print(n*800-n//15*200)

Buggy submission (verdict: Runtime Error):
n=input();print(n*800-n//15*200)
Problem p03796 (python)

Fixed submission:
n = int(input())
ans = 1
for i in range(1, n + 1):
    ans = ans * i % 1000000007
print(ans)

Buggy submission (verdict: Runtime Error):
import math;print(math.factorial(int(input()))%(1e9+7))
Problem p03801 (python)

Fixed submission:
e=enumerate
n,a=open(0)
a=sorted((int(i),j)for j,i in e(('0 '+a).split()))[::-1]
c=[0]*int(n)
t=10**18
for k,(i,j)in e(a[:-1],1):
  t=min(t,j)
  c[t-1]+=(i-a[k][0])*k
print(*c)

Buggy submission (verdict: Runtime Error):
n,a=open(0)
*a,=map(int,a.split())
c,d={},{}
m=0
for j,i in enumerate(a):
  if i>m:d[i],m=j,i
  c[i]=c.get(i,0)+1
i=sorted(d)[::-1]
a=[0]*int(n)
for i,j in zip(i,i[1:]):
  a[d[i]]=(i-j)*c[i]
  c[j]+=c[i]
a[d[j]]=j*c[j]
print(*a)
Problem p03807 (python)

Fixed submission:
input();print('YNEOS'[sum(int(i)%2for i in input().split())%2::2])

Buggy submission (verdict: Runtime Error):
input();print('YNEOS'[eval(input().replace(' ','^'))&1::2])

Buggy submission (verdict: Runtime Error):
input();print('YNEOS'[eval(input().replace(' ','^'))::2])
Problem p03808 (python)

Fixed submission:
n,*a=map(int,open(0).read().split())
b,m=sum(a),n*-~n//2
n-=1
c=b//m
f=b%m>0
for i,j in zip(*[iter([a[-1]]+a*2)]*2):
  j-=i
  if n:
    t=min(0,j//n)
    f|=c!=j+n*-t-t
print('YNEOS'[f::2])

Buggy submission (verdict: Runtime Error):
n,*a=map(int,open(0).read().split())
b,m=sum(a),n*-~n//2
n-=1
c=b//m
f=b%m>0
for i,j in zip(*[iter([a[-1]]+a*2)]*2):
  j-=i
  t=min(0,j//n)
  f|=c!=j+n*-t-t
print('YNEOS'[f::2])
Problem p03813 (python)

Fixed submission:
print('ABC'*(int(input())<1200)or'ARC')

Buggy submission (verdict: Runtime Error):
print('ABC'(int(input())<1200)or'ARC')
Problem p03840 (python)

Fixed submission:
i,o,t,j,l,s,z=map(int,input().split())
a=(i//2+j//2+l//2)*2
print([a,max(a,((i-1)//2+(j-1)//2+(l-1)//2)*2+3)][not(not(i and j and l))]+o)

Buggy submission (verdict: Runtime Error):
i,o,t,j,l,s,z=map(int,input().split())
a=(i//2+j//2+l//2)*2
print([a,max(a,((i-1)//2+(j-1)//2+(l-1)//2)*2+3)][i and j and l]+o)

Buggy submission (verdict: Runtime Error):
i,o,t,j,l,s,z=map(int,input().split())
a=(i//2+j//2+l//2)*2
print([a,max(a,((i-1)//2+(j-1)//2+(l-1)//2)*2+3)][i and j and l]+o)
Problem p03860 (python)

Fixed submission:
print'A%sC'%raw_input()[8]

Buggy submission (verdict: Runtime Error):
print'A%sC'%input()[8]
Problem p03937 (python)

Fixed submission:
h,w=map(int,input().split())
s=[input()for _ in[0]*h]
a=[['..','..'],['.#','..'],['..','#.'],['##','..'],['..','##'],['#.','#.'],['.#','.#'],['##','.#'],['#.','##']]
for i in range(h-1):
  for j in range(w-1):
    t=s[i][j:j+2]
    u=s[i+1][j:j+2]
    for b in a:
      if t==b[0]and u==b[1]:
        break
    else:
      print('Impossible')
      exit()
print('Possible')

Buggy submission (verdict: Runtime Error):
from functools import lru_cache
@lru_cache(maxsize=None)
def search(i,j):
  global s,h,w
  if i==h-1and j==w-1:return 1
  r=0
  if i<h-1and s[i+1][j]=='#':r|=search(i+1,j)
  else if j<w-1and s[i][j+1]=='#':r|=search(i,j+1)
  if i>0and s[i-1][j]=='#':r=0
  if j>0and s[i][j-1]=='#':r=0
  return r
h,w=map(int,input().split())
s=[input()for _ in[0]*h]
print(('P'*search(0,0)or'Imp')+'ossible')
Problem p03943 (python)

Fixed submission:
*a,=map(int,input().split());print('YNeos'[sum(a)/2!=max(a)::2])

Buggy submission (verdict: Runtime Error):
*a=map(int,input().split());print('YNeos'[sum(a)/2!=max(a)::2])
Problem p03970 (python)

Fixed submission:
s=list('CODEFESTIVAL2016');t=list(input());print(sum([1 for i in range(16) if s[i]!=t[i]]))

Buggy submission (verdict: Runtime Error):
import difflib;print(difflib.SequenceMatcher(None,'CODEFESTIVAL2016',input())*100//16)
Problem p03993 (python)

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

Buggy submission (verdict: Runtime Error):
n = int(input())
a = map(int, input().split())
c = 0
for i in range(n):
  if a[a[i]] == i:
    c++
print(c)
Problem p04013 (python)

Fixed submission:
n,a,*x=map(int,open(0).read().split())
x=[0]+x
dp=[[[0]*(50*n+1)for j in range(n+1)]for i in range(n+1)]
dp[0][0][0]=1
for i in range(1,n+1):
  dp[i][0]=dp[i-1][0]
  for j in range(1,n+1):
    for k in range(1,50*n+1):
      dp[i][j][k]=dp[i-1][j][k]
      if k-x[i]>=0:
        dp[i][j][k]+=dp[i-1][j-1][k-x[i]]
ans=0
for i in range(1,n+1):
  j=i*a
  if j<50*n+2:
    ans+=dp[-1][i][j]
print(ans)

Buggy submission (verdict: Runtime Error):
def main():
  n,a,*x=map(int,open(0).read().split())
  x=[0]+x
  dp=[[[0]*(50*n+1)for j in range(n+1)]for i in range(n+1)]
  dp[0][0][0]=1
  for i in range(1,n+1):
    dp[i][0]=dp[i-1][0]
    for j in range(1,n+1):
      for k in range(1,50*n+1):
        dp[i][j][k]=dp[i-1][j][k]
        if k-x[i]>=0:
          dp[i][j][k]+=dp[i-1][j-1][k-x[i]]
  ans=0
  for i in range(1,n+1):
    j=i*a
    if j<50*n+2:
      ans+=dp[-1][i][j]
  print(ans)
def __name__=='__main__':
  main()
Problem p04017 (python)

Fixed submission:
from math import*
from bisect import*
n,*t=map(int,open(0).read().split())
m=int(log2(n))+1
x=t[:n]
l=t[n]
d=[[bisect(x,y+l)-1for y in x]]+[[0]*n for _ in range(m)]
for i in range(m):
    for j in range(n):
        d[i+1][j]=d[i][d[i][j]]
for a,b in zip(t[n+2::2],t[n+3::2]):
    a-=1
    b-=1
    if b<a:a,b=b,a
    c=1
    for i in range(m,-1,-1):
        if d[i][a]<b:
            a=d[i][a]
            c+=2**i
    print(c)

Buggy submission (verdict: Runtime Error):
from bisect import*
r=range
n,*t=map(int,open(0).read().split())
m=2**16
x=t[:n]
d=[[bisect(x,y+t[n])-1for y in x]]+[[0]*n for _ in r(m)]
for i in r(m):
  for j in r(n):
    d[i+1][j]=d[i][d[i][j]]
for a,b in zip(t[n+2::2],t[n+3::2]):
  a-=1
  b-=1
  if b<a:a,b=b,a
  c=1
  for i in r(m,-1,-1):
    if d[i][a]<b:
      a=d[i][a]
      c+=2**i
  print(c)

Buggy submission (verdict: Runtime Error):
from bisect import*
r=range
n,*t=map(int,open(0).read().split())
m=2**16
x=t[:n]
d=[[bisect(x,y+t[n])-1for y in x]]+[[0]*n for _ in r(m)]
for i in r(m):
  for j in r(n):
    d[i+1][j]=d[i][d[i][j]]
for a in zip(t[n+2::2],t[n+3::2]):
  a,b=sorted(i-1for i in a)
  c=1
  for i in r(m,-1,-1):
    if d[i][a]<b:
      a=d[i][a]
      c+=2**i
  print(c)

Buggy submission (verdict: Runtime Error):
from math import*
from bisect import*
n,*t=map(int,open(0).read().split())
m=int(log2(n))+1
x=t[:n]
l=t[n]
d=[[bisect(x,y+l)-1for y in x]]+[[0]*n for _ in range(m)]
for i in range(m):
    for j in range(n):
        d[i+1][j]=d[i][d[i][j]]
for a,b in zip(t[n+2::2],t[n+3::2]):
    a-=1
    b-=1
    if b<a:a,b=b,a
    c=1
    for i in range(m,-1,-1):
        if d[i][a]<b:
            a=d[i][a]
            c+=2**i
    print(c)
Problem p04020 (python)

Fixed submission:
t=c=0
for _ in[0]*input():i=input();c+=(i+t)/2;t=(i+t)%2&(i>0)
print c

Buggy submission (verdict: Runtime Error):
s=t=0
for _ in[0]*int(input()):a=int(input());s+=(a+t)//2;t=(a+t)%2&(i>0)
print(s)
Problem p04032 (python)

Fixed submission:
s=input()
n=len(s)
for i in range(n-1):
  if s[i]==s[i+1]:
    print(i+1,i+2)
    break
  elif i<n-2 and s[i]==s[i+2]:
    print(i+1,i+3)
    break
else:
  print(-1,-1)

Buggy submission (verdict: Runtime Error):
s=input()
n=len(s)
for i in range(n-1):
  if s[i]==s[i+1]:
    print(i+1,i+2)
    break
  elif i<n-1 and s[i]==s[i+2]:
    print(i+1,i+3)
    break
else:
  print(-1,-1)

Buggy submission (verdict: Runtime Error):
s=input()
n=len(s)
for i in range(n-1):
  if s[i]==s[i+1]:
    print(i,i+1)
    break
  elif i<n-1 and s[i]==s[i+2]:
    print(i,i+2)
    break
else:
  print(-1,-1)
Problem p04033 (python)

Fixed submission:
a,b=map(int,input().split());print('Zero'*(a+b==0or abs(a+b)<abs(a)+abs(b))or'NPeogsaittiivvee'[a>0or(b-a)%2::2])

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split());print('NPeogsaittiivvee'[a>0or(b-a)%2::2]*(a*b>0)or'Zero')

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split());print('NPeogsaittiivvee'[a>0or(b-a)%2::2]*(a*b>0)or'Zero')

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split());print('Zero'*(a*b<=0)or'NPeogsaittiivvee'[b>=0or(b-a)%2::2])

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split());print('Zero'*(a+b==0or abs(a+b)<abs(a)+abs(b))or'NPeogsaittiivvee'[a>0or(b-a)%2::2])
Problem p04039 (python)

Fixed submission:
n=int(input().split()[0]);a=set(input())
while a&set(str(n)):n+=1
print(n)

Buggy submission (verdict: Runtime Error):
n=int(input()[:4]);a=set(input())
while a&set(str(n)):n+=1
print(n)

Buggy submission (verdict: Runtime Error):
n=int(input()[:5]);a=set(input())
while a&set(str(n)):n+=1
print(n)
Problem p02641 (python)

Fixed submission:
x, n = map(int, input().split())
if n == 0:
  print(x)
  exit(0)
p = list(map(int, input().split()))
a = [i for i in range(201)]
b = sorted(list(set(a) - set(p)))
min_v = 1000
min_id = 0
for i in range(len(b)):
  if abs(x - b[i]) < min_v:
    min_v = abs(x - b[i])
    min_id = i
print(b[min_id])

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
if n == 0:
  print(x)
  exit(0)
p = list(map(int, input().split()))
a = [i for i in range(1,101)]
b = list(set(a) - set(p))
for i in range(1,len(b)):
  if x <= b[i]:
    if abs(b[i-1]-x) <= abs(b[i]-x):
      print(b[i-1])
      exit(0)
    else:
      print(b[i])
      exit(0)
print(b[-1])

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
if n == 0:
  print(x)
  exit(0)
p = list(map(int, input().split()))
a = [i for i in range(1,101)]
b = list(set(a) - set(p))
for i in range(len(b)):
  if x <= b[i]:
    if abs(b[i-1]-x) <= abs(b[i]-x):
      print(b[i-1])
      exit(0)
    else:
      print(b[i])
      exit(0)
print(b[-1])

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
if n == 0:
  print(x)
  exit(0)
p = list(map(int, input().split()))
a = [i for i in range(1,101)]
b = list(set(a) - set(p))
for i in range(len(b)):
  if x <= b[i]:
    if abs(b[i-1]-x) <= abs(b[i]-x):
      print(b[i-1])
      exit(0)
    else:
      print(b[i])
      exit(0)
print(x-b[-1])

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
if n == 0:
  print(x)
  exit(0)
p = list(map(int, input().split()))
a = [i for i in range(1,101)]
b = list(set(a) - set(p))
for i in range(len(b)):
  if x < b[i]:
    if abs(b[i-1]-x) <= abs(b[i]-x):
      print(b[i-1])
      exit(0)
    else:
      print(b[i])
      exit(0)
print(x-b[-1])

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
if n == 0:
  print(x)
  exit(0)
p = list(map(int, input().split()))
a = [i for i in range(1,101)]
b = list(set(a) - set(p))
for i in range(len(b)):
  if x < b[i]:
    if abs(b[i-1]-x) <= abs(b[i]-x):
      print(b[i-1])
      break
    else:
      print(b[i])
      break
print(x-b[-1])
Problem p02657 (python)

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

Buggy submission (verdict: Runtime Error):
a, b = map(int, intput().split())
print(a * b)

Buggy submission (verdict: Runtime Error):
a, b = map(int, intpu().split())
print(a * b)
Problem p03325 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
c = 0
for i in range(n):
  while a[i] % 2 == 0:
    a[i] /= 2
    c += 1
print(c)

Buggy submission (verdict: Runtime Error):
from decimal import Decimal
n = int(input())
a = list(map(Decimal, input().split()))
cnt = 0
hal = True
while hal:
  hal = False
  for i in range(n):
    if hal == False and a[i] % 2 == 0:
      a[i] /= 2
      hal = True
    else:
      a[i] *= 3
  if hal:
    cnt += 1
print(cnt)
Problem p04012 (python)

Fixed submission:
s = list(input())
if all(s.count(x) % 2 == 0 for x in set(s)):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  string s;
  cin >> s;
  for (char c = 97; c <= 122; c++) {
    if (count(s.begin(), s.end(), c) % 2 != 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}
Problem p02574 (python)

Fixed submission:
import math
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))
m=max(a)+1
g=a[0]
d=dict()
for i in a:
    g=math.gcd(g,i)
    if i in d:
        d[i]+=1
    else:
        d[i]=1
if g>1:
    print("not coprime")
else:
    p=[0]*(m)
    ch=0
    for i in range (2,m):
        if p[i]==1:
            continue
        p[i]=1
        ans=0
        for j in range (i,m,i):
            if j in d:
                ans+=d[j]
        if ans>1:
            ch=1
            break
    if ch==1:
        print("setwise coprime")
    else:
        print("pairwise coprime")

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
a=list(map(int,input().split()))
m=max(a)+1
g=a[0]
d=dict()
for i in a:
    g=math.gcd(g,i)
    if i in d:
        d[i]+=1
    else:
        d[i]=1
if g>1:
    print("not coprime")
else:
    p=[0]*(m)
    ch=0
    for i in range (2,m):
        if p[i]==1:
            continue
        p[i]=1
        ans=0
        for j in range (i,m,i):
            ans+=d[j]
        if ans>1:
            ch=1
            break
    if ch==1:
        print("setwise coprime")
    else:
        print("pairwise coprime")

Buggy submission (verdict: Runtime Error):
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))
a.sort()
g=a[0]
d=defaultdict(int)
for i in a:
    g=math.gcd(g,i)
    d[i]+=1
if g>1:
    print("not coprime")
p=[0]*(a[-1]+1)
ch=0
for i in range (2,a[-1]+1):
    if p[i]==1:
        continue
    p[i]=1
    ans=0
    for j in range (i,a[-1]+1,i):
        ans+=d[j]
    if ans>1:
        ch=1
        break
if ch==1:
    print("setwise coprime")
else:
    print("pairwise coprime")

Buggy submission (verdict: Runtime Error):
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))
a.sort()
g=a[0]
for i in a:
    g=math.gcd(g,i)
d=dict()
for i in a:
    if i%2==0:
        if 2 in d:
            d[2]+=1
        else:
            d[2]=1
    while i%2==0:
        i//=2
    for j in range (3, int(math.sqrt(i))+1 ):
        if i%j==0:
            if j in d:
                d[j]+=1
            else:
                d[j]=1
            while i%j==0:
                i//=j
    if i>2:
        if i in d:
            d[i]+=1
        else:
            d[i]=1
c=1
for i in d:
    c=max(c,d[i])
if c==1:
    print("pairwise coprime")
elif g==1:
    print("setwise coprime")
else:
    print("not coprime")
Problem p02576 (python)

Fixed submission:
import math
n,x,t=map(int,input().split())
r=math.ceil(n/x)*t
print(r)

Buggy submission (verdict: Runtime Error):
n,x,t=map(int,input().split())
r=math.ceil(n/x)*t
print(r)
Problem p02660 (python)

Fixed submission:
import math
n=int(input())
p=2
c=0
curr=0
while n%p==0:
    curr+=1
    n//=p
j=0
j=(math.sqrt(1+8*curr)-1)//2
c+=int(j)
#print(j)
for i in range (3,int(math.sqrt(n))+1,2):
    p=i
    curr=0
    while n%p==0:
        curr+=1
        n//=p
    j=0
    j=(math.sqrt(1+8*curr)-1)//2
    c+=int(j)
    #print(j)
if n>2:
    c+=1
print(c)

Buggy submission (verdict: Runtime Error):
n=int(input())
p=2
c=0
while n%p==0:
    c+=1
    n//=p
    p*=2
for i in range (3,int(math.sqrt(n))+1,2):
    p=i
    while n%p==0:
        c+=1
        n//=p
        p*=i
t=0
for i in range (2,int(math.sqrt(n))+1):
    if n%i==0:
        t=1
if t==0:
    c+=1
print(c)
Problem p02664 (python)

Fixed submission:
s=input()
print(s.replace("?", "D"))

Buggy submission (verdict: Runtime Error):
s=input()
n=len(s)
r=""
c=0
for i in range (n):
    if s[i]=='?':
        r.append('D')
    else:
        r.append(s[i])
print(r)
Problem p02683 (python)

Fixed submission:
from sys import stdin, stdout

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	n, m, x = rli()
	A = []
	for _ in range(n):
		A.append(list(rli()))
	mask = 0
	for i in range(n):
		mask |= (1 << i)

	opt = INF

	def process(s):
		nonlocal opt
		i = 0
		cost = 0
		algs = [0 for _ in range(m)]
		while s:
			s, bit = divmod(s, 2)
			if bit:
				cost += A[i][0]
				for j in range(1, m+1):
					algs[j-1] += A[i][j]
			i += 1
		if all(skill >= x for skill in algs):
			opt = min(opt, cost)

	process(mask)
	s = mask
	while s > 0:
		process(s)
		s = (s-1) & mask

	print(opt if opt < INF else -1)
	stdout.close()

if __name__ == "__main__":
	main()

Buggy submission (verdict: Runtime Error):
from sys import stdin, stdout
from collections import deque

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	n, m, x = rli()
	A = []
	for _ in range(n):
		A.append(list(rli()))
	mask = 0
	for i in range(n):
		mask |= (1 << i)

	opt = INF

	def process(s):
		nonlocal opt
		i = 0
		cost = 0
		algs = [0 for _ in range(m)]
		while s:
			s, bit = divmod(s, 2)
			if bit:
				cost += A[i][0]
				for j in range(1, m+1):
					algs[j-1] += A[i][j]
			i += 1
		if all(skill >= x for skill in algs):
			opt = min(opt, cost)

	process(mask)
	s = mask
	while s > 0:
		process(s)
		s = (s-1) & mask

	print(opt if opt < INF else -1)
	stdout.close()

if __name__ == "__main__":
	main()

Buggy submission (verdict: Runtime Error):
from sys import stdin, stdout
from collections import deque

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def submasks(m):
	s = m
	while s > 0:
		s = (s-1)&m
		yield s

def main():
	n, m, x = rli()
	A = []
	for _ in range(n):
		A.append(list(rli()))
	mask = 0
	for i in range(n):
		mask |= (1 << i)

	opt = INF

	def process(s):
		nonlocal opt
		i = 0
		cost = 0
		algs = [0 for _ in range(m)]
		while s:
			s, bit = divmod(s, 2)
			if bit:
				cost += A[i][0]
				for j in range(1, m+1):
					algs[j-1] += A[i][j]
			i += 1
		if all(skill >= x for skill in algs):
			opt = min(opt, cost)

	process(mask)
	for s in submasks(mask):
		process(s)

	print(opt if opt < INF else -1)
	stdout.close()

if __name__ == "__main__":
	main()
Problem p02783 (python)

Fixed submission:
import math
from sys import stdin, stdout
 
def main():
	arr = [int(x) for x in stdin.readline().split()]
	H, A = arr
	count = 0
	while H > 0:
		H -= A
		count += 1
	stdout.write(str(count))
    
if __name__ == "__main__":
	main()

Buggy submission (verdict: Runtime Error):
import math
from sys import stdin, stdout

def main():
	arr = [int(x) for x in stdin.readline().split()]
	H, A = arr
    count = 0
    while H > 0:
      H -= A
      count += 1
    stdout.write(count)
    
if __name__ == "__main__":
  main()
Problem p03161 (python)

Fixed submission:
from sys import stdin, stdout
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	n, k = rli()
	H = list(rli())
	dp = [INF for _ in range(n)]
	dp[0] = 0
	for i in range(1, n):
		for j in range(max(0, i-k), i):
			cost = abs(H[j] - H[i])
			dp[i] = min(dp[i], dp[j] + cost)
	print(dp[-1])
	stdout.close()

if __name__ == "__main__":
	main()

Buggy submission (verdict: Runtime Error):
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
import math

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	n, k = rli()
	A = list(rli())
	dp = [INF for _ in range(n)]
	dp[0] = 0
	for i in range(1, n):
		for j in range(i-k, i):
			dp[i] = min(dp[i], dp[j] + abs(A[j] - A[i]))
	print(dp[-1])
	stdout.close()

if __name__ == "__main__":
	main()