akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int X, Y, Z, K;
vector<long long> A, B, C;
long long tmp;


vector<long long> top_k(vector<long long>& a_vec, vector<long long>& b_vec, int k){
    vector<long long> prod_vec;
    for(auto itr = a_vec.begin(); itr != a_vec.end(); itr++){
        for(auto itr2 = b_vec.begin(); itr2 != b_vec.end(); itr2++){
            prod_vec.push_back((*itr) + (*itr2));
        }
    }
    sort(prod_vec.rbegin(), prod_vec.rend());
    vector<long long> ret_vec;
    for(int i = 0; i < k; i++){
        ret_vec.push_back(prod_vec[i]);
    }
    return ret_vec;
}


int main(){
    cin >> X >> Y >> Z >> K;
    for(int i = 0; i < X; i++){
        cin >> tmp;
        A.push_back(tmp);
    }
    for(int i = 0; i < Y; i++){
        cin >> tmp;
        B.push_back(tmp);
    }
    for(int i = 0; i < Z; i++){
        cin >> tmp;
        C.push_back(tmp);
    }

    vector<long long> tmp_ret = top_k(A, B, min(K, X * Y));
    vector<long long> ret = top_k(tmp_ret, C, K);
    for(auto itr = ret.begin(); itr != ret.end(); itr++){
        cout << *itr << endl;
    }
}


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

int main(){
	int N;
  	cin >> N;
  	double x;
  	string u;
  	double sum=0;
	for(int i = 0; i<N ;i++){
      	cin>> x>>u;
    	if(u=="JPY"){
        	sum +=x;
        }else if(u == "BTC"){
        	sum +=x*380000;
        }
    }
  	cout << sum << endl;


}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include <math.h>
#include<stdio.h>
#include <climits>
#include<algorithm>
#include<string>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define LL  long long 
#define Pi 3.14159265358979;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int i = 0, j = 0;//ループ用配列
	int n=0,m=0;
	int a[50] = {}, b[50] = {}, c[50] = {}, d[50] = {};
	int distance = 0;
	int ans = 1001001001,now=0;

	cin >> n >> m;
	rep(i,n) {
		cin >> a[i] >> b[i];
	}
	rep(i, m) {
		cin >> c[i] >> d[i];
	}

	rep(i, n) {
		ans = 1001001001;
		now = 0;
		rep(j, m) {
			distance = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			if (distance < ans) {
				ans = distance;
				now = j + 1;
			}
		}
		cout << now << "\n";
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

// #define int ll
#define REP(i,n) for (int i = 0; i < (n); ++i)
#define FORE(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define debug(x) cerr << #x << ": " << x << '\n'

const int MOD = (int)1e9 + 7;

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

    vector<int> vec(N);
    REP(i, N) {
        cin >> vec.at(i);
    }

    // 偶数indで、一番多いものに合わせる
    map<int, int> even_map;
    for(int i = 0; i < N; i+=2) {
        int val = vec[i];

        if (even_map.count(val) == 1) {
            even_map[val] += 1;
        } else {
            even_map[val] = 1;
        }
    }

    // 奇数indで、一番多いものに合わせる
    map<int, int> odd_map;
    for(int i = 1; i < N; i+=2) {
        int val = vec[i];

        if (odd_map.count(val) == 1) {
            odd_map[val] += 1;
        } else {
            odd_map[val] = 1;
        }
    }

    int odd_most_freq = -1;
    int odd_most_freq_cnt = 0;

    int odd_2nd_most_freq;
    int odd_2nd_most_freq_cnt = 0;

    for (auto x : odd_map){
        int key = x.first;
        int value = x.second;

        if (value > odd_most_freq_cnt) {
            odd_2nd_most_freq = odd_most_freq;
            odd_2nd_most_freq_cnt = odd_most_freq_cnt;

            odd_most_freq = key;
            odd_most_freq_cnt = value;
        } else if (value > odd_2nd_most_freq_cnt) {
            odd_2nd_most_freq = key;
            odd_2nd_most_freq_cnt = value;
        }
    }

    int even_most_freq = 0;
    int even_most_freq_cnt = 0;


    int even_2nd_most_freq;
    int even_2nd_most_freq_cnt = 0;
    for (auto x : even_map){
        int key = x.first;
        int value = x.second;
        debug(key);
        debug(value);

        if (value > even_most_freq_cnt) {
            even_2nd_most_freq = even_most_freq;
            even_2nd_most_freq_cnt = even_most_freq_cnt;

            even_most_freq = key;
            even_most_freq_cnt = value;
        } else if (value > even_2nd_most_freq_cnt) {
            even_2nd_most_freq = key;
            even_2nd_most_freq_cnt = value;
        }
    }

    // REP(i, N) {
    //     int v = vec.at(i);
    //     debug(v);
    // }

    debug(even_most_freq);
    debug(even_most_freq_cnt);
    debug(even_2nd_most_freq);
    debug(even_2nd_most_freq);

    debug(odd_most_freq);
    debug(odd_most_freq_cnt);
    debug(odd_2nd_most_freq);
    debug(odd_2nd_most_freq);

    int evens = N % 2 == 0 ? (N / 2) : (N+1) / 2;
    debug(evens);

    int ans_even = evens - even_most_freq_cnt;
    debug(ans_even);

    int odds = N / 2;
    debug(odds);

    int ans_odd = odds - odd_most_freq_cnt;
    debug(ans_odd);

    if (even_most_freq == odd_most_freq) {
        int a = odds - odd_2nd_most_freq_cnt + ans_even;
        int b = evens - even_2nd_most_freq_cnt + ans_odd;

        int c = a < b ? a : b;
        cout << c << endl;

        return 0;
    }

    cout << ans_even + ans_odd << endl;
}


