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

Fixed submission:
import math
import collections
import fractions
import itertools
import decimal

def solve():
    a, b = input().split()
    a = decimal.Decimal(a)
    b = decimal.Decimal(b)
    print(int(a*b))
    return 0

if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
def iput(): return int(input())
def mput(): return map(int, input().split())
def lput(): return list(map(int, input().split()))
 
def solve():
    n = iput()
    a = lput()
    ans = 1
    for i in range(n):
        ans *= a[i]
        if a[i] == 0:
          print(0)
          break
    if ans > 10**18:
        print(-1)
    else:
        print(ans)
    return 0
 
if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
def solve():
    a, b = input().split()
    a = int(a)
    b = float(b)
    print(math.floor(a*b))
    return 0

if __name__ == "__main__":
    solve()
Problem p02695 (python)

Fixed submission:
import numpy as np
import math
import scipy
import itertools

def score(arr):
    hoge = 0
    for ai, bi, ci, di in zip(a, b, c, d):
        if arr[bi-1] - arr[ai-1] == ci:
            hoge += di
    return hoge

def dfs(arr):
    if len(arr) == n:
        return score(arr)
    res = 0
    prev_last = arr[-1] if len(arr) > 0 else 0
    for v in range(prev_last, m):
        arr.append(v)
        res = max(res, dfs(arr))
        arr.pop()
    return res

def solve():
    global a, b, c, d, n, m, q
    n, m, q = map(int, input().split())
    a, b, c, d = [0]*q, [0]*q, [0]*q, [0]*q
    for i in range(q):
        a[i], b[i], c[i], d[i] = map(int, input().split())
    print(dfs([]))
    return 0

if __name__ == "__main__":
    solve()

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

def score(arr):
    hoge = 0
    for ai,bi,ci,di in zip(a, b, c, d):
        if arr[bi-1]-arr[ai-1] == ci:
            hoge += di
    return hoge

def dfs(arr):
    if len(arr) == n:
        return score(arr)
    last = arr[-1] if len(arr) > 0 else 0
    res = 0
    for i in range(last, m+1):
        a.append(i)
        res = max(res, dfs(arr))
        a.pop()
    return res

def solve():
    global a, b, c, d, n, m, q
    n, m, q = map(int, input().split())
    a, b, c, d = [0]*q, [0]*q, [0]*q, [0]*q
    for i in range(q):
        a[i], b[i], c[i], d[i] = map(int, input().split())
    print(dfs([]))
    return 0

if __name__ == "__main__":
    solve()
Problem p02699 (python)

Fixed submission:
import itertools

def solve():
  s, w = map(int, input().split())
  if s > w:
    print("safe")
  else:
    print("unsafe")
  return 0
 
if __name__ == "__main__":
  solve()

Buggy submission (verdict: Runtime Error):
import math
import collections
import fractions
import itertools
 
def solve():
    n = int(input())
    s = [input() for i in range(n)]
    print(len(set(s)))
    return 0
 
if __name__ == '__main__':
    solve()
Problem p02729 (python)

Fixed submission:
import itertools

def solve():
  n, m = map(int, input().split())
  a = len(list(itertools.combinations(range(n), 2)))
  b = len(list(itertools.combinations(range(m), 2)))
  print(a + b)
  return 0

if __name__ == "__main__":
  solve()

Buggy submission (verdict: Runtime Error):
import functools
import math
import collections
import scipy
import fractions
import itertools

def solve():
  n = int(input())
  a = list(map(int, input().split()))
  c = collections.Counter(a)
  s = 0
  for i in list(c.values()):
    s += i*(i-1)//2
  print(c)
  for i in a:
    print(c[i])
    print(s-(c[i]-1))
  return 0
 
if __name__ == "__main__":
  solve()
Problem p02880 (python)

Fixed submission:
import math
from functools import reduce
import itertools
import numpy as np

