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<iostream>
#include<cstdio>
using namespace std;
int main()
{
while(true){
int a,b;
cin >> a >> b;
if(a==0&&b==0)return 0;
int x[4],y[4];
for(int i=0;i<4;i++){
x[i]=a%10;
a/=10;
y[i]=b%10;
b/=10;
}

int hit=0,blow=0;
for(int i=0;i<4;i++)if(x[i]==y[i])hit++;

for(int i=0;i<4;i++){
for(int j=0;j<4;j++)if(x[i]==y[j])blow++;
}
blow-=hit;

printf("%d %d\n",hit,blow);
}
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
	while(1){
		int r, a, hit=0, blow=0;
		int x[4], y[4]; 
		
		cin >> r >> a;
		if(r==0 && a==0) break;
	
		for(int i=0; i<4; ++i){
			x[i] = (r%(int)pow(10, 4-i) - r%(int)pow(10, 3-i)) / (int)pow(10, 3-i);
			y[i] = (a%(int)pow(10, 4-i) - a%(int)pow(10, 3-i)) / (int)pow(10, 3-i);
		}
	
		for(int i=0; i<4; ++i){
			for(int j=0; j<4; ++j){
				if(x[i]==y[j]){
					if(i==j) ++hit;
					else ++blow;
				}
			}
		}
	
		printf("%d %d\n", hit, blow);
	}

	return 0;
}

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

#define ALL(a) (a).begin(), (a).end()
#define llong long long

using namespace std;

signed main(){
	
	while(1){
		string a, b; cin >> a >> b;
		if(a == "0") break;
		bool used[4] = {};
		int aa = 0;
		int bb = 0;
		for(int i = 0; i < 4; i++){
			if(a[i] == b[i]){
				aa++;
				used[i] = true;
			}
		}

		for(int i = 0; i < 4; i++){
			if(used[i]) continue;
			for(int j = 0; j < 4; j++){
				if(i == j) continue;
				if(used[j]) continue;
				if(a[i] == b[j]){
					bb++;
				}
			}
		}

		cout << aa << " " << bb << endl;

	}
	return 0;
}

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

int main(){
int h=0,b=0;
char r[5];
char a[5];
 cin >> r >> a;
while(r[0]!=0&&r[1]!='\0'&&a[0]!=0&&a[1]!='\0'){
 for(int i=0;i<4;i++){
 	 if(r[i]==a[i]){
           h++;
	 }
 }
 for(int i=0;i<4;i++){
  for(int j=0;j<4;j++){
	   if(r[i]==a[j]){
	     b++;
	  }
   }
 }
 b=b-h;
 cout << h << ' ' << b << endl;
 cin >> r >> a;
}
return 0;
}

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

int main(){
 while(1){
	string stra,strb;
	cin>>stra>>strb;
	int h=0,b=0;

	if((stra=="0")&&(strb=="0")){
	 break;}

	for(int i=0;i<4;i++){
	 if(stra[i]==strb[i]){
		h++;
	 }
	 for(int j=0;j<4;j++){
		if(stra[i]==strb[j]){
			b++;
		}
	 }
	}

  b=b-h;
  cout<<h<<' '<<b<<'\n';
 }
return 0;
}

C++: #include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> VI;
typedef pair<int,int> PII;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;

int main(){
    string a,b;
    while(cin>>a>>b){
        if(a=="0" && b=="0")break;
        int h=0,m=0;
        rep(i,4){
            rep(j,4){
                if(a[i]==b[j]){
                    if(i==j)h++;
                    else m++;
                }
            }
        }
        cout<<h<<" "<<m<<endl;
    }
    
    return 0;
}

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

