Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
#payment=桁DPの復習方法
n=input()
#0の方がちょうど、1の方が余裕持って払う
dp0=[0 for i in range(1000001)]
dp1=[0 for i in range(1000001)]
nums=int(n[-1])
dp0[1]=nums
dp1[1]=11-nums
#dp0、dp1でそれぞれぴったり払う時と余裕を持たせて払うときのiけためまでを一つの数としてみたときの最小の値を表すものとする
for i in range(1,len(n)):
    s=int(n[-(i+1)])
    dp0[i+1]=s+min(dp0[i],dp1[i])
    dp1[i+1]=min(9-s+dp1[i],11-s+dp0[i])
print(min(dp0[len(n)],dp1[len(n)]))

Fixed submission:
#payment=桁DPの復習方法
n=input()
#0の方がちょうど、1の方が余裕持って払う
dp0=[0 for i in range(1000002)]
dp1=[0 for i in range(1000002)]
nums=int(n[-1])

dp0[1]=nums
dp1[1]=11-nums
#dp0、dp1でそれぞれぴったり払う時と余裕を持たせて払うときのiけためまでを一つの数としてみたときの最小の値を表すものとする
for i in range(1,len(n)):
    s=int(n[-(i+1)])
    dp0[i+1]=s+min(dp0[i],dp1[i])
    dp1[i+1]=min(9-s+dp1[i],11-s+dp0[i])
print(min(dp0[len(n)],dp1[len(n)]))

Buggy python submission (verdict: Runtime Error):
n=input()
dic={str(i):i for i in range(11)}
for i in range(6,10):
    dic[str(i)]=11-i

ans=0
f
for i in range(len(n)):
    ans+=min(dic[n[i]],dic[str(10-int(n[i]))])
    
if n[0]=="9":
	ans+=1
print(ans+1)

Fixed submission:
#payment=桁DPの復習方法
n=input()
#0の方がちょうど、1の方が余裕持って払う
dp0=[0 for i in range(1000002)]
dp1=[0 for i in range(1000002)]
nums=int(n[-1])

dp0[1]=nums
dp1[1]=11-nums
#dp0、dp1でそれぞれぴったり払う時と余裕を持たせて払うときのiけためまでを一つの数としてみたときの最小の値を表すものとする
for i in range(1,len(n)):
    s=int(n[-(i+1)])
    dp0[i+1]=s+min(dp0[i],dp1[i])
    dp1[i+1]=min(9-s+dp1[i],11-s+dp0[i])
print(min(dp0[len(n)],dp1[len(n)]))
Buggy python submission (verdict: Runtime Error):
n=int(input())
K=int(input())
if K==1:
    counter=0
    for i in range(100):
        for j in range(1,10):
            a="0"*(i)+str(j)+"0"*(99-i)
            if 1<=int(a)<=n:
                counter+=1
    print(counter)
elif K==2:
    counter=0
    for i in range(100):
        for j in range(i+1,100):
            for k in range(1,10):
                for l in range(1,10):
                    a="0"*(i)+str(k)+"0"*(j-i-1)+str(l)+"0"*(99-j)
                    if 1<=int(a)<=n:
                        counter+=1
    print(counter)