def solve():
    n = int(input())
    num = list(range(1,10))
    bit = 0
    for i in num:
        for j in num:
            if i * j == n:
                print("Yes")
                bit = 1
                break
        if bit == 1:
            break
    if bit == 0:
        print("No")
    return 0

if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
import itertools
import numpy as np

def solve():
    n = int(input())
    num = list(range(1,10))
    bit = 0
    for i in num:
        for j in num:
            if i * j == n:
                print("Yes")
                bit = 1
                break
    i bit == 0:
        print("No")
    return 0

if __name__ == "__main__":
    solve()
Problem p03017 (python)

Fixed submission:
import math
import collections
import fractions
import itertools
import functools
import  operator

def solve():
    n, a, b, c, d = map(int, input().split())
    s = input()
    for i in range(a, max(c,d)):
        if s[i-1:i+1] == "##":
            print("No")
            exit()
    if c < d:
        print("Yes")
        exit()
    for i in range(b-1, d):
        if s[i-1:i+2] == "...":
            print("Yes")
            exit()
    print("No")
    return 0

if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
import math
import collections
import fractions
import itertools
import functools
import  operator

def solve():
    n, a, b, c, d = map(int, input().split())
    s = input()
    for i in range(a, max(c,d)):
        if s[i-1:i+1] = "##":
            print("No")
            exit()
    if c > d:
        print("Yes")
        break
    for i in range(b-1, d):
        if s[i-1:i+2] == "...":
            print("Yes")
            exit()
    print("No")
    return 0

if __name__ == "__main__":
    solve()
Problem p03072 (python)

Fixed submission:
import numpy as np
import math
import collections
import fractions
import itertools

def solve():
    n = int(input())
    h = list(map(int, input().split()))
    m = h[0]
    ans = 0
    for i in range(1,n):
        if h[i] >= m:
            ans += 1
            m = h[i]
    print(ans+1)
    return 0

if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
import numpy as np
import math
import collections
import fractions
import itertools

def solve():
    n = int(input())
    h = list(map(int, input().split()))
    m = h[0]
    ans = 0
    for i in range(1,h-1):
        if h[i] >= m:
            ans += 1
            m = h[i]
    print(ans)
    return 0

if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
import numpy as np
import math
import collections
import fractions
import itertools

def solve():
    n = int(input)
    h = list(map(int, input().split()))
    m = h[0]
    ans = 0
    for i in range(1,h-1):
        if h[i] >= m:
            ans += 1
            m = h[i]
    print(ans)
    return 0

if __name__ == '__main__':
    solve()
Problem p03137 (python)

Fixed submission:
import math
import collections
import fractions
import itertools

def solve():
    n, m = map(int, input().split())
    x = list(map(int, input().split()))
    x.sort()
    if n >= m:
        print(0)
    else:
        diff = [abs(x[i] - x[i+1]) for i in range(m-1)]
        diff.sort(reverse=True)
        ans = sum(diff)
        for i in range(n-1):
            ans -= diff[i]
        print(ans)
    return 0

if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
import math
import collections
import fractions
import itertools

def solve():
    n, m = map(int, input().split())
    x = list(map(int, input().split()))
    x.sort()
    if n >= m:
        print(0)
    else:
        diff = [abs(x[i] - x[i+1]) for i in range(m-1)]
        diff.sort(reverse=True)
        ans = sum(diff)
        for i in range(n-1):
            ans -= diff[i]
    print(ans)
    return 0

if __name__ == "__main__":
    solve()
Problem p03745 (python)

Fixed submission:
def solve():
  n = int(input())
  a = list(map(int, input().split()))
  g, z = 0, 0
  cut = 1
  for i in range(n-1):
    if a[i+1] > a[i]:
      g += 1
    elif a[i+1] < a[i]:
      z += 1
    if g != 0 and z != 0:
      cut += 1
      g, z = 0, 0
  print(cut)
  return 0
 
