akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<time.h>
#define INF 1000000000ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<(ll)m; i++)
#define FOR(i,n,m) for(long long i=n; i<(ll)m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	vector<ll> a(n);
	REP(i,n) cin>>a[i];
	map<ll,ll> s;
	ll sum=0;
	ll ans=0;
	s[0]++;
	REP(i,n) {
		sum+=a[i];
		s[sum]++;
		ans+=s[sum];
	}
	cout<<ans-n<<endl;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
int main(){
  int64_t a,b,c;
  cin>>a>>b>>c;
  if(4*a*b<(c-a-b)*(c-a-b)&&c-a-b>=0) cout<<"Yes";
  else cout<<"No";

}


Measured memory_bytes: 256
object Main {
	def main(args:Array[String]) {
		val in = readLine.split(" ").map(_.toInt)
		val W = in(0)
		val H = in(1)
		val x = in(2)
		val y = in(3)
		val r = in(4)
		
		val okLeft = (x - r) >= 0
		val okRight = (x + r) <= W
		val okBottom = (y - r) >= 0
		val okTop = (y + r) <= H
		
		if (okLeft && okRight && okBottom && okTop) {
			println("Yes")
		}else {
			println("No")
		}
	}
}

Measured memory_bytes: 43776
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<int> data(N);
  int flag = 1;
  for(int i = 0; i < N; i++)cin >> data.at(i);
  for(int i = N - 1; i > 0; i--){
    if(data.at(i - 1) <= data.at(i))continue;
    if(data.at(i - 1) - 1 <= data.at(i)){
      data.at(i - 1)--;
    } else {
      flag = 0;
      break;
    }
  }
  if(flag == 1)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 640
// Try AtCoder
// author: Leonarone @ NEETSDKASU
package main

import "fmt"

