stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<iostream>

#include<queue>

#include<functional>

#include<cstring>



using namespace std;



#define maxn 10240 

#define INF 0x3f3f3f3f;



typedef struct edge{

	int to,dis,cos;

	edge(){}

	edge(int to,int dis,int cos):to(to),dis(dis),cos(cos){}

};

typedef pair<int ,int> P;



vector<edge>G[maxn];



int d[maxn];

int v;//定点



void dijkstra(int s){

	priority_queue<P,vector<P>,greater<P> > que;//优先输出小数据；

	memset(d,0x3f,sizeof(d));

	d[s]=0;

	que.push(P(0,s));

	while(!que.empty())

	{

		P p=que.top();

		que.pop();

		int v=p.second;

		if(d[v]<p.first)continue;

		for(int i=0;i<G[v].size();i++)

		{

			edge e=G[v][i];

			if(d[e.to]>d[v]+e.dis)

			{

				d[e.to]=d[v]+e.dis;

				que.push(P(d[e.to],e.to));

			}

		}

	}	

} 

int main()

{

	int m;

	while(cin>>v>>m)

	{

		if(v==0&&m==0)break;

		for(int i=0;i<v;i++)

		{

			G[i].clear();

		}

		for(int i=0;i<m;i++)

		{

			int u,v,d,c;

			cin>>u>>v>>d>>c;

			u--,v--;

			G[u].push_back(edge(v,d,c));

			G[v].push_back(edge(u,d,c)); 

		}

		dijkstra(0);

		int ans=0;

		for(int i=1;i<v;i++)

		{

			int min=INF;

			for (int j=0;j<G[i].size();j++)

			{

				if(d[G[i][j].to]+G[i][j].dis==d[i]&&G[i][j].cos<min)

				{

					min=G[i][j].cos;

				}

				

			} 

			ans+=min;

		}cout<<ans<<endl;

	}

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.1155602665652147x):
#include<stdio.h>

#include<string.h>  

#include<math.h>  

  

//#include<map>   

//#include<set>

#include<deque>  

#include<queue>  

#include<stack>  

#include<bitset> 

#include<string>  

#include<iostream>  

#include<algorithm>  

using namespace std;  

  

#define ll long long  

#define INF 0x3f3f3f3f  

#define mod 1000000

#define clean(a,b) memset(a,b,sizeof(a))// 水印 



struct node{

	int to,next,dis,cost;

}edge[40100];

int head[10100];

int dis[10100],cost[10100];

bool vst[10100];

int n,m,k;



void spfa(int x)

{

	clean(dis,INF);

	clean(cost,INF);

	clean(vst,0);

	queue<int> q;

	dis[x]=0;

	cost[x]=0;

	q.push(x);

	while(!q.empty())

	{

		x=q.front();q.pop();

		vst[x]=0;

		for(int i=head[x];i!=-1;i=edge[i].next)

		{

			node b=edge[i];

			if(dis[b.to]>dis[x]+b.dis)

			{

				if(!vst[b.to])

				{

					vst[b.to]=1;

					q.push(b.to);

				}

				dis[b.to]=dis[x]+b.dis;

				cost[b.to]=b.cost;

			}

			else if(dis[b.to]==dis[x]+b.dis)

			{

				if(cost[b.to]>b.cost)

					cost[b.to]=b.cost;

			}

		}

	}

}



void add(int a,int b,int dis,int cost)

{

	edge[k].to=b;

	edge[k].dis=dis;

	edge[k].cost=cost;

	edge[k].next=head[a];

	head[a]=k;

	k++;

}



int main()

