akhauriyash/Code-Regression huggingface dataset:
import itertools
n,m=map(int,input().split())
edge=[[]for i in range(n+1)]

for i in range(m):
    a,b=map(int,input().split())
    edge[a].append(b)
    edge[b].append(a)
    
ans=0
for i in itertools.permutations(range(1,n+1)):
    if i[0]!=1:
        continue
    for j in range(n-1):
        if i[j+1] not in edge[i[j]]:
            break
    else:
        ans+=1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int ll;

int main(){
    ll n = 0, m = 0, k = 0;
    cin >> n >> m >> k;
    ll a[n+1] = {0}, b[m+1] = {0};
    for(int i = 1; i <= n; ++i){
        cin >> a[i];
    }
    for(int i = 1; i <= m; ++i){
        cin >> b[i];
        b[i] += b[i-1];
    }
    
    int j = m, ans = 0;
    ll total = 0;
    for(int i = 0; i <= n; ++i){
        if(i != 0)		total += a[i];
        if(total > k)   break;
        while(total + b[j] > k) --j;
        ans = max(ans, i+j);
    }

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


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> P(m), Y(m);
    for(int i=0; i<m; ++i) cin >> P[i] >> Y[i], --P[i];

    vector<vector<int>> vals(n);
    for(int i=0; i<m; ++i) vals[P[i]].push_back(Y[i]);

    for(int v=0; v<n; ++v) {
        sort(vals[v].begin(), vals[v].end());

        // 今回は不要だが、通常は数のダブリをなくす
        vals[v].erase(unique(vals[v].begin(), vals[v].end()), vals[v].end());
    }

    for(int i=0; i<m; ++i) {
        int v = P[i];
        printf("%06d", v+1);

        // 座標圧縮して導いた答え
        int id = lower_bound(vals[v].begin(), vals[v].end(), Y[i]) - vals[v].begin();
        printf("%06d\n", id+1);
    }

}

Measured memory_bytes: 7808
#include <stdio.h>
#define N 100
int main(){
  int array[N][N];
  int i,j,n,u,k,v;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<N;j++){
      array[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      array[u][v]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j) printf(" ");
      printf("%d",array[i][j]);
    }
    printf("\n");
      }
  return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
typedef pair<int, int> Pii;
const int INF = (1<<30);

int main()
{
  vector<Pii> v(6); // a:0, b:1, w:2, x:3, y:4, z:5
  string s;

  v[0].fr = 3;   v[0].sc = 4;
  v[1].fr = 4;   v[1].sc = 3;
  v[2].fr = 1;   v[2].sc = 4;
  v[3].fr = INF; v[3].sc = 5;
  v[4].fr = 3;   v[4].sc = INF; 
  v[5].fr = 2;   v[5].sc = 1;

  while( cin >> s, s != "#" ) {
    int now = 0;

    for(int i=0; i<s.size(); i++) {
      if( now == INF ) {
	break;
      }

      if( s[i] == '0' ) {
	now = v[now].fr;
      } else {
	now = v[now].sc;
      }
    }
  
    if( now == 1 ) cout << "Yes" << endl;
    else cout << "No" << endl;
  }	

  return 0;
}

Measured memory_bytes: 1180
from fractions import gcd

n, m = map(int, input().split())
s = input()
t = input()
g = gcd(n, m)
l = n * m // g

for i in range(g):
    if s[i*n//g] != t[i*m//g]:
        print(-1)
        break
else: print(l)


Measured memory_bytes: 5432
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <unordered_set>

 
using namespace std;
 
int main(int argc, const char * argv[]) {
    for (int i = 0; i < 5; i++) {
        int x;
        cin >> x;
        if (x == 0) {
            cout << i + 1;
            break;
        }
    }
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   	ll n;
   	cin >> n;
   	cout << (n/500)*1000+(n%500)/5*5<<"\n";
    return 0;
}

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

class MainClass : Scanner
{
    static void Main()
    {
        long x = RLong();
        long ans = 0;
        ans += (x / 11)*2;
        x %= 11;
        var s = new List<int>() { 6, 5};
        for (int i = 0; i < 3; i++)
        {
            if (x <= 0) break;
            x -= s[i];
            ans++;
           
        }
        WriteLine(ans);
    }
}

class Scanner
{
    public static int RInt() => int.Parse(Console.ReadLine());
    public static long RLong() => long.Parse(Console.ReadLine());
    public static string RString() => Console.ReadLine();
    public static double RDouble() => double.Parse(Console.ReadLine());

    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static string[] RStrings() => Console.ReadLine().Split();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static T1 ReadStream<T1>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        return r1;
    }
    public static (T1, T2) ReadStream<T1, T2>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        return (r1, r2);
    }
    public static (T1, T2, T3) ReadStream<T1, T2, T3>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        return (r1, r2, r3);
    }
    public static (T1, T2, T3, T4) ReadStream<T1, T2, T3, T4>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        var r4 = (T4)Convert.ChangeType(r[3], typeof(T4));
        return (r1, r2, r3, r4);
    }
}

Measured memory_bytes: 27856
#include <stdio.h>
#include <string.h>

