akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db; 
typedef string str; 
typedef pair<ll,ll> pl; 
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
#define mp make_pair
#define se second
#define pb push_back
#define pf push_front
#define nn <<"\n"
#define F0R(i,a) for(ll i=0;i<a;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
int INF=0x3f3f3f3f;
ll MOD=1000000007;

ll binpow(ll a,ll b, ll c=1e18){
	ll res=1;
	while(b>0){
		if(b & 1){
			res*=a;
			res%=c;
		}
		a*=a;
		a%=c;
		b>>=1;
	}
	return res;
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//ifstream cin("name.in");
	//ofstream cout("name.out");
	int a;
	cin>>a;
	cout<<binpow(a,1)+binpow(a,2)+binpow(a,3) nn;
}


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

using namespace std;

const int N = 2010;
const int NN = 2010;

unsigned long long one = 1;
unsigned long long g[N][NN];
unsigned long long was[NN];

bool alive[N];
bool can_put[N];

int a[N];
int x[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (__gcd(a[i], a[j]) > 1) {
        g[i][j >> 6] |= (one << (j & 63));
        g[j][i >> 6] |= (one << (i & 63));
      }
    }
  }
  int nn = ((n - 1) >> 6) + 1;
  for (int i = 0; i < n; i++) {
    alive[i] = true;
    can_put[i] = true;
  }
  for (int it = 0; it < n; it++) {
    for (int i = 0; i < nn; i++) {
      was[i] = 0;
    }
    for (int i = 0; i < n; i++) 
      if (!alive[i])  
        was[i >> 6] |= (one << (i & 63));
        
    int best = -1;
    for (int i = 0; i < n; i++) {
      if (was[i >> 6] & (one << (i & 63)))
        continue;
    
      int b = 0, e = 1;
      x[0] = i;
      was[i >> 6] |= (one << (i & 63));
      while (b < e) {
        for (int j = 0; j < nn; j++) 
          if ((g[x[b]][j] & was[j]) != g[x[b]][j]) 
            for (int u = j * 64; u < (j + 1) * 64; u++) 
              if (g[x[b]][u >> 6] & (one << (u & 63))) 
                if (!(was[u >> 6] & (one << (u & 63)))) {
                  was[u >> 6] |= (one << (u & 63));
                  x[e++] = u;
                }
        b++;
      }
      int cur = -1;
      for (int j = 0; j < e; j++) {
        if (!can_put[x[j]])
          continue;
        if (cur == -1 || a[x[j]] < a[cur])
          cur = x[j];
      }
      if (best == -1 || (cur != -1 && a[cur] > a[best]))
        best = cur;
    }
    if (it > 0) putchar(' ');
    printf("%d", a[best]);
    alive[best] = false;
    for (int i = 0; i < n; i++) {
      if (!alive[i])  
        continue;
      if (g[best][i >> 6] & (one << (i & 63))) {
        can_put[i] = true;
      } else {
        if (a[best] < a[i]) 
          can_put[i] = false; 
      }
    }
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 29696
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define COUT(x) cout<<(x)<<"\n"

int main(){
    string s,t;
    cin >> s >> t;
    int count = 0;
    REP(i,s.size()){
        if(s[i]!=t[i])count++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3856
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <mutex>
#include <cmath>
#include <set>
#include <climits>
#include <bitset>

#define mod 1e9+7
#define mp make_pair
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
using ll = long long;
using pii = pair<int, int>;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, a, b;
    ll ans = 0;
    cin >> N >> a;
    ans = N/a;
    if(N%a!=0) ans++;
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  string a, b;
  bool anum[10];
  bool bnum[10];
  while(cin >> a >> b){
    int hit=0, blow=0;
    memset(anum, 0, sizeof(anum));
    memset(bnum, 0, sizeof(bnum));
    if(a == "0" && b == "0") break;
    
    for(int i = 0 ; i < 4 ; i++){
      if(a[i] == b[i]) hit++;
      else{
	anum[a[i]-'0'] = 1;
	bnum[b[i]-'0'] = 1;
      }
    }
    
    for(int i = 0 ; i <= 9 ; i++){
      if(anum[i] == 1 && bnum[i] == 1){
	blow++;
      }
    }
    
    cout << hit << ' ' << blow << endl;
  }
  return 0;
}

Measured memory_bytes: 916
n=int(input())
w=list(map(int,input().split()))

sum=0
for i in range(n):
    sum+=w[i]
s2=sum
s1=0
dif=sum
#print(dif)
#print()
ans=0
for i in range(n-1):
    s2-=w[i]
    s1+=w[i]
    dif_n=abs(s2-s1)
    if dif_n<dif:
        dif=dif_n
    else:
        print(dif)
        ans=1
        break
if ans==0:
    print(dif)


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

#define N_MAX 100
#define WH 0
#define BK 2


long n;
long G[N_MAX][N_MAX] = {};
long color[N_MAX] = {};
long dist[N_MAX];
queue<long> Q;

void bfs(long u) {
    Q.push(u);
    color[u] = BK;
    dist[u] = 0;
    while (Q.empty() == false) {
        u = Q.front();
        Q.pop();
        for (long v = 0; v < n; v++) {
            if (G[u][v] == 1 && color[v] == WH) {
                Q.push(v);
                color[v] = BK;
                dist[v] = dist[u] + 1;
            }
        }
    }
}

int main() {
    long v_from, deg_out, v_to;

    cin >> n;
    for (long i = 0; i < n; i++) {
        cin >> v_from >> deg_out;
        v_from--;
        for (long j = 0; j < deg_out; j++) {
            cin >> v_to;
            v_to--;
            G[v_from][v_to] = 1;
        }
    }

    // for (long i = 0; i < n; i++) {
    //     for (long j = 0; j < n; j++) {
    //         if (j != 0) { cout << " "; }
    //         cout << G[i][j];
    //     }
    //     cout << endl;
    // }


    for (long i = 0; i < n; i++) {
        dist[i] = -1;
    }

    bfs(0);

    for (long i = 0; i < n; i++) {
        cout << i + 1 << " " << dist[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
typedef long long ll;
using namespace std;
const int mod = 1000000007;
ll modpow(ll a, ll n){
  long long r = 1;
  while (n) {
    r = r * ( (n%2)?a:1 ) %mod;
    a = a * a % mod;
    n >>= 1;
  }
  return r;
}
int main(void){
    ll n;cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    map<ll,ll> mp2;
    rep(i,n){
        ll x=a[i];
        map<ll,ll> mp1;
        for(int i=2;i*i<=x;i++){
            while(x%i==0){
                x/=i;
                mp1[i]++;
            }
        }
        if(x>1)mp1[x]++;
        for(auto& p:mp1){
            mp2[p.first]=max(mp2[p.first],p.second);
        }
    }
    ll lcm=1;
    for(auto& p : mp2){
        lcm*=modpow(p.first,p.second)%mod;
        lcm%=mod;
    }
    ll res=0;
    rep(i,n){
        res+=(lcm*(modpow(a[i],mod-2)%mod))%mod;
        res%=mod;
    }
    cout<<res<<endl;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	const int MX = 1e6 + 100;
	cin >>n;
	VI ct(MX), a, b;
	rep(i, n){
		int ba; cin >>ba;
		ct[ba]++;
	}
	rep(i, MX){
		if(ct[i]==1) a.push_back(i);
		if(ct[i]>=1) b.push_back(i);
	}
	fill(all(ct), 0);
	for(auto cr: b) for(int j=cr+cr; j< MX; j+= cr) ct[j]=1;

	int ans =0;
	for(auto cr: a)if(ct[cr]==0) {ans++; /*dbg(cr);*/}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 9020
#include<iostream>
#include<string>
#include<math.h>

using namespace std;

int main() {
	int A[100];
	int N, i;
	double psum = 0;
	double max = 1000000;
	int ans;
	cin >> N;
	for (i = 0; i < N; ++i) {
		cin >> A[i];
		psum += A[i];
	}
	psum = psum / N;
	for (i = N - 1; i >= 0; --i) {
		if (fabs(psum - A[i]) <= max) {
			max = fabs(psum - A[i]);
			ans = i;
		}

	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    x, n = map(int, readline().split())
    p = list(map(int, readline().split()))

    ans = 1000000

    for i in range(101, -100, -1):
        if i in p:
            continue
        else:
            diff = abs(x-i)
            if diff <= abs(x-ans):
                ans = i
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61816
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

int main() {
	int N; cin >> N;
	int a[100001];
	rep(i, 1, N + 1) {
		cin >> a[i];
	}

	int p = 1;
	int count = 0;
	bool isTwo = false;
	rep(i, 1, N + 1) {
		count++;
		int c = a[p];
		if (c == 2) {
			isTwo = true;
			break;
		}
		p = c;
	}

	cout << ((isTwo) ? count : -1) << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>

using namespace std;

int n,m;
double dp[101][100];
double t[100][100];

double solve(int times, int prev){
  if(dp[times][prev] != -1) return dp[times][prev];
  if(times == m) return dp[times][prev]=1;

  double tmp=-1;
  for(int i=0;i<n;i++){
    if(times == 0){
      tmp = max(tmp, solve(times+1, i) * 1);
    }else{
      tmp = max(tmp, solve(times+1, i) * t[prev][i]);
    }
  }
  
  return dp[times][prev] = tmp;
}

int main(void){
  while(cin >> n >> m){
    if(!(n|m)) break;
    fill((double *)dp, (double *)dp+101*101, -1);
    double retd;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	cin >> t[i][j];
      }
    }
    retd = solve(0,0) * 100;
    printf("%.2lf\n", round(retd) /  100);
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K,S;cin>>N>>K>>S;
  if(S==1000000000){
    for(int i=0;i<N;i++){
      if(i<K)cout<<S;
      else cout<<"1";
      if(i<N-1)cout<<" ";
    }
  }
  else{
    for(int i=0;i<N;i++){
      if(i<K)cout<<S;
      else cout<<S+1;
      if(i<N-1)cout<<" ";
    }
  }
  cout<<endl;
}

Measured memory_bytes: 1280
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().strip().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def ref_slv(N, S):
    ans = 0

    for i in combinations(range(0, 2*N), N):
        l = []
        r = []
        for j in range(2*N):
            if j in i:
                l.append(S[j])
            else:
                r.append(S[j])

        if ''.join(l) == ''.join(reversed(r)):
            ans += 1

    return ans


@mt
def slv(N, S):
    ans = 0

    l = S[:N]
    r = S[N:][::-1]
    ld = defaultdict(lambda: 0)
    rd = defaultdict(lambda: 0)

    for i in range(N+1):
        for j in combinations(range(N), i):
            lb = []
            lr = []
            rb = []
            rr = []
            for k in range(N):
                if k in j:
                    lb.append(l[k])
                    rr.append(r[k])
                else:
                    lr.append(l[k])
                    rb.append(r[k])
            ld[(''.join(lr), ''.join(lb))] += 1
            rd[(''.join(rr), ''.join(rb))] += 1
    for k, v in ld.items():
        if k in rd:
            ans += v * rd[k]

    return ans


def main():
    # for i in range(1, 19):
    #     print(i, slv(i, ""))
    N = read_int()
    S = read_str()
    print(slv(N, S))


if __name__ == '__main__':
    main()


Measured memory_bytes: 128140
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(void) {
	int n; 	cin >> n;
	vector<int> a(n), b(n), c(n);
	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < n; ++j) {
			if (i == 0) cin >> a[j];
			else if (i == 1) cin >> b[j];
			else cin >> c[j];
		}
	}
	sort(a.begin(), a.end()); sort(b.begin(), b.end()); sort(c.begin(), c.end());
	ll ans = 0;
	for (int j = 0; j < n; ++j) {
		ll s = lower_bound(a.begin(), a.end(), b[j]) - a.begin();
		ll m = c.end() - upper_bound(c.begin(), c.end(), b[j]);
		ans += s * m;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
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;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

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

int n;
int m;
int xy[11][11];
int hwl[11];
int re[11];
ll ans=0;
vector< pair<int,int> >PP;


void check(int k){
	if(k==PP.size()){
		ans++;
		return;
	}
	pair<int,int> pp=PP[k];
	//cout<<k<<" "<<pp.first<<"   "<<pp.second<<endl;
	xy[pp.first][pp.second]=1;
	xy[pp.second][pp.first]=-1;
	re[pp.first]--;
	re[pp.second]--;
	hwl[pp.first]++;
	hwl[pp.second]--;
	if(abs(hwl[pp.first])<=re[pp.first]&&abs(hwl[pp.second])<=re[pp.second]){/*cout<<k<<" "<<1<<endl;*/check(k+1);}
	//else cout<<"out1"<<endl;
	pp=PP[k];
	xy[pp.first][pp.second]=-1;
	xy[pp.second][pp.first]=1;
	
	hwl[pp.first]-=2;
	hwl[pp.second]+=2;
	if(abs(hwl[pp.first])<=re[pp.first]&&abs(hwl[pp.second])<=re[pp.second]){/*cout<<k<<" "<<2<<endl;*/check(k+1);}
	//else cout<<"out2"<<endl;
	pp=PP[k];
	xy[pp.first][pp.second]=0;
	xy[pp.second][pp.first]=0;
	re[pp.first]++;
	re[pp.second]++;
	hwl[pp.first]++;
	hwl[pp.second]--;
	return;
}
	
int main(){
	while(1){
		ans=0;
		cin>>n;
		if(n==0)break;
		cin>>m;
		PP.clear();
		for(int i=0;i<11;i++){
			for(int j=0;j<11;j++){
				xy[i][j]=0;
			}
		}
		for(int i=0;i<11;i++){
			hwl[i]=0;
		}
		for(int i=0;i<11;i++){
			re[i]=0;
		}
		for(int i=0;i<m;i++){
			int t,s;
			cin>>t>>s;
			xy[t][s]=1,xy[s][t]=-1;
		}
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				if(i!=j){
					hwl[i]+=xy[i][j];
					if(xy[i][j]==0){
						if(i>j){
						PP.push_back(pair<int,int>(i,j));
						re[i]++;
						re[j]++;
						}
					}
				}
			}
		}
		
		
		/*for(int i=0;i<PP.size();i++){
			cout<<PP[i].first<<" "<<PP[i].second<<endl;
		}*/
		for(int i=1;i<=n;i++){
			if(abs(hwl[i])>re[i]){
				goto A;
			}
		}
		check(0);
		A:
		cout<<ans<<endl;
	}
	return 0;
}

			
				
					

					
				


Measured memory_bytes: 3100
#include <iostream>
#include <queue>
#include <string>

using namespace std;

struct task{
    string name;
    int timeneed;
};

int main()
{
    int n, once;
    
    cin >> n;
    cin >> once;
    
    queue<task> que;
    
    for(int i = 0; i < n; i++){
        string buf_name;
        int buf_time;

        cin >> buf_name;
        cin >> buf_time;

        task buf_task ={buf_name, buf_time};

        que.push(buf_task);
    }


    int cnt = 0;
    int nowtime = 0;
    
    while(1){
        string this_name;
        int this_time;

        this_name = que.front().name;
        this_time = que.front().timeneed;
        que.pop();

        if(this_time >= once){
            nowtime += once;
            this_time -= once;
        }else{
            nowtime += this_time;
            this_time = 0;
        }

        if(this_time > 0){
            task this_task = {this_name, this_time};
            que.push(this_task);
        }else{
            cout << this_name << " " << nowtime << endl;
            cnt++;
        }

        if(cnt == n){
            break;
        }
    }

    return 0;
}



Measured memory_bytes: 6356
a = list(input())
b = 0
c = 0

for i in range(len(a)):
  if(a[i] == "A" or a[i] == "G" or a[i] == "T" or a[i] == "C"):
    b += 1
    if(b > c):
      c = b
  else:
    b = 0

print(c)

Measured memory_bytes: 2940
using static System.Math;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var k = int.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        var p = Array.ConvertAll(line, int.Parse);
        getAns(n, k, p);
    }
    static void getAns(int n, int k, int[] p)
    {
        var s = 0;
        for (int i = 0; i < k; i++) s += p[i];
        var sum = s;
        for (int i = 0; i < n - k; i++)
        {
            s = s - p[i] + p[i + k];
            sum = Max(sum, s);
        }
        var ans = (sum + k) / 2d;
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 28252
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

void angshuGod()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

const int N = 1e5+1;
const double pi = acos(-1);

void solve(){    

    int n,a,b;
    cin>>n>>a>>b;
    if(a==0) {
        cout<<0;
        return;
    }
    int s = n/(a+b);
    s  = s*a + min(n%(a+b),a);
    cout<<s;
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

    while(t--){
        solve();
    }
    
    return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

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

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

	int ans=0;
	for (int i = 1; i <= n; ++i){
		string s=to_string(i);
		if(s.size()%2==1)ans++;
	}

	cout<<ans<<endl;

	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int N;
  scanf("%d",&N);
  int i;
  int a[N];
  int count[200001]={0};
  for(i=1;i<N;i++){
    scanf("%d",&a[i]);
    count[a[i]]++;
  }
  for(i=1;i<=N;i++){
    printf("%d\n",count[i]);
  }
}


Measured memory_bytes: 3292
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
const int inf = 1e9+7;
const int INF = 1e18+7;
int mod = 1e9+7;

char a[400][400], b[400][400];
int n;
int solve(int m){
	rep(i,n)rep(j,n){
		b[i][j] = a[i][(j+m)%n];
	}
	rep(i,n)rep(j,n){
		if(b[i][j] != b[j][i])return 0;
	}
	return n;
}

signed main(){
	int ans = 0;
	scanf("%lld", &n);
	rep(i,n)scanf("%s", a[i]);
	rep(i,n){
		ans += solve(i);
	}
	printf("%lld\n", ans);
	return 0;
}




Measured memory_bytes: 512
MOD = 10**9 + 7

def comb(n, r):
	res = 1
	for i in range(r):
		res *= n-i
		res *= pow(i+1, MOD-2, MOD)
		res %= MOD
	return res

n, a, b = map(int, input().split())
print((pow(2, n, MOD) - 1 - comb(n, a) - comb(n, b)) % MOD)

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

int main() {
	int n;
	set<string> items;

	cin >> n;
	for (int i = 0; i < n; i++) {
		string item;
		cin >> item;
		items.insert(item);
	}

	printf("%d\n", items.size());
	return 0;
}

Measured memory_bytes: 19236
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP1_7_D
{
    class Program
    {
        static int[,] ReadMatrix(int row, int column)
        {
            int[,] matrix = new int[row, column];
            for (var i = 0; i < row; ++i)
            {
                string[] t = Console.ReadLine().Split(' ');
                for (var j = 0; j < column; ++j)
                {
                    matrix[i, j] = int.Parse(t[j]);
                }
            }

            return matrix;
        }


        static long Multiple(int i, int j, int[,] A, int[,] B)
        {
            var m = 0;
            {
                var mA = A.GetLength(1);
                var mB = B.GetLength(0);
                if (mA != mB)
                {
                    return 0;
                }
                m = mA;
            }

            var sum = 0L;
            for (var k = 0; k < m; ++k)
            {
                sum += A[i, k] * B[k, j];
            }
            return sum;
        }


        static void Main(string[] args)
        {
            string[] words = Console.ReadLine().Split(' ');
            var n = int.Parse(words[0]);
            var m = int.Parse(words[1]);
            var l = int.Parse(words[2]);

            var A = ReadMatrix(n, m);
            var B = ReadMatrix(m, l);
            var C = new long[n, l];


            for (var i = 0; i < n; ++i)
            {
                for (var j = 0; j < l; ++j)
                {
                    C[i, j] = Multiple(i, j, A, B);

                    if (j == 0)
                    {
                        Console.Write(C[i, j]);
                    }
                    else
                    {
                        Console.Write(" {0}", C[i, j]);
                    }
                }
                Console.WriteLine();
            }

        }
    }
}

Measured memory_bytes: 20096
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<int> a(n); REP(i, n) cin >> a[i];
  sort(ALL(a), greater<int>());
  int now = 0;
  long long ans = 0;
  REP(i, n) {
    if (now != a[i]) now = a[i];
    else if (ans == 0) {
      ans = now;
      now = 0;
    } else {
      cout << ans * now << '\n';
      return 0;
    }
  }
  cout << 0 << '\n';
  return 0;
}


Measured memory_bytes: 640
#define SuC_VaT              Doc_code_ban_khac
#define Nhan_cach_bang_0     Doc_code_ban_khac

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll, pair<ll,ll> > iii;

const int kn = 2e5 + 5, N = 1e5+5;
const ll mod = 1e9 + 7, mod2 = 1e9+9;
const ll base = 31, base1 = 37;

#define x first
#define y second
#define lwb lower_bound
#define upb upper_bound

#define pb push_back
#define popb pop_back
#define pf push_front
#define popf pop_front

#define log2(X) (31-__builtin_clz(X))
#define log2ll(X) (63-__builtin_clzll(X))
#define numbit(X) __builtin_popcount(X)
#define numbitll(X) __builtin_popcountll(X)

#define ms(val,a) memset(a,val,sizeof(a))

#define ff(i,n) for(int i=1;i<=n;i++)
#define _ff(i,n) for(int i=n;i>=1;i--)
#define f(i,a,b) for(int i = a; i <=b; i++)
#define _f(i,a,b) for(int i = b; i>=a;i--)

#define In(X) freopen(X,"r",stdin)
#define Out(X) freopen(X,"w",stdout)

#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int n, cnt = 0, p , q, ANS = 99999999;
ii coor[kn];
int dp[51], trace[51];

set<int> hi;

int main()
{
	scanf("%d",&n);
	ff(i,n)
	{
		scanf("%d %d", &coor[i].x , &coor[i].y);
		hi.insert(i);
	}
	sort(coor+1,coor+n+1);
	for(int I = 2; I<=n; I++ )
	{
		for(int J = 1; J <I; J++)
		{
			p = coor[I].x - coor[J].x; q = coor[I].y - coor[J].y;
			//cout <<I <<" "<<J<<" "<< p <<" "<<q << endl;
			ff(i,n) hi.insert(i);
			cnt = 0 ;
			while(hi.size())
			{
				cnt++;
				int num = 0, ans;
				for(int i : hi)
				{
					trace[i] = -1;
					dp[i] = 1;
					for(int j : hi)
					{
						if(j == i) break;
						if(coor[j].x + p ==  coor[i].x && coor[j].y + q ==  coor[i].y && dp[i] < dp[j] + 1)
						{
							//cout <<"# "<< j<<" "<< i << endl;
							dp[i] = dp[j] + 1;
							trace[i] = j;
						}
					}
					if(dp[i] > num)
					{
						ans = i;
						num = dp[i];
					}
				}
				hi.erase(ans);
				while(trace[ans] != -1)
				{
					ans = trace[ans];
					hi.erase(ans);
				}
			}
			ANS = min(ANS,cnt);
		}
	}
	if(n==1) cout<<"1";
	else cout << ANS;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <unordered_set>

using namespace std;

using std::string;
using std::unordered_set;

int main()
{
    string a;
    cin >> a;

    unordered_set<char> chars;

    for (int i = 0; i < a.length(); i++)
    {
        chars.insert(a[i]);
    }

    if (chars.size() == 2)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    bool x=0;
    int sum=s.size();
    for(int i=1;i<s.size();i++)
    {
        if(x)
            {
                x=!x;
                continue;
            }
        if(s[i]==s[i-1])
        {
            i++;
            sum--;
            x=1;
        }
    }
    cout<<sum<<'\n';
}


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v) do { x = max(x, v); } while(0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll N;
  cin >> N;
  for (ll x = 1; x <= 500000; x++) {
    if (N == (ll)(x * 1.08)) {
      cout << x << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
long long ret(long long n,vector<long long> &x){
	for(int i=2;i<=n;++i)
		x[i]=x[i-1]+x[i-2];
	return x[n];
}
int main(){
	long long a;
	cin>>a;
	vector<long long> x(87);
	x[0]=2,x[1]=1;
	cout<<ret(a,x);
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i = (a-1); i >= (b); --i)
#define RREP(i,n) RFOR(i,n,0)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int BubbleSort(vi &a)
{
    int cnt = 0;
    bool flag = 1;
    while (flag) {
        flag = 0;
        RREP(j, a.size()) {
            if(a[j] < a[j - 1]) {
                swap(a[j], a[j - 1]);
                cnt++;
                flag = 1;
            }
        }
    }
    return cnt;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);
    
    int n; cin >> n;
    vi a(n); REP(i, n) cin >> a[i];

    int cnt = BubbleSort(a);
    cout << a[0];
    FOR(i, 1, n) cout << " " << a[i];
    cout << endl << cnt << endl;


    return 0;
}


Measured memory_bytes: 3216
public class Main {
	public static void main(String[] args){
		java.util.Scanner scan = new java.util.Scanner(System.in);
		while(true){
			int H = scan.nextInt();
			int W = scan.nextInt();
			if(H == 0 && W ==0)
				break;

			for(int i = 0;i < H;i++){
				for(int j = 1;j < W;j++){
					System.out.print("#");
				}
				System.out.println("#");
		}
		System.out.println();
		}
	}

}

Measured memory_bytes: 35416
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N, K; cin >> N >> K;
    vector<int> A(N);
    rep (i, 0, N) cin >> A[i];

    int ans = 0, cnt = 0;
    while (true) {
        if (N <= 0) break;
        if (cnt == 0) N -= K;
        else N -= (K-1);
        ++ans;
        ++cnt;
    }
    cout << ans << endl;
}

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

using ll = long long int;

const int MAX_N = (int)(1e5 + 5);
const int MAX_M = (int)(1e5 + 5);

int n, m;

map<int, vector<pair<ll, ll>>> cnt;

map<int, pair<int, int>> ans;

using P = pair<ll, int>;

int main(void) {
    // Here your code !
    scanf("%d %d", &n, &m);

    for (int i = 1; i <= m; ++i) {
      ll p;
      ll y;
      scanf("%lld %lld", &p, &y);

      cnt[p].push_back(make_pair(y, i));
    }

    for (auto &e: cnt) {
      auto tmpvec = e.second;
      sort(tmpvec.begin(), tmpvec.end(), [&](P a, P b) { return a.first < b.first; } );
      for (int i = 0; i < tmpvec.size(); ++i) {
        auto obj = tmpvec[i];
        ans[obj.second] = make_pair(e.first, i + 1);
      }
    }

    for (auto &e: ans) {

      int fst = 6 - to_string(e.second.first).length();
      int snd = 6 - to_string(e.second.second).length();

      for (int i = 0; i < fst; ++i) {
        printf("%d", 0);
      }
      printf("%d", e.second.first);


      for (int i = 0; i < snd; ++i) {
        printf("%d", 0);
      }
      printf("%d", e.second.second);

      printf("\n");
    }

    return 0;
}

Measured memory_bytes: 18688
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	ll N;
	cin >> N;
	N++;
	vector<int> bit;
	while (N) {
		bit.push_back(N % 2);
		N /= 2;
	}
	reverse(bit.begin(), bit.end());
	deque<int> p;
	p.push_back(1);
	int k = 2;
	for (int i = 1; i < bit.size(); i++) {
		if (i > 1) p.push_back(k++);
		if (bit[i]) p.push_front(k++);
	}
	cout << (k - 1) * 2 << endl;
	for (int i = 1; i < k; i++) cout << i << " ";
	while (!p.empty()) {
		cout << p.front() << " ";
		p.pop_front();
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <numeric>
#include <algorithm>
//#include <iomanip> : 表示桁数, ex) cout << fixed << setprecision(15) << ...

#define pi 3.14159265358979323846
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using ld = long double;
using Byte = unsigned char;
using namespace std;

//string ans = "Yes";

void SetAns() {
//	const ll max = 1000000000000001;
	ll N;
	vector<int> A(200000, 0);

	cin >> N;

	int tmp;
	rep(i, N) {
		cin >> tmp;
		A[tmp]++;
	}

	//喰えり処理
	int Q;
	int B, C;
	cin >> Q;
	ll nowAns = 0;
	rep(i, 100000) nowAns += (ll)A[i + 1] * (ll)(i + 1);

	rep(_i, Q) {
		cin >> B >> C;
		nowAns -= (ll)B * (ll)A[B];
		nowAns += (ll)C * (ll)A[B];

		A[C] += A[B];
		
		A[B] = 0;
		
		cout << nowAns << endl;
	}

	//こたえ
	return;
}

int main() {
	SetAns();
	//cout << SetAns() << endl;
	return 0;
}


Measured memory_bytes: 3388
n = int(input())
a=list(map(int,input().split()))
 
kane=1000
kabu =0
 
for i in range(n-1):
    if a[i]<=a[i+1]:
        kabu+=kane//a[i]
        kane=kane%a[i]
    else:
        kane+=kabu*a[i]
        kabu=0

print(kane+kabu*a[n-1])

Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int
const int MAX = 510000;


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

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
   int x;
  cin >> x;
  if(x == 3 || x == 5 || x == 7) cout << "YES" << endl;
  else cout << "NO" << endl;

}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

h[0] = h[0] - 1

for i in range(n-1):
    if h[i] < h[i+1]:
        h[i+1] -= 1
    if h[i] > h[i+1]:
        print('No')
        exit()

if h[0] <= h[-1]:
    print('Yes')


Measured memory_bytes: 14396
#include <bits/stdc++.h>
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) v.begin(), v.end()

using namespace std;

ll mod = 1e9+7;
inline ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

inline ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0) {
        return -1;
    }
    
    return (x * y / gcd(x, y));
}

inline ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

inline ll nCr(ll n, ll r) {
    if ( r * 2 > n ) r = n - r;
    ll dividend = 1;
    ll divisor  = 1;
    for ( ll i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return (dividend / divisor);
}

// 因数分解
inline vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1) res.emplace_back(n, 1);
    return res;
}

inline bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

//階乗
inline ll factorialMethod(ll k){
    ll sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

inline ll vector_finder(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
    if (index != vec.size()) { // 発見できたとき
        return 1;
        
        
    }
    else { // 発見できなかったとき
        return 0;
    }
}

void recursive_comb(ll *indexes, ll s, ll rest, std::function<void(ll *)> f) {
    if (rest == 0) {
        f(indexes);
    } else {
        if (s < 0) return;
        recursive_comb(indexes, s - 1, rest, f);
        indexes[rest - 1] = s;
        recursive_comb(indexes, s - 1, rest - 1, f);
    }
}

void foreach_permutation(int n, std::function<void(int *)> f) {
    int indexes[n];
    for (int i = 0; i < n; i++) indexes[i] = i;
    do {
        f(indexes);
    } while (std::next_permutation(indexes, indexes + n));
}

int main(){
    ll ans = 0;
    string s;
    cin >> s;
    
    rep(i, s.size()){
        cout << "x";
    }
    return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s)
k = int(input())
dp = [[[0 for _ in range(2)] for _ in range(k + 1)] for _ in range(n + 1)]
dp[0][0][0] = 1
for a in range(n):
    for b in range(k + 1):
        for c in range(2):
            nd = int(s[a])
            for d in range(10):
                na, nb, nc = a + 1, b, c
                if 0 != d:
                    nb += 1
                if nb > k:
                    break
                if 0 == c:
                    if d > nd:
                        break
                    elif d < nd:
                        nc = 1
                dp[na][nb][nc] += dp[a][b][c]
print(sum(dp[-1][-1]))


Measured memory_bytes: 3064
def prime_list(num)
  count = 0
  num_list = (2..num).to_a
  arr = []

  until num_list[0] >= Math.sqrt(num)
    arr << num_list[0]

    num_list = num_list.select do |i|
      i % num_list[0] != 0
    end

    count += 1
  end

  arr.concat(num_list)
end

num_list = []

loop do
  n = gets.to_i
  break if n.zero?

  num_list << n
end

max = num_list.max
prime_list_of_max = prime_list(max)

num_list.each do |num|
  prime_count = prime_list_of_max.select { |i|
    i <= num
  }.length

  puts prime_count
end

Measured memory_bytes: 77236
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
#define MAX 200005
#define MOD 1000000007
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define si set<int>
#define mp map<ll,ll>
#define mpi map<ii,ll>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#include <unordered_map> 
#define ump unordered_map<ll,ll>
int main()
{ 
	fast 
	ll n;
	long double ans=0;
	cin>>n;
	ll i;
	for(i=0;i<n;i++)
	{
		double x;
		cin>>x;
		ans=ans+1/x;
	}
	ans=1/ans;
	cout<<setprecision(10)<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <climits>

using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
   
    cout << (N == M ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 256
import bisect

def main():
    n = int(input())
    A = list(map(int,input().split()))
    q = int(input())
    for _ in range(q):
        b = int(input())
        lb = bisect.bisect_left(A,b)
        ub = bisect.bisect_right(A,b)
        print (lb,ub)



if __name__ == '__main__':
    main()




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

using namespace std;

class Solution {
public:
	void Yes() { cout << "OK\n"; }
	void solve() {
		int k, a, b;
		cin >> k >> a >> b;
		for (int i = a; i <= b; i++) {
			if ((i % k) == 0) return Yes();
		}
		cout << "NG\n";
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 3584
# B
# 2020/03/06 14:34-
n, a, b = map(int, input().split())

def SumDegit(x):
    ans = 0
    while x > 0:
        ans += x%10
        x = x//10
    return ans

ans = 0
for i in range(1, n+1):
    if a <= SumDegit(i) <= b:
        ans += i
        
print(ans)

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

#define REP(i, n) for(long long i = 0; i < n; i++)
#define REPR(i, n) for(long long i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(long long i = m; i <= n; i++)
#define FORR(i, m, n) for(long long i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;

map<ll,ll> r;

void primes(ll n){
    
    for(int i=2; i<=n; i++){
        while(n % i ==0){
            r[i]++;
            n /= i;
        }
    }

    if(n != 1) r[n] = 1;
    // return r;
}

int main(){FIN

    ll n;cin>>n;
    FOR(i,1,n) primes(i);
    map<ll,ll> num;
    for(auto p: r){
        // cout<<p.first<<' '<<p.second<<endl;
        if (p.second>=2) num[2]++;
        if (p.second>=4) num[4]++;
        if (p.second>=14) num[14]++;
        if (p.second>=24) num[24]++;
        if (p.second>=74) num[74]++;
    }
    ll ans=0;
    ans += num[4] * (num[4]-1) / 2 * (num[2]-2);
    ans += num[14] * (num[4]-1);
    ans += num[24] * (num[2]-1);
    ans += num[74];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<functional>
using namespace std;
int main(void) {
    
   int n;
   cin>>n;
   int a[200000];
   int b[200000];

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

   sort(a,a+n);

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

}

Measured memory_bytes: 3712
use proconio::{input, fastout};
use std::cmp;

fn dfs(n:i64, m:i64, query:&Vec<(usize,usize,i64,i64)>, v:&mut Vec<i64>, max:i64) -> i64 {
    if n>0 {
        let mut ret = 0;
        for i in max..=m {
            v.push(i);
            ret = cmp::max(ret, dfs(n-1, m, query, v, i));
            v.pop();
        }
        return ret;
    } else {
        let mut ret = 0;
        for (a, b, c, d) in query {
            if v[b-1]-v[a-1]==*c {
                ret += d;
            }
        }
        return ret;
    }
}
    

#[fastout]
fn main() {
    input! {
        (n, m, q): (i64, i64, i64),
        query: [(usize,usize,i64,i64); q],
    }
    println!("{}", dfs(n, m, &query, &mut Vec::new(), 1));
}


Measured memory_bytes: 2204
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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 INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a,b;
  cin>>a>>b;
  vector<int> c(a),d(a);
  rep(i,a)
    cin>>c[i]>>d[i];
  int e=INF;
  rep(i,a){
  if(b>=d[i])
    chmin(e,c[i]);
  }
  if(e==INF)
    cout<<"TLE"<<endl;
  else
    out(e);
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int K[200001];
int zentai, N;
ll kotae[200001];
int C[200001];
int E[400001], ne[400001], he[200001];
const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}
char dn[2400000], * di = dn;
inline void putint(ll X) {
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[15];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

void dfs(int p, int mae) {
	int k = K[C[p]] + zentai;
	int k0 = k;
	for (int to = he[p]; to; to = ne[to]) {
		if (mae != E[to]) {
			dfs(E[to], p);
			int sa = K[C[p]] + zentai - k;
			kotae[C[p]] -= ll(sa) * (sa + 1) >> 1;
			k += sa;
		}
	}
	zentai++;
	K[C[p]] = k0 - zentai;
}


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


	N = getint();
	rep1(i, N) C[i] = getint();
	int k = 1;
	rep(i, N - 1) {
		int a = getint(), b = getint();

		E[k] =b;
		ne[k] = he[a];
		he[a] = k++;
		E[k] = a;
		ne[k] = he[b];
		he[b] = k++;
	}

	dfs(1, -1);
	ll n = ll(N) * (N + 1) / 2;
	rep1(i, N) {
		int sa = K[i] + zentai;
		putint(n + kotae[i] - (ll(sa) * (sa + 1) >> 1));
	}
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 26112