akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main()
{
	ll n, k;
	cin >> n;
	ll ans = 0;
	rep(i, 1, n + 1) {
		k = n / i;
		ans += (1 + k) * i * (k) / 2;
	}
	printf("%lld\n", ans);
	return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;

const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
const int dr[]={0,1,0,-1,0};


int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n, res=0;
	string s = "AGC";
	
	cin >> n;
	
	if(n<=1199) puts("ABC");
	else if(n<=2799)puts("ARC");
	else puts("AGC");
	return 0;
}


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

int main() {
  int N,S=0,M=0,d;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> d;
    S+=d;
    M+=d*d;
  }
  S*=S;
  cout << (S-M)/2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<tgmath.h>
#include<cstdio>
using namespace std;
#define SWAP(a,b) { \
                    a^=b;\
                    b^=a;\
                    a^=b;\
}
int main()
{

    int i,j,k,m,n,val,t=0,test,a[5];
    scanf("%d %d %d",&a[0],&a[1],&a[2]);
    sort(a,a+3);
    printf("%d\n",abs(a[2]-a[1])+abs(a[1]-a[0]));
    //free();   //if pointer array
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

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

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

    unordered_map<int, vector<ll>> m;

    for (int i = 0; i < N; ++i) {
        int t, d;
        cin >> t >> d;
        m[t].emplace_back(d);
    }

    for (auto&& p : m) {
        auto&& v = p.second;
        sort(rbegin(v), rend(v));
    }

    priority_queue<int> best, remain;
    for (const auto& p : m) {
        const auto& v = p.second;

        best.emplace(v[0]);

        for (size_t i = 1; i < v.size(); ++i) {
            remain.emplace(v[i]);
        }
    }

    vector<ll> bsum = { 0 };
    while (!best.empty()) {
        bsum.emplace_back(bsum.back() + best.top());
        best.pop();
    }

    vector<ll> rsum = { 0 };
    while (!remain.empty()) {
        rsum.emplace_back(rsum.back() + remain.top());
        remain.pop();
    }

    ll ans = 0;
    for (ll x = 1; x <= K; ++x) {
        if (x >= bsum.size()) {
            continue;
        }

        if (K-x >= rsum.size()) {
            continue;
        }

        ans = max(ans, bsum[x] + rsum[K-x] + x*x);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 12320
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++) 

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<char> Vc;
typedef vector<double> Vd;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int>> VVi;
typedef vector<vector<ll>> VVl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; } inline void Yes() { cout << "Yes" << endl; }
inline void NO() { cout << "NO" << endl; } inline void No() { cout << "No" << endl; }

const int inf = 1 << 30;
const ll linf = 1LL << 60;
const int MOD = 1000000007;

template <class T>
struct BIT {
private:
	vector<T> data;
	int ma;
	int maid;

public:
	// [0, n] is the value you can deal
	BIT(int n);
	BIT();
	void init(int n);

	void add(int a, T val);

	// sum up to a (close-end)
	T sum(int a);

	// sum for [l, r)
	T sum(int left, int right);

	T operator()(int a);
};

int n;

void init()
{
	cin >> n;
}


int main()
{
	init();

	BIT<int> bit((int)1e5);

	REP(_i, n)
	{
		int d; cin >> d;
		bit.add(d, 1);
	}

	int ans = 0;
	REP1C(d, (int)1e5)
		if (bit.sum(d - 1) == n / 2)
			++ans;

	cout << ans << endl;

}


////////// 1-d BIT implementation //////////

// [0, n] is the value you can deal
template <class T> BIT<T>::BIT(int n) : data(n + 2, (T)0), ma{ n }, maid{ n + 1 } {}
template <class T> BIT<T>::BIT() : BIT(1000) {}
template <class T> void BIT<T>::init(int n) { data.assign(n + 2, (T)0); this->ma = n; this->maid = n + 1; }

template <class T> void BIT<T>::add(int a, T val) { for (++a; a <= maid; a += a & (-a)) data[a] += val; }

// sum up to a (close-end)
template <class T> T BIT<T>::sum(int a) { T ret{ 0 }; for (++a; a > 0; a -= a & (-a)) ret += data[a]; return ret; }

// sum for [l, r)
template <class T> T BIT<T>::sum(int left, int right) { return sum(right - 1) - sum(left - 1); }

template <class T> T BIT<T>::operator()(int a) { if (0 <= a && a <= ma) return sum(a) - sum(a - 1); }

////////// END of 1-d BIT implementation //////////