int main(){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a==b){
    printf("%d\n",c);
  }else if(b==c){
    printf("%d\n",a);
  }else{
    printf("%d\n",b);
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef pair<int,int> P;

int n;
int h[20], w[20];
int brd[7][7];
int dp[(1<<16)];

int main(){
	rep(i,(1<<16)) dp[i] = INF;
	dp[0] = 0;
	cin >> n;
	rep(i,n) cin >> h[i] >> w[i];
	for(int i = 3; i < 7; i++) for(int j = 3; j < 7; j++){
		char c;
		cin >> c;
		if(c == 'R') brd[i][j] = 1;
		if(c == 'G') brd[i][j] = 2;
		if(c == 'B') brd[i][j] = 3;
	}
	queue<int> que;
	que.push(0);
	while(!que.empty()){
		int q = que.front();
		int Q = q;
		que.pop();
		int b[7][7];
		rep(i,7) rep(j,7) b[i][j] = 0;
		for(int i = 3; i < 7; i++) for(int j = 3; j < 7; j++){
			b[i][j] = (q&1);
			q >>= 1;
		}
		q = Q;
		rep(i,n){
			rep(j,7){
				rep(k,7){
					if(j+h[i] < 3 || k+w[i] < 3) continue;
					//{
						int l = -1;
						rep(hh,h[i]){
							if(j+hh >= 7) continue;
							rep(ww,w[i]){
								if(k+ww >= 7) continue;
								if(b[j+hh][k+ww] == 0 && brd[j+hh][k+ww] != 0){
									l = brd[j+hh][k+ww];
									break;
								}
							}
						}
						if(l == -1) continue;
						bool ok = true;
						rep(hh,h[i]){
							if(j+hh >= 7) continue;
							rep(ww,w[i]){
								if(k+ww >= 7) continue;
								if(b[j+hh][k+ww] == 0 && brd[j+hh][k+ww] != 0 && brd[j+hh][k+ww] != l){
									ok = false;
									break;
								}
							}
							if(!ok) break;
						}
						if(!ok) continue;
						int x = 0;
						for(int hh = 6; hh >= 3; hh--){
							for(int ww = 6; ww >= 3; ww--){
								if(j <= hh && hh < j+h[i] && k <= ww && ww < k+w[i]){
									x *= 2;
									x += 1;
								} else{
									x *= 2;
									x += b[hh][ww];
								}
							}
						}
						if(dp[x] > dp[q]+1){
							dp[x] = dp[q]+1;
							que.push(x);
							if(x == (1<<16)-1){
								queue<int> emp;
								swap(que,emp);
							}
						}
					//}
				}
			}
		}
	}
	cout << dp[(1<<16)-1] << endl;
}

Measured memory_bytes: 1652
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

	Scanner sc = new Scanner(System.in);

	void run() {
		int n = sc.nextInt();
		int a[] = new int[n];
		for(int i =0 ; i<n;i++){
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		
		
		int ab[] = new int[2];
		for(int i = 0; i< n ;i++){
			ab[i&1] += a[n-i-1];
		}
		System.out.println(ab[0]-ab[1]);
	}
}


Measured memory_bytes: 21716
#[allow(unused_macros)]
macro_rules! input {
        (source = $s:expr, $($r:tt)*) => {
            let mut iter = $s.split_whitespace();
            let mut next = || { iter.next().unwrap() };
            input_inner!{next, $($r)*}
        };
        ($($r:tt)*) => {
            let stdin = std::io::stdin();
            let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
            let mut next = move || -> String{
                bytes
                    .by_ref()
                    .map(|r|r.unwrap() as char)
                    .skip_while(|c|c.is_whitespace())
                    .take_while(|c|!c.is_whitespace())
                    .collect()
            };
            input_inner!{next, $($r)*}
        };
    }

#[allow(unused_macros)]
macro_rules! input_inner {
        ($next:expr) => {};
        ($next:expr, ) => {};

        ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
            let $var = read_value!($next, $t);
            input_inner!{$next $($r)*}
        };

        ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
            let mut $var = read_value!($next, $t);
            input_inner!{$next $($r)*}
        };
    }

