akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case)]
use proconio::input;
// use std::collections::HashMap;

fn main() {
    input! {
        X: usize,
        Y: usize,
        A: usize,
        B: usize,
        C: usize,
        mut Ps: [i64; A],
        mut Qs: [i64; B],
        mut Rs: [i64; C],
    }

    Ps.sort_by(|a, b| b.cmp(a));
    Qs.sort_by(|a, b| b.cmp(a));
    Rs.sort_by(|a, b| b.cmp(a));

    // 問題文の条件より、無色のリンゴを使わずに条件を達成できる。
    // それから、ポイントが高くなるように無色のリンゴに入れ換えていけばよい

    let mut deliciousness = 0;
    for a in 0..X {
        deliciousness += Ps[a];
    }

    for b in 0..Y {
        deliciousness += Qs[b];
    }

    let mut a: isize = X as isize - 1;
    let mut b: isize = Y as isize - 1;

    // colorless index
    for c in 0..C {
        if a >= 0 && b >= 0 {
            // PsとQsの小さいほうが対象
            if Ps[a as usize] <= Qs[b as usize] {
                if Rs[c] > Ps[a as usize] {
                    deliciousness -= Ps[a as usize];
                    deliciousness += Rs[c];

                    a -= 1;
                }
            } else {
                if Rs[c] > Qs[b as usize] {
                    deliciousness -= Qs[b as usize];
                    deliciousness += Rs[c];

                    b -= 1;
                }
            }
        } else if a >= 0 {
            // Psが対象
            if Rs[c] > Ps[a as usize] {
                deliciousness -= Ps[a as usize];
                deliciousness += Rs[c];

                a -= 1;
            }
        } else if b >= 0 {
            // Qsが対象
            if Rs[c] > Qs[b as usize] {
                deliciousness -= Qs[b as usize];
                deliciousness += Rs[c];

                b -= 1;
            }
        }
    }

    let ans = deliciousness;
    println!("{}", ans);
}


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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

//--------------------------------------------

int main(){
  string o,e;

  cin >> o >> e;

  REP (i, o.size()) {
    if (i == o.size() - 1) {
      if (o.size() == e.size()) cout << o.at(i) << e.at(i);
      else cout << o.at(i);
    } else cout << o.at(i) << e.at(i);
  }
  cout << "\n";

}


Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>

using namespace std;

int main() {
  int n, A, B, C;
  cin >> n >> A >> B >> C;
  vector<int> l(n);
  for (int i = 0; i < n; i++) {
    cin >> l[i];
  }

  std::function<int(int, int, int, int)> dfs = [&](int cur, int a, int b,
                                                   int c) -> int {
    if (cur == n) {
      if (min({a, b, c}) == 0) {
        return 1e9;
      }
      return abs(a - A) + abs(b - B) + abs(c - C) - 30;
    }
    int ret1 = dfs(cur + 1, a, b, c);
    int ret2 = dfs(cur + 1, a + l[cur], b, c) + 10;
    int ret3 = dfs(cur + 1, a, b + l[cur], c) + 10;
    int ret4 = dfs(cur + 1, a, b, c + l[cur]) + 10;
    return min({ret1, ret2, ret3, ret4});
  };
  int ans = dfs(0, 0, 0, 0);
  cout << ans << endl;

  return 0;
}


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

using namespace std;

const int inf = 0x3f3f3f3f;

long long peso[100010], valor[100010], pd[100010][110];
int n, w;

long long solve(int index, int weigth){
  if(pd[weigth][index] != -1) return pd[weigth][index];
  if(index == n) return 0;

  pd[weigth][index] = 0;

  if(weigth + peso[index] <= w)pd[weigth][index] = solve(index + 1, weigth + peso[index]) + valor[index];

  //cout<<index << " " << weigth << " = " << pd[weigth][index]<<endl;

  pd[weigth][index] = max(pd[weigth][index], solve(index+1, weigth));

  //cout<<index << " " << weigth << " = " << pd[weigth][index]<<endl;

  return pd[weigth][index];
}

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

  for(int i=0 ; i<n ; i++) cin>>peso[i]>>valor[i];

  memset(pd, -1, sizeof pd);

  cout<<solve(0, 0)<<endl;
}

Measured memory_bytes: 86272
N=int(input())
v=list(map(int,input().split()))

for i in range(N-1):
    x = min(v)
    v.remove(x)
    y = min(v)
    v.remove(y)
    z = (x+y)/2
    v.append(z)
    #print(v)

print(v[-1])


Measured memory_bytes: 62992
import sys
from math import isinf
# どれが終点の時に負の閉路があるかをnegative[v]にいれる
# dists = [float('inf')] * V # 到達不能はinf
# negatives = [False] * V

