puwaer/puwaer_code_translation huggingface dataset:
AtCoder problem 025

C++ solution:
#include <iostream>
#include <string>
#include <algorithm>
using ll = long long;
#define all(a) (a).begin(), (a).end()
using namespace std;

//50[ms]
ll n,b, ans = 0;
void dfs(string s, int v){
  ll cnt = 1;
  for(char c : s) cnt *= c - '0';
  cnt += b;
  string str = to_string(cnt);
  sort(all(str));
  if(str == s && cnt <= n) ans++;
  if((int)s.size() == 11) return;
  for(int i = v; i < 10; i++){
    dfs(s + char(i + '0'), i);
  }
}
int main(){
  cin >> n >> b;
  dfs("", 1);
  string str = to_string(b);
  for(char &c : str) if(c == '0'){
    if(n >= b) ans++;
    break;
  }
  cout << ans << "\n";
}






Ruby solution: require 'set'

f_set = Set.new
f_set.add(0)

for a0 in  1..9
for a1 in a0..9
for a2 in a1..9
for a3 in a2..9
for a4 in a3..9
for a5 in a4..9
for a6 in a5..9
for a7 in a6..9
for a8 in a7..9
for a9 in a8..9
    f_set.add(a0 * a1 * a2 * a3 * a4 * a5 * a6 * a7 * a8 * a9)
end; end; end; end; end; end; end; end; end; end

n, b = readline.split.map(&:to_i)

puts (
    f_set.count do |f_m|
        m = b + f_m
        prod = 1
        k = m
        while k > 0
            prod *= k % 10; k /= 10
        end
        prod == f_m && m <= n
    end
)
AtCoder problem 025

C++ solution:

Crystal solution: n, b = read_line.split.map(&.to_i64)
puts (1..11).sum { |size|
  (0..9).to_a.repeated_combinations(size).count { |m_ary|
    m = m_ary.reduce(1i64) { |acc, i| acc * i } + b
    1 <= m <= n && m.to_s.chars.map(&.to_i).sort == m_ary
  }
}






Ruby solution: require 'set'

f_set = Set.new
f_set.add(0)

for a0 in  1..9
for a1 in a0..9
for a2 in a1..9
for a3 in a2..9
for a4 in a3..9
for a5 in a4..9
for a6 in a5..9
for a7 in a6..9
for a8 in a7..9
for a9 in a8..9
    f_set.add(a0 * a1 * a2 * a3 * a4 * a5 * a6 * a7 * a8 * a9)
end; end; end; end; end; end; end; end; end; end

n, b = readline.split.map(&:to_i)

puts (
    f_set.count do |f_m|
        m = b + f_m
        prod = 1
        k = m
        while k > 0
            prod *= k % 10; k /= 10
        end
        prod == f_m && m <= n
    end
)
AtCoder problem 026

C++ solution:
#include <iostream>

#include <vector>

using namespace std;



// Input

int N;

int A[1 << 18], B[1 << 18];



// Graph

vector<int> G[1 << 18];

int col[1 << 18];



void dfs(int pos, int cur) {

	col[pos] = cur;

	for (int i : G[pos]) {

		if (col[i] >= 1) continue;

		dfs(i, 3 - cur);

	}

}



int main() {

	// Step #1. Input

	cin >> N;

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

		cin >> A[i] >> B[i];

		G[A[i]].push_back(B[i]);

		G[B[i]].push_back(A[i]);

	}



	// Step #2. Graph Coloring

	dfs(1, 1);



	// Step #3. Get Answer

	vector<int> G1, G2;

	for (int i = 1; i <= N; i++) {

		if (col[i] == 1) G1.push_back(i);

		if (col[i] == 2) G2.push_back(i);

	}

	if (G1.size() > G2.size()) {

		for (int i = 0; i < (N / 2); i++) {

			if (i) cout << " ";

			cout << G1[i];

		}

		cout << endl;

	}

	else {

		for (int i = 0; i < (N / 2); i++) {

			if (i) cout << " ";

			cout << G2[i];

		}

		cout << endl;

	}

	return 0;

}