#[allow(unused_macros)]
macro_rules! read_value {
        ($next:expr, ( $($t:tt),* )) => {
            ( $(read_value!($next, $t)),* )
        };

        ($next:expr, [ $t:tt ; $len:expr ]) => {
            (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        };

        ($next:expr, chars) => {
            read_value!($next, String).chars().collect::<Vec<char>>()
        };

        ($next:expr, bytes) => {
            read_value!($next, String).into_bytes()
        };

        ($next:expr, usize1) => {
            read_value!($next, usize) - 1
        };

        ($next:expr, $t:ty) => {
            $next().parse::<$t>().expect("Parse error")
        };
    }

fn main() {
    input! {
            tap: i32,
            need: i32,
        }

    let answer = ((need as f64 - 1f64) / (tap as f64 - 1f64)).ceil();

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

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

      ll i,k,h,j,n,m;
    cin>>n>>m;
    if(n==1||m==1)
    {
        cout<<1<<endl;
        exit(0);
    }
    if((n*m)&1)
    cout<<((n*m)/2)+1;
   else cout<<((n*m)/2);



    return 0;


}


Measured memory_bytes: 764
//
//  abc151_a.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
ll mod = 998244353;
ll INF = 1000000007;
#define PI 3.14159265


int main() {
  char c;
  std::cin >> c;

  std::cout << char(c+1) << std::endl;

  return 0;
}

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

int main(){
	int Q,c,a,n;
	cin>>Q;

	while(Q--){
		cin>>c>>a>>n;
		int cnt=0;
		while(1<=n && 1<=c && 1<=a){
			c--;a--;n--;
			cnt++;
		}
		while(1<=a && 2<=c){
			c-=2;a--;
			cnt++;
		}
		while(3<=c){
			c-=3;
			cnt++;
		}
		cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 3096
// https://atcoder.jp/contests/dp/tasks/dp_h
#include <bits/stdc++.h>
#define fi first
#define se second
#define forn(i, n) for (int i = 0; i < (int)n; ++i)
#define for1(i, n) for (int i = 1; i <= (int)n; ++i)
#define fore(i, l, r) for (int i = (int)l; i <= (int)r; ++i)
#define ford(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define fored(i, l, r) for (int i = (int)r; i >= (int)l; --i)
#define pb push_back
#define el '\n'
#define d(x) cout << #x << " " << x << el
#define ri(n) scanf("%d", &n)
#define vec vector
using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<char, int> pci;
typedef tuple<int, int, int> tiii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

const int MAXN = 1e5 + 200;
const double PI = acos(-1);
const double EPS = 1e-10;
const int MOD = 1e9 + 7;
int dr[] = {1, -1, 0, 0, 1, -1, -1, 1}; // trick to explore an implicit 2D grid
int dc[] = {0, 0, 1, -1, 1, 1, -1, -1};

int main() {
  int N;
  cin >> N;
  double prob[N + 1], mem[N + 1] = {0}, mem2[N + 1] = {0}, acum(0);
  

  forn(i, N) cin >> prob[i+1];

  mem[0] = 1 - prob[1];
  mem[1] = prob[1];
  for (int i = 2; i <= N; ++i) {
    mem2[i] = mem[i - 1] * prob[i];
    for (int j = 1; j < i; ++j) 
      mem2[j] = (mem[j] * (1 - prob[i])) + (mem[j - 1] * prob[i]);
    
    mem2[0] = mem[0]*(1 - prob[i]);
    
    forn(i, N+1)
      mem[i] = mem2[i];
  }

  for (int i = (N / 2)+1; i <= N; ++i)
    acum += mem[i];

  // forn(i, N+1)
    // cout << mem2[i] << " ";
  // cout << el;
  printf("%.10f\n", acum);
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

int main() {
  int N,Q;
  string S;
  cin>>N>>S>>Q;
  vector<set<int>> info(26);
  rep(i,N) {
    int num = S[i] - 'a';
    info[num].insert(i);
  }
  while(Q-->0) {
    int typ;cin>>typ;
    if(typ==1) {
      int p;char c;
      cin>>p>>c;
      p--;
      info[S[p]-'a'].erase(p);
      info[c - 'a'].insert(p);
      S[p] = c;
    } else {
      int l,r;cin>>l>>r;
      l--;r--;
      int cnt = 0;
      rep(i,26) {
	auto it = info[i].lower_bound(l);
	//	cout<<i<<" "<<*it<<endl;
	if(it != info[i].end()) if(*it <= r) cnt++;
      }
      cout<<cnt<<endl;
    }
  }
}


Measured memory_bytes: 27208
#include <iostream>
#include <vector>
#include <map>
#include <tuple>
#include <queue>
using namespace std;

//const int MYINTMAX=2147483647;

void decompose(long num, map<long,int>& data){
    long a=2;
    long tmp = num;
    //long maxv = num*num;
    //while(num >= a && a*a <= tmp){
    vector<char> v(1000000000000,0);
    while(tmp >= a){
        //cout << a << " " << tmp << endl;
        if(tmp%a==0){
            data[a] = data[a]+1;
            tmp /= a;
        }else{
            a++;
        }
    }
}

int main(){

    long N;
    cin >> N;

    long tmp = N;
    long n = 0;
    for(long i=2;i<=tmp;i++){
        int kosuu = 0;
        while(tmp%i==0){
            tmp = tmp/i;
            kosuu++;
        }
        //cout << tmp << endl;
        int j=1;
        while(kosuu>=j){
            kosuu-=j;
            j++;
            n++;
        }

        if(tmp==1) break;
        if(i>1000000){
            cout << n+1 << endl;
            return 0;
        }
    }

    cout << n << endl;

    return 0;
}


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

int main()
{
	int i = 0;
	int value = 0;
	int count = 0;
	char val_char[5] = {0};

	scanf("%d", &value);
        sprintf(val_char, "%d", value);
	//printf("value=%s\n",val_char);

	for(i = 0; i < 4; i++) {
            if(val_char[i] == 0x32) {
            	count++;
            }
	}

	printf("%d\n",count);
	return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
H = list(map(int, input().split()))

INF = 10000000000
dp = [INF]*N
dp[0] = 0

for i in range(N):
    for k in range(1, K+1):
        if i + k < N:
            dp[i + k] = min(dp[i + k], dp[i] + abs(H[i] - H[i + k]))

print(dp[N-1])

Measured memory_bytes: 52448
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <ctime>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P a, const P b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int main() {
    int n;
    while(cin >> n) {
        if(n == -1) break;
        P ret = P(1,0);
        rep(i,0,n-1) {
            P un1 = (ret * P(0, 1)) / abs(ret);
            ret += un1;
        }
        cout << ret.X << endl;
        cout << ret.Y << endl;
    }
    return 0;
}

Measured memory_bytes: 1252
H, W = map(int, input().split())
ans = H * W
area = H * W
if H % 3 == 0 or W % 3 == 0:
    print(0)
else:
    for i in range(1, H):
        kari = W * i
        if (H - i) % 2 == 0 or W % 2 == 0:
            kari_2 = (area - kari) // 2
            ans = min(ans, abs(kari-kari_2))
        else:
            kari_2 = (W // 2 + 1) * (H-i)
            kari_3 = (W // 2) * (H-i)
            ans = min(ans, max(kari, kari_2, kari_3)-min(kari, kari_2, kari_3))
    for j in range(1, W):
        kari = H * j
        if (W - j) % 2 == 0 or H % 2 == 0:
            kari_2 = (area - kari) // 2
            ans = min(ans, abs(kari-kari_2))
        else:

            kari_2 = (H // 2 + 1) * (W-j)
            kari_3 = (H // 2) * (W-j)
            ans = min(ans, max(kari, kari_2, kari_3)-min(kari, kari_2, kari_3))
    ans = min(ans, W, H)

    print(ans)


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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 *1000 + 7;
const LL LINF = INF * (LL)INF;



int main()
{
	//freopen("in.txt","r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	int a, b;
	cin>>a>>b;
	if (a <= 0 && b >= 0)
	{
		cout<<"Zero"<<endl;
		return 0;
	}

	if (b < 0)
	{
		int cnt = (b - a + 1);
		if (cnt & 1)
		{
			cout<<"Negative"<<endl;
			return 0;
		}
	}

	cout<<"Positive"<<endl;

}


Measured memory_bytes: 256
use std::io::Write;

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn main() {
    let n: usize = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        s.parse().unwrap()
    };

    let mut a = vec![vec![0; 10]; 10];
    for i in 1..10 {
        for j in 1..10 {
            a[i][j] = calc(i, j, n);
        }
    }

    // for v in a.iter() {
    //     debugln!("{:?}", v);
    // }

    let mut ans = 0;
    for i in 1..10 {
        for j in 1..10 {
            ans += a[i][j] * a[j][i];
        }
    }
    println!("{}", ans);
}

fn calc(a: usize, b: usize, n: usize) -> usize {
    let str_n = n.to_string();
    let len = str_n.len();
    let chars_n: Vec<char> = str_n.chars().collect();

    if len == 1 {
        if a == b && a <= n {
            return 1;
        } else {
            return 0;
        }
    }

    // 以後len >= 2

    let mut ret = 0;
    for i in 1..len {
        if i == 1 {
            if a == b {
                ret += 1;
            }
        } else {
            ret += 10usize.pow(i as u32 - 2);
        }
    }
    // debugln!("ret1: {}", ret);

    let d = n / 10usize.pow(len as u32 - 1);
    let rest = n - d * 10usize.pow(len as u32 - 1);
    if a < d {
        ret += 10usize.pow(len as u32 - 2);
        // debugln!("ret2: {}", ret);
    } else if a == d {
        ret += count_1_a(b, rest);
        // debugln!("ret3: {}", ret);
    }

    ret
}

// 末尾がa
fn count_1_a(a: usize, n: usize) -> usize {
    let str_n = n.to_string();
    let len = str_n.len();

    // debugln!("a: {}, n: {}", a, n);

    if len == 1 {
        if a <= n {
            return 1;
        } else {
            return 0;
        }
    }

    // 以後len >= 2

    let d = n / 10usize.pow(len as u32 - 1);
    let rest = n - d * 10usize.pow(len as u32 - 1);

    let mut ret = 0;
    ret += d * 10usize.pow(len as u32 - 2);
    ret += count_1_a(a, rest);

    ret
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_count_1_a() {
        assert_eq!(1, count_1_a(1, 10));
        assert_eq!(1, count_1_a(2, 10));
        assert_eq!(2, count_1_a(1, 20));
        assert_eq!(10, count_1_a(1, 100));
    }

    #[test]
    fn test_calc() {
        assert_eq!(1, calc(1, 1, 9));
        assert_eq!(0, calc(1, 2, 9));
        assert_eq!(2, calc(1, 1, 99));
        assert_eq!(1, calc(1, 2, 99));
        assert_eq!(2, calc(1, 1, 20));
        assert_eq!(1, calc(1, 1, 10));
        assert_eq!(1, calc(1, 2, 12));
        assert_eq!(0, calc(1, 2, 11));
        assert_eq!(0, calc(3, 1, 25));
    }
}


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

  ll xx=100;

  int i=1;
  while(true){

    xx=xx+(xx-xx%100)/100;
//    cout << xx << endl;

    if(xx>=x) break;
    i++;
  }
  cout << i << endl;
  return 0;
}

Measured memory_bytes: 3624
N, Y = gets.split(' ').map{|n| n.to_i}
catch :done do
  a = 0
  while a <= N do
    b = 0
    while b <= N - a do
      if Y == 10000 * a + 5000 * b + 1000 * (N - a - b)
        puts "#{a} #{b} #{N - a - b}"
        throw :done
      end
      b += 1
    end
    a += 1
  end
  puts '-1 -1 -1'
end

Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
#define     LL      long long int
queue<LL>q;
vector<LL>v;
int main()
{
    LL n;
    cin>>n;
    LL bf=n/500;
    cout<<1000*bf+((n%500)/5)*5<<endl;



     return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main(){
	int n;
	cin>>n;
	vector<int> a(n+1);
	vector<int> b(n);
	lli ans = 0;
	for(int i = 0;i<n+1;i++){
		cin>>a[i];
	}
	for(int i = 0;i<n;i++){
		cin>>b[i];
	}
	for(int i =0;i<n;i++){
		if(a[i] <= b[i]){
			b[i]-=a[i];
			ans+=(lli)a[i];
			a[i] = 0;
		}
		else if(a[i] > b[i]){
			ans+=(lli)b[i];
			a[i]-=b[i];
			b[i] = 0;
			
		}
		if(a[i+1] <= b[i]){
			b[i]-=a[i+1];
			ans+=(lli)a[i+1];
			a[i+1] = 0;
		}
		else if(a[i+1] > b[i]){
			ans+=(lli)b[i];
			a[i+1]-=b[i];
			b[i] = 0;
			
		}
	}
	cout<<ans;
	return 0;

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000000
int dp(int i);
int n,k;
int h[100009],memo[100009];

int main(){
  memset(memo,-1,sizeof(memo));
  cin>>n>>k;
  for(int i=0;i<n;i++)cin>>h[i];
  cout<<dp(0)<<endl;
  return(0);
}

int dp(int i){
  int rec=INF;
  if(memo[i]!=-1)return memo[i];
  if(i==n-1)return 0;
  for(int j=1;j<=k;j++){
    if(i+j<n)rec=min(rec,dp(i+j)+abs(h[i]-h[i+j]));
  }
  return memo[i]=rec;
}


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

#define MAXN 40010
#define X first
#define Y second

typedef long long ll;



int main()
{
	//freopen("in.in", "r", stdin);
	//freopen("out.out", "w", stdout);
	
	int n, x, cnt0 = 0, cnt1 = 0, cnt2 = 0; 
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
	{
		scanf("%d", &x);
		if (x & 1) ++cnt0;
		else if (x % 4 == 0) ++cnt2;
		else ++cnt1;
	}
	if (cnt2 >= cnt0) puts("Yes");
	else if (cnt2 == cnt0 - 1) puts(cnt1? "No":"Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
  int32_t A, B, C;
  std::cin >> A >> B >> C;
  if ((A <= C && C <= B) || (B <= C && C <= A)) {
    std::cout << "Yes" << std::endl;
    return 0;
  }

  std::cout << "No" << std::endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a > b){
            System.out.println("a > b");       
        }else if(a < b){
            System.out.println("a < b");
        }else{
            System.out.println("a == b");
        } 
    }
}


Measured memory_bytes: 26332
k=int(input())
s=input()

U=2*10**6+1
mod=10**9+7

fact=[1]*(U+1)
fact_inv=[1]*(U+1)

for i in range(1,U+1):
    fact[i]=(fact[i-1]*i)%mod
fact_inv[U]=pow(fact[U],mod-2,mod)

for i in range(U,0,-1):
	fact_inv[i-1]=(fact_inv[i]*i)%mod

def comb(n,k):
    if k<0 or k>n:
        return 0
    x=fact[n]
    x*=fact_inv[k]
    x%=mod
    x*=fact_inv[n-k]
    x%=mod
    return x
m=len(s)
ans=0
for i in range(k+1):
    ans=(ans+pow(25,i,mod)*comb(m+i-1,m-1)*pow(26,k-i,mod))%mod
print(ans)

Measured memory_bytes: 122896
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <cstdio>
#include <numeric>
#include <functional>

using namespace std;
typedef long long ll;

ll N;
vector<ll> a;
int main()
{
    cin >> N;
    a.resize(N);

    ll x = 0;
    for(int i = 0;i < N;i++)
    {
        cin >> a[i];
        x ^= a[i];
    }
    for(int i = 0;i < N;i++)
    {
        ll ans = x ^ a[i];
        cout << ans << endl;
    }
    return 0;
}

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

#define NL '\n'
#define C char
#define D double
#define F float
#define S string
#define sz(x) x.size()
#define INF LONG_LONG_MAX
#define PI (2.0*acos(0.0))
#define sfi(x) scanf("%d",&x)
#define sfi2(x,y) scanf("%d %d",&x,&y)
#define sfi3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sfl(x) scanf("%lld",&x)
#define sfl2(x,y) scanf("%lld %lld",&x,&y)
#define sfl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sfd(x) scanf("%lf",&x);
#define max3(a,b,c) max(a,max(b,c))
#define max4(a,b,c,d) max(max3(a,b,c),d)
#define min3(a,b,c) min(a,min(b,c))
#define min4(a,b,c,d) min(a,min3(b,c,d))
#define mem(ara,val) memset(ara,val,sizeof(ara))
#define READ freopen("input.txt","r",stdin)
#define WRITE freopen("output.txt","w",stdout)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;

/*LL gcd(LL a,LL b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
LL lcm(LL a,LL b)
{
    return a/gcd(a,b)*b;
}*/

/*bool pal (S s)
{
    bool flag = true;
    for(int i=0; i<sz(s); i++)
    {
        if(s[i]!=s[sz(s)-i-1])
        {
            flag = false;
            break;
        }
    }
    if(flag) return true;
    else return false;
}*/

int main()
{
    int arr[3];
    cin>>arr[0]>>arr[1]>>arr[2];
    sort(arr,arr+3);
    if (arr[0]==arr[1] && arr[1]==arr[2])cout<<"No"<<NL;
    else if(arr[0]!=arr[1] && arr[1]!=arr[2])cout<<"No"<<NL;
    else cout<<"Yes"<<NL;



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a1,a2,b1,b2;
    cin>>a1>>a2>>b1>>b2;
    if(a1<b1)
    {
            if(a2<b2)
            {
                if(a2<=b1) cout<<0<<endl;
                else cout<<a2-b1<<endl;
            }
            else
            {
                if(b2<=b1) cout<<0<<endl;
                else cout<<b2-b1<<endl;
            }
    }
    else if(a1>=b1)
    {
            if(a2<b2)
            {
                if(a2<=a1) cout<<0<<endl;
                else cout<<a2-a1<<endl;
            }
            else
            {
                if(b2<=a1) cout<<0<<endl;
                else cout<<b2-a1<<endl;
            }
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    int N; cin >> N;
    vector<vector<int>> points(2 * N, vector<int>(2 * N, 0));
    vector<pair<int, int>> blue(N);
    rep(i, N){
        int a, b;
        cin >> a >> b;
        points[a][b] = 1;
    }
    rep(i, N){
        int a, b;
        cin >> a >> b;
        blue[i] = make_pair(a, b);
    }

    int ans = 0;
    sort(all(blue));
    rep(k, N){
        int x = blue[k].first, y = blue[k].second;
        bool flag = false;
        for(int j = y; j >= 0; j--){
            for(int i = x; i >=0; i--){
                if(points[i][j] == 1){
                    ans++;
                    points[i][j] = 0;
                    flag = true;
                    break;
                }
            }
            if(flag == true) break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1; // Initialize result 
  
    // Update x if it is more than or 
    // equal to p 
    x = x % p;  
  
    while (y > 0) { 
        // If y is odd, multiply x with the result 
        if (y & 1) 
            res = (res * x) % p; 
  
        // y must be even now 
        y = y >> 1; // y = y/2 
        x = (x * x) % p; 
    } 
    return res; 
} 
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	int a,b,c,d,k;
	cin>>a>>b>>c>>d>>k;
	ll t=0;
	if(c>=a){
		t = 60*(c-a) + d-b;
	}
	else{
		t = (24-c)*60 -d;
		t += a*60 + b;
	}
	cout<<t-k<<endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define F first
#define S second
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
using ll = long long;
using pi = pair<int,int>;
int main()
{
  int h,w; cin >> h >> w;
  vector<vector<char>> s(h, vector<char>(w));
  rep(i,h) rep(j,w) cin >> s[i][j];

  vector<vector<int>> L(h, vector<int>(w));
  vector<vector<int>> R(h, vector<int>(w));  
  vector<vector<int>> U(h, vector<int>(w));
  vector<vector<int>> D(h, vector<int>(w));

  rep(i,h) {
    int cnt = 0;
    rep(j,w) {
      if(s[i][j] == '.') cnt++;
      else cnt = 0;
      L[i][j] = cnt;
    }
  }

  rep(i,h) {
    int cnt = 0;
    rep(j,w) {
      if(s[i][w-1-j] == '.') cnt++;
      else cnt = 0;
      R[i][w-1-j] = cnt;
    }
  }  

  rep(j,w) {
    int cnt = 0;
    rep(i,h) {
      if(s[i][j] == '.') cnt++;
      else cnt = 0;
      U[i][j] = cnt;
    }
  }

  rep(j,w) {
    int cnt = 0;
    rep(i,h) {
      if(s[h-1-i][j] == '.') cnt++;
      else cnt = 0;
      D[h-1-i][j] = cnt;
    }
  }  

  int res = 0;
  rep(i,h) {
    rep(j,w) {
      if(s[i][j] == '.') {
	chmax(res, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3);
      }
    }
  }
  cout << res << "\n";
  
  return 0;
}


Measured memory_bytes: 69984
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define int long long
#define INF 1000000000000000000
using namespace std;

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
template<typename T>
void debug(vector<vector<T>> m){ REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;} }



signed main(){

    int H, W; cin >> H >> W;
    vector<string> a(H);
    readv(a);

    mat ans1(H, vec(W, 0)), ans2(H, vec(W, 0));
    REP(i, H){
        ans1[i][0] = 1;
        ans2[i][W - 1] = 1;
    }
    REP(i, H){
        if(i % 2 == 0){
            FOR(j, 1, W - 1) ans1[i][j] = 1;
        }
        else{
            FOR(j, 1, W - 1) ans2[i][j] = 1;
        }
    }
    REP(i, H) FOR(j, 1, W - 1) if(a[i][j] == '#'){
        ans1[i][j] = 1;
        ans2[i][j] = 1;
    }

    REP(i, H){
        REP(j, W){
            if(ans1[i][j]) cout << '#';
            else cout << '.';
        }
        cout << endl;
    }
    cout << endl;
    REP(i, H){
        REP(j, W){
            if(ans2[i][j]) cout << '#';
            else cout << '.';
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define FAST ios_base::sync_with_stdio(false);cin.tie(0);
    const double EPS = 1e-9;
    const double PI = acos(-1);
    const int knightDir[8][2] = {{-2,-1},{-2,1},{-1,2},{1,2},{2,-1},{2,1},{-1,-2},{1,-2}};
    //const int dx[]={0,0,0,1,1,1,-1,-1,-1};
    //const int dy[]={-1,0,1,-1,0,1,-1,0,1};
    const int dx[] = {0 , 1 , 0 , -1};
    const int dy[] = {1 , 0 , -1 , 0};
    //#define MOD         1000000007LL
    #define MAX         1000005
    const ll MOD = 1000000000 + 7;
    
    int main()
    {
        FAST
        int t;
        t = 1;

        while(t--)
        {
           ll x , k , d;
           
           cin >> x >> k >> d;
           
           x = abs(x);
           ll steps = x / d;
           
           ll l = abs(0 - (x - (steps * d)));
           ll r = abs(0 - (x - ((steps + 1) * d)));
           
           if(steps >= k)
           {
               cout << abs(0 - (x - (k * d))) << endl;
           }
           else
           {
               if((k - steps) % 2 == 0)cout << l << endl;
               else cout << r << endl;
           }
        }
    }



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

const ll INF = 1LL << 60;

ll N, M;
vector<P> v;

// 宝箱を開ける時に必要な最小コスト
ll dp[5000];

int main() {
    cin >> N >> M;
    v.resize(M);
    rep(i, M) {
        ll a, b;
        cin >> a >> b;

        int s = 0;
        rep(j, b) {
            ll c;
            cin >> c;
            c--;
            s |= (1 << c);
        }
        // s を開けるのに a 円必要
        v[i] = P(s, a);
    }

    rep(i, 5000) dp[i] = INF;
    sort(v.begin(), v.end());

    // rep(i, v.size()) {
    //     cout << v[i].first << " " << v[i].second << endl;
    // }
    // return 0;

    dp[0] = 0;


    for (int j = 0; j < M; j++) {
        for (int i = 0; i < (1 << N); i++) {
            // 使う
            ll idx = v[j].first;
            ll cost = v[j].second;

            // cout << cost << " " << idx << endl;
            dp[i | idx] = min(dp[i | idx],  dp[i] + cost);
        }
    }

    if (dp[(1 << N) - 1] == INF) {
        cout << -1 << endl;
    } else {
        cout << dp[(1 << N) - 1] << endl;
    }
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef pair<int,int> P;

int main(){
  ll n;
  cin >> n;
  ll ans = 1e12+5;
  for(ll i = 1;i*i<=n;i++){
    if(n%i==0)chmin(ans,i+n/i-2);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
/* ex3_4
   moka223711 */

#include <stdio.h>

int main(void){
	int num, d = 0;
	scanf("%d", &num);

	// Nを1から9で割って、余りが0かつ商が9以下になっているものを探す
	// 割れるものが見つかったらdを1に変える
	for(int i = 1; i <= 9; i++){
    	if(num % i == 0 && num / i <= 9){
        	d = 1;
			break;
		}
	}
	
	// 上のfor文で1から9で割り切れるものが見つかったときd == 1となっているため
	// if文が実行される、なかったときはelse文の実行
	if(d){
		printf("Yes");
	}
	else{
		printf("No");
	}
  
	return 0;
}


Measured memory_bytes: 128
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    assert_eq!(!0usize, std::usize::MAX); //🙊
    assert!(0 == 0); //😇
    let (a, b) = (io.read::<usize>(), io.read::<usize>());
    io.writeln((a + b) % 24);
}

static MX: usize = 1010101;
static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


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

using namespace std;

#ifndef ONLINE_JUDGE
  #define pr_debug(...) do { printf("DEBUG: line %d: %s: ", __LINE__, __PRETTY_FUNCTION__); printf(__VA_ARGS__); } while(0)
  #define pr_vars(...) do { pr_debug(" "); pr_var(split(#__VA_ARGS__, ',').begin(), __VA_ARGS__); } while(0)
#else
  __attribute__ ((constructor)) static void fast_cin() { ios_base::sync_with_stdio(false); cin.tie(0); }
  #define pr_debug(...) do { } while(0)
  #define pr_vars(...) do { } while(0)
#endif /* ONLINE_JUDGE */

using ll = int64_t;
using ull = uint64_t;

template<typename T> ostream &operator<< (ostream &fout, const vector<T> &vec)
{ for (const auto &el : vec) fout << el << ' '; return fout; }

template<typename T> istream &operator>> (istream &fin, vector<T> &vec)
{ for (size_t i = 0; i < vec.size(); i++) fin >> vec[i]; return fin; }

vector<string> split(const string &s, char c) { vector<string> v; ull st = 0, fn = 0, lvl = 0;
for ( ; fn < s.size(); fn++ ) { if (s[fn] == c && lvl == 0) { v.push_back(s.substr(st, fn - st)); st = fn + 1; }
if (s[fn] == '(') { lvl++; } if (s[fn] == ')') { lvl--; } } v.push_back(s.substr(st, fn - st)); return v; }

void pr_var(vector<string>::iterator it) { (void) it; cout << endl; }
template<typename T, typename... Args> void pr_var(vector<string>::iterator it, T a, Args... args)
{ cout << *it << "=" << a << "  "; pr_var(++it, args...); }

ll div_ceil(ll n, ll d) { ll res = n / d; if (res >= 0) res += n % d ? 1 : 0; return res; }
ll gcd(ll a, ll b) { a = llabs(a); b = llabs(b); while (a && b) a > b ? a %= b : b %= a; return a + b; }
ll lcm(ll a, ll b) { ll c = gcd(a, b); return c == 0 ? 0 : llabs(a / c * b); }

#define setp(a) fixed << setprecision(a)
const double PI = acos(-1.0);
constexpr double EPS = 1e-9;
constexpr double INF = 2e18;

using mp = pair<ll, ll>;
using mt = tuple<ll, ll, ll>;    // unpack: tie(ll, ll, ll) = mt;

constexpr ll MAX = 1e5 + 5;

int main()
{
    ll res = 0;
    ll n, a, b; cin >> n >> a >> b;
    for (ll i = 1; i <= n; i++) {
        string s = to_string(i);
        ll sum = 0;
        for (auto c: s)
            sum += c - '0';
        if (sum >= a && sum <= b)
            res += i;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long mod = 1e9+7;


int main(){
    long double ans=0;
    long double n,k;
    cin>>n>>k;
    if(n>k){
        ans = (n-k+1)/n;
        for(int i=1;i<k;i++){            
            int p2 = ceil(log2(k/i));  
            ans += (1.0/n)*(long double)pow(0.5,p2);
        }
    }
    else{
        for(int i=1;i<=n;i++){
            int p2 = ceil(log2(k/i));            
            ans += (1.0/n)*(long double)pow(0.5,p2);
            // cout<<ans<<' ';
        }
    }
    cout<<fixed<<setprecision(20)<<ans;

}

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

template <class T>
using V = vector<T>;

template <class T>
using VV = V<V<T>>;

template <class T>
using P = pair<T, T>;

int main() {
    int N;
    cin >> N;
    VV<int> abc(N, V<int>(3));
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> abc[i][j];
        }
    }

    VV<int> DP(N + 1, V<int>(3));
    for (int i = 0; i < N; ++i) {
        // i -> i + 1への遷移
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue;
                DP[i + 1][k] = max(DP[i + 1][k], DP[i][j] + abc[i][k]);
            }
        }
    }

    cout << *max_element(DP[N].begin(), DP[N].end()) << endl;
    return 0;
}

Measured memory_bytes: 14072
//Zory-2019
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<bitset>
#include<vector>
#include<algorithm>
#include<iostream>
#include<deque>
// #include<unordered_map>
using namespace std;
int bin[40],lg[1<<21];
namespace mine
{
	typedef long long ll;
	#define double long double
	const int INF=0x3f3f3f3f;
	const ll LLINF=0x3f3f3f3f3f3f3f3fll;
	ll qread()
	{
		ll ans=0;char c=getchar();int f=1;
		while(c<'0' or c>'9') {if(c=='-') f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num)
	{
		if(num<0) {num=-num;putchar('-');}
		if(num>9) write(num/10);
		putchar('0'+num%10);
	}
	void writeln(int num){write(num);puts("");}
	#define FR first
	#define SE second
	#define MP make_pair
	#define pr pair<int,int>
	#define PB push_back
	#define vc vector
	inline void chmax(int &x,const int y) {x=x>y?x:y;}
	inline void chmin(int &x,const int y) {x=x<y?x:y;}
	const int MAX_N=2100;
	const int MOD=1e9+7;
	void add(int &x,int y) {x+=y;if(x>=MOD) x-=MOD;if(x<0) x+=MOD;}

	int K;
	vector<int> son[MAX_N];
	int dis[MAX_N],siz[MAX_N];
	int ans=0;
    int f[MAX_N][MAX_N];//f(x,now)=【保证不过x的路径<=K，大小为now】下，子树到x的最大距离
	void solve(int x,int fa)
	{
		f[x][1]=0;siz[x]=1;
		for(int t=0;t<(int)son[x].size();t++)
		{
			int y=son[x][t];if(y==fa) continue;
			solve(y,x);siz[x]+=siz[y];
			for(int all=siz[x];all>=1;all--) for(int b=1;b<=siz[y] and b<=all;b++)
				if(f[x][all-b]+f[y][b]+1<=K) chmin(f[x][all],max(f[x][all-b],f[y][b]+1));
		}
		for(int i=siz[x];i>=1;i--) if(f[x][i]<=K) chmax(ans,i);
	}
	void main()
	{
		int n=qread();K=qread();
		for(int i=1;i<n;i++)
		{
			int x=qread(),y=qread();
			son[x].PB(y);son[y].PB(x);
		}
		memset(f,0x3f,sizeof f);
		solve(1,0);write(n-ans);
	}
};
int main()
{
	srand(time(0));
	bin[0]=1;for(int i=1;i<=30;i++) bin[i]=bin[i-1]<<1;
	lg[1]=0;for(int i=2;i<(1<<21);i++) lg[i]=lg[i>>1]+1;
	mine::main();
}


Measured memory_bytes: 25856
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    if (N >= 2 && M >= 2) {
        cout << (N - 2) * (M - 2) << endl;
    } else if (N == 1 && M == 1) {
        cout << 1 << endl;
    } else {
        cout << max(N, M) - 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256