Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def solve2(s):
    ans = 0
    for i, c in enumerate(s): #見る数字を右に広げていく
        if c in '02468':
            ans += i + 1 # 見ている数字のの一番右の桁が偶数ならその頭に乗っている数字の数だけ
                        # 答えに追加する
                        # 例 2254とし2→偶数、22→偶数（さらに先頭の2をどけても偶数）
                        # →225（奇数）→2254（偶数、上の3つをそれぞれどけても偶数）
    return ans


def solve5(s): # p==2のときと同じ原理
    ans = 0
    for i, c in enumerate(s):
        if c in '05':
            ans += i + 1
    return ans


def solve_other(s, p):
    ans = 0
    last_mod=0
    mods = [0]*p
    mods[0] = 1 #初期値として何も選んでない状態を1個加えとく
    digit = 1
    for i in range(n-1,-1,-1): # 一番右のけたから見る
        last_mod = (last_mod + int(s[i])*digit)%p # 最新のmodに新しく見ている桁*(10**x)を足してmod計算
        ans += mods[last_mod] # modリストに直前までのの値を答えに追加
        mods[last_mod] += 1 # modリスト更新
        digit *=10 # 桁上げ
    return ans


n, p = list(map(int, input().split()))
s = input()
if p == 2:
    print(solve2(s))
elif p == 5:
    print(solve5(s))
else:
    print(solve_other(s, p))

Fixed submission:
def solve2(s):
    ans = 0
    for i, c in enumerate(s): #見る数字を右に広げていく
        if c in '02468':
            ans += i + 1 # 見ている数字のの一番右の桁が偶数ならその頭に乗っている数字の数だけ
                        # 答えに追加する
                        # 例 2254とし2→偶数、22→偶数（さらに先頭の2をどけても偶数）
                        # →225（奇数）→2254（偶数、上の3つをそれぞれどけても偶数）
    return ans


def solve5(s): # p==2のときと同じ原理
    ans = 0
    for i, c in enumerate(s):
        if c in '05':
            ans += i + 1
    return ans


def solve_other(s, p):
    ans = 0
    last_mod=0
    mods = [0]*p
    mods[0] = 1 #初期値として何も選んでない状態を1個加えとく
    digit = 1
    for i in range(n-1,-1,-1): # 一番右のけたから見る
        last_mod = (last_mod + int(s[i])*digit)%p # 最新のmodに新しく見ている桁*(10**x)を足してmod計算
        ans += mods[last_mod] # modリストに直前までのの値を答えに追加
        mods[last_mod] += 1 # modリスト更新
        digit=digit*10%p # 桁上げ
    return ans


n, p = list(map(int, input().split()))
s = input()
if p == 2:
    print(solve2(s))
elif p == 5:
    print(solve5(s))
else:
    print(solve_other(s, p))
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict

n,m,k=map(int, input().split())  
friend=[[] for _ in range(n)]

for i in range(m):
    a,b=map(int, input().split()) 
    friend[a-1].append(b-1)
    friend[b-1].append(a-1)

par=[None]*n
frmember=defaultdict(int)

def dfs(v):
    if par[i]==None:
        par[v]=v
        frmember[par[v]]+=1
    for f in friend[v]:
        if par[f]==None:
            par[f]=par[v]
            frmember[par[v]]+=1
            dfs(f)

for i in range(n):
    if par[i]==None:
        dfs(i)

ans=[0]*n
for i in range(n):
    ans[i]+=frmember[par[i]]-len(friend[i])-1

for i in range(k):
    a,b=map(int, input().split()) 
    if par[a-1]==par[b-1]:
        ans[a-1]-=1
        ans[b-1]-=1

print(*ans)

Fixed submission:
n=int(input())
print(n//2+(n%2))
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict

n,m,k=map(int, input().split())  
friend=[[] for _ in range(n)]

for i in range(m):
    a,b=map(int, input().split()) 
    friend[a-1].append(b-1)
    friend[b-1].append(a-1)

par=[None]*n
frmember=defaultdict(int)

def dfs(v):
    if par[i]==None:
        par[v]=v
        frmember[par[v]]+=1
    for f in friend[v]:
        if par[f]==None:
            par[f]=par[v]
            frmember[par[v]]+=1
            dfs(f)

for i in range(n):
    if par[i]==None:
        dfs(i)

ans=[0]*n
for i in range(n):
    ans[i]+=frmember[par[i]]-len(friend[i])-1

for i in range(k):
    a,b=map(int, input().split()) 
    if par[a-1]==par[b-1]:
        ans[a-1]-=1
        ans[b-1]-=1

print(*ans)

Fixed submission:
N,M,K=map(int, input().split())

class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]

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

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x

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