Measured memory_bytes: 5376
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static long lcm (int a, int b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	static int[] setArray(int a) {
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		return b;
	}
	static String reverce(String str) {
		String strr="";
		for(int i=str.length()-1;i>=0;i--) {
			strr+=str.charAt(i);
		}
		return strr;
	}
	public static void main(String[] args) {
		int a=min(scan.nextInt(),scan.nextInt());
		int b=min(scan.nextInt(),scan.nextInt());
		System.out.println(a+b);
	}
}


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

#ifdef _MSC_VER
#pragma warning(disable:4996)
#endif

using namespace std;



int main() {

	int x, y, a, b, c;

	cin >> x >> y >> a >> b >> c;

	vector<int> a_apple(a);
	vector<int> b_apple(b);
	vector<int> c_apple(c);
	vector<int> x_apple(x);
	vector<int> y_apple(y);

	for (int i = 0; i < a; i++) {
		cin >> a_apple[i];
	}
	for (int i = 0; i < b; i++) {
		cin >> b_apple[i];
	}
	for (int i = 0; i < c; i++) {
		cin >> c_apple[i];
	}

	sort(a_apple.begin(), a_apple.end());
	sort(b_apple.begin(), b_apple.end());
	sort(c_apple.begin(), c_apple.end(), greater<int>());

	copy(a_apple.end()-x, a_apple.end(), x_apple.begin());
	copy(b_apple.end()-y, b_apple.end(), y_apple.begin());
	x_apple.push_back(2147483647);
	y_apple.push_back(2147483647);

	int x_i = 0, y_i = 0;
	for (int c_i = 0; c_i < c; c_i++) {
		if (x_apple[x_i] <= y_apple[y_i] && x_apple[x_i] < c_apple[c_i]) {
			x_apple[x_i] = c_apple[c_i];
			x_i++;
		}
		else if (x_apple[x_i] >= y_apple[y_i] && y_apple[y_i] < c_apple[c_i]) {
			y_apple[y_i] = c_apple[c_i];
			y_i++;
		}
	}

	x_apple.pop_back();
	y_apple.pop_back();

	long long value = 0;
	for (const auto& it : x_apple) {
		value += it;
	}
	for (const auto& it : y_apple) {
		value += it;
	}
	cout << value;
	return 0;
}

