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

Fixed submission:

n,a,b=map(int,input().split())
MOD=10**9+7
def pos(x, n, m):
    if n == 0:
        return 1
    res = pos(x*x%m, n//2, m)
    if n%2 == 1:
        res = res*x%m
    return res

def comb(n,k):
    if n<k:
        return 0
    if n<0 or k<0:
        return 0
    k=min(n-k,k)
    ans=1
    inv=[1]*(k+1)
    if k>=1:
        ans*=(n-k+1)%MOD
    for i in range(2,k+1):
        inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
        ans=ans*(n-k+i)*inv[i]%MOD
    return ans

na=comb(n,a)
nb=comb(n,b)

ans=(pos(2,n,MOD)-na-nb-1)%MOD

print(ans)

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
n,a,b=map(int,input().split())
MOD=10**9+7
def pos(x, n, m):
    if n == 0:
        return 1
    res = pos(x*x%m, n//2, m)
    if n%2 == 1:
        res = res*x%m
    return res

def comb(n,k):
    if n<k:
        return 0
    if n<0 or k<0:
        return 0
    k=min(n-k,k)
    ans=1
    inv=[1]*(k+1)
    if k>=1:
        ans*=(n-k+1)%MOD
    for i in range(2,k+1):
        inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
        ans=ans*(n-k+i)*inv[i]%MOD
    return ans

na=comb(n,a)
nb=comb(n,b)

ans=(pos(2,n,MOD)-na-nb-1)%MOD

print(ans)
Problem p02783 (python)

Fixed submission:
a,b=map(int,input().split())
if a%b==0:
    print(a//b)
else:
    print(a//b+1)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a%b==0:
    print(a//b)
else:
    print(a//b+1)a,b=map(int,input().split())
if a%b==0:
    print(a//b)
else:
    print(a//b+1)
Problem p02803 (python)

Fixed submission:

from collections import deque

def dfs(field, s):
    MOVE = [(0, 1), (1, 0), (0, -1), (-1, 0)]
    q = deque([(0, s)])
    dist = [[-1] * w for _ in range(h)]

    d, i, j = -1, -1, -1
    while q:
        d, (i, j) = q.popleft()
        if dist[i][j] != -1:
            continue
        dist[i][j] = d
        for di, dj in MOVE:
            ni, nj = i + di, j + dj
            if not 0 <= ni < h or not 0 <= nj < w:
                continue
            if field[ni][nj] == '#':
                continue
            if dist[ni][nj] != -1:
                continue
            q.append((d + 1, (ni, nj)))
    return d, i, j

h,w=map(int,input().split())
S=[]
for i in range(h):
    S.append(input())

ans=0
for i in range(h):
    for j in range(w):
        if S[i][j]==".":
            d,i,j=dfs(S,(i,j))
            ans=max(ans,d)

print(ans)

Buggy submission (verdict: Runtime Error):
H,W=map(int,input().split())
S=[]
for i in range(H):
    S.append(input())
from collections import deque

def dfs(field, s):
    MOVE = [(0, 1), (1, 0), (0, -1), (-1, 0)]
    q = deque([(0, s)])
    dist = [[-1] * w for _ in range(h)]

    d, i, j = -1, -1, -1
    while q:
        d, (i, j) = q.popleft()
        if dist[i][j] != -1:
            continue
        dist[i][j] = d
        for di, dj in MOVE:
            ni, nj = i + di, j + dj
            if not 0 <= ni < h or not 0 <= nj < w:
                continue
            if field[ni][nj] == '#':
                continue
            if dist[ni][nj] != -1:
                continue
            q.append((d + 1, (ni, nj)))
    return d, i, j

ans=0
for i in range(H):
    for j in range(W):
        if S[i][j]==".":
            d,i,j=dfs(S,(i,j))
            ans=max(ans,d)

print(ans)
Problem p02899 (python)

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

B=np.argsort(A)+1

print(' '.join(map(str,B)))

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

B=np.argsort(A)+1

print(' '.join(map(str,B)))

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

B=np.argsort(A)

print(' '.join(map(str,B+1)))
Problem p02900 (python)

Fixed submission:
import  fractions
import  math
A, B = map(int, input().split())

c=fractions.gcd(A,B)

Cnt=[]

def prime_decomposition(n):
  i = 2
  table = set([])
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.add(int(i))
    i += 1
  if n > 1:
    table.add(int(n))
  return table

Cnt=prime_decomposition(c)
Cnt=list(Cnt)
def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1

ans=1


for i in range(0,len(Cnt)):
    if is_prime(int(Cnt[i])):
        ans+=1

print(ans)

Buggy submission (verdict: Runtime Error):
import  fractions
import  math
A, B = map(int, input().split())

c=fractions.gcd(A,B)

Cnt=[]

def prime_decomposition(n):
  i = 2
  table = set([])
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.add(int(i))
    i += 1
  if n > 1:
    table.add(int(n))
  return table

Cnt=prime_decomposition(c)

def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1

ans=1


for i in range(0,len(Cnt)):
    if is_prime(int(Cnt[i])):
        ans+=1

print(ans)
Problem p03014 (python)

Fixed submission:
H,W=map(int,input().split())
S=[input() for i in range(H)]

ans=0
tate=[]

for i in range(W):
    c=0
    ad=[]
    while(c<H):
        ad.append(S[c][i])
        c+=1
    tate.append(ad)

left=[]
right=[]
up=[]
down=[]

for i in range(H):
    tmp=S[i]
    cnt=0
    al = [0 for _ in range(W)]
    for j in range(W):
        if tmp[j]==".":
            cnt+=1
            al[j]=cnt
        else:
            cnt=0
    left.append(al)

for i in range(H):
    tmp = S[i]
    tmp=tmp[::-1]
    cnt = 0
    ar = [0 for _ in range(W)]
    for j in range(W):
        if tmp[j] == ".":
            cnt += 1
            ar[j] = cnt
        else:
            cnt = 0
    ar=ar[::-1]
    right.append(ar)

for j in range(W):
    tt=tate[j]
    cnt=0
    bl=[0 for i in range(H)]
    for k in range(H):
        if tt[k]==".":
            cnt+=1
            bl[k]=cnt
        else:
            cnt=0
    up.append(bl)

for j in range(W):
    tt=tate[j]
    tt=tt[::-1]
    cnt=0
    br=[0 for i in range(H)]
    for k in range(H):
        if tt[k]==".":
            cnt+=1
            br[k]=cnt
        else:
            cnt=0
    br=br[::-1]
    down.append(br)

for i in range(H):
    for j in range(W):
        gh=left[i][j]+right[i][j]+up[j][i]+down[j][i]-3
        ans=max(gh,ans)

print(ans)

Buggy submission (verdict: Runtime Error):
#tempt
h,w=map(int,input().split())
s=[]
for i in range(h):
    g=list(map(str,input().split()))
    s.append(g)

revs=[]
for i in range(h):
    tmp=s[i][::-1]
    revs.append(tmp)

cnta=[]
for i in range(h):
    left=[0]*w
    count = 0
    if s[i][0]=='.':
        left[0]=1
        count+=1

    for j in range(1,w-2):
        if s[i][1]=='.':
            left[j]=left[j-1]+1
            count+=1
        else:
            left[j]=0
            count=0
    cnta.append(left)

cntb=[]

for i in range(h):
    right=[0]*w
    count = 0
    if revs[i][0]=='.':
        right[0]=1
        count+=1

    for j in range(1,w):
        if revs[i][j]=='.':
            right[j]=right[j-1]+1
            count+=1
        else:
            right[j]=0
            count=0
    cntb.append(right)

print(cntb)
Problem p03161 (python)

Fixed submission:
import sys
# inputを高速化する。
input = sys.stdin.readline

n,k=map(int,input().split())
h=list(map(int,input().split()))
INF=10**10
cost=[INF]*(n+1)
cost[0]=0

for i in range(0,n):
    for j in range(1,min(k+1,n-i)):
        cost[i+j]=min(cost[i+j],cost[i]+abs(h[i+j]-h[i]))

print(cost[n-1])

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
# inputを高速化する。
input = sys.stdin.readline

n,k=map(int,input().split())
h=list(map(int,input().split()))
INF=10**10
cost=[INF]*(n+1)
cost[0]=0

for i in range(0,n):
    for j in range(1,min(k+1,n-i)):
        cost[i+j]=min(cost[i+j],cost[i]+abs(h[i+j]-h[i]))

print(cost[n-1])
Problem p03163 (python)

Fixed submission:
n,w=map(int,input().split())
weight=[]
value=[]
for i in range(n):
    q,r=map(int,input().split())
    weight.append(q)
    value.append(r)

dp=[[0 for i in range(100111)] for j in range(111)]

for i in range(0,n):
    for sum_w in range(0,w+1):
        if sum_w-weight[i]>=0:
            dp[i+1][sum_w]=max(dp[i+1][sum_w],dp[i][sum_w-weight[i]]+value[i])
        dp[i+1][sum_w]=max(dp[i][sum_w],dp[i+1][sum_w])

print(dp[n][w])

Buggy submission (verdict: Runtime Error):
n,w=map(int,input().split())
weight=[]
value=[]
for i in range(n):
    q,r=map(int,input().split())
    weight.append(q)
    value.append(r)

dp=[[0 for _ in range(10100)] for _ in range(110)]

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

print(dp[n][w])

Buggy submission (verdict: Runtime Error):
n,w=map(int,input().split())
weight=[]
value=[]
for i in range(n):
    q,r=map(int,input().split())
    weight.append(q)
    value.append(r)

dp=[[-1] for _ in range(10100) for _ in range(110)]

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

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

Buggy submission (verdict: Runtime Error):
n,w=map(int,input().split())
weight=[]
value=[]
for i in range(n):
    q,r=map(int,input().split())
    weight.append(q)
    value.append(r)

dp=[[0 for i in range(111)] for j in range(100111)]

for i in range(0,n):
    for sum_w in range(0,w+1):
        if sum_w-weight[i]>=0:
            dp[i+1][sum_w]=max(dp[i+1][sum_w],dp[i][sum_w-weight[i]]+value[i])
        dp[i+1][sum_w]=max(dp[i][sum_w],dp[i+1][sum_w])

print(dp[n][w])

Buggy submission (verdict: Runtime Error):
n,w=map(int,input().split())
weight=[]
value=[]
for i in range(n):
    q,r=map(int,input().split())
    weight.append(q)
    value.append(r)

dp=[[0 for i in range(110)] for j in range(100100)]

for i in range(0,n):
    for sum_w in range(0,w+1):
        if sum_w-weight[i]>=0:
            dp[i+1][sum_w]=max(dp[i+1][sum_w],dp[i][sum_w-weight[i]]+value[i])
        dp[i+1][sum_w]=max(dp[i][sum_w],dp[i+1][sum_w])

print(dp[n][w])

Buggy submission (verdict: Runtime Error):
n,w=map(int,input().split())
weight=[]
value=[]
for i in range(n):
    q,r=map(int,input().split())
    weight.append(q)
    value.append(r)

dp=[[0 for i in range(110)] for j in range(100100)]

for i in range(0,n):
    for sum_w in range(0,w+1):
        if sum_w-weight[i]>=0:
            dp[i+1][sum_w]=max(dp[i+1][sum_w],dp[i][sum_w-weight[i]]+value[i])
        dp[i+1][sum_w]=max(dp[i][sum_w],dp[i+1][sum_w])

print(dp[n][w])
Problem p03197 (python)

Fixed submission:
n=int(input())
a=[int(input()) for i in range(n)]

print( "second" if all(a[i]%2==0 for i in range(n)) else "first" )

Buggy submission (verdict: Runtime Error):
print( "second" if all(a[i]%2==0 for i in range(N)) else "first" )
Problem p03213 (python)

Fixed submission:
n=int(input())
e=[0]*(n+1)
for i in range(2,n+1):
    cur=i
    for j in range(2,i+1):
        while cur%j==0:
            e[j]+=1
            cur//=j
def num(m):
    return len(list(filter(lambda  x: x>=m-1,e)))

print(num(75)+num(25)*(num(3)-1)+num(15)*(num(5)-1)+num(5)*(num(5)-1)*(num(3)-2)//2)

Buggy submission (verdict: Runtime Error):
n=int(input())
e=[0]*(n+1)
for i in range(2,n+1):
    cur=i
    for j in range(2,i+1):
        while cuur%j==0:
            e[j]+=1
            cur//=j
def num(m):
    return len(list(filter(lambda  x: x>=m-1,e)))

print(num(75)+num(25)*(num(3)-1)+num(15)*(num(5)-1)+num(5)*(num(5)-1)*(num(3)-2)//2)
Problem p03254 (python)

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

a.sort()

ans=0

if x==sum(a):
  print(N)
  exit()
  
for i in range(N):
  x-=a[i]
  if x<0:
    print(i)
    exit()
else:
  print(N-1)

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

a.sort()

ans=0
tmp=0
for i in  range(len(a)):
  tmp+=int(a[i])

if tmp==x:
  print(N)
  exit()

for i in range(0,N):
  if x-int(a[i])>=0:
    ans+=1
    x-=int(a[i])
  else:
    print(ans)
    break

if a[0]>x:
  print(0)
Problem p03294 (python)

Fixed submission:
import fractions
n=int(input())
A=list(map(int,input().split()))
gd=1
tmp=A[0]
for i in range(n-1):
    gd=fractions.gcd(A[i+1],A[i])
    tmp*=A[i+1]
lcm=tmp//gd
lcm-=1
ans=0
for a in A:
    ans+=lcm%a

print(ans)

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
A=list(map(int,input().split()))
gd=1
tmp=A[0]
for i in range(n-1):
    gd=math.gcd(A[i+1],A[i])
    tmp*=A[i+1]
lcm=tmp//gd
lcm-=1
ans=0
for a in A:
    ans+=lcm%a

print(ans)

Buggy submission (verdict: Runtime Error):
import math
import functools
n=int(input())
a=list(map(int,input().split()))
tmp=1
for f in a:
    tmp*=f
gcd=functools.reduce(math.gcd, a)
lcm=tmp//gcd
lcm-=1
ans=0
for f in a:
    ans+=lcm%f
print(ans)
Problem p03353 (python)

Fixed submission:
s=list(input())

K=int(input())

L=[]

for i in range (1,K+1):
    for j in range (0, len(s)-i+1):
        L.append("".join(s[j:j+i]))

L=sorted(set(L))

print(L[K-1])

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

K=int(input())

L=[]

for i in range (1,K+1):
    for j in range (0, len(s)-i+1):
        L.append("".join(s[j:j+1]))

L=sorted(set(L))

print(L[K-1])
Problem p03565 (python)

Fixed submission:
S=input()
T=input()
tmp=[]
for i in range(len(S)):
    flag=True
    for j in range(min(len(T),len(S)-i)):
        if S[i+j]==T[j] or S[i+j]=="?" or T[j]=="?":
            continue
        else:
            flag=False
    if flag:
        rec=S[:i]+T+S[i+len(T):]
        if len(rec)==len(S):
            rec=rec.replace("?","a")
            tmp.append(rec)
if tmp==[]:
    print("UNRESTORABLE")
    exit()
tmp.sort()
print(tmp[0])

Buggy submission (verdict: Runtime Error):
#tempt
s=input()
t=input()
lt=len(t)
ls=len(s)
cnt=0
flag=True

for i in range(lt):
    for j in range(ls):
        if t[i]==s[j]:
            bs=j
            bt=i
            af=j
            at=j
            check=True
            while bs>0 and bt>0: #before
                if s[bs]=="?" or s[bs]==t[bt]:
                    continue
                else:
                    check=False
                bs-=1
                bt-=1
            if bt>0:
                check=False
            while af < ls and at < lt:  # before
                if s[af] == "?" or s[af] == t[at]:
                    continue
                else:
                    check = False
                af += 1
                at += 1
            if at != lt-1:
                check = False
        if not check:
            flag=False
        else:
            flag=True
    if flag:
        continue
    else:
        print("UNRESTORABLE")
        exit()
Problem p03577 (python)

Fixed submission:
s=input()
print(s[0:len(s)-8])

Buggy submission (verdict: Runtime Error):
print(input()[0:len(input())-8])
Problem p03608 (python)

Fixed submission:
from scipy.sparse.csgraph import dijkstra,floyd_warshall
from scipy.sparse import csr_matrix
from  itertools import permutations

N,M,R=map(int,input().split())
r=[int(x)-1 for x in input().split()]
dist=[[0 for _ in range(N)] for _ in range(N)]
for i in range(M):
    x,y,z=map(int,input().split())
    dist[x-1][y-1]=z
    dist[y-1][x-1]=z
tr=floyd_warshall(dist)
ans=10**12
for tmp in permutations(r):
    cnt=0
    for i in range(R-1):
        cnt+=tr[tmp[i]][tmp[i+1]]
    ans=min(ans,cnt)

print(int(ans))

Buggy submission (verdict: Runtime Error):
from scipy.sparse.csgraph import dijkstra,floyd_warshall
from scipy.sparse import csr_matrix
from  itertools import permutations

N,M,R=map(int,input().split())
r=[int(x)-1 for x in input().split()]
A=[]
B=[]
C=[]
for i in range(M):
    x,y,z=map(int,input().split())
    A.append(x-1)
    B.append(y-1)
    C.append(z)

d=csr_matrix((C,(A,B)),shape=(N,N))
tr=floyd_warshall(d)
ans=float('inf')

for tmp in permutations(r):
    cnt=0
    for i in range(len(r)-1):
        cnt+=tr[tmp[i]][tmp[i+1]]
    ans=min(ans,cnt)

print(int(ans))

Buggy submission (verdict: Runtime Error):
from scipy.sparse.csgraph import dijkstra,floyd_warshall
from scipy.sparse import csr_matrix
from  itertools import permutations

N,M,R=map(int,input().split())
r=[int(x)-1 for x in input().split()]
A=[]
B=[]
C=[]
for i in range(M):
    x,y,z=map(int,input().split())
    A.append(x-1)
    B.append(y-1)
    C.append(z)

d=csr_matrix((C,(A,B)),shape=(N,N))
tr=floyd_warshall(d)

ans=float('inf')
for tmp in permutations(r):
    cnt=0
    for i in range(len(tmp)-1):
        cnt+=tr[tmp[i]][tmp[i+1]]
    ans=min(ans,cnt)

print(int(ans))
Problem p03651 (python)

Fixed submission:
import fractions
n,k=map(int,input().split())
a=list(map(int,input().split()))
if max(a)<k:
    print("IMPOSSIBLE")
    exit()
t=a[0]
if n!=1:
    for i in range(1,n):
        t=fractions.gcd(t,a[i])

if k%t==0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
bb=set(a)
for i in range(n-1):
    tm=a[i+1]-a[i]
    bb.add(tm)
cv=list(bb)
cv.sort()

if k in cv:
    print("POSSIBLE")
    exit()

if max(cv)<k:
    print("IMPOSSIBLE")
    exit()

if n==1:
    if a[0]==k:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
    exit()

xc=0
cb=False
if cv[0]==1:
    xc=cv[1]
else:
    xc=cv[0]

for i in range(len(cv)):
    if cv[i]%xc!=0:
        cb=True

if k<=max(cv):
    if cb:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
    exit()
    
print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
bb=set(a)
for i in range(n-1):
    tm=a[i+1]-a[i]
    bb.add(tm)
cv=list(bb)
cv.sort()

if k in cv:
    print("POSSIBLE")
    exit()

if max(cv)<k:
    print("IMPOSSIBLE")
    exit()

if n==1:
    if a[0]==k:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
    exit()

xc=0
cb=False
if cv[0]==1:
    xc=cv[1]
else:
    xc=cv[0]

for i in range(len(cv)):
    if cv[i]%xc!=0:
        cb=True

if k<=max(cv):
    if cb:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
    exit()
Problem p03433 (python)

Fixed submission:
a = int(input())
b = int(input())
temp = a % 500
if temp <= b:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
temp = a % 500
if temp <= b:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
if a % 500 <= b:
  print("Yes")
else:
  print("No")
Problem p02683 (python)

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

def generate_n_bit(n):
    bins= []
    for i in range(2**n):
        bins.append(list(str(format(i,'b').zfill(n))))
    
    return bins

min_price = 10**9
bins = generate_n_bit(n)
bins = bins[1:]

for bin in bins:
    a = [0 for k in range(m)]
    price = 0
    for i in range(n):
        if bin[i] == '1':
            for j in range(m):
                a[j] += l[i][j+1]
            
            price += l[i][0]
    
   
    
    if min(a) >= x:
        min_price = min(price, min_price)
        

if min_price == 10**9:
    print(-1)
    exit()
    
print(min_price)

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

def generate_n_bit(n):
    bins= []
    for i in range(2**n):
        bins.append(list(str(format(i,'b').zfill(n))))
    
    return bins

min_price = 10**9
bins = generate_n_bit(10)
bins = bins[1:]

for bin in bins:
    a = [0 for k in range(m)]
    price = 0
    for i in range(n):
        if bin[i] == '1':
            for j in range(m):
                a[j] += l[i][j+1]
            
            price += l[i][0]
    
   
    
    if min(a) >= x:
        min_price = min(price, min_price)
        

if min_price == 10**9:
    print(-1)
    exit()
    
print(min_price)

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

def generate_n_bit(n):
    bins= []
    for i in range(2**n):
        bins.append(list(str(format(i,'b').zfill(n))))
    
    return bins

min_price = 10**9
bins = generate_n_bit(10)
del bins[0]

for bin in bins:
    a = [0 for k in range(m)]
    price = 0
    for i in range(n):
        if bin[i] == '1':
            for j in range(m):
                a[j] += l[i][j+1]
            
            price += l[i][0]
    
   
    
    if min(a) >= x:
        min_price = min(price, min_price)
        print(min_price)


print(min_price)
Problem p02761 (python)

Fixed submission:
import sys
n,m = map(int,input().split())
sc = [list(map(int,input().split())) for i in range(m)]

for i in range(10**n):
    s = str(i)
    if len(s) != n:
        continue
    c = 0
    for i in range(m):
        if n >= 2:
            if sc[i] == [1,0]:
                print(-1)
                sys.exit()
            
        if s[sc[i][0]-1] == str(sc[i][1]):
            c += 1
    
    if c == m:
        print(s)
        sys.exit()

print(-1)

Buggy submission (verdict: Runtime Error):
import sys
n,m = map(int,input().split())
sc = [list(map(int,input().split())) for i in range(m)]

for i in range(10**n):
    s = str(i)
    c = 0
    for i in range(m):
        if n >= 2:
            if sc[i] == [1,0]:
                print(-1)
                sys.exit()
            
        if s[sc[i][0]-1] == str(sc[i][1]):
            c += 1
    
    if c == m:
        print(s)
        sys.exit()

print(-1)

Buggy submission (verdict: Runtime Error):
import sys
n,m = map(int,input().split())
sc = [list(map(int,input().split())) for i in range(m)]

l = [0 for i in range(n)]
set_sc = [[] for i in range(n)]

for i in range(m):
    set_sc[sc[i][0]-1].append(sc[i][1])

for i in range(len(set_sc)):
    if len(set(set_sc[i])) > 1:
        print(-1)
        sys.exit()

if set_sc[0][0] == 0:
    print(-1)
    sys.exit()

for i in range(len(set_sc)):
    if len(set_sc[i]) == 0:
        continue
    l[i] = set_sc[i][0]

l = list(map(str,l))
print(''.join(l))

Buggy submission (verdict: Runtime Error):
import sys
n,m = map(int,input().split())
sc = [list(map(int,input().split())) for i in range(m)]

l = [0 for i in range(n)]
set_sc = [[] for i in range(n)]

for i in range(m):
    set_sc[sc[i][0]-1].append(sc[i][1])

for i in range(m):
    if len(set(set_sc[i])) > 1:
        print(-1)
        sys.exit()

if set_sc[0][0] == 0:
    print(-1)
    sys.exit()

for i in range(n):
    if len(set_sc[i]) == 0:
        continue
    l[i] = set_sc[i][0]

l = list(map(str,l))
print(''.join(l))
Problem p02768 (python)

Fixed submission:
n,a,b = map(int,input().split())
mod = 10**9+7

def C(n, r, mod):
    x=y=1
    for i in range(r):
        x *= n; y *= r
        x %= mod; y %= mod
        n -= 1; r -= 1
    return x * pow(y, mod - 2, mod) % mod


res = pow(2,n,mod) - 1


comb_a = C(n,a,mod)
comb_b = C(n,b,mod)

print((res-(comb_a+comb_b))%mod)

Buggy submission (verdict: Runtime Error):
from scipy.misc import comb

n,a,b = map(int,input().split())

res = pow(2,n,10**9+7)
res -= 1


res -= comb(n, a, exact=True)
res %= 10**9+7

res -= comb(n, b, exact=True)
res %= 10**9+7

print(res)

Buggy submission (verdict: Runtime Error):
from scipy.special import comb

n,a,b = map(int,input().split())

res = pow(2,n,10**9+7)
res -= 1


res -= comb(n, a, exact=True)
res %= 10**9+7

res -= comb(n, b, exact=True)
res %= 10**9+7

print(res)
Problem p02812 (python)

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

c = 0

for i in range(0,n-2):
    if s[i] == 'A':
        if s[i+1] == 'B':
            if s[i+2] == 'C':
                c += 1
        
print(c)

Buggy submission (verdict: Runtime Error):
for i in range(0,n-2):
    if s[i] == 'A':
        if s[i+1] == 'B':
            if s[i+2] == 'C':
                c += 1
        
print(c)