akhauriyash/Code-Regression huggingface dataset:
n=int(input())
a=list(map(int, input().split()))
a.sort()
r=[0]*9
for i in range(n):
  b=a[i]
  if b<400:
    r[0]+=1
  elif b<800:
    r[1]+=1
  elif b<1200:
    r[2]+=1
  elif b<1600:
    r[3]+=1
  elif b<2000:
    r[4]+=1
  elif b<2400:
    r[5]+=1
  elif b<2800:
    r[6]+=1
  elif b<3200:
    r[7]+=1
  else:
    r[8]+=1
m=0
for i in range(8):
  if r[i]>0:
    m+=1
print(*(max(1, m), m+r[8]))

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

int main(){
	int n,k;
  cin>>n>>k;
  vector<int>a;
  int b;
  for(int i=0;i<n;++i){
  	cin >> b;
    a.push_back(b);
  }
  sort(a.rbegin(),a.rend());
  int ans=0;
  for(int i=0;i<k;++i)ans+=a[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    ll x, y, o, a = 0, b = 0;
    cin >> n >> x >> y;
    a = x + y;
    for (int i = 3; i <= n; i++) cin >> o, b ^= o;
    if (a % 2 != b % 2) cout << -1;
    else {
        ll c = (a - b) / 2, z = 0;
        for (int i = 42; i >= 0; i--) {
            if (c & (1ll << i)) z += (1ll << i);
        }
        for (int i = 42; i >= 0; i--) {
            if (b & (1ll << i)) {
                if (z + (1ll << i) <= x) z += (1ll << i);
            }
        }
        if (z == 0 || ((z ^ (a - z)) != b) || z > x) cout << -1;
        else cout << x - z;
    }
}


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

int main()
{
  ll a,b;
  cin >> a >> b;
  for (int i = 1; i <= 3; i++)
  {
    if (i != a && i != b) cout << i << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=998244353;

void Impsble(){
    cout<<0<<endl;
    exit(0);
}

int64_t ModPow(int64_t a, int64_t b){
    int64_t v=1;
    rep(i,0,b){
        v*=a;
        v%=MOD;
    }
    return v;
}

int main(){
    int N; cin>>N;
    vector<int> D(N);
    rep(n,0,N) cin>>D.at(n);

    if(D.front()!=0) Impsble();

    map<int,int> mp;
    rep(n,0,N) mp[D.at(n)]++;

    if(mp[0]!=1) Impsble();

    int64_t ans=1;
    for(auto itr=mp.begin();itr!=prev(mp.end()); itr++){
        if(itr->first+1!=next(itr)->first) Impsble();
        
        ans*=ModPow(itr->second,next(itr)->second);
        ans%=MOD;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 5376
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a,U b) { if (a > b) { a = b; return 1; } return 0; }
constexpr int ten = 10;

int main() {
    int k;
    cin >> k;
    
    vector<long long> ans, buff;
    
    for (int i = 1; i < 10; i++) buff.emplace_back(i);
    while (ans.size() < k) {
        vector<long long> next;
        for (const auto &e : buff) {
            long long n = e;
            long long c = n % ten;
            if (c != 0) next.emplace_back(n * ten + c - 1);
            next.emplace_back(n * ten + c);
            if (c != 9) next.emplace_back(n * ten + c + 1);
        }
        for (const auto &e : buff) ans.emplace_back(e);
        swap(buff, next);
    }
    
    sort(ans.begin(), ans.end());
    cout << ans[k-1] << endl;
    return 0;
}

Measured memory_bytes: 8468
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
int main()
{
    ll n,i,j;
    cin>>n;
    ld p[n];
    for(ll i=0;i<n;i++)cin>>p[i];
    ld dp[n][n+1],ans=0.0;
    dp[0][0]=1.0-p[0];
    for(i=0;i<n;i++)
    {
        for(j=0;j<=n;j++)
        {
            if(j==0&&i!=0)
            {
                dp[i][j]=dp[i-1][j]*(1.0-p[i]);continue;
            }
            if(i==0&&j==1)
            {
                dp[i][j]=p[0];continue;
            }
            if(j>i+1)
            {
                dp[i][j]=0;continue;
            }
            if(i!=0)
            dp[i][j]=dp[i-1][j]*(1.0-p[i])+dp[i-1][j-1]*p[i];
        }
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<=n;j++)
        {
            if(i+1==n&&j>i+1-j)ans+=dp[i][j];
        }
    }
    cout<<fixed<<setprecision(10)<<ans<<"\n";
}


Measured memory_bytes: 140928
#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

const double PI = 4 * atan(1);

#define sz(x) (int)(x).size()
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair <int, int>
#define vi vector<int>
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define vpi vector<pair<int, int>>
#define vpd vector<pair<double, double>>
#define pd pair<double, double>

#define f0r(i,a) for(int i=0;i<a;i++)
#define f1r(i,a,b) for(int i=a;i<b;i++)
#define trav(a, x) for (auto& a : x)

template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
  cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
}

void fast_io(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
void io(string taskname){
    string fin = taskname + ".in";
    string fout = taskname + ".out";
    const char* FIN = fin.c_str();
    const char* FOUT = fout.c_str();
    freopen(FIN, "r", stdin);
    freopen(FOUT, "w", stdout);
    fast_io();
}
int main(){
    fast_io();
    string s;
    getline(cin, s);
    ll k;
    cin >> k;
    ll n = sz(s);
    bool b = true;
    f0r(i, n){
        if(s[i] != s[0]) {
            b = false;
            break;
        }
    }
    if(b) {
        cout << (n*k)/2 << endl;
        return 0;
    }
    vi runs;
    char cur = s[0];
    int cnt = 1;
    f1r(i, 1, n){
        if(s[i] == cur){
            cnt++;
        }
        else{
            runs.eb(cnt);
            cur = s[i];
            cnt = 1;
        }
    }
    runs.eb(cnt);
    if(s[0] != s[n-1]){
        ll ans = 0;
        for(int i: runs) ans += (i/2);
        cout << ans*k << endl;
        return 0;
    }
    ll ans = 0;
    f1r(i, 1, sz(runs) - 1){
        ans += (runs[i]/2);
    }
    ans *= k;
    ans += (runs[0]/2);
    ans += (runs[sz(runs) - 1]/2);
    ans += (((runs[0] + runs[sz(runs) - 1])/2 ) *(k-1) );
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
i,o,_,j,l,_,_ = map(int, input().split())

ans=i//2*2 + j//2*2 + l//2*2
jil_ok=(i>=1 and j>=1 and l>=1)
if jil_ok:
    ans=max(ans,3 + (i-1)//2*2 + (j-1)//2*2 + (l-1)//2*2)
print(ans+o)

Measured memory_bytes: 61712
import java.util.Scanner;
import java.util.Arrays;

public class Main{
    public static void main(String arg[]){
        Scanner sc=new Scanner(System.in);
        while(true){
            int n=sc.nextInt();
            int sum=0;
            if(n==0)break;
            int[] s=new int[n];
            for(int i=0;i<n;i++)s[i]=sc.nextInt();
            Arrays.sort(s);
            s[0]=0;
            s[n-1]=0;
            for(int i=0;i<n;i++)sum+=s[i];
            System.out.println(sum/(n-2));
        }
        sc.close();
    }
}


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

int main(){
    int k;
    char s[101];
    scanf("%d",&k);
    scanf("%s",s);
    if(strlen(s) <= k){
       puts(s);
    }else {
       for(int i = 0;i < k;i++){
          printf("%c",s[i]);          
       }
       puts("...");
    }    
}


Measured memory_bytes: 1664
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

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

int main(void)
{
	int x, a, b;
	cin >> x >> a >> b;
	if (a >= b) { cout << "delicious" << "\n"; }
	else if (x + a >= b) { cout << "safe\n"; }
	else { cout << "dangerous\n"; }
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i)
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef LOCAL
    ~debug() { cerr << endl; }
eni(!=) { cerr << boolalpha << i; ris; }
eni(==) { ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << &", " [ 2 * (it == d.b)] << *it;
  ris << "]";
}
#else
    sim dor(const c&) { ris; }
#endif
};
#define imie(...) "" << #__VA_ARGS__ " = " << (__VA_ARGS__) << ""
#define arr array

const int INF = 1e9 + 5;
const int N = 1e5 + 5;


//dp[curr_idx][weight_till_curr_idx]

int main() {
	int n,W;
	scanf("%d%d", &n, &W);
	vector<int> w(n),v(n);
	for(int i = 0; i < n; i++) {
		cin >> w[i] >> v[i];
	}
	
	vector<vector<long long>> dp(100,vector<long long>(W + 1,0));

	for(int index = 0; index < n; index++) {
		for(int weight = 0; weight <= W; weight++) {
			if(index == 0) {
				if(weight == 0) {
					dp[index][weight] = 0;
				}else {
					dp[index][w[index]] = v[index];
				}
			}else {
				//discard the current item
				dp[index][weight] = dp[index - 1][weight];
				//pick the current item
				if(w[index] <= weight) {
					dp[index][weight] = max(dp[index][weight],v[index] + dp[index-1][weight-w[index]]);
				}
			}
		}
	}
	long long ans = -INF;
	for(int i = 0; i <= W; i++) {
		ans = max(ans,dp[n-1][i]);
	}
	
	cout << ans << "\n";

    return 0;
}




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

int main(void){
    
    int N;
    string S;
    cin >> N >> S;
    
    string ans;
    for(int i = 0; i < S.size(); i++){
        
        char c;
        if(S[i] + N > 90) c = (N + S[i]) - 26;
        else c = N + S[i];
        
        ans.push_back(c);
    }
    
    cout << ans << std::endl;
    
}


Measured memory_bytes: 256
int main(void)
{
    int n=1, i, j;
    
    while (n != 0)
    {
        double a[1000], goukei = 0, heikin = 0, siguma = 0, hensa = 0;

        scanf("%d", &n);

        if (n == 0)
        {
            return 0;
        }
        else
        {
            for (i = 1;i <= n;i++)
            {
                scanf("%lf", &a[i]);
                goukei = goukei + a[i];
            }

            heikin = goukei / n;

            for (j = 1;j <= n;j++)
            {
                siguma = siguma + pow((a[j] - heikin), 2);
            }

            hensa = sqrt(siguma / n);

            printf("%.8f\n", hensa);
        }
    }
    return 0;

}


Measured memory_bytes: 2080
#include <iostream>

typedef struct {
    double x;
    double y;
} point;

double calc_s(point p[], int length);
double calc_s_triangle(point p1, point p2, point p3);
double calc_s_triangle(point p1, point p2);

int main()
{
    point p[20];
    int number_point = 0;
    double px,py;
    while (scanf("%lf,%lf", &px, &py) != EOF) {
        p[number_point].x = px;
        p[number_point].y = py;
        number_point ++;
    }
    std::cout << calc_s(p, number_point) << std::endl;
    return 0;
}

double calc_s(point p[], int length)
{
    double area = 0;
    for (int i = 1; i < length - 1; i++) {
        area += calc_s_triangle(p[0], p[i], p[i+1]);
    }
    return area;
}

double calc_s_triangle(point p1, point p2, point p3)
{
    //p3???????????????????§????
    p1.x -= p3.x;
    p1.y -= p3.y;
    p2.x -= p3.x;
    p2.y -= p3.y;
    return calc_s_triangle(p1, p2);
}

double calc_s_triangle(point p1, point p2) {
    double s = (p1.x * p2.y - p1.y * p2.x) / 2;
    if (s < 0) {
        s *= -1;
    }
    return s;
}

Measured memory_bytes: 3220
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}
ll kai(vector<ll> A, ll key) {
	ll an = 0;
	rep(i, A.size()) {
		an += (A.at(i) - 1) / key;
	}
	return an;
}
ll gcd(ll(a), ll(b)) {
	ll c = a;
	while (a % b != 0) {
		c = a % b;
		a = b;
		b = c;
	}
	return b;
}
set<ll> Nprime;

int main() {
	vector<ll> thpr;
	for (ll n = 2; n <= 1000; n++) {
		bool p = true;
		for (ll i = 2; i * i < n; i++) {
			if (n % i == 0) {
				p = false;
				break;
			}
		}
		if (p)thpr.push_back(n);
	}
	ll N;
	cin >> N;
	bool pa = true;
	vector<ll> A(N);
	vector<ll> NO;
	set<ll> prime;
	ll one = 1;
	rep(i, N) {
		cin >> A.at(i);
		if (A.at(i) == 1)one++;
		else {
			ll g = A.at(i);
			rep(j, thpr.size()) {
				if (g %thpr.at(j) == 0) {
					
					if (prime.count(thpr.at(j))) {
						pa = false;
					}
					else {
						prime.insert(thpr.at(j));
					}
					while (g %thpr.at(j) == 0) {
						g /= thpr.at(j);
					}

				}
			}
			if (prime.count(g) && g > 1) {
				pa = false;
			}
			else {
				prime.insert(g);
			}
		}
	}
	ll G = A.at(0);
	rep(i, N - 1) {
		G = gcd(G, A.at(i + 1));

	}
	if (G != 1) {
		cout << "not coprime" << endl;
	}
	else if (pa) {
		cout << "pairwise coprime" << endl;
	}
	else {
		cout << "setwise coprime" << endl;
	}
}




Measured memory_bytes: 14608
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val H = scanner.nextInt()
    val W = scanner.nextInt()
    val N = scanner.nextInt()

    val c = IntArray(H*W)
    var curIndex = 0
    for (i in 1..N) {
        val noc = scanner.nextInt()
        for (j in 1..noc) {
            c[curIndex] = i
            curIndex++
        }
    }

    val builder = StringBuilder()
    for (i in 0 until H) {
        builder.append(if (i%2==0) c.copyOfRange(i*W,(i+1)*W).toStringWithSpace() else c.copyOfRange(i*W,(i+1)*W).reversedArray().toStringWithSpace()).append("\n")
    }
    print(builder.toString())
}

fun IntArray.toStringWithSpace(): String {
    val builder = StringBuilder()
    this.forEach { builder.append(it).append(" ") }
    return builder.removeSuffix(" ").toString()
}

Measured memory_bytes: 40224
N = int(input())
S = input()

for a in ["SS", "SW", "WS", "WW"]:
    x = list(a)
    for i in range(N - 2):
        if S[i + 1] == "o":
            if x[i + 1] == "S":
                x.append(x[i])
            else:
                # x[i + 1] == "W"
                if x[i] == "S":
                    x.append("W")
                else:
                    x.append("S")
        else:
            # S[i + 1] == "x"
            if x[i + 1] == "S":
                if x[i] == "S":
                    x.append("W")
                else:
                    x.append("S")
            else:
                x.append(x[i])

    # Check
    mask_n = (x[-1] == "S") and ((S[-1] == "o" and x[-2] == x[0]) \
                                 or (S[-1] == "x" and x[-2] != x[0]))
    mask_n |= (x[-1] == "W") and ((S[-1] == "o" and x[-2] != x[0]) \
                                  or (S[-1] == "x" and x[-2] == x[0]))
    
    mask_1 = (x[0] == "S") and ((S[0] == "o" and x[-1] == x[1]) \
                                or (S[0] == "x" and x[-1] != x[1]))
    mask_1 |= (x[0] == "W") and ((S[0] == "o" and x[-1] != x[1]) \
                                 or (S[0] == "x" and x[-1] == x[1]))

    if mask_n and mask_1:
        print("".join(x))
        break
else:
    print(-1)


Measured memory_bytes: 58692
#include <algorithm>
#include <iostream>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  unordered_map<int, int> seat;
  for (int i = 0; i < N; ++i) {
    int tmp;
    cin >> tmp;
    auto itr = seat.find(tmp);
    if (itr != seat.end()) {
      seat[tmp] += 1;
    } else {
      seat[tmp] = 1;
    }
  }
  ll ans = 0;
  for (auto itr = seat.begin(); itr != seat.end(); ++itr) {
    if (itr->first <= itr->second){
    ans += (itr->second - itr->first);
    } else {
    ans += itr->second;
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    int n, a, b; cin >> n >> a >> b;
    int ans = 0;
    for(int i = 1; i <= n; i++){
        int t = i, w = 0, x = 0, y = 0, z = 0;
        if(i >= 10000) w = t / 10000; t %= 10000;
        if(i >= 1000) x = t / 1000; t %= 1000;
        if(i >= 100) y = t / 100; t %= 100;
        if(i >= 10) z = t / 10; t %= 10;
        int sum = w + x + y + z + t;
        if(a <= sum && sum <= b){
            ans += i;
        }
    }
    cout << ans << endl;
}


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

int main()
{
    int n,a,b,c=0,k=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a>>b;
        if(a==b)
            c++;
      	else 
          c=0;
      if(c>=3)
      {
        cout<<"Yes";
        return 0;
      }
    }
    cout<<"No";

    return 0;
}


Measured memory_bytes: 3592
n = int(input())
for _ in range(n):
  y,m,d = map(int,input().split())
  days = 0
  if d!=1:
    days += (20-d) if y%3!=0 and m%2==0 else (21-d)
    d = 1
    if m==10:
      y += 1
      m = 1
    else:
      m+=1
  if y!=1000:
    days += sum([19 if y%3!=0 and i%2==0 else 20 for i in range(11-m)])
    y += 1
    days += sum([19*5+20*5 if i%3!=0 else 20*10 for i in range(1000-y)])
  print(days)


Measured memory_bytes: 5612
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long

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


Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define ARRAY_SIZE 10

void sort(int array[],int size){
    int tmp;
    for(int i=0;i<size;i++){
        for(int j=size-1;j>i;j--){
            if(array[j]>array[j-1]){
                tmp=array[j];
                array[j]=array[j-1];
                array[j-1]=tmp;
            }
        }
    }
}

int main() {
    int array[ARRAY_SIZE]={0};
    
    for(int i=0;i<10;i++) cin>>array[i];
    
    sort(array,ARRAY_SIZE);
    
    for(int i=0;i<3;i++){
        cout << array[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>

#define REP(n) for(int i = 0;i < n;i++)
#define LLREP(n) for(long long int  i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 1000000007

int main(){

    ll n,k,ans = 0;
    cin >> n >> k;


    for(ll b = 1;b <= n;b++){

        ll dis = n/b;
        ll mod = n%b;
        ans += dis*max(0LL,b-k)+max(0LL,mod-k+1);
    }
    if(k == 0){
        ans-=n;
    }
    cout << ans << endl;






    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using pq = priority_queue<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -MOD * MOD;
const long double pi = 3.141592653589793;
int main() { // 問題文はしっかり読め!!!
	int h, w;
	cin >> h >> w;
	int n;
	cin >> n;
	V a(n);
	rep(i, n) {
		cin >> a[i];
	}
	VV ans(h, V(w));
	int nh = 0, nw = 0;
	bool right = true;
	rep(i, n) {
		rep(j, a[i]) {
			ans[nh][nw] = (i + 1);
			if (nw == w - 1 && right) {
				nh++;
				right ^= true;
			}
			else if (nw == 0 && !right) {
				nh++;
				right ^= true;
			}
			else (right) ? nw++ : nw--;
		}
	}
	rep(i, h) rep(j, w) {
		cout << ans[i][j] << (j == w - 1 ? "\n" : " ");
	}
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;
const int N = 2000 + 5;

int n;
pair<ll,int> a[N];
ll f[N][N];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i].first;
		a[i].second=i;
	}
	sort(a,a+n,greater<pair<int,int> >());
	for(int i=0;i<n;i++){
		for(int j=0;j<=i;j++){
			int k=i-j;
			f[j+1][k]=max(f[j+1][k],f[j][k]+a[i].first*(a[i].second-j));
			f[j][k+1]=max(f[j][k+1],f[j][k]+a[i].first*(n-k-1-a[i].second));
		}
	}
	ll ans=0;
	for(int i=0;i<=n;i++) ans=max(ans,f[i][n-i]);
	cout<<ans;
	return 0;
}

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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//---------------------------

int main(){
    int a,b; char op;
    cin >> a >> op >> b;
    if(op=='+') cout << a+b << endl;
    else cout << a-b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int p = 1e9+7;
const int N = 500010;
typedef long long ll;
ll n,m;
ll m_n = 1;

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

ll nCk[N];
ll mknk[N];
int main(){
  cin >> n >> m;
  for(ll i=1;i<=n;++i){
    m_n*=(m-i+1); m_n%=p;
  }
  nCk[0]=1;
  for(int k=1;k<=n;++k){
    nCk[k] = nCk[k-1]*(n-k+1);
    nCk[k] %= p;
    nCk[k] *= inv(k);
    nCk[k] %= p;
  }

  mknk[n] = 1;
  for(ll k=n-1;k>=0;--k){
    mknk[k] = mknk[k+1]*(m-k);
    mknk[k] %= p;
  }
  
  ll S = 0;
  for(ll k=1;k<=n;++k){
    ll sign = -1;
    if(k%2) sign=1;
    ll add = nCk[k]*mknk[k];
    add%=p;
    if(sign==-1)
      add = p-add;
    add%=p;
    S+=add;
    S%=p;
  }
  ll X = m_n-S+p;
  X%=p;
  ll ans = m_n*X;
  ans%=p;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 11408
#include <bits/stdc++.h>
using namespace std; 
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ll long long
long long min(long long x,long long y){return (x<y ? x:y);}
long long max(long long x,long long y){return (x>y ? x:y);}
#define ld long double
int stoi(string s) {return atoi(s.c_str());}
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}

int main(){
  string s; cin >> s;
  int k = s.size();
  int rest = 15 - k;
  int w = 0;
  REP(i,k){ w += (s[i]=='o');}
  bool r = (rest+w>=8);
  cout << (r?"YES\n":"NO\n");

}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int N,A,B;
  cin>>N>>A>>B;
  int k=0;
  int l=0;
  int m=0;
  REP(i,N){
    int P;
    cin>>P;
    if(P<=A)k++;
    else if(P<=B)l++;
    else m++;
  }
  cout<<min(k,min(l,m))<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    double a,b;
    int d,r;
    double f;

    scanf("%lf %lf",&a,&b);

    d = a / b;
    r = a - b * d;
    f = a / b;

    printf("%d %d %lf\n",d,r,f);

    return 0;
}



Measured memory_bytes: 2100
#include <stdio.h>
 int x;
 int y;
int main(void){
  
  int x1=  scanf("%d",&x);
  int x2=  scanf("%d",&y);
    if(x<=8&&y<=8){
        printf("Yay!");
    }else{
        printf(":(");
    }
  //  return 0;
}

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

const int MOD = 1e9 + 7;

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

  auto sumup = [&](int64_t i) { return i * (i + 1) / 2; };

  int64_t ans = 0;
  for (int i = k; i <= n + 1; i++) {
    int64_t min = sumup(i - 1);
    int64_t max = sumup(n) - sumup(n - i);
    ans += max - min + 1;
    ans %= MOD;
  }
  ans = ans % MOD;
  cout << ans << endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
	int a,b,ans=0;
	cin>>a>>b;
	for(int i=a;i<=b;i++){
		if(i/10000==i%10000%1000%100%10 && i%10000/1000==i%10000%1000%100/10)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

int n,a[N],b[N];
int main()
{
	scanf("%d",&n);
	for (int i=1; i<=n; i++) scanf("%d%d",&a[i],&b[i]);
	n++;
	sort(a+1,a+n+1); sort(b+1,b+n+1);
	long long ans=0;
	for (int i=1; i<=n; i++) ans+=max(0,a[n-i+1]-b[i]);
	printf("%lld\n",ans*2); 
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

signed main(){
	int h,w,ch,cw,dh,dw;
	cin>>h>>w>>ch>>cw>>dh>>dw;
	ch--;cw--;dh--;dw--;
	vector<string> s(h);
	rep(i,h)cin>>s[i];

	
	deque<pii> q;
	q.push_front(make_pair(ch,cw));
	vector<vi> added(h,vi(w,0));

	vector<vi> dist(h,vi(w,INF));
	dist[ch][cw]=0;

	while(!q.empty()){
		auto p=q.front();
		q.pop_front();
		int x=p.first;
		int y=p.second;
		// cout<<x<<' '<<y<<' '<<dist[x][y]<<endl;

		// rep(i,4){
		// 	int nx=x+dx[i];
		// 	int ny=y+dy[i];
		// 	chmin(dist[x][y],dist[nx][ny]);			
		// }

		int cnt=0;
		rep(i,4){
			int nx=x+dx[i];
			int ny=y+dy[i];
			if(nx<0||nx>h-1||ny<0||ny>w-1) continue;
			// if(dist[nx][ny]<INF)continue;
			if(s[nx][ny]=='#')continue;
			if(added[nx][ny]>1) continue;
			chmin(dist[nx][ny],dist[x][y]);
			q.push_front(make_pair(nx,ny));
			added[nx][ny]++;
			cnt++;
		}		
		if(cnt==4)continue;
		FOR(i,-2,2){
			FOR(j,-2,2){
				
				int nx=x+i;
				int ny=y+j;
				if(nx<0||nx>h-1||ny<0||ny>w-1) continue;
				if(s[nx][ny]=='#')continue;
				// if(dist[nx][ny]<INF) continue;
				if(added[nx][ny]>0) continue;


				
				chmin(dist[nx][ny],dist[x][y]+1);	

				q.push_back(make_pair(nx,ny));
				added[nx][ny]=1;
			}
		}
	}

	if(dist[dh][dw]<INF){
		cout<<dist[dh][dw]<<endl;
	}else{
		cout<<-1<<endl;
	}

	// rep(i,h){
	// 	rep(j,w){
	// 		if(j>0)cout<<' ';
	// 		cout<<dist[i][j];
	// 	}
	// 	cout<<endl;
	// }

	return 0;
}


Measured memory_bytes: 21360
#include <bits/stdc++.h> 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
string S, T;
const string NF = "UNRESTORABLE";
string res = NF;

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

    cin >> S >> T;
    int n = S.size(), m = T.size();
    res = NF;

    rep(i, n - m + 1){
        bool ok = true;
        rep(j, m){
            if(S[i+j] != '?' and S[i+j] != T[j]){
                ok = false;
            }
        }

        if(ok){
            string cur = S;
            for(auto& e : cur){
                if(e == '?') e = 'a';
            }
            rep(j, m){
                cur[i+j] = T[j];
            }
            if(res == NF){
                res = cur;
            }
            chmin(res, cur);
        }
    }

    cout << res << endl;

    return 0;
}


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

int main(void) {
  int N, M;
  cin >> N >> M;
  int freq[N] = {};
  
  int a,b;
  for (int i = 0; i < M; ++i) {
    cin >> a >> b;
    ++freq[a-1];
    ++freq[b-1];
  }
  for (int i = 0; i < N; ++i) {
    cout << freq[i] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
const int maxN = 1000001;
bool prime[maxN + 1]; 
int32_t main(){
    SPEED;
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i < n; ++i){
        ans += (n - 1) / i;
    }
    cout << ans ;
}

Measured memory_bytes: 3664
#include<stdio.h>

int n, m;
int A[20], Q[200];

int solve(int i, int m);

int main(){
  int i;
  scanf("%d", &n);
  for(i = 0 ; i < n ; i++) scanf("%d", &A[i]);
  scanf("%d", &m);
  for(i = 0 ; i < m ; i++) scanf("%d", &Q[i]);
  for(i = 0 ; i < m ; i++){
    if(solve(0, Q[i]) == 1) printf("yes\n");
    else printf("no\n");
  }
}

int solve(int i, int m){
  if(m == 0) return 1;
  if(i >= n) return 0;
  int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
  return res;
}



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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

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

  int sum = 0;
  rep(i, N) sum += A[i];

  vector<int> d;
  for (int i = 1; i * i <= sum; i++) {
    if (sum % i == 0) {
      d.eb(i);
      if (sum / i != i) {
        d.eb(sum / i);
      }
    }
  }

  sort(rall(d));

  rep(i, sz(d)) {
    int mod = d[i];
    vector<int> a = A;
    rep(j, sz(a)) a[j] %= mod;

    sort(all(a));
    ll m = 0, p = 0;
    rep(j, sz(a)) p += (mod - a[j]);

    rep(j, sz(a)) {
      m += a[j];
      p -= (mod - a[j]);
      if (m == p && m <= K) {
        cout << mod << endl;
        return 0;
      }
    }
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;
typedef double d;
typedef int i;
 
int main() {
  i a , b , c;
  cin >> a >> b >> c;
  if ( b - a == c - b ) cout << "YES";
  else cout << "NO";
}

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

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

    int X = x;
    int Y = y;
    if (X > Y) cout << '>' << endl;
    else if (X < Y) cout << '<' << endl;
    else cout << '=' << endl;

    return 0;
}

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

struct Combination{
    vector<ll> fac,finv,inv;
    Combination(int mx){init(mx);}
    void init(int mx){
        fac.resize(mx+1);
        finv.resize(mx+1);
        inv.resize(mx+1);
        fac[0]=fac[1]=1;
        finv[0]=finv[1]=1;
        inv[1]=1;
        for(int i=2;i<=mx;i++){
            fac[i]=fac[i-1]*i%MOD;
            inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
            finv[i]=finv[i-1]*inv[i]%MOD;
        }
    }
    ll calc(int n,int k){
        return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
    }
};

int main(){
    Combination comb(2000010);
    int r1,r2,c1,c2;
    cin>>r1>>c1>>r2>>c2;
    ll ans=comb.calc(r2+c2+2,r2+1)-comb.calc(r1-1+c2+2,r1-1+1)-comb.calc(r2+c1-1+2,r2+1)+comb.calc(r1-1+c1-1+2,r1-1+1);
    cout<<(ans+MOD)%MOD<<endl;
}


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

Measured memory_bytes: 3624
import qualified Control.Monad as Monad
import qualified Data.ByteString.Char8 as BS
import qualified Data.Maybe as Maybe
import qualified Debug.Trace as Trace

succ' :: Char -> Char
succ' c =
    case c of
    'Z' -> 'A'
    _ -> succ c

succN :: Int -> Char -> Char
succN n c
    | (n == 0) = c
    | (n == 1) = succ' c
    | otherwise = succN (n - 1) (succ' c)

solve :: Int -> String -> String
solve n s = map (succN n) s

main = do
    n <- (fst . Maybe.fromJust . BS.readInt) <$> BS.getLine
    s <- getLine
    let ans = solve n s
    putStrLn ans

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

vector<int> v;

int N;
int main (){
    cin >> N;
    for(int i=0;i<N;i++) {
        int x;
        cin >> x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    int mid = (N)/2;
    if(v[mid] == v[mid-1]) cout << 0 << endl;
    else cout << v[mid] - v[mid-1] << endl;
    return 0;
}

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

int main()
{
    ll N,M;
    cin >> N >> M;
    vector<ll> X(M);
    vector<ll> diff(M-1);

    for(int i = 0; i < M; i++)
    {
        cin >> X.at(i);
    }

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

    
    for(int i = 1; i < M; i++)
    {
        diff[i-1] = X.at(i) - X.at(i-1);
    }

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

    ll count = 0;
    for(int i = 0; i < M-N; i++)
    {
        count += diff.at(i);
    }

    cout << count << endl;
}

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

int main(){
  int N,K;
  int h[10000000];
  cin >> N >>K;
 
  for(int i=0;i<N;i++){
      cin >> h[i];
  }
  
  int dp[N];
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  if(K==1){
    for(int i=2;i<N;i++){
    dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
    }
  }else{
 for(int i=2;i<N;i++){
  int M=K; int Min;
   if(i<K) M=i;
   for(int j=M;j>1;j--){
if(j==M){Min =min(dp[i-j]+abs(h[i]-h[i-j]),dp[i-(j-1)]+abs(h[i]-h[i-(j-1)]));
        }else{Min=min(Min,dp[i-(j-1)]+abs(h[i]-h[i-(j-1)]));}
   }

   dp[i]=Min;

 }
  }
  cout <<dp[N-1] <<endl;
}

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

int main(){
int N, A, B;
  cin >> N >> A >> B;
int cnt, ans;
ans = 0;  
  
  for(int i = 1;i <= N;i++){
    int s = i;
    cnt = 0;
  while(s >= 10){
    cnt += s % 10;
    s /= 10;  
  }
    cnt += s;
    if(A <= cnt && cnt <= B) ans += i;
  }
  
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 256
#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);

  string s;
  int d;
  while (cin >> s >> d) {
    const lli mod = 1e9 + 7;
    const int N = 10000 + 5;
    const int M = 100;
    static lli dp[N][M][2];
    fill(&dp[0][0][0], &dp[N - 1][M - 1][2 - 1] + 1, 0);
    dp[0][0][0] = 1;
    for (int i = 0; i < s.size(); ++i) {
      for (int j = 0; j < d; ++j) {
        for (int k = 0; k < 10; ++k) {
          (dp[i + 1][(j + k) % d][true] += dp[i][j][true]) %= mod;
          if (s[i] - '0' >= k) {
            (dp[i + 1][(j + k) % d][s[i] - '0' > k] += dp[i][j][false]) %= mod;
          }
        }
      }
    }
    lli sum = (dp[s.size()][0][true] + dp[s.size()][0][false]) % mod;
    cout << (sum + mod - 1) % mod << endl;
  }

  return 0;
}


Measured memory_bytes: 15872
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
template <class T> using max_priority_queue = priority_queue<T>;
template <class T>
using min_priority_queue = priority_queue<T, std::vector<T>, std::greater<T>>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
string S;
int N;
const int MAX_N = 100100;
ll dp[MAX_N][4];
int main() {
  cin >> S;
  N = S.size();
  dp[0][0] = 1;
  for (int i = 0; i < N; i++) {
    dp[i][0] %= MOD;
    const char c = S[i];
    const ll p = c == '?' ? 3 : 1;
    dp[i + 1][0] += p * dp[i][0];
    dp[i + 1][1] += p * dp[i][1];
    dp[i + 1][2] += p * dp[i][2];
    dp[i + 1][3] += p * dp[i][3];
    if (c == 'A') {
      dp[i + 1][1] += dp[i][0];
    } else if (c == 'B') {
      dp[i + 1][2] += dp[i][1];
    } else if (c == 'C') {
      dp[i + 1][3] += dp[i][2];
    } else {
      dp[i + 1][1] += dp[i][0];
      dp[i + 1][2] += dp[i][1];
      dp[i + 1][3] += dp[i][2];
    }
    dp[i + 1][1] %= MOD;
    dp[i + 1][2] %= MOD;
    dp[i + 1][3] %= MOD;
  }
  cout << dp[N][3] % MOD << endl;
  return 0;
}


Measured memory_bytes: 3584
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>
#include <fstream>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	string s; cin >> s;
	if (s.size() < 4)cout << "No" << endl;
	else
	{
		if (s.substr(0, 4) == "YAKI")cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

Measured memory_bytes: 3608
<?php

fscanf(STDIN, '%d', $n);
$line = trim(fgets(STDIN));
$arr = explode(' ', $line);
echo implode(' ', $arr), PHP_EOL;
for($i=1;$i<$n;$i++){
  $v=$arr[$i];
  $j=$i-1;
  while($j>=0 && $arr[$j]>$v){
    // v($j);
    $arr[$j+1]=$arr[$j];
    $j--;
    $arr[$j+1]=$v;
  }
  echo implode(' ', $arr), PHP_EOL;
}


Measured memory_bytes: 9276
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int const lim=100000000;
typedef long long ll;
ll s;
int a[601][601],i,j,k,n,m,x,y;
int main(){
	scanf("%d%d%d%d",&n,&m,&x,&y);
	if (x==1&&y==1){
		puts("No");return 0;
	}
	for (i=1,s=0;i<=n;i++)
	 for (j=1;j<=m;j++){
	 	if (i%x==0&&j%y==0) a[i][j]=-lim;else{
	 		a[i][j]=(lim-1)/(x*y-1);
	 		if (i%x==1&&j%y==1) a[i][j]+=(lim-1)%(x*y-1);
		 }
		s+=a[i][j];
	 }
	if (s>0){
		puts("Yes");
		for (i=1;i<=n;i++)
		 for (j=1;j<=m;j++) printf("%d%c",a[i][j],(j==m)?'\n':' ');
	}else puts("No");
	return 0;
}

Measured memory_bytes: 3712
/*
 *  author : Atul Anand   
 *  created on : Wed Apr 01 2020
 */

import java.io.*;
import java.util.*;

public class Main{

    public static void main(String[] args) throws IOException {
        int N = in.nextInt();
        HashMap<String, Integer> map = new HashMap<>();
        for(int i = 0; i < N; i++){
            String s = in.next();
            map.put(s, map.getOrDefault(s, 0) + 1);
        }
        TreeSet<String> set = new TreeSet<>();
        int maxVote = 0;
        for(String s: map.keySet()){
            int vote = map.get(s);
            if(vote > maxVote){
                set.clear();
                maxVote = vote;
                set.add(s);
            }
            else if(vote == maxVote){
                set.add(s);
            }
        }
        
        for(String s: set){
            println(s);
        }

        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static void read(int arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    }
    
    static void read(long arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    }
    
    static void read(String arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.next(); 
    	} 
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i]+" "); 
    	} 
    	println(""); 
    }

    static void println(int arr[][]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		println(arr[i]); 
    	}
    }
    
    static void debug(Object O) { 
    	System.out.println(O); 
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}

Measured memory_bytes: 65076