akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb push_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN (300006)
#define MAXK 26
#define MAXX 15000006
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ++ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
ll n, m;
ll dist[1006][1006];
char grid[1006][1006];
queue <pi> q;
ll dx[] = {0, 0, 1, -1};
ll dy[] = {1, -1, 0, 0};

int main()
{
	FAST
	cin>>n>>m;
	mmst(dist,-1);
	FOR(i,0,n) {
		FOR(j,0,m) {
			cin>>grid[i][j];
			if(grid[i][j] == '#') { q.ph(pi(i,j)); dist[i][j] = 0; }
		}
	}
	while(q.size()) {
		pi x = q.front();
		q.pop();
		for(ll i=0;i<4;++i) {
			ll nx = x.f + dx[i];
			ll ny = x.s + dy[i];
			if(nx < 0 || ny < 0 || nx >= n || ny >= m || dist[nx][ny] != -1) continue;
			dist[nx][ny] = dist[x.f][x.s] + 1;
			q.ph(pi(nx,ny));
		}
	}
	ll ans=0;
	FOR(i,0,n) FOR(j,0,m) ans=max(ans,dist[i][j]);
	cout << ans;
}


Measured memory_bytes: 25524
#include <iostream>

int main()
{
    int N;
    int V[100];
    int C[100];
    int toku[100];
    int profit=0;
    std::cin >> N;
    for(int i=0; i<N; i++){
        std::cin >> V[i];
    } 
    for(int i=0; i<N; i++){
        std::cin >> C[i];
    }
    for(int i=0; i<N; i++){
        toku[i] = V[i] - C[i];
        if(toku[i] >0){
            profit+=toku[i];
        }
    }
    std::cout << profit << std::endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main
{
	public static void main(String[] args) throws IOException
	{
		Scan in = new Scan();
		Print out = new Print();
		int n = in.scanInt();
		Map<Integer, Integer> map = new HashMap<>();
		for(int i=0; i<n-1; i++) {
			int x = in.scanInt();
			if(map.containsKey(x)) {
				map.put(x, map.get(x)+1);
			}
			else {
				map.put(x, 1);
			}
		}

		for(int i=1; i<=n; i++) {
			if(map.containsKey(i)) {
				out.println(map.get(i));
			}
			else {
				out.println(0);
			}
		}
		out.close();
	}
}

class Scan
{
	private byte[] buf=new byte[1024];
	private int index;
	private InputStream in;
	private int total;
	public Scan()
	{
		in=System.in;
	}
	public int scan()throws IOException
	{
		if(total<0)
			throw new InputMismatchException();
		if(index>=total)
		{
			index=0;
			total=in.read(buf);
			if(total<=0)
				return -1;
		}
		return buf[index++];
	}
	public int scanInt()throws IOException
	{
		int integer=0;
		int n=scan();
		while(isWhiteSpace(n))
			n=scan();
		int neg=1;
		if(n=='-')
		{
			neg=-1;
			n=scan();
		}
		while(!isWhiteSpace(n))
		{
			if(n>='0'&&n<='9')
			{
				integer*=10;
				integer+=n-'0';
				n=scan();
			}
			else throw new InputMismatchException();
		}
		return neg*integer;
	}
	public double scanDouble()throws IOException
	{
		double doub=0;
		int n=scan();
		while(isWhiteSpace(n))
			n=scan();
		int neg=1;
		if(n=='-')
		{
			neg=-1;
			n=scan();
		}
		while(!isWhiteSpace(n)&&n!='.')
		{
			if(n>='0'&&n<='9')
			{
				doub*=10;
				doub+=n-'0';
				n=scan();
			}
			else throw new InputMismatchException();
		}
		if(n=='.')
		{
			n=scan();
			double temp=1;
			while(!isWhiteSpace(n))
			{
				if(n>='0'&&n<='9')
				{
					temp/=10;
					doub+=(n-'0')*temp;
					n=scan();
				}
				else throw new InputMismatchException();
			}
		}
		return doub*neg;
	}
	public String scanString()throws IOException
	{
		StringBuilder sb=new StringBuilder();
		int n=scan();
		while(isWhiteSpace(n))
			n=scan();
		while(!isWhiteSpace(n))
		{
			sb.append((char)n);
			n=scan();
		}
		return sb.toString();
	}
	private boolean isWhiteSpace(int n)
	{
		if(n==' '||n=='\n'||n=='\r'||n=='\t'||n==-1)
			return true;
		return false;
	}
}

class Print
{
	private final BufferedWriter bw;
	public Print()
	{
		this.bw=new BufferedWriter(new OutputStreamWriter(System.out));
	}
	public void print(Object object)throws IOException
	{
		bw.append(""+object);
	}
	public void println(Object object)throws IOException
	{
		print(object);
		bw.append("\n");
	}
	public void println()throws IOException
	{
		bw.append("\n");
	}
	public void close()throws IOException
	{
		bw.close();
	}
}

Measured memory_bytes: 67988
<?php

fscanf(STDIN, "%d %d", $n, $y);
$found = false;
for ($i = 0; $i <= $n; $i++) {
    for ($j = 0; $j <= $n - $i; $j++) {
        if($i*1000 + $j*5000 + ($n-$i-$j)*10000==$y){
        $found = true;
        break;
        }
    }
    if($found){
        break;
    }
}
if($found){
    echo ($n-$i-$j).' '.$j.' '.$i;
}else{
    echo '-1 -1 -1';
}


Measured memory_bytes: 3700
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    long N, M;
    scan(N, M);
    auto G = new long[][](N);
    foreach (_; 0 .. M)
    {
        long a, b;
        scan(a, b);
        a--, b--;
        G[a] ~= b;
        G[b] ~= a;
    }
    bool dfs(long v, long d)
    {
        if (v == N - 1 && d == 2)
            return true;
        if (2 <= d)
            return false;
        bool ans;
        foreach (w; G[v])
            ans = ans || memoize!dfs(w, d + 1);
        return ans;
    }

    writeln(dfs(0, 0) ? "POSSIBLE" : "IMPOSSIBLE");
}


