Go: package main

import (
	"bufio"
	"os"
	"strings"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		buf := strings.Split(scanner.Text(), " ")
		a := strings.Split(buf[0], "")
		b := strings.Split(buf[1], "")
		if a == 0 && b == 0 {
			break
		}
		hit := 0
		blow := 0
		for i, av := range a {
			for j, bv := range b {
				if i == j && av == bv {
					hit++
				}
				if i != j && av == bv {
					blow++
				}
			}
		}
		fmt.Println(hit, blow)
	}
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	while (1) {
		string a, b; cin >> a >> b;
		if (a == "0")break;
		else {
			vector<int>nums(10,-1);
			for (int i = 0; i < 4; ++i) {
				nums[a[i] - '0'] = i;
			}
			int hit = 0, blow = 0;
			for (int i = 0; i < 4; ++i) {
				if (nums[b[i] - '0']!=-1) {
					if (nums[b[i] - '0'] == i)hit++;
					else blow++;
				}
				
			}

			cout << hit << " " << blow << endl;
		}
	}
	return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 20000000
int main()
{
        string a,b;
        while(1)
        {
                cin >> a >> b;
                if(a.size()<=2&&b.size()<=2)break;
                int hit_count=0;
                for(int i=0;i<4;i++)
                {
                        if(a[i]==b[i])
                        {
                                hit_count++;
                        }
                }
                int blow_count=0;
                for(int i=0;i<4;i++)
                {
                        for(int j=0;j<4;j++)
                        {
                                if(b[i]==a[j])
                                {
                                        blow_count++;
                                        break;
                                }
                        }
                }
                cout << hit_count << ' ' << blow_count-hit_count << endl;
        }
        return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
 
int main(void) {
  int n,m;
  int res;
 
  while(1) {
    cin >> n >> m;
    if(n == 0 && m == 0) break;
     
    res = 0;
 
    int p[n];
    for(int i = 0; i < n; i++)
      cin >> p[i];
     
    stable_sort(p, p + n);
 
    for(int i = n-1; i >= 0; ) {
      for(int j = 0; j < m-1; j++) {
    if(i < 0) break;
    res += p[i];
    i--;
      }
      i--;
    }
     
    cout << res << endl;
  }
 
  return 0;
}

C++: #include<iostream>
int main(){int h,b,i,j;std::string r,a;while(std::cin>>r>>a,r!="0"&&a!="0"){for(h=b=i=0;i<4;i++)for(j=4;j-->0;)if(a[i]==r[j])i==j?h++:b++;printf("%d %d\n",h,b);}}

C++: #include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)

int a,b;

int main(){
	while(cin>>a>>b&&a){
		int m[4],n[4],x=0,y=0;
		rep(i,4){
			m[i]=(a/(int)pow(10.0,i))%10;
			n[i]=(b/(int)pow(10.0,i))%10;
			x+=m[i]==n[i];
		}
		rep(i,4)rep(j,4)if(i!=j)y+=m[i]==n[j];
		cout<<x<<" "<<y<<endl;
	}
}

C++: #include <cstring>
#include <iostream>

using namespace std;

int main() {

	int  h, b;
	char r[4], a[4];

	while(cin >> r >> a) {
		if(!strcmp(r, "0")&&!strcmp(a, "0"))
			break;
		h=0;
		b=0;
		for(int i=0; i<4; i++) {
			for(int j=0; j<4; j++) {
				if(r[i]==a[j])
					i==j ? h++ : b++;
			}
		}
		cout << h << " " << b << endl;
	}

	return 0;

}

C++: #include <cstdio>
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int solve_testcase() {
  string s, t; cin >> s >> t;
  if(s == "0" and t == "0") return 1;

  int blow = 0, hit = 0;
  vector<bool> seen(4, false);
  vector<bool> A(10), B(10);
  for(int k=0; k<4; k++) {
    if(s[k] == t[k]) {
      hit++;
    }
    else {
      A[ s[k] - '0' ] = true;
      B[ t[k] - '0' ] = true;
    }
  }

  for(int i=0; i<10; i++) {
    if(A[i] and B[i]) blow++;
  }

  cout << hit << " " << blow << endl;
  return 0;
}

int main() {
  while(!solve_testcase());
  return 0;
}

C++: #include <cstdio>

using namespace std;

int main()
{
	char a[5], b[5];
	
	int hit, blow;
	
	a[0] = b[0] = '1';
	
	while(scanf("%s %s", a, b), !(a[0] == '0' && b[0] == '0')){
		hit = blow = 0;
		
		
		for (int i = 0; i < 4; i++){
			for (int j = 0; j < 4; j++){
				if (a[i] == b[j]){
					if (i == j){
						hit++;
					}
					else{
						blow++;
					}
					
					break;
				}
			}
		}
		
		printf("%d %d\n", hit, blow);
	}
	
	
}

C++: #include<iostream>
#include<cstring>
using namespace std;

int hit(char* s1,char* s2){
	int n=0;
	for(int i=0;i<4);i++){
		if(s1[i]==s2[i]){
			n++:
		}
	}
	return n;
}