{

	while(cin>>n>>m&&n!=0||m!=0)

	{

		clean(head,-1);

		k=0;

		for(int i=0;i<m;++i)

		{

			int a,b,d,c;

			cin>>a>>b>>d>>c;

			add(a,b,d,c);

			add(b,a,d,c);

		}

		spfa(1);

		ll res=0;

		for(int i=1;i<=n;++i)

			res=res+cost[i];

		cout<<res<<endl;

	}

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;

#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)

#define REP(i,a,b) REPP(i,a,b,1)

#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)

#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) REP(i,0,(int)a-1)

#define FORD(i,a) REV(i,(int)a-1,0)

#define PB push_back

#define POB pop_back

#define MP make_pair

#define FI first

#define SE second

typedef long long ll;

typedef unsigned long long ull;

typedef pair < int , int > pii;

typedef vector < int > vi;

typedef vector < pii > vii;

typedef vector < ll > vl;



const double EPS = 1e-9;

const double PI = acos(-1);

const int INF = 1e9;

const ll MOD = 1e9 + 7;



ll addMod(ll a, ll b){

	return (a+b) % MOD;

}



ll mulMod(ll a, ll b){

	return (a*b) % MOD;

}



/////////////////////////////////////////////////////////



ll cnt[15];

ll h,w,n;

map < pii , bool > flag;

int dy[] = {-2,-2,-2,-1,-1,-1,0,0,0};

int dx[] = {-2,-1,0,-2,-1,0,-2,-1,0};



bool inRange(int y, int x){

	return y > 0 && y <= h && x > 0 && x <= w;

}



int getCnt(int ty, int tx, int ny, int nx){

	int ret = 0;

	REP(i,ty,ny){

		REP(j,tx,nx){

			if(flag[MP(i,j)]) ret++;

		}

	}

	return ret;

}



void update(int y, int x){

	FOR(i,9){

		int ty = y + dy[i];

		int tx = x + dx[i];

		int ny = ty + 2;

		int nx = tx + 2;

		if(inRange(ty,tx) && inRange(ny,nx)){

			int bef = getCnt(ty,tx,ny,nx);

			cnt[bef]--;

			cnt[bef+1]++;

		}

	}

	flag[MP(y,x)] = true;

}



int main(){

	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin >> h >> w >> n;

	cnt[0] = (h-2) * (w - 2);

	int y,x;

	FOR(i,n){

		cin >> y >> x;

		update(y,x);

	}

	FOR(i,10) cout << cnt[i] << endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.1277654234568655x):
#include<map>

#include<cstdio>

using namespace std;

typedef pair<int,int> pii;

typedef long long ll;

map<pii,int> mp;

long long cnt[10],h,w,n;

int max(int x,int y)

{

 return (x>=y)? x:y;

}

int min(int x,int y)

{

  return (x<y)? x:y;

}

inline int read(){

   int s=0,w=1;

   char ch=getchar();

   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}

   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();

   return s*w;

}

int main()