Measured memory_bytes: 640
#include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    typedef vector<int> vi;
    typedef vector<long long> vll;
    typedef vector<pair<int , int>> vpii;
    typedef pair<int , int> pii;
    typedef pair<long long  , long long> pll;
    typedef pair<double , double> pdd;
    #define eb emplace_back;
    #define mp make_pair;
     
    int main(){
        string s;
        cin>>s;
        bool ok = true;
        int i = 0 ;
        int j = s.length()-1;
        while(i<=j){
            if(s[i]!=s[j]){
                ok = false;
                break;
            }
            i++;
            j--;
        }
        j = (s.length()-1)/2 - 1;
        i = 0;
        while(i<=j){
            if(s[i]!=s[j]){
                ok = false;
                break;
            }
            i++;
            j--;
        }
        i = (s.length()+3)/2 - 1;
        j = s.length()-1;
        while(i<=j){
            if(s[i]!=s[j]){
                ok = false;
                break;
            }
            i++;
            j--;
        }
        if(ok){
            cout<<"Yes\n";
        }
        else{
            cout<<"No\n";
        }

        return 0;
    }

Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n,k] <- getIntList
    as <- sort . map length . group . sort <$> getIntList
    print . sum $ take ((length as) - k) as

Measured memory_bytes: 32124
#[test]
fn check_solve() {
    println!("input:\nneeded\noutput:\n{}\n", solve("needed\n"));
    println!("input:\natcoder\noutput:\n{}\n", solve("atcoder\n"));
}

fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let s = sc.get().chars().collect::<Vec<_>>();

    for i in 1..s.len() {
        if s[i-1] == s[i] {
            return format!("{} {}\n", i, i+1);
        }
    }
    for i in 2..s.len() {
        if s[i-2] == s[i] {
            return format!("{} {}\n", i-1, i+1);
        }
    }

    format!("-1 -1\n")
}

fn main() {
    let mut buf = String::new();
    use std::io;
    use std::io::{Read, Write};
    io::stdin().read_to_string(&mut buf).unwrap();
    io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}

struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
}

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

int main ()
{
   int a,b,c,d;  cin>>a>>b>>c>>d;
   
   int s=a+b;
   int s1=c+d;
   if(s>s1){
	   cout<<"Left"<<endl;
   }
   else if(s<s1){
	   cout<<"Right"<<endl;
   }
   else if(s==s1){
	   cout<<"Balanced"<<endl;
   }


}



Measured memory_bytes: 3612
// Problem Code: abc158_f

#include <iostream>
#include <vector>
#include <limits>
#include <utility>
#include <algorithm>

using namespace std;

int removing_robots(int N, vector<pair<int, int>>& R) {
	int d, mod = 998244353;
	vector<int> dp(N + 1);
	vector<pair<int, int>> st;
	
	dp[N] = 1;
	st.emplace_back(N, numeric_limits<int>::max());
	sort(R.begin(), R.end());

	for (int j, i = N - 1; i >= 0; i--) {
		d = R[i].first + R[i].second;
		while (d > st.back().second)
			st.pop_back();
		j = st.back().first;
		dp[i] = (dp[i + 1] + dp[j]) % mod;
		st.emplace_back(i, R[i].first);
	}

	return dp[0];
}

int main() {
	int N;
	cin >> N;
	vector<pair<int, int>> R(N);
	for (int i = 0; i < N; i++)
		cin >> R[i].first >> R[i].second;
	cout << removing_robots(N, R);
	return 0;
}

Measured memory_bytes: 3704
//#pragma GCC optimize ("O3")
//#pragma GCC target ("tune=native")
//#pragma GCC target ("avx")
//#include <bits/stdc++.h>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,ll> PPI;
typedef pair<ll,P> PIP;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
#define PQ(T) priority_queue<T,vector<T>,greater<T>>
#define PQ2(T) priority_queue<T>
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define REP(i,a,b) for(ll (i)=a;(i)<(ll)(b);++(i))
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) ((x)=min((x),(y)))
#define chmax(x,y) ((x)=max((x),(y)))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
#define DEBUG(x) cerr<<"line ("<<__LINE__<<")  "<<#x<<": "<<x<<endl;
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);

int main(){
	string s;
	cin>>s;
	stringstream ss(s);
	ll a;
	ss>>a;
	ll res = 0;
	int n = s.size();
	rep(i, n) res += s[i]-'0';
	chmax(res, (ll)s[0]-'0'-1+(n-1)*9);
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');
        int N = int.Parse(str[0]);
        int Y = int.Parse(str[1]);

        for(int i = 0; i <= N; i++)
        {
            for(int j = 0; j <= N - i; j++)
            {
                int k = N - i - j;
                if(i*1000+j*5000+k*10000 == Y)
                {
                    Console.WriteLine("{0} {1} {2}",k,j,i);
                    return;
                }

            }
        }
        Console.WriteLine("-1 -1 -1");
        return;
    }
    
}

