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

Fixed submission:
A = int(input())
B = int(input())
 
print(6-A-B)	#和から誤答を引けば正答

Buggy submission (verdict: Runtime Error):
N = int(input())
S, T = input().split()
A = str()
 
for i in range(N):
    A += S[i]
    A += T[i]
    
print(A)

Buggy submission (verdict: Runtime Error):
N = int(input())
S, T = input().split()
A = str()				# ""にするとREになる
 
for i in range(N):
    A += S[i]
    A += T[i]
    
print(A)

Buggy submission (verdict: Runtime Error):
N = int(input())
S, T = input().split()
 
for i in range(N):
    A += S[i]
    A += T[i]
    
print(A)

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

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

Buggy submission (verdict: Runtime Error):
N = int(input())
S, T = input().split()
A = ''
 
for i in range(N):
    A += S[i] + T[i]
    
print(A)

Buggy submission (verdict: Runtime Error):
n = int(input())
s, t = input().split()
ans = ""
for i in range(n):
  ans += s[i] + t[i]
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s, t = input().split()
a = ""

for i in range(n):
    a += s[i] + t[i]
    
print(a)

Buggy submission (verdict: Runtime Error):
N = int(input())
S, T = input().split()
A = ""

for i in range(N):
    A += S[i] + T[i]
    
print(A)

Buggy submission (verdict: Runtime Error):
N = int(input())
S, T = input().split()
A = ""

for i in range(N):
    A += S[i]
    A += T[i]
    
print(A)

Buggy submission (verdict: Runtime Error):
N = int(input())
S, T = input().split()	#空白で区切る
A = ""

for i in range(N):	# :を忘れてハマった
    A += S[i]
    A += T[i]
    
print(A)
Problem p02916 (python)

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

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
m = 0
 
for i in range(n):
  m += b[a[i]-1]
  if i==0:
    continue
  if a[i] == a[i-1]+1:
    m += c[i]
    
print(m)
Problem p03013 (python)

Fixed submission:
n, m = map(int, input().split())
a = set([int(input()) for _ in range(m)])

dp = [0] * (n+1)
dp[0] = 1

if 1 in a:
    dp[1] = 0
else:
    dp[1] = 1

for i in range(2, n+1):
    if i in a:
        continue
    dp[i] = dp[i-1] + dp[i - 2]
    dp[i] %= 1000000007

print(dp[n])

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

for i in range(m):
    if m == 1:
        break
    if a[i+1] - a[i] == 1:
        print(0)
        exit()

dp = [0] * (n+1)
dp[0] = 1

if 1 in a:
    dp[1] = 0
else:
    dp[1] = 1

for i in range(2, n+1):
    if i in a:
        continue
    dp[i] = dp[i-1] + dp[i - 2]
    dp[i] %= 1000000007

print(dp[n])

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

for i in range(m):
    if a[i+1] - a[i] == 1:
        print(0)
        exit()

dp = [0] * (n+1)
dp[0] = 1

if 1 in a:
    dp[1] = 0
else:
    dp[1] = 1

for i in range(2, n+1):
    if i in a:
        continue
    dp[i] = dp[i-1] + dp[i - 2]
    dp[i] %= 1000000007

print(dp[n])
Problem p03038 (python)

Fixed submission:
from collections import Counter
n, m = map(int, input().split())
a = Counter(list(map(int, input().split())))

for i in range(m):
    b, c = map(int, input().split())
    a[c] += b

num = sorted(a.items(), key=lambda x: x[0], reverse=True)
ans = 0

for key, val in num:
    if n > val:
        ans += key * val
        n -= val
    else:
        ans += key * n
        break

print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque
n, m = map(int, input().split())
a = deque(map(int, input().split()))
b = [list(map(int, input().split())) for i in range(m)]

mn = min(a)
for i in b:
    if i[1] < mn:
        continue
    a = a + deque([i[1]] * i[0])

a = list(a)
a.sort(reverse=True)
print(sum(a[:n]))
Problem p03208 (python)

