akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs, x0) vector<vector<T>> xs(n, vector<T>(m, x0))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, a, b);
    if(a <= 0 && 0 <= b){
        Cout("Zero");
    }
    else if(b < 0 && (b-a+1) % 2 == 1){
        Cout("Negative");
    }
    else{
        Cout("Positive");
    }
}


Measured memory_bytes: 256
param_k = int(input())
    
if param_k % 2 == 0:
  print(-1)
  
elif param_k % 5 == 0:
  print(-1)
  
else:
  n=0
  for i in range(1000000):
    n = 10*n + 7
    if n % param_k == 0:
      print(i+1)
      break
    else:
      n = n % param_k
    #if i == param_k + 10 - 1:
    #  print(-1)
  else:
    print(-1)

Measured memory_bytes: 9172
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const ll LL_INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int act[200005];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  vector<int> a(N);
  int now_k = 0;
  fill_n(act, N, INF);
  REP(i,N){
    cin >> a[i];
    a[i]--;
    if(act[a[i]] == INF){
      act[a[i]] = 0;
      now_k++;
    }
    act[a[i]]++;
  }
  sort(act, act + N);
  int ans = 0;
  for(int i = 0; i < now_k - K; ++i){
    ans += act[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;


int main(int argc, char* argv[])
{
    ll a,b,K;
    scanf("%lld%lld%lld", &a, &b, &K);

    if(K<a) {
        a-=K;
    }
    else {
        
        K-=a; a=0;
        if(K<b) {
            b-=K;
        }
        else {
            b=0;
        }
    }
    printf("%lld %lld\n", a, b);
    return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define F first
#define S second
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
using ll = long long;
using pi = pair<int,int>;
int main()
{
  ll n; cin >> n;
  vector<ll> a(n+1);
  rep(i,n) cin >> a[i];

  a[n] = 0;
  ll kane = 1000;
  ll kabu = 0;
  ll bef = 300;
  rep(i,n) {
    if(a[i] <= bef && a[i] < a[i+1]) {
      kabu += kane / a[i];
      kane -= kane / a[i] * a[i];
    }
    if(bef <= a[i] && a[i+1] < a[i]) {
      kane += kabu * a[i];
      kabu = 0;
    }
    bef = a[i];
  }
  cout << kane << "\n";
  
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////


int main() {
	ll N;
	cin >> N;

	vector<ll> P(N + 1);
	repn(i, N) cin >> P[i];

	vector<ll> V(N + 1);
	repn(i, N) V[P[i]] = i;

	ll ans = 1;
	ll c = 1;
	repn(i, N-1) {
		if (V[i] < V[i + 1]) { c++; }
		else { c = 1;}
		ans = max(c, ans);
	}

	cout << N-ans;
	
	system("PAUSE");

}





Measured memory_bytes: 3576
#include <vector>
#include <iostream>
#include <cstdlib>

#define REPR(v) for(int x: v) cout << x << " "; cout << endl

using namespace std;

const int INF = (1 << 30);

int main(){
	int N, K;
	cin >> N >> K;
	vector<int> h(N, 0), dp(N, INF);
	dp[0] = 0;
	for(int i =0 ; i < N; i ++){
		cin >> h[i];
	}

	for(int i = 0; i < N ; i++){
		for(int k = 1; k <= K; k++){
			if (i + k >= N) break;
			dp[i+k] = min(dp[i+k], dp[i] + abs(h[i] - h[i+k]));
		}
	}
	// REPR(dp);
	cout << dp[N-1] << endl;

	return 0;
}

Measured memory_bytes: 1024
#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>
using namespace std;

int main(){

    int n, c, k; cin >> n >> c >> k;

    int t[n];
    for(int i=0; i<n; i++){
        cin >> t[i];
    }

    sort(t, t+n);


    int istart = 0;
    int iend = 0;
    int ibus = 0;
    int done = 1;
    int ctemp = 1;
    int twait = 0;
    int ans = 0;

    vector<int> vempty;
    vector<vector<int>> vbus;

    vbus.push_back(vempty);
    for(iend = istart; iend < n; ){
        if(t[iend] - t[istart] <= k && vbus[ibus].size() < c){
            vbus[ibus].push_back(t[iend]);
            iend++;
        }
        else{
            vbus.push_back(vempty);
            ibus++;
            istart = iend;
        }
    }

    // for(int i=0; i<vbus.size(); i++){
    //     cout << i << ": ";
    //     for(int j=0; j<vbus[i].size(); j++){
    //         cout << vbus[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    cout << vbus.size() << endl;
    
    return 0;
}

Measured memory_bytes: 6964
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

int main() {
  int K,S; cin >>K >>S;
  int ans=0;
  rep_eq(x,0,K) {
    rep_eq(y,0,K) {
      int z=S-x-y;
      if (0<=z && z<=K) ans++;
    }
  }
  cout <<ans <<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 1;i <= (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    int s;
    int w;
    cin >> s >> w;

    if(s>w){
        cout << "safe" << endl;
    }else{
        cout << "unsafe" << endl;
    }

    return 0;
}



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

int main(){
	
	int n;
	cin >> n;
	int a[n+1], b[n+1], c[n+1];
	for(int i=1;i<=n;i++){
		cin >> a[i] >> b[i] >> c[i];
	}

	int dp[n+1][4];
	// dp[i][j] ----> max hapiness till day i 
	// and if he do activity jth last

	dp[1][1] = a[1];
	dp[1][2] = b[1];
	dp[1][3] = c[1];

	for(int i=2;i<=n;i++){
		dp[i][1] = a[i] + max(dp[i-1][2], dp[i-1][3]);
		dp[i][2] = b[i] + max(dp[i-1][1], dp[i-1][3]);
		dp[i][3] = c[i] + max(dp[i-1][1], dp[i-1][2]);
	}

	cout << max(dp[n][1] , max(dp[n][2] , dp[n][3])) << endl;

	return 0;
}

Measured memory_bytes: 6336
#include <bits/stdc++.h>
using namespace std;
int main(){
  bool out=true;
  int a,b,c,d;
  cin >> a >> b >>c >>d;
  while(out){
    c-=b;
    if(c<=0)break;
    a-=d;
    if(a<=0)break;
  }
  if(c<=0)cout <<"Yes"<<endl;
  else cout <<"No"<<endl;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
using namespace std; 
#define ll long long

int main()
{
    ll a,b,k;
  cin>>a>>b>>k;
  if(a>=k)
  {
    a-=k;
  }
  else if(k>=a+b)
  {
      a=0;
      b=0;
  }
  else 
  {
  	b=b-k+a;
    a=0;
  }
  cout<<a<<" "<<b;
    return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    string s;
    cin >> s;

    string ck = "ACGT";
    int n = s.size(), ans = 0, tmp = 0;
    rep(i, n)
    {
        if(ck.find(s[i])!=-1){
            tmp++;
            ans = max(ans, tmp);
        }else{
            tmp = 0;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve
double cross(const Pd &o, const Pd &a, const Pd &b){
  return (a.first - o.first) * (b.second - o.second) - (a.second - o.second) * (b.first - o.first);
}

vector<Pd> convex_hull(vector<Pd> vec){
  int n = vec.size(), k = 0;
  if(n < 3)return vec;

  vector<Pd> ch(2 * n);
  sort(vec.begin(), vec.end());

  // lower
  for(int i = 0; i < n; i++){
    while(k >= 2 && cross(ch[k-2], ch[k-1], vec[i]) <= 0.)k--;
    ch[k++] = vec[i];
  }

  // upper
  for(int i = n - 1, t = k + 1; i > 0; --i){
    while(k >= t && cross(ch[k-2], ch[k-1], vec[i-1]) <= 0.)k--;
    ch[k++] = vec[i-1];
  }

  ch.resize(k - 1);
  return ch;

}

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  vector<Pd> vec;
  rep(i, n){
    double a, b;
    cin >> a >> b;
    vec.pb(mk(a, b));
  }
  vector<Pd> vec2 = vec;
  vector<Pd> ch = convex_hull(vec2);
  if(ch.size() < 3){
    cout << setprecision(20);
    rep(i, n){
      bool flag = true;
      rep(j, int(ch.size())){
        if(vec[i].first == ch[j].first && vec[i].second == ch[j].second){
          cout << 1. / double(ch.size()) << endl;
          flag = false;
          break;
        }
      }
      if(flag)cout << 0. << endl;
    }
    return 0;
  }
  ch.pb(ch[0]);
  vector<double> anga(ch.size()-1);
  rep(i, int(ch.size()) - 1){
    if(ch[i].second != ch[i+1].second){
      double l = - (ch[i].first - ch[i+1].first) / (ch[i].second - ch[i+1].second);
      anga[i] = atan(l);
    }else{
      if(ch[i+1].first > ch[i].first)anga[i] = - M_PI / 2.;
      else anga[i] = M_PI / 2.;
    }
    while(i > 0 && anga[i] < anga[i-1])anga[i] += M_PI;
  }
  anga.pb(anga[0] + 2 * M_PI);
  vector<double> ang(anga.size()-1);
  rep(i, anga.size() - 1){
    ang[i] = abs(anga[i+1]-anga[i]);
  }
  double sum = 2. * M_PI;
  cout << setprecision(20);
  rep(i, n){
    bool flag = true;
    rep(j, int(ch.size())-1){
      if(vec[i].first == ch[j].first && vec[i].second == ch[j].second){
        cout << ang[(j + int(ang.size()) - 1) % int(ang.size())] / sum << endl;
        flag = false;
        break;
      }
    }
    if(flag)cout << 0. << endl;
  }
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#define ll unsigned long long int
using namespace std;
int main()
{
  ll n,w,v1,w1;
  cin>>n>>w;
  ll dp[n+1][w+1];
  ll weights[n];
  ll values[n];
  for(int i=0;i<n;i++)
  {
    cin>>w1>>v1;
    weights[i]=w1;
    values[i]=v1;
  }
  for(int i=0;i<=n;i++)
  {
    for(int j=0;j<=w;j++)
    {
      if(i==0 || j==0)
        dp[i][j]=0;
      else{
        if(j>=weights[i-1]){
        dp[i][j]=max(values[i-1]+dp[i-1][j-weights[i-1]],dp[i-1][j]);
        }
        else dp[i][j]=dp[i-1][j];
      }
    }}
  cout<<dp[n][w];
  return 0;
}

Measured memory_bytes: 79104
import numpy as np
N, *A = map(int, open(0).read().split())
A = np.array(A, dtype=np.int64)
mod = 10**9 + 7
 
ans = 0
for i in range(60):
    mask = 1 << i
    cnt = np.count_nonzero(A&mask)
    x = cnt * (N-cnt)
    x *= mask % mod
    ans += x
    ans %= mod
 
print(ans)

Measured memory_bytes: 65708
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int main(){
    string s;
    cin>>s;
    string ss="AKIHABARA";
    int i=0,j=0;
    while((i<s.size())||(j<ss.size())){
       if(s[i]==ss[j]){
          i++;
          j++;
          continue;
       }
       if(ss[j]=='A'){
          j++;
          continue;
       }
       break;
    }
    while((j<ss.size())&&(ss[j]=='A'))j++;
    
    
    if((i==s.size())&&(j==ss.size())){
       cout<<"YES"<<endl;
    }else{
       cout<<"NO"<<endl;
    }
    return(0);
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
    public static void main(String[] args) throws Exception {
        
        InputStreamReader ISR = new InputStreamReader(System.in);
        BufferedReader BR = new BufferedReader(ISR);
        //入力
        String strInput =  BR.readLine();
        //入力内容をint型に変換
        int intNum = Integer.parseInt(strInput);
        //3乗したもの
        int intCubic = intNum*intNum*intNum;
        //出力
        System.out.println(intCubic);
        
    }
}



Measured memory_bytes: 24312
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

template <class T, class F>
T UpperBound(T i0, T i1, F f) {
    while (i0 < i1) {
        T i = i0 + (i1 - i0) / 2;
        if (f(i)) i0 = i + 1; else i1 = i;
    }
    return i0;
}

struct BIT {
    BIT(int n) : b(n + 1), n(n) {}
    void add(int i, int v) {
        for (int k = i + 1; k <= n; k += k & -k) b[k] += v;
    }
    int sum(int k) {
        int s = 0;
        for (; k > 0; k -= k & -k) s += b[k];
        return s;
    }
    void clear() {
        b.assign(n, 0);
    }
    vector<int> b;
    int n;
};

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

    int n;
    cin >> n;

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    ll t = ((ll)n * (n + 1) / 2 + 1) / 2;
    BIT bt(n * 2 + 1);

    auto j = UpperBound<int>(2, (int)1e9 + 1, [&](auto j) {
        ll r = 0;
        int s = n;
        bt.clear();
        bt.add(s, 1);
        for (int i = 0; i < n; i++) {
            s += a[i] >= j ? 1 : -1;
            r += bt.sum(s + 1);
            bt.add(s, 1);
        }
        return r >= t;
    });

    cout << j - 1 << endl;

    return 0;
}

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

#define ALL(a)  a.begin(),a.end()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define debug(x) cerr << #x << ": " << x << endl

using LL = long long; template<class T> using V = vector<T>;

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

	int N, K;
	while (cin >> N >> K, N) {
		V<int>a(K);
		FOR(i, 0, K) {
			cin >> a[i];
		}
		SORT(a);
		int has = 0;
		if (a[0] == 0)has = 1;
		int ans = 0;
		using PII = pair<int, int>;
		V<PII>v;
		int s = has;
		FOR(i, has, K - 1) {
			if (a[i] + 1 == a[i + 1]) {
				continue;
			}
			else {
				v.push_back(PII(s, i));
				ans = max(ans, i - s + 1);
				s = i + 1;
			}
		}

		v.push_back(PII(s, K - 1));
		if (has)FOR(i, 0, SZ(v) - 1) {
			int LE = v[i].second;
			int RS = v[i + 1].first;
			if (a[LE] + 2 == a[RS]) {
				ans = max(ans, v[i + 1].second - v[i].first + 2);
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3504
#include <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;
int main()
{
int a[3];
scanf("%d %d %d",&a[0],&a[1],&a[2]);
sort(a,a+3);
a[0]=a[0]+a[1];
if(a[0]!=a[2]){printf("No\n");}
else{printf("Yes\n");}
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

struct Node {
  int id;
  int parent;
  int left;
  int right;

  Node() : id(), parent(-1), left(-1), right(-1) {}
  };

static vector<Node> TREE(25);

static void inputNode(Node& node, int id) {
  node.id = id;
  cin >> node.left >> node.right;
}

static const Node& getRoot(const vector<Node>& tree, int num) {
  for (int i = 0; i < num; i++) {
    if (tree[i].parent == -1) {
      return tree[i];
    } 
  }
}

static void getNextPreorder(const vector<Node>& tree, const Node& node) {
  if (node.id == -1) {
    return;
  }

  cout << " " << node.id;
  
  if (node.left != -1) {
    getNextPreorder(tree, tree[node.left]);
  }

  if (node.right != -1) {
    getNextPreorder(tree, tree[node.right]);
  }
}

static void preorderTreeWalk(const vector<Node>& tree, const Node& root) {
  cout << "Preorder" << endl;
  getNextPreorder(tree, root);
  cout << endl;
}

static void getNextInorder(const vector<Node>& tree, const Node& node) {
  if (node.id == -1) {
    return;
  }
  
  if (node.left != -1) {
    getNextInorder(tree, tree[node.left]);
  }

  cout << " " << node.id;

  if (node.right != -1) {
    getNextInorder(tree, tree[node.right]);
  }
}

static void inorderTreeWalk(const vector<Node>& tree, const Node& root) {
  cout << "Inorder" << endl;
  getNextInorder(tree, root);
  cout << endl;
}

static void getNextPostorder(const vector<Node>& tree, const Node& node) {
  if (node.id == -1) {
    return;
  }
  
  if (node.left != -1) {
    getNextPostorder(tree, tree[node.left]);
  }

  if (node.right != -1) {
    getNextPostorder(tree, tree[node.right]);
  }

  cout << " " << node.id;
}

static void postorderTreeWalk(const vector<Node>& tree, const Node& root) {
  cout << "Postorder" << endl;
  getNextPostorder(tree, root);
  cout << endl;
}

static void setupTree(vector<Node>& tree, int num) {
  for (int i = 0; i < num; i++) {
    Node& node = tree[i];
    if (node.left != -1) {
      tree[node.left].parent = node.id;
    }
    if (node.right != -1) {
      tree[node.right].parent = node.id;
    }
  }
}

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

  int id;
  for (int i = 0; i < n; i++) {
    cin >> id;
    inputNode(TREE[id], id);
  }

  setupTree(TREE, n);
  const Node root = getRoot(TREE, n);

  preorderTreeWalk(TREE, root);
  inorderTreeWalk(TREE, root);
  postorderTreeWalk(TREE, root);

  return 0;
}



Measured memory_bytes: 3116
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
	N, W = MAP()

	n1 = N // 2
	n2 = N - n1

	vw1 = [[0, 0]]
	vw2 = [[0, 0]]

	for _ in range(n1):
		v, w = MAP()
		for i in range(len(vw1)):
			p = vw1[i].copy()
			p[0] += v
			p[1] += w
			vw1.append(p)

	for _ in range(n2):
		v, w = MAP()
		for i in range(len(vw2)):
			p = vw2[i].copy()
			p[0] += v
			p[1] += w
			vw2.append(p)
	vw1.sort(key=lambda x:(x[1], -x[0]))
	vw2.sort(key=lambda x:(x[1], -x[0]))
	tmp_v = 0
	for i in range(1<<n2):  # 要素数を減らさずに無駄な荷物を除く
		v, w = vw2[i]
		if tmp_v < v:
			tmp_v = v
		else:
			vw2[i][0] = tmp_v

	idx1 = 0
	idx2 = 2 ** n2 - 1
	ans = 0
	while idx1 < 2 ** n1 and idx2 >= 0:  # しゃくとり法
		v1, w1 = vw1[idx1]
		v2, w2 = vw2[idx2]
		while idx2 > 0 and w1 + w2 > W:
			idx2 -= 1
			v2, w2 = vw2[idx2]
		if w1 + w2 <= W:
			v_sum = v1 + v2
			ans = ans if ans > v_sum else v_sum
		idx1 += 1

	print(ans)

if __name__ == '__main__':
	main()



Measured memory_bytes: 472220
#include<iostream>
#include <string>
#include<vector>
#include<algorithm>
#include <cstdlib>
using namespace std;
int main(){
    int a;
    int ans=0;
    cin >> a;
    int b = a%10;
    int c = a/100;
    int d = (a/10)-c*10;
    if(b == 9){
        ans++;
    }
    else{
        ans=ans+9;
    }
    if(c == 9){
        ans= ans + 100;
    }
    else{
        ans=ans+900;
    }
    if(d == 9){
        ans=ans+10;
    }
    else{
        ans=ans+90;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

vector<bool> prime(100500,true);

int main(){
    prime[0] = prime[1] =false;
    for(int i=2;i*i<100500;i++){
        if(prime[i]){
            for(int j=2;j*i<100500;j++){
                prime[i*j]=false;
            }
        }
    }

    while(true){
        int n,p;
        cin >> n >> p;
        if(n==-1)break;
        vector<int> plist(50);
        int count=0;
        for(int i=n+1;count <50;i++){
            if(prime[i]){
                plist[count]=i;
                count++;
            }
        }

        priority_queue<int,vector<int>,greater<int> > mlist;
        for(int i=0;i<count;i++){
            for(int j=0;j<=i;j++){
                mlist.push(plist[i]+plist[j]);
            }
        }
        for(int i=0;i<p-1;i++){
            mlist.pop();
        }
        int ans=mlist.top();
        cout << ans << endl;
    }
    return 0;
}

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

int main () {
    int N, T, A;
    int index = 0;
    int d = 1000000;
    cin >> N >> T >> A;
    vector<int> H(N);
    vector<int> ans(N);
    for (int i = 0; i < N; i++) {
        cin >> H.at(i);
        ans.at(i) = ((T - H.at(i) * 0.006) - A) * 1000;
        if (ans.at(i) < 0) {
            ans.at(i) *= -1;
        }
        if (d > ans.at(i)) {
            index = i + 1;
            d = ans.at(i);
        }
    }
    cout << index <<endl;
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

void foreach_permutation(int n, std::function<void(int *)> f) {
    int indexes[n];
    for (int i = 0; i < n; i++) indexes[i] = i+1;
    do {
        f(indexes);
    } while (std::next_permutation(indexes, indexes + n));
}

int main() {
   int N,M;
   cin >> N >> M;
   ll correct = 0;
   ll penalty = 0;
   int p[N][2];
   for(int i=0;i<N;i++){
       p[i][0] = 0;
       p[i][1] = 0;
   }
   for(int i=0;i<M;i++){
       int temp;
       string str;
       cin >> temp >> str;
       if(p[temp-1][1]==0&&str=="WA"){
           p[temp-1][0]++;
       }else if(str=="AC"){
           p[temp-1][1]++;
       }
   }
   for(int i=0;i<N;i++){
       if(p[i][1]!=0){
           penalty+=p[i][0];
           correct++;
       }
   }
   cout << correct << endl;
   cout << penalty << endl;
    

}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int odd = 0;
        while (n-- > 0) {
            int num = sc.nextInt();
            if (num % 2 == 1) odd++;
        }
        
        if (odd % 2 == 0) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 48296
#include <iostream>

using namespace std;
int x, n;
pair<int, int> min_ans = {999, -1};
bool exclude[102];

int main() {
    int a;
    cin >> x >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        exclude[a] = true;
    }

    // 1 <= a <= 100
    // therefore, 0 <= ans.second <= 101
    for (int i = 0; i <= 101; ++i) {
        if (exclude[i]) continue;
        pair<int, int> cur = {abs(x - i), i};
        min_ans = min(min_ans, cur);
    }
    cout << min_ans.second << endl;
    return 0;

    int i = 0;
    while (true) {
        if (!exclude[x - i]) {
            cout << x - i << endl;
            return 0;
        }
        if (!exclude[x + i]) {
            cout << x + i << endl;
            return 0;
        }
        i++;
    }
}


Measured memory_bytes: 3588
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        v: [usize; n],
        c: [usize; n],
    }
    let mut ans = 0;
    for i in 0..n {
        if v[i] > c[i]{
            ans += v[i] - c[i];
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<cstdio>
#include<algorithm>
#include<functional>
#include<cstring>
using namespace std;
int main(void)
{
	int a,b,c,k,sum,d;
	scanf("%d %d %d %d",&a,&b,&c,&k);
	if(k<=a)	sum=k;
	else if(k<=a+b)	sum=a;
	else {
		d=k-a-b;
		sum=a-d;
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 1724
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
typedef complex<double>P;
double dot(P a, P b){ return real(conj(a)*b);}
double cross(P a,P b){return imag(conj(a)*b);}
struct L: public vector<P>{
    L(const P &a,const P &b){
        push_back(a); push_back(b);
    }// line
};
struct C{
    P c; double r;
    C(const P &c, double r) : c(c),r(r){}    // circle
};
/*complex ?????????*/
namespace std {
    bool operator < (const P& a, const P& b) {
        return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
        //return imag(a) != imag(b) ? imag(a) < imag(b) : real(a) < real(b);
    }
    bool operator == (const P& a, const P& b) {
        return a.real()==b.real()&&a.imag()==b.imag();
    }
}
/*????¨?????????????????¨???????????????????*/
int ccw(P a, P b, P c) {
    b -= a; c -= a;
    if (cross(b, c) > 0)   return +1;       // counter clockwise
    if (cross(b, c) < 0)   return -1;       // clockwise
    if (dot(b, c) < 0)     return +2;       // c--a--b on line
    if (norm(b) < norm(c)) return -2;       // a--b--c on line
    return 0;
}
int main(){
    vector<P>v(4);vector<pdd>p(3);
    vector<double>t(3,0);
    pdd temp;
    while(cin>>p[0].first>>p[0].second>>p[1].first>>p[1].second>>p[2].first>>p[2].second>>temp.first>>temp.second){
        rep(i,3)v[i]=P(p[i].first,p[i].second);
        P pit=P(temp.first,temp.second); v[3]=v[0];
        bool flag=true;P hoge;
        rep(i,3)t[i]=cross((-v[i]+v[i+1]),-v[i+1]+pit);
        if((t[0]>0&&t[1]>0&&t[2]>0)||(t[0]<0&&t[1]<0&&t[2]<0))puts("YES");
        else puts("NO");
    }
}

Measured memory_bytes: 3132
function Main(inputString) {
    	// 1行目がinput[0], 2行目がinput[1], …に入る
    	let inputArray = inputString.split(" ");
    	//文字列から10進数に変換するときはparseIntを使います
    	let executeCount = parseInt(inputArray[0], 10);
    	let displayRating = parseInt(inputArray[1], 10);
        let innerRating = 0;

        // 10回未満なら表示レーティング+100*(1-参加回数)
        // 10回以上なら表示レーティング

        if(executeCount >= 10){
            innerRating = displayRating;
        } else {
            innerRating = displayRating + (100 * ( 10 - executeCount ));
        }


    	//出力
    	console.log('%d', innerRating);
    }
 Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

	string S, T;
	cin >> S >> T;
	int res = 0;
	REP(i, SZ(S)) {
		res += (S[i] != T[i]);
	}
	cout << res << endl;

	return 0;
}


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

#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;

int main(void) {
    int64_t N;
    bool flag = false;
    mp::cpp_int prod = 1;
    cin >> N;

    vector<int64_t> A(N);
    for(int i=0;i<N;i++) {
        cin >> A[i];
    }

    sort(A.begin(), A.end());
    for(int i=0;i<N;i++) {
        prod *= A[i];
        if(prod > 1000000000000000000) {
            flag = true;
            break;
        }
    }

    if(flag) cout << "-1\n";
    else cout << prod << endl;
    return 0;
}


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

int main(){
    string S;
    cin >> S;
    int ans1=0,ans2=0;
    // 黒白黒白……
    for(int i=0;i<S.size();++i){
        if(i%2==0 && int(S[i])%2!=0) ++ans1;
        else if(i%2==1 && int(S[i]%2==0)) ++ans1;
    }
    // 白黒白黒……
    for(int i=0;i<S.size();++i){
        if(i%2==0 && int(S[i])%2==0) ++ans2;
        else if(i%2==1 && int(S[i]%2!=0)) ++ans2;
    }
    cout << min(ans1,ans2) << endl;
}

Measured memory_bytes: 512
inpl = lambda: list(map(int,input().split()))
MOD = 10**9+7
N = int(input())
C = inpl()
C.sort()
ans = 0
for i in range(N):
    ans += (N+1-i)*C[i]
    ans %= MOD
ans *= pow(2,2*N-2,MOD)
ans %= MOD
print(ans)

Measured memory_bytes: 87372
#include<bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define mod 1000000007
#define bitcount __builtin_popcountll
#define ll long long
#define pb push_back
#define pi pair<int,int>
#define pii pair<pi,int>
#define mp make_pair
int main()
{
	int i,j,k;
	int n,a,b;
	sd(n);
	sd(a);
	sd(b);
	printf("%d\n",min(b,a*n) );
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=300005,p=998244353;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int qpow(int x,int k){
	int t=1;
	for (;k;k>>=1){
		if (k&1) t=(ll)t*x%p;
		x=(ll)x*x%p;
	}
	return t;
}
struct state{
	int a[6];
	int &operator[](int i){return a[i];}
	state(){memset(a,0,sizeof(a));}
}x,rx,s[N][2],c,e;
bool operator==(state a,state b){
	for (int i=0;i<6;i++)
	if (a[i]==b[i]) return false;
	return true;
}
bool operator<(state a,state b){
	for (int i=0;i<6;i++)
	if (a[i]!=b[i]) return a[i]<b[i];
	return false;
}
state operator*(state x,state y){for (int i=0;i<6;i++) x[i]=(ll)x[i]*y[i]%p;return x;}
state operator+(state x,state y){for (int i=0;i<6;i++) if((x[i]+=y[i])>=p) x[i]-=p;return x;}
state operator-(state x,state y){for (int i=0;i<6;i++) if((x[i]-=y[i])<0) x[i]+=p;return x;}
state operator+(state x,int k){for (int i=0;i<6;i++) if ((x[i]+=k)>=p) x[i]-=p;return x;}
state operator-(state x,int k){for (int i=0;i<6;i++) if ((x[i]-=k)<0) x[i]+=p;return x;}
state getval(state *a,state x){
	state cur=a[0]+a[1]*x;
	return cur;
}
int n,m;
ll ans;
char ch[N];
map<state,int> f;
int main(){
	for (int i=0;i<6;i++) x[i]=i+1,rx[i]=qpow(x[i],p-2);
	n=read();
	scanf(" %s",ch+1);
	for (int i=0;i<6;i++) s[n+1][1][i]=1;
	for (int i=n;i;i--)
	if (ch[i]=='+'){s[i][0]=s[i+1][0]+s[i+1][1];s[i][1]=s[i+1][1];c=c-1;}
	else if (ch[i]=='-'){s[i][0]=s[i+1][0]-s[i+1][1];s[i][1]=s[i+1][1];c=c+1;}
	else if (ch[i]=='>'){s[i][0]=s[i+1][0];s[i][1]=s[i+1][1]*x;c=c*rx;}
	else if (ch[i]=='<'){s[i][0]=s[i+1][0];s[i][1]=s[i+1][1]*rx;c=c*x;}
	for (int i=n;i;i--){
		f[getval(s[i+1],e)]++;
		ans+=f[getval(s[i],c)];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 53632
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())|	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import collections
def inpl(): return list(map(int, input().split()))

#### START
N = input()
a = list(map(int,input().split()))

ans_l = []
for a_i in a:
  ans_l.append(a_i)
  ans_l.append(a_i-1)
  ans_l.append(a_i+1)

c = collections.Counter(ans_l)
print(c.most_common()[0][1])

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

ll gcd(ll x, ll y) {
    if (y == 0) return x;
    return gcd(y, x % y);
}

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

int main() {
    ll n;
    cin >> n;
    ll ans = 1;
    for (int i = 0; i < n; ++i) {
        ll t;
        cin >> t;
        ans = lcm(ans, t);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
a = [int(i) for i in input().split()]

idx = 0

for i in range(n):
    if a[i] == 1:
        idx = i
        break

if n <= k:
    print(1)
    exit()

print((n-1+k-2)//(k-1))
exit()
ans = (n-idx+k-2)//(k-1) + (idx+k-2)//(k-1)

for i in range(k-1):
    ans = min(ans,  (n-idx+k-2-1-i)//(k-1) + (idx+k-2-(k-2-i))//(k-1) + 1)
print(ans)

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

#define MOD 1000000007

long myPow(long x, long n, long m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

int main()
{
    int n;
    cin >> n;
    vector<int> a(n), c(n, 0);

    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        c[a[i]]++;
    }

    if(n % 2 == 1)
    {
        bool f = false;
        if(c[0] != 1)f = true;
        for (int i = 2; i < n; i+=2)
        {
            if(c[i] != 2)f = true;
        }
        if(f)cout << 0 << endl;
        else cout << myPow(2,n / 2,MOD) << endl;
    }
    else
    {
        bool f = false;
        for (int i = 1; i < n; i+=2)
        {
            if(c[i] != 2)f = true;
        }
        if(f)cout << 0 << endl;
        else cout << myPow(2,n / 2,MOD) << endl;
    }
    
}

Measured memory_bytes: 4040
h,w = map(int,input().split())
def func(a,b):
  ret = []
  for h1 in (a//3,a//3+1):
    a1 = h1*b
    nh = a-h1
    c = (a1,nh//2*b,(nh-nh//2)*b)
    ret.append(max(c)-min(c))
    c = (a1,nh*(b//2),nh*(b-b//2))
    ret.append(max(c)-min(c))
  return min(ret)
print(min(func(h,w),func(w,h)))

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> graph(n,vector<int>(n));
    rep(i,0,m){
        int u,v,f;
        cin >> u >> v >> f;
        --u;
        --v;
        graph[u][v]=graph[v][u]=f;
    }

    int ans=0;
    rep(i,2,inf){
        if(i*(i-1)/2>m) continue;
        map<set<int>,int> memo;
        map<set<int>,bool> done;
        function<int(int,set<int>&)> rec=[&](int num,set<int> &s){
            int &res=memo[s];
            if(done[s]) return res;
            done[s]=true;
            if(num==0){
                for(int v:s){
                    int tmp=inf;
                    for(int u:s){
                        if(u==v) continue;
                        tmp=min(tmp,graph[v][u]);
                    }
                    res+=tmp;
                }
                return res;
            }
            rep(v,0,n){
                if(s.find(v)!=s.end()) continue;
                bool ok=true;
                for(int u:s){
                    if(graph[v][u]!=0) continue;
                    ok=false;
                    break;
                }
                if(!ok) continue;
                s.insert(v);
                res=max(res,rec(num-1,s));
                s.erase(v);
            }
            return res;
        };
        set<int> s;
        int tmp=rec(i,s);
        if(tmp==0) break;
        ans=max(ans,tmp);
    }
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}

Measured memory_bytes: 17060
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
using namespace std;

struct Node {
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k){
    Node *y=NIL;
    Node *x=root;
    Node *z;
    
    z=(Node *)malloc(sizeof(Node));
    z->key=k;
    z->left=NIL;
    z->right=NIL;
    
    while(x!=NIL){
        y=x;
        if(z->key<x->key){
            x=x->left;
        }
        else{
            x=x->right;
        }
    }
    z->parent=y;
    if(y==NIL){
        root=z;
    }else{
        if(z->key<y->key){
            y->left=z;
        }else{
            y->right=z;
        }
    }
    
}

void preorder(Node *u){
    if (u==NIL) return;
    cout<<" "<<u->key;
    preorder(u->left);
    preorder(u->right);
}

void inorder(Node *u){
    if (u==NIL) return;
    inorder(u->left);
    cout<<" "<<u->key;
    inorder(u->right);
}

int main(){
    int n,i,x;
    string com;

    cin>>n;
    for(i=0;i<n;i++){
        cin>>com;
        if(com=="insert"){
            cin>>x;
            insert(x);
        }else if(com=="print"){
            inorder(root);
            cout<<endl;
            preorder(root);
            cout<<endl;
        }
    }
    
}



Measured memory_bytes: 26492
#include <iostream>
using namespace std;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  long long result = 1;
  int i;
  for (i = 1; i <= n; i++) {
    result = result * i % MOD;
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll=long long;
using P=pair<int,int>;

int main(){
    int n; cin>>n;
    vector<int> w(n);
    rep(i,n) cin>>w[i];
    int ans=100000;
    for(int i=1;i<n;i++){
        int left=0;
        int right=0;
        for(int j=0;j<i;j++){
            left+=w[j];
        }
        for(int k=i;k<n;k++){
            right+=w[k];
        }
        ans=min(ans,abs(left-right));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	double a;
	double time;
	int kai;
	while (cin >> a) {
		time = a / 9.8;
		kai = (4.9 * time * time + 5) / 5 + 1;
		cout << kai << endl;
	}

	return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
#define reg register
#define ll long long
using namespace std;
inline int read() {
    int x=0,f=1,c=getchar();
    for (;c< 48;c=getchar()) if (c=='-') f=0;
    for (;c>=48;c=getchar()) x = x*10 + c-'0';
    return f?x:-x;
}
int main() {
    string s; cin >> s;
    int ans = 0;
    for (int i = 0; i < s.size(); ++ i) ans += s[i] == 'o';
    cout << (15 - s.size() + ans >= 8 ? "YES" : "NO");
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <inttypes.h>

/* ソート関数 */
int int_sort( const void * a , const void * b ) {
  /* 引数はvoid*型と規定されているのでint型にcastする */
  if( *( uint32_t * )a < *( uint32_t * )b ) {
    return -1;
  }
  else
  if( *( uint32_t * )a == *( uint32_t * )b ) {
    return 0;
  }
  return 1;
}

int
main (void)
{
  uint32_t N, i, j, D[100000], distance_num[100000] = {0, }, distance;
  uint64_t ans = 1;

  scanf("%d", &N);
  for (i = 0; i < N; i++) {
    scanf("%d", &D[i]);
  }

  if (D[0] != 0) {
    printf("0");
    return 0;
  }

  qsort(D, N, sizeof(uint32_t), int_sort);

  for (i = 0, distance = 0; i < N; i++) {
    if (D[i] == distance)
      distance_num[distance]++;
    else if (D[i] == distance + 1) {
      distance++;
      distance_num[distance]++;
    } else {
      printf("0");
      return 0;
    }
  }

  if (D[1] == 0) {
    printf("0");
    return 0;
  }

  for (i = 0; i < distance; i++) {
    for (j = 0; j < distance_num[i+1]; j++) {
      ans = (ans * distance_num[i]) % 998244353;
    }
  }
  printf("%"PRIu64"\n", ans);

  return 0;
}

Measured memory_bytes: 1276
#include <iostream>
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;

    if (
        1 <= a && a <= 9 &&
        1 <= b && b <= 9
    ) {
        cout << a * b << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n=nxtl(),a=nxtl(),b=nxtl();
    vector <ll> v(n);
    generate(all(v),nxtl);
    ll l=0,r=1e9;
    ll test;
    while(l<=r)
    {
        ll mid=(l+r)/2;
        vector <ll> temp=v;
        for(int i=0;i<n;i++)
            temp[i]-=b*mid;
        ll count=0;
        for(int i=0;i<n;i++)
            if(temp[i]>0)
                count+=(temp[i]+a-b-1)/(a-b);
            //cout<<mid<<" "<<count<<endl;
        if(count<=mid)
        {
            test=mid;
            r=mid-1;
        }
        else
            l=mid+1;
    }
    cout<<test<<endl;
    
    return 0;   
}




 
 


Measured memory_bytes: 1792