akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD=1e9+7;

//const int MOD=998244353;
const double PI=3.14159265359;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    long long n,k;
    cin>>n>>k;
    
    vector<vector<long long>> v(n+1);
    
    for(int i=0; i<n; i++){
        long long t,d;
        cin>>t>>d;
        v[t].push_back(d);
    }
    
    for(int i=1; i<=n; i++){
        sort(v[i].begin(),v[i].end(),greater<long long>());
    }
    
    vector<long long> big,small;
    for(int i=1; i<=n; i++){
        if(v[i].size()){
            big.push_back(v[i][0]);
            for(int j=1; j<v[i].size(); j++){
                small.push_back(v[i][j]);
            }
        }
    }
    
    sort(big.begin(),big.end(),greater<long long>());
    sort(small.begin(),small.end(),greater<long long>());
    
    
    if(!small.size()){
        long long ans=0;
        for(int i=0; i<k; i++){
            ans+=big[i];
        }
        cout<<ans+k*k;
        return 0;
    }
    
    
    vector<long long> cs(small.size());
    cs[0]=small[0];
    for(int i=1; i<small.size(); i++){
        cs[i]=cs[i-1]+small[i];
    }
    
    
    
    long long ans=0;
    
    long long curs=0;
    
    //cout<<small.size()<<endl;
    for(long long i=0; i<min(k, (long long)big.size()); i++){
        curs+=big[i];
        if(small.size()>=k-i-1){
            //cout<<i<<' '<<k-i-2<<endl;
            
            ans=max(ans,curs+(k-i-1?cs[k-i-2]:0)+(i+1)*(i+1));
        }
    }
    cout<<ans;
    
    
    
    return 0;
}

