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

Fixed submission:
s=input()



"""
◆エッセンス1：割り切れるとは、二つに分けた数字のmodが一緒
例)
1817181712114の
18171が2019で割り切れるかどうかを判断する。

18171は(181712114-2114)/10000となるので、
181712114mod2019＝2114mod2019の時、2019で割り切れる。

1817181712114mod2019
 817181712114mod2019
  17181712114mod2019
   7181712114mod2019
    181712114mod2019
     81712114mod2019
      1712114mod2019
       712114mod2019
    　　・・・・
とmodを調べていき、値が同じペアは割り切れる。
"""

"""
◆エッセンス2：大きい数字は都度modを取る

これだけでもループは1回になるんだけど、
|S|が長すぎてTLEとなってしまう（|S|は10**5）
1234567 mod 2019
=(1*10**7)mod2019 + (234567mod2019)
=(1*10mod2019 * 10**6mod2019)+ (234567mod2019)

10**nを毎回modを取ることで、計算する数字の長さを短くする。

"""



#modの値を保持する配列
cnt=[0]*2019
#mod2019 =0 は、それ一つで割り切れるので。引き算をする必要が無い。
cnt[0]=1

#10の倍数を保持する
fac=1
ss=0
for i in range(len(s)):
    #後ろの数字から順番にとってくる
    ss += int(s[len(s)-i-1])*fac
    ss%=2019
    fac=fac*10
    fac%=2019
    cnt[ss]+=1
    

result=0
for c in cnt:
    result+=c*(c-1)//2

print(result)

Buggy submission (verdict: Runtime Error):
s=input()



"""
◆エッセンス1：割り切れるとは、二つに分けた数字のmodが一緒
例)
1817181712114の
18171が2019で割り切れるかどうかを判断する。

18171は(181712114-2114)/10000となるので、
181712114mod2019＝2114mod2019の時、2019で割り切れる。

1817181712114mod2019
 817181712114mod2019
  17181712114mod2019
   7181712114mod2019
    181712114mod2019
     81712114mod2019
      1712114mod2019
       712114mod2019
    　　・・・・
とmodを調べていき、値が同じペアは割り切れる。
"""

"""
◆エッセンス2：大きい数字は都度modを取る

これだけでもループは1回になるんだけど、
|S|が長すぎてTLEとなってしまう（|S|は10**5）
1234567 mod 2019
=(1*10**7)mod2019 + (234567mod2019)
=(1*10mod2019 * 10**6mod2019)+ (234567mod2019)

10**nを毎回modを取ることで、計算する数字の長さを短くする。

"""



#modの値を保持する配列
cnt=[0]*2019
#mod2019 =0 は、それ一つで割り切れるので。引き算をする必要が無い。
cnt[0]=1

#10の倍数を保持する
fac=1

for i in range(len(s)):
    #後ろの数字から順番にとってくる
    ss = int(s[len(s)-i-1])*fac
    ss%=2019
    fac=fac*10
    fac%=2019
    cnt[ss]+=1

result=0
for c in cnt:
    result+=cnt*(cnt-1)//2

print(result)
Problem p02787 (python)

Fixed submission:
h,n=map(int,input().split())

ab=[]
dp=[10**9]*(10**5)

maxA=0
for _ in range(n):
    a,b=map(int,input().split())
    dp[a]=min(dp[a],b)
    maxA=max(maxA,a)