Fixed submission:
n, k = map(int, input().split())
h = list(int(input()) for _ in range(n))

h.sort()

m = 10 ** 9
for i in range(n-k+1):
    temp = h[i+k-1] - h[i]
    m = min(m, temp)

print(m)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
h = list(int(input()) for _ in range(n))

h.sort()

m = 10 ** 9
for i in range(n-2):
    temp = h[i+k-1] - h[i]
    m = min(m, temp)

print(m)
Problem p02781 (python)

Fixed submission:
n="0"+input()
x=len(n)
k=int(input())
l=[int(i) for i in n]

## dp1:top   dp2:under
dp1=[[0]*(k+2) for i in range(x)]
dp2=[[0]*(k+2) for i in range(x)]

dp1[0][0]=1
dp1[0][1]=0
dp2[0][0]=0
dp2[0][1]=0

cnt=0
for i in range(1,x):
    if l[i]>0:
        cnt+=1
    if cnt<=k:
        dp1[i][cnt]=1
for i in range(1,x):
    for j in range(k+1):
        if j==0:
            dp2[i][0]=1
        else:
            if l[i]==0: dp2[i][j]=(dp2[i-1][j-1]*9)+(dp2[i-1][j])+(dp1[i-1][j-1]*max(0,l[i]-1))
            else: dp2[i][j]=(dp2[i-1][j-1]*9)+(dp2[i-1][j])+(dp1[i-1][j-1]*max(0,l[i]-1))+(dp1[i-1][j])
print(dp1[-1][-2]+dp2[-1][-2])

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-

n=input()
x=len(n)
k=int(input())
l=[int(i) for i in n]
dp1=[[0]*(k+2) for i in range(x+1)]
dp2=[[0]*(k+2) for i in range(x+1)]
dp2[0][0]=1
dp2[1][0]=1
dp2[1][1]=l[0]-1
for i in range(1,k+1):
    dp1[i][i]=1
for i in range(k,x+1):
    dp1[i][k]=1
for i in range(2,x+1):
    for j in range(k+1):
        if j==0:
            dp2[i][j]=1
        elif j<=i:
            dp2[i][j]+=max(0,l[i-1]-1)
            dp2[i][j]+=((dp2[i-1][j])+(dp2[i-1][j-1]*9))
            #print(i,j,dp2[i-1][j],dp2[i-1][j-1]*9)
print(dp1[x][k]+dp2[x][k])
Problem p02912 (python)

Fixed submission:
import heapq
n,m=map(int,input().split())
q=[]
a=[-int(i) for i in input().split()]
for i in a:
    heapq.heappush(q,i)