Measured memory_bytes: 25644
N = int(input())
D = [tuple(map(int, input().split())) for _ in range(N)]

answer = 'No'

count = 0
for i in range(N):
    if D[i][0] != D[i][1]:
        count = 0
    else:
        count += 1
    
    if count == 3:
        answer = 'Yes'
        break

print(answer)

        

Measured memory_bytes: 9164
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    ll X, t;
    cin >> X >> t;
    cout << max(0LL, X - t) << endl;
    return 0;
}

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

int main() {
    int X, N;
    cin >> X >> N;
    if (N == 0)
    {
        cout << X << endl;
        return 0;
    }
    
    vector<P> r;
    vector<int> p(N);
    vector<bool> q(101, true);
    for (int i = 0; i < N; i++)
    {
        cin >> p[i];
        q[p[i]] = false; 
    }
    

    for (int i = -100; i <= 101; i++)
    {
        if (i >= 0 && i <= 100)
        {
            if (!q[i])
            {
                continue;
            }    
        }
        
        int x = abs(X - i);
        r.push_back(make_pair(x, i));
    }
    sort(r.begin(), r.end());
    cout << r.front().second << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define KOZYUN(a) sort(all(a),greater<int>())
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n,m; cin >> n >> m;
    if(n == m) Yes;
    else No;

    return 0;
}

Measured memory_bytes: 256
'''input
10
1 8 10 5 8 12 34 100 11 3
'''
import time
import math
n = int(input())
a = list(map(int, input().strip().split()))
a.sort()
u = sum(a) - a[-1]
if(a[-1] < u):
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define MOD 1000000007
#define DEBUG 0
#define INF (1LL<<50)