#print(dp)
#dp[a]は、相手にaダメージを与えるときの、消耗する自分の最小HP
result=10**9
for i in range(1,h+maxA):
    #print(i,"##########")
    for k in range(1,i//2+2):
        dp[i]=min(dp[i],dp[k]+dp[i-k])
    if i>=h:
        result=min(result,dp[i])
    #print(dp)
print(result)

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

ab=[]
dp=[10**9]*(10**4)

maxA=0
for _ in range(n):
    a,b=map(int,input().split())
    ab.append((a,b))
    dp[a]=b
    maxA=max(maxA,a)
#print(dp)
#dp[a]は、相手にaダメージを与えるときの、消耗する自分の最小HP
result=10**9
for i in range(1,h+maxA):
    #print(i,"##########")
    for k in range(1,i//2+2):
        dp[i]=min(dp[i],dp[k]+dp[i-k])
    if i>=h:
        result=min(result,dp[i])
    #print(dp)
print(result)

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

ab=[]
dp=[10**9]*(h*2)

maxA=0
for _ in range(n):
    a,b=map(int,input().split())
    ab.append((a,b))
    dp[a]=b
    maxA=max(maxA,a)
#print(dp)
#dp[a]は、相手にaダメージを与えるときの、消耗する自分の最小HP
result=10**9
for i in range(1,h+maxA):
    #print(i,"##########")
    for k in range(1,i//2+2):
        dp[i]=min(dp[i],dp[k]+dp[i-k])
    if i>=h:
        result=min(result,dp[i])
    #print(dp)
print(result)

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

ab=[]
dp=[0]*(263)

for _ in range(n):
    a,b=map(int,input().split())
    ab.append((a,b))
    dp[b]=a

#dp[b]は、自分がダメージをｂ受けた時の、相手に与えたダメージ
i=1
while 1:

    dp[i]=max(dp[i],dp[i-1])
    for k in range((i-1)//2+2):
        dp[i]=max(dp[i],dp[k]+dp[i-k])
    
    #print(dp)
    if dp[i]>=h:
        print(i)
        exit()
    i+=1

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

abKeys = set([])
result = [10**9] * (h+1)
for _ in range(n):
    a, b = map(int, input().split())
    result[a] = min(result[a],b)

for i in range(1,h+1):
    j = 1
    while j <= i // 2:
        result[i] = min(result[i], result[j] + result[i - j])

        j += 1


print(result[-1])
Problem p02814 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**9)

n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()

cnt=1
while (a[0]%(2**cnt))==0:
    cnt+=1

cnt-=1
for item in a[1:]:
    if item%(2**cnt)!=0:
        print(0)
        exit()
    if (item//(2**cnt))%2==0:
        print(0)
        exit()


import fractions
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] //fractions.gcd(ans, a[i])

if ans%2==1:
    print(0)
    exit()

if ans//2>m:
    print(0)
    exit()

ans=ans//2

print((((m//ans)*(-1))//2)*(-1))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2147483647)


n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()

import math
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] //math.gcd(ans, a[i])

if ans%2==1:
    print(0)
    exit()

ans=ans//2

print((((m//ans)*(-1))//2)*(-1))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2147483647)


n,m=map(int,input().split())
a=list(map(int,input().split()))

import math
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] //math.gcd(ans, a[i])

cnt=0
i=1
tmp=ans
while 1:
    #print(tmp)
    if tmp%2==0 and (tmp//2)%2==1:
        if (tmp//2)%2<=m:
            cnt+=1
        else:
            break
    
    if tmp//2>m:
        break
    i+=1
    tmp=ans*i

print(cnt)

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

import math
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] //math.gcd(ans, a[i])

cnt=0
i=1
tmp=ans
while 1:
    #print(tmp)
    if tmp%2==0 and (tmp//2)%2==1:
        if (tmp//2)%2<=m:
            cnt+=1
        else:
            break
    
    if tmp//2>m:
        break
    i+=1
    tmp=ans*i

print(cnt)
Problem p02817 (python)

Fixed submission:
s,t=map(str,input().split())
print(t+s)

Buggy submission (verdict: Runtime Error):
s,t=map(str,input.split())
print(t+s)
Problem p02845 (python)

Fixed submission:
n=int(input())

s=list(map(int,input().split()))

cnt=[-1,-1,-1]

result=1

for item in s:

    temp=item-1
    if temp in cnt:
        result=result*cnt.count(temp)
        cnt[cnt.index(temp)]=cnt[cnt.index(temp)]+1
    else:
        print(0)
        exit()

print(result%1000000007)

Buggy submission (verdict: Runtime Error):
n=int(input())

s=list(map(int,input().split()))

cnt=[-1,-1,-1]

result=1

for item in s:

    temp=item-1
    result=result*cnt.count(temp)
    cnt[cnt.index(temp)]=cnt[cnt.index(temp)]+1

print(result%1000000007)

Buggy submission (verdict: Runtime Error):
n=int(input())

s=list(map(int,input().split()))

cnt=[-1,-1,-1]

result=1

for item in s:

    temp=item-1
    result=result*cnt.count(temp)
    cnt[cnt.index(temp)]=cnt[cnt.index(temp)]+1

print(result)
Problem p02850 (python)

Fixed submission:
import sys
sys.setrecursionlimit(2147483647)
INF=float('inf')
MOD=10**9+7
input=sys.stdin.readline

n=int(input())

#初期値が0の辞書
from collections import defaultdict
tree = defaultdict(lambda: set([])) 

color={}
key=[]

for _ in range(n-1):
    a,b=map(int,input().split())
    tree[a-1].add(b-1)
    tree[b-1].add(a-1)
    color[(a-1,b-1)]=0
    key.append((a-1,b-1))

checked=[0]*n
cnt=0

def DEF(parent_color,node_no):
    global color,checked,tree,cnt
    checked[node_no]=1
    cnt=max(cnt,parent_color)
    i=1
    #print("node_no",node_no)
    for item in tree[node_no]:
        if checked[item]==0:
            if i==parent_color:
                i+=1
            
            color[(min(item,node_no),max(item,node_no))]=i
            DEF(i,item)
            i+=1
DEF(0,1)

print(cnt)
for item in key:
    print(color[item])

Buggy submission (verdict: Runtime Error):
n=int(input())

#初期値が0の辞書
from collections import defaultdict
tree = defaultdict(lambda: set([])) 

color={}
key=[]

for _ in range(n-1):
    a,b=map(int,input().split())
    tree[a-1].add(b-1)
    tree[b-1].add(a-1)
    color[(a-1,b-1)]=0
    key.append((a-1,b-1))

checked=[0]*n
cnt=0

def DEF(parent_color,node_no):
    global color,checked,tree,cnt
    checked[node_no]=1
    cnt=max(cnt,parent_color)
    i=1
    print("node_no",node_no)
    for item in tree[node_no]:
        if checked[item]==0:
            if i==parent_color:
                i+=1
            
            color[(min(item,node_no),max(item,node_no))]=i
            DEF(i,item)
            i+=1
DEF(0,1)

print(cnt)
for item in key:
    print(color[item])

Buggy submission (verdict: Runtime Error):
n=int(input())
colors={}

#print("####################")

inputA=[]
for i in range(n-1):
    inputA.append(list(map(int,input().split())))

colors[1]=[1]
colors[2]=[1]

resultCorors=[1]

kindOfcolor=1

for item in inputA[1:]:
    #print(i,colors)
    pati, chil = item[0],item[1]
    if chil not in colors:
        colors[chil]=[]

    temp=set(colors[pati])|set(colors[chil])
    for j in range(1,n+2):
        if j not in temp:
            colors[chil].append(j)
            colors[pati].append(j)
            resultCorors.append(j)
            kindOfcolor=max(kindOfcolor,j)
            break

print(kindOfcolor)
for item in resultCorors:
    print(item)

Buggy submission (verdict: Runtime Error):
n=int(input())
colors={}

#print("####################")

pati,chil=map(int,input().split())
colors[pati]=[1]
colors[chil]=[1]
print(1)

for i in range(n-2):
    #print(i,colors)
    pati, chil = map(int, input().split())
    if chil not in colors:
        colors[chil]=[]

    temp=set(colors[pati])|set(colors[chil])
    for j in range(1,n+2):
        if j not in temp:
            print(j)
            colors[chil].append(j)
            colors[pati].append(j)
            break
Problem p02855 (python)

Fixed submission:
h,w,k=map(int,input().split())

inputCake=[]

for _ in range(h):
  temp=input()
  temp2=[]
  for i in temp:
    temp2.append(i)
  inputCake.append(temp2)
  
#print(inputCake)

result=[[0] * w for i in range(h)]

row=0
rowA=[]

number=1
for i in range(h):
  #行にいちごがある場合
  if "#" in inputCake[i]:
    rowA.append(row)
    count=0
    for j in range(w):
      #いちごを見つけたら
      if inputCake[i][j]=="#":
        #一つ目なら
        if count==0:
          result[i][j]=str(number)
          count+=1
        else:#二つ目以降なら
          number+=1
          result[i][j]=str(number)
      else:
      #いちごじゃなかったら
        result[i][j]=str(number)
    number+=1
  row+=1
    

    
    
#print(result)
#print(rowA)

lastnum=rowA[len(rowA)-1]
for i in range(h):
  #print(rowA)
  if i in rowA:
    print(' '.join(result[i]))
    rowA.pop(0)
  else:
    if rowA!=[]:
      print(' '.join(result[rowA[0]]))
    else:
      print(' '.join(result[lastnum]))

Buggy submission (verdict: Runtime Error):
h,w,k=map(int,input().split())

inputCake=[]

for _ in range(h):
  temp=input()
  temp2=[]
  for i in temp:
    temp2.append(i)
  inputCake.append(temp2)
  
#print(inputCake)

result=[[0] * w for i in range(h)]

row=0
rowA=[]

number=1
for i in range(h):
  #行にいちごがある場合
  if "#" in inputCake[i]:
    rowA.append(row)
    count=0
    for j in range(w):
      #いちごを見つけたら
      if inputCake[i][j]=="#":
        #一つ目なら
        if count==0:
          result[i][j]=str(number)
          count+=1
        else:#二つ目以降なら
          number+=1
          result[i][j]=str(number)
      else:
      #いちごじゃなかったら
        result[i][j]=str(number)
    number+=1
  row+=1
    

    
    
#print(result)
#print(rowA)

for i in range(h):
  #print(rowA)
  if i in rowA:
    print(' '.join(result[i]))
    rowA.pop(0)
  else:
    if rowA!=[]:
      print(' '.join(result[rowA[0]]))
    else:
      print(' '.join(result[i-1]))
Problem p02885 (python)

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

print(max(0,a-2*b))

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

  result=0
  dic={}
  dic[0]=0

  for i in range(1,a[-1]+100):
    if i in a:
      dic[i]=dic[i-1]+a.count(i)
    else:
      dic[i]=dic[i-1]

  #print(dic)

  for i in range(n-2):
    for j in range(i+1,n-1):
      if a[i]+a[j]>a[j+1]:
        temp=a[i]+a[j]
        #print(temp,a[j],a[-1])
        result+=dic[min(a[-1],temp-1)]-dic[a[j]]
        #print(a[i],a[j],a[j+1:],result)

  print(result)



if __name__ == '__main__':
    main()
Problem p02888 (python)

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

l.sort()
l.append(10**9)
cnt=0
i=0
#print(l)

while i<n-2:
    j=i+1
    while j<n-1:
        LL=j+1
        RR=n-1
        #print("#",l[i],l[j],l[LL],l[RR])
        while LL<=RR:
            k=(LL+RR)//2
            if k==n:
                break
            #print(l)
            #print(i,j,LL,RR,k)
            #print(l[i]+l[j],l[k],l[k+1])
            if l[i]+l[j]>l[k] and l[i]+l[j]<=l[k+1]:
                cnt+=k-j
                break
            elif LL==RR:
                break
            elif l[i]+l[j]<=l[k]:
                RR=k
            elif l[i]+l[j]>l[k]:
                LL=k+1
            elif l[i]+l[j]<l[k] and k==j+1:
                break
        j+=1
    i+=1

print(cnt)

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

l.sort()


print(cnt)
Problem p02903 (python)

Fixed submission:
h,w,a,b=map(int,input().split())

#行に含まれる数はa、列に含まれる数はb
#行の並び替えは可能
#列の並び替えも可能

if b>h//2:
    print("No")
    exit()
if a>w//2:
    print("No")
    exit()


mapss=[[0]*w for _ in range(h)]

for y in range(b):
    for x in range(a):
        mapss[y][x]=1

for y in range(b,h):
    for x in range(a,w):
        mapss[y][x]=1


for item in mapss:
    print("".join(map(str,item)))

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

#行はa、列はb
#行の並び替えは可能
#列の並び替えも可能

mapss=[[0]*w for _ in range(h)]

for y in range(a):
    for x in range(b):
        mapss[y][x]=1

for y in range(a,h):
    for x in range(b,w):
        mapss[y][x]=1


for item in mapss:
    print(" ".join(map(str,item)))
Problem p02924 (python)

Fixed submission:
n=int(input())
sumNum=n*(n-1)//2
 
#print(r)
print(sumNum)

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

c=0
for i in range(1,n):
  if r[i-1]==r[i]:
    c+=1
  
print(min(n-1,c+2*k))
Problem p02936 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**8)

input=sys.stdin.readline

n,q=map(int,input().split())

tree=[[] for _ in range(n)]

for _ in range(n-1):
    a,b=map(int,input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

point=[0]*n
for _ in range(q):
    q,x=map(int,input().split())
    point[q-1]+=x

result=["no"]*n

def counter(chouten,count):
    global result,point,tree
    count+=point[chouten]
    result[chouten]=count

    #print(chouten,result)

    for item in tree[chouten]:
        if result[item]=="no":
            counter(item,count)

counter(0,0)

result=map(str,result)
print(" ".join(result))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**5)

input=sys.stdin.readline

n,q=map(int,input().split())

tree=[[] for _ in range(n)]

for _ in range(n-1):
    a,b=map(int,input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

point=[0]*n
for _ in range(q):
    q,x=map(int,input().split())
    point[q-1]+=x

result=[0]*n

def counter(chouten,count):
    global result,point,tree
    count+=point[chouten]
    result[chouten]=count

    #print(chouten,result)

    for item in tree[chouten]:
        if result[item]==0:
            counter(item,count)

counter(0,0)

result=map(str,result)
print(" ".join(result))

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

tree=[[] for _ in range(n)]

for _ in range(n-1):
    a,b=map(int,input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

point=[0]*n
for _ in range(q):
    q,x=map(int,input().split())
    point[q-1]+=x

result=[0]*n

def counter(chouten,count):
    global result,point,tree
    count+=point[chouten]
    result[chouten]=count

    #print(chouten,result)

    for item in tree[chouten]:
        if result[item]==0:
            counter(item,count)

counter(0,0)

result=map(str,result)
print(" ".join(result))
Problem p02945 (python)

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

print(max(a*b,a-b,a+b))

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

print(max([a*b,a-b,a+B]))

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

print(max(a*b,a-b,a+B))
Problem p02963 (python)

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

s=int(input())

#0<= x,y <=10**9
#s/2

if s<=10**9:
    print(0,0,1,0,0,s)
    exit()

y=(-1*s//(10**9))*(-1)
x=10**9*y-s

print(0,0,10**9,1,x,y)

Buggy submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline

s=int(input())

#0<= x,y <=10**9
#s/2

if s<=10**9:
    print(0,0,1,0,0,s)
    exit()

hoge=int(s**0.5)

for i in range(hoge):
    ss=i
    #print(ss)
    if s%ss==0 and s//ss<=10**9:
        print(0,0,ss,0,0,s//ss)
        exit()
Problem p02996 (python)

Fixed submission:
n=int(input())

ba=[]
for _ in range(n):
  a,b=map(int,input().split())
  ba.append([b,a])
  
ba.sort()

time=0
for item in ba:
  b=item[0]
  a=item[1]
  #print(a,b,time)
  
  time+=a
  if time>b:
    print("No")
    exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
n=int(input())

ba=[]
for _ in range(n):
  a,b=map(int,input().split())
  ba.append(b,a)
  
ba.sort()

time=0
for item in ba:
  b=item[0]
  a=item[1]
  
  time+=b
  if time>a:
    print("No")
    exit()
print("Yes")
Problem p03044 (python)

Fixed submission:
import sys
sys.setrecursionlimit(2147483647)



n=int(input())

uvw={}
tree=[[] for _ in range(n)]
for _ in range(n-1):
    u,v,w=list(map(int,input().split()))
    uvw[(u-1,v-1)]=w
    tree[u-1].append(v-1)
    tree[v-1].append(u-1)
    #u<v

result=[-1]*n
#print(tree)
def DEF(x,dis):
    #print("x",x)
    global tree, uvw,result
    for nextNode in tree[x]:
        if result[nextNode]==-1:
            nextDis=dis+uvw[(min(x,nextNode),max(x,nextNode))]
            if (nextDis)%2==0:
                result[nextNode]=0
                DEF(nextNode,nextDis)
            else:
                result[nextNode]=1
                DEF(nextNode,nextDis)
result[0]=0
DEF(0,0)

for item in result:
    print(item)

Buggy submission (verdict: Runtime Error):
n=int(input())

uvw={}
tree=[[] for _ in range(n)]
for _ in range(n-1):
    u,v,w=list(map(int,input().split()))
    uvw[(u-1,v-1)]=w
    tree[u-1].append(v-1)
    tree[v-1].append(u-1)
    #u<v

result=[-1]*n
#print(tree)
def DEF(x,dis):
    #print("x",x)
    global tree, uvw,result
    for nextNode in tree[x]:
        if result[nextNode]==-1:
            nextDis=dis+uvw[(min(x,nextNode),max(x,nextNode))]
            if (nextDis)%2==0:
                result[nextNode]=0
                DEF(nextNode,nextDis)
            else:
                result[nextNode]=1
                DEF(nextNode,nextDis)
result[0]=0
DEF(0,0)

for item in result:
    print(item)
Problem p03050 (python)

Fixed submission:
n=int(input())

#n=m*a+a
#n=(m+1)*a
#m>a

if n==1 or n==2:
    print(0)
    exit()

cnt=0
for i in range(1,int(n**(0.5))+1):
    if n%i==0:
        m=n//i-1
        if n%m==n//m:
            cnt+=m
print(cnt)

Buggy submission (verdict: Runtime Error):
n=int(input())

#n=m*a+a
#n=(m+1)*a
#m>a

cnt=0
for i in range(1,int(n**(0.5))+1):
    if n%i==0:
        m=n//i-1
        if n%m==n//m:
            cnt+=m
print(cnt)
Problem p03069 (python)

Fixed submission:
n=int(input())
s=input()
s=s

ll=0 #左側の黒い数を保持
rr=s.count(".") #右側の白い数を保持

result=ll+rr
for item in s:
    if item=="#":
        ll+=1
    else:
        rr-=1
    
    result=min(result,ll+rr)

print(result)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()

i=0
for ss in s:
  if ss=="#":
    break
  i+=1

s=s[i:]  
  
cnt=0
while s[-1]=="#":
  s=s[:-1]
  if s=="":
    print(0)
    exit()
  
print(min(s.count("."),s.count("#")))

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()

i=0
for ss in s:
  if ss=="#":
    break
  i+=1

s=s[i:]  
  
cnt=0
while s[-1]=="#":
  s=s[:-1]
  
print(min(s.count("."),s.count("#")))

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()

i=0
for ss in s:
  if ss=="#":
    break
  i+=1

s=s[i:]  
  
cnt=0
for i in range(1,n+1):  
  if s[-1*i]=="#":
    cnt+=1
  else:
    break
if cnt>0:
	s=s[:-1*cnt]
#print(s)
  
print(min(s.count("."),s.count("#")))

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()

i=0
for ss in s:
  if ss=="#":
    break
  i+=1

s=s[i:]  
  
cnt=0
for i in range(1,n+1):  
  if s[-1*i]=="#":
    cnt+=1
  else:
    break

s=s[:-1*cnt]
#print(s)
  
print(min(s.count("."),s.count("#")))
Problem p03071 (python)

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


print(max(a,b)+max(max(a,b)-1,min(a,b)))

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


print(max(a,b)+max(max(a,b)-1),min(a,b))
Problem p03096 (python)

Fixed submission:
n=int(input())
cc=[int(input()) for _ in range(n)]


c=[cc[0]]
for i in range(1,n):
    if cc[i]!=cc[i-1]:
        c.append(cc[i])

n=len(c)

right_index=[-1]*n
tmp_right_index=[-1]*(max(c)+1)

for i in range(n):
    if tmp_right_index[c[i]]==-1:
        tmp_right_index[c[i]]=i
    else:
        right_index[i]=tmp_right_index[c[i]]
        tmp_right_index[c[i]]=i

dp=[0]*n
mod=10**9+7
#print(0,c)
for i in range(n):
    if i==0:
        dp[i]=1
    else:
        if right_index[i]==-1:
            dp[i]+=dp[i-1]%mod
        else:
            dp[i]+=dp[i-1]+dp[right_index[i]]%mod

print(dp[-1]%mod)

Buggy submission (verdict: Runtime Error):
n=int(input())
cc=[int(input()) for _ in range(n)]


c=[cc[0]]
for i in range(1,n):
    if cc[i]!=cc[i-1]:
        c.append(cc[i])

n=len(c)

right_index=[-1]*n
tmp_right_index=[-1]*n

for i in range(n):
    if tmp_right_index[c[i]]==-1:
        tmp_right_index[c[i]]=i
    else:
        right_index[i]=tmp_right_index[c[i]]
        tmp_right_index[c[i]]=i

dp=[0]*n

#print(0,c)
for i in range(n):
    if i==0:
        dp[i]=1
    else:
        if right_index[i]==-1:
            dp[i]+=dp[i-1]
        else:
            dp[i]+=dp[i-1]+dp[right_index[i]]

print(dp[-1])
Problem p03145 (python)

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

aa=min(a,b)
bb=min(c,max(a,b))

print((aa*bb)//2)

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

aa=min(a,b)
bb=min(cc,max(a,b))

print((aa*bb)//2)
Problem p03163 (python)

Fixed submission:
n,w=map(int,input().split())


wv=[list(map(int, input().split())) for i in range(n)]
dp=[[0]*(w+1) for _ in range(n)]


for i in range(n):
    for j in range(w+1):
        if i==0:
            if j>=wv[i][0]:
                dp[i][j]=wv[i][1]
        else:
            if j< wv[i][0]:
                dp[i][j]=dp[i-1][j]
            else:
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-wv[i][0]]+wv[i][1])



print(dp[n-1][w])

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


wv=[list(map(int, input().split())) for i in range(n)]
dp=[[0]*(w+1) for _ in range(n)]


for i in range(n):
    for j in range(w+1):
        if i==0:
            if j>=wv[i][0]:
                dp[i][j]=wv[i][1]
        else:
            if j< wv[i][0]:
                dp[i][j]=dp[i-1][j]
            else:
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-wv[i][0]]+wv[i][1])



print(max(dp[n-1][w]))