if __name__ == "__main__":
  solve()

Buggy submission (verdict: Runtime Error):
def solve():
  n = int(input())
  a = list(map(int, input().split()))
  g, z = 0, 0
  cut = 1
  for i in range(n-1):
    if a[i+1] > a[i]:
      g += 1
    elif a[i+1] < a[i]:
      z += 1
    if g != 0 and z != 0:
      ans += 1
      g, z = 0, 0
  print(ans)
  return 0
 
if __name__ == "__main__":
  solve()
Problem p03821 (python)

Fixed submission:
import numpy as np
import math
import collections
import fractions
import itertools

def iput(): return int(input())
def mput(): return map(int, input().split())
def lput(): return list(map(int, input().split()))

def solve():
    n = int(input())
    cost = 0
    a, b = [0]*n, [0]*n
    for i in range(n):
        a[i], b[i] = mput()
    inc = 0
    for i in range(n-1, -1, -1):
        a[i] += inc
        mult = math.ceil(a[i]/b[i])*b[i]
        cost += mult - a[i]
        inc += mult - a[i]
    print(cost)
    return 0

if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
import numpy as np
import math
import collections
import fractions
import itertools

def iput(): return int(input())
def mput(): return map(int, input().split())
def lput(): return list(map(int, input().split()))

def solve():
    n = int(input())
    cost = 0
    a, b = [0]*n, [0]*n
    for i in range(n):
        a[i], b[i] = mput()
    for i in range(n-1, -1, -1):
        mult = math.ceil(a[i]/b[i])*b[i]
        cost += mult - a[i]
        for j in range(0, i+1):
            a[j] += mult - a[i]
    print(cost)
    return 0

if __name__ == "__main__":
    solve()
Problem p02546 (python)

Fixed submission:
s=input()
if s[len(s)-1] =="s":
	print(s + "es")
else:
	print(s + "s")

Buggy submission (verdict: Runtime Error):
s=sys.stdin
if s[len(s)-1] =="s":
	print(s + "es")
else:
	print(s + "s")
Problem p02679 (python)

Fixed submission:
import collections
from math import gcd
import sys
input=sys.stdin.readline
def main():
    n=int(input())
    c=collections.Counter()
    mod=10**9+7
    for _ in range(n):
        a,b=map(int,input().split())
        g=abs(gcd(a,b))
        if g==0:
            g=1
        a//=g
        b//=g
        c[(a,b)]+=1
    ans=1
    s=set()
    for i,j in c:
        if (i,j)==(0,0):
            continue
        if (i,j) not in s:
            s.add((i,j))
            s.add((-i,-j))
            s.add((-j,i))
            s.add((j,-i))
            ans*=(pow(2,c[(i,j)]+c[(-i,-j)],mod)+pow(2,c[(j,-i)]+c[(-j,i)],mod)-1)%mod
    print((ans-1+c[(0,0)])%mod)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
n=int(input())
import collections
c=collections.Counter()
from math import gcd
mod=10**9+7
for _ in range(n):
    a,b=map(int,input().split())
    g=abs(gcd(a,b))
    a//=g
    b//=g
    c[(a,b)]+=1
ans=1
s=set()
for i,j in c:
    if (i,j) not in s:
        s.add((i,j))
        s.add((-i,-j))
        s.add((-j,i))
        s.add((j,-i))
        ans*=(pow(2,c[(i,j)]+c[(-i,-j)],mod)+pow(2,c[(j,-i)]+c[(-j,i)],mod)-1)%mod
print((ans-1)%mod)

Buggy submission (verdict: Runtime Error):
n=int(input())
import collections
c=collections.Counter()
def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)
mod=10**9+7
for _ in range(n):
    a,b=map(int,input().split())
    g=abs(gcd(a,b))
    a//=g
    b//=g
    c[(a,b)]+=1