Measured memory_bytes: 13140
#include<cstdio>
#include<vector>
#include<queue>
using namespace std;
#define i64 long long int
#define ran 101111
int n,m,s,t;
vector<pair<int,int> > e[ran], e2[ran];
i64 d[ran], d2[ran];
priority_queue<pair<i64,int> > q;
i64 res[ran];
void dij(int x,i64 d[ran],vector<pair<int,int> > e[ran]){
	for(int i=1; i<=n; i++)d[i] = -1;
	d[x] = 0;
	q.push(make_pair(0LL,x));
	while(!q.empty()){
		i64 dis = -q.top().first;
		x = q.top().second;
		q.pop();
		if(dis != d[x])continue;
		for(auto it : e[x]){
			int y = it.first;
			i64 dis2 = dis + it.second;
			if(d[y] == -1 || dis2 < d[y]){
				d[y] = dis2;
				q.push(make_pair(-dis2, y));
			}
		}
	}
}
int main(){
	scanf("%d%d%d%d",&n,&m,&s,&t);
	for(int i=0; i<m; i++){
		int x,y,z,w;
		scanf("%d%d%d%d",&x,&y,&z,&w);
		e[x].push_back(make_pair(y,z));
		e[y].push_back(make_pair(x,z));
		e2[x].push_back(make_pair(y,w));
		e2[y].push_back(make_pair(x,w));
	}
	dij(s,d,e);
	dij(t,d2,e2);
	for(int i=n; i>=1; i--){
		res[i] = d[i] + d2[i];
		if(i<n && res[i] > res[i+1])
			res[i] = res[i+1];
	}
	for(int i=1; i<=n; i++)
		printf("%lld\n",((i64)1e15) - res[i]);
	return 0;
}


Measured memory_bytes: 16884
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

a,b,c,d = li()

on = [0]*101

for i in range(101):
    if a <= i <= b and c <= i <= d:
        on[i] += 1
        
print(max(sum(on)-1, 0))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 #include <string> 
 #include <math.h>
 #include <bitset>
 #include <numeric>
 #include <stdio.h>
 #include <algorithm>

 using namespace std;

 int main(){
    int N;
    int i,j;
    int cnt = 0;
    
    cin >> N;
     for (i=1; i*i<N; i++){
         for (j=i; j<N; j++){
             if(i*j<N){  
                if(i==j)
                    cnt++;
                else
                    cnt=cnt+2;
             }
            if(i*j>=N)
                break;
         }
     }
     
    cout << cnt << endl;

    return 0;
 }
 

Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <sstream>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define SZ(x) (int)(x.size())
#define F0(i,n) for(int i=0;i<n;i++)
#define F1(i,n) for(int i=1;i<=n;i++)
#define CL(a,x) memset(x, a, sizeof(x));
const int MOD = 1000000007;
const double pi = atan(1.0)*4.0;
const double eps = 1e-8;
ll gcd(ll x, ll y) { return y ? gcd(y, x%y) : x; }
int bc(int n) { return n ? bc((n-1)&n)+1 : 0; }

int i, j, k, m, n, l, X, Y, Z;
int a[100005], b[100005], c[100005];
ll ans, mans;



int main() {

    cin >> X >> Y >> Z;
    n = X + Y + Z;

    vector<pii> diff;
    set<pii> as;
    set<pii> bs;
    set<int> A;
    set<pii> B;
    
    F0(i, n) {
        cin >> a[i] >> b[i] >> c[i];
        a[i] -= c[i];
        b[i] -= c[i];
        ans += c[i];
        as.insert(pii(-a[i], i));
        diff.push_back(pii(a[i] - b[i], i));
    }
    
    sort(diff.begin(), diff.end());
    int at = 0;
    
    int x = 0, y = 0;
    while (1) {
        // fill
        while (SZ(A) < X && !as.empty()) {
            int j = as.begin()->second;
            A.insert(j);
            as.erase(as.begin());
            ans += a[j];
        }
        while (SZ(B) < Y && !bs.empty()) {
            int j = bs.begin()->second;
            B.insert(pii(b[j], j));
            bs.erase(bs.begin());
            ans += b[j];            
        }
        
        while (SZ(B) && SZ(bs) && B.begin()->first < -bs.begin()->first) {
            int j = B.begin()->second;
            B.erase(B.begin());
            ans -= b[j];  
            bs.insert(pii(-b[j], j));
            j = bs.begin()->second;
            B.insert(pii(b[j], j));
            ans += b[j];
            bs.erase(bs.begin());
        }
        
        if (SZ(A) == X && SZ(B) == Y) {
            mans = max(mans, ans);
        }
        if (at == SZ(diff)) break;
        
        int j = diff[at].second;
        if (A.count(j)) {
            A.erase(A.find(j));
            ans -= a[j];
        } else {
            as.erase(as.find(pii(-a[j], j)));
        }
        bs.insert(pii(-b[j], j));
        at++;
    }
    cout << mans << endl;
 
    return 0;
}

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