func main() {
    var a, b, c int
    fmt.Scan(&a, &b, &c)
    if b - a == c - b {
        fmt.Println("YES")
    } else {
        fmt.Println("NO")
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'

const int N = 1e5 + 11;
int a[N];
map<int, int> freq;

int32_t main() {                                                                                                                        
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    
    int n;
    cin >> n;
    int sum = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      freq[a[i]]++;
      sum += a[i];
    }
    int query;
    cin >> query;
    while (query--) {
      int val, cur;
      cin >> val >> cur;
      sum -= freq[val] * val;
      if (freq.count(cur)) {
        sum += (freq[val]) * cur;
        freq[cur] += freq[val];
      }
      else {
        sum += freq[val] * cur;
        freq[cur] = freq[val];
      }
      //cout << cur << " " << freq[cur] << endl;
      freq.erase(val);
      cout << sum << endl;
    }
}   


Measured memory_bytes: 8352
#include<bits/stdc++.h>
using namespace std;
const int MX=5e5+4;
int bit[MX][27];
void upd(int x,int id,int vl)
{
	while(x<MX)
	{
		bit[x][id]+=vl;
		x+=x&-x;
	}
}
int get(int x,int id)
{
	int ans=0;
	while(x>0)
	{
		ans+=bit[x][id];
		x-=x&-x;
	}
	return ans;
}
int main()
{
	string s;
	int n,q;
	cin>>n>>s;
	s="#"+s;
	for(int i=1;i<=n;i++){
		upd(i,s[i]-'a',1);
	}
	cin>>q;
	while(q--)
	{
		char chr;
		int ch,l,r;
		cin>>ch;
		if(ch==1)
		{
			cin>>l>>chr;
			upd(l,s[l]-'a',-1);
			upd(l,chr-'a',1);
			s[l]=chr;
		}
		else
		{
			int res=0;
			cin>>l>>r;
			for(int j=0;j<26;j++)
			{
				if(get(r,j)-get(l-1,j)>0) res++;
			}
			cout<<res<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 53656
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    string a, b;
    cin >> a >> b;
    string x = a + b;
    int y = stoi(x);
    if(y == ((int)sqrt(y))*((int)sqrt(y))){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

    bool nums[26];
    for (int i = 0; i < 26; i++) nums[i] = false;

    string s;
    cin >> s;

    for (int i = 0; i < s.size(); i++){
        if (!nums[s[i] - 'a']){
            nums[s[i] - 'a'] = true;
        }
    }

    for (int i = 0; i < 26; i++){
        if (!nums[i]){
            char res = 'a' + i;
            cout << res << endl;
            return 0;
        }
    }

    cout << "None" << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;

ll n;
ll k;
ll pa[100];
ll al[100];

ll solve(ll l, ll x) {
  if(l == 0) return 1;
  if(x == 1) return 0;
  if(x <= 1 + al[l-1]) return solve(l-1, x-1);
  if(x == 2 + al[l-1]) return 1 + solve(l-1, x-1);
  else return pa[l-1] + 1 + solve(l-1, x-al[l-1]-2);
}

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

  cin>>n>>k;
  pa[0] = 1;
  FOR(i, 1, n + 1) {
    pa[i] = pa[i-1] * 2 + 1;
  }
  al[0] = 1;
  FOR(i, 1, n + 1) {
    al[i] = al[i-1] * 2 + 3;
  }
  cout << solve(n, k) << endl;
  
  return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<algorithm>
#include <iomanip>
#include <cmath>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <vector>
#include <bitset>
#include <queue>
#include <set>
#include <stack>
#include <string>

using namespace std;

int main() {
	string s; cin >> s;
	if (s.substr(0, 4) == "YAKI") {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll N,u,v,ans=-1;
vector<vector<ll>> tree(200010);
vector<ll> distv(200010,-1);
vector<ll> distnow(200010,-1);
void bfs(ll t){
    queue<ll> q;
    distv.at(t)=0;
    q.push(t);
    while(!q.empty()){
        ll i=q.front();
        q.pop();
        for(auto j:tree.at(i)){
            if(distv.at(j)<0){
                q.push(j);
                distv.at(j)=distv.at(i)+1;
            }
        }
    }
    return;
}
void bfs2(ll t){
    queue<ll> q;
    distnow.at(t)=0;
    q.push(t);
    while(!q.empty()){
        ll i=q.front();
        q.pop();
        for(auto j:tree.at(i)){
            if(distv.at(j)<distv.at(i)) continue;
            if(distnow.at(j)<0){
                q.push(j);
                distnow.at(j)=distnow.at(i)+1;
            }
        }
    }
    return;
}
void Main(){
    cin>>N>>u>>v;u--;v--;
    For(i,0,N-1){
        ll a,b;cin>>a>>b;a--;b--;
        tree.at(a).push_back(b);
        tree.at(b).push_back(a);
    }
    bfs(v);
    ll ok=(distv.at(u)-1)/2+1;
    //cout<<ok<<endl;
    ll now=u;
    while(distv.at(now)>ok){
        //cout<<now<<endl;
        for(auto i:tree.at(now)){
            if(distv.at(now)>distv.at(i)){
                now=i;
                break;
            }
        }
    }
    bfs2(now);
    For(i,0,N){
        //cout<<"v: "<<distv.at(i)<<"now: "<<distnow.at(i)<<endl;
        if(distnow.at(i)>-1){
            if(distv.at(i)>ans) ans=distv.at(i);
        }
    }
    cout<<ans-1<<endl;
}
int main(){
    Main();
    return 0;
}


Measured memory_bytes: 11904
h,w = map(int,input().split())
cnt = 0
L = []
for i in range(h):
    s = input()
    cnt +=s.count("#")
    L.append(list(s))
#print(L,cnt)

d = [[-1]*w for i in range(h)]
d[0][0] = 0
from collections import deque
q = deque([[0,0]])
#print(d,q)

li = ((1,0),(0,1),(-1,0),(0,-1))

while q:
    j,i = q.popleft()
    for dy,dx in li:
        ny,nx = j+dy,i+dx
        if (ny < 0 or ny >= h) or (nx < 0 or nx >= w) or L[ny][nx] == "#":
            continue
        else:
            if d[ny][nx] == -1:
                d[ny][nx] = d[j][i] + 1
                q.append((j+dy,i+dx))

if d[h-1][w-1] == -1:
    print(-1)
else:
    print(h*w - cnt - d[h-1][w-1]-1)


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
/*
	http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_B&lang=jp

	0-1ナップサック問題。

	超有名なDP問題。
*/

using namespace std;

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

const int MAX_N = 100;
const int MAX_W = 10000;
const int INF = 10001;
int N, W;

int v[MAX_N+1], w[MAX_N+1];
int dp[MAX_N+1][MAX_W+1];

int solve (void ){
	rep (i, MAX_N+1 ) rep (j, MAX_W+1 ) dp[i][j] = -INF;

	dp[0][0] = 0;
	rep (i, N ){
		for (int j = 0; j <= W; j++ ){
			if (j - w[i] >= 0 ){
				dp[i+1][j] = max (dp[i+1][j], dp[i][j-w[i]] + v[i] );
			} // end if
			dp[i+1][j] = max (dp[i+1][j], dp[i][j] );
		} // end for
	} // end for

	int res = 0;
	rep (j, W + 1 ) res = max (res, dp[N][j] );

	return res;
}

int main()
{
	memset (v, 0, sizeof (v ) );
	memset (w, 0, sizeof (w ) );

	ios_base::sync_with_stdio(0);
	cin >> N >> W;
	rep (i, N ) cin >> v[i] >> w[i];

	int res = solve (); //dfs (0, W );
	cout << res << endl;
		
	return 0;
}

Measured memory_bytes: 5140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool prime(ll n) {
  if (n == 1) {
    return false;
  } else {
    for (ll i = 2; i <= (ll)pow(n, 0.5); i++) {
      if (n%i == 0) return false;
    }
  }
  return true;
}
ll RepeatSquaring(ll n, ll p, ll m) {
  if (p == 0) return 1;
  if (p%2 == 0) {
    ll t = RepeatSquaring(n, p/2, m);
    return (t*t)%m;
  }
  return (n*RepeatSquaring(n, p-1, m))%m;
}

int main() {
  ll n;
  cin >> n;
  map <string, ll> score;
  rep(i, n) {
    ll a, c;
    string b;
    cin >> a >> b;
    if (a == 0) {
      cin >> c;
      score[b] = c;
    } else if (a == 1) {
      if (score.count(b)) {
        cout << score.at(b) << endl;
      } else {
        cout << 0 << endl;
      }
    } else {
      score.erase(b);
    }
  }
}


Measured memory_bytes: 27872
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n;
	string s;
	cin >> n;
	vector<int> a(26,INF);
	vector<int> b(26,0);
	for(int i = 0; i < n; i++) {
		cin >> s;
		for(int j = 0; j < s.size(); j++) {
			b[s[j] - 'a']++;
		}
		for(int k = 0; k < 26; k++) {
			a[k] = min(a[k],b[k]);
			b[k] = 0;
		}
	}
	vector<char> ans;
	for(int i = 0; i < 26; i++) {
		while(a[i] > 0){
			ans.pb('a' + i);
			a[i]--;
		}
	}
	sort(ALL(ans));
	
	for(int i = 0; i < ans.size(); i++) {
		cout << ans[i];
	}
	cout << endl;
	return 0;
}

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

typedef complex<double> P;

// ?¨±?????????????????
#define EPS (1e-10)
// 2??????????????????????????????????????????
#define EQ(a,b) (abs((a)-(b)) < EPS)

// ?????? (cross product) : a??b = |a||b|sin??
double cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}

// 2??´?????????????????? : a//b <=> cross(a, b) = 0
int is_parallel(P a1, P a2, P b1, P b2) {
  return EQ( cross(a1-a2, b1-b2), 0.0 );
}

int main(){
	int n;
	double x1,x2,x3,x4,y1,y2,y3,y4;

	cin >> n;
	for(int i=0 ; i<n ; i++){
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		P a(x1,y1), b(x2,y2), c(x3,y3), d(x4,y4);
		if( is_parallel(a,b,c,d) ){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 1224
def resolve():
    n = int(input())
    A = list(map(int, input().split()))
    A.sort()
    ans = 0
    ans += A[-1]
    if n % 2 == 0:
        s = sum(A[n - n//2:-1]) * 2
    else:
        s = sum(A[n - n//2:-1]) * 2 + A[n - n//2 - 1]
    print(ans + s)

resolve()

Measured memory_bytes: 31396
#include<iostream>
using namespace std;
typedef long long ll;
#define max(a,b) ((a)>(b)?(a):(b))
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<max((ll)a*d,max((ll)a*c,max((ll)b*c,(ll)b*d)));
}

Measured memory_bytes: 3628
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author dilip
 */

/*
*   author : dilip
*   time : 23-06-2019 22:11
*/

#include <iostream>
#include <fstream>

#include <iostream>
#include<stdio.h>
#include<bits/stdc++.h>
#define ll long long
const int INF = INT_MAX;
using namespace std;
ll n,k;
int a[1000000];
int dp[1000000];


class BFrog2 {
public:
	void solve(std::istream& in, std::ostream& out) {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        in >> n >> k;
        for(int i=0;i<n;i++)in >> a[i];
        for(int i=0;i<1000000;i++)dp[i] = INF;
		dp[0] = 0;
        for(int i=0;i<n;i++){
        	for(int j=1;j<=k;j++){
        		if(i+j < n){
        			dp[i+j] = min(dp[i+j] , dp[i] + abs(a[i] - a[i+j]));
        		}
        	}
        }
		out << dp[n-1] << endl;
	}
};


int main() {
	BFrog2 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

using namespace std;

class BIT {
private:
  vector<ll> vec;

public:
  BIT(ll required_size) { this->vec = vector<ll>(required_size + 1, 0); }
  void add(ll arg_pos, ll num) {
    ll pos = arg_pos + 1;
    for (ll x = pos; x < this->vec.size(); x += x & -x)
      this->vec[x] += num;
  }
  ll sum(ll arg_pos) {
    ll pos = arg_pos + 1;
    ll ret = 0;
    for (ll x = pos; x > 0; x -= x & -x)
      ret += this->vec[x];
    return ret;
  }
};

ll calc_kaisuu(ll h, ll a) {
  ll ret = h / a;
  if (h % a) ret++;
  return ret;
}

void solve() {
  ll N, D, A;
  cin >> N >> D >> A;
  vector<pair<ll, ll>> x_kaisuu(N);
  vector<ll> xs(N);
  rep (i, N) {
    ll X, H;
    cin >> X >> H;
    ll kaisuu = calc_kaisuu(H, A);
    x_kaisuu[i] = make_pair(X, kaisuu);
    xs[i] = X;
  }
  sort(x_kaisuu.begin(), x_kaisuu.end());
  sort(xs.begin(), xs.end());

  BIT bit(N + 1);

  rep (i, N) {
    bit.add(i, x_kaisuu[i].second);
    bit.add(i+1, -x_kaisuu[i].second);
  }

  ll ans = 0;

  rep (i, N) {
    if (bit.sum(i) <= 0) continue;
    ll left = xs[i];
    ll right = left + D * 2; 
    auto it = upper_bound(xs.begin(), xs.end(), right);
    it--;
    ll right_index = it - xs.begin();

    ll tmp = bit.sum(i);
    bit.add(i, -tmp);
    bit.add(right_index + 1, tmp);

    ans += tmp;
  }

  cout << ans << endl;
}

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


Measured memory_bytes: 6528
# Forbidden List

X, N = [int(i) for i in input().split()]
pi = [int(i) for i in input().split()]

pl = []
pu = []
for i in pi:
    if i <= X:
        pl.append(i)
    if X <= X:
        pu.append(i)

pl.sort(reverse=True)
pu.sort()

nl = X
for i in pl:
    if i == nl:
        nl -= 1
nu = X
for i in pu:
    if i == nu:
        nu += 1

if X - nl <= nu - X:
    print(nl)
else:
    print(nu)


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

char rsp[3] = {'r', 'p', 's'};

char hand(char t) {
  char ret;
  for (int i = 0; i < 3; i++) {
    if (t == rsp[i]) {
      ret = rsp[(i + 1) % 3];
    }
  }
  return ret;
}

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

  int N, K, R, S, P;
  string T;
  cin >> N >> K;
  cin >> R >> S >> P;
  cin >> T;

  char ring_buf[K] = {'\0'};
  char h;
  long long total = 0;
  for (int i = 0; i < N; i++) {
    h = hand(T[i]);
    if (ring_buf[i % K] != h) {
      ring_buf[i % K] = h;
      if (h == 'r') total += R;
      if (h == 'p') total += P;
      if (h == 's') total += S;
    } else  if (i + K < N){
      // select lose hand.
      h = hand(T[i + K]);
      for (int j = 0; j < 3; j++) {
        if (h == rsp[j] || T[i] == rsp[j]) {
          continue;
        }
        ring_buf[i % K] = rsp[j];
      }
    } else {
      // select same hand.
      ring_buf[i % K] = T[i];
    }
  }
  cout << total << '\n';
}


Measured memory_bytes: 592
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
struct edge{int to;ll cost;};
typedef pair<ll,int> P;
const ll INF=1000000000000LL;
const ll MOD=1000000007LL;
const ll MAX=100010;
int main(){
	string  s;
	cin>>s;
	reverse(s.begin(),s.end());
	cout<<s<<endl;
	return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rep(i, l, r) for(int i = (l); i < (r); ++i)
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl
//-------
const int N = 2020;
int n;
int pr[2][N];
int main() {
	scanf("%d", &n);
	rep(cas, 0, 2)
	rep(i, 1, n + 1) scanf("%d", pr[cas] + i), pr[cas][i] += pr[cas][i - 1];
	int ans = 0;
	rep(i, 1, n + 1) ans = max(ans, pr[0][i] + pr[1][n] - pr[1][i - 1]);
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define N 305
using namespace std;
typedef long long ll;

ll n, k, h[N], d[N][N];
int main() {
	int i, j, l;
	cin >> n >> k;
	for(j=1; j<=n; j++) {
		cin >> h[j];
		d[0][j] = 4e18;
	}
	for(i=1; i<=n+1; i++) for(j=0; j<=k; j++) {
		d[i][j] = 4e18;
		for(l=0; l<=k; l++) {
			if(i-1-l<0 || j-l<0) break;
			d[i][j] = min(d[i][j], d[i-1-l][j-l] + max(0LL, h[i] - h[i-1-l]));
		}
	}
	cout << d[n+1][k];
	return 0;
}

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

const ll INF = 1e15;

 struct UnionFind {
    vector<ll> par;
    vector<ll> rnk;

    UnionFind(ll n) {
        par.assign(n, 0);
        rnk.assign(n, 1);
        for(ll i=0; i<n; i++) {
            par[i] = i;
        }
    }

    void unite(ll x, ll y) {
        x = find(x); y = find(y);
        if(x == y) return;
        if(rnk[x] < rnk[y]) swap(x, y);
        rnk[x] += rnk[y];
        par[y] = x;
    }

    ll find(ll x) {
        if(par[x] == x) return x;
        return par[x] = find(par[x]);
    }

    bool same(ll x, ll y) {
        return find(x) == find(y);
    }

    ll size(ll x) {
        return rnk[find(x)];
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    vector<ll> p(N);
    rep(i, N) cin >> p[i];
    UnionFind uf(10000010);
    rep(i, M) {
        ll x, y;
        cin >> x >> y;
        uf.unite(x, y);
        //cout << "c" << endl;
    }

    int res = 0;
    rep(i, N) {
        if(p[i] == i+1) res++;
        else if(uf.same(p[i], i+1)) res++;
    }

    cout << res << endl;
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  if (s[0] == '3') {
    cout << "bon" << endl;
  }
  else if (s[0] == '0' || s[0] == '1' || s[0] == '6' || s[0] == '8') {
    cout << "pon" << endl;
  }
  else cout << "hon" << endl;
}

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

int main(){
  int n,t,a,x;
  int amin=100000000;
  cin >> n >> t >> a;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  for(int i=0;i<n;i++){
      h[i]=abs(t*1000-h[i]*6-1000*a);
    if(h[i]<amin){
      amin=h[i];
      x=i;
    }
  }
 cout << x+1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define REEP(i, N) for(ll i = N - 1; i >= 0; --i)
#define FOR(i,m,n) for(ll i = m; i < n; ++i)
#define RFOR(i,m,n) for(ll i = n - 1; i >= m; --i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define PB push_back
#define KIRIAGE(a, b) a += (b - a % b) % b
#define CEIL(c, a, b) if(a % b == 0) { c = a / b;} else { c = a / b + 1;}
#define sp(n) setprecision(n)
#define INF 1000000000
#define MOD 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
int dx8[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	int N;
	cin>>N;
	int ans = 0;
	ll sum = 0;
	vector<int> a(N);
	REP(i, N) cin>>a[i];
	sort(ALL(a));
	REP(i, N) {
		if(sum != 0 && a[i] > 2 * sum) ans = i;
		sum += a[i];
	}
	cout<<N - ans<<endl;
}



Measured memory_bytes: 640
#include <iostream>

int main() {

  int A;
  int B;

  std::cin >> A >> B;

  if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
    std::cout << "Possible" << std::endl;
  } else {
    std::cout << "Impossible" << std::endl;
  }

  return 0;
}

Measured memory_bytes: 256
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import *
from bisect import bisect
 
def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]

N = read()
A = [a-(N-1) for a in reads()]

def possible(x): # possible at exactly x-th turn
  return sum((a + x + N) // (N+1) for a in A if a + x > 0) <= x

l = -1; r = 10 ** 19
while r - l > 1:
  m = (l + r) // 2
  if possible(m):
    r = m
  else:
    l = m
ans = min(x for x in range(l - 10*N**2, l + 10*N**2) if possible(x))
print(ans)



Measured memory_bytes: 44396
N = int(input())
A = [int(a) for a in input().split()]
X = min(A)
Y = max(A)
if Y - X > 1:
    print("No")
elif X == Y:
    print("Yes" if X <= N//2 or X == N-1 else "No")
else:
    K = A.count(X)
    print("Yes" if N-K > 1 and K+1 <= X+1 <= K + (N-K)//2 else "No")

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

using namespace std;

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define int long long
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int,int>
#define INF LLONG_MAX
#define EPS 1e-9
#define all(v) (v).begin(),(v).end()
#define sq(x) ((x)*(x))
#define foreach(it, v) for(auto it=(v).begin(); it != (v).end(); ++it)
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)


#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
 
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}
 
typedef long double dbl;
bool codejam = 0;

const int MOD = 1000*1000*1000 + 7;
const int NMAX = 1000*1000 + 11;

int arr[NMAX];
int n,m,p,q,k,a,b,c,ans;
string s,str;
char ch;
vector<int> v;

void solve()
{
    cin>>k;
    cin>>s;
    for(int i=0;i<s.length();i++){
        if(i < k){
            cout<<s[i];
        }
        if(i == k){
            cout<<"...";
            return;
        }
    }
}

int32_t main(){ fio;
    int t = 1;
    int cs = 1;
    // cin>>t;
    while(t--){
        if(codejam){
            cout<<"Case #"<<cs<<": ";
        }
        cs++;
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 3656
n,t = gets.chomp.split.map(&:to_i)
ts = gets.chomp.split.map(&:to_i)
s = t
e = 0
1.upto n-1 do |i|
    d = ts[i] - ts[i-1]
    if t >= d
        s = ts[i] + t - e
    else
        e += d - t
        s += t
    end
end

puts s


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

typedef long long ll;
#define mod 1000000007

// debug fn.
template<typename T>
void deb(initializer_list<T> l)
{
    for (auto &e : l)
        cout << e << ' ';
    cout << endl;
}

void solve(){
    string s1, s2;
    int count = 0;
    cin>>s1;
    cin>>s2;
    for(int i = 0; i < s1.size(); i++){
        if(s1[i] != s2[i])
            count += 1;
    }
    cout<<count;
}

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

    int t = 1;
    // cin >> t;
    while (t--)
        solve();

    return 0;
}

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

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

  for (int i = 0; i < 3; i++){
    if (N.at(i) == '7') {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
}

Measured memory_bytes: 3628
o,x,b;
main(a){
  for(scanf("%d");~scanf("%s",&a);o==3?o=b=x=!printf("%d\n",x):0)
      for(a%=9,a-8?b=b*2+1,x+=b/8,b&=7:o++;a<7&b;b/=2)x++;
}

Measured memory_bytes: 0
import bisect
n = int(input())
l = sorted(list(map(int,input().split())))
ans = 0
 
for i in range(n-2):
    for j in range(i+1, n-1):
        ans += bisect.bisect_left(l,l[i] + l[j]) - j - 1
print(ans)

Measured memory_bytes: 3188
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cctype>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<sstream>
#include<vector>
#include<cstdlib>
#include<ctime>
#include<list>
#include<deque>
#include<bitset>
#include<fstream>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define rep(i,x) for(int (i)=0;(i)<(x);(i)++)
inline int getint(){
    int x=0,p=1;char c=getchar();
    while (c<=32)c=getchar();
    if(c==45)p=-p,c=getchar();
    while (c>32)x=x*10+c-48,c=getchar();
    return x*p;
}
using namespace std;
//ruogu
int n,res;
multiset<int>S;
//
int main(){
    n=getint();
	rep(i,n){
		int x=getint();
		S.insert(x);
	}
	while(S.size()>=2){
		int x=*(--S.end());
		S.erase(--S.end());
		for(int j=30;j>=0;j--){
			int y=(1<<j)-x;
			if(y<=0)break;
			if(S.find(y)!=S.end()){
				S.erase(S.find(y));
				res++;
				break;
			}
		}
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 9600
X = int(input())

mylist = [i + 100 for i in range(6)]

#print(mylist, X)

dp = [int(i % mylist[0] == 0) for i in range(X + 1)]

for m in mylist[1:]:
    for i in range(m, X+1):
        dp[i] += dp[i-m]


if dp[-1]:
    print(1)
else:
    print(0)

Measured memory_bytes: 7448
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60; 
#define MOD 1000000007

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}
/**
* @fn
* 指定した値との差の絶対値が最小のvectorの番号を返します。
*/
long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

//ここまでライブラリ
//ここから本文

long long int tpabsmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b) && a.at(i) >= b) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


int main() {
	int w, a, b;
	cin >> w >> a >> b;
	int ans = 10000;
	if (a < b) {
		if (b <= a + w) {
			ans = 0;
		}
		else {
			ans = b - (a + w) ;
		}
	}
	else if ( a > b){
		if (b+ w > a) {
			ans = 0;
		}
		else {
			ans = a - (b + w);
		}
	}
	else {
		ans = 0;
	}
	cout << ans << endl;
}



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

int main(void)
{
	int d, n, o = 1;
	cin >> d >> n;

	for (int i = 0; i < d; ++i) {
		o *= 100;
	}

	if (d == 0 && n == 100) {
		cout << 101 << endl;
		return 0;
	} else if (d == 1 && n == 100) {
		cout << 10100 << endl;
		return 0;
	} else if (d == 2 && n == 100) {
		cout << 1010000 << endl;
		return 0;
	} 

	cout << o * n << endl;

	return 0;
}

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

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

LL gcd(LL x, LL y) {
    while (1) {
	if (x) y %= x; else return y;
	if (y) x %= y; else return x;
    }
}

void MAIN() {
    LL A, B, C, D;
    scanf("%lld%lld%lld%lld", &A, &B, &C, &D);

    bool yes;
    if (A < B) {
	yes = false;
    } else if (D < B) {
	yes = false;
    } else if (A % B > C) {
	yes = false;
    } else if (D == B) {
	yes = true;
    } else {
	LL g = gcd(B, D);
	LL a = A % B;
	// C < a + xg < B;
	LL x = (C - a) / g;
	if (C >= a + x*g) x++;
	if (C < a + x*g && a + x*g < B) yes = false;
	else yes = true;
    }
    puts(yes? "Yes": "No");
}

int main() {
    int TC = 1;
    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	int n, i, j, k, a, b, top, pp;
	cin >> n;
	vector<vector<pair<int, int>>> adj(n + 1);
	vector<int> ans(n - 1, -1);
	for (i = 0; i < n - 1; i++) {
		cin >> a >> b;
		adj[a].push_back({ b, -i });
		adj[b].push_back({ a, -i });
	}

	top = 0;
	for (i = 1; i <= n; i++) top = max(top, (int)adj[i].size());
	vector<int> ct(top + 1, 0);

	for (i = 1; i <= n; i++) {		
		for (j = 0; j < adj[i].size(); j++) {
			a = -adj[i][j].second;
			if (ans[a] != -1) {
				adj[i][j].second = ans[a];
				ct[ans[a]] = i;
			}
		}

		pp = 1;
		for (j = 0; j < adj[i].size(); j++) {
			if (adj[i][j].second <= 0) {
				while (ct[pp] == i) pp++;
				ans[-adj[i][j].second] = pp;
				adj[i][j].second = pp;
				ct[pp] = i;
			}
		}
	}

	cout << top << "\n";
	for (i = 0; i < n - 1; i++) cout << ans[i] << "\n";


	return 0;
}



Measured memory_bytes: 6912
n,m = gets.split.map(&:to_i)

py = m.times.map{gets.split.map(&:to_i)}
a = (n+1).times.map{[]}

py.each{|(o,y)|
  a[o]<<y
 }

a.size.times{|i|
  a[i].sort!
}

py.each{|(o,y)|
  ub,lb = a[o].size,0
  30.times{
    mid = (ub+lb)/2
    if a[o][mid]<y
      lb = mid
    else
      ub = mid
    end
  }
  s = (o+1000000).to_s[1..-1]
  t = (ub+1+1000000).to_s[1..-1]
  puts s+t
}


Measured memory_bytes: 18892
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> b(n + 1), w(n + 1);
  for (int i = 0; i < n; i++) {
    b[i + 1] = b[i] + (s[i] == '#' ? 1 : 0);
    w[i + 1] = w[i] + (s[i] == '.' ? 1 : 0);
  }
  for (int i = 0; i <= n; i++) {
    cerr << b[i] << " ";
  }
  cerr << endl;
  for (int i = 0; i <= n; i++) {
    cerr << w[i] << " ";
  }
  cerr << endl;
  int ans = 1 << 30;
  for (int i = 0; i <= n; i++) {
    ans = min(ans, b[i] + w[n] - w[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2196
using System;
using System.IO;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var X = Console.ReadLine().Split();
        var Ps = Enumerable.Range(1, 100).ToArray();
        var answer = 100 * 100 * 100;
        foreach (var P in Ps)
        {
            var sum = 0;
            for (int i = 0; i < N; i++)
            {
                var consume = int.Parse(X[i]) - P;
                sum += consume * consume;
            }
            if (sum < answer) answer = sum;
        }
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();
    }
}


Measured memory_bytes: 28232
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
        string a;
        cin >> a;
        if ('A' <= a[0] && a[0] <= 'Z') {
            cout << "A" << endl;
        } else {
            cout << "a" << endl;
        }
        return 0;
    }

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>

#define err 1e-7
#define INF 2e9 

#define mp make_pair
#define pb push_back

#define tr(container, iterator) \
	for(typeof(container.begin()) iterator=container.begin(); \
		it != container.end(); it++)

using namespace std;

int main() {
	//freopen("a.in", "r", stdin);
	//freopen("a.out", "w", stdout);	

	long long a, b, c, d, n;

	cin >> a >> b >> c >> d;

	cin >> n;

	b = min(b, a * 2);
	c = min(c, b * 2);
	d = min(d, c * 2);

	cout << n / 2 * d + (n % 2) * c;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
int x[100010];
signed main(){
	int n,ans=0;
	cin>>n;
	f(i,n+1){
		cin>>x[i];
	}
	f(i,n){
		int a;
		cin>>a;
		ans+=min(x[i],a)+min(x[i+1],max(a-x[i],(int)0));
		x[i+1]-=min(x[i+1],max(a-x[i],(int)0));
		x[i]-=min(x[i],a);
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

#define Speed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define MOD 998244353
#define fi first
#define se second

const int NR = 2e5 + 10;

ifstream in ("date.in");
ofstream out ("date.out");


ll a,b,c;
int main()	{
    Speed;
    cin >> a >> b >> c ;
    swap ( a, b );
    swap ( a , c ) ;
    cout << a << ' ' << b << ' ' << c;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main (String[] args) {
   Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    if ( (a-2*b)<0) {
      System.out.println(0);
    } else {
    System.out.println(a-2*b);
    }
  }
  
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
struct StronglyConnectedComponent{
  int n, comp_size;
  vector<vector<int>> g, revg;
  vector<int> comp, order, used;

  StronglyConnectedComponent (int sz) {
    n = sz;
    g.resize(n); revg.resize(n);
    comp.assign(n, -1);
    used.assign(n, 0);
  }

  int operator[] (int u) {
    return comp[u];
  }

  void add_edge (int u, int v){
    g[u].emplace_back(v);
    revg[v].emplace_back(u);
  }

  void dfs (int u){
    if (used[u]) return ;
    used[u] = 1;
    for (auto v : g[u]) dfs(v);
    order.emplace_back(u);
    return ;
  }

  void rdfs (int u, int k){
    if (comp[u] != -1) return ;
    comp[u] = k;
    for (auto v : revg[u]) rdfs(v, k);
    return ;
  }

  void build (vector<vector<int>> &ref){
    for (int i = 0; i < n; i++) dfs(i);
    reverse(order.begin(), order.end());
    int cur = 0;
    for (auto i : order) {
      if (comp[i] == -1) {
        rdfs(i, cur);
        cur++;
      }
    }
    ref.resize(cur);
    for (int i = 0; i < g.size(); i++) {
      for (auto j : g[i]) {
        int u = comp[i], v = comp[j];
        if (u == v) continue;
        ref[u].emplace_back(v);
      }
    }
  }

};
int main() {
  int n, m;
  cin >> n >> m;
  StronglyConnectedComponent scc(n);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    scc.add_edge(a, b);
  }

  vector<vector<int>> g;
  scc.build(g);
  vector<vector<int>> res(g.size());
  for (int i = 0; i < n; i++) res[scc[i]].emplace_back(i);

  cout << g.size() << endl;
  for (int i = 0; i < (int)g.size(); i++) {
    cout << res[i].size() << " ";
    for (auto e : res[i]) cout << e << " ";
    cout << endl;
  }
  return 0; 
}


Measured memory_bytes: 103624
/*
   Created by Rahul Goel.
*/
/*******************************************************************************/
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
/*******************************************************************************/
using namespace std;
using ll = long long;
using ld = long double;
ll mod = 1000000007;
const int INF = 1e9;
const ll LINF = 1e18;
/*******************************************************************************/
/*
.-.. . -. -.- .- / .. ... / .-.. --- ...- . -.-.--
 */
/* For PBDS */
/*Two new methods X.order_of_key() and X.find_by_order()*/
/*
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/

/*******************************************************************************/
ll mod_sum() { return 0LL; }
template<typename T, typename... Args>
T mod_sum(T a, Args... args) { return ((a + mod_sum(args...))%mod + mod)%mod; }

ll mod_prod() { return 1LL; }
template<typename T, typename... Args>
T mod_prod(T a, Args... args) { return (a*mod_prod(args...))%mod; }
/*******************************************************************************/
using pii = pair < ll, ll >;
using vi = vector < ll >;
using vb = vector < bool >;
using vvi = vector < vector < ll > >;
using vvb = vector < vector < bool > >;
using vpii = vector < pii >;
using vvpii = vector < vector < pii > >;
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
#define fastio          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(c)          (c).begin(), (c).end()
#define present(c,x)    ((c).find(x) != (c).end())
#define cpresent(c,x)   (find(all(c),x) != (c).end())
#define uniq(c)         (c).resize(distance((c).begin(), unique(all(c))))
#define min_pq(t)       priority_queue < t, vector < t >, greater < t > >
#define max_pq(t)       priority_queue < t >
#define pb              push_back
#define ff              first
#define ss              second
/*******************************************************************************/

/*
    Code begins after this.
*/


ll solve(){
    vi v(5);
    for(ll &x : v)
        cin >> x;
    cout << 1 + find(all(v),0) - v.begin() << endl;
    return 0;
}


signed main(){
    fastio;

    ll t = 1;
    while(t--)
        solve();

    return 0;
}

/*******************************************************************************/
// Remeber - In a custom comparator cmp(a, b) a==b must always return to false.


Measured memory_bytes: 3640
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
typedef long long ll;
const long long llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int ans;
string s;
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>s;
    for(int i=0;i<s.size();i++) if(s[i]=='1') ans++;
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  ll m, k; cin >> m >> k;

  ll n = 1<<m;

  if (k == 0) {
    V a(n);
    drep(i, n) cout << i << " ";
    rep(i, n) cout << i << " ";
    cout << "\n";
    return 0;
  }

  if (k >= n || m == 1) {
    cout << -1 << "\n";
    return 0;
  }

  drep(i, n) if (i != k) cout << i << " ";
  cout << k << " ";
  rep(i, n) if (i != k) cout << i << " ";
  cout << k << "\n";
  return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    int size=s.size();
    int flag=0;
    for (int i=0;i<size;i++) {
        if (s.at(i)!=s.at(size-1-i)) {
            cout<<"No"<<endl;
            flag=1;
            break;
        }
    }
    if (flag==0) {
        int size1=(size-1)/2;
        string tmp1=s.substr(0,size1);
        //cout<<tmp1<<endl;
        for (int j=0;j<tmp1.size();j++) {
            if (tmp1.at(j)!=tmp1.at(tmp1.size()-1-j)) {
                cout<<"No"<<endl;
                flag=1;
                break;
            }
        }
    }
    if (flag==0) {
        int size2=(size+3)/2;
        string tmp2=s.substr(size2-1,size-size2+1);
        //cout<<tmp2<<endl;
        for (int k=0;k<tmp2.size();k++) {
            if (tmp2.at(k)!=tmp2.at(tmp2.size()-1-k)) {
                cout<<"No"<<endl;
                flag=1;
                break;
            }
        }
    }
    if (flag==0) {
        cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 256
/*input
16 4 3
ooxxoxoxxxoxoxxo
*/

#include <bits/stdc++.h>
#define ll long long

using namespace std;

void run() {
	int n, k, c, i;
	string s;
	cin >> n >> k >> c >> s;
	vector<int> first, last;
	for(i=n-1; i>=0; i--) {
		if(s[i]=='o') {
			last.emplace_back(i);
			i -= c;
		}
		if(last.size() == k) 
			break;
	}
	for(i=0; i<n; i++) {
		if(s[i]=='o') {
			first.emplace_back(i);
			i += c;
		}
		if(first.size() == k) 
			break;
	}
	for(i=0; i<k; i++)
		if(first[i] == last[k - 1 - i])
			cout << first[i] + 1 << endl;
}

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


Measured memory_bytes: 3468
#include<stdio.h>
int main()
{
    int m[10000],a,b,c,d,e,k,z;
    for(int i=0;i<=4;i++)
        scanf("%d",&m[i]);
        scanf("%d",&k);
        z=m[4]-m[0];
        if(z<=k)
            {
            printf("Yay!");
            }
        else
            printf(":(");
    return 0;
}


Measured memory_bytes: 128
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final String s = scanner.next();

        final Map<Character, Integer> map = new HashMap<>();
        map.put('R', 0);
        map.put('G', 1);
        map.put('B', 2);

        final long[][] colors = new long[3][n];
        for (int i = n - 1; i >= 0; i--) {
            if (i < n - 1) {
                for (int j = 0; j < 3; j++) {
                    colors[j][i] = colors[j][i + 1];
                }
            }

            colors[map.get(s.charAt(i))][i]++;
        }

        long sum = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n - 1; j++) {
                final int a = map.get(s.charAt(i));
                final int b = map.get(s.charAt(j));
                if (a == b) {
                    continue;
                }

                final int k = 2 * j - i;
                final int c = 3 - (a + b);
                if (k >= n) {
                    sum += colors[c][j + 1];
                } else if (k == n - 1) {
                    sum += colors[c][j + 1] - colors[c][n - 1];
                } else {
                    sum += colors[c][j + 1] - colors[c][k] + colors[c][k + 1];
                }
            }
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 38336