akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 100001

struct Node{
    int num;
    struct Node *parent;
    struct Node *left_child;
    struct Node *right_bro;
};

struct Node node[MAX];

int calc_depth(int num){
    if (node[num].parent == NULL){
        return 0;
    }
    return calc_depth(node[num].parent->num) + 1;
}

void calc_type(int num, char* s){
    if(node[num].parent == NULL){
        strcpy(s, "root");
        return;
    }
    if(node[num].left_child == NULL){
        strcpy(s, "leaf");
        return;
    }
    strcpy(s, "internal node");
    return;
}

void print_children(int num){
    struct Node *nd = node[num].left_child;
    bool is_first = true;
    while(nd){
       if(is_first){
           printf("%d", nd->num);
           is_first = false;
       }else{
           printf(", %d", nd->num);
       }
       nd = nd->right_bro;
    }
}


void output(int n){
    for(int i = 0; i < n; i++){
        printf("node %d: ", i);

        if(node[i].parent != NULL){
            printf("parent = %d, ", node[i].parent->num);
        }else{
            printf("parent = -1, ");
        }

        printf("depth = %d, ", calc_depth(i));
        
        char s[30];
        calc_type(i, s);
        printf("%s, ", s);

        printf("[");
        print_children(i);
        printf("]\n");
    }

    return;
}

int main(void){
    int n;
    scanf("%d", &n);

    for(int i = 0; i < n; i++){
        node[i].num = i;
        node[i].parent = NULL;
        node[i].left_child = NULL;
        node[i].right_bro = NULL;
    }

    for(int i = 0; i < n; i++){
        int num;
        scanf("%d", &num);
        int left_child_node_num = -1;
        int child_node_num;

        int node_num;
        scanf("%d", &node_num);
        for(int j = 0; j < node_num; j++){
            scanf("%d", &child_node_num);
            if (j == 0){
                node[num].left_child = &(node[child_node_num]);
            }
            if(left_child_node_num != -1){
                node[left_child_node_num].right_bro = &(node[child_node_num]);
            }
            node[child_node_num].parent = &(node[num]);
            left_child_node_num = child_node_num;
        }
    }

    output(n);

    return 0;
}



