akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
/* clang-format off */
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */
ll a, b;
ll n;
ll func(double x) { return (ll)((a * x) / b) - (ll)a * (ll)(x / b); }
int main() {
  cin >> a >> b >> n;
  ll ans=func(min(n,b-1));
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3584
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#define N 100010
#define M 3010
#define ll long long
#define ld long double
#define top 1e12
using namespace std;

struct data{ll x; int sum;};
int n, flag[M], l, p[M], y, ans;
ll w[N], x, x1, W;
ld xx;
map<ll, int>mp;
vector<data>son[N];

inline void prev(){
	memset(flag, 0, sizeof(flag)); l=0;
	for(int i=2; i<=3000; i++){
		if(!flag[i])p[++l]=i;
		for(int j=1; j<=l&&i*p[j]<=3000; j++){
			flag[i*p[j]]=1;
			if(i%p[j]==0)break;
		}
	}
}

int main(){
	prev();
	scanf("%d", &n); mp.clear();
	for(int i=1; i<=n; i++){
		scanf("%lld", &w[i]); son[i].clear();
		for(int j=1; j<=l; j++){x=(ll)p[j]*p[j]*p[j]; while(w[i]%x==0)w[i]/=x;}
	}
	for(int i=1; i<=n; i++)mp[w[i]]++;
	ans=0;
	for(int i=1; i<=n; i++)if(w[i]>=2&&mp[w[i]]){
		W=w[i];
		for(int j=1; j<=l; j++){
			y=0; while(W%p[j]==0){y++; W/=p[j];}
			if(y)son[i].push_back((data){p[j], y});
		}
		x=sqrt(W);
		if(x*x==W)xx=x; else xx=W*W;
		for(int j=0; j<son[i].size(); j++)xx*=son[i][j].sum==1?son[i][j].x*son[i][j].x:son[i][j].x;
		if(xx>top){ans+=mp[w[i]]; mp[w[i]]=0; continue;}
		x=(ll)(xx+0.1);
		ans+=max(mp[w[i]], mp[x]); mp[w[i]]=mp[x]=0;
	}
	if(mp[1])ans++;
	printf("%d", ans);
	return 0;
}

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


int main()
{
  ll n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i, n)
    cin >> a[i];
  sort(a.begin(), a.end());
  int l = 0, r = 2 * 1e5 + 1;
  while (l + 1 < r)
  {
    int mid = (l + r ) / 2;
    ll count = 0;
    rep(i, n)
      count += n - distance(a.begin(), lower_bound(a.begin(), a.end(), mid - a[i]));
    if (count >= m)
      l = mid;
    else
      r = mid;
  }
  vector<ll> cs(n + 1);
  rep(i, n)
    cs[i+1] = cs[i] + a[i];
  ll ans = 0;
  ll count = 0;
  for (int i = n - 1; i >= 0; i--)
  {
    int id = distance(a.begin(), lower_bound(a.begin(), a.end(), l - a[i]));
    ans += a[i] * (n - id) + cs[n] - cs[id];
    count += (n - id);
  }
  ans += (m - count) * l;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
#define PP pair<P,P>
using namespace std;
 
 
int main(){
    double a,b,h,m; cin >> a >> b >> h >> m;
    double ak=h*30+m*0.50;
    //cout << ak << endl;
    double bk=m*6;
    if(bk>ak) swap(ak,bk);
    //cout << ak-bk << endl;
    double kakudo=((ak-bk)*PI)/180;
    double ans=sqrt(a*a+b*b-2*a*b*cos(kakudo));
    printf("%.20lf",ans);
return 0;
}

Measured memory_bytes: 4228
#include <bits/stdc++.h>
using namespace std;
int main() {
  long int N,M;
  cin >> N >> M;
  if(N > 2 && M > 2)cout << (N-2)*(M-2) << endl;
  else{
    if(N == 1 && M == 1)cout << 1 << endl;
    else if(N == 2 || M == 2)cout << 0 << endl;
    else if(N == 1)cout << M-2 << endl;
    else if(M == 1)cout << N-2 << endl;
  }
}


Measured memory_bytes: 256
import heapq

N, M = map(int, input().split())
A = list(input().split())
A = [int(i) * (-1) for i in A]

heapq.heapify(A)

for _ in range(M):
    val = heapq.heappop(A)
    heapq.heappush(A, val*(-1)//2*(-1))

print(sum(A) * (-1))

Measured memory_bytes: 14992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    string S;
    cin >> S;
    int ans;
    if(S=="SUN") ans=7;
    if(S=="MON") ans=6;
    if(S=="TUE") ans=5;
    if(S=="WED") ans=4;
    if(S=="THU") ans=3;
    if(S=="FRI") ans=2;
    if(S=="SAT") ans=1;



    cout << ans << endl;




}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using namespace std;

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------


int main() {
 ll n,fans=0,jsize=0;
 cin>>n;
 vll a(n);
 rep(i,n){
     cin>>a.at(i);
    // jsize+=a.at(i);
 }
 for(ll i=n-2;i>=0;i--){
     jsize+=a.at(i+1);
     jsize%=1000000007;
     fans+=jsize*a.at(i);
     fans%=1000000007;
 }
 
 cout<<fans<<endl;
}



Measured memory_bytes: 4772
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

long long gcd(long long a, long long b){
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}

long long lcm(long long a, long long b){
    return (a / gcd(a, b)) * b;
}

string fillUnknownWithA(const string& target) {
    string filled = "";
    repeat (i, target.size()) {
        if (target[i] == '?') {
            filled += 'a';
        } else {
            filled += target[i];
        }
    }
    return filled;
}

string replaceSWithT(const string& S, const string& T, int from) {
    string replaced = "";
    repeat(i, from) {
        replaced += S[i];
    }
    repeat (i, T.size()) {
        replaced += T[i];
    }
    for (int i = from + T.size(); i < S.size(); ++i) {
        replaced += S[i];
    }
    return replaced;
}

bool isFillable(const string& S, const string& T, int from) {
    for (int i = 0; i < T.size(); ++i) {
        if (S.size() <= from + i) {
            return false;
        }
        if (S[from + i] == T[i] || S[from + i] == '?') {
            continue;
        } else {
            return false;
        }
    }
    return true;
}

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

    char first = T[0];
    size_t pos = 0;
    size_t from = pos;
    bool fillable = false;
    while ((pos = S.find(first, pos)) != string::npos) {
        if (isFillable(S, T, pos)) {
            fillable = true;
            from = pos;
        }
        pos += 1;
    }
    pos = 0;
    while ((pos = S.find('?', pos)) != string::npos) {
        if (isFillable(S, T, pos)) {
            fillable = true;
            from = max(pos, from);
        }
        pos += 1;
    }
    if (fillable) {
        string answer = replaceSWithT(S, T, from);
        cout << fillUnknownWithA(answer) << endl;
    } else {
        cout << "UNRESTORABLE" << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
int n,a[555],f[123][123][123];
const int MOD=1e9+7;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n+n-1;++i)
		scanf("%d",a+i);
	sort(a+1,a+n+n);
	f[n][1][1]=1;
	for(int r=n;r>1;--r)
	{
		int dt=(a[r-1]!=a[r])+(a[n+n-r+1]!=a[n+n-r]);
		for(int i=1;i<=n+n;++i)
		{
			for(int j=1;j<=i;++j) if(f[r][i][j])
			{
				int ii=i+dt,jj=j+(a[r-1]!=a[r]),F=f[r][i][j];
				for(int p=1;p<=ii;++p)
				{
					if(abs(p-jj)<=1)
						(f[r-1][ii][p]+=F)%=MOD;
					else if(p<jj)
						(f[r-1][ii-(jj-p)+1][p]+=F)%=MOD;
					else
						(f[r-1][ii-(p-jj)+1][jj+1]+=F)%=MOD;
				}
			}
		}
	}
	ll ans=0;
	for(int i=1;i<=n+n;++i)
		for(int j=1;j<=i;++j)
			ans+=f[1][i][j];
	printf("%lld\n",ans%MOD);
}