Measured memory_bytes: 2464
#include<iostream>
using namespace std;
 
 
main(){
	long long t=0;
	cin>>t;
	long long sum=0;
	for(long long i=0;i<=t;i++){
		if(i%3!=0 && i%5!=0)
		sum+=i;
	}
	cout<<sum;
 
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  int l,r;
  int x=0,y=n;
  rep(i,m){
    cin>>l>>r;
    chmax(x,l);
    chmin(y,r);
  }
  if(y-x+1<0){
    cout<<0<<'\n';
  }
  else{
    cout<<y-x+1<<'\n';
  }
  return(0);
}


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  private static final int A_CODE_POINT = "a".codePointAt(0);
  private static final int Z_CODE_POINT = "z".codePointAt(0);

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    String s = sc.next();
    String t = sc.next();
    Indexes[] sCharIndexes = new Indexes[Z_CODE_POINT + 1];
    for (int i = A_CODE_POINT; i <= Z_CODE_POINT; i++) {
      sCharIndexes[i] = new Indexes();
    }
    for (int i = 0; i < s.length(); i++) {
      int c = s.codePointAt(i);
      sCharIndexes[c].add(i);
    }
    CharIndexMap map = new CharIndexMap(sCharIndexes);
    boolean allContains = true;
    for (int i = 0; i < t.length(); i++) {
      allContains = allContains && map.hasCodePoint(t.codePointAt(i));
    }
    if (!allContains) {
      pw.println(-1);
      return;
    }
    long resetCount = 0;
    for (int i = 0; i < t.length(); i++) {
      int codePoint = t.codePointAt(i);
      if (!map.hasNext(codePoint)) {
        map.resetIndex();
        resetCount++;
      }
      map.next(codePoint);
    }
    pw.println((long) s.length() * resetCount + map.lastIndex + 1);
  }

  static class Indexes {

    List<Integer> indexes = new ArrayList<>();

    void add(Integer i) {
      indexes.add(i);
    }

    boolean hasIndexes() {
      return indexes.size() > 0;
    }

    int size() {
      return indexes.size();
    }

    int getIndex(int n) {
      return indexes.get(n);
    }
  }

  static class CharIndexMap {

    Indexes[] sCharIndexes;
    int[] arrayIndex;
    int lastIndex = -1;

    public CharIndexMap(Indexes[] sCharIndexes) {
      this.sCharIndexes = sCharIndexes;
      this.arrayIndex = new int[sCharIndexes.length];
      for (int i = 0; i < arrayIndex.length; i++) {
        arrayIndex[i] = 0;
      }
    }

    boolean hasCodePoint(int codePoint) {
      return sCharIndexes[codePoint].hasIndexes();
    }

    void resetIndex() {
      for (int i = 0; i < arrayIndex.length; i++) {
        arrayIndex[i] = 0;
      }
    }

    boolean hasNext(int codePoint) {
      if (!(arrayIndex[codePoint] < sCharIndexes[codePoint].size())) {
        return false;
      }
      for (int i = arrayIndex[codePoint]; i < sCharIndexes[codePoint].size(); i++) {
        if (sCharIndexes[codePoint].getIndex(i) > lastIndex) {
          arrayIndex[codePoint] = i;
          return true;
        }
      }
      return false;
    }

    void next(int codePoint) {
      int i = arrayIndex[codePoint];
      lastIndex = sCharIndexes[codePoint].getIndex(i);
      arrayIndex[codePoint] = i + 1;
    }
  }
}


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int x, n;
  cin >> x >> n;
  vi p(n);
  rep(i, n) cin >> p[i];
  // sort(p.begin(), p.end());
  int i1 = -1;
  int i2 = -1;
  int mn = INF;
  rep(i, 102) {
    int exist = false;
    rep(j, n) if (p[j] == i) exist = true;
    if (exist) continue;
    int d = abs(i - x);
    if (d < mn) {
      mn = d;
      i1 = i;
      dump(i, d, x, i1);
    }
  }
  if (i1 < 0) {
    cout << x << endl;
  } else {
    cout << i1 << endl;
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 3640
[a, b, c] = [int(x) for x in input().split()]
k = int(input())

# if a < c:
#     if c > b:
#         print('Yes')

#     elif b > c:
#         while k >0 :
#             c *= 2
#             k -= 1

#         if c > b:
#             print('Yes')
#         else:
#             print('No')

if c > b and b > a:
    print('Yes')

else:
    while b <= a and k > 0:
        b *= 2
        k -= 1

    if k < 0 and not(c > b and b > a):
        print('No')

    if c > b and b > a and k >= 0:
        print('Yes')

    else:
        while c <= b and k > 0:
            c *= 2
            k -= 1

        if k < 0 and not(c > b and b > a):
            print('No')

        if c > b and b > a and k >= 0:
            print('Yes')

        else:
            print('No')








Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_p(x) cerr<<#x": "<<(x).first<<' '<<(x).second<<endl
#define dbg_v(x, n) {cerr<<#x"[]: ";for(long long _=0;_<n;++_)cerr<<(x)[_]<<' ';cerr<<endl;}
#define all(v) v.begin(), v.end()
#define fi first
#define se second
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

template<typename T1, typename T2>
ostream& operator <<(ostream &out, const pair<T1, T2> &item) {
	out << '(' << item.first << ", " << item.second << ')';
	return out;
}

template <typename T>
ostream& operator <<(ostream &out, const vector<T>& v) {
	for(const auto &item : v) out << item << ' ';
	return out;
}

int main()
{
	ios_base::sync_with_stdio(false);

	int n, a;

	cin >> n;
	for(int i = 1; i <= n; ++i) {
		cin >> a;
		if(a % 2 == 0 && a % 3 && a % 5) return cout << "DENIED\n", 0;
	}

	cout << "APPROVED\n";

	return 0;
}



Measured memory_bytes: 256
def main():

    A, B, C, D = input_ints()

    while True:
        C -= B
        if C <= 0:
            print('Yes')
            break

        A -= D
        if A <= 0:
            print('No')
            break


def input_int():
    return int(input())


def input_ints():
    return map(int, input().split())


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


def input_int_tuple_list(n: int, q: int):
    return [tuple(map(int, input().split())) for _ in range(n)]


main()


Measured memory_bytes: 61684
package main

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

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func getFloat() float64 {
	sc.Scan()
	n, _ := strconv.ParseFloat(sc.Text(), 64)
	return n
}

func main() {
	sc.Split(bufio.ScanWords)
	n := getInt()

	t := make(map[string]float64, n)
	for i := 0; i < n; i++ {
		x := getFloat()
		sc.Scan()
		u := sc.Text()
		t[u] += x
	}

	y := t["JPY"]
	btc := t["BTC"] * 380000

	fmt.Println(y + btc)
}


Measured memory_bytes: 640
a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i
ans = 0

(0..a).each do |i|
  (0..b).each do |j|
    (0..c).each do |k|
      if 500 * i + 100 * j + 50 * k == x
        ans += 1
      end
    end
  end
end

puts ans

Measured memory_bytes: 3836
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <map>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
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; }

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    ll sum=0,now=a[0];
    rep(i,n){
        int tmp=now-a[i];
        if(tmp>0){
            sum+=tmp;
        }
        chmax(now,ll(a[i]));
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
#define IO std::ios::sync_with_stdio(false),cin.tie(0)

using namespace std;

int main() {
	int n,a[1000];
	cin >> n;
	int cnt = 0;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		if(i % 2 ==  1 && a[i]  % 2 == 1) cnt++;
	}
	
	cout << cnt << endl;
	return 0;
}


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