int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    ll arr[n+5];
    ll frr[m+5];
    for(int i=0;i<n;i++)cin>>arr[i];
    for(int i=0;i<m;i++)cin>>frr[i];

   ll mn=0;

   for(int i=1;i<n;i++)arr[i]+=arr[i-1];
   for(int i=1;i<m;i++)frr[i]+=frr[i-1];

   for(ll i=0;i<n;i++)
   {
       if(arr[i]<=k)mn=max(mn,i+1);
       ll sum=k-arr[i];
       if(sum<=0)continue;

       int l=0,r=m-1;

       while(l<=r)
       {
           ll mid=(l+r)/2;
           if(frr[mid]+arr[i]<=k)
           {
               mn=max(i+mid+2,mn);
               l=mid+1;
           }
           else r=mid-1;
       }

   }

    for(ll i=0;i<m;i++)
   {
       if(frr[i]<=k)mn=max(mn,i+1);
       ll sum=k-frr[i];
       if(sum<=0)continue;

       int l=0,r=n-1;

       while(l<=r)
       {
           ll mid=(l+r)/2;
           if(arr[mid]+frr[i]<=k)
           {
               mn=max(i+mid+2,mn);
               l=mid+1;
           }
           else r=mid-1;
       }

   }

   cout<<mn<<endl;
}


Measured memory_bytes: 6756
#include<stdio.h>
int main(){
    int a, b, c, d, e;
    scanf("%d %d %d %d %d", &a, &b, &c, &d, &e);
    int higher = 10;
    int nums[]={a,b,c,d,e};
    int sum;
    for(int i=0;i<5;i++){
        if(nums[i]%10!=0){
            if(nums[i]%10<higher)higher = nums[i]%10;
            sum += nums[i]+10-nums[i]%10;
        }else{
            sum += nums[i];
        }
    }
    if(higher!=10)sum +=-10+higher%10;
    printf("%d\n", sum);
    return 0;
} 

Measured memory_bytes: 128
N=int(input())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
C=[int(i) for i in input().split()]
ans=sum(B)
for s in range(N-1):
        if A[s+1]==A[s]+1:
            ans+=C[A[s]-1]
print(ans)
    

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

int main(void)
{
  int num;
  int blood_num[4] = {0};
  string blood;
  char c;
  
  while(cin >> num >> c >> blood)
    {
      if(blood == "A") blood_num[0]++;
      if(blood == "B") blood_num[1]++;
      if(blood == "AB") blood_num[2]++;
      if(blood == "O") blood_num[3]++;
    }
  for(int i = 0 ; i < 4 ; i++)
    {
      cout << blood_num[i] << endl;
    }
  return 0;
}

  

Measured memory_bytes: 0
import itertools

N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
l = []
a = 0
b = 0
for i in itertools.permutations(range(1,N+1)):
    l.append(list(i))

for j in l:
    if j == P:
        a = l.index(j)+1
    if j == Q:
        b = l.index(j)+1
print(abs(a-b))

Measured memory_bytes: 14500
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const long double inf = 1e18;
long double n;

int main(){
	cin>>n;
	vector<long double> vec(n, 0);
	bool zero = false;
	for(int i = 0; i < n; ++i){
		ll a;
		cin>>a;
		vec[i] = a;
		if(a == 0){
			zero = true;
		}
	}
	if(zero){
		cout<<0<<endl;
		return 0;
	}
	else{
		long double s = 1;
		for(auto x : vec){
			if(x * s <= inf)s *= x;
			else{
				s = -1;
			}
		}
		if(s == 0){
			std::cout<<0<<endl;
		}
		else if(s <= inf && s >= 0){
			std::cout<<setprecision(18)<<(long long)s<<endl;
		}
		else{
			std::cout<<-1<<endl;
		}
	}
	return 0;
}
//2 1000000000 1000000001


Measured memory_bytes: 4908
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    public class Program
    {

        public int counter { get; set; }

        public static void Main(string[] args)
        {
            Program p = new Program();
            var n = int.Parse(System.Console.ReadLine());
            int[] aList = System.Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var allEven = true;

            p.counter = 0;
            var result = p.Divide2(n, aList, allEven, p.counter);

            System.Console.WriteLine(result.ToString());


        }

        /// <summary>
        /// 引数が偶数か奇数か判定
        /// 偶数　→　true
        /// </summary>
        /// <param name="_number"></param>
        /// <returns></returns>
        public bool OddOrEven(int _number)
        {
            if (_number % 2 == 0) return true;
            else return false;
        }

        /// <summary>
        ///  aListを２で割る
        /// </summary>
        /// <param name="_n"></param>
        /// <param name="_aList"></param>
        /// <param name="_allEven"></param>
        /// <param name="_counter"></param>
        /// <returns></returns>
        public int Divide2(int _n, int[] _aList, bool _allEven, int _counter)
        {
            for (int i = 0; i < _n; i++)
            {
                if (!OddOrEven(_aList[i]))
                {
                    _allEven = false;
                    break;
                }
            }
            if (_allEven)
            {
                for (int i = 0; i < _n; i++)
                {
                    _aList[i] = _aList[i] / 2;
                }
                counter = counter + 1;
                Divide2(_n, _aList, _allEven, counter);
            }

            return counter;
        }


    }
}


