akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

int main(){
    int n;
    int v;
    map<int,int> mp[2];
    map<int,int>::iterator it;
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> v;
        if(mp[i%2].find(v)!=mp[i%2].end())
            mp[i%2][v]++;
        else
            mp[i%2][v]=1;
    }
    int MAX[2]={0,0};
    int MAX2[2]={0,0};
    int MAXFLAG[2]={-1,-1};
    for(int i = 0;i < 2;i++){
        it = mp[i].begin();
        while(it!=mp[i].end()){
//            cout<<it->first<<" "<<it->second<<endl;
            if(MAX[i]<=it->second){
                MAX2[i]=MAX[i];
                MAX[i]=it->second;
                MAXFLAG[i]=it->first;
            }else{
                MAX2[i]=max(MAX2[i],it->second);
            }
            it++;
        }
    }
    if(MAXFLAG[0]!=MAXFLAG[1]){
        cout<<n-MAX[0]-MAX[1]<<endl;
    }else{
//        cout<<"b "<<MAX[0]<<MAX[1]<<MAX2[0]<<MAX2[1]<<endl;
        int sub = max(MAX[0]+MAX2[1],MAX[1]+MAX2[0]);
        cout<<n-sub<<endl;
    }
}


Measured memory_bytes: 4992
/*
    @uthor: Amit Kumar
    user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    long double
#define ull   unsigned long long
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"Case #"<<x<<":"
#define pi 3.14159265358979323846264338327950L

const ll mod = 1e9+7;
const ll inf = 1e18;

ll popcount(ll num){
    num = num - ((num >> 1) & 0x55555555);
    num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
    return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}

vector<pair<ll,ll>> prime_pow;
void sieveOfEratosthenes(ll N, ll s[]){ 
    vector <bool> prime(N+1, false); 
    for (ll i=2; i<=N; i+=2) 
        s[i] = 2;  
    for (ll i=3; i<=N; i+=2) { 
        if (prime[i] == false) {  
            s[i] = i;  
            for (ll j=i; j*i<=N; j+=2) { 
                if (prime[i*j] == false) { 
                    prime[i*j] = true; 
                    s[i*j] = i; 
                } 
            } 
        } 
    } 
} 
void primefactor(ll N){ 
    ll s[N+1];  
    sieveOfEratosthenes(N, s); 
    ll curr = s[N], cnt = 1;    
    while (N > 1){ 
        N /= s[N];  
        if (curr == s[N]) { 
            cnt++; 
            continue; 
        } 
        prime_pow.push_back({curr,cnt});  
        curr = s[N], cnt = 1; 
    } 
}

void virus(){
        ll a;
        cin>>a;
        cout<<a+(a*a)+(a*a*a);
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    ll t=1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
         //cout << "Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

Measured memory_bytes: 3612
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  typedef pair<int, int> P;
  int K; cin >> K;
  deque<P> dq; dq.pb(P(1, 1));
  vector<bool> visit(K, 0);
  while(!dq.empty()){
    P p = dq.front(); dq.pop_front();
    if(p.first == 0) {
      cout << p.second << endl;
      return 0;
    }

    visit[p.first] = 1;
    int next = (p.first + 1) % K;
    if(!visit[next]) dq.pb(P(next, p.second+1));
    next = (p.first*10) % K;
    if(!visit[next]) dq.emplace_front(P(next, p.second));
  }
}

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

int main() {
    int N, M;
    cin >> N >> M;
    int a[N];
    for (int n=0; n<N; n++){
        a[n] = 0;
    }
    int A, B;
    for (int m=0; m<M; m++){
        cin >> A >> B;
        a[A-1] += 1;
        a[B-1] += 1;
    }
    for (int n=0; n<N; n++){
        cout << a[n] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import fractions

N, M = list(map(int, input().split()))
S = input()
T = input()

gcd_N_M = fractions.gcd(N, M)
lcm_N_M = N*M//gcd_N_M
if S[0::N//gcd_N_M] == T[0::M//gcd_N_M]:
    print(lcm_N_M)
else:
    print(-1)

Measured memory_bytes: 6240
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;

  REP(a, n / 4 + 1) {
    REP(b, n / 7 + 1) {
      if(4 * a + 7 * b == n) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s,t;
  cin>>n>>s>>t;
  for(int i=0;i<2*n;i++){
    if(i%2==0)
      cout<<s[i/2];
    else
      cout<<t[i/2];
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
P x[90000];
int y[90000];
signed main(){
	int a,b,c;
	cin>>a>>b>>c;
	f(i,a){
		f(j,b){
			int d;
			cin>>d;
			x[d-1].F=i;
			x[d-1].S=j;
		}
	}
	f(i,c){
		for(int j=i+c;j<a*b;j+=c){
			y[j]=y[j-c]+abs(x[j].F-x[j-c].F)+abs(x[j].S-x[j-c].S);
		}
	}
	int d;
	cin>>d;
	f(i,d){
		int va,vb;
		cin>>va>>vb;
		cout<<y[vb-1]-y[va-1]<<endl;
	}
	return 0;
}


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

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

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

	cout << v[n / 2] - v[n / 2 - 1] << endl;
}

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

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

int main() {
    string s;
    cin >> s;
    ll ans = 0;
    vector<int> lis;
    rep(i, s.size()){
        if(i < s.size() - 1 && s[i] == 'B' && s[i + 1] == 'C'){
            lis.push_back(1);
            i++;
        }else if(s[i] == 'A'){
            lis.push_back(0);
        }else{
            lis.push_back(2);
        }
    }
    int cnt = 0;
    rep(j, lis.size()){
        if(lis[j] == 0){
            cnt++;
        }else if(lis[j] == 1){
            ans += cnt;
        }else{
            cnt = 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1532
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

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

    int A, B;
    cin >> A >> B;
    for(int i = B - A + 1; i < B + A; i++) {
        cout << i;
        if(i < A + B - 1)
            cout << " ";
    }
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

ll dp[22222];

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

	REP(i, 22222)dp[i] = LLINF;
	ll h, n;cin >> h >> n;

	vector<P> v(n);
	REP(i, n)cin >> v[i].FI >> v[i].SE;

	dp[0] = 0;
	for(int i = 1;i < 22222;i++){
		REP(j, n){
			if((i - v[j].FI) < 0)continue;
			dp[i] = min(dp[i], dp[i-v[j].FI] + v[j].SE);
		}
	}
	REV(i, 22222 - 1)dp[i] = min(dp[i], dp[i+1]);
	cout << dp[h] << endl;

	return 0;
}


Measured memory_bytes: 640
const main = lines => {
  console.log(solve(lines));
};

const solve = (lines: string[]): string => {
  const [N, A, B, C] = parseLines(lines);

  return A.reduce(
    (acc, cur) => {
      if (acc.prev + 1 === +cur) acc.sum += +C[+cur - 2];
      acc.prev = +cur;
      acc.sum += +B[+cur - 1];
      return acc;
    },
    { sum: 0, prev: -1 }
  ).sum.toString();
};

const parseLines = (lines: string[]) => {
  const obj = lines.map(e => e.split(' '));
  debug(obj);
  return obj;
};

const debug = (message?: any, ...optionalParams: any[]) => {
  if (!!process.env.LOCAL_DEBUG) console.log(message, ...optionalParams);
};

if (!process.env.LOCAL_DEBUG) {
  const { stdin: input, stdout: output } = process;
  input.resume();
  input.setEncoding('utf8');
  const lines = [];
  require('readline')
    .createInterface({ input, output })
    .on('line', line => lines.push(line))
    .on('close', () => main(lines));
}

export default solve;


Measured memory_bytes: 7628
import math
n,k = map(int,input().split())
li = list(map(int,input().split()))
li.reverse()
count = 0
#print(li)
for i,l in enumerate(li):
    if i != len(li)-1: 
        a = len(list(filter(lambda x:x > l, li[i+1:])))
        count += a

next_count = 0
#print(li)
for i,l in enumerate(li):
    a = len(list(filter(lambda x:x > l, li)))
    next_count += a
""" 
al = 0
for x in range(1,k+1):
    if x == 1:
        al += count
    else:
        al += count
        al += next_count*(x-1) """
#print(al)
all_count = (k+1)*(k)//2
#print(all_count-k,count,next_count)
al = (all_count-k)*(next_count)+k*count
print(al%(10**9+7))
#print(count,next_count)

Measured memory_bytes: 45916
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
    int N;
    cin >> N;
    N %= 10;
    if(N == 3)
    {
        cout << "bon" << endl;
    }
    else if(N==0 || N==1 || N==6 || N==8)
    {
        cout << "pon" << endl;
    }
    else
    {
        cout << "hon" << endl;
    }
    

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int main()
{
    long long int n, a[100010], b[100010];
    long long int cnt = 0;

    cin >> n;

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

    for (int i = n-1; i >= 0; i--) {
        if ((a[i]+cnt) % b[i]) {
            cnt += b[i] - (a[i]+cnt) % b[i];
        }
    }

    cout << cnt << endl;
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

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

  int num = -1;
  int ans;
  for(int i = 1;i<=n;i++){
    int tmp = 0;
    int k = i;
    while(k%2==0){
      k /= 2;
      tmp++;
      if(k==1||k==0) break;
    }
    num = max(tmp,num);
    if(num==tmp) ans = i;
  }

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


Measured memory_bytes: 3604
#include <iostream>
#include <string>

using namespace std;

int main() {
    int N;  cin >> N;
    char s;
    for (int i = 0; i < N; i++) {
        cin >> s;
        if (s == 'Y') {
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
    return 0;
}

Measured memory_bytes: 256
// B

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main(){
  int N;
  string s;
  cin>>N>>s;
  for (int i(0);i<s.size();i++){
    char a = s[i];
    int k = a - 'A';
    k += N;
    //cout << k;
    if (k >= 26) k-= 26;
    cout << (char)('A' + k);
    //cout << endl;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define x 1000000

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    map<int ,int>mp;
    mp[2]=1;mp[4]=1;mp[5]=1;mp[7]=1;mp[9]=1;mp[0]=2;mp[1]=2;
    mp[6]=2;mp[8]=2;mp[3]=3;
    if(mp[n%10]==1)cout<<"hon"<<endl;
    else if(mp[n%10]==2)cout<<"pon"<<endl;
    else if(mp[n%10]==3)cout<<"bon"<<endl;
    return 0;
}


Measured memory_bytes: 3660
N = gets.chomp.to_i
dp = []
last = -1
ans = 1
current = 1
N.times do |i|
    if dp.empty?
        dp << gets.chomp.to_i 
        next
    elsif (a = gets.chomp.to_i) <= dp[-1]
        dp << a
    else
        dp[dp.bsearch_index{|val| val < a}] = a
    end
end
puts dp.size

Measured memory_bytes: 2996
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <stack>
#include <queue>
#include <list>
#include <stdio.h>
#include <algorithm>
#define MAX 100000
using namespace std;
typedef long long ll;
ll w[100001],n,k;
ll maxmum(ll mid)
{
	ll i,j=0,sum=0;
	for(i=0;i<k;i++)
	{
		ll tmp=mid;
		while(j<n){
			tmp-=w[j];
			if(tmp>=0){
				j++;
				sum++;
				if(sum==n) return sum;
			}else{
				break;
			}
		}
	}
	return sum;
}//can't get real value of packages that could be uploaded before reaching the minimal value of p;
ll bin()
{
	ll left=0,right=100000*10000;
	ll mid;
	while(left<right){
		mid=(left+right)/2;
		if(maxmum(mid)>=n) right=mid;
		else left=mid+1;
	}
	return right;
}
int main(int argc, char *argv[]) {
	ll ans;
	scanf("%lld %lld",&n,&k);
	for(ll i=0;i<n;i++)
	{
		scanf("%lld",&w[i]);
	}
	ans=bin();
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 3988
#3.7.3 -> import math
from fractions import gcd

# [0,--list--,0]
N = int(input())
A = [0]+list(map(int,input().split()))+[0]
L = [0]*(N+2)
R = [0]*(N+2)
#0,A[1]->L[i-1],A[i]->L[N-1],A[N]
for i in range(1,N+1):
    L[i] =gcd(L[i-1],A[i])
#0,A[N]->R[i+1],A[i]->R[2],A[1]
for i in range(N,0,-1):
    R[i] = gcd(R[i+1],A[i])
#A[i]を含めないL,Rのgcdをすべて並べてmaxをとる
print(max(gcd(L[i-1],R[i+1]) for i in range(1,N+1)))


Measured memory_bytes: 16076
def fib(n):
    a, b = 0, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n-2):
            a, b = b, a + b
        return b
    
N, M = map(int, input().split())
a = [-1]
for i in range(M):
    a.append(int(input()))
    
for i in range(M-1):
    if a[i+1] == (a[i] + 1):
        print(0)
        exit()
    
combi = 1

for i in range(len(a)-1):
    dis = a[i+1] - a[i]
    #print(dis)
    combi *= fib(dis)
    #print(a[i])
    
dis = N+1 - a[-1]
#print(dis)
combi *= fib(dis)

print(combi % 1000000007)

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

// 💖 Hi, thanks for using ICIE! 💖
// 🔧 To use a custom code template, set it in Settings(Ctrl+,) in "Icie Template List" entry 🔧
// 📝 If you spot any bugs or miss any features, create an issue at https://github.com/pustaczek/icie/issues 📝

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s,t,u;
    int a,b;
    cin>>s>>t>>a>>b>>u;
    if(s==u)
        cout<<a-1<<" "<<b;
    else
        cout<<a<<" "<<b-1;
    return 0;
}



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

using namespace std;
using ll = long long;
const ll MOD = 1000000007;
bool is_prime[1001];

void factoring(vector<int> &result, int num) {
  if (is_prime[num]) {
    result.push_back(num);
  }
  for (int j = 2; j < num; ++j) {
    if (num % j == 0 and is_prime[j]) {
      result.push_back(j);
      factoring(result, num / j);
      break;
    }
  }
}

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

  // エラトステネスの篩で素数表を作る
  for (int i = 0; i < N + 1; ++i) {
    is_prime[i] = true;
  }
  for (int i = 2; i < N + 1; ++i) {
    int cout = i;
    if (is_prime[cout] == false) continue;
    while (cout < N + 1) {
      cout += i;
      is_prime[cout] = false;
    }
  }

  map<int, int> prime_fact;
  for (int i = 2; i < N + 1; ++i) {
    if (is_prime[i]) {
      auto itr = prime_fact.find(i);
      if (itr != prime_fact.end()) {
        prime_fact[i] += 1;
      } else {
        prime_fact[i] = 1;
      }
    } else {
      vector<int> result;
      factoring(result, i);
      for (auto j_prime : result) {
        auto itr = prime_fact.find(j_prime);
        if (itr != prime_fact.end()) {
          prime_fact[j_prime] += 1;
        } else {
          prime_fact[j_prime] = 1;
        }
      }
    }
  }

  ll ans = 1;
  for (auto itr = prime_fact.begin(); itr != prime_fact.end(); ++itr) {
    ans = (ans * (itr->second + 1)) % MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
// Author -> Preeyadarshee Dev
//
// train hard win easy :D
// nik is love
// nik is motivation
//
// do modulo operations very carefully
// try to avoid binary search, use linear search preferrably to make calculations easier
// always make your custom binary search and watch out for overflows
// read the problems carefully
// never rely on floating point calculation
#include<bits/stdc++.h>
#define mp                    make_pair
#define pb                    push_back
#define ll                    long long
#define ss                       second
#define ff                        first
#define fr(i,a,b)   for(ll i=a;i<b;i++)
#define f(i,n)                fr(i,0,n)
#define rf(i,b,a) for(ll i=b-1;i>=a;i--)
#define r(i,n)                rf(i,n,0)
#define inf                   998244353
#define eps                   0.000000000000001
#define sz(a)                int((a).size())
#define all(c)               (c).begin(),(c).end()
#define tr(c,i)              for(typeof(c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)         ((c).find(x) != (c).end())
#define cpresent(c,x)        (find(all(c),x) != (c).end())
#define pi                   pair<int,int>
#define pll                  pair < ll , ll >
#define endl                 '\n'
#define PI                   3.141592653589793238462643383279502884197169399375105820974944592307816406286
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef vector< int > vi;
typedef vector< vi > vvi;
int dx[8]={1,-1,0,0,-1,-1,1,1};
int dy[8]={0,0,-1,1,-1,1,-1,1};
vector<int> adj[200010],vis(200010,0),dis(200010,inf),fin(200010,0),col(200010,0),par(200010,0),v;
set<int> st[100010];
int myrandom (int i) { return std::rand()%i;}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //ifstream fin;
    //ofstream fout;
    //fin.open("input.txt");
    //fout.open("output.txt");
    int m,d;
    cin>>m>>d;
    int cnt=0;
    for(int i=1;i<=m;i++)
    {
        for(int j=22;j<=d;j++)
        {
            int num=j%10;
            int num1=j/10;
            num1=num1%10;
            if(num1*num==i&&num1>=2&&num>=2)
            {
                cnt++;
            }
        }
    }
    cout<<cnt<<endl;
}



Measured memory_bytes: 13568
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

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

	vector<int> value_list(1000, 0);

	for (int i = 1; i < 1000; i++)
	{
		value_list[i] = i + value_list[i - 1];
	}

	for (int i = 1; i < 499500; i++)
	{
		for (int j = 1; j < 1000 - 1; j++)
		{
			if (value_list[j] - i == a && value_list[j + 1] - i == b)
			{
				cout << i;
				return 0;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n;
ll INF = (1LL<<34);
P t[100];
ll dp[100][100];
 
P on(P x,P y){
  return P(x.first,y.second);
}
 
ll cost(P x,P y){
  return x.first*x.second*y.first*y.second;
}
 
int compute(int a,int b){
  ll A,B;
  if(dp[a][b]!=-1)return dp[a][b];
  if(a==b)return 0;
  
 
  ll res=INF;
  ll sum;
  P X,Y;
  for(int i=a;i<b;i++){
    X=on(t[a],t[i]);
    Y=on(t[i+1],t[b]);
     
    sum=cost(X,Y);
    sum = compute(a,i)+ sum +compute(i+1,b) ;
    res=(sum<res?sum:res);
 
  }
  dp[a][b]=res;
  return res;
}
 
int main(){
 
  while(cin>>n&&n){
    for(int i=0;i<n;i++)cin>>t[i].first>>t[i].second;
    for(int i=0;i<100;i++)for(int j=0;j<100;j++)dp[i][j]=-1;
    cout<<compute(0,n-1)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1244
N = int (input())
if N < 10:
  print (N)
elif N >=10 and N <100:
  print ("9")
elif N >=100 and N < 1000:
  print (N - 99 + 9)
elif N >= 1000 and N < 10000:
  print ("909")
elif N >=10000 and N < 100000:
  print (N - 9999 + 900 + 9)
elif N == 100000:
  print ("90909")

Measured memory_bytes: 3060
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return float(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()



def main():
	n,k=MI()
	mod=10**9+7

	f=[1]
	for i in range(1,n+10):
		f.append((f[-1]*i)%mod)
	finv=[]
	for i in f:
		finv.append(pow(i,mod-2,mod))

	ans=0
	for i in range(k+1):
		if n-i-1>=0:
			ans+=f[n]*finv[i]*finv[n-i]*f[n-1]*finv[i]*finv[n-i-1]
			ans%=mod
		else:
			break
	print(ans%mod)








if __name__ == "__main__":
	main()


Measured memory_bytes: 82636
#include <bits/stdc++.h>
using namespace std;
int main(){
    long n,sum=0,ans = LONG_MAX;
    cin >> n;
    long a[n],b[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum += a[i];
        b[i] = sum;
    } 
    for(int i=0;i<n-1;i++){
        if(abs(b[n-1]-2*b[i])<ans) ans = abs(b[n-1]-2*b[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a[3];
    int cnt5=0, cnt7=0;
    cin>>a[0]>>a[1]>>a[2];
    for(int i=0; i<3; i++){
        if(a[i]==5)
            cnt5++;
        else if(a[i]==7)
            cnt7++;
    }
    if(cnt5==2 && cnt7==1)cout<<"YES\n";
    else cout<<"NO\n";
    return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const int MAX_N = 212345;
vector<int> g[MAX_N];
bool grundy[MAX_N];

pair<int,int> dfs(int cur, int prev) {
  pair<int,int> res = {0, cur};
  for (int nxt : g[cur]) if (nxt != prev) {
    auto p = dfs(nxt, cur);
    p.first++;
    if (res.first < p.first) {
      res = p;
    }
  }
  return res;
}

int main2() {
  REP(i, MAX_N) g[i].clear();
  int N = nextInt();
  REP(i, N-1) {
    int a = nextInt() - 1;
    int b = nextInt() - 1;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  auto p1 = dfs(0, -1);
  auto p2 = dfs(p1.second, -1);

  if (grundy[p2.first + 1]) {
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }
  return 0;
}

int main() {
  grundy[0] = 0;
  grundy[1] = 1;
  grundy[2] = 0;
  for (int i = 3; i < MAX_N; i++) {
    grundy[i] = (grundy[i-1] == 0 || grundy[i-2] == 0) ? 1 : 0;
  }
#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 24192
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors


N = int(input())
ans = len(make_divisors(N-1)) - 1
divisors = make_divisors(N)
for i in range(1, len(divisors)):
    tmp = N
    d = divisors[i]
    while tmp%d == 0:
        tmp //= d
    if tmp % d == 1:
        ans += 1
print(ans)

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

using namespace std;

int main()
{
    vector<long long> v(3);
    cin >> v[0] >> v[1] >> v[2];
    
    sort(v.begin(), v.end());
    
    if(v[0] % 2 == 0 || v[1] % 2 == 0 || v[2] % 2 == 0) {
        cout << 0 << endl;
    }
    else {
        cout << v[0] * v[1] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main (){
  ll n;
  cin>>n;
  if(n==1||n==2){
    cout<<1<<endl;
    return 0;
  }
  vector<ll>c(n,0);
  for(ll i=0;i<n;i++){
    cin>>c[i];
    c[i]--;
  }
  vector<ll>dp(n,0);
  vector<ll>v(n,0);
  vector<ll>vv(n,-1);
  dp[n-1]=1;
  v[c[n-1]]=1;
  vv[c[n-1]]=n-1;
  for(ll i=n-2;i>=0;i--){
    if(v[c[i]]==0||vv[c[i]]-i==1){
      dp[i]=dp[i+1];
      v[c[i]]=dp[i];
    }
    else{
      dp[i]=dp[i+1]+v[c[i]];
      v[c[i]]=dp[i];
    }
    vv[c[i]]=i;
    dp[i]%=MOD;
    v[c[i]]%=MOD;
  }
  cout<<dp[0]<<endl;
}


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

bool pairCompare(pair<int, string> a, pair<int, string> b) {
        return a.first < b.first;

}

int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   long n, m;
   cin >> n >> m;
   vector<pair<long, string>> x(m);
   for(int i = 0;i < m;i++) {
      long a;
      string b;
      cin >> a >> b;
      x[i] = make_pair(a, b);
   }
   stable_sort(x.begin(), x.end(), pairCompare);
   // cout << "--------" << endl;
   // for(int i = 0;i < m;i++) {
   //    cout << x[i].first << " " << x[i].second <<endl;
   // }
   long ac_count = 0;
   long wa_count = 0;
   long flag_num = 0;
   long flag_ac = 0;
   long store_wa = 0;
   for(int i = 0;i < m;i++) {
      if(flag_num==x[i].first) {
         if(flag_ac==1) {

         } else {
            if(x[i].second=="AC") {
               ac_count++;
               flag_ac=1;
               wa_count += store_wa;
               store_wa = 0;
            } else {
               store_wa++;
            }
         }
      } else {
         flag_num = x[i].first;
         flag_ac = 0;
         store_wa = 0;
         i--;
      }
   }
   cout << ac_count << " " << wa_count << endl;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
#define ran 100010
#define int64 long long int
int n;
int64 w[ran], d[ran], k;
bool chk(int64 x,int64 tot){
	for(int i=0; i<n; i++)if(x>=w[i]){
		tot -= (x-w[i])/d[i]+1;
		if(tot <= 0)return true;
	}
	return false;
}
int main(){
	ios::sync_with_stdio(false);
	cin >> n >> k;
	for(int i=0; i<n; i++)cin >> w[i] >> d[i];
	int64 lo = 0, hi = (int64)2e18;
	while(lo != hi){
		int64 mi = (lo + hi)/2;
		if(chk(mi, k))
			hi = mi;
		else
			lo = mi+1;
	}
	cout << lo << endl;
	return 0;
}


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

int main(void){
    int N;
    cin >> N;
    int B[N-1];

    for(int i = 0; i < N - 1; i++){
        cin >> B[i];
    }

    int sum = B[0];
    for(int i = 0; i < N-2; i++){
        sum  += min(B[i], B[i+1]);
    }
    sum += B[N-2];
    cout << sum <<endl;
    
    return 0;

}

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


public class Main {
static int n;
static int[] c;
static int[][] a;
static int m;
static int x;
static final int INF = 999999999;
static int ans = INF;	

	public static void main(String[] args)  {
		Scanner sc = new Scanner(System.in);
		n = Integer.parseInt(sc.next());
		m = Integer.parseInt(sc.next());
		x = Integer.parseInt(sc.next());
		c = new int[n];
		a = new int[n][m];
		
		for(int i = 0; i < n ; i++) {
			c[i] = Integer.parseInt(sc.next());
			for(int j = 0 ; j < m ; j++) {
				a[i][j] = Integer.parseInt(sc.next());
			}
		}
		
		for(int i = 0; i < n ; i++) {
			ArrayList<Integer> list = new ArrayList<Integer>();
			list.add(i);
			permutation(list, i);
		}
		if(ans == INF)ans = -1;
		System.out.println(ans);
	 }

	
	public static void permutation(List<Integer> list ,int last) {
		if(list.size()>= n) {
			check(list);
			return;
		}else {
			check(list);
			for(int i = last+1 ; i < n ; i++) {
				List tmp = new ArrayList(list);
				tmp.add(i);
				permutation(tmp,i);
			}
		}
		return;
	}
	
	public static void check(List<Integer> list) {
		try {
		int[] mm = new int[m];
		int cc = 0;
		for(int i : list) {
			
			cc += c[i];
			for(int j = 0 ; j < m ; j++) {
				mm[j] += a[i][j];
			}
		}
		
		for(int i = 0; i < m ; i++) {
			if(mm[i] < x) {
				cc = INF;
			}
		}
		
		ans = Math.min(ans, cc);
		}catch (Exception e) {
			System.out.println();
		}
	}
	
	
}


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

int ans[26];
int main() {
  string s;
  cin >> s;
  for(int i=0;i<s.size();i++) {
    ans[s[i]-'a']=1;
  }
  
  for(int i=0;i<26;i++) {
    if(ans[i]==0) {
      cout << char('a'+i) << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
const int INF = 1e18;

signed main(){
    char a; cin >> a;
    if(a >= 'a')cout << 'a' << endl;
    else cout << 'A' << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch MultipleOf2019 | diff MultipleOf2019.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address MultipleOf2019.cpp && ./a.out

/*
 
 4/26/2020
 
 5:08-
 
 */