Measured memory_bytes: 3456
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int a,b,c; cin >> a >> b >>c;
    cout << min(a+b,min(a+c,b+c)) <<endl; return 0;
}


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

int dp[105][10010];

int main(){
    int n,x;
    cin>>n>>x;
    vector<int>v(n),w(n);
    for(int i=0; i<n; ++i)cin>>v[i]>>w[i];
    for(int i=0; i<105; ++i){
        for(int j=0; j<10010; ++j){
            dp[i][j]=0;
        }
    }
    for(int i=0; i<n; ++i){
        for(int j=0; j<=x; ++j){
            if(j-w[i]>=0){
                dp[i+1][j]=max(dp[i+1][j],dp[i+1][j-w[i]]+v[i]);
            }
                dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
        }
    }
    cout<<dp[n][x]<<endl;
}


Measured memory_bytes: 7216
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int W = sc.nextInt();
		int w[] = new int[n+1];
		int v[] = new int[n+1];
		
		List<Integer> li[] = new ArrayList[4];
		for(int i=0;i<4;i++)
			li[i] = new ArrayList<>();
		
		for(int i=1;i<=n;i++){
			w[i] = sc.nextInt();
			v[i] = sc.nextInt();
			li[w[i] - w[1]].add(v[i]);
		}
		
		for(int i=0;i<4;i++)
			Collections.sort(li[i]);
		
		int vsum[][] = new int[4][n+1];
		for(int i=0;i<4;i++){
			for(int j=0;j<li[i].size();j++){
				vsum[i][j+1] = vsum[i][j] + li[i].get(li[i].size()-1-j);
			}
		}
		
		int ans = 0;
		int A = li[0].size();
		int B = li[1].size();
		int C = li[2].size();
		int D = li[3].size();
		
		for(int a=0;a<=A;a++){
		for(int b=0;b<=B;b++){
		for(int c=0;c<=C;c++){
		for(int d=0;d<=D;d++){
			if((long)w[1] * (a+b+c+d) + b +2*c + 3*d <= W){
				int sum = vsum[0][a] + vsum[1][b] + vsum[2][c] + vsum[3][d];
				ans = Math.max(ans, sum);
			}
		}}}}
		
		System.out.println(ans);
		
	}

}


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


int main()
{
	int n; cin >> n;
	int X[n], Y[n];
	for (int i = 0; i < n; ++i)
	{
		int x, y; cin >> x >> y;
		X[i] = x + y; Y[i] = x - y;
	}
	sort(X, X+n), sort(Y, Y+n);
	cout << max(X[n-1] - X[0], Y[n-1] - Y[0]) << endl;
}


