akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
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; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
//#include <math.h>
int main(void) 
{
    char c;
    cin >>c;

    
    printf("%c",c+1);
   
    
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while(a>0 && c>0) {
    c -= b;
    if (c <= 0) {
      cout << "Yes" << endl;
      return 0;
    }
    a -= d;
    if (a <= 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int a,b;
    cin >> a >> b;
    if(a > 9 || b > 9){
        cout << -1 << endl;
    }else{
        cout << a * b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n, l = [int(v) for v in input().split()]

a_s = []
for i in range(1, n + 1):
  a_s.append(l + i - 1)

taste_n = sum(a_s)
a_min = min(a_s)
a_max = max(a_s)

if l + n - 1 < 0:
  ans = taste_n - a_max
elif l > 0:
  ans = taste_n - a_min
else:
  ans = taste_n
  
print(ans)

Measured memory_bytes: 3064
S=str(input())
T=str(input())
s=list(S)
t=list(T)
s.sort()
t.sort()
import collections
ss=collections.Counter(s)
tt=collections.Counter(t)
ans=0
a=[]
b=[]
for i in range(len(set(s))):
    a.append(ss.most_common()[i][1])
for i in range(len(set(t))):
    b.append(tt.most_common()[i][1])
if a==b:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 7580
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

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


int main(){
    ll h;   cin >> h;
    ll x = 1;
    ll res = 0;

    while(h > 0){
        h /= 2;
        res += x;
        x *= 2;
    }

    cout << res << endl;





    return 0;
}


Measured memory_bytes: 256
// AtCoder template
// 見た奴全員saba!
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)

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

    int n,r; cin >> n >> r;
    if(n >= 10) cout << r << endl;
    else cout << r + 100*(10-n) << endl;
}

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

int main()
{
    string stc="";
    string tmp;
    while (getline(cin, tmp))
    {
        stc+=tmp;
    }
    for (int i=0; i<stc.size(); i++)
    {
        char moji = stc.at(i);
        if (isupper(moji))
        {
            stc.at(i)=tolower(moji);
        }
    }
    for (char moji='a'; moji<='z'; moji++)
    {
        int sum=0;
        for (int j=0; j<stc.size(); j++)
        {
            if (moji==stc.at(j))
            {
                sum++;
            }
        }
        cout << moji << " : " << sum << endl;
    }
}


Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const int N = 5e5 + 10;
const ll mod = 1e9 + 7;
int par[N], siz[N];
int find(int x) { return par[x] == x ? x : par[x] = find(par[x]); }
void uni(int x, int y) {
	x = find(x); y = find(y);
	if (x != y) {
		par[x] = y;
		siz[y] += siz[x];
	}
}
int n, m;
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++)par[i] = i, siz[i] = 1;
	for (int i = 1; i <= m; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		uni(u, v);
	}
	int ans = 0;
	for (int i = 1; i <= n; i++)ans = max(ans, siz[i]);
	printf("%d\n", ans);
	return 0;
}

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

const int MAXN = 100005;

vector<int> ch[MAXN];
int n;

int depth(int x)
{
    vector<int> huector;
    int res = 0;
    for (int i = 0; i < ch[x].size(); i++)
    {
        huector.push_back(depth(ch[x][i]));
    }
    sort(huector.begin(), huector.end());

    for (int i = 0; i < huector.size(); i++)
    {
        res = max(res, huector[i] + (int)huector.size() - i);
    }
    //cout << x << " " << res << endl;
    return res;
}


