akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using llvec=vector<ll>;
using llmat=vector<vector<ll>>;
#define llmattp(name,a,b,num) name(a,vector<ll>(b,num))
#define INTINF 1<<30
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(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;
}

ll gcd(ll a, ll b) {
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll factorial(ll x) {
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll nPr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

ll nCr(ll n, ll r) {
	if (n == r) { return 1; }
	if (r > n) { return 0; }

	if (r > n / 2) { r = n - r; }

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

bool IsPrime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (ll i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) {
	if(array[max]<array[min]) {
		return NULL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

bool Palind(string s) {
	return s == string(s.rbegin(), s.rend());
}

int main() {
	int N; cin>>N;
	int bA=0, BA=0, Ba=0;
	int result=0;
	for(int i=0; i<N; i++) {
		string S; cin>>S;
		int N=S.length();
		for(int i=0; i<N-1; i++) {
			if(S.at(i)=='A'&&S.at(i+1)=='B')
				result++;
		}
		if(S.at(0)=='B') {
			if(S.at(S.length()-1)=='A')
				BA++;
			else
				Ba++;
		}
		else if(S.at(S.length()-1)=='A')
			bA++;
	}

	if(BA) {
		result+=BA-1;
		if(bA) {
			result++;
			bA--;
		}
		if(Ba) {
			result++;
			Ba--;
		}
	}
	result+=min(bA,Ba);

	cout<<result<<endl;
}


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

using namespace std;
typedef long long LL;

// import here

void search_node(vector<pair<LL,LL>>& component, vector<LL>& arrived, vector<vector<LL>>& edge, vector<LL>& a, LL pos){
    vector<LL> q;
    q.push_back(pos);
    while(!q.empty()){
        LL cur = q.back();
        q.pop_back();
        if(arrived[cur]) continue;
        arrived[cur] = 1;
        component.emplace_back(a[cur], cur);
        for(LL i = 0; i < edge[cur].size(); ++i){
            search_node(component, arrived, edge, a, edge[cur][i]);
        }
    }
}

int main(){
    LL n, m;
    cin >> n >> m;
    vector<LL> a(n);
    for(LL i = 0; i < n; ++i){
        cin >> a[i];
    }
    vector<vector<LL>> edge(n);
    for(LL i = 0; i < m; ++i){
        LL x, y;
        cin >> x >> y;
        edge[x].push_back(y);
        edge[y].push_back(x);
    }
    vector<LL> arrived(n);
    vector<pair<LL,LL>> component;
    vector<pair<LL,LL>> rest;
    LL ans = 0;
    LL cnt_cc = 0;
    for(LL i = 0; i < n; ++i){
        if(arrived[i]) continue;
        component.clear();
        search_node(component, arrived, edge, a, i);
        sort(component.begin(), component.end());
        ans += component[0].first;
        rest.insert(rest.end(), component.begin()+1, component.end());
        ++cnt_cc;
    }
    sort(rest.begin(), rest.end());
    if(cnt_cc == 1){
        cout << 0 << endl;
    }else if(rest.size() < cnt_cc-2){
        cout << "Impossible" << endl;
    }else{
        for(LL i = 0; i < cnt_cc-2; ++i){
            ans += rest[i].first;
        }
        cout << ans << endl;
    }
    return 0;
}

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

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

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

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

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

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

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

signed main() {
    int n;
    while(cin >> n, n) {
        vector<string> w(n);
        rep(i,0,n) cin >> w[i];
        rep(i,0,n) {
            int par = 0;
            int level = 0;
            rep(j,i,n) {
                if(level == 5) break;
                par += w[j].size();
                if(level == 0 || level == 2) {
                    if(par == 5) {
                        level++;
                        par = 0;
                    }
                    else if(par > 5) break;
                }
                else if(level == 1 || level == 3 || level == 4) {
                    if(par == 7) {
                        level++;
                        par = 0;
                    }
                    else if(par > 7) break;
                }
            }
            // printf("level: %lld\n", level);
            if(level == 5) {
                cout << i+1 << endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3112
import Text.Printf
ans i =
  let m = 12 * 60 * i `div` 360
      h = m `div` 60
      m'= m `mod` 60
  in
    (h,m')

main = do
  l <- getLine
  let i = read l :: Int
      (h,m) = ans i
  printf "%d %d\n" h m

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


li a[3333];

int main() {
    li n;
    cin >> n;
    rin{cin >> a[i];}
    li res = 0;
    rin{res += a[i];}
    res -= n;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double W = sc.nextInt();
		double H = sc.nextInt();      
		int x = sc.nextInt();
		int y = sc.nextInt();

      	double a = W * H / 2;
      
      	double x1 = W / 2;
      	double y1 = H / 2;
      
      	int z = x1 == x && y1 == y ? 1 : 0;

        System.out.println(a + " " + z);
	}
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll MOD=1e9+7 ;
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; }

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    int n,k; cin >> n >> k;
    string s;cin >> s;
    int rl = 0;
    int lr = 0;
    int kofuku = 0;
    char nowchar = s[0];
    rep(i,s.length()-1)
    {
        if (nowchar == 'R' && s[i+1] == 'L')
        {
            rl++;
            nowchar = 'L';
        }
        else if (nowchar == 'R' && s[i+1] == 'R')
        {
            kofuku++;
        }
        else if (nowchar == 'L' && s[i+1] == 'R')
        {
            lr++;
            nowchar = 'R';
        }
        else if (nowchar == 'L' && s[i+1] == 'L')
        {
            kofuku++;
        }
    }
    int tmp_rl_lr_min = min(lr, rl);
    int tmpans = kofuku + 2 * min(tmp_rl_lr_min,k);
    rl -= tmp_rl_lr_min;
    lr -= tmp_rl_lr_min;
    int tmp_rl_lr_max = max(lr, rl);
    if (k-tmp_rl_lr_min > 0 && tmp_rl_lr_max != 0)
    {
        tmpans++;
    }
    // int tmpnum;
    // int tmpans2 = tmpans;
    // if (tmp_rl_lr_min == rl)
    // {
    //     if (s[0] == 'L')
    //     {
    //         rl++;
    //     }
        
    //     if (s[n-1] == 'R')
    //     {
    //         rl++;
    //     }
    //     tmpnum = min(lr, rl);
    //     tmpans2 = tmpans + (min(tmpnum, k) - min(tmp_rl_lr_min, k));
    // }
    cout << tmpans << endl;
}


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

int main() {
char a[3][3];
for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
        cin >> a[i][j];
    }
}
for(int i=0;i<3;i++){
    cout << a[i][i];
}
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include <cmath>
#include <limits>

using namespace std;
//#define int long  long int
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int N;
	cin >> N;
	vector<int>L(N);
	for (int i = 0; i < N; i++)cin >> L[i];
	sort(L.begin(), L.end());
	int ans = 0;
	for (int i = 0; i < N-2 ; i++)
	{
		for (int j = i + 1; j < N-1 ; j++)
		{
			int num = lower_bound(L.begin(), L.end(), L.at(i) + L.at(j)) - L.begin();
			ans += num - j - 1;
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    int n, m;
    int point;
    int count;
    int[] map;
    int[] dice;
    int i;

    void run(){
	while(sc.hasNext()){
	    n = sc.nextInt();
	    m = sc.nextInt();
	    if(n!=0){
		map = new int[n];
		dice = new int[m];
		for(i=0; i<n; i++)
		    map[i] = sc.nextInt();
		for(i=0; i<m; i++)
		    dice[i] = sc.nextInt();
		point = 0;
		count = 0;
		solve();
	    }
	}
    }

    void solve(){
	while(m>0 && point<map.length){
	    point += dice[count];
	    count++;
	    if(point>=map.length) continue;
	    point += map[point];
	    m--;	    
	}
	System.out.println(count);
    }
}

Measured memory_bytes: 27576
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define OP ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pii;
const int inf = int(1e9);
const int mod = inf + 7;
const double PI = acos(-1.0);
using namespace std;
const int N = 1e5 + 155;
template<typename T>
inline void read(T&x){
    x=0;int f=1;char ch = getchar();
    while(ch<'0' ||ch>'9'){ if(ch=='-')f=-1;ch=getchar(); }
    while(ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
    x*=f;
}

int CountTriangles(vector <int> A){  
    int n=A.size(); 
    sort(A.begin(), A.end());
    int count = 0; 
    for( int i = n-1; i >= 1; i--){ 
        int l = 0, r = i-1; 
        while( l < r){ 
            if( A[l] + A[r] > A[i]){ 
                count += r - l;
                r--;   
            } 
            else 
                l++;   
        } 
    } 
    return count;
} 
void solve(){
    int n;
    cin >> n;
    std::vector<int> v;
    rep(i, n) {
        int x;
        cin >> x;
        v.pb(x);
    }
    cout << CountTriangles(v);
}
 
int main(){
    OP
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val str = scanner.next()

    var aFlag = false
    var bFlag = false
    var cFlag = false
    if (str.length == 3) {
        str.forEach {it ->
            if (!aFlag && it == 'a') {
                aFlag = true
            }
            else if (!bFlag && it == 'b') {
                bFlag = true
            }
            else if (!cFlag && it == 'c') {
                cFlag = true
            }
        }

        if (aFlag && bFlag && cFlag) {
            println("Yes")
            return
        }
    }
    println("No")
}

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

int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	long long arr[3];
	for(int i=0;i<3;i++)scanf("%lld",&arr[i]);
	char str[n+5];
	scanf("%s",str);
	int m[n];
	for(int i=0;i<n;i++){
		if(str[i]=='r')m[i]=0;
		else if(str[i]=='s')m[i]=1;
		else m[i]=2;
	}
	long long dp[n][3];
	for(int i=0;i<n;i++){
		int cur=(m[i]+2)%3;
		if(i<k){
			dp[i][0]=0;dp[i][1]=0;dp[i][2]=0;
			dp[i][cur]=arr[cur];
		}else{
			dp[i][cur]=arr[cur]+max(dp[i-k][(m[i]+1)%3],dp[i-k][m[i]]);
			dp[i][m[i]]=max(dp[i-k][(m[i]+1)%3],dp[i-k][cur]);
			dp[i][(m[i]+1)%3]=max(dp[i-k][m[i]],dp[i-k][cur]);
		}
	}
	long long ans=0;
	for(int i=n-1;i>=n-k;i--){
		ans+=max(dp[i][0],max(dp[i][1],dp[i][2]));
	}
	printf("%lld",ans);
}


Measured memory_bytes: 3072
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		if (x < a) {
			System.out.println(0);
		} else {
			System.out.println(10);
		}
	}
}


Measured memory_bytes: 23124
n = int(input())
w = [str(input()) for i in range(n)]
z = 'Yes'
l = [w[0]]
for h in range(n-1):
    if w[h][-1] == w[h+1][0] and w[h+1] not in l:
        l.append(w[h+1])
    else:
        z = 'No'
        break
print(z)

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

int main() {
  int N;
  cin >> N;
  vector<int> P(N);
  for (int i = 0; i < N; i++) cin >> P.at(i);
  vector<int> Q(N);
  for (int i = 0; i < N; i++) cin >> Q.at(i);
  if (P > Q) swap(P, Q);
  int ans = 0;
  do {
    if (P == Q) break;
    ans++;
  } while (next_permutation(P.begin(), P.end()));
  cout << ans << "\n";
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define CLEAR(a) memset(a,0,sizeof a)
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define fr freopen("input.txt", "r", stdin);
#define fw freopen("output.txt", "w", stdout);
#define int long long 
typedef long long LL;
typedef pair<int,int> pii;
const int MOD = 1e9 + 7;
const int MAX = 1e5 + 5;
int n,a,b,c,d, fac[MAX], invfac[MAX], dp[1001][1001], C[1001][1001];

int mod_pow(int base, int e){
    int ret =1;
    while(e){
        if(e%2) ret = (ret*base)%MOD;
        base = (base*base)%MOD;
        e /= 2;
    }
    return ret;
}

int inv(int x){
  return mod_pow(x, MOD-2);
}

int solve(int left, int i){
  
  if(left == 0) {
    return 1;
  }

  if(i > b || left < 0) {
    return 0;
  }

  if(dp[left][i] != -1) return dp[left][i];

  int ret = solve(left, i+1);
  for(int j=c;j<=d;j++){
    int s = i*j;
    if(s > left) break;
    int tmp = mod_pow(invfac[i], j);
    tmp = (tmp*invfac[j])%MOD;
    tmp = (tmp*solve(left-s, i+1))%MOD;
    //cout << left <<" "<<i <<" " << j << " " << tmp <<endl;
    ret += tmp;
    ret %= MOD;
  }
  return dp[left][i] = ret;
}

 main() {
    cin >> n >> a >> b >> c >> d;

    fac[0] = 1;
    FOR(i,1,1000) fac[i] = (fac[i-1]*i)%MOD;
    REP(i,1001) invfac[i] = inv(fac[i]);

    memset(dp,-1,sizeof dp);
    int ret = solve(n, a)*fac[n];
    ret %= MOD;
    cout << ret ;
    return 0;
}

Measured memory_bytes: 8192
#include<iostream>

using namespace std;

int main(){
	 
	double left, right;
	
	int A[2] = {};
	int B[2] = {};
	int C[2] = {};
	int D[2] = {};
	
	while( cin >> left >> right ) {
	
	if( left >= 1.1) A[0] ++;
	if( 0.6 <= left && left < 1.1) B[0] ++;
	if( 0.2 <= left && left < 0.6) C[0] ++;
	if( left < 0.2) D[0] ++;
	
	if( right >= 1.1) A[1] ++;
	if( 0.6 <= right && right < 1.1) B[1] ++;
	if( 0.2 <= right && right < 0.6) C[1] ++;
	if( right < 0.2) D[1] ++;
	
	
}
	cout << A[0] << " " << A[1] << "\n";
	cout << B[0] << " " << B[1] << "\n";
	cout << C[0] << " " << C[1] << "\n";
	cout << D[0] << " " << D[1] << "\n";
  	return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	int n;
	double a;
	double sum = 0.0;
	cin >> n;
	for(int i = 0; i < n; ++i)
	{
		cin >> a;
		sum += 1.0 / a;
	}
	printf("%.7f", 1.0 / sum);
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3784
n = int(input())

s = 0
q = int(n ** .5)
for i in range(1, q+1):
	x = n // i
	s += i * (x * (x+1)) / 2
	if x**2 != n:
		y = max(n // (i+1), q)
		s += (i * (i+1) // 2) * ((x * (x+1) // 2) - (y * (y+1) // 2))

print(int(s))

Measured memory_bytes: 9444
#include<stdio.h>
int main()
{
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  
  if(a == 5 && b == 5 && c == 7)
  {
    printf("YES\n");
  }
  else if(a == 5 && b == 7 && c == 5)
  {
    printf("YES\n");
  }
  else if(a == 7 && b == 5 && c == 5)
  {
    printf("YES\n");
  }
  else
  {
    printf("NO\n");
  }
  
  return 0;
  
}

Measured memory_bytes: 128
#include <iostream>
	#include <iomanip>
	#include<math.h>
	#include<list>
	#include <algorithm>
	#include<set>
	#include<vector>
	#include<math.h>
	#include<map>
	#include<string>
	#include <numeric>
	#include <queue>
	#include <sstream>
	#include <bitset>
	#include<stack>

	using namespace std;
	using ll = long long;
	using vll = vector<long long>;
	using sll = set<long long>;


	template<typename T>
	T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
	template<typename T>
	T lcm(T a, T b) { return a / gcd(a, b) * b; }

	template<typename T>
	map<T, T> getPrimeFactor(T n) {
		map<T, T> res;
		for (T i = 2; i * i <= n; ++i) {
			while (n % i == 0) {
				res[i] ++;
				n /= i;
			}
		}
		if (n != 1) res[n] = 1;
		return res;
	}

	template<typename T>
	bool IsPrimeNumber(T num)
	{
		if (num <= 2) return true;
		else if (num % 2 == 0) return false;

		double sqrtNum = sqrt(num);
		for (int i = 3; i <= sqrtNum; i += 2)
		{
			if (num % i == 0)
			{
				return false;
			}
		}

		return true;
	}

	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;
	}

	// 繰り返し二乗法
	ll pow2(ll n, ll p, ll mod) {
		if (p == 0 || n == 1) {
			return 1;
		}
		else {
			ll ret = pow2(n * n % mod, p / 2, mod);
			if (p % 2 == 1) {
				ret *= n;
			}
			return ret % mod;
		}
	}


	#define rep(i,s,e) for(ll i=s;i<e;i++)
	#define repeq(i,s,e) for(ll i=s;i<=e;i++)

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

		ll cnt = 0;
		while (A >= B) {
			cnt++;
			B *= 2;
			if (cnt > K) {
				cout << "No" << endl;
				return 0;
			}
		}
		while (B >= C) {
			cnt++;
			C *= 2;
			if (cnt > K) {
				cout << "No" << endl;
				return 0;
			}
		}


		cout << "Yes" << endl;
		return 0;
	}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;

int main(){
  ll i, j;
  ll a, b;
  bool judge = true;
  vector<ll> count(4, 0);
  for(i = 0; i < 3; i++){
    cin >> a >> b;
    count[a - 1]++;
    count[b - 1]++;
  }
  for(i = 0; i < 4; i++)
    if(count[i] != 1 && count[i] != 2)
      judge = false;
  
  if(judge)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<functional>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#include<iomanip>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef unsigned long long ll;
using namespace std;

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int bc=0;
    int wc=0;
    rep(i,n)
    {
        if(s[i]=='.')wc++;
    }
    int ans=wc;
    rep(i,n)
    {
        if(s[i]=='#')
        {
            bc++;
        }
        else
        {
            wc--;
        }
        ans=min(ans,bc+wc);
        
    }
    cout<<ans;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <climits>
#include <iomanip>
#include <string.h>
#include <algorithm>
#include <functional>

using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#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, a, b) for (int i = (int)(a); i >= b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define clr(a,b) memset((a),b,sizeof(a))
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define sz(a) int((a).size())
#define pb push_back

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

//const int N = (int)2e5+77;

ll n,m,k,x,y,a,b,c,d;
vector<pll> v;

int main() {
    fast;
    cin >> n >> a >> b >> c >> d;

    m = n-1;
    for1(i,n){
        x = a - m*d + (n-1-m)*c;
        y = a - m*c + (n-1-m)*d;

        if (b >= x and b <= y)
            return cout << "YES\n", 0;

        x = a + m*d - (n-1-m)*c;
        y = a + m*c - (n-1-m)*d;

        if (b >= x and b <= y)
            return cout << "YES\n", 0;

        m--;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define endl '\n'
#define Endl '\n'
#define fi first
#define ii pair<int,int>
#define iil pair<ll,ll>
#define se second
#define ld long double
#define mod 1000000007
#define popcount __builtin_popcountll
#define x0 zxcxzcsacasd
#define x1 ghfghujfgfg
#define y0 olkjhdnncvcv
#define y1 bhvgrewm345345435
#define debug(x) std::cerr<<#x<<": "<<(x)<<'\n'
#define all(x) x.begin(), x.end()
using namespace std;
ll dp[1000010][2][2];
int n;
ll cal(int i, int f, int ff){
	if(i==n)return f&&ff;
	ll &ret=dp[i][f][ff];
	if(ret!=-1)return ret;
	ret++;
	ret += 8*cal(i + 1, f, ff); ret%=mod;
	ret += cal(i + 1, 1, ff); ret%=mod;
	ret += cal(i + 1, f, 1); ret%=mod;
	return ret;
}
int main(){
	cin>>n;
	memset(dp,-1,sizeof dp);
	cout<<cal(0, 0, 0)<<endl;
}


Measured memory_bytes: 97336
// AtCoder Beginner Contest 115 - A.cpp
#include <iostream>
using namespace std;

int main()
{
    int num;
    cin >> num;
    if (num == 25)
        cout << "Christmas";
    else if (num == 24)
        cout << "Christmas Eve";
    else if (num == 23)
        cout << "Christmas Eve Eve";
    else if (num == 22)
        cout << "Christmas Eve Eve Eve";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint =  pair<int,int>;
int N; 
vector<vector<pint>> v;
bool judge(int bit){
    for (int i=0;i<N;i++){
        if (!(bit & (1<<i))) continue;
        for (auto xy : v[i]){
            int x = xy.first;
            int y = xy.second;
            if (y==1 && !(bit & (1<<x))) return false;
            if (y==0 && (bit & (1<<x))) return false;
        }
    }
    return true;
}
int main(){
    cin >> N;
    v.resize(N);    
    for (int i=0;i<N;i++){
        int A; cin >> A;
        v[i].resize(A);
        for (int j=0;j<A;j++){
            cin >> v[i][j].first >> v[i][j].second;
            --v[i][j].first;
        }
    }
    int res=0;
    for (int bit=0;bit<(1<<N);bit++){
 
        if (judge(bit)){
            int cnt = 0;
            for (int j=0;j<N;j++){
                if (bit & (1<<j)) cnt++;
            }
            res = max(cnt, res);
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int a,b,c,d,e,k;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	scanf("%d",&e);
	scanf("%d",&k);
	if((e-a)>k)	//直接通信が出来ない場合
		printf(":(");
	else
		printf("Yay!");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

typedef long long ll;

using namespace std;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int H, W;
bool memo[1010][1010];
queue<pair<int, int>> q;

int main() {
    cin >> H >> W;

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            char x; cin >> x;
            if (x == '.') memo[i][j] = false;
            else {
                q.push(make_pair(i, j));
                memo[i][j] = true;
            }
        }
    }

    int res = 0;

    // memoするタイミングと実行の時差に注意
    while(!q.empty()) {
        ++res;

        int round = q.size();
        for (int i = 0; i < round; ++i) {
            pair<int, int> p = q.front(); q.pop();
            int px = p.first;
            int py = p.second;

            if (px - 1 >= 0 && !memo[px-1][py]) {
                q.push(make_pair(px-1, py));
                memo[px-1][py] = true;
            }
            if (py - 1 >= 0 && !memo[px][py-1]) {
                q.push(make_pair(px, py-1));
                memo[px][py-1] = true;
            }
            if (px + 1 < H && !memo[px+1][py]) {
                q.push(make_pair(px+1, py));
                memo[px+1][py] = true;
            }
            if (py + 1 < W && !memo[px][py+1]) {
                q.push(make_pair(px, py+1));
                memo[px][py+1] = true;
            }
        }
    }

    cout << (res - 1) << endl;
}


Measured memory_bytes: 9488
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
int x,y,a,b,c;
int p[N],q[N],r[N],vis[N];
LL sa[N],sb[N],sc[N],ans;
LL get(int l,int r,int i){
  LL ans=0;
  //cout<<i<<' '<<l<<' '<<r<<' ';
  while(r-l>=3){
    int L=l+(r-l)/3;
    int R=r-(r-l)/3;
    LL X=sb[L]+sc[x+y-i-L];
    LL Y=sb[R]+sc[x+y-i-R];
    if(X>Y)r=R;
    else l=L;
  }
  for(int xx=l;xx<=r;xx++){
    ans=max(ans,sb[xx]+sc[x+y-i-xx]);
  }
  //cout<<ans<<'\n';
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin>>x>>y>>a>>b>>c;
  for(int i=1;i<=a;i++)cin>>p[i];
  for(int i=1;i<=b;i++)cin>>q[i];
  for(int i=1;i<=c;i++)cin>>r[i];
  sort(p+1,p+1+a,[](int x,int y){return x>y;});
  sort(q+1,q+1+b,[](int x,int y){return x>y;});
  sort(r+1,r+1+c,[](int x,int y){return x>y;});
  for(int i=1;i<=a;i++)sa[i]=sa[i-1]+p[i];
  for(int i=1;i<=b;i++)sb[i]=sb[i-1]+q[i];
  for(int i=1;i<=c;i++)sc[i]=sc[i-1]+r[i];
  for(int i=0;i<=x;i++){
    ans=max(ans,sa[i]+get(max(0,x+y-i-c),min(y,x+y-i),i));
  }
  cout<<ans<<'\n';
  return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> p, q;
vector<int> inv (vector<int>a) {
  vector<int> ret(n);
  for (int i = 0; i < n; i++) {
    ret[a[i]] = i;
  }
  return ret;
}
vector<int> cmp (vector<int>a, vector<int> b) {
  vector<int> ret(n);
  for (int i = 0; i < n; i++) {
    ret[i] = a[b[i]];
  }
  return ret;
}
vector<int> make (string s) {
  vector<int> ret(n);
  for (int i = 0; i < n; i++) {
    ret[i] = i;
  }
  for (char c : s) {
    if (c == 'p') ret = cmp(ret, p);
    else if (c == 'q') ret = cmp(ret, q);
    else if (c == 'P') ret = cmp(ret, inv(p));
    else if (c == 'Q') ret = cmp(ret, inv(q));
  }
  return ret;
}
vector<int> pow (vector<int>a, int k) {
  vector<int> ret(n);
  for (int i = 0; i < n; i++) {
    ret[i] = i;
  }
  while (k) {
    if (k & 1) {
      ret = cmp(ret, a);
    }
    a = cmp(a, a);
    k >>= 1;
  }
  return ret;
}
int main() {
  int k;
  cin >> n >> k;
  p.resize(n);
  q.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    p[i]--;
  }
  for (int i = 0; i < n; i++) {
    cin >> q[i];
    q[i]--;
  }
  vector<int> ret(n);
  if (k == 1) {
    ret = p;
  } else if (k == 2) {
    ret = q;
  } else {
    k -= 2;
    for (int i = 0; i < n; i++) {
      ret[i] = i;
    }
    string rsd[6] = {"q", "qP", "qPQ", "Q", "pQ", "qpQ"};
    int q = k / 6;
    int r = k % 6;
    ret = cmp(ret, pow(make("qPQp"), q + r / 3));
    ret = cmp(ret, make(rsd[r]));
    ret = cmp(ret, pow(make("PqpQ"), q));
  }
  for (int i = 0; i < n; i++) {
    ret[i]++;
  }
  for (int i = 0; i < n; i++) {
    cout << ret[i];
    if (i < n - 1) {
      cout << ' ';
    } else {
      cout << '\n';
    }
  }
  return 0;
}

Measured memory_bytes: 3424
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int main()
{
    while(1)
    {
        int N;
        scanf("%d", &N);
        if(N == 0) return 0;

        int **a;
        a = (int **)malloc(sizeof(int *)*N);
        for(int i = 0; i < N; i++)
        {
            a[i] = (int *)malloc(sizeof(int)*N);
            for(int j = 0; j < N; j++)
            {
                a[i][j] = 0;
            }
        }

        for(int i = 0; i < N; i++)
        {
            int M;
            scanf("%d", &M);
            for(int j = 0; j < M; j++)
            {
                int temp;
                scanf("%d", &temp);
                a[i][temp-1] = 1;
            }
        }

        int *c, L;
        scanf("%d", &L);
        c = (int *)malloc(sizeof(int)*L);
        for(int j = 0; j < L; j++)
        {
            c[j] = -1;
        }

        for(int i = 0; i < L; i++)
        {
            int d;
            scanf("%d", &d);
            c[i] = d-1;
        }

        int b = -1;
        for(int i = 0; i < N; i++)
        {
            int t = 0;
            for(int j = 0; j < L; j++)
            {
                if(a[i][c[j]] == 0) t++;
            }
            if(t == 0 && b == -1) b = i;
            else if(t == 0 && b != -1) b = -2;
        }
        if(b < 0) printf("-1\n");
        else printf("%d\n", b+1);
    }
}


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

const int maxn=110;
int table[maxn][maxn],vis[maxn];
int d[maxn],f[maxn];
int n,tt;

void dfs(int v){
    d[v]=++tt;
    vis[v]=1;
    for(int i=1;i<=n;i++){
        if(!vis[i] && table[v][i])
            dfs(i);
    }
    f[v]=++tt;
}

int main(){

    memset(table,0,sizeof(table));
    memset(vis,0,sizeof(vis));
    int u,k,num;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>u>>k;
        while(k--){
            cin>>num;
            table[u][num]=1;
        }
    }

    for(int i=1;i<=n;i++){
        if(vis[i]==0)
            dfs(i);
    }

    for(int i=1;i<=n;i++)
        cout<<i<<" "<<d[i]<<" "<<f[i]<<endl;

}


Measured memory_bytes: 3144
A,B,C,D=map(int,input().split())

sFlag=True
HPC=C
HPA=A
while(sFlag):
  HPC=HPC-B
  if(HPC<=0):
    print('Yes')
    sFlag=False
    break
  HPA=HPA-D
  if(HPA<=0):
    print('No')
    sFlag=False
    break

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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int R, C, K; cin >> R >> C >> K;
	vector <vector<int>> grid(R, vector<int>(C));
	for (int i = 0; i < K; ++i){
		int r, c, v;
		cin >> r >> c >> v;
		--r;
		--c;
		grid[r][c] = v;
	}
	vector <vector<vector<long long int>>> dp(R, vector<vector<long long int>>(C, vector<long long int>(4)));
	dp[0][0][0] = 0;
	dp[0][0][1] = grid[0][0];
	for (int col = 1; col < C; ++col){
		dp[0][col][0] = dp[0][col-1][0];
		for (int i = 1; i < 4; ++i){
			dp[0][col][i] = dp[0][col-1][i];
			if (dp[0][col-1][i-1] + grid[0][col] > dp[0][col][i]) dp[0][col][i] = dp[0][col-1][i-1] + grid[0][col];
		}	
	}
	for (int i = 1; i < R; ++i){
		dp[i][0][0] = dp[i-1][0][0];
		dp[i][0][1] = dp[i-1][0][0];
		for (int k = 1; k < 4; ++k){
			if (dp[i-1][0][k] > dp[i][0][1]) dp[i][0][1] = dp[i-1][0][k];
		}
		dp[i][0][1] += grid[i][0]; 
		for (int j = 1; j < C; ++j){
			if (dp[i-1][j][0] > dp[i][j-1][0]) dp[i][j][0] = dp[i-1][j][0];
			else dp[i][j][0] = dp[i][j-1][0];
			dp[i][j][1] = dp[i][j-1][0];
			for (int k = 0; k < 4; ++k){
			if (dp[i-1][j][k] > dp[i][j][1]) dp[i][j][1] = dp[i-1][j][k];
			}
			dp[i][j][1] += grid[i][j];
			if (dp[i][j-1][1] > dp[i][j][1]) dp[i][j][1] = dp[i][j-1][1];
			for (int k = 2; k < 4; ++k){
				dp[i][j][k] = dp[i][j-1][k];
			if (dp[i][j-1][k-1] + grid[i][j] > dp[i][j][k]) dp[i][j][k] = dp[i][j-1][k-1] + grid[i][j];	
			}
		}
	}
	long long int larg = dp[R-1][C-1][3];
	for (int i = 0; i < 3; ++i){
		if (dp[R-1][C-1][i] > larg) larg = dp[R-1][C-1][i];
	}
//	for (int i = 0; i < 4; ++i){
//		cout << "DP " << i << "\n";
//		for (int j = 0; j < R; ++j){
//			for (int k = 0; k < C; ++k){
//			cout << dp[j][k][i] << " \n"[k == C-1];
//			}
//		}
//	}
	cout << larg << "\n";
	return 0;
}


Measured memory_bytes: 671480
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    low = []
    high = []

    for i in range(n):
        a, b = map(int, input().split())
        low.append(a)
        high.append(b)

    low.sort()
    high.sort()

    if n%2 == 1:
        l = low[n//2]
        h = high[n//2]
    else:
        l = low[n//2 - 1] + low[n//2]
        h = high[n//2 - 1] + high[n//2]

    ans = h - l + 1

    print(ans)

main()

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

int main(void){
    int n;
    cin>>n;
    vector<int> pos(n);
    rep(i,n){
        int a;
        cin>>a;
        a--;
        pos[a] = i;
    }
    int pre_pos = -1;
    int max_inc_seq = 0;
    int inc_seq = 0;
    rep(i,n){
        if(pre_pos < pos[i]){
            inc_seq++;
            max_inc_seq = max(max_inc_seq,inc_seq);
        }else{
            inc_seq = 1;
        }
        pre_pos = pos[i];
    }
    cout<< n - max_inc_seq <<endl;
    return 0;
}


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

int main(){
  string S; cin >> S;
  int n = S.length();
  long long ans = 0;
  
  for(int bit=0; bit<(1<<n-1); bit++){
    string dmy = S;
    int j=0;
    for(int i=0; i<n-1; i++){
      if(bit & (1<<i)){
        ans += stol(dmy.substr(j,i+1-j).c_str());
        j = i+1;
      }
    }
    ans += stol(dmy.substr(j).c_str());
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String line = br.readLine();
        String[] lineArray = line.split(" ");
        int H = Integer.parseInt(lineArray[0]);
        int W = Integer.parseInt(lineArray[1]);

        char[][] campus = new char[H + 2][W + 2];

        for (int i = 1; i < H + 1; i++) {
            line = br.readLine();
            for (int j = 1; j < W + 1; j++) {
                campus[i][j] = line.charAt(j - 1);
            }
        }

        String result = "Yes";
        for (int i = 1; i < H + 1; i++) {
            result = drawer(campus, H, W, i);
            if (result == "No") {
                break;
            }
        }

        System.out.println(result);

    }
    
    public static String drawer(char[][] campus, int H, int W, int i) {
        for (int j = 1; j < W + 1; j++) {
            if (!(campus[i - 1][j] == '#' || campus[i][j - 1] == '#' || campus[i][j + 1] == '#'
                    || campus[i + 1][j] == '#') && campus[i][j] == '#') {
                return "No";
            }
        }
        return "Yes";
    }
}

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

int main(){
    int v,t;
    cin>>v;
    int b=v;
    while(v){
        t+=(v%10);
        v/=10;
    }
    if(b%t){cout<<"No"<<endl;}
    else{cout<<"Yes"<<endl;}
    return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    c = collections.defaultdict(int)
    for i in range(1,n+1):
        s = str(i)
        c[s[0]+s[-1]] += 1

    r = 0
    for k,v in c.items():
        for l,u in c.items():
            if k > l or k[0] != l[1] or k[1] != l[0]:
                continue
            if k == l:
                r += v * u
            else:
                r += v * u * 2

    return r


print(main())





Measured memory_bytes: 6220
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define F first
#define S second
#define FBO find_by_order
#define OOK order_of_key
#define mset(m,v) memset((m),(v),sizeof(m))
#define inrep int TC;cin>>TC;while(TC--)
#define cppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PI 3.1415926535897932384626433832795028841971693993751
#define trace1(x) cerr<<#x<<": "<<x<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<"\n"
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"\n"

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

// SOLUTION

int main() {
	cppio;
	ll a, b, c, x;
	cin >> a >> b >> c >> x;
	x /= 50;
	ll ans = 0;
	for(int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
				if(i * 10 + j * 2 + k == x) ans++;
			}
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
using namespace std;

struct start { start() {
cin.tie(0);
ios::sync_with_stdio(0);
cout << fixed << setprecision(10);
}; }start;

typedef long long ll;


int main(){
    int n,memo = 0;
    cin >> n;
    
    rep(i,1,n+1){
        memo = i;
        if(memo % 3 == 0){
            cout << " " << memo ;
            continue;
        }
        
        while(memo){
            if(memo % 10 == 3){
                cout << " " << i ;
                break;
            }
            else{
                memo /= 10;
            }
        }
    }
    
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 3192
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
	vector<int> X,Y;
	int temp,temp2,i;
	for(i=0;i<2;i++){
		cin>>temp>>temp2;
		X.push_back(temp);
		Y.push_back(temp2);
	}
	for(i=0;i<2;i++){
		temp=X.at(i+1)-(Y.at(i+1)-Y.at(i));
		temp2=Y.at(i+1)+(X.at(i+1)-X.at(i));
		X.push_back(temp);
		Y.push_back(temp2);
	}
	for(i=0;i<2;i++){
		printf("%d %d ",X.at(i+2),Y.at(i+2));
	}
}

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

signed main() {
	int n, m;
	cin >> n >> m;
	int L, R;
	cin >> L >> R;
	for (int i = 1; i < m; ++i) {
		int l, r;
		cin >> l >> r;
		if (r < L or R < l) {
			cout << 0 << endl;
			return 0;
		}
		L = max(L, l);
		R = min(R, r);
	}

	cout << R - L + 1 << endl;
}



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

int main(){
    long int N, W;
    cin >> N >> W;
    vector<long int> v(N), w(N);
    long int w0;
    for (int i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
        if (i == 0) w0 = w[0];
        w[i] -= w0;
    }
    vector<vector<long int>> dp(101, vector<long int>(300, 0)); 
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j >= 1; j--) {
            for (int k = 0; k <= 3*N; k++) {
                if (k-w[i] >= 0) {
                    dp[j][k] = max(dp[j][k], dp[j-1][k-w[i]] + v[i]);
                }
            }
        }
    }
    long int ans = 0;
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= 3*N; j++) {
            if (i*w0 + j <= W) ans = max(ans, dp[i][j]);
        }
    }
    
    cout << ans << endl;
   
}

Measured memory_bytes: 512
fn main() {
    proconio::input! {
        n: usize,
        k: usize,
        p: [proconio::marker::Usize1;n],
        c: [i64;n],
    }
    let mut l=vec![(0,0);n];
    let mut m=vec![(n+1,n+1,0);n];
    for i in 0..n {
        let mut v=i;
        let mut s=0;
        let mut j=0;
        while m[v].0>=i && l[v].0==0 {
            if m[v].0!=i {
                m[v]=(i,j,s);
            }
            else {
                l[v]=(j-m[v].1,s-m[v].2);
            }
            v=p[v];
            s+=c[v];
            j+=1;
        }
    }
    let mut t=std::i64::MIN;
    let mut u=vec![false;n];
    for i in 0..n {
        for u in u.iter_mut() {
            *u=false;
        }
        let mut v=p[i];
        let mut s=c[v];
        let mut j=1;
        while j<=k && !u[v] {
            t=t.max(s);
            if l[v].0>0 {
                t=t.max(s+((k-j)/l[v].0)as i64*l[v].1);
            }
            u[v]=true;
            v=p[v];
            s+=c[v];
            j+=1;
        }
    }
    println!("{}",t);
}

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

int main() {
    string S, T;
    cin >> S >> T;
    int cnt = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] != T[i]) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3860
S = input()

ans = 0
l, r = 0, 0
i = 0
while i < len(S):
    while i < len(S) and S[i] == "<":
        l += 1
        i += 1
    while i < len(S) and S[i] == ">":
        r += 1
        i += 1
    ans += l * (l + 1) // 2
    ans += r * (r + 1) // 2
    ans -= min(l, r)
    l, r = 0, 0
print(ans)


Measured memory_bytes: 9956
#include<iostream>
#include<algorithm>
#include<set>
#include<string>
using namespace std;

int main() {
    string s;cin >> s;
    bool f = false;
    for (auto ttt:{"KIHBR","KIHBRA","KIHBAR","KIHBARA",
                   "KIHABR","KIHABRA","KIHABAR","KIHABARA",
                   "AKIHBR","AKIHBRA","AKIHBAR","AKIHBARA",
                   "AKIHABR","AKIHABRA","AKIHABAR","AKIHABARA"
                   }) {
        if (s == ttt) {f = true;break;}
    }
    cout << (f ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

//container util
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQUE(a)  (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define RREP(i,n) RFOR(i,n,0)

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << "[L " << __LINE__ << "] " << #x << " = " << (x) << "\n";

const int _N = 3000,  _M = 1000;
int n,m,v[_N+1],h[_N],t[_M+1],s[_M+1];
int dp[_N+1][_M+1][2]; // [boght items i, 1..][place, 1..][just boght] := max strength
// go next
// or
// buy one more

void smax(int &a, int b){
	a = max(a, b);
}

int main() {
	cin >> n >> m;
	REP(i, n){
		cin >> v[i+1] >> h[i];
		v[i+1]+=v[i];
	}
	REP(i, m){
		cin >> t[i] >> s[i];
	}
	REP(i, n+1)REP(j, m+1)REP(k, 2)dp[i][j][k] = -1;
	dp[0][0][0] = 0;
	REP(j, m){
		REP(i, n+1){
			if(dp[i][j][1]>=0){
				// buy more
				if(i < n && t[j] >= v[i+1])smax(dp[i+1][j][1], dp[i][j][1] + h[i] + abs(h[i] - h[i-1]));
				// go next
				if(s[j] <= dp[i][j][1])smax(dp[i][j+1][0], dp[i][j][1]);
			}
			if(dp[i][j][0]>=0){
				// buy first one
				if(i < n && t[j] >= v[i+1])smax(dp[i+1][j][1], dp[i][j][0] + h[i]);
				// go next
				if(s[j] <= dp[i][j][0])smax(dp[i][j+1][0], dp[i][j][0]);
			}
		}
	}
	REP(i, n+1){
		if(dp[i][m][0] >= 0){
			cout << t[m-1] - v[i] << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}

Measured memory_bytes: 26608