Measured memory_bytes: 5196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 5100+10;
const ll inf = 1e9+7;
int main() {
    ios::sync_with_stdio(0);
    string s;
    cin>>s;
    if(s=="ABC")
    cout<<"ARC"<<endl;
    else
        cout<<"ABC"<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){int n,m,p;cin>>n>>p;n=1,m=p+1;while(n<m)cout<<n++<<" "<<m--<<endl;n=p+2,m=2*p+1;while(n<m)cout<<n++<<" "<<m--<<endl;}

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

	long long int w[101],v[101],dp[101][100001];
	int main(){
		
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
	
		// #ifndef ONLINE_JUDGE
		// freopen("input.txt", "r", stdin);
		// freopen("output.txt", "w", stdout);
		// #endif

		int n,W;
		cin >> n >> W;
		for(int i=0;i<n;i++){
			cin >> w[i+1] >> v[i+1];
		}
		for(int i=0;i<=n;i++) for(int j=0;j<=100000;j++) dp[i][j]=(1ll<<40);
		dp[0][0]=0;
		for(int i=1;i<=n;i++){
			dp[i][0]=0;
			for(int j=1;j<=100000;j++){
				dp[i][j]=dp[i-1][j];
				if(j>=v[i]) dp[i][j]=min(dp[i][j],w[i]+dp[i-1][j-v[i]]);
			}
		}
		long long int ans=0;
		for(int i=1;i<=100000;i++){
			if(dp[n][i]<=W) ans=i;
		}
		cout << ans;

		


	
	
		
	
	}


Measured memory_bytes: 79232
n = int(input())
an = [int(num) for num in input().split()]

sum = 0
for i in range(len(an)-1):
  if an[i] > an[i+1]:
    sum += an[i] - an[i+1]
    an[i+1] += an[i] - an[i+1]
    
print(sum)

Measured memory_bytes: 32116
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
const int N = 1e6 + 10, OO = 0x3f3f3f3f, mod = 1e9 + 7;

#define PI acos(-1)
#define clr(arr, val) memset(arr, val, sizeof(arr))
#define loop(i, n) for (int i = 0; i < int(n); i++)
#define rloop(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define xloop(i, a, b) for (int i = int(a); i <= int(b); i++)
#define ALL(v) ((v).begin()), ((v).end())
#define SZ(v) ((int)((v).size()))
int dx[] = {1, 0, -1, 0}; // {down , right , up , left}
int dy[] = {0, 1, 0, -1}; //4 Direction
//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
//int dy[] = {0, 1, 1, 1, 0, -1, -1, -1}; //8 direction
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2};
//int dy[] = {1, 2, 2, 1, -1, -2, -2, -1}; //Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction

//-- "كلٌّ من يسعى لابد يصل .. كلٌّ من يسعى مضمون له الوصول" --//

int n, total;

int main()
{
  //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

  string s, t;
  cin >> s >> t;
  sort(ALL(s));
  sort(ALL(t));
  reverse(ALL(t));
  if(s < t)
    cout << "Yes\n";
  else
    cout << "No\n";

  return 0;
}


Measured memory_bytes: 3624
import fractions
N, K = map(int, input().split())
arr = list(map(int, input().split()))
t = arr[0]
for i in range(1,N):
    t = fractions.gcd(t,arr[i])
if max(arr) < K or K % t != 0:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 20007;
const int MAX = 30000;

int n;

void init ();
void input ();
void work ();



int main ()
{
	init ();
	input ();
	work ();
}



void init ()
{
	// Init Everything Here

	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method

	cin >> n;
}

void work ()
{
	// main work

	if ( n == 3 ) {
		printf ( "2 3 25\n" );
		return;
	}

	int m2, m3, c3, na;
	lpi ( i, 1, n ) {
		m2 = i << 1;
		c3 = n - i;
		m3 = c3 * 6 - 3;
		if ( m2 <= MAX && m3 <= MAX && c3 ) {
			na = i * ( i + 1 ) + 6 * ( c3 * ( c3 + 1 ) >> 1 ) - 3 * c3;
			if ( na % 2 == 0 && na % 3 == 0 ) {
				lpi ( j, 1, i ) printf ( "%d ", j << 1 );
				lpi ( j, 1, c3 ) printf ( "%d ", j * 6 - 3 );
				putchar ( '\n' );
				return;
			}
		}
	}
}

