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

Fixed submission:
n=int(input())
h=[int(i) for i in input().split()]
dp=[0]*n
dp[1]=abs(h[1]-h[0])
for i in range(1,n-1):
  dp[i+1]+=min(dp[i]+abs(h[i+1]-h[i]),dp[i-1]+abs(h[i+1]-h[i-1]))
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
n=int(input())
h=[int(i) for i in input().split()]
inf=10**10
dp=[inf]*n
def rec(i):
  if dp[i]<inf:
    return dp[i]
  elif i==0:
    return 0
  res=inf
  res=min(inf,rec(i-1)+abs(h[i]-h[i-1]))
  if i>1:
    res=min(res,rec(i-2)+abs(h[i]-h[i-2]))
  dp[i]=res
  return res
print(rec(n-1))

Buggy submission (verdict: Runtime Error):
n=int(input())
h=[int(i) for i in input().split()]
inf=10**10
dp=[inf]*n
def rec(i):
  if dp[i]<inf:
    return dp[i]
  elif i==0:
    return 0
  elif i==1:
    return h[1]-h[0]
  res=min(inf,rec(i-1)+abs(h[i]-h[i-1]),rec(i-2)+abs(h[i]-h[i-2]))
  dp[i]=res
  return res
print(rec(n-1))

Buggy submission (verdict: Runtime Error):
n=int(input())
h=[int(i) for i in input().split()]
memo=[-1]*n
def rec(n):
    if n==1:
        return 0
    elif n==2:
        return abs(h[1]-h[0])
    else:
      if memo[n-1]!=-1:
        return memo[n-1]
      else:
        return min(rec(n-1)+abs(h[n-1]-h[n-2]),rec(n-2)+abs(h[n-1]-h[n-3]))
print(rec(n))

Buggy submission (verdict: Runtime Error):
N = int(input())
h = [int(i) for i in input().split()]
cost = [-1]*N
def jump_min(n):
    if n == 1:
        v = 0
    elif n == 2:
        v = abs(h[1]-h[0])
    else:
        x = jump_min(n-2)+abs(h[n-1]-h[n-3])
        y = jump_min(n-1)+abs(h[n-1]-h[n-2])
        v = min(x,y)
    return v
print(jump_min(N))
Problem p03238 (python)

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

Buggy submission (verdict: Runtime Error):
print("Hello World!" if input()==1 else int(input())+int(input()))
Problem p03251 (python)

Fixed submission:
N,M,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
flag=0
for i in range(N):
  if x[i]>=Y:
    flag+=1
for i in range(M):
  if y[i]<=X:
    flag+=1
if X>Y:
  flag+=1
if flag>0:
  print("War")
else:
  if min(y)>max(x):
    print("No War")
  else:
    print("War")

Buggy submission (verdict: Runtime Error):
N,M,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
flag=0
for i in range(N):
  if x[i]=>Y:
    flag+=1
for i in range(M):
  if y[i]=<X:
    flag+=1
if X>Y:
  flag+=1
if flag>0:
  print("War")
else:
  if min(y)>max(x):
    print("No War")
  else:
    print("War")
Problem p03260 (python)

Fixed submission:
A,B=map(int,input().split())
if A*B*1%2==1 or A*B*2%2==1 or A*B*3%2==1:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N,X=map(int,input().split())
inputcities=list(map(int, input().split()))
cities=list(set([abs(inputcities[i]-X) for i in range(N)]))
N=len(cities)
count=0
flag=0
minimum=min(cities)
for j in range(minimum+1)[::-1]:
  for i in range(N):
    if cities[i]%j==0:
      count+=1
    else:
      count=0
      break
    if count==N:
      print(j)
      flag=1
      break
  if flag==1:
    break

Buggy submission (verdict: Runtime Error):
A,B=map(int,input.split())
if A*B*1%2==1 or A*B*2%2==1 or A*B*3%2==1:
  print("Yes")
else:
  print("No")
Problem p03264 (python)

Fixed submission:
K=int(input())
if K%2==0:
  print(int((K/2)*(K/2)))
else:
  print(int(((K+1)/2)*((K-1)/2)))