Crystal solution: class UnweightedGraph
  getter graph : Array(Array(Int32))

  def initialize(size : Int)
    @graph = Array.new(size) { Array(Int32).new }
  end

  def add_edge(i : Int, j : Int)
    @graph[i] << j
    @graph[j] << i
  end

  delegate size, to: @graph
  delegate :[], to: @graph

  def bipartite_graph : Array(Bool)?
    color = Array(Bool?).new(size, nil)
    queue = Deque.new (0...size).to_a
    while v = queue.shift?
      color[v] = true if color[v].nil?
      flag = color[v].not_nil!
      graph[v].each do |edge|
        if (flag2 = color[edge]).nil?
          color[edge] = !flag
          queue.unshift edge
        else
          return nil if flag == flag2
        end
      end
    end
    color.map(&.not_nil!)
  end
end

n = read_line.to_i
graph = UnweightedGraph.new(n)
n.pred.times do
  a, b = read_line.split.map(&.to_i.pred)
  graph.add_edge(a, b)
end

color = graph.bipartite_graph.not_nil!
puts [true, false].map { |b|
  (0...n).select { |i| color[i] == b }.map(&.succ)
}.max_by(&.size)[0, n // 2].join(' ')
AtCoder problem 026

C++ solution:
#include <iostream>

#include <vector>

using namespace std;



// Input

int N;

int A[1 << 18], B[1 << 18];



// Graph

vector<int> G[1 << 18];

int col[1 << 18];



void dfs(int pos, int cur) {

	col[pos] = cur;

	for (int i : G[pos]) {

		if (col[i] >= 1) continue;

		dfs(i, 3 - cur);

	}

}



int main() {

	// Step #1. Input

	cin >> N;

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

		cin >> A[i] >> B[i];

		G[A[i]].push_back(B[i]);

		G[B[i]].push_back(A[i]);

	}



	// Step #2. Graph Coloring

	dfs(1, 1);



	// Step #3. Get Answer

	vector<int> G1, G2;

	for (int i = 1; i <= N; i++) {

		if (col[i] == 1) G1.push_back(i);

		if (col[i] == 2) G2.push_back(i);

	}

	if (G1.size() > G2.size()) {

		for (int i = 0; i < (N / 2); i++) {

			if (i) cout << " ";

			cout << G1[i];

		}

		cout << endl;

	}

	else {

		for (int i = 0; i < (N / 2); i++) {

			if (i) cout << " ";

			cout << G2[i];

		}

		cout << endl;

	}

	return 0;

}





Kuin solution: var arrT: list<int>
var arrF: list<int>

func main()
	var n: int :: cui@inputInt()
	var graph: []list<int> :: #[n]list<int>
	for i(0, n - 1)
		do graph[i] :: #list<int>
	end for
	for i(0, n - 2)
		var a: int :: cui@inputInt() - 1
		var b: int :: cui@inputInt() - 1
		do graph[a].add(b)
		do graph[b].add(a)
	end for
	
	do @arrT :: #list<int>
	do @arrF :: #list<int>
	do dfs(graph, 0, 0, true)
	
	var majority: list<int>
	if(^@arrT >= n / 2)
		do majority :: @arrT
	else
		do majority :: @arrF
	end if
	do majority.head()
	for i(1, n / 2)
		var ans: int :: majority.get() + 1
		do cui@print("\{ans}" ~ (i = n / 2 ?("\n", " ")))
		do majority.next()
	end for
	
	func dfs(graph: []list<int>, u: int, parent: int, f: bool)
		if(f)
			do @arrT.add(u)
		else
			do @arrF.add(u)
		end if
		do graph[u].head()
		while(!graph[u].term())
			var x: int :: graph[u].get()
			if(x <> parent)
				do dfs(graph, x, u, !f)
			end if
			do graph[u].next()
		end while
	end func
end func
AtCoder problem 026

C++ solution:

Crystal solution: class UnweightedGraph
  getter graph : Array(Array(Int32))

  def initialize(size : Int)
    @graph = Array.new(size) { Array(Int32).new }
  end

  def add_edge(i : Int, j : Int)
    @graph[i] << j
    @graph[j] << i
  end

  delegate size, to: @graph
  delegate :[], to: @graph

  def bipartite_graph : Array(Bool)?
    color = Array(Bool?).new(size, nil)
    queue = Deque.new (0...size).to_a
    while v = queue.shift?
      color[v] = true if color[v].nil?
      flag = color[v].not_nil!
      graph[v].each do |edge|
        if (flag2 = color[edge]).nil?
          color[edge] = !flag
          queue.unshift edge
        else
          return nil if flag == flag2
        end
      end
    end
    color.map(&.not_nil!)
  end
end

n = read_line.to_i
graph = UnweightedGraph.new(n)
n.pred.times do
  a, b = read_line.split.map(&.to_i.pred)
  graph.add_edge(a, b)
end

color = graph.bipartite_graph.not_nil!
puts [true, false].map { |b|
  (0...n).select { |i| color[i] == b }.map(&.succ)
}.max_by(&.size)[0, n // 2].join(' ')





Kuin solution: var arrT: list<int>
var arrF: list<int>

func main()
	var n: int :: cui@inputInt()
	var graph: []list<int> :: #[n]list<int>
	for i(0, n - 1)
		do graph[i] :: #list<int>
	end for
	for i(0, n - 2)
		var a: int :: cui@inputInt() - 1
		var b: int :: cui@inputInt() - 1
		do graph[a].add(b)
		do graph[b].add(a)
	end for
	
	do @arrT :: #list<int>
	do @arrF :: #list<int>
	do dfs(graph, 0, 0, true)
	
	var majority: list<int>
	if(^@arrT >= n / 2)
		do majority :: @arrT
	else
		do majority :: @arrF
	end if
	do majority.head()
	for i(1, n / 2)
		var ans: int :: majority.get() + 1
		do cui@print("\{ans}" ~ (i = n / 2 ?("\n", " ")))
		do majority.next()
	end for
	
	func dfs(graph: []list<int>, u: int, parent: int, f: bool)
		if(f)
			do @arrT.add(u)
		else
			do @arrF.add(u)
		end if
		do graph[u].head()
		while(!graph[u].term())
			var x: int :: graph[u].get()
			if(x <> parent)
				do dfs(graph, x, u, !f)
			end if
			do graph[u].next()
		end while
	end func
end func
AtCoder problem 027

C++ solution:
#include <iostream>

#include <string>

#include <map>

using namespace std;



int N;

string S[1 << 18];

map<string, int> Map;



int main() {

	cin >> N;

	for (int i = 1; i <= N; i++) {

		cin >> S[i];

		if (Map[S[i]] == 0) {

			Map[S[i]] = 1;

			cout << i << endl;

		}

	}

	return 0;

}

Crystal solution: n = read_line.to_i
set = Set(String).new
puts (1..n).select {
  s = read_line
  if set.includes?(s)
    false
  else
    set << s
    true
  end
}.join('\n')
AtCoder problem 027

C++ solution:
#include <iostream>

#include <string>

#include <map>

using namespace std;



int N;

string S[1 << 18];

map<string, int> Map;



int main() {

	cin >> N;

	for (int i = 1; i <= N; i++) {

		cin >> S[i];

		if (Map[S[i]] == 0) {

			Map[S[i]] = 1;

			cout << i << endl;

		}

	}

	return 0;

}


Python solution: n = int(input())
check = {}
for i in range(n):
    s = input()
    if s in check:
        continue
    else:
        print(i+1)
        check[s] = True
AtCoder problem 027

C++ solution:
#include <iostream>

#include <string>

#include <map>

using namespace std;



int N;

string S[1 << 18];

map<string, int> Map;



int main() {

	cin >> N;

	for (int i = 1; i <= N; i++) {

		cin >> S[i];

		if (Map[S[i]] == 0) {

			Map[S[i]] = 1;

			cout << i << endl;

		}

	}

	return 0;

}





Kuin solution: func main()
	var n: int :: cui@inputInt()
	var prev: int :: 0
	var map: dict<[]char, bool> :: #dict<[]char, bool>
	for i(1, n)
		do map.add(cui@input(), true)
		if(^map <> prev)
			do prev :+ 1
			do cui@print("\{i}\n")
		end if
	end for
end func
AtCoder problem 027

C++ solution:

Crystal solution: n = read_line.to_i
set = Set(String).new
puts (1..n).select {
  s = read_line
  if set.includes?(s)
    false
  else
    set << s
    true
  end
}.join('\n')


Python solution: n = int(input())
check = {}
for i in range(n):
    s = input()
    if s in check:
        continue
    else:
        print(i+1)
        check[s] = True
AtCoder problem 027

C++ solution:

Crystal solution: n = read_line.to_i
set = Set(String).new
puts (1..n).select {
  s = read_line
  if set.includes?(s)
    false
  else
    set << s
    true
  end
}.join('\n')





Kuin solution: func main()
	var n: int :: cui@inputInt()
	var prev: int :: 0
	var map: dict<[]char, bool> :: #dict<[]char, bool>
	for i(1, n)
		do map.add(cui@input(), true)
		if(^map <> prev)
			do prev :+ 1
			do cui@print("\{i}\n")
		end if
	end for
end func
AtCoder problem 027

C++ solution:


Python solution: n = int(input())
check = {}
for i in range(n):
    s = input()
    if s in check:
        continue
    else:
        print(i+1)
        check[s] = True




Kuin solution: func main()
	var n: int :: cui@inputInt()
	var prev: int :: 0
	var map: dict<[]char, bool> :: #dict<[]char, bool>
	for i(1, n)
		do map.add(cui@input(), true)
		if(^map <> prev)
			do prev :+ 1
			do cui@print("\{i}\n")
		end if
	end for
end func
AtCoder problem 028

C++ solution:
#include <iostream>

using namespace std;



// Input

int N;

int lx[1 << 18], ly[1 << 18], rx[1 << 18], ry[1 << 18];



// Count Number

int cnt[1009][1009];

int Answer[1 << 18];



int main() {

	// Step #1. Input

	cin >> N;

	for (int i = 1; i <= N; i++) cin >> lx[i] >> ly[i] >> rx[i] >> ry[i];



	// Step #2. Imos Method in 2D

	for (int i = 1; i <= N; i++) {

		cnt[lx[i]][ly[i]] += 1;

		cnt[lx[i]][ry[i]] -= 1;

		cnt[rx[i]][ly[i]] -= 1;

		cnt[rx[i]][ry[i]] += 1;

	}

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

		for (int j = 1; j <= 1000; j++) cnt[i][j] += cnt[i][j - 1];

	}

	for (int i = 1; i <= 1000; i++) {

		for (int j = 0; j <= 1000; j++) cnt[i][j] += cnt[i - 1][j];

	}



	// Step #3. Count Number

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

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

			if (cnt[i][j] >= 1) Answer[cnt[i][j]] += 1;

		}

	}



	// Step #4. Output The Answer

	for (int i = 1; i <= N; i++) cout << Answer[i] << endl;

	return 0;

}

