akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    string s;
    cin >> s;
    int a = INF;
    int z = 0;
    for(int i = 0; i < (int)s.size(); i++){
        if(s[i] == 'A'){
            if(a > i) a = i;
        }
        else if(s[i] == 'Z'){
            if(z < i) z = i;
        }
    }
    cout << z - a + 1 << endl;

    return 0;
}

Measured memory_bytes: 3724
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in));

		String line = br.readLine();
		int answer = Integer.parseInt(line);
		while(true) {
			String operator = br.readLine();

			if(operator.equals("="))break;

			line = br.readLine();
			int val = Integer.parseInt(line);
			if(operator.equals("+")) {
				answer += val;
			}else if (operator.equals("-")) {
				answer -= val;
			}else if (operator.equals("*")) {
				answer *= val;
			}else if (operator.equals("/")) {
				answer /= val;
			}
		}

		System.out.println(answer);
	}
}



Measured memory_bytes: 24368
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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;}
#define DEBUG_VLL(vec) REP(i, vec.size()) cerr<<vec[i]<<(i==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string  s; cin >> s;
    ll k; cin >> k;

    if (s.size()==1) {
        cout << k/2 << '\n';
        return 0;
    }

    ll ans = 0;
    vll tmpss;
    REP(i, s.size()) tmpss.push_back(s[i]-'a');
    tmpss.push_back(s[0]-'a');
    ll tmpsd = 0;
    for (int i=1; i<tmpss.size()-1; i++) {
        if (tmpss[i-1] == tmpss[i]) {
            if (tmpss[i]+1 == tmpss[i+1]) tmpss[i] = (tmpss[i]+2) % 26;
            else tmpss[i] = (tmpss[i]+1)%26;
            tmpsd++;
        }
    }
    ans += tmpsd;

    vll si;
    si.push_back(tmpss[tmpss.size()-2]);
    REP(i, s.size()) si.push_back(s[i]-'a');
    REP(i, s.size()) si.push_back(s[i]-'a');
    si.push_back(s[0]-'a');
    ll diff = 0;
    for (int i=1; i<si.size()-1; i++) {
        if (si[i-1] == si[i]) {
            if (si[i]+1 == si[i+1]) {
                si[i] = (si[i]+2) % 26;
            } else si[i] = (si[i]+1)%26;
            diff++;
        }
    }
    ans += diff*((k-2)/2);

    vll sssi;
    sssi.push_back(si[si.size()-2]);
    REP(i, s.size()) sssi.push_back(s[i]-'a');
    sssi.push_back(s[0]-'a');
    ll odiff = 0;
    for (int i=1; i<sssi.size()-1; i++) {
        if (sssi[i-1] == sssi[i]) {
            if (sssi[i]+1 == sssi[i+1]) {
                sssi[i] = (sssi[i]+2) % 26;
            } else sssi[i] = (sssi[i]+1)%26;
            odiff++;
        }
    }
    if (k%2==1) ans += odiff;
    
    vll tmps;
    if (k%2==1) tmps.push_back(sssi[sssi.size()-2]);
    else tmps.push_back(si[si.size()-2]);
    REP(i, s.size()) tmps.push_back(s[i]-'a');
    ll tmpld = 0;
    for (int i=1; i<tmps.size(); i++) {
        if (tmps[i-1] == tmps[i]) {
            if (tmps[i]+1 == tmps[i+1]) tmps[i] = (tmps[i]+2) % 26;
            else tmps[i] = (tmps[i]+1)%26;
            tmpld++;
        }
    }
    ans += tmpld;

    cout << ans << '\n';

    return 0;
}


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

using namespace std;

#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))


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

template <class T> inline T gcd(T a, T b) { while (b) { a = a%b; swap(a, b); } return a; }
template <class T> inline T bigmod(T p, T e, T m) {
	T ret = 1;
	for (; e > 0; e >>= 1) {
		if (e & 1) ret = (ret * p) % m; p = (p * p) % m;
	} return (T)ret;
}



int main()
{
	//cout.setf(ios::fixed); cout.precision(10);
	ios_base::sync_with_stdio(false);  cout.tie(nullptr); cin.tie(nullptr);

	map<char, int> items;

	int n;
	cin >> n;
	string s;
	cin >> s;

	for (int i = 0; i < n; i++)
	{
		items[s[i]]++;
	}

	if (items['R'] > items['B'])
	{
		cout << "Yes"<<endl;
	}
	else
	{
		cout << "No" << endl;

	}

	return 0;
}

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

int main() {
	int n, d, x; cin >> n >> d >> x;
	vector<int>a(n); for (auto&& i : a)cin >> i;
	
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int tmp = a[i], day = 1;
		while (d >= day) {
			ans++;
			day += tmp;			
		}
	}
	cout << ans + x << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
using ll=long long;
const ll MOD=1000000007,MOD2=998244353;



