akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class UnionFind {
	vector<int> data;
	public:
	int independentSet;
	UnionFind(int size) : data(size, -1), independentSet(size) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
			independentSet--;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

//0-indexed
template <class T>
class SegmentTree
{
	int size;
	T def;
	vector<T> data;
	function<T(T, T)> f;

public:
	SegmentTree<T>(int _size, T _def, function<T(T, T)> _f) : f(_f), def(_def), size(1)
	{
		while (size < _size)
			size <<= 1;
		data = vector<T>(size * 2, def);
	}
	//bottom-up implementation
	//query for[l, r)
	T query(int l, int r)
	{
		T L = def, R = def;
		for (l += size, r += size; l < r; l >>= 1, r >>= 1)
		{
			if (l & 1)
				L = f(L, data[l++]);
			if (r & 1)
				R = f(data[--r], R);
		}
		return f(L, R);
	}
	void update(int idx, T val)
	{
		idx += size;
		data[idx] = val;
		while (idx > 1)
		{
			idx >>= 1;
			data[idx] = f(data[2 * idx], data[2 * idx + 1]);
		}
	}
	T operator[](int idx)
	{
		return data[idx + size];
	}
};



class Solution {
public:
	void solve() {
		int n, k;
		cin >> n >> k;
		vector<int> p(n, 0), a(n, 1);
		SegmentTree<int> stmin(n, 1e9, [](int a, int b){return min(a, b);});
		SegmentTree<int> stmax(n, 0, [](int a, int b){return max(a, b);});
		UnionFind uf(n-k+1);
		for(int i=0; i<n; i++)cin >> p[i];
		for(int i=0; i < n; i++)stmin.update(i, p[i]);
		for(int i=0; i < n; i++)stmax.update(i, p[i]);
		// sorted segment
		int cnt = 1;
		int sorted = -1;
		for(int i=0; i < n; i++){
			if(p[i-1] > p[i])cnt = 0;
			cnt++;
			if(cnt >= k){
				if(sorted == -1)sorted = i-k+1;
				uf.unionSet(sorted, i-k+1);
			}
		}
		// overlapped segment
		for(int i=0; i<n-k; i++){
			int qmin = stmin.query(i+1, i+k);
			int qmax = stmax.query(i+1, i+k);
			if((p[i] < qmin) && (p[i+k] > qmax)){
				uf.unionSet(i, i+1);
			}
		}
		cout << uf.independentSet << "\n";
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 6656
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define double long double
using namespace std;
const ll inf = 1000000000000000000;

ll n, a[1000005], x;
set<ll> myset;
bool f = true;
bool is_prime(ll x) {
    if (x <= 1)
        return false;
    for (ll i = 2; i <= (ll)sqrt(x); ++i)
        if (x % i == 0)
            return false;
    return true;
}
void factorize(ll x) {
    if (!f)
        return;
    ll tec = 1;
    if (is_prime(x)) {
        if (myset.find(x) != myset.end())
            f = false;
        myset.insert(x);
        return;
    }
    bool flag;
    while (x > 1) {
        ++tec;
        flag = false;
        while (x % tec == 0) {
            flag = true;
            x /= tec;
        }
        if (flag) {
            if (myset.find(tec) != myset.end())
                f = false;
            myset.insert(tec);
            if (is_prime(x)) {
                if (myset.find(x) != myset.end())
                    f = false;
                myset.insert(x);
                return;
            }
        }
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (ll i = 1; i <= n; ++i)
        cin >> a[i];
    x = a[1];
    for (ll i = 2; i <= n; ++i) {
        x = __gcd(a[i], x);
    }
    for (ll i = 1; i <= n; ++i)
        factorize(a[i]);
    if (f) {
        cout << "pairwise coprime";
        return 0;
    }
    if (!f && x == 1) {
        cout << "setwise coprime";
        return 0;
    }
    cout << "not coprime";
    return 0;
}


Measured memory_bytes: 11344
#include <limits>
#include <vector>
#include <algorithm>

template<typename Type> class RangeAddMaxSegmentTree {
private:
	unsigned size_; std::vector<Type> dat1, dat2;
	inline void update_(unsigned a, unsigned b, Type x, unsigned k, unsigned l, unsigned r) {
		if (r <= a || b <= l) return;
		if (a <= l && r <= b) {
			dat2[k] += x; return;
		}
		update_(a, b, x, (k << 1), l, (l + r) >> 1);
		update_(a, b, x, (k << 1) + 1, (l + r) >> 1, r);
		dat1[k] = std::max(dat1[k << 1] + dat2[k << 1], dat1[(k << 1) + 1] + dat2[(k << 1) + 1]);
	}
	inline Type query_(unsigned a, unsigned b, unsigned k, unsigned l, unsigned r) {
		if (r <= a || b <= l) return std::numeric_limits<Type>::min();
		if (a <= l && r <= b) return dat1[k] + dat2[k];
		Type lc = query_(a, b, (k << 1), l, (l + r) >> 1);
		Type rc = query_(a, b, (k << 1) + 1, (l + r) >> 1, r);
		return std::max(lc, rc) + dat2[k];
	}
public:
	RangeAddMaxSegmentTree() : size_(0), dat1(std::vector<Type>()), dat2(std::vector<Type>()) {};
	RangeAddMaxSegmentTree(int size__) {
		for (size_ = 1; size_ < size__; ) size_ <<= 1;
		dat1.resize(size_ << 1, 0);
		dat2.resize(size_ << 1, 0);
	}
	inline unsigned size() { return size_; }
	inline void add(unsigned i, Type x) {
		update_(i, i + 1, x, 1, 0, size_);
	}
	inline void add(unsigned l, unsigned r, Type x) {
		update_(l, r, x, 1, 0, size_);
	}
	inline Type query(unsigned l, unsigned r) {
		return query_(l, r, 1, 0, size_);
	}
};

#include <vector>
#include <iostream>
using namespace std;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	vector<vector<pair<int, int> > > G(N);
	for (int i = 0; i < M; ++i) {
		int L, R, A;
		cin >> L >> R >> A;
		G[R - 1].push_back(make_pair(L - 1, A));
	}
	RangeAddMaxSegmentTree<long long> dp(N + 1);
	for (int i = 0; i < N; ++i) {
		dp.add(i + 1, dp.query(0, i + 1));
		for (pair<int, int> j : G[i]) {
			dp.add(j.first + 1, i + 2, j.second);
		}
	}
	long long ans = dp.query(0, N + 1);
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 19456
#include <iostream>
#include <algorithm>
#include <array>
#include <atomic>
#include <bitset>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include <cmath>
using namespace std;

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

template<class T, class U> inline bool chmax(T& a, U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a, U b) { if (a > b) { a = b; return 1; } return 0; }

// 第一引数 == 第二引数 ? true : false
template<class T, class U>
bool check(T first, U second) {
    return (first == second);
}

// 約数列挙
vector<int64_t> divisor(int64_t n) {
  vector<int64_t> ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}


// 数字和
template<class T>
T digitSum(T num) {
    T dig;
    T sum = 0;
    while (num) {
        dig = num % 10;
        sum += dig;
        num /= 10;
    }
    return sum;
}

string background_black(string s) { return "\x1b[40m" + s; }
string background_red(string s) { return "\x1b[41m" + s + "\x1b[40m"; }
string background_green(string s) { return "\x1b[42m" + s + "\x1b[40m"; }
string background_yellow(string s) { return "\x1b[43m" + s + "\x1b[40m"; }
string background_bleu(string s) { return "\x1b[44m" + s + "\x1b[40m"; }
string background_white(string s) { return "\x1b[47m" + s + "\x1b[40m"; }

string black(string s) { return "\x1b[30m" + s + "\x1b[37m"; }
string red(string s) {return "\x1b[31m" + s + "\x1b[37m"; }
string green(string s) { return "\x1b[32m" + s + "\x1b[37m"; }
string yellow(string s) { return "\x1b[33m" + s + "\x1b[37m"; }
string blue(string s) { return "\x1b[34m" + s + "\x1b[37m"; }
string white(string s) { return "\x1b[37m" + s + "\x1b[37m"; }

const int ten = 10;
const int hundred = 100;
const int thousand = 1000;

typedef long long ll;
typedef unsigned long long ull;

string tolower(string s) {
  string c;
  for (int i = 0; i < s.size(); i++) {
    if ((s[i] >= 'A') && (s[i] <= 'Z')) {
        c.push_back((s[i] + 0x20));
    } else {
        c.push_back(s[i]);
    }
  }
  return c;
}
#include <cstdlib>
string solve() {
  string str = "";
// int->string: to_string, string->int: stoi
//=============================================================================


  int n, d;
  cin >> n >> d;
  int i = 0;
  int ans;
  while(true) {
    i++;
    ans = n - (2*d+1)*i;
    if (ans <= 0) {
      str += to_string(i);
      break;
    }
  }


//=============================================================================
  str += "\n";
  return str;
}

int main() {	
  std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
  cout << solve() << endl;
}

Measured memory_bytes: 256
#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;

typedef pair<int,int> PII;
typedef long long int ll;
typedef pair< ll,ll> PLL;
typedef unsigned long long int ULL;
typedef pair<ULL,int> PUI;
#define S second
#define F first
typedef tree<
PLL,
null_type,
less<PLL>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;


PLL operator+(PLL a,PLL b){ return {a.first + b.first, a.second + b.second}; }
PLL operator-(PLL a,PLL b){ return {a.first - b.first, a.second - b.second}; }
PLL operator*(PLL a,PLL b){ return {a.first * b.first, a.second * b.second}; }
PLL operator/(PLL a,PLL b){ return {a.first / b.first, a.second / b.second}; }
PLL operator%(PLL a,PLL b){ return {( b.first + a.first) % b.first, (b.second + a.second) % b.second}; }
PLL operator%(PLL a,ll b){ return {a.first % b, a.second % b} ;}
PLL operator+(PLL a,ll b){ return {a.first + b, a.second + b} ;}
PLL operator-(PLL a,ll b){ return {a.first - b, a.second - b} ;}
PLL operator*(PLL a,ll b){ return {a.first * b, a.second * b} ;}

ostream& operator<<(ostream &out,PLL a)
{
    out << "( " << a.first << ", " << a.second << " )" ;
    return out;
}

ostream& operator<<(ostream &out,PUI a)
{
    out << "( " << a.first << ", " << a.second << " )" ;
    return out;
}
/*
	Order Statistics Tree ( OST )

	find_by_order()
		takes an integer k and returns an iterator to the k'th largest element counting from zero
	order_of_key()
		takes an element, here an integer and returns the number of elements strictly smaller than input
*/


int const MOD = 1e9 + 7;

int const N = 1e5 + 10;
bool mark[N] ;

void sieve()
{
    for(int i = 2; i < N; i++){
        if(!mark[i]){
            for(int j = 2 * i ; j < N; j += i) 
                mark[j] = 1;
        }
    }
}
ll dp[N][20];
string s;
ll DP(int pos,int mod)
{
    if(pos == s.size()) return (mod == 5);
    ll &ret = dp[pos][mod] ;
    if(ret != -1) return ret;
    ret = 0;
    
    if(s[pos] != '?'){
        ret = DP(pos+1,(mod*10 + (s[pos] - '0'))%13 );
    }
    else{
        for(int i =0; i < 10; i++){
            ret += DP(pos+1,(mod*10 + i) % 13 ) ;
            ret %= MOD;
        }
    }
    return ret;
}
int main()
{
    ios::sync_with_stdio(0); cin.tie(0);

    cin >> s;

    memset(dp,-1,sizeof dp);
    cout << DP(0,0) << endl;
    return 0;

}

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

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

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

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

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

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

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

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

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

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


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

	set<string> st;
	repn(i, N) {
		string S;
		cin >> S;
		st.insert(S);
	}

	cout << st.size() << endl;

	system("PAUSE");
}


Measured memory_bytes: 19268
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;


int main() {
    string S;
    int N, A, B, ok = 0, b = 1;
    cin >> N >> A >> B >> S;
    for (int i = 0; i < N; i++){
        if (S.at(i) == 'c'){
            cout << "No" << endl;
        }
        else if(S.at(i) == 'a'){
            if (ok < A + B){
                cout << "Yes" << endl;
                ok++;
            }
            else {
                cout << "No" << endl;
            }
        }
        else {
            if (b <= B && ok < A + B){
                cout << "Yes" << endl;
                ok++;
            }
            else {
                cout << "No" << endl;
            }
            b++;
        }
    }
}


Measured memory_bytes: 896
H, N = map(int, input().split())
inf =1000100001001000
dp = [inf for _ in range(H+1)]
 
# min_cost = np.inf
dp[0]=0
for n in range(N):
    a,b =  map(int, input().split())
    for h in range(H):
        nj = min(h+a,H)
        dp[nj] = min([dp[nj],dp[h]+b])
        
print(int(dp[H]))

Measured memory_bytes: 45148
N, A, B = gets.split.map &:to_i
MOD = 10**9+7

class Integer
  def pow(y, m)
    return 1 if y == 0
    res = self.pow(y/2, m)
    res * res % m * (y.odd? ? self : 1) % m
  end

  def comb(k, m)
    u = d = 1
    n = self
    (1..k).each{|i|
      u = u * n % m
      d = d * i % m
      n -= 1
    }
    u * d.pow(m - 2, m) % m
  end
end

p (2.pow(N, MOD) - 1 - N.comb(B, MOD) - N.comb(A, MOD)) % MOD


Measured memory_bytes: 3836
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    ll N;
    cin >> N;
    cout << N*(N-1)/2 << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    char[] s = S.toCharArray();
    int i = 0;
    int j = s.length-1;
    int ans = 0;
    
    while(i<j){
      if(s[i] != s[j]){
        ans++;
      }
      i++;
      j--;
    }
   
      System.out.println(ans);
    
  }  
}

Measured memory_bytes: 35680
n = int(input())
a = list(map(int, input().split()))

ans = 0

for i in range(2,n+1):
  a[-i] += a[-i+1]

for i in range(len(a)-1):
  ans = ans % 1000000007 + ((a[i] - a[i+1]) * a[i+1]) % 1000000007
    
print(ans % 1000000007)

Measured memory_bytes: 94220
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int N;
vector<int> G[5010];
int DP[5010][5010][2];
int TDP[5010][2];
int VSZ[5010];
int FACT[5010];

void dfs(int v,int pre)
{
	VSZ[v]=1;
	DP[v][1][0]=1;
	for(auto e:G[v])
	{
		if(e==pre)continue;
		dfs(e,v);

		rep(i,0,5010)rep(j,0,2)TDP[i][j]=0;
		rep(i,1,VSZ[v]+1)rep(pi,0,2)
		{
			rep(j,1,VSZ[e]+1)rep(pj,0,2)
			{
				TDP[i+j][(pi+pj)%2]=(TDP[i+j][(pi+pj)%2]+(DP[v][i][pi]*DP[e][j][pj])%MOD)%MOD;
				TDP[i][(pi+pj+1)%2]=(TDP[i][(pi+pj+1)%2]+(((DP[v][i][pi]*DP[e][j][pj])%MOD)*FACT[j-1])%MOD)%MOD;
			}
		}
		swap(DP[v],TDP);
		VSZ[v]+=VSZ[e];
	}
}

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

	cin>>N;
	int x,y;
	rep(i,0,N-1)
	{
		cin>>x>>y;
		x--,y--;
		G[x].push_back(y);
		G[y].push_back(x);
	}

	FACT[1]=1;
	rep(i,3,5010)
	{
		if(i%2==0)continue;
		FACT[i]=i*FACT[i-2];
		FACT[i]%=MOD;
	}

	dfs(0,-1);

	int ans=0;
	rep(i,0,N+1)
	{
		ans=(ans+(DP[0][i][0]*FACT[i-1])%MOD)%MOD;
		ans=(ans+MOD-(DP[0][i][1]*FACT[i-1])%MOD)%MOD;
	}

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


Measured memory_bytes: 392832
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
  

  int main(){
        lint n;
        cin >>n; vector<lint> a(n);
        map<lint,lint>mp;
        rep(i,n-1){cin >> a[i];
        mp[a[i]]++;
        }
        rep(i,n){
            cout<<mp[i+1]<<endl;
        }
  }
  
     


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

typedef long long ll;
typedef pair<int, int> ii;

int main()
{
    int n;
    char inp[100010];
    scanf("%d %s", &n, inp);

    int len = strlen(inp);
    for (int i = 0; i < len; i++)
        printf("%c", (inp[i] - 'A' + n) % 26 + 'A');
    printf("\n");

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int n,m;
  cin>>n>>m;
  bool ac[n] = {};
  int p[m];
  string s[m];
  int np[n] = {};
  REP(i,m){
    cin>>p[i]>>s[i];
    p[i]--;
    if(s[i] == "AC"){
      ac[p[i]] = true;
    }else{
      if(ac[p[i]])continue;
      np[p[i]]++;
    }
  }
  int ans = 0;
  int ans2 = 0;
  REP(i,n){
    if(ac[i]){
      ans++;
      ans2 += np[i];
    }
  }
  cout<<ans<<' '<<ans2<<endl;     
  return 0;
}


Measured memory_bytes: 6656
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int w, h;
		int x, y;
		while(true){
			x = 0;
			y = 0;
			w = sc.nextInt();
			h = sc.nextInt();
			if(w == 0 && h == 0)
				break;
			Game game = new Game(w, h);
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					game.map[i][j] = sc.nextInt();
					if(game.map[i][j] == 2){
						x = i;
						y = j;
					}
				}
			}
			game.search(x, y, 0);
			System.out.println(game.answer <= 10 ? game.answer : -1);
		}
	}
}
class Game{
	int answer = 11;
	int w, h;
	int[][] map;
	int[][] v = new int[][]{{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
	Game(int iw, int ih){
		w = iw;
		h = ih;
		map = new int[h][w];
	}
	void search(int x, int y, int k){
		if(k >= answer)
			return;
		int p, q;
		for(int i = 0; i < v.length; i++){
			p = x + v[i][0];
			q = y + v[i][1];
			if(p < 0 || p >= h || q < 0 || q >= w || map[p][q] == 1)
				continue;
			while(p >= 0 && p < h && q >= 0 && q < w){
				if(map[p][q] == 1){
					map[p][q] = 0;
					search(p-v[i][0], q-v[i][1], k+1);
					map[p][q] = 1;
					break;
				}
				if(map[p][q] == 3){
					if(k+1 < answer)
						answer = k + 1;
					break;
				}
				p += v[i][0];
				q += v[i][1];
			}
		}
		return;
	}
}

Measured memory_bytes: 36900
#include <iostream>
#include <stdlib.h>
#include <string>
#include <algorithm>

using namespace std;

int main(void){
    int N;

    cin >> N;

    int S[N+5];
    int sums = 0;

    for(int i=0;i<N+5;i++){
        S[i] = 0;
    }

    for(int i=0;i<N;i++){
        cin >> S[i];
        sums = sums + S[i];
    }
    if(sums % 10 != 0){
        cout << sums << endl;
        return 0;
    }
    else{
        sort(S, S+N+5);
        for(int i=0;i<N+5;i++){
            if(S[i] >0 and S[i] % 10 != 0){
                cout << sums - S[i] << endl;
                return 0; 
            }
        }
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

	int h, w, e, i, d, f;

	scanf("%d", &h);
	scanf("%d", &w);

	while (h != 0 && w != 0){

		for (e = 0; e<h; e++){

			for (i = 0; i<w; i++){

				
				
				if (e >= 1 && e <= h - 2 && i >= 1&&i<=w-2)
				{	
					
					printf(".");
				}
				else
				{
					printf("#");
				}
				
			}
			
			
			printf("\n");
		
		
		}
		printf("\n");
		scanf("%d", &h);
		scanf("%d", &w);
	}

	return 0;
}

Measured memory_bytes: 572
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void)
{
	int n;
	int q;
	int i;
	scanf("%d",&n);
	int s[n];
	for(i=0;i<n;i++)
	{
		scanf("%d",&s[i]);
	}
	scanf("%d",&q);
	int t[q];
	for(i=0;i<q;i++)
	{
		scanf("%d",&t[i]);
	}
	int j;
	int count=0;
	int count2;
	
	int left;
	int right;
	int mid;
	for(i=0;i<q;i++)
	{
		left =0;
		right = n;
		count2=0;
		while(left<right)
		{
			mid=(left+right)/2;
			if(s[mid]==t[i])
			{
				if(count2==0)
				{
					count++;
					break;
				}
			}
			else if (t[i]<s[mid])
			{
				right = mid;
			}
			else if(t[i]>s[mid])
			{
				left = mid +1;
			}
		}
	}
	printf("%d\n",count);
	return 0;
}



Measured memory_bytes: 2284
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int main(){
  int k,x;
  cin >> k >> x;
  FOR(i,x-k+1,x+k-1){
    cout << i;
    if (i == x+k-1)
      cout << endl;
    else
      cout << ' ';
  }
}

Measured memory_bytes: 256
//=======================//
// coder: Andy - Tohrumi //
    //=======================//
     
    #include <bits/stdc++.h>
     
    using namespace std;
     
    #define fastio ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
    #define ll long long
    #define ld long double
    #define mp make_pair
    #define pb emplace_back
    #define all(x) x.begin(), x.end()
    #define rep(i, a, b) for(__typeof(b) i = a; i < b; i++)
    #define Rep(i, a, b) for(__typeof(a) i = a; i > b; i--)
    #define int long long
     
    typedef vector<int> vi;		typedef vector<ll> vl;
    typedef pair<int, int> ii; 	typedef vector<ii> vii;
     
    // code start here //
     
    const int N = 200005;
    ll dp[N], a[N];
     
    signed main() {
    	fastio;
    	int n; cin >> n;
    	rep(i, 1, n + 1) cin >> a[i];
    	rep(i, 1, n + 1) dp[i] = dp[i - 1] + a[i];
    	ll ans = LLONG_MAX, val[4];
    	rep(i, 1, n + 1) {
    		int l = 1, r = i, p1 = 1, p2;
            while (l <= r) {
                int x = (l + r) / 2;
                if(dp[x] * 2 <= dp[i]) {
                    l = x + 1;
                    p1 = x;
                }
    			else {
                    r = x - 1;
                }
            }
            
            l = i + 1, r = n, p2 = i + 1;
            while (l <= r) {
                int x = (l + r) / 2;
                if ((dp[x] - dp[i]) * 2 <= dp[n] - dp[i]) {
                    l = x + 1;
                    p2 = x;
                }
    			else {
                    r = x - 1;
                }
            }
            for (int j = p1 - 5; j <= p1 + 5; j++){
                for (int k = p2 - 5; k <= p2 + 5; k++){
    				if (j <= i && i <= k) {
    					val[0] = dp[j];
    					val[1] = dp[i] - dp[j];
    					val[2] = dp[k] - dp[i];
    					val[3] = dp[n] - dp[k];
    					ans = min(*max_element(val, val + 4) - *min_element(val, val + 4), ans);
    				}
    			}
    		}
    	}
    	cout << ans << endl;
    }

Measured memory_bytes: 6764
#include <iostream>
using namespace std;
int up(int y){
	cout << "U";
	y++;
	return y;
}
int down(int y){
	cout << "D";
	y--;
	return y;
}
int left(int x){
	cout << "L";
	x--;
	return x;
}
int right(int x){
	cout << "R";
	x++;
	return x;
}
int main() {
	int sx,sy,tx,ty;
	cin >> sx >> sy >> tx >> ty;
	int curx=sx;
	int cury=sy;
	while (cury!=ty){
		cury=up(cury);
	}
	while (curx!=tx){
		curx=right(curx);
	}
	while (cury!=sy){
		cury=down(cury);
	}
	while (curx!=sx){
		curx=left(curx);
	}
	curx=left(curx);
	while (cury!=ty+1){
		cury=up(cury);
	}
	while (curx!=tx){
		curx=right(curx);
	}
	cury=down(cury);
	curx=right(curx);
	while (cury!=sy-1){
		cury=down(cury);
	}
	while (curx!=sx){
		curx=left(curx);
	}
	cury=up(cury);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
//#include<chrono>
//#include<time.h>
//#include<windows.h>
using namespace std;
 
//#define int ll
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
//static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
struct edge {int /*from,*/to,cost;};

int c[3][3];
int a[3],b[3];

void w(){
    
    REP(i,3) printf("%d ",a[i]);
    puts("");
    REP(i,3) printf("%d\n",b[i]);

}

signed main(){
    REP(i,3) REP(j,3) scanf("%d",&c[i][j]);

    REP(i,3) a[i] = b[i] = -INF;
    a[0] = b[0] = 0;

    bool rullonz = false;

    REP(i,2){
        REP(j,2){
            int cur = c[i][j];
            int m = c[i][j+1], s = c[i+1][j];
            bool x = false, y = false;
            if(a[j+1]==-INF) a[j+1] = m - cur,x=true;
            if(b[i+1]==-INF) b[i+1] = s - cur,y=true;
            if(x&&y) continue;

            if(a[j+1]!=m-cur) rullonz = true;
            if(b[i+1]!=s-cur) rullonz = true;
        }
    }

    REP(i,2){
        if(c[i+1][2]-c[i][2]!=b[i+1]) rullonz = true;
        if(c[2][i+1]-c[2][i]!=a[i+1]) rullonz = true;
    }

    puts(!rullonz?"Yes":"No");
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int64_t A, B, C;
  A = 2;
  B = 1;
  for(int i = 0;i < N - 1;i++){
    C = A + B;
    A = B;
    B = C; 
  }
  if(N == 0)C = 2;
  if(N == 1)C = 1;
  if(N == 2)C = 3;
  cout << C << endl;
}


Measured memory_bytes: 256
n = int(input())
b = list(map(int,input().split()))
count_m = 0
b_abs = [abs(b[i]) for i in range(n)]
for i in range(n):
  if b[i] < 0:
    count_m += 1
if count_m % 2 == 0:
  print(sum(b_abs))
else:
  b_min = min(b_abs)
  min_i = b_abs.index(b_min)
  if min_i == 0:
    print(sum(b_abs[1:]) - b_abs[0])
  elif min_i == n-1:
    print(sum(b_abs[:n-1]) - b_abs[n-1])
  else:
    print(sum(b_abs[0:min_i]+b_abs[min_i+1:]) - b_abs[min_i])
    

Measured memory_bytes: 14492
#include<iostream>
#include<vector>
using namespace std;
int main(){
int n,kazu;
char e;
cin>>n;
bool flag[4][13]={0};
for(int i=0;i<n;i++){
cin>>e>>kazu;
if(e=='S')flag[0][kazu-1]=1;
if(e=='H')flag[1][kazu-1]=1;
if(e=='C')flag[2][kazu-1]=1;
if(e=='D')flag[3][kazu-1]=1;
}
for(int i=0;i<4;i++){
for(int j=0;j<13;j++){
if(!(flag[i][j])){
if(i==0)cout<<'S';
if(i==1)cout<<'H';
if(i==2)cout<<'C';
if(i==3)cout<<'D';
cout<<" "<<j+1<<endl;
}
}
}
return 0;
}


Measured memory_bytes: 3088
#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;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> opset;
#define SZ(X) ((int)X.size())
#define ALL(I) I.begin(), I.end()
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define eps 1e-12
#define INF 1000000007
#define MXN 200005
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)

vector<int> v[MXN];
int n, m, fr, to;
int ot[MXN], bk[MXN], dep[MXN];
bool vis[MXN];

void dfs(int x, int pa){
	dep[x] = dep[pa] + 1;
	vis[x] = 1;
	for(auto i : v[x]){
		if(i == pa) continue;
		if(vis[i]){
			if(dep[i] < dep[x]) bk[i] ++;
		}
		else {
			ot[x] ++;
			dfs(i, x);
		}
	}
}

int main(){
	scanf("%d%d", &n, &m);
	while(m --){
		scanf("%d%d", &fr, &to);
		v[fr].PB(to);
		v[to].PB(fr);
	}
	for(int i = 1; i <= n; i ++){
		if(SZ(v[i]) & 1){
			puts("No");
			return 0;
		}
	}
	dfs(1, 1);
	int cnt = 0;
	for(int i = 1; i <= n; i ++){
		if(bk[i]){
			//printf("i: %d %d %d\n", i, ot[i], bk[i]);
			cnt += (ot[i] + bk[i]) >> 1;
		}
	}
	if(cnt < 3) puts("No");
	else puts("Yes");
}



Measured memory_bytes: 12544
#include "bits/stdc++.h"
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define REPS(i, n) for (int i = 1; i <= (n); i++)
#define RREPS(i, n) for (int i = (n); i > 0; i--)
#define mp make_pair
#define pb(a) push_back(a)
typedef long long ll;
bool flag[55556];
int main() {
  int N;
  cin >> N;
  vector<int> ans;
  vector<int> p;
  FOR(i, 2, 55556) {
    if (flag[i]) continue;
    p.pb(i);
    int j = 1;
    while (i * j < 55556) {
      flag[i * j] = true;
      j++;
    }
  }
  REP(i, (int)p.size()) {
    if (p[i] % 5 == 1) {
      if ((int)ans.size() == N) break;
      else ans.pb(p[i]);
    }
  }
  REP(i, N - 1) cout << ans[i] << " ";
  cout << ans[N - 1] << endl;
  return 0;
}


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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug(x) cout<<#x<<" = "<<x<<endl;

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

void solve()
{
    li n;

    cin>>n;

    li a[n];

    f(i,0,n-1)
    {
    	cin>>a[i];
    }

    vi suff(n+1);
    const li M=1e9+7;

    fr(i,n-1,0)
    {
    	suff[i]=suff[i+1]+a[i];
    	suff[i]%=M;
    }

    li ans=0;


    f(i,0,n-1)
    {
    	ans+=(suff[i+1]*a[i]);
    	ans%=M;
    }

    cout<<ans;
}

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

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li t=1;

    // cin>>t;

    while(t--)
    {
        solve();
    }

    return 0;
}

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

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

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

int T,H,W,N;
char map[22][22];

int dy[]={-1,1,0,0}, dx[]={0,0,-1,1};
string tank="^v<>",cmd="UDLR";

bool cango(int y,int x){
    return 0<=y && y<H && 0<=x && x<W && map[y][x]=='.';
}

int main(){
	cin>>T;
    rep(tc,T){
        cin>>H>>W;
        int y,x,dir;
        
        rep(i,H)rep(j,W){
            cin>>map[i][j];
            rep(k,4){
                if(map[i][j]==tank[k]){
                    y=i, x=j, dir=k;
                    map[i][j]='.';
                }
            }
        }
        
        cin>>N;
        rep(i,N){
            char c;
            cin>>c;
            rep(j,4){
                if(c==cmd[j]){
                    dir=j;
                    if( cango(y+dy[j], x+dx[j]) ){
                        y+=dy[j], x+=dx[j];
                    }
                }
            }
            if(c=='S'){
                int Y=y, X=x;
                while(1){
                    Y+=dy[dir], X+=dx[dir];
                    if( !(0<=Y && Y<H && 0<=X && X<W) )break;
                    if(map[Y][X]=='*'){
                        map[Y][X]='.';
                        break;
                    }
                    if(map[Y][X]=='#')break;
                }
            }
        }
        
        rep(i,H){
            rep(j,W){
                if(y==i && x==j) cout<<tank[dir];
                else cout<<map[i][j];
            }
            cout<<endl;
        }
        if(tc!=T-1)cout<<endl;
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	ll n, c; cin >> n >> c;
	vi x(n), v(n);
	REP(i, n) cin >> x[i] >> v[i];
	vi cs(n + 1), ccs(n + 1);
	REP(i, n)
	{
		cs[i + 1] = cs[i] + v[i];
		ccs[i + 1] = ccs[i] + v[n - i - 1];
	}
	vi cw(n + 1), ccw(n + 1);
	FOR(i, 1, n + 1)
	{
		cw[i] = cs[i] - x[i - 1];
		ccw[i] = ccs[i] - (c - x[n - i]);
	}
	ll ans = 0;
	ll mxcw = *max_element(ALL(cw));
	ll mxccw = *max_element(ALL(ccw));
	chmax(ans, mxcw);
	chmax(ans, mxccw);
	ll tccw = ccw[0];
	for (int i = n; i >= 1; i--)
	{
		ll tmp = cw[i] - x[i - 1];
		chmax(ans, tmp + tccw);
		chmax(tccw, ccw[n - i + 1]);
	}
	ll tcw = cw[0];
	for (int i = n; i >= 1; i--)
	{
		ll tmp = ccw[i] - (c - x[n - i]);
		chmax(ans, tmp + tcw);
		chmax(tcw, cw[n - i + 1]);
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
 int N;
 cin >> N;
 vector<int> paper(N);
  for(int i = 0; i < N; i++){
    cin >> paper.at(i);
  }
  int count = 0;
  int cnt = 0;

  for(int i = 0; i < N; i++){
    if(paper.at(i) % 2 == 0){
      count++;
      if(paper.at(i) % 3 == 0){
        cnt++;
        continue;
      }
      if(paper.at(i) % 5 == 0){
        cnt++;
      }
    }
  }
  
  
  if(count == cnt) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
main(){float f,g;for(;~scanf("%f%f",&f,&g);)puts(f<35.5&&g<71?"AAA":f<37.5&&g<77?"AA":f<40&&g<83?"A":f<43&&g<89?"B":f<50&&g<105?"C":f<55&&g<116?"D":f<70&&g<148?"E":"NA");return 0;}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, m;
  cin >> n >> m;
  vl w(n), v(n);
  rep(i, n) cin >> w[i] >> v[i];
  ll dp[n + 1][310] = {};
  rep(i, n) for(ll j = i; j >= 0; j--) rep(k, 300) {
    ll nk = k + w[i] - w[0];
    dp[j + 1][nk] = max(dp[j + 1][nk], dp[j][k] + v[i]);
  }
  ll ans = 0;
  rep(j, n + 1) rep(k, 310) if(j * w[0] + k <= m) ans = max(ans, dp[j][k]);
  cout << ans << endl;
}

Measured memory_bytes: 3808
MOD = 10 ** 9 + 7

def m():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    if a[0] == 0:
        tmp = 2
        for i in range(1, n, 2):
            for k in range(2):
                if a[i+k] != tmp:
                    return 0
            tmp += 2
        tmp -=2
        return (2 ** (tmp//2))%MOD

    if a[0] == 1:
        tmp = 1
        for i in range(0, n, 2):
            for k in range(2):
                if a[i+k] != tmp:
                    return 0
            tmp += 2
        tmp -= 1
        return (2 ** (tmp//2))%MOD
    return 0


print(m())

Measured memory_bytes: 14008
while True:
    n,x=map(int,input().split())
    cnt=0
    if n==x==0:
        break
    for a in range(1,n-1):
        for b in range(a+1,n):
            for c in range(b+1,n+1):
                if a+b+c==x:
                    cnt+=1
    print(cnt)


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

const int MAX = 5000;
const int MOD = 1e9 + 7;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

  for(int i=1;i<=K;i++) {
    cout << COM(K-1, i-1) * COM(N-K+1, i) % MOD << endl;
  }

  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=25e4+10,mo=23333333333333333,M=2e7+3;
ll pw[N],ny[N];
ll n,S,v[N],ans;
char s[N];
ll mul(ll a,ll b){
	ll c=(long double)a*b/mo,z=a*b-c*mo;
	return  z<0?z+mo:z<mo?z:z-mo;
}
ll power(ll a,ll b=mo-2){
	ll ans=1;
	while (b){
		if (b&1)ans=mul(ans,a);
		a=mul(a,a);
		b>>=1;
	}return ans;
}
ll base(int p){
	return p<0?ny[-p]:pw[p];
}
map<ll,int> h;
int main(){
	cin>>n;
	pw[0]=ny[0]=1;
	pw[1]=(1e6+7),ny[1]=power(pw[1]);
	for (int i=2;i<=n;i++)
		pw[i]=mul(pw[i-1],pw[1]),
		ny[i]=mul(ny[i-1],ny[1]);
	int p=0;
	scanf("%s",s+1);
	for (int i=1;i<=n;i++){
		if (s[i]=='+')S=(S+base(p))%mo;
		if (s[i]=='-')S=(S-base(p)+mo)%mo;
		if (s[i]=='<')p--;
		if (s[i]=='>')p++;
		h[S]++;
		v[i]=S;
	}
//	cout<<S<<endl;
	ll a=1,b=0,ia=1;
	for (int i=1;i<=n;i++){
		ll s1=mul((S-b+mo)%mo,ia);
		ans+=h[s1];
		h[v[i]]--;
		if (s[i]=='+')b=(b-1+mo)%mo;
		if (s[i]=='-')b=(b+1)%mo;
		if (s[i]=='<')a=mul(a,pw[1]),b=mul(b,pw[1]),ia=mul(ia,ny[1]);
		if (s[i]=='>')a=mul(a,ny[1]),b=mul(b,ny[1]),ia=mul(ia,pw[1]);
//		cout<<ans<<endl;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 37632
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
#      .      '                    Udit Gupta @luctivud         ,              
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                            ##     ##  #######  # #  ######
                            ##     ##  ##   ##  ###    ##
                            ##     ##  ##    #  # #    ##
                            #########  #######  # #    ##
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

import sys
import math
# sys.setrecursionlimit(10**6)

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))

def printwsp(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")
def printchk(*args): return print(*args, end="tst, ")

MOD = int(1e9+7); BABYMOD = 998244353;
# ################################ HELPER PROGRAMS USED ###################################
# ################################## MAIN STARTS HERE #####################################
# for _testcases_ in range(int(input())):
a, b, n = get_ints()
x = min(b-1, n)
ans = math.floor((a*x)/b) - (a * math.floor(x/b))
print(ans)


# #########################################################################################
'''
THE LOGIC AND APPROACH WAS DEVELOPED BY ME @luctivud.
SOME PARTS OF THE CODE HAS BEEN TAKEN FROM WEBSITES LIKE::
(I Own the code if no link is provided here or I may have missed mentioning it)
PLEASE DO NOT PLAGIARISE.
'''

Measured memory_bytes: 62224
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let n: i32 = read();
    let mut isok = false;
    for i in 0..n {
        for j in 0..n {
            if i * 4 + j * 7 == n {
                isok = true;
            }
        }
    }
    if isok {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  cout << a[0] << b[1] << c[2] << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define SIZE(a) int((a).size())
const int INF=INT_MAX;
vvll con(15,vll(15,-1));//con[i][j]=人iが人jを正直/不親切と思っている

int main(){
  ll a,b,q;
  cin>>a>>b>>q;
  vll s(a),t(b);
  rep(i,0,a){
    cin>>s[i];
  }
  rep(i,0,b){
    cin>>t[i];
  }
  rep(i,0,q){
    ll x;
    cin>>x;
    auto its=lower_bound(s.begin(),s.end(),x),itt=lower_bound(t.begin(),t.end(),x);
    ll sb=*(its-1),se=*its,tb=*(itt-1),te=*itt;
    ll ans=1e15;
    if(its!=s.begin()&&itt!=t.begin()){ans=min(ans,max(x-sb,x-tb));}
    if(its!=s.end()&&itt!=t.end()){ans=min(ans,max(se-x,te-x));}
    if(its!=s.begin()&&itt!=t.end()){ans=min(ans,x-sb+(te-x)*2);ans=min(ans,(x-sb)*2+te-x);}
    if(its!=s.end()&&itt!=t.begin()){ans=min(ans,x-tb+(se-x)*2);ans=min(ans,(x-tb)*2+se-x);}
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 2944