akhauriyash/Code-Regression huggingface dataset:
/**
 * Created by hiramekun at 01:18 on 2020-05-12.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */


void solve() {
    ll h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) {
        cin >> s[i];
    }

    ll ans = 0;
    rep(i, h) {
        rep(j, w) {
            if (s[i][j] == '#') continue;

            vector<vector<bool>> seen(h, vector<bool>(w));
            vector<vector<ll>> d(h, vector<ll>(w, ll_inf));
            queue<P> q;
            q.push(make_pair(i, j));
            d[i][j] = 0;
            ll tmp = 0;
            while (!q.empty()) {
                ll x = q.front().F, y = q.front().S;
                seen[x][y] = true;
                q.pop();
                rep(k, 4) {
                    ll nx = x + dx[k], ny = y + dy[k];
                    if (nx < 0 || h - 1 < nx || ny < 0 || w - 1 < ny) continue;
                    if (seen[nx][ny] || s[nx][ny] == '#') continue;

                    d[nx][ny] = d[x][y] + 1;
                  seen[nx][ny] = true;
                    tmp = max(tmp, d[nx][ny]);
                    q.push(make_pair(nx, ny));
                }
            }
            ans = max(ans, tmp);
        }
    }

    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}


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

int gcd(int a,int b)
{
	return b?gcd(b,a%b):a;
}

int main()
{
	int n;
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			for(int k=1;k<=n;k++)
				ans+=gcd(i,gcd(j,k));
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
    long long a, b, k;
    cin >> a >> b >> k;

    if (k > a)
    {
        if ((k - a) > b)
        {
            cout << 0 << " " << 0;
        }
        else
        {
            cout << 0 << " " << b - k + a << endl;
        }
        
    }
    else
    {
        cout << a - k << " " << b << endl;
    }
}

Measured memory_bytes: 3576
#include <iostream>

using namespace std;

uint64_t T, A;
uint N;

void step(uint64_t t, uint64_t a)
{
  uint64_t n1, n2;
  if (T % t == 0)
    n1 = T / t;
  else
    n1 = T / t + 1;

  if (A % a == 0)
    n2 = A / a;
  else
    n2 = A / a + 1;

  uint64_t n = (n1 < n2) ? n2 : n1;
  T = n * t;
  A = n * a;
}


int main()
{
  cin >> N;
  cin >> T >> A;

  for (uint i=1; i<N; ++i) {
    uint64_t t, a;
    cin >> t >> a;
    step(t, a);
  }

  cout << T + A << endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  if((a+b)>(c+d)){
    cout << "Left" << endl;
  }
  else if((a+b)<(c+d)){
    cout << "Right" << endl;
  }
  else{
    cout << "Balanced" << endl;
  }
}
  

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

int n,m,flg;
bool t[21][21];
bool u[21];
vector<int>ans;
int a,b;
void init();
int main(){
  cin>>n>>m;
  init();
  for(int i=0;i<m;i++){
    cin>>a>>b;t[a][b]=true;
  }
  
  ans.push_back(2);u[2]=true;
  for(int i=0;i<n-1;i++){

    for(int j=1;j<=n;j++){
      if(u[j])continue;
   
      flg=1;
      for(int k=1;k<=n;k++){
	if(t[j][k]==false)continue;
	if(u[k]==false)flg=0;
      }

      if(flg){
	ans.push_back(j);
	u[j]=true;
	break;
      }
    }

  }
  for(int i=(int)ans.size()-1;i>=0;i--){
      cout<<ans[i]<<endl;
  }
  
  return 0;
}
void init(){
  for(int i=0;i<21;i++){
    u[i]=false;
    for(int j=0;j<21;j++)t[i][j]=false;
  }

}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;


int N;
vector<int> h;
vector<int> dp;


