akhauriyash/Code-Regression huggingface dataset:
#include <iostream> 
#include <sstream> 
#include <iomanip> 
#include <algorithm> 
#include <cmath> 
#include <string> 
#include <vector> 
#include <list> 
#include <queue> 
#include <stack> 
#include <set> 
#include <map> 
#include <bitset> 
#include <numeric> 
#include <climits> 
#include <cfloat> 
using namespace std;

int main()
{
    int n, m;
    cin >> m >> n;
    vector<vector<double> > win(m, vector<double>(n));
    for(int i=0; i<m; ++i){
        for(int j=0; j<n; ++j){
            cin >> win[i][j];
        }
    }

    vector<vector<double> > dp(1<<m, vector<double>(m+1, 1.0));
    for(int a=n-1; a>=0; --a){ // ツ攻ツ猟ェツつキツづゥツ敵
        vector<vector<double> > next(1<<m, vector<double>(m+1, 0.0));
        for(int b=1; b<(1<<m); ++b){ // ツ残ツづィツづ個猫
            for(int c=0; c<=m; ++c){ // ツ選ツ妥ーツつオツつスツ猫(c==mツづ按づァツづ篠、ツづ慊つセツ選ツ妥ーツつオツづつ「ツづ按つ「)
                double ret = 0.0;
                if(c == m){
                    for(int i=0; i<m; ++i){
                        bitset<16> bs(b);
                        if(!bs[i])
                            continue;

                        double p = win[i][a] * dp[b][i];
                        bs[i] = false;
                        p += (1.0 - win[i][a]) * next[bs.to_ulong()][m];

                        ret = max(ret, p);
                    }
                }else{
                    bitset<16> bs(b);
                    ret = win[c][a] * dp[b][c];
                    bs[c] = false;
                    ret += (1.0 - win[c][a]) * next[bs.to_ulong()][m];

                }
                next[b][c] = ret;
            }
        }
        dp.swap(next);
    }

    printf("%.10f\n", dp[(1<<m)-1][m]);

    return 0;
}

Measured memory_bytes: 20000
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;

int n, m;
int a[200001], b[200001];
set<int> s = {};

int main(void){
    // Here your code !
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m; ++i) {
      scanf("%d %d", &a[i], &b[i]);
    }

    if (m == 1) {printf("IMPOSSIBLE\n");}
    else {
      for (int i = 0; i < m; ++i) {
        if (b[i] == n) s.insert(a[i]);
      }

      /*
      set<int>::iterator iter;
      for (iter = s.begin(); iter != s.end(); ++iter) printf("%d\n", *iter);
      */

      for (int i = 0; i < m; ++i) {
        if ((a[i] == 1) && (s.find(b[i]) != s.end())) {
            printf("POSSIBLE\n");
            return 0;
        }
      }
      printf("IMPOSSIBLE\n");
      return 0;
    }
}

Measured memory_bytes: 6528
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

//#include "Union_Find.h"

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>

using namespace std;
#define REP(i,a,n) for(int i = a; i < n; ++i)
#define REPM(i,n,a) for(int i = n - 1; i >= a; --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;

class SplitStream {
	typedef basic_ostream<char, char_traits<char> > BaseOst;
	std::ostream& ost_m;
	bool line_is_empty_m;
public:
	SplitStream(std::ostream& ost);
	template <typename T>
	SplitStream& operator<<(T right);
	SplitStream& operator<<(BaseOst& (*right)(BaseOst&));
};
SplitStream::SplitStream(std::ostream& ost) : ost_m(ost), line_is_empty_m(true) {}
template <typename T>
SplitStream& SplitStream::operator<<(T right) {
	if (!line_is_empty_m) ost_m << ' ';
	line_is_empty_m = false;
	ost_m << right;
	return *this;
}
/* std::endl のみ */
SplitStream& SplitStream::operator<<(BaseOst& (*right)(BaseOst&)) {
	ost_m << '\n';
	ost_m.flush();
	line_is_empty_m = true;
	return *this;
}
SplitStream Scout(cout);

template <typename T, int Begin, int End>
class OffsetArray {
	T arr_m[End - Begin];
public:
	OffsetArray();

	T& operator[](int index);
	T operator[](int index) const;
};
template<typename T, int Begin, int End>
OffsetArray<T, Begin, End>::OffsetArray() : arr_m() {}
template<typename T, int Begin, int End>
T& OffsetArray<T, Begin, End>::operator[](int index) {
	return arr_m[index - Begin];
}
template<typename T, int Begin, int End>
T OffsetArray<T, Begin, End>::operator[](int index) const {
	return arr_m[index - Begin];
}

template<typename T, int N>
void Fill(T(&arr)[N], T val) {
	for (int i = 0; i < N; ++i) {
		Fill(arr[i], val);
	}
}
template<typename T, int M, int N>
void Fill2D(T(&arr)[M][N], T val) {
	for (int i = 0; i < M; ++i) {
		Fill(arr[i], val);
	}
}

#if 1
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;
#endif

