akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <atcoder/math>
using namespace std;
using namespace atcoder;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << "Line " << __LINE__ << ": " <<  #x << " = " << (x) << "\n";
#define spa << " " <<
#define fi first
#define se second
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()

using ld = long double;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;

template<typename T> using V = vector<T>;
template<typename T> using P = pair<T, T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){os << "(" << v.first << ", " << v.second << ")"; return os;}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<vector<T>> &v){ for(auto &e : v){os << e << "\n";} return os;}
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

template <class T> void UNIQUE(vector<T> &x) {sort(ALL(x));x.erase(unique(ALL(x)), x.end());}
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; }
void fail() { cout << -1 << '\n'; exit(0); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<"\n";}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<"\n";};

const ll INF = (1ll<<62);
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
const ll mod = (int)1e9 + 7;
//const ll mod = 998244353;

int main(){

    ll T;
    cin >> T;
    while(T--){
        ll N, M, A, B;
        cin >> N >> M >> A >> B;
        cout << floor_sum(N, M, A, B) << "\n";
    }

    return 0;
}

Measured memory_bytes: 3676
// https://atcoder.jp/contests/abc145/tasks/abc145_e
#include <bits/stdc++.h>
using namespace std;

int N,T;
int A[3000], B[3000];

int pre[3000][3000];
int suf[3000][3000];

void print_table(int table[3000][3000], int nrow, int ncol) {
  for (int r=0; r<nrow; r++) {
    for (int c=0; c<ncol; c++) {
      printf("%3d", table[r][c]);
    }
    cout << endl;
  }
}