Crystal solution: MAX_X = 1000
n = read_line.to_i
imos = Array.new(MAX_X + 1) { Array.new(MAX_X + 1, 0) }
n.times do
  lx, ly, rx, ry = read_line.split.map(&.to_i)
  imos[ly][lx] += 1
  imos[ly][rx] -= 1
  imos[ry][lx] -= 1
  imos[ry][rx] += 1
end

(0..MAX_X).each do |i|
  (1..MAX_X).each do |j|
    imos[i][j] += imos[i][j - 1]
  end
end
(1..MAX_X).each do |i|
  (0..MAX_X).each do |j|
    imos[i][j] += imos[i - 1][j]
  end
end

cnt = [0i64] * n.succ
(0...MAX_X).each do |i|
  (0...MAX_X).each do |j|
    cnt[imos[i][j]] += 1
  end
end
puts cnt.skip(1).join('\n')
AtCoder problem 028

C++ solution:
#include <iostream>

using namespace std;



// Input

int N;

int lx[1 << 18], ly[1 << 18], rx[1 << 18], ry[1 << 18];



// Count Number

int cnt[1009][1009];

int Answer[1 << 18];



int main() {

	// Step #1. Input

	cin >> N;

	for (int i = 1; i <= N; i++) cin >> lx[i] >> ly[i] >> rx[i] >> ry[i];



	// Step #2. Imos Method in 2D

	for (int i = 1; i <= N; i++) {

		cnt[lx[i]][ly[i]] += 1;

		cnt[lx[i]][ry[i]] -= 1;

		cnt[rx[i]][ly[i]] -= 1;

		cnt[rx[i]][ry[i]] += 1;

	}

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

		for (int j = 1; j <= 1000; j++) cnt[i][j] += cnt[i][j - 1];

	}

	for (int i = 1; i <= 1000; i++) {

		for (int j = 0; j <= 1000; j++) cnt[i][j] += cnt[i - 1][j];

	}



	// Step #3. Count Number

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

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

			if (cnt[i][j] >= 1) Answer[cnt[i][j]] += 1;

		}

	}



	// Step #4. Output The Answer

	for (int i = 1; i <= N; i++) cout << Answer[i] << endl;

	return 0;

}


