akhauriyash/Code-Regression huggingface dataset:
/*input 
2
*/ 
#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;
typedef long long int ll;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
#define ld double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=3e6+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=998244353;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
int main(){
    int a;
    cin>>a;
    cout<<(a+a*a+a*a*a);
} 


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 4000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////



int main() {
	string s;
	cin >> s;
	rep(i, 4) cout << s[i];
	cout << " ";
	rep(i, 8)cout << s[4 + i];
	cout << endl;


	system("PAUSE");
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
struct revran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { --i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr revran(const i64 e) noexcept: b(0), e(e) {}
  constexpr revran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(e - 1); }
  constexpr iter end() const noexcept { return iter(b - 1); }
};

struct ran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { ++i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr ran(const i64 e) noexcept: b(0), e(e) {}
  constexpr ran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(b); }
  constexpr iter end() const noexcept { return iter(e); }
  constexpr revran rev() const noexcept { return revran(b, e); }
};

constexpr ran rin(const i64 e) noexcept { return ran(1, e + 1); }
constexpr ran rin(const i64 b, const i64 e) noexcept { return ran(b, e + 1); }

int main() {
  i64 E, Y;
  cin >> E >> Y;
  if(E == 0) {
    if(1868 <= Y && Y <= 1911) cout << "M" << Y - 1867 << endl;
    else if(1912 <= Y && Y <= 1925) cout << "T" << Y - 1911 << endl;
    else if(1926 <= Y && Y <= 1988) cout << "S" << Y - 1925 << endl;
    else cout << "H" << Y - 1988 << endl;
  }
  else if(E == 1) cout << Y + 1867 << endl;
  else if(E == 2) cout << Y + 1911 << endl;
  else if(E == 3) cout << Y + 1925 << endl;
  else if(E == 4) cout << Y + 1988 << endl;
}



Measured memory_bytes: 3092
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();
        int sum = 0;
		for(int i = 0; i < n; i++) {
          if (sc.nextInt() >= k) {
            sum++;
          }
        }
    
		// 出力
		System.out.println(sum);
	}
}

Measured memory_bytes: 47972
n, m = map(int, input().split())
L = list(map(int, input().split()))
a = 0
for i in range(len(L)):
  a = a + L[i] 
a = a / (4*m) 
nL = sorted(L, reverse=True)
if a <= nL[m-1]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9192
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll K;
ll countdigits(ll n){
  ll ans=0;
  while(n){n/=K;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  // startupcpp();
  // ll test;cin>>test;while(test--){
  ll i,j,N,H,W,ans;
  cin>>N>>K;
  cout<<countdigits(N)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define vi vector<ll>
#define vii vector<vector<int>>
#define mii map<int,int>
#define pb push_back
#define mod 1e9 + 7;
const int INF = 1e9 + 5;
#define PQ priority_queue<int>
#define pii pair<int, int>
#define ff first
#define ss second
#define endl "\n"

using namespace std;

int main(){

	int n, k;
	cin>>n>>k;
	vi h(n), dp(n, INT_MAX);
	dp[0]=0;
	for(int i=0; i<n; i++)cin>>h[i];

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

	cout<<dp[n-1]<<endl;

}

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

int main() {
	long long n,i,j,k,sum=0,count=0;
	cin>>n>>k;
	long long a[n],dp[n];
	for(i=0;i<n;i++)
	cin>>a[i];
	dp[0]=0; 
    if(k>=(n-1))
    {
      cout<<abs(a[n-1]-a[0]);
      return 0;
    }
	for(i=1;i<k;i++)
	dp[i]=abs(a[i]-a[0]);
    for(i=k;i<n;i++)
    {
        dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
        for(j=2;j<=k;j++)
	    dp[i]=min(dp[i-j]+abs(a[i]-a[i-j]),dp[i]);
    }
	 cout<<dp[n-1];
	return 0;
} 

Measured memory_bytes: 1792
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

int x, y, z, n, total;

int main() {
  scanf("%d %d", &n, &total);
  for(x = 0; x <= n; ++x)
    for(y = 0; x + y <= n; ++y) {
      z = n - x - y;
      if(10000LL * x + 5000LL * y + 1000LL * z == total) return 0 * printf("%d %d %d\n", x, y, z);
    }

  puts("-1 -1 -1");
  
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
 
namespace ITP1_7_D
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[,] a = new int[x[0],x[1]]; int[,] b = new int[x[1],x[2]];
            for (int i = 0; i < x[0]; i++)
            {
                int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
                for (int j = 0; j < x[1]; j++)
                {
                    a[i,j] = n[j];
                }
            }
            for (int i = 0; i < x[1]; i++)
            {
                int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
                for (int j = 0; j < x[2]; j++)
                {
                    b[i,j] = n[j];
                }
            }
            for (int i = 0; i < x[0]; i++)
            {
                long n = 0;
                for (int j = 0; j < x[2] - 1; j++)
                {
                    n = 0;
                    for (int k = 0; k < x[1]; k++)
                    {
                        n += a[i,k] * b[k,j];
                    }
                    Console.Write(n + " ");
                }
                n = 0;
                for (int k = 0; k < x[1]; k++)
                {
                    n += a[i,k] * b[k,x[2] - 1];
                }
                Console.WriteLine(n);
            }
        }
    }
}