signed main() {
  cin >> N >> T;
  for(int i=0; i<N; i++) cin >> A[i] >> B[i];

  for(int t=0; t<T-1; t++) pre[0][t] = t >= A[0] ? B[0] : 0;
  for(int n=1; n<N; n++)   pre[n][0] = 0;

  for(int t=0; t<T-1; t++)  suf[N-1][t] = t >= A[N-1] ? B[N-1] : 0;
  for(int n=N-2; n>=0; n--) suf[n][0] = 0;

  for(int t=0; t<T-1; t++) for(int n=1; n<N; n++) {
    if (t-A[n] >= 0) pre[n][t] = max(pre[n-1][t-A[n]] + B[n], pre[n-1][t]);
    else             pre[n][t] = pre[n-1][t];
  }

  for(int t=0; t<T-1; t++) for(int n=N-2; n>=0; n--) {
    if (t-A[n] >= 0) suf[n][t] = max(suf[n+1][t-A[n]] + B[n], suf[n+1][t]);
    else             suf[n][t] = suf[n+1][t];
  }

  int ans=0;

  for(int n=0; n<N; n++) for(int t=0; t<T-1; t++) {
    if (n==0)        ans = max(ans,               suf[n+1][T-1-t] + B[n]);
    else if (n==N-1) ans = max(ans, pre[n-1][t]                   + B[n]);
    else             ans = max(ans, pre[n-1][t] + suf[n+1][T-1-t] + B[n]);
  }

  //print_table(pre, N, T-1);
  //print_table(suf, N, T-1);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 70528
#include <cstdio>

int main() {
    int n, x, t;
    std::scanf("%d %d %d", &n, &x, &t);

    int cnt = 0;
    while (n > 0) {
        n -= x;
        cnt += t;
    }

    std::printf("%d\n", cnt);

    return 0;
}


Measured memory_bytes: 3232
/*input
1 2
7444
*/

#include <bits/stdc++.h>
using namespace std;

#define fill(a,val) memset(a, (val), sizeof a)
#define pb push_back
#define lli long long int
#define endl "\n"
#define unique(x) x.erase(unique(x.begin(),x.end()), x.end())
#define      rep(i, n)         for(int i = 0; i < (n); ++i)
#define      FOR(i, a, n)     for(int i = a; i < (n); ++i)
#define      repD(i, a, n)     for(int i = a; i >= (n); --i)

int main(void)
{
  int a,b ; cin>>a>>b;
  string s; cin>>s;
  bool p=true;
  for(int i=0; i<a; ++i){
    if(!(s[i]>='0' and s[i]<='9')){
        p=false;
    }
  }
  if(s[a]!='-') p=false;
  for(int i=0; i<b; ++i){
    if(!(s[a+1+i]>='0' and s[a+i+1]<='9')){
        p=false;
    }
  }
  if(p) cout<<"Yes";
  else cout<<"No";
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<map>

using namespace std;

#define   ll            long long
#define   PI            atan(1.0)*4
#define   mst(x,v)      memset(x,v,sizeof(x))
#define   rush()        int T;scanf("%d",&T);while(T--)
#define   debug         puts("debug")

typedef   pair<int,int> P;

const int   M = 2e5+5000;
const int mod = 1e9+7;
const int inf = 1e9;

map<ll,ll> vis;

int main() {

	int n;
	scanf("%d",&n);
	
	vis[0] = 1;
	ll sum = 0,ans = 0,ch;
	for(int i=1;i<=n;i++) {
		scanf("%lld",&ch);
		sum += ch;
		ans += vis[sum];
		vis[sum]++;
	} 
	
//	for(int i=1;i<=n;i++) printf("%d\n",pre[i]);
	
	printf("%lld",ans);
}

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





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

#define times(n, i)      uptil(0, n, i)
#define rtimes(n, i)     downto((n) - 1, 0, i)
#define upto(f, t, i)    for(auto i##0_to = (t), i = decltype(t)(f); i <= i##0_to; i++)
#define uptil(f, t, i)   for(auto i##0_to = (t), i = decltype(t)(f); i <  i##0_to; i++)
#define downto(f, t, i)  for(auto i##0_to = decltype(f)(t), i = (f); i >= i##0_to; i--)
#define downtil(f, t, i) for(auto i##0_to = decltype(f)(t), i = (f); i >  i##0_to; i--)
using LD = long double;
#define double LD
#define long long long
#define LL long
#define int long
template<class T> using vec = vector<T>;
using VB = vec<bool>;   using WB = vec<VB>;
using VC = vec<char>;   using WC = vec<VC>;
using VI = vec<int>;    using WI = vec<VI>;
using VD = vec<double>; using WD = vec<VD>;
using VS = vec<string>; using WS = vec<VS>;
using PI = pair<int, int>;  using VPI = vec<PI>; using WPI = vec<VPI>;
using MI = map<int, int>;   using VMI = vec<MI>;

#if defined(EBUG) && !defined(ONLINE_JUDGE)
    #define debug true
    #define _GLIBCXX_DEBUG
    #define _LIBCPP_DEBUG 2
    #define _LIBCPP_DEBUG2 2
    #define ln << endl
    #define dd(x) cerr << #x << " = " << (x) << ", "
    #define ddd(x) cerr << #x << " = " << (x) ln
#else
    #define debug false
    #define ln << '\n'
    #define dd(x) cerr
    #define ddd(x) cerr
#endif
#define tb << '\t'
#define sp << ' '
#define db dd
#define dbg ddd

template<class T>          inline istream& operator>>(istream& s, vec<T>& v) { for(auto&& p : v) s >> p; return s; }
template<class T, class S> inline ostream& operator<<(ostream&, const pair<T, S>&);
template<class T>          inline ostream& operator<<(ostream&, const vec<T>&);
template<class T, class S> inline ostream& operator<<(ostream&, const map<T, S>&);
#define DEFINE_ITER_OUTPUT(s, x, sep) { int i = 0; for(const auto& x##0_elem : x) { if(i++) s << sep; s << x##0_elem; } return s; }
template<class T, class S> inline ostream& operator<<(ostream& s, const pair<T, S>& p) { return s << "(" << p.first << "," << p.second << ")"; }
template<class T>          inline ostream& operator<<(ostream& s, const vec<T>& v) DEFINE_ITER_OUTPUT(s, v, ' ')
template<class T, class S> inline ostream& operator<<(ostream& s, const map<T, S>& m) DEFINE_ITER_OUTPUT(s, m, ' ')
template<class T>          inline ostream& operator<<(ostream& s, const vec<vec<T>>& w) DEFINE_ITER_OUTPUT(s, w, '\n')
template<class T, class S> inline ostream& operator<<(ostream& s, const vec<map<T, S>>& vm) DEFINE_ITER_OUTPUT(s, vm, '\n')

void solve();

signed main() {
    if(!debug) {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(20);

    solve();

    return 0;
}

void solve() {
// N N(-P)
/* <foxy.memo-area> */
int N;cin>>N;VI P(N);times(N,Ri_0){cin>>P[Ri_0];--P[Ri_0];}
/* </foxy.memo-area> */

    VI q(N); times(N, i) q[P[i]] = i;

    int rz = 1, mx = 1;
    uptil(1, N, i) {
        if(q[i] > q[i-1]) {
            ++rz;
            mx = max(mx, rz);
        } else {
            rz = 1;
        }
    }
    cout << N - mx ln;
}


Measured memory_bytes: 3328
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        // 入力
        var n = int.Parse(Console.ReadLine());
        long[] p = Console.ReadLine().Split().Select(long.Parse).ToArray();

        long min = 2000000;
        long ans = 0;
        for (int i = 0; i < n; i++)
        {
            if (min >= p[i])
            {
                ans += 1;
            }

            min = Math.Min(min,p[i]);
        }

        Console.WriteLine(ans);

    }
}


Measured memory_bytes: 32452
#include <iostream>
using namespace std;
int main(){
  int n,m, sumT,sumH;
  int T[1000],H[1000];

  while( cin>>n>>m&&(n|m) ){
    sumT=0;sumH=0;
    for( int i=0;i<n;i++ ){
      cin >> T[i];
      sumT+=T[i];
    }
    for( int i=0;i<m;i++){
      cin >> H[i];
      sumH+=H[i];
    }

    int index_t=-1, index_h=-1;
    int minSum = 10000;
    for( int i=0;i<n;i++ ){
      for( int j=0;j<m;j++ ){
	if( sumT-T[i]+H[j] == sumH-H[j]+T[i] ){
	  if( minSum > T[i]+H[j] || index_t<0){
	    minSum=T[i]+H[j];
	    index_t=i;
	    index_h=j;
	  }
	}
      }
    }
    if( index_t < 0)
      cout << -1 << endl;
    else
      cout << T[index_t] << " " << H[index_h] << endl;
  }
}

Measured memory_bytes: 1164
#include<cstdio>

using namespace std;

int main(){
	int n, m, q; scanf("%d %d %d", &n, &m, &q);
	int t[600][600] = {};
	for(int i = 0; i < m; i++){
		int l, r; scanf("%d %d", &l, &r);
		t[l][r]++;
	}
	for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++) t[i][j] += t[i][j - 1];
	for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++) t[i][j] += t[i - 1][j];
	for(int i = 0; i < q; i++){
		int a, b; scanf("%d %d", &a, &b);
		printf("%d\n", t[b][b] - t[b][a - 1] - t[a - 1][b] + t[a - 1][a - 1]);
	}
	return 0;
}