Python solution: import numpy

from sys import stdin

max_x = max_y = 1000

N = int(stdin.readline())

A = numpy.zeros(shape=(max_x + 1, max_y + 1), dtype=int)

for i in range(N):
	lx, ly, rx, ry = map(int, stdin.readline().split(' '))
	A[lx, ly] += 1
	A[rx, ly] -= 1
	A[lx, ry] -= 1
	A[rx, ry] += 1

A.cumsum(axis=0, out=A)
A.cumsum(axis=1, out=A)

counts = numpy.bincount(A.flatten(), minlength=N+1)

print("\n".join(map(str, counts[1:])))
# for count in counts[1:]:
# 	print(count)
AtCoder problem 028

C++ solution:
#include <iostream>

using namespace std;



// Input

int N;

int lx[1 << 18], ly[1 << 18], rx[1 << 18], ry[1 << 18];



// Count Number

int cnt[1009][1009];

int Answer[1 << 18];



int main() {

	// Step #1. Input

	cin >> N;

	for (int i = 1; i <= N; i++) cin >> lx[i] >> ly[i] >> rx[i] >> ry[i];



	// Step #2. Imos Method in 2D

	for (int i = 1; i <= N; i++) {

		cnt[lx[i]][ly[i]] += 1;

		cnt[lx[i]][ry[i]] -= 1;

		cnt[rx[i]][ly[i]] -= 1;

		cnt[rx[i]][ry[i]] += 1;

	}

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

		for (int j = 1; j <= 1000; j++) cnt[i][j] += cnt[i][j - 1];

	}

	for (int i = 1; i <= 1000; i++) {

		for (int j = 0; j <= 1000; j++) cnt[i][j] += cnt[i - 1][j];

	}



	// Step #3. Count Number

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

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

			if (cnt[i][j] >= 1) Answer[cnt[i][j]] += 1;

		}

	}



	// Step #4. Output The Answer

	for (int i = 1; i <= N; i++) cout << Answer[i] << endl;

	return 0;

}





