puwaer/puwaer_code_translation huggingface dataset:
AtCoder problem 079

C++ solution:
#include <cmath>

#include <vector>

#include <iostream>

using namespace std;

int main() {

	int H, W;

	cin >> H >> W;

	vector<vector<long long> > A(H, vector<long long>(W)), B(H, vector<long long>(W));

	for (int i = 0; i < H; ++i) {

		for (int j = 0; j < W; ++j) {

			cin >> A[i][j];

		}

	}

	for (int i = 0; i < H; ++i) {

		for (int j = 0; j < W; ++j) {

			cin >> B[i][j];

		}

	}

	long long ans = 0;

	for (int i = 0; i < H - 1; ++i) {

		for (int j = 0; j < W - 1; ++j) {

			int d = B[i][j] - A[i][j];

			A[i][j] += d;

			A[i][j + 1] += d;

			A[i + 1][j] += d;

			A[i + 1][j + 1] += d;

			ans += abs(d);

		}

	}

	if (A == B) {

		cout << "Yes" << endl;

		cout << ans << endl;

	}

	else {

		cout << "No" << endl;

	}

	return 0;

}

Crystal solution: h, w = read_line.split.map(&.to_i)
a = (1..h).map { read_line.split.map(&.to_i64) }
b = (1..h).map { read_line.split.map(&.to_i64) }
cnt = (0...h - 1).sum { |i|
  (0...w - 1).sum { |j|
    x = b[i][j] - a[i][j]
    [i, i + 1].product([j, j + 1]) { |i2, j2|
      a[i2][j2] += x
    }
    x.abs
  }
}
if a == b
  puts "Yes", cnt
else
  puts "No"
end
AtCoder problem 079

C++ solution:
#include <cmath>

#include <vector>

#include <iostream>

using namespace std;

int main() {

	int H, W;

	cin >> H >> W;

	vector<vector<long long> > A(H, vector<long long>(W)), B(H, vector<long long>(W));

	for (int i = 0; i < H; ++i) {

		for (int j = 0; j < W; ++j) {

			cin >> A[i][j];

		}

	}

	for (int i = 0; i < H; ++i) {

		for (int j = 0; j < W; ++j) {

			cin >> B[i][j];

		}

	}

	long long ans = 0;

	for (int i = 0; i < H - 1; ++i) {

		for (int j = 0; j < W - 1; ++j) {

			int d = B[i][j] - A[i][j];

			A[i][j] += d;

			A[i][j + 1] += d;

			A[i + 1][j] += d;

			A[i + 1][j + 1] += d;

			ans += abs(d);

		}

	}

	if (A == B) {

		cout << "Yes" << endl;

		cout << ans << endl;

	}

	else {

		cout << "No" << endl;

	}

	return 0;

}





Kuin solution: func main()
	var h: int :: cui@inputInt()
	var w: int :: cui@inputInt()
	var a: [][]int :: #[h, w]int
	for y(0, h - 1)
		for x(0, w - 1)
			do a[y][x] :: cui@inputInt()
		end for
	end for
	for y(0, h - 1)
		for x(0, w - 1)
			do a[y][x] :- cui@inputInt()
		end for
	end for
	
	var ans: int :: 0
	for y(0, h - 1)
		for x(0, w - 1)
			if(x = w - 1 | y = h - 1)
				if(a[y][x] <> 0)
					do cui@print("No\n")
					ret
				end if
			else
				var v: int :: a[y][x]
				do ans :+ v.abs()
				do a[y][x + 1] :- v
				do a[y + 1][x] :- v
				do a[y + 1][x + 1] :- v
			end if
		end for
	end for
	
	do cui@print("Yes\n")
	do cui@print("\{ans}\n")
end func
AtCoder problem 079

C++ solution:

Crystal solution: h, w = read_line.split.map(&.to_i)
a = (1..h).map { read_line.split.map(&.to_i64) }
b = (1..h).map { read_line.split.map(&.to_i64) }
cnt = (0...h - 1).sum { |i|
  (0...w - 1).sum { |j|
    x = b[i][j] - a[i][j]
    [i, i + 1].product([j, j + 1]) { |i2, j2|
      a[i2][j2] += x
    }
    x.abs
  }
}
if a == b
  puts "Yes", cnt
else
  puts "No"
end





Kuin solution: func main()
	var h: int :: cui@inputInt()
	var w: int :: cui@inputInt()
	var a: [][]int :: #[h, w]int
	for y(0, h - 1)
		for x(0, w - 1)
			do a[y][x] :: cui@inputInt()
		end for
	end for
	for y(0, h - 1)
		for x(0, w - 1)
			do a[y][x] :- cui@inputInt()
		end for
	end for
	
	var ans: int :: 0
	for y(0, h - 1)
		for x(0, w - 1)
			if(x = w - 1 | y = h - 1)
				if(a[y][x] <> 0)
					do cui@print("No\n")
					ret
				end if
			else
				var v: int :: a[y][x]
				do ans :+ v.abs()
				do a[y][x + 1] :- v
				do a[y + 1][x] :- v
				do a[y + 1][x + 1] :- v
			end if
		end for
	end for
	
	do cui@print("Yes\n")
	do cui@print("\{ans}\n")
end func
AtCoder problem 080

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

int main()
{
  ll N, D;
  cin >> N >> D;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }
  
  // addB := d 番目のビットを立てたときに条件が満たされる i の集合
  vector<ll> addB(D, 0);
  for (ll d = 0; d < D; d++)
  {
    for (ll i = 0; i < N; i++)
    {
      if (A.at(i) & (1LL << d))
        addB.at(d) |= (1LL << i);
    }
  }

  // dp[d][b] := d 番目のビットまで立てるか立てないかを見たときの条件が満たされている i の集合が b であるようなビットの立て方の個数
  vector<vector<ll>> dp(D + 1, vector<ll>((1LL << N), 0));
  dp.at(0).at(0) = 1;
  for (ll d = 0; d < D; d++)
  {
    for (ll b = 0; b < (1LL << N); b++)
    {
      // ビットを立てない
      dp.at(d + 1).at(b) += dp.at(d).at(b);

      // ビットを立てる
      ll nb = b | addB.at(d);
      dp.at(d + 1).at(nb) += dp.at(d).at(b);
    }
  }

  cout << dp.at(D).at((1LL << N) - 1) << endl;
}


Crystal solution: n, d = read_line.split.map(&.to_i)
a = read_line.split.map(&.to_i64)
puts (0...1 << n).sum { |bit|
  x = a.each_with_index.reduce(0i64) { |acc, (x, i)|
    bit.bit(i) == 1 ? acc | x : acc
  }.popcount
  y = 1i64 << (d - x)
  bit.popcount.even? ? y : -y
}