Measured memory_bytes: 2304
// finish date: 2018/02/23

#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>


int main() {
    ll K;
    cin >> K;
    vl A(K);
    rep(i, K) cin >> A[i];

    reverse(A.begin(), A.end());
    if (A[0] != 2) {
        cout << -1 << endl;
        return 0;
    }
    ll mi = 2, ma = 3;
    FOR(i, 1, K) {
        if ((ll)A[i] > ma) {
            cout << -1 << endl;
            return 0;
        } else if (A[i] < mi) {
            mi = (ll) A[i] * ((mi + A[i] - 1) / A[i]);
            ma = (ll) A[i] * (ma / A[i] + 1) - 1;
            if(ma<mi) {cout<<-1<<endl; return 0;}
        } else {
            mi = A[i];
            ma = (ll) A[i] * (ma / A[i] + 1) - 1;
            if(ma<mi) {cout<<0<<endl; return 0;}
        }
    }
    cout << mi << " " << ma << endl;


    return 0;
}





Measured memory_bytes: 1024
#include <cstdint>
#include <cstdio>
#include <unordered_set>

int main () {

	int n;

	scanf("%d", &n);

	int * a = new int[n];
	int p = 1;
	uint64_t count = 0;

	std::unordered_set<int> visited;
	visited.insert(1);

	for (int i = 0; i < n; ++i) scanf("%d", &a[i]);

	do {
		p = a[p - 1];
		if (visited.find(p) == visited.end()) {
			visited.insert(p);
			++count;
		} else {
			break;
		}
	} while (p != 2);

	if (p == 2) {
		printf("%llu\n", count);
	} else {
		printf("%d\n", -1);
	}

	delete[] a;

	return 0;

}


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

int main()
{
	int n, max{};
	scanf("%d", &n);
	std::vector<int> h(n + 2);
	for (int i{1}; i <= n; i++)
	{
		scanf("%d", &h[i]);
		max = std::max(max, h[i]);
	}
	h[0] = h[n + 1] = -1;
	int count{};
	for (int i{max}; i > 0; i--)
	{
		for (int j{1}; j <= n; j++)
		{
			if (h[j] != i) continue;
			h[j]--;
			if (h[j + 1] == i) continue;
			count++;
		}
	}
	printf("%d\n", count);

	return 0;
}

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

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

    int x = 0, max = 0;
    for (auto i = 0; i < n; i++) {
        if(s[i] == 'I') x++;
        if(s[i] == 'D') x--;
        if(max < x) max = x;
    }

    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp> 
    #include <ext/pb_ds/tree_policy.hpp> 
    #include<chrono>
    using namespace std;
    using namespace std::chrono;
    using namespace __gnu_pbds; 
    #define lli long long int
    #define fr(i,a,b) for(lli i=a;i<b;i++)
    #define bfr(i,a,b) for(lli i=a;i>=b;i--)
    #define fio ios_base::sync_with_stdio(false); cin.tie(NULL),cout.tie(NULL);
    #define tc int t;cin>>t;while(t--)
    #define mod 1000000007LL
    #define mod2 998244353LL
    #define all(vec) vec.begin(),vec.end()  
    #define ld long double
    #define pb push_back

    #define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update> 



      

       int main()
      
    {
                           
             

                        
              fio  

               
               lli a,b,c,k;
               cin>>a>>b>>c>>k;
               lli s=min(k,a);
               k-=s;
               k= max(0LL,k-b);
               if(k==0)cout<<s;
               else cout<<s-k;

              





    return 0;}

Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
string s;
int main(){
	cin>>s;
	int a=-1,b=-1;
	for(int i=0;i<s.size()-2;i++){
		if(s[i]==s[i+1]||s[i]==s[i+2]||s[i+1]==s[i+2]){
			if(a==-1){
				a=i+1,b=i+3;
			}
		}
	}
	if(s.size()==2){
		if(s[0]==s[1])a=1,b=2;
	}
	cout<<a<<" "<<b<<endl;
	return 0;	
}


Measured memory_bytes: 512
def main():
    n,m = map(int,input().split())
    if abs(n-m) > 1:
        print(0)
    else:
        from math import factorial
        mod = 10**9+7
        res = factorial(n)*factorial(m)%mod
        if n == m:
            print(2*res%mod)
        else:
            print(res)
 
if __name__ == '__main__':
    main()


