akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
const ld EPS = 1e-12L;
const ld PI = 3.1415926535897932385L;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ull x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll x, y, z;
    cin >> x >> y >> z;
    ll n = x+y+z;
    vll a(n), b(n), c(n);
    vp s(n);
    ll calib = 0;
    rep(i, n){
        ll p, q, r;
        cin >> p >> q >> r;
        s[i] = make_pair(p-r, q-r);
        calib += r;
    }
    sort(ALL(s), [&](auto const& l, auto const& r){
        return l.first-l.second > r.first-r.second;
    });
    dump(s);
    vll xsum(n);
    {
        ll sum = 0;
        priority_queue<ll, vector<ll>, greater<ll>> pq;
        rep(i, n){
            if(i < x){
                pq.emplace(s[i].first);
                sum += s[i].first;
            }else{
                pq.emplace(s[i].first);
                sum += s[i].first;
                sum -= pq.top();
                pq.pop();
            }
            xsum[i] = sum;
        }
    }
    vll ysum(n);
    {
        ll sum = 0;
        priority_queue<ll, vector<ll>, greater<ll>> pq;
        repb(i, n){
            if(SZ(pq) < y){
                pq.emplace(s[i].second);
                sum += s[i].second;
            }else{
                pq.emplace(s[i].second);
                sum += s[i].second;
                sum -= pq.top();
                pq.pop();
            }
            ysum[i] = sum;
        }
    }
    dump(xsum, ysum);
    ll ans = -INF;
    repr(i, x, n-y+1){
        chmax(ans, xsum[i-1]+ysum[i]);
    }
    cout << ans+calib << endl;
    return 0;
}

Measured memory_bytes: 6904
n,m = map(int, input().split())
max_L = 0
min_R = 1000000

for i in range(m):
  l,r = map(int, input().split())
  max_L = max(max_L, l)
  min_R = min(min_R, r)
  
print((min_R-max_L + 1) if (min_R-max_L) >= 0 else 0)

Measured memory_bytes: 3060
/*やったぜ。　投稿者：変態糞土方 (8月16日（水）07時14分22秒)

昨日の8月15日にいつもの浮浪者のおっさん（60歳）と先日メールくれた汚れ好きの土方のにいちゃん

（45歳）とわし（53歳）の3人で県北にある川の土手の下で盛りあったぜ。

今日は明日が休みなんでコンビニで酒とつまみを買ってから滅多に人が来ない所なんで、

そこでしこたま酒を飲んでからやりはじめたんや。

3人でちんぽ舐めあいながら地下足袋だけになり持って来たいちぢく浣腸を3本ずつ入れあった。

しばらくしたら、けつの穴がひくひくして来るし、糞が出口を求めて腹の中でぐるぐるしている。

浮浪者のおっさんにけつの穴をなめさせながら、兄ちゃんのけつの穴を舐めてたら、

先に兄ちゃんがわしの口に糞をドバーっと出して来た。

それと同時におっさんもわしも糞を出したんや。もう顔中、糞まみれや、

3人で出した糞を手で掬いながらお互いの体にぬりあったり、

糞まみれのちんぽを舐めあって小便で浣腸したりした。ああ～～たまらねえぜ。

しばらくやりまくってから又浣腸をしあうともう気が狂う程気持ちええんじゃ。

浮浪者のおっさんのけつの穴にわしのちんぽを突うずるっ込んでやると

けつの穴が糞と小便でずるずるして気持ちが良い。

にいちゃんもおっさんの口にちんぽ突っ込んで腰をつかって居る。

糞まみれのおっさんのちんぽを掻きながら、思い切り射精したんや。

それからは、もうめちゃくちゃにおっさんと兄ちゃんの糞ちんぽを舐めあい、

糞を塗りあい、二回も男汁を出した。もう一度やりたいぜ。

やはり大勢で糞まみれになると最高やで。こんな、変態親父と糞あそびしないか。

ああ～～早く糞まみれになろうぜ。

岡山の県北であえる奴なら最高や。わしは163*90*53,おっさんは165*75*60、や

糞まみれでやりたいやつ、至急、メールくれや。

土方姿のまま浣腸して、糞だらけでやろうや。*/
#include "bits/stdc++.h"
#include <numeric>
#define rep(i,n) for(ll i = 0; i < n; i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define llMIN numeric_limits<long long>::min()
#define intMIN numeric_limits<int>::min()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double