int main(){
 
 char qwe[6],ans[6];

 int hit,blow,count;

     count = 0;
 
 while(hit != 4){
    cin >> qwe >> ans;
    hit = 0 ;
    blow = 0;


   for(int i=0; i<4; i++){
      
       for(int g=0; g<4; g++){

           if(qwe[i] == ans[g]){
               
                if(i == g)
                      hit++;
                else
                      blow++;
            }
       }
    }
   
   cout << hit << " " << blow << endl;
   count++;
   cout << "count=" <<count<<endl;
 }

  while(hit != 4){
    if(count == 0){
      break;
    } 
    cin >> qwe >> ans;
    hit = 0 ;
    blow = 0;

   for(int i=0; i<4; i++){
      
       for(int g=0; g<4; g++){

           if(qwe[i] == ans[g]){
               
                if(i == g)
                      hit++;
                else
                      blow++;
            }
       }
    }
   
   cout << hit << " " << blow << endl;
   
   count--;
   cout << "count=" <<count<<endl;
 }

 return 0;
}

C++: #include<iostream>
#include<cstring>
using namespace std;
int main(){
	char a[10],b[10];
	while(true){
	cin>>a>>b;
	if(strcmp(a,"0")==0&&strcmp(b,"0")==0)break;
	int x=0,y=0;
	for(int i=0;i<4;i++){
		for(int j=0;j<4;j++){
			//if(i<j)continue;
			if(a[i]==b[j]){
			if(i==j)x++;
			else y++;
			}			

		}
	}
	cout<<x<<" "<<y<<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 <string>

using namespace std;

int main() {
	
	string t1, t2;

	while (cin >> t1 >> t2 && t1 != "0" && t2 != "0") {

		int h = 0, b = 0;

		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {

				if (t1[i] == t2[j] && i == j)
					h++;

				else if (t1[i] == t2[j] && i != j)
					b++;
			}
		}

		cout << h << " " << b << "\n";
		
	}

	return 0;

}

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

int main() {
	string a,b;
	int hit=0,blow=0;

		while(cin>>a>>b){
		if(a=="0"&&b=="0")break;
		for(int i=0;i<4;i++){
			if(a[i]==b[i])hit++;
		}
		
		for(int j=0;j<4;j++){
			for(int k=0;k<4;k++){
				if(j!=k&&a[j]==b[k])blow++;
			}
		}
		cout<<hit<<" "<<blow<<endl;
		blow=0;
		hit=0;
		}
	
	
	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>
#include<string.h>
#define rep(i,n) for(i = 0;i < n;i++)
using namespace std;

int main()
{
	char s1[5],s2[5];
	int i,j;
	while( cin >> s1 >> s2 )
	{
		bool flag[4] = {false};
		int hit = 0,blow = 0;
		if( strlen(s1) == 1 && strlen(s2) == 1 )
			break;
		rep(i,4){
			if( s1[i] == s2[i] ){
				hit++;
				flag[i] = true;
			}
		}
		rep(i,4){
			if( flag[i] )continue;
			rep(j,4){
				if( i == j )continue;
				if( s1[i] == s2[j] ){
					blow++;
					break;
				}
			}
		}
		cout << hit << " " << blow << endl;
	}
	return 0;
}

C++: 
#include <iostream>
using namespace std;
int main(){
 char r[5];
 char a[5];
 int h,b;
 cin>>r>>a;
 for(int i=0;i<4;i++){
  for(int j=0;j<4;j++){
   if(r[i]==a[i]) h++;
   else if(r[i]==a[j]) b++;
   }
  }
 cout<<h/4<<' '<<b<<endl;
 
 return 0;

}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main()
{
while(){
int a,b;
cin >> a >> b;
if(a==0&&b==0)return 0;
int x[4],y[4];
for(int i=0;i<4;i++){
x[i]=a%10;
a/=10;
y[i]=b%10;
b/=10;
}

int hit=0,blow=0;
for(int i=0;i<4;i++)if(x[i]==y[i])hit++;

for(int i=0;i<4;i++){
for(int j=0;j<4;j++)if(x[i]==y[j])blow++;
}
blow-=hit;

printf("%d %d\n",hit,blow);
}
}