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

Fixed submission:
from itertools import combinations_with_replacement
n, k = map(int, input().split())
d = [int(x) for x in input().split()]
dd = set(list(range(10))) - set(d)

x = str(n)
lst = []
dd = list(dd)
dd.sort()
sel = []
for i in dd:
    if int(x[0]) <= i and len(sel) < 3: sel.append(i*10**(len(x)-1))
if len(sel) < 2:
    if len(dd) == 1:
        sel.append((dd[0]*10 + dd[0])* 10 ** (len(x)-1))
    else:
        if dd[0] != 0:
            sel.append((dd[0]*10 + dd[0])* 10 ** (len(x)-1))
        else:
            sel.append((dd[1]*10 + dd[0])* 10 ** (len(x)-1))
for j in sel:
    for l in combinations_with_replacement(dd, len(x)-1):
        cnt = j
        for i in range(len(x)-1):
            cnt += 10 ** (len(x)-i-2) * l[i]
        if cnt >= n: lst.append(cnt)
print(min(lst))

Buggy submission (verdict: Runtime Error):
from itertools import combinations_with_replacement, product
n, k = map(int, input().split())
d = [int(x) for x in input().split()]
dd = set(list(range(10))) - set(d)

x = str(n)
lst = []
dd = list(dd)
dd.sort()
sel = []
for i in dd:
    if int(x[0]) <= i and len(sel) < 3: sel.append(i*10**(len(x)-1))
if len(sel) < 2:
    if dd[0] != 0:
        sel.append((dd[0]*10 + dd[1])* 10 ** (len(x)-1))
    else:
        sel.append((dd[1]*10 + dd[0])* 10 ** (len(x)-1))
for j in sel:
    for l in combinations_with_replacement(dd, len(x)-1):
        cnt = j
        for i in range(len(x)-1):
            cnt += 10 ** (len(x)-i-2) * l[i]
        if cnt >= n: lst.append(cnt)
print(min(lst))
Problem p02553 (python)

Fixed submission:
a=list(map(int,input().split()))
print(max([a[0]*a[2],a[0]*a[3],a[1]*a[2],a[1]*a[3]]))

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
print(max([a*c,a*d,b*c,c*d])
Problem p02784 (python)

Fixed submission:
k,n=map(int,input().split())
a=list(map(int,input().split()))
if sum(a)>=k:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
k,n=map(int,input().split())
a=list(map(int,intput().split()))
if sum(a)>=k:
  print("Yes")
else:
  print("No")
Problem p02830 (python)

Fixed submission:
'''
author : w2sc
  date : 2019/12/22
  time : 20:03:13
'''
n=int(input())
a,b=input().split()
i=0
s=""
while i<n:
    s+=a[i]+b[i]
    i+=1
print(s)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
print("".jion(s.split()))
Problem p02850 (python)

Fixed submission:
import sys
sys.setrecursionlimit(100010)
n=int(input())
edge=[]
G=[[] for _ in range(n+1)]
for _ in range(n-1):
    x,y=map(int,input().split())
    edge.append([x,y])
    G[x].append(_)
    G[y].append(_)
k=0
root=0
for i in range(1,n+1):
    if k<len(G[i]):
        root=i
        k=len(G[i])
co=[1 for i in range(n+1)]
vis=[False for i in range(n+1)]
def dfs(node,lastco=-1):
    tmp=lastco
    for v in G[node]:
        if not vis[v]:
            tmp+=1
            co[v]=tmp%k
            vis[v]=True
            if node==edge[v][0]:
                dfs(edge[v][1],co[v])
            else:
                dfs(edge[v][0],co[v])

dfs(root)
print(k)
for i in range(n-1):
    print(co[i]+1)

Buggy submission (verdict: Runtime Error):
n=int(input())
edge=[]
G=[[] for _ in range(n+1)]
for _ in range(n-1):
    x,y=map(int,input().split())
    edge.append([x,y])
    G[x].append(_)
    G[y].append(_)
k=0
root=0
for i in range(1,n+1):
    if k<len(G[i]):
        root=i
        k=len(G[i])
co=[1 for i in range(n+1)]
vis=[False for i in range(n+1)]
def dfs(node,lastco=-1):
    tmp=lastco
    for v in G[node]:
        if not vis[v]:
            tmp+=1
            co[v]=tmp%k
            vis[v]=True
            if node==edge[v][0]:
                dfs(edge[v][1],co[v])
            else:
                dfs(edge[v][0],co[v])

dfs(root)
print(k)
for i in range(n-1):
    print(co[i]+1)

Buggy submission (verdict: Runtime Error):
n=int(input())
edge=[]
G=[[] for _ in range(n+1)]
for _ in range(n-1):
    x,y=map(int,input().split())
    edge.append([x,y])
    G[x].append(_)
    G[y].append(_)
k=0
root=0
for i in range(1,n+1):
    if k<len(G[i]):
        root=i
        k=len(G[i])
co=[1 for i in range(n+1)]
def dfs(node,pa=-1):
    #print(node)
    tmp=0
    if pa>=0:
        tmp=co[pa]
    for v in G[node]:
        if pa not in edge[v]:
            #print("??",v)
            tmp+=1
            co[v]=tmp%k+1
            if node==edge[v][0]:
                dfs(edge[v][1],node)
            else:
                dfs(edge[v][0],node)

dfs(root)
print(k)
for i in range(n-1):
    print(co[i])
Problem p02553 (python)

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

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())
if a >= 0:
  if d <= 0:
    print(a*d)
  else:
    print(b*d)
    
