akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        int[][] act = new int[N][3];
        
        for(int i=0; i<N; i++) {
            String[] input = br.readLine().split(" ");
            act[i][0] = Integer.parseInt(input[0]);
            act[i][1] = Integer.parseInt(input[1]);
            act[i][2] = Integer.parseInt(input[2]);
        }
        
        System.out.println(getMaxPoints(act));
    }

    private static int getMaxPoints(int[][] act) {
        int[] dp1 = new int[3];
        int[] dp2 = new int[3];
        
        for(int i=0; i<dp1.length; i++) {
            dp1[i] = act[0][i];
        }
        
        copyArray(dp1, dp2);
        
        for(int i=1; i<act.length; i++) {
            dp1[0] = act[i][0] + Math.max(dp2[1], dp2[2]);
            dp1[1] = act[i][1] + Math.max(dp2[0], dp2[2]);
            dp1[2] = act[i][2] + Math.max(dp2[0], dp2[1]);
            
            copyArray(dp1, dp2);
        }

        return Math.max(dp1[0], Math.max(dp1[1], dp1[2]));
    }
    
    private static void copyArray(int[] dp1, int[] dp2) {
        for(int i=0; i<dp1.length; i++) {
            dp2[i] = dp1[i];
        }
    }
}


Measured memory_bytes: 59992
hako=list(map(int,input().split()))
hk=[]
A=hako[0]*hako[2]
B=hako[0]*hako[3]
C=hako[1]*hako[2]
D=hako[1]*hako[3]
hk.append(A)
hk.append(B)
hk.append(C)
hk.append(D)
hk.sort()
print(hk.pop())

Measured memory_bytes: 9188
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
const ll MAXN=1e5+10;
const ll MOD=1e9+7;
ll pri[MAXN],jud[MAXN],phi[MAXN]={0,1},cnt;
ll qpow(ll a,ll b){
    ll res=1,rem=a;
    while(b){
        if(b&1) res=(res*rem)%MOD;
        rem=(rem*rem)%MOD;
        b>>=1;
    }
    return res;
}
void euler(ll len){
    for(ll i=2;i<=len;i++){
        if(!jud[i]){
            pri[cnt++]=i;
            phi[i]=(i-1)%MOD;
        }
        for(ll j=0;j<cnt&&i*pri[j]<=len;j++){
            jud[i*pri[j]]=1;
            if(i%pri[j]==0){
                phi[i*pri[j]]=phi[i]*pri[j];
                break;
            }
            phi[i*pri[j]]=phi[i]*phi[pri[j]];
        }
    }
}
int main(){
    ll n,k;scanf("%lld %lld",&n,&k);
    euler(k);
    ll res=0;
    for(ll i=1;i<=k;i++) res=(res+qpow(k/i,n)*phi[i])%MOD;
    printf("%lld\n",res);
    return 0;
}


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

typedef signed long long ll;

int main() {
    int a, b;
    string op;
    cin >> a >> op >> b;
    if(op[0] == '+')
        cout << (a + b) << endl;
    else 
        cout << (a - b) << endl;
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  while(s != "0") {
    int sum = 0;
    rep(i,s.size()) {
        sum += s[i] - '0';
    }
    cout << sum << endl;
    cin >> s;
  }

  return 0;
}



Measured memory_bytes: 3144
program abc165d
      implicit none
      integer(8)::a,b,n,m,i,ans=0

         read *, a,b,n

         m=n/b
         if (ans<f(m*b-1)) ans=f(m*b-1)
         if (ans<f(n)) ans=f(n)

         print *, ans
         stop

   contains
      function f(x)
         implicit none
         integer(8),intent(in)::x
         integer(8)::f,s,t

            if (x<0) then
               f=-1
               return
            end if
            s=a*x/b
            t=x/b
            f=s-a*t
            return
      end function

   end program abc165d

