akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int n;
    cin >> s;
	n = s.length();
	int cnt = 0;
	string pre = "";
	for(int i = 0; i < n; ++ i) {
		++ cnt;
		string now = "";
		now += s[i];
		if(pre == now)
			++ i, now += s[i];
		if(i == n) {
			-- cnt;
			break;
		}
		pre = now;
	}
	cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3748
#include <iostream>
#include <bits/stdc++.h>
#define MAX_SIZE 500010
#define INFTY 2000000000
using namespace std;

int n, cmp=0, A[MAX_SIZE];

void merge(int left, int mid, int right) {
    int i, j, k, n1 = mid - left, n2 = right - mid;
    int L[n1+1], R[n2+1];
    for (i=0; i < n1; i++) L[i] = A[left + i];
    for (i=0; i < n2; i++) R[i] = A[mid + i];
    L[n1] = INFTY;
    R[n2] = INFTY;
    i = 0;
    j = 0;
    for (k=left; k < right; k++) {
        if (L[i] <= R[j]) {
            A[k] = L[i];
            i++;
        } else {
            A[k] = R[j];
            j++;
        }
        cmp++;
    }
    return;
}

void mergeSort(int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        mergeSort(left, mid);
        mergeSort(mid, right);
        merge(left, mid, right);
    }
}


int main(){
    cin >> n;
    for (int i=0; i < n; i++) scanf("%d", &A[i]);
    mergeSort(0, n);
    for (int i=0; i < n - 1; i++) printf("%d ", A[i]);
    cout << A[n-1] << endl << cmp << endl;
    return 0;
} 


Measured memory_bytes: 7084
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
 #define PI 3.14159265359

using namespace std;
const int64_t mod = 1000000007;
const int64_t tmpMod = 998244353;

int main() {
 
  int64_t a,b,c,k;
  cin>>a>>b>>c>>k;
  while(k>0){
    if(a>=b){
    	b*=2;
      k--;
    }
    else if(b>=c){
    	c*=2;
      k--;
    }
    else break;
  }
  if(a<b && b<c)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  //vector<int64_t> A(N);
  //for(int i=0; i<N; i++){cin>>A[i];}
  //vector<vector<int> > A(N,vector<int>(M));
  //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}

}

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

int main() {
  int N, L;
  cin >> N >> L;
  long long S = 0;
  for (long long i = 0; i < N; ++i) {
    S += L + i;
  }
  long long R = L + N - 1; 
  if (L >= 0) cout << S - L << endl;
  else if (R <= 0) cout << S - R << endl;
  else cout << S << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define i64 long long
#define maxn (int)(1e5)
#define pii pair<int,int>
#define L first 
#define R second
#define all(x) x.begin(),x.end()
#define eps 1e-9
using namespace std;
bool lessThan( double a, double b ){ 
	if ( a + eps < b ) return true; 
	else return false; 
}
int main(){
	int n;
	double T,A;
	cin>>n>>T>>A;
	double h[n+2], t;
	double minDif = 1e9;
	int id;
	for(int i=0;i<n;i++){
		cin>>h[i];
		t = T-0.006*h[i];
		if(lessThan(fabs(A-t),minDif)) {
			id = i+1;
			minDif = fabs(A-t);
		}
	}
	printf("%d\n",id);
	return 0;
}

Measured memory_bytes: 256
n,m= map(int, input().split())
a= [list(map(int, input().split())) for i in range(m)]
s,t= map(int, input().split())

b= [[] for i in range(3*n)]
# 3で割り切れる数がもとの点
for i in range(m):
    b[3*(a[i][0]-1)].append(3*(a[i][1]-1)+1)
    b[3*(a[i][0]-1)+1].append(3*(a[i][1]-1)+2)
    b[3*(a[i][0]-1)+2].append(3*(a[i][1]-1))

import collections
from collections import deque
def tree(s,g):

    INF=-10**9
    dis = [INF for i in range(3*n)]
    dis[s]=0
    def bfs():
        d = deque()
        d.append(s)

        while len(d):
            x = d.popleft()

            for i in range(len(b[x])):
                y=b[x][i]
                if dis[y] == INF:
                    d.append(y)
                    dis[y]=dis[x]+1


        return dis[g]
    return bfs()

ans=tree(3*(s-1),3*(t-1))
if ans==-10**9:
    print(-1)
else:
    print(ans//3)

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

int main() {
  int N, M, C; cin >> N >> M >> C;
  int b[M];
  for (int i = 0; i < M; i++) {
    cin >> b[i];
  }
  int res = 0;
  for (int i = 0; i < N; i++) {
    int sum = C;
    for (int j = 0; j < M; j++) {
      int a; cin >> a;
      sum += (a*b[j]);
    }
    if (sum > 0) {res++;}
  }
  
  cout << res << endl;
}


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


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

    vector<string> weeks = {"SAT","FRI","THU","WED","TUE","MON","SUN"};
    
    for(int i=0;i<7;i++){
        if(weeks[i] == S)
        {
            cout << i + 1;
        }
    }

    return 0;
}


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

int main(){
    int n;
    cin>>n;
    int s=0;
    int  x[n],y[n],h[n];
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i]>>h[i];
        if(h[i]!=0) s=i;
    }

    int  ansx,ansy,ansh;
    for(ansx=0;ansx<101;ansx++){
        for(ansy=0;ansy<101;ansy++){
            ansh=h[s]+abs(ansx-x[s])+abs(ansy-y[s]);
            bool hi=true;
            for(int i=0;i<n;i++){
                if(h[i]!=max(0,ansh-abs(ansx-x[i])-abs(ansy-y[i]))){
                    hi=false;
                }
            }
            if(hi){
                cout<<ansx<<" "<<ansy<<" "<<ansh<<endl;
                return 0;
            }
        }
    }
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;