Kuin solution: func main()
	var n: int :: cui@inputInt()
	const max: int :: 1000
	var cum2d: [][]int :: #[max + 1, max + 1]int
	for(1, n)
		var lx: int :: cui@inputInt()
		var ly: int :: cui@inputInt()
		var rx: int :: cui@inputInt()
		var ry: int :: cui@inputInt()
		do cum2d[ry][rx] :+ 1
		do cum2d[ry][lx] :- 1
		do cum2d[ly][rx] :- 1
		do cum2d[ly][lx] :+ 1
	end for
	
	for y(0, max - 1)
		for x(1, max - 1)
			do cum2d[y][x] :+ cum2d[y][x - 1]
		end for
	end for
	for x(0, max - 1)
		for y(1, max - 1)
			do cum2d[y][x] :+ cum2d[y - 1][x]
		end for
	end for
	
	var ans: []int :: #[n + 1]int
	for y(0, max - 1)
		for x(0, max - 1)
			do ans[cum2d[y][x]] :+ 1
		end for
	end for
	
	for k(1, n)
		do cui@print("\{ans[k]}\n")
	end for
end func
AtCoder problem 028

C++ solution:

Crystal solution: MAX_X = 1000
n = read_line.to_i
imos = Array.new(MAX_X + 1) { Array.new(MAX_X + 1, 0) }
n.times do
  lx, ly, rx, ry = read_line.split.map(&.to_i)
  imos[ly][lx] += 1
  imos[ly][rx] -= 1
  imos[ry][lx] -= 1
  imos[ry][rx] += 1
end

(0..MAX_X).each do |i|
  (1..MAX_X).each do |j|
    imos[i][j] += imos[i][j - 1]
  end
end
(1..MAX_X).each do |i|
  (0..MAX_X).each do |j|
    imos[i][j] += imos[i - 1][j]
  end
end

cnt = [0i64] * n.succ
(0...MAX_X).each do |i|
  (0...MAX_X).each do |j|
    cnt[imos[i][j]] += 1
  end
end
puts cnt.skip(1).join('\n')


Python solution: import numpy

from sys import stdin

max_x = max_y = 1000

N = int(stdin.readline())

A = numpy.zeros(shape=(max_x + 1, max_y + 1), dtype=int)

for i in range(N):
	lx, ly, rx, ry = map(int, stdin.readline().split(' '))
	A[lx, ly] += 1
	A[rx, ly] -= 1
	A[lx, ry] -= 1
	A[rx, ry] += 1

A.cumsum(axis=0, out=A)
A.cumsum(axis=1, out=A)

counts = numpy.bincount(A.flatten(), minlength=N+1)

print("\n".join(map(str, counts[1:])))
# for count in counts[1:]:
# 	print(count)
AtCoder problem 028

C++ solution:

Crystal solution: MAX_X = 1000
n = read_line.to_i
imos = Array.new(MAX_X + 1) { Array.new(MAX_X + 1, 0) }
n.times do
  lx, ly, rx, ry = read_line.split.map(&.to_i)
  imos[ly][lx] += 1
  imos[ly][rx] -= 1
  imos[ry][lx] -= 1
  imos[ry][rx] += 1
end

(0..MAX_X).each do |i|
  (1..MAX_X).each do |j|
    imos[i][j] += imos[i][j - 1]
  end
end
(1..MAX_X).each do |i|
  (0..MAX_X).each do |j|
    imos[i][j] += imos[i - 1][j]
  end
end

cnt = [0i64] * n.succ
(0...MAX_X).each do |i|
  (0...MAX_X).each do |j|
    cnt[imos[i][j]] += 1
  end
end
puts cnt.skip(1).join('\n')





Kuin solution: func main()
	var n: int :: cui@inputInt()
	const max: int :: 1000
	var cum2d: [][]int :: #[max + 1, max + 1]int
	for(1, n)
		var lx: int :: cui@inputInt()
		var ly: int :: cui@inputInt()
		var rx: int :: cui@inputInt()
		var ry: int :: cui@inputInt()
		do cum2d[ry][rx] :+ 1
		do cum2d[ry][lx] :- 1
		do cum2d[ly][rx] :- 1
		do cum2d[ly][lx] :+ 1
	end for
	
	for y(0, max - 1)
		for x(1, max - 1)
			do cum2d[y][x] :+ cum2d[y][x - 1]
		end for
	end for
	for x(0, max - 1)
		for y(1, max - 1)
			do cum2d[y][x] :+ cum2d[y - 1][x]
		end for
	end for
	
	var ans: []int :: #[n + 1]int
	for y(0, max - 1)
		for x(0, max - 1)
			do ans[cum2d[y][x]] :+ 1
		end for
	end for
	
	for k(1, n)
		do cui@print("\{ans[k]}\n")
	end for