ll digitpower(ll a,ll b){//aのb乗を計算
  if(b==1){
    return a;
  }else if(b==0){
    return 1;
  }
  if(b%2==1){
    ll tmp = digitpower(a,(b-1)/2);
    tmp%=d9_7;
    tmp*=tmp;
    tmp%=d9_7;
    tmp*=a;
    return (tmp)%d9_7;
  }else{
    ll tmp = digitpower(a,(b)/2);
    tmp%=d9_7;
    tmp*=tmp;
    tmp%=d9_7;
    return (tmp)%d9_7;
  }
}
//階乗
vl facs(1000000,-1);
ll Factrial(ll num){
  if(facs[num]!=-1){
    return facs[num];
  }
  if(num==1||num<=0){
    return 1;
  }else if(num<0){
    printf("ERROR_minus\n");
    return 0;
  }else{
    facs[num]=(num*Factrial(num-1))%d9_7;
    return facs[num];
  }
}
long long modinv(long long a, long long m) {//modの逆元
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
ll linercomb(ll n,ll k, ll mod){//n,kの線形時間で求める
  ll ans=Factrial(n);
  ans*=modinv(Factrial(k),mod);
  ans%=d9_7;
  ll k1=Factrial(k);
  k1%=mod;
  ans*=modinv(k1,mod);
  ans%=mod;
  return ans;
}
struct datas{
  ll x;
  ll l;

};
bool cmp(const datas &a, const datas &b)
{
    return a.x < b.x;
}

int main(void){
  ll n,k,s;
  cin>>n>>k>>s;
  ll num1=s/(n+1-k);
  if(s==1000000000){
    rep(i,n){
      if(i<k){
        cout<<s<<' ';
      }else{
        cout<<1<<' ';
      }
    }
    return 0;
  }
  rep(i,n){
    if(i<k){
      cout<<s<<' ';
    }else{
      cout<<s+1<<' ';
    }
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 9088
/*
    Ujjawal Pabreja [cuber_coder]
*/
#include <bits/stdc++.h> 
#include <functional> 
using namespace std;
#define speed_cubing    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll              long long
#define ld              long double
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define in              insert
#define ff              first
#define ss              second
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define sz(c)           (ll)c.size()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define rev             reverse
#define Y				"YES"
#define N 				"NO"
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << endl;
const ll inf = 1e18;  
const ll mod = 1e9 + 7;
const ll MOD = 998244353;
const ll MAX = 2e5 + 1;

inline ll add(ll a,ll b) {return ((a % mod) + (b % mod)) % mod;}
inline ll sub(ll a,ll b) {return ((a % mod) - (b % mod) + mod) % mod;}
inline ll mul(ll a,ll b) {return ((a % mod) * (b % mod)) % mod;}
ll pwr(ll x,ll n){
    if(n == 0){
        return 1;
    }
    if(n&1){
        return mul(x, pwr(mul(x, x), (n - 1) / 2));
    } else {
        return pwr(mul(x, x), n / 2);
    }
}
ll modInv(ll n){ 
    return pwr(n, mod - 2); 
}
ll gcd(ll a,ll b) {
    if(b == 0) {
        return a;
    }
    return gcd(b, a % b);
}
// ====== Useful functions end ======
 
// ====== Global Variables begin ======

// ====== Global Variables end ======

void speed_solve(){
    ll n, x, t;
    cin >> n >> x >> t;
    cout << (n / x + (n % x != 0)) * t << endl;
}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    speed_cubing;
    ll test_cases = 1;
    // cin >> test_cases;
    rep(i,test_cases){
        // cout << "Case #" << i + 1 << ": ";
        speed_solve();
    }
    return 0;
}

Measured memory_bytes: 3632
n=gets.to_i
a=gets.split.map &:to_i
c=0
j=0
1.upto(n-1) do |i|
  if j==0
    if a[i-1] < a[i]
      j=1
    elsif a[i-1] > a[i]
      j=2
    end
  elsif j==1
    if a[i-1] > a[i]
      j=0
      c+=1
    end
  else
    if a[i-1] < a[i]
      j=0
      c+=1
    end
  end
end
p c+1

Measured memory_bytes: 8460
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(ll i = 0; i < (ll)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(ll i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
//
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
//const ll MOD = 998244353ll;
const dou pi=3.141592653589793*2;

int main(){
    ll a,b,c;
    std::cin >>a>>b>>c;
    std::vector<ll> v;
    v.pb(a);
    v.pb(b);
    v.pb(c);
    if(a%2==0||b%2==0||c%2==0){
        std::cout << 0 << std::endl;
    }else{
        sort(all(v));
        std::cout << v[0]*v[1] << std::endl;
    }
}

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

using namespace std;

struct query{
    int a, b, x, y;
};

struct edge{
    int v, c, d;
};

vector<edge> adj[100010];
const int lgmx = log2(100000) + 2;
int sp[lgmx][100010], dist[100010], d[100010];
query q[100010];
vector<int> queries[100010];
int cnt[100010], calc[100010];
long long prefDist[100010], prefCnt[100010], distNow[100010];
int ans[100010];
int N, Q;

void buildSp(int u, int p){
    for(int i = 1; i < lgmx; i++)
        if(sp[i - 1][u] != -1) sp[i][u] = sp[i - 1][sp[i - 1][u]];

    for(auto k : adj[u]){
        if(k.v == p) continue;

        sp[0][k.v] = u;
        dist[k.v] = dist[u] + k.d;
        d[k.v] = d[u] + 1;
        buildSp(k.v, u);
    }
}

int lca(int u, int v){
    if(d[u] < d[v]) swap(u, v);

    int diff = d[u] - d[v];

    for(int i = 0; i < lgmx; i++){
        if(diff & (1 << i)) u = sp[i][u];
    }

    if(u == v) return v;

    for(int i = lgmx - 1; i >= 0; i--){
        if(sp[i][u] != sp[i][v]){
            u = sp[i][u], v = sp[i][v];
        }
    }

    return sp[0][v];
}

int getDist(int a, int b){
    return ((long long) dist[a] + dist[b] - 2LL * dist[lca(a, b)]);
}

void dfs(int u, int p){
    for(auto k : queries[u]){
        if(lca(q[k].a, q[k].b) == u) prefDist[k] = distNow[q[k].x], prefCnt[k] = cnt[q[k].x];
        else ans[k] += ((long long) cnt[q[k].x] - prefCnt[k]) * q[k].y - (distNow[q[k].x] - prefDist[k]);
    }

    for(auto k : adj[u]){
        if(k.v == p) continue;

        distNow[k.c] += k.d;
        cnt[k.c]++;

        dfs(k.v, u);

        distNow[k.c] -= k.d;
        cnt[k.c]--;
    }
}

int main(){
    scanf("%d%d", &N, &Q);

    for(int i = 1; i < N; i++){
        int a, b, c, d;
        scanf("%d%d%d%d", &a, &b, &c, &d);

        adj[a].emplace_back(edge({b, c, d}));
        adj[b].emplace_back(edge({a, c, d}));
    }

    memset(sp, -1, sizeof(sp));
    buildSp(1, -1);

    for(int i = 1; i <= Q; i++){
        scanf("%d%d%d%d", &q[i].x, &q[i].y, &q[i].a, &q[i].b);

        queries[lca(q[i].a, q[i].b)].emplace_back(i);
        queries[q[i].a].emplace_back(i);
        queries[q[i].b].emplace_back(i);

        ans[i] = getDist(q[i].a, q[i].b);
    }

    dfs(1, -1);

    for(int i = 1; i <= Q; i++) printf("%d\n", ans[i]);
    
    return 0;
}

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

int n,m;ll ans;
int main(){
	scanf("%d%d",&n,&m);
	if(n>m)swap(n,m);
	if(n==1)ans=m==1?1:m-2;
	else if(n==2)ans=0;
	else ans=ll(n-2)*(m-2);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
N,Y = map(int,input().split())
for x in range(N+1):
    if x*10000 > Y: break
    for y in range(N+1):
        z = N-x-y
        if x+y > N: break
        p = x*10000 + y*5000 + z*1000
        if p > Y: break
        if p == Y:
            print(x,y,z)
            exit()
print(-1,-1,-1)

Measured memory_bytes: 41436
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) {
	if os.Getenv("ONLINE_JUDGE") == "false" {
		fmt.Fprintln(os.Stderr, a...)
	}
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n, q := scanInt(), scanInt()
	uf := newUnionFind(n)

	for i := 0; i < q; i++ {
		t, u, v := scanInt(), scanInt(), scanInt()
		if t == 0 {
			uf.unite(u, v)
		} else {
			if uf.find(u) == uf.find(v) {
				fmt.Fprintln(wr, 1)
			} else {
				fmt.Fprintln(wr, 0)
			}
		}
	}
}

type unionFind []int

func newUnionFind(n int) *unionFind {
	uf := make(unionFind, n)
	for i := 0; i < n; i++ {
		uf[i] = -1
	}
	return &uf
}

func (uf *unionFind) find(x int) int {
	if (*uf)[x] < 0 {
		return x
	}
	(*uf)[x] = uf.find((*uf)[x])
	return (*uf)[x]
}

func (uf *unionFind) unite(x, y int) {
	x, y = uf.find(x), uf.find(y)
	if x != y {
		if (*uf)[x] > (*uf)[y] {
			x, y = y, x
		}
		(*uf)[x] += (*uf)[y]
		(*uf)[y] = x
	}
}

func (uf *unionFind) size(x int) int {
	return -(*uf)[uf.find(x)]
}


Measured memory_bytes: 4920
#include<bits/stdc++.h>
#define Mod 1000000007
using namespace std;
int n,x,y,z,dp[45][1<<18];
int main(){
	scanf("%d%d%d%d",&n,&x,&y,&z);
	int unuse=(1<<(z-1))|(1<<(z+y-1))|(1<<(x+y+z-1));
	dp[0][0]=1;
	int tmp1=(1<<(x+y+z))-1;
	for (int i=1;i<=n;i++){
		for (int j=0;j<=tmp1;j++){
			for (int k=1;k<=10;k++){
				int S=(j<<k)|(1<<(k-1));
				S=S&tmp1;
				if ((S&unuse)!=unuse)
					dp[i][S]=1ll*(dp[i][S]+dp[i-1][j])%Mod;
			}
		}
	}
	int ans=1;
	for (int i=1;i<=n;i++) ans=1ll*ans*10%Mod;
	for (int i=0;i<=tmp1;i++){
		if ((i&unuse)==unuse) continue;
		ans=ans-dp[n][i];
		if (ans<0) ans+=Mod;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 41728
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		//キーボード入力メソッド
		Scanner sc = new Scanner(System.in);

		//変数宣言
		int H = 1;
		int W = 1;


		while(true) {
			//HとWを手動入力
			H = sc.nextInt();
			W = sc.nextInt();

			//HとWがともに0のとき、処理を抜ける
			if(H == 0 && W == 0) {
				break;
			}

			//図形作成
			for(int i=0; i<H; i++) {
				for(int j=0; j<W; j++) {
					if(i==0 || i==H-1 || j==0 || j==W-1) {
						System.out.print("#");
					}else{
						System.out.print(".");
					}
				}
				System.out.println();
			}
			System.out.println();

		}


	}

}



Measured memory_bytes: 34860
#include<iostream>
#include<cstdio>
#define MAX 10000
#define MMIINN -2000000200
using namespace std;
typedef long long ll;

class Heap{
public:
  int index;
  ll HeapArray[MAX+1];

  Heap(){
    index=0;
    for(int i=0;i<=MAX;i++)HeapArray[i]=MMIINN;
  }

  void insert(ll v){
    index++;
    HeapArray[index]=v;
  }

  ll getValue(int i){
    return HeapArray[i];
  }

  ll getParent(int i){
    return HeapArray[i/2];
  }

  ll getLeft(int i){
    return HeapArray[2*i];
  }

  ll getRight(int i){
    return HeapArray[2*i+1];
  }



};


int main(){
  int n;
  ll val;
  Heap H;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> val;
    H.insert(val);
  }

  for(int i=1;i<=n;i++){
    printf("node %d: key = %lld, ",i,H.getValue(i));
    if(i != 1)printf("parent key = %lld, ",H.getParent(i));
    if(H.getLeft(i) != MMIINN)printf("left key = %lld, ",H.getLeft(i));
    if(H.getRight(i) != MMIINN)printf("right key = %lld, ",H.getRight(i));
    printf("\n");
  }



  return 0;
}



Measured memory_bytes: 3200
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string& s, char c) { vector<string> v; stringstream ss(s); string x; while(getline(ss,x,c)) v.emplace_back(x); return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
const ll MOD=1e9+7;

inline ll f(ll x){return x*(x-1ll)/2;}

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int k,s;
  cin>>k>>s; ++k;
  ll re=f(s+2);
  if(k<=s) re-=3*f(s-k+2);
  if(2*k<=s) re+=3*f(s-2*k+2);
  cout<<(re%MOD+MOD)%MOD<<endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
    using namespace std;
    #define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    #include <ext/pb_ds/assoc_container.hpp> 
    #include <ext/pb_ds/tree_policy.hpp> 
    using namespace __gnu_pbds; 
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
     
    #define ff first
    #define ss second
    #define mp make_pair
     
    #define pb push_back
    #define endl "\n"
     
    #define int long long int
    #define double long double
     
    #define bp __builtin_popcountll
    #define inf 1e18
    const int N=1e5+6;
    const int MOD=1e9+7;
	int connected;
	int n,m;
int root[N], sz[N];

void init()
{
	for(int i=1;i<=n;i++)
	{
		root[i]=i;
		sz[i]=1;
	}
	connected=n;
}

int rt(int k)
{
	while(k!=root[k])
	{
		root[k]=root[root[k]];
		k=root[k];
	}
	return k;
}

void merge(int u, int v)
{
	int rt1=rt(u);
	int rt2=rt(v);

	if(rt1==rt2)
		return;

	connected--;

	if(sz[rt1]>sz[rt2])
		swap(rt1, rt2);

	sz[rt2]+=sz[rt1];
	sz[rt1]=0;
	root[rt1]=root[rt2];
}
    void solve()
    {
    	
    	cin>>n>>m;
    	int ans=0;
    	init();
    		
    	for(int i=0;i<m;i++)
    	{
    		int x,y,z;
    		cin>>x>>y>>z;
    		merge(x,y);
    		
    	}
    	for(int i=1;i<=n;i++)
    	{
    		if(root[i]==i)
    		ans++;
    	}
    	cout<<ans<<endl;
    }
	signed main()  
    {
        FAST
        int t=1;
        // cin>>t;
        while(t--)
        {
        	solve();
        }
    }

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

ll n, k;
vector<ll> ans[100010];

signed main() {
	cin >> n >> k;
	if ((2 * k + 2 * n - 1)*n > ((2 * k + 5 * n - 1)*n / 2)) {
		cout << -1 << endl;
		return 0;
	}
	int cnt = 1;
	for (int i = n + k - 1; i >= k; i -= 2) {
		ans[cnt].push_back(i);
		cnt++;
	}
	for (int i = n + k - 2; i >= k; i -= 2) {
		ans[cnt].push_back(i);
		cnt++;
	}
	for (int i = 1; i <= n; i++)ans[i].push_back(n + k + i - 1);
	for (int i = 1; i <= (n + 1) / 2; i++)ans[i].push_back(k + 2 * n + (n + 1) / 2 - i);
	for (int i = (n + 3) / 2; i <= n; i++)ans[i].push_back(k + 3 * n - i + (n + 1) / 2);
	for (int i = 1; i <= n; i++)cout << ans[i][0] << " " << ans[i][1] << " " << ans[i][2] << endl;
}

Measured memory_bytes: 10592
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int A = scanner.nextInt();
		if (A >= N % 500) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 21972
fn main() {
    proconio::input! {
        n: usize,
        a_s: [i64; n],
    }
    let a_s = a_s.iter().collect::<std::collections::BTreeSet<_>>();
    let ai = **a_s.iter().max().unwrap();
    let aj = a_s
        .iter()
        .min_by_key(|a| {
            if ai % 2 == 0 {
                (***a - ai / 2).abs()
            } else {
                std::cmp::min((***a - ai / 2).abs(), (***a - (ai / 2 + 1)).abs())
            }
        })
        .unwrap();
    println!("{} {}", ai, aj);
}


Measured memory_bytes: 5236
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int a, b;
    cin >> a >> b;
    if(a%b == 0) puts("0");
    else puts("1");
    return 0;
}

Measured memory_bytes: 256
// JOI11-quest2.cpp : Defines the entry point for the console application.
//
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>


int main(void)
{
	int team, point[101] = { 0 };
	scanf("%d", &team);

	int a, b, c, d;
	for (int i = 0; i < (team * (team - 1)) / 2; i++) {
		scanf("%d %d %d %d", &a, &b, &c, &d);

		if (c > d) {
			point[a] += 3;
		}
		else if (c < d) {
			point[b] += 3;
		}
		else {
			point[a] += 1;
			point[b] += 1;
		}
	}

	int rank;
	for (int i = 1; i <= team; i++) {
		rank = 1;
		for (int j = 1; j <= team; j++) {
			if (i == j) {
				continue;
			}
			if (point[i] < point[j]) {
				rank++;
			}
		}
		printf("%d\n", rank);
	}

	return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	int n;
	const int cake=4;
	const int doug=7;
	while(cin>>n){
		int flag=0,i,j;
		for(i=n/doug;i>=0;i--){
			j=n-i*doug;
			if(j%cake==0){
				flag=1;
				cout<<"Yes"<<endl;
				break;
			}
		}
		if(flag==0){
			cout<<"No"<<endl;
		}
	}
	return 0;
}

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

#define MAX 20
#define WHITE 0
#define BLACK 1
int H, W;
char S[MAX][MAX];

int bfs(int x, int y) {
	int col[MAX][MAX], d[MAX][MAX];
	for (int h = 0; h < H; h++) {
		for (int w = 0; w < W; w++) {
			col[w][h] = WHITE;
			d[w][h] = -1;
		}
	}
	queue<pair<int, int>> Q;
	if (S[x][y] == '.') {
		Q.push(make_pair(x, y));
		d[x][y] = 0;
		col[x][y] = BLACK;
	}
	while (!Q.empty()) {
		auto u = Q.front();
		Q.pop();
		if (u.first - 1 >= 0) {
			if (col[u.first - 1][u.second] == WHITE &&
				S[u.first - 1][u.second] == '.') {
				Q.push(make_pair(u.first - 1, u.second));
				d[u.first - 1][u.second] = d[u.first][u.second] + 1;
				col[u.first - 1][u.second] = BLACK;
			}
		}
		if (u.first + 1 < W) {
			if (col[u.first + 1][u.second] == WHITE &&
				S[u.first + 1][u.second] == '.') {
				Q.push(make_pair(u.first + 1, u.second));
				d[u.first + 1][u.second] = d[u.first][u.second] + 1;
				d[u.first + 1][u.second] = d[u.first][u.second] + 1;
				col[u.first + 1][u.second] = BLACK;
			}
		}
		if (u.second - 1 >= 0) {
			if (col[u.first][u.second - 1] == WHITE &&
				S[u.first][u.second - 1] == '.') {
				Q.push(make_pair(u.first, u.second - 1));
				d[u.first][u.second - 1] = d[u.first][u.second] + 1;
				col[u.first][u.second - 1] = BLACK;
			}
		}
		if (u.second + 1 < H) {
			if (col[u.first][u.second + 1] == WHITE &&
				S[u.first][u.second + 1] == '.') {
				Q.push(make_pair(u.first, u.second + 1));
				d[u.first][u.second + 1] = d[u.first][u.second] + 1;
				col[u.first][u.second + 1] = BLACK;
			}
		}
	}
	int ret = INT_MIN;
	for (int h = 0; h < H; h++) {
		for (int w = 0; w < W; w++) {
			ret = max(ret, d[w][h]);
		}
	}
	return ret;
}

int main() {
	cin >> H >> W;
	for (int h = 0; h < H; h++) {
		for (int w = 0; w < W; w++) {
			cin >> S[w][h];
		}
	}
	int ans = INT_MIN;
	for (int h = 0; h < H; h++) {
		for (int w = 0; w < W; w++) {
			ans = max(ans, bfs(w, h));
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
def main():
    MOD = 10**9 + 7
    S = input()
    N = len(S)
    dp = [[0 for _ in range(13)] for _ in range(N + 1)]
    dp[0][0] = 1
    for i, c in enumerate(S):
        for j in range(10):
            if c != '?' and c != str(j):
                continue
            for k in range(13):
                dp[i + 1][(10 * k + j) % 13] += dp[i][k]
        for k in range(13):
            dp[i + 1][k] %= MOD
    print(dp[N][5])


if __name__ == '__main__':
    main()


Measured memory_bytes: 67164
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>*/
#include <bits/stdc++.h>
 
using namespace std;
//using namespace __gnu_pbds;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
 
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
 
const int MOD = 1000000007;
double PI = 4*atan(1);
 
int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int N,P; cin >> N >> P;
	vi a(N); 
	F0R(i,N) cin >> a[i];
	
	int o=0,e=0;
	F0R(i,N) if (a[i] % 2 == 0) e++;
	else o++;
	if (o == 0) {
	    if (P == 1) cout << 0;
	    else cout << (1LL<<N);
	} else cout << (1LL << (N-1));
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;
	vector<int>R(N);
	vector<int>G(N);
	vector<int>B(N);
	int r = 0, g = 0, b = 0;
	rep(i, N) {
		if (S[i] == 'R') {
			r++;
		}
		if (S[i] == 'G') {
			g++;
		}
		if (S[i] == 'B') {
			b++;
		}
		R[i] = r;
		G[i] = g;
		B[i] = b;
	}
	lint ans = 0;
	rep(i, N) {
		rep(j, N) {
			if (i < j) {
				if ((S[i] == 'R' && S[j] == 'G') || (S[i] == 'G' && S[j] == 'R')) {
					ans += B[N - 1] - B[j - 1];
					if (2 * j - i < N && S[2 * j - i] == 'B') {
						ans--;
					}
				}
				else if ((S[i] == 'G' && S[j] == 'B') || (S[i] == 'B' && S[j] == 'G')) {
					ans += R[N - 1] - R[j - 1];
					if (2 * j - i < N && S[2 * j - i] == 'R') {
						ans--;
					}
				}
				else if ((S[i] == 'R' && S[j] == 'B') || (S[i] == 'B' && S[j] == 'R')) {
					ans += G[N - 1] - G[j - 1];
					if (2 * j - i < N && S[2 * j - i] == 'G') {
						ans--;
					}
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3660
#include<iostream>
using namespace std;
using ll = long long;
int main() {
	ll A, B; cin >> A >> B;
	int K; cin >> K;
	for (int i = 0; i < K; i++) {
		if (A % 2) A--;
		A /= 2;
		B += A;
		i++;
		if (i >= K) break;
		if (B % 2) B--;
		B /= 2;
		A += B;
	}
	cout << A << " " << B << 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>;

const int mod = 1000000007;

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    ll ans = 1;
    if (N == K)
        rep(i, K) ans = (ans * A[i]) % mod;
    else {
        vector<ll> plus, minus;
        rep(i, N) {
            if (A[i] < 0)
                minus.push_back(A[i]);
            else
                plus.push_back(A[i]);
        }

        if (plus.size() == 0 && K % 2 == 1) {
            sort(minus.begin(), minus.end(), greater<>());
            rep(i, K) ans = (ans * minus[i]) % mod;
        } else {
            vector<pair<ll, pair<ll, ll>>> product;
            vector<ll> rest;
            sort(plus.begin(), plus.end(), greater<>());
            if (K % 2 == 1) {
                ans = (ans * plus[0]) % mod;
                plus.erase(plus.begin());
                --K;
            }
            if (!plus.empty()) {
                for (int i = 0; i < plus.size(); i += 2) {
                    if (i == plus.size() - 1) {
                        rest.push_back(plus[i]);
                        break;
                    }
                    product.push_back(
                        make_pair(plus[i] * plus[i + 1],
                                  make_pair(-plus[i], -plus[i + 1])));
                }
            }
            if (!minus.empty()) {
                sort(minus.begin(), minus.end());
                for (int i = 0; i < minus.size(); i += 2) {
                    if (i == minus.size() - 1) {
                        rest.push_back(minus[i]);
                        break;
                    }
                    product.push_back(
                        make_pair(minus[i] * minus[i + 1],
                                  make_pair(-minus[i], -minus[i + 1])));
                }
            }

            sort(product.begin(), product.end(), greater<>());
            for (int i = 0; i * 2 < K; ++i) {
                if (i * 2 == K - 1) {
                    for (int j = i; j < product.size(); ++j) {
                        rest.push_back(-product[j].second.first);
                        rest.push_back(-product[j].second.second);
                    }
                    sort(rest.begin(), rest.end(), greater<>());
                    ans = (ans * rest[0]) % mod;
                    break;
                }
                ans = (ans * (product[i].first % mod)) % mod;
            }
        }
    }

    if (ans < 0) ans += mod;
    cout << ans << endl;
}

Measured memory_bytes: 11044
#include<iostream>
#include<stdio.h>
#include<cmath>//??°?????¢??°
using namespace std;
int main(){
	double r,z;
	cin>>r;
	z=M_PI;
	printf("%lf %lf\n",r*r*z,2.0*r*z);
	return 0;
} 

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

int main(){
  string S;
  cin>>S;
  bool flag=true;
  for(int i=0;i<S.size();i++){
    if(i%2==0&&S[i]=='L')flag=false;
    if(i%2==1&&S[i]=='R')flag=false;
  }
  string ans=flag?"Yes":"No";
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
 
int main(){
  int N,K,x,sum=0;
  cin >> N >> K;
  
  rep(i,N){
    cin >> x;
    
    if(K-x>x)
      sum += 2*x;
    else
      sum += 2*(K-x);
  }
  cout << sum << endl;
} 

Measured memory_bytes: 256
X = gets.chomp.to_i

n, m = X.divmod(100)

as = [5, 4, 3, 2, 1]
a = as.shift
cnt = 0
while cnt < n
  if m >= a
    m -= a
    cnt += 1
  elsif as.empty?
    break
  else
    a = as.shift
  end
  break if m.zero?
end
if m.zero?
  puts 1
else
  puts 0
end


Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
 
int main()
{
	int n, k, q;
	cin >> n >> k >> q;
	vector<int> a(q);
	rep(i, q) cin >> a.at(i);
	vector<int> score(n, k-q);
	rep(i, q) score.at(a.at(i) - 1)++;
	rep(i, n) {
		if (score.at(i) > 0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N, A[100010] = {}; int B[100010] = {}; 
	cin >> N; 
	for(int i = 0; i < N; i++) cin >> A[i]; 
	int ans1 = 1, ans2 = 1; 
	int state1 = 1; int state2 = -1;  
	for(int i = 1; i < N; i++){
		if(A[i] > A[i-1]) B[i] = 1; 
		else if(A[i] == A[i-1]) B[i] = 0; 
		else B[i] = -1; 
	}
	for(int i = 1; i < N; i++){
		if(B[i] == 0) continue; 
		if(state1 == 0) state1 = B[i];  
		else if(B[i] != state1){
			state1 *= 0; ans1 ++; 
		}
		if(state2 == 0) state2 = B[i]; 
		else if(B[i] != state2){
			state2 *= 0; ans2 ++; 
		}
	}
	cout << min(ans1, ans2) << endl; 
}

Measured memory_bytes: 1532
from collections import deque

N = int(input())
B = [int(i) for i in input().split()]

if B[0] != 1:
    print(-1)
    exit()
if N == 1:
    print(1)
    exit()

# B[0]は絶対1だから後で加える
B.pop(0)

ans = deque()
while B:
    tmp = -1
    for i,b in enumerate(B):
        if i == 0 and b == 1:
            tmp = i
        elif b == i + 2:
            tmp = i
    if tmp < 0:
        print(-1)
        exit()
    ans.appendleft(B.pop(tmp))

ans.appendleft(1)

print(*ans, sep="\n")

Measured memory_bytes: 3316
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        
        final long N = Long.parseLong(sc.next());
        long sqrt = (long)Math.sqrt(N);
        long ans = 0;
        
        for (long i = 1; i <= sqrt; i++) {
            if (N % i == 0) {
                ans = N / i + i;
            }
        }
        
        out.println(ans - 2);
        
        out.flush();
    }
}

Measured memory_bytes: 23124
use std::cmp;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize
    }

    let mut ans = 0;

    let mut digit = 1;

    let mut c = vec![vec![0; 10]; 10];

    for i in 1..n + 1 {
        let head = i / (usize::pow(10, digit - 1));
        let tail = i % 10;

        if usize::pow(10, digit) == i + 1 {
            digit += 1;
        }

        c[head][tail] += 1;
    }

    for i in 0..10 {
        for j in 0..10 {
            ans += c[i][j] * c[j][i];
        }
    }

    println!("{}", ans);
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 8572
#include <iostream>

using namespace std;

int main() {

  int n;
  string p;
  cin >> n >> p;
  if(p.size() <= n){
    cout << p;
  }else{
    for(int i = 0;i < n;i++){
      cout << p[i];
    }
    cout << "...";
  }
  return 0;
}


Measured memory_bytes: 3628
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)


n = int(input())

GRAPH = {i:[] for i in range(1, n + 1)}
EDGES = []
for _ in range(n - 1):
    a, b = map(int, input().split())
    GRAPH[a].append(b)
    GRAPH[b].append(a)
    EDGES.append((a, b))

def dfs(now, prev = 0):
    a, b = min(now, prev), max(now, prev)
    used = COLORS[(a, b)]
    color = 1
    for v in GRAPH[now]:
        if v == prev:
            continue
        next = v
        a, b = min(now, next), max(now, next)
        if color == used:
            color += 1
            COLORS[(a, b)] = color
            color += 1
        else:
            COLORS[(a, b)] = color
            color += 1
    
    for v in GRAPH[now]:
        if v == prev:
            continue
        next = v
        dfs(next, now)

COLORS = {(0, 1):0}
dfs(1)

print(max(COLORS.values()))
for edge in EDGES:
    print(COLORS[edge])


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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    ll x,n;
    cin>>x>>n;
    ll ans=0;
    set<ll> v;
    rep(i,n)
    {
      ll val;
      cin>>val;
      v.insert(val);
    }
    repA(i,1,101)
    {
      if(v.count(i)==0)
      {
        if(abs(i-x)<abs(ans-x)) ans=i;
      }
    }
    cout<<ans<<'\n';
    return 0; 
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!


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

void solve()
{
	int a,b,c;
	string str,str1,str2;
	cin >> str >> str1;
	str1.pop_back();
	if (str1 == str)
	cout << "Yes";
	else
	cout << "No";
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);	
//	int t;
//	cin >> t;
//	while (t--)
	solve();
	
	return 0;
	
}

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

using namespace std;

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

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

  if(S == "ABC"){
    cout << "ARC";
  }
  else{
    cout << "ABC";
  }
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  int N;
  while(cin>>N,N) {
    vector<int> r(N),w(N);
    int maxi=0,rsum=0,wsum=0;
    for(int i=0; i<N; i++) {
      cin >> r[i] >> w[i];
      maxi = ((r[i]>r[0])?i:0);
      rsum += r[i];
      wsum += w[i];
    }
    swap(r[0],r[maxi]);
    swap(w[0],w[maxi]);
    if(r[0]*2<=rsum){
      cout << rsum+wsum << endl;
    }else{
      int ds = r[0]*2-rsum;
      vector<vector<int> > dp(N, vector<int>(ds+1));
      for(int s=0; s<=ds; s++)
	dp[0][s] = 0;
      for(int n=0; n<N; n++)
	dp[n][0] = 0;
      for(int n=1; n<N; n++)
	for(int s=1; s<=ds; s++)
	  if (s<w[n]) {
	    dp[n][s] = dp[n-1][s];
	  } else {
	    dp[n][s] = max(dp[n-1][s],dp[n-1][s-w[n]]+w[n]);
	  }
      cout << r[0]*2+wsum-dp[N-1][ds] << endl;;
    }
  }
}

Measured memory_bytes: 1344
// Problem : B - Postdocs
// Contest : AtCoder - NOMURA Programming Competition 2020
// URL : https://atcoder.jp/contests/nomura2020/tasks/nomura2020_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

#define Fast            ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define fWrite          freopen ("out.txt","w",stdout);
#define TC              int t;cin >> t;FOR(tc,1,t)
#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define all(a)          a.begin(),a.end()
#define MEM(a,x)        memset(a,x,sizeof(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)

int main()
{
    Fast
    string str;
    cin >> str;
    string ans;
    REP(i,str.size()){
    	if(str[i]=='?')
    	{
    		ans+='D';
    	}
    	else ans+=str[i];
    }
    cout << ans;
}


Measured memory_bytes: 3828
#include <iostream>
#include <set>
#include <vector>
using namespace std;
 
 
#define F(i, a) for (int i = 0; i < (a); i++)
#define Fd(i, a) for (ll i = (a)-1; i >= 0; i--)
#define Fs(i, a, j) for (ll i = (j); i < (a); i++)
#define deb(x) cout << #x << " " << x << endl;
#define debs(x) cout << #x << " " << x << " ";
#define deba(x) for (auto _i:x) cout << _i << " "; cout << endl;
#define ms(a) memset(a,0,sizeof(a));
#define ll long long
#define mp make_pair
#define eb emplace_back
#define FastOpen freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define int long long
#define pii pair < int , int >
//int power(int x,int p){if(p==0)return 1;if(p==1)return x;if(p%2)return x*power(x,p-1);int y=power(x,p/2);return y*y;}
/*
*/

int dist[1010][1010];
vector < string > g(1010);
int n,mr,sx,sy,ex,ey;
const int inf = 1e9+7;

int movex[] = {-1,1,0,0};
int movey[] = {0,0,-1,1};
bool isvalid(int a, int b) {
    return (a < n && a >= 0 && b < mr && b >= 0);
}
int dijkstra() {
    F(i,n) F(j,mr) dist[i][j] = inf;
    multiset < pair < int , pair < int ,int > > > m; // dist and then vertex
    dist[ex][ey] = 0;
    m.insert(mp(0,mp(ex,ey)));
    while (!m.empty()) {
        auto x = *m.begin();
        pii u = x.second;
        m.erase(m.begin());
        F(i,4) {
            pii v = mp(u.first + movex[i], u.second + movey[i]);
            if (isvalid(v.first,v.second) && g[v.first][v.second] != '#') {
//                cout << "HI " << endl;
                if (dist[u.first][u.second] < dist[v.first][v.second]) {
                    dist[v.first][v.second] = dist[u.first][u.second];
                    m.insert(mp(dist[v.first][v.second],mp(v.first,v.second)));
                }
            }
        }
        for (int i=u.first-2; i<=u.first+2; i++) {
            for (int j=u.second-2; j<=u.second+2; j++) {
                if (i==u.first && j==u.second) continue;
                if (isvalid(i,j) && g[i][j] != '#') {
                    if (dist[u.first][u.second] + 1 < dist[i][j]) {
                        dist[i][j] = dist[u.first][u.second] + 1;
                        m.insert(mp(dist[i][j],mp(i,j)));
                    }
                }
            }
        }
    }
    return dist[sx][sy];
}

void solve() {
    cin >> n >> mr;
    cin >> sx >> sy >> ex >> ey;
    sx--;sy--;ex--;ey--;
    F(i,n) cin >> g[i];
    int res = dijkstra();
//    F(i,n) {F(j,mr) cout << dist[i][j] << " "; cout << endl; }
    if (res == inf) cout << "-1" << endl;
    else cout << res << endl;
}

signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//    FastOpen
    int t; t=1;
    while (t--) solve();
}





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

int main() {
    string s;
    cin >> s;
    int k = (int)s.size();
    if (k < 2) {
        cout << 0 << endl;
        exit(0);
    }
    if (k == 3) {
        if (s == "ABC") cout << 1 << endl;
        else cout << 0 << endl;
        exit(0);
    }
    int cnt = 0;
    long long ans = 0;
    for (int i = 0; i <= k - 3; i++){
        if (s[i] == 'A') cnt++;
        else cnt = 0;
        if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') {
            ans += cnt;
            cnt--;
            s[i] = 'B';
            s[i+1] = 'C';
            s[i+2] = 'A';
            i++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640