signed main(){

	lli n;
	cin>>n;
	vector<lli> a(n);

 	lli num=-1;
 	lli index=-1;

	REP(i,0,n){
		cin>>a[i];
		if(num <= abs(a[i])){
			num = abs(a[i]);
			index = i;
		}
	}
	
	vector<pair<lli,lli>> v;
		
	REP(i,0,n){
		if(i==index)continue;

		a[i] += a[index];
		v.push_back(make_pair(index,i));
	}
	bool state = (a[index]>0) ? true:false;

	if(state){
		for(lli i=0;i<n-1;i++){
			a[i+1] += a[i];
			v.push_back(make_pair(i,i+1));
		}
	}
	else{
		for(lli i=n-1;i>0;i--){
			a[i-1] += a[i];
			v.push_back(make_pair(i,i-1));
		}
	}

	cout<<v.size()<<endl;
	REP(i,0,v.size()){
		cout<<v[i].first+1<<" "<<v[i].second+1<<endl;
	}

	if(DEBUG){
		REP(i,0,n){
			cout<<a[i]<<" ";
		}
		cout<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
D,G=gets.chomp.split(" ").map { |e| e.to_i  }

pl=Array.new(D,0)
c=Array.new(D,0)




D.times do |i|
  pl[i],c[i]=gets.chomp.split(" ").map { |e| e.to_i  }
end

def solve(binary,goal,d,pl,c)
  a=Array.new(D,0)
  leng = binary.length
  binary = binary.reverse
  count = 0

 leng.times do |i|
   if binary[i] == "1"
     count +=  pl[i]
     goal -= 100*(i+1)*pl[i] + c[i]
     a[i] = 1
   end
 end

max = -1

 d.times do |i|
   if a[i] == 0
     max = max > i ? max : i
   end
 end

if goal <= 0
  return count
elsif max == -1
  return 100000000
else
  var = (goal + 100*(max + 1) - 1) / (100*(max + 1))
  if var >= pl[max]
    return 1000000
  else
    return count += var
  end
end

end

ans = 10000000

for i in 0..(2**D-1)
  const = solve(i.to_s(2),G,D,pl,c)
  ans = const > ans ? ans : const
end

puts ans


Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std; using ll = long long;
using ull = unsigned long long; using P = pair<int, int>;
const int INF = 1e9; const int MOD = 1000000007;
const int dx[] = {-1,0,1,0}; const int dy[] = {0,-1,0,1};
//const int dx[] = {-1,-1,-1, 0, 0, 1, 1, 1}; const int dy[] = {-1, 0, 1,-1, 1,-1, 0, 1};
#define PI 3.14159265358979323846264338327950L //setprecision(15)

int main() {
	int A, B, C; cin >> A >> B >> C;
	if (A == B && B == C && A % 2 == 0) {
		cout << "-1" << endl; return 0;
	}
	ll ans = 0;
	while (1) {
		if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1) {
			cout << ans << endl; return 0;
		}
		ans++;
		int a = A, b = B, c = C;
		A = b / 2 + c / 2;
		B = a / 2 + c / 2;
		C = a / 2 + b / 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1e18;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
    //a^tを求める
    //例：d[i] = mint(k/i).pow(n);
    //mint(2).pow(n); 2^n
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint dp[3005][3005];//1 未満


int main() {
  ll n; string s;
  cin>>n>>s;
  rep(i,n+1)rep(j,n+1)dp[i][j]=0;
  rep(i,n)dp[1][i]=1;
  for(int i=1;i<=n;i++){
  //  cout<<"i"<<i<<endl;
    mint S[n+1];
    S[0]=0;
    rep(j,n+1){
      S[j+1]=S[j]+dp[i][j];
    //  cout<<dp[i][j]<<" "<<S[j+1]<<endl;
    }
    if (s[i-1]=='<'){
      rep(j,n-i+1){
        dp[i+1][j]=S[n-i+1]-S[j+1];
      //  cout<<S[n+1]<<" "<<S[j+1]<<" "<<dp[i+1][j]<<endl;
      }
    }
    else{
      rep(j,n-i+1){
        dp[i+1][j]=S[j+1];
        //cout<<dp[i+1][j+1]<<endl;
        //cout<<S[j+1]<<dp[i+1][j]<<endl;
      }

    }
  }

  cout<<dp[n][0];
}


Measured memory_bytes: 74192
/* by Natsu Kinmoe */
#include <bits/stdc++.h>
using namespace std;

#define loop(i,n) for(int i=0;i<(n);i++)
#define pool(i,n) for(int i=(n)-1;i>=0;i--)
#define cont(i,n) for(int i=1;i<=(n);i++)
#define tnoc(i,n) for(int i=(n);i>=1;i--)
#define circ(i,a,b) for(int i=(a);i<=(b);i++)
#define cric(i,a,b) for(int i=(b);i>=(a);i--)
#define sub(i,a) for(int i=a;i;i=((i-1)&(a)))
#define subs(i,a) for(int i=a;i>=0;i=(!i?-1:((i-1)&(a))))
#define subt(i,a) for(int i=((a-1)&a);i;i=((i-1)&(a)))
#define subst(i,a) for(int i=((a-1)&a);i>=0;i=(!i?-1:((i-1)&(a))))
#define range(i,a,b,c) for(int i=(a);((c)>0?i<=(b):i>=(b));i+=(c))
#define foreach(it,v) for(__typeof((v).begin()) it=(v).begin(),_e_D_=(v).end();it!=_e_D_;it++)
#define parse(i,s) for(int i=0;s[i];i++)

#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mak make_pair

#define y0 y0O0OO00OO0OO0OO0OOO00OO0OO0O0O000OO0
#define y1 y1II11II11III11I1III11II111IIII1II1I1
#define ws WSrAkIoi2333wSraKIoIWSraKiOi
#define left left_jTjTJtJtIoiiOiioIAuaU66666jtIOIau
#define hash whYusEthiSnamE_caNyoUusEothERnaMesliKeHSH

#define Mask(a) (1ll<<(a))
#define Maskx(a,x) ((a)<<(x))
#define Full(a) ((1ll<<(a))-1)
#define Bit(a,x) (((a)>>(x))&1)
#define all(a) (a).begin(),(a).end()
#define SZ(a) ((int)((a).size()))

typedef long long ll;
typedef long double lf;

const int Inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const lf inF=11451419198101145141919810.1145141919810;
const lf pi=acosl(-1);
/* Source code starts here */

ll lb[64],flb[64];
int n;
ll a[205];
char s[205];

bool add(ll lb[],ll x){
	pool(i,63){
		if(!Bit(x,i))continue;
		if(!lb[i])return (lb[i]=x),1;
		x^=lb[i];
	}
	return 0;
}

void solve(){
	memset(lb,0,sizeof(lb));
	scanf("%d",&n);
	cont(i,n)scanf("%lld",a+i);
	scanf("%s",s+1);
	tnoc(i,n){
		if(s[i]=='0')add(lb,a[i]);
		else{
			memcpy(flb,lb,sizeof(lb));
			if(add(flb,a[i]))return void(puts("1"));
		}
	}
	puts("0");
}

int main(){
	int T;
	scanf("%d",&T);
	while(T--)solve();
	return 0;
}

Measured memory_bytes: 3660
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));
  $l = array_map('intval', explode(" ", trim(fgets(STDIN))));

  sort($l);

  $ans = 0;
  for($i=0;$i<$n-2;$i++){
    for($j=$i+1;$j<$n-1;$j++){
      for($k=$j+1;$k<$n;$k++){
        if($l[$i]!=$l[$j] &&
           $l[$j]!=$l[$k] &&
           $l[$k]!=$l[$i]){
          if($l[$i]+$l[$j] > $l[$k]){
            $ans++;
          }            
        }
      }
    }
  }
  echo $ans;

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

using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<vector<int>> A(2, vector<int>(N));
    rep(i, 2) {
        rep(j, N) {
            cin >> A[i][j];
        }
    }
    ll ans = A[0][0];
    rep(j, N) ans += A[1][j];
    ll s = ans;
    rep(j, N - 1) {
        s = s + A[0][j + 1] - A[1][j];
        ans = max(ans, s);
    }
    cout << ans << "\n";
}

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