int main() {
    string S;
    ll N;
    cin>>N>>S;
    vector<int> R(0),G(0),B(0);
    rep(i,N){
        if(S.at(i)=='R'){R.push_back(i);}
        if(S.at(i)=='G'){G.push_back(i);}
        if(S.at(i)=='B'){B.push_back(i);}
    }
    ll ans=0;
    rep(i,sz(R)){
        rep(j,sz(G)){
            int r=R.at(i),g=G.at(j);
            ans+=sz(B);
            if(binary_search(B.begin(),B.end(),2*g-r)){ans--;}
            if(binary_search(B.begin(),B.end(),2*r-g)){ans--;}
            if((r+g)%2==0 && binary_search(B.begin(),B.end(),(r+g)/2)){ans--;}
        }
    }
    cout<<ans<<endl;
}


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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    int a[N+1];
    bool checked[N+1];
    REP(i,N){
        cin>>a[i+1];
        checked[i+1]=false;
    }
    int cnt;cnt=0;
    int next;next=1;
    while(checked[next]==false){
        cnt++;
        checked[next]=true;
        next=a[next];
        //debug(next);
        if(next==2){
            cout<<cnt<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;

}

Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000001145
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};

int ans=0;
int k,n;
int q[111111],l[111111],r[111111],sum[111111];
vector<int> prime;
unordered_map<int,int> prco;
void prfac(int n){
	int a=2;
	while(n>=a*a){
		if(n%a==0){
			prime.push_back(a);
			n/=a;
		}
		else{
			a++;
		}
	}
	prime.push_back(n);
}
signed main(){
	cin>>n;
	rep(i,n)cin>>l[i]>>r[i];
	int befsize=prime.size(),aftsize;
	for(int i=3;i<=111111;i++){
		prfac(i);
		prfac((i+1)/2);
		aftsize=prime.size();
		if(aftsize-befsize==2)sum[i]++;
		befsize=prime.size();
	}
	rep(i,111111){
		sum[i+1]+=sum[i];
	}
	rep(i,n){
		cout<<sum[r[i]]-sum[l[i]-1]<<endl;
	}
}


Measured memory_bytes: 12652
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    s64 k, n;
    cin >> k >> n;
    vs64 a(n);
    rep (i, n)
    {
        cin >> a[i];
    }

    s64 ans = 1e18;
    for (int i = 1; i < n; ++i)
    {
        ans = MIN(ans, k - (a[i] - a[i - 1]));
    }
    ans = MIN(ans, k - (k - a[n - 1] + a[0]));

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<vector<int>> Graph;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl

vector<int> color;
// if the graph has a cycle of odd length then return
// false.
bool dfs(const Graph& g, int v, int col) {
  color[v] = col;
  for(auto u : g[v]) {
    if(color[u] != -1) {
      if(color[u] == col) return false;
      continue;
    }
    if(!dfs(g, u, 1 ^ col)) return false;
  }
  return true;
}

vector<int> dist;
// bfs from the fixed s.
void bfs(const Graph& g, int s) {
  queue<int> que;
  dist[s] = 0;
  que.push(s);
  while(que.size()) {
    int v = que.front();
    que.pop();
    for(int u : g[v]) {
      if(dist[u] >= 0) continue;
      dist[u] = dist[v] + 1;
      que.push(u);
    }
  }
}