int main()
{
    cin >> n;
    for (int i = 2; i <= n; i++)
    {
        int p;
        cin >> p;
        ch[p].push_back(i);
    }

    cout << depth(1);

    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
//typedef vector<vector<ll>> Graph;

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

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

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

    ll N;
    cin >> N;
    vector<ll> X(N), Y(N), P(N);
    REP(i, N) cin >> X[i] >> Y[i] >> P[i];

    const ll INF = (1ll<<60);
    vector<ll> res(N+1, INF);
    ll M = 1;
    REP(_, N) M *= 3;

    const ll B = (1ll<<N);
    vvl xcost(B, vl(N, INF)), ycost(B, vl(N, INF));

    REP(mask, B){
        REP(i, N){
            ll tmp = abs(X[i]-0);
            REP(j, N){
                if(mask>>j & 1){
                    chmin(tmp, abs(X[i]-X[j]));
                }
            }
            chmin(xcost[mask][i], P[i] * tmp);
        }
    }

    REP(mask, B){
        REP(i, N){
            ll tmp = abs(Y[i]-0);
            REP(j, N){
                if(mask>>j & 1){
                    chmin(tmp, abs(Y[i]-Y[j]));
                }
            }
            chmin(ycost[mask][i], P[i] * tmp);
        }
    }

    REP(mask, M){
        ll Xm=0, Ym=0;
        ll tmp = mask;
        ll cnt = 0;
        REP(i, N){
            ll trit = tmp%3;
            if(trit==1){
                Xm += (1ll<<i);
                cnt++;
            }
            if(trit==2){
                Ym += (1ll<<i);
                cnt++;
            }
            tmp /= 3;
        }
        ll val = 0;    
        REP(i, N){
            val += min(xcost[Xm][i], ycost[Ym][i]);
        }
        chmin(res[cnt], val);
    }

    REP(i, N+1){
        cout << res[i] << endl;
    }


    return 0;
}

Measured memory_bytes: 12940
#include<stdio.h>
#include<math.h>


int main(){

  int array[3],i,k,work;

  scanf("%d %d %d", &array[0], &array[1], &array[2]);

  for(i=0;i<3-1;++i){
    for(k=i+1;k<3;++k){
      if(array[i]>array[k]){
	work = array[i];
	array[i] = array[k];
	array[k] = work;
      }
    }
  }

  printf("%d %d %d\n", array[0], array[1], array[2]);
  

  return 0;
}



Measured memory_bytes: 2712
s=input()
for i in range(len(s)):
    if i%2==0:
        if s[i] in 'RUD':
            continue
        else:
            print('No')
            break
    else:
        if s[i] in 'LUD':
            continue
        else:
            print('No')
            break
else:
    print('Yes')

Measured memory_bytes: 3064
#include <stdio.h>

int main()
{

    int n, i, j, num[100], cnt = 0, tmp;

    scanf("%d", &n);

    for (i = 0; i < n; i++)
    {
        scanf("%d", &num[i]);
    }

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

        for (j = n - 1; j >= i + 1; j--)
        {
            if (num[j - 1] > num[j])
            {
                tmp = num[j - 1];
                num[j - 1] = num[j];
                num[j] = tmp;
                cnt++;
            }
        }
    }

    for (i = 0; i < n; i++)
    {
        printf("%d", num[i]);
        if (i != n - 1)
            printf(" ");
    }
    printf("\n%d\n", cnt);

    return 0;
}



Measured memory_bytes: 2112
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset> 
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
                
#define int long long
#define ll long long 
bool FLAG = 0;
#define debug(x) if (FLAG) { 	cerr << #x << " = " << x << endl;}
#define debug_vec(x) if (FLAG) {cerr << #x << " = {"; for (auto to x) cout << to << ", "; cout << "}" << endl}
#define F first
#define S second                               
#define sqr(x) ((x) * (x))
#define make make_pair
#define pb push_back
#define sz(x) (int)(x.size()) 
#define all(x) x.begin (), x.end ()

using namespace std;
                        
typedef unsigned long long ull;
typedef long double ld;

const int MOD = 998244353, N = (int)1e6+ 222;
const int INF = (int)1e18;
const ld eps = (ld)1e-6;

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

int n, a[N], b[N], k;

inline void solve () {
	cin >> n >> k;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}	
	sort(a + 1, a + 1 + n);
	int ans = 0;
	for (int i = 1; i <= k; ++i) ans += a[i];
	cout << ans;
}	
	    

signed main () {
	#ifdef Maga
		freopen("input", "r", stdin);
	#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 3172
A,B,C = map(int, input().split())
count = 0
while True:
    if A%2==1 or B%2==1 or C%2==1:
        print(count)
        break
    if A==B and A==C:
        print(-1)
        break
    A, B, C = (B+C)/2, (A+C)/2, (A+B)/2
    count += 1

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  int N; cin >> N;
  set<ll> s;
  rep(i, N) {
    ll a; cin >> a;
    s.insert(a);
  }
  while (s.size() > 1) {
    set<ll> t;
    auto it = s.begin();
    auto mod = *it;
    it++;
    for (; it != s.end(); ++it) {
      if (*it % mod > 0) {
        t.insert(*it % mod);
      }
    }
    t.insert(mod);
    s = t;
  }
  cout << *(s.begin()) << endl;
}