#define ll long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
int main() {
    //COMint();
    int N=in();
    int t=in();
    int A=in();
    int ans;
    double dif;dif=999;
    int H[N];
    double T[N];
    REP(i,N){
        H[i]=in();
        T[i]=t-0.006*H[i];
        //debug(T[i]);
        //debug(abs(A-T[i]));
        if(dif>abs(A-T[i])){
            ans=i+1;
            dif=abs(A-T[i]);
        }
    }
    print(ans);
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = a; i < n; ++i)
#define ford(i, a, n) for (int i = n - 1; i >= a; --i)
#define fore(i, a, n) for (int i = a; i <= n; ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> l(n), r(n);
    forn(i, 0, n) cin >> l[i] >> r[i];
    vector<vector<int>> pos(m + 2);
    forn(i, 0, n) pos[l[i]].eb(i);
    multiset<int> rgt;
    vector<int> poss(m + 2);
    forn(i, 0, m + 2) {
        for (int x : pos[i])
            rgt.insert(r[x]);
        while (rgt.size() > i) {
            auto it = rgt.begin();
            ++poss[*it];
            rgt.erase(it);
        }
    }
    int cnt = rgt.size();
    int pl = 0, ans = 0;
    ford(i, 0, m + 2) {
        int x = min(pl, poss[i]);
        //cerr << i << ' ' << x << ' ' << poss[i] - x << '\n';
        pl -= x;
        ans += poss[i] - x;
        if (i > cnt + 1) ++pl;
    }
    cout << ans << '\n';
}


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

int main(){
  int n;
  cin >> n;
  int w[n];
  rep(i,n) cin >> w[i];
  
  int diff = 100000;
  rep(t,n){
    int s1=0,s2=0;
    rep(i,n){
      if(i <= t) s1 += w[i];
      else s2 += w[i];
    }      
    if( abs(s1-s2) < diff ) diff = abs(s1-s2);
  }
  cout << diff << endl;
  return 0;
}

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