int main(){
    
    cin >> N;
    h.assign(N+1,0);
    for (int i = 1; i <= N; i++) {
        cin >> h[i];
    }
    h[0] = h[1];
    dp.assign(N+1, -1);
    dp[0] = 0;
    dp[1] = 0;
    
    for (int i = 1; i <= N; i++) {
        dp[i+1] = min(dp[i]+abs(h[i+1]-h[i]), dp[i-1]+abs(h[i+1]-h[i-1]));
    }
    
    cout << dp[N] << endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define nl                 "\n"
#define ll                 long long
#define pb                 push_back
#define pf                 push_front
#define np                 next_permutation
#define pp                 prev_permutation
#define sqr(x)             ((x)*(x))
#define pi                 acos(-1)
#define setprecision(x)    fixed<<setprecision((int)(x))
#define mem1(x)            memset(x,0,sizeof(x))
#define mem2(x)            memset(x,-1,sizeof(x))
#define all(x)             (x).begin(),(x).end()
#define rev(x)             reverse(all(x))
#define iota(x,a)          iota(all(x),a)
#define sorta(x)           sort(all(x))
#define sortd(x)           sort(all(x),greater<int>())
#define csort(x,c)         sort(all(x),c)
#define rsort(x)           sort(x.rbegin(),x.rend())
#define faster_io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define all_ele(x)         for(auto i:(x)){cout<<i<<' ';}cout<<nl;
#define multiple_test      int t; cin>>t; while(t--){solve();}
#define single_test        solve();
using namespace std;
//vector<vector<int>>p(sz,vector<int>(sz,val));
void solve()
{
   int n;
   cin>>n;
   vector<ll>a(n);
   for(int i=0; i<n; i++)
        cin>>a[i];
   ll taka=1000,bundle;
   int i,j;
   for(i=0; i<n-1;)
   {
       bundle=0;
       if(a[i]<a[i+1])
          {
              for(j=i+2; j<n; j++)
              {
                  if(a[j]<a[j-1])
                  {
                      break;
                  }
              }
            bundle=taka/a[i];
            taka=taka%a[i];
            taka+=(bundle*a[j-1]);
            i=j;
        }
        else
            i++;
   }
   cout<<taka<<nl;
}
int main()
{
    faster_io;
    //multiple_test
    single_test
    return 0;
}




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

void Main() {
  int n;
  cin >> n;

  int x[n];
  int y[n];
  vector<int> indexes(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    indexes[i] = i;
  }

  double sum = 0;
  double cnt = 0;
  do {
    for (int i = 0; i < n - 1; i++) {
      int a = indexes[i];
      int b = indexes[i + 1];
      sum += sqrt((x[a] - x[b]) * (x[a] - x[b]) + (y[a] - y[b]) * (y[a] - y[b]));
    }
    cnt++;
  } while (next_permutation(indexes.begin(), indexes.end()));

  cout << sum / cnt << endl;
}

int 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 <stdio.h>

int main()
{
	long int a,b,a1,b1;
	long int r;
	while(scanf("%ld %ld",&a1,&b1) != EOF){
		a = a1;
		b = b1;
		if(a < b){
			r = b;
			b = a;
			a = r;
		}
		if(a <= 0 || b <= 0){
			return 0;
		}
		r = a % b;
		while(r != 0){
			a = b;
			b = r;
			r = a % b;
		}
		printf("%ld %ld\n", b, a1 / b * b1);
	}
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
vector<int> vt;
vector<int> vt1;
vector<int> vt2;
vector<int> dap;
int main()
{
	int n;
	scanf("%d", &n);
	if (n == 3)
	{
		printf("2 5 63");
		return 0;
	}
	for (int i = 8; i <= 30000; i += 2) {
		if (i % 6 == 0)continue;
		vt.push_back(i);
	}
	for (int i = 15; i <= 30000; i += 6)
		vt1.push_back(i);
	for (int i = 6; i <= 30000; i+=6)
		vt2.push_back(i);
	int ch = 0;
	dap.push_back(2); dap.push_back(4);
	dap.push_back(3); dap.push_back(9);
	n -= 4;
	for (int i = 0; i < vt.size(); i+=2)
	{
		if (n / 2 == 0)break;
		dap.push_back(vt[i]); dap.push_back(vt[i + 1]);
		n -= 2;
	}
	for (int i = 0; i < vt1.size(); i += 2)
	{
		if (n / 2 == 0)break;
		dap.push_back(vt1[i]); dap.push_back(vt1[i + 1]);
		n -= 2;
	}
	for (int i = 0; i < vt2.size(); i += 2)
	{
		if (n / 2 == 0)break;
		dap.push_back(vt2[i]); dap.push_back(vt2[i + 1]);
		n -= 2;
	}
	sort(dap.begin(), dap.end());
	if (n)
		dap.push_back(30000);
	for (int i = 0; i < dap.size(); i++)
		printf("%d ", dap[i]);
}

Measured memory_bytes: 640
import sys


try:
    sys.stdin = open(sys.path[0] + '\\input.txt', 'r')
    sys.stdout = open(sys.path[0] + '\\output.txt', 'w')
except FileNotFoundError:
    pass


n, m, x = list(map(int, input().split()))
arr = []
c = []

for i in range(n):
    row = list(map(int, input().split()))
    c.append(row[0])
    arr.append(row[1:])

mincost = float('inf')

for i in range(1 << n):
    temp = []
    cost = 0

    for j in range(n):
        if i & (1 << j):
            temp.append(j)
            cost += c[j]

    if temp:
        res = [0] * m
        for k in temp:
            for i in range(m):
                res[i] += arr[k][i]

        flag = True
        for i in res:
            if i < x:
                flag = False
                break

        if flag:
            mincost = min(mincost, cost)

if mincost == float('inf'):
    print(-1)
else:
    print(mincost)


Measured memory_bytes: 9248
#include <iostream>

using namespace std;
typedef long long ll;
const int MAXN = 100010;

int n;
ll a[MAXN];

void solve() {
  int cnt1 = 0;
  int cnt2 = 0;
  int cnt4 = 0;
  for (int i=0;i<n;i++) {
    if (a[i] % 4 == 0) {
      cnt4++;
    } else if (a[i] % 2 == 0) {
      cnt2++;
    } else {
      cnt1++;
    }
  }
  if (cnt4 >= cnt1 || (cnt4 == cnt1-1 && cnt2 == 0)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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


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


int main(){

    string s, t;
    cin >> s >> t;
    int ans=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]!=t[i])
            ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3832
import Control.Monad

fill [x, _, 1] (xl, xr, yb, yt) = (max x xl, xr, yb, yt)
fill [x, _, 2] (xl, xr, yb, yt) = (xl, min x xr, yb, yt)
fill [_, y, 3] (xl, xr, yb, yt) = (xl, xr, max y yb, yt)
fill [_, y, 4] (xl, xr, yb, yt) = (xl, xr, yb, min y yt)

calc (xl, xr, yb, yt) = max 0 (xr-xl) * max 0 (yt-yb)


main = map read . words <$> getLine >>= \[w,h,n] -> (replicateM n (fill . map read . words <$> getLine) >>= print . calc . foldr ($) (0, w, 0, h))

Measured memory_bytes: 1020
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cassert>

using namespace std;


bool solve(){
	int n;
	cin>> n;
	if(!n) return false;
	int ans = 0;
	for(int i=2;i<n;i++){
		if(i%2==0){
			int num = n/i;
			num += i-1;
			int sum = 0;
			for(int j=0;j<i;j++){
				sum += num-j;
			}
			if(sum == n) ans++;
		}else{
			if(n%i==0) ans++;
		}
	}
	cout<< ans<< endl;
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	while(solve());
	
	return 0;
}

 

Measured memory_bytes: 1160
#include<iostream>
#include<string>
using namespace std;
int main(){
  int s;
  string n[41]={"00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39"};
  while(cin>>s){
    while(s>39) s -= 39;
    cout << "3C" << n[s] << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
from collections import Counter,defaultdict,deque
import sys
from itertools import permutations, combinations
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
    
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])


def main():
    n,m,Q = inpm()
    ans = [[0 for _ in range(n)] for _ in range(n)]
    for i in range(m):
        l,r = inpm()
        r-=1
        ans[r][0]+=1
        if l != n:
            ans[r][l] -= 1
    for i in range(n):
        for j in range(1,n):
            ans[i][j] += ans[i][j-1]
    for i in range(n):
        for j in range(1,n):
            ans[j][i] += ans[j-1][i]
    for _ in range(Q):
        p,q = inpm()
        print(ans[q-1][p-1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 55388
//#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define owo(i,a, b) for(int i=(a);i<(b); ++i)
#define uwu(i,a, b) for(int i=(a)-1; i>=(b); --i)
#define senpai push_back
#define ttgl pair<int, int>
#define ayaya cout<<"ayaya~"<<endl
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
gpu_hash_table<int, int> mp;
#define ordered_set tree<ttgl, null_type,less<ttgl>, rb_tree_tag,tree_order_statistics_node_update>
 */
using ll = long long;
using ld = long double;
const ll MOD = 924844033;
const ll root = 62;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll binpow(ll a,ll b){ll res=1;while(b){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b>>=1;}return res;}
ll modInv(ll a){return binpow(a, MOD-2);}
const double PI = acos(-1);
const double eps = -1e6;
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0xc0c0c0c0c0c0c0c0;
const int mxN = 101;
int n;
int arr[mxN];
int main() {
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin.tie(0)->sync_with_stdio(0);
    cin>>n;
    int sum = 0;
    owo(i, 0, n) {
        cin>>arr[i];
        sum+=arr[i];
    }
    int ans = 0;
    int diff = INF;
    owo(i, 0, n) {
        if(abs(arr[i]*n-sum)<diff) {
            diff = abs(arr[i]*n-sum);
            ans = i;
        }
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3620
#include<cstdio>
int main()
{
	char A[100];
	while(scanf("%s",A)!=EOF){
		for(int i = 0; i < 19; i++){
			if(A[i]==',')	printf(" ");
			else	printf("%c",A[i]);
		}
		printf("\n");
		getchar();
	}
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var abc = ReadInts();
            if(abc[1] + abc[2] - abc[0] <= 0)
            {
                WriteLine(0);
            }
            else
            {

            WriteLine(abc[1] + abc[2]-abc[0]);
            }
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数

        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

        //文字数を数える
        public static int CountChar(string s, char c)
        {
            return s.Length - s.Replace(c.ToString(), "").Length;
        }
    }
}


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

string S;

int main(){
	cin>>S;

	if(S.at(0)==S.at(1)&&S.at(1)==S.at(2))
		cout<<"No"<<endl;
	else if(S.at(0)==S.at(1)&&S.at(2)==S.at(3))
		cout<<"Yes"<<endl;
	else if(S.at(0)==S.at(2)&&S.at(1)==S.at(3))
		cout<<"Yes"<<endl;
	else if(S.at(0)==S.at(3)&&S.at(1)==S.at(2))
		cout<<"Yes"<<endl;
	else 
		cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  int key;
  struct node *next;
  struct node *prev;
};

typedef struct node *NodePointer;
NodePointer nil;


NodePointer listSearch(int key){
  NodePointer cur = nil->next;
  while(cur != nil && cur->key != key){
    cur = cur->next;
  }
  return cur;
}


void init(){
  nil = (NodePointer)malloc(sizeof(NodePointer));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 0;
  while(1){
    if(cur == nil) break;
    if(isf++ > 0) printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  if(t == nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void deleteKey(int key){
  deleteNode(listSearch(key));
}

void insert(int key){
  NodePointer x = (NodePointer)malloc(sizeof(NodePointer));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  
  scanf("%d", &n);
  init();
  for(i = 0 ; i < n ; i++){
    scanf("%s%d", com, &key);
    if(com[0] == 'i') {
      insert(key);
      np++;
      size++;
    }
    else if(com[0] == 'd'){
      if(strlen(com) > 6){
	if(com[6] == 'F') deleteFirst();
	else if(com[6] == 'L') deleteLast();
      }
      else{
	deleteKey(key);
	nd++;
      }
      size--;
    }
  }

  printList();
}


Measured memory_bytes: 32956
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long
 
const int INF = 1e9;
const long long LLINF = 1e18;
 
using namespace std;
 
int dy[] = {0,1,0,-1};
int dx[] = {1,0,-1,0};
int dy8[] = {0,1,1,1,0,-1,-1,-1};
int dx8[] = {1,1,0,-1,-1,-1,0,1};
 
/*==================================================*/
/*variable*/
int N, C;
int s[100005], t[100005], c[100005];
int sum[200005];
 
/*==================================================*/
/*function*/
 
/*==================================================*/
 
int main() {
    cin>>N>>C;
    REP(i,0,N){
        cin>>s[i]>>t[i]>>c[i];
    }
 
    REP(i,0,C){
        int ts[200005];
        REP(j,0,200005) ts[j] = 0;
 
        REP(j,0,N){
            if(c[j]-1 == i){
                ts[s[j]*2-1]++;
                ts[t[j]*2]--;
            }
        }
        REP(j, 1, 200005) ts[j] += ts[j-1];
        REP(j, 0, 200005) if(ts[j] > 0) sum[j]++;
    }
 
    int ans = 0;
    REP(i,0,200005){
        ans = max(ans, sum[i]);
    }
 
    cout<<ans<<endl;
 
    return 0;
}

Measured memory_bytes: 2944
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<ll> a(200, 1);
  for(int i = 0; i < n; i++) {
    a[s[i]]++;
  }
  ll ans = 1;
  for(int i = 0; i < 200; i++) {
    if(a[i] == 1) {
      continue;
    }
    ans *= a[i];
    ans %= MOD;
  }
  ans -= 1;
  if(ans < 0) {
    ans += MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3696
from itertools import combinations

N = int(input())
S = input()
count = 0

ans = set({})

for password in range(0, 1000):
    s = "{:03d}".format(password)
    s1, s2, s3 = s
    
    if s1 not in S:
        continue
    i1 = S.index(s1)
    if s2 not in S[i1+1:]:
        continue
    i2 = S[i1+1:].index(s2)
    if s3 not in S[i1+1:][i2+1:]:
        continue
    i3 = S[i1+1:][i2+1:].index(s3)
    # print(s, s1, s2, s3, "|", i1, i1 + i2, i1 + i2 + i3)
    ans.add(password)

print(len(ans))

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n - 1);
	rep(i, n - 1) cin >> a.at(i);
	int o = a.at(0) + a.at(n - 2);
	rep(i, n - 2) o += min(a.at(i), a.at(i + 1));
	cout << o << endl;
}

Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,a,b;
int main(){
	scanf("%d%d%d",&n,&a,&b);
	printf("%d %d\n",min(a,b),max(0,a + b - n));
	return 0;
}


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

lli n, k;

int main(void){
	cin >> n >> k;
	vector<lli> h(n);
	rep(i, n) cin >> h[i];
	sort(h.begin(), h.end());
	lli ans = INT_MAX;
	rep(i, n){
		if(k+i-1 >= n) break;
		ans = min(ans, h[k+i-1]-h[i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4024
n = int(input())
can = []
xyh = []
for _ in range(n):
  xyh.append(list(map(int,input().split())))
time = 0
while xyh[time][2] == 0:
  time += 1
x,y,h = xyh[time]
for i in range(101):
  for j in range(101):
    can.append([i, j, h + abs(x-i) + abs(y-j)])
step = 0
while len(can) != 1:
  x,y,h = xyh[(time + step) % n]
  if h != 0:
    cnt = 0
    while cnt < len(can):
      now = can[cnt]
      if now[2] != h + abs(x-now[0]) + abs(y-now[1]):
        del can[cnt]
      else:
        cnt += 1
  else:
    cnt = 0
    while cnt < len(can):
      now = can[cnt]
      if now[2] > abs(x-now[0]) + abs(y-now[1]):
        del can[cnt]
      else:
        cnt += 1
  step += 1
print(' '.join(list(map(str,can[0]))))

Measured memory_bytes: 4464
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m=numeric_limits<T>::max()){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int N,K;

bool sumadd(vector<int> &A, vector<int> &light){
  bool ok = true;
  for (int i=0; i<N; i++){
    int ai = max(0, i - A[i]);
    int bi = min(N, i + A[i] + 1);
    light[ai]++;
    light[bi]--;
  }
  rep(i, light.size()-1){
    light[i+1] += light[i];
    if (light[i] < N) ok = false;
  }
  swap(A, light); light.assign(N+1, 0);
  return ok;
}

void solve(vector<int> &A){
  if (N <= K){
    rep(i, N) cout <<N <<" ";
    cout <<endl; return;
  }
  vector<int> light(N+1, 0);
  sumadd(A, light);
  rep(i, K-1){
    if (sumadd(A,light)) break;
  }
  rep(i, N){
    cout <<A[i] <<" ";
  }
  cout <<endl;

}

int main() {
  cin >>N >>K;
  vector<int> A(N+1); rep(i, N) cin >>A[i];
  solve(A);
}

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

int main(){
    int r,g,b;
    cin >> r >> g >> b;
    int a;
    a = r*100 + g*10 + b;

    if(a%4 ==0){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << 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;

const int_least64_t INF = 10000000;

int main(){
    //cin coutを高速化
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout.tie(0);

    int n;
    cin >> n;
    vector<int> a(n, 0);
    map<int, int> m;
    rep(i, n) {
        cin >> a[i];
    }

    bool res = false;

    rep(i, n){
        if(m.count(a[i]) == 0)
            m[a[i]] = -1;
        else{
            res = true;
            break;    
        }   
    }

    if(res == true) cout << "NO";
    else cout << "YES";

    return 0;
}

Measured memory_bytes: 10368
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>

#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>

using namespace std;

int main()
{
    uint64_t N, M;
    std::cin >> N >> M;

    constexpr uint64_t m = 1000000007ULL;

    if (N == M) {
        uint64_t ans = 1;
        for (uint64_t i = 1; i <= N; ++i) {
            ans *= i * i;
            ans %= m;
        }
        ans *= 2;
        ans %= m;
        std::cout << ans << std::endl;
    }
    else if (N == M + 1) {
        uint64_t ans = 1;
        for (uint64_t i = 1; i <= M; ++i) {
            ans *= i * i;
            ans %= m;
        }
        ans *= N;
        ans %= m;
        std::cout << ans << std::endl;
    }
    else if (N + 1 == M) {
        uint64_t ans = 1;
        for (uint64_t i = 1; i <= N; ++i) {
            ans *= i * i;
            ans %= m;
        }
        ans *= M;
        ans %= m;
        std::cout << ans << std::endl;
    }
    else {
        std::cout << 0 << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;

}

Node treeSearch(Node u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key){
      u = u->left;
    }
    else u = u->right;
  }
  return u;

}

Node treeSuccessor(Node x){
  if(x->right != NIL){
    return treeMinimum(x->right);
  }
  Node y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL){
    Transplant(z,z->right);
  }
  else if(z->right == NIL){
    Transplant(z,z->left);
  }
  else{
    y = treeMinimum(z->right);
    if(y->parent != z){
      Transplant(y,y->right);
      y->right = z->right;
      y->right->parent =y;
    }
    Transplant(z,y);
    y->left = z->left;
    y->left->parent = y;
  }


}

void Transplant(Node u, Node v){
  if(u->parent == NIL){
    root = v;
  }
  else if(u == u->parent->left){
    u->parent->left = v;
  }
  else u->parent->right = v;
  if(v != NIL){
    v->parent = u->parent;
  }

}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x; // set parent
    if(z->key < x->key){
      x = x->left; // shift to left child
    }
    else{
      x = x->right; // shift to right child
    }
  }
  z->parent = y;

  if(y == NIL){
    root = z; // Tree is empty
  }
  else if(z->key < y->key){
    y->left = z; 
  }
  else{
    y->right = z;
  }

}

void inorder(Node u){
  if(u != NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }

}
void preorder(Node u){
  if(u != NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }

}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

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

int main() {
  ll n,m,dp[100007]={0};
  dp[0]=1;
  cin >> n >> m;
  bool broken[n]={0};
  r(i,m){
    int x;
    cin >> x;
    broken[x]=1;
  }
  for(int i = 0; i <= n; i++){
    if(broken[i])continue;
    dp[i+1]+=dp[i];
    dp[i+2]+=dp[i];
    dp[i+1]%=1000000007;
    dp[i+2]%=1000000007;
  }
  cout<<dp[n]<<endl;
}

Measured memory_bytes: 1152
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

#define _GLIBCXX_DEBUG
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    vector<pair<int, int>> a(5);
    int input, amari;
    for(int i=0; i<5; i++){
        cin >> input;
        amari = input%10==0 ? 10 : input%10;
        a.at(i) = make_pair(amari, input);
    }
    sort(a.begin(), a.end());
    int res = 0;
    for(int i=1; i<5; i++){
        res += a.at(i).second%10==0 ? (a.at(i).second/10)*10 : (a.at(i).second/10 + 1)*10;
    }
    res += a.at(0).second;
    cout << res << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main (void)
{
    int D;
    int T;
    int S;
    int div;
    int mod;

    scanf("%d", &D);
    scanf("%d", &T);
    scanf("%d", &S);

    // printf("%d, %d, %d",D,T,S);
    div = D / S;
    mod = D % S;

    if(div < T){
        printf("Yes");
    }
    else if ((div == T) && (mod ==0)){
        printf("Yes");
    }
    else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

int main()
{
  int N,ans=0;
  cin>>N;
  vector<int> H(N);
  for(int i=0;i<N;i++){
    cin>>H[i];
  }
  for(int i=0;i<N;i++){
    bool flag=true;
    for(int j=0;j<i;j++){
      if(H[j]>H[i])flag=false;
    }
    if(flag)ans++;

  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
X = int(input())
x = X
L = []
for i in 500,100,50,10,5,1:
    a = x // i
    x -= i * a
    L.append(a)
for i in 100*L[1], 50*L[2], 10*L[3]:
    L[4] += i // 5
ans = 1000*L[0] + 5*L[4]
print(ans)

Measured memory_bytes: 3064
use std::collections::HashMap;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|i| i.parse().ok().unwrap())
        .collect()
}

struct Data {
    ac: usize,
    wa: usize,
}

impl Data {
    fn new() -> Self {
        Data { ac: 0, wa: 0 }
    }
}

fn main() {
    let input = read_vec::<usize>();
    let n = input[0];
    let m = input[1];

    let mut hm = HashMap::new();
    for i in 0..n {
        let i = i + 1;
        hm.insert(i, Data::new());
    }
    for _ in 0..m {
        let input = read_vec::<String>();
        let p: usize = input[0].parse().ok().unwrap();
        let data = hm.get_mut(&p).unwrap();
        if data.ac == 0 {
            if input[1] == "AC" {
                data.ac = 1;
            } else {
                data.wa += 1;
            }
        }
    }

    println!("{} {}", 
        hm.values().map(|v| v.ac).sum::<usize>(), 
        hm.values().filter(|v| v.ac == 1).map(|v| v.wa).sum::<usize>());
    

}

Measured memory_bytes: 12540
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  ll x;
  cin >> x;
  int ans = 0;
  ll now = 100;
  while(now < x){
    now += now/100;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


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

struct edge{long long t; long long c; long long r;};
vector<edge> G[105];
long long depth[105], n, INF=1e15, ans, a;

void add_edge(long long f, long long t, long long c){
	G[f].push_back(edge{t, c, (long long)G[t].size()});
	G[t].push_back(edge{f, 0, (long long)G[f].size()-1});
}

bool bfs(long long s, long long t){
	memset(depth,-1,sizeof(depth));
	depth[s] = 0;
	queue<long long> que;
	que.push(s);
	while(!que.empty()){
		long long v = que.front(); 
		que.pop();
		for(edge e: G[v]) if(e.c && depth[e.t] == -1){
			depth[e.t] = depth[v] + 1;
			que.push(e.t);
		}
	}
	return depth[t] != -1;
}

long long dfs(long long v, long long t, long long f){
	if(v == t) return f;
	long long ret = 0;
	for(edge& e: G[v]){
		if(depth[v] < depth[e.t] && e.c){
			long long d = dfs(e.t, t, min(f - ret, e.c));
			if(d){
				e.c -= d; 
                G[e.t][e.r].c += d;
				ret += d;
			}
		}
		if(f == ret) break;
	}
	return ret;
}

long long maxflow(long long s, long long t){
	long long ret = 0;
	while(bfs(s,t)) ret += dfs(s, t, INF);
	return ret;
}
 
int main(){
	cin>>n;
	for(long long i=1; i<=n; i++){
		cin>>a;
		if(a < 0) add_edge(0,i,-a);
		else{
			ans += a;
			add_edge(i,n+1,a);
		}
		for(long long j=i*2; j<=n; j+=i) add_edge(i,j,INF);
	}
	cout<<ans-maxflow(0,n+1)<<endl;
}

Measured memory_bytes: 3672
s = input()

flag = [0] * 3

if s[0] == 'A':
	flag[0] += 1
	s = 'a' + s[1:]

Ccnt = 0
for i in range(2, len(s) - 1):
	if s[i] == 'C':
		Ccnt += 1
		s = s[:i] + 'c' + s[i+1:]

if Ccnt == 1:
	flag[1] = 1

if s.islower() is True:
	flag[2] = 1


if sum(flag) == 3:
	print('AC')
else:
	print('WA')

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int N;
int HP[101];

int M;

vector< tuple<int, int, int> > magic;

int dp[2][1000001]; // Single/All???just i???????????????????????????????°????MP

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  while(cin >> N, N) {
    magic.clear();

    int mxhp = 0;
    rep(i, N) cin >> HP[i], mxhp = max(mxhp, HP[i]);

    cin >> M;
    rep(i, M) {
      string na, tar;
      int mp, dam;
      cin >> na >> mp >> tar >> dam;
      magic.emplace_back(mp, (tar == "All"), dam);
    }

    fill(dp[0], dp[2], inf);
    dp[0][0] = dp[1][0] = 0;
    for(auto m : magic) {
      int mp, tar, dam;
      tie(mp, tar, dam) = m;
      rep(i, mxhp+1) {
	dp[tar][min(mxhp, i+dam)] = min(dp[tar][min(mxhp, i+dam)], dp[tar][i] + mp);
      }
    }

    for(int i = mxhp; i > 0; i--) {
      if(dp[0][i] < dp[0][i-1]) dp[0][i-1] = dp[0][i];
    }

    int ans = inf;
    rep(i, mxhp+1) if(dp[1][i] != inf) {
      int sum = dp[1][i];
      rep(j, N) sum += dp[0][max(HP[j]-i, 0LL)];
      ans = min(ans, sum);
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 18748
#include <iostream>
#include <string>
using namespace std;
int main() {
	string s;
	int sum = 700;

	cin >> s;

	if (s[0] == 'o')sum += 100;
	if (s[1] == 'o')sum += 100;
	if (s[2] == 'o')sum += 100;

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
/*	Don’t Quit
	
	When things go wrong as they sometimes will;
		When the road you’re trudging seems all uphill;
			When the funds are low, and the debts are high;
				And you want to smile, but you have to sigh;
					When care is pressing you down a bit
						Rest if you must, but don’t you quit.
*/
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3e5+10;
int32_t main()
{
  IOS;
	int n;
	cin>>n;
	string s;
	cin>>s;
	int cnt=0;
	for(int i=0;i<=999;i++)
	{
		vector<int>vp;
		int cnt1=3;
		int ii=i;
		while(cnt1>0)
		{
			vp.pb(ii%10);
			ii/=10;
			cnt1--;
		}
		reverse(all(vp));
		int k=0;
		for(int j=0;j<s.size();j++)
		{
			if(s[j]-'0'==vp[k])
			{
				k++;
			}
			if(k==vp.size())
			{
				cnt++;
				break;
			}
		}
		
	}
	cout<<cnt<<endl;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N;
    cin >> N;
    ll arr[10][10];
    rep(i, 10){rep(j, 10){arr[i][j] = 0;}}
    ll ans = 0;
    rep2(i, 1, N + 1){
        string num = to_string(i);
        int ind_i = num[0] - '0';
        int ind_j = num[num.size() - 1] - '0';
        arr[ind_i][ind_j] += 1;
    }
    rep(i, 10){rep(j, 10){ans += arr[i][j] * arr[j][i];}}
    cout << ans << endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define mp make_pair
#define gcd __gcd
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define N 10005  //check the limits, man
const ll INF = 1e18;
vi v;
int check(int j,int n,int k)
{
    bitset<N> bit;
    bit.reset();
    int i,a,f;
    bit[0]=1;
    rep(i,n)
    {
        a=v[i];
        if(i!=j)
            bit|=(bit<<a);
    }
    f=0;
    lp(i,k-v[j],k)
        if(bit[i]==1)f=1;
    return f;
}
int main()
{
    int n,k,i,x,l,r,m;
    in2(n,k);
    ll sum=0;
    rep(i,n)
    {
        in(x);
        sum+=x;
        if(x<k)
            v.pb(x);
    }
    if(sum<k)
    {
        out(n);
        return 0;
    }
    n=v.size();
    if(n==0)
    {
        out(0);
        return 0;
    }
    l=0,r=n;
    sort(all(v));
    while(l<r)
    {
        m=((l+r)>>1);
        if(check(m,n,k))
            r=m;
        else
            l=m+1;
    }
    out(l);
}




Measured memory_bytes: 384
def solve
  return [-1] unless K < 2**M
  return [-1] if M==1 && K==1
  return (0...2**M).to_a.map{|i| [i, i]}.flatten if K.zero?
  l = []
  r = []
  used = Array.new(2**M)
  used[0] = used[K] = true
  if K == 1
    l = [2, 0, K, 0, 2]
    r = [2^K, K, 2^K]
    used[2] = used[2^K] = true
  else
    l = [1, 0, K, 0, 1]
    r = [1^K, K, 1^K]
    used[1] = used[1^K] = true
  end
  (0...2**M).each do |i|
    next if used[i]
    used[i] = used[i^K] = true
    l.unshift(i)
    l.push(i)
    r.unshift(i^K)
    r.push(i^K)
  end
  l + r
end

M, K = gets.split.map &:to_i
puts solve*" "


Measured memory_bytes: 20732
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  double w, h, x, y;
  cin >> w >> h >> x >> y;
  double ans = w*h/2;
  printf("%.10f ", ans);
  if(w/2 == x && h/2 == y){
    cout << 1 << endl;
  }else{
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
/*Made by Shivam Solanki*/
#include<bits/stdc++.h> 
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define ll long long int
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<pii> vp;
typedef vector<pll> vpll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef set<int> sii;
typedef set<ll> sll;
typedef priority_queue<int> pq;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
typedef queue<int> qii;
#define rep(i,k,n) for (int i = k; i < n; ++i) 
#define repr(i,k,n) for (int i = n; i>=k; --i)
#define repll(i,k,n) for (ll i = k; i < n; ++i) 
#define repllr(i,k,n) for (ll i = n; i >= k; --i) 
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int INF = 1e9+5;
const int MOD = 1e9+7;
 
void solve(){
    int n;
    cin>>n;
    vi a(n);
    int sum=0;
    rep(i,0,n){
        cin>>a[i];
        sum+=a[i];
    }
    int avg1=sum/n,avg2=(sum+n-1)/n;
    // cout<<avg1<<' '<<avg2<<'\n';
    int ans1=0,ans2=0;
    rep(i,0,n){
        ans1+=pow(a[i]-avg1,2);
        ans2+=pow(a[i]-avg2,2);
    }
    cout<<min(ans1,ans2)<<'\n';
} 
  
int main(){
    // #ifndef ONLINE_JUDGE  
        // freopen("input.txt", "r", stdin); 
        // freopen("output.txt", "w", stdout); 
    // #endif 
    // fastio;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
vector<string>v;


int main(){

ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int r,p,s1,n,k,i;
    cin>>n>>k;
    cin>>r>>s1>>p;
    string s;
    cin>>s;
    ll sum=0,a[n+1]={0};
    for(i=1;i<=n;i++)
    {
    	if(i<=k)
    	{
    		if(s[i-1]=='r')
    		sum+=p;
    		else
    		{
    			if(s[i-1]=='p')
    			sum+=s1;
    			else
    			sum+=r;
			}
			a[i]=1;
			
		}
		else
		{
			if(s[i-1]!=s[i-k-1])
			{
				if(s[i-1]=='r')
    		sum+=p;
    		else
    		{
    			if(s[i-1]=='p')
    			sum+=s1;
    			else
    			sum+=r;
			}
			a[i]=1;
			}
			else
			{
				if(a[i-k]==0)
				{
					if(s[i-1]=='r')
    		sum+=p;
    		else
    		{
    			if(s[i-1]=='p')
    			sum+=s1;
    			else
    			sum+=r;
			}
			a[i]=1;
				}
			}
			
		}
	
	}
    cout<<sum;
}

Measured memory_bytes: 1232