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

Fixed submission:
def shakutori(a,M):
  left =0
  right = 0
  su = 0
  ans = 0
  for i in range(len(a)):
    su +=a[right]
    right +=1
    if su%M==0:
      ans+=1
      while su%M!=0:
        su -=a[left]
        left+=1
  return ans
from itertools import accumulate
N,M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
A = list(accumulate(A))
A = list(map(lambda x: x%M,A))
ans = {}
ans1=0
for i in range(N):
  if A[i] in ans:
    ans[A[i]] +=1
  else:
    ans[A[i]] =1
  ans1 += ans[A[i]]-1
if 0 in ans:
  ans1 += ans[0]
print(ans1)

Buggy submission (verdict: Runtime Error):
def shakutori(a,M):
  left =0
  right = 0
  su = 0
  ans = 0
  for i in range(len(a)):
    su +=a[right]
    right +=1
    if su%M==0:
      ans+=1
      while su%M!=0:
        su -=a[left]
        left+=1
  return ans
from itertools import accumulate
N,M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
A = list(accumulate(A))
A = list(map(lambda x: x%M,A))
ans = {}
ans1=0
for i in range(N):
  if A[i] in ans:
    ans[A[i]] +=1
  else:
    ans[A[i]] =1
  ans1 += ans[A[i]]-1
ans1 += ans[0]
print(ans1)
Problem p03289 (python)

Fixed submission:
S = input()
cnt = 0
for i in range(len(S)):
  if i==0 and S[i]!="A":
    print("WA")
    exit()
  if 2<=i<=len(S)-2 and S[i]=="C":
    cnt+=1
    if cnt>1:
      print("WA")
      exit()
  if 1<=i<=len(S)-1:
    if S[i]!="C" and S[i].isupper():
      print("WA")
      exit()
if cnt<1:
  print("WA")
  exit()
print("AC")

Buggy submission (verdict: Runtime Error):
for i in range(len(S)):
  if i==0 and S[i]!="A":
    print("WA")
    exit()
  if 2<=i<=len(S)-2 and S[i]=="C":
    cnt+=1
    if cnt>1:
      print("WA")
      exit()
  if 1<=i<=len(S)-1:
    if S[i]!="C" and S[i].isupper():
      print("WA")
      exit()
print("AC")

Buggy submission (verdict: Runtime Error):
S = input()
cnt = 0
for i in range(len(S)):
  if i==0 and S[i]!="A":
    print("WA")
    exit()
  if 2<=i<=len(i)-2 and S[i]=="C":
    cnt+=1
    if cnt>1:
      print("WA")
      exit()
  if 1<=i<=len(i)-1:
    if S[i]!="C" and S[i].isupper():
      print("WA")
      exit()
print("AC")
Problem p03316 (python)

Fixed submission:
N = input()
a = int(N)
b = 0
for i in range(len(N)):
  b += int(N[i])
print("Yes" if a%b==0 else "No")

Buggy submission (verdict: Runtime Error):
N = input()
a = int(N)
for i in range(len(N)):
  b += int(N[i])
print("Yes" if a%b==0 else "No")
Problem p03360 (python)

Fixed submission:
A= [int(x) for x in input().split()]
K = int(input())
ma = max(A)
mb = ma*2**K
print(sum(A)-ma+mb)

Buggy submission (verdict: Runtime Error):
A,B,C = [int(x) for x in input().split()]
K = int(input())
ma = max(A,B,C)
mb = ma*2**K
print(sum(A,B,C)-ma+mb)
Problem p03370 (python)

Fixed submission:
N,X = [int(x) for x in input().split()]
mi = 110000000
ans = 0
for i in range(N):
  x = int(input())
  ans +=x 
  mi = min(x,mi)