Measured memory_bytes: 2804
#include<iostream>
void swap(int *x,int *y){
	int z=*x;
	*x=*y,*y=z;
}
int main(){
	using namespace std;
	int n,a,b,c;
	cin>>n;
	while(n--){
		cin>>a>>b>>c;
		if(b<c)swap(b,c);
		if(a<b)swap(a,b);
		if(b<c)swap(b,c);
		if((a*a)==(b*b)+(c*c))cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1152
import sys


def in_ctrl():
    _input = [_.rstrip() for _ in sys.stdin.readlines()]
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    N = int(_input[0])
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    return N


def out_ctrl(s):
    print(s)


if __name__ == "__main__":
    N = in_ctrl()
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    n = list(map(int,list(str(N))))
    flag = False
    for _ in n:
        if _ == 7:
            flag=True
            break
    s = 'Yes' if flag else 'No'
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    out_ctrl(s)

Measured memory_bytes: 61736
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long n,cou,ans,k;
  cin>>n;
  vector<long> vec(n);
  for(int i=0; i<n; i++){
    cin>>vec.at(i);
  }
  ans=10000000000;
  for(int i=1; i<101; i++){
    cou=0;
    for(int j=0; j<n; j++){
      k=vec.at(j)-i;
      cou=cou+k*k;
    }
    ans=min(cou,ans);
  }
  cout<<ans;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

void dout() { cerr << '\n'; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << " " << H;
    dout(T...);
}

#ifdef LOCAL
    #define dbg(...) cerr << #__VA_ARGS__, dout(__VA_ARGS__)
#else
    #define dbg(...) ;
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

const int N = 200003, M = 1000000, MOD = 998244353;
int n, a[N], cnt[M + 3], s[M + 3], mob[M + 3], val[M + 3], lp[M + 3];
vector <bool> prime(M + 3, true);
vector <int> primes;

int binpow(int x, int y) {
    int res = 1;
    while (y > 0) {
        if (y & 1) {
            res = (ll)res * x % MOD;
        }
        x = (ll)x * x % MOD;
        y /= 2;
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif

    prime[0] = prime[1] = false;
    for (int i = 2; i <= M; i++) {
        if (prime[i]) {
            primes.pb(i);
            lp[i] = i;
        }
        for (int j : primes) {
            if ((ll)i * j > M) {
                break;
            }
            prime[i * j] = false;
            lp[i * j] = j;
            if (i % j == 0) {
                break;
            }
        }
    }
    mob[1] = 1;
    for (int i = 2; i <= M; i++) {
        mob[i] = 1;
        int x = i;
        while (x > 1) {
            int p = lp[x], res = 0;
            while (x % p == 0) {
                x /= p;
                res++;
            }
            if (res > 1) {
                mob[i] = 0;
            }   else {
                mob[i] *= -1;
            }
        }
    }

    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    for (int i = 1; i <= M; i++) {
        for (int j = i; j <= M; j += i) {
            int tmp = i * mob[i];
            if (tmp < 0) {
                tmp += MOD;
            }
            val[j] += tmp;
            if (val[j] >= MOD) {
                val[j] -= MOD;
            }
            s[i] += (ll)cnt[j] * j % MOD;
            if (s[i] >= MOD) {
                s[i] -= MOD;
            }
        }
    }
    int ans = 0;
    for (int i = 1; i <= M; i++) {
        int tmp = (ll)val[i] * s[i] % MOD;
        tmp = (ll)tmp * s[i] % MOD;
        tmp = (ll)tmp * binpow(i, MOD - 2) % MOD;
        ans += tmp;
        if (ans >= MOD) {
            ans -= MOD;
        }
    }
    for (int i = 1; i <= n; i++) {
        ans -= a[i];
        if (ans < 0) {
            ans += MOD;
        }
    }
    cout << (ll)ans * binpow(2, MOD - 2) % MOD;
}


Measured memory_bytes: 21112
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

int main() {
	double r;
	cin >> r;
	cout << fixed;
	cout << setprecision(6);
	cout << r * r * M_PI << " " << 2 * r * M_PI << endl;
	return 0;
}


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi h(n);
    rep(i, n) cin >> h[i];
    vi dp(n, INF);
    dp[0] = 0;
    rep(i, n) {
        if (i-1>=0) dp[i] = min(dp[i], dp[i-1]+abs(h[i]-h[i-1]));
        if (i-2>=0) dp[i] = min(dp[i], dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 4000
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
using namespace std;

typedef pair <int, int> pii;

const int MAX_N = 5e5 + 25, MAX_M = 1100000, MOD = 1e9 + 7;
int n, ans;
int Arr[MAX_N];
int dp[MAX_N];
int DP[MAX_N];
int ind;
vector <int> vec[MAX_N];
vector <pii> P[MAX_M];
unordered_map <int, int> Map;

int _sum (int a, int b) {
	int c = a + b;
	if (MOD <= c)
		c -= MOD;

	return c;
}

int _mul (int a, int b) {
	int c = 1LL * a * b % MOD;
	return c;
}

int _pow (int a, int b) {
	if (!b)
		return 1;

	int res = _pow(a, b >> 1);
	res = _mul(res, res);

	if (b & 1)
		res = _mul(res, a);

	return res;
}

void solve1(int tmp) {
	int a = 1, b = 0, x = 0;
	for (int i = 0; i < n; i++) {
		x ^= Arr[i];

		if (x != 0 && x != tmp)
			continue;

		if (x == 0) {
			dp[i] = b;
			a = _sum(a, dp[i]);
		}
		else {
			dp[i] = a;
			b = _sum(b, dp[i]);
		}
	}

	cout << dp[n - 1] << "\n";
}

int calc1() {
	int x = 0, cnt = 0;
	for (int i = 0; i < n; i++) {
		x ^= Arr[i];
		if (!x)
			cnt++;
	}

	return _pow(2, cnt - 1);
}

int calc2(int tmp) {
	int res = P[tmp][0].second;
	DP[0] = 0;
	dp[0] = P[tmp][0].second;

	for (int i = 1; i < P[tmp].size(); i++) {
		dp[i] = _mul(_mul(dp[i - 1], P[tmp][i].second), P[tmp][i].first - P[tmp][i - 1].first);
		int f = _mul(dp[i - 1], _pow(P[tmp][i - 1].second, MOD - 2));
		f = _sum(f, _mul(P[tmp][i].first - P[tmp][i - 1].first, DP[i - 1]));
		dp[i] = _sum(dp[i], _mul(f, P[tmp][i].second));

		DP[i] = _sum(DP[i - 1], dp[i - 1]);
		res = _sum(res, dp[i]);
	}

	return res;
}

void process1() {
	int x = 0;
	for (int i = 0; i < n; i++) {
		vec[ind].push_back(Arr[i]);
		x ^= Arr[i];
		if (!x)
			ind++;
	}
}

void process2() {
	for (int i = 0; i < ind; i++) {
		Map.clear();
		int x = 0;
		for (int j = 0; j + 1 < vec[i].size(); j++) {
			x ^= vec[i][j];
			Map[x]++;
		}

		for (auto t: Map)
			P[t.first].push_back({i, t.second});
	}
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> Arr[i];

	int tmp = 0;
	for (int i = 0; i < n; i++)
		tmp ^= Arr[i];

	if (tmp) {
		solve1(tmp);
		return 0;
	}

	ans = calc1();
	process1();
	process2();

	for (int i = 0; i < MAX_M; i++)
		if (P[i].size())
			ans = _sum(ans, calc2(i));

	cout << ans << "\n";
	return 0;
}


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

long long N,arr[200010];

void Input(){
	cin>>N;
	for(int i=0; i<N; i++)cin>>arr[i];
}

void Solve(){
	long long total=0,maxim=0;
	for(int i=0; i<N; i++){
		maxim=max(maxim,arr[i]);
		total+=maxim-arr[i];
	}
	cout<<total<<'\n';
}

int main(){
	Input();
	Solve();
}

Measured memory_bytes: 5180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  ll n,a[100010],c[100010]={},d=0;
  cin>>n;
  fr(i,n){
    cin>>a[i];
    if(a[i]<=100000) c[a[i]]++;
    else d++;
  }
  Fr(i,100000){
    if(c[i]<i) d+=c[i];
    else d+=c[i]-i;
  }
  cout<<d<<endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7



char S[300000];
int A[300000], Z[300000];

int main() {

	int N;
	char S[200];
	scanf("%d", &N);
	scanf("%s", S);

	int x = 0;
	int maxX = 0;

	for (int i = 0; i < strlen(S); i++) {
		if (S[i] == 'I') {
			x++;
			maxX = max(x, maxX);
		}
		else if (S[i] == 'D') {
			x--;
		}

	}

	printf("%d", maxX);



}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
    #if 1
    long long a;
    long double b;
    cin >> a >> b;
    cout << (long long)((long double)a*b) << endl;
    #else
    long long a;
    double b;
    cin >> a>> b;
    int b_large;
    double b_small;
    b_large = (int)b;
    b_small = b-b_large;
    int b_smallDigit1 = (int)(b_small*10);
    int b_smallDigit2 = (int)(b_small*100)-b_smallDigit1*10;
    long long ans = a*b_large;
    //cout << ans << endl;
    ans += (a*b_smallDigit1/10);
    //cout << ans << endl;
    ans += (a*b_smallDigit2/100);
    //cout << ans << endl;

    //ans += (long long)((double)a*b_small);

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

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
//constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  ll A, B;
  cin >> A >> B;

  if (A >= 10 || B >= 10)
    FINALANS(-1);
  cout << A * B << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define COUNT_RESET 0
#define ARRAY_RESET 0
#define LOOP_RESET 0

void array_reset(unsigned char * array, unsigned short size);
unsigned short scan_word(unsigned char * str, unsigned short length_max);
void print_word(unsigned char * str, unsigned short length);
void card_shuffle(unsigned char * card, unsigned short num);
unsigned short str_to_int(unsigned char * str, unsigned short digit);

int main(){
	unsigned char card[201];
	unsigned short card_num;
	unsigned char char_times[4];
	unsigned short int_times;
	unsigned short times_digit;
	unsigned short i;
	
	while(1){
		card_num = scan_word(card, 201);
		if(*card == '-'){
			break;
		}

		times_digit = scan_word(char_times, 4);
		int_times = str_to_int(char_times, times_digit);
		for(i = 0;i < int_times;i++){
			card_shuffle(card, card_num);
		}

		print_word(card, card_num);
	}
	return 0;
}

/* 関数名：配列初期化 */
/* 概要：渡されたアドレスを先頭とする配列の値を初期化する */
/* 引数：初期化する配列の先頭アドレス、その配列の大きさ */
/* 戻り値：なし */
void array_reset(unsigned char * array, unsigned short size)
{
	unsigned short usW_C_i; 	/* ループ変数 */
	/* 配列の初期化 */
	for(usW_C_i = COUNT_RESET;usW_C_i < size;usW_C_i++){
		*(array + usW_C_i) = ARRAY_RESET;
	}
}

/* 関数名：文字列入力 */
/* 概要：文字列を入力する。入力された文字列の長さを返す */
/* 引数：文字列を格納する配列の先頭アドレス、その配列の大きさ */
/* 戻り値：入力された文字列の長さ */
unsigned short scan_word(unsigned char * str, unsigned short length_max)
{
	unsigned short usW_C_count_text = COUNT_RESET;  	/* 文字列長カウンタ */
	unsigned short usW_C_i;                         	/* ループ変数 */

	/* 配列の初期化 */
	for(usW_C_i = COUNT_RESET;usW_C_i < length_max;usW_C_i++){
		*(str + usW_C_i) = ARRAY_RESET;
	}
	
	/* 文字列の入力 */
	for(usW_C_i = LOOP_RESET;usW_C_i < length_max;usW_C_i++){
		scanf("%c", str + usW_C_i);
		/* 入力終了の処理 */
		if((*(str + usW_C_i) == ' ') || (*(str + usW_C_i) == '\n')){
			break;
		}
		/* 文字数をカウント */
		usW_C_count_text++;
	}

	/* 文字列長を返す */
	return usW_C_count_text;
}

void print_word(unsigned char * str, unsigned short length)
{
	unsigned short i;
	for(i = 0;i < length;i++){
		printf("%c", *(str + i));
	}
	printf("\n");
}

void card_shuffle(unsigned char * card, unsigned short num)
{
	unsigned char card_memo[200 * 2];
	unsigned char char_stage[4];
	unsigned short int_stage = 0;
	unsigned short stage_digit;
	unsigned short i;
	
	for(i = 0;i < num;i++){
		card_memo[i] = *(card + i);
	}

	for(i = 0;i < num;i++){
		card_memo[i + num] = *(card + i);
	}
	
	stage_digit = scan_word(char_stage, 4);
	int_stage = str_to_int(char_stage, stage_digit);

	for(i = 0;i < num;i++){
		*(card + i) = card_memo[i + int_stage];
	}
}

unsigned short str_to_int(unsigned char * str, unsigned short digit)
{
	unsigned short multi;
	unsigned short ans = 0;
	unsigned short i, j;

	for(i = 0;i < digit;i++){
		multi = 1;
		for(j = 0;j < i;j++){
			multi *= 10;
		}
		ans += (*(str + digit - i -1) -48) * multi;
	}

	return ans;
}


Measured memory_bytes: 2120
#include <bits/stdc++.h>
#define MOD 1000000007
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using pr = pair<int, int>;

int N;
char A[100005];
ll D[100005][15];

int main() {
    D[0][0] = 1;
    scanf("%s", A);
    N = strlen(A);
    for(int i=0; i<N; i++) for(int j=0; j<13; j++) if(D[i][j]) {
        if(A[i] == '?') {
            for(int k=0; k<10; k++) D[i+1][(j*10+k)%13] = (D[i+1][(j*10+k)%13] + D[i][j]) % MOD;
        }
        else {
            D[i+1][(j*10+(A[i]-'0'))%13] = (D[i+1][(j*10+(A[i]-'0'))%13] + D[i][j]) % MOD;
        }
    }
    printf("%lld\n", D[N][5]);
}


Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    bool ans = true;
    rep(i, n) {
        if (a[i]%2==0) {
            if (a[i]%3!=0 && a[i]%5!=0) {
                ans = false;
            }
        }
    }
    if (ans == true) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<functional>
#include<cstdlib>
#include<cmath>
#include<cassert>

#define N 200
#define ACOL 100
#define JUMP 100

const int infty=1<<29;

using namespace std;

struct state{
  int r,c,cost,left;
  state(int r,int c,int cost, int left):r(r),c(c),cost(cost),left(left){}
  bool operator<(const state &t)const{return cost>t.cost;}
};

int dijkstra(int n,int m,
	     const vector< vector<int> > &C,
	     const vector< vector<int> > &D)
{
  static bool vis[N][ACOL][JUMP];
  static int A[N][ACOL][JUMP];for(int i=0;i<N;++i)for(int j=0;j<ACOL;++j)for(int k=0;k<JUMP;++k){vis[i][j][k]=false;A[i][j][k]=infty;}
  priority_queue<state> qs;qs.push(state(0,0,0,m));
  
  while(!qs.empty()){
    state s=qs.top();qs.pop();
    if(s.r>=n+1){continue;}
    vis[s.r][s.c][s.left]=true;
    for(int k=1;k<=2;++k){
      for(int i=0;i<C[s.r+k].size();++i){
	int nxr=s.r+k,nxc=i,nxcost=s.cost+(D[s.r][s.c]+D[nxr][nxc])*abs(C[s.r][s.c]-C[nxr][nxc]),nxj=s.left-(k-1);
	if(s.r==0||nxr>=n+1)nxcost=s.cost;
	if(nxj<0)continue;
	state next(nxr,nxc,nxcost,nxj);if(!vis[nxr][nxc][nxj]&&A[nxr][nxc][nxj]>nxcost){A[nxr][nxc][nxj]=nxcost;qs.push(next);}
      }
    }
  }
  int ret=infty;
  for(int i=0;i<JUMP;++i){for(int j=0;j<ACOL;++j){
      ret=min(A[n+1][j][i],min(A[n+2][j][i],ret));
    }
  }
  return ret;
}

int main()
{
  while(true){
    int n,m;cin>>n>>m;if(n==0&&m==0)break;
    vector< vector<int> > D(n+3);D[0].push_back(0);D[n+1].push_back(0);D[n+2].push_back(0);
    vector< vector<int> > C(n+3);C[0].push_back(0);C[n+1].push_back(0);C[n+2].push_back(0);
    for(int i=0;i<n;++i){
      int k;
      cin>>k;
      for(int j=0;j<k;++j){
	int col,danger;
	cin>>col>>danger;
	C[i+1].push_back(col);
	D[i+1].push_back(danger);
      }
    }
    cout<<dijkstra(n,m,C,D)<<endl;
  }
  return 0;
}

Measured memory_bytes: 11000
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


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

  Int a;
  cin>>a;
  Int ans = a + a * a + a * a * a;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3652
import java.util.*;
import java.io.*;

public class Main {
	static int[] memo;
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		memo = new int[n + 1];
		Arrays.fill(memo, Integer.MAX_VALUE / 10);

		memo[n] = 0;
		for(int i = n; i > 0; i--) {
			for(int num = 1; num <= i; num *= 6) {
				memo[i - num] = Math.min(memo[i - num], memo[i] + 1);
			}
			for(int num = 9; num <= i; num *= 9) {
				memo[i - num] = Math.min(memo[i - num], memo[i] + 1);
			}
		}
		out.println(memo[0]);
				
		out.close();
	} 


static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}


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

int main()
{
	int H;
	int A;
	int answer=0;
	
	cin >> H >> A;

	while (true) {
		
		H -= A;
		answer++;

		if (H <= 0) {
			break;
		}
		
	}
		
	cout << answer <<  endl;

	return 0;
}

Measured memory_bytes: 256
def main():
    s_x, s_y, t_x, t_y = map(int, input().split())

    dx = t_x - s_x
    dy = t_y - s_y

    way = []
    for i in range(2):
        if i == 1:
            way.append("D")

        for j in range(dx+i):
            way.append("R")
        for j in range(dy+i):
            way.append("U")

        if i == 1:
            way.append("L")
            way.append("U")

        for j in range(dx+i):
            way.append("L")
        for j in range(dy+i):
            way.append("D")

        if i == 1:
            way.append("R")

    print("".join(way))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy[4] = {-1, 0, +1, 0};
int dx[4] = {0, +1, 0, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------


int main(void){
    int n, i;

    cin >> n >> i;

    if(n == 1){
        cout << n << endl;
    } else {
        cout << n - i + 1 << endl;
    }
}



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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);

    int average = 0;
    rep(i, n)
    {
        cin >> a[i];
        average += a[i];
    }
    double temp= average/(double) n;
    average= round(temp);
    //cout<<average<<endl;
    long long int ans=0;
    rep(i,n){
        ans+=(a[i]-average)*(a[i]-average);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
Q, H, S, D = map(int, input().split())
N = int(input())
if N == 1:
    print (min(4 * Q, 2 * H, S))
    exit()

if N % 2 == 0: #偶数Lのとき
    n = N // 2
    print (n * min(8 * Q, 4 * H, 2 * S, D))
else:
    n = N // 2
    print (n * min(8 * Q, 4 * H, 2 * S, D) + min(4 * Q, 2 * H, S))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
const int MAX=2e5+10;
const ll MOD=1e9+7;

int N;
int x[100], y[100], h[100];
int mh=0;
void input(){
	cin>>N;
	rep(i,N)cin>>x[i]>>y[i]>>h[i];
	rep(i,N){
		mh=max(mh, h[i]);
	}
}

int ax, ay, ah;
void solve(){
	rep(i,101)rep(j,101)rep(k,201){
		int th=mh+k;
		bool ok=true;
		rep(p,N){
			if(max(0, th-abs(i-x[p])-abs(j-y[p]))!=h[p]){
				ok=false;
				break;
			}
		}
		if(ok){
			ax=i;
			ay=j;
			ah=th;
		}
	}
	cout<<ax<<" "<<ay<<" "<<ah<<endl;
}

void output(){
}

int main(){
  input();
  solve();
  output();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////
int main(){
    int N,K;
    cin >> N >> K;
    if ((N + (2 - 1)) / 2 >= K) printf("YES\n");
    else printf("NO\n");

}


Measured memory_bytes: 256
s=list(map(int,input().split()))
a=0
d=0
list = []
for i in range(s[0]):
  c=0
  b=2
  e=i+1
  for l in range(17):
    if e<s[1]:
      e=b*e
      c=c+1
  list.append(c)
for j in range(len(list)):
  d=d+1/(s[0]*2**list[j])
print(d)

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

using namespace std;

int main()
{
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == '1') {
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}


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







Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int N = cin.nextInt();
        int X = cin.nextInt();
        int[] m = new int[N];
        for (int i = 0; i < N; i++) {
            m[i] = cin.nextInt();
        }

        int x = X - m[0];
        int min = m[0];
        for (int i = 1; i < N; i++) {
            x -= m[i];
            min = Math.min(min, m[i]);
        }

        System.out.println(N + (x / min));
    }
}

Measured memory_bytes: 21716
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF (1LL<<60)
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
#define MSB(x) (63-__builtin_clzll(x))
#define pcnt(x) (__builtin_popcountll(x))
#define parity(i,j) (i&(1LL<<j))
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n;
  cin >> n;

  int a[10][10] = {};
  FOR(i,1,n+1){
    string s = to_string(i);
    a[s[0]-'0'][s.back()-'0']++;
  }

  int ans = 0;
  FOR(i,1,n+1){
    string s = to_string(i);
    ans += a[s.back()-'0'][s[0]-'0'];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
(function Main(input){
	var input = input.split('\n'),
		X = input[1].split(' ').map(Number),
		len = X.length,
		result = 0,
		avg = function(data){
			var sum = 0;
			for(var i=0; i<len; i++){
				sum += data[i];
			}
			return Math.round(sum / len);
		}(X);
	for(var i=0; i<len; i++){
		result += Math.pow(X[i]-avg, 2);
	}
	console.log(result);
})(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 21064
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

K = int(input())

lunluns = collections.deque()
for i in range(1, 10):
    lunluns.append(str(i))

# lunluns = []
for i in range(K - 9):
    a = lunluns[i]
    if a[-1] == "9":
        for j in ["8", "9"]:
            lunluns.append(a + j)
    elif a[-1] == "0":
        for j in ["0", "1"]:
            lunluns.append(a + j)
    else:
        base = int(a[-1])
        for j in range(base - 1, base + 2):
            lunluns.append(a + str(j))

print(lunluns[K - 1])

Measured memory_bytes: 26184
// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}

vector<i64> calc(vector<pair<i64,i64>> v, int m){
    int n = v.size();
    if(n == 0)
        return vector<i64>(m + 1, 0);
    vector<vector<vector<i64>>> dp(n + 1, vector<vector<i64>>(n + 1, vector<i64>(m + 1, INF)));
    for(int i = 0; i <= n; ++i){
        dp[i][i][0] = 0;
        for(int j = i + 1; j <= n; ++j){
            vector<i64> v_rui(1, 0);
            for(int k = i; k < j; ++k)
                v_rui.emplace_back(v[k].second);
            for(int k = 0; k < v_rui.size() - 1; ++k)
                v_rui[k + 1] += v_rui[k];
            int idx = distance(v_rui.begin(), lower_bound(v_rui.begin(), v_rui.end(), v_rui.back() / 2)) - 1;
            i64 cost2 = 0;
            for(int k = i; k < j; ++k)
                cost2 += abs(v[k].first) * v[k].second;
            i64 pos = v[i + idx].first;
            i64 cost = 0;
            for(int k = i; k < j; ++k)
                cost += abs(pos - v[k].first) * v[k].second;
            dp[i][j][1] = min(cost, cost2);
            dp[i][j][0] = cost2;
        }
    }
    for(int k = 0; k < m; ++k){
        for(int i = 0; i <= n; ++i){
            for(int j = 0; j <= i; ++j){
                chmin(dp[0][i][k], dp[0][j][k] + dp[j][i][0]);
                chmin(dp[0][i][k + 1], dp[0][j][k] + dp[j][i][1]);
            }
        }
    }
    return dp[0][n];
}

void solve(long long n, std::vector<long long> x, std::vector<long long> y, std::vector<long long> p){

    vector<i64> ans(n + 1, INF);
    for(int bi = 0; bi < (1 << n); ++bi){
        vector<pair<i64,i64>> vx, vy;
        for(int i = 0; i < n; ++i){
            if(bi & (1 << i))
                vx.emplace_back(x[i], p[i]);
            else
                vy.emplace_back(y[i], p[i]);
        }
        sort(vx.begin(), vx.end());
        sort(vy.begin(), vy.end());
        auto ret_x = calc(vx, n);
        auto ret_y = calc(vy, n);
        for(int k = 0; k <= n; ++k){
            for(int xnum = 0; xnum <= k; ++xnum){
                chmin(ans[k], ret_x[xnum] + ret_y[k - xnum]);
            }
        }
    }
    for(int i = 0; i <= n; ++i)
        cout << ans[i] << endl;
}


signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> X(N);
    std::vector<long long> Y(N);
    std::vector<long long> P(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
        scanf("%lld",&Y[i]);
        scanf("%lld",&P[i]);
    }
    solve(N, std::move(X), std::move(Y), std::move(P));
    return 0;
}


Measured memory_bytes: 3776
#include <iostream>
#include <algorithm>
#include <numeric>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl


int main() {
    ll n ,k;
    cin >> n >> k;

    if(n > k * 2){
        n = n % k;
    }

    while(1){
        if(n-k > 0){
            n -= k;
        } else {
            break;
        }
    }

    if(n > abs(n-k)){
        cout << abs(n-k) << endl;
    } else {
        cout << n << endl;
    }


    return 0;
}

Measured memory_bytes: 256
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#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 ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n,k;
    cin>>n>>k;
    cout<<(int)(log(n)/log(k)) + 1<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
inline long long read(){
    long long f = 1, x = 0;char ch = getchar();
    while (ch > '9' || ch < '0'){if (ch == '-')f = -f;ch = getchar();}
    while (ch >= '0' && ch <= '9'){x = x * 10 + ch - '0';ch = getchar();}
    return x * f;
}
const int maxn = 1e6 + 10;
int vis[maxn];
int main(){
    int n = read();
    for(int x=1; x<=100; x++){
        for(int y=1; y<=100; y++){
            for(int z=1; z<=100; z++){
                int tot = x*x + y*y + z*z + x*z + x*y + y*z;
                vis[tot]++;
            }
        }
    }
    for(int i=1; i<=n; i++){
        cout << vis[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3776
#include<bits/stdc++.h>
#include<vector>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define rep(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007

using namespace std;


int main(void){
    int ck[12]={0,2,0,1,0,1,0,0,1,0,1,0};
    int x,y;
    cin>>x>>y;
    if(ck[x-1]==ck[y-1])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int N, M; cin >> N >> M;
    vector<ll> fact(N + M + 1);
    ll ans = 0;
    for(int i = 0; i <= N + M; i++) {
        if(i == 0) fact[0] = 1;
        else {
            fact[i] = i * fact[i - 1];
            fact[i] %= mod;
        }
    }
    if(max(N, M) - min(N, M) > 1) {
        cout << ans << endl;
        return 0;
    }
    else if(N == M) {
        ans = 2 * fact[N] * fact[M] % mod;
        cout << ans << endl;
        return 0;
    }
    else {
        ans = fact[N] * fact[M];
        ans %= mod;
        cout << ans << endl;
        return 0;
    }
}

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

int main()
{
	int n;
	cin >> n;
	auto s = vector<int>(n);
	for(auto&& ss : s) cin >> ss;
	auto dp = vector<bool>((n + 1) * 100 + 1);
	dp[0] = true;
	for(auto ss : s){
		for(auto i = (n + 1) * 100; i >= 0; --i){
			if(dp[i]) dp[i + ss] = true;
		}
	}
	int ans = n * 100;
	while(ans > 0 && ans % 10 == 0 || !dp[ans]) --ans;
	cout << ans << endl;
	return 0;
}

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

const int max_v = 101;
char fruit[max_v][max_v];
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
int R, L, res;
char temp;
void dfs(int x,int y) {
	fruit[x][y] = '.';
	for (int i = 0; i < 4; i++) {
		int nx = x + dx[i];
		int ny = y + dy[i];
		if ((0 <= nx&&nx < R) && (0 <= ny&&ny < L) && fruit[nx][ny] == temp)
			dfs(nx,ny);
	}
}

int main() {
	while (cin >> R >> L&&R != 0 && L != 0) {
		res = 0;
		for (int i = 0; i < R; i++) {
			for (int j = 0; j < L; j++) {
				cin >> fruit[i][j];
			}
		}
		for (int i = 0; i < R; i++) {
			for (int j = 0; j < L; j++) {
				if (fruit[i][j] != '.') {
					temp = fruit[i][j];
					dfs(i, j);
					res++;
				}
			}
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 3412