elif b>0:
  if d<0:
    print(a*c)
  else:
    print(max(a*c,b*d)
else:
  if c>=0:
    print(b*c)
  else:
    print(a*c)
Problem p02630 (python)

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

d=dict()
sum=0
for i in A:
  if not i in d:
    d[i]=0
  d[i]+=1
  sum+=i
#counterと同じ
for i in range(int(input())):
  b,c=map(int,input().split())
  if not c in d:
    d[c]=0
  if not b in d:
    d[b]=0
    
  sum=sum-(d[b]*b)
  sum=sum-(d[c]*c)
  d[c]+=d[b]
  d[b]=0
  sum=sum+(d[c]*c)
  #print(d)
  print(sum)

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

d=dict()
sum=0
for i in A:
  if not i in d:
    d[i]=0
  d[i]+=1
  sum+=i
#counterと同じ
for i in range(int(input())):
  b,c=map(int,input().split())
  if not c in d:
    d[c]=0
    
  sum=sum-(d[b]*b)
  sum=sum-(d[c]*c)
  d[c]+=d[b]
  d[b]=0
  sum=sum+(d[c]*c)
  #print(d)
  print(sum)
Problem p02714 (python)

Fixed submission:
N=int(input())
s=input()
R=[0]
G=[0]
B=[0]
ans=0
#RGBの累積和を作る
for i in range(N):
  if s[i]=="R":
    R[i]+=1
  elif s[i]=="G":
    G[i]+=1
  else:
    B[i]+=1
  R.append(R[i])
  G.append(G[i])
  B.append(B[i])
del R[-1]
del G[-1]
del B[-1]
#作った

#全探索する
for i in range(N-2):
  a=s[i]
  for j in range(i+1,N-1):
    if a==s[j]:
      continue
    b=s[j]
    k=2*j-i
    if "R" not in a+b:
      ans+=R[-1]-R[j]
      try:
        if s[k]=="R":
          ans-=1
      except:
        pass
    
    if "G" not in a+b:
      ans+=G[-1]-G[j]
      try:
        if s[k]=="G":
          ans-=1
      except:
        pass
        
    if "B" not in a+b:
      ans+=B[-1]-B[j]
      try:
        if s[k]=="B":
          ans-=1
      except:
        pass
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import accumlate
N=int(input())
s=input()
R=[]
G=[]
B=[]
ans=0
#RGBの累積和を作る
for i in range(N):
  if s[i]=="R":
    R.append(s[i])
  elif s[i]=="G":
    G.append(s[i])
  else:
    B.append(s[i])
R.accumlate()
G.accumlate()
B.accumlate()
#作った

#全探索する
for i in range(N):
  a=s[i]
  for j in range(i+1,N):
    if a==s[j]:
      continue
    b=s[j]
    k=2*j-i
    if "R" not in a+b:
      ans+=R[N]-R[j+1]
      if s[k]=="R":
        ans-=1
    if "G" not in a+b:
      ans+=G[N]-G[j+1]
      if s[k]=="G":
        ans-=1
    if "B" not in a+b:
      ans+=B[N]-B[j+1]
      if s[k]=="B":
        ans-=1
print(ans)
Problem p02732 (python)

Fixed submission:
def f(n):#nC2の関数
    if n==0:
        return 0
    return n*(n-1)/2
N=int(input())
A=list(map(int,input().split()))
d=dict()
e=dict()
ans=0
for i in range(N):#辞書を作る
    if A[i] not in d:
        d[A[i]]=0
    d[A[i]]+=1

for j in d:#それぞれのキーの個数をnC2として保存
    e[j]=f(d[j])
    ans+=e[j]#nC2の総和をとる

for i in A:
    print(int(ans-d[i]+1))

Buggy submission (verdict: Runtime Error):
def f(n):
  return (n*(n-1))//2
N=int(input())
A=list(map(int,input().split()))
d=dict()
ans=0
#それぞれが何個あるかを辞書に登録
for i in range(len(A)):
  if A[i] not in d:
    d[i]=0
  d[i]+=1
for i in d:
  ans+=f(d[i])
for i in range(len(A)):
  print(ans-d[A[i]]-1)
Problem p02741 (python)

Fixed submission:
L=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(L[int(input())-1])

Buggy submission (verdict: Runtime Error):
from decimal import Decimal
from math import sqrt
a,b,c=map(int,input().split())
if Decimal(sqrt(a))+Decimal(sqrt(b))<Decimal(sqrt(c)):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
from math import sqrt
a,b,c=map(int,input().split())
if sqrt(a)+sqrt(b)<sqrt(c):
  print("Yes")
else:
  print("No")
Problem p02743 (python)

Fixed submission:
from decimal import Decimal
a,b,c=map(Decimal,input().split())
if (a.sqrt()+b.sqrt())<c.sqrt():
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
from dicimal import Decimal
a,b,c=map(Decimal,input().split())
if (a.sqrt()+b.sqrt())<c.sqrt():
  print("Yes")
else:
  print("No")
Problem p02756 (python)

Fixed submission:
from collections import deque
S=deque(input())
Q=int(input())
F=0#フラグ
for i in range(Q):
  N=list(input().split())
  if F==0:#反転していない場合
    if N[0]=="1":#反転させる
      F=1
    elif N[1]=="1":#先頭に追加
      S.appendleft(N[2])
    else:#末尾に追加
      S.append(N[2])
  elif F==1:#反転している場合
    if N[0]=="1":#反転を戻す
      F=0
    elif N[1]=="1":#末尾に追加
      S.append(N[2])
    else:#先頭に追加
      S.appendleft(N[2])
if F==1:#反転するならsを反転させる
  S.reverse()
  print("".join(S))
else:#そうでないならそのまま
  print("".join(S))

Buggy submission (verdict: Runtime Error):
from collections import deque
S=deque(input())
Q=int(input())
F=0
for i in range(Q):
  N=list(input().split())
  if F==0:
    if N[0]=="1":
      F=1
    elif N[1]=="1":
      S.appendleft(N[2])
    else:
      S.append(N[2])
  elif F==1:
    if N[0]=="1":
      F=0
    elif N[1]=="1":
      S.append(N[2])
    else:
      S.appendleft(N[2])
if F==1:
  print("".join(S.reverse()))
else:
  print("".join(S))

Buggy submission (verdict: Runtime Error):
from collections import deque
S=deque(input())
Q=int(input())
for i in range(Q):
  N=list(input().split())
  if N[0]=="1":
    S.reverse()
  elif N[1]="1":#先頭にC1
    S.appendleft(N[2])
  else:
    S.append(N[2])
print(S)
Problem p02760 (python)

Fixed submission:
from sys import stdin,exit
import  numpy as np
A = [stdin.readline().rstrip().split() for _ in range(3)]
A=sum(A,[])
n = int(stdin.readline().rstrip())
B= [stdin.readline().rstrip().split() for _ in range(n)]
B=sum(B,[])
if len(B)<=2:
    print("No")
    sys.exit()
for i in range(len(B)):
    try:
        A[A.index(B[i])]=0
    except:
        continue
A=[int(i) for i in A]
if A[1]+A[2]+A[0]==0 or A[0]+A[3]+A[6]==0 or A[2]+A[4]+A[6]==0 or A[3]+A[4]+A[5]==0 or A[1]+A[4]+A[7]==0 or A[0]+A[4]+A[8]==0 or A[6]+A[7]+A[8]==0 or A[2]+A[5]+A[8]==0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
from sys import stdin,exit
import  numpy as np
A = [stdin.readline().rstrip().split() for _ in range(3)]
A=sum(A,[])
n = int(stdin.readline().rstrip())
B= [stdin.readline().rstrip().split() for _ in range(n)]
B=sum(B,[])
if len(B)<=2:
    print("No")
    sys.exit()
for i in range(len(B)):
    try:
        A[A.index(B[i])]=0
    except:
        continue    
if A[1]+A[2]+A[0]==0 or A[0]+A[3]+A[6]==0 or A[2]+A[4]+A[6]==0 or A[3]+A[4]+A[5]==0 or A[1]+A[4]+A[7]==0 or A[0]+A[4]+A[8]==0 or A[6]+A[7]+A[8]==0 or A[2]+A[5]+A[8]==0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
from sys import stdin,exit
import  numpy as np
A = [stdin.readline().rstrip().split() for _ in range(3)]
sum(A,[])
n = int(stdin.readline().rstrip())
B= [stdin.readline().rstrip().split() for _ in range(n)]
if len(B)<=2:
    print("No")
    sys.exit()
for i in range(len(B)):
    try:
        A[A.index(B[i])]=0
    except:
        continue
if A[1]+A[2]+A[3]==0 or A[1]+A[4]+A[7]==0 or A[3]+A[5]+A[7]==0 or A[4]+A[5]+A[6]==0 or A[2]+A[5]+A[8]==0 or A[1]+A[5]+A[9]==0 or A[7]+A[8]+A[9]==0 or A[3]+A[6]+A[9]==0:
    print("Yes")
else:
    print("No")
Problem p02778 (python)

Fixed submission:
a=input()
print("x"*len(a))

Buggy submission (verdict: Runtime Error):
print(x*len(input()))
Problem p02786 (python)

Fixed submission:
import math
print(2**(math.ceil(math.log2(float(input())+1)))-1)

Buggy submission (verdict: Runtime Error):
import math
H=int(input())+1
print(2**(math.celi(math.log(H,2)))-1)
"""import math
print(2**(math.ceil(math.log(float(input())+1,2)))-1)"""

Buggy submission (verdict: Runtime Error):
import math
print(2**(math.ceil(log(input(H),2)))-1)

Buggy submission (verdict: Runtime Error):
import math
print(2**(math.ceil(input(H),2))-1)
Problem p02789 (python)

Fixed submission:
x,y=map(int,input().split())
if x==y:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
x,y=map(int,input().split())
if x=y:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
x,y=map(int,input().split())
if x=y:
  print("Yes")
else:
  print("No")
Problem p02801 (python)

Fixed submission:
alfa=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
c=input()
print(alfa[alfa.index(c)+1])

Buggy submission (verdict: Runtime Error):

from collections import deque
from copy import deepcopy

def bfs(pos,map):
      while pos:
        x,y,depth=pos.popleft()
        if map[x][y]=="#":
            continue
        map[x][y]="#"
        if map[x-1][y]!="#":
          pos.append([x-1,y,depth+1])
        if map[x+1][y]!="#":
          pos.append([x+1,y,depth+1])
        if map[x][y+1]!="#":
          pos.append([x,y+1,depth+1])
        if map[x][y-1]!="#":
          pos.append([x,y-1,depth+1])
      return depth
H,W=map(int,input().split())
ans=0
fence=["#"]*(W+2)
field=[fence]
for _ in range(H):
  L=list(input())
  field.append(["#"]+L+["#"])
field.append(fence)
for i in range(1,H+1):
  for j in range(1,W+1):
    if field[i][j]==".": 
      pos=deque([[i,j,0]])
      depth=bfs(pos,deepcopy(field))
      if ans<depth:
        ans=depth
print(ans)
Problem p02830 (python)

Fixed submission:
N=int(input())
S,T=input().split()
for i in range(N):
  print(S[i],T[i],sep="",end="")

Buggy submission (verdict: Runtime Error):
N=int(input())
S,T=input().split()
for i in range(N):
  print(S[i]T[i],end="")
Problem p02848 (python)

Fixed submission:
N=int(input())
S=input()
A=[]
#65~90
for i in range(len(S)):
  A.append(chr((ord(S[i])-65+N)%26+65))
print("".join(A))

Buggy submission (verdict: Runtime Error):
N=int(input().split())
S=list(input())
#65~90
for i in range(len(S)):
  S[i]+=N
  S[i]=(S[i]%26)+65
print("".join(S))
Problem p02887 (python)

Fixed submission:
N=int(input())
S=input()
for i in range(1,len(S)):
  if S[i]==S[i-1]:
    N-=1
print(N)

Buggy submission (verdict: Runtime Error):
from itertools import groupby
N=int(input())
s=input()
print(len(groupby(s)))
Problem p02899 (python)

Fixed submission:
from operator import itemgetter
N=int(input())
A=list(map(int,input().split()))
B=[(i+1,A[i]) for i in range(N)]
B=sorted(B,key=itemgetter(1))
for k in range(N):
  print(B[k][0],end=" ")

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
for i in range(N):
  print(A.index(i)+1,end=" ")
Problem p02911 (python)

Fixed submission:
N,K,Q=map(int,input().split())
P=[K for _ in range(N)]
for i in range(Q):
  P[int(input())-1]+=1
P=[j-Q for j in P]
for k in range(N):
  if P[k]>0:
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
N,K,Q=map(int,input().split())
P=[K for _ in range(N)]
for i in range(N):
  P[int(input())-1]+=1
P=[j-Q for j in P]
for k in range(Q):
  if P[i]>0:
    print("Yes")
  else:
    print("No")
Problem p02922 (python)

Fixed submission:
import math
A,B=map(int,input().split())
ans=1
B-=A
print(ans+math.ceil(B/(A-1)))

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
ans=1
i=0
while True:
  if ans>=B:
    print(i)
    exit()
  ans+=a-1
  i+=1
Problem p02923 (python)

Fixed submission:
N=int(input())
H=list(map(int,input().split()))
A,a=0,0
C=[0]*N
H=H[::-1]
for i in range(N-1):
  if H[i]<=H[i+1]:
    A+=1
  else:
    C[a]=A
    a+=1
    A=0
C[a]=A
print(max(C))

Buggy submission (verdict: Runtime Error):
N=int(input())
H=list(map(int,input().split()))
A,a=0,0
C=[0]*N
H=H[-1:0:-1]
for i in range(N):
  if H[i]>=H[i+1]:
    A+=1
  else:
    C[a]=A
    a+=1
    A=0
print(max(C))
Problem p02947 (python)

Fixed submission:
N=int(input())
d=dict()
ans=0
for _ in range(N):
  s=input()
  s=tuple(sorted(s))
  if s in d:
    d[s]+=1
  else:
    d[s]=0
for i in d.values():
  ans+=(int(i)**2+int(i))/2
print(int(ans))

Buggy submission (verdict: Runtime Error):
def f(n):
  return (n**2-n)//2
ans=0
N=int(input())
d=dict()
for i in range(N):
  s=sorted(input())
  if s not in d:
    d[s]=0
  d[s]+=1
for i in d:
  ans+=f(i)
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
d={}
ans=0
for _ in range(N):
  s=input()
  s=sortde(s)
  if s in d:
    d[s]+=1
  else:
    d[s]=0
for i in d.value():
  ans+=(int(i)**2+int(i))/2
print(ans)
Problem p02952 (python)

Fixed submission:
ans=0
N=int(input())
for i in range(1,N+1):
    if len(str(i))%2==1:
      ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
ans=0
N=int(input()):
  for i in range(N):
    if len(str(i))%2==1:
      ans+=1
print(ans)
Problem p02953 (python)

Fixed submission:
N=int(input())
H=list(map(int,input().split()))
if N==1:
  print("Yes")
  exit()
for i in range(N-1):
  if H[i]-1<=H[i+1]:
    if i!=0:
      if H[i-1]<H[i]:
        H[i]-=1
  elif H[i]==H[i+1]:
    continue
  else:
    print("No")
    exit()
for i in range(N-1):
  if H[i]>H[i+1]:
    print("No")
    exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
N=int(input())
H=list(map(int,input().split()))
if H[0]<H[1]:
  H[0]-=1
elif H[0]>H[1]:
  print("No")
  exit()
for i in range(1,N):
  if H[i-1]<H[i]:
    H[i]-=1
  elif H[i-1]>H[i]:
    print("No")
    exit()
print("Yes")
Problem p02983 (python)

Fixed submission:
L,R=map(int,input().split())
ans=2018
if R-L>=673:
    print(0)
    exit()
for i in range(R-L):
    for j in range(i+1,R-L+1):
        if ans>((L+i)*(L+j))%2019:
            ans=((L+i)*(L+j))%2019
print(ans)

Buggy submission (verdict: Runtime Error):
L,R=map(int,input().split())
ans=100100100
for i in range(min(R-L,2000),min(R,2001):
  for j in range(i+1,min(R,2002)):
    if ans>((i*j)%2019):
      ans=((i*j)%2019)
print(ans)
Problem p03086 (python)

Fixed submission:
S=list(input())
A=[0]*10
c=0
for i in range(len(S)):
  if S[i]=="A" or S[i]=="G" or S[i]=="C" or S[i]=="T":
    A[c]+=1
  else:
    c+=1
print(max(A))

Buggy submission (verdict: Runtime Error):
S=list(input())
A=[0]*10
c=0
for i in range(10):
  if S[i]=="A" or S[i]=="G" or S[i]=="C" or S[i]=="T":
    A[c]+=1
  else:
    c+=1
print(max(A))
Problem p03087 (python)

Fixed submission:
N,Q=map(int,input().split())
s=input()
A=[0]
for i in range(N-1):
  if s[i]+s[i+1]=="AC":
    A.append(A[i]+1)
  else:
    A.append(A[i])
for i in range(Q):
  l,r=map(int,input().split())
  print(A[r-1]-A[l-1])

Buggy submission (verdict: Runtime Error):
N,Q=map(int,input().split())
s=input()
for i in range(Q):
  l,r=map(int,input().split())
  print(s[l-1:r].count("AC")
Problem p03102 (python)

Fixed submission:
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
ans=0
for i in range(N):
  A=list(map(int,input().split()))
  d=0
  for j,k in zip(A,B):
    d+=j*k
  if d>-C:
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
ans=0
for i in range(N):
  A=list(map(int,input().split()))
  d=0
  for j,k in zip(A,B):
    d+=A*B
  if d>-C:
    ans+=1
print(ans)
Problem p03110 (python)

Fixed submission:
N=int(input())
ans=0
for i in range(N):
  x,u=input().split()
  if u=="JPY":
    ans+=float(x)
  else:
    ans+=(float(x)*380000)
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
ans=0
for i in range(N):
  x,u=input().split()
  if u=="JPY":
    ans+=int(x)
  else:
    ans+=(int(x)*380000)
print(ans)
Problem p03128 (python)

Fixed submission:
# 解説放送の１つめ
N,M = map(int, input().split())
A = list(map(int, input().split()))
f = [-1, 2,5,5,4,5,6,3,7,6] # 1-indexed

# dp[i]: マッチi本数で作れる最大の数(str)
dp = [None]*(N+1)
dp[0] = ""

# strの数の大きいほう
def max_str(s1:str, s2:str)->str:
    """return bigger one"""
    l1, l2 = len(s1), len(s2)
    if l1 != l2:
        return s1 if l1>l2 else s2
    if l1 == l2: 
        return s1 if s1>s2 else s2
    
for i in range(2, N+1):
    nxt = ""
    for aj in A:
        # 配列外参照と，i本ちょうどで作れないものはだめ
        if i-f[aj]<0 or dp[i-f[aj]]==None: continue
        nxt = max_str(nxt, 
                      dp[i-f[aj]]+str(aj))
    if nxt!="":
        dp[i] = nxt
    #print(dp)
print(dp[N])

Buggy submission (verdict: Runtime Error):
解説放送の１つめ
N,M = map(int, input().split())
A = list(map(int, input().split()))
f = [-1, 2,5,5,4,5,6,3,7,6] # 1-indexed
 
# dp[i]: マッチi本数で作れる最大の数(str)
dp = [None]*(N+1)
dp[0] = ""
 
# strの数の大きいほう
def max_str(s1:str, s2:str)->str:
    """return bigger one"""
    l1, l2 = len(s1), len(s2)
    if l1 != l2:
        return s1 if l1>l2 else s2
    if l1 == l2: 
        return s1 if s1>s2 else s2
    
for i in range(2, N+1):
    nxt = ""
    for aj in A:
        # 配列外参照と，i本ちょうどで作れないものはだめ
        if i-f[aj]<0 or dp[i-f[aj]]==None: continue
        nxt = max_str(nxt, 
                      dp[i-f[aj]]+str(aj))
    if nxt!="":
        dp[i] = nxt
    #print(dp)
print(dp[N])

Buggy submission (verdict: Runtime Error):
解説放送の１つめ
N,M = map(int, input().split())
A = list(map(int, input().split()))
f = [-1, 2,5,5,4,5,6,3,7,6] # 1-indexed
 
# dp[i]: マッチi本数で作れる最大の数(str)
dp = [None]*(N+1)
dp[0] = ""
 
# strの数の大きいほう
def max_str(s1:str, s2:str)->str:
    """return bigger one"""
    l1, l2 = len(s1), len(s2)
    if l1 != l2:
        return s1 if l1>l2 else s2
    if l1 == l2: 
        return s1 if s1>s2 else s2
    
for i in range(2, N+1):
    nxt = ""
    for aj in A:
        # 配列外参照と，i本ちょうどで作れないものはだめ
        if i-f[aj]<0 or dp[i-f[aj]]==None: continue
        nxt = max_str(nxt, 
                      dp[i-f[aj]]+str(aj))
    if nxt!="":
        dp[i] = nxt
    #print(dp)
print(dp[N])
Problem p03136 (python)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
L=sorted(A,reverse=True)
if L[0]<sum(L[1:]):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
L=sorted(A,reverse=True)
if L[0]<sum(L[1,]):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
L=sorted(A,reverse=True)
if L[0]<sum(L[1,]):
  print("Yes")
else:
  print("No")
Problem p03161 (python)

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
dp=[float("INF")]*(N+1)
dp[0]=0
for i in range(N):
  for j in range(1,K+1):
    if j+i>=N:
      break
    dp[i+j]=min(abs(A[i+j]-A[i])+dp[i],dp[i+j])
print(dp[N-1])

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
A=list(map(int,input().split()))
A+=[0]*N
dp=[float("INF")]*(2N)
dp[0]=0
for i in range(N):
  for j in range(K):
    dp[i+j]=min(abs(A[i+j]-A[i])+dp[i],dp[i+j])
print(dp[N-1])
Problem p03163 (python)

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