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

int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i = 0; i < N; i++) cin >> d[i];
    sort(d.begin(), d.end());

    int answer = d[N/2] - d[N/2-1];
    cout << answer << endl;
    return 0;

}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long M = sc.nextLong();
        long ans = 0;
        if (N == 1 && M == 1) {
            ans = 1;
        } else if (N == 1 && M != 1 ) {
            ans = M - 2 ;
        } else if (N != 1 && M == 1) {
            ans = N - 2;
        } else {
            ans = (N - 2) * (M - 2) ;
        }
        System.out.println(ans);
    }

}

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

int main() {
        int m, h, i, j, k, x;
        string str, str1, str2;
        for (k = 0; k < 100; k++) {
                cin >> str;
                if (str == "-") break;
                cin >> m;
                h = 0;
                for (i = 0; i < m; i++) {
                        cin >> j;
                        h += j;
                }
                x = h % str.size();
                str1 = str.substr(0, x);
                str2 = str.substr(x, str.size());
                str = str2 + str1;
                cout << str << endl;
        }
        return 0;
}

Measured memory_bytes: 3144
#include <stdio.h>
 
int main(void){
	double v,t,y,n1;
	int n;
	while(scanf(" %lf",&v)!=EOF){
    	t=v/9.8;
    	y=4.9*t*t;
    	n=0;
    	n1=(5+y)/5;
    	while(n<n1){
    		n=n+1;
    	}
		printf("%d\n",n);
    }
	return 0;
}

//debug for alfa

Measured memory_bytes: 628
import Data.List

main :: IO ()
main  = getContents
    >>= return . map (map (read :: String -> Int)) . map words . lines
    >>= return . takeWhile (/= [0,0])
    >>= return . map sort
    >>= return . map (\ [x,y] -> show x ++ " " ++ show y)
    >>= mapM_ putStrLn

Measured memory_bytes: 4568
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int w, a, b, ans;
  cin >> w >> a >> b;
  if (a < b) ans = b - a - w;
  else ans = a - b -w;
  if (ans > 0) cout << ans << endl;
  else cout << 0 << endl;
  return 0;
}

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

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#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__)