int blow(char* s1,char* s2){
	int n=0;
	for(int i=0;i<4;i++){
	if(s1[i]==s2[0]){
		n++:
		}
	if(s1[i]==s2[1]){
		n++:
		}
	if(s1[i]==s2[2]){
		n++:
		}
	if(s1[i]==s2[3]){
		n++:
		}
	}
	return n;
}

int main{
	char r[5],a[5];
	for(int i=0;i<100;i++){
		cin>>r;cin>>a;
		if(r==0&&a==0){
		i=101;
		}
		else{
		cout<<<hit(r,a)<<' '<<blow(r,a)<<endl;
		}
	}
return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;

int main() {
	string r, a;
	while(cin >> r >> a, a != "0" && r != "0") {
		int hit, blow;
		int tmp[10] = {};
		hit = blow = 0;
		for(int i = 0; i < a.size(); i++)
			hit += a[i] == r[i];
		for(int i = 0; i < a.size(); i++) {
			tmp[a[i]-'0']++;
		}
		for(int i = 0; i < r.size(); i++) {
			if(tmp[r[i]-'0']) {
				blow++;
				tmp[r[i]-'0']--;
			}
		}
		blow -= hit;
		cout << hit << " " << blow << endl;
	}
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    string a,b; int c,d;string temp;
    while(true){
        cin>>a>>b;
        c=stoi(a); d=stoi(b);
        if(d+c==0)return 0;
        int hit=0,brow=0; vc v;
        rep(i,a.size())v.push_back(a[i]);
        rep(i,a.size()){if(a[i]==b[i])hit++;}
        rep(i,a.size())rep(j,a.size())if(b[i]==v[j])brow++;
        cout<<hit<<" "<<brow-hit<<endl;
    }
}

C++: #include<iostream>
#include<cstring>
using namespace std;

int hit(char* s1,char* s2){
	int n=0;
	for(int i=0;i<4;i++){
		if(s1[i]==s2[i]){
			n++;
		}
	}
	return n;
}

int blow(char* s1,char* s2){
	int n=0;
	for(int i=0;i<4;i++){
	if(s1[i]==s2[0]){
		n++;
		}
	if(s1[i]==s2[1]){
		n++;
		}
	if(s1[i]==s2[2]){
		n++;
		}
	if(s1[i]==s2[3]){
		n++;
		}
	}
	return n;
}

int main(){
	char r[5],a[5];
	for(int i=0;i<100;i++){
		cin>>r;cin>>a;
		if(r[0]=='0'&&a[0]=='0'){
		break;
		}
		else{
		cout<<hit(r,a)<<' '<<blow(r,a)-hit(r,a)<<endl;
		}
	}
return 0;
}