akhauriyash/Code-Regression huggingface dataset:
s = input()

max = 2 ** 3

for i in range(max):
    b = bin(i)[2:].zfill(3)
    op = []
    test = int(s[0])
    for j, flag in enumerate(b):
        if flag == '1':
            test += int(s[j+1])
            op.append('+')
        else:
            test -= int(s[j+1])
            op.append('-')
    if test == 7:
        break

print(s[0]+op[0]+s[1]+op[1]+s[2]+op[2]+s[3]+'=7')

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

#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
namespace adaptor = boost::adaptors;

// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */

using ll = long long;
using ull = unsigned long long;

/*
	int N;
	std::cin >> N;
	std::vector<int> vec(N);
	for (auto& v : vec)
	{
		std::cin >> v;
	}
*/

void Main()
{
	int A;
	cin >> A;

	if (A % 1000 != 0) {
		cout << 1000 - (A % 1000);
	}
	else {
		cout << 0;
	}
	return;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

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

int main() {
  ll n, K;
  cin >> n >> K;
  pair<ll, ll> p[100005];
  rep(i, n) {
    ll a, b;
    cin >> a >> b;
    p[i] = make_pair(a, b);
  }

  ll ans = 0;
  sort(p, p+n);
  rep(i, n) {
    if (p[i].second < K) {
      K -= p[i].second;
    }
    else {
      ans = p[i].first;
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1920
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int a, b, c, d;
signed main(){
	cin >> a >> b >> c >> d;
	if(a != c) cout << 1 << endl;
	else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int n , a[10000] , maxc = -1 , temp , s =0;

int main(){
     cin >> n;
     for(int i = 0 ; i < n ; i++){ cin >> a[i]; s+= a[i];}
     cout << abs(s-n);
     return 0;
}

Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
d = [0] * N
for i in range(N - 1):
    if S[i:i + 2] == 'AC':
        d[i + 1] += 1

for i in range(1, N):
    d[i] += d[i - 1]

for i in range(Q):
    l, r = map(int, input().split())
    l, r = l - 1, r - 1
    print(d[r] - d[l])

Measured memory_bytes: 9332
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;

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

    string u;
    cin >> u;

    if (s == u)
    {
        a--;
    }
    else
    {
        b--;
    }
    cout << a << " " << b << endl;
}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))

#define MAX_N 100005
#define INF 1000000000
#define MOD 1000000007

ll N;
ll fact[MAX_N];
ll fact_inv[MAX_N];
int isExist[MAX_N];     // 存在するならそのインデックス。存在しないなら -1

ll combination(int n, int r) {
    assert(n <= N+1);
    assert(r <= n);
    ll ret = (fact[n] * fact_inv[n - r]) % MOD;
    ret = (ret * fact_inv[r]) % MOD;
    return ret;
}
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while ( n > 0) {
        if (n & 1) { res = res * x % mod; } // 最下位ビットが立っているときに x^(2^i) を掛ける
        x = x * x % mod;                    // x を順次 2 乗していく
        n >>= 1;
    }
    return res;
}

int main()
{
    ZERO(fact);
    ZERO(fact_inv);
    MINUS(isExist);
    cin >> N;
    fact[0] = 1;
    for(int i = 1; i <= N+1; ++i) {
        fact[i] = fact[i-1] * i;
        fact[i] %= MOD;
    }
    fact_inv[N+1] = mod_pow(fact[N+1], MOD-2, MOD);
    assert((fact[N+1] * fact_inv[N+1] % MOD) == 1);
    for(int i = N; i >= 0; --i) {
        fact_inv[i] = (fact_inv[i + 1] * (i + 1)) % MOD;
        assert((fact[i] * fact_inv[i] % MOD) == 1);
    }

    ll first = 0;
    ll second = 0;   // 2 番目が出て来る場所
    REP(i, N+1) {
        ll tmp;
        cin >> tmp;
        if(isExist[tmp] != -1) {
            first = isExist[tmp];
            second = i;
            break;
        }
        isExist[tmp] = i;
    }

    //printf("second: %lld\n", second);
    assert(second != 0);
    printf("%lld\n", N);
    for(int i = 2; i <= N+1; ++i) {
        ll a = combination(N+1, i);
        ll b = 0;
        if(N - second + first >= i-1) {
            b = combination(N - second + first, i-1);
        }
        //printf("a: %lld\n", a);
        //printf("b: %lld\n", b);
        printf("%lld\n", (a - b + MOD) % MOD);
    }
    return 0;
}


Measured memory_bytes: 3200
(N,K) = map(int,input().split())
h = list(map(int,input().split()))
n = 2
cost = [0]*N
cost[1] = abs(h[1]-h[0])
for n in range(2,N):
    costmin = 10**10
    for i in range(max(0,n-K),n):
        costmin = min(costmin,cost[i]+abs(h[n]-h[i]))
    cost[n] = costmin
    
print(cost[N-1])

Measured memory_bytes: 84768
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
  int n;
  scanf("%d",&n);
  if(n==1)
     printf("Hello World");
  
  else
  {
    int a,b;
    scanf("%d%d",&a,&b);
    printf("%d",a+b);
  }
  
}

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

