Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	var scanner = bufio.NewScanner(os.Stdin)
	board := make([][]int, 8)
	for i := range board {
		board[i] = make([]int, 8)
			for j := range board[i] {
				board[i][j] = 0
			}
	}
	var ans string
	for scanner.Scan() {
		tmp := strings.Split(scanner.Text(), "")
		for i := 0; i < 8; i++ {
			board[0][i], _ = strconv.Atoi(tmp[i])
		}
		for i := 1; i < 8; i++ {
			scanner.Scan()
			row := strings.Split(scanner.Text(), "")
			for j := 0; j < 8; j++ {
				board[i][j], _ = strconv.Atoi(row[j])
			}
		}
		fmt.Println(board)
		for i := 0; i < 7; i++ {
			for j := 0; j < 7; j++ {
				if board[i][j] == 1 && board[i+1][j] == 1 && board[i][j+1] == 1 && board[i+1][j+1] == 1 {
					ans = "A"
				}
			}
		}
		for i := 0; i < 5; i++ {
			for j := 0; j < 8; j++ {
				if board[i][j] == 1 && board[i+1][j] == 1 && board[i+2][j] == 1 && board[i+3][j] == 1 {
					ans = "B"
				}
			}
		}
		for i := 0; i < 8; i++ {
			for j := 0; j < 5; j++ {
				if board[i][j] == 1 && board[i][j+1] == 1 && board[i][j+2] == 1 && board[i][j+3] == 1 {
					ans = "C"
				}
			}
		}
		for i := 0; i < 6; i++ {
			for j := 0; j < 7; j++ {
				if board[i][j+1] == 1 && board[i+1][j] == 1 && board[i+1][j+1] == 1 && board[i+2][j] == 1 {
					ans = "D"
				}
			}
		}
		for i := 0; i < 7; i++ {
			for j := 0; j < 6; j++ {
				if board[i][j] == 1 && board[i][j+1] == 1 && board[i+1][j+1] == 1 && board[i+1][j+2] == 1 {
					ans = "E"
				}
			}
		}
		for i := 0; i < 7; i++ {
			for j := 0; j < 6; j++ {
				if board[i][j+1] == 1 && board[i][j+2] == 1 && board[i+1][j] == 1 && board[i+1][j+1] == 1 {
					ans = "G"
				}
			}
		}
		for i := 0; i < 6; i++ {
			for j := 0; j < 7; j++ {
				if board[i][j] == 1 && board[i+1][j] == 1 && board[i+1][j+1] == 1 && board[i+2][j+1] == 1 {
					ans = "F"
				}
			}
		}
		fmt.Println(ans)
	}
}

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

int main(){
	char f[9][9];
	while(1){
		bool flag=false;
		
		for(int i=0; i<8; ++i){
			for(int j=0; j<8; ++j){
				if( scanf(" %c", &f[i][j])==EOF){
					flag=true;
					break;
				}
			} 
			if(flag) break;	
		}
		if(flag) break;

		bool ans=false;
		char c='1';
		for(int i=0; i<8; ++i){
			for(int j=0; j<8; ++j){
				
				if(f[j][i]==c){
					if(i<=6 && j<=6 && f[j+1][i]==c && f[j][i+1]==c && f[j+1][i+1]==c){
						printf("A\n");	
						ans=true;
						break;
					}
					else if(j<=4 && f[j+1][i]==c && f[j+2][i]==c && f[j+3][i]==c){
						printf("B\n");	
						ans=true;
						break;
					}
					else if(i<=4 && f[j][i+1]==c && f[j][i+2]==c && f[j][i+3]==c){
						printf("C\n");	
						ans=true;
						break;
					}
					else if(1<=j && j<=6 && i<=6 && f[j+1][i]==c && f[j][i+1]==c && f[j-1][i+1]==c){
						printf("D\n");	
						ans=true;
						break;
					}
					else if(j<=6 && i<=5 && f[j][i+1]==c && f[j+1][i+1]==c && f[j+1][i+2]==c){
						printf("E\n");	
						ans=true;
						break;
					}
					else if(j<=5 && i<=6 && f[j+1][i]==c && f[j+1][i+1]==c && f[j+2][i+1]==c){
						printf("F\n");	
						ans=true;
						break;
					}
					else if(1<=j && i<=5 && f[j][i+1]==c && f[j-1][i+1]==c && f[j-1][i+2]==c){
						printf("G\n");	
						ans=true;
						break;
					}
											
				}
	
			}
			if(ans) break;
		}
			
	}
}

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

char field[8][9];
struct P { int x, y; };
P pat[7][3] = {
	{{1,0}, {0,1}, {1,1}},
	{{0,1}, {0,2}, {0,3}},
	{{1,0}, {2,0}, {3,0}},
	{{1,-1}, {1,0}, {0,1}},
	{{1,0}, {1,1}, {2,1}},
	{{0,1}, {1,1}, {1,2}},
	{{1,-1}, {2,-1}, {1,0}},
};

bool ok(int x, int y) {
	if (x<0 || x>=8 || y<0 || y>=8) return false;
	return (field[y][x] == '1');
}