Measured memory_bytes: 13380
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vec,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int main(){
    int q=in();
    ll tmp=0,sum1=0,sum2=0;
    int mid=INT_MAX;
    pq q1;
    pqg q2;
    rep(i,q){
        if(in()==1){
            int x=in();
            tmp+=in();
            if((mid==INT_MAX)&q1.empty()&q2.empty()){
                mid=x;
                continue;
            }
            if(mid==INT_MAX){
                if(q2.top()<x){
                    sum2-=mid=q2.top();
                    q2.pop();
                    q2.push(x);
                    sum2+=x;
                }else if(q1.top()<=x){
                    mid=x;
                }else{
                    sum1-=mid=q1.top();
                    q1.pop();
                    q1.push(x);
                    sum1+=x;
                }
            }else{
                if(mid<x){
                    q1.push(mid);
                    sum1+=mid;
                    q2.push(x);
                    sum2+=x;
                }else{
                    q2.push(mid);
                    sum2+=mid;
                    q1.push(x);
                    sum1+=x;
                }
                mid=INT_MAX;
            }
        }else{
            if(mid==INT_MAX)cout<<q1.top()<<" "<<-sum1+sum2+tmp<<endl;
            else cout<<mid<<" "<<-sum1+sum2+tmp<<endl;
        }
    }
}


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

 
int main() {
  vector<int> vec(3);
    for (int i = 0; i < 3; i++) {
    cin >> vec.at(i);
}

 sort(vec.begin(),vec.end());
  
  cout << vec.at(0)+vec.at(1)<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    long int i, n, min=1000001, max=-1000001, sum=0;
    scanf("%ld", &n);
    int a[n];
    for(i=0;i<n;i++){
        scanf("%ld",&a[i]);
    }
    for(i=0;i<n;i++){
        if(a[i]<min) min = a[i];
        if(a[i]>max) max = a[i];
        sum = sum + a[i];
    }
    printf("%ld %ld %ld\n", min, max, sum);
    return 0;
}



Measured memory_bytes: 2136
#define _CRT_SECURE_NO_WARNINGS
#define y1 klfjvkldfngldf

#pragma comment(linker, "/STACK:400000000")

#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <complex>
#include <functional>
#include <numeric>
#include <random>
#include <memory.h>
#include <time.h>

using namespace std;

typedef long long LL;

void go(string & s)
{
	int prev = -1;
	int now = 0;
	while (now != -1 && now != s.size())
	{
		if (prev < now)
		{
			if (s[now] == 'A')
			{
				s[now] = 'B';
				prev = now;
				now--;
			}
			else
			{
				s[now] = 'A';
				prev = now;
				now++;
			}
		}
		else
		{
			if (s[now] == 'A')
			{
				s[now] = 'B';
				prev = now;
				now++;
			}
			else
			{
				s[now] = 'A';
				prev = now;
				now--;
			}
		}
	}
}

char f(char c, bool inv)
{
	if (!inv)
		return c;
	return c == 'A' ? 'B' : 'A';
}

string solve(string s, int k)
{
	int n = s.size();
	int pos = 0;
	bool inv = 0;
	while (pos < n && k > 0)
	{
		k--;
		if (f(s[pos], inv) == 'A')
		{
			s[pos] = f('B', inv);
			continue;
		}

		inv ^= 1;
		pos++;
	}

	string res = "";
	if (k > 0)
	{
		if (n & 1)
		{
			res += f('A', k & 1);
			for (int i = 1; i < n; ++i)
				res += f('A', (i & 1));
		}
		else
		{
			for (int i = 0; i < n; ++i)
				res += f('B', (i & 1));
		}
	}
	else
	{
		while (pos < s.size())
			res += f(s[pos++], inv);
		while (res.size() < n)
		{
			if ((n - res.size()) & 1)
				res += 'A';
			else
				res += 'B';
		}
	}
	return res;
}

int main()
{
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	cout << solve(s, k) << endl;
	return 0;
}

Measured memory_bytes: 1160
if __name__ == "__main__":
    n, x, y = map(int, input().split())
    x -= 1
    y -= 1

    ans = [0] * (n+1)
    for start in range(n):
        for end in range(start + 1, n):
            if (start < x and end < x) or (start > y and end > y):
                ans[end - start] += 1
            
            elif start < x and end >= x and end <= y:
                tmp = x - start
                tmp += min(end - x, y - end + 1)
                ans[tmp] += 1
            
            elif start >= x and start <= y and end > y:
                tmp = end - y
                tmp += min(start - x + 1, y - start)
                ans[tmp] += 1
            
            elif start < x and end > y:
                tmp = x - start + end - y + 1
                ans[tmp] += 1
            
            else:
                ans[min(end - start, start - x + y - end + 1)] += 1
    
    for i in range(1, n):
        print(ans[i])

