akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
//typedef long long ll;

int main() {
	long long n, ans;
	cin >> n ;
	vector<long long> v(5,0);
	cin >> v[0];
	long long m = v[0];
	
	for (int i = 1;i < 5;++i){
		cin >> v[i];
		m = min(m,v[i]);
	}
	
	ans = 5 + n/m;
	if (n % m == 0){
		ans -= 1;
	}
	cout << ans << endl;
}


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

int main(){
	int n,m;
	cin>>n>>m;
	int inf = 100000000;
	int dis[100][100];
	int a[1000],b[1000];
	int x[1000];
	for(int i=0;i<m;i++){		
		cin>>a[i]>>b[i]>>x[i];
		a[i]--;
		b[i]--;
	}
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(i == j){
                dis[i][j] = 0;
            }else{
                dis[i][j] = inf;
            }
        }
    }
	for(int i=0;i<m;i++){
		dis[a[i]][b[i]]=min(dis[a[i]][b[i]],x[i]);
		dis[b[i]][a[i]]=min(dis[b[i]][a[i]],x[i]);
	}
	for(int k=0;k<n;k++){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
			}
		}
	}
	int ans=m;
	for(int i=0;i<m;i++){
		bool sht=false;
		for(int j=0;j<n;j++)
			if(dis[j][a[i]]+x[i]==dis[j][b[i]])
				sht=true;
			

		
		if(sht==true){
				ans-=1;
			}
	}
	cout<<ans<<endl;
}		

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)


using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    bool f = false;


    REP(i, 0, n){
        ll sum = m * i;
        REP(j, 0, m){
            sum = sum - i + n - i;
            if(sum == k)f = true;
        }
    }
    cout << (f ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
n=int(input())
ab=[list(map(int,input().split())) for i in range(n)]
ab.sort(key=lambda x: x[1])
t=0
for x in ab:
  if t+x[0] <= x[1]:
    t += x[0]
  else:
    print('No')
    break
else:
  print('Yes')

Measured memory_bytes: 46908
def com(n,r,mod):
    k=min(r,n-r)
    C=1
    for i in range(1,k+1):
        C=(C*(n+1-i)*pow(i,mod-2,mod))%mod
    return C

x, y = map(int,input().split())
mod = 10 ** 9 + 7
n = (2 * y - x) // 3 if (2 * y - x) % 3 == 0 else -1
m = (2 * x - y) // 3 if (2 * x - y) % 3 == 0 else -1

if n >= 0 and m >= 0:
    print(com(n + m, n, mod))
else:
    print(0)

Measured memory_bytes: 3064
import java.io.*;
public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        String[] x = str.split(" ");
        int a = Integer.parseInt(x[0]);
        int b = Integer.parseInt(x[1]);
        System.out.println(a*b + " " + (a+b)*2);
    }
}

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