int main() {
	while (scanf("%s", &field[0]) == 1) {
		for (int i = 1; i < 8; i++)
			scanf("%s", &field[i]);

		int x0, y0;
		for (int i = 0; i < 8*8; i++) {
			int x = i%8, y = i/8;
			if (ok(x, y)) {
				x0 = x, y0 = y;
				break;
			}
		}

		char kind;
		for (int i = 0; i < 7; i++) {
			if (!ok(x0+pat[i][0].x, y0+pat[i][0].y)) continue;
			if (!ok(x0+pat[i][1].x, y0+pat[i][1].y)) continue;
			if (!ok(x0+pat[i][2].x, y0+pat[i][2].y)) continue;
			kind = 'A' + i;
			break;
		}

		cout << kind << endl;
	}
	return 0;
}

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

int main() {
	char c[8][8];
	while (cin >> c[0]) {
		for (int i = 1;i < 8;i++)cin >> c[i];

		int ax, ay;
		for (int i = 0;i < 8;i++) {
			for (int j = 0;j < 8;j++) {
				if (c[i][j] == '1') {
					ax = i;
					ay = j;
					goto floop;
				}
			}
		}
	floop:
		if (c[ax][ay] == c[ax][ay + 1]) {
			if (ax<7&&c[ax][ay] == c[ax + 1][ay] && c[ax + 1][ay] == c[ax + 1][ay])cout << 'A' << endl;
			else if (ay<5&&c[ax][ay] == c[ax][ay + 2] && c[ax][ay ] == c[ax][ay + 3])cout << 'C' << endl;
			else if (ax<7&&ay<6&&c[ax][ay] == c[ax + 1][ay + 1] && c[ax][ay] == c[ax + 1][ay + 2])cout << 'E' << endl;
			else cout << 'G' << endl;
		}
		if (c[ax][ay] == c[ax + 1][ay]) {
			if (ax<5&&c[ax][ay] == c[ax + 2][ay] && c[ax][ay] == c[ax + 3][ay])cout << 'B' << endl;
			else if (ax<6&&ay<7&&c[ax][ay] == c[ax + 1][ay + 1] && c[ax][ay] == c[ax + 2][ay + 1])cout << 'F' << endl;
			else if(c[ax+1][ay+1]=='0')cout << 'D' << endl;
		}
	}
	return 0;
}

C++: #define scanf_s scanf
//#define gets_s gets
#include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>
using namespace std;
#define MAX 8
#define MIN -100001
#define _MAX 8
int main(void)
{
	char a[MAX][MAX + 1], ans;
	int ki, kj;
	while (1) {
		for (int i = 0; i < MAX; ++i) {
			scanf_s("%s", a[i]);
			for (int j = 0; j < MAX; ++j) {
				if (a[i][j] == '1') {
					ki = i; kj = j;
				}
			}
		}//a,b,d,f,g
		if (ki - 1 >= 0 && a[ki - 1][kj] == '1') {
			if (ki - 2 >= 0 && a[ki - 2][kj] == '1') ans = 'B';
			else {//a,d,f,g
				if (kj - 1 < MAX && a[ki][kj - 1] == '1') {//a,g,
					if (a[ki - 1][kj - 1] == '1') ans = 'A';
					else ans = 'G';
				}
				else {//f,g
					if (kj - 1 < MAX && a[ki - 1][kj - 1] == '1') ans = 'F';
					else ans = 'G';
				}
			}
		}//c,e
		else {
			if (kj - 2 >= 0 && a[ki][kj - 2] == '1') ans = 'C';
			else ans = 'E';
		}
		printf("%c\n", ans);
	}
}

C++: #include <bits/stdc++.h>
using namespace std;

using pii = pair<int, int>;

int main() {
    string s;
    while(cin >> s) {
        vector<string> v(8);
        v[0] = s;
        for(int i = 0; i < 7; ++i) {
            cin >> v[i + 1];
        }
        vector<vector<pii>> m = {{pii{0, 0}, pii{0, 1}, pii{1, 0}, pii{1, 1}},
                                 {pii{0, 0}, pii{1, 0}, pii{2, 0}, pii{3, 0}},
                                 {pii{0, 0}, pii{0, 1}, pii{0, 2}, pii{0, 3}},
                                 {pii{0, 0}, pii{1, -1}, pii{1, 0}, pii{2, -1}},
                                 {pii{0, 0}, pii{0, 1}, pii{1, 1}, pii{1, 2}},
                                 {pii{0, 0}, pii{1, 0}, pii{1, 1}, pii{2, 1}},
                                 {pii{0, 0}, pii{0, 1}, pii{1, -1}, pii{1, 0}}};
        vector<pii> b;
        for(int i = 0; i < 8; ++i) {
            for(int j = 0; j < 8; ++j) {
                if(v[i][j] == '1') b.emplace_back(i, j);
            }
        }
        sort(begin(b), end(b));
        for(int i = 3; i >= 0; --i) {
            b[i].first -= b[0].first;
            b[i].second -= b[0].second;
        }

        char ans = 'A' + find(begin(m), end(m), b) - begin(m);
        cout << ans << endl;
    }
}