Measured memory_bytes: 384
#include <iostream> // cout, endl, cin
#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 <math.h> // sqrt
#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 <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    int N, M;
    cin >> N >> M;
    vector<vi> data(N + 1);
    for (int i = 1; i < M + 1; i++) {
        int a, b;
        cin >> a >> b;
        data[a].push_back(b);
        data[b].push_back(a);
    }
    vi dist(N + 1, -1);
    queue<int> que;
    dist[1] = 0;
    que.push(1);
    while(!que.empty()) {
        int v = que.front();
        que.pop();
        for (int x : data[v]) {
            if (dist[x] != -1) {
                continue;
            }
            dist[x] = v;
            que.push(x);
        }
    }
    for (int i = 1; i < N + 1; i++) {
        if (dist[i] == -1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    for (int i = 2; i < N + 1; i++) {
        cout << dist[i] << endl;
    }
}

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

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


Measured memory_bytes: 256
long p[444][444],s[444],S;long f(i,j,k){long*q=p[i]+j;if(!*q)for(*q=j-i<2?0:9e18,k=i;++k<j;)*q=fmin(*q,f(i,k)+f(k,j)+s[j]-s[i]);return*q;}i;main(a){for(;~scanf("%d",&a);)s[i++]=S+=i?a:0;printf("%ld",f(0,i-1));}

Measured memory_bytes: 1536
N = gets.to_i
nums = gets.strip.split(' ').map(&:to_i)

i = 0

def all_even?(nums)
  nums.each do |n|
    if n.odd?
      return false
    end
  end
  return true
end

while all_even?(nums) do
  i += 1
  nums = nums.map{ |n| n/2 }
end

puts i
  

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

using namespace std;

#define K 500001
#define FOE(i, s, t) for (int i = s; i <= t; i++)
#define pb push_back

int n;
int a[K];

int main() {
	scanf("%d", &n);
	
	FOE(i, 1, n) {
		scanf("%d", &a[i]); a[i] *= -1;
	}

	sort(a + 1, a + n + 1);
	
	FOE(i, 1, n) a[i] *= -1;
	
	int good = -1;
	
	FOE(i, 1, n) {
		if (a[i] >= i) good = i;
	}
	
//	printf("good is %d\n", good);
	
	int sol = 2;
	
	int dist = a[good] - good;
	
	if (dist % 2) sol = 1;
		
	int id = good;
	
	while (id < n && a[id + 1] >= good) id++;
	
	dist = id - good;
	
	if (dist % 2) sol = 1;
	
	if (sol == 2) puts("Second"); else puts("First");
}

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

int main()
{
  string str;
  cin >> str;
  int cnt = 0;
  for(int i = 0 ; i < (int) str.size() ; ++i) {
    if(str[i] == '+') cnt++;
    else cnt--;
  } cout << cnt << endl;
}


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

using namespace std;

int main() {

	long long  N, M, L, R;
	cin >> N >> M;

	int lmax, rmin;
	lmax = 0;
	rmin = 999999;
	for (int i = 0; i < M; i++)
	{
		cin >> L >> R;
		if (L > lmax) {
			lmax = L;
		}
		if (R < rmin) {
			rmin = R;
		}
	}
	if (lmax > rmin) {
		cout << 0 << endl;
	}
	else {
		cout << rmin - lmax + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
//??????????¶???????(??????????????????)???2^|S|??????????????????????????????????????????????????????|S|^3??????//??\?????§????????????????????????????????????????????????????????£????????????????????????????????¨??????????¨???????//?????????)
//?????????????????????????????¨??¢?´¢??????
#include <iostream>
#include <string>
using namespace std;

int main()
{
	int n;					//????????????????????°
	string board;			//?????????????????????????????????
	string oldBoard[100];	//?????¨?????????????????????????????????
	int cnt = 0;
	int i, j, start, end;
	
	cin >> n;
	cin >> board;
	for( i = 0; i < n; i++ )
		cin >> oldBoard[i];
	
	for( i = 0; i < n; i++ ){
		//oldBoard[i]??????j??????????????§????????????????????¨??§?????????board?????§?????????
		for( j = 1; j < oldBoard[i].length(); j++ ){
			for( start = 0; start < oldBoard[i].length(); start++ ){
				string str;
				for( end = start; end < oldBoard[i].length(); end += j ){
					str += oldBoard[i][end];
					if( str == board ){
						cnt++;
						goto END;
					}
				}
			}
		}
		END:;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
const int N=1e3+5;
typedef long long LL;
struct Node{
	int a,b,c;
}a[N],b[N];
int tmp[N*3],tmp1[N*3],si=1,si1=1;
bool vis[N*3][N*3],vis1[N*3][N*3],V[N*3][N*3];
int que[N*N*9][2],s,t;
void calc(int *a,int x,int y){*a=x,*(a+1)=y;}
LL bfs(){
	LL ans=0;
	while(s<t){
		int x=que[s][0],y=que[s++][1];
		ans+=1ll*(tmp[x]-tmp[x-1])*(tmp1[y]-tmp1[y-1]);
		if(!x||!y||x>=si||y>=si1)return -1;
		if(!V[x-1][y]&&!vis1[x][y])calc(que[t++],x-1,y),V[x-1][y]=1;
		if(!V[x][y-1]&&!vis[x][y])calc(que[t++],x,y-1),V[x][y-1]=1;
		if(!V[x+1][y]&&!vis1[x+1][y])calc(que[t++],x+1,y),V[x+1][y]=1;
		if(!V[x][y+1]&&!vis[x][y+1])calc(que[t++],x,y+1),V[x][y+1]=1;
	}
	return ans;
}
void check(int &x,int &y){if(x>y)swap(x,y);}
int main(){
	int n,m;scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)scanf("%d%d%d",&a[i].a,&a[i].b,&a[i].c),check(a[i].a,a[i].b),tmp[si++]=a[i].a,tmp[si++]=a[i].b,tmp1[si1++]=a[i].c;
	for(int i=0;i<m;i++)scanf("%d%d%d",&b[i].c,&b[i].a,&b[i].b),check(b[i].a,b[i].b),tmp1[si1++]=b[i].a,tmp1[si1++]=b[i].b,tmp[si++]=b[i].c;
	sort(tmp,tmp+si),sort(tmp1,tmp1+si1);
	si=unique(tmp,tmp+si)-tmp,si1=unique(tmp1,tmp1+si1)-tmp1;
	for(int i=0;i<n;i++){
		int x=lower_bound(tmp,tmp+si,a[i].a)-tmp,y=lower_bound(tmp,tmp+si,a[i].b)-tmp,
		z=lower_bound(tmp1,tmp1+si1,a[i].c)-tmp1;
		for(int i=x+1;i<=y;i++)vis[i][z+1]=1;
	}
	for(int i=0;i<m;i++){
		int x=lower_bound(tmp1,tmp1+si1,b[i].a)-tmp1,y=lower_bound(tmp1,tmp1+si1,b[i].b)-tmp1,
		z=lower_bound(tmp,tmp+si,b[i].c)-tmp;
		for(int i=x+1;i<=y;i++)vis1[z+1][i]=1;
	}
	int u=lower_bound(tmp,tmp+si,0)-tmp,v=lower_bound(tmp1,tmp1+si1,0)-tmp1;
	for(int i=0;i<2;i++)for(int j=0;j<2;j++)calc(que[t++],u+i,v+j),V[u+i][v+j]=1;
	LL ans=bfs();
	if(ans==-1)puts("INF");
	else printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 96968
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>

using namespace std;

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

    cout<<(48-M)<<endl;
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define hash dhsjakhd
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;

ll n,m,T,k,q;
const ll big = 1000000007;

unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 eng(seed);
uniform_int_distribution<> DD(0, 1000000000);

ll random(ll r){
    return (ll(DD(eng))*1000000000 + ll(DD(eng)))%r;
}

const ll MAXN = 5001;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);

    ll a,b,c,d;

    cin >> n;

    if(n%2 == 0){
        m = (n*(n-1))/2 - n/2;
        cout << m << "\n";
        for(int c1 = 0; c1 < n; c1++){
            for(int c2 = c1+1; c2 < n; c2++){
                if(c1+c2 != n-1){
                    cout << c1+1 << " " << c2+1 << "\n";
                }
            }
        }
    }
    else{
        m = (n*(n-1))/2 - n/2;
        cout << m << "\n";
        for(int c1 = 0; c1 < n; c1++){
            for(int c2 = c1+1; c2 < n; c2++){
                if(c1+c2 != n-2){
                    cout << c1+1 << " " << c2+1 << "\n";
                }
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int cnt = 0;

    char S[6];
    for (int i = 0; i < 6; i++) {
        scanf("%c", &S[i]);
    }

    for (int i = 0; i < 6; i++) {
        if (S[i] == '1') {
            cnt++;
        }
    }

    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 128
n, m, c = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
ans = 0
n.times.each{
    a = gets.split.map(&:to_i)
    x = 0
    a.each_with_index{|ai, i|
        x += a[i] * b[i]
    }
    x += c
    if x > 0
        ans += 1
    end
}
puts ans


Measured memory_bytes: 1788
w, h, n = list(map(int, input().split()))
al, xl, yl = [0 for i in range(n)], [0 for i in range(n)], [0 for i in range(n)]
for i in range(n):
	x,y,a = list(input().split())
	xl[i] = int(x)
	yl[i] = int(y)
	al[i] = a

total = w*h
d = {"1": 0, "2": w, "3": 0, "4": h}
for i in range(n):
	if al[i] == "1":
		if xl[i] > d["1"]:
			d["1"] = xl[i]
	elif al[i] == "2":
		if xl[i] < d["2"]:
			d["2"] = xl[i]
	elif al[i] == "3":
		if yl[i] > d["3"]:
			d["3"] = yl[i]
	else:
		if yl[i] < d["4"]:
			d["4"] = yl[i]
if (d["2"]-d["1"]) <= 0 or (d["4"]-d["3"]) <= 0:
	print(0)
else:
	print((d["2"]-d["1"]) * (d["4"]-d["3"]))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
#define pb push_back
#define mp make_pair
#define INF (ll)(1e18)
#define inf 0x7fffffff
#define inff 100000
#define ff first
#define ss second
#define sz(x) ((int) (x).size())
#define fast cin.sync_with_stdio(0);cin.tie(0)
#define rep(i,N) for(int i = 0;i < N;i++)
#define frep(i,a,b) for(int i = a;i <= b;i++)
#define pii pair<int , int>
#define pll pair<ll , ll>
#define vii vector<int>
#define vpii vector< pii >
#define fill(A,v) memset(A,v,sizeof(A))
#define setbits(x) __builtin_popcountll(x)
#define print(A,j,k) for(int ii=j;ii<k;ii++)cout<<A[ii]<<" ";cout<<"\n"
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
#define SQRT 350
#define CASES int t;cin>>t;while(t--)
#define FILE freopen("inp.txt" , "r" , stdin);
#define ld long double

const int MOD = 1e9 + 7;
const int N = 1e6 + 5;


ll cnt[15];
ll h , w , n;


int main(int argc, char const *argv[])
{
	
	fast;

	cin >> h >> w >> n;

	vector< pii > V;
	map< pii , int> black;

	rep(i , n) {
		int a , b;
		cin >> a >> b;
		a--;
		b--;
		for(int x = a;x >= max(0 , a - 2);x--)
			for(int y = b;y >= max(0 , b - 2);y--) {
				if (x >= h - 2 || y >= w - 2)
					continue;
				black[ {x , y} ]++;
			}
	}

	cnt[0] = (h - 2LL) * (w - 2LL);

	for(auto it = black.begin();it != black.end();it++) {
		auto x = it -> ff;
		// cout << x.ff << ' ' << x.ss << '\n';
		// cout << it -> ss << '\n';
		cnt[it -> ss]++;
	}

	for(int j = 1;j <= 9;j++)
		cnt[0] -= cnt[j];

	for(int j = 0;j <= 9;j++)
		cout << cnt[j] << '\n';

	return 0;
}

Measured memory_bytes: 56576
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>
 
using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)

int rec(long long x, int& n, bool has7, bool has5, bool has3) {
  if (x > n) return 0;
  return rec(x * 10 + 7, n, true, has5, has3)
       + rec(x * 10 + 5, n, has7, true, has3)
       + rec(x * 10 + 3, n, has7, has5, true)
       + (has7 and has5 and has3);
}
 
int main() {
  int n; cin >> n;
  cout << rec(0, n, false, false, false) << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"os"
	"strconv"
	"strings"
	"fmt"
)

var sc = bufio.NewScanner(os.Stdin)

func read() string {
	sc.Scan()
	return sc.Text()
}

func geti() int {
	n, _ := strconv.Atoi(read())
	return n
}

func getli(size int) ([]int) {
	a := make([]int, size)
	list := strings.Split(read(), " ")
	for i, s := range list {
		n, _ := strconv.Atoi(s)
		a[i] = n
	}
	return a
}

func main() {
	n := geti()
	as := make([][]int, 2)
	for i := 0; i < 2; i++ {
		as[i] = getli(n)
	}
	sum := 0
	max := 0
	for i := 0; i < n; i++{
		sum = 0
		for j := 0; j < n; j++{
			if j <= i {
				sum += as[0][j]
			} else {
				sum += as[1][j]
			}
			if j == i {
				sum += as[1][j]
			}
		}
		if sum > max{
			max = sum
		}
	}
	fmt.Println(max)
}

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

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

  int Ans = X;
  rep(i, 0, N) Ans += 1 + (D-1)/A.at(i);

  cout << Ans << endl;
}


Measured memory_bytes: 256
const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {
    const [X, Y] = input.split(' ').map(n => n - 0)

    if (X * 4 < Y) {
        console.log('No')
    } else if (Y % 2 === 1) {
        console.log('No')
    } else if (X * 2 > Y) {
        console.log('No')
    } else {
        console.log('Yes')
    }

})(input)


Measured memory_bytes: 29616
#include <bits/stdc++.h>
 
#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0) (__VA_ARGS__)
#define rep_0(i, end) for (int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for (int i = (fr); i <= (ba); ++i)
#define overload_rep(arg_0, arg_1, arg_2, name, ...) name
#define all(box) box.begin(), box.end()
 
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }

using lint = long long;

int main() {

  lint N, M;
  std::cin >> N >> M;
  std::vector<lint> A(N);
  rep (i, N) std::cin >> A[i];
  rep (i, N) A[i] /= 2;

  int bef = -1;
  rep (i, N) {
    int t = A[i] & -A[i];
    if (bef == -1) bef = t;
    else if (bef != t) {
      puts("0");
      return 0;
    }
  }

  lint now = 1;
  rep (i, N) {
    lint g = std::__gcd(A[i], now);
    now = now / g * A[i];
    if (now > M) {
      puts("0");
      return 0;
    }
  }

  std::cout << M / now - M / (now * 2) << '\n';
  return 0;

}


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

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  vll p(n*n);
  re(i, n*n) {
    scanf("%lld", &p[i]);
    p[i]--;
  }
  vvl dat = VV(n, n, 0, ll);
  for(ll i=0;i<n;i++){
    for(ll j=0;j<n;j++){
      dat[i][j] = min({i, j, n-1-i, n-1-j});
    }
  }
  vvl be = VV(n, n, 1, ll);

  ll ans = 0;
  for(int i=0;i<n*n;i++){
    ll x = p[i]%n, y = p[i]/n;
    ans += dat[x][y];
    be[x][y] = 0;
    deque<ll> q;
    q.push_back(p[i]);

    while(!q.empty()){
      ll top = q.front();q.pop_front();
      ll X = top%n, Y = top/n;
      ll prev = dat[X][Y]+be[X][Y];
      if(X>0){
        if(dat[X-1][Y] > prev){
          dat[X-1][Y] = prev;
          q.push_back(Y*n+X-1);
        }
      }
      if(X<n-1){
        if(dat[X+1][Y]>prev){
          dat[X+1][Y] = prev;
          q.push_back(Y*n+X+1);
        }
      }
      if(Y>0){
        if(dat[X][Y-1]>prev){
          dat[X][Y-1] = prev;
          q.push_back((Y-1)*n+X);
        }
      }
      if(Y<n-1){
        if(dat[X][Y+1]>prev){
          dat[X][Y+1] = prev;
          q.push_back((Y+1)*n+X);
        }
      }
    }
  }
  std::cout << ans << '\n';
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 6e5;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb push_back
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

ll n;
ll d[maxn];
ll q , x;
ll dp[maxn];
ll mn[maxn];

int main(){
    migmig
    cin >> n >> dp[0];
    mn[n]=1;
    for(int i = 1 ; i <= n ; i ++)
		cin >> d[i];
    for(int i = 1 ; i <= n ; i ++)
		dp[i] = min(dp[i - 1], abs(d[i] - dp[i - 1]));
    for(int i = n-1 ; i ; i --)
		mn[i] = mn[i + 1] + ((d[i+1] < 2 * mn[i + 1])?d[i+1]:0);
    cin >> q;
	while(q--){
		cin >> x;
		cout << ((dp[x-1] >= mn[x])?"YES":"NO")<< endl;
	}
    return(0);
}

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

int main() {
    int a, b;
    cin >> a >> b;
    if (a>b){
      cout << "a > b" << endl;
    }else if (a<b){
      cout << "a < b" << endl;
    }else{
      cout << "a == b" << endl;
    }
}


Measured memory_bytes: 3084
#include "bits/stdc++.h"
    using namespace std;
    #define MOD 1000000007
    #define INF 1<<50LL
    #define FOR(i,a,b) for(auto i=(a);i<(b);i++)
    #define RFOR(i,a,b) for(auto i = (b-1);i>=a;i--)
    #define REP(i,n)  FOR(i,0,n)
    #define RREP(i,n) RFOR(i,0,n)
    #define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
    #define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
    #define dump(x)  cout << #x << " = " << (x) << endl;
    #define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
    typedef long long ll;
    typedef pair<ll,ll> P;
     
    int main(){
      ios::sync_with_stdio(false);
      cin.tie(0);
     
      string t;
      cin >> t;
      
      bool w = false,n = false, e = false, s = false;
      REP(i,t.size()){
        if(t[i] == 'W') w = true;
        if(t[i] == 'E') e = true;
        if(t[i] == 'S') s = true;
        if(t[i] == 'N') n = true;
      }
      
      if(w == e && s == n) cout << "Yes" << endl;
      else cout << "No" << endl;
     
      return 0;
    }

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <time.h>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
    int H, W;
    scanf("%d%d", &H, &W);
    vector<int> a(H), b(H);

    map<int, int> z;
    int i;
    for (i = 0; i < W; i++) {
        z[i] = 0;
    }
    map<int, int> cnt;
    cnt[0] = W;

    vector<int> ans;
    for (i = 0; i < H; i++) {
        int a, b;
        scanf("%d%d", &a, &b); a--; b--;
        auto it0 = z.lower_bound(a);
        auto it1 = z.lower_bound(b+1);
        set<int> dd;
        int tmp = INF;
        while (it0 != it1) {
            dd.insert(it0->first);
            int tmp0 = b + 1 - (it0->first) + it0->second;
            tmp = MIN(tmp, tmp0);
            it0++;
        }
        if (it1!=z.end() && it1->first == b + 1) {
            tmp = MIN(tmp, it1->second);
        }
        if (b + 1 < W) {
            auto it5 = z.find(b + 1);
            if (it5 != z.end()) {
                cnt[it5->second]--;
                if (cnt[it5->second] == 0) {
                    cnt.erase(it5->second);
                }
            }
            z[b + 1] = tmp;
            cnt[tmp]++;
        }
        auto it2 = dd.begin();
        for (; it2 != dd.end(); ++it2) {
            int tmp = *it2;
            auto it8 = z.find(tmp);
            assert(it8 != z.end());
            int tmp2=it8->second;
            cnt[tmp2]--;
            if (cnt[tmp2] == 0) {
                cnt.erase(tmp2);
            }
            z.erase(tmp);
        }

        if(0){
            auto it = z.begin();
            for (; it != z.end(); ++it) {
                printf("(%d %d)", it->first, it->second);
            }
            printf("\n");
        }
        if (cnt.empty()) {
            ans.push_back(-1);
        }
        else {
            auto it7 = cnt.begin();
            ans.push_back(it7->first);
        }
    }
    for (i = 0; i < H; i++) {
        if (ans[i] >= W || ans[i]<0) {
            printf("-1\n");
        }
        else {
            printf("%d\n", 1+ i + ans[i]);
        }
    }

    return;
}

int main()
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for (t = 0; t < T; t++) {
        //printf("Case #%d: ", t + 1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 14812
N, M = map(int, input().split())
PY = [list(map(int, input().split())) + [i] + [0] for i in range(M)]

PY_sorted = sorted(PY, key=lambda a: (a[0], a[1]))
PY_sorted[0][3] = str(PY_sorted[0][0]).zfill(6) + str(1).zfill(6)
#print(PY_sorted)
cnt = 1
for i in range(1, M):
    cnt += 1
    if PY_sorted[i][0] != PY_sorted[i - 1][0]:
        cnt = 1
        PY_sorted[i][3] = str(PY_sorted[i][0]).zfill(6) + str(cnt).zfill(6)
    else:
        PY_sorted[i][3] = str(PY_sorted[i][0]).zfill(6) + str(cnt).zfill(6)
#print(PY_sorted)
ans = sorted(PY_sorted, key=lambda a: a[2])
for a in ans:
    print(a[3])



Measured memory_bytes: 38216
n=int(input())
V=[[0]*3 for i in range(2)]
d=1
e=0
for i in range(n):
  a,b,c=map(int,input().split())
  V[d][0]=max(V[e][1],V[e][2])+a
  V[d][1]=max(V[e][2],V[e][0])+b
  V[d][2]=max(V[e][0],V[e][1])+c
  d=e
  e=(e+1)%2
print(max(V[e][0],V[e][1],V[e][2]))

Measured memory_bytes: 3064
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


S = LS2()
if S[-1] == 's':
    S += ['e','s']
else:
    S += ['s']

print(''.join(S))


Measured memory_bytes: 61840
#include<iostream>
#include<unordered_map>
#include<algorithm>
#include<vector>
#include<string>
#include<string.h>
#include<unordered_set>

using namespace std;




vector<int> prime_sieve(int n)
{
    int* arr = new int[n+1];
    
    int i, p;
    for (i = 0; i <= n; ++i) {
        arr[i] = i;
    }
    for (i = 2; i <= n; ++i) {
        if (arr[i] != 0) {
            for (p = arr[i] * arr[i]; p <= n; p += arr[i]) {
                arr[p] = 0;
            }
        }
    }
    vector<int> primes;
    for (i = 2; i <= n; ++i) {
        if (arr[i] != 0) {
            primes.push_back(arr[i]);
        }
    }
    return primes;
}

int min(int a, int b)
{
    return a < b ? a : b;
}



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

    int i;
    for(i=a;i<1000000;++i){
        if ((i * 8) / 100 == a && (i / 10) == b) {
            cout << i;
            exit(0);
        }
    }
    cout << "-1";
    
}

    


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

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main()
{
	int n;
	cin >> n;
	int h[n];
	for(int i=0;i<n;i++)
		cin >> h[i];
	int dp[n];
	dp[0] = 0;
	dp[1] = abs(h[0] - h[1]);
	for(int i=2;i<n;i++)
		dp[i] = min(dp[i-2] + abs(h[i-2] - h[i]), dp[i-1] + abs(h[i] - h[i-1]));
	cout << dp[n-1] << "\n";

	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

vector<int> edges[100005];
ll ret = 1;
const int MOD = 1000000007;
int k;

void dfs(int curr, int par = -1) {
  int avail = k;
  if(par == -1) {
  }
  else {
    avail--;
  }
  for(int out: edges[curr]) {
    if(out == par) continue;
    ret *= --avail;
    ret %= MOD;
    dfs(out, curr);
  }
}

void solve() {
  int n;
  cin >> n >> k;
  for(int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }
  ret = k;
  dfs(1);
  cout << ret << "\n";
}

void casesolve() {
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << " ";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


Measured memory_bytes: 10368
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
double a,b,x;
const double PI=acos(-1);
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	scanf("%lf %lf %lf",&a,&b,&x);
	double ans;
	if(x<=a*a*b/2){
		ans=atan(a*b*b/(2*x));
	}else{
		ans=atan(2*b/a-2*x/(a*a*a));
	}
	printf("%.8f\n",ans*180/PI);
}

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

#define rep(a, b, c) for (int a = b; a < (c); a++)
#define repe(a, b, c) for (int a = b; a <= (c); a++)
#define repr(a, b, c) for (int a = b; a > (c); a--)
#define repre(a, b, c) for (int a = b; a >= (c); a--)

using namespace std;

int main() {
    vector<bool> is_prime(1000001, true);
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; (i * i) <= 1000001; i += 2) {
        if (is_prime[i]) {
            for (int j = i * i; j <= 1000001; j += i) {
                is_prime[j] = false;
            }
        }
        if (i == 2) i--;
    }
    while(true) {
        int N, X;
        cin >> N >> X;
        if ((N | X) == 0) break;
        bool dp[X];
        memset(dp, false, X + 1);
        dp[0] = true;
        int ans = 0;
        rep(i, 0, N) {
            int value;
            cin >> value;
            repe(j, 0, X - value) {
                if (dp[j]) {
                    dp[j + value] = true;
                    if (is_prime[j + value]) {
                        ans = max(ans, j + value);
                    }
                }
            }
        }
        if (ans == 0) {
            cout << "NA" << endl;
        } else {
            cout << ans << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4144
type ABC(stream:System.IO.TextReader) =
  member this.Scan1 f = stream.ReadLine() |> f
  member this.Scan2 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1]))
  member this.Scan3 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2]))
  member this.Scan4 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2], a.[3]))
  member this.ScanVecH f = stream.ReadLine().Split() |> Array.map f
  member this.ScanVecV n f = [| for i in 1..n -> stream.ReadLine() |> f |]
  member this.ScanMatrix n f  = [ for i in 1..n do yield stream.ReadLine().Split() |> Array.map f ]
  member this.ScanCharMatrix n = [| for i in 1..n -> stream.ReadLine().ToCharArray() |]
  member this.Close () = stream.Close()