def bellman_ford(start:int)->bool:
    """ ベルマンフォード O(|V|*|E|)
    :param V:      頂点数
    :param edges:  辺 [(始点，終点，重み)]
    :param start:  始点
    """
    global dists, negatives
    global edges
    dists[start] = 0
    V = len(dists)
    for i in range(V):
        for (s, t, w) in edges:
            if isinf(dists[s]): continue
            if dists[t] > dists[s] + w:
                dists[t] = dists[s] + w
                if i==V-1:
                    negatives[t] = True


if __name__ == "__main__":
    V,E,start = map(int, input().split())
    edges = []
    for _ in range(E):
        s,t,d = map(int, input().split())
        edges.append((s,t,d))

    dists = [float('inf')] * V # 到達不能はinf
    negatives = [False] * V
    bellman_ford(start)
    if any(neg for neg in negatives)==True:
        print("NEGATIVE CYCLE")
        exit()
    for di in dists:
        if di==float('inf'):
            print("INF")
        else:
            print(di)



Measured memory_bytes: 6200
#include <bits/stdc++.h>
#define maxn 405
#define inf 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
ll dp[maxn][maxn];
ll a[maxn];
ll sum[maxn];

ll dfs(int l, int r)
{
    if(dp[l][r]!=inf) return dp[l][r];
    for(int i=l;i+1<=r;i++)
    {
        dp[l][r] = min(dp[l][r],dfs(l,i)+dfs(i+1,r)+sum[r]-sum[l-1]);
    }
    return dp[l][r];
}

int main()
{
    int n;
    cin>>n;
    memset(dp,inf,sizeof(dp));
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        sum[i] = a[i]+sum[i-1];
        dp[i][i] = 0;
    }
    cout<<dfs(1,n)<<endl;
}


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