elif K==3:
    counter=0
    for i in range(100):
        if 100-i>len(str(n)):
            pass
        elif 100-i<len(str(n)):
            for j in range(i+1,100):
                for k in range(j+1,100):
                    counter+=9*9*9
        elif 100-i==len(str(n)):
            for j in range(i+1,100):
                for k in range(j+1,100):
                    for a in range(int(str(n)[i]),int(str(n)[i])+1):
                        for b in range(1,10):
                            for c in range(1,10):
                                P=str(a)+"0"*(j-i-1)+str(b)+"0"*(k-j-1)+str(c)+"0"*(99-k)
                                if 1<=int(P)<=n:
                                    counter+=1
            counter+=((98-i)*(99-i)//2)*9*9*(int(str(n)[i])-1)
    print(counter)
                    


                    


Fixed submission:
s=list(input().split())
a,b=map(int,input().split())
u=input()
if s[0]==u:
    print(a-1,b)
else:
    print(a,b-1)
Buggy python submission (verdict: Runtime Error):

##mod,nについての制約は自分でいかに記入する
mod=10**9+7
def find_power(n,mod):
    # 0!からn!までのびっくりを出してくれる関数(ただし、modで割った値に対してである）
    powlist=[0]*(n+1)
    powlist[0]=1
    powlist[1]=1
    for i in range(2,n+1):
        powlist[i]=powlist[i-1]*i%(mod)
    return powlist
 #あるかずxのn乗をmodで割ったあまりを返す関数pow_cal(x,n,mod)
def pow_cal(x,n,mod):
    if n==0:
        return 1
    elif n==1:
        return x%mod
    elif n>=2:
        if n%2==0:
            return (pow_cal(x,n//2,mod)**2)%mod
        else:
            return (x*pow_cal(x,n//2,mod)**2)%mod

def find_inv_power(n,mod):
    #0!からn!までの逆元を素数modで割ったあまりリストを作る関数
    c=1
    uselist=[0 for i in range(n+1)]
    for i in range(1,n+1):
        c*=i
        c%=mod
    first=pow_cal(c,mod-2,mod)
    uselist[n]=first
    for i in range(n,0,-1):
        uselist[i-1]=(uselist[i]*i)%(mod)
    return uselist
    
A=find_power(2*10**6,mod)
B=find_inv_power(2*10**6,mod)

def combi(n,r,mod):
    if n<r:
        return 0
    elif n>=r:
        return (A[n]*B[r]*B[n-r])%(mod)
    
r1,c1,r2,c2=map(int,input().split())

mod=10**9+7     

K=combi(r2+c2+2,c2+1,mod)-combi(r2+c1+1,c1,mod)-combi(r1+c2+1,r1,mod)+combi(r1+c1,c1,mod)

print(K%mod)


Fixed submission:

##mod,nについての制約は自分でいかに記入する
mod=10**9+7
def find_power(n,mod):
    # 0!からn!までのびっくりを出してくれる関数(ただし、modで割った値に対してである）
    powlist=[0]*(n+1)
    powlist[0]=1
    powlist[1]=1
    for i in range(2,n+1):
        powlist[i]=powlist[i-1]*i%(mod)
    return powlist
 #あるかずxのn乗をmodで割ったあまりを返す関数pow_cal(x,n,mod)
def pow_cal(x,n,mod):
    if n==0:
        return 1
    elif n==1:
        return x%mod
    elif n>=2:
        if n%2==0:
            return (pow_cal(x,n//2,mod)**2)%mod
        else:
            return (x*pow_cal(x,n//2,mod)**2)%mod

def find_inv_power(n,mod):
    #0!からn!までの逆元を素数modで割ったあまりリストを作る関数
    c=1
    uselist=[0 for i in range(n+1)]
    for i in range(1,n+1):
        c*=i
        c%=mod
    first=pow_cal(c,mod-2,mod)
    uselist[n]=first
    for i in range(n,0,-1):
        uselist[i-1]=(uselist[i]*i)%(mod)
    return uselist
    
A=find_power(2*10**6+10,mod)
B=find_inv_power(2*10**6+10,mod)

def combi(n,r,mod):
    if n<r:
        return 0
    elif n>=r:
        return (A[n]*B[r]*B[n-r])%(mod)
    
r1,c1,r2,c2=map(int,input().split())

mod=10**9+7     

K=combi(r2+c2+2,c2+1,mod)-combi(r2+c1+1,c1,mod)-combi(r1+c2+1,r1,mod)+combi(r1+c1,c1,mod)

print(K%mod)
Buggy python submission (verdict: Time Limit Exceeded):
h,n=map(int,input().split())

lists=[]
for i in range(n):
    a,b=map(int,input().split())
    lists.append([a,b])
    
    
#dic[x]=y モンスターの体力をｘ減らすために必要な魔力
minimum=[10**9 for i in range(20001)]
#minimum[k]=ダメージｋを与えるために最小の魔力
minimum[0]=0
for i in range(1,20001):
    for j in range(n):
        if i>=lists[j][0]:
            minimum[i]=min(minimum[i-lists[j][0]]+lists[j][1],minimum[i])
        else:
            minimum[i]=minimum[i]
ans=10**8
for k in range(h,20001):
    ans=min(ans,minimum[k])
print(ans)


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

lists=[]
for i in range(n):
    a,b=map(int,input().split())
    lists.append([a,b])
    
    
#dic[x]=y モンスターの体力をｘ減らすために必要な魔力
minimum=[10**9 for i in range(20001)]
#minimum[k]=ダメージｋを与えるために最小の魔力
minimum[0]=0
for i in range(1,20001):
    for j in range(n):
        if i>=lists[j][0]:
            minimum[i]=min(minimum[i-lists[j][0]]+lists[j][1],minimum[i])
        else:
            minimum[i]=minimum[i]
ans=10**8
for k in range(h,20001):
    ans=min(ans,minimum[k])
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
lists=[[ 0 for j in range(10)]for i in range(10)]
for i in range(1,n+1):
    a=str(i)
    lists[int(a[0])][int(a[-1])]+=1
c=0
for i in range(1,10):
    for j in range(1,10):
        c+=lists[i][j])*lists[j][i]
print(c)        


Fixed submission:
n=int(input())
lists=[[ [] for j in range(10)]for i in range(10)]
for i in range(1,n+1):
    a=str(i)
    lists[int(str(a[0]))][int(str(a[-1]))].append(i)
c=0
for i in range(1,10):
    for j in range(1,10):
        c+=len(lists[i][j])*len(lists[j][i])
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
import math
import fractions

#最小公倍数
def union_lcm(lists):
    if len(lists)==1:
        return lists[0]
    elif len(lists)>1:
        num=lists[0]
        for i in range(1,len(lists)):
            num=num*lists[i]//fractions.gcd(num,lists[i])
        return num


#最大公約数
def union_gcd(lists):
    if len(lists)==1:
        return lists[0]
    elif len(lists)>1:
        num=lists[0]
        for i in range(1,len(lists)):
            num=fractions.gcd(num,lists[i])
        return num
mod=10**9+7   
n=int(input())
lists=list(map(int,input().split()))
a=union_lcm(lists)

c=0
for i in range(n):
    c+=a//lists[i]
    c=c%mod
print(c)

Fixed submission:
import math
import fractions
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0

def modinv(a, m):
    g, x, y = xgcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

#最小公倍数
def union_lcm(lists):
    if len(lists)==1:
        return lists[0]
    elif len(lists)>1:
        num=lists[0]
        for i in range(1,len(lists)):
            num=num*lists[i]//fractions.gcd(num,lists[i])
        return num


#最大公約数
def union_gcd(lists):
    if len(lists)==1:
        return lists[0]
    elif len(lists)>1:
        num=lists[0]
        for i in range(1,len(lists)):
            num=fractions.gcd(num,lists[i])
        return num
mod=10**9+7   
n=int(input())
lists=list(map(int,input().split()))
a=union_lcm(lists)
c=0
a=a%mod

for i in range(n):
    c+=a*modinv(lists[i],mod)
    c=c%mod
print(c)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
lists=list(map(int,input().split()))
uselist=[]
for some in lists:
    some=some//2
    uselist.append(some)

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

flags=True
for some in uselist:
    a=ans//some
    if a%2==0:
        flags=False
        break
if flags:
    p=math.floor(m/ans)
    if p%2==0:
      print(p//2)
    elif p%2!=0:
      print(p//2+1)
    
else:
    print(0)


Fixed submission:
k,x=map(int,input().split())
if 500*k>=x:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import math
n,m,v,p=map(int,input().split())
lists=list(map(int,input().split()))
lists=sorted(lists)
def is_ok(N,m,v,p):
    counter=0
    howadd=0
    not_avoid=0
    judge=lists[N]+m
    for k in range(n-1,-1,-1):
        if k!=N:
            if judge<lists[k]:
                counter+=m
                howadd+=1
                not_avoid+=1
            elif judge==lists[k] and howadd<p-1:
                counter+=m
                howadd+=1
            elif judge==lists[k] and howadd==p-1:
                pass
            elif judge>lists[k] and howadd<p-1:
                howadd+=1
                counter+=m
            elif judge>lists[k] and howadd==p-1:
                counter+=min(judge-lists[k],m)    
    if not_avoid>=p:
            return False
    elif not_avoid<p:
        if counter<(m)*(v-1):
            return False
        elif counter>=(m)*(v-1):
            return True
start=0
end=n-1
for _ in range(30):
    c=(start+end)/2
    if is_ok(math.floor(c),m,v,p):
        end=c
    elif not (is_ok(math.floor(c),m,v,p)):
        start=c       
print(n-math.floor(end))
                

Fixed submission:
import math
n,m,v,p=map(int,input().split())
lists=list(map(int,input().split()))
lists=sorted(lists)
def is_ok(N,m,v,p):
    counter=0
    howadd=0
    not_avoid=0
    judge=lists[N]+m
    for k in range(n-1,-1,-1):
        if k!=N:
            if judge<lists[k]:
                counter+=m
                howadd+=1
                not_avoid+=1
            elif judge==lists[k] and howadd<p-1:
                counter+=m
                howadd+=1
            elif judge==lists[k] and howadd==p-1:
                pass
            elif judge>lists[k] and howadd<p-1:
                howadd+=1
                counter+=m
            elif judge>lists[k] and howadd==p-1:
                counter+=min(judge-lists[k],m)    
    if not_avoid>=p:
            return False
    elif not_avoid<p:
        if counter<(m)*(v-1):
            return False
        elif counter>=(m)*(v-1):
            return True
start=0
end=n-1
for _ in range(30):
    c=(start+end)/2
    if is_ok(math.floor(c),m,v,p):
        end=c
    elif not (is_ok(math.floor(c),m,v,p)):
        start=c       
print(n-math.floor(end))
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000000)
n,u,v=map(int,input().split())
visitedlist=[-1 for  i in range(n)]
kilist=[[] for i in range(n)]
anslist=[0 for i in range(n)]
searchedlist=[-1 for i in range(n)]
for i in range(n-1):
        a,b=map(int,input().split())
        kilist[a-1].append(b)
        kilist[b-1].append(a)
def search(P):
        searchedlist[P-1]=1
        visitedlist[P-1]=1
        flag=0
        for j in kilist[P-1]:
            if visitedlist[j-1]<0:
                visitedlist[j-1]=1
                flag+=1
                anslist[j-1]=anslist[P-1]+1
        else:
            pass

        if flag>0:    
            for k in kilist[P-1]:
                if searchedlist[k-1]==-1:
                    search(k)
search(v)
if v<u:
	print(anslist[u]-1)
else:
  if u>1:
  	print(v-u)
  else:
    print(v-2)


Fixed submission:

a=int(input())
b=int(input())
for j in range(1,4):
    if j!=a and j!=b:
        print(j)
Buggy python submission (verdict: Runtime Error):
n,u,v=map(int,input().split())
visitedlist=[-1 for  i in range(n)]
kilist=[[] for i in range(n)]
anslist=[0 for i in range(n)]
searchedlist=[-1 for i in range(n)]
for i in range(n-1):
        a,b=map(int,input().split())
        kilist[a-1].append(b)
        kilist[b-1].append(a)
def search(P):
        searchedlist[P-1]=1
        visitedlist[P-1]=1
        flag=0
        for j in kilist[P-1]:
            if visitedlist[j-1]<0:
                visitedlist[j-1]=1
                flag+=1
                anslist[j-1]=anslist[P-1]+1
        else:
            pass

        if flag>0:    
            for k in kilist[P-1]:
                if searchedlist[k-1]==-1:
                    search(k)
search(v)
if v<u:
	print(anslist[u]-1)
else:
  if u>1:
  	print(v-u)
  else:
    print(v-2)

Fixed submission:
import sys
sys.setrecursionlimit(10000000)
n,u,v=map(int,input().split())
kilist=[[] for i in range(n)]
for i in range(n-1):
        a,b=map(int,input().split())
        kilist[a-1].append((b,1))
        kilist[b-1].append((a,1))    
visitedlist=[-1 for  _ in range(n)]
anslist=[0 for _ in range(n)]
searchedlist=[-1 for _ in range(n)]        
def search(i):
        searchedlist[i-1]=1
        visitedlist[i-1]=1
        flag=0
        for j in kilist[i-1]:
            if visitedlist[j[0]-1]<0:
                visitedlist[j[0]-1]=1
                flag+=1
                anslist[j[0]-1]=anslist[i-1]+j[1]
        else:
            pass
        if flag>0:    
            for k in kilist[i-1]:
                if searchedlist[k[0]-1]==-1:
                    search(k[0])
search(u)
u_list=anslist.copy()
visitedlist=[-1 for  _ in range(n)]
anslist=[0 for _ in range(n)]
searchedlist=[-1 for _ in range(n)]  

q=search(v)
v_list=anslist.copy()

maxi=0
for i in range(n):
    if u_list[i]<=v_list[i]:
        maxi=max(maxi,v_list[i])
print(maxi-1)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
dic={i:{j:2 for j in range(1,n+1)}for i in range(1,n+1)}
proof={k:0 for k in range(n+1)}
       
for i in range(1,n+1):
    a=int(input())
    for _ in range(a):
        x,y=map(int,input().split())
        dic[i][x]=y
                    
#dicに誰々が正直者か嘘つきであるかということをまとめるdic[x][y]=? xからｙは正直者あるいは真偽不明の者である

maxi=0

for _ in range(1,2**n): 
    #計算量 3* (10)**4
    choice=format(_,"0%ib"%n)
    #1が正直者,0がよくわからない人
    #正直者の発言が全て一致していなくてはいけない　それであれば、矛盾は生じない
    flag=True
    honest=[0 for _ in range(n+1)]
    for i in range(n):
        if choice[i]=="1":
            honest[i+1]=1
    for i in range(1,n+1):
      for j in range(1,n+1):
        if (i!=j and dic[i][j]==0 and honest[i] and honest[j]) or(i!=j and dic[i][j]==1 and honest[i] and (not honest[j])):
          flag=False
          break
         
    if flag:
      maxi=max(maxi,sum(honest))
      
      	

print(maxi)

Fixed submission:
n=int(input())
lists=[[] for _ in range(n)]
for i in range(n):
    a=int(input())
    for j in range(a):
        x,y=map(int,input().split())
        lists[i].append([x,y])
ans=0
for k in range(2**n):
    subans=0
    flag=True
    string=format(k,"0%ib"%n)
    listss=["unknown" for i in range(n)]
    for i in range(n):
        if string[i]=="1":
            #正直者だとした場合の全探索
            subans+=1
            for some in lists[i]:
                if listss[some[0]-1]=="unknown":
                    listss[some[0]-1]=some[1]
                elif listss[some[0]-1]!="unknown":
                    if listss[some[0]-1]!=some[1]:
                        flag=False
                        break

    if flag:
        flags=True
        for i in range(n):
            if  listss[i]!="unknown" and listss[i]!=int(string[i]):
                flags=False
        if flags:
            ans=max(ans,subans)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

input=sys.stdin.readline

h, w = map(int, input().split())

a = [list(map(int, input().split())) for _ in range(h)]

b = [list(map(int, input().split())) for _ in range(h)]

dp = [[[False for i in range(80 * h + 80 * w + 1)] for _ in range(1 + w)] for j in range(1 + h)]
# dp[i][j][k]=マスの(i,j)において絶対値をkにすることができるかどうか
dp[0][0][0] = True
dp[1][0][0] = True
dp[0][1][0] = True

# 初期値の設定
for i in range(1, h + 1):
    for j in range(1, w + 1):
      
        a_num = a[i - 1][j - 1]
        b_num = b[i - 1][j - 1]
        dif = a_num - b_num
        if i == 1:
            for k in range(80 * i + 80 * j - 79):
                if dp[1][j - 1][abs(k - dif)] or dp[1][j - 1][abs(k + dif)]:
                    dp[1][j][abs(k)] = True

        elif j == 1:
            for k in range(80 * i + 80 * j - 79):
                if dp[i - 1][1][abs(k - dif)] or dp[i - 1][1][abs(k + dif)]:
                    dp[i][1][k] = True

        else:
            for k in range(80 * i + 80 * j - 79):
                if dp[i - 1][j][abs(k - dif)] or dp[i - 1][j][abs(k + dif)] or dp[i][j - 1][abs(k - dif)] or dp[i][j - 1][abs(k + dif)]:
                    dp[i][j][k] = True

ans = 0
for i in range(80 * h + 80 * w + 1):
    if dp[h][w][i]:
        ans = i
        break

print(ans)


Fixed submission:
# Atcoder Problem Solving
H,W=map(int,input().split())
c=[list(map(int,input().split())) for i in range(H)]
b=[list(map(int,input().split())) for i in range(H)]
a=[[0 for i  in range(W)] for j in range(H)]

for i in range(H):
    for j in range(W):
        a[i][j]=abs(c[i][j]-b[i][j])
        
dp=[[0 for i in range(W)] for j in range(H)]

# Bitset演算
# 答えは絶対値が絶対-80から80以内に収まる

X=3200

dp[0][0]= (1<<(X+a[0][0]))  | (1<<(X-a[0][0]))
# 初期化の条件

for i in range(H):
    for j in range(W):
        if 0<=i<H and 0<=j+1<W:
            dp[i][j+1]|=(dp[i][j]<<a[i][j+1])
            dp[i][j+1]|=(dp[i][j]>>a[i][j+1]) 
            
        if 0<=i+1<H and 0<=j<W:
            dp[i+1][j]|=(dp[i][j]<<a[i+1][j])
            dp[i+1][j]|=(dp[i][j]>>a[i+1][j])
            
A=str(bin(dp[H-1][W-1]))[::-1]
L=len(A)
ans=3200
for i in range(L):
    if A[i]=="1":
        ans=min(ans,abs(i-X))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# Sum Difference
N, X, D = map(int, input().split())
if D < 0:
    X, D = -X, -D
# D>=0 として一般性を失わない
if D == 0:
    Sets = set()
    for i in range(N+1):
        Sets.add(i*X)
    print(len(Sets))
    exit()

# D>0
ans = 0
Sets = set()

#TLE O(N**3)
for j in range(N+1):
    for k in range((j-1)*j//2, (2*N-1-j)*j//2+1):
        Sets.add(X*j+D*k)
print(len(Sets))

Fixed submission:
# Sum Difference
from collections import defaultdict
N, X, D = map(int, input().split())
if D < 0:
    X, D = -X, -D

if D == 0:
    Sets = set()
    for i in range(N+1):
        Sets.add(i*X)
    print(len(Sets))
    exit()

# D>0
ans = 0
Mode = defaultdict(list)
for i in range(N+1):
    L = (i*X+D*i*(i-1)//2-i*X % D)//D
    R = (i*X+D*i*(2*N-1-i)//2-i*X % D)//D
    Mode[i*X % D].append((L, 1))
    Mode[i*X % D].append((R+1, -1))
Data = []
for key in Mode.keys():
    Mode[key].sort()
    cnt = 1
    sums = Mode[key][0][0]
    for num, which in Mode[key][1:]:
        Data.append((sums, num, cnt))
        cnt += which
        sums = num
ans = 0
for l, r, v in Data:
    if v > 0:
        ans += r-l
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
S=input()

ans=0
for i in range(1000):
    j="0"*(3-len(str(i)))+str(i)
    flag1=False
    flag2=False
    flag3=False
    for i in range(n):
        if not flag1 and S[i]==j[0]:
            flag1=True
            continue
        if flag1 and not flag2:
            if S[i]==j[1]:
                flag2=True
                continue
        if flag2 and not flag3:
            if S[i]==j[2]:
                flag3=True
                break
    if flag3:
        ans+=1
print(ans)

Fixed submission:
n=int(input())
S=input()
ans=0
sublist=[]
for i in range(100):
    used=0
    j="0"*(2-len(str(i)))+str(i)
    flag1=False
    flag2=False
    for i in range(n):
        if not flag1 and S[i]==j[0]:
            flag1=True
            continue
        if flag1 and not flag2:
            if S[i]==j[1]:
                flag2=True
                used=i+1
    if flag2:
        sublist.append((j,used))
anslist=[]
for some in sublist:
    a1=some[0]
    index=some[1]
    lis=[0 for i in range(10)]
    for j in range(index,n):
        anslist.append(a1+S[j])
anslist=set(anslist)
print(len(anslist))
Buggy python submission (verdict: Runtime Error):
import math
t1,t2=map(int,input().split())
a1,a2=map(int,input().split())
b1,b2=map(int,input().split())
dis=abs(a1-b1)*t1
oi=abs(a2-b2)*t2
if oi==0:
    print("infinity")
else:
    print(math.ceil(dis/abs(oi-dis))

Fixed submission:

#atcoder 
t1,t2=map(int,input().split())
a1,a2=map(int,input().split())
b1,b2=map(int,input().split())

d1=a1-b1
d2=a2-b2

if d1*d2>0:
    print(0)
else:
    if d1>0 and d2<0:
        plus=d1*t1+d2*t2
        if plus>0:
            print(0)
        elif plus==0:
            print("infinity")
        elif plus<0:
            d=-plus
            k=d1*t1
            if k%d==0:
                print(2*k//d)
            else:
                print(2*(k//d)+1)
    else:
        d1=-d1
        d2=-d2
        plus=d1*t1+d2*t2
        if plus>0:
            print(0)
        elif plus==0:
            print("infinity")
        elif plus<0:
            d=-plus
            k=d1*t1
            if k%d==0:
                print(2*k//d)
            else:
                print(2*(k//d)+1)
Buggy python submission (verdict: Runtime Error):

# shortest path on line

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

graph = {i: {} for i in range(1, n + 1)}

for i in range(1, n):
    graph[i + 1][i] = 0

for _ in range(m):
    l, r, c = map(int, input().split())
    graph[l][r] = c


###############################################################

import heapq

def dijkstra(s, graph, n):
    # ｓからのグラフの最短最短距離をまとめたデータを返す
    dist = [10**20 for i in range(n + 1)]
    dist[s] = 0
    pq = []
    heapq.heapify(pq)
    # 全ての接点を一度優先度付きキューに挿入する
    heapq.heappush(pq, (0, s))
    while pq:
        x = heapq.heappop(pq)
        node, mini_dis = x[1], x[0]
        for point in graph[node].keys():
            w = graph[node][point]
            # nodeからpointに対して伸びる辺の長さ
            newlen = dist[node] + w
            if newlen < dist[point]:
                heapq.heappush(pq, (newlen, point))
                dist[point] = newlen

    return dist
###############################################################


a = dijkstra(1, graph, n)
if a[n]>=10**20:
    print(-1)
else:
    print(a[n])
    


Fixed submission:
n=int(input())
print((n-1)//2)

Buggy python submission (verdict: Runtime Error):
n=int(input())
lists=list(map(int,input().split()))
a=lists.copy()
anslist=[0 for i in range(n+1)]
for j in lists:
    anslist[j]+=1
if anslist[0]!=1:
    print(0)
else:
    ans=1
    for j in range(n):
            for k in range(anslist[j+1]):
                ans=anslist[j]*ans
                ans=ans%(998244353)
    if a[0]!=0:
      print(0)
    else:
      print(ans)


Fixed submission:
n=int(input())
print((n-1)//2)