using namespace std;

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    string ans;
    int dx = tx - sx, dy = ty - sy;

    // 1周目→↑
    for (int i = 0; i < dx; ++i) ans += "R";
    for (int i = 0; i < dy; ++i) ans += "U";

    // 1周目←↓
    for (int i = 0; i < dx; ++i) ans += "L";
    for (int i = 0; i < dy; ++i) ans += "D";

    // 2周目↓→↑←
    ans += "D";
    for (int i = 0; i < dx + 1; ++i) ans += "R";
    for (int i = 0; i < dy + 1; ++i) ans += "U";
    ans += "L";

    // 2周目↓→↑←
    ans += "U";
    for (int i = 0; i < dx + 1; ++i) ans += "L";
    for (int i = 0; i < dy + 1; ++i) ans += "D";
    ans += "R";

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    long double x;
    cin >> x;
    cout << fixed << setprecision(10) << x * 2 * pi << '\n';
}


Measured memory_bytes: 3788
let partition a p r =
  let x = a.(r) in
  let swap i j = let t = a.(i) in a.(i) <- a.(j); a.(j) <- t
  in
  let rec doit i j =
    if j >= r then i
    else begin
      if a.(j) <= x then (swap (i + 1) j; doit (i + 1) (j + 1))
      else doit i (j + 1)
    end
  in
  let i = doit (p - 1) p in
  swap (i + 1) r;
  i + 1

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun e -> e)) in
  let k = partition a 0 (n - 1) in
  Array.iteri (fun i e ->
    Printf.printf (if i = 0 then "%d" else if i = k then " [%d]" else " %d") e) a;
  print_newline ()

Measured memory_bytes: 5316
#N,K = map(int,(input().split()))
N = int(input())
h = list(map(int,input().split()))


dp = [float("inf")]*len(h)
dp[0] = 0


for i in range(1, len(h)):
    dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]))


print(dp[N-1])

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

intl pow1(intl x,intl y){
	intl res=1;
	while(y){
		if(y%2){
			res*=x;
		}
		x*=x;
		y/=2;
	}
	return res;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	intl i,j,n;
	cin>>n;
	j=1;
	intl x=pow1(26,1);
	while(n>x){
		j++;
		n-=x;
		x=pow1(26,j);
	}
	// cout<<j<<"\n";
	string s="";
	string ans="";
	// vector<char> a/r(j);
	// vector<char> ans;
	// x-=pow1(26,j);
	for(i=0;i<j;i++){
		if(i==j-1){
			s+=('a'+n-1);
			break;
		}
		intl x1=pow1(26,j-i-1);
		intl m=n/x1;
		if(n%x1==0){
			m--;
		}
		s+=('a'+m);
		n-=(m*x1);
		// cout<<s[i];
	}
	cout<<s<<"\n";
}



Measured memory_bytes: 3580
#include <stdio.h>
#include <algorithm>
using namespace std;

int main()
{
    int n, si[300005];
    char str[300005];
    scanf("%d %s", &n, str);

    si[0] = (str[0] == 'E' ? 1 : 0);
    for(int i = 1; i < n; i++) 
        si[i] = si[i-1] + (str[i] == 'E' ? 1 : 0);
    
    int ans = si[n-1] - si[0];
    for(int i = 1; i < n; i++){
        ans = min(ans, (i+1-si[i])+(si[n-1]-si[i]));
    }

    printf("%d", ans);
    return 0;
}

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

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());

    int N, K;
    cin >> N >> K;
    long h[N];
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }

    sort(h, h+N);
    long min = LONG_MAX;
    for (int i = 0; i < N - K + 1; i++) {
        long h_dist = h[i+K-1] - h[i];
        if (h_dist < min) {
            min = h_dist;
        }
    }
    cout << min << endl;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

// original: https://qiita.com/keymoon/items/11fac5627672a6d6a9f6
class RollingHash {
  private:
    using ulint                        = unsigned long long;
    static constexpr ulint mask30      = (1ULL << 30) - 1;
    static constexpr ulint mask31      = (1ULL << 31) - 1;
    static constexpr ulint mod         = (1ULL << 61) - 1;
    static constexpr ulint positivizer = mod * ((1ULL << 3) - 1);
    static constexpr unsigned int base = 1033;
    int len;
    std::vector<ulint> pow_b, hash;
    static ulint mul(ulint l, ulint r) {
        const ulint lu        = l >> 31;
        const ulint ld        = l & mask31;
        const ulint ru        = r >> 31;
        const ulint rd        = r & mask31;
        const ulint middleBit = ld * ru + lu * rd;
        return ((lu * ru) << 1) + ld * rd + ((middleBit & mask30) << 31) + (middleBit >> 30);
    }
    static ulint calcMod(ulint val) {
        val = (val & mod) + (val >> 61);
        if (val > mod)
            val -= mod;
        return val;
    }