int main(){
    int n,c;
    cin>>n>>c;
    int d[c][c];
    rep(i,c) rep(j,c) cin>>d[i][j];
    vector<int> th[3];
    rep(i,n) rep(j,n){
        int tmp;
        cin>>tmp;
        th[(i+j)%3].push_back(--tmp);
    }
    int changed[3][c];
    rep(i,3){
        rep(j,c){
            int tmp=0;
            for(auto au:th[i]){
                tmp+=d[au][j];
            }
            changed[i][j]=tmp;
        }
    }
    int ans=1000000000;
    rep(i,c){
        rep(j,c){
            rep(k,c){
                if(i==j||j==k||k==i)continue;
                chmin(ans,changed[0][i]+changed[1][j]+changed[2][k]);
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1520
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int N,a;
vector<vector<int>> u(100010);



int dfs(int n){
	int c = 0;
	if(u[n].size()==0) return 0;
	vector<int> dp;
	for(int i=0;i<u[n].size();i++){
		dp.push_back(dfs(u[n][i]));
	}
	sort(dp.begin(),dp.end());
	reverse(dp.begin(),dp.end());
	for(int i=0;i<dp.size();i++){
		c = max(c,dp[i]+i+1);
	}	
	return c;
}



int main(){
	cin >> N;
	for(int i=2;i<=N;i++){
		cin >> a;
		u[a].push_back(i);
	}
	cout << dfs(1) << endl;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long ll;

ll gcd(ll x, ll y){
  if(y == 0) return x;
  return gcd(y, x % y);
}

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

  ll ans = a*b/gcd(a,b);

  cout << ans << endl;
}

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

using namespace std;

int main()
{
    long long n, k;
    cin >> n >> k;

    vector<pair<long long, long long>> sushi(n);

    for (auto &u : sushi)
        cin >> u.second >> u.first;

    priority_queue<pair<long long, long long>> plate;
    unordered_map<long long, long long> count;
    long long current = 0;

    // Take all but the most delicious sushis of each type (in first k)
    sort(sushi.rbegin(), sushi.rend());

    long long i;
    for (i = 0; i < k; i++)
    {
        current += sushi[i].first;

        if (count[sushi[i].second])
            plate.push({-sushi[i].first, sushi[i].second});
        count[sushi[i].second]++;
    }
    long long totalTypes = count.size();
    current += totalTypes * totalTypes;

    vector<long long> answer;
    answer.push_back(current);

    while (!plate.empty() and i < n)
    {
        // Improvement comes only by taking a different type
        if (!count[sushi[i].second])
        {
            current -= totalTypes * totalTypes;
            current += plate.top().first;
            plate.pop();

            totalTypes++;
            current += sushi[i].first + totalTypes * totalTypes;
            count[sushi[i].second]++;
            answer.push_back(current);
        }
        i++;
    }

    cout << *max_element(answer.begin(), answer.end()) << endl;

    return 0;
}

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

int maxprofit( int arr[][3] , int n){
    int dp[n][3] ;
     int maxans = INT_MIN ;
       for( int j = 0 ; j<3 ; j++){
           dp[0][j] = arr[0][j] ; 
           maxans = max( maxans , dp[0][j]) ;
       }
  
 // int maxans = INT_MIN ;
  for( int i = 1 ; i< n ; i++ ){
      for( int j = 0 ; j< 3 ; j++){
          dp[i][j] = arr[i][j] + max( dp[i-1][(j+1)%3] , dp[i-1][(j+2)%3] ) ;
          maxans = max( maxans , dp[i][j]) ;
      }
  }

  return maxans ;
}

int main(){
   int n ;
   cin>> n ;
   int arr[n][3] ;
   for( int i = 0 ;i< n ; i++ ){
       for( int j = 0 ;j<3 ; j++){
       cin>>arr[i][j] ;
       }
   }

cout<<maxprofit( arr , n )<<endl ;
return 0 ;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  
  if (N <= K) {
   	cout << 0 << endl; 
    return 0;
  }

  vector<int> H(N);
  for (int i = 0; i < N; i++) {
  	cin >> H.at(i);
  }
  sort(H.begin(),H.end(),std::greater<int>());
  for (int i = 0; i < K; i++) {
    H.at(i) = 0;
  }
  long S=0;
  for (int i = 0; i < N; i++) {
  	S += H.at(i);
  }
  cout << S << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

const int nmax = 200100;
int N;
int a[nmax];
int b[nmax];

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

void solve(){
    sort(a, a  + N);
    int l = (N + 1) / 2 - 1;
    for(int i = 0 ; i < N; ++i)
    {
        if(b[i] <= a[l]) 
            cout << a[l+1] << endl;
        else
            cout << a[l] << endl;
    }
}

int main(){
    read();
    solve();
}

Measured memory_bytes: 3712
import numpy as np
H ,W = map(int,input().split())

maze = [[] for _ in range(H)]
for i in range(H):
    maze[i] = np.array(list(input())) == "."
maze = np.array(maze)

up = np.zeros((H, W), dtype=int)
down = np.zeros((H, W), dtype=int)
right = np.zeros((H, W), dtype=int)
left = np.zeros((H, W), dtype=int)

for i in range(H):
    up[i] = (up[i-1] + 1)*maze[i]
    down[-(i+1)] = (down[-i] + 1)*maze[-(i+1)] 
    
#print(up)
#print(down)

for i in range(W):
    right[:, i] = (right[:, i-1] + 1)*maze[:, i]
    left[:, -(i+1)] = (left[:, -i] + 1)*maze[:, -(i+1)]

print(np.max(up+down+right+left)-3)


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

int main() {
	int d;
	cin >> d;
	const int n = 26;
	vector<int> c(n);
	vector<vector<int>> s(d, vector<int>(n));
	rep(i, n) cin >> c[i];
	rep(i, d) rep(j, n) cin >> s[i][j];
	vector<int> t(d), last(n);
	
	// 貪欲
	ll ans = 0;
	rep(i, d) {
		ll mx = -1001001001;
		int now = 0;
		
		rep(j, n) {
			ll tmp = ans;
			tmp += s[i][j];
			rep(k, n) {
				if(j == k) continue;
				tmp -= c[k] * (i+1-last[k]);
			}
			if(mx < tmp) {
				mx = tmp;
				now = j;
			}
		}
		ans = mx;
		last[now] = i+1;
		t[i] = now+1;
	}
	int cnt = 0;
	while(1) {
		// 局所探索法
		cnt++;
		if(cnt > 200000) break;
		vector<int> old = t;
		const int CH = 10; // 10箇所変える
		rep(i, CH) {
			int nd = rand()%d;
			int nq = rand()%n + 1;
			t[nd] = nq;	
		}
		
		// 点数のシミュレーション
		vector<int> nlast(n);
		ll now = 0;
		rep(i, d) {
			now += s[i][t[i]];
			nlast[t[i]-1] = i+1;
			rep(j, n) {
				now -= c[j] * (i+1-nlast[j-1]);
			}
		}
		
		// 良くなれば更新
		if(now > ans) {
			ans = now;
		} else {
			t = old;
		}
	}
	
	rep(i, d) printf("%d\n", t[i]);
	return 0;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int n, k;

vector<pair<ll, int>> td;

map<int, int> mp;

priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pque;

vector<ll> ans;

int main(void) {
  // Here your code !

  scanf("%d %d", &n, &k);

  for (int i = 0; i < n; ++i) {
    int t;
    ll d;
    scanf("%d %lld", &t, &d);

    td.push_back(make_pair(d, t));
  }

  sort(td.begin(), td.end(), greater<pair<ll, int>>());

  ll tmp_sum = 0;

  for (int i = 0; i < k; ++i) {
    mp[td[i].second] += 1;
    if (mp[td[i].second] > 1) {
      pque.push(make_pair(td[i].first, td[i].second));
    }
    tmp_sum += td[i].first;
  }

  ans.push_back(tmp_sum + pow(mp.size(), 2));

  for (int i = k; i < n; ++i) {
    if (mp.find(td[i].second) == mp.end() && !pque.empty()) {
      pair<ll, int> e = pque.top();
      pque.pop();

      mp[e.second] -= 1;
      tmp_sum -= e.first;

      mp[td[i].second] += 1;
      tmp_sum += td[i].first;

      ans.push_back(tmp_sum + powl(mp.size(), 2));
    }
  }

  ll last_ans = *max_element(ans.begin(), ans.end());

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

  return 0;
}


Measured memory_bytes: 5744
#include<bits/stdc++.h>
#define ll long long
#define pb emplace_back
#define mr make_pair
#define N 300010
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
struct Info{int x,y;}a[N];
struct seg{int l,r,ma,ta;}t[N*4];
int w,h,n,n1,n2,ans,s1[N],s2[N];
bool c1(const Info &a,const Info &b){return a.y<b.y;}
void build(int nu,int l,int r){
	t[nu].l=l;t[nu].r=r;t[nu].ta=0;t[nu].ma=-a[l].y;
	if (l!=r){build(nu*2,l,(l+r)/2);build(nu*2+1,(l+r)/2+1,r);}
}
void add(int nu,int l,int r,int x){
	if (l>r) return ;
	if (t[nu].l==l&&t[nu].r==r){t[nu].ta+=x;t[nu].ma+=x;return ;}
	int mid=(t[nu].l+t[nu].r)/2;
	if (l<=mid) add(nu*2,l,min(mid,r),x);
	if (r>mid) add(nu*2+1,max(mid+1,l),r,x);
	t[nu].ma=max(t[nu*2].ma,t[nu*2+1].ma)+t[nu].ta;
}
void getans(){
	sort(a+1,a+n+1,c1);
	build(1,1,n);n1=0,n2=0;
	for (int i=1;i<=n;i++){
		if (i>1)add(1,i-1,i-1,w);
		ans=max(ans,(a[i].y+t[1].ma)*2);
		if (a[i].x<=w/2){
			if (n1==0)add(1,1,i-1,-a[i].x);
			else add(1,s1[n1],i-1,-a[i].x);
			while (n1>0&&a[s1[n1]].x<a[i].x){add(1,max(1,s1[n1-1]),s1[n1]-1,-a[i].x+a[s1[n1]].x);n1--;}
			s1[++n1]=i;
		}else{
			if (n2==0)add(1,1,i-1,a[i].x-w);
			else add(1,s2[n2],i-1,a[i].x-w);
			while (n2>0&&a[s2[n2]].x>a[i].x){add(1,max(1,s2[n2-1]),s2[n2]-1,a[i].x-a[s2[n2]].x);n2--;}
			s2[++n2]=i;
		}
	}
}
int main(){
	read(w);read(h);read(n);
	for (int i=1;i<=n;i++){read(a[i].x);read(a[i].y);}
	n+=2;a[n]={w,h};a[n-1]={0,0};
	getans();
	for (int i=1;i<=n;i++)swap(a[i].x,a[i].y);swap(w,h);
	getans();
	cout<<ans<<endl;
	return 0;
}

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

int64_t INF = 0; // 2^31-1

vector<int64_t> value; // ノードの値を持つ配列
int n = 1;           // 葉の数

void update(int64_t i, int64_t x) {
  // i 番目の葉の値を x に変える
  i += n - 1; // i 番目の葉のノード番号[1-index]
  value[i] = x;
  while (i > 0) {
    i = (i - 1) / 2; // ノード i の親ノードの番号に変える
    value[i] = max(value[i * 2 + 1],
                   value[i * 2 + 2]); // 左右の子の min を計算しなおす
  }
}

int64_t query(int a, int b, int k, int l, int r) { //a,b,0,0,n
  // [a, b) の区間に対するクエリについて
  // ノード k （区間 [l, r) 担当）が答える
  if (r <= a || b <= l) return INF; // 区間が被らない場合は INF を返す
  if (a <= l && r <= b)
    return value[k]; // ノード k の担当範囲がクエリ区間 [a, b)
  // に完全に含まれる
  else {
    int64_t c1 = query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子に値を聞く
    int64_t c2 = query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子に値を聞く
    return max(c1, c2); // 左右の子の値の min を取る
  }
}


int main(){
  int N;
  cin >> N;
  vector<int> H(N);
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> H[i];
  }
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  //初期化
  while (n < N) n *= 2; // 葉の数を計算（n以上の最小の2冪数）
  value = vector<int64_t>(2 * n - 1, INF);
  
  vector<int64_t> ans(N,0);
  
  
  for(int i=0; i<N; i++){
    ans[i] = A[i] + query(0,H[i],0,0,n);
    update(H[i]-1,ans[i]);
    /*for(int i=0; i<=2*n-1; i++){
      cout << value[i] << " ";
    }
    cout << endl;
    cout << ans[i] << endl;*/
  }
  
  
  cout << *max_element(ans.begin(),ans.end()) << endl;
}
    

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

int main(){
	int n, r;
	int card[4][14];
	char M;
	for(int i = 0; i < 4; i++){
		for(int j = 1; j < 14; j++){
			card[i][j] = 0;
		}
	}
	cin >> n;
	for(int m = 0; m < n; m++){
		cin >> M >> r;
		if(M == 'S') card[0][r] = 1;
		if(M == 'H') card[1][r] = 1;
		if(M == 'C') card[2][r] = 1;
		if(M == 'D') card[3][r] = 1;
	}
	for(int i = 0; i < 4; i++){
		for(int j = 1; j < 14; j++){
			if(card[i][j] == 1) continue;
			if(i == 0) M = 'S';
			if(i == 1) M = 'H';
			if(i == 2) M = 'C';
			if(i == 3) M = 'D';
			cout << M << " " << j << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>

int main() {
    int h, w;
    std::vector<std::string> sv;
    std::cin >> h >> w;
    for (int i = 0; i < h; ++i) {
        std::string tmp;
        std::cin >> tmp;
        sv.push_back(tmp);
    }
    std::vector<int> dx = {1,0,-1,0};
    std::vector<int> dy = {0 ,-1, 0, 1};
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if(sv[i][j] == '#'){
                bool can = false;
//                std::cerr << i << ',' << j << '\n';
                for (int k = 0; k < 4; ++k) {
                    if(i+dx[k] < h && i+dx[k] >= 0 && j+dy[k] < w && j+dy[k] >=0){
                       if(sv[i+dx[k]][j+dy[k]] == '#'){
//                           std::cerr << i+dx[k] << ',' << j+dy[k] <<  ':' << k << "ads\n";
                           can = true;
                           continue;
                       }
                    }
                }
                if(!can){
                    std::cout << "No\n";
                    return 0;
                }
            }
        }
    }
    std::cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sys/time.h>
using namespace std;

int memo[100] = {0};

int fibo(int n){//メモ化再帰を用いて再計算を防ぎ、再帰計算速度を上げる
    if(memo[n] != 0) return memo[n];
    if(n == 0 || n == 1) return 1;
    memo[n] = fibo(n - 1) + fibo(n - 2);
    return memo[n];
}

int main(void){
    int n;
    cin >> n;
    fibo(n);
    cout <<  fibo(n) << endl;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
int main(){
int64_t X,Y;
  cin>>X>>Y;
  int64_t x=Y/X;
  int64_t sum=1;
  int ans=0;
  for(int i=0;sum<=x;i++){
  ans++; sum*=2;
  }cout<<ans<<endl;
   return 0;
  
}



Measured memory_bytes: 256
<?php
	$n = trim(fgets(STDIN));
	$nyukyo = array_fill(0, 4, array_fill(0, 3, array_fill(0, 10, 0)));

	for ($i = 0; $i < $n; $i++) {
		$line = trim(fgets(STDIN));
		$arr = explode(" ", $line);

		$nyukyo[$arr[0]-1][$arr[1]-1][$arr[2]-1] += $arr[3];
	}

	for ($i = 0; $i < 4; $i++) {
		for ($j = 0; $j < 3; $j++) {
			echo " " . implode(" ", $nyukyo[$i][$j]) . "\n";
		}

		if ($i < 4-1) echo str_repeat("#", 20) . "\n";
	}

Measured memory_bytes: 6624
k, n = map(int,input().split())
A = list(map(int,input().split()))
for i in range(n):
    A.append(A[i]+k)
P = [A[1]-A[0]]
"""B = []
for x in range(1,n):
    B.append("""

for i in range(2, 2*n):
    P.append(P[i-2]+(A[i]-A[i-1]))
#print(P)
'''
i = n-1
while True:
    sm -= A[i]-A[i-1]
    sm += A[(i+1)%n]-A[i]'''
mn = 10000000000000
for i in range(n):
    if i > 0:
        mn = min(mn, P[i+n-1]-P[i])
    else:
        mn = min(mn, P[i+n-1])
print(mn)


Measured memory_bytes: 38676
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
	vector<double> h;
	double n;

	while( scanf("%lf", &n) != EOF ){
		h.push_back(n);
	}
	sort( h.begin() , h.end() );
	int i = h.size()-1;
	printf("%.1f\n", h[i]-h[0]);
	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll A, B, K;
    cin >> A >> B >> K;
    ll t = min(A, K);
    A -= t;
    if (A == 0) {
        K -= t;
        B -= min(B, K);
    }
    cout << A << ' ' << B << endl;
}

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


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<unordered_map>
#define lli long long int
using namespace std;

int main() {
	// your code goes here
	lli n,temp;
	cin>>n;
	string s;
	// cin>>s;
	
	unordered_map<lli,lli> v1;
	for(lli i=0;i<n;i++){
		cin>>temp;
		v1[temp]++;
	}
	for(auto x:v1){
		if(x.second>1){
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES";
	return 0;
}

Measured memory_bytes: 8520
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359
LL solve(int nokori, int sum, int goal){
	if(nokori == 0){
		if(goal == sum%2) return 1;
		else return 0;
	}
	return solve(nokori-1,sum,goal) + solve(nokori-1,sum+1,goal);
}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	int N,P;
	int ki = 0;
	int gu = 0;
	cin >> N >> P;
	for(int i=0; i<N; i++){
		int A;
		cin >> A;
		if(A%2 == 0) gu++;
		else ki++;
	}
	
	cout << ((LL)1<<gu) * solve(ki,0,P) << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
class A{
    static void Main(string []args){
        string []t=Console.ReadLine().Split(' ');
        long A=long.Parse(t[0]);
        long B=long.Parse(t[1]);
        long C=long.Parse(t[2]);
        ulong K=ulong.Parse(t[3]);
        if(A==B){
                Console.WriteLine(0);
                return;
        }else if(K==0){
            Console.WriteLine(A-B);
        }else if(Math.Abs(A-B)>Math.Pow(10,18)){
            Console.WriteLine("Unfair");
            return;
        }else if(K%2==0){
            Console.WriteLine(A-B);
        }else if(K%2!=0){
            Console.WriteLine(B-A);
        }
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=998244353;
const int MAX=1e5+10;
const ll INF=1e18;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<P> p(n);
    rep(i,n) {
        p[i].second = i;
        cin >> p[i].first;
    } 
    sort(p.begin(),p.end());
    rep(i,n) cout << p[i].second+1 << ' ';
    cout << endl;

    return 0;   
}

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

int main()
{
    int y, m, d;
    scanf("%d/%d/%d", &y, &m, &d);
    if (y < 2019 || y == 2019 && m < 4 || y == 2019 && m == 4 && d <= 30)
        cout << "Heisei" << endl;
    else
        cout << "TBD" << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n,q=map(int,input().split())
s=str(input())

t=[0]*n
for i in range(n-1):
        t[i+1]=t[i]+(1 if s[i:i+2]=='AC' else 0)
for j in range(q):
        l,r=map(int,input().split())
        print(t[r-1]-t[l-1])

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

int ans = 0;

int isCompSeq(int N, int* seq) {
    for(int i=0;i<N;i++) {
        if(seq[i] == 0) {
            return 0;
        }
    }

    return 1;
}

void copySeq(int N, int* seq, int* ne) {
    for(int i=0;i<N;i++) {
        ne[i] = seq[i];
    }
}

void printSeq(int N,int* seq) {
    for(int i=0;i<N;i++) {
        printf("%d,", seq[i]);
    }

    printf("\n");
}

void judge(int N, int* edge, int s, int* seq) {
//  printSeq(N, seq);

    if(isCompSeq(N, seq)) {
        ans++;
        return;
    }

    int* ne;
    for(int i=0;i<N;i++) {
        if(edge[i*N + s] && seq[i] == 0) {
            ne = (int*)malloc(sizeof(int)*N);
            copySeq(N, seq, ne);
            ne[i] = 1;
            judge(N, edge,i,ne);
            free(ne);
        }
    }
}


int main() {

    int N,M;

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

    int edge[N*N];

    for(int i=0;i<N;i++) {
        for(int t=0;t<N;t++) {
            edge[i*N+t] = 0;
        }
    }

    int a,b;
    for(int i=0;i<M;i++) {
        scanf("%d %d", &a, &b);
        edge[(b-1)*N+(a-1)] = 1;
        edge[(a-1)*N+(b-1)] = 1;
    }

    int* seq;
    for(int i=0;i<N;i++) {
        if(edge[i*N + 0]) {
            seq = (int*)malloc(sizeof(int)*N);
            for(int t=0;t<N;t++) {
                seq[t] = 0;
            }
            seq[0] = 1;
            seq[i] = 1;
            judge(N, edge, i, seq);
            free(seq);
        }
    }

    printf("%d\n", ans);

    return 0;
}


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

using namespace std;
using ll = long long;
using indx = size_t;

int main() {
    int n, m;
    cin >> n >> m;
    ll a = n/2;
    ll b = a + 1;
    while(m) {
        m--;
        if (n == 2*(b-a) or n == 2*(b-a-1))
            b++;
        cout << a << " " << b << endl;
        a--, b++;
    }
}


Measured memory_bytes: 3640
#ifndef ___CLASS_MODINT
#define ___CLASS_MODINT

#include <cstdint>

template<std::uint32_t mod>
class modint {
private:
	std::uint32_t n;
public:
	modint() : n(0) {};
	modint(std::uint64_t n_) : n(n_ % mod) {};
	bool operator==(const modint& m) const { return n == m.n; }
	bool operator!=(const modint& m) const { return n != m.n; }
	std::uint32_t get() const { return n; }
	modint& operator+=(const modint& m) { n += m.n; n = (n < mod ? n : n - mod); return *this; }
	modint& operator-=(const modint& m) { n += mod - m.n; n = (n < mod ? n : n - mod); return *this; }
	modint& operator*=(const modint& m) { n = std::uint64_t(n) * m.n % mod; return *this; }
	modint operator+(const modint& m) const { return modint(*this) += m; }
	modint operator-(const modint& m) const { return modint(*this) -= m; }
	modint operator*(const modint& m) const { return modint(*this) *= m; }
	modint binpow(std::uint64_t b) const {
		modint ans = 1, m = modint(*this);
		while (b) {
			if (b & 1) ans *= m;
			m *= m;
			b >>= 1;
		}
		return ans;
	}
	modint inv() { return (*this).binpow(mod - 2); }
};

#endif // ___CLASS_MODINT

#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
using modulo = modint<1000000007>;
int main() {
	int N;
	cin >> N;
	vector<int> A(N), B(N);
	int la = 0, lb = 0;
	for (int i = 0; i < N; ++i) {
		cin >> A[i] >> B[i];
		la = max(la, A[i]);
		lb = max(lb, B[i]);
	}
	vector<vector<modulo> > dp(la + 1, vector<modulo>(lb + 1)), comb(la * 2 + 1, vector<modulo>(lb * 2 + 1));
	comb[0][0] = 1;
	for (int i = 0; i <= la * 2; ++i) {
		for (int j = 0; j <= lb * 2; ++j) {
			if (i >= 1) comb[i][j] += comb[i - 1][j];
			if (j >= 1) comb[i][j] += comb[i][j - 1];
		}
	}
	for (int i = 0; i < N; ++i) {
		dp[A[i]][B[i]] += 1;
	}
	for (int i = la; i >= 1; --i) {
		for (int j = lb; j >= 1; --j) {
			dp[i - 1][j] += dp[i][j];
			dp[i][j - 1] += dp[i][j];
		}
	}
	modulo ans = 0;
	for (int i = 1; i <= la; ++i) {
		for (int j = 1; j <= la; ++j) {
			ans += dp[i][0] * dp[j][0];
		}
	}
	for (int i = 1; i <= lb; ++i) {
		for (int j = 1; j <= lb; ++j) {
			ans += dp[0][i] * dp[0][j];
		}
	}
	for (int i = 1; i <= la; ++i) {
		for (int j = 1; j <= lb; ++j) {
			ans += dp[i][0] * dp[0][j] * comb[i][j] * 2;
		}
	}
	for (int i = 0; i < N; ++i) {
		ans -= comb[A[i] * 2][B[i] * 2];
	}
	ans *= modulo(2).inv();
	cout << ans.get() << endl;
	return 0;
}

Measured memory_bytes: 80256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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;}

const ll INF=1e9+7;


int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    if(a==b && b==c) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3472
#![allow(non_snake_case)]

use std::cmp::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    }
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

const INF: i64 = 1 << 60;

fn main() {
    input!{
        N: usize,
        h: [i64; N],
    }
    let mut dp = vec![INF; N];
    dp[0] = 0;
    for i in 1..N {
        let cost_1 = (h[i] - h[i-1]).abs();
        dp[i] = min(dp[i], dp[i-1] + cost_1);
        if i-1 > 0 {
            let cost_2 = (h[i] - h[i-2]).abs();
            dp[i] = min(dp[i], dp[i-2] + cost_2);
        }
    }
    println!("{}", dp[N-1]);
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int r, g, b, target;
    cin >> r >> g >> b >> target;
    int ans = 0;
    for(int i = 0; i <= 3000; i++) {
        for(int j = 0; j <= 3000; j++) {
            int curr = (r * i) + (g * j);
            if(curr > target)
                break;
            if((target - curr) % b == 0)
                ans++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 3580
S=input()
T="keyence"
X,Y=0,0
for i in range(7):
  if(S[i]==T[i]):
    X+=1;
  else:
    break
for i in range(7):
  if(S[len(S)-1-i]==T[6-i]):
    Y+=1;
  else:
    break
if(X+Y>=7):
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    public static void main(final String... args) {
        final String mode = "a";

        if (mode.equals("a")) {
            A.solve();
        }
    }
}

class A {
    static void solve() {
        final Scanner sc = new Scanner(System.in);
        final int r = sc.nextInt();
        final int res = calc(r);
        System.out.println(res);
    }

    static int calc(final int r) {
        return 3 * r * r;
    }
}

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

int main(void){
    int x,b,p,i,ans1000;
    i = 1;
    vector<int>  bekilist(1000,1001);
    bekilist.at(0) = 1;
    cin >> x;

    //list up
    for(b=2; b<33; b++){
        for(p=2; pow(b,p) <= 1000; p++){
            bekilist.at(i) = pow(b,p);
            i++;
        }
    }
    sort(bekilist.begin(),bekilist.end());

    //included x < 1000
    for(i=0; bekilist.at(i) <= 1000; i++){
        if(bekilist.at(i) > x){
            cout << bekilist.at(i-1) << endl;
            break;
        }
    }

    //x = 1000
    if(x == 1000){
        for(i=0; bekilist.at(i) != 1001; i++){
            ans1000 = bekilist.at(i);
        }
        cout << ans1000 << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

using T = ll;
const int MAX_V = 5e5;
//演算の内容
T f(T a, T b){return min(a, b);}
//何で初期化するか
T other = 1e18;

struct segment_tree{
    int n;
    T seg[2*MAX_V];
    //要素数N(0〜N-1)の初期化されたセグメント木を構築
    segment_tree(int N){
        n = 1;
        while(n < N) n *= 2;
        fill_n(seg, 2*n-1, other);
    }
    //i番目の要素をxに変更(0番目から数える)
    void update(int i, T x){
        i += n-1;
        seg[i] = x;
        while(i > 0){
            i = (i-1)/2;
            seg[i] = f(seg[2*i+1], seg[2*i+2]);
        }
    }
    //query(a, b)で[a, b)における演算の結果を取得
    T query(int a, int b, int i = 0, int l = 0, int r = -1){
        if(r < 0) r = n;
        if(a >= r || b <= l) return other;
        elif(a <= l && r <= b) return seg[i];
        else{
            T vl = query(a, b, 2*i+1, l, (l+r)/2);
            T vr = query(a, b, 2*i+2, (l+r)/2, r);
            return f(vl, vr);
        }
    }
};

int main(){
    int N, Q, A;
    cin >> N >> Q >> A;
    A--;
    int x[Q+1];
    rep(i, Q+1){
        cin >> x[i];
        x[i]--;
    }
    segment_tree seg1(N), seg2(N);
    rep(i, N){
        seg1.update(i, INF+i);
        seg2.update(i, INF-i);
    }
    seg1.update(A, A);
    seg2.update(A, -A);
    ll sum = 0;
    rep(i, Q){
        ll tmp = INF;
        tmp = min(tmp, seg1.query(x[i+1], N) - x[i+1]);
        tmp = min(tmp, seg2.query(0, x[i+1]) + x[i+1]);
        ll c = tmp-seg1.query(x[i], x[i]+1)+x[i];
        ll d = abs(x[i+1]-x[i]);
        if(c < d){
            seg1.update(x[i], seg1.query(x[i], x[i]+1) + c-d);
            seg2.update(x[i], seg2.query(x[i], x[i]+1) + c-d);   
        }
        sum += d;
    }
    ll ans = INF;
    rep(i, N){
        ans = min(ans, sum+seg1.query(i, i+1) - i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 13056
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
constexpr int kMax = 10000000;
typedef long long LL;

int main() {
  LL K; cin >> K;
  if (K % 2 == 0) {
    cout << -1 << endl;
    return 0;
  }

  LL sum = 0;
  LL digit = 7;
  for (int i = 0; i < kMax; ++i) {
    sum = (sum + digit) % K;
    if (sum % K == 0) {
      cout << i + 1 << endl;
      return 0;
    }

    digit = (digit * 10) % K;
  }
  cout << -1 << endl;
  return 0;
}


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

double x, y;
double area( double x1, double y1, double x2, double y2 )
{
        double a, b, c, z;
        a = sqrt( (x-x1)*(x-x1) + (y-y1)*(y-y1) );
        b = sqrt( (x-x2)*(x-x2) + (y-y2)*(y-y2) );
        c = sqrt( (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) );

        z = ( a + b + c ) / 2;
        return sqrt( z * ( z-a ) * ( z-b ) * ( z-c ) );

}

int main()
{
        double x1, y1, x2, y2;
        double s = 0;
        char str[100];

        scanf( "%lf,%lf", &x, &y );
        scanf( "%lf,%lf", &x1, &y1 );

        while ( scanf( "%lf,%lf", &x2, &y2 ) != EOF ) {
                s += area( x1, y1, x2, y2 );
                x1 = x2;
                y1 = y2;
        }
        printf( "%.8lf\n", s );
        return 0;
}



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

int main() {
    long long num;
    long long sum;
    long long time = 0;
    long long tmp = 0;

    cin >> num;

    long long idx = 1;
    while (true){
        sum = idx * (idx + 1) / 2;
        time++;

        if (sum >= num){
            cout << time;
            return 0;
        }

        idx++;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
  int x;
  cin >> x;
  int a = 0, b = 0;
  for (a = -1000; a <= 1000; a++)
  {
    for (b = -1000; b <= 1000; b++)
    {
      if (pow(a, 5.0) - pow(b, 5.0) == x)
      {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
  return 0;
}

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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  set<ll> xs;
  for (ll i = 0; i < N; i++) {
    ll d; cin >> d;
    xs.insert(d);
  }
  cout << xs.size() << endl;
  

  return 0;
}



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

        using namespace std;

        #define pb push_back
        #define mp make_pair
        #define fr first
        #define sc second

        typedef long long int lli;

        lli h, temp = 1, ans = 0, cnt = 0;

        int main(){
            cin>>h;
            while(h){
                cnt++;
                h /= 2;
            }
            while(cnt--){
                ans += temp;
                temp = temp << 1;
            }
            cout<<ans<<endl;
            return 0;
        }


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

int main()
{
	int a[5], need=9;
	for(int i=0; i<5; i++)
	{
		cin>>a[i];
		if(a[i]%10!=0 && a[i]%10<=need%10)
			need=a[i];
	}
	//printf("need=%d\n",need);
	
	int sum=0,flag=1; 
	for(int i=0; i<5; i++)
	{
		if(flag&&a[i]==need)
		{
			sum+=a[i];
			flag=0;
		}
		else 
		{
			if(a[i]%10)
			{
				a[i]=a[i]/10;
				a[i]=a[i]+1;
				a[i]*=10;	
			}
				sum+=a[i];
				//printf("a[%d]=%d\n",i,a[i]); 			
		}
	}
	
	printf("%d",sum);
	return 0;
}

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

#26進数
dim = []
while n>0:
    q,r = divmod(n-1, 26)
    dim.append(r)
    n=q

import string
dic = {i:l for i,l in enumerate(string.ascii_lowercase)}

print(''.join([dic[d] for d in reversed(dim)]))
    

Measured memory_bytes: 9964
#include<bits/stdc++.h>
using namespace std;
int main() {
	long long n,a,b,s=0;
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++){
		int u=i,ss=0;
		while(u)ss+=u%10,u/=10;
		if(a<=ss&&ss<=b)s+=i;
	}
	cout<<s<<endl;
}

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;


void print_line(vector<string> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}

struct DoublingLowestCommonAncestor {
    const int LOG;
    vector<int> dep;
    const vector<vector<int>> &g;
    vector<vector<int> > table;

    DoublingLowestCommonAncestor(const vector<vector<int>> &g) : g(g), dep(g.size()),
                                                                 LOG(32 - __builtin_clz(g.size())) {
        table.assign(LOG, vector<int>(g.size(), -1));
    }

    void dfs(int idx, int par, int d) {
        table[0][idx] = par;
        dep[idx] = d;
        for (auto &to : g[idx]) {
            if (to != par) dfs(to, idx, d + 1);
        }
    }

    void build() {
        dfs(0, -1, 0);
        for (int k = 0; k + 1 < LOG; k++) {
            for (int i = 0; i < table[k].size(); i++) {
                if (table[k][i] == -1) table[k + 1][i] = -1;
                else table[k + 1][i] = table[k][table[k][i]];
            }
        }
    }

    int query(int u, int v) {
        if (dep[u] > dep[v]) swap(u, v);
        for (int i = LOG - 1; i >= 0; i--) {
            if (((dep[v] - dep[u]) >> i) & 1) v = table[i][v];
        }
        if (u == v) return u;
        for (int i = LOG - 1; i >= 0; i--) {
            if (table[i][u] != table[i][v]) {
                u = table[i][u];
                v = table[i][v];
            }
        }
        return table[0][u];
    }
};

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

    vector<vector<int>> g(n);

    rep(i, n) {
        int k;
        cin >> k;
        rep(j, k) {
            int t;
            cin >> t;
            g[i].push_back(t);
            g[t].push_back(i);
        }
    }

    DoublingLowestCommonAncestor lca(g);
    lca.build();

    int q;
    cin >> q;
    rep(i, q) {
        int u, v;
        cin >> u >> v;
        cout << lca.query(u, v) << endl;
    }
}



Measured memory_bytes: 18340
// atcoder/abc138/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

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

using namespace std;

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

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

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

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

  int n;
  while (cin >> n) {
    vector<double> a(n);
    cin >> a;

    double x = 0;
    each (i, a) x += 1.0 / i;

    printf("%.10lf\n", 1.0 / x);
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define PI 3.1415926535897932
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define f(i, a, n) for (int i = a; i < n; i++)
using namespace std;
typedef vector<int> vi;
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;

int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int x,y,z; cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y;

    return 0;
}

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

ll char_to_int(char c) {
	return c - '0';
}

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

	string s;
	cin >> s;

	ll rsl = 0;
	for(int mask = 0; mask < 1 << (s.size() - 1); mask++) {
		vector<ll> v;
		ll tmp = char_to_int(s[0]);
		rep(i, 0, s.size() - 1) {
			if(mask & 1 << i) {
				v.push_back(tmp);
				tmp = char_to_int(s[i + 1]);
			} else {
				tmp = tmp * 10 + char_to_int(s[i + 1]);
			}
		}
		v.push_back(tmp);
		rep(i, 0, v.size()) {
			rsl += v[i];
		}
	}
	cout << rsl << endl;


}


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

using namespace std;

int main()
{
    int i = 'a';
    char C;
    cin >> C;
    for ( i = 'a'; i <= 'z'; i++)
    {
        if (i == C)
        {
            cout << char(i+1);
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <complex>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;

int main() {
  int N;
  ll D;
  cin >> N >> D;
  D = D * D;

  int ans = 0;
  for (int i = 0; i < N; i++) {
    ll x, y;
    cin >> x >> y;
    ll dist = x * x + y * y;
    if (dist <= D) {
      ans++;
    }
  }
  cout << ans << endl; 
}


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

int main() {
  int H, W;
  string a, b;
  cin >> H >> W;
  for (; W > -2; W--) b += '#';
  for (cout << b << endl; H; H--) {
    cin >> a;
    cout << '#' << a << '#' << endl;
  }
  cout << b;
}

Measured memory_bytes: 3636
N=int(input())
happy=[]
dp=[[0,0,0] for r in range(N)]
for i in range(N):
  happy.append(list(map(int,input().split())))
dp[0]=happy[0].copy()
for i in range(1,N):
  for j in range(3):
    for k in range(3):
      if j != k :
        dp[i][j]=max(dp[i-1][k]+happy[i][j],dp[i][j])
        

  
print(max(dp[N-1]))

Measured memory_bytes: 49992