akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, p;
    cin >> n >> p;
    string s;
    cin >> s;
    if(10%p == 0){
        ll ans = 0;
        rep(r,n){
            if((s[r]-'0') % p == 0){
                ans += r+1;
            }
        }
        cout << ans << endl;
        return 0;
    }
    vector<int> d(n+1, 0);
    int ten = 1;
    for(int i = n-1; i >= 0; i--){
        int a = (s[i] - '0') * ten % p;
        d[i] = (d[i+1] + a) % p;
        ten *= 10;
        ten %= p;
    }
    vector<int> cnt(p);
    ll ans = 0;
    for(int i = n; i >= 0; i--){
        ans += cnt[d[i]];
        cnt[d[i]]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1428
from collections import deque

S = list(input())
Q = int(input())

S = deque(S)
rev = 1
for _ in range(Q):
    query = input()
    if len(query) == 1:
        rev *= -1
    else:
        T, F, C = query.split()
        if rev == 1:
            if F == "1":
                S.appendleft(C)
            else:
                S.append(C)
        else:
            if F == "1":
                S.append(C)
            else:
                S.appendleft(C)

if rev == -1:
    S = reversed(S)

print("".join(S))


Measured memory_bytes: 103432
#include<stdio.h>
#include<string.h>

long long int array[200001];

int main()
{
    int a = 0, b = 0, c;
    long long int n, answer = 0;
    long long int divide_num = 1;
    long long int array_sum = 0;
    long long int same_array_mul_sum = 0;

    for (int i = 0; i<9; i++)
    {
        divide_num *= 10;
    }

    divide_num += 7;

    scanf("%lld", &n);

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

    for (int i = 0; i<(int)n; i++)
    {
        array_sum += array[i];

        if (array_sum > divide_num)
        {
            a ++;
            array_sum %= divide_num;
        }
    }

    for (int i = 0; i<(int)n; i++)
    {
        same_array_mul_sum += array[i]*array[i];

        if (same_array_mul_sum > divide_num)
        {
            b ++;
            same_array_mul_sum %= divide_num;
        }
    }

    answer = (array_sum)*(array_sum) - same_array_mul_sum + divide_num;

    if (answer > divide_num)
    {
        answer %= divide_num;
    }

    if ((answer%2) != 0)
    {
        answer += divide_num;
    }

    answer /= (long long int)2;

    answer %= divide_num;

    printf("%lld", answer);

    return 0;
}

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

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) ((int) x.size())

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

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


  int q; cin >> q;
  while(q --) {
    ll a, b; cin >> a >> b;

    if(a > b) swap(a, b);

    ll sol = a - 1;

    ll lo = 0, hi = b - 1;
    while(lo < hi) {
      ll mid = (lo + hi + 1) >> 1;

      ll lo1 = 0, hi1 = mid - 1;

      while(lo1 < hi1) {

        ll mid1 = (lo1 + hi1) >> 1;

        if((mid - mid1) * (a + 1 + mid1) > (mid - (mid1 + 1)) * (a + 2 + mid1)) {
          hi1 = mid1;
        }
        else {
          lo1 = mid1 + 1;
        }

      }

      if((mid - lo1) * (a + 1 + lo1) < a * b) {
        lo = mid;
      }

      else {
        hi = mid - 1;
      }

    }

    cout << sol + lo << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector> 
#include <algorithm>

using namespace std;

struct card {
    char face;
    int num, id;
};

// void merge(vector<pair<char, int> >&v, int l, int m, int r){
//     int l1 = m -l;
//     int r1 = r-m;
//     vector<pair<char, int> >lv(l1), rv(r1);
//     for(int i=0; i<l1; i++) lv[i] = v[l+i];
//     for(int i=0; i<r1; i++) rv[i] = v[m+i];
    
//     int i = 0, j = 0;
//     for(int k=l; k<r; k++){
//         if(i<l1 and (j>=r1 || lv[i].second<=rv[j].second)) v[k] = lv[i++];
//         else v[k] = rv[j++];
//     }
// }

// void mergeSort(vector<pair<char, int> >&v, int l, int r){
//     if(l+1<r){
//         int m = (l+r)/2;
//         mergeSort(v, l ,m);
//         mergeSort(v, m, r);
//         merge(v, l, m, r);
//     }
// }

int partition(vector<card>&v, int p, int r){
    int x = v[r].num;
    int i = p-1;
    for(int j=p;j<r;j++) if(v[j].num <= x) swap(v[++i], v[j]);
    swap(v[++i],v[r]);
    return i;
}

void quickSort(vector<card>&v, int p, int r){
    if(p<r){
        int q = partition(v, p, r);
        quickSort(v, p, q-1);
        quickSort(v, q+1, r);
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin >> n;
    vector<card> v(n);
    for(int i=0; i<n; i++){
        cin >> v[i].face >> v[i].num;
        v[i].id = i;
    }
    quickSort(v, 0, n-1);
    bool stable = true;
    for(int i=1; i<n; i++){
        if(v[i].num == v[i-1].num and v[i].id < v[i-1].id) stable = false;
    }
    if(stable) cout << "Stable" << endl;
    else cout << "Not stable" << endl;
    for(int i=0; i<n; i++) cout << v[i].face << " " << v[i].num << endl;
    
    return 0;
}


Measured memory_bytes: 4156
h,w = map(int,input().split())
s = [input() for i in range(h)]
dp = [[0 for _ in range(w)] for _ in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j]=='.':
            continue
        for x in range(-1,2):
            for y in range(-1,2):
                if 0<=i+y<h and 0<=j+x<w:
                    dp[i+y][j+x]+=1
for i in range(h):
    for j in range(w):
        if s[i][j]=='.':
            print(dp[i][j],end = '')
        else:
            print('#',end='')
    print('')

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int h[100];

int main()
{
    int n, ans = 0;
    cin>>n;
    REP(i,n) cin>>h[i];

    int l = 0;
    while (l != n) {
        if (h[l] == 0) {
            l++;
            continue;
        }
        FOR(i,l,n) {
            if (h[i] != 0) {
                h[i]--;
            } else {
                //cout<<l<<" "<<i<<endl;
                break;
            }
        }
        ans++;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <map>
typedef long long ll;
using namespace std;
int h, w, n;
map<ll, bool> board;
int cur_board[5][5];
ll ans[10];
int main() {
	scanf("%d%d%d", &h, &w, &n);
	ans[0] = (ll)(h - 2) * (w - 2);
	while(n--) {
		ll a;
		int b; scanf("%lld%d", &a, &b);
		if(board[a << 30 | b]) continue;
		for(int di = -2; di <= 2; di++) for(int dj = -2; dj <= 2; dj++) {
			if(1 <= a + di && a + di <= h && 1 <= b + dj && b + dj <= w)
				cur_board[di + 2][dj + 2] = board[(a + di) << 30 | (b + dj)];
			else
				cur_board[di + 2][dj + 2] = 0;
		}
		for(int i = 0; i < 5; i++) for(int j = 0; j < 5; j++) {
			if(i > 0) cur_board[i][j] += cur_board[i - 1][j];
			if(j > 0) cur_board[i][j] += cur_board[i][j - 1];
			if(i > 0 && j > 0) cur_board[i][j] -= cur_board[i - 1][j - 1];
		}
		for(int di = -1; di <= 1; di++) for(int dj = -1; dj <= 1; dj++) {
			int a_ = a + di, b_ = b + dj;
			if(2 <= a_ && a_ <= h - 1 && 2 <= b_ && b_ <= w - 1) {
				int c = cur_board[di + 3][dj + 3];
				if(di >= 0) c -= cur_board[di][dj + 3];
				if(dj >= 0) c -= cur_board[di + 3][dj];
				if(di >= 0 && dj >= 0) c += cur_board[di][dj];
				ans[c]--;
				ans[c + 1]++;
			}
		}
		board[a << 30 | b] = true;
	}
	for(int i = 0; i < 10; i++) printf("%lld\n", ans[i]);
	return 0;
}


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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 307;

int n, m, MOD;
int C[MAXN][MAXN];
int dp[MAXN][MAXN];
int ps[MAXN];

void init ();
void input ();
void work ();



int add ( int x, int y )
{
	x += y;
	if ( x >= MOD ) x -= MOD;
	return x;
}

void addv ( int &x, int y )
{
	x += y;
	if ( x >= MOD ) x -= MOD;
}



int main ()
{
	init ();
	input ();
	work ();
}



void init ()
{
	// Init Everything Here

	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method

	cin >> n >> m >> MOD;
}

void work ()
{
	// main work

	lp ( i, 0, MAXN ) {
		C[i][0] = C[i][i] = 1;
		lp ( j, 1, i ) C[i][j] = add ( C[i - 1][j], C[i - 1][j - 1] );
	}

	dp[m][0] = ps[0] = 1;
	lpdi ( i, m - 1, 0 ) {
		dp[i][0] = 1;
		lpi ( k, 0, n ) {
			lpi ( j, 1, n - k ) {
				addv ( dp[i][k + j], SC ( LL, dp[i][k] ) * ps[j - 1] % MOD * C[k + j - 1][k] % MOD );
			}
		}
		lpi ( j, 0, n ) addv ( ps[j], dp[i][j] );
	}

	cout << dp[0][n] << endl;
}

Measured memory_bytes: 1024
N = int(input())
S1 = input()  # aab
S2 = input()  # ccb

ans_pt = []
ans = 1
i = 0
while i < N:
    if S1[i] == S2[i]:
        ans_pt.append("H")
        i += 1
    else:
        ans_pt.append("W")
        i += 2

if ans_pt[0] == "W":
    ans = ans*6
else:
    ans = ans*3

for i in range(1, len(ans_pt)):
    if ans_pt[i-1] == "W" and ans_pt[i] == "W":
        ans = ans*3
    elif ans_pt[i-1] == "W" and ans_pt[i] == "H":
        ans = ans*1
    elif ans_pt[i-1] == "H" and ans_pt[i] == "W":
        ans = ans*2
    else:
        ans = ans*2

print(ans % 1000000007)


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define mp make_pair
#define INF 1e9

void init()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
}

int main()
{
    init();
    int k, n;
    cin>>n>>k;
    vector<int> data(n);
    rep(i, n)
    {
        cin >> data[i];
    }
    sort(all(data));
    int ans = 0;
    rep(i, k)
    {
        ans += data[i];
    }
    cout << ans << endl;
}


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

using namespace std;

int main() {
    int A, B, C, K;
    cin >> A >> B >> C >> K;

    int xa = min(A, K);
    K -= xa;
    int xb = min(B, K);
    K -= xb;
    int xc = K;

    int ans = xa - xc;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3640
n = int(input())

A = [int(x) for x in input().split()]

B = [0] * n

B[1] = abs(A[0] - A[1])

for i in range(2, n):
  B[i] = min([B[i - 1] + abs(A[i] - A[i - 1]),
              B[i - 2] + abs(A[i] - A[i - 2])])
  
print(B[n - 1])

Measured memory_bytes: 13980
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <cmath>
#include <stdio.h>
#include <sstream>
#define int_inf 1000000000 //1e9
#define ll_inf  1000000000000000000 //1e18
using namespace std;
template <typename T> std::string to_string(const T& t){
	std::ostringstream os; os<<t; return os.str();
}

int main(){
	char n[4];
	cin>>n;
	if(n[0]==n[2]) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}




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

int main() {
    while (true) {
        int sq, d; cin >> sq >> d; if (sq == 0 && d == 0) break;
        int sqs[sq];
        for (int i_sq = 0; i_sq < sq; i_sq++) cin >> sqs[i_sq];
        int ds[d]; for (int i = 0; i < d; i++) cin >> ds[i];

        int time = 0, c = 0;
        for (int i = 0; i < d; i++) {
            c += ds[i]; if (c >= sq - 1) { time = i + 1; break; }
            c += sqs[c]; if (c >= sq - 1) { time = i + 1; break; }
        }

        cout << time << endl;
    }
}


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

//#define int long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

int main(){
    string S;
    cin>>S;
    if (S[0]==S[1] || S[1]==S[2] || S[2]==S[3]){
        cout << "Bad" <<endl;
    }
    else{
        cout << "Good" <<endl;
    }
}

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

using namespace std;

int N, X, T, x, t;

int main()
{
    cin >> N >> X >> T;
    x = X;
    t = T;
    while (X < N) {
        X += x;
        T += t;
    }
    cout << T;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
using Graph = vector<vector<int>>;

#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}
vector<ll> res; 
Graph G;
map<int, ll> m;

void dfs(int p, int x, int pa) {
    if (p != pa && m.count(p)) {
        x += m[p];
        m.erase(p);
    }
    res[p] += x;
    for(auto z: G[p]) {
        dfs(z, x, pa);
    }
}

int main() {
    int N, Q; cin >> N >> Q;
    G.resize(N+1);
    res.resize(N+1);

    repp(i,0,N-1) {
        int a, b; cin >> a >> b;
        G[a].push_back(b);
    }

    /*
    repp(i,0,Q) {
        int p, x; cin >> p >> x;
        dfs(p, x);
    }
    */
    repp(i,0,Q) {
        int p, x; cin >> p >> x;
        if (!m.count(p)) {
            m[p] = x;
        } else {
            m[p] += x;
        }
    }
    for (auto x: m) {
        dfs(x.first, x.second, x.first);
    }
    
    repp(i,1,N+1) {
        if (i > 1) cout << " ";
        cout << res[i];
    }
    cout << endl;
}



Measured memory_bytes: 45952
n,t=map(int,input().split())
l=list(map(int,input().split()))
ans=t
stop=t
for i in range(1,n):
	if l[i]<=stop:
		ans+=t-(stop-l[i])
		stop=l[i]+t
	else:
		ans+=t
		stop=l[i]+t
print(ans)

Measured memory_bytes: 25196
//Dragon_warrior7(IITK)
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
#define ull unsigned ll
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
#define deb(x) cout<<#x<<' '<<'='<<' '<<x<<'\n'
//typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}
// const int mod=1e9+7;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
ll n,m,a,b,c,k,temp,x,y;
void solveforthiscase(const int & test)
{//deb(test);
cin>>n>>m;
cin>>a;
vll v(a);
read(v);
ll ans[n][m];
ll i=0;
ll j=0;
int index=0;
while(index!=a)
{
    ans[i][j]=index+1;
    if(i%2==0 && j<m-1)
    j++;
    else if(i%2==0 && j==m-1)
    i++;
    else if(i%2==1 && j>=1)
    j--;
    else if(i%2==1 && j==0)
    i++;
    v[index]--;
    if(v[index]==0)
    index++;
}
for(int i=0;i<n;i++)
{
    for(int j=0;j<m;j++)
    {
        cout<<ans[i][j]<<' ';
    }
    nl;
}






return ;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}

Measured memory_bytes: 512
/*#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
    string s,t;
    cin>>s>>t;

    return 0;
}*/
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
    int n,m,x,y;
    cin>>n>>m>>x>>y;
    int a=-100,b=LONG_MAX;
    for (int i = 0; i < n; ++i) {
        int t;
        cin>>t;
        a=max(a,t);
    }
    for (int i = 0; i < m; ++i) {
        int t;
        cin>>t;
        b=min(b,t);
    }
    for (int i = -100; i <= 100; ++i) {
        if(x<i&&i<=y&&a<i&&i<=b){
            cout<<"No War"<<endl;
            return 0;
        }

    }
    cout<<"War"<<endl;
    return 0;
}


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

int main() {
  ll N, x;
  cin >> N >> x;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  
  int count = 0;
  for (int i = 0; i < N; i++) {
    if (i == N-1) {
      if (x == A[N-1]) {
        count++;
      }
    }
    else {
      if (x >= A[i]) {
        count++;
        x = x - A[i];
      }
      else {
        break;
      }
    }
  }
  cout << count << endl;
}

        

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

long long n, x, m;
vector<vector<long long>> memo, sum;

int main() {
  cin >> n >> x >> m;
  memo.assign(60, vector<long long>(m, 0));
  sum.assign(60, vector<long long>(m, 0));
  for (int i = 0; i < m; ++i) memo[0][i] = (long long)i * i % m;
  for (int i = 0; i < m; ++i) sum[0][i] = i;
  for (int i = 1; i < 60; ++i)
    for (int j = 0; j < m; ++j) {
      long long mid = memo[i - 1][j];
      memo[i][j] = memo[i - 1][mid];
      sum[i][j] = sum[i - 1][j] + sum[i - 1][mid];
    }
  long long res = 0;
  for (int i = 0; i < 60; ++i)
    if (n >> i & 1) {
      res += sum[i][x];
      x = memo[i][x];
    }
  cout << res << endl;
  return 0;
}

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

int main()
{
	long long int n,d;
	cin>>n>>d;
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		long long int x,y;
		cin>>x>>y;
		if(x*x+y*y<=d*d)
			ans++;
	}
	cout<<ans;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define sz(v) (int)(v).size()
using namespace std;
using P = pair<int, int>;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
  int A,B;
  cin >> A >> B;
  if (A <= B + B)
    cout << 0 << endl;
  else
    cout << A - B - B << endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 
public class Main {
	static InputStreamReader isr;
	static BufferedReader br;
	public static void main(String args[]) throws IOException{
	    isr = new InputStreamReader(System.in);
		br = new BufferedReader(isr);
		int c;
		while ((c = getint() ) != -1){
		    if (c != 0){
                int[] arr = getData(c);
                Arrays.sort(arr);
                System.out.println( averageP(arr) );
		    }else{
                break;
            }
        }
	}
	static int getint(){
	    try{
	        int n = 0;
			String buf = br.readLine();
			n = Integer.parseInt(buf);
			return n;
		}catch(Exception e){
		    return -1;
		}
	}
	static int[] getData(int n){
	    try{
    	    int[] r = new int[n];
    	    for(int i=0; i<n; i++){
    	        r[i] = Integer.parseInt(br.readLine());
    	    }
    	    return r;
	    }catch(Exception e){
	        System.err.println("List Length Error");
	        return new int[]{};
	    }
	}
	static int averageP(int[] r){
	    if(r.length > 2){
	        int sum = 0;
	        for(int i=1; i<(r.length-1); i++){
	            sum += r[i];
	        }
	        sum = sum / (r.length - 2);
	        return sum;
	    }else{
	        return 0;
	    }
	}
}

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

int main() {
  long long V_TOTAL_MAX = 100000;
  long long INF = 10000000010;

  long long N, W;
  cin >> N >> W;
  vector<vector<long long>> dp(N + 1, vector<long long>(V_TOTAL_MAX + 1, INF)); // dp[品物番号][基準となる価値] = 重さの総和の最小値
  dp[0][0] = 0;
  
  for (long long i = 1; i <= N; i++) {
  	int w, v;
  	cin >> w >> v;
  	for (long long j = 0; j <= V_TOTAL_MAX; j++) {
      if (j < v) {
        dp[i][j] = dp[i - 1][j];
      }
      else{
        dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v] + w);
//        cout << "w: " << w <<  " v:" << v;
//  	  cout << "    i, j: " << i << "," << j <<  " dp:" << dp[i][j] << endl;
  	  }
    }
  }
  
  long long ans = -1;
  for (long long j = 0; j <= V_TOTAL_MAX; j++) {
    if (dp[N][j] <= W) {
      ans = max(ans, j);
    }
  }
  cout << ans << endl;
}

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

int main() {
	int W,H,x,y,r;
	int x1=0;
	int y1=0;
	cin>>W>>H>>x>>y>>r;
	int r1=y-r;
	int r2=x-r;
	if(x<=x1||y<=y1||W<=x||H<=y||r1<x1||r2<y1||r1>W||r2>H){
		cout<<"No\n";
	}
	else{
		cout<<"Yes\n";
	}
}


Measured memory_bytes: 1128
#include <iostream>
#include <utility>
#include <cstdio>

using namespace std;

int main(void) {

    int a, b, c;
    cin >> a >> b >> c;

    int count = 0;
    for (int i = a; i <= b; ++i) {
        if (c % i == 0) { ++count; }
    }

    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};


int main(){
  int N;
  cin>>N;
  vector<int> a(N),num(100005,0);
  for(int i=0;i<N;i++){
    cin>>a[i];
    num[a[i]]++;
  }
  int ans=0;
  for(int i=0;i<100000;i++){
    ans=max(ans,num[i]+num[i+1]+num[i+2]);
  }
  cout<<ans<<endl;
  return 0;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long,long>> vpll;
typedef vector<pair<int,int>> vpii;
int main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	ini(n);
	ini(n1);
	ins(a);

	if(n1 == 2 or n1 == 5){
		ll tmp = 0;
		FOR(i,0,n){
			if((a[i]-'0')%n1 == 0){tmp+=i+1;}
		}
		out(tmp);
		return 0;
	}

	map<ll,ll>map1;
	map1[0] = 1;
	reverse(all(a));
	ll tmp = 0;
	ll pos = 1;
	ll total = 0;
	for(auto i:a){
		tmp=(tmp+(i-'0')*pos)%n1;
		total+=map1[tmp];
		map1[tmp]++;
		pos = (pos*10)%n1;
	}
	out(total);
	return 0;
}

Measured memory_bytes: 1044
import java.util.*;
import java.io.*;

//C - Vacation
//simple dp
//build your logic

//https://atcoder.jp/contests/dp/tasks/dp_c

public class Main {
    static StringTokenizer st;
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

 
    public static void main(String[] args) throws IOException {
  
        int N = nextInt(); 
        int[][] dp = new int[N+1][3];

        for (int i=1; i<=N;  i++) {
            int a = nextInt();
            int b = nextInt();
            int c = nextInt();
            dp[i][0] = Math.max(dp[i-1][1],dp[i-1][2]) + a;
            dp[i][1] = Math.max(dp[i-1][0],dp[i-1][2]) + b;
            dp[i][2] = Math.max(dp[i-1][1],dp[i-1][0]) + c;
        }
 
        int ans = Math.max(dp[N][1],dp[N][2]);
        ans = Math.max(ans,dp[N][0]);
        
        System.out.println(ans);
    }
    

    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}

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

void input(string& rsSrc, string& rsTrg)
{
  cin >> rsSrc >> rsTrg;
}

string canConvert(string sSrc, string sTrg)
{
  vector<int> vnSrc(26, -1), vnTrg(26, -1);

  for (int i = 0; i < sSrc.size(); ++i)
  {
    int nSrc = sSrc[i] - 'a';
    int nTrg = sTrg[i] - 'a';

    if (vnSrc[nSrc] == -1 && vnTrg[nTrg] == -1)
    {
      vnSrc[nSrc] = nTrg;
      vnTrg[nTrg] = nSrc;
    }
    else
      if (vnSrc[nSrc] != nTrg || vnTrg[nTrg] != nSrc)
        return "No";
  }

  return "Yes";
}
  
int main()
{
  string sSrc, sTrg;
  
  input(sSrc, sTrg);
  cout << canConvert(sSrc, sTrg) << endl;

  return 0;
}

Measured memory_bytes: 4116
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    if (A * B < N || A + B > N + 1) {
        cout << -1 << endl;
        return 0;
    }

    vector<ll> ans;
    ll num = 0;
    for (ll i = 0; i < B; i++) {
        ll tmp_num = min(N - num - (B - i - 1), A);
        for (ll j = 0; j < tmp_num; j++) {
            ans.push_back(N - num - tmp_num + j + 1);
        }
        num += tmp_num;
    }

    for (ll i = 0; i < N; i++) {
        printf("%lld%c", ans[i], " \n"[i == N - 1]);
    }
}

Measured memory_bytes: 6256
import java.util.*

fun main(args: Array<String>) {
	val scan = Scanner(System.`in`)
	val W = scan.nextInt()
	val H = scan.nextInt()

	val x = scan.nextInt()
	val y = scan.nextInt()

	val r = scan.nextInt()
	println(if ((x - r < 0 || x + r > W) || (y - r < 0 || y + r > H)) {
		"No"
	} else {
		"Yes"
	})
}


Measured memory_bytes: 27528
<?php

    $N = intval(trim(fgets(STDIN)));
    
    if($N%2 !=0){
        echo "No";
        exit;
    }
    
    $line = trim(fgets(STDIN));
    
    $L = str_split($line);
    
    for($i=0;$i<$N/2;$i++){
        if($L[$i] != $L[$i+($N/2)]){
            // echo $L[$i]; 
            echo "No";
            exit;
        }
    }
    echo "Yes";
?>

Measured memory_bytes: 16012
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main() {
  int a,b,k;
  cin>>a>>b>>k;
  
  int cnt=0,ans;
  for(int i=100;i>0;i--){
    if(a%i==0 && b%i==0){
      cnt++;
    }
    if(cnt==k){
      ans=i;
      break;
    }
  }
  
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 3428
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n,m,p=map(int,input().split())
    E=[[] for _ in range(n)]
    R=[[] for _ in range(n)]
    for _ in range(m):
        u,v,c=map(int,input().split())
        u-=1; v-=1
        E[u].append((v,p-c))
        R[v].append((u,p-c))

    # 0 から到達できる点、かつ n-1 から逆辺で到達できる点を計算
    state=[0]*n
    state[0]+=1
    state[n-1]+=2

    # from 0
    Q=[0]
    while(Q):
        v=Q.pop()
        for nv,w in E[v]:
            if(state[nv]&1): continue
            state[nv]+=1
            Q.append(nv)

    # to n-1
    Q=[n-1]
    while(Q):
        v=Q.pop()
        for nv,w in R[v]:
            if(state[nv]&2): continue
            state[nv]+=2
            Q.append(nv)

    # state[v]==3 を結ぶ頂点のみを用いてBellman-Ford
    dist=[INF]*n
    dist[0]=0
    for k in range(n):
        flag=0
        for v in range(n):
            for nv,w in E[v]:
                if(state[v]&state[nv]!=3): continue
                if(dist[nv]>dist[v]+w):
                    dist[nv]=dist[v]+w
                    flag=1
        if(flag and k==n-1):
            print(-1)
            return

    print(max(-dist[-1],0))
resolve()

Measured memory_bytes: 49628
#include <stdio.h>

int main(void) {
	int i = 1;
	int x;
	
	do{
	    scanf("%d", &x);

		if(x > 0){
	    
	    printf("Case %d: %d\n", i, x);
	    }
	    i++;
	}while(x > 0);

	return 0;
}



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

int main() {

    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    int n;
    cin>>n;
    vector<int> arr(n);
    for(int i = 0; i < n; i++)
    	cin>>arr[i];

    int minC = 0, maxC = 0;
    vector<int> buckets(9);
    for(int i :arr) {
    	if(i >= 3200)
    		buckets[8]++;
    	else {
    		buckets[i/400]++;
    	}
    }

    for(int i = 0; i < 8; i++)
    	if(buckets[i])
    		minC++;

    maxC = minC + buckets[8];
    if(minC == 0)
    	minC++;
    cout<<minC<<" "<<maxC;
	return 0;		
}


Measured memory_bytes: 256
L, R = map(int, input().split())
if R - L >= 2019:
    print(0)
else:
    result = float('inf')
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            mod = (i * j) % 2019
            if mod == 0:
                result = 0
                break
            elif mod < result:
                result = mod
    print(result)

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll MOD = 1e9 + 7;
const ll MX = 2e6 + 6;

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


ll extend_gcd(ll a, ll b, ll &x, ll &y) {  
    if (b == 0) {  
	x = 1, y = 0;  
	return a;  
    }  
    else {  
	ll r = extend_gcd(b, a % b, y, x);  
	y -= x * (a / b);  
	return r;  
    }  
}  
ll inv(ll a, ll mod) {  
    ll x, y;  
    extend_gcd(a, mod, x, y);  
    x = (x % mod + mod) % mod;  
    return x;  
}  

ll K, NS, N;
string S;

ll fs[MX], ifs[MX];

ll mpow(ll a, ll n){
	if(n == 0) return 1;
	ll r = mpow(a, n/2);
	r *= r;
	r %= MOD;
	if(n % 2 == 1) r *= a;
	return r % MOD;
}

ll Cnm(ll n, ll m){
	return (((((fs[n] * ifs[m]) % MOD + MOD)%MOD) * ifs[n-m])%MOD + MOD)%MOD;
}

void init(){
	for(ll a=0; a<MX; a++){
		if(a == 0) fs[a] = 1;
		else fs[a] = (fs[a-1] * a) % MOD;
		ifs[a] = (inv(fs[a], MOD)%MOD + MOD)%MOD;
	}

}

int main(){
	init();
	cin>>K>>S;
	NS = S.size();
	N = NS + K;
	ll res = 0;
	for(ll j=0; j<=K; j++){
		res += (Cnm(N, j + NS) * mpow(25, N - NS - j))%MOD;
		res %= MOD;
	}
	cout<<res<<endl;


    return 0;
}






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

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto Q = s[1];
    auto st = new LazySegmentTree!(long, long, (a,b)=>a+b, (a,b)=>b, (a,b)=>b, (a,b)=>a*b, 0L, 1L<<59)(N+1);

    while (Q--) {
        s = readln.split.map!(to!int);
        int q = s[0];
        int l = s[1];
        int r = s[2];
        if (q == 0) {
            long v = s[3];
            st.update(l, r, v);
        } else {
            st.query(l, r).writeln;
        }
    }
}


class LazySegmentTree(T, L, alias opTT, alias opTL, alias opLL, alias opPrd, T eT, L eL) {
    T[] table;
    L[] lazy_;
    int n;
    int size;

    this(int n) {
        this.n = n;
        size = 1;
        while (size <= n) size <<= 1;
        size <<= 1;
        table = new T[](size);
        lazy_ = new T[](size);
        table[] = eT;
        lazy_[] = eL;
    }

    void push(int i, int a, int b) {
        if (lazy_[i] == eL) return;
        table[i] = opTL(table[i], opPrd(lazy_[i], b - a + 1));
        if (i * 2 + 1 < size) {
            lazy_[i*2] = opLL(lazy_[i*2], lazy_[i]);
            lazy_[i*2+1] = opLL(lazy_[i*2+1], lazy_[i]);
        }
        lazy_[i] = eL;
    }

    T query(int l, int r) {
        if (l > r) return eT;
        return query(l, r, 1, 0, n-1);
    }

    T query(int l, int r, int i, int a, int b) {
        if (b < l || r < a) return eT;
        push(i, a, b);
        if (l <= a && b <= r) {
            return table[i];
        } else {
            return opTT(query(l, r, i*2, a, (a+b)/2), query(l, r, i*2+1, (a+b)/2+1, b));
        }
    }

    void update(int l, int r, L val) {
        if (l > r) return;
        update(l, r, 1, 0, n-1, val);
    }

    void update(int l, int r, int i, int a, int b, L val) {
        if (b < l || r < a) {
            push(i, a, b);
        } else if (l <= a && b <= r) {
            lazy_[i] = opLL(lazy_[i], val);
            push(i, a, b);
        } else {
            push(i, a, b);
            update(l, r, i*2, a, (a+b)/2, val);
            update(l, r, i*2+1, (a+b)/2+1, b, val);
            table[i] = opTT(table[i*2], table[i*2+1]);
        }
    }
}



Measured memory_bytes: 7428
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
#define ld long double
 
#define endl '\n'
#define FAST                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int MAXN = 1e5 + 5;

int main() {
int arr[3][3];
bool vis[3000];
memset(vis,0,sizeof vis);

for(int i=0;i<3;i++)
{
    for(int j=0;j<3;j++)
{
    cin>>arr[i][j];
}
}
int n;
cin>>n;
while(n--)
{
    int a;
    cin>>a;
    vis[a]=1;
}
int c=0;
for(int i=0;i<3;i++)
{
c=0;
    for(int j=0;j<3;j++)
{
    if(vis[arr[i][j]])
    c++;
}
if(c==3)
return cout<<"Yes",0;
}
c=0;
for(int i=0;i<3;i++)
{
     c=0;
    for(int j=0;j<3;j++)
{
    if(vis[arr[j][i]])
    c++;
}
if(c==3)
return cout<<"Yes",0;
}
c=0;
for(int i=0;i<3;i++)
{
    
    for(int j=0;j<3;j++)
{
    if(i==j){
    if(vis[arr[i][j]])
    c++;
    }
}

}
if(c==3)
return cout<<"Yes",0;
if(vis[arr[0][2]] &&vis[arr[1][1]] &&vis[arr[2][0]] )
return cout<<"Yes",0;
cout<<"No"<<endl;


    return 0;
}

Measured memory_bytes: 256
import collections
N =int(input())
A =list(map(int,input().split()))
col = (collections.Counter(A))
col_key = sorted(col.keys(),reverse = 1)
hen = []
counter  =0
for i in range(len(col_key)):
    if 2 <= col[col_key[i]] <4:
        hen.append(col_key[i])
        counter += 1
    elif col[col_key[i]] >= 4:
        hen.append(col_key[i])
        hen.append(col_key[i])
        counter +=2
    if counter>=2:
        break
if counter<2:
    print(0)
else:
    print(hen[0]*hen[1])


Measured memory_bytes: 22164
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)+(x)-1)/(x))
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        ((a)*((b)/gcd((a),(b))))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int n;
    cin>>n;

    vi v(n);
    for(int i=0;i<n;++i)
        cin>>v[i];

    vi val(21);
    val[0]=1;
    for(int i=1;i<21;++i)
        val[i]=val[i-1]+val[i-1];

    //show(val);

    deque<pii> dq;
    vi arr(21);

    int ans=0;
    int prv=-1;
    for(int i=0;i<n;++i)
    {
        if(v[i])
        {
            if(sz(dq)==22)
                dq.pob();

            dq.pf({v[i],i});
        }
        else
        {
            ans+=(i-prv);
            continue;
        }

        fill(all(arr),0);
        bool fl=0;
        for(auto it:dq)
        {
            for(int k=0;k<21;++k)
            {
                if(it.F&val[k])
                {
                    ++arr[k];
                    if(arr[k]>1)
                    {
                        ans+=(i-it.S);
                        prv=it.S;
                        fl=1;
                        break;
                    }
                }
            }

            if(fl)
                break;
        }

        if(!fl)
            ans+=(i+1);
    }

    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int r; cin>>r;
    cout<<3*r*r<<endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.TreeMap;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		int n=scanner.nextInt();
		int[] a=new int[n];
		Map<Integer,Integer>map=new TreeMap<>();
		for(int i=0;i<n;i++) {
			a[i]=scanner.nextInt();
			int key=a[i];
			if (map.containsKey(key)) {
				map.put(key, map.get(key) + 1);
			} else {
				map.put(key, 0);
			}
		}
		int sum=0;;
		for(int val:map.values()) {
			sum+=val;
		}
		System.out.println(sum%2==0?n-sum:n-(sum+1));
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 30728
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }
 
signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  int n;
  cin>>n;
  vi L(n);
  rep(i,n) cin>>L[i];
  vsort(L);
  
  int ans=0;
  rep(i,n){
    for(int j=i+1;j<n;j++){
      int sum = L[i]+L[j];
      int r = lower_bound(L.begin(), L.end(), sum) - L.begin();
      int l = j+1;
      // c = [l,r) つまり r-(l-1)-1=r-l
      ans += r-l;
    }
  }
  cout(ans);
}

Measured memory_bytes: 256
N=int(input())
S=[]
for i in range(N):
    s=int(input())
    S.append(s)
S.sort()
wa=sum(S)


for i in range(N):
    if wa%10!=0:
        print(wa)
        break
    if i==N-1:
        print(0)
        break
    if S[i]%10==0:
        for j in range(i,N):
            if S[j]%10!=0:
               minus=S[j] 
               wa=wa-minus
               break
        continue
    wa=wa-S[i]

Measured memory_bytes: 3064
H, W, N = map(int, raw_input().split())
p = set()
for i in range(N):
  a, b = map(int, raw_input().split())
  p.add((a,b))
r = [0]*10
c = set()
for a, b in p:
  for y0 in range(a-2, a+1):
    for x0 in range(b-2, b+1):
      if x0<1 or x0+2>W or y0<1 or y0+2>H or (y0,x0) in c:
        continue
      c.add((y0,x0))
      s = 0
      for y in range(y0, y0+3):
        for x in range(x0, x0+3):
          if (y,x) in p:
            s += 1
      r[s] += 1