int main(){
  int n,s=0;
  cin >> n;
  vector<int> v(n),c(n);
  for(int i=0;i<n;i++)
    cin >> v[i];
  for(int i=0;i<n;i++)
    cin >> c[i];
  for(int i=0;i<n;i++){
  	if(v[i]-c[i]>=0)
      s+=v[i]-c[i];
  }
  cout << s;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S, T; cin >> S >> T;
    rep(i, S.size()){
        if(S == T){
            cout << "Yes" << endl;
            return 0;
        }
        char c = S[S.size()-1];
        S.pop_back();
        S = c + S;
    }
    cout << "No" << endl;
    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int flood(char map[][14], int i, int j){
    if(map[i][j] == '1')
        map[i][j] = '0';
    if(map[i+1][j] == '1')
        flood(map,i+1,j);
    if(map[i][j+1] == '1')
        flood(map,i,j+1);
    if(map[i-1][j] == '1')
        flood(map,i-1,j);
    if(map[i][j-1] == '1')
        flood(map,i,j-1);
    return 1;
}

int main(){
    bool loop = true;
    char map[14][14] = {{'0'}}, s[14];
    while(loop){
        range(i,1,13){
            if(!(cin >> s)) loop = false;
            rep(j,12){
                map[i][j+1] = s[j];
            }
        }
        int ans = 0;
        range(i,1,13){
            range(j,1,13){
                if(map[i][j] == '1')
                    ans += flood(map,i,j);
            }
        }
        if(loop)
            cout << ans << endl;
    }
}

Measured memory_bytes: 1148
// #include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <array>
#include <map>

#define fo(i, n) for (i = 0; i < n; i++)
#define PI 3.1415926535897932384626

// using namespace std;
// using std::array;
using std::cin;
using std::cout;
using std::endl;
// using std::map;
// using std::multimap;
// using std::multiset;
// using std::set;
using std::string;
using std::vector;

int32_t randint(int32_t l, int32_t u)
{
    return l + (rand() % u);
}

template <typename T>
void readarray(T *arr, size_t l)
{
    int32_t i;
    fo(i, l)
    {
        std::cin >> arr[i];
    }
}
template <typename T>
vector<T> readvector(size_t l)
{
    vector<T> vec;
    size_t i;
    T a;
    for (i = 0; i < l; i++)
    {
        cin >> a;
        vec.push_back(a);
    }
    return vec;
}
template <typename T>
void readmatrix(int32_t rows, int32_t columns, std::vector<std::vector<T>> &matrix)
{
    int32_t num;
    int32_t i, j;
    int32_t arr[columns];
    fo(i, rows)
    {
        matrix[i] = std::vector<int32_t>(columns);
        fo(j, columns)
        {
            cin >> num;
            matrix[i][j] = num;
        }
    }
}

template <typename T>
void printarray(T *arr, size_t l, std::string sep = " ")
{
    size_t i;
    fo(i, l)
    {
        if (i == l - 1)
        {
            std::cout << arr[i];
        }
        else
        {
            std::cout << arr[i] << sep;
        }
    }
    std::cout << std::endl;
}

template <typename T>
void printvector(std::vector<T> vec, std::string sep = " ")
{
    size_t i;
    for (i = 0; i < vec.size(); i++)
    {
        if (i == vec.size() - 1)
        {
            std::cout << vec[i];
        }
        else
        {
            std::cout << vec[i] << sep;
        }
    }
    std::cout << std::endl;
}
template <typename T>
void display(T x)
{
    cout << x << endl;
}
template <typename T, typename U>
void display(T x, U y)
{
    cout << x << " " << y << endl;
}
int64_t solve(int32_t n, vector<int32_t> nums)
{
    int64_t total = 0;
    int32_t currentmax = -1;
    for (auto num : nums)
    {
        if (num > currentmax)
        {
            currentmax = num;
        }
        if (num < currentmax)
        {
            total += currentmax - num;
        }
    }
    return total;
}

int main()
{
    int32_t n_test_cases = 1;
    // cin >> n_test_cases;
    while (n_test_cases--)
    {
        int32_t i, j, k, a, b, c, l, m, n, x, t;
        cin >> n;
        vector<int32_t> nums = readvector<int32_t>(n);
        display(solve(n, nums));
    }
    return 0;
}

Measured memory_bytes: 4628
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <limits.h>
#include <assert.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <bitset>
#include <vector>
using namespace std;

#define LL long long

#define fi first
#define se second
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(a,b) (((a)+(b))>>1)
#define maxx(a,b) ((a)<(b)?(b):(a))
#define minx(a,b) ((a)<(b)?(a):(b))
#define absx(a) ((a)<0?-(a):(a))
#define mk(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define itr iterator
#define lowbit(x) ((x)&-(x))

typedef unsigned LL ULL;
typedef unsigned uint;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;

template< typename T > inline void read(T &x) {
    bool f; char ch; f=0; x=0; ch=getchar();
    while(ch<'0' || ch>'9') {if(ch=='-') f=1; ch=getchar();}
    while(ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}
    if(f) x=-x;
}

template< typename T > inline void Max(T &a, T b) {if(a<b) a=b;}
template< typename T > inline void Min(T &a, T b) {if(b<a) a=b;}
template< typename T > inline T Abs(T a) {if(a<0) return -a; else return a;}

const double pi=(double) acos(-1.0);
const int MOD=(int) 1e9+7;
const int INF=(int) 0x3f3f3f3f;
const LL  LINF=(LL) INF<<32|INF;
const int SINF=(uint) ~0>>1;
const LL  SLINF=(ULL) (-1)>>1;
const double DINF=(double) 1e50;
const double eps=(double) 1e-8;
const int maxn=(int) 2000+20;
const int maxm=(int) 1e6+20;
const int maxk=(int) 5e2+20;

inline int sig(double x) {return x<-eps?-1:x>eps;}

//--------------start------------------

void work()
{
    int R,G;
    cin >>R >>G;
    cout <<G-R+G <<endl;
}

//--------------end--------------------

int main()
{
#ifdef yukihana0416
freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
#endif // yukihana0416
    work();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define MAXR 100000
#define _GLIBCXX_DEBUG
 
int threemax(int a, int b, int c) {
	if (a >= b && a >= c) {
		return a;
	}
	else if (b >= a && b >= c) {
		return b;
	}
	else {
		return c;
	}
}
 
int threemin(int a, int b, int c) {
	if (a <= b && a <= c) {
		return a;
	}
	else if (b <= a && b <= c) {
		return b;
	}
	else {
		return c;
	}
}
 
void chmaxl(ll &a,ll b){
	if(a<b){
		a=b;
	}
	return;
}
 
void chminl(ll &a,ll b){
	if(a>b){
		a=b;
	}
	return;
}
 
void chmaxi(int &a,int b){
	if(a<b){
		a=b;
	}
	return;
}
 
void chmini(int &a,int b){
	if(a>b){
		a = b;
	}
	return;
}
 
 
 
int main() {
  int N,T;
  cin >> N >> T;
  int ans=10000;
  vector<int> cvec(N);
  vector<int> tvec(N);
  for(int i=0;i<N;i++){
    cin >> cvec.at(i) >> tvec.at(i);
    if(tvec.at(i)<=T&&cvec.at(i)<ans){
      ans=cvec.at(i);
    }
  }
  if(ans==10000){
    cout << "TLE";
  }
  else{
    cout << ans;
  }
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

cnt = 0
for n in range(N):
    if A[n] <= B[n]:
        cnt += A[n]
        B[n] -= A[n]
        if A[n+1] < B[n]:
            cnt += A[n+1]
            A[n+1] = 0
        else:
            cnt += B[n]
            A[n+1] -= B[n]
    else:
        cnt += B[n]
        
print(cnt)

Measured memory_bytes: 24104
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        long d = scan.nextInt();
        int out = 0;
        for(int i = 0; i < n; i++){
            long x = scan.nextLong();
            long y = scan.nextLong();
            if(x * x + y * y <= d * d) out++;
        }
        System.out.println(out);
    }

    public static void main(String[] args){
        new Main().solve();
    }
}


Measured memory_bytes: 59672
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

int main(){
	int k, ret;
	scanf("%d\n", &k);
	if(k%2){
		ret = ((k+1) / 2) * (k / 2);
	} else {
		ret = (k / 2) * (k / 2);
	}
	printf("%d\n", ret);
	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n;
int a[200000];

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n;
    forn(i, n) {
        cin >> a[i];
    }
    for (int x = 1; x <= 1000000000; x *= 2) {
        int sum = 0;
        forn(i, n) {
            sum ^= a[i] & x;
        }
        forn(i, n) {
            a[i] ^= sum;
        }
    }
    forn(i, n) {
        cout << a[i] << ' ';
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 4440
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  
  int a,b;cin>>a>>b;
  cout << max(0,a-b*2) << endl;
  

}


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

#define INF 1000000000000

int main(){
  int n,a,b;
  cin>>n>>a>>b;
  if(n==1){cout<<"Hello World"<<endl;}
  else cout<<a+b<<endl;


}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;


/* range: ± 3.27 * 10^4 */
using i16 = short int;
/* range: 0 to 65535 */
using u16 = short unsigned int;
/* range: ± 2.14 * 10^9 */
using i32 = int;
/* range: 0 to 4.29 * 10^9 */
using u32 = unsigned int;
/* range: ± 9.22 * 10^18 */
using i64 = long long int;
/* range: 0 to 1.84 * 10^19 */
using u64 = long long unsigned int;

vector<vector<u64>> memo;

u64 dp(const vector<array<u32, 3>>& day_happiness, u16 prev_task, u32 days,
       u32 curr_day) {
    if (curr_day == days) {
        return 0;
    }

    if (prev_task < 3 && memo[curr_day][prev_task] > 0) {
        return memo[curr_day][prev_task];
    }

    u64 res = 0;
    for (u16 task = 0; task < 3; task++) {
        if (task == prev_task) {
            continue;
        }
        res = max(res, day_happiness[curr_day][task] +
                           dp(day_happiness, task, days, curr_day + 1));
    }

    if (prev_task < 3) {
        memo[curr_day][prev_task] = res;
    }
    return res;
}

i32 main() {
    u32 num_vacations = 0;
    cin >> num_vacations;

    vector<array<u32, 3>> day_happiness(num_vacations);
    for (u32 day = 0; day < num_vacations; day++) {
        for (u16 task = 0; task < 3; task++) {
            cin >> day_happiness[day][task];
        }
    }

    memo = vector<vector<u64>>(num_vacations, vector<u64>(3, 0));
    cout << dp(day_happiness, 3, num_vacations, 0) << '\n';
}

Measured memory_bytes: 17264
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define INF 10000000001
#define DIM 200001
#define mod 1000000007
#define PI 3.1415926535897932384626433
#define se second
#define fi first
#define pb push_back
#define T true
#define F false
#define endl "\n"
typedef char ch;
typedef bool boll;
typedef string st;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef set < string > sst;
typedef set < long long > sl;
typedef queue < long long > que;
typedef vector < long long > vec;
typedef map < long long, long long > mll;
typedef pair < long long, long long > pll;
typedef vector < pair < long long, long long > > vpl;
typedef pair < long long, unsigned long long > pul;


int main(){
    int n;
    cin >> n;
    int arr[n-1],ans[n]={ 0 };
    for(int i=0;i<n-1;i++){
        cin >> arr[i];
        ans[arr[i]-1] += 1;
    }
    
    
    for(int i=0;i<n;i++) cout << ans[i] << endl;
    
}



Measured memory_bytes: 5192
import java.util.*;


public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		double num = 0;
		double c =  Math.pow(b-1,a-1);
		num = b * c;
		// 出力
		int k = (int)num;
		System.out.println(k);
    }
}


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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



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

	int res = 0;
	REP(i, N) {
		res += L + i;
	}

	int l = L, r = L + N - 1;
	if (r < 0) {
		res -= L + N - 1;
	}
	else if (0 < l) {
		res -= L;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
num = int(input())
arr = []
for i in range(0, num):
  enter = input().split()
  arr.append(tuple((enter[0], int(enter[1]), i+1)))
             
sorted_by_score = sorted(arr, key = lambda x: x[1], reverse=True)
sorted_by_name = sorted(sorted_by_score, key = lambda x: x[0])
for i in sorted_by_name:
  print(i[2])

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

int main() {
    int n, min, sub;
    cin >> n;
    ll ans = 0;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    min = a[0];
    for (int i = 1; i < n; ++i) {
        if (min > a[i]) {
            sub = min - a[i];
            ans += sub;
            a[i] += sub;
        } else {
            min = a[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3988
fn get_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().to_string()
}

fn reads<T>() -> Vec<T>
    where
        T: std::str::FromStr,
        <T as std::str::FromStr>::Err: std::fmt::Debug {
    get_line().split(' ').map(|x| x.parse().unwrap()).collect()
}

fn readln<T>() -> T
    where
        T: std::str::FromStr,
        <T as std::str::FromStr>::Err: std::fmt::Debug {
    get_line().parse().unwrap()
}

use std::cmp;

fn main() {
    let n = readln();

    let mut xs = vec![];
    for _ in 0..2 {
        let x = reads();
        xs.push(x);
    }

    let mut ts = vec![vec![0; n]; 2];
    ts[0][0] = xs[0][0];
    
    for j in 1..n {
        ts[0][j] = xs[0][j] + ts[0][j - 1];
    }
    ts[1][0] = xs[1][0] + ts[0][0];
    for j in 1..n {
        ts[1][j] = xs[1][j] + cmp::max(ts[0][j], ts[1][j - 1]);
    }

    println!("{}", ts[1][n - 1]);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
#define inf  100000000000000000
# define M_PI           3.14159265358979323846  /* pi */
vector<pair<vector<int>,vector<int>>> gr;
int n,m;
vector<int> mrk,ord;
vector<int> dist;
vector<int> cnt;
int main(){
    cin>>n>>m;
    cnt=vector<int> (n,0);
    gr=vector<pair<vector<int>,vector<int>>> (n,{vector<int>(0,0),vector<int>(0,0)});
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        gr[x-1].first.push_back(y-1);
        gr[y-1].second.push_back(x-1);
        cnt[y-1]++;
    }
    queue<int> AJ;
    mrk=vector<int> (n,0);
    dist=vector<int> (n,0);
    for(int i=0;i<n;i++){
        if(gr[i].second.size()==0)
            AJ.push(i);
    }
    //cout<<AJ.size()<<" "<<AJ.front()<<endl;

    while(AJ.size()){

        int v=AJ.front();
        AJ.pop();
        mrk[v]=1;
        //cout<<v<<endl;
        ord.push_back(v);
        for(int i=0;i<gr[v].first.size();i++){
                cnt[gr[v].first[i]]--;
            if(!mrk[gr[v].first[i]] && cnt[gr[v].first[i]]==0)AJ.push(gr[v].first[i]);}
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<gr[ord[i]].second.size();j++)
            dist[ord[i]]=max(dist[ord[i]],dist[gr[ord[i]].second[j]]);
        if(gr[ord[i]].second.size())dist[ord[i]]++;

    }
//    for(int i=0;i<n;i++)
//        cout<<dist[i]<<" ";
//    cout<<endl;
    cout<<dist[ord[n-1]];
    return 0;
}


Measured memory_bytes: 13056
package main

import "fmt"

func main() {
	var N, L int
	fmt.Scanf("%d %d", &N, &L)
	total := 0
	for i := 1; i <= N; i++ {
		total += L + i - 1
	}
	min := 10000000000000
	minTaste := 0
	for i := 1; i <= N; i++ {
		taste := total - (L + i - 1)
		diff := total - taste
		if diff < 0 {
			diff = -diff
		}
		if diff < min {
			min = diff
			minTaste = taste
		}
	}
	fmt.Println(minTaste)
}


Measured memory_bytes: 512
L = int(input())

b = []
while L > 0:
    b.append(L % 2)
    L = int(L / 2)

p = []

cost = 1
for i in range(len(b), 1, -1):
    p.append((i - 1, i, 0))
    p.append((i - 1, i, cost))
    cost *= 2

cost2 = cost
for i in range(2, len(b) + 1):
    cost2 = int(cost2 / 2)
    if b[-i] % 2 == 1:
        p.append((1, i, cost))
        cost += cost2

print(len(b), len(p))
for tp in p:
    print(tp[0], tp[1], tp[2])

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;


signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll a, b; cin >> a >> b;
	if (b < a) {
		cout << "No\n";
	}
	else {
		cout << "Yes\n";
	}
	return 0;	
}

/*
3
0 1
3 0
1 0
*/

Measured memory_bytes: 256
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include <cstdlib>
#include <typeinfo>
#include <math.h>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << n); bit++)
using namespace std;

template<class T>
void print(const T &value) {
    std::cout << value << std::endl;
}

void yesno(bool a) { if (a)cout << "yes" << endl; else cout << "no" << endl; }

void YesNo(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

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

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

ll INF = 10000000;
ll mod = 1000000007;//10^9+7
int dx[8] = {-1, 0, 0, 1, -1, -1, 1, 1};
int dy[8] = {0, -1, 1, 0, -1, 1, -1, 1};
using Graph = vector<vector<int>>;//隣接リスト:G[i]にはiと隣接する頂点が入るよ。
using P = pair<int, int>;//BFSで利用。queueに入れる。
using lP = pair<ll, ll>;
using PP = pair<int, P>; //dijkstraで利用,priority_queueに入れる。
using p_queue = priority_queue<int, vector<int>, greater<int>>;//小さい順
//struct edge{int to, cost};



//番号ズレ注意！！
int main() {
    int N;
    cin >> N;
    int a[3 * N];
    REP(i, 3 * N) {
        cin >> a[i];
    }
    p_queue former;
    ll sum_f[2 * N + 1];
    sum_f[N - 1] = 0;//sum_f[j]:=「0<=i<=jを前半に取った時の，前半N要素の総和の最大値」(N-1<=j<=2N-1)
    REP(i, N) {
        former.push(a[i]);
        sum_f[N - 1] += a[i];
    }
    for (int j = N; j < 2 * N; j++) {
        former.push(a[j]);
        int m = former.top();
        former.pop();
        sum_f[j] = sum_f[j - 1] + a[j] - m;
    }


    priority_queue<int> latter;
    ll sum_l[2 * N + 1];
    sum_l[2 * N - 1] = 0;//sum_l[j]:=「j+1<=i<=3N-1を後半に取った時の，後半N要素の総和の最小値」(N-1<=j<=2N-1)
    for (int i = 2 * N; i < 3 * N; i++) {
        latter.push(a[i]);
        sum_l[2 * N - 1] += a[i];
    }
    for (int j = 2 * N - 1; j >= N; j--) {
        latter.push(a[j]);
        int M = latter.top();
        latter.pop();
        sum_l[j - 1] = sum_l[j] + a[j] - M;
    }
    ll ans = -sum_l[2 * N - 1];
    for (int j = N - 1; j < 2 * N; j++) {
        ll score = sum_f[j] - sum_l[j];
        ans = max(ans, score);
//        cout << "j:" << j << " sum_f:" << sum_f[j] << " sum_l:" << sum_l[j] << endl;
    }
    print(ans);
}

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

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    bool outputFlag = true;
    if(n == 2){
        if(h[0]-2 >= h[1]){
            cout << "No" << endl;
            outputFlag = false;
        } 
    }else{
        int maxNum = h[0];
        for(int i = 1; i < n;i++){
            if(maxNum-2 >= h[i]){
                cout << "No" << endl;
                outputFlag = false;
                break;
            }else{
                maxNum = max(maxNum, h[i]);
            }
        }
    }
    if(outputFlag) cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void){

	int w,h,x,y,r;

	scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);

	if(x-r<0||x+r>w||y-r<0||y+r>h)printf("No\n");
	else printf("Yes\n");

	return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const int N = 2000005;

int n, dp[N], dp_sum[N], mod = 1e9 + 7;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for(int i = 2 * n + 1 ; i > n ; i--){
        dp[i] = 1;
        dp_sum[i] = dp[i] + dp_sum[i + 1];
    }
    dp[n] = n;
    dp_sum[n] = dp[n] + dp_sum[n + 1];
    for(int i = n - 1 ; i >= 1 ; i--){
        dp[i] = dp[i + 1];
        dp[i] = ((dp[i] + dp_sum[i + 3]) % mod - dp_sum[i + n + 2] + mod) % mod;
        dp[i] = (dp[i] + 1LL * (n - 1) * (n - 1)) % mod;
        dp_sum[i] = (dp[i] + dp_sum[i + 1]) % mod;
    }
    cout << dp[1] << endl;
}


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

using namespace std;

int main(){
    string S;
    int count=0;
    cin>>S;
    if(S[0]=='R'&&S[1]=='R'&&S[2]=='R'){
        count=3;
    }else if(S[0]=='R'&&S[1]=='R'||S[1]=='R'&&S[2]=='R'){
        count=2;
    }else if(S[0]=='R'||S[1]=='R'||S[2]=='R'){
        count=1;
    }else{
        count=0;
    }

    

    cout<<count;

}


Measured memory_bytes: 3196
#include <stdio.h>

int main(void) {

  int i;
  int n;
  long long sum = 0;
  int max = -1000000;
  int min = 1000000;

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    int a[i];
    scanf("%d", &a[i]);
    sum += a[i];

    if(a[i] < min)
      min = a[i];

    if(a[i] > max)
      max = a[i];
  }

  printf("%d %d %lld\n", min, max, sum);

  return 0;
}



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

