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

using namespace std;

int main() {
  string s; cin>>s;
  reverse(s.begin(), s.end());
  vector<int>v(2019 , 0);
  v[0]++;
  int cur = 0 , rem = 1;
  for(int i = 0 ; i < s.size(); ++i){
    cur = (cur + (s[i] - '0')*rem) % 2019;
    rem = rem * 10 % 2019;
    v[cur]++;
    //cout<<cur<<" ";
  }
  int ans = 0;
  for(int i = 0 ; i < v.size(); ++i){
    ans += v[i] * ( v[i] - 1) / 2;
  }
  cout<<ans<<"\n";
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
const ll INF=1e15+7;
const ll N = 1002;
string s;
ll d[4];


int main(){
	FOR(i,0,4)d[i]=0;
	cin>>s;
	FOR(i,0,s.size()){
		if(s[i]=='N')d[0]=1;
		else if(s[i]=='S')d[1]=1;
		else if(s[i]=='E')d[2]=1;
		else if(s[i]=='W')d[3]=1;
	}
	if(d[0]==d[1]&&d[2]==d[3]){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


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

int main() {
    int N;
    string S;
    const int MAX = 2e5+1;
    int a[MAX]={0}, b[MAX]={0};

    cin >> N;
    cin >> S;

    for(int i=0; i<N; i++){
        a[i+1] = a[i] + (S[i]=='#');
        b[i+1] = b[i] + (S[i]=='.');
    }

    int min = N;
    for(int i=0; i<=N; i++){
        int x = a[i] + (b[N] - b[i]);
        if (min>x) min=x;
    }

    cout << min << endl;
    return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	if(n%2==0) printf("%.9f\n", 0.5);
	else printf("%.9f\n", (double)(n+1)/(2*n));
	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef long long unsigned int llu;
#define tc long long int t; cin>>t; while(t--)
#define  sync ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define mpi unordered_map<ll, ll>
#define mpc unordered_map<char, ll>
#define map_loop(it,m) for(auto it = m.begin(); it!=m.end(); it++)
#define rep(i,n) for(ll i=0;i<n;i++)


int main(){
  
  ll n;
  cin>>n;
  ll sum=0;
  for(int i=1;i<=n;i++){
	  for(int j=1;j<=n;j++){
		  for(int k=1;k<=n;k++){
			sum+=  __gcd(i,__gcd(j,k));
		  }
	  }
  }
  
  cout<<sum<<endl;
}






















Measured memory_bytes: 3620
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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);
	string s;
	cin >> s;
	rep(i,2)rep(j,2)rep(k,2){
		int num = s[0]-'0';
		num += (i ? (s[1]-'0') : -(s[1]-'0'));
		num += (j ? (s[2]-'0') : -(s[2]-'0'));
		num += (k ? (s[3]-'0') : -(s[3]-'0'));
		if(num == 7){
			cout << s[0];
			cout << (i ? "+" : "-");
			cout << s[1];
			cout << (j ? "+" : "-");
			cout << s[2];
			cout << (k ? "+" : "-");
			cout << s[3];
			cout << "=7" << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<climits>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)
#define P pair<int, int>
const int INF = INT_MAX / 2;

int main(){
    int bef = 4280, n;
    while(cin >>n && n != -1){
        int aft = 1150;
        n = max(0, n - 10);
        REP(i, 10){
            if(!n) break;
            aft += 125;
            n--;
        }
        REP(i, 10){
            if(!n) break;
            aft += 140;
            n--;
        }
        aft += (n * 160);
        cout <<bef - aft<<endl;
    }
    return 0;
}

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

long long int N, c[9], a, b;

int main(){
    scanf("%lld", &N);
    for(int i = 0; i < N; ++i){
        scanf("%lld", c);
        if(*c < 3200){if(++c[*c / 400 + 1] == 1)++a;}
        else ++b;
    }
    cout << max(a, 1LL) << " " << a + b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

struct K{
	long long A;
	long long B;
};

int asc(const void *a, const void *b) {
	struct K *X = (struct K *)a;
	struct K *Y = (struct K *)b;
	return X->A - Y->A;
}

int main() {
	struct K Ks[100000];
	long long i, N, M, cko = 0, csu = 0;

	scanf("%lld %lld", &N, &M);

	for (i = 0; i < N; i++) scanf("%lld %lld", &Ks[i].A, &Ks[i].B);

	qsort(Ks, N, sizeof(struct K), asc);

	for (i = 0; i < N; i++) {
		if (cko + Ks[i].B < M) {
			cko += Ks[i].B;
			csu = csu + (Ks[i].A * Ks[i].B);
		}
		else {
			csu = csu + (Ks[i].A * (M - cko));
			break;
		}
	}

	printf("%lld\n", csu);

	return 0;
}

Measured memory_bytes: 3324
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll ans[3000][3000];

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

ll f(ll a[], ll i, ll j)
{
    if(i>j) return 0;
    if(ans[i][j]!=-1) return ans[i][j];
    if(i==j) {ans[i][j]=a[i]; return ans[i][j];}
    ans[i][j]=max(a[i]-f(a,i+1,j),a[j]-f(a,i,j-1));
    return ans[i][j];
}

int main() {
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++) cin>>a[i];
	//ll ans[n][n];
	for(ll i=0;i<3000;i++)
	{
	    for(ll j=0;j<3000;j++)
	    {
	        ans[i][j]=-1;
	    }
	}
	cout<<f(a,0,n-1);
	return 0;
}


Measured memory_bytes: 70784
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
using namespace std;

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class itr, class func> void array_output(itr start, itr goal, func out = [](itr x) { return x; } ){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr, class func> void nint_output(itr start, itr goal, func out = [](itr x) { return x; } ){ string ans; for(auto i = start; i != goal; i++){ ans += string(out(*i)) + " "; } ans.pop_back(); cout << ans << endl; }
long gcd(long a, long b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcount(n)

int main(){
    int n;
    vector<int> prime_sieve(1e6, -1);
    for(int i = 2; i < 1e6; i++){
        if(prime_sieve[i] == -1){
            prime_sieve[i] = 1;
            for(int j = i * 2; j < 1e6; j += i){
                prime_sieve[j] = 0;
            }
        }
    }
    vector<int> cumulative_sum{0, 0};
    for(int i = 2; i < 1e6; i++){
        cumulative_sum.push_back(cumulative_sum.back() + prime_sieve[i]);
    }
    while(cin >> n){
        cout << cumulative_sum[n] << endl;
    }
}



Measured memory_bytes: 10684
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    i64 w, h, x, y;
    std::cin >> w >> h >> x >> y;
    int flg = 2ll * x == w && 2ll * y == h;
    printf("%.10lf %d\n", (double)w * h / 2.0, flg);

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace CSharp
{
    static class Program
    {
        static void Main(string[] args)
        {
            int n, k;
            ReadInt(out n, out k);
            var P = ReadIntArray();

            int sum = 0;
            int ans;

            for (int i = 0; i < k; i++)
            {
                sum += P[i];
            }

            ans = sum;

            for (int i = k; i < n; i++)
            {
                sum += P[i] - P[i - k];
                ans = Max(ans, sum);
            }

            double result = (double)(ans + k) / 2;
            Console.WriteLine(result);
        }

        #region Helpers

        static int[] ReadIntArray() => Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        static long[] ReadLongArray() => Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();

        static int[] ReadLineIntArray(int count) => Enumerable.Repeat(0, count).Select(_ => int.Parse(Console.ReadLine())).ToArray();
        static long[] ReadLineLongArray(int count) => Enumerable.Repeat(0, count).Select(_ => long.Parse(Console.ReadLine())).ToArray();

        static string ReadString() => Console.ReadLine();
        static int ReadInt() => int.Parse(Console.ReadLine());
        static long ReadLong() => long.Parse(Console.ReadLine());

        static void ReadInt(out int first)
        {
            var array = ReadIntArray();
            first = array[0];
        }

        static void ReadInt(out int first, out int second)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
        }

        static void ReadInt(out int first, out int second, out int third)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadInt(out int first, out int second, out int third, out int fourth)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        static void ReadLong(out long first)
        {
            var array = ReadLongArray();
            first = array[0];
        }

        static void ReadLong(out long first, out long second)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
        }

        static void ReadLong(out long first, out long second, out long third)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadLong(out long first, out long second, out long third, out long fourth)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        #endregion
    }
}

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

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

void solve(void) {
  ll N, K; cin >> N >> K;
  vector<ll> h(N);
  rep(N, i) cin >> h[i];

  if(N <= K) {
    cout << 0 << endl;
    return;
  }

  ll res = 0;
  sort(h.begin(), h.end());

  for(ll i = 0; i < N - K; ++i) {
    res += h[i];
  }
  cout << res << endl;
}

int main(void) {
  solve();
  return 0;
}

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

using namespace std;

const int N = 5e5 + 5;

#define int long long

signed main(){
	#ifdef LOCAL
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,k;
	cin>>n>>k;
	int s[n],x;
	for(int i=0;i<n;i++)
		cin>>s[i];
	sort(s,s+n);
	int ans=0;
	if(k>=n){cout<<0;return 0;}
	for(int i=0;i<n-k;i++)
		ans=ans+s[i];
	cout<<ans;
	return 0;
}

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    bool found_ans = false;
    bool awake = true;
    int cnt = 0;
    for(int t=1;t<=4000;++t){
        cnt++;
        if(awake && cnt > a){
            cnt = 1;
            awake = false;
        }
        if(!awake && cnt >= b){
            cnt = 0;
            awake = true;
        }
        if(t%60 == c && awake){
            cout << t << endl;
            found_ans = true;
            break;
        }
    }

    if(!found_ans)cout << -1 << endl;

    return 0;
}



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

int main() {
  int n,a;
  cin>>n>>a;
  if(n%500<=a){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    vector<pair<pair<string, int>,int> > z;
    int i;
    for(i=0; i<n; i++) {
        char str[12]={0};
        int p;
        scanf("%s", str);
        scanf("%d", &p);
        z.push_back(make_pair(make_pair(string(str), 200-p),i));
    }
    sort(z.begin(), z.end());

    for(i=0; i<n; i++) {
        printf("%d\n", z[i].second+1);
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
// by piano
template<typename tp> inline void read(tp &x) {
	x = 0;char c = getchar();bool f = 0;
	for(; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
	for(; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
	if(f) x = -x;
}
const int N = 2e6 + 10 ;
int n, a[N], sum, Min, l[N], r[N], ans;
map<int, int> S, s;
main() {
	read(n);n *= 3;
	for(int i = 1; i <= n; i ++) read(a[i]);
	int per = n / 3;
	for(int i = 1; i <= per; i ++) sum += a[i], s[a[i]] ++;
	for(int i = n; i >= n - per + 1; i --) Min += a[i], S[a[i]] ++;
	l[per] = sum;r[n - per + 1] = Min;
	for(int i = per + 1; i <= n; i ++) {
		if(a[i] > s.begin() -> first) {
			sum = sum - (s.begin() -> first) + a[i];
			s.begin() -> second --;
			if(s.begin() -> second == 0) s.erase(s.begin());
			s[a[i]] ++;
		}
		l[i] = sum;
	}
//	for(int i = 1; i <= n; i ++) cout << l[i] << ' ';putchar('\n');
	for(int i = n - per; i >= 1; i --) {
//		for(auto it:S)
//			cout << it.first << ' ' << it.second << ' ' << "map\n";
		map<int, int> ::iterator it = S.end(); -- it;
//		cout << it -> first << ' ' << it -> second << " it \n";
		if(a[i] < (it -> first)) {
			Min = Min - (it -> first) + a[i];
			it -> second --;
//			cout << it -> second << "sec\n";
			if(it -> second == 0) 
				S.erase(it);
			S[a[i]] ++;
		}
		r[i] = Min;
//		cout << S.size() << "\n";
//		for(auto it:S)
//			cout << it.first << ' ' << it.second << ' ' << i << "map\n";
//		puts("AFO");
	}
//	puts("---------");
//	for(int i = 1; i <= n; i ++) cout << r[i] << ' ';
	int ans = - 1e17;
	for(int i = per; i <= n - per; i ++) ans = max(ans, l[i] - r[i + 1]);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 20480
// atcoder/arc070/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  lli x;
  while (cin >> x) {
    for (lli i = 1; ; ++i) {
      if (x <= i * (i - 1) / 2) {
        cout << i-1 << endl;
        break;
      }
    }
  }

  return 0;
}


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int d = Integer.toString(N).length();
		final int[] elm_753 = { 3, 5, 7 };

		ArrayList<Integer> list753 = new ArrayList<>();
		list753.add(3);
		list753.add(5);
		list753.add(7);
		int time = 10;
		for (int i = 1; i < d; i++) {
			ArrayList<Integer> list = new ArrayList<>();
			int tmpTime = time;
			list753.forEach(l -> {
				for (int e : elm_753) {
					list.add(l + e * tmpTime);
				}
			});
			list753.addAll(list);
			time *= 10;
		}
		long count = 0;
		count = list753.stream().filter(l -> (l <= N && is753Number(l))).count();
		System.out.println(count);

		sc.close();
	}

	private static boolean is753Number(int x) {
		boolean three = false;
		boolean five = false;
		boolean seven = false;
		while (x > 0) {
			int mod = x % 10;
			switch (mod) {
			case 3:
				three = true;
				break;
			case 5:
				five = true;
				break;
			case 7:
				seven = true;
				break;
			default:
				return false;
			}
			x /= 10;
		}
		return three && five && seven;
	}
}


Measured memory_bytes: 32980
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <tuple>
using namespace std;

int main(){

    int n; cin >> n;

    int a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }

    int m[n] = {};
    int ans[n] = {};

    for(int j=0; j<n; j++){
        m[j] = 1 - 2*(j%2);
    }
    
    for(int j=0; j<n; j++){
        ans[0] += m[j] * a[j];
    }

    for(int i=1; i<n-1; i++){
        ans[i] = a[i-1]*2 - ans[i-1];
    }
    ans[n-1] = a[n-1]*2 - ans[0];

    for(int i=0; i<n; i++){
        cout << ans[i] << " ";
    }

    return 0;
}

Measured memory_bytes: 2432
def calc_E(prob):

    E = (prob + 1) / 2
    return E

def main(N, K, list_p):
    
    list_E = list(map(calc_E, list_p))
    max_E  = sum(list_E[0:K])
    prev_E = sum(list_E[0:K])

    for i in range(1, N-K+1):
        tmpE   = prev_E - list_E[i-1] + list_E[i-1+K]
        max_E  = max(max_E, tmpE)
        prev_E = tmpE

    return max_E
        


if __name__ == "__main__":

    [N, K] = list(map(int, input().split(' ')))
    list_p = list(map(int, input().split(' ')))

    answer = main(N, K, list_p)
    print(answer)

Measured memory_bytes: 24804
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  string s;
  cin >> s;
  string key = "keyence";
  rep(i, 7){
    if(s.at(i) != key.at(i)){
      string sb = s.substr(s.size()-key.size()+i, 7-i+1);
      string skey = key.substr(i, key.size()-i+1);
      cerr << sb << " " << skey << endl;
      if(sb == skey) cout << "YES" << endl;
      else cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

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

long long A[100000];
long long B[100000];

int main(){
  int n;
  std::cin>>n;
  long long diff=0;
  long long ans=0;
  long long need=0;
  std::priority_queue<long long> pq;
  for(int i=0;i<n;++i){
    std::cin>>A[i];
  }
  for(int i=0;i<n;++i){
    std::cin>>B[i];
  }
  for(int i=0;i<n;++i){
    diff+=A[i]-B[i];
    if(B[i]>A[i]){
      need+=B[i]-A[i];
      ++ans;
    }else{
      pq.push(A[i]-B[i]);
    }
  }
  if(diff<0){
    std::cout<<-1<<std::endl;
    return 0;
  }
  while(need>0){
    need-=pq.top();
    pq.pop();
    ++ans;
  }
  std::cout<<ans<<std::endl;
  
  return 0;
}


Measured memory_bytes: 2936
#include <iostream>
using namespace std;
int main(void){
  int n;
  int m;
  int l;
  int r;
  int min;
  int max;
  int pass;
    
  min = 0;
  max = 1000000000;
  
  cin >> n;
  cin >> m;
  
  for(int i = 0; i < m; i++) {
    cin >> l;
    cin >> r;
	if (l >= min){
      min = l;
    }
    if (r <= max){
      max = r;
    }
  }
  
  pass = max - min + 1;
  if(pass <= 0){
    pass = 0;
  }
  
  cout << pass << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma comment(linker, "/STACK:512000000")
#define _CRT_SECURE_NO_WARNINGS
//#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;

#define all(a) a.begin(), a.end()
typedef long long li;
typedef long double ld;
void solve(bool);
void precalc();
clock_t start;
int main() {
#ifdef AIM
  freopen("/home/alexandero/ClionProjects/ACM/input.txt", "r", stdin);
  //freopen("/home/alexandero/ClionProjects/ACM/output.txt", "w", stdout);
  //freopen("out.txt", "w", stdout);
#else
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
#endif
  start = clock();
  int t = 1;
  cout.sync_with_stdio(0);
  cin.tie(0);
  precalc();
  cout.precision(10);
  cout << fixed;
  //cin >> t;
  int testNum = 1;
  while (t--) {
    //cout << "Case #" << testNum++ << ": ";
    //cerr << testNum << endl;
    solve(true);
    //cerr << testNum - 1 << endl;
  }
  cout.flush();
#ifdef AIM1
  while (true) {
      solve(false);
  }
#endif

#ifdef AIM
  cerr << "\n\n time: " << (clock() - start) / 1.0 / CLOCKS_PER_SEC << "\n\n";
#endif

  return 0;
}

//BE CAREFUL: IS INT REALLY INT?

template<typename T>
T binpow(T q, T w, T mod) {
  if (!w)
    return 1 % mod;
  if (w & 1)
    return q * 1LL * binpow(q, w - 1, mod) % mod;
  return binpow(q * 1LL * q % mod, w / 2, mod);
}

template<typename T>
T gcd(T q, T w) {
  while (w) {
    q %= w;
    swap(q, w);
  }
  return q;
}
template<typename T>
T lcm(T q, T w) {
  return q / gcd(q, w) * w;
}

void precalc() {

}

template<typename T>
void relax_min(T& cur, T val) {
  cur = min(cur, val);
}

template<typename T>
void relax_max(T& cur, T val) {
  cur = max(cur, val);
}

//#define int li
//const int mod = 1000000007;


void solve(bool read) {
  int n;
  cin >> n;
  map<int, int> a;
  for (int i = 0; i < n; ++i) {
    int cur;
    cin >> cur;
    ++a[cur];
  }
  if (a.size() > 2) {
    cout << "No\n";
    return;
  }
  if (a.size() == 1) {
    int cur = a.begin()->first;
    if (cur + 1 == n || 2 * cur <= n) {
      cout << "Yes\n";
    } else {
      cout << "No\n";
    }
    return;
  }
  if (a.begin()->first + 1 != a.rbegin()->first) {
    cout << "No\n";
    return;
  }
  int cur = a.begin()->first;
  int k = a.begin()->second;

  if (k <= cur && n - k >= (cur + 1 - k) * 2) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }

}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

int a,b,c;

int main(){
	cin.sync_with_stdio(false);
  cin>>a>>b>>c;
  rep(i,61){
    int start=(a+b)*i,end=(a+b)*i+a;
    for(int j=0;j<10000;j++){
      if(start<=c+60*j&&c+60*j<=end){
        cout<<c+60*j<<endl;
        return 0;
      }
    }
  }
  cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 3156
let [| N; M |] = stdin.ReadLine().Split() |> Array.map int
let A = stdin.ReadLine().Split() |> Array.map int64
let mutable As = Set.ofArray (Array.zip A [| 1..N |])

for _ in [ 1..M ] do
    let (v, i) as a = Set.maxElement As
    As <- As |> Set.remove a
    As <- As |> Set.add (v / 2L, i)

As
|> Set.fold (fun sum (v, i) -> sum + v) 0L
|> stdout.WriteLine


Measured memory_bytes: 49672
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N, K;
int x[50], y[50];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i];
  }
  ll ans = 1LL << 62;
  for (int l = 0; l < N; l++) {
    for (int r = 0; r < N; r++) {
      for (int d = 0; d < N; d++) {
        for (int u = 0; u < N; u++) {
          if (x[l] > x[r] || x[l] > x[d] || x[l] > x[u]) continue;
          if (x[r] < x[l] || x[r] < x[d] || x[r] < x[u]) continue;
          if (y[d] > y[l] || y[d] > y[r] || y[d] > y[u]) continue;
          if (y[u] < y[l] || y[u] < y[r] || y[u] < y[d]) continue;
          int cnt = 0;
          for (int i = 0; i < N; i++) {
            cnt += (x[l] <= x[i] && x[i] <= x[r] && y[d] <= y[i] && y[i] <= y[u]);
          }
          if (cnt >= K) ans = min(ans, (ll)(x[r] - x[l]) * (y[u] - y[d]));
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}

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

const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

// 階乗を求める
mint facctorial(int k) {
  mint sum = 1;
  int cnt = 0;
  mint i = 1;
  while (cnt < k) {
    sum *= i;
    cnt += 1;
    i += 1;
  }
  return sum;
}

int main() {
  int x, y;
  cin >> x >> y;

  if ((x + y) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }

  if (x * 2 < y || y * 2 < x) {
    cout << 0 << endl;
    return 0;
  }

  if (x * 2 == y || y * 2 == x) {
    cout << 1 << endl;
    return 0;
  }

  if (x == y) {
    int a0 = (x + y) / 3;
    mint a1 = facctorial(a0);
    mint a2 = facctorial(a0 / 2);
    mint ans = a1 / (a2 * a2);
    cout << ans.x << endl;
    return 0;
  }

  int sub = abs(x - y);
  int b0 = (x + y) / 3;
  int b1 = (b0 + sub) / 2;
  mint b2 = facctorial(b0);
  mint b3 = facctorial(b1);
  mint b4 = facctorial(b0 - b1);
  mint ans = b2 / (b3 * b4);
  cout << ans.x << endl;

  return 0;
}

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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	for(int n;cin>>n&&n;){
		vi a(n);
		rep(i,n) cin>>a[i];

		// ? 4 ? 4 ... ? 4 2 2 2 ... 2
		int odd=0,two=0,four=0;
		for(int x:a){
			if(x%4==0)
				four++;
			else if(x%2==0)
				two++;
			else
				odd++;
		}

		if(two==1){
			two--;
			odd++;
		}

		if(two==0)
			cout<<(odd<=four+1?"Yes":"No")<<endl;
		else
			cout<<(odd<=four?"Yes":"No")<<endl;
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

long long min_kobai(int n, int m){
	for(long long l=n; ; l +=n){
		if(l%m==0) return l;
	}
}

long long ans(){
	int n, m;
	long long l;
	std::string s, t;
	std::cin >> n >> m >> s >> t;
	l = min_kobai(n, m);
	for(int i=0; i<n; i++){
		char s1 = s[i];
		if((l/n*i)%(l/m)==0){
			int j = (l/n*i)/(l/m);
			if(t[j]!=s1){
				// printf("%s %s\n"())
				return -1;
			}
		}
	}
	return l;
}

int main(){
	std::cout << ans() <<std::endl;
	return 0;
}


Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

//The House of Huge Family
public class Main{

	class E{
		int s, t, c, id;
		public E(int s, int t, int c, int id) {
			this.s = s;
			this.t = t;
			this.c = c;
			this.id = id;
		}
	}
	
	int n, m;
	List<E>[] adj;
	
	boolean isCon(int f1, int f2){
		boolean[] u = new boolean[n];
		List<Integer> l = new ArrayList<Integer>();
		l.add(0); u[0] = true;
		int N = 0;
		while(!l.isEmpty()){
			List<Integer> next = new ArrayList<Integer>();
			for(int i:l){
				N++;
				for(E e:adj[i])if(!u[e.t]&&e.id!=f1&&e.id!=f2){
					u[e.t] = true; next.add(e.t);
				}
			}
			l = next;
		}
		return N==n;
	}
	
	@SuppressWarnings("unchecked")
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			n = sc.nextInt(); m = sc.nextInt();
			if((n|m)==0)break;
			adj = new List[n];
			for(int i=0;i<n;i++)adj[i]=new ArrayList<E>();
			int N = 0, M = 0;
			List<Integer> cost = new ArrayList<Integer>();
			while(m--!=0){
				int s = sc.nextInt(), t = sc.nextInt(), c = sc.nextInt();
				if(c<=0)M+=c;
				else{
					cost.add(c); adj[s].add(new E(s, t, c, N)); adj[t].add(new E(t, s, c, N)); N++;
				}
			}
			int min = Integer.MAX_VALUE;
			if(!isCon(-1, -1))min = 0;
			for(int i=0;i<N;i++)if(!isCon(i, -1))min = Math.min(min, cost.get(i));
			for(int i=0;i<N;i++)for(int j=i+1;j<N;j++)min = Math.min(min, cost.get(i)+cost.get(j));
			System.out.println(M+min);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
using System;
using System.Linq;
using System.Collections.Generic;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var list = new List<string>();

            var a="";
            for(int i=0;i<ab[1];i++)
            {
                a+=ab[0].ToString();
            }
            list.Add(a);

            var b = "";
            for(int j=0;j<ab[0];j++)
            {
                b+=ab[1].ToString();
            }
            list.Add(b);

            list = list.OrderBy(x=>x).ToList();

            Console.WriteLine(list.First());
        }
    }
}


Measured memory_bytes: 13664
#include<stdio.h>
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,j,n) for((i)=(j) ; (i)<(n) ; (i)++)
#define pl(format,var) p(format "\n",var)
#define p(format,var) printf(format,var)
#define asizeof(array) (sizeof(array)/sizeof(array[0]))

int count(int a){
	int c = 1;
	while(1){
		a /= 10;
		if(a==0)
			break;
		c++;
	}
	return c;
}
int main(){
	int i,j,k,n;
	char line[80];
	int a,b,c;
	while(fgets(line, sizeof(line), stdin) != NULL){
		sscanf(line, "%d %d", &a, &b);
		c = a+ b;
		pl("%d",count(c));
	}
  return 0;
}

Measured memory_bytes: 608
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL N,T; cin >> N >> T;
    VL A(N); REP(i,N) cin >> A[i];
    LL minrec = A[0];
    VL minA(N);
    VL dif(N);
    minA[0] = A[0];
    dif[0] = 0;
    FOR(i,1,N){
        minA[i] = min(minA[i-1], A[i]);
        dif[i] = A[i] - minA[i];
    }
    sort(dif.begin(),dif.end());
    reverse(dif.begin(),dif.end());
    LL ans = 0;
    LL maxdif = dif[0];
    REP(i,N){
        if(dif[i] == maxdif) ans++;
    }
    cout << ans << endl;


}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <stack>
#include <unordered_set>
#include <numeric>
#include <iterator>
#include <unordered_map>
#include <array>
#include <map>
#include <cstring>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctgmath>
#include <set>
#include <queue>

using namespace std;

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

	if (d == 25)
	{
		cout << "Christmas\n";
	}
	else if (d == 24)
	{
		cout << "Christmas Eve\n";
	}
	else if (d == 23)
	{
		cout << "Christmas Eve Eve\n";
	}
	else
	{
		cout << "Christmas Eve Eve Eve\n";
	}

	
}



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


def a1():
    if a[0] == 1 or a[0] == 0:
        a[0] = 0
        return a[0]
    else:
        return a[0] * (a[0] - 1) / 2


def b1():
    if a[1] == 1 or a[1] == 0:
        a[1] = 0
        return a[1]
    else:
        return a[1] * (a[1] - 1) / 2


print(int(a1() + b1()))


Measured memory_bytes: 3064
n = int(input())
counter = 0
for i in range(1,n+1):
  count = 0
  if i % 2 == 1:
    for j in range(1,i+1):
      if i%j == 0:
        count += 1
      if j == i:
        if count == 8:
          counter += 1
print(counter)

Measured memory_bytes: 9180
var input = '';
var line = 0;
var groupname;
var group = {};
var membership = {};

process.stdin.on('data', function (chunk) {
    input += chunk;
});
process.stdin.on('end', function () {
    input = input.trim().split(/\s+/);
    solve();
});

function solve() {
    while (true) {
        var n = input[line++];
        if (n == 0)
            break;
        for (var i = 0; i < n; i++) {
            var nested = input[line++].slice(0, -1).split(':');
            group[nested[0]] = nested[1].split(",");
            if (i === 0) {
                groupname = nested[0];
            }
        }
        dfs(groupname);
        var answer = 0;
        for (var i in membership) {
            ++answer;
        }
        console.log(answer);

        group = {};
        membership = {};
    }
}

function dfs(groupname) {
    var member = group[groupname];
    group[groupname] = [];
    for (var i = 0; i < member.length; i++) {
        element = member[i];
        if (group[element] !== undefined) {
            dfs(element);
        } else {
            membership[element] = true;
        }
    }
}

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

if n % 2 == 1:
    print(0)
    exit(0)

l = []
for i in range(30, 0, -1):
    l.append(2 * (5**i))

here = 0
for i in range(1, len(l)):
    here += (n//l[i] - n//l[i-1]) * (len(l) - i)

print(here)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
template <class T> void chmax(T &x, T y) { if (x < y) x = y; }
const Int INF = 1e18;
Int dp[200020][2][3];
int main() {
    int N; cin >> N;
    vector<int> A(N); for (auto &a : A) cin >> a;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 2; j++) {
            for (int k = 0; k < 3; k++) {
                dp[i][j][k] = -INF;
            }
        }
    }
    if (N % 2 == 0) {
        dp[0][1][1] = A[0];
        dp[0][0][0] = 0;
    } else {
        dp[0][1][2] = A[0];
        dp[0][0][1] = 0;
    }
    for (int i = 0; i < N - 1; i++) {
        for (int j = 0; j < 2; j++) {
            for (int k = 0; k < 3; k++) {
                if (j == 1 || i + 1 >= N - k) {
                    chmax(dp[i + 1][0][k], dp[i][j][k]);
                } else {
                    if (k != 0) {
                        chmax(dp[i + 1][0][k - 1], dp[i][j][k]);
                    }
                    chmax(dp[i + 1][1][k], dp[i][j][k] + A[i + 1]);
                }
            }
        }
    }
    Int ans = -INF;
    for (int j = 0; j < 2; j++) {
        for (int k = 0; k < 3; k++) {
            chmax(ans, dp[N - 1][j][k]);
        }
    }
    cout << ans << '\n';
    return 0;
}


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

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


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

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define MOD 1000000007
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

int D;
vi C, S[370], T, V, cost;

int calc_minus(int day){
    int res = 0;
    rep(i, 26){
        res += C[i] * (day - cost[i]); 
    }
    return res;
}

int calc_S(vi t){
    ll ans = 0;
    cost.resize(26, 0);

    rep(i, D){
        ans += S[i][T[i]-1];
        cost[T[i]-1] = i+1;
        ans -= calc_minus(i+1);
    }

    return ans;
}

int get_max_c(int day){
    int res = -1, tmp = 0;

    rep(i, 26){
        if(tmp < S[day][i] + C[i]){
            res = i;
            tmp = S[day][i] + C[i];
        }
    }

    return res;
}

void solve(){
    rep(i, D){
        T[i] = get_max_c(i) + 1;
    }
    // cout << calc_S(T) << endl;

    rep(i, D) cout << T[i] << endl;
}

int main(){
    cin >> D;
    C.resize(26);
    T.resize(D, 1);
    
    
    rep(i, 26){
        cin >> C[i];
    }   

    rep(i, D){
        S[i].resize(26);
        rep(j, 26) cin >> S[i][j];
    }

    solve();
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
int digit(int n){
		int count = 0; 
		while(n > 0){
			n /= 2; 
			count ++; 
		}
		return count; 
	}
int main(){
	int N; 
	cin >> N; 
	int A[200010] = {}; 
	for(int i = 0; i < N; i++){
		cin >> A[i]; 
	}
	sort(A, A+N, greater<int>()); 
    int D[200010] = {}; 
	for(int i = 0; i < N; i++){
		D[i] = digit(A[i]); 
	}
	int B[200010] = {}; 
	for(int i = 0; i < N; i++){
		B[i] = (1 << D[i]) - A[i]; 
	}
	int count = 0; 
	int r = N - 1; 
	for(int i = 0; i < N; i++){
		for(int j = r; j >= 0; j--){
                        if(B[i] == -1){break; }
			if((B[i] == A[j] && B[i] > 0) && i != j){count ++; A[i] = -1, A[j] = -1; B[i] = -1; B[j] = -1; r = j-1; break;}
			if(B[i] > 0 && A[j] > 0 && B[i] < A[j]){r = min(j+1, N-1); break;}
		}
		if((i != (N - 1)) && D[i] != D[i+1]) {r = N - 1;}
	}
	cout << count << endl; 
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
using namespace std;
int main(void){
  string s;
  cin >> s;
  
  bool ans = false;
  
  for(int i=0;i<3;i++){
    if(s[i] == '7') ans = true;
  }
  
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

#define int ll

int n,m;
int a[1001],b[1001],c[1001];
int d[1001][1001];
int dd[1001][1001];
int cnt;

void warshall_floyd(int n){
  rep(i,0,n)rep(j,0,n)rep(k,0,n){
    if(d[j][k]>d[j][i]+d[i][k] )d[j][k]=d[j][i]+d[i][k];
  }
}

signed main(){
    cin>>n>>m;
    rep(i,0,1000)rep(j,0,1000){
        if(i!=j)d[i][j]=1<<28;
        else d[i][j]=0;
    }
    rep(i,0,m){
        cin>>a[i]>>b[i]>>c[i];
        a[i]--,b[i]--;
        d[a[i]][b[i]]=c[i];
        d[b[i]][a[i]]=c[i];
        dd[a[i]][b[i]]=dd[b[i]][a[i]]=c[i];
    }
    warshall_floyd(n);
    
    cnt=0;
    rep(i,0,n){
        rep(j,i+1,n){
            if(dd[i][j]>d[i][j])cnt++;
        }
    }
    
    cout<<cnt<<endl;
    
    return 0;
}

Measured memory_bytes: 10240
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  if(a == 1) a = 14;
  if(b == 1) b = 14;
  if(a > b) cout << "Alice" << endl;
  else if(a < b) cout << "Bob" << endl;
  else cout << "Draw" << endl;
  return 0;
}

Measured memory_bytes: 3632
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int s = sc.nextInt();
		sc.close();

		PrintWriter pw = new PrintWriter(System.out);
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < k; i++) {
			sb.append(s).append(' ');
		}
		int a = s + 1;
		if (s == 1000000000) {
			a = 1;
		}
		for (int i = k; i < n; i++) {
			sb.append(a).append(' ');
		}
		sb.deleteCharAt(sb.length() - 1);
		System.out.println(sb.toString());
		pw.flush();
	}
}


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

using namespace std;
int main(){
long long n,y;
cin>>n>>y;
if(y%1000)
{
    cout<<"-1 -1 -1";
    return 0;
}

for(long long i=0;i<=n;i++)
{
    for(long long j=0;j+i<=n;j++)
    {
            long long k=n-i-j;
            long long s=k*1000ll+j*5000ll+10000ll*i;
            if(s==y)
            {
                if(i+j+k==n)
                {
                    cout<<i<<" "<<j<<" "<<k<<endl;
                    return 0;
                }
            }
            
        
    }
}
cout<<"-1 -1 -1";
return 0;
}
 


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        int a = Integer.parseInt(n.substring(0,1));
        int b = Integer.parseInt(n.substring(1,2));
        int c = Integer.parseInt(n.substring(2,3));
        int d = Integer.parseInt(n.substring(3,4));
        if(a+b+c+d==7) {
            System.out.println(a+"+"+b+"+"+c+"+"+d+"=7");
            return;
        }
        if(a+b+c-d==7) {
            System.out.println(a+"+"+b+"+"+c+"-"+d+"=7");
            return;
        }
        if(a+b-c+d==7) {
            System.out.println(a+"+"+b+"-"+c+"+"+d+"=7");
            return;
        }
        if(a-b+c+d==7) {
            System.out.println(a+"-"+b+"+"+c+"+"+d+"=7");
            return;
        }
        if(a+b-c-d==7) {
            System.out.println(a+"+"+b+"-"+c+"-"+d+"=7");
            return;
        }
        if(a-b+c-d==7) {
            System.out.println(a+"-"+b+"+"+c+"-"+d+"=7");
            return;
        }
        if(a-b-c+d==7) {
            System.out.println(a+"-"+b+"-"+c+"+"+d+"=7");
            return;
        }
        if(a-b-c-d==7) {
            System.out.println(a+"-"+b+"-"+c+"-"+d+"=7");
            return;
        }
        
    }
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int n;
	cin>>n;
	int a,b;
	cin>>a>>b;
	int c[3];
	c[0]=0;
	c[1]=0;
	c[2]=0;
	int i;
	while(n--)
	{
		cin>>i;
		if(i<=a)
		c[0]++;
		else if(i>=b+1)
		c[2]++;
		else
		c[1]++;
	}
	cout<<min(c[0],min(c[1],c[2]));
	return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define clr(s, x) memset(s, x, sizeof(s))
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
inline int read(){int r=0;char c=getchar();while(c<'0'||c>'9') {c=getchar();}while(c>='0'&&c<='9') {r=r*10+c-'0';c=getchar();}return r;}
inline ll readll(){ll r=0;char c=getchar();while(c<'0'||c>'9') {c=getchar();}while(c>='0'&&c<='9') {r=r*10+c-'0';c=getchar();}return r;}
inline ll qpow(ll a,ll b,ll mod){ll res=1;while(b){if(b&1)res = (res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}
inline ll gcd(ll a,ll b){while(b^=a^=b^=a%=b);return a;}
const double eps = 1e-8;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int MAXN = 1e6+100;
const int MAXM = 1e5;
int main(){
	ll n,a,b;
	cin>>n>>a>>b;
	ll day=a-1;
	if(day+2>n){
		cout<<n+1<<endl;
	}
	else{
		ll res=n-day;
		ll ans=res%2;
		res/=2;
		cout<<max(n+1,ans+b*res-(res-1)*a);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
int tab[101][3];
int a[102];
int b[102];
int main(){
    int n;
    cin >> n;
    for ( int i = 1 ; i <= n ; i++){
        cin >> tab[i][1];
        a[i]=a[i-1]+tab[i][1];
    }
    for ( int i = 1 ; i <= n ; i++){
        cin >> tab[i][2];

    }
    for ( int i = n ; i > 0 ; i--){
        b[i]=b[i+1]+tab[i][2];
    }
    int m = 0;
    for ( int i = 1 ; i <= n ; i++){
        if ( m < a[i] + b[i]){
            m = a[i] + b[i];
        }
    }
    cout << m;
return 0;
}


Measured memory_bytes: 256