Buggy submission (verdict: Runtime Error):
K=int(input())
if K%2==0:
  print((K/2)^2)
else:
  print(((K+1)/2)*((K-1)/2))
Problem p03281 (python)

Fixed submission:
N=int(input())
div=0
A=0
B=N
count=0
answer=0
for i in range(1,N+1,2):
  div=0
  count=0
  while True:
    div+=1
    if i%div==0:
      A=div
      B=i/div
      if A<B:
        count+=1
    if A>=B:
      if count==4:
        answer+=1  
      break
print(answer)

Buggy submission (verdict: Runtime Error):
N=input()
div=0
A=0
B=0
count=0
answer=0
for i in range(1,N+1,2):
  div=0
  count=0
  while True:
    div+=1
    if i%div==0:
      A=div
      B=N/siv
      count+=1
    if B=count:
      if A<B and count==4:
        answer+=1  
      break
print(answer)
Problem p03284 (python)

Fixed submission:
N, K = map(int, input().split())
if N%K==0:
  print(0)
else:
  print(1)

Buggy submission (verdict: Runtime Error):
N,K=input()
if N%K==0:
  print("0")
else:
  print("1")
Problem p03288 (python)

Fixed submission:
R=int(input())
if R<1200:
  print("ABC")
elif R>=1200 and R<2800:
  print("ARC")
elif R>=2800:
  print("AGC")

Buggy submission (verdict: Runtime Error):
R=input()
if R<1200:
  print("ABC")
elif R>=1200 and R<2800:
  print("ARC")
elif R>=2800:
  print("AGC")
Problem p03289 (python)

Fixed submission:
S=list(input())
flag=0
Ccount=0
Cnumber=0
if S[0]=="A":
  flag+=1
if S[2:-1].count("C")==1:
  flag+=1
  del S[0]
  S.remove("C")
if str(S).islower():
  flag+=1
if flag==3:
  print("AC")
else:
  print("WA")

Buggy submission (verdict: Runtime Error):
S=list(input())
flag=0
Ccount=0
Lcount=0
Cnumber=-1
if S[0]=="A":
  flag+=1
  del S[0]
if S.count("C")==1:
  flag+=1
  del S[Cnumber]
N=len(S)
if S[0:].islower():
  flag+=1
if flag==3:
  print("AC")
else:
  print("WA")

Buggy submission (verdict: Runtime Error):
S=list(input())
flag=0
Ccount=0
Lcount=0
if S[0]=="A":
  flag+=1
  del S[0]
if flag!=1:
  flag=-100
N=len(S)
for i in range(1,N-1):
  if S[i]=="C":
    Ccount+=1
    del S[i]
if Ccount==1:
  flag+=1
if flag!=2:
  flag=-100
N=len(S)
for i in range(N):
  if S[i].islower():
    Lcount+=1
if Lcount==N:
  flag+=1
if flag==3:
  print("AC")
else:
  print("WA")

Buggy submission (verdict: Runtime Error):
S=list(input())
flag=0
Ccount=0
Lcount=0
if S[0]=="A":
  flag+=1
  del S[0]
N=len(S)
for i in range(1,N-1):
  if S[i]=="C":
    Ccount+=1
    del S[i]
if Ccount==1:
  flag+=1
M=len(S)
for i in range(M):
  if S[i].islower():
    Lcount+=1
if Lcount==M:
  flag+=1
if flag==3:
  print("AC")
else:
  print("WA")

Buggy submission (verdict: Runtime Error):
S=list(input())
flag=0
Ccount=0
Lcount=0
if S[0]=="A":
  flag+=1
  del S[0]
N=len(S)
for i in range(1,N-1):
  if S[i]=="C":
    Ccount+=1
    del S[i]
if Ccount==1:
  flag+=1
M=len(S)
for i in range(M):
  if S[i].islower():
    Lcount+=1
if Lcount==M:
  flag+=1
if flag==3:
  print("AC")
else:
  print("WA")
Problem p03292 (python)

Fixed submission:
L = list(map(int, input().split()))
MAX=max(L)
MIN=min(L)
print(MAX-MIN)

Buggy submission (verdict: Runtime Error):
L = list(map(int, raw_input().split()))
MAX=max(L)
MIN=min(L)
print(MAX-MIN)
Problem p03351 (python)

