akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;

typedef long long ll;

struct Monster {
  ll x, h;
};

struct Bomb {
  ll x, d;
};

int main() {
  ll n, d, a; cin >> n >> d >> a;
  vector<Monster> monsters;
  queue<Bomb> q;
  for (int i = 0; i < n; ++i) { 
    ll x, h; cin >> x >> h;
    monsters.push_back((Monster){x, h});
  }
  sort(monsters.begin(), monsters.end(), [&](const auto &l, const auto &r){
    return l.x < r.x;
  });
  ll ans = 0;
  ll sum = 0;
  for (auto &m : monsters) {
    while (!q.empty()) {
      Bomb b = q.front();
      if (b.x >= m.x) break;
      q.pop();
      sum -= b.d;
    }
    ll h = m.h-sum;
    if (h <= 0) continue;
    ll na = (h+a-1)/a;
    ans += na;
    sum += na*a;
    q.push({m.x+2*d, na*a});
  }
  cout << ans << endl;
}



Measured memory_bytes: 6256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll a, b;
  cin >> a >> b;
  string a1 = "";
  string b1 = "";

  for (ll i = 0; i < b; i++)
    a1 += (char)('0' + a);

  for (ll i = 0; i < a; i++)
    b1 += (char)('0' + b);

  cout << min(a1, b1) << en;

  return 0;
}

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

void check(char A[12][12], int i, int j) {
	if(A[i][j] == '1') {
		A[i][j] = '0';
		if(i > 0)    check(A, i - 1, j);
		if(i < 11)   check(A, i + 1, j);
		if(j > 0)    check(A, i, j - 1);
		if(j < 11)   check(A, i, j + 1);
	}
}