  public:
    template <typename T>
    RollingHash(const T &s) : len(s.size()), pow_b(s.size() + 1), hash(s.size() + 1) {
        pow_b[0] = 1;
        hash[0]  = 1;
        for (int i = 0; i < len; ++i) {
            pow_b[i + 1] = calcMod(mul(pow_b[i], base));
            hash[i + 1]  = calcMod(mul(hash[i], base) + s[i]);
        }
    }
    // hash for [l, r)
    ulint get(int l, int r) const { return calcMod(hash[r] + positivizer - mul(hash[l], pow_b[r - l])); }
    // length of longest common prefix
    int lcp(const RollingHash &rhs, int l1, int r1, int l2, int r2) const {
        int lb = 0, ub = std::min(r1 - l1, r2 - l2) + 1;
        while (ub - lb > 1) {
            const int md                                         = (lb + ub) >> 1;
            (get(l1, l1 + md) == rhs.get(l2, l2 + md) ? lb : ub) = md;
        }
        return lb;
    }
};

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    RollingHash rh(s);
    int ok     = 0;
    int ng     = n;
    auto check = [&](int m) {
        for (int i = 0; i < n; ++i) {
            for (int k = i + m; k < n - m + 1; ++k) {
                if (rh.get(i, i + m) == rh.get(k, k + m)) {
                    return true;
                }
            }
        }
        return false;
    };
    while (ok + 1 != ng) {
        int mid = (ok + ng) / 2;
        if (check(mid)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    cout << ok << "\n";
    return 0;
}

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

int main(){
  
  int num[3];
  cin >> num[0] >> num[1] >> num[2];
  sort(num,num+3);
  int ans = num[2]*10 + num[1] + num[0];
  cout << ans << endl;
  return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

const int N = 1e5+234;

int ar[N], br[N];

void solve() {
	int a, b, m; scanf("%d%d%d", &a, &b, &m);
	int mina = 2e9, minb = 2e9;
	for (int i = 0; i < a; ++i) {
		scanf("%d", ar+i);
		mina = min(mina, ar[i]);
	}
	for (int i = 0; i < b; ++i) {
		scanf("%d", br+i);
		minb = min(minb, br[i]);
	}
	int ans = mina+minb;
	for (int i = 0; i < m; ++i) {
		int x, y, c; scanf("%d%d%d", &x, &y, &c);
		--x; --y;
		ans = min(ans, ar[x]+br[y]-c);
	}
	printf("%d", ans);
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
using namespace std;
ll a,b,c,k;
int main(){
	cin>>a>>b>>c>>k;
	if(a>=k)
	{
		cout<<k<<endl;
		return 0;
	}
	if(a+b>=k)
	{
		cout<<a<<endl;
		return 0;
	}
	cout<<a-(k-(a+b))<<endl;
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int n, A[21];

bool solve(int i, int m){
    if(m == 0)  return true;
    if(i >= n)  return false;
    return solve(i+1, m)||solve(i+1,m-A[i]);
}

int main(){
    int q, m;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> A[i];
    }
    cin >> q;
    for(int i=0; i<q; i++){
        cin >> m;
        if(solve(0, m)) cout << "yes" <<endl;
        else    cout << "no" <<endl;
    }
    
    
    return 0;
}



Measured memory_bytes: 3112
H,N=map(int,input().split())
C=[0 for i in range(H+(10**4)+1)]
d=0
for i in [0]*N:
 A,B=map(int,input().split())
 for i in range(H+A+1):
  if A==i :
   C[i]=B
  elif A<i :
   if C[i]==0 and C[i-A]>0:
    C[i]=C[i-A]+B
   elif C[i-A]>0:
    C[i]=min(C[i],C[i-A]+B)
 d=max(d,A)
e=10**9
for i in range(H,H+d+1):
 if C[i]>0:
  e=min(C[i],e)
print(e)

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //3種類以上の文字があるなら確実にゲームを続けられる
    //2種類以下になったら絶対にゲームは終わる
    //2文字に対する終了状態は一意に定まらない…

    //考察を深めてみる
    //ゲームをなるべく長く続かせるのが最善。後一手でゲームが終わってしまうようになる手は打ちたくないので
    //stack使えば行けそうかな 先頭と二番目とこれから入れたい文字を見て、先頭を抜いて大丈夫そうならpop
    stack<char> st;
    int cnt = 0;
    string S; cin >> S;
    st.push(S[0]);
    st.push(S[1]);
    for(int i = 2; i < S.length(); i++){
        //出来る限り要素を取り除きたい
        if(st.size() <= 1) st.push(S[i]);
        else{
            char tp = st.top(); st.pop();
            while(true){
                if(st.empty()){
                    st.push(tp);
                    st.push(S[i]);
                    break;
                }
                else if(S[i] == st.top()){
                    st.push(tp);
                    st.push(S[i]);
                    break;
                }
                else{
                    cnt++;
                    tp = st.top(); st.pop();
                }
            }
        }
    }
    //cout << cnt << endl;
    if(cnt % 2) cout << "First" << endl;
    else cout << "Second" << endl;
    return 0;
}

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

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using namespace std;

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

    if (s == "Sunny") {
        cout << "Cloudy" << endl;
    }
    else if (s == "Cloudy") {
        cout << "Rainy" << endl;
    }
    else {
        cout << "Sunny" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        long[] a = Console.ReadLine().Split().Select(i => long.Parse(i)).ToArray();
        long[] l = new long[n];
        long[] r = new long[n];
        l[0] = 0;
        for (int i = 1; i < n; i++)
        {
            if (i == 1)
            {
                l[1] = a[0];
                continue;
            }
            l[i] = Gcd(l[i - 1], a[i - 1]);
        }
        r[n - 1] = 0;
        for (int i = n - 2; 0 <= i; i--)
        {
            if (i == n - 2)
            {
                r[n - 2] = a[n - 1];
            }
            r[i] = Gcd(r[i + 1], a[i + 1]);
        }

        List<long> ans = new List<long>();
        for (int i = 0; i < n; i++)
        {
            if (l[i] == 0) ans.Add(r[i]);
            else if (r[i] == 0) ans.Add(l[i]);
            else ans.Add(Gcd(l[i], r[i]));
        }
        Console.WriteLine(ans.Max());
    }

    static long Gcd(long a, long b)
    {
        long r = a % b;
        if (r == 0) return b;
        return Gcd(b, r);
    }
}

Measured memory_bytes: 26336
N = input()
L = len(N)
K = int(input())


def main(d, k):
    if (L - d) < k:
        return 0
    if N[d] == "0":
        return main(d + 1, k)
    if k == 1:
        return ((L - d) - 1) * 9 + int(N[d])
    elif k == 2:
        return (
            ((((L - d) - 1) * ((L - d) - 2)) // 2) * 81
            + ((L - d) - 1) * 9 * (int(N[d]) - 1)
            + main(d + 1, k - 1)
        )
    elif k == 3:
        return (
            ((((L - d) - 1) * ((L - d) - 2) * ((L - d) - 3)) // 6) * (9 ** 3)
            + ((((L - d) - 1) * ((L - d) - 2)) // 2) * 81 * (int(N[d]) - 1)
            + main(d + 1, k - 1)
        )


print(main(0, K))



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  double k;
 
  // 変数aで入力を受け取る
  cin >> n;
  double sum = 0;
 
  for(int i =0; i < n;i++){
  	cin >> k;

    sum += 100000000/k;
  }

  cout << 100000000/sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
  double a, s;
  while (cin >> a) {
    s = a;
    for (int i = 2; i <= 10; i++)
      if (i & 1) s += (a /= 3);
      else s += (a *= 2);
    cout << fixed << setprecision(8) << s << endl;
  }
}

Measured memory_bytes: 1280
#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
#define ll long long
#define cases ll t;cin>>t;while(t--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)


int main(){
    fast;
    ll i,j,n,k,m,x,y,cnt=1;
    cin>>n>>k;
    x=n%k;
    cout<<min(x,k-x);
    return 0;
}


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

using namespace std;

class B {
	int a, b, ans{ 0 };
public:
	void solve()
	{
		cin >> a >> b;

		string xs;
		for (int x{ a }; x <= b; x++)
		{
			xs = to_string(x);

			if (xs[0] == xs[4] && xs[1] == xs[3]) ans++;
		}

		cout << ans << endl;
	}
};


int main()
{
	B solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void GetAns(string s,int n) {

	n--;

	int maxInt = 0;
	for (int i = 0; i < s.size(); i++) {

		chmax(maxInt, (int)(s.at(i) - 'a'));
	
	}
	
	if (n == 1) {
		for (int i = 0; i <= maxInt + 1; i++) {
			string tmp_s = s + (char)(i + 'a');
			cout << tmp_s << endl;
		}
		
	}
	else {
		for (int i = 0; i <= maxInt + 1; i++) {
			string tmp_s = s + (char)(i + 'a');
			GetAns(tmp_s,n);
		}
	}

}

int main()
{
	int n; cin >> n;
	
	if (n == 1) {
		cout << "a" << endl;
		return 0;
	}

	GetAns("a",n);
	
	return 0;
}

Measured memory_bytes: 1536
object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val Array(datA, datB) = readLine.split(" ").map(_.toInt)
    var count = 0
    for(i <- datA to datB) {
      val strI = i.toString.split("").filterNot(_ == "")
      //println(strI(0) + "-" + strI(1) + "-" + strI(2) + "-" + strI(3) + "-" + strI(4))
      if((strI(0) == strI(4)) && (strI(1) == strI(3))) count += 1
    }

    println(count)
  }
}


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

int main(){
  int n = 0;
  
  cin >> n;
  
  if((n%1000)%111 == 0){
    cout << "Yes" << endl;
  }
  else if((n/10)%111 == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
/*
 * ID: ITP2_1_A
 * Problem: Vector
 */

#include <stdio.h>

int main(void)
{
    int a[200000];
    int n_query, index = 0;
    int i;

    scanf("%d", &n_query);
    for (i = 0; i < n_query; i++) {
        int query, sub;
        scanf("%d", &query);
        if (query != 2)
            scanf("%d", &sub);
        switch (query) {
            case 0: // pushBack(x)
                a[index++] = sub;
                break;
            case 1: // randomAccess(p)
                printf("%d\n", a[sub]);
                break;
            case 2: // popBack()
                index--;
                break;
        }
    }

    return 0;
}



Measured memory_bytes: 2516
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n;
	cin>>n;
	int h[111]={};
	FOR(i,0,n)cin>>h[i];
	int cnt=h[0];
	FOR(i,1,n){
		if(h[i]==h[i-1]){

		}else if(h[i]>h[i-1]){
			cnt+=h[i]-h[i-1];
		}else{

		}
	}
	cout<<cnt<<endl;
    return 0;
}


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

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

    vector<string> s(N);
    vector<int> t(N);
    rep(i, 0, N) cin >> s[i] >> t[i];
    string X; cin >> X;
    bool flag = 0;
    ll ans = 0;
    rep(i, 0, N){
        if(s[i] == X){
            flag = true;
        }else if(flag){
            ans += t[i];
        }
    }
    cout << ans << endl;
}

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

#define PQ priority_queue
#define P pair<int,int>
#define CLA(array) memset(array,0,sizeof array)
#define CLINF(array) memset(array,0x3f,sizeof array)
#define CLF(array) memset(array,-1,sizeof array)
#define DB(a) cout << "DEBUG " << a << endl;
#define rep(i,a,b) for(int i=(int)a;i<b;i++)
typedef long long LL;
typedef unsigned long long ULL;
const int MAXN = 100000 + 50;
const int INF = 1 << 30;

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

    return 0;
}

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

using namespace std;
int N;
int f[101];

int main(){
cin >> N;
for(int i = 0;i <N;i++){
int d;
cin >> d;
f[d] = 1;
}

int a = 0;

for(int i = 0;i < 101;i++){
a += f[i];
}
cout << a << endl;
}



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

#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n);i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
typedef long long ll;
typedef pair<int, int> pii;

const int N = 2e5 + 5;
ll benfit[N];
int add[N];
vi del[N];
ll ans;
int arr[N];
int n , m;

void solve(int st , int ed){
    if(st > ed)ed += m;
    ans += (ed - st);
    if(st+1 == ed)return;
    add[st+2]++;
    del[ed+1].pb(ed+1-(st+2));
}

int main()
{

#ifndef ONLINE_JUDGE
	//freopen("in.in", "r", stdin);
	//freopen("out.in", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    cin >> n >> m;
    loop(i,n)cin >> arr[i];
    loop(i,n-1)solve(arr[i],arr[i+1]);
    ll cur = 0;
    ll have = 0;
    range(i,1,m+m){
        for(int val : del[i])
            cur -= val , have--;
        have += add[i];
        cur += have;
        benfit[i > m ? i-m : i] += cur;
    }

    ans -= *max_element(benfit,benfit+m+2);
    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 9088
import collections
import math

n = int(input())
B = [1,3,6,10,15,21,28,36,45,55,66,78,91,105]
ans = 0

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True
if is_prime(n) == True:
  print(1)
  exit()

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

c = collections.Counter(prime_factorize(n))  
for v in c.values():
  for j in range(len(B)):
    if v < B[j]:
      ans += j
      break
      
print(ans)



Measured memory_bytes: 9440
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
typedef long long int llint;

int main(void){
  int n;
  std::cin >> n;

  int count = 0;
  int minimum = 10000000;
  for(int i=0; i<n; i++){
    int p;
    std::cin >> p;
    if(minimum >= p){
      minimum = p;
      count++;
    }
  }

  std::cout << count << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
n = int(input())
if 400 <= n <600:
    print("8")
elif 600 <= n < 800:
    print("7")
elif 800 <= n < 1000:
    print("6")
elif 1000 <= n < 1200:
    print("5")
elif 1200 <= n < 1400:
    print("4")
elif 1400 <= n < 1600:
    print("3")
elif 1600 <= n < 1800:
    print("2")
elif 1800 <= n < 2000:
    print("1")

Measured memory_bytes: 9188
from collections import Counter
n = int(input())
mat = []
for _ in range(n):
    s = input()
    s = ''.join(sorted(s))
    mat.append(s)
a = Counter(mat)
x = 0
for i in a:
    y = a[i]
    x += (y*(y-1))//2
print(x)

Measured memory_bytes: 19728
import sys
from collections import Counter
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    S=[input() for i in range(N)]
    c=Counter(S)
    mc=c.most_common()
    num=mc[0][1]
    ans=[]
    for t in mc:
        if t[1]==num:
            ans.append(t[0])
        else:
            break
    ans.sort()
    for a in ans:
        print(a)
        
    
        

if __name__ == '__main__':
    main()


Measured memory_bytes: 111432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////

int main(){
    ll n;
    cin>>n;
    ll a[10][10];
    rep(i,0,9){
        rep(j,0,9){
            a[i][j]=0;
        }
    }
    string s;
    string s1,s2;
    rep(i,1,n){
        s=to_string(i);
        s1=s[0];
        s2=s[s.size()-1];
        a[stoll(s1)][stoll(s2)]++;
        
    }
    ll ans=0;
    rep(i,0,9){
        rep(j,0,9){
            ans=ans+(a[i][j]*a[j][i]);
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int64_t n,k;
    cin >> n >> k;

    vector<bool> done(n*2);
    vector<vector<int>> paths;
    auto trace=[&](vector<int> &path,int i){
        for(;;){
            done[i]=true;
            path.push_back(i);
            if(i<n){
                i=n+i+k;
                if(i>=2*n) break;
            }else{
                i=i-n+k;
                if(i>=n) break;
            }
        }
    };
    rep(i,0,n){
        if(!done[i]){
            paths.push_back(vector<int>());
            trace(paths.back(),i);
        }
        if(!done[i+n]){
            paths.push_back(vector<int>());
            trace(paths.back(),i+n);
        }
    }

    int64_t mod=924844033;
    vector<vector<vector<int64_t>>> dp0;
    rep(i,0,paths.size()){
        vector<int> &path=paths[i];
        vector<vector<vector<int64_t>>> dp;
        dp.resize(path.size());
        dp=vector<vector<vector<int64_t>>>(path.size(),vector<vector<int64_t>>(path.size(),vector<int64_t>(2)));
        dp[0][0][0]=1;
        rep(j,1,path.size()){
            rep(k,0,path.size()){
                dp[j][k][0]=(dp[j-1][k][0]+dp[j-1][k][1])%mod;
                if(k>0) dp[j][k][1]=dp[j-1][k-1][0];
            }
        }
        dp0.push_back(dp[path.size()-1]);
    }

    vector<int64_t> dp1(2048);
    dp1[0]=1;
    rep(i,0,paths.size()){
        for(int j=n; j>0; --j){
            rep(k,1,paths[i].size()){
                if(j-k<0) continue;
                dp1[j]=(dp1[j]+dp1[j-k]*((dp0[i][k][0]+dp0[i][k][1])%mod)%mod)%mod;
            }
        }
    }

    vector<int64_t> fact(2048);
    fact[0]=1;
    rep(i,1,2048) fact[i]=fact[i-1]*i%mod;
    int64_t sum=0;
    rep(i,1,n+1) sum=(sum+(i%2==0?-1:1)*dp1[i]*fact[n-i]+mod)%mod;
    cout << (fact[n]-sum+mod)%mod << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 219396
/*                                  /   \                                 */      
/*                                 /*****\                               */
/*     Jai Shree Mataji           /       \ |\| |_| $ |-| K             */
#include<vector>
#include<iostream>
#include<algorithm>                
#include<string.h>                 
#include<bits/stdc++.h>            
#include<cstring>                  
#include<map>                     
#include<cmath>                  
#include<set>
using namespace std;            
#define ll long long int        
#define ld long double
#define MOD 1000000007 
#define PI 3.1415926535897932384626433832795                                               
#define YY cout<<"YES"
#define NN cout<<"NO"
#define ee cout<<"\n"
#define ne cout<<"-1"
#define pb push_back 
#define fi first
#define se second
#define mkp make_pair    
#define sall(v ) sort(v.begin(), v.end())      
#define all(v )  v.begin(), v.end()      
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define vl vector<ll>
#define vll vector< pair<ll,ll> > 
#define mpl map<ll, ll>
#define pr pair<ll,ll>
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b) {return (a.second < b.second); }
ll pow1(ll n,ll p){if(p==0)return 1;ll x=pow1(n, p/2);x=(x*x)%MOD;if(p%2==0) return x%MOD;else return (x*n)%MOD;}
ll pd(ll x,ll y){if(x%y==0) return x/y;else return x/y+1;}  
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);	
	  ll t=1;


//	   cin>>t;
	      while(t--)
{
//SUN, MON, TUE, WED, THU, FRI, or SAT.
ll n;
string s;
cin>>s;
if(s=="SUN")	
cout<<7;
else if(s=="MON")	
cout<<6;
else if(s=="TUE")	
cout<<5;
else if(s=="WED")	
cout<<4;
else if(s=="THU")	
cout<<3;
else if(s=="FRI")	
cout<<2;
else if(s=="SAT")	
cout<<1;
	
}
return 0;
}









Measured memory_bytes: 3592