signed main() {
  ios::sync_with_stdio(false);

  int N, K;
  cin >> N >> K;

  vector<int> X(N);
  for (int i = 0; i < N; ++i) {
    cin >> X[i];
  }

  int fnnp = N; // first non-negative position
  int fnpp = -1; // last negative position
  for (int i = 0; i < N; ++i) {
    if (0 <= X[i]) {
      fnnp = i;
      break;
    } else {
      fnpp = i;
    }
  }

  int ans = 1 << 29;
  for (int i = 0; i < N; ++i) {
    if (i < fnnp) {
      if (fnnp - i >= K) {
        ans = min(ans, -X[i]);
      } else {
        if (i + K <= N) {
          ans = min(ans, -2 * X[i] + X[i + K - 1]);
        }
      }
    } else {
      if (i - fnpp >= K) {
        ans = min(ans, X[i]);
      } else {
        if (-1 <= i - K) {
          ans = min(ans, 2 * X[i] - X[i - K + 1]);
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
N = int(input())
h = list(map(int,input().split()))
if h == [0]*N:
    print(0)
    exit()
for i in range(1,10001):
    f = False
    for j in range(N):
        if h[j] > 0:
            h[j] -= 1
            f = True
        elif h[j] <= 0 and f:
            break
    if h == [0]*N:
        ans = i
        break
print(ans)

Measured memory_bytes: 3064
/*bismillah ->                                                                                                         << Suirkhanov Meyirlan >>
  GL HF


                                                                                                                      42

    bless my code =)
                                                                                                            NEVER FOLLOW YOUR RULES :D HAHAHAHA
*/


///scanf ("%d%d", &x, &y);
///printf("%d", &a)

#include <bits/stdc++.h>

#define fast ios_base::sync_with_stdio();   cin.tie(0);   cout.tie(0);
#define randoperation srand(time(0));
#define pii pair < int , int >
#define pll pair < ll, ll >
#define pb push_back
#define pf psuh_front
#define mp make_pair
#define fi first
#define se second
#define fast ios_base::sync_with_stdio();   cin.tie(0);   cout.tie(0);
#define randoperation srand(time(0));
#define eb emplace_back

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const ll N = 2 * 1e5 + 7;
const ld pi = 3.14159265359;
const int INF = 1e9 + 7;
const double eps = 1e-9;

const int xi[4] = {-1, 0, +1, 0};
const int yj[4] = {0, +1, 0, -1};
const int xxi[4] = {+1, 0, -1, 0};
const int yyj[4] = {0, -1, 0, +1};

ll n;

map < ll, ll > cnt;

int main(){

  //freopen("bridge.in", "r", stdin);
  //freopen("bridge.out", "w", stdout);

  fast
  randoperation;

  ///           ||
  ///start here \/

  cin >> n;

  for(int i = 2; i <= n; i++){

    int x = i;

    for(int j = 2; j <= x; j++){
      while(x % j == 0){
        cnt[j]++;
        x /= j;
      }
    }
  }

  ll res = 1;

  for(int i = 1; i <= n; i++){
    res = (res * (cnt[i] + 1)) % INF;
  }

  cout << res;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		long sn = 0;
		for(char c: stringN.toCharArray()) {
			sn += c-'0';
		}
//		System.out.println("\tsn:"+sn);

		System.out.println((Integer.parseInt(stringN)%sn == 0) ? "Yes" : "No");
	}
}


Measured memory_bytes: 21844
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#define EPS 1e-10
#define INF 1e5
using namespace std;

double add(double a,double b){
	if(fabs(a+b)<EPS*(fabs(a)+fabs(b)))return 0.0;
	return a+b;
}

struct P{
	double x,y;
	P(){}
	P(double xx,double yy){
		x=xx;
		y=yy;
	}
	P operator +(P p){
		return P(add(x,p.x),add(y,p.y));
	}
	P operator -(P p){
		return P(add(x,-p.x),add(y,-p.y));
	}
	P operator *(double d){
		return P(x*d,y*d);
	}
};

struct Segment{
	P p1,p2;
	Segment(){}
	Segment(P pp1,P pp2){
		p1=pp1;
		p2=pp2;
	}
};
typedef P Vector;
typedef Segment Line;
typedef vector<P> Polygon;

double norm(P p){
	return add(p.x*p.x,p.y*p.y);
}

double abs(P p){
	return sqrt(norm(p));
}

double dot(P a,P b){
	return add(a.x*b.x,a.y*b.y);
}

double cross(P a,P b){
	return add(a.x*b.y,-a.y*b.x);
}

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

double getDistanceLP(Line l,P p){
	return abs(cross(l.p2-l.p1,p-l.p1)/abs(l.p2-l.p1));
}

double getDistanceSP(Segment s,P p){
	if(dot(s.p2-s.p1,p-s.p1)<0.0)return abs(p-s.p1);
	if(dot(s.p1-s.p2,p-s.p2)<0.0)return abs(p-s.p2);
	return getDistanceLP(s,p);
}

int contains(Polygon& g,P p){
	int N=g.size();
	bool x=false;
	for(int i=0;i<N;i++){
		P a=g[i]-p,b=g[(i+1)%N]-p;
		if(abs(cross(a,b))<EPS && dot(a,b)<EPS)return 1;
		if(a.y>b.y)swap(a,b);
		if(a.y<EPS && EPS<b.y && cross(a,b)>EPS)x=!x;
	}
	return (x?2:0);
}

double getDistancePP(Polygon& g,P p){
	double res=INF;
	int n=g.size();
	for(int i=0;i<n;i++){
		P p1=g[i],p2=g[(i+1)%n];
		res=min(res,getDistanceSP(Segment(p1,p2),p));
	}
	if(contains(g,p)!=2)res=-res;
	return res;
}

double Cx(Polygon& g, double x){
	double l=-1.0,r=10001;
	for(int i=0;i<100;i++){
		double ml=(l*2.0+r)/3.0;
		double mr=(l+r*2.0)/3.0;
		if(getDistancePP(g,P(x,ml))<getDistancePP(g,P(x,mr)))l=ml;
		else r=mr;
	}
	return getDistancePP(g,P(x,l));
}

int main(void){
	int n;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		Polygon g;
		for(int i=0;i<n;i++){
			P p;
			scanf("%lf%lf",&p.x,&p.y);
			g.push_back(p);
		}
		double l=-1.0,r=10001;
		for(int i=0;i<100;i++){
			double ml=(l*2.0+r)/3.0;
			double mr=(l+r*2.0)/3.0;
			if(Cx(g,ml)<Cx(g,mr))l=ml;
			else r=mr;
		}
		printf("%.10f\n",Cx(g,l));
	}
	return 0;
}

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

#define ll long long

const ll mxN = 1e18;
ll n, ans = mxN;

int main()
{
    cin >> n;

    for (ll i = 1; i * i <= n; i++)
    {
        if (!(n % i))
        {
            ans = min(ans, i + n / i - 2);
        }
    }

    cout << ans << endl;
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back
#define eb emplace_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using vpint = vector<pint>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

ll myPow(ll x, ll n)
{
    ll ans = 1;
    while (n > 0)
    {
        if ((n % 2) == 1)
        {
            ans = ans * x;
        }
        x = x * x;
        n >>= 1;
    }
    return ans;
}

void Main()
{
    ll n = in();
    ll ans = 0;
    vvint data(15, vint(15, 0));
    REP(a, 1, n + 1)
    {
        int l = to_string(a).front() - '0';
        int r = a % 10;
        ++data[l][r];
    }

    REP(a, 1, n + 1)
    {
        int l = to_string(a).front() - '0';
        int r = a % 10;
        if (r == 0)
            continue;
        ans += data[r][l];
    }
    cout << ans << endl;
}

signed main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

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

    vector<int> cnt(26,0);
    REP(i,h) {
        string s;
        cin >> s;
        REP(j,w) cnt[s[j]-'a']++;
    }

    if((h*w)%2==1) {
        REP(i,26) {
            if(cnt[i]%2==1){
                cnt[i]--;
                break;
            }
        }
    }

    REP(i,26) {
        if(cnt[i]%2==1){
            cout << "No" << endl;
            return 0;
        }
    }

    int k2 = 0;
    if(h%2==1) k2 += w/2;
    if(w%2==1) k2 += h/2;

    int ex2 = 0;
    REP(i,26) {
        if(cnt[i]%4==2) ex2++;
    }

    if(ex2 > k2) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll l,r,res=inf;

int main(){
	cin>>l>>r;
	if(r-l<5000){
		for(ll i=l;i<=r;i++) for(ll j=i+1;j<=r;j++) res=min(res,i*j%2019);
	}
	else res=0;
	cout<<res<<endl;
}

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

#define ll long long int
#define db double
#define fl float
#define endl '\n'

#define mod (ll)(1000000007)
#define mod1 (ll)998242353
#define mod2 (ll)998244353
#define PI 3.1415926535897932384626433832795

#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp(x,y) make_pair(x,y)
#define pb push_back
#define pob pop_back

#define Sort(v) sort(v.begin(),v.end())
#define Sortd(v) sort(v.begin(),v.end(),greater<>())

#define f(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<n;i++)
#define rf(i,n) for(int i=n-1;i>=0;--i)
#define rf1(i,n) for(int i=n-1;i>=1;--i)
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repn(i,a,b) for(int i=a;i<=b;++i)

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<vi> vvi;
typedef priority_queue<int> pqi;
typedef priority_queue<ll> pql;

vvi adj(200001);
vb vis(200001);

int  connected=0;
//DFS
int dfs(int s,int x){
    vis[s]=1;++x;
    for(auto i:adj[s]){
        if(!vis[i])x=dfs(i,x);
    }
    return x;
}

// //BFS
// vi level(200001);
// void bfs(int s){
//     queue<int> q;
//     q.push(s);
//     vis[s]=1;
//     level[s]=0;
//     int v;
//     while(!q.empty()){
//         v=q.top();
//         q.pop();
//         for(auto i:adj[v]){
//             if(!vis[i]){
//                 q.push(i);
//                 vis[i]=1;
//                 level[i]=level[v]+1;
//             }
//         }
//     }
// }

// //BFS-{Multi Source}
// vi level(200001);
// void bfs(vi s){
//     queue<int> q;
//     for(auto i:s){
//         q.push(i);
//         vis[i]=1;
//         level[i]=0;
//     }
//     int v;
//     while(!q.empty()){
//         v=q.top();
//         q.pop();
//         for(auto i:adj[v]){
//             if(!vis[i]){
//                 q.push(i);
//                 vis[i]=1;
//                 level[i]=level[v]+1;
//             }
//         }
//     }
// }



int main(){
    
    fast
    cin.tie(NULL);

    int n,m;
    cin>>n>>m;
    int x,y;
    f(i,m){
        cin>>x>>y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    int ans=0;
    f1(i,n+1){
        if(!vis[i]){
            ans=max(ans,dfs(i,0));
        }
    }
    cout<<ans<<endl;
    

    


    return 0;
}



Measured memory_bytes: 20300