Skip to content

Instantly share code, notes, and snippets.

View asi1024's full-sized avatar

Akifumi Imanishi asi1024

  • Preferred Networks Inc.
  • Tokyo, Japan
View GitHub Profile
# import numpy
from cupy.fallback_mode import numpy
x = numpy.array([[float('nan'), -1], [float('nan'), 1]]) # cupy.array
result1 = numpy.nanargmin(x, axis=1) # Converts to numpy.array, calls numpy.argmin and returns cupy.array
result2 = numpy.nanargmin(x) # Returns privitive int
print(result1) # Output: [1 1]
print(result2) # Output: 1
#include "../../lib/template/template.cpp"
{% if mod %} #include "../../lib/types/mod.cpp" {% endif %}
{% if mod %} using Mod = Modulo<{{ mod }}>; {% endif %}
{% if yes_str and no_str %}
struct yes_no : std::numpunct<char> {
string_type do_truename() const { return "{{ yes_str }}"; }
string_type do_falsename() const { return "{{ no_str }}"; }
};
#include <bits/stdc++.h>
using namespace std;
template<typename Edge>
vector<int> scc(const vector<vector<Edge>> &g) {
const int n = g.size();
vector<vector<int>> rg(n);
vector<int> cmp(n), vs;
vector<bool> used(n, false);
template <class T>
class SegmentTree {
const int n;
vector<T> data;
public:
SegmentTree(const int s) : n(1 << s), data(n * 2, T()) {}
void update(int p, T val) {
data[p += n] = val;
while (p /= 2) {
data[p] = merge(data[p * 2], data[p * 2 + 1]);
template <class T>
class SegmentTree {
const int n;
vector<T> data;
T sub(int l, int r, int node, int lb, int ub) const {
if (ub <= l || r <= lb) return T();
if (l <= lb && ub <= r) return data[node];
T vl = sub(l, r, node * 2 + 0, lb, (lb + ub) / 2);
T vr = sub(l, r, node * 2 + 1, (lb + ub) / 2, ub);
return merge(vl, vr);
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
const int mod = 1000000007;
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;
int N, M;
int s[16], d[128];
int memo[1<<15][128];
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;
using ld = long double;
struct Edge{ int src, dest; };
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;
vector<string> from_jfen(string s) {
s += "/";
vector<string> res;