Measured memory_bytes: 5248
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

void Calculate_Depth(vector<vector<int>>&edge, vector<int>&depth, int stnode) {
	depth[stnode] = 0;
	queue<int>Q;
	Q.push(stnode);
	while (!Q.empty()) {
		int cn = Q.front();
		Q.pop();
		for (auto i : edge[cn]) {
			if (depth[i] > depth[cn] + 1) {
				depth[i] = depth[cn] + 1;
				Q.push(i);
			}
		}
	}
	return;
}

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

	cin >> N >> L >> R;
	L--, R--;
	vector<vector<int>>edge(N);
	for (int i = 1; i < N; i++) {
		cin >> H >> W;
		H--, W--;
		edge[H].push_back(W);
		edge[W].push_back(H);
	}
	vector<int>deptha(N, MOD);
	vector<int>depthb(N, MOD);
	Calculate_Depth(edge, deptha, L);
	Calculate_Depth(edge, depthb, R);
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (deptha[i] < depthb[i]) {
			ans = max(ans, depthb[i] - 1);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 6656
from itertools import product
import math

D, G = map(int, input().split()) 
ipcl = []
for i in range(D):
    p, c = map(int, input().split()) 
    ipcl.append( [i+1, p, c] )

pattern = 2
ite = product(range(pattern),repeat=D)

ans = 10**5
for comb in ite:

    curr_ipcl = ipcl[:]
    curr_sum = 0
    curr_prob = 0
    for i, comp in enumerate(comb):
        if comp:
            pi, p,c = ipcl[i]
            curr_sum += (i+1)*p*100
            curr_sum += c
            curr_prob += p
            curr_ipcl[i] = [pi,0,0]
    
    for ipc in reversed(curr_ipcl):
        i,p,c = ipc
        if curr_sum + p*i*100 <= G:
            curr_sum += p*i*100
            curr_prob += p
        else:
            remain = max(0, G-curr_sum)
            curr_prob += math.ceil( remain/(i*100) )
            break

    ans = min(ans, curr_prob)


print(ans)

Measured memory_bytes: 41584
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    s = S()
    a = 0
    ans = 0
    f = 0
    i = 0
    while i < len(s) - 1:
        if s[i] == "A":
            a += 1
            i += 1
        elif s[i: i + 2] == "BC":
            ans += a
            i += 2
        else:
            a = 0
            i += 1

    print(ans)

    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 41056
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vec>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  ll n;
  cin >> n;
  vec c(n-1),s(n-1),f(n-1);
  for(ll i=0;i<n-1;i++)cin >> c[i] >> s[i] >> f[i];

  vec ans;

  for(ll i=0;i<n-1;i++){
    ll t=0;
    for(ll j=i;j<n-1;j++){
      t=max(t,s[j]);
      while(t%f[j]!=0)t++;
      t+=c[j];
    }
    ans.push_back(t);
  }


  ans.push_back(0);
  for(ll i=0;i<n;i++)cout << ans[i] << endl;

}

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

#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i,p,k) for (int i = p; i <= (int)(k); ++i)
#define FOREACH(it,x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); ++it)
#define ALL(x) x.begin(), x.end()
template<class T> void DUMP(const T& v) { FOREACH(it,v) cerr<<*it<<' '; cerr<<endl; }

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

typedef pair<int, int> pii;