Measured memory_bytes: 54768
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
template <typename T> using lim = numeric_limits<T>;
template <bool Directed, typename TEdge> struct graph {
    using EType = TEdge;
    vector<TEdge> edges;
    vector<vector<int>> adj;
    graph(int n) : adj(n + 1) {}
    graph(int n, int m) : graph(n) { edges.reserve(m); }
    TEdge& operator()(int i) { return edges[i]; }
    vector<int>& operator[](int u) { return adj[u]; }
    int size() { return adj.size() - 1; }
    void add_edge(const TEdge& e) {
        adj[e.u].push_back(edges.size());
        edges.push_back(e);
        if(not Directed) {
            adj[e.v].push_back(edges.size());
            edges.push_back(e.reverse());
        }
    }
};
template <typename TEdge> struct dfs_params {
    function<void(int)> pre_node = [](int) {};
    function<void(int)> pos_node = [](int) {};
    function<void(TEdge&)> pre_edge = [](TEdge&) {};
    function<void(TEdge&)> pos_edge = [](TEdge&) {};
    int root = 0;
};
template <bool Directed, typename TEdge, typename TParamsetter>
void dfs(graph<Directed, TEdge>& g, const TParamsetter& psetter) {
    static_assert(is_convertible<decltype(psetter), function<void(dfs_params<TEdge>&)>>::value,
        "psetter must be void(dfs_params<TEdge>&)");
    dfs_params<TEdge> params;
    psetter(params);
    vector<bool> vis(g.size() + 1);
    function<void(int)> dfs = [&](int u) {
        vis[u] = true;
        params.pre_node(u);
        for(int i : g[u]) if(not vis[g(i).v]) {
            params.pre_edge(g(i)), dfs(g(i).v), params.pos_edge(g(i));
        }
        params.pos_node(u);
    };
    if(params.root) {
        dfs(params.root);
    } else {
        for(int u = 1; u <= g.size(); u++) if(not vis[u]) {
            dfs(u);
        }
    }
}
struct wedge {
    int u, v, w;
    wedge reverse() const { return {v, u, w}; }
};
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    graph<0, wedge> g(n);
    for(int i = 1; i < n; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        g.add_edge({u, v, w});
    }
    vector<int> c(n + 1);
    dfs(g, [&](auto& p) {
        p.pre_edge = [&](wedge& e) {
            c[e.v] = c[e.u] ^ (e.w & 1);
        };
    });
    for(int i = 1; i <= n; i++) {
        cout << c[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 11824
x,y = map(int,input().split())
g1 = [1,3,5,7,8,10,12]
g2 = [4,6,9,11]
g3 = [2]
if x in g1 and y in g1:
    print("Yes")
elif x in g2 and y in g2:
    print("Yes")
elif x in g3 and y in g3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
int main()
{
	int a = 0, b = 0, c = 0, d = 0, e = 0, min = 0, ma = 0, ans = 0, ansb = 0, count = 0, countb, crowdy[101] = {}, bu = 0;
	int reset = 0, w = 0;
	char hairetu[200] = {};
	int number[10000], price[10000], sort[100000] = {}, kisu[10000] = { 100000 }, gusu[10000] = { 100000 };
	using namespace std;
	int x = 0, y = 0, z = 0, play[200] = {}, acount = 0, bcount = 0;
	std::string toki, tokit, fun, funt;
	int cake = 4, cookie = 7;
	bool okada = true;
	cin >> a>>b;
	cout << a * b - a - b + 1;
	/*	for (int i = 0; i <= a; i++) {


		}

		if (okada) {
			cout << "No" << endl;
		}
		else {
			cout << "Yes" << endl;
		}
		return 0;
	}
	*/
	return 0;
}


Measured memory_bytes: 764
xn = gets.chomp.split
x = xn[0].to_i
n = xn[1].to_i

if n != 0
    p_a = gets.chomp.split
    n.times do |i|
        p_a[i] = p_a[i].to_i
    end

    x_plus = x
    x_minus = x
    loop do
        if !p_a.include?(x_minus)
            puts x_minus
            break
        end
        if !p_a.include?(x_plus)
            puts x_plus
            break
        end
        x_plus += 1
        x_minus -= 1
    end
else
    puts x
end


Measured memory_bytes: 14376
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <math.h>
using namespace std;

int main(){
  long long int L,R;
  cin>>L>>R;
  long long int tmp;
  long long int L_mod,R_mod;
  vector<long long int> v;  
  L_mod=L%2019;
  R_mod=R%2019;
  if(R-L>2018){
    cout<<0<<endl;
    return 0;
  }
  for(int i=L_mod;i<R_mod+1;i++){
    for(int j=i+1;j<R_mod+1;j++){
      v.push_back((i*j)%2019);
    }
  }
  tmp=*min_element(v.begin(), v.end());
  cout<<tmp<<endl;
}

Measured memory_bytes: 18408
#include<stdio.h>
#define MAX 1000

void DFS(int);

int n;
int time = 1;
int A[MAX][MAX], d[MAX],f[MAX];
int V[MAX];//訪れた場所を記録する配列

int main(){
  int i, j;
  int id, k, R;

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d %d", &id, &k);
    for(j = 0; j < k; j++){
      scanf("%d", &R);
      A[id][R] = 1;
    }
  }

  for(i = 1; i <= n; i++){
    DFS(i);
  }
  
  for(i = 1; i <= n; i++){
    printf("%d %d %d\n", i, d[i], f[i]);
  }
  
  return 0;
}

void DFS(int id){
  int i;

  if(V[id] == 1) return;

  d[id] = time;
  V[id] = 1;
  time++;

  for(i = 1; i <= n; i++){
    if(A[id][i] == 1) DFS(i);
  }

  time++;
  f[id] = time - 1;
}





Measured memory_bytes: 2172
import java.util.Arrays;
import java.util.Scanner;

class A {
    public static void main(String... args) {
        final Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        final int[] h = new int[N];
        for (int i = 0; i < N; i++)
            h[i] = sc.nextInt();
        final int[] dp = new int[N];
        Arrays.setAll(dp, i -> i > 0 ? Integer.MAX_VALUE : 0);
        for (int i = 0; i < N; i++) {
            if (i >= 1)
                dp[i] = Math.min(dp[i], dp[i - 1] + Math.abs(h[i] - h[i - 1]));
            if (i >= 2)
                dp[i] = Math.min(dp[i], dp[i - 2] + Math.abs(h[i] - h[i - 2]));
        }
        System.out.println(dp[N - 1]);
    }
}
public class Main {
    public static void main(String... args) {
        A.main();
    }
}


Measured memory_bytes: 52388
#include <stdio.h>
int main(void){
    // Your code here!
    char s[11];
    int i=0,ans=1;
    scanf("%s",s);
    while(s[i]!=0){
        if(s[i]!='h'||s[i+1]!='i'){
            ans=-1;
            break;
        }
        i+=2;
    }
    if(ans==1)
        puts("Yes");
    else
        puts("No");
        
    return 0;
    
}


Measured memory_bytes: 128
#include <stdio.h>

int main()
{
	int a,b,c,ret;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);

	ret = 0;

	ret = b/a;

	ret = (ret>c)?c:ret;


	printf("%d\n",ret);
	return 0;
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int a,b,k;
    Scd3(a,b,k);

    Rep(i,k){
        if(i%2){
            a += b/2;
            b /= 2;
        }else{
            b += a/2;
            a /= 2;
        }

    }
        printf ("%d %d\n", a, b);

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
 
using namespace std;
 
int main() {
	int n,sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		while (a % 2 == 0) {
			a /= 2;
			sum++;
		}
	}
		cout << sum << endl;
 
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#include <random>
#include <chrono>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

ll d;
vector<ll> c(26 + 1, 0);
vector<vector<ll>> s(365 + 1, vector<ll>(26 + 1, 0));

ll scoring(vector<int> t)
{
    ll ans = 0;
    vector<ll> last(26 + 1, 0);

    for (int i = 1; i <= d; i++)
    {
        ans += s[i][t[i]];
        ans -= c[t[i]] * (i - last[t[i]]) * (i - last[t[i]] - 1) / 2;
        last[t[i]] = i;
    }

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

        ans -= c[i] * (d - last[i] + 1) * (d - last[i]) / 2;
    }

    return ans;
}

