akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define int long long
const int MOD = 1e9+7;

signed main(){

static int table[1000] = {};
for(int i = 2; i <= 1000; i++){
 bool f = false;
 for(int j = 2; j < i; j++){
  if(i%j == 0) f = true;
 }
 if(!f) table[i] = 1;
}

  int n; cin >> n;
  vector<int> v(n+1,0);
  for(int i = 2; i <= n; i++){
    bool f = false;
    for(int j = 2; j <= i; j++){
      if(i%j == 0 && table[j]){
       int t = i,cnt = 0;
        while(t%j == 0){
         cnt++;
         t /= j;
        }
       v[j] += cnt;
       f = true;
      }
    }
    if(!f) v[i]++;

}

  int ans = 1;
  for(int i = 2; i <= n; i++){
    if(v[i] == 0) continue;
    ans = (ans * (v[i]+1) % MOD);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////


///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	int n, l;
	cin >> n >> l;
	int temp = l;
	int ans = 0;
	for(int i = 1; i <= n; i++){
		ans += l + i - 1;
		//cout << "current ans: " << ans << endl;
		if(abs(l + i - 1) < abs(temp)) temp = l + i - 1;
		//cout << "current temp: " << temp << endl;
	}
	
	cout << ans - temp << endl;
	
	
	
	
	
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
#define FAST_IO {ios::sync_with_stdio(0);cin.tie(0);}
using namespace std;
signed main() {
  int A, B; cin >> A >> B;
  if (A+B == 3) {
    cout << 3 << endl;
  } else if (A+B == 4) {
    cout << 2 << endl;
  } else {
    cout << 1 << endl;
  }  
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n = 0, k = 0; cin >> n;
    vector<ll> a(n);
    rep (i, n) {
        cin >> a[i];
        if (a[i] < 0) k++;
    }
    sort(all(a), [](ll a, ll b){return abs(a) < abs(b);});

    ll ans = 0;
    if (k % 2 == 1) ans -= abs(a[0]);
    else ans += abs(a[0]);
    eprintf("%d\n", k);
    rep (i, 1, n) ans += abs(a[i]);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();

		String[] Ws = W.split(" ");
		long N = Long.parseLong(Ws[0]);

		W = in.readLine();
		Ws = W.split(" ");
		long[] a = new long[Ws.length];
		long even = 0;
		for (int i = 0; i < Ws.length; i++) {
			a[i] = Long.parseLong(Ws[i]);
			if(a[i]%2==0){
				long k=a[i];
				while(k%2==0){
					k=k/2;
					even++;
				}
			}
		}

		System.out.println(even);
	}
}


Measured memory_bytes: 25556
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <unordered_map>
using namespace std;

constexpr int mod = 10000;
int n, k;
int memo[100][4][3];

unordered_map<int, int> determined;

int dfs(int day, int eated, int num) {
	if(num == 3) return 0;
	if(day == n) return 1;
	if(memo[day][eated][num] != -1) return memo[day][eated][num];

	if(determined.count(day)) {
		const int eating = determined[day];
		return memo[day][eated][num] = dfs(day + 1, eating, (eated == eating ? num + 1 : 1));
	}

	int res = 0;
	for(int i = 0; i < 3; ++i) {
		res += dfs(day + 1, i, (eated == i ? num + 1 : 1));
		res %= mod;
	}

	return memo[day][eated][num] = res;
}

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

	cin >> n >> k;

	for(int i = 0; i < k; ++i) {
		int a, b;
		cin >> a >> b;
		determined[a - 1] = b - 1;
	}

	memset(memo, -1, sizeof(memo));
	cout << dfs(0, 3, 0) << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1224
a, b = map(int, input().split())
p = list(map(int, [input() for i in range(a)]))
m = 1000000000

p.sort()

for i in range(a-b+1):
  if p[i+b-1] - p[i] < m:
    m = p[i+b-1] -p[i]

print(m)

Measured memory_bytes: 14236
<?php

$input1 = trim(fgets(STDIN));
$input2 = trim(fgets(STDIN));
$input3 = trim(fgets(STDIN));

$arr = [1 => 0, 2 => 0, 3 => 0, 4 => 0];

list($a, $b) = explode(" ", $input1);
$arr[$a]++;
$arr[$b]++;

list($a, $b) = explode(" ", $input2);
$arr[$a]++;
$arr[$b]++;

list($a, $b) = explode(" ", $input3);
$arr[$a]++;
$arr[$b]++;

$arr2 = [0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0];
foreach ($arr as $key => $value) {
    $arr2[$value]++;
}

if ($arr2[1] == 2 && $arr2[2] == 2) {
    echo "YES";
} else {
    echo "NO";
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
vl info;
pl solve(ll l,ll r){
    ll L=l,R=r;
    ll now=INF,m,s;
    while(r-l>1){
        ll middle=(r+l)/2;
        ll p=info[R]-info[middle],q=info[middle]-info[L];
        if(now>abs(p-q)){
            now=min(now,abs(p-q));
            m=max(p,q),s=min(p,q);
        }
        if(p>q)l=middle;
        else r=middle;
        assert(0<=l and r<=info.size());
    }
    return mp(s,m);
}
int main(){
    ll N;cin>>N;
    info=vl(N+1);
    repl(i,1,N+1){
        cin>>info[i];
        info[i]+=info[i-1];
    }
    ll ans=INF;
    repl(i,1,N-2){
        ll A=solve(0,i+1).fi,B=solve(0,i+1).se,C=solve(i+1,N).fi,D=solve(i+1,N).se;
        ans=min(ans,max(B,D)-min(A,C));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

int main(){
	int n,m;
	while(cin>>n>>m,n&&m){
		vint ta(n),ha(m);
		int suma=0,sumb=0;
		rep(i,n) cin>>ta[i];
		rep(i,m) cin>>ha[i];
		sort(ALL(ta));
		sort(ALL(ha));
		rep(i,n) suma+=ta[i];
		rep(i,m) sumb+=ha[i];
		if((suma+sumb)%2==1){
			cout<<-1<<endl;
			continue;
		}
		int ansa=-1,ansb=-1;
		rep(i,n){
			rep(j,m){
				if(suma-ta[i]+ha[j]==sumb-ha[j]+ta[i]){
					ansa=ta[i]; ansb=ha[j];
					break;
				}
			}
			if(ansa!=-1) break;
		}
		if(ansa==-1||ansb==-1) cout<<-1<<endl;
		else cout<<ansa<<" "<<ansb<<endl;
	}
	return 0;
}
				

Measured memory_bytes: 1216
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int a = sc.nextInt(), b = sc.nextInt();
			
			if(a == 0 && b == 0){
				break;
			}
			
			if(a < b){
				int tmp = a;
				a = b;
				b = tmp;
			}
			
			int count = 0;
			while(b != 0){
				a = a % b;
				
				int tmp = a;
				a = b;
				b = tmp;
				count++;
			}
			
			
			System.out.println(a + " " + count);
		}
	}
	
}

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

int main() {

    int n,x;
    cin>>n>>x;
    int m[n];
    int sum=0;
    int min=1000;
    for(int i=0;i<n;i++){
        cin>>m[i];
        sum+=m[i];
        if(min>m[i]){
            min=m[i];
        }
    }
    cout<<(x-sum)/min+n<<endl;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<queue>
using namespace std;
int bfs[110][110];
int c[110];
int d[110];
int e[110];
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		for(int i=0;i<110;i++)for(int j=0;j<110;j++)
			bfs[i][j]=999999999;
		queue<pair<int,int> > Q;
		bfs[0][0]=0;
		Q.push(make_pair(0,0));
		for(int i=0;i<b;i++){
			scanf("%d%d%d",c+i,d+i,e+i);
		}
		while(Q.size()){
			int s=Q.front().first;
			int t=Q.front().second;
			Q.pop();
			for(int i=0;i<b;i++){
				if(t<e[i])continue;
				if(bfs[min(a,s+c[i])][min(t+d[i],100)]>99999999){
					bfs[min(a,s+c[i])][min(t+d[i],100)]=bfs[s][t]+1;
					Q.push(make_pair(min(a,s+c[i]),min(t+d[i],100)));
				}
			}
		}
		int ret=999999999;
		for(int i=0;i<=100;i++)ret=min(ret,bfs[a][i]);
		if(ret>99999999)printf("NA\n");
		else printf("%d\n",ret);
	}
}