let util = ABC(stdin)

let rec gcd a b =
  if b > a 
  then gcd b a
  else match a % b with
       | 0L -> b
       | c -> gcd b c

util.Scan1 int |> ignore
let xs = util.ScanVecH int64

xs
|> Array.fold gcd xs.[0]
|> printfn "%d"



Measured memory_bytes: 23516
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int k, x;
	cin >> k >> x;
	
	for(int i = x - k + 1; i < x + k; ++i) {
		cout << i << " ";
	}
	
	cout << endl;
	
	return 0;
}


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

long long int f(long long int a,long long int b){
  int la=to_string(a).size();
  int lb=to_string(b).size();
  return max(la,lb);
}

int main() {
  long long int N, res=pow(10,10);
  cin>>N;
  for(int i=1;i<sqrt(N)+1;i++){
    if(N%i==0){
      long long int a=i,b=N/i;
      res=min(res,f(a,b));
    }
  }
  cout<<res<<endl;
}

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

int main() {
    int N; cin >> N;
    vector<long long> L(N);
    for (int i = 0; i < N; ++i) cin >> L[i];
    sort(L.begin(), L.end()); // L をソートしておく

    long long res = 0;
    
    // a を固定して、(b, c) をしゃくとり法
    for (int i = 0; i < N; ++i) {
        int k = i;
        for (int j = i+1; j < N; ++j) {
            while (k < N && L[k] < L[i]+L[j]) ++k;
            res += k - (j+1);
        }   
    }
    cout << res << endl;
}

Measured memory_bytes: 256