int main(void) {
	char A[12][12];
	int island;
	
	while(cin >> A[0]) {
		island = 0;
		for(int i = 1; i < 12; ++i) {
			cin >> A[i];
		}
		
		for(int i = 0; i < 12; ++i) {
			for(int j = 0; j < 12; ++j) {
				if(A[i][j] == '1') {
					check(A, i, j);
					++island;
				}
			}
		}
		
		cout << island << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3048
#include <bits/stdc++.h>
using namespace std;
//    std::sort(a.begin(), a.end(), std::greater<int>() );
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

int main()
{
    string s;
    cin >> s;
    rep(i,s.size())
        if(i%2==0)
            cout<<s[i];

    cout<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define INT(a) scanf("%d",&a)
#define STR(a) scanf("%s",a)
#define DBL(a) scanf("%lf",&a)
#define LNG(a) scanf("%lld",&a)
#define PI acos(-1)

int cnt[100005];
int main(){
	int n,q;
	cin>>n>>q;
	string s;
	cin>>s;
	s='#'+s;
	for(int i=2;i<s.length();i++){
		if(s[i-1]=='A' && s[i]=='C') cnt[i]=1;
		cnt[i]+=cnt[i-1];
	}

	for(int i=1;i<=q;i++){
		int l, r;
		cin>>l>>r;
		cout<<cnt[r]-cnt[l]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1404
#include <iostream>

using namespace std;
int Solve(int x, int y, int z)
{
	int c = 0;
	for (int i = x; i <= y; i++)
	{
		if (i % z == 0)
		{
			c++;
		}
	}
	return c;
}
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	cout << Solve(a, b, c);
	return 0;
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
#define ll unsigned long long
#define pp pair<int,int>
#define ppn pair<pp,int>
#define F first
#define S second
#define N 1000005
#define mod 1000000007


using namespace std;


string longDivision(string number, int divisor)
{

    string ans;


    int idx = 0;
    int temp = number[idx] - '0';
    while (temp < divisor){
        temp = temp * 10 + (number[++idx] - '0');


    while (number.size() > idx) {
        // Store result in answer i.e. temp / divisor
        ans += (temp / divisor) + '0';

        // Take next digit of number
        temp = (temp % divisor) * 10 + number[++idx] - '0';
    }
    }

    if (ans.length() == 0)
        return "0";

    // else return ans
    return ans;
}


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

    string s(N,'7');
    int n;
    cin>>n;
    int i=0,c=0;
    bool f = true;
    while(i<N){
            //cout<<c<<endl;
        c=c*10+7;
        if(c%n==0){
            cout<<i+1<<endl;
            f = false;
            break;
        }
        c%=n;
        i++;

    }
    if(f)cout<<"-1"<<endl;

}


Measured memory_bytes: 4192
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<queue>

using namespace std;

long long n,m;

int main(){
  cin>>n;
  string s,t;
  int sn = 0;
  int tn = n-1;
  cout<<"0"<<endl;
  cin>>s;
  if(s == "Vacant") return 0;
  cout<<(n-1)<<endl;
  cin>>t;
  if(t == "Vacant") return 0;

  string tmp;
  for(int i=0;i<20;i++){
    int mid = (sn+tn)/2;
    cout<<mid<<endl;
    cin>>tmp;
    if(tmp == "Vacant") return 0;

    bool sett = false;

    if(tmp != t){
      if(((tn - mid + 1)%2) == 1) sett = true;
    }

    if(tmp == t){
      if(((tn - mid + 1)%2) == 0) sett = true;
    }


    tmp = (tmp == "Male") ? "Female" : "Male";

    if(!sett){
      t = tmp;
      tn = mid - 1;
    } else {
      s = tmp;
      sn = mid + 1;
    }

  }
  return 0;
}


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

int main() {
  int N, Y;
  cin >> N >> Y;

  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= N; j++) {
      if (10000 * i + 5000 * j + 1000 * (N - i - j) == Y && N - i - j >= 0) {
        cout << i << " " << j << " " << N - i - j << endl;
        return 0;
      }
    }
  }

  cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
#include<iostream>

int ball[10];
bool res;

void dfs(int i, int ls, int rs){
	if (i == 10){
		res = true;
		return;
	}

	if (ball[i] > ls)dfs(i + 1, ball[i], rs);
	if (ball[i] > rs)dfs(i + 1, ls, ball[i]);
}

int main(){
	int n;
	std::cin >> n;

	for (int i = 0; i < n; i++){
		for (auto &i : ball)std::cin >> i;
		res = false;
		dfs(0, 0, 0);
		std::cout << (res ? "YES" : "NO") << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1152
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

readi b | Just (n, _) <- B.readInt b = n

solve :: Int -> [Int] -> Bool
solve n as = even . length $ filter odd as

main :: IO ()
main = do
    n <- readLn :: IO Int
    as <- fmap readi . B.words <$> B.getLine
    if solve n as
        then putStrLn "YES"
        else putStrLn "NO"

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

#define FOR(i, j, k) for(int i=j ; i<k ; i++)
#define REP(i, j) FOR(i, 0, j)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {
    int a, b; cin >> a >> b;

    if (a + b == 15) cout << "+" << endl;
    else if (a * b == 15) cout << "*" << endl;
    else cout << "x" << endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
	int cnt,hukuro;
	int n,m,yasai[1000],total=0;
	
	while(1){
		cin>>n>>m;
		if(n==0&&m==0)break;
		cnt=0;
		hukuro=n/m;
		for(int i=0;i<n;i++){
			cin>>yasai[i];
		}
		sort(yasai,yasai+n);
		reverse(yasai,yasai+n);
		for(int i=0;i<n;i++){
			if((i+1)%m!=0)total+=yasai[i];
			cnt++;
		}
		
		cout<<total<<endl;
		total=0;
	}
	return 0 ;
}

Measured memory_bytes: 3112
// HowManyWays.c
// 1 から n までの数の中から、重複無しで３つの数を選び、
// それらの合計が x となる組み合わせの数を求めるプログラムを作成して下さい。
//
// 例えば、1 から 5 までの数から３つを選んでそれらの合計が 9 となる組み合わせは、
//
// ・1 + 3 + 5 = 9
// ・2 + 3 + 4 = 9
//
// の２通りがあります。
// 【入力】
// 複数のデータセットが入力として与えられます。
// 各データセットでは、空白で区切られた n、x が 1 行に与えられます。
//
// n、x がともに 0 のとき入力の終わりとします。
// 【出力】
// 各データセットについて、組み合わせの数を１行に出力して下さい。
// 【制約】
// ・3 ≤ n ≤ 100
// ・0 ≤ x ≤ 300
// 【例】
// 入力：
// 5 9
// 0 0
// 出力：
// 2
#include<stdio.h>

int main( void) {
  int n, x;

  while ( 1) {
    scanf( "%d %d", &n, &x);

    if ( n == 0 && x == 0) break;

    int counter = 0;
    for ( int i = 1 ; i <= n; i++) {
      for ( int j = i + 1; j <= n; j++) {
	for ( int k = j + 1; k <= n; k++) {
	  if ( i + j + k == x) counter++;
	}
      }
    }

    printf( "%d\n", counter);
  }

  return 0;
}



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

int main(){
  long long n,x=1;
  cin>>n;
  double a=sqrt(n);
  long long y=n;
  for(int i=2;i<=a;i++){
    if(n%i==0){
      x=i;
      y=n/i;
    }
  }int count=0;
  while(0<y){
    y/=10;
    count++;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

A, B, C, D = map(int, list(input()[:-1]))

n = 3
ops = []
for bit in range(0, 1<<n):
    op = ["-"]*n
    for j in range(n):
        if bit>>j & 1:
            op[j] = "+"
    ops.append(op)

for op in ops:
    a, b, c, d = A, B, C, D
    if op[0] == "-":
        b = -B
    if op[1] == "-":
        c = -C
    if op[2] == "-":
        d = -D
    if a + b + c + d == 7:
        ans = op
        break
ans = str(a)
for num in (b, c, d):
    if num >= 0:
        ans += "+"
        ans += str(num)
    else:
        ans += str(num)
ans += "=7"
print(ans)


        

Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
#include<queue>
#include<stack>
#include<algorithm>
#define ll long long
#define MAXN 100005
using namespace std;
int father[MAXN];
ll d[MAXN];
int getfather(int x){
    if (father[x]==x) return x;
    int f=father[x];
    father[x]=getfather(father[x]);
    d[x]+=d[f];
    return father[x];
}
int main(){
    int n,m,i,x,y;
    ll dis;
    char c;
    while (~scanf("%d%d",&n,&m) && n){
        for (i=1;i<=n;i++) father[i]=i,d[i]=0;
        while (m--){
            do{
                c=getchar();
            }
            while (c!='!' && c!='?');
            scanf("%d%d",&x,&y);
            if (c=='?'){
                if (getfather(x)!=getfather(y))
                    printf("UNKNOWN\n");
                else
                    printf("%lld\n",d[y]-d[x]);
            }
            else{
                scanf("%lld",&dis);
                if (getfather(y)==getfather(x)) continue;
                d[father[y]]+=dis-d[y];
                father[father[y]]=x;
            }
         }
    }
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }
    auto r = unique(A.begin(), A.end());
    for (auto i = A.begin(); i != r; i++) {
        if (i != A.begin()) cout << " ";
        cout << *i;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ios::sync_with_stdio(false);
    cin.tie();
    ll x, y, a, b, c;
    cin>>x>>y>>a>>b>>c;
    vector<ll> p(a), q(b), r(c);
    for(ll i = 0; i < a; i++)
    cin>>p[i];
    for(ll i = 0; i < b; i++)
    cin>>q[i];
    for(ll i = 0; i < c; i++)
    cin>>r[i];
    sort(p.begin(), p.end(), greater<ll>());
    sort(q.begin(), q.end(), greater<ll>());
    sort(r.begin(), r.end(), greater<ll>());
    ll i = x-1;
    ll j = y-1;
    ll k = 0;
    while (1)
    {
        if(i < 0 || j < 0 || k == c)
        break;
        ll n1 = p[i];
        ll n2 = q[j];
        if(r[k] <= min(n1, n2)){
            break;
        }
        if(n1 < n2){
            p[i] = r[k];
            i -= 1;
            k++;
        }else{
            q[j] = r[k];
            k++;
            j -= 1;
        }
        // cout<<n1<<" "<<n2<<" "<<i<<" "<<j<<" "<<k<<" "<<endl;
    }
    if(i==-1){
        while(j >= 0 && k!=c && r[k] > q[j]){
            q[j] = r[k];
            k++;
            j -= 1;
        }
    }
    if(j ==-1){
        while(i >= 0 && k!=c && r[k] > p[i]){
            p[i] = r[k];
            k++;
            i -= 1;
        }
    }
    ll ans = 0;
    for(int i = 0; i < x; i++){
        ans += p[i];
        // cout<<p[i]<<" ";
    }
    // cout<<endl;
    for(int i = 0; i < y; i++){
        ans+=q[i];
        // cout<<q[i]<<" ";
    }
    // cout<<endl;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 5612
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=x*10+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x>=10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int k,int mod){
	int res=1,bas=x;
	while(k){
		if(k&1) res=1ll*res*bas%mod;
		bas=1ll*bas*bas%mod,k>>=1;
	}
	return res;
}
const int N = 2e3+5;
int n,u,v,ans=INF,val[N],dis[N],sz[N],sum[N],f[N];
char s[N];
vector<int> G[N];
il add_edge(int u,int v){
	G[u].push_back(v);
	G[v].push_back(u);
}
il DFS(int u,int fa){
	dis[u]=dis[fa]+1,sz[u]=val[u];
	sum[u]=dis[u]*val[u];
	int mx=0,mxp;
	for(auto v:G[u]){
		if(v==fa) continue;
		DFS(v,u),sz[u]+=sz[v],sum[u]+=sum[v];
		if(mx<sum[v]-dis[u]*sz[v])
			mx=sum[v]-dis[u]*sz[v],mxp=v;
	}
	int t=sum[u]-dis[u]*sz[u];
	if(t>=2*mx) f[u]=t/2;
	else f[u]=t-mx+min(f[mxp],(2*mx-t)/2);
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n),scanf("%s",s+1),dis[0]=-1;
	for(ri i=1;i<=n;++i) val[i]=s[i]-'0';
	for(ri i=1;i<n;++i)
		read(u),read(v),add_edge(u,v);
	for(ri i=1;i<=n;++i){
		del(f,0),DFS(i,0);
		if(2*f[i]==sum[i]) ans=min(ans,f[i]);
	}
	print(ans==INF?-1:ans);
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <limits.h>
int count = 0;
void merge(int *array, int p, int q, int r){
	int n1 = q-p+1;
	int n2 = r-q;

	int left[n1 + 1];
	int right[n2 + 1];

	for(int i = 0; i < n1; ++i){
		left[i] = array[p + i];
	}
	left[n1] = INT_MAX;
	for(int i = 0; i < n2; ++i){
		right[i] = array[q + 1 + i];
	}
	right[n2] = INT_MAX;

	int i=0, j=0;
	for(int k = p; k <= r; ++k){
		++count;
		if(left[i] < right[j]){
			array[k] = left[i];
			++i;
		}else{
			array[k] = right[j];
			++j;
		}
	}
}
void mergeSort(int *array, int p, int r){
	if(p < r){
		int q = (p+r)/2;
		mergeSort(array, p, q);
		mergeSort(array, q+1, r);
		merge(array, p, q, r);
	}
}

void printarray(int array[], int size){
	for(int i = 0; i < size; ++i){
		printf("%d", array[i]);
		if(i != size - 1)
			printf(" ");
	}
	printf("\n");
}
int main(){
	int n;
	scanf("%d", &n);
	int numbers[n];
	for(int i = 0; i < n; ++i){
		scanf("%d", &numbers[i]);
	}	
	mergeSort(numbers, 0, n-1);
	printarray(numbers, n);
	printf("%d\n", count);
	return 0;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

const int mod = 1000000007;

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    cout << a * b/ 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
int main(){
    string s;
    cin>>s;
    int n = s.length();
    vector<string>a = {"dreamer","dream","erase","eraser"};
    rep(i,4)reverse(been(a[i]));
    bool f = true;
    reverse(been(s));
    rep(i,(int)s.length()){
        bool c= false;
        rep(j,4){
            if(s.substr(i,a[j].length())==a[j]){
                c=true;
                i+=a[j].length()-1;
            }
        }
        //cout<<i<<c<<endl;
        if(!c){
            f=false;
        }
    }
    if(f)cout<<"YES"<<endl;
    else
    {
        cout<<"NO"<<endl;
    }
    
    
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
typedef long long ll;
typedef double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
  
using namespace std;
 
const ll inf = 1e9;
const ll N = 1e5+10;
const ll bits = 21;
const ll mod = 1e9+7;
const ld pi = 3.14159265358979323846;

ll dp[101][N];

inline void add(ll &a, ll b){
    a+=b;
    if(a>=mod) a-=mod;
}

inline void sub(ll &a,ll b){
    a-=b;
    if(a<0) a+=mod;
}
int main(){
    FASTIO;
    PRECISION;

    ll n,k,temp;
    cin>>n>>k;

    dp[0][0] = 1;

    for(int i=1;i<=n;i++){
        cin>>temp;
        for(int x=0;x<=k;x++){
            int l = x;
            int r = x + min(temp,k-x);
            // dp[i][l]+=dp[i-1][x];
            add(dp[i][l],dp[i-1][x]);
            sub(dp[i][r+1],dp[i-1][x]);
            // dp[i][r+1]-=dp[i-1][x];
            // for(int y=0;y<=min(temp,k-x);y++){
            //     dp[i][x+y]+=dp[i-1][x];
            //     dp[i][x+y]%=mod;
            // }
        }

        for(int j=1;j<=k;j++){
            add(dp[i][j],dp[i][j-1]);
        }

    }

    cout<<dp[n][k]<<"\n";    
    

    

}

Measured memory_bytes: 78336
while True:
    try:
        c1,c2,c3 = map(int,raw_input().split())
        count = 0
        for i in xrange(10):
            temp = i + 1
            if temp != c1 and temp != c2 and temp != c3 and  c1 + c2 + temp <= 20:
            	count += 1
            if count >= 4:
                print "YES"
                break
        else:
            print "NO"
         
    except EOFError:
        break

Measured memory_bytes: 6220
def main():
    n, *a = map(int, open(0).read().split())
    x = sum(a[::2]) - sum(a[1::2])
    ans = str(x)
    tmp = x
    for i in a[:-1]:
        tmp = 2 * i - tmp
        ans += ' ' + str(tmp)
    print(ans)


if __name__ == '__main__':
    main()


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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

typedef pair<ll, ll> P;
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
    int n;
    cin >> n;

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

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

    ll tmp = 0;
    int cnt = 0, ans = 0;
    for (int i = 0; i < n; i++) {
        if (tmp != a[i]) {
            if (cnt % 2) ans++;
            cnt = 1;
            tmp = a[i];
        } else {
            cnt++;
        }
    }
    if (cnt % 2) ans++;

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



Measured memory_bytes: 1024
#include<iostream>
#include<vector>
using namespace std;
int main(void){
    int N;
    cin >> N;
    vector<int> H(N);
    for (int i = 0; i < N; i++)
    {
        cin >> H[i];
    }
    int maxheight=-1;
    int counter = 0;
    for (int i = 0; i < N; i++)
    {
        if(maxheight <= H[i])
        {
            counter = counter+1;
            maxheight = H[i];
        }
    }
    cout << counter << endl;   
    return 0;
}

Measured memory_bytes: 256
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>

using namespace std;



int main(){
	int64_t n;
	cin>>n;
	int64_t prev;
	cin>>prev;
	bool possible=true;
	if(prev!=0){
		cout<<-1<<endl;
		possible=false;
	}else{
		int64_t ans=0;
		for(int64_t i1=1;i1<n;i1++){
			int64_t temp;
			cin>>temp;
			if(temp>prev+1){
				cout<<-1<<endl;
				possible=false;
				break;
			}else if(temp==prev+1){
				ans++;
			}else{
				ans+=temp;
			}
			prev=temp;
		}
		if(possible){
			cout<<ans<<endl;
		}
	}



}


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

using namespace std;

const int inf=1e9;
const int N=2e5+10;


int f[N];
int ma[1<<26];
int main(){
	string s;
	cin>>s;
	int n=s.length();
	fill(ma+1,ma+(1<<26),inf);
	ma[0]=0;
	for(int i=1,mask=0;i<=n;i++){
		mask^=1<<(s[i-1]-'a');
		f[i]=ma[mask]+1;
		for(int j=0;j<26;j++){
			int cmask=mask^(1<<j);
			f[i]=min(f[i],ma[cmask]+1);
		}
		ma[mask]=min(ma[mask],f[i]);
	}
	//for(int i=1;i<=n;i++) cout<<f[i]<<" \n"[i==n];
	cout<<f[n];
}


Measured memory_bytes: 263556
N = input()
n = [int(N[i]) for i in range(4)]  

def addd(lista,op):
    cnt = lista[0]


    tmp = [lista[0]]
    for i in range(len(op)):
        if op[i]==0:
            cnt+=lista[i+1]
            tmp.append("+")
            tmp.append(lista[i+1])
        else:
            cnt -=lista[i+1]
            tmp.append("-")
            tmp.append(lista[i+1])
    if cnt ==7:
        tmp.append("=7")
        return tmp
    else:
        return False

for i in range(2):
    for j in range(2):
        for k in range(2):
            ans = addd(n,[i,j,k])
            if ans != False:
                print("".join([str(n) for n in ans]))
                exit()
    




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

int main(void){
    int N,a,b,c,i;
    char buf[256];

    /*?????°???????????????*/
    fgets(buf,sizeof(buf),stdin);
    sscanf(buf,"%d",&N);

    for(i = 0;i < N;i++){
    	fgets(buf,sizeof(buf),stdin);
    	sscanf(buf,"%d %d %d",&a,&b,&c);
    	if((a*a + b*b == c*c) || (a*a + c*c == b*b) || (b*b + c*c == a*a)){
    		printf("YES\n");
    	}else{
    		printf("NO\n");
    	}

    }
    return 0;
}

Measured memory_bytes: 1752
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
vector<int>E1[251000], E2[251000];
int w[510],n, Res[251000], UF1[251000], UF2[251000];
int Find1(int a){
    if(a==UF1[a])return a;
    return UF1[a] = Find1(UF1[a]);
}
int Find2(int a){
    if(a==UF2[a])return a;
    return UF2[a] = Find2(UF2[a]);
}
void Ins(int a, int b){
    Res[a] = b;
    UF1[a] = Find1(a-1);
    UF2[a] = Find2(a+1);
}
bool Do1(int a, int b, int y){
    int i, x;
    for(i=0;i<b;i++){
        x = Find2(1);
        if(x > a)return false;
        Ins(x, y);
    }
    return true;
}
bool Do2(int a, int b, int y){
    int i, x;
    for(i=0;i<b;i++){
        x = Find1(n*n);
        if(x < a)return false;
        Ins(x, y);
    }
    return true;
}
int main(){
    int i;
    scanf("%d",&n);
    for(i=1;i<=n*n;i++)UF1[i] = UF2[i] = i;
    UF1[0]=0,UF2[n*n+1]=n*n+1;
    for(i=1;i<=n;i++){
        scanf("%d",&w[i]);
        if((w[i]==1 && i!=1) || (i==n*n&&w[i]!=n)){
            printf("No\n");
            return 0;
        }
        Ins(w[i],i);
        E1[w[i]-1].push_back(i);
        E2[w[i]+1].push_back(i);
    }
    for(i=1;i<=n*n;i++){
        if(!E1[i].empty()){
            int x = E1[i][0];
            if(!Do1(i, x-1, x)){
                printf("No\n");
                return 0;
            }
        }
    }
    for(i=n*n;i>=1;i--){
        if(!E2[i].empty()){
            int x = E2[i][0];
            if(!Do2(i, n-x, x)){
                printf("No\n");
                return 0;
            }
        }
    }
    printf("Yes\n");
    for(i=1;i<=n*n;i++)printf("%d ",Res[i]);
}

Measured memory_bytes: 15872
/* << IN THE NAME OF GOD >> */
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pob pop_back
#define ft first
#define sc second
#define err(x) cerr << #x  << " = "<<  x << '\n'
#define out(x) cout << x << '\n'
#define forp(i, r, l) for(int i = int(r); i < int(l); i++)
#define forn(i, r, l) for(int i = int(r); i > int(l); i--)
#define FAST ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
#define ctz __builtin_ctz
typedef pair<int, int> pii;
const int maxn = 1e6;
 

ll n ,m ,res;

int main(){
          
	cin >> n >> m;
	if(n>m) swap(n,m);
	if(n==1 && m==1) cout << 1 << endl;
	else if(n==1) cout << m-2 << endl;
	else cout << (n-2)*(m-2) << endl;
   return 0;
}
 



Measured memory_bytes: 256
/*
    ____        __
   / __ \____  / /_  ____ _____ ___
  / /_/ / __ \/ __ \/ __ `/ __ `__ \
 / _, _/ /_/ / / / / /_/ / / / / / /
/_/ |_|\____/_/ /_/\__,_/_/ /_/ /_/
*/
#include<bits/stdc++.h>

typedef long long ll ;

#define pll pair<ll , ll >
#define X   first
#define Y   second
#define mp  make_pair
#define pii pair<int , int>
#define vec vector
#define vpii vector<pair<int , int>>
#define i_n   int i = 0 ; i< n ; i++
#define cn  int n ; cin>>n
#define file_io freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define cina int a[n] ; for(int i = 0 ; i < n ; i++) cin>>a[i]
#define pb push_back

using namespace std;
const int maxn = 1000*100+5 ;
const ll inf = 9223372036854775807 ;
ll n , h , dp[1001][10004] , a[1001] , b[1001] ; 

int main()
{
	migmig ;
	cin>>h >> n  ; 
	for(int i = 1 ; i <= n ; i ++ )
	{
		cin>>a[i] >> b[i] ; 
	}
	memset(dp , 63 , sizeof dp) ; 
	dp[0][0] = 0 ;
	for(int i = 1 ; i <= n ; i++ )
	{
		dp[i][0] = 0 ; 
	}
	for(int i = 1 ; i <= n ; i ++ )
	{
		for(int j = 1 ; j <= h ; j++ )
		{
			dp[i][j] = min(dp[i-1][j] , b[i] + dp[i][max((ll)j - a[i] , (ll)0)]) ; 
		}
	}
//	cout<<dp[1][1]<<endl ; 
	cout<<dp[n][h] ; 
}
//////
////////
///////////




Measured memory_bytes: 78464
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define forn(a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define mp make_pair

int main()
{
	ll n,d;
	cin >> n >> d;
 	ll count = 0;

 	while(n--)
 	{
 		ll a,b; cin >> a >> b;
 		double di = sqrt((a*a) + (b*b));
 		// cout << di << endl;
 		if(di <= d)
 			count++;
 	}

 	cout << count;
}

Measured memory_bytes: 3648
/**
 *      purpose : KEYENCE Programming Contest 2019 C
 *      author  : kyomukyomupurin
 *      created : 2019-01-13 21:08:56
**/

#include <bits/stdc++.h>
using namespace std;
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define fi first
#define se second

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n; cin >> n;
    int64 a[n], b[n];
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];

    if (accumulate(a, a + n, int64()) < accumulate(b, b + n, int64())){
        print(-1); return 0;
    }

    int64 diff[n];
    rep(i, n) diff[i] = a[i] - b[i];
    sort(diff, diff + n, greater<int64>());
    int64 minus = 0; int64 tasu = 0;
    int64 sumofminus = 0; int64 sumofplus = 0;
    rep(i, n) {
        if (diff[i] < 0) {
            ++minus; sumofminus += (-1) * diff[i];
        }
    }
    if (minus == 0){
      print(0); return 0;
    }

    rep(i, n){
        sumofplus += diff[i]; ++tasu;
        if (sumofplus >= sumofminus){
            print(minus + tasu); return 0;
        }
    }
    
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h> 
inline int getint() {
	register char ch;
	while(!isdigit(ch=getchar()));
	register int x=ch^'0';
	while(isdigit(ch=getchar())) x=(((x<<2)+x)<<1)+(ch^'0');
	return x;
}
const int N=2e5+1;
typedef long long int64;
int64 m,n,x[N],ans;
int64 pre[N],suf[N];
int main() {
	m=getint(),n=getint();
	for(int i=1;i<=n;i++) x[i]=getint();
	for(int i=1;i<=n;i++) {
		pre[i]=pre[i-1]+x[i];
		suf[i]=suf[i-1]+m-x[i];
	}
	ans=std::max(ans,x[n]);
	ans=std::max(ans,m-x[1]);
	for(int i=1;i<=n;i++) {
		{
			int l=i+1,r=n,len=(r-l+1)/2;
			if (l<=r) {
				int64 tmp=2*x[i];
				tmp+=2*(pre[l+len-1]-pre[l-1]);
				tmp+=2*(suf[r]-suf[r-len]);
				if(len*2==r-l+1) {
					tmp-=pre[l+len-1]-pre[l+len-2];
				} else {
					tmp+=suf[l+len]-suf[l+len-1];
				}
				ans=std::max(ans,tmp);
			}
		}
		{
			int l=1,r=i-1,len=(r-l+1)/2;
			if(l<=r) {
				int64 tmp=2*(m-x[i]);
				tmp+=2*(pre[l+len-1]-pre[l-1]);
				tmp+=2*(suf[r]-suf[r-len]);
				if (len*2==r-l+1) {
					tmp-=suf[l+len]-suf[l+len-1];
				} else {
					tmp+=pre[l+len]-pre[l+len-1];
				}
				ans=std::max(ans,tmp);
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;
using namespace std;
typedef long long ll;
#define endl "\n"
#define loop(n) for (ll i = 0; i < n; i++)
#define loop2(n) for (ll i = 0; i < n; i += 2)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
int Mint = INT_MAX;
ll Mlong = LLONG_MAX;

void fast() {
    cin.tie(0);
    cin.sync_with_stdio(0);
}

int pow(ll a, ll b) {
    if (b == 1)return a;
    if (b == 0) return 1;
    return a * pow(a, b - 1);
}

int n;
int operation = 0;

int counti = 0;


int solve(int s) {
    if(s==0)
        return 0;
    if(s==1)
        return 2;
    if(s==2)
        return 4;



    //cout << s << endl;
    operation++;
    return solve(s-1)+solve(s-2);
}

int main() {
    fast();
    ll n,k;
    cin>>n>>k;
    ll c[n];
    for (int i = 0; i <n ; ++i) {
        cin>>c[i];
    }
    sort(c,c+n);
    ll i=n-1;
    ll ans=0;
    while(k!=0&&i>=0){
        k--;
        i--;
    }
    for (int j = 0; j <=i ; ++j) {
        ans+=(c[j]);
    }
    cout<<ans;
}


Measured memory_bytes: 1792
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define popb pop_back
#define mt make_tuple 
#define eb emplace_back
#define mp make_pair
#define F first
#define S second   
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).end()
#define setval(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 

#define int ll

using namespace std;

const int N = 5e5 +5 ;
const int mod = 1e9 + 7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef vector<int> vi;
typedef pair<int, int> pii; 
typedef pair<int , pii> piii ; 
typedef unsigned long long ull ;
typedef long double ld;

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

int t[4 * N];
string s;
#define m ((l + r)/2)

void build(int l , int r, int id){
    if(l == r){
        int tmp = s[l-1] - '0';
        t[id] = (1 << tmp);
        return;
    }
    build(l , m , id * 2);
    build(m + 1 , r , id * 2 + 1);
    t[id] = (t[id * 2] | t[id * 2 + 1]);
}

void upd(int l , int r , int pos , int id){
    if(l == r){
        int tmp = s[l - 1] - '0';
        t[id] = (1 << tmp);
        return;
    }
    if(pos <= m){
        upd(l , m , pos , id * 2);
    }else{
        upd(m + 1 , r , pos , id * 2 + 1);
    }
    t[id] = (t[id * 2] | t[id * 2 + 1]);
}

int query(int l , int r , int Ql , int Qr , int id){
    if(l > Qr || r < Ql) return 0;
    if(Ql <= l && r <= Qr) return t[id];
    return (query(l , m , Ql , Qr , id * 2) | query(m + 1, r , Ql , Qr , id * 2 + 1));
}
void solve()
{
    int n , q;
    cin >> n >> s >> q;
    build(1 , n , 1);
    rep(_ , q){
        int T , l , r;
        cin >> T ; 
        if(T == 1) {
            char b ; int a;
            cin >> a >> b ;
            s[a - 1] = b , upd(1 , n , a , 1);
        }
        else {
            cin >> l >> r ;
            cout << __builtin_popcount(query(1,n,l,r,1)) << '\n';
        }
    }

}   

     
int32_t main(int32_t argc, char *argv[])
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}

Measured memory_bytes: 11164
num = int(input())
count = 0
for i in range(num):
    a = int(input())
    j = 2
    d = 0
    while (j <= a//j):
        r = a%j
        if r == 0:
            d += 1
            break
        elif j == 2:
            j += 1
        else:
            j += 2
    if d == 0:
        count += 1
print(count)


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

int main(){
	string s,t;
	cin>>s>>t;
	int n=s.size(),m=t.size();
	int mx=0;
	rep(i,n-m+1){
		int cnt=0;
		rep(j,m){
			if(t[j]==s[j+i])cnt++;
		}
		mx=max(mx,cnt);
	}
	cout<<m-mx<<endl;
}

Measured memory_bytes: 3624
import java.util.*;
import java.lang.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long K = sc.nextLong();
        
        N = N%K;
        
        System.out.println(Math.min(N, K-N));
    }
}


Measured memory_bytes: 21972
n,k,q=map(int, input().split())
a=[int(input())-1 for _ in range(q)]
point=[k-q for _ in range(n)]
for i in range(q):
    t=a[i]
    point[t]+=1
for i in range(n):
    if point[i]>0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 11792
# -*- coding:utf-8 -*-
import math
N, M = map(int, input().split())
if abs(N-M) == 0:
    print((2*math.factorial(N)*math.factorial(M))%((10**9)+7))
elif abs(N-M) == 1:
    print((math.factorial(N)*math.factorial(M))%((10**9)+7))
else:
    print(0)

Measured memory_bytes: 5176
#include<stdio.h>

int main()
{
	int t,a,b,w;
    scanf("%d %d %d",&w,&a,&b);
	if(a>b)
	{
	t=a;
	a=b;
	b=t;
	}


    if(a+w>=b)
	printf("0");
	else
	printf("%d",b-(a+w));
		
//	int d,a,b,w;

//	d=abs(a-b);
//	printf("%d",d);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    while(k &&  b <= a){
        b *= 2;
        --k;
    }
    while(k &&  c <= b){
        c *= 2;
        --k;
    }
    if(b > a && c > b)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3576
n=int(input())
li=list(map(int,input().split()))

x=0
y=0
for i in range(len(li)):
    for j in range(len(li)-1):
        if li[j]<li[j+1]:
            a=li[j]
            li[j]=li[j+1]
            li[j+1]=a


for k in range(len(li)):
    if k%2==0:
        x=x+li[k]
    else:
        y=y+li[k]

print(x-y)

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

int main(){
  string a, b;
  cin >> a >> b;
  if (a.size()>b.size()) {
    printf("GREATER\n");
  } else if (a.size()<b.size()) {
    printf("LESS\n");
  } else {
    for (int i=0; i<a.size(); i++) {
      int a0=a[i]-'0', b0=b[i]-'0';
      if (a0>b0) {
        printf("GREATER\n");
        return 0;
      } else if (a0<b0) {
        printf("LESS\n");
        return 0;
      }
    }
    printf("EQUAL\n");
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define Mod 998244353
#define pi 3.14159265358979323846
#define endl '\n'
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;

int main()
{
    char ch;
    cin>>ch;
    if(ch>='A' && ch<='Z') cout<<"A"<<endl;
    else cout<<"a"<<endl;
    return 0;
}


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

int main() {
  int n, k;
  cin>>n>>k;
  int p[n];
  for (int i=0; i<n; i++) cin>>p[i];
  double e[n];
  long acc[1001];
  acc[0] = 0;
  for (int i=1; i<1001; i++) acc[i] = acc[i-1] + i;
  for (int i=0; i<n; i++) {
    e[i] = 1.0 * acc[p[i]] / p[i];
  }
  double ans = 0.0;
  for (int i=0; i<k; i++) {
    ans += e[i];
  }
  double tmp = ans;
  for (int i=k; i<n; i++) {
    tmp = tmp - e[i-k] + e[i];
    ans = max(tmp, ans);
  }
  printf("%.9lf\n", ans);
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(cnt,e) for(ll cnt=0;cnt<e;cnt++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;

ll i,j,k;


int main(){
   ll N,i;
   cin>>N>>i;
   cout<<N-i+1<<endl;

}

Measured memory_bytes: 256
read N M
sort -n | awk -v M=$M '
{
    if ($2 < M) {
        sum+=$1*$2
        M-=$2
    } else {
        sum+=$1*M
        M=0
    }
    
    if (M == 0) {
        printf "%f", sum
        exit
    }
}' | sed 's/\..*//'

Measured memory_bytes: 10616
while true
	a,l = gets.split(" ").map{|e|e.to_i}
	break if a==0 && l==0

	array=[a]
	while true
		small=array[-1].to_s.split("").sort.join.to_i
		big=small.to_s.reverse
		(l-big.length).times{big+="0"}
		big = big.to_i
		now = big - small
		if array.index(now) == nil
			array.push big-small
		else
			puts "#{array.index(now)} #{now} #{array.length - array.index(now)}"
			break
		end
	end

end

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

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

	vector<pair<int, int> > g;
	if (n & 1) {
		g.emplace_back(n, 1);
		g.emplace_back(n, n - 1);
		if (n > 3) {
			g.emplace_back(n, n / 2);
			g.emplace_back(n, n / 2 + 1);
		}
		n--;
	} else {
		if (n > 4) {
			g.emplace_back(1, n / 2);
			g.emplace_back(1, n / 2 + 1);
			g.emplace_back(n, n / 2);
			g.emplace_back(n, n / 2 + 1);
		}
	}
	for (int i = 1; i < n / 2; i++) {
		g.emplace_back(i, i + 1);
		g.emplace_back(i, n - i);
		g.emplace_back(n - i + 1, i + 1);
		g.emplace_back(n - i + 1, n - i);
	}

	cout << g.size() << endl;
	for (auto x: g) {
		cout << x.first << " " << x.second << endl;
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	solve();
}


Measured memory_bytes: 256
n=require('fs').readFileSync('/dev/stdin','utf8').split(" ");
  for(i=a=0;i<=~~n[0];i++){s=""+i;for(j=k=0;j<s.length;j++){k+=~~s[j]}if(k>=~~n[1]&&k<=~~n[2])a+=i}
  console.log(a);

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

#define M 1000001
#define NIL -1

int T[M];

int h1(int k)
{
	return k % M;
}

int h2(int k)
{
	return (1 + (k % (M-1)));
}

int h(int k, int i)
{
	return (h1(k) + i * h2(k)) % M;
}

int insert(int key)
{
	int i = 0, p;
	while (1) {
		if (i >= M)
			return NIL;
		p = h(key, i++);
		if (NIL == T[p]) {
			T[p] = key;
			return p;
		}
	}
}

int find(int key)
{
	int i = 0, p;
	while (1) {
		if (i >= M)
			return NIL;
		p = h(key, i++);
		if (key == T[p]) {
			return p;
		} else if (NIL == T[p]) {
			return NIL;
		}
	}
}

int get_char(char ch)
{
	switch (ch) {
	case 'A': return 1;
	case 'C': return 2;
	case 'G': return 3;
	case 'T': return 4;
	default: return 0;
	}
}

int get_key(char *cargs)
{
	int key = 0, p = 1;
	while (*cargs != 0) {
		key += p * get_char(*cargs);
		p *= 5;
		cargs++;
	}
	return key;
}

int main(int argc, char *argv[])
{
	int i, n, key;
	char cmd[10], cargs[12];
	memset(T, NIL, sizeof(T));

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s %s", cmd, cargs);
		key = get_key(cargs);

		if (!strcmp(cmd, "insert")) {
			insert(key);
		} else if (!strcmp(cmd, "find")) {
			if (NIL != find(key)) {
				printf("yes\n");
			} else {
				printf("no\n");
			}
		}
	}

	return 0;
}



Measured memory_bytes: 5632
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
using namespace std;
int main() {
	int n, k, d[9];
	cin >> n >> k;
	string s;
	for (int i = 0; i<k; i++)cin >> d[i];
	for (int i = n;; i++) {
		s = to_string(i);
		for (int j = 0; j<s.size(); j++) {
			for (int l = 0; l<k; l++) {
				if (s[j] - '0' == d[l])goto out;
			}
		}
		cout << s << endl;
		return 0;
	out:;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int f = a + b;
    int g = c + d;
    if (f > g) {
        cout << "Left" << endl;
    }
    else if (f == g) {
        cout << "Balanced" << endl;
    }
    else {
        cout << "Right" << endl;
    }
   
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>

class BinaryIndexedTree {
	std::vector<int> count;
public:
	BinaryIndexedTree(const int size) : count(size, 0) {};
	int operator[](int position) const {
		int result = 0;
		while (position >= 0) {
			result += count[position];
			position -= (position + 1) & ~position;
		}
		return result;
	}
	void increment(int position) {
		while (position < count.size()) {
			count[position]++;
			position += (position + 1) & ~position;
		}
	}
};
int main() {
	constexpr long long int mod = 1000000007LL;
	int n; long long int k; std::cin >> n >> k;
	std::vector<int> numbers(n); for (auto& a : numbers) std::cin >> a;
	for (auto& a : numbers) a = 2001 - a;
	std::vector<int> count_all(2001, 0);
	for (const auto& a : numbers) count_all[a]++;
	for (auto i = 1; i < count_all.size(); ++i) count_all[i] += count_all[i - 1];
	BinaryIndexedTree bit(2001);
	long long int result = 0;
	for (const auto a : numbers) {
		result += (k - 1) * k / 2 % mod * count_all[a - 1] % mod;
		result += bit[a - 1] * k;
		result %= mod;
		bit.increment(a);
	}
	std::cout << result << std::endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  llong n;
  cin >> n;

  llong ans = 0;
  for(llong i = 1; i <= n; ++i){
    if(i % 3 != 0 && i % 5 != 0){
      ans += i;
    }
  }

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



Measured memory_bytes: 3588
#define _USE_MATH_DEFINES
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <numeric>
#include <array>
#include <fstream>
#include <float.h>
#include <memory>
#include <functional>
#include <iomanip>
#include <queue>
#include <random>
#include <map>
#include <set>

#pragma warning(disable:4996)

using namespace std;

int main(){
  int n;
  std::unordered_map<int, bool> map;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int buf;
    cin >> buf;
    auto it = map.find(buf);
    if (it == map.end()) {
      map[buf];
    }
    else {
      map.erase(buf);
    }
  }
  cout << map.size() << endl;

  return 0;
}


Measured memory_bytes: 4388
#include <iostream>

using namespace std;

int main(){
	while(1){
		int n,m;
		cin>>n;
		if(n==0) break;
		char map[n][2];
		for(int i=0;i<n;i++){
			cin>>map[i][0]>>map[i][1];
		}
		cin>>m;
		char result[m+1];
		for(int i=0;i<m;i++){
			cin>>result[i];
			for(int j=0;j<n;j++){
				if(result[i]==map[j][0]){
					result[i]=map[j][1];
					break;
				}
			}
		}
		result[m]=0;
		cout<<result<<endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	map<int, int> mp;
	int add=a;
	while(1){
		if(a % b == c){
			cout << "YES" << endl;
			break;
		}
		if(mp[a % b]){
			cout << "NO" << endl;
			break;
		}
		mp[a % b]++;
		a += add;
	}
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
 string s,t;
 cin>>s>>t;
 if((s.length()==t.length()-1) && (t.substr(0,s.length())==s)) 
 cout<<"Yes"<<endl;
 else
 cout<<"No"<<endl;
 return 0;
}


Measured memory_bytes: 3600
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int k = in.nextInt();
        in.nextLine();
        final int a = in.nextInt();
        final int b = in.nextInt();
        in.nextLine();
        boolean found = false;
        for (int i = a; i <= b; i++) {
            if (i % k == 0) {
                found = true;
                break;
            }
        }
        System.out.println(found ? "OK" : "NG");
    }
}


Measured memory_bytes: 35828
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
int main(){
    DRII(N,M);
    VI d;
    set<int>H;
    REP(i,M){
        DRII(x,y);
        if(x==1)d.PB(y);
        if(y==N)H.insert(x);
    }
    REP(i,SZ(d)){
        if(H.count(d[i]))return 0*puts("POSSIBLE");
    }
    return 0*puts("IMPOSSIBLE");
}


Measured memory_bytes: 5368