akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <deque>
using namespace std;
#define rep(i,n) for (ll i=0;i<n;i++)
#define REP(i,n) for (int i=1;i<=n;i++)
typedef long long ll;

int A;
int B;
int M;
int a[110000];
int b[110000];
int x[110000];
int y[110000];
int c[110000];

int main() {
	cin >> A >> B >> M;
	REP(i, A) cin >> a[i];
	REP(i, B) cin >> b[i];
	rep(i, M) cin >> x[i] >> y[i] >> c[i];
	int ans = a[1] + b[1];
	rep(i, M) {
		int sum = a[x[i]] + b[y[i]] - c[i];
		ans = min(ans, sum);
	}
	sort(a+1, a + A+1);
	sort(b+1, b + B+1);
	ans = min(ans, a[1] + b[1]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2176
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        String s = sc.next();

        List<Integer> list = new ArrayList<>();
        //11101010110011
        int begin = 0;
        char now = '1';

        for (int i = 0; i < n; i++) {
            if (s.charAt(i) != now) {
                list.add(i - begin);
                now = s.charAt(i);
                begin = i;
            }
        }
        list.add(n - begin);
        if (now == '0') list.add(0);

        int result = 0, sum = 0, left = 0, right = 0;
        for (int i = 0; i < list.size(); i += 2) {
            int nextLeft = i;
            int nextRight = Math.min(i + k * 2 + 1, list.size());

            while (nextLeft > left) {
                sum -= list.get(left);
                left++;
            }

            while (nextRight > right) {
                sum += list.get(right);
                right++;
            }
            result = Math.max(sum, result);
        }

        System.out.println(result);
    }

}

Measured memory_bytes: 28756
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	ll N, K;
	cin >> N >> K;

	ll ans = 0;
	ll summin = 0;
	ll summax = 0;
	rep(i, K)
		summin += i;
	rep(i, K)
		summax += (N - i);
	for (ll k = K; k <= N + 1; k++) {
		ans += (summax - summin + 1);
		ans %= mod;
		summax += (N - k);
		summin += k;
	}

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

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <vector>
using namespace std;
int hit, blow;
string a, b;
int main(){
	while(getline(cin, a)){
		getline(cin, b);
		hit = 0;
		blow = 0;
		for(int i = 0; i < 7; i += 2){
			if(b[i] == a[i]){
				hit++;
			}
			else if(a.find(b[i]) != -1){
				blow++;
			}
		}
		cout << hit << " " << blow << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3144
import java.text.DecimalFormat;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double r = sc.nextDouble();
		double menseki = Math.PI * r * r;
		double enshu = Math.PI * 2 * r;
		DecimalFormat decimalFormat = new DecimalFormat("0.00000");
		System.out.println(decimalFormat.format(menseki) + " " + decimalFormat.format(enshu));
	}
}

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

#define int long long
#define endl '\n'

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #ifdef LOCAL
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
    int n,m,k; cin>>n>>m>>k;
    vector<string> grid(n);
    for (auto &i: grid) cin>>i;

    int ans = 0;
    for (int i = 0; i < (1<<n); i++) {
        for (int j = 0; j < (1<<m); j++) {
            vector<string> v = grid;
            for (int x = 0; x < n; x++) {
                if (i>>x&1) {
                    for (int k = 0; k < m; k++) v[x][k] = '.';
                }
            }
            for (int y = 0; y < m; y++) {
                if (j>>y&1) {
                    for (int k = 0; k < n; k++) v[k][y] = '.';
                }
            }
            int c = 0;
            for (int x = 0; x < n; x++) {
                for (int y = 0; y < m; y++) {
                    if (v[x][y] == '#') c++;
                }
            }
            if (c == k) ans++;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3664
#include<stdio.h>
#include<queue>
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n,k,i,a,b,c,f[1000],sum_max=-999999999,sum;
	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++)
	{
		scanf("%d",&f[i]);
	}
	for(a=0;a<=k;a++)
	{
		for(b=0;b<=k;b++)
		{
				for(c=0;c<=k;c++)
				{
					priority_queue<int>q;
					if(a+b+c<=k&&a+b>=c&&a+b<=n)
					{
						for(i=0;i<a;i++)
						{
					       q.push(f[i]);
						}
						for(i=0;i<b;i++)
						{
					       q.push(f[n-i-1]);
						}
						int sum=0;
						for(i=0;i<a+b-c;i++)
						{
							sum=sum+q.top();
							q.pop();
						}
						sum_max=max(sum_max,sum);
					}
				}
			
		}
	}
	printf("%d",sum_max);
	return 0;	
}