print (H-2)*(W-2)-sum(r[1:10])
for ri in r[1:10]:
  print ri

Measured memory_bytes: 146984
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N, A, B = nl()

count = 0
for i in range(1, N+1):
    total = 0
    for c in str(i):
        total += int(c)
    if A <= total and total <= B:
        count += i

print(count)


Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <iomanip>
#include <limits>
#include <stack>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007
//static const long double pi = 3.1415926535897932;

using namespace std;
using ll = long long int;
using ull = unsigned long long;

char toSmall(char c) { // 大文字を小文字へ
	return (c + 0x20);
}

char toLarge(char c) { // 小文字を大文字へ
	return (c - 0x20);
}

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

ll combination(ll n, ll r) { // nCr の計算
	if (n < 0 || r < 0 || r > n) return -1;

	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> num(r);
	vector<ll> den(r);

	for (ll i = 0; i < r; i++) {
		num[i] = n - r + i + 1;
		den[i] = i + 1;
	}

	for (ll p = 2; p <= r; p++) {
		ll pivot = den[p - 1];
		if (pivot > 1) {
			ll offset = (n - r) % p;
			for (ll k = p - 1; k < r; k += p) {
				num[k - offset] /= pivot;
				den[k] /= pivot;
			}
		}
	}
	ll result = 1;
	for (ll k = 0; k < r; k++) {
		if (num[k] > 1) result *= num[k];
	}
	return result;
}