//const int MAX_N=1e6+1;
int N;
string S;

void solve() {
  N=SZ(S);
  int P=2019;
  vector<LL> cnt(P,0);
  cnt[0]=1;
  int cur=0;
  LL res=0;
  int pow10=1;
  for(int i=N-1; i>=0; --i) {
    cur=(pow10*(S[i]-'0')+cur)%P;
//    dump(i,cur,cnt[cur])
    res+=cnt[cur];
    cnt[cur]++;
    pow10=pow10*10%P;
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>S;
  solve();
  
  return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (auto &i:a) {
        cin >> i;
    }
    sort(begin(a), end(a));
    ll sum = 0;
    for (int i = 0; i < n - k; ++i) {
        sum += a[i];
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 1024
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
const int MAX_N =10010;
int d[MAX_N];//最短距離
struct edge{
	int from,to,cost;
	edge(int _from,int _to,int _cost){
		from =_from;
		to =_to;
		cost =_cost;
	}
};
vector<edge> es;//辺
int V,E;//頂点数と変数

void bellman(int s){
	for(int i =0;i <V;i++)d[i]=INF;
	d[s] = 0;
	while(true){
		bool update=false;
		for(int i =0;i <E;i++){
			edge e =es[i];
			if(d[e.from]!=INF&&d[e.to] >d[e.from] +e.cost){
				d[e.to] =d[e.from]+e.cost;
				update =true;
			}
		}
		if(!update)break;
	}
}
int main(){
	cin>>V;
	E = 0;
	for(int i =0;i < V;i++){
		int node,k;
		cin>>node>>k;
		for(int j =0;j <k;j++){
			int x,c;
			cin>>x>>c;
			es.push_back(edge(node,x,c));
			E++;
		}
	}
	bellman(0);
	for(int i=0;i < V;i++){
		cout <<i<<" "<<d[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 8420
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 100000

void push(int);
int pop();
int num[N],top=0;

int main(){
    char text[N];
    int a,b,s,i;
    while(1){
        s=scanf("%s",text);
        if(s==-1)
            break;
        if(text[0]>='0' && text[0]<='9'){
            push(atoi(text));
        }
        else if(text[0]=='+'){
            a=pop();
            b=pop();
            push(a+b);
        }
        else if(text[0]=='-'){
            b=pop();
            a=pop();
            push(a-b);
        }
        else if(text[0]=='*'){
            a=pop();
            b=pop();
            push(a*b);
        }
    }
    
    printf("%d\n",pop());
    return 0;
}

void push(int s){
    num[++top]=s;
}
int pop(void){
    top--;
    return num[top+1];
}




Measured memory_bytes: 2104
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

int main()
{
    //cout << fixed << setprecision(10);
    int N,M;
    cin >> N >> M;

    vector<vector<int>> g(N+1);
    rep(i,M){
        int A, B;
        cin >> A >> B;
        g[A].push_back(B);
        g[B].push_back(A);
    }

    vector<int> ans(N+1);
    fill(ans.begin(), ans.end(), -1);

    queue<int> q;
    q.push(1);
    
    while(!q.empty()){
        int n = q.front();
        q.pop();

        for(int x : g[n]){
            if(ans[x] == -1){
                ans[x] = n;
                q.push(x);
            }
        }
    }

    cout << "Yes" << endl;
    FOR(i, 2, N + 1)
    {
        cout << ans[i] << endl;
    }
}



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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

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

    cout << (abs(x-y) <= 1 ? "Brown" : "Alice") << endl;

    return 0;
}


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

#[fastout]
fn main() {
    input! {
        n: i64,
        a: i64,
        b: i64
    }

    let ans = n / (a + b) * a + min(n % (a + b), a);

    println!("{}", ans);
}


Measured memory_bytes: 2108
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    s = S()
    l = len(s)
    r = [[0]*4 for _ in range(l+1)]
    r[0][0] = 1
    for i in range(l):
        c = s[i]
        if c == 'A' or c == '?':
            r[i+1][0] += r[i][0]
            r[i+1][1] += r[i][1] + r[i][0]
            r[i+1][2] += r[i][2]
            r[i+1][3] += r[i][3]
        if c == 'B' or c == '?':
            r[i+1][0] += r[i][0]
            r[i+1][1] += r[i][1]
            r[i+1][2] += r[i][2] + r[i][1]
            r[i+1][3] += r[i][3]
        if c == 'C' or c == '?':
            r[i+1][0] += r[i][0]
            r[i+1][1] += r[i][1]
            r[i+1][2] += r[i][2]
            r[i+1][3] += r[i][3] + r[i][2]
        for j in range(4):
            r[i+1][j] %= mod


    return r[-1][3]


print(main())


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

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);

  int n, w;cin >> n >> w;
  int arr[n+1][2];
  arr[0][0] = 0;
  arr[0][1] = 0;

  for(int i =0 ; i< n ; i++){
    cin>>arr[i+1][0] >> arr[i+1][1]; 
  }
  vector<vector<long long>> dp(n+1, vector<long long>(w+1,0));

  for(int i=1; i<n+1;i++){
    for(int j=1;j<w+1; j++){
      if(j-arr[i][0]>=0){
        dp[i][j] = max(dp[i-1][j], dp[i-1][j-arr[i][0]] + arr[i][1]);
      }
      else
        dp[i][j] = dp[i-1][j]; 
    }
  }
  cout<<dp[n][w];
  return 0;
}



Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

const i64 mod = 1e9 + 7;

template<const i64 N, const i64 M>
struct matrix {
  using T = i64;
  vector<vector<T>> mat;
  matrix(T init = T()): mat(N, vector<T>(M, init)) {}
  vector<T>& operator[](i64 i) { return mat[i]; }
  const vector<T>& operator[](i64 i) const { return mat[i]; }
  static matrix<N, N> E() {
    matrix<N, N> mat(0);
    rep(i,0, N) mat[i][i] = 1;
    return mat;
  }
};
template<const i64 L, const i64 M, const i64 N>
matrix<L, N> operator*(const matrix<L, M>& lm, const matrix<M, N>& rm) {
  matrix<L, N> ret;
  rep(i, 0, L) rep(j, 0, M) rep(k, 0, N) (ret[i][k] += lm[i][j] * rm[j][k]) %= mod;
  return ret;
}

template<const i64 N>
matrix<N, N> matrix_pow(matrix<N, N> mat, i64 r) {
  matrix<N, N> ret = matrix<N, N>::E();
  while(r > 0) {
    if(r & 1) ret = ret * mat;
    mat = mat * mat;
    r >>= 1;
  }
  return ret;
}

int main() {
  i64 N, K;
  cin >> N >> K;
  matrix<50, 50> mat;
  rep(i,0,N) rep(j, 0, N) {
    i64 a;
    cin >> a;
    mat[i][j] = a;
  }
  matrix<1, 50> base(1);
  auto res = (base * matrix_pow(mat, K));
  i64 ans = 0;
  for(auto x: res[0]) {
    ans = (ans + x) % mod;
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int D; cin >> D;
    vector C(26, 0);
    rep(i,26) cin >> C.at(i);
    vector S(D, vector(26, 0));
    rep(i, D) rep(j, 26) cin >> S[i][j];
    vector last(26, 0);
    rep(d,D) {
        int ma = 0;
        int maj = 0;
        rep(j, 26) {
        int sat = 0;
        int keep = last[j];
            last[j] = d + 1;
            rep(i,26) sat -= (d + 1 - last[i]) * C[i];
            sat += S[d][j];
            if (ma < sat) {
                ma = sat;
                maj = j;
            }
            last[j] = keep;
        }
        cout << maj + 1 << endl;
        last[maj] = d + 1;
    }
}

Measured memory_bytes: 3680
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//CODE

void solve(void)
{
  int K;
  cin>>K;
  int vec[32] ={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout<<vec[K-1]<<endl;
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 256
n, a, b = list(map(int, input().split()))
total = 0

for i in range(1,n + 1):
    length = len(str(i)) # iの桁数
    ele = []
    # 各桁の和
    l = str(i)
    array = list(map(int, l))
    s = sum(array)
    if a <= s and s <= b:
        total += i
print(total)


Measured memory_bytes: 9112