Measured memory_bytes: 6904
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<a.length;i+=2){if(op==='=='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};let ssinteger=-1;const ssin=()=>{ssinteger++;return input[0][ssinteger]};
const main = ()=>{
  let a=[ssin(),ssin(),ssin()]
  let ans=700;
  if(a[0]=='o') ans+=100
  if(a[1]=='o') ans+=100
  if(a[2]=='o') ans+=100
  out(ans)
}
main()

Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
using namespace std;
typedef pair<ll,ll> lp;
const int inf=0x3f3f3f3f;
void A() {
    int n;
    cin>>n;
    vector<int> a(n,0);
    for(int i=0; i<n; i++)
        cin>>a[i];
    vector<int> dp(n+1,inf);
    dp[0]=0;
    for(int i=1; i<n; i++) {
        dp[i]=min(dp[i],dp[i-1]+abs(a[i]-a[i-1]));
        if(i>=2)
            dp[i]=min(dp[i],dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1]<<endl;

}
void B() {
    int n,k;
    cin>>n>>k;
    vector<int> dp(n+1,inf);
    vector<int> h(n,0);
    for(int i=0; i<n; i++)
        cin>>h[i];
    dp[0]=0;
    for(int i=1; i<n; i++) {
        for(int len=1; len<=min(k+1,i+1); len++) {
            int j=i-len+1;
            dp[i]=min(dp[i],dp[j]+abs(h[j]-h[i]));
        }
    }
    cout<<dp[n-1]<<endl;
}
void C() {
    int n;
    cin>>n;
    vector<vector<int>> a(n,vector<int>(3,0));
    for(int i=0; i<n; i++)
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    vector<vector<int>> dp(n,vector<int>(3,0));
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    for(int i=1; i<n; i++) {
        for(int j=0; j<3; j++) {
            for(int k=0; k<3; k++) {
                if(j==k)
                    continue;
                dp[i][j]=max(dp[i][j],dp[i-1][k]+a[i][j]);
                //cout<<dp[i][j]<<endl;
            }
        }
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
}
void D() {
    ll n,W;
    cin>>n>>W;
    vector<lp> p;
    for(int i=0; i<n; i++) {
        ll a,b;
        cin>>a>>b;
        p.emplace_back(a,b);
    }
    sort(p.begin(),p.end());
    vector<ll> dp(W+1,0);
    for(int i=0; i<n; i++) {
        for(int j=W; j>=p[i].first; j--) {
            if(j>0)
                dp[j]=max(dp[j],dp[j-1]);
            dp[j]=max(dp[j],dp[j-p[i].fi]+p[i].se);
        }
    }
    cout<<dp[W]<<endl;

}
void E()
{
    //价值比较小，将dp[i]转化为获得当前i的价值的最小体积，然后根据W寻找符合要求的解；
    int n,W;
    cin>>n>>W;
    vector<ll> w(n,0);
    vector<ll> v(n,0);
    for(int i=0;i<n;i++) cin>>w[i]>>v[i];
    vector<ll> dp(100005,inf);
    dp[0]=0;
    int res=0;
    for(int i=0;i<n;i++){
        for(int j=1e5;j>=v[i];j--){
            dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
            if(dp[j]<=W){
                res=max(res,j);
            }
        }
    }
    cout<<res<<endl;

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


Measured memory_bytes: 3968
#include<iostream>
using namespace std;
long ans(long n){
  if(n<=1) return 1; 
  else return 1+ans(n/2)*2;
}
int main(){
  long long h;
  cin>>h;
  if(h==1){
    cout<<h<<endl;
    return 0;
  }
  else{
    cout<<ans(h)<<endl;
    return 0;
  }
}


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

int N;
string s;

int main() {
    cin>>N>>s;
    if (N%2==1) {
        cout<<"No"<<endl;
        return 0;
    }
    vector<char> s1(N/2),s2(N/2);
    for (int i=0; i<N/2; i++) {
        s1[i]=s[i];
        s2[i]=s[N/2+i];
    }
    if (s1==s2) cout<<"Yes"<<endl;
    else cout<<"No"<<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>
using namespace std;
// using namespace __gnu_pbds;
#define lli long long int
#define llu unsigned long long int
#define fr(va, beg, end) for (lli va = beg; va < end; va++)
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
#define sz(x) (lli)(x.size())
const lli MOD = 998244353;

vector<lli> fac;

lli power(lli x, lli y) {
    // log y complexity
    // return (x^y) % MOD
    lli ans = 1;
    x = x % MOD;
    while (y > 0) {
        if (y & 1) {
            ans *= x;
            ans %= MOD;
        }
        y = y >> 1;
        x = (x * x) % MOD;
    }
    return ans;
}

lli inverseMod(lli a) {
    return power(a, MOD - 2);
}

lli nCr(lli n, lli r) {
    // lli val =
    //     (fac[n] * (inverseMod(fac[n - r]) * inverseMod(fac[r])) % MOD) % MOD;

    lli val = (inverseMod(fac[n - r]) * inverseMod(fac[r])) % MOD;
    val = (val * fac[n]) % MOD;
    return val;
}

void solve() {
    lli n, a, m, k;
    cin >> n >> m >> k;

    fac.resize(n + 2, 0);
    fac[0] = 1;
    for (lli i = 1; i <= n; i++) {
        fac[i] = (fac[i - 1] * i) % MOD;
    }

    lli val = max((lli)1, n - k);
    lli ans = 0;

    for (lli i = val; i <= n; i++) {
        lli p = power(m - 1, i - 1);
        p *= m;
        p %= MOD;
        p *= nCr(n - 1, i - 1);
        p %= MOD;
        ans += p;
        ans %= MOD;
    }

    cout << ans << endl;
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // lli t; cin >> t; while(t--)
    solve();
    rt;
}

Measured memory_bytes: 4776
#include <cstdio>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <tuple>
typedef long long ll;

using namespace std;
int main(){
    int n;
    cin >> n;
    cout << n*n*n<<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>

#define FIO                 ios::sync_with_stdio(false); cin.tie(nullptr)
#define TC(t)               int t; cin >> t; for(int i = 1; i <= t; i++)
#define deb(x)              cerr << #x << " = " << x << endl
#define deb2(x, y)          cerr << #x << " = " << x << ", " << #y << " = " << y << endl
#define f0(i, a, n)         for(i = a; i < n; i++)
#define f1(i, a, n)         for(i = a; i <= n; i++)
#define ini(x, y)           memset(x, y, sizeof(x))
#define all(x)              x.begin(), x.end()
#define sz(x)               x.size()
#define ll                  long long int
#define vi                  vector<int>
#define pb                  emplace_back
#define ppb                 pop_back
#define mp                  make_pair
#define M                   1000000007
#define endl                '\n'
#define bits(x)             __builtin_popcountll(x)
#define zrbits(x)           __builtin_ctzll(x)
#define ordered_set         tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

const int N = 1e5 + 1;
const int MX = 1e9;
const ll INF = 1e18;

using namespace std;
using namespace __gnu_pbds;

inline ll ceil(ll a,ll b) {return (a % b ? a / b + 1 : a / b);}
inline ll mod(ll x) {return ( (x % M + M) % M );}

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
        for(auto& x : v) os << x << " ";
        return os << '\n';
}

template<typename... T>
void in(T&... args) {
        ((cin >> args), ...);
}

template<typename... T>
void out(T&&... args) {
        ((cout << args << endl), ...);
}

template<typename... T>
void out2(T&&... args) {
        ((cout << args << " "), ...);
}

void solve() {
        int n, i, j;
        cin >> n;
        int a[n][2];
        for(i = 0; i < n; i++) {
                for(j = 0; j < 2; j++) {
                        cin >> a[i][j];
                }
        }

        for(i = 0; i < n - 2; i++) {
                for(j = i; j < i + 3; j++) {
                        if(a[j][0] != a[j][1]) break;
                }
                if(j == i+3) {
                        cout << "Yes" << endl;
                        break;
                }
        }
        if(i == n-2) cout << "No" << endl;
}

int main () {
        FIO;
        // TC(t) 
        solve();
        return 0;
}

Measured memory_bytes: 3636
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
AB = [LIST() for _ in range(N)]

for i in range(N):
	AB[i].append(sum(AB[i]))

AB.sort(key = lambda x: -x[2])

print(sum([AB[i][0] for i in range(0, N, 2)]) - sum([AB[i][1] for i in range(1, N, 2)]))

Measured memory_bytes: 36452
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

int main() {
    std::ios::sync_with_stdio(false);

    //h = max(H−|x−CX|−|y−CY|,0)

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

    for (int cx = 0; cx <= 100; cx++) {
        for (int cy = 0; cy <= 100; cy++) {
            int hh = -1;
            bool ok = true;
            for (int i = 0; i < n; i++) {
                if (h[i] > 0) {
                    int hhh = h[i] + std::abs(x[i] - cx)+ std::abs(y[i] - cy);
                    if (hhh <= 0) {
                        ok = false;
                    }
                    if (hh == -1) {
                        hh = hhh;
                    }
                    if (hhh != hh) {
                        ok = false;
                    }
                }
            }
            if (hh == -1) hh = 1;
            for (int i = 0; i < n; i++) {
                if (h[i] == 0) {
                    if (hh - std::abs(x[i] - cx) - std::abs(y[i] - cy) > 0) {
                        ok = false;
                    }
                }
            }
            if (ok) {
                cout << cx << " " << cy << " " << hh;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define int         int64_t
#define ii          pair<int,int>
#define dd          pair<double,double>
#define vi          vector<int>
#define pb          push_back
#define all(x)      (x).begin(), (x).end()
#define checkBit(v, p)      (v&(1LL << p))
#define loop(i,a,b) for(int i = a;i < int(b);i++)
#define x           first
#define y           second
using namespace std;
int inf = 4e18;

int32_t main()
{
    ios_base::sync_with_stdio(false); cout << fixed <<setprecision(0);
    int n,a,b,sum = 0; cin >> n >> a >> b;
    for(int i=0,l,cur;i<n;i++){
        cin >> cur;
        if(i) sum += min(b, a * (cur - l));
        l = cur;
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define rrep1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

deque<char> q;

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

    rep(i, s.size()) q.push_back(s[i]);

    int n_rev = 0;
    rep(i, Q) {
        int t; cin >> t;
        if (t == 1) n_rev++;
        else {
            int f; char c;
            cin >> f >> c;
            if (f == 1) {
                if (n_rev % 2 == 0) q.push_front(c);
                else q.push_back(c);
            } else {
                if (n_rev % 2 == 0) q.push_back(c);
                else q.push_front(c);
            }
        }
    }

    if (n_rev % 2 == 0) {
        while (q.size()) {
            cout << q.front();
            q.pop_front();
        }
    } else {
        while (q.size()) {
            cout << q.back();
            q.pop_back();
        }
    }
    cout << endl;
}


Measured memory_bytes: 896
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int area = (a + b) * h / 2;
        System.out.println(area);
    }
}


Measured memory_bytes: 21716
#include<queue>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
using namespace std;
int a[300010];
int main()
{
    int n,k,indx;
    scanf("%d%d",&k,&n);
    indx=n;
    if(k%2==0)
    {
        a[1]=k/2;
        for(int i=2;i<=n;i++)
            a[i]=k;
    }
    else
    {
        int temp=n/2;
        for(int i=1;i<=n;i++)
            a[i]=(k+1)/2;
        while(temp--)
        {
            if(a[indx]==1)
                a[indx--]--;
 
            else
            {
                a[indx]--;
                while(indx<n)
                    a[++indx]=k;
            }
        }
    }
    for(int i=1;i<=indx-1;i++)
        printf("%d ",a[i]);
    printf("%d\n",a[indx]);
    return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> A(N), B(N), C(N);
	REP(i, N) scanf("%d %d %d", &A[i], &B[i], &C[i]);
	vector<int> D(M), E(M), F(M);
	REP(i, M) scanf("%d %d %d", &D[i], &E[i], &F[i]);
	
	vector<int> cx, cy;
	cx.emplace_back(-INF); cx.emplace_back(INF);
	cy.emplace_back(-INF); cy.emplace_back(INF);
	REP(i, N) { cx.emplace_back(A[i]); cx.emplace_back(B[i]); cy.emplace_back(C[i]); }
	REP(i, M) { cx.emplace_back(D[i]); cy.emplace_back(E[i]); cy.emplace_back(F[i]); }
	
	sort(ALL(cx)); cx.erase(unique(ALL(cx)), cx.end());
	sort(ALL(cy)); cy.erase(unique(ALL(cy)), cy.end());
	
	auto compress = [](auto &x, const auto &cx) {
		for (auto &c : x) c = lower_bound(ALL(cx), c) - cx.begin();
	};
	compress(A, cx); compress(B, cx); compress(C, cy);
	compress(D, cx); compress(E, cy); compress(F, cy);
	
	vector<vector<bool>> isok[4], maps(cy.size(), vector<bool>(cx.size())), done = maps;
	// isok[urdl]
	
	REP(i, 4) isok[i] = vector<vector<bool>>(cy.size(), vector<bool>(cx.size()));
	
	int dx[] = {0,1,0,-1}, dy[] = {-1,0,1,0};
	REP(dir, 4) REP(i, cy.size()) REP(j, cx.size()) {
		int ny = i + dy[dir], nx = j + dx[dir];
		isok[dir][i][j] = nx >= 0 && nx < cx.size() && ny >= 0 && ny < cy.size();
	}
	
	REP(i, N) {
		int y = C[i];
		FOR(x, A[i] + 1, B[i] + 1) {
			isok[2][y][x] = isok[0][y + 1][x] = false;
		}
	}
	REP(i, M) {
		int x = D[i];
		FOR(y, E[i] + 1, F[i] + 1) {
			isok[1][y][x] = isok[3][y][x + 1] = false;
		}
	}
	
	int stx = lower_bound(ALL(cx), 0) - cx.begin(), sty = lower_bound(ALL(cy), 0) - cy.begin();
	queue<pii> que;
	que.emplace(sty, stx);
	done[sty][stx] = true;
	ll ans = 0;
	
	while (!que.empty()) {
		int y = que.front().fi, x = que.front().se;
		que.pop();
		
		if (abs(cx[x]) == INF || abs(cy[y]) == INF) {
			puts("INF");
			return 0;
		}
		
		ans += (ll)(cy[y] - cy[y - 1]) * (cx[x] - cx[x - 1]);
		
		REP(dir, 4) if (isok[dir][y][x]) {
			int ny = y + dy[dir], nx = x + dx[dir];
			if (!done[ny][nx]) {
				done[ny][nx] = true;
				que.emplace(ny, nx);
			}
		}
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
using namespace std;

bool check_feasiblity(int state, int data[10], int m, int n, vector<int> p_values){

    for(int i=0;i<m;i++){
        int anded = data[i] & state;
        int number_of_1s = 0;
        while(anded > 0){
            if(anded % 2 == 1) number_of_1s++;
            anded = anded >> 1;
        }
        if(number_of_1s % 2 != p_values[i]) return  false; 
    }
    return(true);
}

int main(){
    IOS;

    int n, m;
    cin >> n >> m;
    int data[m];

    for(int i=0;i<m;i++){
        int k;
        cin >> k;
        int check_number = 0;
        for(int j=0;j<k;j++){
            int t;
            cin >> t;
            check_number += pow(2,t-1);
        }
        data[i] = check_number;
    }
    
    vector<int> p_values(m);
    for(int i=0;i<m;i++) cin >> p_values[i];

    int number_of_valid_states = 0;
    vector<int> switch_states(n);
    int number_of_states = pow(2,n);
    for(int i=0;i<number_of_states;i++){
        bool ans = check_feasiblity(i,data,m,n,p_values);
        if(ans) number_of_valid_states++;
    }

    cout << number_of_valid_states << endl;

    return 0;
}

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

int main() {
    int n;
  
 
   cin >> n;
  
  if(n==24){
    
    cout << "Christmas Eve" << endl;
    
  }else if(n==25){
    cout << "Christmas" << endl;
  }else if(n==23){
    cout << "Christmas Eve Eve" << endl;
   
  }else{
    
     cout << "Christmas Eve Eve Eve" << endl;
    
  }
  
   
 
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define elnd endl //* missspell check



ll simple(string s, ll &c){
    while(s.length()>1){
        ll a = s.back()-'0'; s.pop_back();
        ll b = s.back()-'0'; s.pop_back();
        c++;
        a = a+b;
        b = a % 10;
        a = a / 10;
        if(a > 0)
            s.push_back((char)(a + '0'));

        s.push_back((char) (b+'0'));
    }
    return (ll)(s[0]-'0');

}

pll calsame(ll x, ll n){
    if( n<= 0)
        return pll(0, 0);
    if(n == 1)
        return pll(x, 0);
    if(n == 2){
        if(x >= 5)
            return pll((2*x)%10+(2*x)/10, 2);
        else
        {
            return pll(2*x, 1);
        }
        
    }
    pll r1 = calsame(x, n/2);

    ll c = 0;
    string s(2, '0');
    s.at(0) = (char)(r1.first+'0');
    s.at(1) = (char)(r1.first+'0');
    if(n % 2)
        s.push_back((char) ('0'+x));
    ll r = simple(s, c);
    return pll(r, c+r1.second*2);
}

void solve(long long M, std::vector<long long> d, std::vector<long long> c){
    string my;
    ll cnt = 0;
    REP(i, M){
        /*
        if(c[i]>0){
            my.push_back((char)('0'+d[i]));
            c[i]--;
        }
            
        if(c[i]>0){
            my.push_back((char)('0'+d[i]));
            c[i]--;
        }
        */
        if(c[i]>0){
            auto r = calsame(d[i], c[i]);
            cnt += r.second;
            my.push_back((char)('0'+r.first));
        }
        
    }

    ll res = simple(my, cnt);
    cout << cnt << endl;
}

int main(){
    long long M;
    scanf("%lld",&M);
    std::vector<long long> d(M);
    std::vector<long long> c(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&d[i]);
        scanf("%lld",&c[i]);
    }
    solve(M, std::move(d), std::move(c));
    return 0;
}


Measured memory_bytes: 3844
#include<bits/stdc++.h>
using namespace std;
int main(){
    string str;
    cin>>str;
    int back=str.size()-1;
    while(1){
        int c=0;
        if(back%2!=0){
            back--;
        }
        for(int i=0;i<back/2;++i){
            if(str[i]==str[back/2+i]) c++;
        }
        if(c==back/2) break;
        back-=2;
    }
    printf("%d\n",back);
    return 0;
}



Measured memory_bytes: 256
main = interact main'

main' :: String -> String
main'
    = show . f . map read . words . head . reverse . lines

f :: [Integer] -> Integer
f x = g [] x 0 (sum x)

g :: [Integer] -> [Integer] -> Integer -> Integer -> Integer
g _ [] x _ = x
g xl (x:xr) suml sumr
    = min (g (x:xl) xr (suml+x) (sumr-x)) (abs (sumr - suml))

Measured memory_bytes: 96636
#include "bits/stdc++.h"
using namespace std;
int N;
vector<int>to[100005];
vector<int>dist;
void dfs(int v, int d = 0, int p = -1) {
	dist[v] = d;
	for (int e : to[v]) {
		if (p == e) {
			continue;
		}
		dfs(e, d + 1, v);
	}
}
vector<int>f(int x) {
	dist = vector<int>(N);
	dfs(x);
	return dist;
}

int main() {
	cin >> N;
	for (int n = 0; n < N - 1; ++n) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	vector<int>DistU = f(0);
	vector<int>DistV = f(N-1);
	int ans = 0;
	int ans2 = 0;
	for (int n = 0; n < N; ++n) {
		if (DistU[n] <= DistV[n]) {
			ans++;
		}
		else {
			ans2++;
		}
	}
	if (ans > ans2){
		cout <<"Fennec" <<endl;
	}
	else {
		cout << "Snuke" << endl;
	}
	return 0;
}

Measured memory_bytes: 14564
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/

ll get(ll n,ll d){
	if(d==0)return (n+1)/2;
	ll ret=0;
	if(n%2==0)ret+=(!!(n--&(1ll<<d)));
	return ret+2ll*get(n/2,d-1);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b;
	cin>>a>>b;
	ll ans=0;
	rep(i,40){
		if((get(b,i)-get(a-1,i))%2)ans|=(1ll<<i);
	}
	puta(ans);
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long double ld;
#define mp make_pair
#define pb push_back

#define rep(i, N) for(ll i = 0; i < N; i++)
#define repa(i, a, N) for(ll i = a; i < N; i++)
#define repr(i, N) for(ll i = N-1; i >= 0; i--)

#define drep(i, N, j, M) rep(i, N) rep(j, M)
#define trep(i, N, j, M, k, L) rep(i, N) rep(j, M) rep(k, L)

#define all(A) A.begin(), A.end()

const ll mod = 1e9 + 7;
// const ll mod = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}

ll id(char c) {
	return c - 'a';
}

int dp[5000][5000];
int main() {
	ll N;
	cin >> N;
	
	string S;
	cin >> S;

	int lcs = 0;

	repa(i, 1, N) {
		if (S[i] == S[0]) {
			dp[i][0] = 1;
			dp[0][i] = 1;
			lcs = 1;
		}
	}

	repa(i, 1, N - 1) {
		repa(j, i + 1, N) {
			if (S[i] == S[j] &&
				(j - i) > lcs)
			{
				dp[i][j] = dp[i - 1][j - 1] + 1;
				lcs = max(dp[i][j], lcs);
			}
			else {
				dp[i][j] = 0;
			}
		}
	}

	cout << lcs << endl;
	
	return 0;
}

Measured memory_bytes: 96896
#include <stdio.h>
int main(void){
    int a,b;
    int i,j,k;
    int ans;
    while(1){
        scanf("%d %d", &a,&b);
        if(a==0 && b==0) break;
        ans=0;
        for(i=1;i<a-1;i++){
            for(j=i+1;j<a;j++){
                for(k=j+1;k<a+1;k++){
                    if(i+j+k==b) ans++;
                }
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	int sum=0;
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
		sum+=a[i];
	}
	int m;
	cin >> m;
	int c=sum;
	for(int i=0;i<m;i++)
	{
		sum=c;
		int x,y;
		cin >> x >> y;
		sum-=a[x-1];
		sum+=y;
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	string s1,s2;
	cin>>s1>>s2;
	reverse(s1.begin(),s1.end());
	if(s1==s2) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int a[110];
int main(){
	int n,x;
	scanf("%d%d",&n,&x);
	for(int i=1;i<=n;i++)
		scanf("%d",a+i);
	sort(a+1,a+1+n);
	int ans=0;
	for(int i=1;i<=n;i++){
		if(x>=a[i]) x-=a[i],ans++;
		else{
			x=0;
			break;
		}
	}
	if(x>0) ans--;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() { 
    int N, Q;
    string S;
    int type;
  
    cin >> N >> S >> Q;

    set<int> tree[26];
    for(int i = 0; i < S.size(); i++) {
        tree[(int)(S[i]-'a')].insert(i);
    }
  
    for(int i = 0; i < Q; i++) {
        cin >> type;
        if(type == 1) {
            int l;
            char c;
            cin >> l >> c;
            l--;
            tree[(int)(S[l]-'a')].erase(l);
            S[l] = c;
            tree[(int)(S[l]-'a')].insert(l);
        }
        else if(type == 2) {
            int l, r;
            cin >> l >> r;
            l--, r--;
            int sum = 0;
            for(int j = 0; j < 26; j++) {
                auto it = tree[j].lower_bound(l);
                if(it != tree[j].end()) {
                    if(*it <= r) {
                        sum++;
                    }
                }
            }
            cout << sum << endl;
        }
    }
  
  return 0; 
}

Measured memory_bytes: 24196
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		String s = stdIn.next();
		if(s.length() % 2 != 0) {
			System.out.println("No");
			return;
		}
		
		String a = "hi";
		
		for(int i = 0; i < s.length()-1; i+=2) {
			if(!s.substring(i,i+2).equals(a)) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
		
		
		
	}

}


Measured memory_bytes: 23764
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <fstream>
#include <iomanip>
//#include <unordered_map>
using namespace std;
#define dbg(x) cerr << #x " = " << x << endl;
typedef pair<int, int> P;
typedef long long ll;
#define FIN freopen("in.txt", "r", stdin);

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int k, a, b;
    cin>> k >> a >> b;
    for(int i = a; i <= b; i++)
    {
        if(i % k == 0)
        {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
//二分木の表現
vint pt(1000,-1),lt(1000),rt(1000),het(1000),dep(1000);
//深さを求める。
void setDepth(int i,int d){
    if(i!=-1){
        dep[i]=d;//深さをメモ。
        setDepth(lt[i],d+1);
        setDepth(rt[i],d+1);
    }
    else{
        return;
    }
}
//高さを求める。
int setHeight(int i){
    int h1=0,h2=0;
    if(rt[i]!=-1){
        h1=setHeight(rt[i])+1;//右側の高さ
    }
    if(lt[i]!=-1){
        h2=setHeight(lt[i])+1;//左側の高さ 
    }
    chmax(h1,h2);
    return het[i]=h1;
}
//兄弟を返す。
int getSibiling(int i){
    if(pt[i]==-1){
        return -1;
    }
    if(lt[pt[i]]!=i && lt[pt[i]]!=-1){//左に兄弟がいる場合
        return lt[pt[i]];
    }
    if(rt[pt[i]]!=i && rt[pt[i]]!=-1){//右に兄弟がいる場合
        return rt[pt[i]];
    }
    return -1;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int id,lf,ri;
    pt.resize(n,-1);
    rep(i,n){
        cin>>id>>lf>>ri;
        lt[id]=lf;
        rt[id]=ri;
        if(lf!=-1){
            pt[lf]=id;
        }
        if(ri!=-1){
            pt[ri]=id;
        }
    }
    int root;
    rep(i,n){
        if(pt[i]==-1){
           root=i; 
        }
    }
    setDepth(root,0);
    setHeight(root);
    rep(j,n){
        cout<<"node "<<j;
        cout<<": parent = "<<pt[j];
        cout<<", sibling = "<<getSibiling(j);
        cout<<", degree = ";
        int count=0;
        if(lt[j]!=-1){
            count++;
        }
        if(rt[j]!=-1){
            count++;
        }
        cout<<count;
        cout<<", depth = "<<dep[j];
        cout<<", height = "<<het[j];
        if(pt[j]==-1){
            cout<<", root\n";
        }
        else if(lt[j]==-1 && rt[j]==-1){
            cout<<", leaf\n";
        }
        else{
            cout<<", internal node\n";
        }
    }
    return(0);
}


Measured memory_bytes: 3152
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>

using namespace std;

const int N = 100005;
int a[N] , b[N] , x[N] , y[N] , c[N];

int minn = 0x7fffffff;
int mina = 0x7fffffff , minb = 0x7fffffff;
int n , m;
int A , B;

int main(){
	cin >> A >> B >> m;
	for(int i = 1; i <= A; i++) { cin >> a[i]; mina = min(mina , a[i]); }
	for(int i = 1; i <= B; i++) { cin >> b[i]; minb = min(minb , b[i]); }
	minn = mina + minb;
	for(int i = 1; i <= m; i++){
		scanf("%d%d%d" , &x[i] , &y[i] , &c[i]);
		minn = min(minn , a[x[i]] + b[y[i]] - c[i]);
		//cout << minn << "\n";
	}
	cout << minn;
}

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

using namespace std;

//int score(int min, int player, int stones, vector<int> &nums, vector<vector<int>> &memo) {
//    int op = 1 - player, winner;
//    if (min > stones) {
//        return op;
//    }
//
//    if (memo[player][stones] != -1) {
//        return memo[player][stones];
//    }
//    for (int i = 0; i < nums.size(); i++) {
//        if (stones - nums[i] > 0) {
//            winner = score(min, op, stones - nums[i], nums, memo);
//            if (winner == player) {
//                memo[player][stones] = player;
//                return player;
//            } else {
//
//            }
//        }
//
//    }
//
//    memo[player][stones] = op;
//    return op;
//}

int score(int mn, int player, int stones, vector<int> &nums, vector<vector<int>> &memo) {
    int op = 1 - player, winner;
    if (mn > stones) {
        memo[player][stones] = op;
        return op;
    }
    if (memo[player][stones] != -1) {
        return memo[player][stones];
    }

    for (int i = 0; i < nums.size(); i++) {
        if (stones >= nums[i]) {
            winner = score(mn, op, stones - nums[i], nums, memo);
            if (winner == player) {
                memo[player][stones] = player;
                return player;
            }
        }
    }

    memo[player][stones] = op;
    return op;
}

void win(vector<int> &arr1, int stones) {
    int mn = INT_MAX;
    for (auto x: arr1) {
        mn = min(mn, x);
    }
    vector<vector<int>> memo(2, vector<int> (stones + 1, -1));
    if (score(mn, 1, stones, arr1, memo)) {
        cout<<"First";
    } else {
        cout<<"Second";
    }
}

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

    return 0;
}



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

#define ll long long
#define ld long double
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define ppb pop_back
#define vll vector<ll>
#define vi vector<int>
#define endl "\n"

const ll INF = 1000000007;

/*
const int max_size = 100001;
int parent[max_size];
int Size[max_size];

int root(int x){
	while(x!=parent[x]){
		parent[x] = parent[parent[x]];
		x = parent[x];
	}
	return x;
}

void sunion(int x,int y){
	int rx = root(x);
	int ry = root(y);
	if(rx != ry){
		if(Size[rx] > Size[ry]){
			parent[ry] = parent[rx];
			Size[rx] += Size[ry];
		}
		else{
			parent[rx] = parent[ry];
			Size[ry] += Size[rx];
		}
	}
}
*/

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin >> t;
	while(t--){
		ll q,h,s,d;
		cin >> q >> h >> s >> d;
		ll n;
		cin >> n;
		ll a1;
		a1 = n/2;
		ll cst = min(min(8*q,4*h),min(2*s,d));
		ll ans = a1*cst;
		a1 = n%2;
		cst = min(min(4*q,2*h),s);
		ans += (a1*cst);
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
/*
 * atcoder/abc089/b.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
void solve();
int main() { solve(); return 0; }

#define ld long double
void solve() {
  string s; cin >> s;
  int n = s.size();
  loop(i,0,n) cout << 'x';
  cout << endl;
}


Measured memory_bytes: 3600
#include <stdio.h>

int check(int *p,int n,int a){
  int i;
  
  for(i=0;i<n;i++){
    if(a==p[i]){
      return 0;
    }
  }
  return 1;
}

int main(){
  int x,n,i;
  int p[100]={-1};
  int min=10000000,tmp,result;
  
  scanf("%d %d",&x,&n);
  
  if(n==0){
    printf("%d",x);
    return 0;
  }

  for(i=0;i<n;i++){
    scanf("%d",&p[i]);
  }
  
  for(i=-100;i<=200;i++){
    if(check(p,n,i)){
      tmp=(x-i)*(x-i);
      if(tmp<min){
        min=tmp;
        result=i;
      }
    }
  }
  
  printf("%d",result);
}

Measured memory_bytes: 1736
/*ANKON GHOSH
  KUET,ECE 2K16*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define MAX 4003
#define mod 1000000007
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define Case(i) cout<<"Case #"<<i<<": "
#define pf(a) printf("%lld\n",a)
#define pfsn printf("NO\n")
#define pfs  printf("YES\n")
#define pff(a,b) printf("%lld %lld\n",a,b)
#define pfff(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define pffff(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define LOOP(x,y) for(ll r=x;r<=y;r++)
#define RFOR(i,n) for(ll i=n-1;i>=0;i--)
#define RFOR1(i,n) for(ll i=n;i>0;i--)
#define RLOOP(x,y) for(ll i=y;i>=x;i--)
#define m_p(a,b) make_pair(a,b)
#define p_b(a) push_back(a)
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
map<ll,ll>mp1,mp;
vector<pair<ll,pair<ll,ll> > >vpp,vpp1;
vector<pair<ll,ll> >vp,fin;
vector<ll>v,v1,v2,dummy;
map<pair<ll,ll>,bool>mbb;
map<ll,bool>mb;
ll n,k,a,b,c,d,ta,sum=0,cnt=0,m,l,req,sz,maxi;
bool sortbysec(const pair<pair<ll,ll>,ll> &a,const pair<pair<ll,ll>,ll> &b)
{
    return (a.second < b.second);
}
vector<ll>power;
int main()
{
    ll q;
    ll x;
    cin>>n;
    ll arr[n+10];
    memset(arr,0,sizeof arr);
    FOR(i,n-1)
    {
        cin>>a;
        arr[a]++;
    }
    FOR1(i,n)
    {
        cout<<arr[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 5144
A = [list(map(int, input().split())),
     list(map(int, input().split())),
     list(map(int, input().split()))]
 
N = int(input())
b = [int(input()) for _ in range(N)]

for a in A:
    if a[0] in b and a[1] in b and a[2] in b:
        print('Yes')
        exit()

for i in range(3):
    if A[0][i] in b and A[1][i] in b and A[2][i] in b:
        print('Yes')
        exit()

if A[0][0] in b and A[1][1] in b and A[2][2] in b:
    print('Yes')
    exit()

if A[0][2] in b and A[1][1] in b and A[2][0] in b:
    print('Yes')
    exit()

print('No')

Measured memory_bytes: 3064
h, w = map(int,input().split())
n = int(input())
a = list(map(int,input().split()))
c = []

for i in range(n):
  while a[i]>0:
    a[i] -=1
    c.append(str(i+1))

for i in range(h):
  if i%2==0:
    print(" ".join(c[i * w:(i + 1) * w]))
  else:
    print(" ".join(reversed(c[i * w:(i + 1) * w])))

Measured memory_bytes: 9600
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:256000000")
#include <iostream>
#include <iterator>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <cassert>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <climits>
#include <ctime>
#include <bitset>

using namespace std;
using ll = long long;
const int inf = 0x3f3f3f3f;
const int maxn = 200000;


void solve() {
	 int n;
	 scanf("%d", &n);
	 vector<int> a(n);
	 int sum = 0;
	 for (int i = 0; i < n; ++i) {
		 scanf("%d", &a[i]);
		 sum += a[i];
	 }
	 bitset<4*1000*1000+1> w = 1;
	 for (int i = 0; i < n; ++i)
		w |= w << a[i];
	 int k;
	 for (k = (sum+1)/2; w[k] != 1; ++k);
	 printf("%d", k);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	solve();

#ifdef LOCAL
	cerr << double(clock()) / CLOCKS_PER_SEC << " sec" << endl;
#endif
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <math.h>
#include <string>
#include <string.h> 
#include <stdio.h>
using namespace std;
#define MAX 200000
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)

int main(){
    int n,a;
    int min=1001,max=0;
    scanf("%d",&n);
    REP(i,n){
        scanf("%d",&a);
        if(a<min)min=a;
        if(a>max)max=a;
    }
    printf("%d\n",max-min);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void)
{
    char s1[101], s2[101];
    int i, n;
    int taro = 0, hanako = 0;
    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%s %s", &s1, &s2);
        if (strcmp(s1, s2) == 0)
        {
            taro++, hanako++;
        }
        else if (strcmp(s1, s2) > 0)
        {
            taro += 3;
        }
        else if (strcmp(s1, s2) < 0)
        {
            hanako += 3;
        }
    }
    printf("%d %d\n", taro, hanako);
    return 0;
}


Measured memory_bytes: 2044
n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(n)]

ans_m = 0
ans_b = []
for i in range(n-1,n//2-1,-1):
    # print(i)
    if a[i] == 1:
        b[i] = 1
        ans_m += 1
        ans_b.append(i+1)
        
        # print(i+1)

# print(b)
for i in range(n//2-1,-1,-1):
    # print(i)
    s = 0
    for j in range((i+1)*2,n+1,i+1):
        # print(j)
        s += b[j-1]
        # print([i+1,j])
    # print(s)
    if s % 2 != a[i]:
        b[i] = 1
        ans_m += 1
        ans_b.append(i+1)
        # print(i+1)

# print(b)

print(ans_m)
print(*ans_b)

Measured memory_bytes: 14016
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
struct UnionFind
{
    vector<int> data;

    UnionFind(int sz)
    {
        data.assign(sz, -1);
    }

    bool unite(int x, int y)
    {
        x = find(x), y = find(y);
        if (x == y)
            return (false);
        if (data[x] > data[y])
            swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }

    int find(int k)
    {
        if (data[k] < 0)
            return (k);
        return (data[k] = find(data[k]));
    }

    int size(int k)
    {
        return (-data[find(k)]);
    }
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
};

int main()
{
    int N,M;
    cin>>N>>M;
    if(M==0)
    {
        cout<<1<<endl;
        return 0;
    }
    UnionFind uf(N);
    set<int>mem;
    for (size_t i = 0; i < M; i++)
    {
        int a,b;
        cin>>a>>b;
        a--;b--;
        uf.unite(a,b);
        mem.insert(a);
        mem.insert(b);
    }
    set<int>cnt;
    int ans=0;
    for (size_t i = 0; i < N; i++)
    {
        chmax(ans,uf.size(i));
    }
    //cout<<(mem.size()+cnt.size()-1)/cnt.size()<<endl;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 13552
#include <stdio.h>

int main(){
    long long  x = 1;
    int n;
    scanf("%d",&n);

    long long vet[n];

    for(int i = 0; i < n;++i){
        scanf("%lld",&vet[i]);
        if(vet[i] == 0){
            printf("0\n");
            return 0 ;
        }
    }
    for (int i = 0 ; i < n; ++i){
        
        if(x> 1000000000000000000ll/vet[i]){
        printf("-1\n");
        return 0;
        }
        else
        {
            x = vet[i] * x;
        }
        
    }
        

    
    printf("%lld\n",x);
    return 0 ;

}

Measured memory_bytes: 2432