ans=[0]*N
uf1=UnionFind(N)
for i in range(M):  # range(m):
    a,b=map(int, input().split()) #a,b:つながっている辺
    uf1.union(a-1,b-1)
    ans[a-1]-=1
    ans[b-1]-=1

for i in range(N):
    uf1.find(i)  # 一周findすることによって接続漏れをなくす。

from collections import defaultdict
ll=defaultdict(int)
for i in uf1.par:
    ll[i]+=1

for i in range(N):
    ans[i]+=ll[uf1.par[i]]-1

for i in range(K):
    a,b=map(int, input().split()) #a,b:つながっている辺
    if uf1.is_same(a-1,b-1):
        ans[a-1]-=1
        ans[b-1]-=1

print(*ans)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
class segtree:
    def x_func(self,d1,d2):
        dret=defaultdict(int)
        keys=set(d1.keys())|set(d2.keys())
        for k in keys:
            dret[k]+=d1[k]+d2[k]
        return dret
    def __init__(self,N):
        self.n=(1<<len(bin(N-1)[2:]))
        self.x=[defaultdict(int) for _ in range(2*self.n)]
    def build(self,seq):
        for i, j in enumerate(seq):
            self.x[i+self.n][j]+=1
        for i in range(self.n-1, 0, -1):
            self.x[i]=self.x_func(self.x[i*2],self.x[i*2+1])
    def update(self, i, c):
        j=i+self.n
        s=list(self.x[j].keys())[0]
        while j>0:
            self.x[j][s]-=1
            self.x[j][c]+=1
            j//=2
    def get(self,l,r):
        ans=defaultdict(int)
        l+=self.n
        r+=self.n
        while l<r:
            if l%2==1:
                ans=self.x_func(self.x[l],ans)
                l+=1
            if r%2==0:
                ans=self.x_func(self.x[r],ans)
                r-=1
            l//=2
            r//=2
        if l==r:
            ans=self.x_func(self.x[r],ans)
        cnt=0
        for k in ans.keys():
            if ans[k]>0:
                cnt+=1
        print(cnt)
        
n=int(input())
s=list(input())
seg=segtree(n)
seg.build(s)
#print(seg.x)
for _ in range(int(input())):
    que=list(input().split())
    if que[0]=='1':
        seg.update(int(que[1]), que[2])
    elif que[0]=='2':
        seg.get(int(que[1])-1,int(que[2])-1)

Fixed submission:
class segtree:
    def __init__(self,N):
        self.n=(1<<len(bin(N-1)[2:]))
        self.x=[0 for _ in range(2*self.n)]
    def build(self,seq):
        for i, j in enumerate(seq, start=self.n):
            self.x[i]=1<<j
        for i in range(self.n-1, 0, -1):
            self.x[i]=self.x[i*2]|self.x[i*2+1]
    def update(self, i, c):
        j=i+self.n
        self.x[j]=1<<c
        while j>1:
            j//=2
            self.x[j]=self.x[j*2]|self.x[j*2+1]
    def get(self,l,r):
        ans=0
        l+=self.n
        r+=self.n
        while l<r:
            if l%2==1:
                ans|=self.x[l]
                l+=1
            if r%2==0:
                ans|=self.x[r]
                r-=1
            l//=2
            r//=2
        if l==r:
            ans|=self.x[l]
        cnt=sum(list(map(int, list(bin(ans)[2:]))))
        print(cnt)
        
n=int(input())
s=list(input())
s=[ord(i)-97 for i in s]
seg=segtree(n)
seg.build(s)
#print(seg.x)
for _ in range(int(input())):
    que=list(input().split())
    if que[0]=='1':
        seg.update(int(que[1])-1, ord(que[2])-97)
    elif que[0]=='2':
        seg.get(int(que[1])-1,int(que[2])-1)
Buggy python submission (verdict: Runtime Error):
n=int(input())
S=[]
for i in range(n):
    S.append(input())

from collections import defaultdict
d = defaultdict(lambda:0)

for k in S:
    d[str(k)]+=1

ansn=max(d.values())
ans=[]
for i in set(S):
    if d[i]==ansn:
        ans.append(i)

ans=sorted(ans)
for i in range(len(ans)):
    print(ans[i])