int main(void)
{
    random_device seed_gen;
    mt19937 rand(seed_gen());
    cin >> d;

    for (int i = 1; i <= 26; i++)
    {
        cin >> c[i];
    }

    for (int i = 1; i <= d; i++)
    {
        for (int j = 1; j <= 26; j++)
        {
            cin >> s[i][j];
        }
    }

    vector<int> BestT(d + 1, 1);

    for (int i = 1; i <= d; i++)
    {
        BestT[i] = rand() % 26 + 1;
    }

    double BestScore = scoring(BestT);
    double score;

    auto start = chrono::system_clock::now();
    vector<int> t(d + 1, 1);

    double T0 = 2e3;
    double T1 = 6e2;
    double TL = 1980;
    double msec;

    ll count = 0;

    while (1)
    {
        if (count % 100 == 0)
        {
            msec = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now() - start).count();
        }

        if (msec >= TL)
        {
            break;
        }

        double T = powf(T0, 1 - msec / TL) * powf(T1, msec / TL);

        t = BestT;

        t[rand() % d + 1] = rand() % 26 + 1;

        score = scoring(t);

        double p = exp((score - BestScore) / T);

        if (p > 0.5)
        {
            BestT = t;
            BestScore = score;
        }

        count++;
    }

    for (int i = 1; i <= d; i++)
    {
        printf("%d\n", BestT[i]);
    }
}


Measured memory_bytes: 4376
# S = input()
# N = int(input())
N, K = map(int, input().split())
X = list(map(int, input().split()))
# LR = [list(map(int, input().split())) for _ in range(M)]

ans = 10000000000

if K == 1:
    for i in range(N):
        if ans > abs(X[i]):
            ans = abs(X[i])
else:
    for i in range(N - K+1):
        left = X[i]
        right = X[i + K - 1]
        sum = 0

        if abs(left) <= abs(right):
            sum += abs(left)
        else:
            sum += abs(right)

        sum += abs(left - right)

        if ans > sum:
            ans = sum

print(ans)

Measured memory_bytes: 14352
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int n;
    cin >> n;
    string w[n];
    vector<string> v;
    cin >> w[0];
    v.push_back(w[0]);
    for (int i=1; i<n; i++) {
        cin >> w[i];
        if(w[i][0] != w[i-1][w[i-1].size()-1]) {
            cout << "No" << endl;
            return 0;
        } else if (find(v.begin(), v.end(), w[i]) != v.end()) {
            cout << "No" << endl;
            return 0;
        } else {
            v.push_back(w[i]);
        }
    }
    cout << "Yes" << endl;
}

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define E 2.71828182845905
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define debug(x) cout<<#x<<" is "<<x<<endl;
#define PI 3.14159265
#define mem(x) memset(x,0,sizeof(x));
#define br cout<<endl
using namespace std;
  
void sol() {
	int n,W;
	cin>>n>>W;
	ll w[n],v[n];
	rep(i,0,n)
	cin>>w[i]>>v[i];
	ll dp[n][W+1];
	mem(dp);
	rep(i,1,W+1){
		if(i>=w[0])
			dp[0][i]=v[0];
	}
	rep(i,1,n){
		rep(j,1,W+1){
			dp[i][j]=dp[i-1][j];
			if(j-w[i]>0)
				dp[i][j]=max(dp[i][j],dp[i-1][j-w[i]]+v[i]);
		}
	}
	cout<<dp[n-1][W];
}