int main(void) {
	int n, h[101] = { 0 }, min = 101, max = 0, ans = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &h[i]);
		if (min > h[i])min = h[i];
		if (max < h[i])max = h[i];
	}
	ans += min;
	for (int k = min + 1; k <= max; k++) {
		for (int l = 0; l < n; l++) {
			if (h[l] >= k) {
				if (h[l + 1] >= k)continue;
				else ans++;
			}
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 128
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0004
#include <bits/stdc++.h>
using namespace std;

int main(){
  for(double a,b,c,d,e,f,x,y; cin>>a>>b>>c>>d>>e>>f;){
    x = (e*c-b*f)/(a*e-b*d);
    y = ((-d)*c+a*f)/(a*e-b*d);

    char buff[100];
    sprintf(buff, "%.3f", x);
    if(!strcmp(buff, "-0.000")) x = 0;
    sprintf(buff, "%.3f", y);
    if(!strcmp(buff, "-0.000")) y = 0;
    cout<<fixed; // ?°???°?????\??????????????????????????????????????????????????°???????????°??????????????????
    cout<<setprecision(3)<<x<<" "<<y<<endl;
  }
  return EXIT_SUCCESS;
}

Measured memory_bytes: 1284
#include <algorithm>
#include <cassert>
#include <vector>
#include <iostream>
#include <climits>
#include <functional>

template <typename T>
struct SegmentTree{
private:
  using F = std::function<T(T,T)>;
  int n;
  F f;
  T ti;
  std::vector<T> dat;
public:
  SegmentTree(){};
  SegmentTree(F f,T ti) : f(f),ti(ti) {}
  void build(int n_){
    n = n_;
    dat.assign(2*n,ti);
  }
  void build(const std::vector<T> &v){
    int n_ = v.size();
    build(n_);
    for(int i = 0; i < n; ++i) dat[n+i]=v[i];
    for(int i = n-1; i >= 0; --i)
      dat[i]=f(dat[2*i+0],dat[2*i+1]);
  }
  void set_val(int k,T x){
    dat[k+=n] = x;
    while(k > 0){
      k = k/2;
      dat[k]=f(dat[2*k+0],dat[2*k+1]);
    }
  }
  T query(int a,int b){
    if(a == b) return ti;
    T vl = ti, vr = ti;
    for(int l = a+n, r = b+n; l < r; l >>= 1, r >>= 1){
      if(l&1) vl = f(vl,dat[l++]);
      if(r&1) vr = f(dat[--r],vr);
    }
    return f(vl,vr);
  }
};

#include <iostream>
#include <vector>
#include <utility>
#include <tuple>
#include <queue>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> P(N);
  vector<pair<int,int>> Odd, Even;
  const int INF = 1e9;
  for(int i = 0; i < N; ++i){
    int p;
    cin >> p;
    P[i] = p;
    if(i%2) Odd.emplace_back(p,i), Even.emplace_back(INF,i);
    else Even.emplace_back(p,i), Odd.emplace_back(INF,i);
  }

  using T = pair<int,int>;
  function<T(T,T)> f = [](T a, T b) -> T {
                         return min(a,b);
                       };

  T ti(INF,-1);
  SegmentTree<T> odd(f,ti), even(f,ti);
  odd.build(Odd);
  even.build(Even);
  using tup = tuple<int,int,int,int>;

  auto find_lr = [&](int l, int r) -> pair<int,int> {
               assert(l%2 == r%2);
               if(r-l < 2) return {};
               auto li = (l%2 ? odd.query(l,r) : even.query(l,r));
               auto ri = (l%2 ? even.query(li.second,r) : odd.query(li.second,r));
               return make_pair(li.second,ri.second);
              };
  
  vector<int> Q;
  priority_queue<tup,vector<tup>,greater<>> pq;
  {
    // auto [l,r] = find_lr(0,N);
    int l, r;
    tie(l,r) = find_lr(0,N);
    Q.push_back(P[l]);
    Q.push_back(P[r]);
    vector<pair<int,int>> v = {{0,l},{l+1,r},{r+1,N}};
    for(auto e : v){
      if(e.second-e.first < 2) continue;
      // auto [ll,rr] = find_lr(e.first,e.second);
      int ll, rr;
      tie(ll,rr) = find_lr(e.first,e.second);
      pq.emplace(P[ll],P[rr],e.first,e.second);
    }
  }
  for(int i = 1; i < N/2; ++i){
    // auto [a, b, L, R] = pq.top();
    int a, b, L, R;
    tie(a,b,L,R) = pq.top();
    pq.pop();
    Q.push_back(a);
    Q.push_back(b);
    if(R - L < 2) continue;
    // auto [l,r] = find_lr(L,R);
    int l, r;
    tie(l,r) = find_lr(L,R);
    vector<pair<int,int>> v = {{L,l},{l+1,r},{r+1,R}};
    for(auto e : v){
      if(e.second-e.first < 2) continue;
      // auto [ll,rr] = find_lr(e.first,e.second);
      int ll, rr;
      tie(ll,rr) = find_lr(e.first,e.second);
      pq.emplace(P[ll],P[rr],e.first,e.second);
    }
  }

  for(int i = 0; i < N; ++i)
    cout << Q[i] << (i+1 < N ? " " : "\n");
}


Measured memory_bytes: 14180
s = int(input())
a = [s]
z = set([s])
idx = 1
for i in range(10**8):
    idx += 1
    if a[i] % 2 == 0:
        ai = a[i] // 2
    else:
        ai = 3 * a[i] + 1
    if ai in z:
        print(idx)
        exit()
    a.append(ai)
    z.add(ai)


Measured memory_bytes: 3060
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;

uint64_t X,Y;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> X>>Y;

	int32_t count = 0;
	while (X <= Y) {
		++count;
		X *= 2;
	}
	out << count << endl;

	return 0;
}
#endif


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


char s[100100];

