akhauriyash/Code-Regression huggingface dataset:
n, k = map(int, input().split())
v = list(map(int, input().split()))

ans = 0
for p in range(min(k, n) + 1):
    for q in range(min(k, n) - p + 1):
        t = []
        for i in range(p):
            t.append(v[i])
        for i in range(q):
            t.append(v[n - 1 - i])
        t.sort()
        s = sum(t)
        for i in range(min(k - p - q, len(t))):
            if t[i] < 0:
                s -= t[i]
        ans = max(ans, s)

print(ans)


Measured memory_bytes: 3188
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	if a+b+c != 17 ||
		(a != 5 && a != 7) ||
		(b != 5 && b != 7) ||
		(c != 5 && c != 7) {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;

class A
{
	public static void Main ()
	{

		char[] s = Console.ReadLine ().ToCharArray ();
		for (int i=0; i<s.Length; i++) {
			if (s [i] >= 65 && s [i] <= 90) {	//up
				s [i] += (char)32;
			} else if (s [i] >= 97 && s [i] <= 122) { //low
				s [i] -= (char)32;
			}
		}

		Console.WriteLine ( s );

	}
}

Measured memory_bytes: 8736
n, m = map(int, input().split())

c = [0]* m
s = [0]* m
for i in range(m):
    s[i], c[i] = map(int, input().split())

flg = True

if n == 1:
    i = 0
    i_str = str(i)
    for j in range(m):
        if i_str[s[j]-1] != str(c[j]):
            flg = False
            continue
    if flg==True:
        print(i)
        exit()
    flg = True

for i in range(10**(n-1),10**n):
    i_str = str(i)
    for j in range(m):
        if i_str[s[j]-1] != str(c[j]):
            flg = False
            continue
    if flg==True:
        print(i)
        exit()
    flg = True

print(-1)


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

int sq(int n){
    return n*n;
}

int main(){
    int n;
    cin >> n;
    while(n--){
        int arr[3];
        for(int i=0; i<3; i++){
            cin >> arr[i];
        }
        sort(arr,arr+3);
        if(sq(arr[0]) + sq(arr[1]) == sq(arr[2])){
            cout << "YES" << endl;
        } else
            cout << "NO" << endl;
    }
}

Measured memory_bytes: 1168
#include<iostream>
#include<vector>
using namespace std;
bool solve(string s,vector<pair<char,char>>q,int p,int n){
  for(int i=0;i<q.size()&&p!=n;i++)if(q[i].first==s[p])p+=(q[i].second=='R'?1:-1);
  return p==n?true:false;
}
int main(){
  int n,q,ok,ng,ans;
  cin>>n>>q;
  ans=n;
  string s;
  cin>>s;
  s="0"+s+"0";

  vector<pair<char,char>>Q(q);
  for(int i=0;i<q;i++)cin>>Q[i].first>>Q[i].second;

  ok=1,ng=n+1;
  while(abs(ok-ng)>1){
    int mid=(ok+ng)/2;
    if(solve(s,Q,mid,0))ok=mid;
    else ng=mid;
  }
  ans-=ok;

  ok=n+1,ng=1;
  while(abs(ok-ng)>1){
    int mid=(ok+ng)/2;
    if(solve(s,Q,mid,n+1))ok=mid;
    else ng=mid;
  }
  ans-=(n-ok+1);

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

Measured memory_bytes: 1472
N, M = input().split(" ")
#S = []
if M == 1:
    a, b = input().split(" ")
    print(int(b)-int(a)+1)
else:    
    a, b = input().split(" ")
    aM, bm = int(a),int(b)
    #sets = set([i for i in range(int(a),int(b)+1)])
    for m in range(int(M)-1):
        a, b = input().split(" ")
        aM = max(aM,int(a))
        bm = min(bm,int(b))
        #sets = sets & set([i for i in range(int(a),int(b)+1)])
    if(bm<aM):
        print(0)
    else:
        print(int(bm)-int(aM)+1)

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i=(a); i<(n); ++i)
#define rrep(i,a,n) for(ll i=(a); i>(n); --i)
#define erep(i,a,n) for(ll i=(a); i<=(n); ++i)
#define rerep(i,a,n) for(ll i=(a); i>=(n); --i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int) x.size())
#define print(X) cout << (X) << endl
#define _ << " " <<
static const int INF = 1e+9+7;
ll n,m;
str s,t;
ll A[100000];


int main(){
  int a,b,c,d;
  cin >> a >> b>> c>>d;

  if(abs(c-a)<=d || (abs(a-b)<=d && abs(b-c)<=d)) print("Yes");

  else print("No");

  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    x = list(map(int, input().split()))
    ans = float('inf')

    for p in range(-100, 201):
        summed = 0

        for xi in x:
            summed += (xi - p) ** 2

        ans = min(ans, summed)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <limits>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <queue>

#define MAX 100009
#define INF 99999999
#define in(a,b)  ( (b).find(a) != (b).end())
#define clr(a,b) memset((a), (b), sizeof((a)))
#define pb       push_back
#define all(a)   a.begin(), a.end()  
#define mp       make_pair
#define ll	long long
#define fi	first
#define se second

const long double pi = 3.141592653589793238L;
const ll mod = 1e9 + 7;

/**
*
* @Author Lahia omar
*/

using namespace std;

void split(vector<string> &v, string cur) {
	istringstream iss(cur);
	copy(istream_iterator<string>(iss), istream_iterator<string>(), back_inserter(v));
}
int t;
string a, b, c;
int main(int argc, char* argv[]) {
	cin >> a >> b >> c;
	cout << ((stoll(a + b + c) % 4 == 0) ? "YES" : "NO" )<< endl;
	return 0;
}

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

char a[12];

ll f(int x, ll s, ll t){
    if(!a[x]) return s + t;
    ll v = a[x] - '0';
    return f(x + 1, s + t, v) + f(x + 1, s, t * 10 + v);
}

int main(){
    scanf("%s", a);
    printf("%lld\n", f(1, 0, a[0] - '0'));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n, k;
    cin >> n >> k;
    vll t(n), d(n);
    vp sushi(n);
    rep(i, n){
        cin >> t[i] >> d[i];
        sushi[i] = make_pair(d[i], t[i]);
    }
    vi types(n+1, 0);
    sort(ALL(sushi));
    reverse(ALL(sushi));
    priority_queue<ll, vll, greater<ll>> S;
    vll f(n+1, -INF);
    ll taste = 0;
    ll ty = 0;
    rep(i, k){
        taste += sushi[i].first;
        types[sushi[i].second]++;
        if(types[sushi[i].second] > 1) S.push(sushi[i].first);
        else ty++;
    }
    f[ty] = taste;
    repr(i, k, n){
        if(S.empty()) break;
        if(types[sushi[i].second] == 0){
            ll next = S.top();
            S.pop();
            types[sushi[i].second]++;
            ty++;
            taste -= next;
            taste += sushi[i].first;
            f[ty] = taste;
        }
    }
    ll ans = -INF;
    repr(i, 1, n+1){
        chmax(ans, f[i]+i*i);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int a, b, c1, c2,c3, ans;
    cin>>a>>b;
    
    c1 = a+b;
    c2 = a-b;
    c3 = a*b;
    
    if(c1>c2){
        if(c1>c3){
            ans=c1;
        }else{
            ans=c3;
        }
    }else{
        if(c2>c3){
            ans=c2;
        }else{
            ans=c3;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import io.{StdIn => in}

object Main extends App {
  val Array(n, a) = in.readLine.split(" ").map(_.toInt)
  val x = in.readLine.split(" ").map(_.toInt).sorted
  val sumMax = math.max(x.max * n, a * n)
  val dp = Array.ofDim[Long](n+1, n+1, sumMax + 1)

  for(i <- 0 to n) dp(i)(0)(0) = 1
  for{
      i <- 1 to n; xi = i - 1
      j <- 1 to n; if j <= i
      k <- 1 to sumMax
    } {
      dp(i)(j)(k) =
        if(k < x(xi)) dp(i-1)(j)(k)
        else dp(i-1)(j)(k) + dp(i-1)(j-1)(k-x(xi))

      // if(k == sumMax) println(i + " " + j + " : " + dp(i)(j).mkString(" "))
    }

  val ans = (1 to n)./:(0L)((acc,j) => {
    // println(n + " " + j +  " " + a*j + " : " + dp(n)(j)(a*j))
    acc + dp(n)(j)(a*j)
  })
  println(ans)
}

Measured memory_bytes: 92140
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        int N, K;
        String S;
        StringBuilder ans = new StringBuilder();

        void solve(InputReader in, PrintWriter out) {
            // write your code here
            N = in.nextInt();
            K = in.nextInt();
            S = in.next();

            for (int i = 0; i < N; ++i) {
                if (i == K - 1) {
                    ans.append(Character.toLowerCase(S.charAt(i)));
                } else {
                    ans.append(S.charAt(i));
                }
            }

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

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int size) {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        long[] nextLongArray(int size) {
            long[] arr = new long[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
    }
}


Measured memory_bytes: 21460
#include <iostream>
using namespace std;
int main(void){
	int n;
	cin >>n;
	int soma=0;
	int drinks[n];
	for(int i=0;i<n;i++){
		cin>>drinks[i];
		soma+=drinks[i];
	}
	int m;
	cin >> m;
	while(m--){
		int x,y;
		cin >> x >>y;
		cout << soma - drinks[x-1]+y<<endl;
	}
}

Measured memory_bytes: 3576
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define FF first
#define SS second
#define INF 2e18;
#define mp make_pair
#define ll long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define endl '\n'
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define sz(s) (int)s.size()
#define all(x) x.begin(), x.end()
typedef long double ld;

const int N = 1005;
int a[N];
vector<int> pos, pos1, pos2;

signed main()
{
    //freopen("inp.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    srand(time(NULL));
 
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    // n = 1000;
    bool lol = 1;
    fr(i, 1, n) {
        cin >> a[i];
        if(a[i] >= 0) lol = 0;
        // a[i] = -1000 + rand() % 2000;
    }
    int l = -1, r = -1;
    int maxi = -1e18;
    if(!lol) {
        fr(i, 1, n) {
            int s = 0;
            if(a[i] < 0) continue;
            for(int j = 0; i + j <= n; j += 2) {
                s += max(a[i + j], (int)0);
                if(s > maxi) maxi = s, l = i, r = i + j;
            }
        }
    }
    else {
        fr(i, 1, n) {
            if(a[i] > maxi) {
                maxi = a[i], l = i, r = i;
            }
        }
    }
    // cout << l << " " << r << endl;
    for(int i = l; i <= r; i += 2) {
        if(a[i] >= 0) pos1.pb(i);
    }
    cout << maxi << endl;
    fr(i, 1, l - 1) {
        pos.pb(1);
    }
    int cc = (l - 1);
    r -= (l - 1);
    n -= (l - 1);
    l = 1;
    while(n != r) {
        pos.pb(n);
        n--;
    }
    for(int i = 0; i < sz(pos1) - 1; i++) {
        int idx = (pos1[i] + pos1[i + 1]) / 2;
        for(int j = 1; j <= idx - pos1[i]; j++) {
            pos.pb(idx - j + 1 - cc);
        }
        cc += 2 * (idx - pos1[i]);
    }
    cout << sz(pos) << endl;
    for(int p : pos) {
        cout << p << endl;
    }
    return 0;
}

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

using namespace std;

bool visited[200001];
vector <int> adj[200001];
int n,m,a,b;
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int res = 1;

	cin >> n >> m;
	for(int i=0;i<m;i++)
	{
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}

	memset(visited,false,sizeof(visited));
	for(int i=1;i<=n;i++)
	{
		if(visited[i]==false)
		{
			int cnt = 0;
			queue <int> que;
			que.push(i);
			visited[i] = true;
			while(!que.empty())
			{
				int now = que.front();
				que.pop();
				cnt++;
				for(auto next : adj[now])
				{
					if(visited[next]==false)
					{
						visited[next] = true;
						que.push(next);
					}
				}
			}
			res = max(res,cnt);
		}
	}

	cout << res << '\n';
	
	return 0;	
}

Measured memory_bytes: 15080
def pr(a):
    for i in range(len(a)):
        print(a[i],end="")
        if i == len(a)-1:
            print("")
        else :
            print(" ",end="")
def insertionsort(a,n):
    for i in range(1,n):
        v = a[i]
        j = i - 1
        while j >= 0 and a[j] > v:
            a[j+1] = a[j]
            j -= 1
        a[j+1] = v
        pr(a)

n = int(input())
a = input().split()
a = [int(i) for i in a]
pr(a)
insertionsort(a,n)




Measured memory_bytes: 6324
#include<bits/stdc++.h>
#define llu unsigned long long
#define ll long long
#define INF 0x3f3f3f3f
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;

int main()
{
	fast
	int x,y,z;
	cin>>x>>y>>z;
	swap(x,y);
	swap(x,z);
	cout<<x<<" "<<y<<" "<<z;
}

Measured memory_bytes: 256
#include <stdio.h>

#define DATA 10000

int main(void)
{
	int n, i;
	int a[DATA];
	long long int sum = 0;
	long int max = -1000000, min = 1000000;

	scanf("%d", &n);
	if(n < 1)
		return -1;
	for(i = 0;i < n;i++)
	{
		scanf("%d", &a[i]);
		if(a[i] > max)
			max = a[i];
		if(a[i] < min)
			min = a[i];
		sum += a[i];
	}
	printf("%ld %ld %ld\n", min, max, sum);

	return 0;
}

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

int main(void){
    string s;
    cin>>s;
    int q;
    cin>>q;
    deque<char> dq;
    rep(i, (int)(s.length())){
        dq.push_back(s[i]);
    }
    int flag=0;
    rep(i, q){
        int a;
        //cout<<flag<<endl;
        cin>>a;
        if(a==1){
            flag++;
        }
        else{
            int f;
            char c;
            cin>>f>>c;
            if((f==1&&flag%2==0) || (f==2 && flag%2==1)) dq.push_front(c);
            else dq.push_back(c);
        }
    }
    if(flag%2==0){
        while(!dq.empty()){
            cout<<dq.front();
            dq.pop_front();
        }
    }
    else{
        while(!dq.empty()){
            cout<<dq.back();
            dq.pop_back();
        }
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
	
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int L = sc.nextInt();
		
		int sum = 0;
		int ans = 0;
		
		for(int i=1; i<=N; i++) {
			sum += L + i -1;
		}
		
		if(N+L-1<=-1) {
			ans = sum - N - L + 1; 
		}else if(N+L-1>=0 && L<=-1) {
			ans = sum;
		}else {
			ans = sum - L;
		}
		System.out.println(ans);
	}
}



Measured memory_bytes: 21844
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ll infll=(1ull<<63)-1,mod=1e9+7;
const int inf=(1ull<<31)-1;
int n;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(18);
	cin>>n;
	cout<<3*n*n;
	return 0;
}


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

typedef long long ll;

int n, m;
string s, t;
string solution;

bool isValid(int r, int c){
    if (r<0 || r>n || c<0 || c>m) return false;
    return true;
}

void backtrack(int i, int j, vector<vector<int> > &dp){
    if (!isValid(i, j)) return;
    int path1 = (isValid(i-1, j-1) && dp[i][j] == dp[i-1][j-1] + 1) ? dp[i-1][j-1] : -1;
    int path2 = (isValid(i-1, j)) ? dp[i-1][j] : 0;
    int path3 = (isValid(i, j-1)) ? dp[i][j-1] : 0;

    if (path1 >= path2 && path1 >= path3) {
        backtrack(i-1, j-1, dp);
        solution.push_back(s[i-1]);
    }
    else if (path2 >= path3) backtrack(i-1, j, dp);
    else backtrack(i, j-1, dp);
    return;
}

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

    cin>>s>>t;
    n = (int)s.size(); m = (int)t.size();
    
    vector<vector<int> > dp(n+1, vector<int>(m+1));

    for (int i=0;i<=n;++i){
        for (int j=0;j<=m;++j){
            if (i==0 || j==0) dp[i][j] = 0;
            else if (s[i-1] == t[j-1]) 
                dp[i][j] = dp[i-1][j-1] + 1;
            else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }

    backtrack(n, m, dp);
    cout<<solution<<endl;

    return 0;
}


Measured memory_bytes: 35712
import itertools
n,m=map(int,input().split())
link=[[]for j in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  link[a-1].append(b-1)
  link[b-1].append(a-1)
s=list(range(1,n))
res=0
for perm in list(itertools.permutations(s)):
  last=0
  ok=True
  for i in range(n-1):
    if perm[i] not in link[last]:
      ok=False
      break
    else:
      last=perm[i]
  if ok==True:
    res=res+1
print(res)

Measured memory_bytes: 40432
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    int n;cin>>n;
    int ans=0;
    rep(i,1,n+1){
        int cnt=0;
        int u=i;
        while(u>0){
            cnt++;
            u/=10;
        }
        if(cnt%2)ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    i64 h,w;
    cin>>h>>w;
    
    if(h==1||w==1){
        cout<<1<<endl;
    }
    else{
        cout<<(h*w + 1)/2<<endl;
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

///////////////////////////////////////////////////////////////////////////

int main(){
	int n,a,b,c,x,y;
	string s;
	
	cin >> a >> b;

	if(a+b >= 10)cout << "error" << endl;
	else cout << a + b << endl;
	
    
	return  0;
}

Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll 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 fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

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;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;
ll dp[150][10][3];

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

  cin >> s >> k;
  dp[0][0][0] = 1;
  rrep(i, 1, Size(s) + 1) {
    rep(j, k + 1) {
      if (i < j) continue;
      // 0を入れる
      if (s[i - 1] == '0') {
        dp[i][j][0] += dp[i - 1][j][0];
        dp[i][j][1] += dp[i - 1][j][1];
      } else {
        // dp[i][j][0] += dp[i - 1][j][0];
        dp[i][j][1] += dp[i - 1][j][1] + dp[i - 1][j][0];
      }

      if (j == 0) continue;
      // 0でないのを入れる
      rrep(in, 1, 10) {
        if (in < (s[i - 1] - '0')) {
          dp[i][j][1] += dp[i - 1][j - 1][1] + dp[i - 1][j - 1][0];
        } else if (in == (s[i - 1] - '0')) {
          dp[i][j][0] += dp[i - 1][j - 1][0];
          dp[i][j][1] += dp[i - 1][j - 1][1];
        } else {
          dp[i][j][1] += dp[i - 1][j - 1][1];
        }
      }
    }
  }
  ans = dp[Size(s)][k][1] + dp[Size(s)][k][0];
  Cout(ans);
  return 0;
}

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

int main(){
    int n,x,y;
    cin>>n>>x>>y;
    int a[n+1]={0};
    for(int i=1;i<=n;i++){
        for(int j=1;j<i;j++){
            a[min(i-j,abs(x-j)+abs(y-i)+1)]++;
        }
    }
    for(int i=1;i<=n-1;i++)
        cout<<a[i]<<endl;
}


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

using namespace std;

int main(){
    int a,b;
    while(cin>>a>>b){
        int s = a + b;
        if(s==0){
            cout<<1<<endl;
        }else{
            int ans = 0;
            while(s){
                ans++;
                s /= 10;
            }
            cout<<ans<<endl;
        }
    }
}

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

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

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N;
  cin>>N;
  vector<pair<ll,ll>>X(N);
  for(int i=0;i<N;i++)cin>>X[i].first>>X[i].second;
  ll NN=1;
  for(int i=1;i<=N;i++)NN*=i;
  double ans=0;
  sort(rng(X));
  do{
    ll x,y,px,py;
    double res=0;
    for(int i=0;i<N;i++){
      x=X[i].first;
      y=X[i].second;
      if(i==0)px=x,py=y;
      else{
        res+=sqrt((x-px)*(x-px)+(y-py)*(y-py));
        px=x,py=y;
      }
    }
    ans+=res;
  }while(next_permutation(rng(X)));
  cout<<fixed<<setprecision(10)<<ans/NN<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define maxn 100005
int n,k,a[maxn];
ll sum[maxn],pst[maxn],ans;
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);
	for(int i=1;i<=n;++i){
		sum[i]=sum[i-1]+a[i];
		pst[i]=pst[i-1]+std::max(a[i],0);
	}
	for(int l=1;l<=n-k+1;++l){
		int r=l+k-1;
		ans=std::max(ans,pst[l-1]+pst[n]-pst[r]);
		ans=std::max(ans,pst[l-1]+sum[r]-sum[l-1]+pst[n]-pst[r]);
	}printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 2176
#include<iostream>

using i64 = int_fast64_t;

i64 gcd(i64 a,i64 b){
    while(b){
        a%=b;
        std::swap(a,b);
    }
    return a;
}
i64 lcm(i64 a,i64 b){
    return a/gcd(a,b)*b;
}

int main(){
    int n;
    std::cin>>n;
    i64 ans = 1;
    for(int i=0;i<n;++i){
        i64 a;
        std::cin>>a;
        ans = lcm(ans,a);
    }
    std::cout<<ans<<std::endl;
}


Measured memory_bytes: 3104
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;


ll N;
int d[]={3,5,7};
ll cnt=0;

bool ck(ll num){
    set<int> s;
    while(num>0){
        s.insert(num%10);
        num/=10;
    }
    return (s.size()>=3);
}

void calc(ll num,bool is753){
    if(num>N) return;
    if(!is753&&ck(num)) is753=1;
    cnt+=is753;
    num*=10;
    rep(i,3){
        calc(num+d[i],is753);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N;
    calc(0,0);
    cout1(cnt)
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (const string& e_) { return "\"" + e_ + "\""; }
string to_string (char e_) { return "\'" + string(1, e_) + "\'"; }
string to_string (bool e_) { return e_ ? "true" : "false"; }
template <typename T> string to_string (T e_) {
	string s_ = "[ ";
	for (const auto& x_ : e_) s_ += to_string(x_) + " ";
	return s_ + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e_) {
	return "(" + to_string(e_.first) + ", " + to_string(e_.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
const int N = 100010;
ll a[N];
int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	ll n, k , q, x;	
	cin >> n >> k >> q;

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

	for(int i = 1; i <= n; i++){
		ll p = (k - (q - a[i]));
		if(p > 0) cout << "Yes\n";
		else cout << "No\n";
	}
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N, M;
  cin >> N >> M;
  ll ans = N * M;
  if (ans == 1) {
    cout << 1 << "\n";
    return 0;
  }
  if (N == 1 || M == 1) {
    cout << ans - 2 << "\n";
  }
  else {
    cout << ans - 2 * N - 2 * M + 4 << "\n";
  }
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


n = int(input().rstrip())
a = [a for a in input().split()]

b = [None] * n
for i in range(n):
    if i % 2 == 0: b[n // 2 + i // 2] = a[i]
    else: b[n // 2 - (-(-i // 2))] = a[i]
if (n - 1) % 2 == 0: b = list(reversed(b))

for elem in b: print(elem, end=' ')

Measured memory_bytes: 22324
#include<bits/stdc++.h>
using namespace std;
#define pow107 int(pow(10,9) + 7)
#define F(i,x,n) for(int i = x; i < n ; ++i)

bool comp(pair<int, int> a, pair<int, int> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

inline bool pn(long int x){
    if(x <= 1)return false;
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i <= (3 + int(sqrt(x)))/2; ++i){
        if((x != i && x % i == 0) || (x != (3 + int(sqrt(x)) - i) && x % (3 + int(sqrt(x)) - i) == 0))
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}

long int Func2(long int n,long int m){
    long int s2 = 1,
        r = 1;
    for(long int i = 1; i <= m; ++i){
        s2 = (s2*(n - (i - 1))/i) % (pow107);
    }
    return s2;
}

bool secsort(pair<int, int> a, pair<int, int> b){
    if(a.second == b.second)return a.first > b.first;
    else return a.second > b.second;
}

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

long int LCM(long int a,long int b){
    return a/GCD(a,b)*b;
}

void warfl(vector<vector<int> > &dist, int n){
  for(int k=0; k<n; k++){
    for(int i=0; i<n; i++){
      for(int j=0; j<n; j++){
        dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
      }
    }
  }
  return;
}
//#define long long long

const int MAX = 1000000;
const int MOD = 1e9+7;

long mpow(long x, long n){
    long ans = 1;
    while(n != 0){
        if(n%2==1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n/2;
    }
    return ans;
}

long mfact(long n){
  long ans = 1;
  for(long i=2; i<=n; i++){
    ans = ans*i % MOD;
  }
  return ans;
}

long mcomb(long n, long m){ //aCbをmod計算
    if(n == 0 && m == 0) return 1;
    if(n < m || n < 0) return 0;
    long ans = mfact(n)*mpow(mfact(m), MOD-2) %MOD;
    ans = ans*mpow(mfact(n-m), MOD-2) %MOD;
    return ans;
}

long int jjjjj(long int n){
    long int x = 1;
    for(int i = 1; i <= n; ++i){
        x *=i;
    }
    return x;
}

int main(){
    int n,x[2][101] = {};
    cin >> n;

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

    int i = 0, j = 0,ans = 0;

    for(int i = 0; i < n; ++i){
        int anss = 0;
        for(int j = 0; j <= i; ++j){
            anss += x[0][j];
        }
        for(int j = i; j < n; ++j){
            anss += x[1][j];
        }
        if(ans < anss)ans = anss;
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long lint;

int N,A,B;
int M;
const int MAX_N = 55;

lint a[MAX_N], b[MAX_N], c[MAX_N];
lint dp[MAX_N][MAX_N];

lint f(lint x,lint y){
    if(y==0)return 1;
    if(x<y)return 0;
    if(x==y)return 1;
    lint& ret = dp[x][y];
    if(~ret)return ret;
    ret = f(x-1,y) + f(x-1,y-1);
    return ret;
}

void solve(){
    lint sum = 0;
    for(int i=0;i<A;i++){
        sum += a[i];
    }
    printf("%lf\n", (double)sum/A);
    
    lint cnt = 0, x = 0;
    while(x<M && cnt<A){
        cnt += c[x++];
    }
    x--;
    
    lint ans = 0;
    if(x == 0){
        for(int i=A;i<=B;i++){
            ans += f(c[x],i);
        }
    }else{
        ans = f(c[x],A-(cnt-c[x]));
    }
    printf("%lld\n",ans);
}

int main(){
    memset(dp,-1,sizeof(dp));
    scanf("%d%d%d",&N,&A,&B);
    for(int i=0;i<N;i++){
        scanf("%lld",&a[i]);
    }
    sort(a,a+N);
    for(int i=0;i<N;i++){
        b[i] = a[i];
    }

    M = unique(b,b+N)-b;
    reverse(a,a+N);
    reverse(b,b+M);

    for(int i=0,j=0,k=0;i<M;i++){
        while(j<N && a[j]==b[i])j++;
        c[i] = j-k;
        k=j;
    }
    solve();

    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>
 
int main(void) {
  int a, b;
  while(scanf("%d%d", &a, &b) != EOF) {
    int c = a + b;
    int d = (int)log10(c) + 1;
    printf("%d\n", d);
  }
  return 0;
}


Measured memory_bytes: 2976
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000



int main(){
	
	int N,A,B;
	cin>>N>>A>>B;
	
	string S;
	cin>>S;
	int x = 0;
	int y = 0;
	for(int i=0;i<S.size();i++){
		if(S[i]=='c'){
			cout<<"No"<<endl;
			continue;
		}
		
		if(S[i]=='a'){
			if(x<A+B){
				x++;
				cout<<"Yes"<<endl;
				continue;
			}
			else{
				cout<<"No"<<endl;
				continue;
			}
		}
		else{
			if(x<A+B&&y<B){
				y++;
				x++;
				cout<<"Yes"<<endl;
			}
			else{
				cout<<"No"<<endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 896
/*
We will not return to the countless mistakes of the past
I will not relive the failures of the man I once was

Only through dedication will I destroy all preconception

No longer will I let myself be truly satisfied with the standard
We will not return to the countless mistakes of the past

Only through dedication will I destroy all preconception

Let this be
Be the day
Day of my
My declaration
Let this be the day of my declaration

Join me,
Walk with me
Shatter the bonds that tie us
To what we strive to never be

Join me,
Walk with me
*/
#include<bits/stdc++.h>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const ll maxn=1000001,mod=1e9+7;

vvi v(maxn);
bool vis[maxn];
ll temp[maxn],dist[maxn];
ll a[maxn];

void init(ll n){
fore(i,1,n){ v[i].clear(); vis[i]=false; temp[i]=0; dist[i]=INT_MAX; }
}


int main(){

int a[3];
cin>>a[0]>>a[1]>>a[2];
sort(a,a+3);
cout<<abs(a[0]-a[1])+abs(a[1]-a[2]);
//int ans=min(abs(a-b)+abs(b-c,min(abs(b-c)+a,abs(a-c)+b));
//cout<<ans;
return 0;
}


Measured memory_bytes: 23680
// AOJ 2334 Roads on Towns
// 2018.2.24 bal4u

#include <stdio.h>
#include <math.h>

#define EPS			1e-10
#define INF			1e20
typedef struct { double x, y; } PP;

PP p[2][1002];

PP vectorSub(PP p1, PP p2) { PP r; r.x = p1.x - p2.x, r.y = p1.y - p2.y; return r; }
double cross(PP a, PP b) { return a.x * b.y - a.y * b.x; }
double dot(PP a, PP b) { return a.x * b.x + a.y * b.y; }
double norm(PP a) { return a.x * a.x + a.y * a.y; }
double vectorAbs(PP a) { return hypot(a.x, a.y); }

int ccw(PP p0, PP p1, PP p2)
{
	PP a = vectorSub(p1, p0), b = vectorSub(p2, p0);
	double t = cross(a, b);
	if (t >  EPS) return 1;
	if (t < -EPS) return -1;
	if (dot(a, b) < -EPS) return 2;
	if (norm(a) < norm(b)) return -2;
	return 0;
}

int intersect(PP p1, PP p2, PP p3, PP p4)
{
	return ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 &&
		   ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0;
}

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	if (c == '-') {
		c = getchar_unlocked();
		do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
		while (c >= '0');
		return -n;
	}
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

double calc(PP s, PP g, PP *a, int n, PP es, PP eg)
{
	int i, j;
	double ans, x, y;

	if (!intersect(s, g, es, eg)) return vectorAbs(vectorSub(s, g));
	if (n == 0) return INF+100;

	ans = INF+100;
	for (i = 0; i < n; i++) {
		if (intersect(s, a[i], es, eg)) continue;
		x = vectorAbs(vectorSub(s, a[i]));
		if (!intersect(g, a[i], es, eg)) {
			y = vectorAbs(vectorSub(g, a[i]));
			if (x + y < ans) ans = x + y;
			continue;
		}
		for (j = 0; j < n; j++) if (j != i) {
			if (intersect(a[i], a[j], es, eg)) continue;
			if (!intersect(g, a[j], es, eg)) {
				y = vectorAbs(vectorSub(a[i], a[j])) + vectorAbs(vectorSub(g, a[j]));
				if (x + y < ans) ans = x + y;
			}
		}
	}
	return ans;
}

int main()
{
	int i, j, n[2];
	PP s[2], g[2];
	double ans, x;

	n[0] = in()-2, n[1] = in()-2;
	for (i = 0; i < 2; i++) {
		s[i].x = in(), s[i].y = in();
		g[i].x = in(), g[i].y = in();
		for (j = 0; j < n[i]; j++) p[i][j].x = in(), p[i][j].y = in();
	}

	ans = INF+100;
	for (i = 0; i < 2; i++) {
		x = vectorAbs(vectorSub(s[1-i], g[1-i])) + calc(s[i], g[i], p[i], n[i], s[1-i], g[1-i]);
		if (x < ans) ans = x;
	}

	if (ans >= INF) puts("-1");
	else printf("%.12lf\n", ans);
	return 0;
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int N;
	scanf("%d",&N);

	ll ans = 0;
	ll tmp;

	for(ll i = 1; i <= N; i++){

		scanf("%lld",&tmp);

		ans += tmp-i;
	}

	printf("%lld\n",ans);

	return 0;
}



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

ll vec[3100][3100][4]={};
ll p[3100][3100]={};

int main(){
  int r,c,k;
  cin>>r>>c>>k;
  for(int i=0;i<k;i++){
    int a,b;
    ll point;
    cin>>a>>b>>point;
    p[a][b]=point;
  }
  for(int i=1;i<=r;i++){
    for(int j=1;j<=c;j++){
      vec[i][j][0]=max(vec[i][j][0],vec[i][j-1][0]);
      vec[i][j][0]=max({vec[i][j][0],vec[i-1][j][0],vec[i-1][j][1],vec[i-1][j][2],vec[i-1][j][3]});
      vec[i][j][1]=max({vec[i][j][1],vec[i][j-1][0]+p[i][j],vec[i][j-1][1]});
      vec[i][j][1]=max({vec[i][j][1],max({vec[i-1][j][0],vec[i-1][j][1],vec[i-1][j][2],vec[i-1][j][3]})+p[i][j]});
      vec[i][j][2]=max({vec[i][j][2],vec[i][j-1][1]+p[i][j],vec[i][j-1][2]});
      //vec[i][j][2]=max({vec[i][j][2],max({vec[i][j-1][0],vec[i][j-1][1],vec[i][j-1][2],vec[i][j-1][3]})+p[i][j]});
      vec[i][j][3]=max({vec[i][j][3],vec[i][j-1][2]+p[i][j],vec[i][j-1][3]});
      //vec[i][j][3]=max({vec[i][j][1],max({vec[i][j-1][0],vec[i][j-1][1],vec[i][j-1][2],vec[i][j-1][3]})+p[i][j]});
    }
  }
  cout<<max(vec[r][c][0],max(vec[r][c][1],max(vec[r][c][2],vec[r][c][3])))<<endl;
}

Measured memory_bytes: 366688
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			double t = sc.nextDouble();
			double a = sc.nextDouble();
			double h[] = new double[n];
			double p[] = new double[n];
			double tmp = 1000000;
			int ans = 0;
			for (int i = 0; i < n; i++) {
				h[i] = sc.nextDouble();
				p[i] = Math.abs(t - h[i] * 0.006 - a);
				if (tmp > p[i]) {
					tmp = p[i];
					ans = i + 1;
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 27224
array = gets.split(" ")
array.map!{|i|i.to_i}
 sa = ( array[0].abs - array[1].abs ).abs
if array[0] * array[1] == 0 && array[0] <= array[1]
  puts sa
elsif array[0] * array[1] == 0 && array[0] > array[1]
  puts sa + 1
else
  if array[0] * array[1] > 0 && array[0] < array[1]
    puts sa
  elsif array[0] * array[1] > 0 && array[0] >= array[1]
    puts sa + 2
  else
    puts sa + 1
  end
end

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

int main(){
    string s;
    cin >> s;
    ll k,ans=0;
    cin >> k;
    
    ll nagasa=s.length();
    
    
    if(k==1){
        ll x=s[0]-'0';
        ans+=x;
        ans+=(nagasa-1)*9;
    }
    
    if(k==2){
        ll now=nagasa;
        for(ll i=1;i<nagasa;i++){
            if(s[i]!='0'){
                now=i;
                break;
            } 
        }
        for(ll i=now;i<nagasa;i++){
            if(i==now) ans+=s[i]-'0';
            else ans+=9;
        }
        ll x=s[0]-'0';
        ans+=(x-1)*(nagasa-1)*9;
        ans+=(nagasa-1)*(nagasa-2)*81/2;
    }
    
    if(k==3){
        ll now=nagasa;
        ll now2=-1;
        for(ll i=1;i<nagasa;i++){
            if(s[i]!='0'){
                now=i;
                break;
            }
        }
        for(ll i=now+1;i<nagasa;i++){
            if(s[i]!='0'){
                now2=i;
                break;
            }
        }
        if(now2!=-1){
        for(ll i=now2;i<nagasa;i++){
            if(i==now2) ans+=s[i]-'0';
            else ans+=9;
        }
        }
        //cout << ans << endl;
        ans+=81*(nagasa-now)*(nagasa-now-1)/2;
        //cout << ans << endl;
        ll y=s[now]-'0';
        ans-=(10-y)*9*(nagasa-now-1);
        //cout << ans << endl;
        
        ll x=s[0]-'0';
        
        ans+=(x-1)*(nagasa-1)*(nagasa-2)*81/2;
        //cout << ans << endl;
        ans+=9*9*9*(nagasa-1)*(nagasa-2)*(nagasa-3)/6;
    }

    cout << ans << endl;


    return 0;
}









Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
 
using namespace std;
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	string s;
	long long N,ans, a, b, c;
 
 
	cin >>a >> b;
 
	ans = max(a-b, max(a + b, a*b));
	
 
	cout << ans  << "\n";
	//cin >> s;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;


int main(void) {
	vector<bool> prime(MAXI+1, true);
	prime[0] = false;
	prime[1] = false;
	FOR(i, 2, MAXI) {
		if (prime[i] == true) {
			for (int j = i + i; j <= MAXI; j += i) {
				prime[j] = false;
			}
		}
	}

	while (1) {
		int m, n;
		vector<bool> num(MAXI + 1, true);
		int now;

		cin >> m >> n;
		if (m == 0) {
			break;
		}

		if (m > n) {
			cout << m + n << endl;
		}
		else {
			now = 1;
			if (now <= n) {
				FOR(i, m, MAXI) {
					if (num[i] == true) {
						if (now-1  == n) {
							cout << i << endl;
							break;
						}
						now++;
						for (int j = i + i; j <= MAXI; j += i) {
							num[j] = false;
						}
					}
				}
			}

			
		}
	}

	return 0;
}


Measured memory_bytes: 4668
n=int(input())
a=[]
for i in range(1,n+1):
    for j in range(i,n+1-n%2):
        if j!=i!=n-j+1-n%2:
            a.append((i,j))
if n%2:
    a+=[(i,n)for i in range(1,n)]
print(len(a))
for t in a:
    print(*t)

Measured memory_bytes: 43120
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
#define endl '\n'


using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long int X[200001];
    long long int N,i,temp;
    for (i = 0; i < 200001;i++){
        X[i] = 0;
    }
    cin >> N;
    for (i = 1; i < N;i++){
        cin >> temp;
        X[temp]++;
    }
    for (i = 1; i < N+1;i++){
        cout << X[i] << "\n";
    }         
    return 0;
}

Measured memory_bytes: 5216