{   

	h=read(),w=read(),n=read();

    int i,j;

while(n--)

{

  int x=read(),y=read();

  for (i=max(1,x-2);i<=min(h-2,x);++i)

  {

    for (j=max(1,y-2);j<=min(w-2,y);++j)

	{

      mp[pii(i,j)]++; 

    }

    }

  }

for (map<pii,int>::iterator iter=mp.begin();iter!=mp.end();iter++) cnt[iter->second]++,n++;

ll ans=1ll*(h-2)*(w-2);

 printf("%lld\n",ans-n-1);

for (i=1;i<=9;++i) printf("%lld\n",cnt[i]);

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;

#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)

#define REP(i,a,b) REPP(i,a,b,1)

#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)

#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) REP(i,0,(int)a-1)

#define FORD(i,a) REV(i,(int)a-1,0)

#define PB push_back

#define POB pop_back

#define MP make_pair

#define FI first

#define SE second

typedef long long ll;

typedef unsigned long long ull;

typedef pair < int , int > pii;

typedef vector < int > vi;

typedef vector < pii > vii;

typedef vector < ll > vl;



const double EPS = 1e-9;

const double PI = acos(-1);

const int INF = 1e9;

const ll MOD = 1e9 + 7;



ll addMod(ll a, ll b){

	return (a+b) % MOD;

}



ll mulMod(ll a, ll b){

	return (a*b) % MOD;

}



/////////////////////////////////////////////////////////



ll cnt[15];

ll h,w,n;

map < pii , bool > flag;

int dy[] = {-2,-2,-2,-1,-1,-1,0,0,0};

int dx[] = {-2,-1,0,-2,-1,0,-2,-1,0};



bool inRange(int y, int x){

	return y > 0 && y <= h && x > 0 && x <= w;

}



int getCnt(int ty, int tx, int ny, int nx){

	int ret = 0;

	REP(i,ty,ny){

		REP(j,tx,nx){

			if(flag[MP(i,j)]) ret++;

		}

	}

	return ret;

}



void update(int y, int x){

	FOR(i,9){

		int ty = y + dy[i];

		int tx = x + dx[i];

		int ny = ty + 2;

		int nx = tx + 2;

		if(inRange(ty,tx) && inRange(ny,nx)){

			int bef = getCnt(ty,tx,ny,nx);

			cnt[bef]--;

			cnt[bef+1]++;

		}

	}

	flag[MP(y,x)] = true;

}



int main(){

	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin >> h >> w >> n;

	cnt[0] = (h-2) * (w - 2);

	int y,x;

	FOR(i,n){

		cin >> y >> x;

		update(y,x);

	}

	FOR(i,10) cout << cnt[i] << endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.28447511047163x):
#include<stdio.h>

#include<stdlib.h>

#include<string.h>

#include<algorithm>

using namespace std;

#define INF (int(1e9)+7)//1e9+7进制

#define maxn (int(1e6)+5)

typedef long long ll;

ll node[maxn];

ll res[15];

int main(void)

{

	ll H, W, N;

	scanf("%lld %lld %lld", &H, &W, &N);

	int cnt = 0;

	while (N--)

	{

		ll a, b;

		scanf("%lld %lld", &a, &b);

		for (int i = -1; i <= 1; i++)

			for (int j = -1; j <= 1; j++)

				if (a + i >= 2 && a + i <= H - 1 && b + j >= 2 && b + j <= W - 1)

					node[cnt++] = (a + i) * INF + (b + j);

	}

	sort(node, node + cnt);

	ll temp = node[0];

	ll sum = 1;

	for (int i = 1; i < cnt; i++) {

		if (node[i] == temp)

			sum++;

		else

			res[sum]++, sum = 1, temp = node[i];

	}

	if(cnt)res[sum]++;

	res[0] = (H - 2) * (W - 2);

	for (int i = 1; i <= 9; i++)

		res[0] -= res[i];

	for (int i = 0; i <= 9; i++)

		printf("%lld\n", res[i]);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define int long long

#define rg register

#define file(x) freopen(x".in","r",stdin);freopen(x".out","w",stdout);

using namespace std;

const int N=200000+10;

const int mod=1e9+7;

const int inf=1e10;

int read(){

    int x=0,f=1;char c=getchar();

    while(c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar();

    while(c>='0'&&c<='9') x=x*10+c-48,c=getchar();

    return f*x;

}

int X[N],Y[N],W,H,n,res;

map<int,int> Map,f;

void calc(int x,int y){

	int X1,Y1,X2,Y2;

	for(int i=1;i<=3;i++)

		for(int j=1;j<=3;j++){

			if(i==1&&j==1) X1=x-2,Y1=y-2,X2=x,Y2=y;

			if(i==1&&j==2) X1=x,Y1=y-2,X2=x+2,Y2=y;

			if(i==1&&j==3) X1=x-1,Y1=y-2,X2=x+1,Y2=y;

			if(i==2&&j==1) X1=x-2,Y1=y,X2=x,Y2=y+2;

			if(i==2&&j==2) X1=x,Y1=y,X2=x+2,Y2=y+2;

			if(i==2&&j==3) X1=x-1,Y1=y,X2=x+1,Y2=y+2;

			if(i==3&&j==1) X1=x-2,Y1=y-1,X2=x,Y2=y+1;

			if(i==3&&j==2) X1=x,Y1=y-1,X2=x+2,Y2=y+1;

			if(i==3&&j==3) X1=x-1,Y1=y-1,X2=x+1,Y2=y+1;

			if(X1<1||Y1<1||X2>H||Y2>W) continue;

			if(f[X1*inf+Y1]) continue;

			f[X1*inf+Y1]=1;

			int ans=0;

			res++;

			for(int i=X1;i<=X2;i++)

				for(int j=Y1;j<=Y2;j++)

					if(Map[i*inf+j])

						ans++;

			//		if(ans==0) cout<<x<<" "<<y<<" "<<X1<<" "<<Y1<<" "<<X2<<" "<<Y2<<endl;

			f[ans]++;

		}

}

main(){

	H=read(),W=read(),n=read();

	for(int i=1;i<=n;i++)

		X[i]=read(),Y[i]=read(),Map[X[i]*inf+Y[i]]=1;

	for(int i=1;i<=n;i++)

		calc(X[i],Y[i]);

//	exit(0);

	cout<<(H-2)*(W-2)-res<<endl;

	for(int i=1;i<=9;i++)

		cout<<f[i]<<endl;

}


// Faster C++ solution for the same problem (measured speedup: 5.1590037932858275x):
#include<stdio.h>

#include<stdlib.h>

#include<string.h>

#include<algorithm>

using namespace std;

#define INF (int(1e9)+7)//1e9+7进制

#define maxn (int(1e6)+5)

typedef long long ll;

ll node[maxn];

ll res[15];

int main(void)

{

	ll H, W, N;

	scanf("%lld %lld %lld", &H, &W, &N);

	int cnt = 0;

	while (N--)

	{

		ll a, b;

		scanf("%lld %lld", &a, &b);

		for (int i = -1; i <= 1; i++)

			for (int j = -1; j <= 1; j++)

				if (a + i >= 2 && a + i <= H - 1 && b + j >= 2 && b + j <= W - 1)

					node[cnt++] = (a + i) * INF + (b + j);

	}

	sort(node, node + cnt);

	ll temp = node[0];

	ll sum = 1;

	for (int i = 1; i < cnt; i++) {

		if (node[i] == temp)

			sum++;

		else

			res[sum]++, sum = 1, temp = node[i];

	}

	if(cnt)res[sum]++;

	res[0] = (H - 2) * (W - 2);

	for (int i = 1; i <= 9; i++)

		res[0] -= res[i];

	for (int i = 0; i <= 9; i++)

		printf("%lld\n", res[i]);

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

#include<algorithm>

using namespace std;

#define in read()

#define re register

#define fur(i,a,b) for(re int i=a;i<=b;++i)

#define fdr(i,a,b) for(re int i=a;i>=b;--i)

#define cl(a,b) memset(a,b,sizeof(a))

#define jinitaimei signed

#define int long long

inline int read()

{

	int x=0;

	char ch=getchar();

	for(;!isalnum(ch);ch=getchar());

	for(;isalnum(ch);ch=getchar()) x=x*10+ch-'0';

	return x;

}

const int xx=1e5+1;

struct point

{

	int x,y;

}tmp[xx],check[xx*9];

int w,h,n;

inline int num(point a){return (a.x-1)*w+a.y;}

inline bool cmp(point a,point b){return num(a)<num(b);}

inline bool cmpp(point a,point b){return a.x<b.x;}

inline int look_up(int k)

{

	int hd=1,tl=n,ans=n+1;

	while(hd<=tl)

	{

		int mid=hd+tl>>1;

		if(num(tmp[mid])>=k) ans=mid,tl=mid-1;

		else hd=mid+1;

	}

	return ans;

}

inline int look_down(int k)

{

	int hd=1,tl=n,ans=0;

	while(hd<=tl)

	{

		int mid=hd+tl>>1;

		if(num(tmp[mid])<=k) ans=mid,hd=mid+1;

		else tl=mid-1;

	}

	return ans;

}

int res[10],all=0;

jinitaimei main()

{

	h=in;w=in;n=in;

	fur(i,1,n) tmp[i]=(point){in,in};

	sort(tmp+1,tmp+n+1,cmp);

	res[0]=(w-2)*(h-2);

	fur(i,1,n) fur(x,tmp[i].x-2,tmp[i].x) fur(y,tmp[i].y-2,tmp[i].y) if(x>0&&y>0)

	{

		int ch=num((point){x,y});

		int chh=num(tmp[i]);

		int delta=chh-ch;

		if(delta/w>2||delta%w>2) continue;

		if(x+2>h||y+2>w) continue;

		int cnt=0;

		fur(k,0,2)

		{

			int l=look_up(ch+k*w),r=look_down(ch+k*w+2);

			cnt+=(r-l+1);

		}

		if(cnt>0) check[++all]=(point){ch,cnt};

	}

	sort(check+1,check+all+1,cmpp);

	fur(i,1,all)

	{

		while(check[i].x==check[i+1].x) ++i;

		++res[check[i].y];

		--res[0];

	}

	fur(i,0,9) printf("%lld\n",res[i]);

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.049353947121482x):
#include<stdio.h>

#include<stdlib.h>

#include<string.h>

#include<algorithm>

using namespace std;

#define INF (int(1e9)+7)//1e9+7进制

#define maxn (int(1e6)+5)

typedef long long ll;

ll node[maxn];

ll res[15];

int main(void)

{

	ll H, W, N;

	scanf("%lld %lld %lld", &H, &W, &N);

	int cnt = 0;

	while (N--)

	{

		ll a, b;

		scanf("%lld %lld", &a, &b);

		for (int i = -1; i <= 1; i++)

			for (int j = -1; j <= 1; j++)

				if (a + i >= 2 && a + i <= H - 1 && b + j >= 2 && b + j <= W - 1)

					node[cnt++] = (a + i) * INF + (b + j);

	}

	sort(node, node + cnt);

	ll temp = node[0];

	ll sum = 1;

	for (int i = 1; i < cnt; i++) {

		if (node[i] == temp)

			sum++;

		else

			res[sum]++, sum = 1, temp = node[i];

	}

	if(cnt)res[sum]++;

	res[0] = (H - 2) * (W - 2);

	for (int i = 1; i <= 9; i++)

		res[0] -= res[i];

	for (int i = 0; i <= 9; i++)

		printf("%lld\n", res[i]);

	return 0;

}
// Slower C++ solution:
#include<map>

#include<cstdio>

using namespace std;

typedef pair<int,int> pii;

typedef long long ll;

map<pii,int> mp;

long long cnt[10],h,w,n;

int max(int x,int y)

{

 return (x>=y)? x:y;

}

int min(int x,int y)

{

  return (x<y)? x:y;

}

inline int read(){

   int s=0,w=1;

   char ch=getchar();

   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}

   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();

   return s*w;

}

int main()

{   

	h=read(),w=read(),n=read();

    int i,j;

while(n--)

{

  int x=read(),y=read();

  for (i=max(1,x-2);i<=min(h-2,x);++i)

  {

    for (j=max(1,y-2);j<=min(w-2,y);++j)

	{

      mp[pii(i,j)]++; 

    }

    }

  }

for (map<pii,int>::iterator iter=mp.begin();iter!=mp.end();iter++) cnt[iter->second]++,n++;

ll ans=1ll*(h-2)*(w-2);

 printf("%lld\n",ans-n-1);

for (i=1;i<=9;++i) printf("%lld\n",cnt[i]);

}

// Faster C++ solution for the same problem (measured speedup: 4.685792808112058x):
#include<stdio.h>

#include<stdlib.h>

#include<string.h>

#include<algorithm>

using namespace std;

#define INF (int(1e9)+7)//1e9+7进制

#define maxn (int(1e6)+5)

typedef long long ll;

ll node[maxn];

ll res[15];

int main(void)

{

	ll H, W, N;

	scanf("%lld %lld %lld", &H, &W, &N);

	int cnt = 0;

	while (N--)

	{

		ll a, b;

		scanf("%lld %lld", &a, &b);

		for (int i = -1; i <= 1; i++)

			for (int j = -1; j <= 1; j++)

				if (a + i >= 2 && a + i <= H - 1 && b + j >= 2 && b + j <= W - 1)

					node[cnt++] = (a + i) * INF + (b + j);

	}

	sort(node, node + cnt);

	ll temp = node[0];

	ll sum = 1;

	for (int i = 1; i < cnt; i++) {

		if (node[i] == temp)

			sum++;

		else

			res[sum]++, sum = 1, temp = node[i];

	}

	if(cnt)res[sum]++;

	res[0] = (H - 2) * (W - 2);

	for (int i = 1; i <= 9; i++)

		res[0] -= res[i];

	for (int i = 0; i <= 9; i++)

		printf("%lld\n", res[i]);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;



typedef long long ll;



const int N=200050;

const ll MOD=1e9+7;

int n;

int a[N],p[N];

ll f[N];



int main(){

	scanf("%d",&n);

	for (int i=1;i<=n;++i) scanf("%d",&a[i]);

	f[0]=0;f[1]=1;

	memset(p,0,sizeof(p));p[a[1]]=1;

	for (int i=2;i<=n;++i){

		f[i]=f[i-1];

		if (a[i]!=a[i-1])

			f[i]=(f[i]+f[p[a[i]]])%MOD;

		p[a[i]]=i;

	}

	printf("%lld\n",f[n]);

}

// Faster C++ solution for the same problem (measured speedup: 1.7847716380432086x):
#include<iostream>

 using namespace std;

 const long long mod = 1e9 + 7;

 int a[200005], b[200005], c[200005];

 long long num[200005];

int main() 

{

	 int n, k = 1;

	 cin >> n;

     for (int i = 1; i <= n; i++) 

		 scanf("%d", &a[i]);

	 c[1] = a[1];

	 int t = 1;

	 for (int i = 2; i <= n; i++) 

	 {

		 if (a[i] != c[t])

			 c[++t] = a[i];

	

	  }

	  num[0] = 1;

	  for (int i = 1; i <= t; i++) {

		   if (b[c[i]])

			   num[i] = (num[i - 1] + num[b[c[i]]]) % mod;

		   else num[i] = num[i - 1];

		       num[i] %= mod;

		       b[c[i]] = i;

		

	  }

	  cout << num[t] << endl;

	  return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;



typedef long long ll;



const int N=200050;

const ll MOD=1e9+7;

int n;

int a[N],p[N];

ll f[N];



int main(){

	scanf("%d",&n);

	for (int i=1;i<=n;++i) scanf("%d",&a[i]);

	f[0]=0;f[1]=1;

	memset(p,0,sizeof(p));p[a[1]]=1;

	for (int i=2;i<=n;++i){

		f[i]=f[i-1];

		if (a[i]!=a[i-1])

			f[i]=(f[i]+f[p[a[i]]])%MOD;

		p[a[i]]=i;

	}

	printf("%lld\n",f[n]);

}

// Faster C++ solution for the same problem (measured speedup: 9.36095447905552x):
#include <algorithm>

#include <cstdio>

using namespace std;

const int M = 1000000007;

const int N = 2e5 + 10;

int n, dp[N], s[N], c[N];

int main() {

	scanf("%d", &n); dp[0] = 1;

	for(int i = 1; i <= n; i ++) {

		scanf("%d", c + i);

		if(c[i] == c[i - 1]) {

			i --; n --;

		}

	}

	for(int i = 1; i <= n; i ++) {

		dp[i] = (s[c[i]] + dp[i - 1]) % M;

		(s[c[i]] += dp[i - 1]) %= M;

	}

	printf("%d\n", dp[n]);

	return 0;

}
// Slower C++ solution:
#include<iostream>

 using namespace std;

 const long long mod = 1e9 + 7;

 int a[200005], b[200005], c[200005];

 long long num[200005];

int main() 

{

	 int n, k = 1;

	 cin >> n;

     for (int i = 1; i <= n; i++) 

		 scanf("%d", &a[i]);

	 c[1] = a[1];

	 int t = 1;

	 for (int i = 2; i <= n; i++) 

	 {

		 if (a[i] != c[t])

			 c[++t] = a[i];

	

	  }

	  num[0] = 1;

	  for (int i = 1; i <= t; i++) {

		   if (b[c[i]])

			   num[i] = (num[i - 1] + num[b[c[i]]]) % mod;

		   else num[i] = num[i - 1];

		       num[i] %= mod;

		       b[c[i]] = i;

		

	  }

	  cout << num[t] << endl;

	  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.2449032019125434x):
#include <algorithm>

#include <cstdio>

using namespace std;

const int M = 1000000007;

const int N = 2e5 + 10;

int n, dp[N], s[N], c[N];

int main() {

	scanf("%d", &n); dp[0] = 1;

	for(int i = 1; i <= n; i ++) {

		scanf("%d", c + i);

		if(c[i] == c[i - 1]) {

			i --; n --;

		}

	}

	for(int i = 1; i <= n; i ++) {

		dp[i] = (s[c[i]] + dp[i - 1]) % M;

		(s[c[i]] += dp[i - 1]) %= M;

	}

	printf("%d\n", dp[n]);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;



typedef long long ll;



const int N=200050;

const ll MOD=1e9+7;

int n;

int a[N],p[N];

ll f[N];



int main(){

	scanf("%d",&n);

	for (int i=1;i<=n;++i) scanf("%d",&a[i]);

	f[0]=0;f[1]=1;

	memset(p,0,sizeof(p));p[a[1]]=1;

	for (int i=2;i<=n;++i){

		f[i]=f[i-1];

		if (a[i]!=a[i-1])

			f[i]=(f[i]+f[p[a[i]]])%MOD;

		p[a[i]]=i;

	}

	printf("%lld\n",f[n]);

}

// Faster C++ solution for the same problem (measured speedup: 1.7900298068804084x):
#include <bits/stdc++.h>

using namespace std;

#define LL long long



int N;

int A[200010], pre[200010], suc[200010], H[200010], f[200010];

LL pp = (1e9) + 7;



int main(){

	cin >> N;

	for (int i = 1; i <= N; i++){

		cin >> A[i];

		pre[i] = H[A[i]];

		suc[H[A[i]]] = i;

		H[A[i]] = i;

	}

	f[N] = 1;

	for (int i = N - 1; i >= 1; i--){

		f[i] = f[i + 1];

		if ((suc[i] != 0) & (suc[i] > i + 1))

			f[i] = (f[i] + f[suc[i]]) % pp;

	}

	cout << f[1] << endl;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



#define int long long

#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)

#define all(x) (x).begin(),(x).end()

#define sz(x) ((int)x.size())

template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}

template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}



typedef pair<int, int> pii;

typedef vector<int> vi;

typedef vector<vi> vvi;



const int inf = 1LL<<60;

const int mod = 1e9 + 7;

const double eps = 1e-9;



/*{

  }*/



signed main(){

  int n;

  cin >> n;



  vi c(n);

  rep(i, 0, n) cin >> c[i];



  vi places[200001];

  vi dp(200001);



  rep(i, 0, n) places[c[i]].emplace_back(i);



  dp[0] = 1;

  rep(i, 1, n+1){

    (dp[i] += dp[i-1]) %= mod;



    int color = c[i-1];

    int it = lower_bound(all(places[color]), i-1) - places[color].begin();

    if(it > 0){

      int j = places[color][it-1];

      if((i-1) - j > 1) (dp[i] += dp[j+1]) %= mod;

    }

  }



  cout << dp[n] << endl;



  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 3.201593204285123x):
#include <bits/stdc++.h>

using namespace std;



#define int long long

#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)

#define all(x) (x).begin(),(x).end()

#define sz(x) ((int)x.size())

template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}

template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}



typedef pair<int, int> pii;

typedef vector<int> vi;

typedef vector<vi> vvi;



const int inf = 1LL<<60;

const int mod = 1e9 + 7;

const double eps = 1e-9;



/*{

  1 2 3

  1   2

  }*/



signed main(){

  int n;

  cin >> n;



  vi c(n);

  rep(i, 0, n) cin >> c[i];



  vi dp(n+1); 

  vi prev(200001, -1);

  dp[0] = 1;

  rep(i, 1, n+1){

    (dp[i] += dp[i-1]) %= mod;

    

    int &p = prev[c[i-1]];

    if(p != -1 and i-p > 1){

      (dp[i] += dp[p]) %= mod;

    }



    p = i;

  }



  cout << dp[n] << endl;



  return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

const int M = 2e5 + 5;

const int P = 1e9 + 7;

int a[M], w[M], dp[M];

inline int Mod(int x) {

	return x >= P ? x - P : x;

}

int main() {

	int n; cin >> n;

    for (int i = 1; i <= n; ++i) scanf("%d", a + i);

	dp[n] = w[a[n]] = 1;

	for (int i = n - 1; i > 0; --i) {

        if (a[i] == a[i + 1]){dp[i] = dp[i + 1];continue;}

		dp[i] = Mod(dp[i + 1] + w[a[i]]);

		w[a[i]] = dp[i];

	}

	cout << dp[1] << endl;

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.242094825350033x):
#include <cstdio>

#include <algorithm>

using namespace std;

#define N 200000 + 5

#define Mod 1000000007



int n, Dp[N], Last[N];



int main()

{

	scanf("%d", &n);

	Dp[0] = 1;

	for (int i = 1, x; i <= n; i ++)

	{

		scanf("%d", &x);

		Dp[i] = Dp[i - 1];

		if (Last[x] && Last[x] != i - 1)

			Dp[i] = (Dp[i] + Dp[Last[x]]) % Mod;

		Last[x] = i;

	}

	printf("%d\n", Dp[n]);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

const int M = 2e5 + 5;

const int P = 1e9 + 7;

int a[M], w[M], dp[M];

inline int Mod(int x) {

	return x >= P ? x - P : x;

}

int main() {

	int n; cin >> n;

    for (int i = 1; i <= n; ++i) scanf("%d", a + i);

	dp[n] = w[a[n]] = 1;

	for (int i = n - 1; i > 0; --i) {

        if (a[i] == a[i + 1]){dp[i] = dp[i + 1];continue;}

		dp[i] = Mod(dp[i + 1] + w[a[i]]);

		w[a[i]] = dp[i];

	}

	cout << dp[1] << endl;

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.253273291025995x):
#include<cstdio>

#include<vector>

#define ll long long

#define rep(i, l, r) for(int i=l; i<=r; ++i)

#define N 200005

#define mod 1000000007

using namespace std;

int t;

int n;

int a[N];

int dp[N];

int f[N];

int main() {

	scanf("%d", &n);

	rep(i, 1, n) scanf("%d", &a[i]);

	dp[0]=1;

	rep(i, 1, n){

		dp[i]=0;

		if(i==1 || a[i-1]!=a[i]) f[a[i]]=(f[a[i]]+dp[i-1])%mod;

		dp[i]=(dp[i]+f[a[i]])%mod;

	}

	printf("%d", dp[n]);

	return 0;

}