int main() {

	uint N;
	cin >> N;

	vector<int32_t> h(3);
	vector<int32_t> dp(3);
	
	for(uint32_t i=1; i<=N; i++) {
		int32_t ic = i % 3;
		int32_t i1 = (i - 1) % 3;
		int32_t i2 = (i - 2) % 3;
		
		cin >> h[ic];
		
		if(i > 2) {
			int32_t cst_1 = abs(h[ic] - h[i1]);
			int32_t cst_2 = abs(h[ic] - h[i2]);
			dp[ic] = min(cst_1 + dp[i1], cst_2 + dp[i2]);
		} else if(i > 1) {
			dp[ic] = abs(h[ic] - h[i1]) + dp[i1];
		}
		
	}

	cout << dp[N % 3];
	return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int sum(int n) {
  return n*(n+1)/2;
}

int main() {
  string s;
  cin >> s;
  int n = s.size() + 1;
  vector<int> a(n, 0);
  for (int i = 0; i < n-1; i++) {
    if (s[i] == '<') {
      a[i+1] = a[i] + 1;
    }
  }
  for (int i = n-1; i >= 0; i--) {
    if (s[i] == '>') {
      a[i] = max(a[i+1]+1, a[i]);
    }
  }
  ll ans = 0;
  rep(i, n) {
    ans += a[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2820
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }
ll mod = 1e9+7;
signed main() {
    int sx,sy,gx,gy;
    cin>>sx>>sy>>gx>>gy;
    string a,b,c,d;
    rep(i,gy-sy){a+="U";c+="D";}
    rep(i,gx-sx){b+="R";d+="L";}
    cout<<a<<b<<c<<d<<"L"<<a<<"U"<<b<<"RDR"<<c<<"D"<<d<<"L"<<"U"<<endl;
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  int ans = 0, tmp = 0;
  rep(i, 3) {
    if (s.at(i) == 'R') ++tmp;
    else tmp = 0;
    ans = max(ans, tmp);
  }

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

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

int main(void)
{
	string str;
	int n, x, sum;
	while (true)
	{
		sum = 0;
		cin >> str;
		if (str == "-") break;
		cin >> n;
		for (int i = 0; i < n; i++)
		{
			cin >> x;
			sum += x;
		}
		for (int i = 0; i < str.size(); i++)
		{
			cout << str[(i + sum) % str.size()];
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3164
import Control.Arrow
import Control.Monad
import Data.Bits
import Data.Char
import Data.List

main :: IO ()
main = do
  n <- getInt
  xs <- getInts
  let ys = zipWith (-) xs [1..]
  print . sum . map (abs . (subtract $ median ys)) $ ys

getInt :: IO Int
getInt = readLn

getInts :: IO [Int]
getInts = map read . words <$> getLine

median :: Ord a => [a] -> a -- O(n log n)
median xs = sort xs !! (length xs `div` 2)


Measured memory_bytes: 164220
#include <bits/stdc++.h>
#define pb push_back
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define db(x) (cerr << #x << ": " << (x) << '\n')
#define cps CLOCKS_PER_SEC
#define tests(t) int t; cin >> t; while(t--)
#define iceil(n, x) (((n) + (x) - 1) / (x))
#define ll long long
#define ld double
#define eb emplace_back
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define uni(v) sort(all(v)), (v).erase(unique(all(v)), (v).end())
#define fi first
#define se second
#define bitcount(x) __builtin_popcount(x)
#define PI acos(-1.0)
#define EPS 1e-9
#define mod 998244353
#define bit(x) (1 << x)
#define par pair<int,int>
#define maxn 2005

using namespace std;
///All indexing is 0-based
using namespace __gnu_pbds;
template<class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
///methods: find_by_order(k); & order_of_key(k);
///To make it an ordered_multiset, use pairs of (value, time_of_insertion)
///to distinguish values which are similar

ll N,K,dist[maxn],cant[maxn],X,Y,nod;
queue<int> Q;
vector<int> G[maxn];
void bfs(int nodo)
{
    fill(dist,dist+1+N,0);
    Q.push(nodo);
    while(!Q.empty())
    {
        nod = Q.front();
        Q.pop();
        for(auto a:G[nod]){
            if(dist[a] )
                    continue;
            dist[a] = dist[nod]+1;
            if(a>nodo)
            cant[dist[a]]++;
            Q.push(a);
        }
    }
}

int main()
{
    #ifdef acm
    freopen("a.in","r",stdin);
    #endif // acm
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> N >> X >> Y;

    if(X>Y) swap(X,Y);

    for(int i=1;i<N;i++)
        G[i].pb(i+1) , G[i+1].pb(i);
    G[X].pb(Y);
     G[Y].pb(X);

    for(int i=1;i<=N;i++)
        bfs(i);

    for(int i=1;i<N;i++)
        cout << cant[i] << "\n";





}


Measured memory_bytes: 384
import sys
# recieve |V| and |E|
V, E = map(int, input().split())
es = [[] for i in range(V)]

for i in range(E):

	# recieve edges
	a, b, c = map(int, input().split())
	a, b = a-1, b-1
	es[a].append((b,c))
	es[b].append((a,c))

# recieve frequencies
F  = list(map(int,input().split()))

T = int(input())

# recieve info
for i in range(T):

	# the number of new order
	Nnew = int(input())
	for j in range(Nnew):
		new_id, dst = map(int, input().split())

	# the number of items transfered into the car at time t.
	Nput = int(input())
	for j in range(Nput):
		put_id = int(input())

	# insert your code here to get more meaningful output
	# you have to output a command here
	print(-1,flush=True)

	vardict = input()
	if vardict == 'NG':
		sys.exit()

	# the number of orders that have been delivered at time t.
	Nachive = int(input())
	for j in range(Nachive):
		achive_id = int(input())


Measured memory_bytes: 4292
using System;
using System.Linq;
class Program
{
	static void Main(string[] args){
Console.ReadLine();
System.Collections.Generic.IEnumerable<int> x = Console.ReadLine().Split(' ').Select<string,int>(i => int.Parse(i));
Console.WriteLine(x.Sum()>x.Max()*2?"Yes":"No");
}
}

Measured memory_bytes: 11220
N = int(input())

div = []
i = 1

while i * i < N:
    if N % i == 0:
        div.append(N // i)
    i += 1

ans = 0  
for i in div:
    if N // (i - 1)== N % (i - 1):
        ans += i - 1
print(ans)

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

const int mod=1000000007;
int n,jc[1000010],inv[1000010],iv[1000010],f[1000010][3],ans,nw;

int quickmi(int a,int b)
{
	int t=1;
	for (; b; b>>=1,a=1ll*a*a%mod)
		if (b&1) t=1ll*t*a%mod;
	return t;
}

int add(int x,int y) {return (x+y>=mod?x+y-mod:x+y);}

int main()
{
	scanf("%d",&n),jc[0]=1;
	for (int i=1; i<=1000000; i++) jc[i]=1ll*jc[i-1]*i%mod;
	inv[1000000]=quickmi(jc[1000000],mod-2);
	for (int i=1000000; i; i--) inv[i-1]=1ll*inv[i]*i%mod;
	for (int i=1; i<=1000000; i++) iv[i]=1ll*inv[i]*jc[i-1]%mod;
	f[0][0]=1,f[0][1]=0,f[0][2]=0;
	for (int i=1; i<=n; i++) f[i][0]=add(f[i-1][1],f[i-1][2]),f[i][1]=add(f[i-1][0],f[i-1][2]),f[i][2]=add(f[i-1][0],f[i-1][1]);
	for (int i=1; i<=n; i++) nw=1ll*iv[i]*inv[i]%mod*inv[n-i]%mod*f[i][1]%mod,ans=add(ans,nw);
	ans=1ll*ans*iv[3]%mod*iv[n]%mod*jc[n]%mod*quickmi(quickmi(3,n-1),mod-2)%mod,printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 23680
#include<cstdio>
#include<algorithm>

using namespace std;

int main(){
	int t;	scanf("%d",&t);
	while(t--){
		int n;	scanf("%d",&n);
		int hmax[2]={},h;	scanf("%d",&h);
		for(int i=1;i<n;i++){
			int hh;	scanf("%d",&hh);
			hmax[0]=max(hmax[0],hh-h);
			hmax[1]=min(hmax[1],hh-h);
			h=hh;
		}
		printf("%d %d\n",hmax[0],-hmax[1]);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef struct { ll cos, x, y; } state;

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

int ans;
int h, w;
char mp[1005][1005];
int cos[1005][1005];
queue<state> que;

int main()
{
    for (int i = 0; i < 1005; i++) {
        for (int j = 0; j < 1005; j++) {
            cos[i][j] = -1;
        }
    }
    
    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> mp[i][j];

            if (mp[i][j] == '#') {
                cos[i][j] = 0;
                que.push((state){0, j, i});
            }
        }
    }

    while (!que.empty()) {
        state s = que.front();
        que.pop();

        for (int i = 0; i < 4; i++) {
            int y = s.y + dy[i];
            int x = s.x + dx[i];
            int c = s.cos + 1;

            if (y >= 0 && y < h &&
                x >= 0 && x < w &&
                cos[y][x] == -1) {
                
                cos[y][x] = c;
                que.push((state){c, x, y});
            }
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            ans = max(ans, cos[i][j]);
        }
    }

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

    return 0;
}


Measured memory_bytes: 29364
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstring>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()
#define pb push_back

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

// 最小公約数
long lcm(long a, long b) {
	return a / gcd(a, b) * b;
}*/

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

	ll a, b, c;
	cin >> a >> b >> c;

	ll cnt = b / a;
	
	cnt = min(cnt, c);

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
long long d[100001];
int x[100001];
int size[100001];
long long g[100001];
vector<pair<int, int> > edge;
map<long long, int>f;
bool cmp(int x, int y) {
    return d[x] > d[y];
}
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n ; i ++)
        scanf("%lld", &d[i]), x[i] = i, size[i] = 1, f[d[i]] = i;
    sort(x + 1, x + n + 1, cmp);
    bool sig = 0;
    for (int i = 1; i <= n ; i ++) {
        long long dd = d[x[i]] +size[x[i]] - n + size[x[i]];
        if (dd != d[x[i]]&&f[dd] && dd < d[x[i]]) size[f[dd]] += size[x[i]], edge.push_back(make_pair(x[i], f[dd])), g[f[dd]] += g[x[i]] + size[x[i]];
    }
    if (size[x[n]] == n && edge.size() == n - 1 &&g[x[n]] == d[x[n]]){
        for (auto u : edge) printf("%d %d\n", u.first, u.second);
    } else printf("-1");
    return 0;
}

Measured memory_bytes: 13312
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();
		int result =K;
		for (int i=0;i<N-1;i++) {
			result *=(K-1);
		}
		System.out.print(result);
	}
}

Measured memory_bytes: 35772
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
int a[100006];
int b[100006];
int ng[100006];
signed main() {
	int n; cin >> n;
	rep(i, n + 1)cin >> a[i];
	if (!n) {
		if(a[0]==1)cout << 1 << endl;
		else cout << -1 << endl;
	}
	else {
		b[0] = 1 - a[0];
		for (int i = n-1; i >= 0; i--)ng[i] = ng[i + 1] + a[i+1];

		rep(i, n) {
			b[i + 1] = 2 * b[i] - a[i + 1];
			if (b[i + 1] > ng[i + 1])b[i + 1] = ng[i + 1];
		}
		int flg = 0;
		int ans = 0;
		rep(i, n + 1)if (b[i] < 0)flg++;
		rep(i, n + 1) {
			ans += a[i]+b[i];
		}
		rep(i, n) {
			if (b[i] * 2 < b[i + 1] + a[i + 1])flg++;
			if (b[i] > b[i + 1] + a[i + 1])flg++;
		}
		if (flg)ans = -1;
		cout << ans << endl;
	}
}

Measured memory_bytes: 5968
<?php
fscanf(STDIN,'%d',$n);
$a = fgets(STDIN);
$array = explode(' ',$a);
$m = array();
$total =0;
for ($i=0;$i<$n;$i++){
	//総降雨量
	$total+=$array[$i];
}

for ($i=1;$i<$n;$i+=2){
	//2とびの合計
	$twoSum+=$array[$i];
}
//1個目の山の降雨量
$m[0]=$total-2*$twoSum;
//1個目以降の山の降雨量
for ($i=0;$i<$n-1;$i++){
	//漸化式
	$m[$i+1]=2*$array[$i]-$m[$i];
}

for ($i=0;$i<$n;$i++){
	//答え出力
	echo (" ".$m[$i]);
}

Measured memory_bytes: 38004
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC113A
{
    class Program
    {
        static void Main(string[] args)
        {
            var XY = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var charge = XY[0] + XY[1] / 2;

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


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

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

int main(){
  int s,w;
  cin >> s >> w;

  if(s<=w){
    cout << "unsafe" << endl;
  }else{
    cout << "safe" << endl;
  } 
  return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(void) {
        int n;
        scanf("%d", &n);

        if (n > 81) {
                printf("No\n");
                return 0;
        }

        int i, j;
        int is81 = 0;
        for (i = 1; i < 10; i++) {
                for (j = 1; j <= i; j++) {
                        if (i * j == n) {
                                is81 = 1;
                                break;
                        }
                }
        }

        if (is81) {
                printf("Yes\n");
        } else {
                printf("No\n");
        }
        return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N;
	cin >> N;
	
	vector<string> S(N), rS(N);
	vector<int> C(N);
	
	vector<string> cs;
	cs.emplace_back("");
	REP(i, N) {
		cin >> S[i] >> C[i];
		rS[i] = S[i];
		reverse(ALL(rS[i]));
		REP(j, S[i].size()) FOR(k, j, S[i].size()) {
			string cur = S[i].substr(j, k - j + 1);
			cs.emplace_back(cur);
			reverse(ALL(cur));
			cs.emplace_back(cur);
		}
	}
	
	sort(ALL(cs));
	cs.erase(unique(ALL(cs)), cs.end());
	
	// cs.size() < 2 * 10^4
	
	// [j][k] := 残っている先頭文字列が cx[j] のときの min cost
	// k = 1: なら reverse した状態
	vector<vector<ll>> dp(cs.size(), vector<ll>(2, longINF));
	
	struct Data {
		int i;
		bool rev;
		ll cost;
		
		bool operator >(const Data &rhs) const {
			return cost > rhs.cost;
		}
	};
	
	priority_queue<Data, vector<Data>, greater<Data>> pq;
	REP(i, N) {
		int idx = lower_bound(ALL(cs), S[i]) - cs.begin();
		if (chmin(dp[idx][0], C[i])) pq.emplace(Data{idx, false, C[i]});
	}
	
	while (!pq.empty()) {
		Data cd = pq.top(); pq.pop();
		if (dp[cd.i][cd.rev] < cd.cost) continue;
		
		REP(i, N) {
			string &cur = !cd.rev ? rS[i] : S[i];
			int lcp = 0;
			while (lcp < cs[cd.i].size() && lcp < cur.size() && cs[cd.i][lcp] == cur[lcp]) ++lcp;
			if (lcp < cs[cd.i].size() && lcp < cur.size()) continue;
			string res = lcp == cs[cd.i].size() ? cur.substr(lcp) : cs[cd.i].substr(lcp);
			int nex_idx = lower_bound(ALL(cs), res) - cs.begin();
			int nex_rev = cd.rev ^ (lcp == cs[cd.i].size());
			ll nex_cost = cd.cost + C[i];
			if (chmin(dp[nex_idx][nex_rev], nex_cost)) {
				pq.emplace(Data{nex_idx, nex_rev, nex_cost});
			}
		}
	}

	ll ans = longINF;
	REP(i, cs.size()) {
		bool pali = true;
		REP(j, cs[i].size() / 2) pali &= cs[i][j] == cs[i][cs[i].size() - 1 - j];
		if (pali) REP(j, 2) chmin(ans, dp[i][j]);
	}
	if (ans == longINF) puts("-1");
	else cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4588
#include <stdio.h>
#include <stdlib.h>
#define ll long long int
int compare_long(const void *a, const void *b) {long *A = (long *)a;long *B = (long *)b;if (*A > *B) return 1;if (*A < *B) return -1;return 0;}
ll sum(ll n){
	if(n<0)return 0;
	ll i,s=0;
	for(i=1;i<=n;i++){s+=i;}
	return s;
}
int main(void){
	ll n,a,i;
	scanf("%lld",&n);
	ll s[n+1];
	s[0] = 0;
	for(i=0;i<n;i++){
		scanf("%lld",&a);
		s[i+1] = s[i] + a;
	}
	qsort(s, n+1, sizeof(ll), compare_long);
	ll ans=0,b=s[0],count=0;
	for(i=1;i<n;i++){
		if(b == s[i]) count++;
		else{
			ans += sum(count);
			count = 0;
			b = s[i];
		}
	}
	if(b==s[n]) ans += sum(++count);
	
	
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 3324
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    REP(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    REP(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

int main()
{
	int N = inputValue();
	
	int val1;
	if(N < 10){
	    val1 = N;
	}else if(10 <= N && N < 100){
		val1 = 9;
	}else if(100 <= N && N < 1000){
		val1 = N - 90;
	}else if(1000 <= N && N < 10000){
		val1 = 909;
	}else if(10000 <= N && N < 100000){
		val1 = N - 9090;
	}else{
		val1 = 90909;
	}
	
	cout << val1 << endl;
}


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

char s[30][11];
int main() {
	int n;
	while (scanf("%d", &n), n) {
		int m, h, d; scanf("%d%d%d", &m, &h, &d);
		m--; h--;
		rep(i, d)scanf("%s", s[i]);
		{
			vector<P>v;
			rep(k, d)rep(t, n - 1) {
				if (s[k][t] == '1')v.push_back(P(t, t + 1));
			}
			int pos = m;
			for (P p : v) {
				if (p.first == pos)pos = p.second;
				else if (p.second == pos)pos = p.first;
			}
			if (pos == h) {
				puts("0");
				goto g;
			}
		}
		rep(i, d)rep(j, n - 1) {
			if (s[i][j] == '1' || (j&&s[i][j - 1] == '1') || (j + 1 < n - 1 && s[i][j + 1] == '1'))continue;
			vector<P>v;
			s[i][j] = '1';
			rep(k, d)rep(t, n - 1) {
				if (s[k][t] == '1')v.push_back(P(t, t + 1));
			}
			int pos = m;
			for (P p : v) {
				if (p.first == pos)pos = p.second;
				else if (p.second == pos)pos = p.first;
			}
			if (pos == h) {
				printf("%d %d\n", i + 1, j + 1);
				goto g;
			}
			s[i][j] = '0';
		}
		puts("1");
	g:;
	}
}

Measured memory_bytes: 3148
/* 
 Author:N_o_o_B 
 Created:November 03 2019 13:10:44
*/
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;
const int maxn=5e5+6;
vi adj[maxn];
vi dp(maxn,-1);
int ans=0;
void dfs(int u){
    dp[u]=0;
    for(int v:adj[u]){
        if(dp[v]==-1) {
            dfs(v);
        }
        dp[u]=max(dp[v]+1,dp[u]);
    }
    ans=max(ans,dp[u]);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    string s;
    cin >> s;
    int n=sz(s)+1;
    fori(i,n-1){
        if(s[i]=='>') adj[i].pb(i+1);
        else adj[i+1].pb(i);
    }
    for(int i=0;i<n;i++){
        if(dp[i]==-1) dfs(i);
    }
    ll res=0;
    for(int i=0;i<n;i++){
        res+=dp[i];
       // cout << ans - dp[i] << " "; 
    }
   // cout << endl;
    cout << res << endl;
    time_taken();
    return 0;
}

Measured memory_bytes: 53532
#include <iostream>

using namespace std;

int calc_simple_interest ( int money, int year, double rate, int fee )
{
	int sum = 0;
	for ( int i = 0; i < year; ++i ) {
		sum += money * rate;
		money -= fee;
	}
	return money + sum;
}

int calc_compound_interest ( int money, int year, double rate, int fee )
{
	for ( int i = 0; i < year; ++i ) {
		money += money * rate;
		money -= fee;
	}
	return money;
}

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

	while ( data_num-- ) {
		int money, year, n;
		cin >> money
			>> year
			>> n;

		int max_money = 0;
		for ( int i = 0; i < n; ++i ) {
			int type, fee, temp;
			double rate;

			cin >> type >> rate >> fee;

			if ( type == 0 ) {
				temp = calc_simple_interest( money, year, rate, fee );
			}
			else {
				temp = calc_compound_interest( money, year, rate, fee );
			}
			max_money = max( max_money, temp );
		}

		cout << max_money << endl;
	}
	return 0;
}

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

int main(){
  int N, M, K, A;
  cin >> N >> M;
  vector<bool> resi(M,false); //i番目の人が好きな場合はTrue
  vector<bool> res(M,true); //一人でも好きじゃない場合にFalseになる
  for (int i=0;i<N;i++){
    cin >> K;
    for (int j=0;j<M;j++){
      resi[j] = false;
    }
    for (int j=0;j<K;j++){
      cin >> A;
      resi[A-1] = true;
    }
    for (int j=0;j<M;j++){
      if (resi[j]==false){
        res[j] = false;
      }
    }
  }

  int count = 0;
  for (int i=0;i<M;i++){
    if (res[i] == true) count++;
  }
  cout << count << endl;  
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

#include<vector>
using namespace std;

vector<bool> Mon_Sat_sieve(int x){//range...[0,x]
    vector<bool> flags(x+1,true);
    for(int i=1;7*i+1<=x;i++){
        int sat = 7*i-1,mon=7*i+1;
        if(flags[sat])for(int mult = 2*sat;mult<=x;mult+=sat)flags[mult]=false;
        if(flags[mon])for(int mult = 2*mon;mult<=x;mult+=mon)flags[mult]=false;
    }
    return flags;
}

int main(){
    int N;
    vector<int> Mon_Sat_PrimeFactors;
    vector<bool> tmp = Mon_Sat_sieve(300100);
    for(int i=1;7*i+1<300100;i++){
        if(tmp[7*i-1])Mon_Sat_PrimeFactors.push_back(7*i-1);
        if(tmp[7*i+1])Mon_Sat_PrimeFactors.push_back(7*i+1);
    }
    /*rep(i,Mon_Sat_PrimeFactors.size()){
        cout << Mon_Sat_PrimeFactors[i] << endl;
    }*/
    while(cin >> N,N!=1){
         vector<int> MS_Primes;
         rep(i,Mon_Sat_PrimeFactors.size()){
             if(N%Mon_Sat_PrimeFactors[i]==0)MS_Primes.push_back(Mon_Sat_PrimeFactors[i]);
         }
         cout << N << ": ";
         rep(i,MS_Primes.size()-1)cout << MS_Primes[i] << " ";
         cout << MS_Primes[MS_Primes.size()-1];
         cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3208
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    A = input()
    B = input()
    if A[0] == B[2] and A[1] == B[1] and A[2] == B[0]:
        print(YES)
    else:
        print(NO)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3956
// Created by  Ambesh kumar
#include "bits/stdc++.h"

//I already compile this file in my computer system to save the time
//if get the compiler error then you should change this header to
// #include "bits/stdc++.h"  ---> #include <bits/stdc++.h>

using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0, lim - 1);
	return uid(rang);
}
int mpow(int base, int exp);
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1000000007;
const int N = 3e5, M = N;
//=================================================================================================================================//

vi g[N];
int a[N];






void solve() {
	int i = 0, j, n, m, k;

	cin >> n >> k ;

	ll arr[n];

	fo(i, n)
	cin >> arr[i];

	ll t[n];

	t[0] = 0;
	t[1] = abs(arr[0] - arr[1]);

	//deb(t[1]);
	ll min1;
	Fo(i, 2, n )
	{
		//deb(i);
		min1 = INT_MAX;
		for (j = i - 1; j >= i - k &&  j >= 0; j--)
		{
			//deb2(t[j], arr[i]);

			//deb(j);

			min1 = min(t[j] + abs(arr[i] - arr[j]), min1);
			//deb2(min1, arr[j]);

		}

		t[i] = min1;


		//deb2(t[i], min1);

	}



	cout << t[n - 1] << '\n' ;

}







int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());

	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}

	return 0;
}







Measured memory_bytes: 12212