Measured memory_bytes: 20516
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n,d;
    cin >> n >> d;
    int cnt = 0;
    rep(i,n){
        ll a,b;
        cin >> a >> b;
        if(a*a + b*b <= d*d) cnt++; 
    }
    cout << cnt;


    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include<iomanip>
#include <numeric>

using namespace std;

//#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

typedef long long ll;

//static const ll MOD = 1000000007;

int main() {
    ll N;
    ll day = 0;

    // input
    cin >> N;

    ll A[N][N - 1];
    for (ll i = 0; i < N; i++) {
        for (ll j = 0; j < N - 1; j++) {
            ll a;
            cin >> a;
            A[i][j] = a - 1;
        };
    }

    // process
    ll progress[N];
    memset(progress, 0, sizeof(progress));
    int day_play[N];
    ll complete = 0;

    while (1) {
        ll day_progress = 0;
        day++;
        memset(day_play, 0, sizeof(day_play));

        for (ll player = 0; player < N; player++) {
            if (day_play[player] == 1 || progress[player] == N - 1) {
                continue;
            }

            ll enemy_player = A[player][progress[player]];
            if (day_play[enemy_player] == 1) {
                continue;
            }
            if (progress[enemy_player] == N - 1) {
                cout << -1 << endl;
                return 0;
            }

            if (A[enemy_player][progress[enemy_player]] == player) {
                progress[player]++;
                if (progress[player] == N - 1) {
                    complete++;
                }
                progress[enemy_player]++;
                if (progress[enemy_player] == N - 1) {
                    complete++;
                }
                day_progress++;
                day_play[player] = 1;
                day_play[enemy_player] = 1;
            }
        }

        if (complete >= N) {
            break;
        }
        if (day_progress == 0) {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << day << endl;

    return 0;
}

Measured memory_bytes: 8064
n,x,m=gets.chomp.split(' ').map(&:to_i)
res = 0
buckets = Array.new(m, nil)
values = Array.new([m,n].min, 0)
buckets[x] = 0
values[0] = x
res += x
(1...n).each do |i|
  x = x * x % m
  values[i] = x
  if buckets[x].nil?
    buckets[x] = i
    res += x
  else
    j = buckets[x]
    d = i - j
    rotc = (n - i) / d
    rotv = values[j...i].sum
    res += rotc * rotv
    remain = n - (i + rotc * d)
    res += values[j...j+remain].sum
    break
  end
end
p res

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

int main() {
    int a, b;
    cin >> a >> b;
    if(a > b) {
        cout << "a > b" << endl;
    }else if(a < b) {
        cout << "a < b" << endl;
    }else{
        cout << "a == b" << endl;
    }
}

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

int main()
{
    long long n, m;
    cin>>n>>m;
    long long w = min(n, m/2);
    long long p = max(m-n*2, 0LL);
    cout<<w+p/4<<endl;
    return 0;
} 

Measured memory_bytes: 384
n=int(input())
from math import sqrt as S 
pf=[]
for i in range(2,int(S(n))+1):
    if n%i==0:
        c=0 
        while n%i==0:
            n//=i 
            c+=1 
        pf.append([i,c])
if n>1:
    pf.append([n,1])
cnt=0 
def search(x):
    i=1 
    while i*(i+1)//2<=x:
        i+=1 
    return i-1 
for x in range(len(pf)):
    a=pf[x][0]
    b=pf[x][1]
    cnt+=search(b)
print(cnt)

Measured memory_bytes: 9228
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll 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(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll llpow(ll n,ll i){ll cnt=n;  for(ll j=0;j<i-1;j++){n*=cnt;}return n;}

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


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

using namespace std;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

const int N = 1e5 + 5;

vi g[N];
int p[N];

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n,m;
	cin >> n >> m;
	rep(i,0,m){
		int x,y;
		cin >> x >> y;
		--x,--y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	fill(p,p+N,-1);
	queue<int> q;
	q.push(0);
	p[0] = 0;
	while(q.size()){
		int u = q.front();
		q.pop();
		for(int v:g[u]){
			if(p[v] == -1){
				p[v] = u;
				q.push(v);
			}
		}
	}
	cout << "Yes" << '\n';
	rep(i,1,n){
		cout << p[i] + 1 << '\n';	
	}
}


Measured memory_bytes: 10384
from sys  import stdin,stdout

import bisect

import math

def st():
    return list(stdin.readline().strip())

def inp():
    return int(stdin.readline())

def li():
    return list(map(int,stdin.readline().split()))

def mp():
    return map(int,stdin.readline().split())

def pr(n):
    stdout.write(str(n)+"\n")

def soe(limit):
    l=[1]*(limit+1)
    prime=[]
    for i in range(2,limit+1):
        if l[i]:
            for j in range(i*i,limit+1,i):
                l[j]=0

    for i in range(2,limit+1):
        if l[i]:
            prime.append(i)
    return prime

def segsoe(low,high):
    limit=int(high**0.5)+1
    prime=soe(limit)
    n=high-low+1
    l=[0]*(n+1)
    for i in range(len(prime)):
        lowlimit=(low//prime[i])*prime[i]
        if lowlimit<low:
            lowlimit+=prime[i]
        if lowlimit==prime[i]:
            lowlimit+=prime[i]
        for j in range(lowlimit,high+1,prime[i]):
            l[j-low]=1
    for i in range(low,high+1):
        if not l[i-low]:
            if i!=1:
                print(i)
                
def gcd(a,b):
    while b:
        a=a%b
        b,a=a,b
    return a

def power(a,n):
    r=1
    while n:
        if n&1:
            r=(r*a)
        a*=a
        n=n>>1
    return r
    
def solve():
    l=li()
    l.sort()
    if l==[5,5,7]:
        pr("YES")
    else:
        pr("NO")
        

for _ in range(1):
    solve()
    


Measured memory_bytes: 9228
# import numpy as np
from collections import defaultdict
from collections import deque

N = int(input())
ss = list()
for i in range(N):
    ss.append(input())

types = list()
indices_dict = defaultdict(deque)
for i, s in enumerate(ss):
    if s[-1] == 'A':
        if s[0] != 'B':
            type_ = 0
        else:
            type_ = 1

    elif s[0] == 'B':
        type_ = 2
    else:
        type_ = 3
    types.append(type_)
    indices_dict[type_].append(i)

# print(indices_dict)
indices = list()
type_prev = 3
while True:
    # print(indices)
    # does not end with 'A'
    if type_prev in {2, 3}:
        if len(indices_dict[0]) != 0:
            idx = indices_dict[0].pop()
            indices.append(idx)
            type_prev = 0
        elif len(indices_dict[1]) != 0:
            idx = indices_dict[1].pop()
            indices.append(idx)
            type_prev = 1
        elif len(indices_dict[3]) != 0:
            idx = indices_dict[3].pop()
            indices.append(idx)
            type_prev = 3
        elif len(indices_dict[2]) != 0:
            idx = indices_dict[2].pop()
            indices.append(idx)
            type_prev = 2
        else:
            break

    # end with 'A'
    else:
        if len(indices_dict[1]) != 0:
            idx = indices_dict[1].pop()
            indices.append(idx)
            type_prev = 1
        elif len(indices_dict[2]) != 0:
            idx = indices_dict[2].pop()
            indices.append(idx)
            type_prev = 2
        elif len(indices_dict[3]) != 0:
            idx = indices_dict[3].pop()
            indices.append(idx)
            type_prev = 3
        elif len(indices_dict[0]) != 0:
            idx = indices_dict[0].pop()
            indices.append(idx)
            type_prev = 0
        else:
            break

st = ''
for idx in indices:
    st += ss[idx]

ans = 0
for i in range(len(st) - 1):
    if st[i] == 'A':
        if st[i + 1] == 'B':
            ans += 1
print(ans)
# heads = list()
# tails = list()
# for i, s in enumerate(ss):
#     if s[0] == 'B':
#         tails.append(i)

#     if s[-1] == 'A':
#         heads.append(i)

# for tail in tails:
    


Measured memory_bytes: 4588
#pragma region include
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstdio>
#include <tuple>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (n); i < (m); i++)
#define MOD 1000000007
#define INF 1000000000
#define LLINF 4000000000000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#pragma endregion

vector<vector<ll>> dp;
vector<vector<bool>> visited;
VI a;
int N;

ll point(int l, int r) {
    if (visited[l][r]) return dp[l][r];
    if (l == r) dp[l][r] = a[l];
    else dp[l][r] = max(a[r] - point(l, r - 1), a[l] - point(l + 1, r));
    visited[l][r] = true;
    return dp[l][r];
}

int main() {
    cin >> N;
    dp.assign(N, vector<ll>(N));
    visited.assign(N, vector<bool>(N, false));
    a.resize(N);
    REP(i, N) {
        cin >> a[i];
    }
    cout << point(0,N-1) << endl;
    getchar(); getchar();
}

Measured memory_bytes: 73984
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define range(i,l,h) for(int i=l;i<h;i++)
#define endl '\n'
#define I INT_MAX
#define L INT_MIN
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vi vector<int>
using namespace std;
using std::ios;
constexpr int MOD=1e9+7;
constexpr int mod=998244353;

int main()
{
  ll h,w,m;
  cin>>h>>w>>m;
  vector<pair<ll,ll> > coord(m);
  vector<ll> r(h+1),c(w+1);
  map<pair<int,int>,int> mp;
  range(i,0,m)
  {
    int x,y;
    cin>>x>>y;
    coord[i]={x,y};
    r[x]++,c[y]++;
    mp[make_pair(x,y)]++;
  }
  sort(coord.begin(),coord.end());
  ll mxr=0,rid=0,mxc=0,cid=0;
  vector<ll> row,col;
  ll ans=0;
  for(int rr=1;rr<=h;rr++)
  {
    if(r[rr]>mxr)
    {
      mxr=r[rr];
      rid=rr;
    }
  }

  for(int cc=1;cc<=w;cc++)
  {
    if(c[cc]>mxc)
    {
      mxc=c[cc];
      cid=cc;
    }
  }

  for(int rr=1;rr<=h;rr++)
  {
    if(r[rr]==mxr)
    {
     row.pb(rr);
    }
  }

  for(int cc=1;cc<=w;cc++)
  {
    if(c[cc]==mxc)
    {
      col.pb(cc);
    }
  }

  bool ok=false;
  int id=0;
  for(ll R:row)
  {
    for(ll C:col)
    {
      //cout<<R<<','<<C<<endl;
      ll temp=mxc+mxr;
      if(mp[{R,C}])temp--;
    
      if(id>0&&temp>ans)
      {
        ans=temp;
        ok=1;
        break;
      }else if(id>0&&temp<ans)
      {
        ok=1;
        break;
      }

      ans=max(ans,temp);
      id++;

    }
    if(ok)break;
  }
  cout<<ans;
}


Measured memory_bytes: 44476
import java.util.*

fun main(args: Array<String>) {
    val upper = object : Comparator<Long> {
        override fun compare(o1: Long?, o2: Long?): Int {
            return if (o1!! == o2!!) -1 else if (o1 < o2) -1 else 1
        }
    }

    val lower = object : Comparator<Long> {
        override fun compare(o1: Long?, o2: Long?): Int {
            return if (o1!! == o2!!) 1 else if (o1 < o2) -1 else 1
        }
    }
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = LongArray(n) { sc.nextLong() }.sorted()
    val b = LongArray(n) { sc.nextLong() }.sorted()
    val c = LongArray(n) { sc.nextLong() }.sorted()

    val ret = b
        .map { bv ->
            val ac = a.binarySearch(bv, lower).let { i -> -(i + 1) }
            val cc = c.binarySearch(bv, upper).let { i -> n - (-(i + 1)) }

            cc.toLong() * ac.toLong()
        }
        .sum()

    println(ret)
}

Measured memory_bytes: 119820
import java.util.Scanner;

public class Main{
	public static void main(String[]args){
		Scanner sc = new Scanner(System.in);

		int width, height;
		int w, h;

		height = sc.nextInt();
		width = sc.nextInt();

		while(height != 0 || width != 0){
			for(h = 0;h < height;h++){
				for(w = 0;w < width;w++){
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
			height = sc.nextInt();
			width = sc.nextInt();
		}

	}
}


Measured memory_bytes: 35752
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
int cnt[7];
int main(){
    int i,n,sn=0;
    cin>>n;
    int x=n;
    while(x){
        sn+=x%10;
        x/=10;
    }
    if(n%sn) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define s second
#define f first
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;

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

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

int main(){ _

	int N;
	cin >> N;
	N = 0;

	string S;
	cin >> S;

	int ans = N;
	for(auto x : S){
		if(x == 'I') N++;
		if(x == 'D') N--;
		ans = max(ans,N);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3448
#include<stdio.h>

#define Max 250

typedef struct{
  int key;
  int parent;
  int left;
  int right;
}Node;

int main(){
  int i, H;
  Node T[Max];

  scanf("%d",&H);
  for(i = 1; i <= H; i++){
    T[i].parent = NULL;
    T[i].left = NULL;
    T[i].right = NULL;
  }
  for(i = 1; i <= H; i++){
    scanf("%d",&T[i].key);
    if(i > 1) T[i].parent = T[i / 2].key;
  }
  for(i = 1; i <= H; i++){
    T[i].left = T[2 * i].key;
    if(2 * i > H) T[i].left = NULL;
    T[i].right = T[2 * i + 1].key;
    if(2 * i + 1> H) T[i].right = NULL;
  }

  for(i = 1; i <= H; i++){
    printf("node %d: key = %d, " ,i, T[i].key);
    if(T[i].parent != NULL) printf("parent key = %d, ", T[i].parent);
    if(T[i].left != NULL) printf("left key = %d, ", T[i].left);
    if(T[i].right != NULL) printf("right key = %d, ", T[i].right);
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 604
N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))

L = [1]
for n in range(N-1):
    L.append(max(L[-1], A[n]))

R = [1]
A.reverse()
for n in range(N-1):
    R.append(max(R[-1], A[n]))
R.reverse()

for i in range(N):
    print(max(L[i], R[i]))


Measured memory_bytes: 15636
#include<iostream>
#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int dt[100];
long long dp[100][21];

long long func(int i,int j){
	long long res;
	if(j<0 || j>20)return 0;
	if(dp[i][j]>=0)return dp[i][j];
	if(i==0){
		if(dt[0]==j)res=1;
		else res=0;
	}else res=func(i-1,j-dt[i])+func(i-1,j+dt[i]);
	return dp[i][j]=res;
}

int main(){
	int n;
	cin>>n;
	rep(i,n){
		cin>>dt[i];
	}
	rep(i,100){
		rep(j,21){
			dp[i][j]=-1;
		}
	}
	cout<<func(n-2,dt[n-1])<<endl;
	return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <map>
using namespace std;
map<long long,int > mp;
int main() {
    long long N,P;
    cin>>N>>P;
    long long p = P;
    for (long long i = 2;i*i<=P;++i){
        if (p%i==0){
            while(p%i==0){
                ++mp[i];
                p/=i;
            }
        }
    }
    if(p!=1) ++mp[p];
    long long ans = 1;
    for(auto &x:mp){
        for (int i = 1; i<=x.second/N;++i){
            ans*=x.first;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
// I make this just for fun because i'm done
// Aimi Haraguni >> Konomi Suzuki >> Yui >>  Ikimono Gakari >> Garnidelia >> Kalafina >> Eir Aoi.   .. dude? 
// problems that involves any kind of persistent data structures are the best of the best, are not them?
 
// #pragma GCC optimize ("Ofast,unroll-loops")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
 
#define pb push_back
#define ff  first
#define ss second
#define tm1 first
#define tm2 second.first
#define tm3 second.second
#define sz(x) ll(x.size())
#define all(v) (v).begin(), (v).end()
#define fill(x, v) memset(x, v, sizeof(x))
#define FER(i,a,b) for(int i=int(a); i< int(b); ++i)
#define IFR(i,a,b) for(int i=int(a); i>=int(b); --i )
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
 
// #define N 21000000
// #define M 19
// #define mod3 9
 
#define mod1  998244353
#define mod 1000000007
#define mod2 1000000009
#define mody 998244353
#define bas 987625403
#define sqr(x) (x)*(x)  
#define INF 3000000000000000000
#define N1 1000
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii > tri;
typedef vector<ll> vi;
typedef vector<vi> vv;
typedef vector<ii> vii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> S_t;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
 
#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}
 
inline ll add(ll a, ll b) { return a+b < mod? a+b : a+b-mod;}
inline ll rem(ll a, ll b) { return a >= b? a - b: a- b + mod;}
inline ll mul(ll a, ll b) { return (long long) a*b%mod;}
inline void Mul(ll &a, ll b) { a = (long long) a*b%mod;}
inline ll bp(ll a, ll p){
    ll ret;
    for(ret = 1; p; p>>=1, Mul(a, a)) (p & 1) && (Mul(ret, a), 1);
    return ret;
}
 
 
static inline void read(ll &result) {
    bool minus = false;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' and ch <= '9') break;
        ch = getchar();
    }
    (ch == '-')? minus = true: result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' or ch > '9') break;
        result = (result<<3)+ (result<<1) + (ch - '0');
    }
    if(minus) result=-result;
}

ll ar[1<<18];

int main(){
	ll n; read(n);
	ll tot = 0;
	FER(i, 0, n) read(ar[i]), tot = add(tot, ar[i]);
	ll ans = 0;
	FER(i, 0, n){
		ll cur = rem(tot, ar[i]);
		ans = add(ans, mul(cur, ar[i]));
	}
	ans = mul(ans, bp(2, mod - 2));
	cout<<ans<<"\n";
	return 0;
}

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

class Town{
	int id, num;

	public Town(int id, int num ) {
		super();
		this.id = id;
		this.num = num;
	}
	
}

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt(), m = fs.nextInt();
		Map<Integer,TreeSet<Town>> map = new HashMap<>();
		for(int i=0;i<m;i++) {
			int p = fs.nextInt()-1, y = fs.nextInt();
			Town t = new Town(i,y);
			if(!map.containsKey(p)) {
				map.put(p, new TreeSet<Town>((t1,t2)->t1.num - t2.num));
				map.get(p).add(t);
			}
			else {
				map.get(p).add(t);
			}
		}
		int ans[][] = new int[m][2];
		for(int i=0;i<n;i++) {
			if(map.containsKey(i)) {
				TreeSet<Town> set = map.get(i);
				int cnt = 1;
				while(!set.isEmpty()) {
					Town t = set.pollFirst();
					ans[t.id][0]=i+1;
					ans[t.id][1]=cnt;
					cnt++;
				}
			}
		}
		StringBuilder sb = new StringBuilder();
		for(int i=0;i<m;i++) {
			String l = String.format("%06d", ans[i][0]);
			String r = String.format("%06d", ans[i][1]);
			sb.append(l + r + "\n");
		}
		System.out.println(sb.toString());
		
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 154196
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<lli> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

void solve()
{

    lli n;
    cin>>n;
    lli a[n + 1];
    vector<lli > X, Y;
    map<lli, lli> ma;
    for(int i = 1; i <= n; i ++) {
        cin>>a[i];
        X.push_back(a[i] + i);
        Y.push_back(i - a[i]);
        ma[Y.back()] ++;
    }

    lli ans = 0;
    for(int i = 1; i <= n;  i ++) {
        ans += ma[a[i] + i] ;
    }

    cout<<ans;

    cout<<"\n";
    return ;
}

/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 30680
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

mint dub(ll n, ll p) {
    if (p == 0) return 1;
    if (p == 1) return n;
    if (p % 2) return dub(n, p - 1) * n;
    mint r = dub(n, p / 2);
    return r * r;
}

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

    ll n;
    cin>>n;
    vl as(n);
    cin>>as;

    map<int, int> res;
    rep(i, n) {
        int temp = as[i];
        for (int j = 2; j * j <= temp; ++j) {
            int cnt = 0;
            while (temp % j == 0) {
                temp /= j;
                cnt++;
            }
            if (cnt) {
                chmax(res[j], cnt);
            }
        }
        if (temp != 1) {
            chmax(res[temp], 1);
        }
    }
    mint lcm = 1;
    for (auto v : res) {
        lcm *= dub(v.first, v.second);
    }
    mint ans = 0;
    rep(i, n) {
        ans += lcm / as[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
using namespace std;


int main() {
	//cout << fixed << setprecision(10);
	string str;
	cin >> str;
	for (int i = 0; i < str.length(); i++) {
		if (str[i] == 'A')cout << 'T';
		if (str[i] == 'T')cout << 'A';
		if (str[i] == 'G')cout << 'C';
		if (str[i] == 'C')cout << 'G';
	}
}

Measured memory_bytes: 256
l=list(map(int,input().split()))
x=l[0]
k=l[1]
d=l[2]
x1=abs(x)

cou=x1//d
cou+=1
x1=x1-d*cou
# while x1>0:
#   x1-=d
#   cou+=1
if k<cou:
  x2=abs(x)-k*d
  print(x2)


else:
  a=cou%2
  b=k%2
  x4=x1*(-1)
  if a==b:
    print(abs(x1))
  if a!=b:
    print(x1+d)


Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
 
signed main(){
    int A,B,C;
    cin>>A>>B>>C;
    int ans=0;
    if(A%2==1&&B%2==1&C%2==1){
        ans=min(A*B,min(B*C,C*A));
    }
    cout<<ans<<endl;
}

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

#define ll  int
#define intmax INT_MAX
#define pi 3.14159265358979323846
#define ff first 
#define ss second
#define pb push_back
#define watch(xxx) cerr<<(#xxx)<<" is "<<xxx<<"\n";

#define N 10000002

int a[N]; 
long long s[N];


int main(){
for(int i=1;i<=1e7;i++){
	for(int j=i;j<=1e7;j+=i) a[j]++;
	s[i]+=i*1LL*a[i]+s[i-1];
}
int n; scanf("%d",&n);
cout<<s[n];


	return 0;
}


Measured memory_bytes: 120908
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        IhateFactorization solver = new IhateFactorization();
        solver.solve(1, in, out);
        out.close();
    }

    static class IhateFactorization {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long x = in.nextLong();
            for (long a = -200; a <= 200; a++) {
                for (long b = -200; b <= 200; b++) {
                    if ((Math.pow(a, 5) - Math.pow(b, 5)) == x) {
                        out.append(String.valueOf(a) + " " + String.valueOf(b));
                        return;
                    }
                }
            }
        }

    }
}



Measured memory_bytes: 39124
#include <iostream>
using namespace std;
int N, A[10010];

int min() {
  int min = A[0];
  for (int i=0; i<N; ++i) {
    if (min > A[i])
      min = A[i];
  }
  return min;
}

int max() {
  int max = A[0];
  for (int i=0; i<N; ++i) {
    if (max < A[i])
      max = A[i];
  }
  return max;
}

long long int sum() {
  long long int sum = 0;
  for (int i=0; i<N; ++i) {
    sum += A[i];
  }
  return sum;
}

int main() {
  cin >> N;
  for (int i=0; i<N; ++i)
    cin >> A[i];
  cout << min() << ' ' << max() << ' ' << sum() << endl;
}

# if 0
    long longにしておらず通らない場合があった。
    関数自体の型指定に気をつけたい。
# endif




Measured memory_bytes: 3140
//
//	Created by shamim_nik
//

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,
		tree_order_statistics_node_update> indexed_set;

#define br printf("\n")

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

//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	int a;
	cin >> a;
	cout << a + (a * a) + (a * a * a) << '\n';
	return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
 
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
using namespace std;
void file(){
	#ifndef ONLINE_JUDGE
    	freopen("tst.txt", "r", stdin);
	#endif	
}
const int N=1e5+5,MAX=3e7,MOD=1e9+7;
 
int n;
int main()
{	
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();

	scanf("%d",&n);
	std::vector<int> a(n);
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	int cnt = 0;
	for(int i=0;i<n;i++){
		if(a[i]!=i+1)cnt++;
	}

	if(cnt<=2)printf("YES\n");
	else printf("NO\n");
	
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;



#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)
#define MP(a,b) make_pair(a,b)

ll debugFlag = false;
template<typename T> void debug(T&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

void solve() {
	
	string S;
	cin >> S;

	ll ans = 0;
	rep(i, S.size() / 2) {
		if (S[i] != S[S.size() - 1 - i]) ans++;
	}

	cout << ans;

}


int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	return 0;
}


Measured memory_bytes: 256
n = int(input())
left = []
right = []

for i in range(n):
    array = list(map(int, input().split()))
    left.append(array[0])
    right.append(array[1])

left.sort()
right.sort()

if n % 2 != 0:
    print(right[n//2] - left[n//2] + 1)
else:
    num1 = (right[n//2] + right[n//2-1])/2
    num2 = (left[n//2] + left[n//2-1])/2
    print(int((num1 - num2)*2 + 1))

Measured memory_bytes: 25436
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

n = I()



small = sorted(LI())
middle = sorted(LI())
big = sorted(LI())


ans = 0
for i in range(n):
    ans += bisect_left(small, middle[i]) * (n - bisect_right(big, middle[i]))



print(ans)

Measured memory_bytes: 95332
'use strict';
process.stdin.on('data', function(chunk) {
  var inputs = chunk.toString().trim();
  var S = Number(inputs);
  var h = Math.floor(S/3600);
  var m = Math.floor((S-(h*3600))/60);
  var s=S%60;

console.log([h,m,s].join(':'));
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 15560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a)  (a).begin(),(a).end()
using P = pair<int, int>;

int main() {
  int N;cin >>N;
  vector<int> A(N), B(N), C(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) cin >> B[i];
  for (int i = 0; i < N; i++) cin >> C[i];
  sort(ALL(A));
  sort(ALL(B));
  sort(ALL(C));
  ll ans=0;
  for (int i = 0; i < N; i++) {
    auto Iter1 = lower_bound(ALL(A), B[i]);
    auto Iter2 = upper_bound(ALL(C), B[i]);
    ll k1 = Iter1 - A.begin();
    ll k2 = C.end() - Iter2;
    ans += k1*k2;
  }
  cout << ans << endl;
  return 0;
}

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

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

	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A.at(i);

	sort(A.begin(), A.end());
	
	cout << A.at(N - 1) - A.at(0) << endl;
}

Measured memory_bytes: 256