int main() {
  int n;
  cin >> n;
  Graph g(n);
  rep(i, n) {
    string s;
    cin >> s;
    rep(j, n) if(s[j] == '1') g[i].push_back(j);
  }

  color.assign(n, -1);
  if(!dfs(g, 0, 0)) {
    cout << -1 << endl;
    return 0;
  }
  
  int ans = 0;
  rep(i, n) {
    dist.assign(n, -1);
    bfs(g, i);
    rep(j, n) ans = max(ans, dist[j]);
  }

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

Measured memory_bytes: 512
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
from collections import deque


def bfs(xg,yg):
    queue = deque([(xs,ys,0)])
    while queue:
        x,y,dep = queue.popleft()
        l = []
        f1 = True
        f2 = True
        f3 = True
        f4 = True
        for i in range(1,k+1):
            if f1:
                if cord[y][x+i] == '.':
                    l.append((x+i,y))
                elif cord[y][x+i] == '@' or cord[y][x+i] != dep+1:
                    f1 = False
            if f2:
                if cord[y][x-i] == '.':
                    l.append((x-i,y))
                elif cord[y][x-i] == '@' or cord[y][x-i] != dep+1:
                    f2 = False
            if f3:
                if cord[y+i][x] == '.':
                    l.append((x,y+i))
                elif cord[y+i][x] == '@' or cord[y+i][x] != dep+1:
                    f3 = False
            if f4:
                if cord[y-i][x] == '.':
                    l.append((x,y-i))
                elif cord[y-i][x] == '@' or cord[y-i][x] != dep+1:
                    f4 = False
            if not (f1 or f2 or f3 or f4):
                break
        for nx, ny in l:
            if cord[ny][nx] == '.':
                cord[ny][nx] = dep+1
                if (nx,ny) == (xg,yg):
                    return dep+1
                else:
                    queue.append((nx,ny,dep+1))
    return -1

h,w,k = iim()
ys,xs,yg,xg = iim()

cord = [['@']*(w+2)]
for i in range(h):
    cord.append(['@']+list(input())+['@'])
cord.append(['@']*(w+2))
cord[ys][xs] = '#'
#for i in cord:
#    print(*i)
#print(len(cord),len(cord[0]))

print(bfs(xg,yg))


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

int main(void){
    int n, W;
    cin >> n >> W;
    vector<ll> dp(W+1, -1);
    dp[0] = 0;
    rep(i,n){
        ll w,v;
        cin >> w >> v;
        for (int j = W; j >= 0; j--) {
            if (dp[j] == -1) continue;
            if (j+w > W) continue;
            dp[j+w] = max(dp[j+w], dp[j]+v);
        }
    }
    cout << *max_element(all(dp)) << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

int main()
{
    ll n,item,temp,ans=0;
    vector<ll>A;
    vector<ll>B;
    vector<ll>C;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>item;
        item--;
        A.push_back(item);
    }
    for(int i=0;i<n;i++)
    {
        cin>>item;
        B.push_back(item);
    }
    for(int i=0;i<n-1;i++)
    {
        cin>>item;
        C.push_back(item);
    }
    for(int i=0;i<n;i++)
    {
        ans+=B[A[i]];
        if(i==0)
            continue;
        if(A[i-1]<n-1 && A[i-1]+1==A[i])
        {
          ans+=C[A[i-1]];
        }

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


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define endl "\n"
#define loop(i,s,e) for(int i=s;i<e;i++)
#define int long long
#define mp make_pair
#define pii pair<int,int>
#define mset(a,f)  memset(a , f , sizeof(a))
#define pb push_back
const int N = 2e6 + 6;
const int M = 1e9 + 7;
int A[N];
int n;

void solve()
{
	cin >>n;

	if(n <= 9)
	{
		cout << n;
		return;
	}

	queue <int> q;

	loop(i,1,10)q.push(i);
	n -= 9;
	while(1)
	{
		int cur = q.front();
		q.pop();
		int  prev = cur%10;
		cur *= 10;
		if(prev >= 1)
		{
			n--;
			q.push(cur+prev-1);
			if(n==0)
			{
				cout << cur+prev-1;
				return;
			}
		}
		n--;
		q.push(cur+prev);
		if(n==0)
		{
			cout << cur+prev;
			return;
		}
		if(prev <= 8)
		{
			n--;
			q.push(cur+prev+1);
			if(n==0)
			{
				cout << cur+prev+1;
				return;
			}
		}
	}
}
 
int32_t main()
{
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
    
 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
const long long maxn=(1e5+10);
long long n,a[maxn],b[maxn],ans=0;
int main()
{
	cin>>n;
	for(long long i=1;i<=n+1;i++)
		cin>>a[i];
	for(long long i=1;i<=n;i++)
	{
		cin>>b[i];
		if(b[i]>=a[i]+a[i+1])
		{
			ans+=(a[i]+a[i+1]);
			a[i]=a[i+1]=0;
			continue;
		}
		if(b[i]<=a[i])
			a[i]-=b[i],ans+=b[i];
		else
		{
			long long tmp=b[i]-a[i];
			a[i+1]-=tmp;
			ans+=b[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
import itertools
import functools

N, M = map(int, input().split())
A = list(map(int, input().split()))

A = list(map(lambda x: x // 2, A))

def gcd(a, b):
    while b != 0:
        a, b = b, a % b

    return a

def lcm(a, b):
    return a // gcd(a, b) * b

def ok(A):
    def f(x, y):
        return x % 2 == y % 2
    return functools.reduce(f, A, A[0])

pow2 = functools.reduce(gcd, A, A[0])
while pow2 % 2 == 0:
    A = list(map(lambda x: x // 2, A))
    pow2 //= 2
    M //= 2

x = functools.reduce(lcm, A, 1)

if x % 2  == 0:
    print(0)
else:
    print(M // x - M // (2 * x))

Measured memory_bytes: 14764
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<bool>> s(H, vector<bool>(W,false)); // 黒はfalse
    int num_white = 0;
    rep(i,0,H) rep(j,0,W) {
        char c;
        cin >> c;
        if (c == '.') { s[i][j] = true; num_white++; }
    }

    // ans = num_white - 最短経路長
    queue<pair<int,int>> q;
    vector<vector<int>> dist(H, vector<int>(W,-1));
    dist[0][0] = 0;
    q.push({0,0});
    int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
    while (!q.empty()) {
        int y = q.front().first, x = q.front().second;
        q.pop();
        rep(i,0,4) {
            int nx = x+dx[i], ny = y+dy[i];
            if (nx < 0 || W <= nx || ny < 0 || H <= ny) continue;
            if (dist[ny][nx] != -1) continue;
            if (!s[ny][nx]) continue;
            q.push({ny,nx});
            dist[ny][nx] = dist[y][x] + 1;
        }
    }

    if (dist[H-1][W-1] == -1) cout << -1 << endl;
    else cout << num_white - dist[H-1][W-1] - 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define maxn 110
typedef long long ll;
int H,W;
char s[maxn][maxn];
int ans[maxn][maxn];
int main(void)
{
    scanf("%d %d\n",&H,&W);
    for(int i =1 ;i <= H;i ++)
    {
        for(int j =1 ;j <= W;j ++)
        {
            ans[i][j]=INT_MAX;
            scanf("%c",&s[i][j]);
        }
        char ch;
        scanf("%c",&ch);
    }
    ans[1][1] =(s[1][1]=='#');
    for(int i =1;i <=H;i ++)
    {
        for(int j = 1;j <=W;j ++)
        {
            if(i>=2)
                ans[i][j] = min(ans[i][j],ans[i-1][j]+(s[i-1][j]=='.'&&s[i][j]=='#'));
            if(j>=2)
                ans[i][j] = min(ans[i][j],ans[i][j-1]+(s[i][j-1]=='.'&&s[i][j]=='#'));
        }
    }
    printf("%d\n",ans[H][W]);
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
  public static void main(String[] args) throws IOException {
 
    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
 
    String revStr = "";
    while (input.ready()) {
      char[] str = input.readLine().toCharArray();
      for (char ch : str) {
        revStr = ch + revStr;
      }
      System.out.println(revStr);
    }
  }
 
}

Measured memory_bytes: 24024
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 100000
#define MAX_M 100000
const int INF = 1e9;
 
int main() {
  int n;
  int long ans=0;
  cin>>n;
  vector<int> A(n);
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      for(int z=j+1;z<n;z++){
        if(A[i]<A[j]+A[z]){
          ans++;
        }
        else{
          break;
        }
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
n=int(input())
xlist=list(map(int,input().split()))
ber1=sum(xlist)//n
ber2=sum(xlist)//n+1
ans1=0
for i in range(n):
    ans1+=(xlist[i]-ber1)**2
ans2=0
for i in range(n):
    ans2+=(xlist[i]-ber2)**2
if ans1>ans2:
    print(ans2)
else:
    print(ans1)


Measured memory_bytes: 38256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var sc *bufio.Scanner

const BufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

func min(a ...int) int {
	res := a[0]
	for i := 1; i < len(a); i++ {
		if res > a[i] {
			res = a[i]
		}
	}
	return res
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := nextInt()
	b := nextInt()

	_, _ = fmt.Fprintf(writer, "%d", min(n*a, b))
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
bool res[40005];
int n,q,A[25];

void solve(int now,int ans)
{
    res[ans]=true;
    if(now>n) return ;
    solve(now+1,ans+A[now]);
    solve(now+1,ans);
}

int main()
{
    ios::sync_with_stdio(false);    
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>A[i];
    }
    solve(0,0);
    cin>>q;
    for(int i=1;i<=q;i++)
    {
        int M;
        cin>>M;
        if(res[M]==0) cout<<"no"<<endl;
        else cout<<"yes"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define fastcin  ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main(){

	fastcin
	
	ll a, b, n;
	cin >> a >> b >> n;
	
	ll d = n/b;
	ll e = d*b-1;
	
	if(d == 0) cout << floor((a*n)/(double)b) - a*floor(n/(double)b) << endl;
	else cout << max(floor((a*e)/(double)b) - a*floor(e/(double)b), floor((a*n)/(double)b) - a*floor(n/(double)b)) << endl;
		
	      
	return 0;
}



Measured memory_bytes: 3884
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

use std::cmp;

#[allow(dead_code)]
fn find_min(x: &[u64]) -> u64 {
    let mut min: u64 = x[0];
    let mut x_iter = x.iter();
    while let Some(i) = x_iter.next() {
        min = cmp::min(*i, min);
    }
    return min
}

#[allow(dead_code)]
fn find_max(x: &[u64]) -> u64 {
    let mut max: u64 = x[0];
    let mut x_iter = x.iter();
    while let Some(i) = x_iter.next() {
        max = cmp::max(*i, max);
    }
    return max
}


fn main() {
    let init: Vec<usize> = read_vec();
    let n = init[0];
    let m = init[1];

    let mut favorite: Vec<Vec<u32>> = Vec::new();

    for _i in 0..n {
        let mut tmp: Vec<u32> = read_vec();
        tmp.remove(0);
        favorite.push(tmp);
    }

    let mut count: Vec<u32> = vec![0; m];

    for i in 0..n {
        for j in favorite[i].iter() {
            count[(j-1) as usize] += 1;
        }
    }

    let mut ans: u32 = 0;
    for i in 0..m {
        if count[i] == n as u32 {
            ans += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
//prepared by dumb
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define llu unsigned long long int
#define scll(x) scanf("%lld",&x)
#define scld(x) scanf("%lf",&x)
#define scull(x) scanf("%llu",&x)
#define scch(x) scanf(" %c",&x)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define ppb() pop_back()
#define ppf() pop_front()
#define Pi acos(-1.0)
#define INF 1e18
#define ff first
#define ss second
#define mpr make_pair
ll  _xor(ll a,ll b){return a^b;}
ll _and(ll a,ll b){return a&b;}
ll _or(ll a,ll b){return a|b;}
ll _not(ll a){ return ~a;}
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
           #ifndef ONLINE_JUDGE 
         freopen("input.txt","r",stdin);
         freopen("output.txt","w",stdout);
         #endif
    ll b,c,d,e,f,g,h,i,j,k,l1,l2,l3,t,a,m,n,p,q,r,s,u,v,x,y,c1,c2,c3;

        string str;
               scll(k);
              cin>>str;
             if(str.length()<=k)
             	cout<<str;
             else
             {
             for(i=0;i<k;i++)
             {
             	cout<<str[i];
             }
             cout<<"...";
             }
return 0;
}

Measured memory_bytes: 3676
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn solve(n: usize, x: u64, sizes: &Vec<u64>) -> u64 {
    if x == 0 {
        0
    } else if n == 0 {
        x
    } else {
        if x <= sizes[n - 1] + 1 {
            solve(n - 1, x - 1, &sizes)
        } else if x <= sizes[n - 1] + 2 {
            solve(n - 1, sizes[n-1], &sizes) + 1
        } else if x <= sizes[n - 1] * 2 + 2 {
            solve(n - 1, sizes[n-1], &sizes) + 1 + solve(n - 1, x - sizes[n-1] - 2, &sizes)
        } else {
            solve(n - 1, sizes[n-1], &sizes) * 2 + 1
        }
    }
}

fn main() {

    let mut sizes = vec![1u64; 60];
    for i in 1..51 {
        sizes[i] = sizes[i - 1] * 2 + 3;
    }

    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let x: u64 = sc.cin();
    put!(solve(n, x, &sizes));
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int p[210000];
int inv[210000];
int segtree[2][524288];
int ret[210000];
int query(int a,int b,int c,int d,int e,int f){
	if(d<a||b<c)return mod;
	else if(c<=a&&b<=d)return segtree[f][e];
	return min(query(a,(a+b)/2,c,d,e*2,f),query((a+b)/2+1,b,c,d,e*2+1,f));
}
void update(int a,int b,int c){
	a+=262144;
	while(a){
		segtree[c][a]=min(segtree[c][a],b);
		a/=2;
	}
}
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){scanf("%d",p+i);p[i]--;}
	for(int i=0;i<2;i++)for(int j=0;j<524288;j++)segtree[i][j]=mod;
	for(int i=0;i<a;i++)inv[p[i]]=i;
	for(int i=0;i<a;i++){
		update(i,p[i],i%2);
	}
	priority_queue<pair<int,pair<int,int> > >Q;
	Q.push(make_pair(-query(0,262143,0,a-1,1,0),make_pair(0,a)));
	int ind=0;
	while(Q.size()){
		int cost=-Q.top().first;
		int L=Q.top().second.first;
		int R=Q.top().second.second;
		Q.pop();
		int at=inv[cost];
		int q=query(0,262143,at,R-1,1,(at+1)%2);
		int at2=inv[q];
		ret[ind++]=cost;
		ret[ind++]=q;
		if(L<at){
			Q.push(make_pair(-query(0,262143,L,at-1,1,L%2),make_pair(L,at)));
		}
		if(at+1<at2){
			Q.push(make_pair(-query(0,262143,at+1,at2-1,1,(at+1)%2),make_pair(at+1,at2)));
		}
		if(at2+1<R){
			Q.push(make_pair(-query(0,262143,at2+1,R-1,1,(at2+1)%2),make_pair(at2+1,R)));
		}
	}
	for(int i=0;i<a;i++){
		if(i)printf(" ");
		printf("%d",ret[i]+1);
	}
	printf("\n");
}

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

#define  int        long long int
 #define    sp(x)                 setprecision(x)
#define    bp(x)           __builtin_popcount(x)
 #define  ld         long double
 #define  f(i,j,n)            for(int i = j; i <= n; i++)
#define  r(i,n,j)       for(int i = n; i >= j; i--)
 #define  all(container)       container.begin() , container.end()
#define  sz(container)   (int)container.size()
 #define  ff             first
#define  ss             second
 #define  pii      pair <int , int>
#define  sp(x)       setprecision(x)
 #define  endl    "\n"
#define  mod  1000000007
 #define  pb    push_back
#define  mp    make_pair
 #define  T     int ttt; cin >> ttt; while(ttt--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

int power(int x, int y, int p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0)  
    {     
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res; 
}

int32_t main()
{
    fast
    ld a,b;
    cin>>a>>b;
    int n=a*b;
    cout<<n;
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
#define D isdigit(c=getchar())
#define min(a,b) ((a)<(b)?(a):(b))
inline int getint(){
    int c,l=0,x;
    for (;!D;l=c)if(c==EOF)return 1<<31;
    for (x=c-'0';D;x=x*10+c-'0')if(c==EOF) break;
    return l=='-'?-x:x;
}
int buf[100];
inline int putint(int x){
    int i=0;
    x=x<0?putchar('-'),-x:x;
    for (;buf[i++]=x%10,x;x/=10);
    for (i=i-1?i-1:1;i--;putchar(buf[i]+'0'));
    return 1;
}
const int N=230000;
int n,q,a[N],b;
long long k;
int q1,q2;
long long min1[N*3],min2[N*3],min3[N*3],add1[N*3],add2[N*3],add3[N*3];
void Add1(int o,int l,int r){
	if(q1<=l&&r<=q2){add1[o]+=k;min1[o]+=k;return;}
	int mid=(l+r)>>1;
	if(q1<=mid)Add1(o<<1,l,mid);
	if(q2>mid)Add1(o<<1|1,mid+1,r);
	min1[o]=min(min1[o<<1],min1[o<<1|1])+add1[o];
}
void Add2(int o,int l,int r){
	if(q1<=l&&r<=q2){add2[o]+=k;min2[o]+=k;return;}
	int mid=(l+r)>>1;
	if(q1<=mid)Add2(o<<1,l,mid);
	if(q2>mid)Add2(o<<1|1,mid+1,r);
	min2[o]=min(min2[o<<1],min2[o<<1|1])+add2[o];
}
void Add3(int o,int l,int r){
	if(q1<=l&&r<=q2){add3[o]+=k;min3[o]+=k;return;}
	int mid=(l+r)>>1;
	if(q1<=mid)Add3(o<<1,l,mid);
	if(q2>mid)Add3(o<<1|1,mid+1,r);
	min3[o]=min(min3[o<<1],min3[o<<1|1])+add3[o];
}
void getmin1(int o,int l,int r,long long z){
	if(q1<=l&&r<=q2){k=min(k,min1[o]+z);return;}
	int mid=(l+r)>>1;
	if(q1<=mid)getmin1(o<<1,l,mid,z+add1[o]);
	if(q2>mid)getmin1(o<<1|1,mid+1,r,z+add1[o]);
}
void getmin2(int o,int l,int r,long long z){
	if(q1<=l&&r<=q2){k=min(k,min2[o]+z);return;}
	int mid=(l+r)>>1;
	if(q1<=mid)getmin2(o<<1,l,mid,z+add2[o]);
	if(q2>mid)getmin2(o<<1|1,mid+1,r,z+add2[o]);
}
void getmin3(int o,int l,int r,long long z){
	if(q1<=l&&r<=q2){k=min(k,min3[o]+z);return;}
	int mid=(l+r)>>1;
	if(q1<=mid)getmin3(o<<1,l,mid,z+add3[o]);
	if(q2>mid)getmin3(o<<1|1,mid+1,r,z+add3[o]);
}
int main(){
    n=getint();q=getint();a[0]=getint();b=getint();
    q1=1;q2=n;k=0x1f3f3f3f3f3f3f3f;
    Add1(1,1,n);Add2(1,1,n);Add3(1,1,n);
    q1=b;q2=b;k=-0x1f3f3f3f3f3f3f3f;
    Add1(1,1,n);Add2(1,1,n);Add3(1,1,n);
    for(int i=1;i<=n;i++){
    	q1=i;q2=i;k=i;Add2(1,1,n);k=-i;Add3(1,1,n);
	}
	for(int i=1;i<=q;i++)a[i]=getint();
	for(int i=1;i<=q;i++){
		q1=1;q2=n;k=abs(a[i]-a[i-1]);
		Add1(1,1,n);Add2(1,1,n);Add3(1,1,n);
		q1=1;q2=a[i];k=0x3f3f3f3f3f3f3f3f;
		getmin3(1,1,n,0);
		long long s1=k+a[i]-abs(a[i]-a[i-1]);
		q1=a[i]+1;q2=n;k=0x3f3f3f3f3f3f3f3f;
		if(q1<=q2)getmin2(1,1,n,0);
		long long s2=k-a[i]-abs(a[i]-a[i-1]);
		q1=a[i-1];q2=a[i-1];k=0x3f3f3f3f3f3f3f3f;
		getmin1(1,1,n,0);
		long long s3=k;
		s1=min(s1,s2);
		if(s1<s3){
			k=s1-s3;
			Add1(1,1,n);Add2(1,1,n);Add3(1,1,n);
		}
	}
	q1=1;q2=n;k=0x3f3f3f3f3f3f3f3f;
	getmin1(1,1,n,0);
	cout<<k<<endl;
	return 0;
}

Measured memory_bytes: 32384
#include<iostream>
#include<cstdio>
#include<cstring>
#define maxn 110
using namespace std;
struct P{
	int x,y;
}red[maxn],blue[maxn];
int n;
bool f[maxn][maxn];
bool used[maxn];//表示用过与否的标记
int match[maxn];
bool DFS(int pos)
{
    for(int i=1; i<=n; i++)
    {
        if(f[pos][i]&&used[i]==false)
        {
            used[i] = true;
            if(match[i]==0 || DFS(match[i])) //如果这个点i还未匹配则pos和他匹配，如果这个点已经匹配，那么如果本来和他匹配的点match[i]还能找到另一个点匹配则pos把i“抢”过来，让match[i]去匹配另一个点，否则就不干涉i和match[i]匹配
            {
                match[i] = pos;
                return true;
            }
        }
    }
    return false; 
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)  scanf("%d%d",&red[i].x,&red[i].y);
	for(int i=1;i<=n;i++)  scanf("%d%d",&blue[i].x,&blue[i].y);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(red[i].x<blue[j].x&&red[i].y<blue[j].y)
			{
				//cout<<i<<" "<<j<<endl;
				f[i][j]=true;
			}
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		memset(used,false,sizeof(used));
		if(DFS(i)==true)
		{
			ans++;
		}
	}
	printf("%d\n",ans);
	return 0;	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long 
#define pb push_back
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<int>
#define vll vector<long long>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl; 
#define cno cout << "No" << endl;
#define mod (long long)1000000007
#define mod2 998244353
#define INT_MAX1 900000000
#define MAXN 2000000
#define INF INT_MAX





void solve()
{
  int n;
  cin >> n;
  int x = n/500;
  n%=500;
  x = x*1000+(n/5)*5;
  cout << x<< endl;
}

signed main()
{
    
    speed;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;

int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(rall(a));
    ll ans = a[0];
    ll count = n - 1;
    ll tmp = 1;
    ll cnt = 0;
    ll i = 1;
    while(true){
        if(tmp == count || cnt == count || i >= n) break;
        if(cnt == 2){
            cnt = 0;
            i++;
        }
        ans += a[i];
        tmp++;
        cnt++;
    }
    print(ans);
}



Measured memory_bytes: 4736
/**In The Name Of Allah*/

#include<bits/stdc++.h>
#include<numeric>

using namespace std;
#define pri(n)          printf("%d\n",n)
#define prll(n)         printf("%lld\n",n)
#define prd(n)          printf("%lf\n",n)
#define scll(n)         scanf("%lld",&n)
#define sci(n)          scanf("%d",&n)
#define scd(n)          scanf("%lf",&n)
#define pi              acos(-1)//inbuilt M_PI
#define ll              long long
#define pb              push_back
#define vsort(v)        sort(v.begin(),v.end())
#define asort(n)        sort(ar,ar+n)
#define yes             cout<<"Yes\n"
#define no              cout<<"No\n"
#define for1(i,n)       for(i=1;i<=n;i++)
#define for0(i,n)       for(i=0;i<n;i++)
#define mod             1000000007
#define watch(x)        cout << (#x) << " is " << (x) <<"\n";


int main()
{
    /*freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);*/
    /*ios_base::sync_with_stdio(false);
    cin.tie(NULL);/**Dont't use scanf of printf*/
    ll i,a,b,len,l,r,d,n,t,minn,sum=0,cnt=0,odd;
    cin>>n;
    ll ar[n+5];
    for1(i,n) cin>>ar[i];
    for1(i,n){
        if(i&1 && ar[i]&1) cnt++;
    }
    cout<<cnt<<endl;


    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define int long long
int a, b, q;
int s[123456], t[123456];
pair<int, int> fs(int k) {
	int l = 0, r = a + 1;
	while (r - l > 1) {
		if (s[l] == k || s[r] == k)return make_pair(0, 0);
		int mid = (l + r) / 2;
		if (s[mid] < k)l = mid;
		else r = mid;
	}
	if (s[l] == k || s[r] == k)return make_pair(0, 0);
	return make_pair(k - s[l], s[r] - k);
}
pair<int, int> ft(int k) {
	int l = 0, r = b + 1;
	while (r - l > 1) {
		if (t[l] == k || t[r] == k)return make_pair(0, 0);
		int mid = (l + r) / 2;
		if (t[mid] < k)l = mid;
		else r = mid;
	}
	if (t[l] == k || t[r] == k)return make_pair(0, 0);
	return make_pair(k - t[l], t[r] - k);
}
signed main() {
	cin >> a >> b >> q;
	s[0] = -10000000001;
	t[0] = -10000000001;
	for (int i = 1; i <= a; i++)cin >> s[i];
	for (int j = 1; j <= b; j++)cin >> t[j];
	s[a + 1] = 20000000001;
	t[b + 1] = 20000000001;
	for (int i = 0; i < q; i++) {
		int p; cin >> p;
		pair<int, int>ps, pt;
		ps = fs(p); pt = ft(p);
		cout << min(min(max(ps.first, pt.first), max(ps.second, pt.second)), min(min(ps.first * 2 + pt.second, pt.first * 2 + ps.second), min(ps.first + pt.second * 2, pt.first + ps.second * 2))) << endl;
	}
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mkp make_pair
#define rep(i,s,f) for(i=s;i<f;i++)
#define db cout<<'h'<<'i'<<endl 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PI 3.14159265
#define mod 1000000007
#define mod2 998244353
#define space 100005
#define lg 18
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;

    cin>>n;
    int arr[n+1];
    rep(i,1,n+1)cin>>arr[i];
    
    int c=0;
    sort(arr+1,arr+n+1);
    int a=arr[n/2];
    int b=arr[n/2+1];
    cout<<b-a;
    return 0;
}



Measured memory_bytes: 640
n = int(input())
l = [tuple(map(int, input().split())) for i in range(n)]

flag = True
i = 0
while(flag and i < n):
    if i == 0:
        dif = l[i][1] + l[i][2]
        t = 0
    else:
        dif = abs(l[i][1] - l[i-1][1]) + abs(l[i][2] - l[i-1][2])
        t = l[i-1][0]
    if l[i][0] - t < dif:
        flag = False
    elif (l[i][0] - t) % 2 != dif % 2:
        flag = False
    i += 1

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


Measured memory_bytes: 17324
#include <bits/stdc++.h>
 #define ll long long
 #define int long long
 #define MOD  1000000007
 #define MAX 500005
 #include<iomanip>
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define x first
 #define y second
using namespace std;
int gcd(int a, int b);
  
int power(int x, unsigned int y, unsigned int m)
{
    if (y == 0)
        return 1;
    int p = power(x, y/2, m) % m;
    p = (p * p) % m;
  
    return (y%2 == 0)? p : (x * p) % m;
}
ll modInverse(int a, int m)
{
    int g = gcd(a, m);
   
    {
        // If a and m are relatively prime, then modulo inverse
        // is a^(m-2) mode m
      
             return power(a, m-2, m);
    }
}
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
//void spf(ll num)
//{
//    fore(i,0,num+1)arr[i]=i;
//    for(ll i=2;i<=num;i+=2)
//    {
//        arr[i]=2;
//    }
//    for(ll i=3;i<=num;i+=2)
//    {
//        if(arr[i]==i)
//        for(ll j=i;j<=num;j+=i)
//        {
//           if(arr[j]==j) arr[j]=i;
//        }
//    }
//}
 
 int32_t main()
{
    Need_for_speed(activated);
//    satisfy
//    {}
ll k;cin>>k;
    string a,b;
    cin>>a>>b;
    for(ll i=0;i<a.length();i++)cout<<a[i]<<b[i];
    return 0;
    }


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

int main(void)
{
    int n;
    cin >> n;
    vector<int> p(n);
    for(auto i=0; i<n; i++)
        cin >> p[i];

    int ans = 0;
    for(int i=0; i < n-2; i++)
        if((p[i]-p[i+1])*(p[i+1]-p[i+2])>0)
            ans++;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;



void main() {
    int n;
    scan(n);
    auto a = readln.split.to!(int[]);

    int[int] c;
    foreach (ai ; a) {
        int b = ai;
        for (int j = 2; j*j <= ai; j++) if (b % j == 0) {
            int t;
            while (b % j == 0) {
                t++;
                b /= j;
            }
            if (j in c) c[j] = max(c[j], t);
            else c[j] = t;
        }
        if (b > 1) {
            if (b in c) c[b] = max(c[b], 1);
            else c[b] = 1;
        }
    }

    debug {
        writeln(c);
    }

    long M = 1;
    foreach (k, v ; c) {
        (M *= k^^v) %= mod;
    }

    long ans;

    foreach (ai ; a) {
        auto b = M * powmod(ai, mod - 2) % mod;
        (ans += b) %= mod;
    }

    writeln(ans);
}


long powmod(int x, int y) {
    return y > 0 ? powmod(x, y>>1)^^2 % mod * x^^(y&1) % mod : 1;
}















void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


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



int main() {

    int n,y; cin >> n >> y;
    int ans = false;

    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <= n; j++) {
            if(n-i-j >= 0) {
                int sum;
                sum = i * 10000 + j * 5000 + (n-i-j) *1000;
                if(sum == y) {
                    ans = true;
                    cout << i << ' ' << j << ' ' << n-i-j << endl;
                    break;
                }
            }
        }
        if(ans) break;
    }

    if(!ans) cout << "-1 -1 -1" << endl;

    return 0;
}





Measured memory_bytes: 3592
#include<cstdio>
#include<iostream>

using namespace std;
  
main(){
  int n;
  cin>>n;
 while(n!=0){
    int d[n+1][n+1];

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

    for(int i=0;i<n;i++){
      d[i][n]=0;
      for(int j=0;j<n;j++){
	d[i][n]+=d[i][j];
      }
    }

    for(int i=0;i<=n;i++){
      d[n][i]=0;
      for(int j=0;j<n;j++){
	d[n][i]+=d[j][i];
      }
    }
    for(int i=0;i<=n;i++){
      for(int j=0;j<=n;j++){
	printf("%5d",d[i][j]);
	if(j==n)
	  printf("\n");
      }
    }
    cin>>n;
  }
}

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

int main(){
	int N;
	string str, str2;
	int ans_size, up, num;
	vector<int> ans;
	
	cin >> N;
	for(int n = 0; n < N; n++){
		cin >> str >> str2;
		
		up = 0;
		for(int i = 0; ; i++){
			if(i >= str.size() && i >= str2.size()){
				if(up > 0) ans.push_back(up);
				break;
			}
			num = 0;
			if(i < str.size()) num += str[str.size() - 1 - i] - 48;
			if(i < str2.size()) num += str2[str2.size() - 1 - i] - 48;
			ans.push_back((num + up) % 10);
			up = (num + up) / 10;
		}
		
		if(ans.size() > 80){
			cout << "overflow";
		}
		else{
			for(int i = ans.size() - 1; i >= 0; i--){
				cout << ans[i];
			}
		}
		cout << endl;
		ans.clear();
	}
	
	return 0;
}

Measured memory_bytes: 1236