Fixed submission:
a,b,c=map(int, input().split())  
x=len(set([a,b,c]))
if x==2:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n=int(input())
S=[]
for i in range(n):
    S.append(input())

from collections import defaultdict
d = defaultdict(lambda:0)

for k in S:
    d[str(k)]+=1

dmax=max(d.value())
ansn=dmax
ans=[]
for i in set(S):
    if d[i]==ansn:
        ans.append(i)

ans=sorted(ans)
for i in range(len(ans)):
    print(ans[i])


Fixed submission:
from collections import *
n=int(input())
a=[]
for _ in range(n):
  a.append(input())
aset=set(a)
cnt=Counter(a)
cnt=dict(cnt)
maxi=0
for k in cnt.keys():
  maxi=max(maxi,cnt[k])

anss=[]
for s in aset:
  if cnt[s]==maxi:
    anss.append(s)
anss.sort()
for i in range(len(anss)):
  print(anss[i])

Buggy python submission (verdict: Runtime Error):
from collections import *
n=int(input())
a=[]
for _ in range(n):
  a.append(input())
aset=set(a)
cnt=Counter(a)
maxi=0
for k in cnt.keys():
  maxi=max(maxi,cnt[k])

anss=[]
for s in seta:
  if cnt[s]==maxi:
    anss.append(s)
anss.sort()
for i in range(len(anss)):
  print(anss[i])

Fixed submission:
from collections import *
n=int(input())
a=[]
for _ in range(n):
  a.append(input())
aset=set(a)
cnt=Counter(a)
cnt=dict(cnt)
maxi=0
for k in cnt.keys():
  maxi=max(maxi,cnt[k])

anss=[]
for s in aset:
  if cnt[s]==maxi:
    anss.append(s)
anss.sort()
for i in range(len(anss)):
  print(anss[i])
Buggy python submission (verdict: Time Limit Exceeded):
H,N=map(int,input().split())
ABC=[]
for _ in range(N):
  a,b=map(int,input().split())
  ABC.append((a,b,a/b))
ABC=sorted(ABC, key=lambda x:x[2], reverse=True)
A=[ABC[i][0] for i in range(N)]
B=[ABC[i][1] for i in range(N)]
dp=[[float('inf')]*(H+1) for i in range(N+1)]
for i in range(N+1):
  dp[i][0]=0
  
for i in range(N):
  for j in range(1,H+1):
    if j-A[i]>=0:
      dp[i+1][j]=min(dp[i][j],dp[i+1][j-A[i]]+B[i])
    else:
      dp[i+1][j]=min(dp[i][j],dp[i+1][0]+B[i])
print(dp[N][H])
#print(dp)

Fixed submission:
H,N=map(int,input().split())
ABC=[]
for _ in range(N):
  a,b=map(int,input().split())
  ABC.append((a,b,a/b))
ABC=sorted(ABC, key=lambda x:x[2], reverse=True)
A=[ABC[i][0] for i in range(N)]
B=[ABC[i][1] for i in range(N)]
dp=[[float('inf')]*(H+1) for i in range(N+1)]
for i in range(N+1):
  dp[i][0]=0
  
for i in range(N):
  for j in range(1,H+1):
    if j-A[i]>=0:
      dp[i+1][j]=min(dp[i][j],dp[i+1][j-A[i]]+B[i])
    else:
      dp[i+1][j]=min(dp[i][j],dp[i+1][0]+B[i])
print(dp[N][H])
#print(dp)
Buggy python submission (verdict: Time Limit Exceeded):
N,D,A=map(int,input().split())
XH=[]
for _ in range(N):
  x,h=map(int,input().split())
  XH.append([x,h])
XH=sorted(XH, key=lambda x:x[0])
X=[XH[i][0] for i in range(N)]
H=[XH[i][1] for i in range(N)]

from bisect import bisect_right
import numpy as np
H=np.array(H)
ans=0
js=[bisect_right(X, 2*D+X[i]) for i in range(N)]
for i in range(N):
  if H[i]<=0:
    continue
  else:
    j=js[i]
    att=H[i]//A
    if H[i]%A!=0:
      att+=1
    H[i:j]-=att*A
    ans+=att
#print(H)
print(ans)

Fixed submission:
N,D,A=map(int,input().split())
XH=[]
for _ in range(N):
  x,h=map(int,input().split())
  XH.append([x,h])