int X;
int main() {
	int sum = 0, i = 0;
	cin >> X;
	while (sum < X) {
		++i;
		sum += i;
	}
	cout << i << endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
int main(){
  int input[2], keep, n, max;
  std::cin >> n;
  for(int i=0; i<n; i++){
    if(i == 0){
      std::cin >> input[0];
      continue;
    }
    if(i == 1){
      std::cin >> input[1];
      max = input[1] - input[0];
      continue;
    }
    std::cin >> keep;
    if(input[0] > input[1]) input[0] = input[1];
    input[1] = keep;
    if(input[1]-input[0] > max) max = input[1]-input[0];
  }
  std::cout << max << "\n";
  return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define ll long long
vector<vector<int>> adj;
const int N = 1001;
const int M = 2001;
const int MOD = 1e9 + 7;
struct Edge{
  int u, v, w;
  bool inMST;
  Edge(){}
  Edge(int u, int v, int w){
    this -> u = u;
    this -> v = v;
    this -> w = w;
    this -> inMST = 0;
  }
  int ot(int x){
    return x ^ u ^ v;
  }
} e[M];

int par[N];
int find_set(int u){
  return par[u] == u ? u : par[u] = find_set(par[u]);
}
bool join(int u, int v){
  u = find_set(u);
  v = find_set(v);
  if(u == v)return false;
  if(rand() & 1)swap(u, v);
  par[u] = v;
  return true;
}
void init(){
  for(int i = 0;i < N;i++)
    par[i] = i;
}
vector<vector<int>> mst;
// cost of minimum spanning tree
ll kruksal(int num_edges){
  init();
  vector<int> se(num_edges);
  for(int i = 0;i < num_edges;i++)
    se[i] = i;
  sort(se.begin(), se.end(), [](int a, int b){
    return e[a].w < e[b].w;
  });
  ll res = 0;
  for(int i = 0;i < num_edges;i++){
    if(join(e[se[i]].u, e[se[i]].v)){
      mst[e[se[i]].u].push_back(se[i]);
      mst[e[se[i]].v].push_back(se[i]);
      res += e[se[i]].w;
      e[se[i]].inMST = 1;
    }
  }
  return res;
}
int epar[N];
int depth[N];
void root_at(int u, int p = -1){
  depth[u] = (p == -1 ? 0 : depth[p] + 1);
  for(auto el : mst[u]){
    int v = e[el].ot(u);
    if(v == p)continue;
    root_at(v, u);
    epar[v] = el;
  }
}
int max_path(int u, int v){
  int res = 0;
  if(depth[u] < depth[v])swap(u, v);
  while(depth[u] != depth[v]){
    res = max(res, e[epar[u]].w);
    u = e[epar[u]].ot(u);
  }
  if(u == v)return res;
  while(u != v){
    res = max(res, e[epar[u]].w);
    res = max(res, e[epar[v]].w);
    u = e[epar[u]].ot(u);
    v = e[epar[v]].ot(v);
  }
  return res;
}
ll pow1(ll n, ll p){
  return p == 0 ? 1 : ((p & 1) ? n * pow1(n, p - 1) % MOD : pow1(n * n % MOD, p / 2));
}
int main(){
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  int n, m;
  ll x;
  cin >> n >> m >> x;
  int u, v, w;
  adj.resize(n);
  mst.resize(n);
  for(int i = 0;i < m;i++){
    scanf("%d %d %d", &u, &v, &w);
    u--, v--;
    adj[u].push_back(i);
    adj[v].push_back(i);
    e[i] = Edge(u, v, w);
  }
  ll D = kruksal(m);
  root_at(0);
//  for(int i = 0;i < n;i++){
//    for(auto el : mst[i])
//      cout << el << ' ';
//    cout << endl;
//  }
//  return 0;
  vector<int> diffs;
  for(int i = 0;i < m;i++){
    if(!e[i].inMST){
      diffs.push_back(e[i].w - max_path(e[i].u, e[i].v));
    }
  }
  int hi, lo, eq;
  hi = lo = eq = 0;
  for(auto el : diffs){
    if(el == x - D)
      eq++;
    else if(el > x - D)
      hi++;
    else
      lo++;
  }
//  cout << D << ' ' << x << endl;
//  cout << lo << ' ' << eq << ' ' << hi << endl;
//  cout << diffs[0] << endl;
  ll res = 0;
  if(D == x){
    res = pow1(2, m - (n - 1)) * (pow1(2, n - 1) - 2 + MOD) % MOD;
    res += 2 * (pow1(2, eq) - 1) % MOD * pow1(2, hi) % MOD;
    res %= MOD;
  }else if(D < x){
    res += 2 * (pow1(2, eq) - 1) % MOD * pow1(2, hi) % MOD;
  }
  cout << res;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
struct data {
  int nt, to, w;
} a[N << 1];
int head[N], cnt = 0;

void add(int x, int y, int w) {
  a[++cnt].to = y;
  a[cnt].w = w;
  a[cnt].nt = head[x];
  head[x] = cnt;
}

int vs[N], dis[N];
deque<int> q;

int main() {
  int k;
  scanf("%d", &k);
  for(int i = 1; i < k; ++i) {
    int pos = i * 10 % k;
    add(i, (i + 1) % k, 1);
    add(i, pos, 0);
  }
  memset(dis, 0x3f, sizeof dis);
  dis[1] = 1;
  q.push_front(1);
  while(!q.empty()) {
    int u = q.front(); q.pop_front();
    if(vs[u]) continue;
    vs[u] = 1;
    if(u == 0) {
      printf("%d\n", dis[u]);
      break;
    }
    for(int i = head[u]; i; i = a[i].nt) {
      int to = a[i].to, w = a[i].w;
      if(dis[to] > dis[u] + w) {
        dis[to] = dis[u] + w;
        if(!w) q.push_front(to);
        else q.push_back(to);
      }
    }
  }
  return 0;
}

/*
41
4
41 * 271 = 1111
*/

Measured memory_bytes: 3968
pickMax :: [Int] -> (Int, [Int])
pickMax [] = error "undefined"
pickMax [x] = (x, [])
pickMax (x:xs)
 | x > x'    = (x, x':xs')
 | otherwise = (x', x:xs')
 where (x', xs') = pickMax xs

main = do
  l <- map read . words <$> (getLine >> getLine)
  let (maxL, others) = pickMax l
  if maxL < sum others then putStr "Yes" else putStr "No"

Measured memory_bytes: 508
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A.at(i);

    string ans = "APPROVED";
    rep(i, N) {
        if(A.at(i) % 2 == 0) {
            if(!(A.at(i) % 3 == 0 || A.at(i) % 5 == 0)) {
                ans = "DENIED";
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3612
n, k = map(int, input().split())
a = list(map(int, input().split()))
for _ in range(k):
    b = [0] * (n + 1)
    for i in range(n):
        b[max(0, i - a[i])] += 1
        b[min(n, i + a[i] + 1)] -= 1
    for i in range(n):
        b[i + 1] += b[i]
    a = b[:-1].copy()
    for x in a:
        if x < n:
            break
    else:
        print(*a)
        exit(0)
print(*a)


Measured memory_bytes: 169612
from itertools import combinations_with_replacement
N,M,Q = map(int,input().split())

abcd = [tuple(map(int,input().split())) for _ in range(Q)]

ans = 0
for n in combinations_with_replacement(range(1,M+1),N):
    tmp = 0
    for a,b,c,d in abcd:
        if n[b-1] - n[a-1] == c:
            tmp += d
    
    ans = max(ans,tmp)


print(ans)

Measured memory_bytes: 9172
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if ((a == 5 && b == 5 && c == 7) || (a == 5 && b == 7 && c == 5) || (a == 7 && b == 5 && c == 5)) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 21844
#include<stdio.h>
#include<math.h>

int main(){
  int N, T, A, ans, count = 0;
  float x, H, min = 100001;
  
  scanf("%d", &N);
  scanf("%d %d", &T, &A);
  x = ((float)T - (float)A)/0.006;
  
  for (int i = 0; i < N; i++){
    scanf("%f", &H);
    count++;
    if(min > fabs(H - x)){
      min = fabs(H - x);
      ans = count;
    }
  }
  
  printf("%d\n", ans);
  
  return 0;
}
      
    

Measured memory_bytes: 128
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <vector>
#include <stack>
using namespace std;
#define ll int64_t
const ll mod = 1000000007;


const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


int main() {
  ll n, m;

  long b[11];

  b[1] = 2;
  b[2] = 5;
  b[3] = 5;
  b[4] = 4;
  b[5] = 5;
  b[6] = 6;
  b[7] = 3;
  b[8] = 7;
  b[9] = 6;


  cin >> n >> m;
  vector<long> a(m);
  cin >> a;

  long minb = 110;
  for (auto v : a) {
    if (minb > b[v])minb = b[v];
  }

  cerr << minb <<endl;
  vector<vector<long >> ans(n + 1, vector<long>());

  vector<long> dp(n + 1, -1);

sort(a.begin(),a.end(),greater<long>());


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

    if (!(i==0 || i>=minb))continue;

    for (auto v : a) {
      if (i + b[v] <= n) {
        if ( dp[i + b[v] ] <= dp[i] + 1 ) {

          vector<long> tmp;
          tmp = ans[i];
          tmp.push_back(v);

          bool islarge = true;
          if (tmp.size() > ans[i + b[v]].size()) {
          } else {
            for (int k = 0; k < tmp.size(); k++) {
              if (tmp[k] < ans[i + b[v]][k]){
                islarge = false;
              }
              if (tmp[k] > ans[i + b[v]][k])break;
            }
          }

          if (islarge) {
            ans[i + b[v] ] = tmp;
            dp[i + b[v] ] = tmp.size();
          }
        }
      }
    }
  }


  sort(ans[n].begin(),ans[n].end(),greater<long>());

  for (auto s : ans[n]) {
    cout << s ;
  } cerr << endl;


}




















Measured memory_bytes: 311040
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;
    map<int,int> m;
    REP(i,n) {
        int x;
        cin >> x;
        m[x]++;
    }

    priority_queue<int> pq;
    for(auto p:m) {
        // cerr << p.second << endl;
        pq.push(p.second);
    }
    cerr << endl;
    while(pq.top() != 1) {
        int t = pq.top(); pq.pop();
        // cerr << t << endl;
        if (t > 2) {
            t -= 2;
            pq.push(t);
        } else { // t == 2 
            int s = pq.top(); pq.pop();
            if (s == 2) {
                REP(i,2) pq.push(1);
            } else pq.push(1);
        }
    }

    cout << pq.size() << endl;

    return 0;
}

Measured memory_bytes: 5632
n = int(input())
ans = 0
for i in range(1,n+1):
    flag = 1
    if i%3 == 0 and i%5 == 0:
        flag = 0
    elif i%3 == 0:
        flag = 0
    elif i%5 == 0:
        flag = 0
    if flag == 1:
        ans += i
print(ans)

Measured memory_bytes: 65440
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
int GCD(int a, int b) {
  if(a < b) GCD(b, a);
  int r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

void _main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, 0, N) cin >> A[i];

    vector<int> a(N);
    vector<int> b(N);

    a[0] = A[0];
    b[N - 1] = A[N - 1];

    rep(i, 0, N - 1)
    {
        a[i + 1] = GCD(a[i], A[i + 1]);
    }
    rrep(i, N - 1, 1)
    {
        b[i - 1] = GCD(A[i - 1], b[i]);
    }
/*
    rep(i, 0, N)
    {
        cout << a[i] << " ";
    }
    cout << endl;

    rep(i, 0, N)
    {
        cout << b[i] << " ";
    }
    cout << endl;
    */

    int ans = 0;
    rep(i, 0, N)
    {
        if (i == 0)
        {
            chmax(ans, b[i + 1]);
        }
        else if (i == N - 1)
        {
            chmax(ans, a[i - 1]);
        }
        else
        {
            chmax(ans, GCD(a[i - 1], b[i + 1]));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1408
A,B,C,X,Y=map(int,input().split())

ans = A*X + B*Y
tmp = A*X + B*Y
x = X
y = Y
z = 0

while x >= 0 or y >= 0:
    if x<0 and y<0:
        tmp = C*z
    elif x<0:
        tmp = B*y + C*z
    elif y<0:
        tmp = A*x + C*z
    else:
        tmp = A*x + B*y + C*z
    ans = min(ans,tmp)
    x=x-1
    y=y-1
    z=z+2

print(ans)

Measured memory_bytes: 3188
/**
*	created: 23.08.2020 18:00:09
**/
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
using ll = long long;
using P = pair<int,int>;
// #define endl '\n'
#define int long long
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1ll << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

// ModInt
template <typename T> T pow(T a, long long n, T e = 1) {
    T ret = e;
    while (n) {if (n & 1) ret *= a; a *= a; n >>= 1;}
    return ret;
}

template <int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {if ((x = x_ % mod + mod) >= mod) x -= mod;}
    ModInt& operator+=(ModInt rhs) {if ((x += rhs.x) >= mod) x -= mod; return *this;}
    ModInt& operator-=(ModInt rhs) {if ((x -= rhs.x) < 0) x += mod; return *this;}
    ModInt& operator*=(ModInt rhs) {x = (unsigned long long)x * rhs.x % mod; return *this;}
    ModInt& operator/=(ModInt rhs) {x = (unsigned long long)x * rhs.inv().x % mod; return *this;}
    ModInt operator-() const {return -x < 0 ? mod - x : -x;}
    ModInt operator+(ModInt rhs) const {return ModInt(*this) += rhs;}
    ModInt operator-(ModInt rhs) const {return ModInt(*this) -= rhs;}
    ModInt operator*(ModInt rhs) const {return ModInt(*this) *= rhs;}
    ModInt operator/(ModInt rhs) const {return ModInt(*this) /= rhs;}
    bool operator==(ModInt rhs) const {return x == rhs.x;}
    bool operator!=(ModInt rhs) const {return x != rhs.x;}
    ModInt inv() const {return pow(*this, mod - 2);}
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {s << a.x; return s;}
    friend istream& operator>>(istream& s, ModInt<mod>& a) {s >> a.x; return s;}
};

using mint = ModInt<MOD>;

mint fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    rep2(i,2,MAX){
        fac[i] = fac[i-1] * (mint)i;
        inv[i] = (mint)MOD - inv[MOD%i] * (mint)(MOD/i);
        finv[i] = finv[i-1] * inv[i];
    }
}

mint COM(int n,int k) {
    if (n < k or n < 0 or k < 0) return 0;
    return fac[n] * finv[k] * finv[n-k];
}

mint PER(int n, int k) {
    if (n < k or n < 0 or k < 0) return 0;
    return fac[n] / fac[n-k];
}

map<int,int> mp;

void prime(int n) {
    if (n == 1) return;
    for (int i = 2; i*i<= n; i++) {
        if (n % i == 0) {
            prime(i);
            prime(n/i);
            return;
        }
    }
    mp[n]++;
    return;
}

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n, m; cin >> n >> m;
    prime(m);
    COMinit();
    mint ans = 1;
    for (auto p : mp) ans *= COM(p.second+n-1,n-1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 27100
a,b,c = list(map(int, input().strip().split()))
f=0
if a%2==1 or b%2==1 or c%2==1:
    print(f)
elif a==b and b==c:
    f=-1
    print(f)
else:
    while a%2==0 and b%2==0 and c%2==0:
        A=a
        B=b
        C=c
        a=B//2+C//2
        b=A//2+C//2
        c=A//2+B//2
        f=f+1
    else:
        print(f)
        

Measured memory_bytes: 9128
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from collections import Counter, defaultdict


def main():
    N, A = map(int, input().split())
    X = [int(x) - A for x in input().split()]

    result = Counter([0])

    for x in X:
        dct = defaultdict(int)
        for k, v in result.items():
            dct[k + x] += v
        result += dct

    print(result[0] - 1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3572
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(void) {
    int ant[5];
    int max;
    for (int i = 0; i < 5; ++i) {
        cin >> ant[i];
    }
    cin >> max;

    for (int i = 0; i < 5; ++i) {
        for (int j = i; j < 5; ++j) {
            int dist = abs(ant[i] - ant[j]);
            if (dist > max) {
                cout << ":(" << endl;
                return 0;
            }
        }
    }
    cout << "Yay!" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long LL;

LL powmod(LL a, int n){
	if(n == 0) return 1;
	if(n % 2) return (a*powmod(a,n-1)) % MOD;
	LL c = powmod(a,n/2);
	return (c*c) % MOD;
}
LL inv(LL a){
	return powmod(a,MOD-2);
}
LL dp[2100][2100];
LL fact[5000000];
LL invfact[5000000];
int main(){
	int n, k;
	cin >> n >> k;
	if(k == 1){
		cout << 1 << endl;
		return 0;
	}
	fact[0] = 1;
	for(LL i = 1; i <= 4010000; i++) fact[i] = (fact[i-1]*i) % MOD;
	invfact[4010000] = inv(fact[4010000]);
	for(LL i = 4010000-1; i >= 0; i--) invfact[i] = (invfact[i+1] * (i+1)) % MOD;

	dp[0][0] = 1;
	for(int a = 1; a <= n; a++){
		for(int b = a; b >= 0; b--){
			LL r = 0;
			if(b > 0){
				r = (a*fact[a*k-b-1]) % MOD;
				r = (r*invfact[k-2]) % MOD;
				r = (r*invfact[a*k-b-1 - (k-2)]) % MOD;
				r = (r*dp[a-1][b-1]) % MOD;
			}
			r = (r + dp[a][b+1]) % MOD;
			dp[a][b] = r;
		}
	}
	cout << dp[n][0] % MOD << endl;
}


Measured memory_bytes: 85888
#include <iostream>
#include <stack>
#include <queue>
#include <map>
#include <vector>
#include <cstdio>
#include <string>
#include <climits>
#include <cmath>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
    int x,n,ans = 0;
    cin>>n;
    int a[100005] = {0};
    for(int i = 0; i < n; i++){
        cin>>x;
        a[x]++;
        a[x+1]++;
        a[x+2]++;
        ans = max(ans, a[x]);
        ans = max(ans, a[x+1]);
        ans = max(ans, a[x+2]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];

int main(){
    int n, R; cin >> n >> R;
    int maximum = INT_MIN, origin = R;
    rep(i,n-1){
        cin >> R;
        maximum = max(maximum, R-origin);
        origin = min(origin, R);
    }
    cout << maximum << endl;
}


Measured memory_bytes: 3108
n = int(input())
t = [0]
x = [0]
y = [0]
for i in range(n):
    t_tmp, x_tmp, y_tmp = map(int, input().split())
    t.append(t_tmp)
    x.append(x_tmp)
    y.append(y_tmp)

r_init = [0, 0]
parity = 0 # 偶数
for i in range(1, n+1):
    dt = t[i] - t[i-1]
    dx = abs(x[i] - x[i-1])
    dy = abs(y[i] - y[i-1])
    dist = dx + dy

    if dist > dt:
        print('No')
        exit()
    
    if dt % 2 != dist % 2:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 11796
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class B
{
	public static void Main()	
	{
		string[] args = Console.ReadLine().Split(' ');
		int A = Int32.Parse(args[0]);
		int B = Int32.Parse(args[1]);
		int C = Int32.Parse(args[2]);
		int D = Int32.Parse(args[3]);

		if((B < C) || (A > D))
		{
			Console.WriteLine(0);
		}
		else
		{
			Console.WriteLine(Math.Min(B,D) - Math.Max(A,C));
		}
	}
}





Measured memory_bytes: 13140
X, K, D = map(int, input().split())

X = abs(X)

if X >= K * D:
    print(abs(X - K * D))
    exit()

mov = X // D    # 0～Xの間で移動する回数

if abs(X-mov*D) > abs(X-(mov+1)*D):
    mov += 1

rem = abs(X-mov*D)
mov = K - mov   # 残回数（あとは地点0付近を行ったり来たりするだけ）
mov = mov % 2

print(abs(rem-mov*D))


Measured memory_bytes: 9184
import math
import time
from collections import deque
from copy import deepcopy

t = time.time()
def iip():
    ret = [int(i) for i in input().split()]
    if len(ret) == 1:
        return ret[0]
    return ret


def main():
    n = iip()

    if n == 0:
        print(0)
        exit()
    if n % 2 == 1:
        print(0)
        exit()

    ret = int(0)

    num = 10
    while num <= n:
        ret += n // num
        num *= 5

    print(int(ret))


main()

Measured memory_bytes: 3568
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a,b,c) > 0 else INF
    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b  + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c  + l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)

print(dfs(0,0,0,0))

Measured memory_bytes: 3064
#include<bits/stdc++.h>

using namespace std;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out2.txt", "w", stdout);
    int T;
    cin >> T;
    vector<int> pp;
    for (int i = 1; i <= 2*T; ++i)
    {
        int x;
        cin>>x;
        pp.push_back(x);
    }
    
    sort(pp.begin(), pp.end());
    
    int sum = 0;
    for (int i = 0; i < pp.size(); i+=2)
    {
        sum += pp[i];
    }
    cout<<sum;
    
    return 0;
}



Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <cmath>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <fstream>
#include <list>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <ctime>
#include<numeric>


using namespace std;
#define vec vector
#define pb push_back
#define en '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<ll, ll> pull;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef long double ld;
typedef pair<ld, int> pli;
typedef unsigned int ui;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vi2;
typedef vector<vector<ll>> vll2;
typedef vector<vector<ll>> matrix;
typedef vec<vec<vec<int>>> vi3;

#define _DEBUG

#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define for1(i,n) for(int i = 1;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>
#define REP(a,i,b) for (int i = a;i<b;i++);
#pragma warning(disable : 4996)
/*
 #pragma GCC optimize("Ofast")
 #pragma GCC target("avx,avx2,fma")
 */
const int inf = 2e9;
const ll linf = 2e18;
const ld LDINF = 2e18;


void solve()
{
	ll n,x,y;
	cin >> n;
	vector<pll> mas(n);
	for0(i, n) {
		cin >> x >> y;
		mas[i] = { x,y };
	}
	vector<ll> s(n);
	for0(i, n) {
		s[i] = mas[i].first + mas[i].second;
	}
	vector<ll> m(n);
	for0(i, n) {
		m[i] = mas[i].first - mas[i].second;
	}
	sort(all(s));
	sort(all(m));
	cout << max(s[n - 1] - s[0], m[n - 1] - m[0]);

}


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int tst = 1;
	//cin >> tst;
	while (tst--)
		solve();
	return 0;
}

Measured memory_bytes: 9516
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 100001
#define INF (ll)1e18
#define pll pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define vv vector
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define repr(i,n) repr2(i,n,0)
#define repr2(i,m,n) for(ll i=m;i>=(n);i--)
#define get(n) ll (n); scanf("%lld",&(n));
#define get2(n,k) ll (n),(k); scanf("%lld%lld",&(n),&(k));
#define get3(n,m,k) ll (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k));
#define gets(s) string (s); cin >> (s);
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) vector<ll> A((n)); for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}
#define pi 3.1415926535897
#define noop

int main() {

    get(n);
    fill_nums(A,n);

    ll res = 1, k=0;
    map<ll,ll> ma;
    rep(i,n) {
        if(A[i]==0) k++;

        if(A[i]==0) ma[0]++;
        else {

            if(ma[A[i]-1]<=0) {
                printf("0\n");
                return 0;
            }

            res = (res*ma[A[i]-1])%N;
            ma[A[i]-1]--;
            ma[A[i]]++;
        }

    }

    if(k==0 || k>3) {
        printf("0\n");
        return 0;
    }

    if(k==1) {
        res = (res*(ll)3)%N;
    }
    else {
        res = (res*(ll)6)%N;
    }   

    printf("%lld\n", res);

    return 0;  
}



Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;

int n, m, a[105], tot, cnt;
double s;

int main() {
	cin>>n>>m;
	for(int i = 1; i <= n; i++) {
		cin>>a[i];
		tot += a[i];
	}
	s = (double)tot/(double)(4*m);
	for(int i = 1; i <= n; i++) 
		if(a[i] >= s) cnt++;
	if(cnt >= m) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
from collections import defaultdict
counts = defaultdict(lambda: 0)

n = int(input())
s = input()
ans = 0

for i, c in enumerate(s):
    counts[c] += 1
    j = 1
    while i - j >= 0 and i + j <= n - 1:
        if s[i - j] != s[i] and s[i] != s[i + j] and s[i - j] != s[i + j]:
            ans -= 1
        j += 1
print(ans + counts['R'] * counts['G'] * counts['B'])


Measured memory_bytes: 68400
#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;

#define INF 		2000000007
#define MINF		-2000000007
#define MAX 		100005

const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//


// agc071
int main(){
	string N;cin>>N;

	sort(ALL(N));

	if(N[0]==N[1] && N[2]==N[3] && N[0]!=N[2])puts("Yes");
	else puts("No");

	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;

int main()
{
  int X, Y;
  
  vector<int> panel(3);
  cin >> panel.at(0) >> panel.at(1) >> panel.at(2);
  
  sort(panel.begin(), panel.end());
  reverse(panel.begin(), panel.end());
  
  X = 10 * panel.at(0) + panel.at(1);
  Y = panel.at(2);
  
  cout << X + Y << endl;
  
  return 0;
}



Measured memory_bytes: 256
N = int(input())

def cKeta(A):
    return(len(str(A)))

th = round(N ** 0.5)
minketa = 12
for i in range(1,th+1):
    if N % i == 0:
        keta = max(cKeta(i),cKeta(N//i))
        if keta < minketa:
            minketa = keta
            
print(minketa)
        

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for(ll i = a; i < (ll)(b); i++)

#define ALL(x) (x).begin(), (x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

using namespace std;
using ll = long long;
using vel = vector<ll>;
using ves = vector<string>;
using veb = vector<bool>;
using qul = queue<ll>;

void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

int binary_search(ll x, vel a){
    auto ite = lower_bound(ALL(a), x);
    if(ite != a.end() && *ite == x) {
        return ite - a.begin() ;
    } else {
        return -1;
    }

}

ll modpow(ll a, ll n, ll mod) {
    if(n == 0)
        return 1;
    if(n == 1)
        return a % mod;
    if(n % 2 == 1)
        return (a * modpow(a, n - 1, mod)) % mod;
    ll t = modpow(a, n / 2, mod);
    return (t * t) % mod;
}

int main() {
    ll N, K, sum = 0, sum2 = 0, next, count = 0, ans, num, num2,  m_l, m_l2;
    cin >> N >> K;
    vel P(N), C(N), check(N);
    REP(i, N) cin >> P[i];
    REP(i, N) cin >> C[i];
    
    bool flag = false;
    ans = C[0];
    REP(i,N){
        count = 0;
        next = i;
        sum = 0;
        m_l = C[next];
        m_l2 = C[next];
        REP(j,N){
            sum += C[next];
            next = P[next]-1;
            ans = max(ans, sum);
            m_l2 = max(m_l2, sum);
            count++;
            if(j+1 >= K || next == i)
                break;
        }

        next = i;
        sum2 = 0;
        REP(j, K%count) {
            sum2 += C[next];
            next = P[next]-1;
            m_l = max(m_l, sum2);
        }



        if(sum >= 0){
            if(K%count==0) m_l = 0;
            num = K/count * sum + m_l;
            num2 = (K/count - 1) * sum  + m_l2;
            num = max(num, num2);
            ans = max(ans, num);
        } else {
            ans = max(ans, m_l);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    string color;
    cin >> color;

    int red;
    int white = 0;
    for (int i = 0; i < n; i++) {
        if (color[i] == 'W') {
            white++;
        }
    }   
    red = n - white;

    ll sum = 0;
    for (int i = 0; i < red; i++) {
        if (color[i] == 'W') {
            sum++;
        }
    } 
    cout << sum << endl;
     

    return 0;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;

double euclidnorm(vector<int> a, vector<int> b){
    int d = a.size();
    int ssum = 0;
    for(int i=0; i<d; i++){
        ssum += pow(a[i]-b[i],2);
    }
    return pow(ssum,0.5);
}

int main(){
    int n,d; cin >> n >> d;
    vector<vector<int>> point(n,vector<int>(d)) ;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < d; j++){
            cin>>point[i][j];
        }
    }
    int count = 0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            double norm = euclidnorm(point[i],point[j]);
            if (norm == floor(norm)) count ++;
        }
    }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
int main() {
	int A,B,C,D;
	cin>>A>>B>>C>>D;
	int ans=min(A,B)+min(C,D);
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#https://naoyat.hatenablog.jp/entry/k-dimension-manhattan-distance
N=int(input())
kouho=[(10**10)*(-1)]*4#xmax,ymax,xmin,ymin
kouho[2]=10**10
kouho[3]=10**10
ans=0
for i in range(N):
    x,y=map(int,input().split())
    newx=x-y
    newy=x+y
    if newx>kouho[0]:
        kouho[0]=newx
    if newx<kouho[2]:
        kouho[2]=newx
    if newy>kouho[1]:
        kouho[1]=newy
    if newy<kouho[3]:
        kouho[3]=newy
ans=max(kouho[0]-kouho[2],kouho[1]-kouho[3])
print(ans)

Measured memory_bytes: 9188
#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>
using namespace std;
#define error(args...)                       \
{                                            \
    cerr<<"LINE "<<__LINE__;                 \
    string _s = #args;                       \
    replace(_s.begin(), _s.end(), ',', ' '); \
    stringstream _ss(_s);                    \
    istream_iterator<string> _it(_ss);       \
    err(_it, args);                          \
    cerr<<endl;                              \
}
void err(istream_iterator<string> it)
{
} 
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
  cerr<<' '<< *it << " = " << a ;
  err(++it, args...);
}

typedef long long ll;
const ll MOD = 1e9 + 7;
const int N = 2e5 + 1, M = 1e6, OO = 0x3f3f3f3f;

int main()
{
  ll n;
  scanf("%lld",&n);
  ll ans = 0;
  ll p =2;
  while(p<=n)
  {
    ans+=p;
    p<<=1;
  }
  printf("%lld",ans+1);
  #ifdef _LOCAL_DEFINE
  cerr << (double)clock() * 1.0 / CLOCKS_PER_SEC << endl;
  #endif
  return 0;
}

Measured memory_bytes: 256
while (line = gets) do
  a, l = line.split.map(&:to_i)
  break if a == 0 && l == 0
  results = [a]
  (1..20).each do |i|
    str = "%0#{l}d" % a
    small = str.split(//).sort.join
    big = small.reverse
    a = big.to_i - small.to_i
    index = results.index(a)
    if index
      puts [index, a, i - index].join ' '
      break
    end
    results << a
  end
end

Measured memory_bytes: 6112
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void print() { cout << "\n"; }
template <class T, class... Args>
void print(const T &x, const Args &... args) { cout << x << " "; print(args...);}
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  string sa, sb, sc;
  cin >> sa >> sb >> sc;
  char turn = 'a';
  int ca = 0, cb = 0, cc = 0;
  while(true) {
    if (turn == 'a') {
      if (ca >= (int)sa.size()) {
        cout << "A\n";
        return 0;
      }
      turn = sa[ca];
      ca++;
    }
    else if (turn == 'b') {
      if (cb >= (int)sb.size()) {
        cout << "B\n";
        return 0;
      }
      turn = sb[cb];
      cb++;
    }
    else {
      if (cc >= (int)sc.size()) {
        cout << "C\n";
        return 0;
      }
      turn = sc[cc];
      cc++;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
int mod=1e9+7;

signed main(){
  int n,m;
  cin>>n>>m;
  vector<int> x(n);
  vector<int> y(m);
  for(int i=0;i<n;i++)cin>>x[i];
  for(int i=0;i<m;i++)cin>>y[i];
  int lx=0;
  for(int i=0;i<n;i++){
    lx+=x[i]*i;
    lx%=mod;
    lx-=x[i]*(n-i-1);
    lx%=mod;
  }
  int ly=0;
  for(int i=0;i<m;i++){
    ly+=y[i]*i;
    ly%=mod;
    ly-=y[i]*(m-i-1);
    ly%=mod;
  }
  cout<<(lx*ly)%mod<<endl;
}


Measured memory_bytes: 1792
N = int(input())
F = list(list(map(int,input().split()))for i in range(N))
P = list(list(map(int,input().split()))for i in range(N))
ans = -float('inf')
for i in range(1023):
    b = bin(1024+i+1)[3:]
    pp = [0]*N
    for j in range(N):
        for k in range(10):
            if F[j][k] == 1 and b[k] == "1":
                pp[j] += 1
    hoge = 0
    for j in range(N):
        hoge += P[j][pp[j]] 
    ans = max(ans,hoge)

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;

int main()
{
   int N,M; cin>>N>>M;
   vector<int> x(N);
   for(int i=0;i<N;i++) cin>>x[i];
   sort(x.begin(),x.end());

   vector<int> cnt(M),cntPair(M);
   for(int i=0;i<N;){
      int i0=i++;
      while(i<N and x[i]==x[i0]) i++;
      cnt[x[i0]%M]+=i-i0;
      cntPair[x[i0]%M]+=(i-i0)/2;
   }
   // for(int i=0;i<M;i++) cout<<cnt[i]<<' '; cout<<endl;
   // for(int i=0;i<M;i++) cout<<cntPair[i]<<' '; cout<<endl;

   int ans=cnt[0]/2;
   for(int i=1;i<=(M-1)/2;i++){
      int x=i,y=M-x;
      // cout<<x<<' '<<y<<endl;
      int ma=0;
      for(int j=0;j<=min(cnt[x],cnt[y]);j++){
         int cnt_pair=j;
         int X=cnt[x]-j;
         int Y=cnt[y]-j;
         if(X>=2*cntPair[x]) cnt_pair+=cntPair[x];
         else cnt_pair+=X/2;
         if(Y>=2*cntPair[y]) cnt_pair+=cntPair[y];
         else cnt_pair+=Y/2;
         ma=max(ma,cnt_pair);
      }
      ans+=ma;
   }
   if(M%2==0) ans+=cnt[M/2]/2;
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



int main(){
    int x;
    cin >> x;

    for(int i=x;;i++){
        bool p = isPrime(i);
        if(p){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define reprs(i, s, e) for(int i=s-1; i>=s; i--)

struct UnionFind {
    vector<int> par;

    UnionFind(int n): par(n, -1) {};
    
    void init(int n) { par.assign(n, -1); }

    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y){
        return root(x) == root(y);
    }

    bool merge(int x, int y){
        x = root(x);
        y = root(y);

        if(x == y) return false;
        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x){
        return -par[root(x)];
    }
};



int main(){

    ll n, m; cin >> n >> m;
    vector<P> v;
    rep(i, m){
        int a, b; cin >> a >> b;
        a--; b--;

        v.push_back({a, b});
    }

    reverse(v.begin(), v.end());
    vector<ll> vans;

    UnionFind uf(n);
    ll ans = n*(n-1)/2;
    rep(i, m){
        vans.push_back(ans);

        int a = v[i].first;
        int b = v[i].second;

        if(uf.issame(a, b)) continue;
        
        // rep(i, n) cout << getn(i) << " ";
        // cout << endl;
        ll prod = (ll)uf.size(a) * uf.size(b);
        ans -= prod;

        uf.merge(a, b);

    }

    reverse(vans.begin(), vans.end());

    rep(i, vans.size()){
        cout << vans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3444
N = gets.to_i

str = ''
n = N
99.times do |i|
    x = 1 << i
    if n.abs&x > 0
        str << '1'
        n -= x if i.even?
        n += x if i.odd?
    else
        str << '0'
    end
    break if n == 0
end

puts str.reverse


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;

//#define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : " " );
  }
  return os;
}
/* }}} */

signed main() 
{
  int a, b;
  cin >> a >> b;
  a+b>=24?print(a+b-24):print(a+b);
  return 0;
}

Measured memory_bytes: 256