int main() {
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1;
 	//cin>>t;
 	while(t--){	
	sol();
 }

}

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

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

int msg() {
    srand( time( 0 ) ) ;
    vector < string > st = {
        "Wish everyone high ratings!",
        "Good luck!",
        "Have fun!",
        "Please, read all the problems!",
        "Go Go fight!"
    } ;
    cerr << st[ rand() % sz( st ) ] ;
    return 0 ;
}

void FastInputOutput() {
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}


int n ;
int mod = 1e9 + 7 ;
ll mul = 1 ;

int main() {
    cin >> n ;
    forn( int , i , 1 , n + 1 ){
        mul = ( mul % mod ) * ( i % mod ) ;
        mul %= mod ;
    }
    cout << mul ;
    return 0 ;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
    return powmod(a, MOD-2);
}
ll f[1000010], invf[1000010];
void fac(int n){
    f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=f[i-1]*i%MOD;
    invf[n]=inv(f[n]);
    for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1)%MOD;
}
ll comb(int x, int y){
    if(!(0<=y && y<=x)) return 0;
    return f[x]*invf[y]%MOD*invf[x-y]%MOD;
}
int main()
{
    int x; cin>>x;
    cout<<(x^1)<<endl;
    return 0;
}

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

int main() {
	while (1) {
		int h, w;
		cin >> h >> w;
		if (h == 0) break;

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}



Measured memory_bytes: 3096
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
/********************************************************************************************************************************/
/* main *************************************************************************************************************************/
/********************************************************************************************************************************/
int DEBUG = 0;										/* デバッグプリント 提出時は0 */
int main()
{
	int		a, b, ans = 0;
	
	scanf("%d %d", &a, &b);

	if (DEBUG) printf("%d %d\n",a,b);
	printf("%d %d\n",a*b,a*2+b*2);


	return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
#define fo(int, i, a, b)        for (int i=a; i<(b); i++)
#define forev(int, i, b, a)     for (int i = (b)-1; i >= a; i--)
#define uns                     unsigned
#define lli                     long long int
#define ld                      long double
#define all(x)                  x.begin(), x.end()
#define sortall(x)              sort(all(x))
#define enl                     "\n"
// #define PI 3.1415926535897932384626
// const int MOD = 1000000007; // const ll INF = 1e18; // const int MX = 100001;
//==================================================================================

void solve() {
    ld a, b; cin >> a >> b;
    b *= 100;
    a /= 100;
    int64_t ans = a * b;
    cout << ans;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    // int testcase; cin >> testcase; for (int i = 1; i <= testcase; ++i)
    solve();
    return 0;
}

Measured memory_bytes: 3696
#include <iostream>
#include <set>

using namespace std;

#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define For(i, s, n) for(int i = s; i < (int)(n); ++i)

int main() {
  int X, N;
  cin >> X >> N;

  set<int> p;
  Rep(n, N) {
    int a;
    cin >> a;
    p.insert(a);
  }

  int answer = 1000;
  For(i, -200, 200) {
    if (p.count(i) != 0) continue;
    if (abs(X - i) < abs(X - answer)) {
      answer = i;
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
typedef long long LL;
int a[100030], b[100030];
char s[100030];
int main() {
    scanf("%s", s);
    for (int i = 0; s[i]; ++i) {
        if (s[i] == 'A') {
            a[i] = 1;
        } else {
            a[i] = 2;
        }
    }
    for (int i = 1; s[i]; ++i) {
        a[i] = (a[i] + a[i - 1]) % 3;
    }
    scanf("%s", s);
    for (int i = 0; s[i]; ++i) {
        if (s[i] == 'A') {
            b[i] = 1;
        } else {
            b[i] = 2;
        }
    }
    for (int i = 1; s[i]; ++i) {
        b[i] = (b[i] + b[i - 1]) % 3;
    }
    int q;
    scanf("%d", &q);
    while (q--) {
        int l, r;
        scanf("%d%d", &l, &r);
        l -= 2;
        r--;

        int tmp = (a[r] - ((l < 0) ? 0 : a[l]) % 3 + 3) % 3;
        scanf("%d%d", &l, &r);
        l -= 2;
        r--;

        int tem = (b[r] - ((l < 0) ? 0 : b[l]) % 3 + 3) % 3;
        puts(tmp == tem ? "YES" : "NO");
    }
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define lli long long int
#define ld long double
#define pb push_back
#define is insert
int dp[3005][3005];
#define iamspid ios_base::sync_with_stdio(false); cin.tie(NULL);
int main()
{
    iamspid
    string s1, s2;
    cin>>s1>>s2;
    int m=s1.size(), n=s2.size();
    for(int i=1;i<=m;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(s1[i-1]==s2[j-1]) dp[i][j]=dp[i-1][j-1]+1;
            else dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
        }
    }
    int i=m, j=n;
    string s;
    while(i&&j)
    {
        if(s1[i-1]==s2[j-1])
        {
            s=s+s1[i-1];
            i--, j--;
        }
        else if(dp[i-1][j]>dp[i][j-1]) i--;
        else j--;
    }
    reverse(s.begin(),s.end());
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 38832
def ST(A,k):
    #標準形の文字列を与えたときに
    #長さが1大きい標準形の文字列の集合を出力
    OP = []
    for a in A:
        max_cord = 0
        for i in range(len(a)):
            max_cord = max(ord(a[i]),max_cord)
        for i in range(97,max_cord+2):
            OP.append(a+chr(i))
    return OP

N = int(input())

n,A = 1,["a"]
while n < N:
    A = ST(A,n)
    n += 1

A.sort()
for i in range(len(A)):
    print(A[i])


Measured memory_bytes: 12988
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N, M; cin >> N >> M;
  vector<int> As(N); for (auto &A : As) cin >> A;
  int c = 0, s = accumulate(As.begin(), As.end(), 0);
  for (auto A : As)
    {if (4 * M * A >= s) ++c;}
  puts(M <= c ? "Yes" : "No");}

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	cout << A * B / 2 << endl;
}


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

int main(void) {
  int i, j, tmp, h[10];

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

  for (i = 0; i < 10; i++) {
    for (j = 9; j > i; j--) {
      if (h[j - 1] < h[j]) {
        tmp = h[j];
        h[j] = h[j - 1];
        h[j - 1] = tmp;
      }
    }
  }

  for (i = 0; i < 3; i++) {
    printf("%d\n", h[i]);
  }

  return EXIT_SUCCESS;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	is >> p.first >> p.second;
	return (is);
}

int main() {
	string S, T;
	string U;
	int A, B;
	cin >> S >> T;
	cin >> A >> B;
	cin >> U;
	if (U == S) {
		cout << A - 1 <<  " " << B << endl;
	} else {
		cout << A << " " << B - 1 << endl;
	}
	return (0);
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
const int man = 2e5+10;
template<typename T>T gcd(T a, T b) {return b==0?a:gcd(b, a%b);}
template<typename T>T exgcd(T a,T b,T &g,T &x,T &y){if(!b){g = a,x = 1,y = 0;}else {exgcd(b,a%b,g,y,x);y -= x*(a/b);}}
template<typename T>T quick_add(T a,T b,T mod){T ans = 0;while(b){if(b&1)ans = (ans+a)%mod;a = (a+a)%mod;b /= 2;};return ans%mod;}
template<typename T>T quick_mod(T a,T b,T mod){T ans = 1;while(b){if(b&1)ans = ans*a%mod;a = a*a%mod;b /= 2;};return ans%mod;}
#ifndef ONLINE_JUDGE
#define debug(fmt, ...) {printf("debug ");printf(fmt,##__VA_ARGS__);puts("");}
#else
#define debug(fmt, ...)
#endif
typedef long long ll;
const ll mod = 1e9+7;
int a[man],b[man],c[man],d[man];
int n;

inline int erfen_L(int maxx){
    int l = 1,r = n;
    int ans = -1;
    while(l<=r){
        int mid = l+r>>1;
        if(c[mid]>=maxx){
            ans = mid;
            r = mid - 1;
        }else l = mid + 1;
    }
    return ans;
}

inline int erfen_R(int maxx){
    int l = 1,r = n;
    //cout << "maxx:" << maxx <<endl;
    int ans = -1;
    while(l<=r){
        int mid = l+r>>1;
        if(c[mid]<maxx){
           //if(maxx==1)cout << "mid:" << mid << " c:" << c[mid] << endl;
            ans = mid;
            l = mid + 1;
        }else r = mid - 1;
    }
    return ans;
}
  
int main() {
    #ifndef ONLINE_JUDGE
        //freopen("in.txt", "r", stdin);
        //freopen("out.txt","w",stdout);
    #endif
    scanf("%d",&n);
    for(int i = 1;i<= n;i++){
        scanf("%d",&a[i]);
    }   
    for(int i = 1;i <= n;i++){
        scanf("%d",&b[i]);
    }
    int ans = 0;
    for(int k = 1;k <= 30;k++){
        for(int i = 1;i <= n;i++){
            c[i] = a[i]&((1<<k)-1);
            d[i] = b[i]&((1<<k)-1);
        }
        sort(c+1,c+1+n);
        int tp = 0;
        for(int i = 1;i <= n;i++){
            int l = erfen_L((1<<(k-1))-d[i]);
            int r = erfen_R((1<<k)-d[i]);
            if(l!=-1&&r!=-1)tp += (r-l+1);
            l = erfen_L((1<<k)+(1<<(k-1))-d[i]);
            r = erfen_R((1<<(k+1))-d[i]);
            if(l!=-1&&r!=-1)tp += (r-l+1);
        }
		if(tp%2)ans += (1<<(k-1));
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define _USE_MATH_DEFINES
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
// DON'T USE THESE MACROS DURING ICPC PRACTICE
#define For(i,n) for (int i=0; i<n; i++)
#define FOR(i,a,b) for (int i=a; i<=b; i++)
#define Down(i,n) for (int i=n-1; i>=0; i--)
#define DOWN(i,a,b) for (int i=b; i>=a; i--)
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef complex<ld> pt;
typedef vector<pt> pol;
typedef vector<int> vi;
 
const char nl = '\n';
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9+7;
const ld EPS = 1e-10;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
 
 
 
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(10);
 
  int n;
  cin >> n;
 
  int adj[n][n];
  For(i,n) {
    For(j,n) {
      cin >> adj[i][j];
    }
  }
 
  ll cost[1<<n], dp[1<<n];
  for (int bm=1; bm<1<<n; bm++) {
    cost[bm] = 0;
    for (int i=0; i<n; i++) {
      if (bm&1<<i) {
        for (int j=0; j<i; j++) {
          if (bm&1<<j) {
            cost[bm] += adj[i][j];
          }
        }
      }
    }
    dp[bm] = cost[bm];
    for (int sm=(bm-1)&bm; sm>0; sm=(sm-1)&bm) {
      dp[bm] = max(dp[bm], dp[sm] + cost[sm^bm]);
    }
  }
  cout << dp[(1<<n)-1] << nl;
 
  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

int main() {
  int n; cin>>n;
  int nn=n;
  int sumn=0;
  while(n>=1){
    sumn+=n%10;
    n/=10;}
  if(nn%sumn==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
    

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
using namespace std;

struct data{
    int pos, mod, num;
};

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> v[n];
    while(m-- > 0){
        int a, b;
        cin >> a >> b;
        v[--a].push_back(--b);
    }
    int s, t;
    cin >> s >> t;
    s--, t--;
    vector<vector<bool>> visit(3, vector<bool>(n, 0));
    queue<data> q;
    q.push(data({s,0,0}));
    while(!q.empty()){
        data d = q.front(); q.pop();
        for(int npos : v[d.pos]){
            int nmod = (d.mod+1)%3;
            int nnum = d.num + (nmod == 0);
            if(npos == t && nmod == 0){
                cout << nnum << endl;
                return 0;
            }
            if(!visit[nmod][npos]){
                visit[nmod][npos] = true;
                q.push(data({npos,nmod,nnum}));
            }
        }
    }
    cout << -1 << endl;
    return 0;
}


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

int main(){
  int n,m;
  cin>>n>>m;
  priority_queue<int> q;//プライオリティ・キューを用意
  rep(i,n){
    int a;
    cin>>a;//入力
    q.push(a);//プライオリティ・キューに入れていく
  }
  
  rep(i,m){
    int b=q.top();//プライオリティ・キューの最大値を取る
    q.pop();//プライオリティ・キューの最大値を捨てる
    q.push(b/2);//最大値を半分にしてプライオリティ・キューに入れる
  }
  
  ll ans=0;//ロング・ロングじゃないとエラーになる
  rep(i,n){
    ans+=q.top();//プライオリティ・キューの最大値を取ってansに足す
    q.pop();//プライオリティ・キューの最大値を捨てる
  }  

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

Measured memory_bytes: 892
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n = int(input())
  Ss = list(input().strip())
  ans = [Ss[0]]
  for S in Ss[1:]:
    if ans[-1] == S:
      continue
    else:
      ans.append(S)
  print(len(ans))
  
if __name__=='__main__':
  main()



Measured memory_bytes: 5420
import sys


def main():
    array = []
    input_num = int(input())
    for v in range(input_num):
        array.append(int(input()))
    min_value = array[0]
    max_diff = array[1] - array[0]
    array = array[1:]
    for v in array:
        max_diff = max(max_diff, v - min_value)
        min_value = min(min_value, v)
    print(max_diff)


if(__name__ == '__main__'):
    main()



Measured memory_bytes: 15096
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
//二項係数 nCr
const int MAX = 700000;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
  ll n,m,k;
  cin>>n>>m>>k;
  COMinit();
  ll ans=0;
  rep(i,m){
    ans+=i*(m-i)*n*n;
    ans%=MOD;
  }
  rep(i,n){
    ans+=i*(n-i)*m*m;
    ans%=MOD;
  }
  ans*=COM(n*m-2,k-2);
  ans%=MOD;
  COUT(ans);
}


Measured memory_bytes: 20036
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  ll red_cnt = 0;
  ll white_cnt = 0;
  REP(i, n) { (s[i] == 'R') ? red_cnt++ : white_cnt++; }
  ll diff_cnt = 0;
  REP(i, red_cnt) {
    if (s[i] != 'R') diff_cnt++;
  }
  cout << min(min(red_cnt, white_cnt), diff_cnt) << endl;
}

Measured memory_bytes: 3752
N = gets.to_i
A = N.times.map {|i| gets.to_i - 1 }
seen = [false] * N
x = 0
count = 0
while x != 1 and not seen[x]
  seen[x] = true
  count += 1
  x = A[x]
end
puts (x == 1 ? count : -1)


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    char a, b;cin >> a >> b;
    map<pair<char, char>, char> m;
    m[{'H', 'H'}] = 'H';
    m[{'H', 'D'}] = 'D';
    m[{'D', 'H'}] = 'D';
    m[{'D', 'D'}] = 'H';
    cout << m[{a, b}] << endl;
    return 0;
}


Measured memory_bytes: 256
<?php
while (true) {
  list($a, $op, $b) = explode(" ", trim(fgets(STDIN)));
  if ($op == "?") break;

  if ($op == "+") echo $a + $b . "\n";
  else if ($op == "-") echo $a - $b . "\n";
  else if ($op == "*") echo $a * $b . "\n";
  else echo intval($a / $b) . "\n";
}



Measured memory_bytes: 9232
#include<stdio.h>

int A[20];
int n;

int solve(int i, int m){
    int res;
    if(m==0){
        return 1;
    }
    if(n<=i){
        return 0;
    }
    res = solve(i+1,m) || solve(i+1,m-A[i]);
    return res;
}

int main(){
    int i, q, m;

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

    scanf("%d", &q);
    for(i=0;i<q;i++){
        scanf("%d", &m);
        if(solve(0,m)){
            printf("yes\n");
        }else{
            printf("no\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1820