Measured memory_bytes: 1132
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int n, m;
    cin >> n >> m;
    priority_queue<ll> pq;
    rep(i, n){
        ll x;
        cin >> x;
        pq.push(x);
    }
    
    rep(i, m){
        ll top = pq.top();
        pq.pop();
        top /= 2;
        pq.push(top);
    }

    ll sum = 0;
    rep(i, n){
        sum += pq.top();
        pq.pop();
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4308
class Solution:
    def solve(self, N: int, M: int, X: int, Y: int, x, y) -> int:

        x_ub = max(x + [X])
        y_lb = min(y + [Y])

        if x_ub < y_lb:
            return "No War"
        else:
            return "War"


if __name__ == '__main__':

    # standard input
    N, M, X, Y = map(int, input().split())

    x = list(map(int, input().split()))
    y = list(map(int, input().split()))

    # solve
    solution = Solution()
    print(solution.solve(N, M, X, Y, x, y))


Measured memory_bytes: 3064
#include<stdio.h>
#define N 100
 
int main(){
  int numbers[N];
  int i,j,n,temp,c;
 
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&numbers[i]);
   
  for(i=0;i<n;i++){
    for(j=n-1;j>=i+1;j--){
      if(numbers[j]<numbers[j-1]){
    temp=numbers[j];
    numbers[j]=numbers[j-1];
    numbers[j-1]=temp;
    c=c + 1;
      }
    }
  }
 
   for(i=0;i<n-1;i++){
     printf("%d ",numbers[i]);
 
    
    }
 
   printf("%d\n",numbers[i]);
  printf("%d\n",c);
 
 
  return 0;
}





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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextInt();
		long ans = 0;
		for(long i = 1; i <= N; i++)
			ans += i * (i + 1) / 2;
		for (int i = 0; i < N-1; i++) {
		    int u = sc.nextInt();
		    int v = sc.nextInt();
		    if(u > v) {
		    	int t = u;
		    	u = v;
		    	v = t;
		    }
		    ans -= (N - v + 1) * u;
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 59592
S = list(input())
like_number = 753
i = 0
r = []
while True:
  if i == len(S):
    break
  elif len(S[0+i:3+i]) >=3:
    c = int(''.join(S[0+i:3+i])) - like_number
    r.append(abs(c))
  else:
    break
  i += 1
print(min(r))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define Rep(i,a,n) for (ll i = (a); i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)
using Graph = vector<vector<ll>>;
using V = vector<ll>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n;
  cin >> n;
  V a(n);
  rep(i,n) cin >> a[i];
  ll x = 0;
  rep(i,n) {
    if (i%2 == 0) x += a[i];
    else x -= a[i];
  }
  rep(i,n) {
    cout << x << ' ';
    x = 2*a[i] - x;
  }
  cout << '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

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

using namespace std;

int main(){


	int n;
	cin >> n;


	for(int p = 0; p < n; p++){
	string str[2];
	cin >> str[0];
	cin >> str[1];

	int a[2];
	int sum = 0;
	for(int k = 0; k < 2; k++){
		bool m = false;
		bool c = false;
		bool x = false;
		bool i = false;
		int cnt = 0;
		for(int j = 0; j < str[k].size(); j++){
			if(str[k][j] >= '2' && str[k][j] <= '9'){
				if(str[k][j+1] == 'm' && m == false && c == false && x == false && i == false){
					m = true;
					cnt += (1000*(str[k][j]-'0'));
					j++;
				}
				else if(str[k][j+1] == 'c' && c == false && x == false && i == false){
					c = true;
					cnt += (100*(str[k][j]-'0'));
					j++;
				}
				else if(str[k][j+1] == 'x' && x == false && i == false){
					x = true;
					cnt += (10*(str[k][j]-'0'));
					j++;
				}
				else if(str[k][j+1] == 'i' && i == false){
					int tmp = str[k][j] - '0';
					cnt += (tmp);
					j++;
				}
				else{
					// dame
				}
			}
			else{
				if(str[k][j] == 'm' && m == false && c == false && x == false && i == false){
					m = true;
					cnt += (1000);
				}
				else if(str[k][j] == 'c' && c == false && x == false && i == false){
					c = true;
					cnt += (100);
				}
				else if(str[k][j] == 'x' && x == false && i == false){
					x = true;
					cnt += (10);
				}
				else if(str[k][j] == 'i' && i == false){
					i = true;
					cnt += (1);
				}
				else{
					// dame
				}
			}
		}
		sum += cnt;
	}

	string form = "";
	int vv = 1000;
	while(vv!=0){
		if(vv == 1000){
			int tmp = sum / 1000;
			if(tmp != 0){
				if(tmp != 1){
					form += (tmp + '0');
				}
				form += 'm';
			}
		}
		else if(vv == 100){
			int tmp = sum / 100;
			tmp %= 10;
			if(tmp != 0){
				if(tmp != 1){
					form += (tmp + '0');
				}
				form += 'c';
			}
		}
		else if(vv == 10){
			int tmp = sum / 10;
			tmp %= 10;
			if(tmp != 0){
				if(tmp != 1){
				form += (tmp + '0');
				}
				form += 'x';
			}
		}
		else{
			int tmp = sum % 10;
			if(tmp != 0){
				if(tmp != 1){
					form += (tmp + '0');
				}
				form += 'i';
			}
		}
		vv/=10;
	}
	cout << form << endl;

	}

	
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
#define INFTY 1000000000;
void merge(int[], int, int, int);
void mergeSort(int[], int, int);
int count=0;
int main(){
  int *A, n, i;
  scanf("%d",&n);
  A = (int *)malloc(sizeof(int) * n);
  for(i=0; i<n; i++)
    scanf("%d",&A[i]);
  mergeSort(A, 0, n);
  for(i=0; i<n; i++){
    printf("%d",A[i]);
    if(i != n - 1)
      printf(" ");
  }
  printf("\n%d\n",count);

  return 0;
}

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

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

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

int main() {
	int n, ans = 0;
	cin >> n;
	if (n >= 105) {
		for (int i = 105; i <= n; i += 2) {
			int count = 0;
			for (int j = 1; j*j <= i; j++) {
				if (j*j == i) count++;
				else if (i % j == 0) count += 2;
			}
			if (count == 8) ans++;
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a,b,c,d,tmp[ohara],tmpp,m,h,w,x,y,sum,pos,k,l;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
P p[ohara];
    
//-------------------------↓↓↓↓↓↓------------------------
    
//------ 自分を天才だと信じる ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n>>l;
    rep(i,n){
        tmp[i]=l+i;
        p[i]=m_p(abs(tmp[i]),i);
    }
    sort(p,p+n);
    rep(i,n){
        if(p[0].se==i)continue;
        ans+=tmp[i];
    }
    Cout(ans);
    return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/07/23  Problem: AOJ 0526 / Link: https://onlinejudge.u-aizu.ac.jp/challenges/search/volumes/0526  ----- */
/* ------問題------

JOI国には，n 島の島があり，各島には 1 から n までの番号が付けられている．現在，JOI国では各島の間を結ぶ航路網の整備が進んでいる．
あなたは，船舶の切符を扱っているチケットセンターに勤務している．JOI国には船舶を使って，できる限り安価に，島と島の間を旅行したいと考えている人が沢山おり，彼らは，出発地と目的地を注文票に記入して，あなたのところに送ってくる．
あなたの仕事は，客から注文票を受け取ったらすぐに，いくつかの船舶を乗り継いで，出発地と目的地を結ぶ航路の中で，もっとも安価な運賃を計算し，客に伝えることである． ただし，旅程によっては，船舶を使って旅行することが出来ない場合もある．そのときは『船舶を使って旅行することが出来ない』と客に伝える必要がある．また，JOI国では，島と島の間を結ぶ新しい船舶が，次々と運航を開始しており，あなたには，その情報が随時伝えられる．客に返事をする際には，最新の情報に留意しなければならない．
入力として，客の注文票や新たに運航を開始した船舶の運航情報が与えられたときに，客への返事を求めるプログラムを作成せよ．
なお，入力例１と出力例１に対する実行状況を，図１として図示している．

-----問題ここまで----- */
/* -----解説等-----

ワーシャルフロイドを思い出すと、更新は経由地を決めたときだけなので、a,bの二点を更新の要素にする。
更新されるのは1000回しか無いので、10^7ぐらいの計算で間に合う。

----解説ここまで---- */


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

	int N, K;
	while (cin >> N >> K, N) {

		VVI dist(N, VI(N, INF));
		FOR(i, 0, N)dist[i][i] = 0;
		FOR(_, 0, K) {
			int q; cin >> q;
			if (!q) {
				int a, b; cin >> a >> b;
				a--, b--;
				cout << (dist[a][b] != INF ? dist[a][b] : -1) << endl;
			}
			else {
				int a, b, c; cin >> a >> b >> c; a--, b--;
				if (dist[a][b] > c) {
					dist[a][b] = dist[b][a] = c;
					int kth[] = { a,b };
					FOR(k, 0, 2) {
						FOR(i, 0, N) {
							FOR(j, 0, N) {
								dist[i][j] = min(dist[i][j], dist[i][kth[k]] + dist[kth[k]][j]);
							}
						}
					}
				}
			}
		}
	}



	return 0;
}



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


int main(){
    int n;
    cin >> n;
    vector<long long> A(n);
    for(auto& a : A){
        cin >> a;
    }
    long long min_A = A[0];
    long long max_A = A[0];
    long long sum_A = 0;
    for(auto& a : A){
        min_A = min(min_A, a);
        max_A = max(max_A, a);
        sum_A += a;
    }
    cout << min_A << " " << max_A << " " << sum_A << endl;
    return 0;
}


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


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

	ll ans = (n/500) * 1000;

	n %= 500;

	ans += (n/5)*5;

	cout << ans << endl;

	return 0;		
}

Measured memory_bytes: 256
function main(input) {
    var list = input[0].split(" ").map(v=>v-0);
    var a = list[0], b=list[1], x=list[2];
    var ans = true;
    if(a+b<x) ans = false;
    if(a>x) ans = false;
    console.log(ans?"YES":"NO");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


Measured memory_bytes: 7372
N = int(input())
c1 = 0
c2 = 0
c3 = 0
count = 0
for i in range(N):
  s = input()
  count += s.count('AB')
  if s[0] == 'B' and s[-1] == 'A':
    c1 += 1
  elif s[0] == 'B' and s[-1] != 'A':
    c2 += 1
  elif s[0] != 'B' and s[-1] == 'A':
    c3 += 1
  else:
    pass

if c1 == 0:
  print(count + min(c2,c3))
else:
  if c2 > 0 or c3 > 0:
    print(count + c1 + min(c2,c3))
  else:
    print(count + c1-1)

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

int main() {
  
  string v = "aeiou";

  char c;
  cin >> c;
  
  string ans = "consonant";
  for(int i=0; i<5; i++){
    if (v.at(i) == c) ans = "vowel";
  }
  
  cout << ans << endl;
  
  
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;

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



Measured memory_bytes: 256
//#pragma GCC optimize ('O3')
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int N = 80 + 5;
const int M = 5e5 + 5;
const int OO = 1e9;
const int mod = 1e9 + 7;

int n,a[N],inc,idx;
ll ans=1000;

void init() {}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;

    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    for (int i = 1; i < n; ++i) {
        if(a[i]>a[i-1] && !inc) {
            inc = 1;
            idx = i - 1;
        } else if(a[i]<=a[i-1] && inc) {
            //cout << idx << ' ' << i - 1 << '\n';
            ans = ans/a[idx]*a[i-1] + ans%a[idx];
            inc = 0;
        }
    }

    //cout << ans << '\n';
    //cout << idx << ' ' << n - 1 << '\n';
    if(inc) ans = ans/a[idx]*a[n-1] + ans%a[idx];

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 3572
//#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;
    cin >> n;
    vll a(n);
    REP(i,n){
        cin >> a[i];
    }
    sort(ALL(a));
    if(a[n-1]==0){
        cout << "Yes\n";
        return 0;
    }else if(n%3==0){
        if(a[0]==a[n/3-1]&&a[n/3-1]!=a[n/3]&&a[n/3]==a[2*(n/3)-1]&&a[2*(n/3)-1]!=a[2*(n/3)]&&a[2*(n/3)]==a[n-1]){
            if(a[0]==((a[n/3])^(a[n-1]))){
                cout << "Yes\n";
                return 0;
            }
        }else if(a[0]==0&&a[0]==a[n/3-1]&&a[n/3-1]!=a[n/3]&&a[n/3]==a[n-1]){
                cout << "Yes\n";
                return 0;
        }
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 1024
from numba import njit
import numpy as np


def main(N, K, A):
    d = np.zeros(N, np.int32)
    d = d-1
    p = 1
    for i in range(K):
        if d[p-1] == -1:
            d[p-1] = i
            p = A[p-1]
        else:
            p = A[p-1]
            loop = i-d[p-1]+1
            nokori = (K-d[p-1]) % loop
            for _ in range(nokori):
                p = A[p-1]
            return p
    return p


N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = main(N, K, A)
print(ans)


Measured memory_bytes: 115320
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int N;
   cin >> N;
   int T[N];
   int sum = 0;
   for (int i = 0; i < N; i++) {
      cin >> T[i];
      sum += T[i];
   }
   int M;
   cin >> M;
   int P, X;
   for (int i = 0; i < M; i++) {
      cin >> P >> X;
      P--;
      cout << sum - T[P] + X << endl;
   }
   return 0;
}


Measured memory_bytes: 256
#include<iostream>

#define	mp	make_pair
#define	pb	push_back

using namespace std;

typedef	pair<int,int>	pii;

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

int main(){
	char maze[30][31],nextmaze[30][30];
	int chk[30][30];

	for(int w,h;cin>>w>>h,w;){
		for(int i=0;i<h;i++)	cin>>maze[i];

		int man=0;
		for(int i=0;i<h;i++)for(int j=0;j<w;j++){
			if(maze[i][j]!='.' && maze[i][j]!='X' && maze[i][j]!='#'){
				if     (maze[i][j]=='E')	maze[i][j]=0;
				else if(maze[i][j]=='N')	maze[i][j]=1;
				else if(maze[i][j]=='W')	maze[i][j]=2;
				else if(maze[i][j]=='S')	maze[i][j]=3;
				man++;
			}
		}

		int ans=-1;
		for(int t=0;t<=180;t++){
#ifdef DEBUG
cout<<"t="<<t<<endl;
for(int i=0;i<h;i++){for(int j=0;j<w;j++){
if(maze[i][j]==0)cout<<"E ";
else if(maze[i][j]==1)cout<<"N ";
else if(maze[i][j]==2)cout<<"W ";
else if(maze[i][j]==3)cout<<"S ";
else	cout<<maze[i][j]<<" ";
}cout<<endl;}cout<<endl;
#endif
			if(man==0){ ans=t; break; }

			for(int i=0;i<h;i++)for(int j=0;j<w;j++)	chk[i][j]=777;

			for(int i=0;i<h;i++)for(int j=0;j<w;j++){
				if(maze[i][j]>3)	continue;
				for(int k=0,l=(maze[i][j]+3)%4;k<4;k++,l=(l+1)%4){
					int y=i+dy[l],x=j+dx[l];
					if(0<=y && y<h && 0<=x && x<w && (maze[y][x]=='.' || maze[y][x]=='X')){
						maze[i][j]=l;
						chk[y][x]=min(chk[y][x],(l+2)%4);
						break;
					}
				}
			}
#ifdef DEBUG2
for(int i=0;i<h;i++){for(int j=0;j<w;j++){
if(chk[i][j]>100)cout<<"x ";
else	cout<<chk[i][j]<<" ";
}cout<<endl;}cout<<endl;
#endif
			for(int i=0;i<h;i++)for(int j=0;j<w;j++)	nextmaze[i][j]=maze[i][j];

			for(int i=0;i<h;i++)for(int j=0;j<w;j++){
				if(maze[i][j]>3)	continue;
				int y=i+dy[maze[i][j]],x=j+dx[maze[i][j]];
				if(0<=y && y<h && 0<=x && x<w && chk[y][x]==(maze[i][j]+2)%4){	// movable
					if(maze[y][x]=='.')	nextmaze[y][x]=maze[i][j];
					else if(maze[y][x]=='X')	man--;
					nextmaze[i][j]='.';
				}
			}

			for(int i=0;i<h;i++)for(int j=0;j<w;j++)	maze[i][j]=nextmaze[i][j];
		}

		if(~ans)	cout<<ans<<endl;
		else		cout<<"NA"<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
h,*s=open(0)
h,w,k,*m=map(int,h.split())
b=w
while b:
 b-=1;r=t=j=0;d=[0]*h
 while w-j:
  i=c=0;j+=1
  while h-i:
   d[c]+=s[i][~j]>'0';c+=b>>i&1;i+=1
   if max(d)>k:d=[0]*h;r+=1;t,j=j,j-(t<j);i=h
 m+=r+c,
print(min(m))

Measured memory_bytes: 44124
#include "bits/stdc++.h"
using namespace std;

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}


/* math_method */
int ceil(int a, int b){return a / b + (a % b > 0);}


/* main */

int a, b;
void in(){
    cin >> a >> b;
}

void solve(){

    print((a * 3 + b) / 2);
}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

Measured memory_bytes: 256
use std::io;
fn main() {

    let mut input = String::new();
    io::stdin().read_line(&mut input)
        .expect("Failed to read line")
        ;

    let v: Vec<char> = input.chars().collect();
    let mut res = 0;
    if v[0] == '1' { res = res + 1 }
    if v[1] == '1' { res = res + 1 }
    if v[2] == '1' { res = res + 1 }

    println!("{}", res);

}


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

int l, r, d;

int main () {
    int n;
    while(scanf("%d %d %d", &l, &r, &d) == 3) {
        int res = 0;
        for (int i = l; i <= r; i++) res += i % d == 0;
        printf("%d\n", res);
    }
}



Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; ++i)

using namespace std;
using ll = long long;

int main() {
    int D, G, p[11], c[11];
    cin >> D >> G;

    rep(i, D) cin >> p[i] >> c[i];

    int ans = 1e9;
    // maskを2ビット表示にして、選択する問題を効率よく表示
    for (int mask = 0; mask < (1 << D); ++mask) {
        int s = 0, num = 0, rest_max = -1;
        // ボーナスを獲得するまで解く問題を選択
        rep(i, D) {
            // i番目のビットが1だった場合(i番目の本を選択する場合)
            if (mask >> i & 1) { // maskを右にi[bit]シフト
                s += 100 * (i + 1) * p[i] + c[i]; // 100i点*問題数+ボーナス
                num += p[i]; // 問題数を加算
            }
            else {
                rest_max = i;
            }
        }
        // 点が足りなかった場合、中途半端に解く問題を追加
        if (s < G) {
            int s1 = 100 * (rest_max + 1);
            int need = (G - s + s1 - 1) / s1;
            if (need >= p[rest_max]) {
                continue;
            }
            num += need;
        }

        ans = min(ans, num);
    }
    cout << ans << endl;
}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  vector<int> res(1 << 15);
  vector<int> v;
  auto dfs = [&](auto&& self) -> void {
    int s = 0;
    for (int e : v) {
      s += e * e;
    }
    if (s < 1 << 15) {
      ++res[s];
    }
    if (v.size() == 4) {
      return;
    }
    for (int i = v.empty() ? 1 : v.back(); i < 200; ++i) {
      v.push_back(i);
      self(self);
      v.pop_back();
    }
  };
  dfs(dfs);
  int n;
  while (cin >> n, n) {
    cout << res[n] << '\n';
  }
}



Measured memory_bytes: 3120
#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {
    int N, K;
    cin >> N >> K;

    int ans =0;
    for(int i=0; i<N; i++) {
        int x;
        cin >> x;
        ans += 2 * min(x, K-x);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// more : http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_B&lang=jp

#include <bits/stdc++.h>
using namespace std;

struct SegTree
{
    int N;
    vector<int> dat,lazy;

    SegTree(int n)
    {
        N = 1;
        while (N < n) N<<=1;
        dat.assign(2*N-1, 0);
        lazy.assign(2*N-1, 0);
    }

    void add(int a,int b,int x) { add(a,b,x,0,0,N); }

    int add(int a,int b,int x,int k,int l,int r)
    {
        if ( r <= a || b <= l ) return dat[k];
        if ( a <= l && r <= b )
        {
            lazy[k] += x;
            return dat[k] += x;
        }

        return dat[k] = add(a,b,x,k*2+1,l,(l+r)/2) + add(a,b,x,k*2+2,(l+r)/2,r) + lazy[k] * (r-l);
    }

    int sum(int a,int b){ return sum(a,b,0,0,N); }

    int sum(int a,int b,int k,int l,int r)
    {
        if ( r <= a || b <= l ) return 0;
        if ( a <= l && r <= b ) return dat[k];

        return sum(a,b,k*2+1,l,(l+r)/2) + sum(a,b,k*2+2,(l+r)/2,r) + lazy[k] * (r-l);
    }
};


int main()
{
    int N,Q;
    cin >> N >> Q;

    SegTree seg(N);

    for(int i=0; i<Q; i++)
    {
        int c,x,y;
        cin >> c >> x >> y;

        if(c)
        {
            cout << seg.sum(x-1,y) << endl;
        }
        else
        {
            seg.add(x-1,x,y);
        }
    }
}

Measured memory_bytes: 3116
import sys

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

N = int(input())
ans = 0
for i in range(1, N + 1):
    if len(str(i)) % 2 == 1:
        ans += 1
print(ans)


Measured memory_bytes: 3064
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,w;
    cin>>n>>w;
    VP vec(n);
    ll leastw=1e18;
    rep(i,n){
        cin>>vec[i].F>>vec[i].S;
        chmin(leastw,vec[i].F);
    }
    ll topw=0;
    VV dp(n+1,V(500,0));
    rep(i,n){
        ll disw=vec[i].F-leastw;
        for(int j=i;j>=0;j--){
            rep(k,topw+1){
                chmax(dp[j+1][k+disw],dp[j][k]+vec[i].S);
            }
        }
        topw+=disw;
    }
    ll ans=0;
    rep(i,n+1){
        rep(j,500){
            if(i*leastw+j>w)continue;
            chmax(ans,dp[i][j]);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <queue>
#include <set>
#include <queue>
using namespace std;
#define N 500050
int head[N],to[N<<1],nxt[N<<1],cnt,n,a[N],p[N],du[N],K,Q[N],ans[N];
set<int>S,T;
priority_queue<int>q;
inline void add(int u,int v) {
	swap(u,v);
	to[++cnt]=v; nxt[cnt]=head[u]; head[u]=cnt; du[v]++;
}
int main() {
	scanf("%d%d",&n,&K);
	int i,x,lq=0;
	for(i=1;i<=n;i++) scanf("%d",&a[i]),p[a[i]]=i;
	for(i=1;i<=K;i++) S.insert(a[i]);
	for(i=1;i<=n;i++) {
		set<int>::iterator it;
		it=S.upper_bound(a[i]);
		if(it!=S.end()) add(p[*it],i);
		it=T.upper_bound(a[i]);
		if(it!=T.end()) add(p[*it],i);
		T.insert(a[i]);if(i-K+1>=1) T.erase(a[i-K+1]);
		if(i+K<=n) S.insert(a[i+K]); S.erase(a[i]);
	}
	for(i=1;i<=n;i++) if(!du[i]) q.push(-i);
	while(!q.empty()) {
		x=-q.top(); q.pop();
		Q[++lq]=x;
		for(i=head[x];i;i=nxt[i]) {
			if((--du[to[i]])==0) q.push(-to[i]);
		}
	}
	for(i=1;i<=n;i++) ans[Q[i]]=i;
	for(i=1;i<=n;i++) printf("%d\n",ans[i]);
}


Measured memory_bytes: 46464
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████   
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1LL<<60
#define fs first
#define sc second
#define pb push_back
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int 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 range(i,a,b) (a)<=(i) && (i)<(b)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;

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

  int s;
  cin >> s;

  int cnt = 1;
  map<int,int> mp;
  mp[s]++;

  while(s){
    cnt++;
    if(s % 2 == 0) s /= 2;
    else s = s*3+1;
    mp[s]++;
    if(mp[s] == 2){
      cout << cnt << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b||b==c||c==a)
        if(a==b&&b==c&&c==a)
            cout<<"No";
        else   
            cout<<"Yes";
    else
        cout<<"No";
}

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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin>>n;
	set<pair<pair<int,int>,int>> s;
	int count=0;
	for(int i=1;i<=1000000;i++){
		for(int j=1;j<=1000000;j++){
			if(i*j<n){
				count++;
			
			}
			else{
				break;
			}
		}
	}
	cout<<count<<endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    for (int i = 0; i < ty - sy; i++) cout << "U";
    for (int i = 0; i < tx - sx; i++) cout << "R";
    for (int i = 0; i < ty - sy; i++) cout << "D";
    for (int i = 0; i < tx - sx; i++) cout << "L";

    cout << "L";
    for (int i = 0; i <= ty - sy; i++) cout << "U";
    for (int i = 0; i <= tx - sx; i++) cout << "R";
    cout << "DR";
    for (int i = 0; i <= ty - sy; i++) cout << "D";
    for (int i = 0; i <= tx - sx; i++) cout << "L";
    cout << "U";

    return 0;
}

Measured memory_bytes: 256