string s;
vector<string> cand;

int ans;
void dfs(int p, int C) {
    if (p == (int)s.size()) {
        cand.push_back(s);
        return;
    }
    // change
    int idx = (s[p] - 'a');
    // not change
    if (idx == 0 || C >> (idx - 1) & 1) {
        dfs(p + 1, C);
    } 
    if (~C >> idx & 1) {
        if (s[p] != 'z') {
            s[p]++;
            C ^= 1 << idx;
            dfs(p + 1, C);
            C ^= 1 << idx;
            s[p]--;
        }
    }

}

int main() {
    while (cin >> s && s[0] != '#') {
        cand.clear();
        dfs(0, 0);
        cout << cand.size() << endl;
        //sort(cand.begin(), cand.end());
        if (cand.size() <= 10) {
        } else {
            vector<string> new_cand;
            for (int i = 0; i < 5; ++i) {
                new_cand.push_back(cand[i]);
            }
            for (int i = 0; i < 5; ++i) {
                new_cand.push_back(cand.rbegin()[i]);
            }
            cand = new_cand;
            reverse(cand.begin() + 5, cand.end());
        }
        //sort(cand.begin(), cand.end());
        for (auto &s : cand) cout << s << "\n";
    }
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
string s,t;

int main(){
  cin>>n>>s>>t;
  ll ans = 1;
  int bef = 0;
  REP(i,n){
    if(s[i]==t[i]){
      // tate
      ll tak = 3-bef;
      ans = ans * tak % MOD;
      bef = 1;
    }else{
      // yoko
      i++;
      ll tak;
      if(bef==0){
        tak = 6;
      }else if(bef==1){
        tak = 2;
      }else if(bef==2){
        tak = 3;
      }
      ans = ans * tak % MOD;
      bef = 2;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
a,b = map(int,input().split())

d=a//b
r=a%b
f='{:.5f}'.format(a/b)

print(d,r,f)


"""
a, b = map(int, input().split())

d, r = divmod(a, b)
f = '{:.5f}'.format(a / b)

print(d, r, f)
"""


Measured memory_bytes: 5620
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

int main() {

	string s;
	cin >> s;

	replace(s.begin(), s.end(), '?', 'D');

	cout << s << "\n";

	return 0;
}



Measured memory_bytes: 3720
#include<iostream>
#include<vector>
#include<queue>
#include <string.h>
#include <algorithm>

using namespace std;

int main(){
  int H,N;
  cin>>H>>N;
  int A[N];
  for (int i = 0; i < N; i++) {
    cin>>A[i];
  }
  for(int i=0;i<N;i++){
    H-=A[i];
    if(H<=0){
      cout<<"Yes"<<"\n";
      return 0;
    }
  }
  cout <<"No"<<"\n";
}

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

int main()
{
   ///int a,b,k;
   long k;
   cin>>k;
  long p=100;
  long  c=0;
   while(p<k)
   {
     c++;
   long a=p*1.01;
   
    p=a;
   }
   cout<<c;
   return 0;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main(){
	long int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(a>=k){
		cout<<k;
		return 0;
		}
    else if(a+b>=k){
        cout<<a;
        return 0;
		}
	else{
		cout<<a-(k-a-b);
		}
	return 0;
	}


Measured memory_bytes: 3600
import Control.Applicative
import Data.List

-- maximum :: [Int] -> Int
-- maximum (x:xs) | (maximum xs) > x = maximum xs
--                | otherwise        = x

main = do
  [a, b, c] <- map ( read :: String -> Int ) . words <$> getLine
  let z = sort [a,b,c]
  -- let z = a + b + c
  putStrLn $ unwords $ map show $ z



Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
//typedef __int128_t lll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll a, b;std::cin >> a >> b;
  std::cout << max({a+b, a-b, a*b}) << '\n';
  return 0;
}


Measured memory_bytes: 632
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9 + 7, A = 5e5 + 2;

int main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    multiset <int> st;
    for (int i = n - 1; i >= 0; i--) {
        auto it = st.upper_bound(a[i]);
        if (it != st.end())
            st.erase(it);
        st.insert(a[i]);
    }
    cout << st.size();
    return 0;
}


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

const int MAX = 200000;

int main() {
	static int N, A[MAX];
	cin >> N;
	for (int i = 0;i < N;++ i) cin >> A[i];
	sort(A, A+N);

	int ans = 0;
	for (int i = 1 << 30;i > 0;i >>= 1) {
		for (int j = 0, k = N - 1;j < k;) {
			if (A[j] < 0 || A[k] > 0 && A[j] + A[k] < i) ++ j;
			else if (A[k] < 0 || A[j] + A[k] > i) -- k;
			else {
				A[j] = A[k] = -1;
				++ ans;
			}
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1152
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
v vec,F;
int n,k;
bool check(int med){
	int comp=0;
	priority_queue<int> pq;
	for(auto it:vec)pq.push(it);
	for(auto it:F){
		int x=med/it;
		int f=pq.top();
		pq.pop();
		if(f<=x)continue;
		comp+=(f-x);
	}
	return (comp<=k);
}
int32_t main(){
	boost;
	cin>>n>>k;
	vec.resize(n),F.resize(n);
	for(auto& it:vec)
		cin>>it;
	for(auto& it:F)
		cin>>it;
	sort(all(vec));
	sort(all(F));
	int l=0,r=INF,ans=0;
	while(l<=r){
		int med=(l+r)>>1LL;
		if(check(med))
			r=med-1,ans=med;
		else l=med+1;
	}
	cout<<ans;
	return 0;
}
//long long
//array bounds
//special cases
//binary search

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

const int N=2e5+5;
int cnt[N];

void init();
void work();
int ca=1;
int main(){
//    freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
//    init();
//    int T;cin>>T;
//    while(T--)
    work();
    return 0;
}
void work(){
    int n;cin>>n;
    int x;
    for(int i=1;i<n;i++) cin>>x,cnt[x]++;
    for(int i=1;i<=n;i++) cout<<cnt[i]<<'\n';
}


Measured memory_bytes: 4396
#include <stdio.h>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
typedef long long ll;

using namespace std;

int main(){
	int N, M;
  	cin >> N >> M;
  	priority_queue<int> que;
  	ll sum = 0;
  	for(int i = 0; i < N; i++){
      	int a;
    	cin >> a;
      	que.push(a);
    }
  	while(M > 0){
    	int q = que.top();
      	que.pop();
      	q /= 2;
      	M--;
    	que.push(q);
    }
  	while(!que.empty()){
    	int q = que.top();
      	que.pop();
      	sum += (ll)q;
    }
  	cout << sum << endl;
}

Measured memory_bytes: 892
#include <stdio.h>
int main(void) {
	int x;
	scanf("%d",&x);
	if(x%7==0){
		puts("thu");
	}
	else if(x%7==1){
		puts("fri");
	}
	else if(x%7==2){
		puts("sat");
	}
	else if(x%7==3){
		puts("sun");
	}
	else if(x%7==4){
		puts("mon");
	}
	else if(x%7==5){
		puts("tue");
	}
	else{
		puts("wed");
	}
	return 0;
}


Measured memory_bytes: 2108
# たまにはDFSでグラフを全探索する
from collections import deque

N,M=map(int,input().split())
out=[set() for v in range(N+1)];out[0]=None
es=[None]
for e in range(1,M+1):
    a,b=map(int,input().split())
    es.append((a,b))
    out[a].add(b);out[b].add(a)

# print(es) #DB
# print(out) #DB

ans=0
q=deque()
for e in es[1:]: # 各辺を順にチェックする
    r=[False for v in range(N+1)];out[0]=None # 到達フラグ
    a,b=e # 着目している辺の始点と終点
    r[a]=True # 始点に到達する
    for u in out[a]-{b}:
        q.append(u);r[u]=True # 始点と繋がっている終点以外の頂点を全てスタックに入れ，到達する
    while q:
        u=q.pop() # LIFO
        for v in out[u]:
            if not r[v]:
                q.append(v);r[v]=True
    if not r[b]: # 終点（頂点b）に到達していなければ，辺(a,b)は橋であった
        ans+=1

print(ans)

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

int main(){
  int n,l;
  cin >> n >> l;
  vector<string> s(n);
  
  for(int i = 0;i < n;++i) cin >> s[i];
  
  sort(s.begin(),s.end());
  
  for(int i = 0;i < n;++i){
    cout << s[i];
  }
  cout << endl; 
  return 0;
}

Measured memory_bytes: 256
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,a[100005]={},ans=0;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  for(int i=1; i<n; i++) {
    if(a[i]>a[i-1]) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ip;
const int MAX=1010;
int cnt[MAX][MAX];
int mx[]={1,1,1,0,0,-1,-1,-1},my[]={1,0,-1,1,-1,1,0,-1};
int main(){
	int h,w;	cin>>h>>w;
	vector<string> s(h);
	for(int i=0;i<h;i++)	cin>>s[i];
	queue<ip> q;
	for(int i=0;i<h;i++){//各地点の周りにいくつ更地があるかカウント
		for(int j=0;j<w;j++){
			if(s[i][j]=='.')	continue;
			for(int k=0;k<8;k++){
				if(s[i+my[k]][j+mx[k]]=='.')	cnt[i][j]++;
			}
			if(cnt[i][j]>=s[i][j]-'0'){//壊せるなら壊す
				s[i][j]='0';
				q.push(make_pair(i,j));
			}
		}
	}
	if(q.empty()){
		cout<<0<<endl;
		return 0;
	}
	int ans=1;
	while(true){
		queue<pair<int,int>> broken;
		while(!q.empty()){
			auto now=q.front();	q.pop();
			int y=now.first,x=now.second;
			for(int i=0;i<8;i++){//壊れた地点の周りのカウントを＋１。
				int yy=y+my[i],xx=x+mx[i];
				if(s[yy][xx]=='.'||s[yy][xx]=='0')	continue;
				cnt[yy][xx]++;
				if(cnt[yy][xx]>=s[yy][xx]-'0'){
					s[yy][xx]='0';
					broken.push(make_pair(yy,xx));
				}
			}
		}
		if(broken.empty()){
			cout<<ans<<endl;
			return 0;
		}
		while(!broken.empty()){
			q.push(broken.front());	broken.pop();
		}
		ans++;
	}
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	cin >> N;
	int ans = 0;
	rep(i, 1, N + 1)
	{
		if (i % 3 != 0 && i % 5 != 0)ans += i;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3664
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793

ll dp[450][450]; ll a[450], cum[500];

ll rec(int a, int b){
  if(a+1==b) {
    return dp[a][b] = 0;
  }
  if(dp[a][b]!=0) return dp[a][b];
  ll tmp, res=longinf;
  REP(i, a+1, b){
    tmp = rec(a, i) + rec(i, b);
    res = min(tmp, res);
  }
  res += (cum[b] - cum[a]);
  return dp[a][b] = res;
}

int main(){
  int N; cin >> N;
  rep(i, N){
    cin >> a[i];
  }
  rep(i, N){
    cum[i+1] = cum[i] + a[i];
  }
  cout << rec(0, N) << endl;
}

Measured memory_bytes: 1792
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			var dp = new int[n, 3];
			for (int i = 0; i < n; i++) {
				var abc = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
				if (i == 0) {
					for (int j = 0; j < 3; j++) {
						dp[i, j] = abc[j];
					}
				} else {
					for (int j = 0; j < 3; j++) {
						for (int k = 0; k < 3; k++) {
							if (j == k) {
								continue;
							}

							dp[i, j] = Math.Max(
								dp[i, j],
								dp[i - 1, k] + abc[j]);
						}
					}
				}
			}

			int ans = Math.Max(
				dp[n - 1, 0],
				Math.Max(dp[n - 1, 1], dp[n - 1, 2]));
			Console.WriteLine(ans);
		}
	}
}

Measured memory_bytes: 16308
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void){
	int n=0;
    cin>>n;
    int*data = new int[n];
    for(int i=0;i<n;i++){
    	cin>>data[i];
    }
    sort(data,data+n);
    int count=1;
    int prev=data[0];
    for(int i=1;i<n;i++){
    	if(prev < data[i]){
    		count++;
    		prev=data[i];
    	}
    }
    cout<<count<<endl;
    return 0;
}

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

#define ll long long
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))

const int N =100;

bool isprime(int n)
{
    if (n <= 1)
        return false;
    for (int i = 2; i*i<=n; i++)
        if (n % i == 0)
            return false;

    return true;
}
int binarySearch(int arr[], int l, int r, int x)
{
    if (r >= l) {
        int mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
long long lcm(long long a,long long b)
{
    long long p,r;
    p = a*b;
    r = __gcd(a, b);
    return p/r;
}
bool ispalindrome(string s)
{
    int n = s.length();
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-i-1])
            return false;
    }
    return true;
}
bool isPerfectSquare(long double x)
{
  long double sr = sqrt(x);
  return ((sr - floor(sr)) == 0);

}
ll f(ll n) {
	return n * (n - 1) / 2;
}
bool cmp(const tuple<int, string, string>& a,
               const tuple<int, string, string>& b)
{
    return (get<0>(a) < get<0>(b));
}

void solve()
{
    ll d,t,s;
    cin>>d>>t>>s;
    if(t*s>=d)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3692
def e_bomber():
    import sys
    input = sys.stdin.readline

    H, W, M = [int(i) for i in input().split()]

    bomb_row = [0] * H
    bomb_col = [0] * W
    bomb_pos = set()
    for _ in range(M):
        r, c = [int(i) - 1 for i in input().split()]
        bomb_row[r] += 1
        bomb_col[c] += 1
        bomb_pos.add((r, c))

    bomb_row_max = max(bomb_row)
    bomb_col_max = max(bomb_col)
    row_index_list = [r for r, v in enumerate(bomb_row) if v == bomb_row_max]
    col_index_list = [c for c, v in enumerate(bomb_col) if v == bomb_col_max]

    # 破壊できる数が最大になるような行と列の組を全探索する。
    # (行, 列) が破壊対象の上になってしまわないような組があれば、そこに置けばいい。
    # そのような組がまったくなければ、破壊対象の上に置かざるを得ない (-1 される)。
    for row in row_index_list:
        for col in col_index_list:
            if (row, col) not in bomb_pos:
                return bomb_row_max + bomb_col_max
    return bomb_row_max + bomb_col_max - 1

print(e_bomber())

Measured memory_bytes: 83368
#include <iostream>
using namespace std;
 
int main(void){
    int x,y,z;
    cin >> x ;
    cin >> y ;
    cin >> z ;
    if(x>y){
        int temp = x;
        x=y;
        y=temp;
    }
     if(y>z){
        int temp = y;
        y=z;
        z=temp;
    }  
       if(x>y){
        int temp = x;
        x=y;
        y=temp;
    }
    cout  << x;
    cout  <<" ";
    cout  << y;
    cout  <<" ";
    cout  << z;
    cout  << endl;
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
    using namespace std;
    int main(){
        int n;
      cin>>n;
      int len;
      cin>>len;
        string arr[n];
      for(int i=0;i<n;i++){
        cin>>arr[i];
      }
      sort(arr,arr+n);
      string output;
      for(int i=0;i<n;i++){
        output+=arr[i];
      }
      cout<<output;
    }


Measured memory_bytes: 3560
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>

using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main() {
    int n,k;
    scanf("%d %d",&n,&k);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int tmp;
        scanf("%d",&tmp);
        if (tmp >= k) ans++;
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 256
while 1:
    n = int(raw_input())
    if not n: break
    c = [0 for i in xrange(7)]
    for i in xrange(n):
        age = int(raw_input())
        if age < 10: c[0] += 1
        elif 10 <= age < 20: c[1] += 1
        elif 20 <= age < 30: c[2] += 1
        elif 30 <= age < 40: c[3] += 1
        elif 40 <= age < 50: c[4] += 1
        elif 50 <= age < 60: c[5] += 1
        else: c[6] += 1
    for i in xrange(len(c)):
        print c[i]

Measured memory_bytes: 4240
#![allow(dead_code, unused_imports, deprecated)]
use std::cmp::{max, min, Reverse};
use std::collections::*;
use maplit::*;
use num::Integer;
use proconio::input;
use proconio::marker::*;
use proconio::fastout;

const INF : usize = 1000000007;

fn main() {
  input! {
    n : usize, d : isize,
  };

  let mut res = 0usize;
  for _ in 0..n {
    input! {
      x : isize, y : isize,
    };

    if x * x + y * y <= d * d {
      res += 1;
    }
  }
  
  println!{"{}", res};
}

Measured memory_bytes: 4940
#pragma region Macros
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;
#pragma endregion
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	int N, ans = 0;
	string S;
	cin >> N >> S;

	rep(i, N - 2)
	{
		if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C')
			ans++;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
fun main(){
    val key = arrayOf("AC","WA","TLE","RE")
    val n = readLine()!!.toInt()
    val s = Array(n){
        readLine()
    }
    val r = s.groupingBy { it }.eachCount()
    for(k in key){
        println("$k x ${r[k] ?: 0 }")
    }
}

Measured memory_bytes: 60284
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <string>
using u8t = std::uint64_t;
using i8t = std::int64_t;
#define F(I,N) for(i8t I=0,_N=N;I<_N;I++)
#define FR(I,N) for(i8t I=N;I--;)
#define R(V) i8t V;std::cin>>V;
#define RV(V,N) std::vector<i8t> V;F(_i,N){R(_x)V.push_back(_x);}
#define RL1(line) std::getline(std::cin,line);
#define RL(line) std::string line;RL1(line)
#define RM(V,L,C) std::vector<char> V;F(_i,L){RL(_l)F(_j,C)V.push_back(_l[_j]);}
#define P(X) std::cout<<(X)<<std::endl;

int main() {
  R(X);
  i8t rem=X%5;
  for(int i=rem;i<200;i+=5){
    if (X%i)continue;
    u8t q=X/i;

    // B positive or zero
    if (q>=i*i*i*i){
      u8t Bmax=std::ceil(std::pow(q-i*i*i*i,0.25));
      for (u8t B=0; B<=Bmax;B++){
        u8t q2=i*i*i*i;
        q2+=5*B*i*i*i;
        q2+=10*B*B*i*i;
        q2+=10*B*B*B*i;
        q2+=5*B*B*B*B;
        if(q==q2){
          std::cout <<B+i<<" "<<B<<std::endl;
          return 0;
        }
      }
    }

    // B negative
    for (u8t b=1;b<i-1;b++){
      u8t a=i-b;
      u8t x2=a*a*a*a*a+b*b*b*b*b;
      if(X==x2){
        std::cout <<a<<" "<<-(i8t)b<<std::endl;
        return 0;
      }
    }
  }
  return 0;
}


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

int main(){
    int H, W;
    cin>>H>>W;
    int ch, cw, dh, dw;
    cin>>ch>>cw>>dh>>dw;
    ch--; cw--; dh--; dw--;
    string s[H];
    rep(i, H) cin>>s[i];

    deque<P> q;
    vector<vector<int>> dist(H, vector<int>(W, INF));
    int search[H][W];
    rep(i, H)rep(j, W) search[i][j]=0;
    dist[ch][cw]=0;
    search[ch][cw]=1;
    q.emplace_back(ch, cw);

    while(q.empty()==false){
        int x=q.front().first;
        int y=q.front().second;
        q.pop_front();
        //cost 0
        for(int i=-1; i<=1; i++){
            for(int j=-1; j<=1; j++){
                if(abs(i+j)!=1) continue;
                if(x+i<0) continue;
                if(y+j<0) continue;
                if(x+i>=H) continue;
                if(y+j>=W) continue;
                if(dist[x+i][y+j]<=dist[x][y]) continue;
                if(search[x+i][y+j]==0 && s[x+i][y+j]=='.'){
                    dist[x+i][y+j]=dist[x][y];
                    q.emplace_front(x+i, y+j);
                    search[x+i][y+j]=1;
                }
            }
        }

        //cost 1
        for(int i=-2; i<=2; i++){
            for(int j=-2; j<=2; j++){
                if(x+i<0) continue;
                if(y+j<0) continue;
                if(x+i>=H) continue;
                if(y+j>=W) continue;
                if(dist[x+i][y+j]<=dist[x][y]) continue;
                if(search[x+i][y+j]==0 && s[x+i][y+j]=='.'){
                    dist[x+i][y+j]=min(dist[x+i][y+j], dist[x][y]+1);
                    q.emplace_back(x+i, y+j);
                }
            }
        }
    }
    int ans=dist[dh][dw];
    // rep(i, H){
    //     rep(j, W) cout<<dist[i][j]<<" ";
    //     cout<<endl;
    // }
    if(ans==INF) ans=-1;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 14064
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<cmath>
#include<bitset>
#include<cassert>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<iomanip>
#include<fstream>
using namespace std;
typedef long long ll;
typedef long double ld;
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
 
int main()
{
    fast_io;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    string str;
    cin >> str;

    if(str.back() == 's') str.append("es");
    else str.append("s");

    cout << str << endl;

    return 0;
}

Measured memory_bytes: 3160
package main 

import (
        "fmt"
)

func main () {
        var n, x, na, ana, an int 
        fmt.Scan(&n)
        for i := 0 ; i < n ; i++ {
                x = 0
                na = n - i
                for{
                        x += 1
                        xx := x * x
                        if xx == na {
                                ana +=1
                                an = xx
                                break 
                        }  else if xx > na {
                                break
                        }
                }
                if ana != 0 {
                        fmt.Println(an)
                        break
                }
        }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

int main() {
    LL t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    // 調整成 a1 < b1
    if (a1 > b1) {
        swap(a1, b1);
        swap(a2, b2);
    }
    LL A1 = t1 * a1;
    LL A2 = t2 * a2;
    LL B1 = t1 * b1;
    LL B2 = t2 * b2;
    LL A = A1 + A2;
    LL B = B1 + B2;
    if (A < B) {
        cout << 0 << endl;
        return 0;
    } else if (A == B) {
        cout << "infinity" << endl;
        return 0;
    } else {
        LL x = (B1 - A1) / (A - B) + 1;
        // printf("ans = %lld\n", ans);
        LL ans = x * 2 - 1;
        if ((B1 - A1) % (A - B) == 0) {
            ans--;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3684
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int[] C = new int[N];
            int[] V = new int[N];

            int sum = 0;
            for (int i = 0; i < N; i++) {
                V[i] = in.nextInt();
            }
            for (int i = 0; i < N; i++) {
                C[i] = in.nextInt();
            }
            for (int i = 0; i < N; i++) {
                int diff = V[i] - C[i];
                if (diff > 0) {
                    sum += diff;
                }
            }
            out.println(sum);
        }

    }
}



Measured memory_bytes: 21844
import bisect
N=int(input())
L=sorted(list(map(int,input().split())))

ans=0
for i in range(N-2):
  for j in range(i+1,N-1):
    # ans+=bisect.bisect_left(L,L[i]+L[j])-j-1 # Code 1 
    ans+=bisect.bisect_left(L,L[i]+L[j],j)-j-1 # Code 2 
print(ans)

Measured memory_bytes: 3188
import numpy as np

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

A=np.array(A)
B=np.array(B)
E=A-B
e=sum(E)

if e<0:
    print(-1)

else:

    Eminus=[]
    Ezero=[]
    Eplus=[]
    nn=0
    n0=0
    nminus=0

    for n in range(N):
        if E[n]<0:
            Eminus.append(E[n])
            nminus=nminus+1
        
        elif E[n]>0:
            Eplus.append(E[n])
            nn=nn+1
        
        else:
            Ezero.append(E[n])
            n0=n0+1
    
    Eplus.sort()
    sumup=0

    for n in range(nn):
        sumup=sumup+Eplus[n]

        if sumup>e:
            break

    if nminus==0:
        print(0)
    else:
        print(N-n0-n)

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

int main(){  
	long N;
	long A;
	long B;
	cin >> N >> A >> B;
	if(A == B){
		cout << 1 << endl;
	}else if(A > B){
		cout << 0 << endl;
	}else if(N == 1){
		cout << 0 << endl;
	}else{
		cout << (B - A) * (N - 2) + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
//#pragma GCC target("avx2")
//#pragma GCC optimization("O3")
//#pragma GCC optimization("unroll-loops")
//assert(q==w) если q!=w --> runtime error
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bit __builtin_popcount
#define memset(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vector<int>> matrix;

inline void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const ll maxn=2e5+123;
const ll inf=1e9+123;
const ll linf=1e18+123;
const ll mod=1e9+7;
const double eps=1e-9;
const double pi=acos(-1);
int dx[8]={0,1,-1,0,1,-1,1,-1};
int dy[8]={1,0,0,-1,1,1,-1,-1};
pii a[maxn];
int b[maxn];
int main(){
    boost();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        cin>>a[i].F>>a[i].S;
        b[a[i].F]++;
        b[a[i].S+1]--;
    }
    for(int i=1;i<=n;i++){
        b[i]+=b[i-1];
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(m==b[i]){
            ans++;
        }
    }
    cout<<ans;
    exit(0);
}


Measured memory_bytes: 1408
n, d = map(int, input().split())
x = [0] * n
y = [0] * n
for i in range(n):
    x[i], y[i] = map(int, input().split())

result = 0

d = d**2

for i in range(n):
    if x[i]**2 + y[i]**2 <= d:
        result +=1

print(result)

Measured memory_bytes: 73036
a, b, k = map(int, input().split())

total = a+b
if total <= k:
    ans = [0, 0]
else:
    if a <= k:
        k -= a
        a = 0
        b -= k
        ans = [a, b]
    else:
        a -= k
        ans = [a, b]

print(*ans)

Measured memory_bytes: 9004
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
 
bool shoukai(pair<pair<string, int>, int> a, pair<pair<string, int>, int> b) {
  if (a.first.first == b.first.first) return a.first.second > b.first.second;
  else return a.first.first < b.first.first;
}
int main(){
  int n; cin >> n;
  string x;
  int y;
  vector<pair<pair<string, int>, int>> v(n); 
  rep(i, n) {
    cin >> x >> y;
    v.at(i) = make_pair(make_pair(x, y), i+1);
  }
  sort(all(v), shoukai);
  rep(i, n) cout << v.at(i).second << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;

template <typename T> inline void getint(T &num){
	register int ch, neg = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') neg = 1;
	num = ch & 15;
	while(isdigit(ch = getchar())) num = num * 10 + (ch & 15);
	if(neg) num = -num;
}

int N, M, A[100005], cnt = 0;

int main(){
	getint(N), getint(M);
	for(register int i = 1; i <= M; i++) getint(A[i]);
	for(register int i = 1; i <= M; i++) if(A[i] & 1){
		if(++cnt == 1) swap(A[i], A[1]);
		else if(cnt == 2) swap(A[i], A[2]);
		else return puts("Impossible"), 0;
	}
	if(cnt) swap(A[cnt], A[M]);
	for(register int i = 1; i <= M; i++) printf("%d ", A[i]); puts("");
	if(cnt <= 1){
		printf("%d\n1 ", A[M] == 1 ? M : M + 1);
		for(register int i = 1; i < M; i++) printf("%d ", A[i]);
		if(A[M] > 1) printf("%d\n", A[M] - 1);
	}
	else{
		printf("%d\n%d ", A[M] == 1 ? M - 1 : M, A[1] + 1);
		for(register int i = 2; i < M; i++) printf("%d ", A[i]);
		if(A[M] > 1) printf("%d\n", A[M] - 1);
	}
	return 0;
}

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

typedef long long LL;

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

template<typename T>
T digitsum(T x){
    T y=0;
    while(x){
        y += x % 10;
        x /= 10;
    }

    return y;
}

int main(int argc, char const* argv[])
{
    int n,a,b;
    cin >> n >> a >> b;

    int c=0;
    for (int i = 1; i <= n; i++) {
        if (a <= digitsum(i) && digitsum(i) <= b) {
            c += i;
        }
    }

    cout << c << endl;

    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }

// string を int に変換 stoi("1010")
// int を string に変換 to_string(1010)


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string input;
  cin >> input;
  
  int count = 0;
  
  if (input == "SSS") {
 	count = 0;
  } else if(input == "SSR" || input == "SRS" || input == "RSS" || input == "RSR") {
  	count = 1;
  } else if(input == "SRR" || input == "RRS") {
  	count = 2;
  } else {
  	count = 3;
  }
  
  cout << count << endl;

}

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

int main() {
  int n, m;
  cin >> n >> m;
  
  vector<vector<int> > adata(n, vector<int>(m));
  for(int i=0; i<n; i++) {
    for(int j=0; j<m; j++) {
      cin >> adata.at(i).at(j);
    }
  }
  
  vector<int> bdata(m);
  for (int i=0; i<m; i++) {
    cin >> bdata.at(i);
  }
  
  for(int i=0; i<n; i++) {
    int sum = 0;
    for(int j=0; j<m; j++) {
      int x, y;
      x = adata.at(i).at(j);
      y = bdata.at(j);
      sum += x*y;
      if (j == m-1) cout << sum << endl;
    }
  }
  
  return 0;
}


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

void dfs(int v, lint w, vector<lint> &cost, const vector< vector< LLP > > &g){
    cost[v] = w;
    for(auto e : g[v]){
        if(cost[e.first] > w + e.second){
            dfs(e.first, w + e.second, cost, g);
        }
    }
    return;
}

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

    lint n;
    cin >> n;

    vector< vector< LLP > > g(n);
    rep(i, n - 1){
        lint u, v, w;
        cin >> u >> v >> w;
        --u;
        --v;
        g[u].emplace_back(v, w);
        g[v].emplace_back(u, w);
    }

    vector<lint> cost(n, LLINF);
    dfs(0, 0LL, cost, g);

    rep(i, n){
        cout << cost[i] % 2LL << endl;
    }

    return 0;
}

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

int main() {

#ifdef LOCAL_DEFINE
	freopen("input.txt", "rt", stdin);
#endif

	int ans = 0;

	int n;
	cin >> n;

	for (int i = 1; i <= n; i += 2) {
		int cnt = 0;
		for (int j = 1; j <= i; j++) {
			if (i % j == 0) cnt++;
		}
		if (cnt == 8) ans++;
	}

	cout << ans << endl;

#ifdef LOCAL_DEFINE
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s. \n";
#endif

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n, d, x, a[101];
  cin >> n >> d >> x;

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

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

  cout << total + x << endl;
  return 0;
}

Measured memory_bytes: 256
import math
a, b, x = map(int,input().split())

if x > a*a*b / 2:
    print(math.atan(2*(a*a*b - x) / (a*a*a)) * (180 / math.pi))
else:
    print(math.atan(a*b*b/(2*x)) * (180 / math.pi))

Measured memory_bytes: 9232
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def bs(ar,eq,n) en=(eq==1 ? :>= : :>); ar.bsearch_index{|x|x.send(en,n)} end
def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n=gi
s=gs

puts s.squeeze.length


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

int h,w;
int math0[20][20],math1[20][20][20][20];

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

int bfs(int sy,int sx){
  if(math0[sy][sx]==0)return 0;
  math1[sy][sx][sy][sx]=0;
  queue<pair<int,int>> que;
  que.push(pair<int,int> (sy,sx));
  int res=-1;
  while(!que.empty()){
    pair<int,int> p=que.front();
    que.pop();
    for(int i=0; i<4; i++){
      int ny=p.first+dy[i];
      int nx=p.second+dx[i];
      if(0<=ny && ny<h && 0<=nx && nx<w){
        if(math1[sy][sx][ny][nx]==-1){
          math1[sy][sx][ny][nx]=math1[sy][sx][p.first][p.second]+1;
          res=max(math1[sy][sx][ny][nx],res);
          que.push(pair<int,int>(ny,nx));
        }
      }
    }
  }
  return res;
};

int main(){
  cin >> h >> w;
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      char tmp;
      cin >> tmp;
      if(tmp=='#')math0[i][j]=0;//壁
      else math0[i][j]=-1;
    }
  }

  int ans=0;

  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      for(int k=0; k<h; k++){
        for(int l=0; l<w; l++){
          math1[i][j][k][l]=math0[k][l];
        }
      }
      //if(bfs(i,j)==39)cout << i << "!" << j << ",,,";
      ans=max(bfs(i,j),ans);//そのスタート地点における最適なゴールを取った時のdepth
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 896
from collections import deque

N = int(input())
a_list = list(map(int,input().split()))

b = deque()
for i, a in enumerate(a_list):
    if i % 2 == 0:
        b.append(a)
    else:
        b.appendleft(a)

if N % 2 == 1:
    b.reverse()

print(" ".join(map(str,b)))

Measured memory_bytes: 123732
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <map>
 
using namespace std;
typedef long long ll;

ll asum,bsum,sum;
int main(){
	int n;
	cin>>n;
	ll a[n+1];
	for(ll i =0; i <=n; i++){
		cin>>a[i];
		asum += a[i];
	}
	ll b[n];
	for(int i=0; i<n; i++){
		cin>>b[i];
		bsum += b[i];
	}
	for(int i =0; i < n; i++){
		if(b[i] > a[i]){
			b[i] -= a[i];
			a[i]=0;
			if(b[i] < a[i+1]) a[i+1] -= b[i];
			else if(b[i]>=a[i+1]) a[i+1] =0;
		}
		else if(b[i]< a[i]) {
			a[i] -= b[i];
		}
		else a[i]=0;
	}
	for(int i = 0; i <= n; i++){
		sum+= a[i];
		//cout<<a[i]<<" ";
	}
	cout<<asum-sum<<endl;
	
}

Measured memory_bytes: 1792