XH=sorted(XH, key=lambda x:x[0])
X=[XH[i][0] for i in range(N)]
H=[XH[i][1] for i in range(N)]
from math import ceil
from bisect import bisect_right
imos=[0]*(N+1)
hit=0
ans=0
for i in range(N):
  hit+=imos[i]
  restH=H[i]-hit*A
  if restH>0:
    ans+=ceil(restH/A)
    hit+=ceil(restH/A)
    ind=bisect_right(X,X[i]+2*D)
    imos[ind]-=ceil(restH/A)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,D,A=map(int,input().split())
XH=[]
for _ in range(N):
  x,h=map(int,input().split())
  XH.append([x,h])
XH=sorted(XH, key=lambda x:x[0])
X=[XH[i][0] for i in range(N)]
H=[XH[i][1] for i in range(N)]

import numpy as np
from bisect import bisect_right

H=np.array(H)
ans=0

for i in range(N):
  if H[i]<=0:
    continue
  else:
    xj=2*D+X[i]
    j=bisect_right(X, xj)
    att=[H[i]//A if H[i]%A==0 else H[i]//A+1]
    H[i:j]-=A*att[0]
    ans+=att[0]
#print(H)
print(ans)

Fixed submission:
N,D,A=map(int,input().split())
XH=[]
for _ in range(N):
  x,h=map(int,input().split())
  XH.append([x,h])
XH=sorted(XH, key=lambda x:x[0])
X=[XH[i][0] for i in range(N)]
H=[XH[i][1] for i in range(N)]
from math import ceil
from bisect import bisect_right
imos=[0]*(N+1)
hit=0
ans=0
for i in range(N):
  hit+=imos[i]
  restH=H[i]-hit*A
  if restH>0:
    ans+=ceil(restH/A)
    hit+=ceil(restH/A)
    ind=bisect_right(X,X[i]+2*D)
    imos[ind]-=ceil(restH/A)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,D,A=map(int,input().split())
XH=[]
for _ in range(N):
  x,h=map(int,input().split())
  XH.append([x,h])
XH=sorted(XH, key=lambda x:x[0])
X=[XH[i][0] for i in range(N)]
H=[XH[i][1] for i in range(N)]

import numpy as np
from bisect import bisect_right

H=np.array(H)
ans=0
import math
for i in range(N):
  if np.all(H<=0):
    break
  if H[i]<=0:
    continue
  else:
    xj=2*D+X[i]
    j=bisect_right(X, xj)
    att=math.ceil(H[i]/A)
    H[i:j]-=A*att
    ans+=att
#print(H)
print(ans)

Fixed submission:
N,D,A=map(int,input().split())
XH=[]
for _ in range(N):
  x,h=map(int,input().split())
  XH.append([x,h])
XH=sorted(XH, key=lambda x:x[0])
X=[XH[i][0] for i in range(N)]
H=[XH[i][1] for i in range(N)]
from math import ceil
from bisect import bisect_right
imos=[0]*(N+1)
hit=0
ans=0
for i in range(N):
  hit+=imos[i]
  restH=H[i]-hit*A
  if restH>0:
    ans+=ceil(restH/A)
    hit+=ceil(restH/A)
    ind=bisect_right(X,X[i]+2*D)
    imos[ind]-=ceil(restH/A)
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
A=np.array(A)
MOD=10**9+7

def cmb(n, k, mod, fac, ifac): #calc nCk under mod
    k = min(k, n-k)
    return fac[n] * ifac[k] * ifac[n-k] % mod

def make_tables(mod, n): #Make factorial and inverse tables under mod 
    fac = [1, 1] # factorial table
    ifac = [1, 1] #factorial of inverse table
    inverse = [0, 1] #inverse
 
    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac
MOD=10**9+7
Nmax=10**5
fac,ifac = make_tables(MOD,Nmax)

combs=[0]*N
for i in range(0,N-K+1):
  combs[i]=cmb(N-i-1, K-1, MOD, fac, ifac)
#print(combs)
neg=combs
pos=sorted(combs)
pos=np.array(pos)
neg=np.array(neg)
X=(A*pos-A*neg)
print(X.sum()%MOD)

Fixed submission:
alpha='abcdefghijklmnopqrstuvwxyza'
s=input()
for i in range(len(alpha)):
  if s==alpha[i]:
    print(alpha[i+1])
    break
Buggy python submission (verdict: Runtime Error):
MOD=10**9+7
import math
def comb(n, k):
    MOD=10**9+7
    return math.factorial(n)/math.factorial(n-k)/math.factorial(k)%MOD

N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
import numpy as np
pos=[0]*N
neg=[0]*N
for i in range(N):
  if N-1-i>=K-1:
    neg[i]=comb(N-1-i,K-1)
  if i>=K-1:
    pos[i]=comb(i,K-1)
pos=np.array(pos)
neg=np.array(neg)
keisu=pos-neg
#print(keisu)
ans=0
for i in range(N):
  ans+=(keisu[i]*A[i])%MOD
print(int(ans%MOD))

Fixed submission:
import numpy as np
mod=10**9+7
N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
A=np.array(A)

def cmb(n, k, mod, fac, ifac): #calc nCk under mod
    k = min(k, n-k)
    return fac[n] * ifac[k] * ifac[n-k] % mod

def make_tables(mod, n): #Make factorial and inverse tables under mod 
    fac = [1, 1] # factorial table
    ifac = [1, 1] #factorial of inverse table
    inverse = [0, 1] #inverse
    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac
  
fac,ifac = make_tables(mod,N+1)
MAX=0
MIN=0

for i,a in enumerate(A):
  if i>=K-1:
    MAX+=cmb(i, K-1, mod, fac, ifac)*a
    MAX%=mod
  if N-i-1>=K-1:
    MIN+=cmb(N-i-1, K-1, mod, fac, ifac)*a
    MIN%=mod
print((MAX-MIN)%mod)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import Fraction
MOD=10**9+7
def comb(n, k):
    MOD=10**9+7
    if n < 0 or k < 0:
        pdt = 0
    else:
        pdt = 1
        for s in range(1, k + 1):
            pdt *= Fraction(n - s + 1, s)%MOD
    return pdt.numerator%MOD

N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
import numpy as np
pos=[0]*N
neg=[0]*N
for i in range(N):
  if N-1-i>=K-1:
    neg[i]=comb(N-1-i,K-1)
  if i>=K-1:
    pos[i]=comb(i,K-1)
pos=np.array(pos)
neg=np.array(neg)
keisu=pos-neg
#print(keisu)
ans=0
for i in range(N):
  ans+=(keisu[i]*A[i])%MOD
print(ans%MOD)

Fixed submission:
import numpy as np
mod=10**9+7
N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
A=np.array(A)

def cmb(n, k, mod, fac, ifac): #calc nCk under mod
    k = min(k, n-k)
    return fac[n] * ifac[k] * ifac[n-k] % mod

def make_tables(mod, n): #Make factorial and inverse tables under mod 
    fac = [1, 1] # factorial table
    ifac = [1, 1] #factorial of inverse table
    inverse = [0, 1] #inverse
    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac
  
fac,ifac = make_tables(mod,N+1)
MAX=0
MIN=0

for i,a in enumerate(A):
  if i>=K-1:
    MAX+=cmb(i, K-1, mod, fac, ifac)*a
    MAX%=mod
  if N-i-1>=K-1:
    MIN+=cmb(N-i-1, K-1, mod, fac, ifac)*a
    MIN%=mod
print((MAX-MIN)%mod)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
arr=[int(i) for i in input().split()]
def sumXOR(arr, n):
    MOD=int((1e+9)+7)
    sum = 0
    for i in range(0, 62): 
        zc = 0
        oc = 0
        idsum = 0
        for j in range(0, n): 
            if (arr[j] % 2 == 0): 
                zc = zc + 1
            else: 
                oc = oc + 1
            arr[j] = arr[j]//2
        idsum = oc * zc * (1 << i) 
        sum = (sum + idsum)%MOD
    return sum

ans = sumXOR(arr, n); 
print (ans)

Fixed submission:
n=int(input())
arr=[int(i) for i in input().split()]
def sumXOR(arr, n):
    MOD=int((1e+9)+7)
    sum = 0
    for i in range(0, 62): 
        zc = 0
        oc = 0
        idsum = 0
        for j in range(0, n): 
            if (arr[j] % 2 == 0): 
                zc = zc + 1
            else: 
                oc = oc + 1
            arr[j] = arr[j]//2
        idsum = oc * zc * (1 << i) 
        sum = (sum + idsum)%MOD
    return sum

ans = sumXOR(arr, n); 
print (ans)
Buggy python submission (verdict: Runtime Error):
x=int(input())
if x>=2000:
    print(1)
else:
    a=x//100
    #print(a)
    n=x-a*100
    #print(n)
    if n/a>5:
        print(0)
    else:
        print(1)

Fixed submission:
x=int(input())
if x<100:
    print(0)
elif x>=2000:
    print(1)
else:
    a=x//100
    #print(a)
    n=x-a*100
    #print(n)
    if n/a>5:
        print(0)
    else:
        print(1)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=str(input())

def isThere(suji):
    flag1=False
    flag2=False
    flag3=False
    for i in s:
        if flag2==True and suji[2]==i:
            flag3=True
            break
        if flag1==True and suji[1]==i:
            flag2=True
        if suji[0]==i:
            flag1=True
    return flag3 

candidate=list(range(1000))
candidate=['0'+'0'+str(candidate[i]) if candidate[i]<10 else ('0'+str(candidate[i]) if 9<candidate[i]<100 else str(candidate[i])) for i in range(1000)]
ans=0
for suji in candidate:
    if isThere(suji):
        ans+=1
print(ans)

Fixed submission:
n=int(input())
s=str(input())
 
def isThere(suji):
    flag1=False
    flag2=False
    flag3=False
    for i in s:
        if flag2==True and suji[2]==i:
            flag3=True
            break
        if flag1==True and suji[1]==i:
            flag2=True
        if suji[0]==i:
            flag1=True
    return flag3 
 
candidate=list(range(1000))
candidate=['0'+'0'+str(candidate[i]) if candidate[i]<10 else ('0'+str(candidate[i]) if 9<candidate[i]<100 else str(candidate[i])) for i in range(1000)]
ans=0
for suji in candidate:
    if isThere(suji):
        ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
*a,=map(int,input().split())
mod=10**9+7
col=[0]*n
col[0]=3

ans=1

for i in range(n):
    ans*=col[a[i]]
    col[a[i]]-=1
    col[a[i]+1]+=1
    ans%=mod

print(ans%mod)

Fixed submission:
n=int(input())
*a,=map(int,input().split())
mod=10**9+7
col=[0]*(n+1)
col[0]=3

ans=1

for i in range(n):
    ans*=col[a[i]]
    col[a[i]]-=1
    col[a[i]+1]+=1
    ans%=mod

print(ans%mod)
Buggy python submission (verdict: Runtime Error):
n=int(input())
XY=[]
for i in range(n):
    x,y=map(int,input().split())
    XY.append((x,y))
from itertools import permutations
perm=permutations(XY)

dists=[]
for i in perm:
    dist=0
    for j in range(1,3):
        dist+=((i[j][0]-i[j-1][0])**2+(i[j][1]-i[j-1][1])**2)**0.5
    dists.append(dist)
ans=sum(dists)/len(dists)
print(ans)


Fixed submission:
n=int(input())
xy=[]
for i in range(n):
    xt,yt=map(int, input().split())
    xy.append((xt,yt))

from itertools import permutations

perms=permutations(xy)
dis=[]
for p in perms:
    d_tmp=[]
    for i in range(1,len(p)):
        d=((p[i][0]-p[i-1][0])**2+(p[i][1]-p[i-1][1])**2)**0.5
        d_tmp.append(d)
    dis.append(sum(d_tmp))
        
print(sum(dis)/len(dis))
Buggy python submission (verdict: Runtime Error):
x,y=map(int, input().split())
mod=10**9+7

def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod

if (2*y-x)%3!=0 or (2*x-y)%3!=0:
    print('0')
else:
    a=(2*y-x)//3
    b=(2*x-y)//3
    n=a+1
    r=b
    ans=comb(n+r-1,r,mod)
    print(int(ans%mod))x,y=map(int, input().split())
mod=10**9+7

def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod

if (2*y-x)%3!=0 or (2*x-y)%3!=0:
    print('0')
else:
    a=round((2*y-x)/3)
    b=round((2*x-y)/3)
    n=a+1
    r=b
    ans=comb(n+r-1,r,mod)
    print(int(ans%mod))

Fixed submission:
x,y=map(int, input().split())
mod=10**9+7

def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod

if (2*y-x)%3!=0 or (2*x-y)%3!=0 or y>2*x or x>2*y:
    print('0')
else:
    a=round((2*y-x)/3)
    b=round((2*x-y)/3)
    n=a+1
    r=b
    ans=comb(n+r-1,r,mod)
    print(int(ans%mod))
Buggy python submission (verdict: Runtime Error):
import numpy as np
N=int(input())
root=int(np.sqrt(N))+1
a=1
b=N
for i in range(root, 0, -1):
    if N%i==0:
        a=i
        b=N//i
        break
print(a-1+b-1)

Fixed submission:
import numpy as np
N=int(input())
root=int(np.sqrt(N)//1)
a=N
b=N
for i in range(root, 0, -1):
    if N%i==0:
        a=i
        b=N//i
        break
print(a-1+b-1)