Measured memory_bytes: 3244
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#define int long long
using namespace std;

signed main() {
	int N,M;
	cin >> N >> M;
	if(N == 1 && M == 1) {
		cout << 1 << endl;
	}
	else if(N == 1) {
		cout << M - 2 << endl;
	}
	else if(M == 1) {
		cout << N - 2 << endl;
	}
	else {
		cout << (N - 2) * (M - 2) << endl;
	}
}

Measured memory_bytes: 256
from itertools import accumulate
N, Q = map(int, input().split())
S = input()
LR = [tuple(map(int, input().split())) for _ in range(Q)]
A = list(map(lambda s1,s2: int(s1 == "A" and s2 == "C"), S, S[1:]))
B = [0] + list(accumulate(A))
C = list(accumulate(A[::-1]))[::-1] + [0]
P = S.count("AC")
for l, r in LR:
    print(P - B[l-1] - C[r-1])

Measured memory_bytes: 26596
H,W = map(int,input().split())
ans = [H//2+W//3+1,H//3+W//2+1,H,W]

if(H%3==0 or W%3==0):
  ans+=[0]
if(H%2==0):
  ans+=[H//2]
if(W%2==0):
  ans+=[W//2]

print(min(ans))

Measured memory_bytes: 3064
#pragma once

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection) (collection).begin(), (collection).end()  // begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)       // repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)      // repeat reverse
#define size(collection) ((ll) (collection).size())               // collection size

#endif

namespace DPF
{

	struct DP
	{
		ll value;
		ll update_i;
		ll update_j;
		bool update_value;
	};

	void Run()
	{
		string s, t; cin >> s >> t;
		s += " ";
		t += " ";
		s.insert(0, " ");
		t.insert(0, " ");

		vector<vector<DP>> dp(size(s), vector<DP>(size(t)));
		rep(i, 1, size(s) - 1)
		{
			rep(j, 1, size(t) - 1)
			{
				if (s[i] == t[j] && dp[i - 1][j].value == dp[i - 1][j + 1].value)
				{
					dp[i][j + 1].value = dp[i - 1][j].value + 1;
					dp[i][j + 1].update_i = i - 1;
					dp[i][j + 1].update_j = j;
					dp[i][j + 1].update_value = true;
				}
				else
				{
					if (dp[i][j].value < dp[i - 1][j + 1].value)
					{
						dp[i][j + 1].value = dp[i - 1][j + 1].value;
						dp[i][j + 1].update_i = i - 1;
						dp[i][j + 1].update_j = j + 1;
						dp[i][j + 1].update_value = false;
					}
					else
					{
						dp[i][j + 1].value = dp[i][j].value;
						dp[i][j + 1].update_i = i;
						dp[i][j + 1].update_j = j;
						dp[i][j + 1].update_value = false;
					}
				}
			}
		}

		string ans;
		ll lcs_i = size(s) - 2;
		ll lcs_j = size(t) - 1;
		while (dp[lcs_i][lcs_j].value != 0)
		{
			if (dp[lcs_i][lcs_j].update_value)
				ans += s[lcs_i];

			ll next_i = dp[lcs_i][lcs_j].update_i;
			ll next_j = dp[lcs_i][lcs_j].update_j;
			lcs_i = next_i;
			lcs_j = next_j;
		}
		reverse(all(ans));
		cout << ans;
	}
}

int main(void)
{
	DPF::Run();
	return 0;
}

Measured memory_bytes: 282112
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
n = ii()
H = iil()

now = 0
ans = 0
for item in H:
    if item > now:
        ans += item-now
    now = item

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
using namespace std; //std::の省略のため
using ll = long long;

int main()
{
    ll a[4];
    for (int i = 0; i < 4; i++)
        cin >> a[i];

    ll tmp[4];

    int k = 0;

    for (int i = 0; i < 2; i++)
    {
        for (int j = 2; j < 4; j++)
        {
            tmp[k] = a[i] * a[j];
            k++;
        }
    }

    ll ans;

    sort(tmp, tmp + 4);

    ans = tmp[3];

    cout << ans << endl;
}


Measured memory_bytes: 3628
import itertools
X = int(input().strip())

data = {}
for v in range(-200, 200):
    data[v] = pow(v, 5)

for a, b in itertools.product(data.items(), data.items()):
    if a[1] - b[1] == X:
        print(a[0], b[0])
        break

Measured memory_bytes: 9268
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

typedef struct data{
	data* bit[10];
	data* par;
	int val;
}trie;

trie* head;

data* bfs(int k){
	head=new trie();
	data* cur=head;
	queue<data*> q;
	q.push(cur);
	while(k>0){
		cur=q.front();
		q.pop();
		if(cur==head){
			rep(i,1,10){
				cur->bit[i]=new trie();
				cur->bit[i]->par=cur;
				cur->bit[i]->val=i;
				q.push(cur->bit[i]);
				k--;
				if(k==0)
					return cur->bit[i];
			}
		}
		else{
			int b=cur->val;
			if(b<9 and b>0){
				cur->bit[b-1]=new trie();
				cur->bit[b-1]->par=cur;
				cur->bit[b-1]->val=b-1;
				q.push(cur->bit[b-1]);
				k--;
				if(k==0)
					return cur->bit[b-1];
				cur->bit[b]=new trie();
				cur->bit[b]->par=cur;
				cur->bit[b]->val=b;
				q.push(cur->bit[b]);
				k--;
				if(k==0)
					return cur->bit[b];
				cur->bit[b+1]=new trie();
				cur->bit[b+1]->par=cur;
				cur->bit[b+1]->val=b+1;
				q.push(cur->bit[b+1]);
				k--;
				if(k==0)
					return cur->bit[b+1];
			}
			else if(b==9){
				cur->bit[b-1]=new trie();
				cur->bit[b-1]->par=cur;
				cur->bit[b-1]->val=b-1;
				q.push(cur->bit[b-1]);
				k--;
				if(k==0)
					return cur->bit[b-1];
				cur->bit[b]=new trie();
				cur->bit[b]->par=cur;
				cur->bit[b]->val=b;
				q.push(cur->bit[b]);
				k--;
				if(k==0)
					return cur->bit[b];
			}
			else{
				cur->bit[b]=new trie();
				cur->bit[b]->par=cur;
				cur->bit[b]->val=b;
				q.push(cur->bit[b]);
				k--;
				if(k==0)
					return cur->bit[b];
				cur->bit[b+1]=new trie();
				cur->bit[b+1]->par=cur;
				cur->bit[b+1]->val=b+1;
				q.push(cur->bit[b+1]);
				k--;
				if(k==0)
					return cur->bit[b+1];
			}
		}
	}
}

void solve()
{
	int k;
	cin>>k;
	data* cur=bfs(k);
	ll ans=0;
	vi s;
	while(cur!=head){
		s.pb(cur->val);
		cur=cur->par;
	}
	reverse(all(s));
	rep(i,0,sz(s))
		cout<<s[i];
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	return 0;
}

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long
#define MAX_V
const double PI=3.14159265358979323846;

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain; 

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

    int ookii = 0;
    int a[8];
    REP(i, 8) a[i] = 0;

    REP(i, n) {
        int ab;
        cin >> ab;
        if(ab < 3200) {
            a[ab/400]++;
        } else {
            ookii++;
        }
    }

    int syurui = 0;
    REP(i, 8) {
        if(a[i] > 0) syurui++;
    }

    if(syurui == 0) cout << "1 " << ookii << endl;
    else cout << syurui << " " << syurui + ookii << endl;

    return 0;
}
 

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;

inline bool check(ll x, ll y, ll xMax, ll yMax) { return x >= 0 && y >= 0 && xMax > x && yMax > y; }
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string tostring(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }
template<class T> inline T mypow(T x, ll n) { T res = 1; while (n > 0) { if (n & 1)res = res * x;	x = x * x;	n >>= 1; }return res; }
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

#define For(i,a,b)	for(ll (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define rFor(i,a,b)	for(ll (i) = (a-1);i >= (b);(i)--)
#define rrep(i,n)	rFor(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define tostr(a)	tostring(a)
#define dump(val) 	cerr << #val " = " << val << endl;
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

const ll dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, -1, 0, 1, -1, 1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = 1e17 + 9;

#define int ll
#define double ld

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

	int k, t;
	cin >> k >> t;
	vector<int> a(t);

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

	int pre = -1;
	while (1) {
		P ma(-1, -1);
		rep(i, t) {
			if (pre != i) {
				ma = max(ma, P(a[i], i));
			}
		}
		if (ma.first == 0)break;
		if (ma.first == -1)break;
		int j = ma.second;
		a[j]--;
		pre = j;
	}
	int ans = 0;
	rep(i, t) {
		ans += a[i];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {
	int m, d;
	int dd[13] = { 0,31,29,31,30,31,30,31,31,30,31,30,31 };
	string Mon[7] = { "Monday","Tuesday" , "Wednesday" , "Thursday" , "Friday", "Saturday", "Sunday" };
	while (cin >> m >> d) {
		int day = 2;
		if (m == 0 && d == 0) break;
		for (int i = 1; i < m;i++) {
			day += dd[i];
		}
		day += d;
		day %= 7;
		cout << Mon[day] << endl;
	}
}

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


signed main(){
    int a;
    int d[110] = {0};
    while(cin >> a){
        d[a]++;
    }
    int MAX = 0;
    rep(i, 1, 101){
        MAX = max(MAX, d[i]);
    }
    vector<int> ans;
    rep(i, 1, 101){
        if(d[i] == MAX) ans. push_back(i);
    }
    rep(i, 0 ,ans.size()){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 2968
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <ctype.h>
using namespace std;

typedef long long ll;

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int res = min(a, b) + min(c, d);
  cout << res << endl;
  return 0;
}


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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 1E9 + 7, INF = 2E18 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

bool arr[1005] ;

int main()
{
    ll n, x, val, dist = 0 ;
    cin >> x >> n ;
    for (int i = 0; i < n; i++) {
        cin >> val ;
        arr[val] = true ;
    }
    for (int i = x; i >= 0; i--) {
        if (!arr[i]) {
            dist = x - i ;
            val = i ;
            break ;
        }
    }
    for (int i = x; i <= 105; i++) {
        if (!arr[i]) {
            if (i - x < dist) {
                val = i ;
                break ;
            }
        }
    }
    cout << val ;


    return 0 ;
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		if(a*b<=c) {
			System.out.println(a*b);
		}else if(c < a*b) {
			System.out.println(c);
		}

	}
}

Measured memory_bytes: 25300
/*suri_kumkaran*/

#include <bits/stdc++.h>

using namespace std;

#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define endl "\n"
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long

typedef long long int64;
typedef vector<int> VI64;
typedef vector<pair<int,int>> VII64;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;

int32_t main()
{
	IOS;
	int T=1;
	//cin>>T;
	while(T--)
	{
		int n,i;
		int ans=0;
		cin>>n;
		for(i=1;i<=n;i++)
		{
			if(i%3!=0&&i%5!=0)
				ans+=i;
		}
		cout<<ans;
	}

	return 0;
}

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

// clang-format off
#define rep(i, n) for(int i=0; i< (n); i++)
#define reps(i, a, n) for(int i=a; i < (n); i++)

const int INF{1001001001};
const int MOD{(int)1e9 + 7};
const double EPS{1e-9};
const double PI{acos(-1)};
const int dx[]{0, 1, 0, -1, 1, -1, 1, -1}, dy[]{1, 0, -1, 0, 1, -1, -1, 1};

int main(){
    int ans=0;
    string s;
    cin >> s;
    
    rep(i, 4){
        if(s[i] == '+')ans++;
        else ans--;
    }
    
    cout << ans << endl;
    return 0;
}


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

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

    int N; 
    string S, T; 

    cin >> N;
    cin >> S >> T;

    for (int i = 0; i < N; ++i){
        cout << S[i] << T[i]; 
    }
    cout << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define Max 50
using namespace std;

int main() {
    int s,cnt = 0,flg = 0;
    cin >> s;
    int  t[s];
    
    for(int i = 0; i < s; i++){
        cin >> t[i];
    }
    
    for(int j = 0 ; j < Max; j++){
    for(int i = 0; i < s; i++){
        if(t[i] % 2 != 0) {
            flg = 1;
            break;
        }
        t[i] = t[i] / 2;
    }
        if(flg == 1) break;
        cnt++;
    }

    cout << cnt << endl;
}


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

int main(){
    string w;cin >> w;
    if(w.size()%2 == 1){
        cout << "No" << endl;
        return 0;
    }
    sort(w.begin(),w.end());
    for(int i=0;i<w.size()/2;i++){
        if(w[2*i] != w[2*i+1]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;

}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main(){
	string a, b, c;
	cin >> a >> b >> c;
	cout << "A" << b[0] << "C" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type
typedef long long ll;
typedef long double ld;
// loop
//#define For(i, l, r, x)     for (int i = l; i < r; i+=x)
//#define ForE(i, l, r, x)    for (int i = l; i <= r; i+=x)
//#define Ford(i, r, l)       for (int i = r; i > l; i--)
//#define FordE(i, r, l)      for (int i = r; i >= l; i--)
//#define Fora(i, a)          for (auto i : a)
// I/O 
#define FAST_IO             std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
//#define PrintV(a)           Fora(ii, a) cout << ii << ' '; cout << rl;
//#define PrintVl(a)          Fora(ii, a) cout << ii << rl;
//#define PrintA(a, l, r)     for (int ii = l; ii <= r; ii++) cout << a[ii] << ' '; cout << rl;
//#define PrintAl(a, l, r)    for (int ii = l; ii <= r; ii++) cout << a[ii] << rl;
//#define Ptest(x)            return cout << x, 0;
#define setpre(n)           fixed << setprecision(n)
// pair
#define F                   first
#define S                   second
#define pii                 pair<int, int>
#define pll                 pair<ll, ll>
#define pdd                 pair<ld, ld>
// vector & !!?(string)
#define eb                  emplace_back
#define pb                  push_back
#define all(a)              a.begin(), a.end()
#define rall(a)             a.rbegin(), a.rend()
#define sz(a)               a.size()
#define len(a)              a.length()
// geometry calc    
#define pi                  acos(-1.0)
#define g_sin(a)            sin(a*pi/180)
#define g_cos(a)            cos(a*pi/180)
#define g_tan(a)            tan(a*pi/180)
// set val
#define ms0(a)              memset(a,        0, sizeof(a));
#define ms1(a)              memset(a,        1, sizeof(a));
#define msn1(a)             memset(a,       -1, sizeof(a));
#define msinf(a)            memset(a, 0x3f3f3f, sizeof(a));
// constant
const int mod1 = 998244353, mod = 1e9+7;
const int MAX_N = 100005, MAX_M = 200010;
// code
//#define int long long
const int N = 105;
int c[2][N], n;
void Solve() {
    cin >> n;
    for (int i = 0; i < 2; i++)
        for (int j = 1; j <= n; j++)
            cin >> c[i][j];
    
    for (int i = 1; i <= n; i++) c[0][i] += c[0][i-1];
    for (int j = n; j >= 1; j--) c[1][j] += c[1][j+1];
    int ans = INT_MIN;
    for (int i = 1; i <= n; i++) ans = max(ans, c[0][i] + c[1][i]);
    cout << ans;
}

signed main(){
    FAST_IO;
    int TC = 1; 
	//cin >> TC;
    while(TC--) Solve();
    return 0;
}


Measured memory_bytes: 3660
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        int n = input[0];
        int k = input[1] - 1;
        List<int> h = new List<int>();
        for (int i = 0; i < n; i++)
        {
            h.Add(int.Parse(Console.ReadLine()));
        }
        h.Sort();
        int min = h[k] - h[0];
        for (int i = 1; i < n - k; i++)
        {
            min = Math.Min(min, h[i + k] - h[i]);
        }
        Console.WriteLine(min);
    }
}

Measured memory_bytes: 16096
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,a[200010],q[200010],l[200010],r[200010],k;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	for (int i=1;i<=n;i++)
	{
		while (k && a[q[k]]>a[i])
		{
			r[q[k--]]=i-1;
		}
		q[++k]=i;
	}
	while (k)
	{
		r[q[k--]]=n;
	}
	for (int i=n;i;i--)
	{
		while (k && a[q[k]]>=a[i])
		{
			l[q[k--]]=i+1;
		}
		q[++k]=i;
	}
	while (k)
	{
		l[q[k--]]=1;
	}
	ll ans=0;
	for (int i=1;i<=n;i++)
	{
		//cerr<<l[i]<<" "<<r[i]<<endl;
		ans+=1LL*(i-l[i]+1)*(r[i]-i+1)*a[i];
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

void solve() {
    int N;
    cin >> N;
    priority_queue<pll> Q;
    vector<ll> A(N), B(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
        Q.push({A[i] + B[i], i});
    }
    vector<int> flag(N);

    int turn = 0;
    ll ans = 0;
    while(!Q.empty()) {
        pll p = Q.top(); Q.pop();
        if (flag[p.second]) continue;

        flag[p.second] = 1;
        if (turn % 2 == 0) {
            ans += A[p.second];
        } else {
            ans -= B[p.second];
        }
        turn++;
    }

    cout << ans << endl;
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();

    #ifdef LOCAL_ENV
    assert(cin.rdstate() & ios_base::eofbit);
    #endif
}

Measured memory_bytes: 3956
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
 
public class Main {
	
	public static void main(String[] args) throws IOException {
		try (Scanner sc = new Scanner(System.in)) {
			final int N = sc.nextInt();
			final int A = sc.nextInt();
			final int B = sc.nextInt();
			
			System.out.println((B - A) % 2 == 0 ? "Alice" : "Borys");
			
		}
	}
 
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextInt();
			}
			return ret;
		}
 
		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextLong();
			}
			return ret;
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define gc getchar()
#define pc(x) putchar(x)
template<typename T> void scan(T &x){x = 0;bool _=0;T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

using namespace std;
using ll = long long;

ll k, ans, rem;

int main(){
	scan(k);
	rem = 7%k;
	ans = 1;
	while(rem){
		ans++;
		rem = (rem*10+7)%k;
		if(ans > k*7+5){
			print(-1);
			return 0;	
		}
	}
	print(ans);
}

Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    long long N, M;
    cin >> N >> M;
    if(N == 1 && M == 1) cout << 1 << endl;
    else if(N == 1 || M == 1) cout << max(N, M) - 2 << endl;
    else cout << (N - 2) * (M - 2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
  	cin>>N;
    int a[N+10];
    int b[N+10];
    int c[N+10];
    a[0]=b[0]=c[0]=0;
    for (int i=1;i<=N;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    bool flag=true;
    for (int i=0;i<N;i++){
        if( abs(b[i]-b[i+1])+abs(c[i]-c[i+1])>abs(a[i]-a[i+1]) || (abs(b[i]-b[i+1])+abs(c[i]-c[i+1]))%2!=abs(a[i]-a[i+1])%2){
            flag=false;
            break;
        }
    }
    if (flag==true){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 4808
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        if(C >=A && C <= B){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


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

int main(){
  	string s;cin>>s;
    bool flag=false;
  	for(int i=0;i<3;i++){
      if(s[i]==s[i+1]){
        flag=true;
      }
    }
  int a=0;
  	for(int i=0;i<100000000;i++){
      a+=1;
    }
  	if(flag){
      cout<<"Bad"<<endl;
    }else{
      cout<<"Good"<<endl;
    }
  
	return 0;
}

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

int main() {
#ifdef whyqx
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif
    long long x, a, b;
    cin >> x >> a >> b;
    long long c = x * a;
    if (b < c) cout << b << endl;
    else cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque

s = input()
a = deque()
for i in s:
  a.append(i)
q = int(input())
rev = 0
for i in range(q):
  s = input()
  if s[0] == '1':
    rev ^= 1
  else:
    b = (int(s[2]) - 1) ^ rev
    if b:
      a.append(s[4])
    else:
      a.appendleft(s[4])
if rev:
  a.reverse()
for i in a:
  print(i, end="")

Measured memory_bytes: 7536
# -*- coding: utf-8 -*-
import sys

#2種類の組み合わせ個数の組み合わせを求める関数
def kumiawase(x, y, n):
    p = max(x, y)
    q = min(x, y)

    kumi_kosu = 0

    for i in range(n // p + 1):
        if (n - p * i) % q == 0:
            kumi_kosu = kumi_kosu + 1
            #print('func, ', n - p * i, kumi_kosu)

    return kumi_kosu


p = [int(i) for i in input().split()]

#箱が最小となる個数を与える
r,g,b = sorted(p[0:3], reverse=True)
n = p[3]

#print(r,g,b,n)

kumi_kosu_2 = 0

#最大の場合の残り個数
#print(n // r)

for i in range(n // r + 1):
    kumi_kosu_2 = kumi_kosu_2 + kumiawase(g, b, n - r * i)
    #print('main, ', n - r * i, kumi_kosu_2)

print(kumi_kosu_2)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
using namespace std;

const int MAX_N = 1e4 + 5;

int a[MAX_N], b[MAX_N];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int n;
	cin >> n;

	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for(int i = 0; i < n; i++) {
		cin >> b[i];
	}
	
	ll needed = 0, available = 0;
	for(int i = 0; i < n; i++) {
		if(b[i] < a[i]) {
			needed += 1ll * a[i] - 1ll * b[i];
		}
		else if(a[i] < b[i]) {
			available += (1ll * b[i] - 1ll * a[i]) / 2ll;
		}
	}
	
	if(needed > available) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

	return 0;
}


Measured memory_bytes: 384
import numpy as np

N = int(input())
# a = np.array([int(i) for i in input().split()])
a = np.array([input().split() for i in range(N)], dtype=int)

dp = np.zeros((N, 3), dtype=int)
dp[0] = a[0]

for i in range(1, N):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i][k] = max(dp[i][k], dp[i-1][j] + a[i][k])

print(np.max(dp[-1]))


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

using namespace std;


int main()
{
    int n, m;
    int p[110000];
    int s[110000];
    int a[110000];
    int b[110000];
    cin >> n >> m;

    int x = 0, y = 0;
    for (int i = 0; i < m; i++)
    {
        b[i] = 0;
        a[i] = 0;
        cin >> p[i];
        string ss;
        cin >> ss;
        if (ss == "AC")
        s[i] = 1;
        else
        s[i] = 0;
    }

    for (int i = 0; i < m; i++)
    {
        if (s[i] && !b[p[i]-1])
        {
            x++;
            y += a[p[i]-1];
            b[p[i]-1] = 1;
        }
        else if (!s[i])
        {
            a[p[i]-1]++;
        }
    }
    cout << x << " " << y << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<queue>

using namespace std;
static const int N = 100;
static const int INFTY = (1<<21);

int n, M[N][N];
int d[N];

void bfs(int s) {
  queue<int> q;
  q.push(s);
  for ( int i = 0; i < n; i++ ) d[i] = INFTY;
  d[s] = 0;
  int u;
  while ( !q.empty() ) {
    u = q.front(); q.pop();
    for ( int v = 0; v < n; v++ ) {
      if ( M[u][v] == 0 ) continue;
      if ( d[v] != INFTY ) continue;
      d[v] = d[u] + 1;
      q.push(v);
    }
  }
  for ( int i = 0; i < n; i++ ) {
    cout << i+1 << " " << ( (d[i] == INFTY) ? (-1) : d[i] ) << endl;
  }
}

int main() {
  int u, k, v;

  cin >> n;
  for ( int i = 0; i < n; i++ ) {
    for ( int j = 0; j < n; j++ ) M[i][j] = 0;
  }
  
  for ( int i = 0; i < n; i++ ) {
    cin >> u >> k;
    u--;
    for ( int j = 0; j < k; j++ ) {
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }

  bfs(0);

  return 0;
}



Measured memory_bytes: 3160
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

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


signed main(void) {
    int n;
    cin >> n;
    vi prime(100,1);
    vi p;
    loop(i,2,100)if(prime[i]){
        p.push_back(i);
        for(int j = 2; i*j < 100; j++)prime[i*j] = 0;
    }
    //rep(i,p.size())cout << " " << p[i];cout << endl;
    int m = p.size();
    vi v(m);
    loop(i,2,n+1){
        int t = i;
        rep(j,m){
            int cnt = 0;
            while(t%p[j] == 0){
                cnt++;
                t /= p[j];
            }
            v[j] += cnt;
            //cout << i << " " << p[j] << " " << cnt << endl;
        }
    }
    //rep(i,m)cout << " " << v[i];cout << endl;
    int ans = 0;
    rep(i,m)loop(j,i+1,m){
        rep(k,m)if(i != k && j != k){
            if(v[i] >= 4 && v[j] >= 4 && v[k] >= 2)ans++;
        }
    }
    rep(i,m)rep(j,m)if(i != j){
        if(v[i] >= 14 && v[j] >= 4)ans++;
        if(v[i] >= 24 && v[j] >= 2)ans++;
    }
    rep(i,m)if(v[i] >= 74)ans++;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
        using namespace std;
        int main()
        {
          int a,b;
          cin>>a>>b;
          if(a==b)
            cout<<"Draw"<<endl;
          else if(a==1)
            cout<<"Alice"<<endl;
          else if(b==1)
            cout<<"Bob"<<endl;
          else if(a>b)
            cout<<"Alice"<<endl;
          else if(a<b)
            cout<<"Bob"<<endl;
          
          return 0;
        }

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define DEBUG_VEC2(v) rep(i,v.size())cout<<#v<<":"<<v[i]<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pi=pair<int,int>;
using pll=pair<int,int>;
using vi=vector<int>;
using vll=vector<ll>;
using vstr=vector<string>;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
void yes(bool c) { if (c)print("Yes"); else print("No"); };
void YES(bool c) { if (c)print("YES"); else print("NO"); };

void solve() {
    ll n; cin >> n;
    vector<vll> x(10,vll(10,0));
    rng(i,1,n+1){
        int keta = to_string(i).length();
        int head = i / pow(10,keta-1);
        int tail = i % 10;
        x[head][tail]++;
    }
    ll ans = 0;
    rep(i,10){
        rep(j,10){
            ans += x[i][j]*x[j][i];
        }
    }
    print(ans);
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}


Measured memory_bytes: 4152
import numpy as np


def main():
    N = int(input())
    A = []
    B = []
    for i in range(0, N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
    
    takahashi = 0
    aoki = 0
    # 足し算して一番大きいところからとる
    A = np.array(A)
    B = np.array(B)
    sum_AB = A + B
    l = sum_AB.argsort()[::-1]
    takahashi = sum([A[i] for i in [j for idx, j in enumerate(l) if idx % 2 == 0]])
    aoki = sum([B[i] for i in [j for idx, j in enumerate(l) if idx % 2 != 0]])

    print(int(takahashi - aoki))


main()


Measured memory_bytes: 21212
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__;
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N,M; cin >> N >> M;
    int k[10];
    int s[10][10];
    for(int i=0;i<M;i++){
        cin >> k[i];
        for(int j=0;j<k[i];j++){
            cin >> s[i][j];
        }
    }
    int p[10];
    for(int i=0;i<M;i++){
        cin >> p[i];
    }
    int out = 0;
    for(int i=0;i<(1<<N);i++){ //スイッチの状態を全探索
        cerr << i << " " << out << "\n";
        int cnt;
        bool f=true;
        for(int j=0;j<M;j++){ //全ての電球について調べる
            cnt=0;
            for(int l=0;l<k[j];l++){
                if(i&(1<<(s[j][l]-1))){
                    cnt++;
                }
            }
            if(cnt%2!=p[j]){
                f=false;
                break;
            }
        }
        if(f) out++;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define in(j,n) for(j=0;j<n;j++)
#define inp(j,n) for(j=1;j<=n;j++)
#define lo(i,st,n) for(i=st;i<n;i++)
#define pb push_back
#define csbits(n) __builtin_popcount(n)
int main()
{
  ll i,j,n;
  cin>>n;
  inp(i,( ll )sqrt(n))
  {
    if(i>9)
      break;
    if(n%i==0)
    {
      ll u=n/i;
      if(u<10)
      {
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
  return 0;
}

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

int main() {
  int N, M, K; cin >> N >> M >> K;
  int A[N], B[M];
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < M; i++) cin >> B[i];
  long ca[N+1], cb[M+1];
  ca[0] = cb[0] = 0;
  for (int i = 0; i < N; i++) ca[i+1] = ca[i] + A[i];
  for (int i = 0; i < M; i++) cb[i+1] = cb[i] + B[i];
  int max_books = 0;
  for (int i = 0; i <= N; i++) {
    if (ca[i] <= K) {
      int books_B = distance(cb, upper_bound(cb, cb+(M+1), K - ca[i])) - 1;
      max_books = max(max_books, i + books_B);
    }
  }
  cout << max_books << endl;
}

Measured memory_bytes: 8284
n = int(input())
s = 0

a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
  

  
for i in range(n):
  s += b[i]

  
for i in range(n-1):
  if a[i+1] - a[i] == 1:
    s += c[a[i]-1]
print(s)
  
  
    
    

  




Measured memory_bytes: 9216
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <map>
#include <cstdlib>
#include <istream>
#include <set>
#include <queue>
#define rep0(i,n) for (long long int i = 0; i <= (n); ++i)
#define rep1(i,n) for (long long int i = 1; i <= (n); ++i)
#define REP(a,b) for (long long int i = a; i <= (b); ++i) 
#define ps push_back 
using namespace std;
typedef long long ll;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;
	ll save = 0;
	ll anser = 0;
	cin >> n;
	map<string, ll>a;
	rep0(i, n - 1) {
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		a[s]++;
	}
	for (auto& j : a) {
		save = j.second;
		if (save > 1) {
			anser += (save * (save - 1)) / 2;;
		}
	}
	cout << anser << endl;
	return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  //vector<int> a(n);
  vector<pair<int, int>> A(n);
  for(int i=0;i<n;i++){
    int a;
    cin >> a;
    A[i] = make_pair(a,i);
  }
  
  sort(A.begin(),A.end());
  for(int i=0;i<n;i++){
    cout << A[i].second+1 << endl;
  }
  return 0;
}


Measured memory_bytes: 1536