Measured memory_bytes: 5884
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::multiset<i64, std::greater<>> s;
    for (int i = 0; i < n; i++) {
        int a;
        std::cin >> a;
        s.insert(a);
    }

    int ret = 0;
    while (!s.empty()) {
        auto mm = *s.begin();
        s.erase(s.begin());
        for (i64 x = 1; x <= 2 * mm; x *= 2) {
            if (x <= mm) continue;
            auto it = s.find(x - mm);
            if (it == s.end()) continue;
            s.erase(it);
            ret++;
            break;
        }
    }

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 9600
class segment_tree():
    def __init__(self, N, function, b):
        #initialization
        self.n = N
        self.K = (N-1).bit_length()
        self.f = function
        self.b = b
        self.data = [b]*(1+ (1 << (self.K+1)))
        for i in range((1 << self.K)-1, 0, -1):
            self.data[i] = self.f(self.data[i << 1], self.data[i << 1 | 1])

    def update(self, k, value):
        # update a[k] = value
        k += 1 << self.K
        self.data[k] = value
        while k:
            k = k >> 1
            self.data[k] = self.f(self.data[k << 1], self.data[(k << 1) | 1])

    def query(self, L, R):
        #query [L,R)
        L += 1 << self.K
        R += 1 << self.K
        vL = self.b
        vR = self.b
        while L < R:
            if L & 1:
                vL = self.f(vL, self.data[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.f(self.data[R], vR)
            L >>= 1
            R >>= 1
        return self.f(vL, vR)


N, K = map(int, input().split())
A = [int(input()) for i in range(N)]
ans = 0
seg_tree = segment_tree(6*10**5+10, max, 0)
for i, v in enumerate(A):
    v+= 1
    ans = max(seg_tree.query(max(1, v-K), v+K+1) + 1, 1)
    seg_tree.update(v, ans)
ans = seg_tree.query(0,6*10**5+10)
print(ans)


Measured memory_bytes: 150316
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

const int MAX = 1000000;
const int MOD = 1000000007;

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(){
  int n; ll k; cin >> n >> k; ll ans = 1;
  COMinit();
  if(k>=(ll)n-1){
    cout << COM(2*n-1, n-1) << endl; return 0;
  }
  int K = (int)k; ll an = 0;
  rep(i, K+1){
    ll tmp = 1;
    tmp*=COM(n, i); tmp%=mod;
    tmp*=COM(n-1, i); tmp%=mod;
    an+=tmp; an%=mod;
  }
  cout << an << endl;
}

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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

int n, m;
int a[N];
int p[N];

int find(int x)
{
	if (x != p[x]) p[x] = find(p[x]);
	return p[x];
}

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 0; i <= n; i ++ ) p[i] = i;
	
	for (int i = 1; i <= n; i ++ ) scanf("%d", a + i);
	for (int i = 0; i < m; i ++ )
	{
		int a, b;
		scanf("%d%d", &a, &b);
		
		int pa = find(a), pb = find(b);
		p[pa] = pb;
	}
	
	int res = 0;
	for (int i = 1; i <= n; i ++ )
	{
		int pa = find(a[i]), pb = find(i);
		res += pa == pb;
	}
	
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  ll a, b, c;
  cin >> a >> b >> c;
  ll foo = c - a - b;
  if (foo < 0) {
    cout << "No" << endl;
    return;
  }
  foo = foo * foo;
  ll bar = a * b * 4;
  if (bar < foo) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


Measured memory_bytes: 256
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005

int main()
{
	ios
	ll n,i,j,ans=hell;
	cin>>n;
	ll a[n+1];
	for(i=0;i<n;i++)
		cin>>a[i];
	for(i=-100;i<=100;i++){
		ll sum=0;
		for(j=0;j<n;j++)
			sum+=(i-a[j])*(i-a[j]);
		ans=min(ans,sum);
	}
	cout<<ans;
	return 0;
}

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

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

  int ans = 0;
  for(int i=0;i<N;i++){
    if((x>=a[i] && i!=N-1) || (i==N-1 && x==a[i])){
      ans++;
      x -= a[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#include <bits/stdc++.h>
 
int main() {
    int n;
	string s;
	cin >> n >> s;
	long res = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < i; j++) {
			if (s[i] == s[j]) continue;
			for (int k = 0; k < j; k++) if (j - k != i - j && s[k] != s[i] && s[k] != s[j]) res++;
		}
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define si(x) int(x.size())
const int mod=1000000007,MAX=2005,INF=1<<29;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int A,B;cin>>A>>B;
    if(A<=B) cout<<"unsafe\n";
    else cout<<"safe\n";
}





Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
const ll mod=1000000007; // 998244353 = (119<<23)+1
ll powmod(ll a,ll b) {ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
// head
string s;
stack<char> st;
int main() {
	  ios::sync_with_stdio(false);
  	cin.tie(0);
		cin>>s;
		int ans=0;
		for(auto a:s) {
			if(st.size() && a!=st.top()) {
				ans+=2;
				st.pop();
			} else st.push(a);
		}
		cout<<ans;
		return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s=="SUN") printf("7\n");
	if(s=="MON") printf("6\n");
	if(s=="TUE") printf("5\n");
	if(s=="WED") printf("4\n");
	if(s=="THU") printf("3\n");
	if(s=="FRI") printf("2\n");
	if(s=="SAT") printf("1\n");
	return 0;
}

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

int main() {
  int count = 0;
  string S;
  cin >> S;

  if(S[0]== '1') ++ count;
  if(S[1]== '1') ++ count;
  if(S[2]== '1') ++ count;
  
  cout << count << endl;

}

Measured memory_bytes: 256
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>

using ll = long long;
using ull = unsigned long long;

using namespace std;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

template <class T>
constexpr bool in(T min, T max, T t)
{
    return t >= min && t <= max;
}

template <class T>
constexpr bool nin(T min, T max, T t)
{
    return !in(min, max, t);
}

template <class T>
void ninDebug(T min, T max, T t)
{
    using namespace std;
    if (nin(min, max, t))
    {
        cout << "ERROR" << endl;
    }
}


int main()
{

    ll n, k;
    cin >> n >> k;

    vec<ll> v(n);

    for (int i = 0; i < k; ++i)
    {
        ll d;
        cin >> d;
        for (int j = 0; j < d; ++j)
        {
            ll a;
            cin >> a;
            --a;
            v[a]++;
        }
    }

    cout << count(v.cbegin(), v.cend(), 0) << endl;

    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};


int main(){
    int N;
    cin>>N;
    vector<ll>a(N);
    ll total=0;
    for(int i=0;i<N;i++){
        cin>>a[i];
        total+=a[i];
    }
    ll rest=0;
    for(int i=1;i<N;i+=2){
        rest+=2*a[i];
    }
    vector<ll> ans(N);
    ans[0]=total-rest;

    for(int i=1;i<N;i++){
        ans[i]=2*a[i-1]-ans[i-1];
    }

    for(int i=0;i<N-1;i++){
        cout<<ans[i]<<" ";
    }
    cout<<ans[N-1]<<endl;
    return 0;
}



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

using namespace std;

int main()
{
    int a, b[6] = {1, 5, 10, 50, 100, 500}, sum = 0;
    for (int i = 0; i < 6; i++) {
        cin >> a;
        sum += a * b[i];
    }
    cout << (sum >= 1000) << endl;
    return 0;
}

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

using ll = long long;

#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_(i, 0, n)
#define rrep(i, n) rfor_(i, 0, n)

ll solve(ll N, ll K) {
  ll ans;
  if(K%2) {
    ll n = N/K;
    ans = n*n*n;
  }else {
    ll n = N/(K/2);
    ll m = n/2;
    ll l = n-m;
    ans = m*m*m + l*l*l;
  }
  return ans;
}

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

  ll N, K;
  cin>>N>>K;

  cout<<solve(N, K)<<endl;

  return 0;
}


Measured memory_bytes: 888
//file_name:ABC90_C.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    ll n,m;
    scanf("%lld%lld",&n,&m);



    ll ans = 0;

    if(n==1){
        if(m==1){
            ans = 1;
        }
        if(m==2){
            ans = 0;
        }
        if(m>=3){
            ans = m-2;
        }
    }
    if(n==2){
        if(m==1){
            ans = 0;
        }
        if(m==2){
            ans = 0;
        }
        if(m>=3){
            ans = 0;
        }
    }
    if(n>=3){
        if(m==1){
            ans = n-2;
        }
        if(m==2){
            ans = 0;
        }
        if(m>=3){
            ans = (n-2)*(m-2);
        }
    }

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



Measured memory_bytes: 256
import java.io.*;
public class Main {
	/**
	 * 不足しているカードの発見
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//カードの枚数を入力
		int n = Integer.parseInt(br.readLine());
		//トランプ全てのの配列
		String[] strs = new String[52];
		//カードの有無の配列
		Boolean[] judes = new Boolean[52];
		//スートの配列
		String[] suit = {"S","H","C","D"};
		//有無の配列にまず全て無い状態にする
		for(int i = 0; i < suit.length; i++){
			for(int l = 1; l <= 13; l++){
				strs[i * 13 + l - 1] = suit[i] + " " + l;
				judes[i * 13 + l - 1] = false;
			}//for
		}//for
		//入力されたカードを有る状態に刷る
		for(int i = 0; i < n; i++){
			String str = br.readLine();
			for(int l = 0; l < strs.length; l++){
				if(str.equals(strs[l])){
					judes[l] = true;
					break;
				}//if
			}//for
		}//for
		//無いカードを表示する
		for(int i = 0; i < judes.length; i++){
			if(!judes[i]){
				System.out.println(strs[i]);
			}//if
		}//for
	}
}

Measured memory_bytes: 16892
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <climits>
#include <cfloat>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <complex>
#include <utility>
#include <memory>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <sstream>
#include <assert.h>
using namespace std;
typedef long long ll;

int N;
ll k;
int A[202000], sum[202000];
map<int, int> mp;

int main()
{
    cin >> N >> k;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        A[i] %= k;
    }
    if (k <= 400)
    {
        ll res = 0;
        for (int i = 0; i < N; i++)
        {
            ll tot = 0;
            for (int j = 0; j < k - 1 && i + j < N; j++)
            {
                tot += A[i + j];
                if (tot >= k)
                    tot -= k;
                if (tot == j + 1)
                    res++;
            }
        }
        cout << res << endl;
    }
    else
    {
        for (int i = 0; i < N; i++)
        {
            sum[i + 1] = sum[i] + A[i];
            sum[i + 1] %= k;
        }
        ll res = 0;
        for (int i = 0; i <= N; i++)
        {
            sum[i] -= i;
            while (sum[i] < 0)
                sum[i] += k;
            if (sum[i] > k)
                sum[i] -= k;
            if (i >= k)
                mp[sum[i - k]]--;
            res += mp[sum[i]];
            mp[sum[i]]++;
        }
        cout << res << endl;
    }
    return 0;
}

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

bool isSum(int a, int b, int c){
    int ketasum = 0;
    while(c>0){
        ketasum += c % 10;
        c /= 10;
    }
    if(ketasum >= a && ketasum <= b) return true;
    else return false;
}

int main() {
    int n,a,b;
    cin >> n >> a >> b;
    int sum = 0;
    for(int i = 0; i <= n; i++){
        if(isSum(a, b, i)){
            sum += i;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef unsigned long long ull;
typedef std::pair<int,int> P;

int rect[5][6];

int rectangleSearch(){
    FOR(j, 1, 5){
        REP(k, 5){
            if(rect[j-1][k] >= 1 && rect[j][k] == 1){
                rect[j][k] = rect[j-1][k] + 1;
            }
        }
    }

    // REP(i, 5){
    //     REP(j, 5){
    //         printf("%d ", rect[i][j]);
    //     }
    //     puts("");
    // }

    int res = 0;
    REP(i, 5){
        std::stack<P> s;
        REP(j, 6){
            if(s.empty()){
                s.push(mp(j, rect[i][j]));
            }else if(s.top().second < rect[i][j]){
                s.push(mp(j, rect[i][j]));
            }else if(s.top().second > rect[i][j]){
                int lowest_pos = 0;
                while(!s.empty() && s.top().second >= rect[i][j]){
                    //std::cout << (j - s.top().first) * s.top().second << std::endl;
                    res = std::max(res, (j - s.top().first) * s.top().second);
                    lowest_pos = s.top().first;
                    s.pop();
                }
                s.push(mp(lowest_pos, rect[i][j]));
            }
        }
    }

    return res;
}

int main(){
    int N;
    std::cin >> N;

    REP(i, N){
        REP(j, 5){
            REP(k, 5){
                std::cin >> rect[j][k];
            }
        }

        REP(j, 5){
            rect[j][5] = 0;
        }

        std::cout << rectangleSearch() << std::endl;
    }
}

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

#define INF 102030405060708090

// memo: 2^17 == 131072
const int MAX_N = 1 << 17; 
int n2 = 1;

vector<int> dat(MAX_N*2-1);

void init(int m) {
  while (n2 < m) n2 *= 2;

  for (int i=0;i<n2*2-1;i++) {
    dat[i] = INT_MAX;
  }
}

void update(int k, int a) {
  k += n2-1;
  dat[k] = a;
  while (k > 0) {
    k = (k-1)/2;
    dat[k] = min(dat[k*2+1],dat[k*2+2]);
  }
}

// min of [a,b)
// usage : query(a,b,0,0,n2);
int query(int a, int b, int k, int l, int r) {
  if (r <= a || b <= l) return INT_MAX;
  if (a <= l && r <= b) return dat[k];
  else {
    int vl = query(a,b,k*2+1,l,(l+r)/2);
    int vr = query(a,b,k*2+2,(l+r)/2,r);
    return min(vl,vr);
  }
}

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  long long x;
  cin >> n >> x;
  vector<int> a(n);
  for (int i=0;i<n;i++) cin >> a[i];

  init(n*2);
  for (int i=0;i<n;i++) {
    update(i,a[i]);
    update(n+i,a[i]);
  }

  long long ans = INF;
  for (int i=0;i<n;i++) {
    long long kans = x*i;
    for (int j=0;j<n;j++) {
      kans += query(n+j-i,n+j+1,0,0,n2);
    }
    ans = min(ans,kans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4116
#pragma GCC optimize("O3", "unroll-loops")
#include <bits/stdc++.h>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(a + b, min(b + c, c + a)) << '\n';	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int n,s,c;

void dfs(int v,int sum,int M){//iは0から
	if(n==v){
		if(sum==s)c++;
	}else if(v<n){
		for(int i=M;i<=9;i++){
			if(sum+i<=s)dfs(v+1,sum+i,i+1);
		}
	}
}
int main(){
	while(true){
		cin>>n>>s;
		if(n==0&&s==0)break;
		dfs(0,0,0);
		cout<<c<<endl;
		c=0;
	}
return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
 
int E(int);
 
/*
  if(E(A) == 0 || E(B) == 0 || E(C) == 0 || E(D) == 0)
    exit(0);
    */
int main(){
  int A,B,C,D,L,R;
  cin >> A >> B >> C >> D;
  L = A + B;
  R = C + D;
  if(E(A) == 0 || E(B) == 0 || E(C) == 0 || E(D) == 0)
    exit(0);
  if(L > R)
    cout << "Left" << endl;
  if(L < R)
    cout << "Right" << endl;
  if(L == R)
    cout << "Balanced" << endl;
}
 
int E(int A){
  if(1 <= A & A <= 10)
    return 1;
  else return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	
	string s;
	cin >> s;

	string s1, s2, s3;
	int n = s.size();
	int a = (n-1)/2;
	
	for (int i=0; i<a; i++){
		s1 += s[i];
	}
	
	s2 = s1;
	reverse(s2.begin(), s2.end());
	
	reverse(s.begin(), s.end());
	for (int i=0; i<a; i++){
		s3 += s[i];
	}

	if (s1 == s2 && s1 == s3) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main{

	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
	static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
	public static long mod = (long) (1e9+7);
	public static long[] fac,inv;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int k = sc.nextInt();
		double[] pre = new double[n+1];
		for(int i=1;i<=n;++i) {
			double p = sc.nextDouble();
			p = (1+p)/2;
			pre[i] = pre[i-1] + p;
		}
		double max = pre[k];
		for(int i=k+1;i<=n;++i) max = Math.max(max,pre[i] - pre[i-k]);
		out.print(max);
		out.close();

	}
	 
	

}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    cout << a.back() - a.front() << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int min;
		if(N*A < B){
		    min = N*A;
		} else {
		    min = B;
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int m;
  cin >> m;
  cout << 24+24-m << endl;
}


Measured memory_bytes: 256
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離

N = iin()
a = list(map(lambda x:int(x)-1, input().split()))

cnt = 0
for i in range(N):
    if i == a[a[i]]:cnt += 1
print(cnt//2)

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

int main(){
    int a,b;
    while(true){
        cin>>a>>b;
        if(a==0&&b==0) break;
        if(a>b){
            int t;
            t = a;
            a = b;
            b = t;
        }
        cout<<a<<' '<<b<<'\n';
    }
    return 0;
}


Measured memory_bytes: 3036
#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 D, G;
  cin >> D >> G;

  vector<int> p(D);
  vector<int> c(D);
  rep(i, D) cin >> p.at(i) >> c.at(i);

  int ans = 1e9;

  rep(i, (1 << D)){
    int sum = 0;
    int big_sum = 0;
    int num = 0, i_ans = 1e9;
    int biggest = 0;
    rep(j, D){
      if (i >> j & 1){
        sum += 100 * (j+1) * p.at(j) + c.at(j);
        num += p.at(j);
      }
      else{
        biggest = j;
      }
    }


    if(sum <= G){
      rep(k, p.at(biggest)){
        if (sum >= G ){
          i_ans = num;
          break;
        }
        else{
          sum += (biggest+1) * 100;
          num++;

        }
      }
    }
    else {
      i_ans = num;
    }
    //cout << i_ans << endl;
    ans = min(ans, i_ans);
    
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

    int n, m; cin>>n>>m;
    vector<vector<P>> G(n);
    for(int i=0; i<m; i++){
        int p, y; cin>>p>>y;
        p--;
        G[p].emplace_back(y, i);
    }

    vector<P> ans(m);
    for(int i=0; i<n; i++){
        sort(G[i].begin(), G[i].end());
        for(int j=0; j<G[i].size(); j++){
            int y, index;
            tie(y, index) = G[i][j];

            ans[index] = make_pair(i + 1, j + 1);
        }
    }

    for(int i=0; i<m; i++){
        cout << setfill('0') << right << setw(6) << ans[i].first;
        cout << setfill('0') << right << setw(6) << ans[i].second << endl;
    }
}

Measured memory_bytes: 7808
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	int A = 0;
	int B = 0;
	for (int i = 0; i < N/2; i++) {
		A += a[2*i];
		B += a[2*i + 1];
	}
	if (N % 2 == 1) {
		A += a[N - 1];
	}
	cout << A-B << endl;
	return 0;
}

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

int main() {
  int n, q;
  cin >> n >> q;
  
  vector<int> c(n);
  for (int i = 0; i < n; i++) {
    cin >> c.at(i);
    c.at(i)--;
  }
  
  vector<vector<pair<int, int>>> p(n);
  for (int i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    l--; r--;
    p.at(l).emplace_back(r, i);
  }
  
  vector<vector<int>> same(n);
  vector<int> prev(n, -1);
  for (int i = 0; i < n; i++) {
    if (prev.at(c.at(i)) != -1) {
      same.at(prev.at(c.at(i))).push_back(i);
    }
    prev.at(c.at(i)) = i;
  }
  
  vector<int> ans(q), bit(n + 1);
  for (int i = n - 1; i >= 0; i--) {
    for (int x : same.at(i)) {
      int k = x + 1;
      while (k <= n) {
        bit.at(k)++;
        k += k & -k;
      }
    }
    for (auto query : p.at(i)) {
      int r = query.first, index = query.second, s = 0, k = r + 1;
      while (k) {
        s += bit.at(k);
        k -= k & -k;
      }
      ans.at(index) = r - i + 1 - s;
    }
  }
  
  for (int i = 0; i < q; i++) {
    cout << ans.at(i) << "\n";
  }
}


Measured memory_bytes: 59920
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int r,g;
  cin>>r>>g;
  cout<<2*g-r<<endl;



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}

signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n;
    cin>>n;
    n--;
    int pw=1,len=0;
    while(1){
        pw*=26;
        len++;
        if(n>=pw){
            n-=pw;
            continue;
        }
        string ans="";
        rep(i,len){
            ans=(char)('a'+(n%26))+ans;
            n/=26;
        }
        cout<<ans<<endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 3616
n,m = map(int,input().split())
p = []
for i in range(m):
    x1,y1,z1,=[int(i) for i in input().split()]
    p.append([x1-1,y1-1,z1])
cost = [[] for i in range(n)]
for path in p:
    cost[path[0]].append((path[1],path[2]))
    cost[path[1]].append((path[0],path[2]))
zan = [[float("inf"),float("inf")] for i in range(n)]
zan[0] = (1,0)
tan =[(0,0)]
e = 0
while len(tan):
  i,j = tan.pop()
  for a,b in cost[i]:
    if (zan[a][0] != float("inf")):
      if abs((j)-zan[a][1]) == 1:
        pass
      elif ((j)-zan[a][1])%2 == 1:
        if zan[a][0] != b - zan[i][0]:
          e=1
          tan = []
          break
      else:
        e = 2
        if zan[a][0] != b - zan[i][0]:
          e = 3
          x = zan[a][0] + zan[i][0]
          if (b-x)% 2 != 0:
            e = 4
            tan = []
            break
          ano = zan[a][0] + (b-x)//2
          ino = zan[i][0] + (b-x)//2
          iti = (j)-zan[a][1]
          zan = [[float("inf"),float("inf")] for i in range(n)]
          zan[a] = (ano,0)
          kime = a
          zan[i] = (ino,iti)
          tan = []
          break
    zan[a] = (b - zan[i][0],j+1)
    tan.append((a,j+1))
  cost[i] = []
if e == 1:
  print(0)
elif e == 2:
  f = 0
  for i in range(n):
    if zan[i][0]<= 0:
      f = 1
      break
  if f == 0:
    print(1)
  else:
    print(0)
elif e == 4:
  print(0)
elif e == 0:
  syou =0
  f = 0
  dai = float("inf")
  for a,b in zan:
    if b %2 ==0:
      if a < 1:
        syou = max(syou,-a+1)
    else:
      if a > 0:
        dai = min(dai,a-1)
      else:
        f = 1
        break
  if f == 1:
    print(0)
  else:
    if dai >= syou:
      print(dai-syou+1)
    else:
      print(0)
elif e == 3:
  tan =[(kime,0)]
  cost = [[] for i in range(n)]
  for path in p:
    cost[path[0]].append((path[1],path[2]))
    cost[path[1]].append((path[0],path[2]))
  while len(tan):
      i,j = tan.pop()
      for a,b in cost[i]:
        if (zan[a][0] != float("inf")):
          if abs((j)-zan[a][1]) == 1:
            pass
          elif ((j)-zan[a][1])%2 == 1:
            if zan[a][0] != b - zan[i][0]:
              e=1
              tan = []
              break
          else:
            if zan[a][0] != b - zan[i][0]:
              e = 1
              break
        zan[a] = (b - zan[i][0],j+1)
        tan.append((a,j+1))
      cost[i] = []
  if e == 1:
    print(0)
  else:
    f = 0
    for i in range(n):
      if zan[i][0]<= 0:
        f = 1
        break
    if f == 0:
      print(1)
    else:
      print(0)


Measured memory_bytes: 128728
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
int mod = 1e9 + 7;

signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> bit1(70, 0), bit0(70, 0);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (i == N - 1) continue;
        for (int j = 0; j < 63; j++) {
            if (A[i] & (1L << j)) ++bit1[j];
            else ++bit0[j];
        }
    }
    int ans = 0;
    for (int i = N - 1; i >= 0; i--) {
        for (int j = 0; j < 63; j++) {
            if ((A[i] & (1LL << j))) {
                ans = (ans + ((1LL << j) % mod) * (bit0[j] % mod)) % mod;
            } else {
                ans = (ans + ((1LL << j) % mod) * (bit1[j] % mod)) % mod;
            }
        }
        for (int j = 0; j < 63; j++) {
            if (A[i - 1] & (1L << j)) --bit1[j];
            else --bit0[j];
        }
    }
    cout << ans << endl;
    /*
    int temp = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            temp += (A[i] xor A[j]);
            temp %= mod;
        }
    }
    cout << temp << endl;
     */
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<double> v(N);
  for(int i = 0; i < N; i++) cin >> v[i];
  sort(v.begin(), v.end());
  for(int i = 1; i < N; i++) {
    v[i] = (v[i - 1] + v[i])/2;
  }
  cout << setprecision(10) << v[N - 1] << endl;
 }

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

int diveder(long long x, int d){
  int ret = 0;
  while(x > 0){
    ret += x % d;
    x /= d;
  }
  return ret;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  long long N;
  cin >> N;
  int min = 999999;
  for (int i = 0; i < N / 6 + 1; i++) {
    long long n = N;
    n -= i * 6;
    int j = n / 9;
    int ans = n % 9;
    ans += diveder(i, 6) + diveder(j, 9);
    if(ans < min){
      min = ans;
    }
  }
  cout << min <<endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
    #define ll int
    #define N 100000
    #define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
    #define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
    #define po pop_back
    #define pb push_back
    #define lb lower_bound
    #define fi first
    #define se second
    #define debug(x) cout << #x << " = " << x << endl
    #define ub upper_bound
    #define ibs ios_base::sync_with_stdio(false)
    #define cti cin.tie(0)
    #define all(x) x.begin(),x.end()
    #define PI 3.14159265
    #define cot cout.tie(0)
    using namespace std;
      /**
        * @author :: Sawlani
        *
        */

       ll n,k;
       ll a[101];
       ll dp[N+1][3];
       int main()
      {
          //  freopen("input.txt","r",stdin);
           cin >> n >> k;

        memset(dp,-1,sizeof(dp));
         f(i,1,n) cin >> a[i];


         f(i,0,a[1]-1)
            dp[i][1]=2,dp[i][2]=1;


         f(i,a[1],k)
         {
              f(j,1,n)
              {
                   if(i>=a[j])
                   {
                       if(dp[i-a[j]][2]==1)
                        dp[i][1]=1;
                       if(dp[i-a[j]][1]==2)
                        dp[i][2]=2;
                   }
              }
              if(dp[i][1]==-1)
                dp[i][1]=2;
              if(dp[i][2]==-1)
                dp[i][2]=1;

        }

//        f(i,2,5)
//        cout << dp[i][1] << " " << dp[i][2] << endl;

          if(dp[k][1]==1)
            cout <<  "First";
          else
            cout << "Second" ;

      }


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

#define rep(i,n) for(int i = 0;i < n;i++)

using namespace std;
using ll = long long;

const int INF = 1001001001;
const int MOD = 1000000007;



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

	ll ans = 0;
	for (int i = 1;i < n+1;++i){
		
		if(i % 3 == 0 || i % 5 == 0){
			continue;
		}
		ans += i;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define in(v) int v; std::cin >> v
#define vint vector<int>
#define pb push_back
typedef long long int ll;

int main(){
  int h1,m1,h2,m2,k;
  cin >>h1>>m1>>h2>>m2>>k;
  print((h2*60+m2)-(h1*60+m1)-k);
  return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <stack>

using namespace std;

int main(){

	char buf[10001];
	int i_count,j_count;

	while(scanf("%s",buf)!=EOF){
		i_count = j_count = 0;

		for(int i = 2; buf[i] != '\0';i++){
			if(buf[i] == 'I' && buf[i-1] == 'O'){
				if(buf[i-2] == 'I')i_count++;
				else if(buf[i-2] == 'J')j_count++;
			}
		}

		printf("%d\n%d\n",j_count,i_count);

	}

    return 0;
}

Measured memory_bytes: 2604
#include<stdio.h>
int main(void){
    int x[30]={0},y,i;
    for(i=0;i<28;i++){
        scanf("%d",&y);
        x[y-1]=1;
    }
    for(i=0;i<30;i++){
        if(x[i]==0){
            printf("%d\n",i+1);
        }
    }
    return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
typedef long long LL;
using namespace std;
const int N=500010;
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
int n,ans,q[N],top,flag,a[N],dp[N][5],len;
char s[N];
inline int Solve(int l,int r)
{
	q[top=1]=0;
	For(i,l,r)
		if(s[i]=='1')q[top]++;
			else q[++top]=0;
	len=0;
	For(i,1,top)if(q[i])a[++len]=q[i];
	For(i,1,len-1)
	{
		dp[i][0]=dp[i-1][4]+a[i];
		dp[i][1]=max(dp[i-1][4],max(dp[i-1][0],dp[i-1][1]))+a[i]-1;
		if(a[i]>1)
			dp[i][2]=max(dp[i-1][3],max(dp[i-1][4],max(dp[i-1][0],dp[i-1][1])))+a[i+1];
		else
			dp[i][2]=max(dp[i-1][3],dp[i-1][4])+a[i+1];
		if(a[i]>1)
			dp[i][3]=max(dp[i-1][3],max(dp[i-1][4],max(dp[i-1][0],dp[i-1][1])))+a[i+1]-1;
		else
			dp[i][3]=max(dp[i-1][3],dp[i-1][4])+a[i+1]-1;
		dp[i][4]=max(dp[i-1][2],max(dp[i-1][3],max(dp[i-1][4],max(dp[i-1][0],dp[i-1][1]))));
	}
	int x=max(max(max(max(dp[len-1][0],dp[len-1][1]),dp[len-1][2]),dp[len-1][3]),dp[len-1][4]);
	return x;
}
int main()
{
	//file();
	read(n);
	scanf("%s",s+1);
	int pre=1;
	For(i,1,n)
		if(s[i]=='0'&&s[i-1]=='0')
		{
			ans+=Solve(pre,i);
			pre=i+1;
		}
	ans+=Solve(pre,n);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
#define INF 1000000000000000
using namespace std;
struct edge{long long  to,cost;
  edge(long long t,long long c):to(t),cost(c){}
};
typedef pair<int ,int>P;

int V;
vector<edge>G[60000];
long long lx[5000];
long long ly[5000];
long long lt[5000];
long long int  a,b,c;
long long v;
long long co;
void dk(long long ,long long*);
int ch(long long ,long long);
int main(){
  V=60000;
  int n,m;
  cin >> n >> m;
  for(int i=0;i<m;i++){
    int x,y,t;
    cin >> x >> y >> t;
    lx[i]=x;
    ly[i]=y;
    lt[i]=t;
  }
  cin >> v;
  cin >> a >> b >> c;
  int VV = 30000;
  //dk
  for(int i=0;i<m;i++){
    for(int j=0;j<c;j++){
      //cout << ch(lx[i],j)<<endl;
      G[ch(lx[i],j)].push_back(edge(ch(ly[i],(a*j+b)%c),j*lt[i]));
      G[ch(ly[i],j)].push_back(edge(ch(lx[i],(a*j+b)%c),j*lt[i]));      
      G[VV+ch(lx[i],j)].push_back(edge(VV+ch(ly[i],(a*j+b)%c),j*lt[i]));
      G[VV+ch(ly[i],j)].push_back(edge(VV+ch(lx[i],(a*j+b)%c),j*lt[i]));      
    }
  }
  for(int i=0;i<c;++i)
    G[ch(n,i)].push_back(edge(VV+ch(n,i),0));      
    
  //cout << 1<<endl;
  long long ans=INF;
  long long sd[V];
  dk(ch(1,v),sd);

  for(int i=0;i<c;i++){
    ans = min(ans, sd[VV+ch(1,i)]);
  }
  //cout << 3<<endl;
  
  cout << ans << endl;
  return 0;
}
void dk(long long s,long long* d){
  priority_queue<P,vector<P>,greater<P> >que;
  fill(d,d+V,INF);
  d[s]=0;
  que.push(P(0,s));

  while(!que.empty()){
    P p = que.top();que.pop();
    int v = p.second;
    if(d[v]<p.first) continue;
    for(int i=0;i<G[v].size();i++){
      edge e = G[v][i];
      if(d[e.to] > d[v]+e.cost){
	d[e.to]=d[v]+e.cost;
	que.push(P(d[e.to],e.to));
      }
    }
  }
}
int ch(long long A,long long B){
  return A*c+B;
}

Measured memory_bytes: 27480