Measured memory_bytes: 3444
w,h,n=map(int,input().split())
lx,ly,ux,uy=0,0,w,h
for i in range(n):
    x,y,a=map(int,input().split())
    if a == 1:
        lx=max(lx,x)
    elif a == 2:
        ux=min(ux,x)
    elif a == 3:
        ly=max(ly,y)
    else:
        uy=min(uy,y)
if ux < lx or uy < ly: print(0)
else: print((ux-lx)*(uy-ly))

Measured memory_bytes: 3064
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));



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

	int N, A, B, ma=0;
	cin >> N >> A >> B;
	int C = A - B;
	VI H(N);
	REP(i, N) {
		cin >> H[i];
		ma = max(ma, H[i]);
	}
	int L = 0, R = (ma-1) / B + 1;
	while (R-L>1) {
		int M = L + (R - L) / 2;
		//cout << L << " " << R << endl;
		int cnt = 0;
		REP(i, N) {	
			if (H[i] - M * B > 0) {
				cnt += (H[i] - M * B - 1) / (A - B) +1;
			}
			
		}
		//cout << cnt << endl;
		if (cnt > M) {
			L = M;
		}
		else {
			R = M;
		}
	}
	//cout << L <<" "<< R << endl;
	int cnt = 0;

	REP(i, N) {
		if (H[i] - L * B > 0) {
			cnt += (H[i] - L * B - 1) / (A - B)+1;
		}
	}
	//cout << cnt << endl;
	if (cnt > L) {
		cout << R << endl;
	}
	else {
		cout << L << endl;
	}
	return 0;
}



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

