///1001 简单那字符串处理
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
ll a,b,ans;
while(scanf("%lld%lld",&a,&b)!=EOF){
string s,s1;
ans=a+b;
if(ans<0)cout<<'-';
if(ans==0){cout<<0<<endl; continue;}
ans=abs(ans);
while(ans){int t=ans%10;ans/=10;s+=(char)(t+48);}
int len=s.length();
for(int i=0;i<len;i++){s1+=s[i];if((i+1)%3==0&&i<len-1)s1+=',';}
reverse(s1.begin(),s1.end());
cout<<s1<<endl;
}
return 0;
}
///1102 简单哈希
#include<bits/stdc++.h>
using namespace std;
const int maxn =10010;
typedef long long ll;
int n,m;
double ans[maxn];
int main(){
scanf("%d",&n);
int maxt=0,cnt=0;
memset(ans,0,sizeof(ans));
for(int i=0;i<n;i++){
int a;double b;
scanf("%d%lf",&a,&b);
ans[a]+=b;
maxt=max(maxt,a);
}
scanf("%d",&m);
for(int i=0;i<m;i++){
int a;double b;
scanf("%d%lf",&a,&b);
ans[a]+=b;
maxt=max(maxt,a);
}
for(int i=0;i<=maxt;i++)if(ans[i]!=0)cnt++;
printf("%d",cnt);
for(int i=maxt;i>=0;i--)if(ans[i]!=0)printf(" %d %.1lf",i,ans[i]);
printf("\n");
return 0;
}
///1003
/// 代码一 dfs ****
#include<bits/stdc++.h>
using namespace std;
const int maxn =10010;
typedef long long ll;
#define INF 0x7FFFFF
int u[502]={0};
int teams[502]={0};
int dis[502];
int mp[502][502];
int n,m,st,en;
int shortNum=0,maxteam=0,mindist=INF;
void dfs(int s,int dis,int team){ ///到达S结点时的距离,teams 节点,距离,队员个数
if(s==en){
if(dis<mindist){
mindist=dis;
shortNum=1;
shortNum=1;
maxteam=team;
}
else if(dis==mindist){
shortNum++;
if(team>maxteam)maxteam=team;
}
return;
}
u[s]=1;
for(int i=0;i<n;i++){
if(u[i]==0&&mp[s][i]>0){
dfs(i,dis+mp[s][i],team+teams[i]);
}
}
u[s]=0;
}
int main()
{
int i;
scanf("%d%d%d%d",&n,&m,&st,&en);
for(i=0;i<n;i++)scanf("%d",&teams[i]);
memset(mp,-1,sizeof(mp));
for(i=0;i<m;i++){
int t1,t2,dis;
scanf("%d%d%d",&t1,&t2,&dis);
mp[t1][t2]=mp[t2][t1]=dis;
}
dfs(st,0,teams[st]);
printf("%d %d\n",shortNum,maxteam);
return 0;
}
///代码二 dijsktra ****
#include<bits/stdc++.h>
using namespace std;
const int maxn=510;
const int INF=0x7FFFFF;
int n,m,st,en,vis[maxn],dis[maxn],mp[maxn][maxn],pathcount[maxn],amount[maxn],team[maxn];
void dijkstra(int s){
pathcount[s]=1;
amount[s]=team[s];
dis[s]=0;
while(1){
int mint=INF,u;
for(int i=0;i<n;i++){
if(vis[i]==0&&dis[i]<mint){
mint=dis[i];
u=i;
}
}
cout<<"---"<<endl;
if(mint==INF||u==en)break;
vis[u]=1;
for(int v=0;v<n;v++){
if(vis[v]==0){
if(dis[v]>dis[u]+mp[u][v]){
dis[v]=dis[u]+mp[u][v];
pathcount[v]=pathcount[u];
amount[v]=amount[u]+team[v];
}
else if(dis[v]==dis[u]+mp[u][v]){
pathcount[v]+=pathcount[u];
amount[v]=max(amount[v],amount[u]+team[v]);
}
}
}
}
}
int main()
{
scanf("%d%d%d%d",&n,&m,&st,&en);
for(int i=0;i<n;i++)scanf("%d",&team[i]);
for(int i=0;i<n;i++){
dis[i]=INF;
for(int j=0;j<n;j++)
mp[i][j]=INF;
}
for(int i=0;i<m;i++){
int t1,t2,t3;
scanf("%d%d%d",&t1,&t2,&t3);
mp[t1][t2]=mp[t2][t1]=t3;
}
dijkstra(st);
printf("%d %d\n",pathcount[en],amount[en]);
return 0;
}