akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main()
{
    int n[3],i,j;
    for(i=0;i<3;i++) scanf("%d",&n[i]);
    for(i=0;i<3;i++)
        for(j=i;j<3;j++)
    {
        if(n[i]<n[j])
        {
            int temp=n[i];
            n[i]=n[j];
            n[j]=temp;
        }
    }
    // printf("%d %d %d",a[0],a[1],a[2]);
    int res=(n[0]-n[2]);
    printf("%d\n",res);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rrep(i, n) for(ll i = n - 1; i > -1; i--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
#define se second
#define debug(V) rep(i, V.size()) cout << V[i] << " ";
const ll INF = (1 << 30) - 1;
const ll MOD = 1000000007 /*988244353*/;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, h, x, y, z, p, q, n, t, r, k, w, l, ans, i, j, u, v;
string S, T;
vl A, B;
vector<PP> node, UE[513];
void solve() {
    UE[0].pb({0, 0});
    rep(i, 513) {
        if(i) {
            k = i / 2;
            rep(j, UE[k].size()) {
                a = UE[k][j].fi;
                b = UE[k][j].se;
                UE[i].pb({a, b});
                UE[i].pb({a + node[i].fi, b + node[i].se});
            }
            sort(all(UE[i]));
            rep(j, UE[i].size()) {
                if(j)
                    UE[i][j].se = max(UE[i][j].se, UE[i][j - 1].se);
            }
        }
    }

    /*rep(i, 4) {
        for(PP x : UE[i]) {
            cout << x.fi << " " << x.se << "  ";
        }
        cout << endl;
    }*/

    while(q--) {
        cin >> v >> l;
        if(v <= 512) {
            k = upper_bound(all(UE[v]), (PP){l, INF}) - UE[v].begin() - 1;
            cout << UE[v][k].se << endl;
        } else {
            vector<PP> SITA;
            SITA.pb({0, 0});
            while(v > 512) {
                t = SITA.size();
                rep(i, t) {
                    a = SITA[i].fi;
                    b = SITA[i].se;
                    SITA.pb({a + node[v].fi, b + node[v].se});
                }
                v /= 2;
            }
            ans = 0;
            rep(i, SITA.size()) {
                a = SITA[i].fi;
                b = SITA[i].se;
                if(a <= l) {
                    c = l - a;
                    k = upper_bound(all(UE[v]), (PP){c, INF}) - UE[v].begin() - 1;
                    ans = max(ans, b + UE[v][k].se);
                }
            }

            cout << ans << endl;
        }
    }
}
int main() {
    // cout<<fixed<<setprecision(15);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    node.pb({0, 0});
    rep(i, n) {
        cin >> a >> b;
        node.pb({b, a});
    }
    cin >> q;
    solve();
}

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

using ll = long long;

int main() {
    int N;
    cin >> N;
    ll Nsum = 0;
    rep(i, N + 1) Nsum += i;
    vector<ll> A(N + 1);
    ll Asum = 0;
    rep(i, N) {
        cin >> A[i];
        Asum += A[i];
    }
    A[N] = A[0];
    if (Asum % Nsum != 0) {
        cout << "NO" << endl;
        return 0;
    }
    ll n = Asum / Nsum;
    ll s = 0;
    rep(i, N) {
        ll d = A[i + 1] - A[i];
        // d = n - x - (N - 1) * x
        //   = n - N * x
        // x = (n - d) / N;
        if ((n - d) % N != 0 || n - d < 0) {
            cout << "NO" << endl;
            return 0;
        }
        s += (n - d) / N;
    }
    if (s == n) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

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

int main(){
    char str[33];
    vector<char> rh={'y','u','i','o','p','h','j','k','l','n','m'};
    while(1){
        cin >> str;
        if(str[0]=='#') break;
        
        int count=0;
        bool right;
        for(int i=0; str[i]!=0; i++){
            auto itr = find(rh.begin(),rh.end(),str[i]);
            bool hand= (itr!= rh.end())?true:false;
            if(i==0)right=hand;
            if(right!=hand){
                count++;
                right=hand;
            }
        }
        cout << count << endl;
    }    
    return 0;
}

Measured memory_bytes: 3064
import java.util.Scanner;

/**
 * @author yoshizaki
 *
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner= new Scanner(System.in);
        int tax8 = scanner.nextInt();
        int tax10 = scanner.nextInt();
        int price = 0;
        
        if (20 < (tax10 - tax8) || (tax10- tax8) < 0) {
            price = -1;
        } else {
            
            for(int i = 0; i <= 9; i++) {
                int pPrice10 = tax10 * 10;
                int p10 = (int) ((pPrice10 + i)* 0.08);
                if(tax8 != p10) {
                    price = -1;
                    continue;
                } else {
                    price = pPrice10 + i;
                    break;
                }
            }
        }
        System.out.println(price);
    }
}


Measured memory_bytes: 24020
#include<iostream>
#include<vector>
using namespace std;
int main() {
	string a;
	int ans = 0;
	cin >> a;
	
	for (int i = 0; i < a.size()/2; i++) {
		if (a[i] == a[a.size() - i-1]) {
			continue;
		}
		else {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
#include <math.h>
using namespace std;
using ll = long long;
using ld = long double;
using namespace std::chrono; 
#define fo(i,z,n) for(int i = z;i<n;i++)
#define Fo(i,z,n) for(ll i = z;i<n;i++)
#define INT_BITS 32
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> > 
#define pb push_back
#define f first
// #define s second
#define int long long
#define all(c) (c).begin(), (c).end()
#define endl '\n'
// auto start = high_resolution_clock::now(); 
// auto stop = high_resolution_clock::now(); 
// auto duration = duration_cast<microseconds>(stop - start); 
 
// cout << duration.count() << endl; 


bool check(int* arr,int mid ,int k,int n){
	int r = 0;
	fo(i,0,n){
		r += (arr[i]+mid-1)/mid;
		r--;
	}
	if(r <= k)return true;
	else return false;
}



int32_t main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     cout.tie(0);
     // int t;
     // cin >> t;

     // while(t--){

 
     // }

     int n,k;
     cin >> n >> k;
     int arr[n];
     fo(i,0,n)cin >> arr[i];
sort(arr,arr+n);

int l = 0;
int r = mod;
int ans = -1;
while(r-l > 1){
	int mid = (l+r)/2;
	// cout << mid << endl;
	if(check(arr,mid,k,n)){
		ans = mid;
		r = mid;
	}
	else l = mid;
}

cout << ans << endl;

     

return 0;
}



Measured memory_bytes: 5152
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
using namespace std;

#define pb push_back
#define fst first
#define snd second

typedef long long ll;
typedef pair<int,int> pii;
template<typename T> using min_queue=priority_queue<T,vector<T>,greater<T> >;

const ll MOD=1e9+7;

int N;
int a[10100],b[10100];

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

  cin>>N;
  ll sa=0,sb=0;
  for(int i=0;i<N;i++) cin>>a[i],sa+=a[i];
  for(int i=0;i<N;i++) cin>>b[i],sb+=b[i];
  if(sa>sb){
    cout<<"No\n";
    return 0;
  }
	

  ll c=sb-sa;
  ll d=sb-sa;
  
  for(int i=0;i<N;i++){
    if(a[i]>b[i]){
      d-=(a[i]-b[i]);
      b[i]=a[i];
    }
    if(d<0){
      cout<<"No\n";
      return 0;
    }
  }
  for(int i=0;i<N;i++){
    if(a[i]<b[i]){
      int e=b[i]-a[i];
      c-=(e+1)/2;
      d-=e%2;
      a[i]=b[i];
    }
    if(c<0 || d<0){
      cout<<"No\n";
      return 0;
    }
  }
  cout<<"Yes\n";
  return 0;
}


Measured memory_bytes: 384
def bsearch_first(l, r, &pred)
    return nil if l > r
    c = (l + r) / 2 
    if pred[c]
        bsearch_first(l, c-1, &pred) || c
    else
        bsearch_first(c+1, r, &pred)
    end
end

n, k = gets.split.map(&:to_i)
x = 0
loop do
    n -= 1
    break if n == 0
    y = bsearch_first(x, (1 + x) * k) {|z| z - (1 + z / k) >= x}
    x = y
end
puts x


Measured memory_bytes: 9436
from math import sqrt
point_num, dimension = tuple(int(i) for i in input().split(" "))
cor_list = []
for i in range(point_num):
    cor_list.append(tuple(int(j) for j in input().split(" ")))


def distance(X, Y):
    in_sqrt = 0
    for k in range(dimension):
        in_sqrt += (X[k] - Y[k]) ** 2
    return sqrt(in_sqrt)


ans = 0
for i in range(point_num - 1):
    for j in range(i + 1, point_num):
        d = distance(cor_list[i], cor_list[j])
        if d == int(d):
            ans += 1
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int t,an,bn,a[100001],b[100001],x,y,c;
int ans1=0x3f3f3f3f,ans2=0x3f3f3f3f,ans;
int main()
{
	scanf("%d%d%d",&an,&bn,&t);
	for(int i=1;i<=an;i++)scanf("%d",&a[i]),ans1=min(ans1,a[i]);
	for(int i=1;i<=bn;i++)scanf("%d",&b[i]),ans2=min(ans2,b[i]);
	ans=ans1+ans2;
	while(t--)
	{
		scanf("%d%d%d",&x,&y,&c);
		ans=min(ans,a[x]+b[y]-c);
	}
	printf("%d",ans);
	return 0;
}


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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

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

  int sum = 0;
  sum += (x/500) * 1000;
  sum += ((x%500)/5) * 5;

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC143B
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputInt = int.Parse(Console.ReadLine());
            var inputArr = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int N = inputInt;
            int[] d = inputArr;

            int ans = 0;
            //string ans = "";

            for(int i = 0; i < N - 1; i++)
            {
                for(int j = i + 1; j < N; j++)
                {
                    ans += d[i] * d[j];
                }
            }

            Console.WriteLine(ans);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13396
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	float f,h,z,c;
	int a,s,d,g,i,j,x;
	while(1){
		scanf("%d",&a);
		if(a==0) break;
		scanf("%d",&s);
		c=0;
		x=0;
		for(i=0;i<a;i++){
			scanf("%d %f %d",&d,&f,&g);
			h=1;
			if(g==1) h=1+s*(f/100);
			else if(g==2) for(j=0;j<s;j++) h*=1+(f/100);
			//printf("%f\n",h);
			if(h>c){
				c=h;
				x=d;
			}
		}
		printf("%d\n",x);
	}
	return 0;
}

Measured memory_bytes: 2668
def examC():
    N = I()
    S = SI()
    E = S.count("E"); W = N-E
    curW = 0; curE = 0
    ans = N-1
    for i in range(N):
        if S[i]=="W":
            curW +=1
        cur = N -1 - (W-curW) - curE
        if S[i]=="E":
            curE +=1
        ans = min(ans,cur)
#        print(cur)
    print(ans)
    return

def examD():
    N = I()
    A = LI()
    cur = [0]*21
    k = 0; ans = 0
    flag = True
    for i in range(N):
        for j in range(21):
            if cur[j]>=2:
                a = A[i]
                for l in range(21):
                    if a & (1 << l) == (1 << l):
                        cur[l] -= 1
                continue
        flag = True
        while(k<N):
            a = A[k]
            for j in range(21):
                if a&(1<<j)==(1<<j):
                    if cur[j]>=1:
                        flag = False
                        break
            if flag:
                for j in range(21):
                    if a & (1 << j) == (1 << j):
                        cur[j] += 1
                k +=1
            if not flag:
                break
        ans += k-i
#        print(i,k,ans,cur)
        a = A[i]
        for j in range(21):
            if a & (1 << j) == (1 << j):
                cur[j] -= 1

    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,ALPHABET
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]
ALPHABET = [chr(ord('A') + i) for i in range(26)]

if __name__ == '__main__':
    examD()


Measured memory_bytes: 72560
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main() {
	int r, g, b, n, r_n, g_n, sum,cnt = 0;
	scanf("%d%d%d%d", &r, &g, &b, &n);
	for (r_n=0; r_n <= n; r_n++) {
		g_n = 0;
		if (r_n * r + g_n * g > n)
			break;
		for (; g_n <= n - r_n; g_n++) {
			if (r_n * r + g_n * g > n)
				break;
			if ((n - r_n * r - g_n * g) % b == 0)
				cnt++;
		}
	}
	printf("%d\n", cnt);
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

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

	int mod = c % b;
	int step = a;
	for (int i = 1; i <= 1000; ++i) {
		if (a % b == mod) {
			cout << "YES\n";
			return 0;
		}

		a += step;
	}

	cout << "NO\n";

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }


int main() {
    int n; cin >> n;
    string s; cin >> s;
    vector<int> bsum(n+2, 0);
    vector<int> wsum(n+2, 0);
    for(int i = 0; i < n; ++i) {
        if(s[i] == '#') bsum[i+1]++;
        else wsum[i+1]++;
    }
    for(int i = 0; i < n; ++i) {
        bsum[i+1] += bsum[i];
        wsum[i+1] += wsum[i];
    }

    /*for(int i = 0; i <= n; ++i) {
        cout << bsum[i] << " ";
    }
    cout << endl;
    for(int i = 0; i <= n; ++i) {
        cout << wsum[i] << " ";
    }
    cout << endl;*/

    int ans = 1e9;
    chmin(ans, bsum[n]-bsum[0]);
    chmin(ans, wsum[n]-wsum[0]);
    for(int i = 0; i < n; ++i) {
        if(s[i] == '#') {
            int ch = (bsum[i]-bsum[0])+(wsum[n]-wsum[i]);
            chmin(ans, ch);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5248
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    int ans = n*(n-1)/2 + m*(m-1)/2;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
X = [int(T) for T in input().split()]
SortX = sorted(X)
MedL = SortX[(N//2)-1]
MedR = SortX[(N//2)]
Disp = [0]*N
for T in range(0,N):
    if X[T]<=MedL:
        Disp[T] = str(MedR)
    else:
        Disp[T] = str(MedL)
print('\n'.join(Disp))

Measured memory_bytes: 36412
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include<cstdio>
#include <vector>
#include<queue>
#include<limits.h>
#include<string.h>
#include<functional>
using namespace std;

signed main() {
	int a; cin >> a;
	printf("%d:%d:%d\n", a / 3600, a % 3600 / 60, a % 3600 % 60);
}

Measured memory_bytes: 3228
#include <iostream>
#include <numeric>
using namespace std;
using ll = long long;

int n2(ll n) {
  int ret{};
  while (n % 2 == 0) {
    n /= 2;
    ++ret;
  }
  return ret;
}

int main() {
  ll N, M, a, r{1}, t{};
  cin >> N >> M;
  while (cin >> a) {
    if (!t) {
      t = n2(a);
    } else if (t != n2(a)) {
      r = M + 1;
      break;
    }
    r = lcm(r, a / 2);
    if (r > M) break;
  }
  cout << (M / r + 1) / 2 << endl;
}


Measured memory_bytes: 3644
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 101
void initialize(void);
void push(int);
int pop(void);
int isEmpty(void);
int isFull(void);
int S[MAX];
int top;
 
int main(void){
 
 
  int x,y,i=0;
  char s[MAX];
  initialize();
  while(scanf("%s",s) != EOF){
    if(s[0] == '+'){
      x = pop();
      y = pop();
      x = x + y;
    }
    else if(s[0] == '-'){
      x = pop();
      y = pop();
      x = y - x;
    }
    else if(s[0] == '*'){
      x = pop();
      y = pop();
      x = x * y;
    }
    else x = atoi(s);
 
    push(x);
  }
 
 
  printf("%d\n",S[top]);
  return 0;
}
 
void initialize(void){
  top = 0;
}
 
int isEmpty(void){
  if( top == 0)return 1;
  else return 0;
}
 
int isFull(void){
  if( top >= MAX -1)return 1;
  else return 0;
}
 
void push(int x){
  if(isFull() == 1) printf("error overflow\n");
 
  top++;
  S[top] = x;
}
 
int pop(){
  if(isEmpty() == 1) printf("error underflow\n");
 
  top--;
  return S[top+1];
}

Measured memory_bytes: 548
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;

#define huge 1000000007

int main(void) {

	int N = 0, A=0, B = 0;
	cin >> N >> A >> B;

	int res = 0;
	if (N*A >= B)
		res = B;
	else res = A*N;

	cout << res << endl;
	return 0;


}

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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define SPACEREP(lst,itr) for(auto itr=lst.begin(); itr!=lst.end();++itr){cout<<*itr<<(++itr!=anslist.end()?" ":"\n");itr--;}
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

int convert(string s){
    int hh,mm,ss;
    hh = ((s[0]-'0')*10+(s[1]-'0'))*60*60;
    mm = ((s[3]-'0')*10+(s[4]-'0'))*60;
    ss = ((s[6]-'0')*10+(s[7]-'0'));
    return hh+mm+ss;
}

int main(){
    int n,start,end;
    string s;
    list< list<int> > inputs;
    while(1){
        cin >> n;
        if(n==0)break;
        list<int> tmp={};
        REP(i,0,n){
            cin >> s;
            start = convert(s);
            cin >> s;
            end = convert(s);
            tmp.push_back(start);
            tmp.push_back(end);
        }
        inputs.push_back(tmp);
    }

    for(auto x : inputs){
        int time[86401]={0};
        int ans=0;
        for(auto itr=x.begin();itr!=x.end();itr++){
            time[*itr]+=1;
            itr++;
            time[*itr]-=1;
        }
        ans=max(time[0],ans);
        REP(i,1,86400){
            time[i]+=time[i-1];
            ans=max(time[i],ans);
        }
        p(ans);
    }
    
}


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

int main()
{
  int x, y, temp;

  while(1)
    {
      cin >> x >> y;

      if(x==0 && y==0)
	break;

      if(x > y)
	{
	temp = x;
	x = y;
	y = temp;
      }

      cout << x << " "  << y << endl;
    }
  return 0;
}

Measured memory_bytes: 1160
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    k, a, b = map(int, input().split())

    if b - a < 2:
        print(k + 1)
    else:
        n = k - a + 1
        res = a + n // 2 * (b - a)
        res += 1 if n % 2 != 0 else 0
        print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3060
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
a.sort()
if n%2==0:
    for i in range(n):
        if a[i]==(i//2)*2+1:
            continue
        else:
            print(0)
            break
    else:
        print(pow(2,n//2,mod))
else:
    for i in range(n):
        if a[i]==((i+1)//2)*2:
            continue
        else:
            print(0)
            break
    else:
        print(pow(2,(n-1)//2,mod))

Measured memory_bytes: 13880
h, w = map(int, input().split())
n = int(input())
ls = list(map(int, input().split()))

index = 0
total = 0
count = 0
a = ls[index]
res = [[0] * w for _ in range(h)]
for y in range(h):
    for x in range(w):
        if y % 2 == 1:
            x = w - 1 - x
        res[y][x] = index + 1
        count += 1
        total += 1
        if total < h * w and count >= a:
            index += 1
            a = ls[index]
            count = 0
for row in res:
    print(*row)

Measured memory_bytes: 3828
N,K=map(int,input().split())
x=list(map(int,input().split()))
ans=10**9
for i in range(N-K+1):
    tmp1=abs(x[i])+abs(x[i]-x[i+K-1])
    tmp2=abs(x[i+K-1])+abs(x[i]-x[i+K-1])
    ans=min([ans,tmp1,tmp2])
print(ans)


Measured memory_bytes: 14568
//Bismillahir Rahmanir Rahim
#include <bits/stdc++.h>
#define ll long long int
#define li long int
#define ld long double
using namespace std;
const ll mod = 1e9 + 7;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

    string s;
    cin >> s;
    long long sum = 0;
    for(int i = 0; i < s.size(); i++){
        sum += (s[i] - '0') % 9;
        sum %= 9;
    }
    if(sum % 9 == 0) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 3704
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

a,b,c,d = map(int, input().split())

ans = "Yes"
if abs(a-c) <= d:
    pass
elif abs(a-b) <= d and abs(b-c) <= d:
    pass
else:
    ans = "No"
print(ans)




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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
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;
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;
ll mod_pow(ll x, ll n) {
    if (n == 0) return 1;
    if (n % 2 == 0) return mod_pow(x * x % MOD, n / 2) % MOD;
    else return x * mod_pow(x, (n - 1)) % MOD;
}
ll mod_pow_r(ll x, ll n) {
    if (x == 0) return 0;
    if (n == 0) return 1;
    ll ret = 1;
    while (n) if (n & 1) ret = ret * x % MOD; x = x * x % MOD; n /= 2;
    return ret;
}
ll factorial(ll n) {
    ll ret = 1;
    REP(i, n) ret *= (i + 1); ret %= MOD;
    return ret;
}
ll combination(ll n, ll r) {
    if (n < 0 || n < r || r < 0) return 0;
    ll fn = factorial(n);
    ll fr = factorial(r);
    ll fn_r = factorial(n-r);
    ll d = (mod_pow(fr, MOD - 2) * mod_pow(fn_r, MOD - 2)) % MOD;
    ll u = fn % MOD;
    return u * d % MOD;
}

void solve() {
    int n; cin >> n;
    vector<string> a;
    a.resize(n);
    FOR(i, 0, n) cin >> a[i];

    int count = 0;
    set<string> s;
    FOR(i, 0, n) {
        auto it = s.find(a[i]);
        if (it == s.end()) {
            ++count;
            s.insert(a[i]);
        } else {
            continue;
        }
    }
    cout << count;
}

signed main() {
    solve();
    return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A+B > C+D) 
    cout << "Left" <<endl;
  else if (A+B < C+D)
    cout << "Right" <<endl;
  else
    cout << "Balanced" << endl;
}


Measured memory_bytes: 3612
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

ll inv[100010];

ll kaijo(ll n){
  ll ans=1;
  for(int i=1;i<=n;i++){
    ans=ans*i%MOD;
  }
  return ans;
}

int main(){
  inv[1]=1;
  int N; cin >> N;
  ll rui=kaijo(N-1);
  vector<ll> x(N);
  rep(i,N) cin >> x[i];
  ll ans=0;
  for(int i=0;i<=N-1;i++){
    if(i==0){
      ans+=(x[N-1]-x[i])*rui%MOD;
      continue;
    }
    inv[i+1]=MOD-inv[MOD%(i+1)]*(MOD/(i+1))%MOD;
    ans+=(x[N-1]-x[i])*(rui*inv[i+1]%MOD)%MOD;
  }
  cout << ans%MOD<< endl;
  
}

Measured memory_bytes: 1792
#!/usr/bin/env python3

from math import ceil

def main():
    n, k = list(map(int, input().split()))
    # ダイスの目iのとき、表が必要な数の配列
    needs = [0] * (n + 1)
    p = 0
    current = len(bin(k)) - 2
    for i in range(1, n + 1):
        if k > i * 2**(current-1):
            needs[i] = current
        else:
            current -= 1
            needs[i] = current
        if needs[i] <= 0:
            p += 1 / n
        else:
            p += 0.5 ** needs[i] / n
    print(p)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3828
import java.util.*;


class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		String[] s = new String[ N ];
		for(int i = 0 ; i < N ; i++){
			s[i] = sc.next();
		}
		
		int M = sc.nextInt();
		String[] t = new String[ M ];
		for(int i = 0 ; i < M ; i++){
			t[i] = sc.next();
		}
		
		int countMax = 0 ;
		for(int k = 0 ; k < N + M ; k ++){
			
			String str = ( k < N ) ? s[k] : t[ k - N ] ; 
			
			int count = 0;
			for(int i = 0 ; i < N ; i ++){
				if(str.equals(s[i])){
					count ++;
				}
			}
			for(int j = 0 ; j < M ; j ++){
				if(str.equals(t[j])){
					count --;
				}
			}
			if(count > countMax){
				countMax = count;
			}
		}
		System.out.println(countMax);
	}
}


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

int main() {
	int n,i;
	cin >> n;
	vector<int> a(n - 1);
	vector<int> b(n);
	for (i = 0; i < n; i++) b.at(i) = 0;
	for (i = 0; i < n - 1; i++) {
		cin >> a.at(i);
		b.at(a.at(i)-1) += 1;
	}
	for (i = 0; i < n; i++) {
		cout << b.at(i) << endl;
	}
}

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

template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
template <typename T> void chmin(T &x,const T &y)
{
	if(x>y)x=y;
}
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
const int N=2e5+5;
char s[N],t[N];
int n;

void check(int u,int S,char L,char R)
{
	int l=0,r=u+1;
	per(i,n,1)
	{
		if(t[i]==L)chmin(++r,u+1);
		if(t[i]==R)chmax(--l,0);
		if(s[i]==L)++l;
		if(s[i]==R)--r;
		if(l+1>=r)break;
	}
	if(S<=l||S>=r)
	{
		puts("NO");
		exit(0);
	}
}

int main()
{
#ifdef kcz
	freopen("1.in","r",stdin);
#endif
	int h,w,sr,sc;
	scanf("%d%d%d%d%d%s%s",&h,&w,&n,&sr,&sc,s+1,t+1);
	check(h,sr,'U','D');
	check(w,sc,'L','R');
	puts("YES");
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>

using namespace std;

typedef complex<double> xy_t;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF= 1 << 30;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;

#define rep(i, n) for(int i = 0; i < n; i++)

string aba[] = {
	"* = ****",
	"* =* ***",
	"* =** **",
	"* =*** *",
	"* =**** ",
	" *= ****",
	" *=* ***",
	" *=** **",
	" *=*** *",
	" *=**** ",
};

int main(){
	int n;
	int cnt = 0;
	while(cin >> n){
		if(cnt == 0) cnt++;
		else cout << endl;
		int num = 1;
		string res[5];
		rep(i, 5){
			res[i] = aba[(n % (num * 10)) / num];
			num *= 10;
		}
		rep(i, 8){
			rep(j, 5){
				cout << res[4-j][i];
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 912
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) {
		try(Scanner scanner = new Scanner(System.in)) {
			String data1 = scanner.nextLine();
			String data2 = scanner.nextLine();

			int N = Integer.parseInt(data1);

			String[] data2Array = data2.split(" ");
			int[] arr = Stream.of(data2Array).mapToInt(Integer::parseInt).toArray();

			int prevHeight = 0;
			long ans = 0;
			for (int A : arr) {
				if (prevHeight == 0) {
					prevHeight = A;
					continue;
				}

				if (prevHeight > A) {
					ans += prevHeight - A;
					prevHeight = Math.max(prevHeight, A);
				} else {
					prevHeight = Math.max(prevHeight, A);
					continue;
				}
			}

			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 83456
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (int i = 0; i < v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    if (v.size() > 0) {
        os << v[v.size() - 1] << endl;
    }
    return os;
}

int main() {
    ll l;
    cin >> l;
    --l;
    if (l == 1){
        cout << 2 << " " << 2 << endl;
        cout << 1 << " " << 2 << " " << 0 << endl;
        cout << 1 << " " << 2 << " " << 1 << endl;
        return 0;
    }
    vint arr;
    while (l > 0) {
        arr.push_back((l & 1));
        l >>= 1;
    }
    reverse(arr.begin(), arr.end());
    int n = arr.size();
    vint idxs;
    FOR(i, 1, n) {
        if (arr[i] == 1) {
            idxs.push_back(i);
        }
    }
    ll now = (1 << (n - 1));
    int sz = idxs.size();
    cout << n << " " << sz + 1 + 2*(n - 1) << endl;
    assert(n <= 20);
    assert(sz + 1 + 2 * (n - 1) <= 60);
    REP(i, n - 1) {
        cout << i + 1 << " " << i + 2 << " " << 0 << endl;
        cout << i + 1 << " " << i + 2 << " " << (1 << (n - 2 - i)) << endl;
    }
    REP(i, sz) {
        cout << 1 << " " << 1 + idxs[i] << " " << now << endl;
        now += 1 << (n - 1 - idxs[i]);
    }
    cout << 1 << " " << n << " " << now << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#define int long long
#define ll getchar();getchar();return 0;
	using namespace std;
	signed main() {
		int w, a, b;
		cin >> w >> a >> b;
		if (a <= b) {
			if (a + w >= b)cout << 0 << endl;
			else cout << b - (a + w) << endl;
		}
		else {
			if (b + w >= a)cout << 0 << endl;
			else cout << a - (b + w) << endl;
		}
		ll
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(false);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int N;
  cin >> N;
  vvi G(N);
  rep(i, 0, N - 1) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    if (u > v) swap(u, v);
    G[v].pb(u);
  }
  int ans = 0;
  int d = 0;
  rep(v, 0, N) {
    int tmp = v + 1;
    for (int w : G[v]) {
      tmp -= w + 1;
    }
    d += tmp;
    ans += d;
  }
  cout << ans << endl;
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 14216
#include <cstdio>
#include <cstring> 
#include <iostream>
#include <queue> 
using namespace std;
int n,m,k; 
char str[200010];
int main(){
	scanf("%s",str);
	n=strlen(str);
	m=0;
	for(int i=0;i<n;++i) m+=str[i]-'0';
	if(m%9==0) printf("Yes");
	else printf("No");
	return 0;
} 

Measured memory_bytes: 3940
import collections,sys
def s():
 d=collections.deque()
 input()
 for e in sys.stdin:
  if'i'==e[0]:d.appendleft(e[7:-1])
  else:
   if' '==e[6]:
    m=e[7:-1]
    if m in d:d.remove(m)
   elif'i'==e[7]:d.popleft()
   else:d.pop()
 print(*d)
if'__main__'==__name__:s()



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

// Shrotening
#define fst first
#define snd second
#define pb push_back
#define mp std::make_pair

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::pair<int,int> PII;

typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;
typedef std::vector<PII> VPII;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;
int N;
VI b(1e5+3, 0);
int main() {
    std::cin >> N;
    int a;
    REP(i, N) {
        std::cin >> a;
        ++b[a];
        ++b[a+1];
        ++b[a+2];
    }

    int ans = 0;
    REP(i, 1e5+2) {
        ans = std::max(ans, b[i]);
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 640
n=int(input())
s1=input()
s2=input()
if s1[0]==s2[0]:
  pos=1
  ans=3
  flag=0
else:
  pos=2
  ans=6
  flag=1
while pos<n:
  if flag==0:
    if s1[pos]==s2[pos]:
      ans*=2
      pos+=1
      flag=0
    else:
      ans*=2
      pos+=2
      flag=1
  else:
    if s1[pos]==s2[pos]:
      ans*=1
      pos+=1
      flag=0
    else:
      ans*=3
      pos+=2
      flag=1
print(ans%(10**9+7))

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

int main()
{
  int x,y;
  while(true)
  {
    cin >> x >> y;
    if ( x == 0 && y == 0 ) return 0;
    if ( x<y )
    {
      cout << x << ' ' << y << endl;
    }else
    {
      cout << y << ' ' << x << endl;
    }
  }
}

Measured memory_bytes: 1160
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let i : Vec<i32> = read_vec();
    let n = i[0];
    let a = i[1];
    let b = i[2];
    let ans: i32= (1..(n+1))
                    .map(|x| 
                        {(x,
                            x.to_string()
                            .chars()
                            .map(|y| y.to_digit(10).unwrap() as i32)
                            .fold(0,|sum,i| sum + i)
                            )
                        })
                    .filter(|&(_,x)|  a <= x && x <= b )
                    .map(|(x, _)| x)
                    .fold(0, |sum, i | sum + i);
    println!("{:?}",ans);
}


Measured memory_bytes: 4352
#include <stdio.h>
int main(void){
    int N, M, Q[101], drink[101], time[100000];
    scanf("%d", &N);
    for(int i=0; i<N; i++) scanf("%d", &Q[i]);
    scanf("%d", &M);
    for(int i=0; i<M; i++) scanf("%d %d", &drink[i], &time[i]);
    for(int i=0; i<M; i++){
        int total=0;
        int Qcopy[N+1];
        for (int j=0; j<N; j++) Qcopy[j] = Q[j];
        Qcopy[drink[i]-1] = time[i];
        for(int j=0; j<N; j++) total+= Qcopy[j];
        printf("%d\n", total);
    }
    return 0;
}

Measured memory_bytes: 1672
#include <bits/stdc++.h>
#define ll long long
#define mod 998244353
using namespace std;

ll gcd(ll a,ll b){
	if(b==0)return a;return gcd(b,a%b);
}
ll expo(ll base,ll pow){
    ll ans = 1;
    while(pow!=0){
        if(pow&1==1){ans = ans*base;}
        base *= base;pow/=2;}return ans;
}
ll inv(ll x){return expo(x,mod-2);}

ll nCr[5010][5010], fact[5001];

void pre(){
     for(int i = 0; i <= 5000; i++){
         nCr[i][i] = 1LL;
         nCr[i][0] = 1LL;
     }
     for(int i = 2; i <= 5000; i++){
         for(int j = 1; j < i; j++){
             nCr[i][j] = (nCr[i-1][j-1]+nCr[i-1][j])%mod;
         }
     }

     fact[0] = 1;
     for(int i = 1; i <= 5000; i++) fact[i] = (1LL*fact[i-1]*i)%mod;
}

int cmp(pair <pair<ll,ll>, ll> p1, pair <pair<ll,ll>, ll> p2){
    int dif1 = abs(p1.first.first-p1.first.second);
    int dif2 = abs(p2.first.first-p2.first.second);
    return dif1 < dif2;
}

int ok(long double x1, long double y1){
    if(abs(x1-y1) < 1e-5) return 1;
    return 0;
}


int main(){
    //freopen("ip.txt", "rt", stdin);
    //freopen("op.txt", "wt", stdout);
    string s, s1;
    cin >> s;
    for(int i = 0; i < (s.size()-8); i++){
        cout << s[i];
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c,N,buhin[500],mei[2000][5],karibuhin[500];
int main(){
    while(1){
        fill(buhin,buhin+400,2);
        int fl=1;
        cin>>a>>b>>c;
        if(a+b+c==0)break;
        cin>>N;
        for(int i=0;i<N;i++){
            cin>>mei[i][0]>>mei[i][1]>>mei[i][2]>>mei[i][3];
            mei[i][0]--;mei[i][1]--;mei[i][2]--;
        }
        while(1){
            for(int f=0;f<a+b+c;f++){
                karibuhin[f]=buhin[f];
            }
            if(fl==0)break;
            fl=0;
            for(int i=0;i<N;i++){
                if(mei[i][3]==1){
                    buhin[mei[i][0]]=1;
                    buhin[mei[i][1]]=1;
                    buhin[mei[i][2]]=1;
                }else if(mei[i][3]==0){
                    if(buhin[mei[i][0]]==1&&buhin[mei[i][1]]==1){buhin[mei[i][2]]=0;}
                    if(buhin[mei[i][1]]==1&&buhin[mei[i][2]]==1){buhin[mei[i][0]]=0;}
                    if(buhin[mei[i][2]]==1&&buhin[mei[i][0]]==1){buhin[mei[i][1]]=0;}
                }
                for(int f=0;f<a+b+c;f++){
                    if(karibuhin[f]!=buhin[f]){fl++;}
                }
            }
        }for(int lk=0;lk<a+b+c;lk++){
            cout<<buhin[lk]<<endl;
        }
    }
}

Measured memory_bytes: 3028
#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);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n; ll K; cin >> n >> K;
    vll a(n); for(auto& e : a) cin >> e, e--;

    vll sum(n+1);
    map<ll, int> hist;
    rep(i, n){
        sum[i+1] = ADD(sum[i], a[i], K);
        if(i < K-1){
            hist[sum[i+1]]++;
        }
    }

    ll res = 0LL;
    ll cur = 0LL;
    rep(i, n){
        res += hist[cur];
        cur = ADD(cur, a[i], K);
        hist[sum[i+1]]--;
        if(i + K-1 < n){
            hist[sum[i+K]]++;
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (int)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N, P;
    string S;
    cin >> N >> P >> S;

    vector<ll> T(N);

    ll ans = 0;
    if(P == 2 || P == 5){
        rep(i, N) T[i] = (S[i] - '0') % P;
        rep(i, N) if(T[i] == 0) ans += i + 1;
        print(ans);
        return 0;
    }

    ll dig = 1;
    rrep(i,N){
        T[i] = (S[i] - '0') * dig % P;
        dig *= 10;
        dig %= P;
    }

    vector<ll> X(P);
    ++X[0];
    ++X[T[0]%P];

    for (int i = 1; i < N; ++i){
        T[i] += T[i-1];
        T[i] %= P;
        ++X[T[i]];
    }

    rep(i,P) ans += X[i] * (X[i] - 1) / 2;

    print(ans);

    return 0;
}

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

int main(void){
    int a,b,i,ans;
    ans = 0;
    cin >> a >> b;

    if(a < b){
        for(i=0; i<b; i++){
            ans += pow(10,i)*a;
        }
    }else{
        for(i=0; i<a; i++){
            ans += pow(10,i)*b;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384