int main()
{
	while(~scanf("%s",s))
	{
		int len = strlen(s);
		int n = len;
		int F= 0;
		for(int i = 0;i < len-2;i++)
		{
			if(s[i] == s[i+1])
			{
				printf("%d %d\n",i+1,i+2);
				F = 1;
				break;
			}
			if(s[i] == s[i+2])
			{
				printf("%d %d\n",i+1,i+2+1);
				F = 1;
				break;
			}
			
		}
		
		if(!F)
		{
			if(s[n-1] == s[n-2])
			{
				printf("%d %d\n",n-1,n);
				F = 1;
			}
		}
		
		if(!F)
		{
			printf("-1 -1\n");
		}
	}
/*
needed 
atcoder
Sample Output 

The string s2s3s4s5 = eede is unbalanced. There are also other unbalanced substrings. For example, the output 2 6 will also be accepted.

Sample Input 2







*/



 return 0;
}



Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
  int k, s, count = 0;
  cin >> k >> s;
  for (int x = 0; x < k + 1; ++x) {
    for (int y = 0; y < k + 1; ++y) {
      int z = s - x - y;
      if (0 <= z and z <= k) count++;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(){
    long a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    long n=min(x,y);
    long ans=0;
    ans+=min((a*n+b*n),(2*c*n));
    long m=max(x-n,y-n);
    if (x>y){
        ans+=min((a*m),(2*c*m));
    }
    else if(x<y){
        ans+=min((b*m),(2*c*m));
    }
    cout<<ans;
    return 0;
}

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

using namespace std;


int main(){
  int s,k;cin>>k>>s;
  int ans = 0;
  for(int i=0;i<=k;i++){
    for(int j=0;j<=k;j++){
      if((0 <= (s-i-j)) && ((s-i-j) <= k))ans++;
    }
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial,sin
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

a,b,c=MI()
k=I()
while b<=a:
    b*=2
    k-=1
while c<=b:
    c*=2
    k-=1
if k>=0:
    print("Yes")
else:
    print("No")
        



        
    
    


    


    


Measured memory_bytes: 9484
#include<bits/stdc++.h>
#define int long long int
#define fr(i,x,y) for(int i=x;i<y;i++)
#define f(n) for(int i=0;i<n;i++)
#define ff(m) for(int j=0;j<m;j++)
#define F(x) for(auto it:x)
#define in insert
#define pb push_back
#define pi pair<int,int>
#define si second
#define fi first
#define show_(x) cerr<<"-> "<<#x<<endl;F(x){cerr<<it<<" ";}cout<<endl;
#define show(x) cerr<<#x<<"-> "<<x<<endl;
//#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
//#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0;
#define FILEIO freopen("F:\\inout\\input.txt", "r", stdin); freopen("F:\\inout\\output.txt", "w", stdout);
using namespace std;
void print(int a[],int n){f(n){cout<<a[i]<<" ";}cout<<endl;}
int m(int x){return x%1000000007;} 
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
int p(int a,int b){if(b==0)return 1;int t=p(a,b/2); if(b%2==0)return t*t; else return a*t*t; } 
//strlen(s.c_str());  set <int, greater<int>> s; numeric_limits<double>::max()
//---------------------------------------------------------------------------------------------------------------------------------------------

int dp[2001][2001]={{0}};


signed main(){
	//FILEIO
	//cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	f(2001){
		dp[i][0]=1;
		dp[i][1]=i;
	}
	//dp[0][0]=0;
	f(2001){
		if(i==0 || i==1){
			continue;
		}
		for(int j=0;j<2001;j++){
			dp[i][j]=m(m(dp[i-1][j])+m(dp[i-1][j-1]));
		}
	}
	int n,k;
	cin>>n>>k;
	f(k+1){
		if(i==0){
			continue;
		}
		int y=n-k-i+1;
		if(y<0){
			cout<<0<<endl;
			continue;
		}
		int ans=m(m(dp[k-1][i-1])*m(dp[y+i][i]));
		ans+=1000000007;
		ans=m(ans);
		cout<<ans<<endl;
	}

	

	
	
	






	return 0;
}



Measured memory_bytes: 31488
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 1000;
static const int VMAX = 10000;

int n, A[MAX], s;
int B[MAX], T[VMAX+1];

int solve(){

  int i, ans = 0;
  bool V[MAX];

  for (i=0; i<n; i++){
    B[i] = A[i];
    V[i] = false;
  }

  sort(B, B+n);

  for (i=0; i<n; i++) T[B[i]] = i;

  for (i=0; i<n; i++){
    if (V[i]) continue;
    int an = 0;
    int S = 0;
    int cur = i;
    int m = VMAX;
    while (1){
      V[cur] = true;
      an++;
      int v = A[cur];
      S += v;
      m = min(m, v);
      cur = T[v];
      if (V[cur]) break;
    }
    ans += min(S + (an - 2) * m, m + S + (an + 1) * s);
  }
  return ans;
}

int main(){
  s = VMAX;
  cin >> n;

  for (int i=0; i<n; i++){
    cin >> A[i];
    s = min(s, A[i]);
  }

  int ans = solve();
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3176
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n = ri()
    lh = rli()
    c = lh[0]
    ans = 0
    cur = 0
    for h in lh[1:]:
        ans = max(ans, cur)
        if h > c:
            cur = 0
        else:
            cur += 1
        c = h
    ans = max(ans, cur)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14480
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
struct Segment_Max {
private:
  int n;
  vector<int> node;
public:
  Segment_Max(vector<int> v) {
    int sz = v.size();
    n = 1; while(n < sz) n *= 2;
    node.resize(2*n-1, 0);
    for(int i=0; i<sz; i++) node[i+n-1] = v[i];
    for(int i=n-2; i>=0; i--) node[i] = max(node[2*i+1], node[2*i+2]);
  }
  void update(int x, int val) {
    x += (n - 1);
    node[x] = val;
    while(x > 0) {
      x = (x - 1) / 2;
      node[x] = max(node[2*x+1], node[2*x+2]);
    }
  }
  int getmax(int a, int b, int k=0, int l=0, int r=-1) {
    if(r < 0) r = n;
    if(r <= a || b <= l) return 0;
    if(a <= l && r <= b) return node[k];
    int vl = getmax(a, b, 2*k+1, l, (l+r)/2);
    int vr = getmax(a, b, 2*k+2, (l+r)/2, r);
    return max(vl, vr);
  }
};
int main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<vector<int>> chr(26, vector<int>(N, 0));
    REP(i, N) {
        chr[S[i] - 'a'][i] = 1;
    }
    vector<Segment_Max> segs;
    REP(i, 26) {
        segs.emplace_back(chr[i]);
    }
    int Q;
    cin >> Q;
    REP(q, Q) {
        int m;
        cin >> m;
        if(m == 1) {
            int id;
            cin >> id;
            char c;
            cin >> c;
            REP(i, 26) {
                segs[i].update(id-1, 0);
            }
            segs[c - 'a'].update(id-1, 1);
        } else {
            int l, r;
            cin >> l >> r;
            l--;
            int ans = 0;
            REP(i, 26) {
                ans += segs[i].getmax(l, r);
            }
            cout << ans << endl;
        }
    }
}

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

int main() {
  string S;
  cin >> S;
  int y=0, m=0, d=0;
  for (int i=0; i<4; i++) {
    y+=(S[i]-'0')*pow(10,3-i);
  }
  for (int i=0; i<2; i++) {
    m+=(S[i+5]-'0')*pow(10,1-i);
  }
  
  string ans="TBD";
  if (y<2019) {
    ans="Heisei";
  }
  else if (y==2019) {
    if (m<=4) {
      ans="Heisei";
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  string s;
  in6 k;
  cin >> k >> s;
  in6 size = s.size();
  if(size <= k) cout << s;
  else {
    rep(i,k) cout << s[i];
    cout << "...";
  }
 hinata;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;

ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll h,w;
	cin >> h >> w;
	vector <string> grid(h);
	for (int z=0;z<h;z++){
		cin >> grid[z];
	}
	vector <vector<ll>> hor(h,vector<ll>(w,0));
	vector <vector<ll>> ver(h,vector<ll>(w,0));
	for (int z=0;z<h;z++){
		ll c = 0;
		for (int x=0;x<w;x++){
			if (grid[z][x] == '.'){
				c++;
				hor[z][x] = c;
			} else {
				c = 0;
			}
		}
	}
	for (int z=0;z<h;z++){
		for (int x=w-2;x>-1;x--){
			if (hor[z][x] == 0) continue;
			hor[z][x] = max(hor[z][x],hor[z][x+1]);
		}
	}
	for (int x=0;x<w;x++){
		ll c = 0;
		for (int z=0;z<h;z++){
			if (grid[z][x] == '.'){
				c++;
				ver[z][x] = c;
			} else {
				c = 0;
			}
		}
	}
	for (int x=0;x<w;x++){
		for (int z=h-2;z>-1;z--){
			if (ver[z][x] == 0) continue;
			ver[z][x] = max(ver[z+1][x],ver[z][x]);
		}
	}

	ll ans = 0;
	for (int z=0;z<h;z++){
		for (int x=0;x<w;x++){
			ans = max(ans,hor[z][x]+ver[z][x]-1);
		}
	}
	cout << ans << endl;
	cin >> h;
}

Measured memory_bytes: 67200
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 8080
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD=1e9+7;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
int N,M;
int main(){
	ll A,B,C,K;
	cin>>A>>B>>C>>K;
	if(K%2==1){
		cout<<B-A<<endl;
	}else{
		cout<<A-B<<endl;
	}
}

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long N = lread();
    auto L = aryread();
    L.sort();
    long cnt;
    foreach (A; 0 .. N)
        foreach (B; A + 1 .. N)
        {
            long a = L[A];
            long b = L[B];
            long min_c = max(a - b, b - a);
            auto min_C = max(B + 1, L.bsearch(min_c) + 1);
            long max_c = a + b;
            auto max_C = min(N, L.bsearch(max_c));
            // writefln("%d %d %d", min_C, max_C, max(0, max_C - min_C));
            cnt += max(0, max_C - min_C + 1);
        }
    writeln(cnt);
}

long bsearch(T)(T[] ary, T key)
{
    long ok = 0;
    long ng = ary.length;
    while (1 < ng - ok)
    {
        long m = (ok + ng) / 2;
        if (ary[m] < key)
        {
            ok = m;
        }
        else
        {
            ng = m;
        }
    }
    return ok;
}


Measured memory_bytes: 380
//テスト
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
const ll MOD = 1000000007;
// const ll INF = 1000000000000000000LL;


int main(){
    int d;
    cin >> d;
    vector<int> c(26);
    rep(i,26) cin >> c[i];
    vector<vector<int>> s(d,vector<int>(26));
    rep(i,d){
        rep(j,26){
            cin >> s[i][j];
        }
    }
      ll sum=0;
      vector<int> last(26);
    //答え入れる配列
     vector<int> ans(d);
    //減少

    rep(i,d){
        ll nax=-INF;
        ll nax_i;
        rep(j,26){
            ll now_sum=0;
            now_sum+=s[i][j];
            last[j]=i+1;
            ll minus=0;
            rep(k,26){
                if(k!=j)
                    minus+=c[k]*(i+1-last[k]);
            }
            now_sum-=minus;
            if(nax<now_sum){
                nax_i = j;
                nax = now_sum;
            }
        }
        ans[i] = nax_i+1;
        last[nax_i] = i+1;
    }  
    rep(i,d){
        cout << ans[i] << endl;
    }
	return 0;   
}


Measured memory_bytes: 3656
import math
n,d=map(int,input().split())
x=[list(map(int,input().split())) for i in range(n)]
distance=0
ans=0

for i in range(n):
  for j in range(i+1,n):
    for k in range(d):
      distance+=(x[i][k]-x[j][k])**2
    if math.sqrt(distance).is_integer():
      ans+=1
    distance=0
print(ans)
    

Measured memory_bytes: 61568
#include <bits/stdc++.h>
using namespace std;
#define N 100001

int ans[N][3];

int main() {
    int n, a, b, c;

    cin >> n;

    int mass[N][3];

    for (int i = 0;i < n;i++) {
        cin >> a >> b >> c;

        mass[i][0] = a; mass[i][1] = b; mass[i][2] = c;
    }

    ans[0][0] = mass[0][0]; ans[0][1] = mass[0][1]; ans[0][2] = mass[0][2];

    //cout << ans[0][0] << " " << ans[0][1] << " " << ans[0][2] << endl;

    for (int i = 1;i < n;i++) {
        ans[i][0] = max(ans[i - 1][1], ans[i - 1][2]) + mass[i][0];
        ans[i][1] = max(ans[i - 1][0], ans[i - 1][2]) + mass[i][1];
        ans[i][2] = max(ans[i - 1][0], ans[i - 1][1]) + mass[i][2];

        //cout << ans[i][0] << " " << ans[i][1] << " " << ans[i][2] << endl;
    }

    cout << max(max(ans[n - 1][0], ans[n - 1][1]), ans[n - 1][2]);
}

Measured memory_bytes: 2688
package main

import (
	"fmt"
)

//const pi = math.Pi

func main() {
	var n, x int
	fmt.Scan(&n, &x)
	min := 1001
	for i := 0; i < n; i++ {
		var t int
		fmt.Scan(&t)
		x -= t
		if min > t {
			min = t
		}
	}
	fmt.Println(n + (x / min))
}

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


int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b && a != c && b != c)
    {
        cout << c << endl;
    }
    else if(a == c && a != b && c != b)
    {
        cout << b << endl;
    }
    else if(c == b && a != c && a != b)
    {
        cout << a << endl;
    }
    return 0;
}

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

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll x, k, d;
	cin >> x >> k >> d;
	x = abs(x);
	ll r = x % d;
	ll c = x / d;
	ll ans = min(c, k);
	k -= ans;
	x -= ans * d;
	if (k == 0)
		cout << x;
	else
	{
		if (k % 2 == 0)
			cout << x;
		else
			cout << abs(x - d);
	}
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {

    int numberOfHinaarare;
    cin >> numberOfHinaarare;
    bool isFour = false; // 黄色があれば4種類
    for (int indexOfHinaarare = 0; indexOfHinaarare < numberOfHinaarare; indexOfHinaarare++) {
        string colorOfHinaarare;
        cin >> colorOfHinaarare;
        if (colorOfHinaarare == "Y") {
            isFour = true;
            break;
        }
    }
    
    if (isFour) {
        cout << "Four" << endl;
    } else {
        cout << "Three" << endl;
    }
}

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

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

    int L = S.size();
    string last = "";
    int i = 0, K = 0;
    for(int i = 0; i < L; i++){
        string s = S.substr(i, 1);
        if(last == s && i < L-1) {
            s = S.substr(i, 2);
            i++;
        }
        if(last != s) K++;
        last = s;
    }

    cout << K << endl;
}

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

int main()
{
    string a, b;
    cin >> a >> b;
    int n = stoi(a + b);
    for (int i = 1; i * i <= n; i++)
    {
        if (i * i == n)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<set>
#include<cmath>
#include<queue>
#include<vector>
using namespace std;
priority_queue<int, vector<int>, greater<int> > q;
int n, T, a[150000],d = -1e9, mn = 1e9;
int main(){
	scanf("%d%d", &n, &T);
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
		d = max(a[i] - mn, d);
		mn = min(mn, a[i]);
	}
	int ans = 0;
	q.push(a[1]);
	for(int i = 2; i <= n; i++){
		if(a[i] - q.top() == d) {ans++;q.pop();}
		q.push(a[i]);
	}
	if(d<0) cout<<"1";
	else cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1276
process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

function Main(input) {

    var n = parseInt(input[0], 10);
    var ans = 1;
    for (var i = 1; i <= n; i++) {
        if (i * i > n) {
            ans = (i - 1) * (i - 1);
            break;
        }
    }

    console.log(ans);

    return 0;
}


Measured memory_bytes: 21320
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int H,W;
    cin >> H >> W;
    vector<vector<char>> data(H,vector<char>(W));
    for (int i=0;i<H;i++) {
        for (int j=0;j<W;j++) {
            cin >> data.at(i).at(j);
        }
    }
    for (int i=0;i<H;i++) {
        for (int j=0;j<W;j++) {
            int count=0;
            if (data.at(i).at(j) == '.') {
                for (int k=-1;k<2;k++) {
                    for (int l=-1;l<2;l++) {
                        if (i+k<0 || i+k>=H || j+l<0 || j+l>=W) {
                            continue;
                        }
                        else if (data.at(i+k).at(j+l) == '#') {
                            count++;
                        }
                    }
                
                }
                cout << count;
            }
            else {
                cout << '#';
            }
            
            
        }
        cout << endl;
    }
    
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

typedef long long ll;

const int MAXN=2e5+10;
const int MOD=2019;

string s;
int cnt[MOD]={1,0};
ll sum[MAXN]={0},p[MAXN]={1},tot=0;

void exgcd(const ll &a,const ll &b,ll &x,ll &y) {
	if(!b) {
		x=1,y=0;
		return ;
	}
	exgcd(b,a%b,y,x);
	y-=(a/b)*x;
}

int main() {
	cin>>s;
	for(int i=0,len=s.length(),num=0; i<len; ++i) {
		sum[i+1]=(sum[i]*10+s[i]-48)%MOD;
		p[i+1]=(10*p[i])%MOD;
	}
	for(ll i=1,len=s.length(),x,y; i<=len; ++i) {
		exgcd(p[i],MOD,x,y);
		if(x<0) x+=MOD;
		++cnt[sum[i]*x%MOD];
	}
	for(int i=0; i<MOD; ++i) tot+=1LL*cnt[i]*(cnt[i]-1)>>1;
	cout<<tot<<endl;
	return 0;
}

Measured memory_bytes: 6300
K=int(input())
if K!=10 and K!=792:
    exit()
def snuke(N):
    S=list(str(N))
    SN=0
    for i in S:
        SN+=int(i)
    return N/SN
def X(D,n):
    temp=(n+10**(D+1))//(10**(D+1))
    return 10**(D+1)*temp-1
L=[1]
k=1
for i in range(1,K):
    N=L[k-1]+1
    x=X(0,N)
    tmp=snuke(N)
    ans=N
    for d in range(len(str(N))):
        x=X(d,N)
        if snuke(x)<tmp:
            tmp=snuke(x)
            ans=x
    L.append(ans)
    k+=1
for i in L:
    print(i)


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;

void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int n;
    cin >> n;
    int a[n + 1];
    int b[n + 1];
    FOR(i, 1, n - 1) cin >> b[i];
    a[1] = b[1];
    a[n] = b[n - 1];
    int res = 0;
    FOR(i, 2, n - 1)
    {
        a[i] = min(b[i - 1], b[i]);
    }
    FOR(i, 1, n) res += a[i];
    cout << res;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define forin(in, n) for(int i=0; i<n; i++) cin>>in[i]
#define forout(out, n) for(int i=0; i<n; i++) cout<<out[i]<<endl;
using namespace std;

int main(){
    int A[3];
    forin(A, 3);
    sort(A, A+3);
    cout<<A[0]<<" "<<A[1]<<" "<<A[2]<<endl;
}



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



int main() {
  int n;
  cin>>n;
  int k;
  cin>>k;
  bool dp[k+2] ;
  int a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  for(int i=0;i<=k ;i++)
  {
    dp[i]=0;
  }

  for(int i=0;i<=k;i++)
  {
    for(int j=0;j<n;j++)
    {
      if(i-a[j]>=0  and dp[i-a[j]]==0)
      {
        dp[i]=1;
        break;
      }
    }
  }
  if(dp[k])
  cout<<"First"<<endl;
  else 
  cout<<"Second"<<endl;

}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  int n; cin>>n;
  vector<vector<int>> a(2,vector<int>(n));
  // vector<vector<int>> c(2,vector<int>(n));
  rep(j,2){
    rep(i,n){
      int A; cin>>A;
      if(j==0){
        if(i==0)
        a[j][i]=A;
        else
        a[j][i]=a[j][i-1]+A;
      }else{
        if(i==0)
        a[j][i]=a[j-1][i]+A;
        else
        a[j][i]=max(a[j-1][i],a[j][i-1])+A;
      }
    }
  }
  cout<<a[1][n-1]<<endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	H, W, h, w := nextInt(), nextInt(), nextInt(), nextInt()
	fmt.Println((H-h)*(W-w))
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,l,t;
    cin >> n >> l >> t;
    int arr[n],w[n];
    for (int i = 0; i < n; i++) cin >> arr[i] >> w[i];
    int finpos[n];
    for (int i = 0; i < n; i++){
        if (w[i] == 1) finpos[i] = (arr[i]+t)%l;
        else finpos[i] = (arr[i]+l-t%l)%l;
    }
    int start = 0;
    for (int i = 1; i < n; i++){
        if (w[i] != w[0]){
            int loop = t/l;
            int change = 2*loop;
            int timeleft = t-loop*l;
            if (w[0] == 1){
                int rem = arr[i]-arr[0];
                if (rem/2 < timeleft) change++;
                if ((rem+l)/2 < timeleft) change++;
                start = (start+change%n)%n;
            }
            else{
                int rem = l-arr[i]+arr[0];
                if (rem/2 < timeleft) change++;
                if ((rem+l)/2 < timeleft) change++;
                start = (start+n-change%n)%n;
            }

        }
    }
    int actpos[n];
    actpos[start] = finpos[0];
    sort(finpos,finpos+n);
    int newpos = 0;
    for (int i = 0; i < n; i++){
        if (finpos[i] == actpos[start]) {
            newpos = i;
            break;
        }
    }
    if (newpos < n-1 && finpos[newpos] == finpos[newpos+1] && w[0]== 2)newpos++;
    for (int i = 1; i < n; i++) actpos[(start+i)%n] = finpos[(newpos+i)%n];
    for (int i = 0; i < n; i++) cout << actpos[i] << "\n";
}



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

using namespace std;

typedef long long int ll;

ll n,m,a,b;

int main() 
{
  cin >>n>>m;
  vector <pair<ll,ll>> v;
  for(ll i=0;i<n;i++) 
  {
    cin >>a>>b;
    v.push_back(make_pair(a,b));
  }
  sort(v.begin(),v.end());
  ll sum=0,ans=0;
  for(ll i=0;i<n;i++)
  {
    ll k=m-sum;
    if(k>=0)
    {
       if(k>=v[i].second)
       {
         ans+=(v[i].second*v[i].first);
         sum+=v[i].second;
       }
       else
       {
         ans+=(k*v[i].first);
         sum+=k;
       }
    }
    else break;
  }
  cout <<ans<<endl;
}

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

int main(){
    unsigned long N, M;
    cin >> N >> M;
    class union_find{
        vector<long> parent, tree_size;
    public:
        union_find(unsigned long _n) : parent(_n), tree_size(_n, 1){
            for(unsigned long i = 0; i < _n; ++i){
                parent[i] = i;
            }
        }
        long find(long x){
            return parent[x] == x ? x : parent[x] = find(parent[x]);
        }
        bool marge(long a, long b){
            a = find(a);
            b = find(b);
            if(a == b)return false;
            if(tree_size[a] < tree_size[b])swap(a, b);
            tree_size[a] += tree_size[b];
            parent[b] = a;
            return true;
        }
    } uf{N};
    unsigned long ans{N};
    for(unsigned long i = 0, a, b, c; i < M; ++i){
        cin >> a >> b >> c;
        ans -= uf.marge(a - 1, b - 1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
import collections
N = int(input())
A = [int(x) for x in input().split()]

a = []
b = []
for i in range(N//2):
	a.append(int(A[i*2]))
	b.append(int(A[i*2+1]))

a = collections.Counter(a)
b = collections.Counter(b)

if a.most_common()[0][0] == b.most_common()[0][0] 	:
	if len(a) == 1:
		print(N//2)
	elif a.most_common()[0][1] == b.most_common()[0][1] 	:
		if a.most_common()[1][1] > b.most_common()[1][1]:
			print(N - a.most_common()[1][1] - b.most_common()[0][1])
		else:
		 	print(N - a.most_common()[0][1] - b.most_common()[1][1])
	elif a.most_common()[0][1] > b.most_common()[0][1]:
		print(N - a.most_common()[0][1] - b.most_common()[1][1]) 
	else:
		print(N - a.most_common()[1][1] - b.most_common()[0][1])
else:
	print(N - a.most_common()[0][1] - b.most_common()[0][1])


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

ll mod = 1000000007;

ll gcd(ll a, ll b){
  if (a%b == 0)return(b);
  else return(gcd(b, a%b));
}

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

  string s;
  cin >> s;
  rep(i,s.length()){
    if(s[i] == '?')s[i] = 'D';
  }
  cout << s << endl;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#define MOD 1000000007
#define INT long long int
#define REP(i,n) for(int(i)=0;(i)<(n);(i)++) 
using namespace std;
const long long INF = numeric_limits<long long>::max();


int main()
{
    int N;
    cin >> N;
    int A[N];
    REP(i,N) cin>>A[i];
    INT ans = 0;

    for (int i=0;i<N;i++){
        ans += A[i]/2;
        A[i] %= 2;
        if (i==N-1) break;
        if (A[i+1] <= A[i]){
            ans += A[i+1];
            A[i+1] = 0;
        }else{
            ans += A[i];
            A[i+1] -= A[i];
        }
    }
    cout << ans << endl;

    
    return 0;
}

Measured memory_bytes: 640
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

#n,m = [int(i) for i in readline().split()]
#d = [int(i) for i in readline().split()]

#文字p,文字q

res = [[0]*10 for _ in range(10)]

n = int(input())
for i in range(1,n+1):
    q = i%10
    r = i
    while r:
        p = r%10
        r //= 10
    #print(p,q,i)        
    res[p][q] += 1        

ans = 0
for p in range(1,10):
    for q in range(1,10):
        ans += res[p][q]*res[q][p]

print(ans)        
        

        
        
        
        

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define first fi;
#define second se;
using namespace std;
typedef pair<int, int> P;

int n;
string m[1010];
vector<int> d[1010];

void dfs(int id, int depth){
    rep(i, 0, depth) cout << ".";
    cout << m[id] << endl;
    rep(i, 0, d[id].size()){
        dfs(d[id][i], depth + 1);
    }
}

signed main(){
    cin >> n;
    rep(i, 0, n){
        int k;
        cin >> k >> m[i];
        if(k == 0) continue;
        d[k - 1].push_back(i);
    }
    dfs(0, 0);

}

Measured memory_bytes: 3368
h,w,k = map(int,input().split())

move = [[0 for i in range(w)] for j in range(w)]
from itertools import product
for bits in product([0, 1], repeat=w-1):
    flag = True
    for i in range(w-2):
        if bits[i] == 1 and bits[i+1] == 1:
            flag = False
    if not flag:
        continue

    for i in range(w):
        a = 0
        if i != 0:
            if bits[i-1] == 1:
                move[i][i-1] += 1
                a = 1
        if i != w-1:
            if bits[i] == 1:
                move[i][i+1] += 1
                a = 1
        if a == 0:
            move[i][i] += 1

dp = [[0 for i in range(w)] for j in range(h+1)]

dp[0][0] = 1
MOD = 10**9 + 7

for i in range(h):
    for j in range(w):
        for k1 in range(w):
            dp[i+1][k1] += dp[i][j] * move[j][k1]
            dp[i+1][k1] %= MOD


print(dp[-1][k-1])
    

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

const long long int mod = 1000000007LL;
bool f[114514] = {};
long long int ans = 1;
long long int n, k;

bool kansu( vector< vector< long long int > > & v, long long int p, long long int c0, long long int c1 ) {

//cout << " " << p << endl;
    long long int cc = k - c0 - c1;
    if ( cc <= 0 ) return false;
    ans *= cc;
    ans %= mod;
    f[p] = true;

    long long int cnt = 0;
    for ( long long int i = 0; i < v[p].size(); i++ ) {
        long long int q = v[p][i];
        if ( f[q] ) continue;
        if ( !kansu( v, q, 1, c0 + cnt ) ) return false;
        cnt++;
    }
    return true;

}

int main() {

    cin >> n >> k;

    vector< vector< long long int > > v;
    for ( long long int i = 0; i < n; i++ ) {
        vector< long long int > vv;
        v.push_back( vv );
    }

    for ( long long int i = 0; i < n - 1; i++ ) {
        long long int a, b;
        cin >> a >> b;
        a--;
        b--;
        v[a].push_back( b );
        v[b].push_back( a );
    }

    if ( kansu( v, 0, 0, 0 ) ) {
        cout << ans << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;

}


Measured memory_bytes: 9328
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, c, k;
    cin >> a >> b >> c;
    cin >> k;
    int sum = 0;
    if (k <= a)
    {
        sum += k * 1;
    }
    else
    {
        sum += a * 1;
        k -= a;
        if (k <= b)
        {
            sum += k * 0;
        }
        else
        {
            sum += b * 0;
            k -= b;
            if (k <= c)
            {
                sum += k * (-1);
            }
            else
            {
                sum += c * (-1);
            }
        }
    }
    cout << sum;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define int long long int
#define rep(a,b) for(int a=0;a<b;a++)
#define pb push_back
#define str string
#define INF
#define sf(a) scanf("%d",&a)
using namespace std;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,num,ans=0,b;
    char s,mae;
    str st;
    //vector<int> ans;
while(1){
    cin >> n;
    //cout << n;
    if(!n)break;
    cin >> num;
    cin >> st;
    int sum=0;
    bool ok=false;
    ans=0;
    for(int j=2;j<num;){
        if(num<j)break;
        if(st[j-2]=='I'&&st[j-1]=='O'&&st[j]=='I'){
            ok=true;
            sum++;
          //  cout << sum << "a";
            if(sum>=n){ans++;sum--;}
        }else{
            ok=false;
            sum=0;
        }
        j+=(ok)?2:1;
    }
    if(sum>=n){ans++;sum--;}
    cout << ans << endl;
}
return 0;
}

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

int main(){
  ll N;
  cin >> N;
  if (N == 0){
    cout << '0' << endl;
    exit(0);
  }
  
  vector<ll> bin(0);
  while (N != 1){
    ll amari = N % -2;
    if (amari >= 0){
      bin.push_back(amari);
      N /= -2;
    }
    else{
      bin.push_back(1);
      N /= -2;
      N += 1;
    }
  }
  bin.push_back(1);
  
  for (ll i = bin.size() - 1; i >= 0; i--){
    ll a = bin.at(i);
    cout << a;
  }
  cout << endl;
  
  /*ll a = N % -2;
  ll b = N / -2;
  cout << a << ' ' << b << endl;*/
}

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

if sum(A) < sum(B):
    print(-1)
    exit()

isgoukaku = True
fusokus = []
yobun = []

for a, b in zip(A, B):
    if a < b:
        # 不足点系列
        fusokus.append(b - a)
        isgoukaku = False
    else:
        # 余分な点系列
        yobun.append(a - b)
# print(fusokus, yobun)


if isgoukaku:
    print(0)
    exit()

fusoku = sum(fusokus)
yobun.sort(reverse=True)

henkou = len(fusokus)
# print(henkou)
tmp = 0
for y in yobun:
    # print(tmp, fusoku)
    if tmp >= fusoku:
        break
    tmp += y
    henkou += 1
    # print(henkou)

print(henkou)


Measured memory_bytes: 18356
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>
#include <stdio.h>

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
const ll INF = 1e15;
const ld eps = 1e-6;

int main() {
  ll N;
  vector<ll> A(3);
  cin >> N >> A[0] >> A[1] >> A[2];
  vector<ll> l(N + 3, -1);
  for (int i = 0;i < N;i++)
    cin >> l[i];
  sort(l.begin(), l.end());
  ll answer = INF;
  do {
    ll p = 0;
    ll ans = 0;
    for (int i = 0;i < 3;i++) {
      ll sum = 0;
      ll mp = -10;
      while (l[p] >= 0) {
	mp += 10;
	sum += l[p];
	p++;
      }
      p++;
      if (mp < 0)
	ans = INF;
      ans += abs(A[i] - sum) + mp;
    }
    answer = min(answer, ans);
    //    for(int i=0;i<l.size();i++)
    //  cout << l[i] << " ";
    //cout << ans << endl;
  } while (next_permutation(l.begin(), l.end()));
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 256