int main()
{
	ll N;
	cin >> N;
	double ans(0),x;
	string u;
	for(ll i(0);i<N;++i){
		cin >> x;
		cin >> u;
		if((char)u[0] == 'J'){
			ans += x;
		}else if((char)u[0] == 'B'){
			ans += 380000 * x;
		} 
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
d = {}

N=int(input())

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


for a in A:
    if a in d.keys():
        d[a] += 1
    else:
        d[a] = 1

def solve(n):
    if n ==1 or n==0:
        return 0
    return n*(n-1)//2

ret1 = {}
ret2 = {}
for k in d.keys():
    ret1[k]=solve(d[k])
    ret2[k]=solve(d[k]-1)


sums=sum(ret1.values())
for  i in range(N):
    ans = sums - ret1[A[i]] + ret2[A[i]]
    print(ans)

Measured memory_bytes: 41744
#include "bits/stdc++.h"
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(V) (V).begin(), (V).end() 
using namespace std;
typedef long long ll;
string to_string(string s) {
  return '"' + s + '"';
}
string to_string(const char* s) {
  return to_string((string) s);
}
string to_string(bool b) {
  return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef KEK
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {fio;
	int n, k, c;
	cin >> n >> k >> c;
	string s;
	cin >> s;
	vector <int> pref(n, 0);
	for(int i = 0; i < s.size(); i++) {
		if(s[i] == 'o') {
			pref[i] = (i - c - 1 >= 0 ? pref[i - c - 1] : 0) + 1;
		} else {
			pref[i] = i ? pref[i - 1] : 0;
		}
	}
	vector <int> suff(n, 0);
	for(int i = n - 1; i >= 0; i--) {
		if(s[i] == 'o') {
			suff[i] = 1 + (i + c + 1 < n ? suff[i + c + 1] : 0);
		} else {
			suff[i] = i == n - 1 ? 0 : suff[i + 1];
		}
	}
	vector <bool> can_take(n, false);
	vector <int> pos;
	for(int i = 0; i < n; i++) {
		int bst = (i - c - 1 >= 0 ? pref[i - c - 1] : 0) + (i + c + 1 < n ? suff[i + c + 1] : 0);
		if(bst == k - 1 && s[i] == 'o') {
			can_take[i] = true;
			pos.push_back(i);
		}
	}
	// debug(pos);
	// debug(pref);
	// debug(suff);
	for(int i = 0; i < pos.size(); i++) {
		bool h = false;
		if(i) {
			int bef = pos[i - 1];
			int bstbef = pref[bef];
			int kek = max(bef + c + 1, pos[i] + 1);
			int rem = kek < n ? suff[kek] : 0;
			if(rem + bstbef >= k) {
				h = true;
			}
		}
		if(i < pos.size() - 1) {
			int af = pos[i + 1];
			int bstaf = suff[af];
			int kek = min(af - c - 1, pos[i] - 1);
			int rem = kek >= 0 ? pref[kek] : 0;
			if(rem + bstaf >= k) {
				h = true;
			}
		}
		if(!h) {
			cout << pos[i] + 1 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 4364
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, K;
bool Count[105];

int main(){
  cin >> N >> K;
  for (int i = 0; i < K; i++){
    int D; cin >> D;
    for (int j = 0; j < D; j++){
      int A; cin >> A;
      Count[A] = true;
    }
  }
  int ans = 0;
  for (int i = 1; i <= N; i++){
    if (Count[i] == 0) ans++;
  }
  cout << ans << endl;
  

  return 0;
}


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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

#ifdef LOCAL
#define i64 "%lld"
#else
#define i64 "%I64d"
#endif

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int N = 1e5 + 10;

int n, cnt[N];
bool can[N];

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

    int m;
    cin >> n >> m;
    fill(cnt, cnt+n, 1);
    can[0] = 1;

    while (m--) {
        int x,y; cin >> x >> y;
        x--; y--;
        if (can[x]) {
            if (cnt[x] == 1) {
                can[x] = false;
                can[y] = true;
            }
            else can[y] = true;
        }
        cnt[x]--;
        cnt[y]++;
    }
    int ans = 0;
    forn(i,n) ans += can[i];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 768
#include<stdio.h>
#include<math.h>
int main(){
    long N,i,j,center;
    scanf("%ld",&N);
    center = sqrtl(N);
    i = center;
    
    while(N%i!=0){
        i--;
    }
    j = N/i;
    printf("%ld",i+j-2);
    return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    int n; ll k; cin >> n >> k;
    vector<ll> A(n); rep(i, n) cin >> A[i], A[i]--;

    //ダブリング
    vector<vector<ll>> D(70, vector<ll>(n));
    rep(i, n)D[0][i] = A[i];
    rept(i, 1, 70){
        rep(j, n){
            D[i][j] = D[i-1][D[i-1][j]];
        }
    }
    /*
    rep(i, 5){
        rep(j, n){
            cout << D[i][j] << " ";
        }cout << ln;
    }*/

    vector<int> check(65); ll num = k, rui = pow(2, 60);
    for(int i=60; i>=0; i--){
        if(num >= rui){
            check[i] = true;
            num -= rui;
        }
        rui /= 2;
    }
    int v = 0;
    rep(i, 65){
        if(check[i]){
            v = D[i][v];
        }
    }
    cout << v + 1 << ln;
}
    


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

long long n,q,i,j,k,d,m,d_m,ans;
char s[1000005];
	
int main()
{
	cin>>n>>s>>q;
	for(i=0; i<q; i++)
	{
		cin>>k;
		d=m=d_m=ans=0;
		for(j=0; j<n; j++)
		{
			if(j>=k)
			{
				if(s[j-k]=='D')
				{
					d--;
					d_m-=m;
				}
				if(s[j-k]=='M')
					m--;
			}
			if(s[j]=='D')
				d++;
			if(s[j]=='M')
			{
				m++;
				d_m+=d;
			}
			if(s[j]=='C')
				ans+=d_m;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<cmath>

using namespace std;

bool isPrime(int a){
	for ( int i = 3; i <= sqrt(a); i+=2){
		if (a%i == 0) return false;
	}
	return true;
}
int main(){
	int n; cin >> n;
	int count = 0;
	for (int i = 0; i < n; i++){
		int num; cin >> num;
		if(num == 2){
			count++;
		}else if(num%2 == 0) {
			;
		}else if(isPrime(num)){
			count++;
		}
	}
	cout << count << endl;
return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;
typedef unsigned long long BITMASK; typedef long long ll; typedef long double ld;
#define smallest_on_bit(bit_mask) (__builtin_ctzint((bit_mask) & (-(bit_mask))))
#define CLOCK_START clock_t chrono_clk_beg = clock()
#define CLOCK_END clock_t chrono_clk_end = clock(); cerr << (double(chrono_clk_end - chrono_clk_beg) / CLOCKS_PER_SEC) << " sec"
#define bug(args ...) cerr << __LINE__ << ">> ", err(new istringstream(string(#args)), args), cerr << '\n'
#define decToBin(name, num) string name = bitset<8>(num).to_string();
#define binToDec(name, binary) unsigned long name = bitset<8>(binary).to_ulong();
#define radToDeg(name, radians) double name = radians * 180 / M_PI;
#define all(x) x.begin(), x.end()
#define mapfind(mp, x) (mp.find(x) != mp.end())
#define arrfind(arr, x) (find(all(arr), x) != arr.end())
#define removeDuplicates(vec) sort(vec.begin(), vec.end()); vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define printMat(mat) for (auto &x : mat) { for (auto &y : x) cout << y << " "; cout << '\n'; }
#define printArr(arr) for (auto &x : arr) cout << x << " "; cout << '\n';
#define ceil(a, b) ((a+b-1)/b)
#define int ll
#define double ld
#define INF (1LL<<62)
#define M_PI 3.14159265358979323846
void err(istringstream *iss) {} template<typename T, typename ... Args> void err(istringstream *iss, const T &_val, const Args & ... args) { string _name; *iss >> _name; if (_name.back()==',') _name.pop_back(); cerr << _name << " = " << _val << "; ", err(iss, args ...); }
void str_replaceAll(string& str, const string& from, const string& to) { if(from.empty()) return; size_t start_pos = 0; while((start_pos = str.find(from, start_pos)) != std::string::npos) { str.replace(start_pos, from.length(), to); start_pos += to.length(); } }
#define MOD 1000000007

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int res[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << res[k-1] << '\n';
    return 0;
}

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

#define int long long

int32_t main() {
	int l , r ;
	cin >> l >> r ;
	int x = r%2019 , y = l%2019 ;
	if(l + 2019 <= r || (x <= y)){
		cout << 0 ;
	}else{
		int m = 2018 ;
		for(int i = y ; i  <= x ; i++){
			for(int j = i + 1 ; j <= x ; j++ ){
				m = min(m,(i*j)%2019);
			}
		}
		cout << m ;
	}
	return 0;
}

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

using namespace std;

int H, W, N;
vector<int> ans;
vector<pair<int, int>> ab;
map<pair<int, int>, int> colored;

long long res;
int main() {
  cin >> H >> W >> N;
  ans.resize(10);
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    ab.push_back(make_pair(a, b));
    colored[make_pair(a, b)] = 0;
  }
  sort(ab.begin(), ab.end());
  res = (long long)(H - 2) * (W - 2);
  // cout << res << endl;
  for (int i = 0; i < ab.size(); i++) {
    int a = ab[i].first;
    int b = ab[i].second;
    int color_bit = colored[make_pair(a, b)];
    for (int y = 0; y < 3; y++) {
      for (int x = 0; x < 3; x++) {
        int bit = y * 3 + x;
        int color_bit = colored[make_pair(a, b)];

        if (color_bit & (1 << bit)) {
          //cout << "a = " << a << " b = " << b << " " << y << " " << x << endl;
          continue;
        }

        bool ok = true;
        for (int Y = a - y; Y < (3 - y) + a; Y++) {
          for (int X = b - x; X < (3 - x) + b; X++) {
            if (Y < 0 or Y >= H or X < 0 or X >= W) {
              ok = false;
              break;
            }
          }
        }
        if (ok) {
          colored[make_pair(a, b)] |= 1 << bit;
          int index = 0;
          int cnt = 0;
	  //cout << "a = " << a << " b = " << b << " " << y << " " << x << endl;
          for (int Y = a - y; Y < (3 - y) + a; Y++) {
            for (int X = b - x; X < (3 - x) + b; X++) {
              if (colored.count(make_pair(Y, X)) > 0) {
		//cout << "Y = " << Y << " X = "  << X << " " << index << endl;
                colored[make_pair(Y, X)] |= 1 << index;
                cnt++;
              }
              index++;
            }
          }
          ans[cnt]++;
          if (cnt == 3) {
            // cout << "a = " << a << " b = " << b << " " << y << " " << x <<
            // endl;
          }
        }
      }
    }
  }
  long long sum = 0;
  for (int i = 0; i < ans.size(); i++){
    sum += ans[i];
  }
  for (int i = 0; i < ans.size(); i++) {
    if (i == 0){
      cout << res - sum << endl;
    }else{
      cout << ans[i] << endl;
    }
  }
}


Measured memory_bytes: 7412
#include<stdio.h>

typedef long long int int64;

int64 calc(int64 k,int64 a,int64 b){
  if(k<=a) return 1;
  if(a-b<=0) return -1;
  return 1+((k-a)+(a-b)-1)/(a-b)*2;
}

void run(void){
  int64 k,a,b;
  scanf("%lld%lld%lld",&k,&a,&b);
  printf("%lld\n",calc(k,a,b));
}

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

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc153() {
	ll n, k;
	ll ans = 0;

	cin >> n >> k;

	V h(n);
	rep(i, n) {
		cin >> h[i];
	}

	sort(ALL(h));

	rep(i, n - k) {
		ans += h[i];
	}

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

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

	solve_abc153();

	return 0;
}

Measured memory_bytes: 1792
#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 INF = 1001001001;

int main() {
  string s;
  cin>>s;
  int tmp = 0, ans = 0;

  rep(i,s.length()){
    if(s[i] == 'A' || s[i] == 'T' || s[i] == 'C' || s[i] == 'G'){
      tmp++;
      ans = max(ans, tmp);
    }else tmp = 0;
  }
  cout<<ans<<endl;

  return 0;
}

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr const char* YES = "YES";
static constexpr const char* NO = "NO";

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

int main(int argc, char* argv[]) {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> p(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &p[i]);
  }

  vector<ll> candidates;

  rep(i, 0, N) {
    if (p[i] == i + 1) continue;
    candidates.pb(i);
  }

  if (!sz(candidates)) {
    cout << YES << endl;
    return 0;
  }

  if (sz(candidates) > 2) {
    cout << NO << endl;
    return 0;
  }

  cout << YES << endl;
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 256
from fractions import gcd

def prime(n:int):
    cnt = 2
    ans = set()
    while n > 1:
        if n%cnt == 0:
            ans.add(cnt)
        while n%cnt == 0:
            n //= cnt
        cnt += 1
    return ans

def main():
    N,K = map(int,input().split())
    P = [(int(p)+1)/2 for p in input().split()]

    S = [P[0]]
    for p in P[1:]:
        S.append(S[-1] + p)
    S += [0]
    ans = 0
    for i in range(N - K + 1):
        ans = max(ans,S[i + K - 1] - S[i-1])
    print(ans)
    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 26188
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long int64;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    vector<int> h(n + 1);
    for (int i = 1; i <= n; ++ i) {
        cin >> h[i];
    }
    vector<int> adj[n + 1];
    for (int i = 0; i < m; ++ i) {
        int u, v;
        cin >> u >> v;
        adj[u].emplace_back(v);
        adj[v].emplace_back(u);
    }
    int ans = n;
    for (int i = 1; i <= n; ++ i) {
        for (auto& x : adj[i]) {
            if (h[x] >= h[i]) {
                ans --;
                break;
            }
        }
    }
    cout << ans;
    
}

Measured memory_bytes: 8788
n = int(input())
a = list(map(int, input().split()))
x = list(sorted(set(a)))
n_sub = n * (n + 1) // 2
Li = 0
Ri = len(x)
while Ri > Li + 1:
    i = (Li + Ri) // 2
    xi = x[i]
    UorD = [1 if ak >= xi else -1 for ak in a]
    cnt_sum = [0] * (2 * n + 1)
    cumsum = 0
    cnt_sum[cumsum + n] = 1
    judge = 0
    s = 0
    for uk in UorD:
        cumsum += uk
        if uk == 1:
            s += cnt_sum[cumsum + n] + 1
        else:
            s -= cnt_sum[cumsum + n + 1] - 1
        cnt_sum[cumsum + n] += 1
        judge += s
        if judge >= n_sub // 2:
            Li = i
            break
    else:
        Ri = i
print(x[Li])


Measured memory_bytes: 14852
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define ssd ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type, less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>


int main()
{
	ssd
	#define task "TASK"
	 //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);
    int n;
    cin>>n;
    ll x=n/100;
    ll y=n%100;
    if(y>0 && y<=12)
    {
        if(x>0 && x<=12)
        {
            cout<<"AMBIGUOUS";
        }
        else
        {
            cout<<"YYMM";
        }
    }
    else
    {
        if(x>0 && x<=12)
        {
            cout<<"MMYY";
        }
        else
        {
            //cout<<"YYMM";
            cout<<"NA";
        }
    }

	return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    string s;
    IN s;
    int a = 700;
    rep(i,0,3){
        if(s[i] == 'o')a += 100;
    }
    P(a);
	return  0;
}

Measured memory_bytes: 256
#include<stdio.h>
using namespace std;

int main(){
    int a,b;
    char c;
    for(;;){
        scanf("%d %c %d",&a,&c,&b);
        if(c == '?'){
            break;
        }
        if(c =='+'){
            printf("%d\n",a+b);
        }else if(c =='-'){
            printf("%d\n",a-b);
        }else if(c =='*'){
            printf("%d\n",a*b);
        }else if(c =='/'){
            printf("%d\n",a/b);
        }
    }
    
}


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

void run(void){
  double x=0,y=0;
  int dir=90;
  int d,a;
  scanf("%d,%d",&d,&a);
  while(d!=0 || a!=0){
    x+=d*cos(M_PI*dir/180);
    y+=d*sin(M_PI*dir/180);
    dir=(dir-a+360)%360;
    scanf("%d,%d",&d,&a);
  }
  printf("%d\n%d\n",(int)x,(int)y);
}

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


Measured memory_bytes: 2100
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>s;
    rep(i,n){
        if(s[i]=='R')cnt++;
        else tmp++;
    }
    if(cnt>tmp)Cout("Yes");
    else Cout("No");
    return 0;
}


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

int main(){
    int w,h,n;
    cin >> w >> h >>n;
    int x,y,a;
    int L=0,R=w,U=0,H=h;
    for(int i=0;i<n;i++){
        cin >> x >> y >> a;
        if(a==1)
        L=max(L,x);
        else if(a==2)
        R=min(R,x);
        else if(a==3)
        U=max(U,y);
        else
        H=min(H,y);
    }
    if(R<=L||H<=U)
    cout << 0 << endl;
    else
    cout << (R-L)*(H-U) << endl;
}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n;
  std::cin >> n;
  std::vector<int64_t> a(n);
  std::cin >> a;

  int64_t m0 = 0, n0 = 0;
  for (int64_t i = 0; i < n; i++) {
    if (m0 < a[i]) {
      m0 = a[i];
      n0 = 1;
    } else if (m0 == a[i]) {
      n0++;
    }
  }

  int64_t m1 = 0;

  for (int64_t i = 0; i < n; i++) {
    if (m1 < a[i] && a[i] != m0) {
      m1 = a[i];
    }
  }

  for (int64_t i = 0; i < n; i++) {
    if (m0 != a[i]) {
      std::cout << m0 << std::endl;
    } else if (m0 == a[i] && n0 == 1) {
      std::cout << m1 << std::endl;
    } else {
      std::cout << m0 << std::endl;
    }
  }

  return 0;
}


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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define rep(idx, N) for (u64 idx = 0; idx < N; idx++)

vector<u32> v[200005];

int main() {
  u32 n, m;
  cin >> n >> m;

  unordered_set<u32> p;
  rep(i, n) { p.insert(i); }

  rep(i, m) {
    u32 a, b;
    cin >> a >> b;
    v[a - 1].push_back(b - 1);
    v[b - 1].push_back(a - 1);
  }

  deque<vector<u32>> g;

  u64 ans = 0;
  u64 mem = 0;

  while (!p.empty()) {
    mem = 0;
    g.clear();

    g.push_back(v[*p.begin()]);
    p.erase(*p.begin());

    mem++;

    while (!g.empty()) {
      for (auto f : *g.begin()) {
        if (p.find(f) != p.end()) {
          mem++;
          p.erase(f);
          g.push_back(v[f]);
        }
      }
      g.pop_front();
    }

    if (mem > ans)
      ans = mem;
  }

  cout << ans;

  return 0;
}


Measured memory_bytes: 23444
# -*- coding: utf-8 -*-
a = int(input())  # Nを入力
b = input()  # a1,a2...anを入力
b = map(int, b.split())  # a1,a2...anをint型でリストに入れる
b = sorted(b)  # 大きい順に並べる 
b = b[::-1]  # リストの要素の順番を逆転する
c = b[::2]  # Aliceのとる要素を抽出
c_number = len(c)
d = b[1::2]  # Bobのとる要素を抽出
d_number = len(d)
c_sum = 0
d_sum = 0
for i in range(c_number):
    c_sum += c[i] # Aliceのとる要素の合計
for g in range(d_number):
    d_sum += d[g]  # Bobのとる要素の合計
print(c_sum - d_sum)  # 差分を出力


Measured memory_bytes: 3064
#include <stdio.h>

int main(){
    int a, b, c, tot=3;
    scanf("%d %d %d", &a, &b, &c);
    if(a==b || a==c){
        tot-=1;
    }
    if(b==c){
        tot-=1;
    }

    printf("%d\n", tot);
    return 0;
}

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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int N = 1e5 + 10;
ll n, x, y, z, a[N], b[N], c[N];

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

    cin >> x >> y >> z;
    n = x+y+z;

    ll fix = 0;
    forn(i,n) {
        cin >> a[i] >> b[i] >> c[i];
        b[i] -= a[i];
        c[i] -= a[i];
        fix += a[i];
        a[i] = 0;
    }

    vi p(n); iota(all(p),0);
    sort(all(p), [&](int i, int j) {
        return b[i] - c[i] > b[j] - c[j];
    });

    ll sum = 0;
    vector<ll> pref(1), suf(1);
    priority_queue<ll,vector<ll>,greater<ll>> q;
    forn(i,n) {
        auto elem = b[p[i]];
        q.push(elem);
        sum += elem;
        if (si(q) > y) {
            sum -= q.top();
            q.pop();
        }
        pref.pb(sum);
    }

    while (!q.empty()) {
        //D(q.top());
        q.pop();
    }
    sum = 0;
    dforsn(i,0,n) {
        auto elem = c[p[i]];
        q.push(elem);
        sum += elem;
        if (si(q) > z) {
            sum -= q.top();
            q.pop();
        }
        suf.pb(sum);
    }

    ll ans = -9e18;
    for (int pr = y, su = n-y; su >= z; pr++, su--) {
        ans = max(ans, pref[pr] + suf[su]);
    }
    cout << ans+fix << endl;

    return 0;
}


Measured memory_bytes: 6260
#include<cstdio>

using namespace std;

char ch[1100100];
int N;

bool isD[1100100], isM[1100100], isC[1100100];

long long solve(int K){
	long long m = 0, c = 0, mc = 0;
	long long ans = 0;
	for(int i = 1; i <= K - 1; ++i){
		if(isM[i]){
			m++;
		}
		if(isC[i]){
			mc += m;
			c++;
		}
	}
	for(int i = 0; i < N; ++i){
		if(isD[i]){
			ans += mc;
		}
		if(i + 1 < N && isM[i + 1]){
			mc -= c;
			m--;
		}
		if(i + 1 < N && isC[i + 1]){
			c--;
		}
		if(i + K < N && isM[i + K]){
			m++;
		}
		if(i + K < N && isC[i + K]){
			mc += m;
			c++;
		}
	}
	return ans;
}

int main(){
	scanf("%d", &N);
	scanf("%s", ch);
	for(int i = 0; i < N; ++i){
		if(ch[i] == 'D') isD[i] = true;
		if(ch[i] == 'M') isM[i] = true;
		if(ch[i] == 'C') isC[i] = true;
	}
	int Q;
	scanf("%d", &Q);
	for(int i = 0; i < Q; ++i){
		int K;
		scanf("%d", &K);
		long long ans = solve(K);
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 4224
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

const ll MOD = 998244353;

int main() {
    int N, K;
    cin >> N >> K;
    int a[N];
    for(int i = 0; i < N; i++) cin >> a[i];

    ll ans = 0;
    vector<ll> dp(K + 1, 0);

    dp[0] = 1;
    for(int i = 0; i < N; i++) {
        for(int j = K; j - a[i] >= 0; j--) {
            dp[j] += dp[j - a[i]];
            dp[j] %= MOD;
        }
        ans += dp[K];
        ans %= MOD;
        dp[0]++;
    }

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


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

const int prime[15] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47};
const int pow[5] = {2, 4, 14, 24, 74};
int dp[15];

void fact(int n) {
	for (int i = 0; i < 15; i++) {
		if (n == prime[i]) {
			dp[i]++;
			return;
		}
	}
	for (int i = 0; i < 15; i++) {
		if (n % prime[i] == 0) {
			dp[i]++;
			fact(n / prime[i]);
			return;
		}
	}
}

int main() {
	int n;
	cin >> n;
    int c[5] {0};
	for (int i = 0; i < 15; i++) {
		dp[i] = 0;
	}
	for (int i = 1; i <= n; i++) {
		fact(i);
	}
    for(int i = 0; i < 15; i++){
        for(int j = 0; j < 5; j++){
            if(dp[i] >= pow[j]){
                c[j]++;
            }
        }
    }
    cout << c[4] + c[3] * (c[0] - 1) + c[2] * (c[1] - 1) + c[1] * (c[1] - 1) * (c[0] - 2) / 2;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll now = 0;
    int ten = 1;
    ll ans = 0;
    int l = (int)s.size();
    vint cnt(2019,0);
    cnt[0] = 1;
    for(int i = l-1;i>=0;--i){
        int num = (int)(s[i]-'0');
        now += ten*num;
        ten *= 10;
        ten %= 2019;
        now %= 2019;
        ans += cnt[now];
        cnt[now]++;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
long double a,b,h,m,c,d1,d2;
int main()
{
	cin>>a>>b>>h>>m;
	d1=m/2.0+h*30.0;
	d2=m*6.0;
	d2=fabs(d1-d2);
	c=sqrt(2.0*a*b)*sqrt((a*a+b*b)/(2.0*a*b)-cos(d2*3.14159265358979323846264338327950L/180.0));
	cout<<fixed<<setprecision(15)<<c; 
}


Measured memory_bytes: 4128
#include<bits/stdc++.h>
using namespace std;
string a, s="None";
int i, c[130];
int main(){
  cin>>a;
  for(i=0;a[i];i++)c[a[i]]++;
  for(i='z';i>='a';i--)if(!c[i])s=i;
  cout<<s<<endl;
}

Measured memory_bytes: 512
n, m = [int(i) for i in input().split()]
ab = [[int(i) for i in input().split()] for j in range(n)]
ab = sorted(ab, key=lambda x:x[0])

sm = 0
i = 0
for i in ab:
    if m > i[1]:
        sm += i[0] * i[1]
        m -= i[1]
    else:
        sm += i[0] * m
        break
print(sm)

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



int main() {
  string s;
  cin >> s;
  int n=s.size();
  string ans="Yes";
  if(n==3 && s[0]==s[2]){
    cout << ans << endl;
    return 0;
  }
  else if(n==3 && s[0]!=s[2]){
    cout << "No" << endl;
    return 0;
  }
  int i=0,j=n-1;
  while(i<j){
    if(i==j) break;
    if(s[i]!=s[j]){
      cout << "No" << endl;
      return 0;
    }
    i++;
    j--;
  }
  i=0;
  j=n/2-1;
  while(i<j){
    if(s[i]!=s[j]){
      cout << "No" << endl;
      return 0;
    }
    i++;
    j--;
  }
  i=n/2+1;
  j=n-1;
  while(i<j){
    if(s[i]!=s[j]){
      cout << "No" << endl;
      return 0;
    }
    i++;
    j--;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3608
N,K = map(int, input().split())
h = list(map(int, input().split()))
dp = [float('inf')]*len(h)
dp[0] = 0
for i in range(N):
    if i<N-K:
        for k in range(1,K+1):
            dp[i+k] = min(dp[i]+abs(h[i]-h[i+k]), dp[i+k])
    else:
        for k in range(1, N-i):
            dp[i+k] = min(dp[i]+abs(h[i]-h[i+k]), dp[i+k])
print(dp[-1])

Measured memory_bytes: 55776
#include<bits/stdc++.h>
#define lf double
#define ll long long
#define ull unsigned ll
#define ii pair<int,int>
#define li pair<ll,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define iiii2 pair<int,iii>
#define lii pair<ll,ii>
#define lolo pair<ll,ll>
#define heap priority_queue
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define all(x) x.begin(),x.end()
#define len(x) strlen(x)
#define sz(x) (int) x.size()
#define orta ((bas+son)/2)
#define min3(x,y,z) min(min(x,y),z)
#define max3(x,y,z) max(max(x,y),z)
#define umin(x,y) x=min(x,y)
#define umax(x,y) x=max(x,y)
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define MOD 998244353
#define inf 1000000001
#define N 39
#define LOG 20
#define KOK 350
#define EPS 0.000000000001
#define pw(x) (1<<(x))
#define PI 3.1415926535
using namespace std;

int n;
ll ans;
char s[N];
string B,R;
map< pair<string,string> ,int > MP[2];

void solve(int cur,int fin,int add,int w) {

	if(cur==fin) {

		MP[w][{R,B}]++;

		return ;

	}

	int cur_real=add+cur;

	R.pb(s[cur_real]);

	solve(cur_real,fin,add,w);

	R.ppb();

	B.pb(s[cur_real]);

	solve(cur_real,fin,add,w);

	B.ppb();

}

int main() {

	#if 0

	freopen("input.txt","r",stdin);

	#endif

	scanf("%d",&n);

	scanf("%s",s+1);

	solve(0,n,1,0);
	solve(2*n+1,n+1,-1,1);

	for(auto x:MP[0]) ans+=1ll*x.nd*MP[1][{x.st.nd,x.st.st}];

	printf("%lld",ans);

}

Measured memory_bytes: 102656
/*
 * Author       : YangDavid
 * Created Time : 2019年07月12日 星期五 16时59分54秒
 */

#include<bits/stdc++.h>
#define rep(i, n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int maxn = 222222, MOD = 1000000007, inv2 = (MOD + 1) / 2, D = 2003;
int muln(int x, int y) { return 1LL * x * y % MOD; }
int mo(int x) { if(x >= MOD) x -= MOD; if(x < 0) x += MOD; return x; }
int qpow(int x, int y) {
    int ret = 1;
    for(; y; y >>= 1, x = muln(x, x))
        if(y & 1) ret = muln(ret, x);
    return ret;
}
int inv(int x) { return qpow(x, MOD - 2); }

int n, a[maxn], b[maxn], dp[4030][4030], fac[maxn], ifac[maxn], p[2010][2010], ans;
int f(int x, int y) { return muln(fac[x + y], muln(ifac[x], ifac[y])); }
int main() {
    scanf("%d", &n);
    rep(i, n) {
        scanf("%d%d", &a[i], &b[i]);
        dp[-a[i] + D][-b[i] + D]++;
        p[a[i]][b[i]]++;
    }
    fac[0] = ifac[0] = 1;
    for(int i = 1; i <= 200000; ++i) {
        fac[i] = muln(fac[i - 1], i);
        ifac[i] = inv(fac[i]);
    }
    for(int i = -2000; i <= 2000; ++i) {
        for(int j = -2000; j <= 2000; ++j) {
            dp[i+D][j+D] = mo(dp[i+D][j+D] + dp[i - 1+D][j+D] + dp[i+D][j - 1+D]);
            if(i >= 0 && j >= 0) ans = mo(ans + muln(dp[i+D][j+D], p[i][j]));
        }
    }
    for(int i = 1; i <= n ;++i)
        ans = mo(ans - f(2 * a[i], 2 * b[i]));
    ans = muln(ans, inv2);
    printf("%d\n", ans);

    return 0;
}


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

using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

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

    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    int sum = 0;
    for (int i = 0; i < k; ++i) {
        sum += v[i];
    }
    cout << sum << "\n";
}















Measured memory_bytes: 3644
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int stack[50000];
int size=0;
int main(void){
	while(1){
		char c;
		int flag=0;
		size=0;
		int flag2=1;
		while((c=getchar())!='.'){
			flag=1;
			if(!flag2)continue;
			if(c=='(')stack[size++]=1;
			if(c=='[')stack[size++]=2;
			if(c==')'){
				if(size==0)flag2=0;
				else{
					size--;
					if(stack[size]!=1)flag2=0;
				}
			}
			if(c==']'){
				if(size==0)flag2=0;
				else{
					size--;
					if(stack[size]!=2)flag2=0;
				}
			}
		}
		c=getchar();
		if(!flag)break;
		if(size!=0)flag2=0;
		printf("%s\n",flag2?"yes":"no");
	}
	return 0;
}

Measured memory_bytes: 912
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
#define fs first
#define se second
#define M 1000000007
#define pii pair<long long,long long>
 
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
unordered_map<char,pii>dir;
ll D=1e9;
 
bool check(ll x,ll y,ll n,ll m){
	return (x>=0 && y>=0 && n>x && m>y);
}

int main()
{
	ios_base::sync_with_stdio(false);
	
	ll n;
	cin>>n;
	vector<ll>arr(n);
	for(ll i=0;i<n;i++)
		cin>>arr[i];
	ll p=1000,net=0;
	ll ans=0;
	ll mn=arr[0];
	ll mx=arr[0];
	for(ll i=1;i<n;i++)
	{
		if(mx<arr[i])
			mx=arr[i];
		else
		{
			net=p/mn;
			p=p%mn;
			p+=net*mx;
			mn=arr[i];
			mx=arr[i];
		}
	}

	net=p/mn;
	p=p%mn;
	p+=net*mx;
	cout<<p<<endl;

}



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

int n, m, a, b;
vector<int> AL[100005];
int ans[100005];
queue<int> bfs;

int main(){
    scanf("%d%d", &n, &m);
    for (int i=0; i<m; ++i){
        scanf("%d%d", &a, &b);
        AL[a].push_back(b);
        AL[b].push_back(a);
    }
    memset(ans, -1, sizeof ans);
    bfs.push(1);
    ans[1] = 0;
    while (!bfs.empty()){
        int u = bfs.front(); bfs.pop();
        for (int v: AL[u]){
            if (ans[v]!=-1) continue;
            ans[v] = u;
            bfs.push(v);
        }
    }
    for (int i=1; i<=n; ++i){
        if (ans[i]==-1){
            printf("No");
            return 0;
        }
    }
    printf("Yes\n");
    for (int i=2; i<=n; ++i){
        printf("%d\n", ans[i]);
    }
    return 0;
}


Measured memory_bytes: 10540
#include<bits/stdc++.h>
#define int long long
using namespace std;


int32_t main()
{


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

       int temp, mx=-1e18;

        temp = a * c;
       mx = max(temp,mx);

        temp = a * d;
       mx = max(temp,mx);


        temp = b * c;
       mx = max(temp,mx);


        temp = b * d;
       mx = max(temp,mx);

       cout<<mx<<endl;


    return 0;
}


Measured memory_bytes: 3632