vector<string> split(const string& src, const char* delim = ",") { //カンマ区切り
	vector<string> vec;
	string::size_type len = src.length();

	for (string::size_type i = 0, n; i < len; i = n + 1) {
		n = src.find_first_of(delim, i);
		if (n == string::npos) {
			n = len;
		}
		vec.push_back(src.substr(i, n - i));
	}

	return vec;
}

bool check_int(string str)
{
	if (all_of(str.cbegin(), str.cend(), [](char ch) { return isdigit(ch);}))
	{
		return true;
	}
	return false;
}

struct rest {
	string s;
	int p;
	int num;

	/* -------------------------------------
	sort関数を使用したときのソートの定義をする。
	まずは文字列sでソートする。
	文字列sが同じだった場合、pでソートする。
	この条件を参考演算子で表現(ifでもOK)
	-------------------------------------*/
	bool operator<(const rest& right) const {
		return s == right.s ? p > right.p : s < right.s;
	}
};

int main() {
	int n;
	cin >> n;
	stack<int> stackList;
	for (int i = 0; i < n; i++) {
		int a; 
		cin >> a;
		if (a % 2 == 0) {
			stackList.push(a);
		}
	}
	int flag = 0;
	int num = stackList.size();
	while(!stackList.empty()) {
		if (stackList.top() % 3 == 0 || stackList.top() % 5 == 0) {
			stackList.pop();
			flag++;
		} else {
			stackList.pop();
		}
	}
	if (flag == num) {
		cout << "APPROVED" << endl;
	} else {
		cout << "DENIED" << endl;
	}
	return 0;
}

Measured memory_bytes: 3596
N = gets.chomp.to_i
ary = []
result = {}
kekka = []
N.times do
  ary.push(gets.chomp)
end

for s in ary do
  result[s] = 1 + result[s].to_i
end
max =  result.max {|x, y| x[1] <=> y[1]}[1]
for r in result do
  if r[1] == max
    kekka.push(r[0])
  end
end 

puts kekka.sort

Measured memory_bytes: 47836