Fixed submission:
a,b,c,d=map(int,input().split())
print("Yes" if ((abs(a-b)<=d and abs(b-c)<=d) or abs(a-c)<=d) else "No")

Buggy submission (verdict: Runtime Error):
x=int(input())
ans=0
for b in range(2,x):
  for p in range(2,x):
    if x-b**p>=0:
      ans=max(ans,b**p)
    else:
      break
print(ans)

Buggy submission (verdict: Runtime Error):
x=int(input())
ans=0
for b in range(2,11):
  for p in range(2,x):
    if x-b**p>=0:
      ans=max(ans,b**p)
    else:
      break
print(ans)
Problem p03352 (python)

Fixed submission:
x=int(input())
ans=1
for b in range(1,x):
  for p in range(2,x):
    if x-b**p>=0:
      ans=max(ans,b**p)
    else:
      break
print(ans)

Buggy submission (verdict: Runtime Error):
x=int(input())
ans=0
for i in range(2,11):
  for j in range(x):
    if x-j**i>0 and j**i>ans:
      tmp=j**i
    else:
      break
  ans=[tmp,ans][tmp<ans]
print(ans)
Problem p03369 (python)

Fixed submission:
s=input()
print(700+100*((s[0]=='o')+(s[1]=='o')+(s[2]=='o')))

Buggy submission (verdict: Runtime Error):
s=input()
print(700+100*((s[0]==o)+(s[1]==o)+(s[2]==o)))
Problem p03485 (python)

Fixed submission:
a,b=map(int,input().split())
print(int((a+b)/2+0.99999))

Buggy submission (verdict: Runtime Error):
print((int(input())+int(input())+0.99999999999)//2)
Problem p03493 (python)

Fixed submission:
a,b,c=map(int,input())
print(a+b+c)

Buggy submission (verdict: Runtime Error):
a,b,c=int(input())
print(a+b+c)

Buggy submission (verdict: Runtime Error):
S=list(input())
print(len([i for i in S if S[i]=='1']))
Problem p03547 (python)

Fixed submission:
a,b=map(ord,input().split())
print(['<' if a<b else '>','='][a==b])

Buggy submission (verdict: Runtime Error):
a,b=map(ord,input().split())
print(['<' if a<b else '>','='][a==b]
Problem p03563 (python)

Fixed submission:
r=int(input())
g=int(input())
print(2*g-r)

Buggy submission (verdict: Runtime Error):
r=int(input())
g=int(input())
print(int(g*2−r))

Buggy submission (verdict: Runtime Error):
r=int(input())
g=int(input())
print(g*2−r)
Problem p03575 (python)

Fixed submission:
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(m)]
graph=[[0 for _ in range(n)] for _ in range(n)]
for i in range(m):
  graph[ab[i][0]-1][ab[i][1]-1]=1
  graph[ab[i][1]-1][ab[i][0]-1]=1
visited=[0 for _ in range(n)]

def dfs(v):
  visited[v]=1
  for v2 in range(n):
    if graph[v][v2]==0:
      continue
    if visited[v2]==1:
      continue
    dfs(v2)

ans=0

for i in range(m):
  graph[ab[i][0]-1][ab[i][1]-1]=0
  graph[ab[i][1]-1][ab[i][0]-1]=0
  for j in range(n):
    visited[j]=0
  dfs(0)
  bridge=0
  for j in range(n):
    if visited[j]==0:
      bridge=1
  if bridge==1:
    ans+=1
  graph[ab[i][0]-1][ab[i][1]-1]=1
  graph[ab[i][1]-1][ab[i][0]-1]=1
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(m)]
graph=[[0 for _ in range(m)] for _ in range(m)]
for i in range(m):
  graph[ab[i][0]-1][ab[i][1]-1]=1
  graph[ab[i][1]-1][ab[i][0]-1]=1
visited=[0 for _ in range(m)]

def dfs(v):
  visited[v]=1
  for v2 in range(n):
    if graph[v][v2]==0:
      continue
    if visited[v2]==1:
      continue
    dfs(v2)

ans=0