int main() {
  int n;
  while (cin >> n, n) {
    int maxx = 0;
    int maxy = 0;
    int minx = 0;
    int miny = 0;
    vector<pii> v(1, pii(0,0));
    while(--n) {
      int a, d; cin >> a >> d;
      pii base = v[a];
      pii next = pii(base.first + dx[d], base.second + dy[d]);
      v.push_back(next);
    }
    REP(i, v.size()) {
      int x = v[i].first;
      int y = v[i].second;
      maxx = max(x, maxx);
      maxy = max(y, maxy);
      minx = min(x, minx);
      miny = min(y, miny);
    }
    cout << maxx - minx + 1 << ' ' << maxy - miny + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <list>
#include <map>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <bitset>
#include <utility>
#include <complex>
#include <assert.h>
#include <limits.h>
#include <iomanip>
//#include <bits/stdc++.h>
using namespace std;
#define rank rankk
#define mp make_pair
#define pb push_back
#define xo(a,b) ((b)&1?(a):0)
#define tm tmp

//#define LL ll
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,int> pli;
typedef pair<int,ll>pil;
typedef pair<ll,ll> pll;
//const double INF=1e20;
const int INF=0x3f3f3f3f;
//const int INF= 0x7fffffff;
//const ll INF=0x3f3f3f3f3f3f3f3fll;
const ll INFF=0x3f3f3f3f3f3f3fll;
//const ll INFF=1e14+5;
const int MAX=4e5+5;
//const ll MAXN=2e8;
//const int MAX_N=MAX;
const ll MOD=1e9+7;
//const ll MOD=998244353;
//const long double pi=acos(-1.0);
//const double eps=0.00000001;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
template<typename T>inline T abs(T a) {return a>0?a:-a;}
//#define double long double
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
inline ll powMM(ll a,ll b,ll M){
    ll ret=1;
    a%=M;
//    b%=M;
    while (b){
        if (b&1) ret=ret*a%M;
        b>>=1;
        a=a*a%M;
    }
    return ret;
}
//const long double eps=-1.0;
//clock_t t1 = clock();
//fprintf(stderr, "%ld ms\n", clock() - t1);
void open()
{
    freopen("in2.txt","r",stdin);
    freopen("out2.txt","w",stdout);
}
int n;
ll sum[MAX];
map<ll,int>cnt;
ll an;
int main()
{
    scanf("%d",&n);
    ll now=0,tem;
    cnt[0]=1;
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&tem);
        now+=tem;
        if(cnt[now])
            an+=cnt[now];
        cnt[now]++;
    }
    printf("%lld\n",an);
}
/*



4 1 1 3 1 5 5 1 3
*/


Measured memory_bytes: 12800
x,n=map(int,input().split())
p=list(map(int,input().split()))
pp=[i for i in range(0,102)]
p=list(set(pp)-set(p))
ans=1000
z=1000
num=len(p)
for i in range(num-1,-1,-1):
    a=p[i]
    if abs(x-a)<=z:
        z=abs(x-a)
        if a<ans:
            ans=a
            if ans==x:
                break
print(ans)

Measured memory_bytes: 9208
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
int n,Fa[1005],Limit[1005],dp[1005]/*含义见PPT*/;
bool pack[5005],tmp[5005];//进行背包
//pack[i]=true表示到目前为止存在一种方案满足跟他同色节点的权值之和为i
vector<int> vec[1005];
int main()
{
	scanf("%d",&n);
	for(int i=2;i<=n;i++)
	{
		scanf("%d",&Fa[i]);
		vec[Fa[i]].push_back(i);
	}
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&Limit[i]);
	}
	for(int i=n;i>=1;i--)
	{
		memset(pack,false,sizeof(pack));
		pack[0]=true;
		int sum=0;
		for(auto x : vec[i])//分别考虑每个儿子跟他同色还是异色
		{
			sum+=Limit[x]+dp[x];
			for(int j=0;j<=Limit[i];j++)//复制一遍防止背包过程中dp值循环利用
			{
				tmp[j]=pack[j];
			}
			for(int j=0;j<=Limit[i];j++)
			{
				pack[j]=false;//调了我一年QAQ
				if(j>=Limit[x]) pack[j]|=tmp[j-Limit[x]];//同色
				if(j>=dp[x]) pack[j]|=tmp[j-dp[x]];//异色
			}
		}
		bool possible=false;
		for(int j=Limit[i];j>=0;j--)
		{
			//由于所有儿子的Limit和dp值之和是固定的，所以跟他同色的节点权值的和越大，剩下来的就越少
			if(pack[j])
			{
				possible=true;
				dp[i]=sum-j;
				break;
			}
		}
		if(!possible)
		{
			printf("IMPOSSIBLE\n");
			return 0;
		}
	}
	printf("POSSIBLE\n");
}