ans=1
s=set()
for i,j in c:
    if (i,j) not in s:
        s.add((i,j))
        s.add((-i,-j))
        s.add((-j,i))
        s.add((j,-i))
        ans*=(pow(2,c[(i,j)]+c[(-i,-j)],mod)+pow(2,c[(j,-i)]+c[(-j,i)],mod)-1)%mod
print(ans-1)
Problem p02729 (python)

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

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
print(a*(a-1)//2+b(b-1)//2)
Problem p02763 (python)

Fixed submission:
n=int(input())+1
data=[0]*n*2
def update(i,x):
    i+=n
    data[i]=x
    i//=2
    while i:
        data[i]=data[i*2]|data[i*2+1]
        i//=2
def query(l,r):
    l+=n
    r+=n
    s=0
    while l<r:
        if l&1:
            s|=data[l]
            l+=1
        if r&1:
            r-=1
            s|=data[r]
        l//=2
        r//=2
    return sum(map(int,bin(s)[2:]))
s=input()
for i,c in enumerate(s,n):
    data[i]=1<<(ord(c)-97)
for i in range(n-1,0,-1):
    data[i]=data[2*i]|data[2*i+1]
for _ in range(int(input())):
    q,a,b=input().split()
    if q=="2":
        print(query(int(a)-1,int(b)))
    else:
        update(int(a)-1,1<<(ord(b)-97))

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
from collections import Counter
l=Counter()
for i,c in enumerate(list(s)):
    if not l[c]:
        l[c]=[]
    l[c].append(i)

for j in l:
    l[j].append(10**18)
q=int(input())
import bisect
for i in range(q):
    a,b,c=input().split()
    if a=="1":
        b=int(b)-1
        idx=bisect.bisect_left(l[s[b]],b)
        del l[s[b]][idx]
        if not l[c]:
            l[c]=[]
        idx=bisect.bisect_left(l[c],b)
        l[c].insert(idx,b)
        l[c].append(10**18)
    else:
        ans=0
        left,right=int(b)-1,int(c)-1
        for j in l:
            p=bisect.bisect_left(l[j],left)
            q=bisect.bisect_left(l[j],right)
            if p!=q:
                ans+=1
            else:
                if l[j]!=[]:
                    if left<=l[j][p]<=right:
                        ans+=1
        print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
from collections import Counter
l=Counter()
for i,c in enumerate(list(s)):
    if not l[c]:
        l[c]=[]
    l[c].append(i)

for j in l:
    l[j].append(10**18)
q=int(input())
import bisect
for i in range(q):
    a,b,c=input().split()
    if a=="1":
        b=int(b)-1
        idx=bisect.bisect_left(l[s[b]],b)
        del l[s[b]][idx]
        if not l[c]:
            l[c]=[]
        idx=bisect.bisect_left(l[c],b)
        l[c].insert(idx,b)
        l[c].append(10**18)
    else:
        ans=0
        left,right=int(b)-1,int(c)-1
        for j in l:
            p=bisect.bisect_left(l[j],left)
            q=bisect.bisect_left(l[j],right)
            if p!=q:
                ans+=1
            else:
                if l[j]!=[]:
                    if left<=l[j][p]<=right:
                        ans+=1
        print(ans)
Problem p02793 (python)

Fixed submission:
n=int(input())
a=[int(j) for j in input().split()]
t=1
mod=10**9+7
def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)
for i in a:
    t*=i//gcd(t,i)