ans=chk=0
for i in range(m):
    x=heapq.heappop(q)
    heapq.heappush(q,-(-x//2))
print(-sum(q))
exit()

Buggy submission (verdict: Runtime Error):
import heapq
n,m=map(int,input().split())
q=[]
a=[-int(i) for i in input().split()]
for i in a:
    heapq.heappush(q,(i,i,0))
ans=chk=0
while 1:
    f=1
    for i in range(m):
        x=heapq.heappop(q)
        j=-x[1]
        k=-q[0][1]
        if (i==m-1) or (j//(2**(i+1+x[2]))<k):
            f=0
            heapq.heappush(q,(-(j//(2**(i+1+x[2]))),x[1],x[2]+i+1))
            m-=(i+1)
            break
    if f:
        break
for i in q:
    ans+=-i[0]
print(ans)
Problem p02948 (python)

Fixed submission:
#from https://atcoder.jp/contests/abc137/submissions/6808061
import heapq
import sys
input=sys.stdin.readline

def sol():
    n,m=map(int,input().split())
    d=[]
    for i in range(n):
        a,b=map(int,input().split())
        if a<=m: d.append((a,b))
    d.sort(reverse=True)
    q=[]
    ans=0
    for i in range(1,m+1):
        while d and d[-1][0]<=i:
            a,b=d.pop()
            heapq.heappush(q,-b)
        if q:
            ans += -heapq.heappop(q)
    print(ans)

if __name__=="__main__":
    sol()

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

def sol():
    n,m=map(int,input().split())
    d=[]
    ans=[0]*(m+1)
    t=0
    ans[0]=1
    y=m
    for i in range(n):
        a,b=map(int,input().split())
        d.append((b,a))
    d.sort(reverse=True)
    for bb,aa in d:
        if max(ans.index(0),aa)==y:
            ans[y]=1
            t+=bb
            y-=1
        else:
            for j in range(max(ans.index(0),aa),y+1):
                if ans[j]==0:
                    ans[j]=1
                    t+=bb
                    break

    print(t)

if __name__=="__main__":
    sol()
Problem p03015 (python)

Fixed submission:
# from https://atcoder.jp/contests/abc129/submissions/5845940
mod=1000000007
s=input()
chk=ans=0

for i,j in enumerate(s):
    if j=='0': continue
    chk+=1
    rest=len(s)-i-1
    ans+=pow(2,chk-1,mod) * pow(3,rest,mod) % mod
    ans%=mod
ans+=pow(2,chk,mod)
print(ans%mod)

Buggy submission (verdict: Runtime Error):
# from https://atcoder.jp/contests/abc129/submissions/5845940
mod=1000000007
s=input()
chk=ans=0

for i,j in enumerate(s):
    if j=='0': continue
    chk+=1
    rest=n-i-1
    ans+=pow(2,chk-1,mod) * pow(3,rest,mod) % mod
    ans%=mod
ans+=pow(2,chk,mod)
print(ans%mod)
Problem p03045 (python)

Fixed submission:
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-

class UnionFind:
    def __init__(self, size):
        self.rank=[0]*size
        self.par =[int(i) for i in range(size)]
        self.grp =size

    def find(self, x):
        if x==self.par[x]: return x

        self.par[x]=self.find(self.par[x])
        return self.par[x]

    def same(self, x, y): #2つの頂点が同じグループであるかを判定する
        return self.find(x)==self.find(y)

    def unite(self, x, y): #辺で接続されている2つの頂点を投げて統合する
        x,y=self.find(x),self.find(y)
        if x==y:
            return

        self.grp-=1
        if self.rank[x]<self.rank[y]:
            self.par[x]=y
        else:
            self.par[y]=x
            if self.rank[x]==self.rank[y]:
                self.rank[x]+=1

    def group_num(self):
        return self.grp


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

uf=UnionFind(n)

for i in range(m):
    x,y,z=map(int, input().split())
    uf.unite(x-1,y-1)

print(uf.grp)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-

class UnionFind:
    def __init__(self, size):
        self.rank=[0]*size
        self.par =[int(i) for i in range(size)]
        self.grp =size

    def find(self, x):
        if x==self.par[x]: return x

        self.par[x]=self.find(self.par[x])
        return self.par[x]

    def same(self, x, y): 
        return self.find(x)==self.find(y)

    def unite(self, x, y):
        x,y=self.find(x),self.find(y)
        if x==y:
            return

        self.grp-=1
        if self.rank[x]<self.rank[y]:
            self.par[x]=y
        else:
            self.par[y]=x
            if self.rank[x]==self.rank[y]:
                self.rank[x]+=1

    def group_num(self):
        return self.grp



n,m=map(int,input().split())
uf=UnionFind(n)
ans=chk=0
w=collections.deque()
for i in range(m):
    x,y,z=map(int,input().split())
    uf.unite(x,y)
print(uf.group_num)
Problem p03137 (python)

Fixed submission:
n,m=map(int,input().split())
l=[int(i) for i in input().split()]
l.sort()
ans=[0]
for i in range(m-1):
    ans.append(l[i+1]-l[i])
ans.sort()
for i in range(n-1):
    if len(ans)==1: break
    ans.pop()
print(sum(ans))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=[int(i) for i in input().split()]
l.sort()
ans=[0]
for i in range(m-1):
    ans.append(l[i+1]-l[i])
ans.sort()
for i in range(n-1):
    ans.pop()
    if len(ans)==1: break
print(sum(ans))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=[int(i) for i in input().split()]
l.sort()
ans=[0]
for i in range(m-1):
    ans.append(l[i+1]-l[i])
ans.sort()
for i in range(n-1): ans.pop()
print(sum(ans))
Problem p03201 (python)

Fixed submission:
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
d={}
for i in a:
    if i in d:
        d[i]+=1
    else:
        d[i]=1
p=max(a)*2
chk=[pow(2,i) for i in range(1,32) if pow(2,i)<=p]
ans=0
for i in a[::-1]:
    if d[i]>0:
        d[i]-=1
        for j in chk[::-1]:
            if j-i in d and d[j-i]>0:
                d[j-i]-=1
                ans+=1
                break
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
ans=0
for i in range(n-1):
    for j in range(i+1,n):
        if "1" not in bin(t)[3:]:
            ans+=1
print(len(ans))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
for i in range(n-1):
    for j in range(i+1,n):
        if "1" not in bin(t)[3:]:
            ans+=1
print(len(ans))
Problem p03252 (python)

Fixed submission:
s=input()
t=input()
a,b={},{}
cnt=1
for i in s:
    if i not in a:
        a[i]=cnt
        cnt+=1
cnt=1
for i in t:
    if i not in b:
        b[i]=cnt
        cnt+=1

for i in range(len(s)):
    if a[s[i]]!=b[t[i]]:
        print("No")
        exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
s=input()
t=input()
a,b={},{}
cnt=1

for i in range(len(s)):
    if s[i] not in a and t[i] not in b:
        a[s[i]]=cnt
        b[t[i]]=cnt
        ant+=1
    elif s[i] in a and t[i] in b and (a[s[i]]==b[t[i]]):
        pass
    else
        print("No")
        exit()
print("Yes")
Problem p03291 (python)

Fixed submission:
mod=1000000007

s=input()
x=len(s)
dp=[[0 for i in range(4)] for j in range(100005)]
for i in range(x,-1,-1):
    for j in range(3,-1,-1):
        if i==x:
            dp[i][j]=[0,1][j==3]
        else:
            dp[i][j]=dp[i+1][j]*([1,3][s[i]=="?"])
            if (j<3 and (s[i]=="?" or s[i]=="ABC"[j])):
                dp[i][j]+=dp[i+1][j+1]
            dp[i][j]%=mod
print(dp[0][0])

Buggy submission (verdict: Runtime Error):
s=input()
x=len(s)
dp=[[0 for i in range(4)] for j in range(100005)]
for i in range(x,-1,-1):
    for j in range(3,-1,-1):
        if i==x:
            dp[i][j]=[0,1][j==3]
        else:
            dp[i][j]=dp[i+1][j]*([1,3][s[i]=="?"])
            if (j<3 and (s[i]=="?" or s[i]=="ABC"[j])):
                dp[i][j]+=dp[i+1][j+1]
            dp[i][j]%=mod
print(dp[0][0])
Problem p03295 (python)

Fixed submission:
n,m=map(int,input().split())
w=[]
for i in range(m):
    a,b=map(int,input().split())
    w.append((a,b))
w.sort(reverse=True)
d=[]
for i in range(m):
    a,b=w.pop()
    if i==0:
        d.append([a,b])
    else:
        if d[-1][1]<=a:
            d.append([a,b])
        elif d[-1][1]>b:
            d[-1][1]=b
print(len(d))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
w=[]
if n<99:
    print(w[1])
for i in range(m):
    a,b=map(int,input().split())
    w.append((a,b))
w.sort(reverse=True)
d=[]
for i in range(m):
    a,b=w.pop()
    if i==0:
        d.append([a,b])
    else:
        if d[-1][1]<=a:
            d.append([a,b])
        elif d[-1][1]>b:
            d[-1][1]=b
print(len(d))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
w=[]
if n>99:
    print(w[1])
for i in range(m):
    a,b=map(int,input().split())
    w.append((a,b))
w.sort(reverse=True)
d=[]
for i in range(m):
    a,b=w.pop()
    if i==0:
        d.append([a,b])
    else:
        if d[-1][1]<=a:
            d.append([a,b])
        elif d[-1][1]>b:
            d[-1][1]=b
print(len(d))
Problem p03464 (python)

Fixed submission:
k=int(input())
a=[int(i) for i in input().split()]
l=2
r=3
for i in range(k-1,-1,-1):
    l=(l+a[i]-1)//a[i]*a[i]
    r=(r+a[i]-1)//a[i]*a[i]
if l==r:
    print(-1)
else:
    print(l,r-1)

Buggy submission (verdict: Runtime Error):
k=int(input())
a=[int(i) for i in input().split()]
chk=2
if a[-1]!=2:
    print(-1)
    exit()
else:
    for i in range(k-1,0,-1):
        if a[i-1]>=a[i]*2:
            print(-1)
            exit()
    print(chk[2])

Buggy submission (verdict: Runtime Error):
k=int(input())
a=[int(i) for i in input().split()]
chk=2
if a[-1]!=2:
    print(-1)
    exit()
else:
    for i in range(n-1,0,-1):
        if a[i-1]>=a[i]*2:
            print(-1)
            exit()
    print(chk[2])

Buggy submission (verdict: Runtime Error):
k=int(input())
a=[int(i) for i in input().split()]
chk=2
if a[-1]!=2:
    print(-1)
    exit()
else:
    print(chk[2])

Buggy submission (verdict: Runtime Error):
k=int(input())
a=[int0(i) for i in input().split()]
ans=0
chk=2
if a[-1]!=2:
  print(-1)
  exit()
elif k==1 and a[0]==2:
  print(2,3)
  exit()
for i in range(k-1,1,-1):
  if a[i]>=chk*2:
    print(-1)
    exit()
    
  if a[i]<chk:
    a[i]=(a[i]+chk)//a[i]*a[i]
  chk=a[i]
print(a[0],(a[0]+a[1]*2)//a[0]*a[0]-1)

Buggy submission (verdict: Runtime Error):
k=int(input())
a=[int(i) for i in input().split()]
ans=0
chk=2
if a[-1]!=2:
  print(-1)
  exit()
elif k==1 and a[0]==2:
  print(2,2)
  exit()
for i in range(n-1,-1,-1):
  if a[i]>=chk*2:
    print(-1)
    exit()
  if a[i]<chk:
    a[i]=(a[i]+chk)//a[i]*a[i]
    chk=a[i]
print(a[0],a[1]*2-1)

Buggy submission (verdict: Runtime Error):
k=int(input())
a=[int(i) for i in input().split()]
ans=0
chk=2
if a[-1]!=2:
    print(-1)
    exit()
elif k==1 and a[0]==2:
  print(2,2)
  exit()
for i in range(n-1,-1,-1):
  if a[i]>=chk*2:
    print(-1)
    exit()
  if a[i]<chk:
    a[i]=(a[i]+chk)//a[i]*a[i]
    chk=a[i]
print(a[0],a[1]*2-1)

Buggy submission (verdict: Runtime Error):
k=int(input())
a=[int(i) for i in input().split()]
ans=0
chk=0
if a[-1]!=2:
    print(-1)
else:
    print(ans[1])
Problem p03634 (python)

Fixed submission:
from collections import deque
n=int(input())
l=[0]*n
d={}
for i in range(n-1):
    a,b,c=map(int,input().split())
    a-=1
    b-=1
    if a in d:
        d[a].add((b,c))
    else:
        d[a]={(b,c)}
    if b in d:
        d[b].add((a,c))
    else:
        d[b]={(a,c)}
q,k=map(int,input().split())
k-=1
p=deque([k])
while len(p):
    w=p.popleft()
    for i in d[w]:
        if (l[i[0]]==0 and i[0]!=k) or (l[i[0]]!=0 and l[i[0]]>l[w]+i[1]):
            l[i[0]]=l[w]+i[1]
            p.append(i[0])

for i in range(q):
    x,y=map(int,input().split())
    print(l[x-1]+l[y-1])

Buggy submission (verdict: Runtime Error):
from collections import deque

def main()
    n=int(input())
    l=[0]*n
    d={}
    for i in range(n-1):
        a,b,c=map(int,input().split())
        a-=1
        b-=1
        if a in d:
            d[a].add((b,c))
        else:
            d[a]={(b,c)}
        if b in d:
            d[b].add((a,c))
        else:
            d[b]={(a,c)}
    q,k=map(int,input().split())
    k-=1
    p=deque([k])
    while len(p):
        w=p.popleft()
        for i in d[w]:
            if (l[i[0]]==0 and i[0]!=k) or (l[i[0]]!=0 and l[i[0]]>l[w]+i[1]):
                l[i[0]]=l[w]+i[1]
                p.append(i[0])

    for i in range(q):
        x,y=map(int,input().split())
        print(l[x-1]+l[y-1])
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main()
    n=int(input())
    l=[0]*n
    d={}
    for i in range(n-1):
        a,b,c=map(int,input().split())
        a-=1
        b-=1
        if a in d:
            d[a].add((b,c))
        else:
            d[a]={(b,c)}
        if b in d:
            d[b].add((a,c))
        else:
            d[b]={(a,c)}
    q,k=map(int,input().split())
    k-=1
    p=deque([k])
    while len(p):
        w=p.popleft()
        for i in d[w]:
            if (l[i[0]]==0 and i[0]!=k) or (l[i[0]]!=0 and l[i[0]]>l[w]+i[1]):
                l[i[0]]=l[w]+i[1]
                p.append(i[0])

    for i in range(q):
        x,y=map(int,input().split())
        print(l[x-1]+l[y-1])
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from collections import deque
n=int(input())
l=[0]*n
d={}
for i in range(n-1):
    a,b,c=map(int,input().split())
    a-=1
    b-=1
    if a in d:
        d[a].add((b,c))
    else:
        d[a]={(b,c)}
    if b in d:
        d[b].add((a,c))
    else:
        d[b]={(a,c)}
q,k=map(int,input().split())
k-=1
p=deque([k])
while len(p):
    w=p.popleft()
    for i in d[w]:
        if (l[i[0]]==0 and i[0]!=k) or (l[i[0]]!=0 and l[i[0]]>l[w]+l[i[1]]):
            print(i)
            l[i[0]]=l[w]+i[1]
            p.append(i[0])

for i in range(q):
    x,y=map(int,input().split())
    print(l[x-1]+l[y-1])
Problem p03776 (python)

Fixed submission:
def pscl(num,l=[1]):
    for i in range(num):
        l = map(lambda x,y:x+y,[0]+l,l+[0])
    return l

n,a,b=map(int,raw_input().split())
v=[int(i) for i in raw_input().split()]
chk=[i for i in set(v)]
chk.sort()
if len(chk)==1:
    print chk[0]*1.0
    print sum(pscl(n)[a:b+1])
    exit()
d={}
for i in v:
    if i in d:
        d[i]+=1
    else:
        d[i]=1
total=ans=tmp=0
t=a
for p,i in enumerate(chk[::-1]):
    if d[i]<t:
        total=total+i*d[i]
        t=t-d[i]
    elif p==0 and d[i]>=t:
        print i*1.0
        print sum(pscl(d[i])[a:min(b,d[i])+1])
        break
    else:
        total=total+i*t
        print total*1.0/a
        print pscl(d[i])[t]
        break

Buggy submission (verdict: Runtime Error):
def pscl(num,l=[1]):
    for i in range(num):
        l = map(lambda x,y:x+y,[0]+l,l+[0])
    return l

n,a,b=map(int,raw_input().split())
v=[int(i) for i in raw_input().split()]
chk=[i for i in set(v)]
chk.sort()
if len(chk)==1:
    print chk[0]*1.0
    print sum(pscl(n)[a:b+1])
    exit()
d={}
for i in v:
    if i in d:
        d[i]+=1
    else:
        d[i]=1
total=ans=tmp=0
t=a
for i in chk[::-1]:
    if d[i]<t:
        total=total+i*d[i]
        t=t-d[i]
    else:
        total=total+i*t
        print total*1.0/a
       # print d,t,d[i],b-(a-t),pscl(d[i])
        #print sum(pscl(d[i])[t:min(d[i],b-(a-t))+[0,1][d[i]>b-(a-t)]])
        print pscl(d[i][t])
        break
Problem p03806 (python)

Fixed submission:
mod=1777777777
n,ma,mb=map(int,input().split())
d=[[mod for j in range(100)] for i in range(100)]
for i in range(n):
    a,b,c=map(int,input().split())
    x=a
    y=b
    for j in range(100-a-1,0,-1):
        for k in range(100-b-1,0,-1):
            if d[j][k]!=mod:
                d[j+a][k+b]=min(d[j+a][k+b],d[j][k]+c)
    d[x][y]=min(d[x][y],c)
ans=mod
for i in range(100):
    if i%ma==0 and mb*i//ma<100:
        ans=min(ans,d[i][mb*i//ma])

print([ans,-1][ans==mod])

Buggy submission (verdict: Runtime Error):
mod=1777777777
n,ma,mb=map(int,input().split())
d=[[mod for j in range(100)] for i in range(100)]
for i in range(n):
    a,b,c=map(int,input().split())
    x=a
    y=b
    for j in range(100-a,0,-1):
        for k in range(100-b,0,-1):
            if d[j][k]!=mod:
                d[j+a][k+b]=min(d[j+a][k+b],d[j][k]+c)
    d[x][y]=min(d[x][y],c)
ans=mod
for i in range(100):
    if i%ma==0 and mb*i//ma<100:
        ans=min(ans,d[i][mb*i//ma])

print([ans,-1][ans==mod])

Buggy submission (verdict: Runtime Error):
mod=1777777777
n,ma,mb=map(int,input().split())
d=[[mod for j in range(100)] for i in range(100)]
for i in range(n):
    a,b,c=map(int,input().split())
    x=a
    y=b
    for j in range(100-a,0,-1):
        for k in range(100-b-1,0,-1):
            if d[j][k]!=mod:
                d[j+a][k+b]=min(d[j+a][k+b],d[j][k]+c)
    d[x][y]=min(d[x][y],c)
ans=mod
for i in range(100):
    if i%ma==0 and mb*i//ma<100:
        ans=min(ans,d[i][mb*i//ma])

print([ans,-1][ans==mod])

Buggy submission (verdict: Runtime Error):
mod=1777777777
n,ma,mb=map(int,input().split())
d=[[mod for j in range(100)] for i in range(100)]
for i in range(n):
    a,b,c=map(int,input().split())
    x=a
    y=b
    d[x][y]=min(d[x][y],c)
    for j in range(100-a):
        for k in range(100-b):
            if d[j][k]!=mod:
                d[j+a][k+b]=min(d[j+a][k+b],d[j][k]+c)
ans=mod
for i in range(100):
    if i%a==0:
        ans=min(ans,d[i][b*i//a])

print([ans,-1][ans==mod])
Problem p02572 (python)

Fixed submission:
import sys
stdin = sys.stdin

def main():
    n = int(stdin.readline().rstrip())
    ls = list(map(int, stdin.readline().split()))
    ans = 0
    m = 10**9 + 7
    sum1 = sum(ls)%m
    for i in range(n-1):
        sum1 = sum1-ls[i]
        ans = ((sum1 * ls[i])+ans) % m
    print(ans)

if __name__ == '__main__':
    main()

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

def main():
    n = int(stdin.readline().rstrip())
    ls = list(map(int, stdin.readline().split()))
    lsm = list(set(ls))
    m = len(lsm)
    ans = 0
    for i in range(n-1):
        for j in range(i+1, n):
            ans = (ans + lsm[i] * lsm[j]) % (10**9 + 7)
    print(ans)

if __name__ == '__main__':
    main()