int main(){
    int n,ans=0,w,h;
    cin >> w >> h >> n ;
    int a,b,q;
    int sq[w][h];
    for(int x=0;x<w;x++){
            for(int y=0;y<h;y++){
                sq[x][y]=0;
            }
    }
    for(int i=0;i<n;i++){

        cin >> a >> b >> q;

        for(int x=0;x<w;x++){
            for(int y=0;y<h;y++){

                if(q==1){
                    if(x<a){sq[x][y]=1;}
                }
                if(q==2){
                    if(x>=a){sq[x][y]=1;}
                }
                if(q==3){
                    if(y<b){sq[x][y]=1;}
                }
                if(q==4){
                    if(y>=b){sq[x][y]=1;}
                }

            }
        }

    }

    for(int x=0;x<w;x++){
        for(int y=0;y<h;y++){
            if(sq[x][y]==0){
                ans++;
            }
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion
template <typename T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

vector<int> dp;
vector<int> h;
#define INF INT32_MAX
int hop(int i)
{
    if (dp[i] < INF)
        return dp[i];
    if (i == 0)
        return 0;

    int optimal = INF;
    chmin(optimal, hop(i - 1) + abs(h[i] - h[i - 1]));
    if (i > 1)
        chmin(optimal, hop(i - 2) + abs(h[i] - h[i - 2]));

    return dp[i] = optimal;
}

int main()
{
    int n;
    cin >> n;
    h = vector<int>(n);
    dp = vector<int>(n + 1, INF);
    rep(i, n) cin >> h[i];

    int ans = hop(n - 1);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int aa = c/b,bb=a/d;
    if(c%b!=0)
        aa++;
    if(a%d!=0)
        bb++;
    if(aa<=bb)
        cout<<"Yes";
    else
        cout<<"No";
}



Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n, m, l, r, a = 0, b = 100001;
	cin >> n >> m;
	for (int h = 1; h <= m; h++) {
		cin >> l >> r;
		a = max(a, l);
		b = min(b, r);
	}
	if ((b - a + 1) < 0) { cout << '0' << endl; }
	else { cout << b - a + 1 << endl; }
	cin >> n;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const double PI=3.14151926535;
const ll INFl=(ll)9223372036854775807/2;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
const ll tMOD=(ll)998244353;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
int a[100100];
int t[3];

ll ans=1;
int main(){
	cin>>n;
	REP(i,n)cin>>a[i];
	REP(i,n){
		ll c=0;
		for(int j=0;j<3;j++){
			if(t[j]==a[i])c++;
		}
		ans*=c;
		for(int j=0;j<3;j++){
			if(t[j]==a[i]){
				t[j]++;
				break;
			}
		}
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <valarray>
#include <cstdio>
using namespace std;
typedef valarray<int>V;
int N,M,A,B,C,T;
V mul(const V &a, const V &b){
	V c(N*N);
	int i=0,j;
	for(;i<N;i++)for(j=0;j<N;j++)c[i*N+j]=(a[slice(i*N,N,1)]*b[slice(j,N,N)]).sum()%M;
	return c;
}
V exp(const V &a, const int n){
	if(n==1)return a;
	if(n&1)return mul(exp(a,n-1),a);
	V b=exp(a,n>>1);
	return mul(b,b);
}
V s,x;
void output(const V &r){
int i=0;
	for(i=0;i<N-1;i++)printf("%d ",(r[slice(i*N,N,1)]*s).sum()%M);
	printf("%d\n",(r[slice(i*N,N,1)]*s).sum()%M);
}
main(){
	int i;
	for(;scanf("%d%d%d%d%d%d",&N,&M,&A,&B,&C,&T),N;){
		s.resize(N);
		for(i=0;i<N;i++)scanf("%d",&s[i]);
	x.resize(0);
	x.resize(N*N);
	int i;
	if(T){
		x[0]=B;
		x[1]=C;
		for(i=1;i<N-1;i++){
			x[i*N+i-1]=A;
			x[i*N+i]=B;
			x[i*N+i+1]=C;
		}
		x[i*N+i-1]=A;
		x[i*N+i]=B;
		output(exp(x,T));
	}else{
		for(i=0;i<N;i++)x[i*N+i]=1;
		output(x);
	}

	}
}

Measured memory_bytes: 1084
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

LL dp[1005][1005];

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

    int h, w;
    cin >> h >> w;
    bool canvisit[1005][1005];
    for( int i = 1; i <= h; ++i ) {
        for( int j = 1; j <= w; ++j ) {
            char a;
            cin >> a;
            if( a == '.' ) {
                canvisit[i][j] = true;

            } else {
                canvisit[i][j] = false;

            }
        }
    }

    for( int i = 1; i <= h; ++i ) {
        for( int j = 1; j <= w; ++j ) {
            if( i == 1 || j == 1 ) {
                if( i == j ) {
                    dp[i][j] = 1;

                } else if( i == 1 ) {
                    if( canvisit[i][j] ) {
                        dp[i][j] = dp[i][j - 1];

                    } else {
                        dp[i][j] = 0;

                    }
                } else {
                    if( canvisit[i][j] ) {
                        dp[i][j] = dp[i - 1][j];

                    } else {
                        dp[i][j] = 0;

                    }
                }
            } else {
                if( canvisit[i][j] ) {
                    dp[i][j] = ( dp[i - 1][j] + dp[i][j - 1] ) % MOD;

                } else {
                    dp[i][j] = 0;

                }
            }
        }
    }
    cout << dp[h][w] << endl;

    return 0;
}



Measured memory_bytes: 9088
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
static const int inf = 1 << 30;

/**
* 最大公約数をa,bから求める
* @param [in] a 正整数
* @param [in] b 正整数
* @return 最大公約数
*/
template <typename TypeInt>
TypeInt G_C_D(TypeInt a, TypeInt b)
{
  if (a < 0)
    a = -a;
  if (b < 0)
    b = -b;
  while (b != 0)
  {
    a %= b;
    if (a == 0)
      return b;
    b %= a;
  }
  return a;
}

/**
* 最大公約数をa,b,...から求める
* @param [in] list 2つ以上の正整数
* @return 最大公約数
*/
template <typename TypeInt>
TypeInt G_C_D(const std::vector<TypeInt> &list)
{
  if (list.size() < 2)
    throw "内容が1以下\n";

  TypeInt a = list[0];
  for (size_t i = 1; i < list.size(); ++i)
  {
    a = G_C_D(a, list[i]);
  }
  return a;
}

int main(void)
{
  long long N, X;
  cin >> N >> X;
  vector<long long> d;
  REP(i, N)
  {
    long long a;
    cin >> a;
    d.push_back(abs(a - X));
  }
  if (N == 1)
  {
    cout << abs(d[0]) << endl;
  }
  else
  {
    cout << G_C_D(d) << endl;
  }
}

Measured memory_bytes: 1400
#include <stdio.h>  
#include <string.h>  
#include <stdlib.h>  
#include <iostream>  
#include <algorithm>  
#include <time.h>  
#include<cstdio>
#include<vector>
#include<functional>


using namespace std;

int main() {
	int A, B;
	scanf("%d%d", &A, &B);
	if ((A + B) >= 10) {
		printf("error");
	}
	else {
		printf("%d", A + B);
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Main
 */
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] d = new int[K];
        int[] A = new int[N];
        int tmp;

        for(int i=0; i<K; i++){
            d[i] = sc.nextInt();
            for(int j=0; j<d[i]; j++){
                tmp = sc.nextInt();
                A[tmp-1] = 1;
            }
        }

        int count = 0;
        for(int i=0; i<N; i++){
            if(A[i]==0){
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 37476
#include<bits/stdc++.h>
#include<unordered_map>
#define ll long long
#define M 1000000007
#define pb push_back
#define fs first
#define se second
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    vector<ll>arr(n+2,0),st(n+1,0);
    for(ll i=1;i<=n;i++)
        {cin>>arr[i];
            st[i]=arr[i];
            st[i]+=st[i-1];
        }
    ll dp[n+2][n+2];
    for(ll i=1;i<=n;i++)
        {for(ll j=i;j<=n;j++)
            {
                // ll sum=st[n];
                ll left=st[i-1],right=st[n]-st[j];
                dp[i][j]=left+right;
                // cout<<dp[i][j]<<" ";
            }
            // cout<<endl;
        }

    ll ans=0;
    for(ll i=1;i<=n;i++)
        for(ll j=i;j<=n;j++)
        {
            ll r=i-1+(n-j);
            ll cut=n-r;
            priority_queue<ll,vector<ll>,greater<ll>>pq;
            if(r<=k)
            {
                r=k-r;
                ll tmp=dp[i][j];
                for(ll p=1;p<i;p++)
                    pq.push(arr[p]);
                for(ll p=j+1;p<=n;p++)
                    pq.push(arr[p]);
                while(!pq.empty() && r-- && pq.top()<0)
                {
                    tmp-=pq.top();
                    pq.pop();
                }

                ans=max(ans,tmp);
                // cout<<ans<<" "<<i<<" "<<j<<endl;
            }
        }
        if(n<=k)
            ans=max(ans,st[n]);
        cout<<ans<<endl;

}

// mongodb
// elasticsearch
// micron modules



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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <LL,LL>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

LL n,t,x,y,dp[200010][40],ans=0;
vector <pii> v;
vector <LL> vv;

bool cmp(pii a,pii b)
{
	return b.fi*(a.se+1)<a.fi*(b.se+1);
}

int main()
{
	cin>>n>>t;
	rep(i,n)
	{
		cin>>x>>y;
		if(x>0) v.pb(mpr(x,y));
		else vv.pb(y);
	}
	sort(v.begin(),v.end(),cmp);
	sort(vv.begin(),vv.end());
	for(int i=1;i<vv.size();i++) vv[i]=vv[i-1]+vv[i]+1;
	rep(i,200005) rep(j,38) dp[i][j]=1e18;
	dp[0][0]=0;
	rep(i,v.size())
	{
		rep(j,35)
		{
			if(dp[i][j]==1e18) continue;
			dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
			if(dp[i][j]+1+v[i].fi*(dp[i][j]+1)+v[i].se<=t)
			dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]+1+v[i].fi*(dp[i][j]+1)+v[i].se);
		}
	}
	rep(i,35)
	{
		if(dp[v.size()][i]==1e18) continue;
		ans=max(ans,i+(LL)(upper_bound(vv.begin(),vv.end(),t-dp[v.size()][i]-1)-vv.begin())-1+1);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 66796
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	std::string s,t;
	std::cin >> s >> t;
	int count = 0;
	rep(i,3) if(s[i]==t[i]) count++;
	print(count);
	return 0;
}


Measured memory_bytes: 256
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int dist[202][202],n,ans=0;
vector<int> adj[2020];
string s[202];

bool checkb(){

//https://cp-algorithms.com/graph/bipartite-check.html

vector<int> side(n, -1);
bool is_bipartite = true;
queue<int> q;
for (int st = 0; st < n; ++st) {
    if (side[st] == -1) {
        q.push(st);
        side[st] = 0;
        while (!q.empty()) {
            int v = q.front();
            q.pop();
            for (int u : adj[v]) {
                if (side[u] == -1) {
                    side[u] = side[v] ^ 1;
                    q.push(u);
                } else {
                    is_bipartite &= side[u] != side[v];
                }
            }
        }
    }
}
return is_bipartite;
}

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
	
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> s[i];
		for(int j=0;j<n;j++){
			if(s[i][j]=='1'){
				adj[i].pb(j);
				dist[i][j]=1;
			}
			else {
				dist[i][j]=inf;
			}
		}
	}
	if(!checkb()){
		cout << -1 << endl;
		return 0;
	}
	for(int k=0;k<n;++k) {
  for(int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]); 
    }
  }
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(i==j)continue;
			ans=max(ans,dist[i][j]);
		}
	}
	cout << ans+1 << endl;

return 0;
}
///....


Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define double long double
//↓TLE,MLE魔!!!
#define int long long
//↑TLE,MLE魔!!!
#define inf 1000000007 //10^9+7
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int a[114514],cnt[114514];
signed main() {
	int n,memo=0,ans=0;
	cin>>n;
	rep(i,n)cin>>a[i];
	rep(i,n)cnt[a[i]-1]++;
	rep(i,114514){
		if(cnt[i]>1)ans+=cnt[i]-1;
		if(cnt[i]>=1)memo++;
	}
	cout<<memo-ans%2<<endl;
}


Measured memory_bytes: 1792