end func
AtCoder problem 028

C++ solution:


Python solution: import numpy

from sys import stdin

max_x = max_y = 1000

N = int(stdin.readline())

A = numpy.zeros(shape=(max_x + 1, max_y + 1), dtype=int)

for i in range(N):
	lx, ly, rx, ry = map(int, stdin.readline().split(' '))
	A[lx, ly] += 1
	A[rx, ly] -= 1
	A[lx, ry] -= 1
	A[rx, ry] += 1

A.cumsum(axis=0, out=A)
A.cumsum(axis=1, out=A)

counts = numpy.bincount(A.flatten(), minlength=N+1)

print("\n".join(map(str, counts[1:])))
# for count in counts[1:]:
# 	print(count)




Kuin solution: func main()
	var n: int :: cui@inputInt()
	const max: int :: 1000
	var cum2d: [][]int :: #[max + 1, max + 1]int
	for(1, n)
		var lx: int :: cui@inputInt()
		var ly: int :: cui@inputInt()
		var rx: int :: cui@inputInt()
		var ry: int :: cui@inputInt()
		do cum2d[ry][rx] :+ 1
		do cum2d[ry][lx] :- 1
		do cum2d[ly][rx] :- 1
		do cum2d[ly][lx] :+ 1
	end for
	
	for y(0, max - 1)
		for x(1, max - 1)
			do cum2d[y][x] :+ cum2d[y][x - 1]
		end for
	end for
	for x(0, max - 1)
		for y(1, max - 1)
			do cum2d[y][x] :+ cum2d[y - 1][x]
		end for
	end for
	
	var ans: []int :: #[n + 1]int
	for y(0, max - 1)
		for x(0, max - 1)
			do ans[cum2d[y][x]] :+ 1
		end for
	end for
	
	for k(1, n)
		do cui@print("\{ans[k]}\n")
	end for
end func
AtCoder problem 030

C++ solution:
#include <iostream>

using namespace std;



int N, K;

int cnt[1 << 24];



int main() {

	// Step #1. Input

	cin >> N >> K;



	// Step #2. Count Number

	for (int i = 2; i <= N; i++) {

		if (cnt[i] >= 1) continue;

		for (int j = i; j <= N; j += i) cnt[j] += 1;

	}



	// Step #3. Get Answer

	int Answer = 0;

	for (int i = 1; i <= N; i++) {

		if (cnt[i] >= K) Answer += 1;

	}

	cout << Answer << endl;

	return 0;

}

Crystal solution: n, k = read_line.split.map(&.to_i)
cnt = [0] * n.succ
(2..n).each do |x|
  next if cnt[x] != 0
  x.step(to: n, by: x) { |y|
    cnt[y] += 1
  }
end
puts cnt.count { |x| x >= k }
AtCoder problem 030

C++ solution:
#include <iostream>

using namespace std;



int N, K;

int cnt[1 << 24];



int main() {

	// Step #1. Input

	cin >> N >> K;



	// Step #2. Count Number

	for (int i = 2; i <= N; i++) {

		if (cnt[i] >= 1) continue;

		for (int j = i; j <= N; j += i) cnt[j] += 1;

	}



	// Step #3. Get Answer

	int Answer = 0;

	for (int i = 1; i <= N; i++) {

		if (cnt[i] >= K) Answer += 1;

	}

	cout << Answer << endl;

	return 0;

}