for i in range(m):
  graph[ab[i][0]-1][ab[i][1]-1]=0
  graph[ab[i][1]-1][ab[i][0]-1]=0
  for j in range(n):
    visited[j]=0
  dfs(0)
  bridge=0
  for j in range(n):
    if visited[j]==0:
      bridge=1
  if bridge==1:
    ans+=1
  graph[ab[i][0]-1][ab[i][1]-1]=1
  graph[ab[i][1]-1][ab[i][0]-1]=1
print(ans)
Problem p03583 (python)

Fixed submission:
N=int(input())
for h in range(1,3501):
  for n in range(1,3501):
    if 4*h*n-N*n-N*h>0:
      if (N*h*n)%(4*h*n-N*n-N*h)==0:
        print(h,n,(N*h*n)//(4*h*n-N*n-N*h))
        exit()

Buggy submission (verdict: Runtime Error):
N=int(input())
for h in range(3501):
  for n in range(3501):
    if (N*h*n)%(4*h*n-N*n-N*h)==0:
      print(h,n,(N*h*n)%(4*h*n-N*n-N*h))
Problem p03610 (python)

Fixed submission:
print(''.join(list(input())[::2]))

Buggy submission (verdict: Runtime Error):
print(''.join(list(input())[1::2])
Problem p03623 (python)

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

Buggy submission (verdict: Runtime Error):
x,a,b=map(int,input().split())
print("A" if |x-a|<|x-b| else "B")
Problem p03632 (python)

Fixed submission:
a,b,c,d=map(int,input().split())
s=[]
for i in range(0,101):
  if a<=i<=b and c<=i<=d:
    s.append(i)
print(0 if len(s)==0 else max(s)-min(s))

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
s=[]
for i in range(0,101):
  if a<=i<=b and c<=i<=d:
    s.append(i)
print(max(s)-min(s))
Problem p03672 (python)

Fixed submission:
s=input()
ans=0
for i in range(1,len(s)//2):
  if s[0:i]==s[i:2*i]:
    ans=i
print(ans*2)

Buggy submission (verdict: Runtime Error):
s=input()
for i in reversed(range(0,len(s)-1,2)):
  if s[:len(s)//2]==s[len(s)//2:]:
    print(len(s))
    break
  else:
    s=[:len(s)-2]
Problem p03694 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
print(max(a)-min(a))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(input()) for _ in range(n)]
print(a[0] if len(a)==1 else max(a)-min(a))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(input()) for _ in range(n)]
print(max(a)-min(a))
Problem p03773 (python)

Fixed submission:
a,b=map(int,input().split())
print((a+b)%24)

Buggy submission (verdict: Runtime Error):
a,b=map(int,inpuy().split())
print((a+b)%24)

Buggy submission (verdict: Runtime Error):
print((int(input())+int(input()))%24)
Problem p03779 (python)

Fixed submission:
x=int(input())
n=0
while 2*x>n*n+n:
  n+=1
print(n)

Buggy submission (verdict: Runtime Error):
x=int(input())
n=0
while 2x>n*n+n:
  n+=1
print(n)
Problem p03826 (python)

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

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(iint,input().split())
print(a*b if a*b>c*d else c*d)
Problem p03943 (python)

Fixed submission:
a,b,c=map(int,input().split())
print("Yes" if a+b+c==2*max(a,b,c) else "No")

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
print("Yes" if a+b+c=2*max(a,b,c) else "No")
Problem p02812 (python)

Fixed submission:
input()
s = input()
ans = 0
while 1:
    pos = s.find('ABC')
    if pos == -1:
        break
    ans += 1
    s = s[pos + 3:]
print(ans)

Buggy submission (verdict: Runtime Error):
https://atcoder.jp/contests/abc150/submitinput()
s = input()
ans = 0
while 1:
    pos = s.find('ABC')
    if pos == -1:
        break
    ans += 1
    s = s[pos + 3:]
print(ans)
Problem p02981 (python)

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

if li[0]*li[1]>li[2]:
  print(li[2])
else:
  print(li[0]*li[1])

Buggy submission (verdict: Runtime Error):
n,a,b=map(int,input()split())

if n*a>b:
  return b

else:
  return n*a
Problem p02555 (python)

Fixed submission:
from math import trunc
import sys
import copy
from collections import deque
import collections
import itertools
stdin = sys.stdin
import math

mod = 10**9+7

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()

s = [0 for _ in range(2001)]
s[0] = 1
s[3] = 1
s[4] = 1
s[5] = 1

if n < 6:
    print(s[n])
    exit(0)

for i in range(6, 2001):
    s[i] = s[i-3] + s[i-1]
    s[i] %= mod
    if i==n:
        break

print(s[n])

Buggy submission (verdict: Runtime Error):
from math import trunc
import sys
import copy
from collections import deque
import collections
import itertools
stdin = sys.stdin
import math

mod = 10**9+7

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()

s = [0 for _ in range(2000)]
s[0] = 1
s[3] = 1
s[4] = 1
s[5] = 1

if n < 6:
    print(s[n])
    exit(0)

for i in range(6, 2001):
    s[i] = s[i-3] + s[i-1]
    s[i] %= mod
    if i==n:
        break

print(s[n])
Problem p02642 (python)

Fixed submission:
import sys
import copy
from collections import deque
stdin = sys.stdin
 
mod = 10**9+7
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces
 
n = ni()
a = na()
a.sort()
a_max = max(a)

c = [0 for _ in range(1000005)]
for aa in a:
    c[aa] += 1

dp = [False for _ in range(1000005)]
cnt = 0
for ai in set(a):
    if dp[ai]:
        continue
    if c[ai]==1:
        cnt += 1
    for j in range(ai+ai, a_max+1, ai):
        dp[j] = True

print(cnt)

Buggy submission (verdict: Runtime Error):
import sys
import copy
from collections import deque
stdin = sys.stdin
 
mod = 10**9+7
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces
 
n = ni()
a = na()
a.sort()
a_max = max(a)

c = [0 for _ in range(1000000)]
for aa in a:
    c[aa] += 1

dp = [False for _ in range(1000000)]
cnt = 0
for ai in set(a):
    if dp[ai]:
        continue
    if c[ai]==1:
        cnt += 1
    for j in range(ai+ai, a_max+1, ai):
        dp[j] = True

print(cnt)

Buggy submission (verdict: Runtime Error):
import sys
import copy
from collections import deque
stdin = sys.stdin
 
mod = 10**9+7
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces
 
n = ni()
a = na()
a.sort()
b = copy.deepcopy(a)
 
maps = {}
 
for aa in a:
    if aa in maps:
        tmp = maps[aa]
        maps[aa] = tmp+1
    else:
        maps[aa] = 1
 
i = 0
while True:
    a_tmp = b[i]
    check = set()
    for j in range(len(b)-1, i, -1):
        if b[j]==a_tmp:
            check.add(i)
            check.add(j)
            continue
        if b[j]%a_tmp==0:
            check.add(j)
            continue
        if a_tmp*2 > b[j]:
            break
 
    check = list(check)
    check.sort(reverse=True)
    for c in check:
        del b[c]
    
    i += 1
    if i>=len(a):
        break
 
 
 
print(len(a))
Problem p02582 (python)

Fixed submission:
s=input()
c=0
mc=0
for i in s:
  if i=='R':
    c+=1
    mc=c
  else:
    c=0
print(max(c,mc))

Buggy submission (verdict: Runtime Error):
s=input()
c=0
mc=0
for i in s:
  if i='R':
    c+=1
    mc=c
  else:
    c=0
print(max(c,mc))
Problem p02606 (python)

Fixed submission:
l,r,d=map(int,input().split())
ans=0
for i in range(l,r+1):
  if i%d==0:
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
l,r,d=map(int,input.split())
ans=0
for i in range(l,r+1):
  if i%d==0:
    ans+=1
print(ans)
Problem p03455 (python)

Fixed submission:
x,y=map(int,input().split())

if(x%2==0 or y%2==0):
    print("Even")
else:
    print("Odd")

Buggy submission (verdict: Runtime Error):
x=int(input())
y=int(input())

if(x%2==0 or y%2==0):
    print("Even")
else:
    print("Odd")

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

if(x%2==0 or y%2==0):
    print("Even")
else:
    print("Odd")
Problem p02600 (python)

Fixed submission:
x=int(input())

if x<600:
  print(8)
elif x<800:
  print(7)
elif x<1000:print(6)
elif x<1200:print(5)
elif x<1400:print(4)
elif x<1600:print(3)
elif x<1800:print(2)
else:print(1)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
A=list(map(int,input().split()))
cc=1
for j in range(k):
  cc*=A[j]

for i in range(k,n):
  pp=A[i]*cc//A[i-k]
  if pp>cc:print('Yes')
  else:print('No')
  
  cc=pp
Problem p02609 (python)

Fixed submission:
n=int(input())
x=list(input())
def str2int(z):
  flag=1
  a=0
  for i in reversed(x):
    if i=='1':a+=flag
    flag*=2
  return a
 
popc=x.count('1')
z=str2int(x)
if popc-1!=0:
  fl_1=z%(popc-1)
fl_0=z%(popc+1)

for i in range(n):
  if x[i]=='1':
    if popc-1==0:
      print(0)
      continue
    mod=(fl_1-pow(2,n-1-i,popc-1))%(popc-1)
  else:mod=(fl_0+pow(2,n-1-i,popc+1))%(popc+1)
  #print('mod : %s'%mod)
  cnt=1
  while mod!=0:
    pp=bin(mod).count("1")
    mod%=pp
    cnt+=1
  print(cnt)

Buggy submission (verdict: Runtime Error):
n=int(input())
x=list(input())
def str2int(z):
  flag=1
  a=0
  for i in reversed(x):
    if i=='1':a+=flag
    flag*=2
  return a
 
popc=x.count('1')
x=str2int(x)
fl_1=x%(popc-1)
fl_0=x%(popc+1)
cc=[]
for i in range(n):
  if ((x>>i)&1):
    mod=(fl_1-(2**i)%(popc-1))%(popc-1)
  else:mod=(fl_0+(2**i)%(popc+1))%(popc+1)
  #print('mod : %s'%mod)
  cnt=1
  while mod!=0:
    pp=bin(mod).count("1")
    mod%=pp
    cnt+=1
  cc.append(cnt)
  
for c in reversed(cc):
  print(c)

Buggy submission (verdict: Runtime Error):
n=int(input())
x=list(input())
def str2int(z):
  flag=1
  a=0
  for i in reversed(x):
    if i=='1':a+=flag
    flag*=2
  return a

popc=x.count('1')
x=str2int(x)

cc=[]
for i in range(n):
  if ((x>>i)&1):
    mod=(x-2**i)%(popc-1)
  else:mod=(x+2**i)%(popc+1)
  #print('mod : %s'%mod)
  cnt=1
  while mod!=0:
    pp=bin(mod).count("1")
    mod%=pp
    cnt+=1
  cc.append(cnt)
  
for c in reversed(cc):
  print(c)
Problem p02612 (python)

Fixed submission:
n=int(input())
s=n%1000
if s==0:s=1000
print(1000-s)

Buggy submission (verdict: Runtime Error):
from itertools import product
h,w,k=map(int,input().split())
idxs=[]
cols=[0]*w
clis=[]
al=0
k_score=0
def nir(x):
  if x=='#':return 1
  else:return 0
  
for _ in range(h):
  tmp=list(map(nir, list(input())))
  clis.append(tmp)
  idxs.append(sum(tmp))
  al+=sum(tmp)
  for q in range(w):
    cols[q]+=tmp[q]
uu=product((0,1),repeat=h+w)
for bits in uu:
  idd=[]
  coll=[]
  for i in range(h):
    if bits[i]==1:idd.append(i)
  
  for i in range(w):
    if bits[i+h]==1:coll.append(i)
  
  s=al
  if not coll:
    for x in idd:s-=idxs[x]
  elif not idd:
    for y in coll:s-=cols[y]
  else:
    for x in idd:s-=idxs[x]
    for y in coll:s-=cols[y]
    for x in idd:
      for y in coll:
        s+=clis[x][y]
        
  if s==k:k_score+=1
    
print(k_score)
Problem p02614 (python)

Fixed submission:
from itertools import product
h,w,k=map(int,input().split())
idxs=[]
cols=[0]*w
clis=[]
al=0
k_score=0
def nir(x):
  if x=='#':return 1
  else:return 0
  
for _ in range(h):
  tmp=list(map(nir, list(input())))
  clis.append(tmp)
  idxs.append(sum(tmp))
  al+=sum(tmp)
  for q in range(w):
    cols[q]+=tmp[q]
uu=product((0,1),repeat=h+w)
for bits in uu:
  idd=[]
  coll=[]
  for i in range(h):
    if bits[i]==1:idd.append(i)
  
  for i in range(w):
    if bits[i+h]==1:coll.append(i)
  
  s=al
  if not coll:
    for x in idd:s-=idxs[x]
  elif not idd:
    for y in coll:s-=cols[y]
  else:
    for x in idd:s-=idxs[x]
    for y in coll:s-=cols[y]
    for x in idd:
      for y in coll:
        s+=clis[x][y]
        
  if s==k:k_score+=1
    
print(k_score)

Buggy submission (verdict: Runtime Error):
from itertools import product
h,w,k=map(int,input().split())
idxs=[]
cols=[0]*w
al=0

def nir(x):
  if x=='#':return 1
  else:return 0
  
for _ in range(h):
  tmp=list(map(nir, list(input())))
  idxs.append(sum(tmp))
  al+=sum(tmp)
  for q in range(w):
    cols[q]+=tmp[q]
    
for bits in product((0,1),repeat=h+w):
Problem p02615 (python)

Fixed submission:
from collections import deque
n=int(input())
a=sorted(list(map(int,input().split())),reverse=True)

between=deque([a[0]])
score=0
for i in range(1,n):
  score+=between.popleft()
  between.extend([a[i],a[i]])
  
print(score)

Buggy submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
print(sum(a)-min(a))
Problem p02630 (python)

Fixed submission:
n=int(input())
a=[0]*(10**5)
A=list(map(int,input().split()))
su=0
for i in range(n):
  su+=A[i]
  a[A[i]-1]+=1
q=int(input())
sus=[su]
for i in range(q):
  
  b,c=map(lambda x:int(x)-1,input().split())
  sus.append(sus[-1]+(c-b)*a[b])
  a[c]+=a[b]
  a[b]-=a[b]
  print(sus[-1])

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


q=int(input())
for i in range(q):
  s=0
  b,c=map(int,input().split())
  for j in a:
    if a[j]==b:
      a[j]=c
      s+=a[j]
    else:s+=a[j]
  print(s)
Problem p02641 (python)

Fixed submission:
x,n=map(int,input().split())
a=sorted(list(map(int,input().split())))
if n==0:
  print(x)
  exit()
else:
  for i in range(100):
    aa=x-i
    if aa not in a:
      print(aa)
      exit()
    bb=x+i
    if bb not in a:
      print(bb)
      exit()

Buggy submission (verdict: Runtime Error):
x,n=map(int,,input().split())
a=sorted(list(map(int,input().split())))
if n==0:
  print(x)
  exit()
else:
  for i in range(100):
    aa=x-i
    if aa not in a:
      print(aa)
      exit()
    bb=x+i
    if bb not in a:
      print(bb)
      exit()
Problem p02642 (python)

Fixed submission:
from bisect import bisect
from collections import Counter
n=int(input())
b=sorted(list(map(int,input().split())))
a=Counter(b)
mA=b[-1]
acc=0
dp=[True]*(mA+1)
for i,v in a.items():
  if dp[i]==True and v==1:
    acc+=1
  else:dp[i]=False
  for k in range(mA//i+1):
    dp[k*i]=False
print(acc)

Buggy submission (verdict: Runtime Error):
from bisect import bisect
n=int(input())
a=sorted(list(map(int,input().split())))
y=set(a)
acc=0
if a[0]==1 and a[1]!=1:acc+=1
dp=[True]*(a[-1]+1)
for i in range(2,a[-1]+1):
  if i in y:
    if dp[i]==True:
      idx=bisect(a,i)
      if a[idx-1]==a[idx-2]:
        dp[i]=False
      else:acc+=1
    dp[2*i::i]=[False]*len(dp[2*i::i])
print(acc)