Measured memory_bytes: 3240
# coding=utf-8

if __name__ == '__main__':
    N = int(input())
    all_list = {i for i in range(1, N+1)}
    A_list = list(map(int, input().split()))
    B_list = list(map(int, input().split()))
    C_list = list(map(int, input().split()))
    A_number = A_list[0]
    A_identity = set(A_list[1:])
    B_number = B_list[0]
    B_identity = set(B_list[1:])
    C_number = C_list[0]
    C_identity = set(C_list[1:])
    not_A_identity = all_list - A_identity

    cond1 = not_A_identity & C_identity
    cond2 = B_identity & C_identity

    suspected = cond1 | cond2
    print(len(suspected))



Measured memory_bytes: 5640
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = 1<<29;
typedef long long int ll;


int main(){
    string S;cin >> S;
    ll K;cin >> K;
    bool flg = true;
    char ans;
    for(int i = 0;i < 100 && i < K;++i){
        if(S[i] != '1'){
            flg = false;
            ans = S[i];
            break;
        }
    }
    cout << ((flg) ? '1' : ans);
}


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

int main(){
    string S;
    cin >> S;
    char tmp = S[0];
    for(int i=1; i<S.size(); i++){
        if(tmp != S[i]){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)
	sum := 0
	for i := 1; i <= n; i++ {
		s := strconv.FormatInt(int64(i), 10)
		if len(s)%2 == 1 {
			sum++
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
// #define IOFILE
#define F first
#define S second
#define pb push_back
#define eb emplace_back
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define debug(...) do{\
	fprintf(stderr, "%s - %d : (%s) = ", __func__, __LINE__, #__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename T> void _DO(T&&x){cerr << x << '\n';}
template<typename T, typename... A> void _DO(T&&x, A&&...As){cerr << x << ", ";_DO(As...);}
constexpr ll MOD = 1e9 + 7;

inline void solve() {
	int n; cin >> n;
	int h[n], dp[n];
	memset(dp, 0, sizeof(dp));
	for(int i = 0; i < n; ++i)
		cin >> h[i];
	dp[0] = 0, dp[1] = abs(h[1] - h[0]);
	for(int i = 2; i < n; ++i)
		dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]));
	cout << dp[n - 1] << '\n';
}	

int main() {
	cin.tie(nullptr), cout.tie(nullptr), ios::sync_with_stdio(false);
#ifdef IOFILE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("err.txt", "w", stderr);
	clock_t time = clock();
#endif
	solve();

#ifdef IOFILE
	cout << "\nUse " << static_cast<double>(clock() - time) / CLOCKS_PER_SEC << " seconds";
#endif
}


Measured memory_bytes: 4436
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
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 (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, Q; cin >> N >> Q;
	vector<int>a(N, 0);
	rep(i, 0, N)cin >> a[i];
	rep(i, 0, Q) {
		int x; cin >> x;
		int ans(0), sum(0), l(0);
		rep(i, 0, N) {
			sum += a[i];
			while (sum > x)sum -= a[l++];
			ans += i - l + 1;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3636
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# E - Red and Green Apples

x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
assert len(p) == a and len(q) == b and len(r) == c

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

pi = x - 1
qi = y - 1
ri = 0
while ri < c:
    if pi >= 0 and p[pi] < r[ri] and (qi < 0 or p[pi] <= q[qi]):
        p[pi] = r[ri]
        pi -= 1
        ri += 1
    elif qi >= 0 and q[qi] < r[ri] and (pi < 0 or q[qi] <= p[pi]):
        q[qi] = r[ri]
        qi -= 1
        ri += 1
    else:
        break

print(sum(p[:x] + q[:y]))


Measured memory_bytes: 105444
def main():
  n = int(input())
  
  dp = [0]*(n+1)
  dp[0] = 1
  mod = pow(10, 9) + 7
  for i in range(n+1):
    for j in range(i-2):
      dp[i] += dp[j]
      dp[i] %= mod
  
  print(dp[n])

if __name__ == "__main__":
  main()

Measured memory_bytes: 9192
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl
#define CE cout<<endl
#define pb push_back

ll n,m,a,b,c,x,y,z,aa[200010],ab[200010],ac[200010];
ll xa,xb,ua,ub;
bool r,ra,rb,rc[200010];
string s,sa,sb,sc;
char ca,cb,cc,cd[1010][1010];
vector<ll> va,vb,vc,vd,ve,vaa,vbb;
set<ll> st;

#define SIZ 200010


vector<vector<ll>> dp;

vector<vector<ll>> v2vec(int x,int y,int value=0){ return vector<vector<ll>>(y,vector<ll>(x,value)); }

int main(){
    cin>>s;
    n=s.size();
    m=0;
    for(int i=0;i<n;i++){
        //a+=(s[i]=='g');
        if(i%2){
            if(s[i]=='g')m++;
        }
        else{
            if(s[i]=='p')m--;
        }
    }
    C m E;
    
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<complex>
#include<cstdio>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 300005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
int dp[N];
int st[4*N];
void update(int i,int l,int r,int x,int v){
	if(l==r){
		st[i]=max(st[i],v);
		return;
	}
	int m=mid(l,r);
	if(x<=m)update(2*i+1,l,m,x,v);
	else update(2*i+2,m+1,r,x,v);
	st[i]=max(st[2*i+1],st[2*i+2]);
}
int qry(int i,int l,int r,int l1,int r1){
	if(l1<=l&&r<=r1)return st[i];
	if(r<l1||r1<l)return 0;
	return max(qry(2*i+1,l,mid(l,r),l1,r1),qry(2*i+2,mid(l,r)+1,r,l1,r1));
}
void solve(){
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	int ans=0;
	for(int i=n-1;i>=0;i--){
		int v=a[i];
		int l=max(0,v-k);
		int r=min(300000,v+k);
		dp[v]=max(dp[v],1+qry(0,0,300000,l,r));
		update(0,0,3e5,v,dp[v]);
		ans=max(ans,dp[v]);
	}
	cout<<ans;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 10056
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;


int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    ll sum=0;
    rep(i,n){
        if(i%2==0)sum+=a[i];
        else sum-=a[i];
    }
    vector<int>ans(n);
    ans[0]=sum;
    rep(i,n-1){
        ans[i+1]=2*a[i]-ans[i];
    }
    rep(i,n)cout<<ans[i]<<endl;
    return 0;
}

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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

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

constexpr long long mod = 1000000007;

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

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

    int n, k;
    cin >> n >> k;

    vi c(200000, 0);
    rep(i, n) {
        int t;
        cin >> t;
        c[t - 1]++;
    }
    int s = 0;
    rep(i, 200000) {
        if (c[i] > 0) {
            s++;
        }
    }

    sort(c.begin(), c.end());

    int cnt = 0;

    rep(i, 200000) {
        if (s <= k) {
            break;
        } else {
            if (c[i] > 0) {
                cnt += c[i];
                s--;
            }
        }
    }

    cout << cnt << endl;
}

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

int main() {
    int N, H, W;
    cin >> N >> H >> W;

    int ans = 0;
    rep(i, N) {
        int a, b;
        cin >> a >> b;
        if (H <= a && W <= b)
            ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import math
N = 5
H = 500
N,H = map(int,input().split())
As = []
Bs = []
for i in range(N):
    a,b = map(int,input().split())
    As.append(a)
    Bs.append(b)
A_max = max(As)
Bs_select = []
for b in Bs:
    if(b>A_max):
        Bs_select.append(b)
if(sum(Bs_select) < H):
    print(len(Bs_select) + math.ceil((H-sum(Bs_select))/A_max))
else:
    Bs_select.sort(reverse=True)
    S = 0
    cnt = 0
    for b in Bs_select:
        S += b
        cnt += 1
        if(S >= H):
            print(cnt)
            break


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define int ll
//#define int __int128
//#define ll __int128
typedef pair<int, int   > pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
//typedef complex<double> base;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < (int)(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef RUS_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";

template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}



void smain();

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

#ifdef RUS_HOME
    freopen("input", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef RUS_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}


void smain() {

    int n, a, b;
    cin >> n >> a >> b;

    if (a % 2 == b % 2) {
        cout << (b - a) / 2;
        return;
    }
    int ans1, ans2;
    {
        int aa = a, bb = b;
        ans1 = aa;
        aa = 1;
        bb -= ans1;
        ans1 += (bb - aa) / 2;
    }
    {
        int aa = a, bb = b;
        ans2 = n - bb + 1;
        aa += ans2;
        bb = n;
        ans2 += (bb - aa) / 2;
    }
    cout << min(ans1, ans2);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<stack>
#include<queue>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

int main(){
    int n, m, ans = 0;
    int all[100001];
    cin >> n;
    rep(i, n){
        cin >> all[i];
    }
    cin >> m;
    rep(i, m){
        int right = n, left = 0, mid;
        int inp;
        cin >> inp;
        while(left < right){
            mid = (right + left) / 2;
            if(all[mid] == inp){
                ans++;
                break;
            }else if(all[mid] < inp){
                left = mid + 1;
            }else{
                right = mid;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1548
#include <iostream>
using namespace std;
typedef long long ll;
int main(void){
    int n, a, b, d=1e9+7;
    ll c=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        c+=b;
        if(b<a){
            d=min(d, b);
        }
    }
    if(d==1e9+7){
        cout<<0<<endl;
    }else{
        cout<<c-d<<endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

   int n,m,l,i,j,k;

   long int A[101][101], B[101][101], C[101][101]={};

   scanf("%d %d %d",&n,&m,&l);

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

    for(j=0;j<m;j++){

       scanf("%ld",&A[i][j]);

    }

   }

   for(j=0;j<m;j++){

       for(k=0;k<l;k++){

           scanf("%ld",&B[j][k]);

       }

   }

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

       for(j=0;j<l;j++){

           for(k=0;k<m;k++){

               C[i][j]+=A[i][k]*B[k][j];

           }

           printf("%ld",C[i][j]);

           if (j<l-1) printf(" ");

       }

       printf("\n");

   }

   

   return 0;

}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){fastio
    ll Q;cin>>Q;
    set<l_l> st;
    auto mid=st.begin();
    ll sum_l=0,sum_r=0;
    ll b_sum=0;
    ll a_counter=0;
    rep(i,0,Q-1){
        ll q;cin>>q;
        if(q==1){
            ll a,b;cin>>a>>b;
            if(a_counter==0){
                st.insert(l_l(a,i));
                b_sum+=b;
                mid=st.find(l_l(a,i));
                a_counter++;
            }else if(a_counter%2==0){
                st.insert(l_l(a,i));
                b_sum+=b;
                a_counter++;
                if((*mid).first<=a){
                    sum_l+=(*mid).first;
                    ++mid;
                    sum_r+=a;
                    sum_r-=(*mid).first;
                }else{
                    sum_l+=a;
                }
                
            }else{
                st.insert(l_l(a,i));
                b_sum+=b;
                a_counter++;
                if((*mid).first>a){
                    sum_r+=(*mid).first;
                    --mid;
                    sum_l+=a;
                    sum_l-=(*mid).first;
                }else{
                    sum_r+=a;
                }
            }
        }else{
            if(a_counter%2==0){
                ll mi=(*mid).first;
                cout<<mi<<' ';
                cout<<(mi*(a_counter/2-1)-sum_l)+(sum_r-mi*(a_counter/2))+b_sum<<endl;
            }else{
                ll mi=(*mid).first;
                cout<<mi<<' ';
                cout<<(mi*(a_counter/2)-sum_l)+(sum_r-mi*(a_counter/2))+b_sum<<endl;
            }
        }
    }
    
    
    return 0;
}





Measured memory_bytes: 16052
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();

        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = scanner.nextInt();
        }

        int[] R = new int[N];
        Arrays.fill(R,0);

        int digit = 1;
        while(digit <= 1000000000){

            int C = 0;
            for (int i = 0; i < N; i++) {
                C = C ^ (A[i] & digit);
            }

            for (int i = 0; i < N; i++) {
                R[i] += digit & (C ^ A[i]);
            }

            digit = digit << 1;
        }

        System.out.print(R[0]);
        for (int i = 1; i < N; i++) {
            System.out.print(" " + R[i]);
        }
    }
}


Measured memory_bytes: 62516
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int[] pol = new int[1000000];
		ArrayList<Integer> p1 = new ArrayList<>();
		int[] pol_odd = new int[1000000];
		ArrayList<Integer> p1_odd = new ArrayList<>();
		
		int num = 1;
		for(int i=1;num<1000000;i++){
			p1.add(num);
			if((num&1)==1){
				p1_odd.add(num);
			}
			num = num * (i+3) / i;
		}
		
		for(int i=1;i<1000000;i++){
			int min = Integer.MAX_VALUE;
			for(int j=0;j<p1.size();j++){
				if(i-p1.get(j)<0) break;
				min = Math.min(min,pol[i-p1.get(j)]);
			}
			pol[i] = min + 1;
			
			min = Integer.MAX_VALUE;
			for(int j=0;j<p1_odd.size();j++){
				if(i-p1_odd.get(j)<0) break;
				min = Math.min(min,pol_odd[i-p1_odd.get(j)]);
			}
			pol_odd[i] = min + 1;
		}
		
		while(true){
			int x = in.nextInt();
			if(x==0) break;
			else{
				System.out.println(pol[x]+" "+pol_odd[x]);
			}
		}
	}	
}

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

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

  string C;
  for (char s : S) {
    int back = C.size() - 1;
    if (C.empty()) {
      C.push_back(s);
      continue;
    } else {
      if (C[back] == '(' && s == ')')
        C.pop_back();
      else
        C.push_back(s);
    }
  }

  int l = 0, r = 0;
  for (int i = 0; i < C.size(); i++) {
    if (C[i] == '(')
      l++;
    else
      r++;
  }

  string left, right;
  for (int i = 0; i < r; i++) left.push_back('(');
  for (int i = 0; i < l; i++) right.push_back(')');
  cout << left + S + right << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
//#include"functions.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define LDEPS 1e-9
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,m,n) for(int a=m;a<n;a++)
#define repn(a,m,n,p) for(int a=m;a<n;a+=p)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0xff,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

int main(){
	int k,x;
	cin>>x>>k;
	int s=k-x+1,e=k+x-1;
	for(int i=s;i<=e;i++){
		cout<<i<<" ";
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<stdlib.h>
#include<math.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int N, L;
int mn = INF;

int abss(int A){
    if(A < 0)return -A;
    else return A;
}


signed main(){
    cin >> N >> L;
    int ans = 0;
    for(int i = 0; i < N; i++){
        ans += L + i;
    }
    int res = ans;
    for(int i = 0; i < N; i++){
        if(mn > abss(res - (res - (L + i)))){
            ans = res - (L + i);
            mn = abss(res - (res - (L + i)));
        }
    }
    cout << ans << endl;

    return 0;
}
/*


*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define DUMP(v) for(auto& x : v) cerr << x << " "; cerr << endl;
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

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

  string s;
  cin >> s;
  vector<int> a(s.size() + 1, 0);
  a[0] = 0;

  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '<') chmax(a[i+1], a[i] + 1);
  }

  for (int i = s.size()-1; i >= 0; i--) {
    if (s[i] == '>') chmax(a[i], a[i+1] + 1);
  }

  ll ans = SUM(a);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2844
import sys

n = int(input())
li = list(map(int,input().split()))

n_str = str(n)
li_size = len(li)
max = li[0]
for i in range(li_size):
  if max == li[i]:
    continue
  elif max > li[i]:
    print("No")
    sys.exit()
  elif max < li[i]:
    max = li[i] - 1
print("Yes")

Measured memory_bytes: 14396
import java.util.*;
public class Main {
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int n = Integer.parseInt(sc.next());
      	int[] a = new int[n];
      	int count = 0;
				for (int i = 0; i < n; i++){
          a[i] = Integer.parseInt(sc.next());
        }
        while(true){
					boolean odd = false;
					for (int i = 0; i < n; i++){
						if(a[i]%2 != 0){
							odd = true;
						}
						}
						if(odd){
							break;
					}
					for(int i=0; i<n; i++){
						a[i] = a[i]/2;
					}
					count++;
				}
     System.out.print(count);
   }
}


Measured memory_bytes: 21844
from sys import stdin

a, b, c = [int(x) for x in stdin.readline().rstrip().split()]

flag = True
if a == b:
    if a == c:
        flag = False
    else:
        flag = True
elif a == c:
    flag = True
elif b == c:
    flag = True
else:
    flag = False

if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060