print(N+(X-ans)//mi)

Buggy submission (verdict: Runtime Error):
N,X = [int(x) for x in input().split()]
mi = 110000000
for i in range(N):
  x = int(input())
  ans +=x 
  mi = min(x,mi)
print(N+(X-ans)//mi)
Problem p03378 (python)

Fixed submission:
from bisect import bisect_left
N,M,X = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
b = bisect_left(A,X)
if b==0:
  print(0)
  exit()
print(min(b,M-b))

Buggy submission (verdict: Runtime Error):
import bisect from bisect_left
N,M,X = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
b = bisect_left(A,X)
print(min(b,N-1-B))
Problem p03385 (python)

Fixed submission:
S = input()
cnt = 0
for i in ["a","b","c"]:
  if i in S:
    cnt+=1
print("Yes" if cnt==3 else"No")

Buggy submission (verdict: Runtime Error):
S = input()
if all("a" in S,"b" in S ,"c" in S):
  print("Yes")
else:
  print("No")
Problem p03387 (python)

Fixed submission:
A,B,C =[int(x) for x in input().split()]
d = max(A,B,C)
l = [d-A,d-B,d-C]
su = sum(l)
if su%2==0:
  print(su//2)
else:
  print(1+(su+1)//2)

Buggy submission (verdict: Runtime Error):
A,B,C =[int(x) for x in input().split()]
d = max(A,B,C)
l = [d-A,d-B,d-C]
su = sum(l)
if l%2==0:
  print(l%2)
else:
  print(1+(l+1)//2)
Problem p03449 (python)

Fixed submission:
import numpy as np
N = int(input())
A = np.array([[int(x) for x in input().split()] for _ in range(2)])
ans = 0
for i in range(1,N+1):
  #print(A[0,:i],A[1,i-1:])
  ans = max(ans,sum(A[0,:i])+sum(A[1,i-1:]))
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = np.array([[int(x) for x in input().split()] for _ in range(2)])
ans = 0
for i in range(1,N+1):
  #print(A[0,:i],A[1,i-1:])
  ans = max(ans,sum(A[0,:i])+sum(A[1,i-1:]))
print(ans)
Problem p03474 (python)

Fixed submission:
A,B = [int(x) for x in input().split()]
S = input()
for i in range(A+B+1):
  if i==A and S[i]!="-":
    print("No")
    exit()
  if i!=A and (S[i]=="-" or int(S[i])>=10):
    print("No")
    exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
A,B = [int(x) for x in input().split()]
S = input()
for i in range(A+B+1):
  if i==A and S[i]!="-":
    print("No")
    exit()
  if i!=A and S[i]=="-" or int(S[i])>=10:
    print("No")
    exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
A,B = [int(x) for x in input().split()]
S = input()
for i in range(A+B+1):
  if i==A and S[i]!="-":
    print("No")
  if i!=A and int(S[i])>=10:
    print("No")
print("Yes")
Problem p03479 (python)

Fixed submission:
import math
x,y=map(int,input().split())
i=0
while(x<=y):
  x*=2
  i+=1
print(i)

Buggy submission (verdict: Runtime Error):
import numpy as np
from collections import Counter
import collections
round = lambda x:(x*2+1)//2
a = list(map(float,input().split()))
a = np.array(a)
X = a[0]
Y = a[1]
i = 0
while(X=<Y):
  X * = 2
  i++
print(i)
Problem p03493 (python)

Fixed submission:
l = list(input())
n=0
for i in l :
  if int(i)==1:
    n += 1
print(n)

Buggy submission (verdict: Runtime Error):
import numpy as np
a = list(map(int,input().split()))
N = a[0]
K = a[1]
b = list(map(int,input().split()))
li = list(set(b))
c = np.array(b)
d = np.array([])
h = len(li) -K
Num = 0
if K >= len(li):
  print(0)
  exit()
for i in li :
  ind = np.take(c,np.where( c== i),axis = 0)
  d = np.append(d,ind.shape)
d = np.sort(d)
print(d)
for i in range(h):
  Num += d[i]
print(int(Num))

Buggy submission (verdict: Runtime Error):
import numpy as np
N = list(input())
a = list(map(int,input().split()))

for i in range(1,30):
  b = np.array([n/2 if n%2==0 else 0 for n in a])
  a = b
  if 0 in list(b):
    print(i-1)
    exit()

Buggy submission (verdict: Runtime Error):
l = list(input())
n=0
for int(i) in l :
  if int(i)==1:
    print(i)
    n += 1
print(n)
Problem p03494 (python)

Fixed submission:
import numpy as np
N = list(input())
a = list(map(int,input().split()))

for i in range(1,31):
  b = np.array([n/2 if n%2==0 else 0 for n in a])
  a = b
  if 0 in list(b):
    print(i-1)
    exit()

Buggy submission (verdict: Runtime Error):
    import numpy as np
    N = list(input())
    a = list(map(int,input().split()))
     
    for i in range(1,10):
      b = np.array([n/2 if n%2==0 else 0 for n in a])
      a = b
      if 0 in list(b):
        print(i-1)
        exit()
Problem p03504 (python)

Fixed submission:
import sys
from itertools import accumulate
input = sys.stdin.readline
def inputs():return [int(x) for x in input().split()]
N,C = inputs()
stc = [inputs() for i in range(N)]
stc = sorted(stc,key=lambda x:x[1])
stc = sorted(stc,key=lambda x:x[2])
ans = [0]*(10**5+2)
for i in range(N):
    s,t,c, = stc[i]
    if i>0 and c==stc[i-1][2] and s==stc[i-1][1]:
      ans[s+1]+=1
      ans[t+1]-=1
      continue
    ans[s]+=1
    ans[t+1]-=1
ans = list(accumulate(ans))
print(max(ans))

Buggy submission (verdict: Runtime Error):
import sys
from itertools import accumulate
input = sys.stdin.readline
def inputs():return [int(x) for x in input().split()]
N,C = inputs()
stc = [inputs() for i in range(N)]
ans = [0]*(10**5+1)
for i in range(N):
    s,t,c, = stc[i]
    ans[s]+=1
    ans[t+1]-=1
ans = list(accumulate(ans))
print(max(ans))
Problem p03546 (python)

Fixed submission:
import itertools
import sys
input = sys.stdin.readline
def inputs():
    return [int(x) for x in input().split()]
H,W = inputs()
c = [inputs() for _ in range(10)]
HW = [inputs() for _ in range(H)]
A = (0,9,8,7,6,5,4,3,2)
B = list(itertools.permutations(A))
N = [c[i][1] for i in range(10)]
for i in B:
    a = i[0]
    ans = 0
    for j in range(1,9):
        ans +=c[i[j-1]][i[j]]
        if N[a]<=ans:
          break
        N[a] = min(ans+c[i[j]][1],N[a])    
ans = 0
for i in range(H):
    for j in range(W):
        if HW[i][j]!=-1:
            ans += N[HW[i][j]]
print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
import sys
input = sys.stdin.readline
def inputs():
    return [int(x) for x in input().split()]
H,W = inputs()
c = [inputs() for _ in range(10)]
HW = [inputs() for _ in range(H)]
A = (0,9,8,7,6,5,4,3,2)
B = list(itertools.permutations(A))
N = [c[i][1] for i in range(10)]
for i in B:
    a = i[0]
    ans = 0
    for j in range(1,10):
        ans +=c[i[j-1]][i[j]]
        if N[a]<=ans:
          break
        N[a] = min(ans+c[i[j]][1],N[a])    
ans = 0
for i in range(H):
    for j in range(W):
        if HW[i][j]!=-1:
            ans += N[HW[i][j]]
print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
import sys
input = sys.stdin.readline
def inputs():
    return [int(x) for x in input().split()]
H,W = inputs()
c = [inputs() for _ in range(10)]
HW = [inputs() for _ in range(H)]
A = (0,9,8,7,6,5,4,3,2)
B = list(itertools.permutations(A))
N = [c[i][1] for i in range(10)]
ans = 0
for i in B:
    a = i[0]
    ans = 0
    for j in range(1,10):
        ans +=c[i[j-1]][i[j]]
        if N[a]<ans:
          break
        N[a] = min(ans+c[i[j]][1],N[a])
        
ans = 0
for i in range(H):
    for j in range(W):
        if HW[i][j]!=-1:
            ans += N[HW[i][j]]
print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
import sys
input = sys.stdin.readline
def inputs():
    return [int(x) for x in input().split()]
H,W = inputs()
c = [inputs() for _ in range(10)]
HW = [inputs() for _ in range(H)]
A = (0,9,8,7,6,5,4,3,2)
B = list(itertools.permutations(A))
N = [c[i][1] for i in range(10)]
ans = 0
for i in B:
    a = i[0]
    ans = 0
    for j in range(1,10):
        ans +=c[i[j-1]][i[j]]
        if N[a]<ans:
          break
        N[a] = min(ans+c[i[j]][1],N[a])
        
ans = 0
for i in range(H):
    for j in range(W):
        if HW[i][j]!=-1:
            ans += N[HW[i][j]]
print(ans)
Problem p03547 (python)

Fixed submission:
X,Y = input().split()
if X>Y:
  print(">")
elif X<Y:
  print("<")
else:
  print("=")

Buggy submission (verdict: Runtime Error):
X,Y = [input().split()]
if X>Y:
  print(">")
elif X<Y:
  print("<")
else:
  print("=")
Problem p03569 (python)

Fixed submission:
s = list(input())
s1=s[::-1]
ans = 0
cnt = 0
cnt1 = 0
while cnt<len(s) and cnt1<len(s) and cnt<=len(s)-1-cnt1:
  if s[cnt]!=s1[cnt1]:
    if s[cnt]=="x" and s1[cnt1]!="x":
      cnt+=1
      ans+=1
    elif s1[cnt1]=="x" and s[cnt]!="x":
      cnt1+=1
      ans+=1
    elif s[cnt]!="x" and s1[cnt1]!="x":
      print(-1)
      exit()
  elif s[cnt]==s1[cnt1]:
    cnt+=1
    cnt1+=1
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
s1 = []
le = []
lex = []
cnt= 0
for i in list(s):
  if i!="x":
    le.append(cnt)
    s1.append(i)
  else:
    lex.append(cnt)
  cnt+=1
if s1!=s1[::-1]:
  print(-1)
  exit()
midlle=le[len(le)//2]
ans =[]
for i in lex:
  ans.append(abs(i-midlle))
ans = list(set(ans))
print(len(ans))

Buggy submission (verdict: Runtime Error):
s = input()
s1 = []
le = []
cnt= 0
for i in list(s):
  if i!="x":
    le.append(cnt)
    s1.append(i)
  cnt+=1
if s1!=s1[::-1]:
  print(-1)
  exit()
print(le[len(le)//2])
Problem p03573 (python)

Fixed submission:
l = list(map(int, input().split()))
if l[0]==l[1]:
	print(l[2])
elif l[0] ==l[2]:
	print(l[1])
elif l[1] ==l[2]:
	print(l[0])

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

l = map(int, input().split())
if l[0]==l[1]:
	print(l[2])
elif l[0] ==l[2]:
	print(l[1])
elif l[1] ==l[2]:
	print(l[0])

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

l = map(int, raw_input().split())
if l[0]==l[1]:
	print(l[2])
elif l[0] ==l[2]:
	print(l[1])
elif l[1] ==l[2]:
	print(l[0])

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

l = map(int, raw_input().split())
if l[0]==l[1]:
  print(l[2])
elif l[0] ==l[2]:
  print(l[1])
elif l[1] ==l[2]:
  print(l[0])
Problem p03576 (python)

Fixed submission:
import sys
input = sys.stdin.readline
def inputs():return [int(x) for x in input().split()]
N,K = inputs()
xy = [inputs() for _ in range(N)]
#xy = sorted(xy,key=lambda x: x[1])
xy = sorted(xy,key=lambda x: x[0])
#print(xy)
ans = 10**20
for i in range(N-K+1):
  for j in range(i+K-1,N):
    #print(i,j)
    xy1 = xy[i:j+1]
    #print(xy1)
    xy1 = sorted(xy1,key=lambda x: x[1])
    mi = min(xy1[i+K-1][1]-xy1[i][1] for i in range(len(xy1)-K+1))
    ans = min(ans,(xy[j][0]-xy[i][0])*mi)
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def inputs():return [int(x) for x in input().split()]
N,K = inputs()
xy = [inputs() for _ in range(N)]
#xy = sorted(xy,key=lambda x: x[1])
xy = sorted(xy,key=lambda x: x[0])
#print(xy)
ans = 10**20
for i in range(N-K+1):
  for j in range(i+K-1,N):
    #print(i,j)
    xy1 = xy[i:j+1]
    #print(xy1)
    xy1 = sorted(xy1,key=lambda x: x[1])
    mi = min(xy1[i+K-1]-xy1[i] for i in range(len(xy1)-K+1))
    ans = min(ans,(xy[j][0]-xy[i][0])*mi)
print(ans)
Problem p03478 (python)

Fixed submission:
ans = 0
n, a, b = map(int, input().split())
for i in range(1, n + 1):
  t = 0
  z = i
  while z > 0:
    t = t + z % 10
    z = z // 10
  if t >= a and t <= b:
    ans = ans + i
print(ans)

Buggy submission (verdict: Runtime Error):
ans = 0
for i in range(1, int(input()) + 1):
  t = 0
  z = i
  while z > 0:
    t = t + z % 10
    z = z // 10
  if t >= a and t <= b:
    ans = ans + i
print(ans)
Problem p02848 (python)

Fixed submission:
n=int(input())
s=input()
cnt=len(s)
a='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ans=''
for i in range(cnt):
  
  l=a.index(s[i])
  ans=ans+a[(l+n)%26]
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
cnt=len(s)
a='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ans=''
for i in range(cnt):
  ans=ans+a[i+n]
print(ans)
Problem p02886 (python)

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

Buggy submission (verdict: Runtime Error):
n=int(input())
List=[int(i) for i in input().split()]
print(Lint)
Problem p02791 (python)

Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]
preMin = [a[0]]
for i in range(1,n):
    preMin.append(min(preMin[-1],a[i]))
ans = 1
for i in range(1,n):
    if a[i]<preMin[i-1]:
        ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
from math import gcd
M = 10**9+7


def lcm(a, b): return (a//gcd(a, b))*b


totalLCM = 1

n = int(input())
a = [int(x) for x in input().split()]
for i in a:
    totalLCM = lcm(totalLCM, i)

ans = 0
for i in a:
    ans += (totalLCM//i)
    ans %= M

print(ans % M)
Problem p02947 (python)

Fixed submission:
from collections import defaultdict
n = int(input())
seen = defaultdict(int)
for _ in range(n):
  s = "".join(sorted(input()))
  seen[s]+=1

ans = 0
for i in seen:
  ans+= seen[i]*(seen[i]-1)//2
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
n = int(input())
seen = defaultdict(int)
for _ in range(n):
  s = sorted(input())
  seen[s]+=1

ans = 0
for i in seen:
  ans+= seen[i]*(seen[i]-1)//2
print(ans)
Problem p03493 (python)

Fixed submission:
s = input()
print(s.count("1"))

Buggy submission (verdict: Runtime Error):
S1, S2, S3 = map(int,input().split())
S = S1 + S2 + S3

print(str(S))

Buggy submission (verdict: Runtime Error):
S1, S2, S3 = map(int,input().split()) #'1'あるいは'0'
print(str(S1 + S2 +S3))
Problem p02576 (python)

Fixed submission:
import sys
import math

n, x, t = sys.stdin.readlines()[0].split()
n,x,t = float(n),int(x),int(t)

print(int(math.ceil(n/x) * t))

Buggy submission (verdict: Runtime Error):
import sys

n, x, t = sys.stdin.readlines()[0].split()
n, x, t = int(n), int(x), int(t)
return math.ceil(n/x) * t
Problem p02576 (python)

Fixed submission:
import numpy as np 

s_ = np.array(input().split())
s = [int(i) for i in s_]
N,X,T =s[0],s[1],s[2]
n = N//X
if N % X != 0:
  n += 1
out = n * T
print(out)

Buggy submission (verdict: Runtime Error):
s = int(input().split())
N,X,T =s[0],s[1],s[2]
n = N//X
if N % X != 0:
  n += 1
out = n * T
print(out)
Problem p02576 (python)

Fixed submission:
n,x,t=map(int,input().split())
print((n//x+((n%x)!=0))*t)

Buggy submission (verdict: Runtime Error):
n,x,t=map(int,input().split())
print((n//x+((n%x)!=0)*t)
Problem p02658 (python)

Fixed submission:
n,*a=map(int,open(0).read().split())
if 0 in a:
  print(0)
  exit()
s=1
for i in a:
  s*=i
  if s>10**18:
    print(-1)
    exit()
print(s)

Buggy submission (verdict: Runtime Error):
n,*a=map(open(0).read().split())
if 0 in a:
  print(0)
  exit()
s=1
for i in a:
  s*=i
  if s>10**18:
    print(-1)
    exit()
print(s)

Buggy submission (verdict: Runtime Error):
n,*a=map(int,open(0).read().split())
s=1
if any(a==0):
  print(0)
  exit()
for i in a:
  s*=i
  if s>1e18:
    print(-1)
    exit()
print(s)
Problem p02681 (python)

Fixed submission:
s=input()
t=input()
if s==t[:-1]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
A=list(map(int,input().split()))
a=[0]*n
a[0]=1
nxt=A[0]-1
i=2
while 1:
  a[nxt]=i
  nxt=A[nxt]-1
  i+=1
  if a[nxt]!=0:
    g=i-a[nxt]
    t=a[nxt]-1
    break
if t>=k:
  print(a.index(k+1)+1)
else:
  k-=t
  u=k%g
  print(a.index(t+u+1)+1)
Problem p02690 (python)

Fixed submission:
x=int(input())
l=[]
for i in range(1,int(x**0.5)+1):
  if x%i==0:
    l.append(i)
    l.append(x//i)
for i in l:
  for j in range(int(x**0.2)+100,0,-1):
    A=j
    B=j-i
    if A<B:
      break
    if A**5-B**5==x:
      print(A,B,sep=' ')
      exit()

Buggy submission (verdict: Runtime Error):
from collections import Counter
n,*a=map(int,open(0).read().split())
l=[0]*n
r=[0]*n
for i,c in enumerate(a):
  l[i]+=c+i+1
  r[i]+=i+1-c
L=Counter(l)
R=Counter(r)
ans=0
for i in range(1,n+max(a)):
  ans+=L[i]*R[i]
print(ans)

Buggy submission (verdict: Runtime Error):
x=int(input())
l=[]
for i in range(1,int(x**0.5)+1):
  if x%i==0:
    l.append(i)
    l.append(x//i)
for i in l:
  for j in range(x**0.2+10*2,0,-1):
    A=j
    B=j-i
    if A<B:
      break
    if A**5-B**5==x:
      print(A,B,sep=' ')
      exit()
Problem p02696 (python)

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

Buggy submission (verdict: Runtime Error):
a,b,n=map(int,input().split())
x=min(b-1,x)
print(a*x//b)
Problem p02705 (python)

Fixed submission:
import math
r=int(input())
print(2*r*math.pi)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
mod=10**9+7
ans=0
for i in range(k,n+2):
  ans+=((2*n-i+1)*i//2-i*(i-1)//2+1)%mod
print(ans)
Problem p02706 (python)

Fixed submission:
n,m=map(int,input().split())
a=list(map(int,input().split()))
s=0
for i in a:
    s+=i
if s>n:
    print(-1)
else:
    print(n-s)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))
s=0
for i in a:
    s+=i
if s>a:
    print(-1)
else:
    print(a-s)
Problem p02718 (python)

Fixed submission:
n,m=map(int,input().split())
a=list(map(int,input().split()))
c=sum(a)/(4*m)
ans=0
for i in range(n):
    if a[i]>=c:
        ans+=1
if ans>=m:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))
c=sum(a)/(4*m)
ans=0
for i in range(n):
    if a[n]>=c:
        ans+=1
if ans>=m:
    print('Yes')
else:
    print('No')
Problem p02732 (python)

Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
s=Counter(a)
res=0
for i in s.values():
    res+=i*(i-1)//2
ans=0
for j in range(n):
    if s[a[j]]==1:
        print(res)
    else:
        ans=res-s[a[j]]+1
        print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
def ans(a,x):
  b=0
  c=a[:x]+a[x+1:]
  d=list(set(c))
  for i in range(len(d)):
    if c.count(d[i])>1:
      b=b+(c.count(d[i])*(c.count(d[i])-1))/2
      return b
for k in range(n):
  print(int(ans(a,k)))
Problem p02756 (python)

Fixed submission:
from collections import deque
S=deque(input())
q=int(input())
rev=False
for i in range(q):
  c=list(input().split())
  if c[0]=='1':
    rev=not rev
  elif c[1]=='1' and rev==False:
    S.appendleft(c[2])
  elif c[1]=='2' and rev==True:
    S.appendleft(c[2])
  else:
    S.append(c[2])
if rev:
  S.reverse()
ans=''.join(S)
print(ans)

Buggy submission (verdict: Runtime Error):
S=list(input())
q=int(input())
for i in range(q):
  c=list(input().split())
  print(c)
  if c[0]=='1':
    S.reverse()
  elif c[0]=='2':
    if c[1]=='1':
      S.appendleft(c[2])
    elif c[1]=='2':
      S.append(c[2])
ans=''.join(S)
print(ans)
Problem p03160 (python)

Fixed submission:
n,*h=map(int,open(0).read().split())
dp=[10**18]*(n+1)
dp[0]=0
h=h+[0]
for i in range(n-1):
  dp[i+1]=min(dp[i+1],dp[i]+abs(h[i+1]-h[i]))
  dp[i+2]=min(dp[i+2],dp[i]+abs(h[i+2]-h[i]))
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
import numpy as np
N,W = map(int,input().split())
dp = np.full(N*1000+1,W+1)
dp[0] = 0
for _ in range(N):
    w,v = map(int,input().split())
    dp[v:]=np.minimum(dp[v:],dp[:-v]+w)
print(np.where(dp<=W)[0][-1])

Buggy submission (verdict: Runtime Error):
n,*h=map(int,open(0).read().split())
dp=[0]*(n+1)
dp[0]=h[0]
for i in range(n):
  dp[i+1]=min(dp[i+1],dp[i]+abs(h[i+1]-h[i]))
  dp[i+2]=min(dp[i+2],dp[i]+abs(h[i+2]-h[i]))
print(dp[n-1])
Problem p03162 (python)

Fixed submission:
n=int(input())
dp=[[0]*3 for i  in range(n+1)]
for i in range(n):
  a,b,c=map(int,input().split())
  dp[i+1][0]=max(dp[i][1],dp[i][2])+a
  dp[i+1][1]=max(dp[i][0],dp[i][2])+b
  dp[i+1][2]=max(dp[i][0],dp[i][1])+c
print(max(dp[-1]))

Buggy submission (verdict: Runtime Error):
n=int(input())
dp=[[0]*3 for i  in range(n+1)]
for i in range(n):
  a,b,c=map(int,input())
  dp[i+1][0]=max(dp[i][1],dp[i][2])+a
  dp[i+1][1]=max(dp[i][0],dp[i][2])+b
  dp[i+1][2]=max(dp[i][0],dp[i][1])+c
print(max(dp[-1]))

Buggy submission (verdict: Runtime Error):
N=int(input())
dp=[[0]*3 for i  in range(n+1)]
for i in range(n):
  a,b,c=map(int,input())
  dp[i+1][0]=max(dp[i][1],dp[i][2])+a
  dp[i+1][1]=max(dp[i][0],dp[i][2])+b
  dp[i+1][2]=max(dp[i][0],dp[i][1])+c
print(max(dp[-1]))
Problem p03163 (python)

Fixed submission:
N,W=map(int,input().split())
dp=[[0]*(W+1) for _ in range(N+1)]
for i in range(N):
  w,v=map(int,input().split())
  for j in range(W+1):
    if j-w>=0:
      dp[i+1][j]=max(dp[i][j],dp[i][j-w]+v)
    else:
      dp[i+1][j]=dp[i][j]
print(max(dp[N]))

Buggy submission (verdict: Runtime Error):
N,W=map(int,input().split())
dp=[[0]*(W+1) for _ in range(N+1)]
for i in range(N+1):
  w,v=map(int,input())
  for j in range(W+1):
    if j-w>=0:
      dp[i+1][j]=max(dp[i][j],dp[i][j-w]+v)
    else:
      dp[i+1][j]=dp[i][j]
print(max(dp[N]))
Problem p03164 (python)

Fixed submission:
import numpy as np
N,W = map(int,input().split())
dp = np.full(N*1000+1,W+1)
dp[0] = 0
for _ in range(N):
    w,v = map(int,input().split())
    dp[v:]=np.minimum(dp[v:],dp[:-v]+w)
print(np.where(dp<=W)[0][-1])

Buggy submission (verdict: Runtime Error):
N,W=map(int,input().split())
dp=[[0]*(W+1) for _ in range(N+1)]
for i in range(N):
  w,v=map(int,input().split())
  for j in range(W+1):
    if j-w>=0:
      dp[i+1][j]=max(dp[i][j],dp[i][j-w]+v)
    else:
      dp[i+1][j]=dp[i][j]
print(dp[N][W])

Buggy submission (verdict: Runtime Error):
N,W=map(int,input().split())
dp=[[0]*(N+1) for _ in range(W+1)]
for i in range(N):
  w,v=map(int,input().split())
  for j in range(W+1):
    if j-w>=0:
      dp[i+1][j]=max(dp[i][j],dp[i][j-w]+v)
    else:
      dp[i+1][j]=dp[i][j]
print(dp[N][W])