print(sum(t//i for i in a)%mod)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(j) for j in input().split()]
t=1
mod=10**9+7
import math
for i in a:
    t*=i//math.gcd(t,i)
print(sum(t//i for i in a)%mod)
Problem p02948 (python)

Fixed submission:
n,m=map(int,input().split())
ab=[]
l=[[] for i in range(m+1)]
for i in range(n):
    tmp=[int(j) for j in input().split()]
    ab.append(tmp)
    a,b=tmp
    if a<=m:
        l[a].append(b)
import heapq
q=[]
ans=0
for i in range(1,1+m):
    for j in l[i]:
        heapq.heappush(q,-j)
    if q:
        ans-=heapq.heappop(q)
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
ab=[]
q=0
for i in range(n):
    p=[int(j) for j in input().split()]
    q=max(q,p[0])
    ab.append(p)
from operator import itemgetter

ab.sort(key=itemgetter(0))
ab.reverse()
ab.sort(key=itemgetter(1))
ab.reverse()

k=0
ans=0
l=[0 for i in range(q+1)]
import numpy as np
l=np.array(l)
for i in range(n):
    if l[ab[i][0]]<m-ab[i][0]+1:
        ans+=ab[i][1]
        a=np.array([1]*(ab[i][0]+1)+[0]*(q-ab[i][0]))
        l=l+a
        k+=1
    if k==m:
        break
print(ans)
Problem p02987 (python)

Fixed submission:
s=input()
l=list(s)
import collections
c=collections.Counter(l)
ll=c.most_common()

for i,j in ll:
    if j!=2:
        print("No")
        import sys
        sys.exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
s=input()
sl=list(s)
p=s[0]
ans=0
ans2=0
for i in range(4):
    if s[i]==p:
        ans+=1
    else:
        q=s[i]

for i in range(4):
    if s[i]==q:
        ans2+=1

if ans==2 and ans2==2:
    print("Yes")
else:
    print("No")
Problem p02990 (python)

Fixed submission:
import math
def c(n,r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
 
n,k=map(int,input().split())
mod=10**9+7
 
for i in range(k):
    if n-k<i:
        print(0)
    else:
        print(c(k-1,i)*c(n-k+1,i+1)%mod)

Buggy submission (verdict: Runtime Error):
import math
def c(n,r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
 
n,k=map(int,input().split())
mod=10**9+7
 
for i in range(K):
    if n-k<i:
        print(0)
    else:
        print(c(k-1,i)*c(n-k+1,i+1)%mod)
Problem p03033 (python)

Fixed submission:
import sys
input = sys.stdin.readline
n,q=[int(j) for j in input().split()]
l=[]
for i in range(n):
    s,t,x=[int(j) for j in input().split()]
    l.append((s-x,1,x))
    l.append((t-x,0,x))

for i in range(q):
    d=int(input())
    l.append((d,2,i))

l.sort()

ans=[-1]*q
ll=set()
m=10**18
p=False
for i,j,x in l:
    if j==1:
        ll.add(x)
        if m>x:
            m=x
            p=True
    elif j==0:
        ll.remove(x)
        if x==m:
            p=False
    else:
        if not p:
            if ll:
                p=True
                m=min(ll)
            else:
                m=-1
        ans[x]=m
print('\n'.join(map(str,ans)))

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
stx=[]
m=0
for i in range(n):
    p=[int(j) for j in input().split()]
    stx.append([max(p[0]-p[2],0),p[1]-p[2]-1,p[2]])
    m=max(m,p[1]-p[2])
from operator import itemgetter
stx.sort(key=itemgetter(2))
stx=stx[::-1]
l=[-1]*(m+7)
for i in range(n):
    l[stx[i][0]:stx[i][1]+1]=[stx[i][2]]*(stx[i][1]-stx[i][0]+1)
d=[]
for i in range(q):
    d.append(int(input()))

for i in d:
    print(l[i])
Problem p03104 (python)

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

def f(n):
    p=0
    if n%2==1:
        p=(n+1)//2
        if p%2==0:
            return 0
        else:
            return 1
    else:
        p=n//2
        if p%2==0:
            return n^0
        else:
            return n^1

print(f(a-1)^f(b))

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a==b:
    print(a)
    import sys
    sys.exit()

def f(a):
    l=""
    a+=1
    i=1
    while i<a:
        if a%(i*2)>i:
            if a%(i*2)%2==0:
                l="0"+l
            else:
                l="1"+l
        else:
            l="0"+l
        i*=2
    return l

a=int(f(a-1),2)
b=int(f(b),2)
print(a^b+1)
Problem p03137 (python)

Fixed submission:
n,m=map(int,input().split())
x=[int(i) for i in input().split()]
x.sort()

if n>=m:
    print(0)
    import sys
    sys.exit()
l=[]
ans=x[-1]-x[0]
for i in range(m-1):
    l.append(abs(x[i]-x[i+1]))
l.sort()
l.reverse()
for i in range(n-1):
    ans-=l[i]
if ans>=0:
    print(ans)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
x=[int(i) for i in input().split()]
x.sort()

if n>=m:
    print(0)
    import sys
    sys.quit()
l=[]
ans=x[-1]-x[0]
for i in range(m-1):
    l.append(abs(x[i]-x[i+1]))
l.sort()
l.reverse()
for i in range(n-1):
    ans-=l[i]
if ans>=0:
    print(ans)
else:
    print(0)
Problem p03252 (python)

Fixed submission:
s=input()
t=input()


def f(s):
    l=[]
    a="abcdefghijklmnopqrstuvwxyz"
    r=""
    for i in range(len(s)):
        if s[i] in l:
            for j in range(len(l)):
                if s[i]==l[j]:
                    r+=a[j]
        else:
            r+=a[len(l)]
            l.append(s[i])
    return r

if f(s)==f(t):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import sys
s=input()
t=input()

def c(a,b,s,t):
    li=""
    j=0
    for i in s:
        if i==a:
            li+=b
            if t[j]!=b:
                print("No")
                sys.exit()
        elif i==b:
            li+=a
        else:
            li+=i
        j+=1
    return li
    

for i in range(len(t)):
    if s[i]!=t[i]:
        l.append(t[i])
        s=c(s[i],t[i],s,t)
    
        

if s==t:
    print("Yes")
else:
    print("No")
Problem p03327 (python)

Fixed submission:
N=int(input())
if N<1000:
    print("ABC")
else:
    print("ABD")

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

if N<1000:
    print(“ABC”)
else:
    print(“ABD”)

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

if N<1000:
    print(“ABC”)
else:
    print(“ABD”)
Problem p03806 (python)

Fixed submission:
n,ma,mb=map(int,input().split())
abc=[]
for i in range(n):
    abc.append([int(j) for j in input().split()])
from operator import itemgetter
abc.sort(key=itemgetter(2))

dp=[[10**18 for i in range(401)]for j in range(401)]
dp[0][0]=0

p,q=0,0
for a,b,c in abc:
    for j in reversed(range(q+1)):
        for i in range(p+1):
            if dp[i][j]==10**18:
                continue
            else:
                dp[i+a][j+b]=min(dp[i+a][j+b],dp[i][j]+c)
    p+=a
    q+=b

ans=1145141919
i=1
while ma*i<401 and mb*i<401:
    ans=min(ans,dp[ma*i][mb*i])
    i+=1
if ans==1145141919:
    print(-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
n,ma,mb=map(int,input().split())
abc=[]
for i in range(n):
    abc.append([int(j) for j in input().split()])

from operator import itemgetter
abc.sort(key=itemgetter(2))

dp=[[10**100 for i in range(401)]for j in range(401)]
dp[0][0]=0
from collections import deque
q=deque([(0,0)])
p=0
for a,b,c in abc:
    l=[]
    while q:
        i,j=q.popleft()
        l.append([i,j])
        l.append([i+a,j+b])
        dp[a+i][b+j]=min(dp[a+i][b+j],dp[i][j]+c)
    q=deque(l)

ans=1145141919
i=1
while ma*i<500 and mb*i<500:
    ans=min(ans,dp[ma*i][mb*i])
    i+=1
if ans==1145141919:
    print(-1)
else:
    print(ans)