Kuin solution: func main()
	var n: int :: cui@inputInt()
	var k: int :: cui@inputInt()
	
	var isPrime: []bool :: sieve(n)
	var a: []int :: #[n + 1]int
	for i(2, n)
		if(isPrime[i])
			var j: int :: i
			while(j <= n)
				do a[j] :+ 1
				do j :+ i
			end while
		end if
	end for
	
	var ans: int :: 0
	for i(2, n)
		if(a[i] >= k)
			do ans :+ 1
		end if
	end for
	
	do cui@print("\{ans}\n")
	
	func sieve(n: int): []bool
		if(n < 2)
			ret[false].repeat(n + 1)
		end if
		var isPrime: []bool :: [true].repeat(n + 1)
		do isPrime[0] :: false
		do isPrime[1] :: false
		for i(2, n)
			if(isPrime[i])
				var j: int :: i * i
				while(j <= n)
					do isPrime[j] :: false
					do j :+ i
				end while
			end if
		end for
		ret isPrime
	end func
end func
AtCoder problem 030

C++ solution:

Crystal solution: n, k = read_line.split.map(&.to_i)
cnt = [0] * n.succ
(2..n).each do |x|
  next if cnt[x] != 0
  x.step(to: n, by: x) { |y|
    cnt[y] += 1
  }
end
puts cnt.count { |x| x >= k }





Kuin solution: func main()
	var n: int :: cui@inputInt()
	var k: int :: cui@inputInt()
	
	var isPrime: []bool :: sieve(n)
	var a: []int :: #[n + 1]int
	for i(2, n)
		if(isPrime[i])
			var j: int :: i
			while(j <= n)
				do a[j] :+ 1
				do j :+ i
			end while
		end if
	end for
	
	var ans: int :: 0
	for i(2, n)
		if(a[i] >= k)
			do ans :+ 1
		end if
	end for
	
	do cui@print("\{ans}\n")
	
	func sieve(n: int): []bool
		if(n < 2)
			ret[false].repeat(n + 1)
		end if
		var isPrime: []bool :: [true].repeat(n + 1)
		do isPrime[0] :: false
		do isPrime[1] :: false
		for i(2, n)
			if(isPrime[i])
				var j: int :: i * i
				while(j <= n)
					do isPrime[j] :: false
					do j :+ i
				end while
			end if
		end for
		ret isPrime
	end func
end func
AtCoder problem 031

C++ solution:
#include <iostream>

using namespace std;

#pragma warning (disable: 4996)



int N;

int A[1 << 18], B[1 << 18];



int grundy[55][1555];



void init() {

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

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

			int mex[1555];

			for (int k = 0; k < 1555; k++) mex[k] = 0;

			if (i >= 1) {

				mex[grundy[i - 1][j + i]] = 1;

			}

			if (j >= 2) {

				for (int k = 1; k <= (j / 2); k++) mex[grundy[i][j - k]] = 1;

			}

			for (int k = 0; k < 1555; k++) {

				if (mex[k] == 0) { grundy[i][j] = k; break; }

			}

		}

	}

}



int main() {

	// Step #1. Input

	cin >> N;

	for (int i = 1; i <= N; i++) cin >> A[i];

	for (int i = 1; i <= N; i++) cin >> B[i];



	// Step #2. Initialize

	init();



	// Step #3. Get Answer

	int sum_xor = 0;

	for (int i = 1; i <= N; i++) {

		if (i == N) {

			i += 0;

		}

		sum_xor ^= grundy[A[i]][B[i]];

	}



	// Step #4. Output

	if (sum_xor != 0) cout << "First" << endl;

	if (sum_xor == 0) cout << "Second" << endl;

	return 0;

}

Crystal solution: class Array(T)
  def mex
    result = 0
    sort.each do |i|
      return result if result < i
      result = i.succ
    end
    result
  end
end

grundy = Hash({Int32, Int32}, Int32).new { |hash, (w, b)|
  if w == 0 && b <= 1
    0
  else
    a = [] of Int32
    a << hash[{w - 1, b + w}] if w >= 1
    a.concat (1..b // 2).map { |k| hash[{w, b - k}] }
    hash[{w, b}] = a.mex
  end
}

read_line
w = read_line.split.map(&.to_i)
b = read_line.split.map(&.to_i)
puts w.zip(b).reduce(0) { |acc, (w, b)|
  acc ^ grundy[{w, b}]
} > 0 ? "First" : "Second"