akhauriyash/Code-Regression huggingface dataset:
n = int(input())
sevenfivethree = []
judge = 0

def dfs(num: str):
    if int(num) > n or len(num) > 8:
        return
    else:
        if int(num+"3") <= n:
            sevenfivethree.append(num + "3")
        if int(num+"5") <= n:
            sevenfivethree.append(num + "5")
        if int(num+"7") <= n:
            sevenfivethree.append(num + "7")

        dfs(num + "3")
        dfs(num + "5")
        dfs(num + "7")

        return

dfs("3")
dfs("5")
dfs("7")

for i in range(len(sevenfivethree)):
    if sevenfivethree[i].count("3") ==0 or sevenfivethree[i].count("5") ==0 or sevenfivethree[i].count("7") ==0:
        sevenfivethree[i] = 0 #条件に合わないやつを0に書き換え
        judge = 1
print(len(set(sevenfivethree)) - (judge == 1)) #0があれば、setの数が1こ余分なので引く。


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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()
#define SIZE(a,n) (a).resize(n)
#define SORT(a) sort(ALL(a))
#define VSORT(a, type) sort(ALL(a),greater<type>())
#define MAPIN(a,i,j) (a).insert(make_pair(i,j))

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > Matrix;

int main() {
    string s,t,u;
    ll count,i,j;

    cin>>s;
    count=1;
    t=s[0];
    u="";
    repj(i,1,s.length()){
        u+=s[i];
        if(t!=u){
            count++;
            t=u;
            u="";
        }
    }
    if(t==u){
        count--;
    }
    if(u!="")count++;

    cout<<count;
	
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#define mp make_pair
#define ii pair < ll, ll >
#define F first
#define S second
#define mod ((ll)(1e9+7))
#define ll long long int

using namespace std;

int main()
{
    ll n, a;
    cin >> n;
    map < ll, ll > :: iterator it;
    map < ll, ll > m[2];
    vector < ii > v[2];
    ll res;
    for(int i = 0 ; i < n ; i++){
        cin >> a;
        m[i%2][a]++;
    }
    for(it = m[0].begin() ; it != m[0].end() ; it++){
        v[0].push_back( mp(it->second, it->first) );
    }
    for(it = m[1].begin() ; it != m[1].end() ; it++){
        v[1].push_back( mp(it->second, it->first) );
    }
    sort(v[0].begin(), v[0].end());
    sort(v[1].begin(), v[1].end());
    reverse(v[0].begin(), v[0].end());
    reverse(v[1].begin(), v[1].end());
    //cout << 1;
    v[1].push_back( mp(0, 0) );
    v[0].push_back( mp(0, 0) );
    if(v[0][0].S != v[1][0].S){
        res = n - v[0][0].F - v[1][0].F;
    }else{
        res = n - v[0][0].F - v[1][1].F;
        res = min(res, n - v[1][0].F - v[0][1].F);
    }
    cout << res;
    return 0;
}












Measured memory_bytes: 8824
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

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

    // 一つだけの場合
    if (n==1) {
        cout << p << endl;
        return 0;
    }

    ll ans = 1;
    // 素因数分解
    for (ll i=2; i*i<=p; i++) {
        if (p%i==0) {
            int k = 0;
            while (p%i==0 && p>0){
                p /= i;
                k++;
            }
            k /= n;
            ans *= pow(i, k);
        }
    }

    cout << ans << endl;

    return 0;
}


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

typedef long long ll;

const int N  = 200030;
ll t[N];

int main()
{
    int n,T;
    cin >> n >> T;
    for (int i = 0; i < n; i ++ )
    {
        cin >> t[i];
    }

    ll sum = 0;
    for (int i = 1; i < n; i ++ )
    {
        if(t[i] - t[i-1] >= T) sum += T;
        else sum += (t[i]-t[i-1]);
    }
    cout << sum+T << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    if(s[0] == s[1] && s[1] != s[2] && s[2] == s[3]){
        cout << "Yes" << "\n";
    }else puts("No");
    return 0;
}

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

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

 int main() {
   ll a, b, c;
   cin >> a >> b >> c;
   if (c > a + b && 4 * a * b < (c - a - b) * (c - a - b)) cout << "Yes" << endl;
   else cout << "No" << endl;
 }


Measured memory_bytes: 256
from collections import deque

H,W=map(int,input().split())
S=[]

for i in range(H):
    S.append(list(input()))

step=[[1,0],[-1,0],[0,1],[0,-1]]


mx=0
for sh in range(H):
    for sw in range(W):
        if S[sh][sw]=="#":continue
        visited = [[False] * W for i in range(H)]
        q=deque([[sh,sw,0]])
        visited[sh][sw]=True

        while q:
            h,w,c=q.popleft()
            for dh,dw in step:
                if not (0<=h+dh<H and 0<=w+dw<W):continue
                if S[h+dh][w+dw]=="#":continue
                if visited[h+dh][w+dw]==False:
                    q.append([h+dh,w+dw,c+1])
                    visited[h+dh][w+dw]=True
                else:
                    mx=max(mx,c)
print(mx)


Measured memory_bytes: 3316
#include <stdio.h>

int main() {
  int a, b, c, count , i;
  scanf("%d %d %d",&a, &b, &c);

  for(i=a;i<=b;i++) {
    if(c%i==0) count++;
  }

  printf("%d\n",count);



  return 0;
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    ll a,b;
    cin>>a>>b;
    ll ans=0;
    if(a==b){
        cout<<a<<endl;
        return 0;
    }
    if(a%2==1){
        ans^=a;
        a++;
    }
    if(b%2==0){
        ans^=b;
        b--;
    }
    if((b-a+1)/2%2==1) ans^=1;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
#define INF 1000000000001
#define N 101
#define VALUE 100001
int n, weight;
ll w[N], v[N], dp[VALUE], mx;
 
signed main() {
        ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
 
        cin >> n >> weight;
        for (int i = 1; i <= n; i++) {
                cin >> w[i] >> v[i];
 
                mx += v[i];
        }
 
        for (int i = 1; i <= mx; i++)
                dp[i] = INF;
 
        for (int j = 1; j <= n; j++)
                for (int i = mx; i >= v[j]; i--)
                        dp[i] = min(dp[i], dp[i-v[j]] + w[j]);
 
        for (int i = mx; i >= 0; i--)
                if (dp[i] <= weight) {
                        cout << i << endl;
 
                        return 0;
                }
}

Measured memory_bytes: 1024
fun main(arr:Array<String>) {
    val n = readLine()!!.toInt()
    val cnt = mutableMapOf<String, Int>()
    var max = 0
    for(i in (1..n)) {
        val word = readLine()!!
        if(!cnt.containsKey(word)) {
            cnt[word] = 1
        } else {
            cnt[word] = cnt[word]!! + 1
        }
        max = Math.max(max, cnt[word]!!)
    }
    val ans = cnt.filter { it.value == max }.keys.sorted()
    ans.forEach { println(it) }
}

Measured memory_bytes: 93596
from collections import deque
n, m = map(int, input().split())

# G[i] = 部屋iとつながっている部屋のリスト
G = [[] for i in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

# 部屋1までの距離
dist = [-1] * n
dist[0] = 0
# 前の部屋番号
pre = [-1] * n

# 検査対象
q = deque()
q.append(0)

while len(q) != 0:
    V = q.popleft()
    for v in G[V]:
        if pre[v] == -1:
            dist[v] = dist[V] + 1
            pre[v] = V
            q.append(v)

print("Yes")
for i in range(1, n):
    print(pre[i] + 1)

Measured memory_bytes: 34972
#include <iostream>

using namespace std;

int main(int argc, char** argv) {
    int N;
    cin >> N;
    int ans;
    for (int i = 1; i <= N; i+=2) {
        int c = 0;
        for (int j = 1; j <= N; j++) if (i % j == 0) c++;
        if (c == 8) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<int>L(N);
  for(int i=0; i<N; i++){
    cin >> L.at(i);
  }
  int a=0;
  for(int i=0; i<N; i++){
    a = max(a, L.at(i));
  }
  int sum =0;
  for(int i=0; i<N; i++){
    sum += L.at(i);
  }
  if(a<(sum-a)){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

public static void main (String[] args){

Main main = new Main();
main.solve();

}

private void solve(){

Scanner sc = new Scanner (System.in);

String s = sc.next();

if (s.length()==2){
System.out.println(s);
} else {
System.out.print(s.charAt(2));
System.out.print(s.charAt(1));
System.out.println(s.charAt(0));
}
}
}

Measured memory_bytes: 21460
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;
char a[100];
int main()
{
	cin>>a+1;
	int n = strlen(a+1);
	int flag = 0;
	for(int i = 1; i <= n; i++){
		if(a[i] == 'A' && a[i+1] == 'C') flag = 1;
	}
	if(flag) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define degreeToRadian(deg) (((deg)/360)*2*M_PI)
#define radianTodegree(rad) (((rad)/2/M_PI)*360)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const int MOD = 1e9 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//cin.tie(0);ios::sync_with_stdio(false);
//cout << fixed << setprecision(15) << y << endl;

struct mint {
  ll x;
  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 {
    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 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;
  }
};

// pow mod
mint powm(ll a, ll n) {
  mint res = 1;
  mint x = a;
  while (n > 0) {
    if (n & 1) res *= x;
    x *= x;
    n >>= 1;
  }
  return res;
}

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

  if (N < 2) {
    cout << 0 << endl;
    return 0;
  }

  mint ans = powm(10, N) - ((powm(9, N) - powm(8, N)) * 2) - powm(8, N);
  
  cout << ans.x << endl;
  
  return 0;
}


Measured memory_bytes: 3608
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define REPS(i,n) for(int i=1;i<=(n);i++)
#define RREPS(i,n) for(int i=(n);i>0;i--)
#define mp make_pair
#define pb(a) push_back(a)
#define VSORT(v) sort(v.begin(), v.end());
typedef long long ll;
int A[100002];
int main(){
    int N;
    cin >> N;
    int sum = 0;
    A[0] = 0;
    A[N+1] = 0;
    REPS(i,N){
        cin >> A[i];
        sum += abs(A[i] - A[i-1]);
    }
    sum += abs(A[N+1] - A[N]);
    REPS(i,N){
        int ans = sum;
        ans += abs(A[i+1]-A[i-1]);
        ans -= abs(A[i] - A[i-1]);
        ans -= abs(A[i+1] - A[i]);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N, A, B; cin >> N >> A >> B;
  ll c = A + B;
  ll k = N / c;
  ll m = N % c;
  cout << k * A + min(m, A) << endl;

  return 0;
}



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

int main()
{
  int sx, sy, tx, ty;
  int a, b;
  a = b = 0;
  cin >> sx >> sy >> tx >> ty;
  for (int i = sy; i < ty; i++)
  {
    cout << "U";
    a++;
  }
  for (int i = sx; i < tx; i++)
  {
    cout << "R";
    b++;
  }
  while (a--)
  {
    cout << "D";
  }
  while (b--)
  {
    cout << "L";
  }
  cout << "L";
  for (int i = sy; i <= ty; i++)
  {
    cout << "U";
    a++;
  }
  for (int i = sx; i <= tx; i++)
  {
    cout << "R";
    b++;
  }
  cout << "D";
  cout << "R";
  a++;
  b++;
  while (a--)
  {
    cout << "D";
  }
  while (b--)
  {
    cout << "L";
  }
  cout << "U" << endl;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
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;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    int n;
    cin>>n;
    vll a(n);
    rep(i,0,n)cin>>a[i];
    sort(a.begin(),a.end());
    ll res=gcd(a[0],a[1]);
    rep(i,2,n){
        res=gcd(res,a[i]);
    }
    cout<<res<<endl;
    return 0;
}




Measured memory_bytes: 1024
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

void main(){
    auto n = readInt();
    long[] a, b;
    foreach(i; iota(n)) {
        auto ab = readInts();
        a ~= ab[0];
        b ~= ab[1];
    }
    long calc(uint i, uint j) {
        if(j == i+1) {
            return 0;
        }
        auto ans = long.max/2;
        foreach(k; iota(i+1, j)) {
            ans = min(
                    ans,
                    memoize!calc(i, k) + memoize!calc(k, j)
                    + a[i]*b[k-1]*a[k]*b[j-1]
                    );
        }
        return ans;
    }
    writeln(calc(0, n));
}

Measured memory_bytes: 2716
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#define re register
using namespace std;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=600000+10;
const int mod=924844033;
inline int qpow(int a,int b) { int c=1;
    for (;b;b>>=1,a=1ll*a*a%mod) if (b&1) c=1ll*c*a%mod;
    return c;
}

int n;

struct edge { int v,nxt; } e[N<<1];
int head[N];
inline void addEdge(int u,int v) {
    static int c=0;
    e[++c]=(edge){v,head[u]},head[u]=c;
}

int fac[N],ifac[N];
inline void init(int n) {
    fac[0]=1;
    for (re int i=1;i<=n;++i) fac[i]=1ll*fac[i-1]*i%mod;
    ifac[n]=qpow(fac[n],mod-2);
    for (re int i=n;i;--i) ifac[i-1]=1ll*ifac[i]*i%mod;
}
inline int C(int n,int m) {
    return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}

int cnt[N],sz[N];
inline void dfs(int u,int fa) {
    sz[u]=1;
    for (re int i=head[u];i;i=e[i].nxt) {
        int v=e[i].v; if (v==fa) continue;
        dfs(v,u),sz[u]+=sz[v],++cnt[sz[v]];
    }
    ++cnt[n-sz[u]];
}

int r[N],F[N],G[N];
inline void NTT(int* A,int n,int op) {
    for (re int i=0;i<n;++i) if (i<r[i]) swap(A[i],A[r[i]]);
    for (re int i=1;i<n;i<<=1) {
        int rot=qpow(op==1?5:554906420,(mod-1)/(i<<1));
        for (re int j=0;j<n;j+=i<<1)
            for (re int k=0,w=1;k<i;++k,w=1ll*w*rot%mod) {
                int x=A[j+k],y=1ll*w*A[j+k+i]%mod;
                A[j+k]=(x+y)%mod,A[j+k+i]=(x-y+mod)%mod;
            }
    }
    if (op==-1) { int inv=qpow(n,mod-2);
        for (re int i=0;i<n;++i) A[i]=1ll*A[i]*inv%mod;
    }
}

int main() {
    n=read();
    for (re int i=1;i<n;++i) {
        int u=read(),v=read();
        addEdge(u,v),addEdge(v,u);
    }
    dfs(1,0); init(n);
    for (re int i=1;i<=n;++i) F[i]=1ll*cnt[i]*fac[i]%mod;
    reverse(F,F+n+1);
    for (re int i=0;i<=n;++i) G[i]=ifac[i];
    int lim=1,l=0;
    for (;lim<=n<<1;lim<<=1,++l);
    for (re int i=0;i<lim;++i) r[i]=(r[i>>1]>>1)|((i&1)<<(l-1));
    NTT(F,lim,1),NTT(G,lim,1);
    for (re int i=0;i<lim;++i) F[i]=1ll*F[i]*G[i]%mod;
    NTT(F,lim,-1);
    reverse(F,F+n+1);
    for (re int i=1;i<=n;++i)
        printf("%lld\n",(1ll*n*C(n,i)%mod
                        -1ll*ifac[i]*F[i]%mod+mod)%mod);
    return 0;
}

Measured memory_bytes: 30096
/* HARE KRSNA HARE KRSNA KRSNA KRSNA HARE HARE
    HARE RAMA HARE RAMA RAMA RAMA HARE HARE  */

#include <bits/stdc++.h>
using namespace std;

#define nl "\n"
#define ff first
#define ss second
#define pp pop_back
#define pf pop_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define all(x) x.begin(),x.end()
#define test ll t; cin>>t; while(t--)
#define loop(i,s,n) for(ll i=s;i<n;i++)
#define rloop(i,s,n) for(ll i=s;i>=n;i--)
#define fill(a,value) memset(a,value,sizeof(a))

#define debug2(a)  for(auto x : a)  cout<<x<<" ";  cout<<nl;
#define debug4(a)  for(auto x : a)  cout<<x.ff<<" "<<x.ss<<nl;
#define debug1(a,n) loop(i,0,n)  cout<<a[i]<<" ";  cout<<nl;
#define debug3(a,n,m)  loop(i,0,n){ loop(j,0,m)	cout<<a[i][j]<<" ";	cout<<nl; }

typedef long long ll;
typedef long double ld;

typedef stack<ll> sll;
typedef queue<ll> qll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef pair<ll, pll> ppll;
typedef vector<vector<ll>> vvll;
typedef priority_queue<ll> pqll;

const ll mod = 1000000007;	//998244353;
const ld pi =  acos((ld) - 1);	//3.1415926535;

ll num_generator()		{   return rand() % 1000;	}
void array_generator(ll a[], ll n)		{   loop(i, 0, n)	a[i] = rand() % 100;	}

void solve()
{
	ll n;	cin >> n;
	cout << n + n*n + n*n*n;
}

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

// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif

	// test
	solve();
	return 0;
}

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

int main() {
  	int n;
    double ans=0;
	cin >> n;
	vector<double> v(n);
	
  	for(int i = 0; i < n; i++) cin >> v[i];
	sort(v.begin(), v.end());
  	ans = v[0];
  	for(int i = 1; i < n; i++)
    {
      ans = (ans+v[i])/2;
    }
  	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush
import collections
import bisect

def main():
    n,l = map(int, input().split())
    array = [input() for _ in range(n)]

    array.sort()
    print(''.join(array))


if __name__ == '__main__':
    main()


Measured memory_bytes: 66052
#include<bits/stdc++.h>
using namespace std;
#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define all(a) a.begin(),a.end
#define pb push_back
#define abs(a,b) (a-b>0?a-b:b-a)
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    ll k;
    cin >> k;
    int p,cnt=0;
    rp(i,s.size()){
        if(s.at(i)!='1'){
            p=i;
            break;
        }else{
            cnt++;
        }
    }
    if(cnt==s.size()){
        cout << 1 << endl;
        return 0;
    }else{
        cout << (p<=k-1?s.at(p)-'0':1) << endl;
        return 0;
    }
}






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

int64_t n;


int main() {
	cin >> n;
  	int64_t mn = pow(10,18);
  	
	for(int64_t i = 1; i <= sqrt(n); i++){
      	if(n%i == 0){
      		int64_t tmp = i + n/i - 2;
      		mn = min(tmp,mn);
        }
      	else continue;
    }
  	
  	cout << mn << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;
import java.util.HashMap;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    
    ArrayList<String> sa = new ArrayList<>();
    for(String s: scanner.next().split("")) {
      sa.add(s);
    }
    ArrayList<String> sb = new ArrayList<>();
    for(String s: scanner.next().split("")) {
      sb.add(s);
    }
    ArrayList<String> sc = new ArrayList<>();
    for(String s: scanner.next().split("")) {
      sc.add(s);
    }
    HashMap<String, ArrayList> smap = new HashMap<>();
    smap.put("a", sa);
    smap.put("b", sb);
    smap.put("c", sc);
    
    // 手番プレイヤーをAに決める
    // 繰り返し
    //  手番プレイヤーの配列0番目を見て、"a"なら次の人はAのように次の人を決める
    //  手番プレイヤーの配列0番目を捨てる
    //  手番プレイヤーの配列が長さ0なら手番プレイヤーの勝利で終わり
    String player = "a";
    while(true) {
      ArrayList<String> splayer = smap.get(player);
      if(splayer.size() == 0) {
        System.out.println(player.toUpperCase());
        break;
      }
      player = splayer.get(0);
      splayer.remove(0);
    }
  }
}


Measured memory_bytes: 35776
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<cmath>
#include<queue>
#include<unordered_map>
#include<map>
#include<stack>
#include<bits/stdc++.h>
#include<string.h>
#include <ext/pb_ds/assoc_container.hpp>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
//#define f first
//#define s second
#define respr(fir,sec) for(int i=0;i<=fir;i++){for(int j=0;j<=sec;j++){cout << res[i][j] << " ";}cout << "\n";}
#define pb push_back
//#define INF (1LL<<31)
using namespace std;
using namespace __gnu_pbds;
const int mod = 1e9+7;
const ll MAX = 1000000000000000000;
typedef pair<int,ll> pii;
typedef pair<ll,int> pi;
typedef tuple<long long,int> tp;
typedef tuple<int,int,long long> tu;
typedef multimap<pii , int> mpp;
typedef priority_queue< tp , vector<tp>, greater<tp>>  minheap;
typedef priority_queue<pii , vector<pii>> maxheap;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>  new_data_set;
const int nax=3005;
int dp[nax][nax];


int main()
{
	FASTIO;
	string s,t;
	cin >> s >> t;
	if(s.length()< t.length())
		swap(s,t);

	int n1 = s.length();
	int n2 = t.length();

	
	for(int i=1;i<=n1;i++){
		for(int j=1;j<=n2;j++){
			if(s[i-1]==t[j-1])
			{
				dp[i][j] = 1+dp[i-1][j-1];
			}
			else{
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			}
		}
	}
	
	int i=n1,j=n2;
	
	string res="";
	while(i>0 && j>0){
		if(dp[i][j]> dp[i-1][j] && dp[i][j] > dp[i][j-1]){
			res += s[i-1];
			--i;--j;
		}
		else if(dp[i][j] == dp[i-1][j])
			--i;
		else
			--j;
	}
	
	reverse(res.begin(), res.end());
	cout << res << "\n";
	return 0;
}


Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    int A,B,m,x,y,c,mn=2e5;
    cin >> A >> B >> m;
    vector<int> a(A),b(B);
    rep(i,A)cin >> a.at(i);
    rep(i,B)cin >> b.at(i);
    rep(i,m){
        cin >> x >> y >> c;
        mn=min(a.at(x-1)+b.at(y-1)-c,mn);
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    mn=min(mn,a.at(0)+b.at(0));
    cout << mn << endl;
}


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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
// using namespace __gnu_pbds;

typedef long long ll;
#define int ll
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
#define vi vector<int>
#define pii pair<int,int>
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define MAX 1005
#define initialize(arr,elem) memset(arr,elem,sizeof(arr))
#define sz size
const int MOD = 1e9+7;

// typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int h,w, dp[MAX][MAX];
char grid[MAX][MAX];

int solve(int x,int y){
	if (x<1 || y<1) return 0;
	if (dp[x][y] != -1) return dp[x][y];
	if (grid[x][y] == '#') return dp[x][y] = 0;

	return dp[x][y] = (solve(x,y-1) + solve(x-1,y))%MOD ;
}

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

	cin>>h>>w;
	For(i,1,h+1){
		For(j,1,w+1) cin>>grid[i][j];
	}
	initialize(dp,-1);

	dp[1][1] = 1;
	cout<< solve(h,w)<<endl;
/*	For(i,1,h+1){
		For(j,1,w+1){
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}
*/	return 0;
}


Measured memory_bytes: 9216
#include<iostream>
#include<cstdio>
using namespace std;
int a[301000],n;
long long ans;
int main()
{
	int i;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(i=1;i<=n;i++)
	if(a[i]-a[i-1]>1||a[i]>i-1)
	{
		cout<<-1;
		return 0;
	}
	for(i=1;i<=n;i++)
	{
		if(a[i]-a[i-1]==1)
		ans++;
		else
		ans+=a[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int a[]=new int[n];
        for (int i=0;i<n;i++){
            a[i]=sc.nextInt();
        }
        long ans=0;
        int max=0;
        for (int i:a){
            max=Math.max(max,i);
            ans+=max-i;
        }
        System.out.println(ans);


    }




    static void sort(int[] a) {
        ArrayList<Integer> l=new ArrayList<>();
        for (int i:a) l.add(i);
        Collections.sort(l);
        for (int i=0; i<a.length; i++) a[i]=l.get(i);
    }
    static void sortReverse(long[] a) {
        ArrayList<Long> l=new ArrayList<>();
        for (long i:a) l.add(i);
//        Collections.sort.(l);
        Collections.sort(l,Collections.reverseOrder());
        for (int i=0; i<a.length; i++) a[i]=l.get(i);
    }

    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        String next() {
            while (!st.hasMoreTokens())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        int[] readArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }


}

Measured memory_bytes: 60520
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        List<Integer> numlist = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            numlist.add(Integer.parseInt(sc.next()));
        }
        numlist.sort(Comparator.reverseOrder());
        int Alice = 0;
        int Bob = 0;
        for (int i = 0; i < numlist.size(); i++) {
            if (i % 2 == 0) {
                Alice += numlist.get(i).intValue();
            } else {
                Bob += numlist.get(i).intValue();
            }
        }
        System.out.println(Alice - Bob);
    }
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

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

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
VLL p;
bool prime[2000000];
void makePrime(){

  memset(prime,true,sizeof(prime));
  prime[0] = false;
  prime[1] = false;
  for(int i = 2; i * i <2000000; i++){
    if(prime[i] == false) continue;
    ll x = 2;
    while(x * i < 2000000){
      prime[i*x] = false;
      x++;
    }
  }
  rep(i,2000000){
    if(prime[i]) p.push_back(i);
  }
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  makePrime();
  while(true){
    cin >> n;
    if(n == 0) break;
    if(prime[n]){
      cout << 0 << endl;
      continue;
    }
    //cerr << "check" << *lower_bound(all(p),n) << endl;
    ll  ans =  *lower_bound(all(p),n) - *(lower_bound(all(p),n)-1);
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 6732
N = int(input())
s = list(input())
MOD = 10 ** 9 + 7

DP = [[0] * N for _ in range(N)]

for i in range(N):
  DP[0][i] = 1

for i in range(1, N):
  if s[i - 1] == "<":
    for j in range(N - i - 1, -1, -1):
      DP[i][j] = (DP[i][j + 1] + DP[i - 1][j + 1]) % MOD
  else:
    for j in range(N - i):
      DP[i][j] = (DP[i][j - 1] + DP[i - 1][j]) % MOD

print(DP[-1][0])

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

int main() {
  string s;
  ll K;
  cin >> s >> K;
  for (ll i = 0; i < K; i++) {
    if(i==K-1) {
      cout << s.at(K-1) << endl;
      break;
    }
    else if(s.at(i)=='1') continue;
    else {
      cout << s.at(i) << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vvvd = vector<vector<vector<double>>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pint = pair<int, int>;
using Graph = vvi;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
bool cmp(pint a, pint b) {return a.second < b.second;}

int main() {
    int h, a;
    cin >> h >> a;

    int cnt = 0;
    while(h > 0) {
        h -= a;
        cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int d,n;
	ll x=1;
	ll m;
	cin>>d>>n;

	for(int i=0;i<d;i++){
		x = x*100;
	}
	if(n != 100){
		m=x*n;
	}
	else{
		m=x*(n+1);
	}
	cout<<m<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define max(x) *max_element(all(x))
#define min(x) *min_element(all(x))

using namespace std;

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

//二項係数の計算
void comint()
{
    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;
    }
}
ll 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;
}

//Nが素数か判定する
bool is_prime(ll N)
{
    for (ll i = 2; i * i < N; ++i)
    {
        if (N % i == 0)
            return false;
    }
    return true;
}

//Nを素因数分解した結果のリストを返す
vector<ll> soinsubunkai(long long N)
{
    vector<ll> tmp;
    ll num = N;
    for (ll i = 2; i * i <= N; ++i)
    {
        if (N % i == 0)
        {
            ll j = N / i;
            if (is_prime(i))
            {
                while (num % i == 0)
                {
                    tmp.push_back(i);
                    num /= i;
                }
            }
            if (is_prime(j))
            {
                while (num % j == 0)
                {
                    tmp.push_back(j);
                    num /= j;
                }
            }
        }
    }
    return tmp;
}

//法mにおけるaの逆元を返す
ll modinv(ll a, ll m)
{
    ll b = m, u = 1, v = 0;
    while (b)
    {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}

//法mにおけるa^bの値を返す
ll modpow(ll a, ll n, ll m)
{
    ll res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % m;
        a = a * a % m;
        n >>= 1;
    }
    return res;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll ans = 0;
    cin >> N;
    vector<ll> vec(N);
    rep(i, N) cin >> vec[i];
    vector<ll> ruisekiwa(N + 1);
    set<ll> st;
    ruisekiwa[0] = 0;
    rep(i, N)
    {
        ruisekiwa[i + 1] = ruisekiwa[i] + vec[i];
    }
    sort(all(ruisekiwa));
    map<ll, ll> mp;
    for (auto i : ruisekiwa)
        mp[i]++;

    for (auto i : mp)
    {
        ans += i.second * (i.second - 1) / 2;
    }

    cout << ans << endl;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define pint pair<int,int>
#define Lower(v,X) lower_bound(v.begin(),v.end(),X)-v.begin();
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
  lli A,B,C,D,E,X,Y,W,H,N,M,K,sum=0,num=0,flag=0;string S,T;
  cin >> H >> W >> A >> B;
  rep(i,0,H)rep(j,0,W){
    if(i<B&&j<A||i>=B&&j>=A)cout << 1;
    else cout << 0;
    if(j==W-1)cout << endl;
  }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, a, b;
    cin >> n;
    vector<int> d(n);
    for(int i=0; i<n; i++){ 
        cin >> d[i];
    }
    
    sort(d.begin(),d.end());
    
    a = d[n/2-1];
    b = d[n/2];
    
    if ( a == b ) {
        cout << "0" << endl;
    } else {
        cout << b - a << endl;
    }
    
    
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <unordered_set>

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

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

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

    int A, B;
    cin >> A >> B;

    cout << (A * B % 2 == 0 ? "No" : "Yes") << endl;

    return 0;
}


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

int main(){
	int A, i, ans = 0, x = 0;
	for(i = 0; i < 5; i++){
		scanf("%d", &A);
		ans += (A + 9) / 10 * 10;
		x = max(x, (1000 - A) % 10);
	}
	printf("%d\n", ans - x);
	return 0;
}

Measured memory_bytes: 256
#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; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n, m, d;
    cin>>n>>m>>d;

    if (1 + d > n) {
        cout<<0<<endl;
    }
    double f = d == 0 ? 1.0 : 2.0;
    printf("%.10f\n", f * (n - d) / n / n * (m - 1));
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<vector>
#include<tuple>
#include<queue>
#include<algorithm>

using namespace std;

using LL = long long;

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

	vector<tuple<int, int>> points; // [x, y]
	vector<tuple<int, int>> vx, vy; // [value, index];
	for (int i = 0; i < N; ++i)
	{
		int x;
		int y;
		cin >> x >> y;
		points.push_back(make_tuple(x, y));
		vx.push_back(make_tuple(x, i));
		vy.push_back(make_tuple(y, i));
	}

	sort(vx.begin(), vx.end());
	sort(vy.begin(), vy.end());

	set<int> sx, sy;
	priority_queue<tuple<int, int>> q; // [-dist, index];
	vector<bool> used(N);

	LL result = 0;
	q.push(make_tuple(0, 0));
	while (!q.empty())
	{
		auto t = q.top();
		q.pop();
		int dist, index;
		tie(dist, index) = t;

		if (used[index]) { continue; }
		used[index] = true;

		result += (-1 * dist);
		auto cx = get<0>(points[index]);
		auto cy = get<1>(points[index]);
		sx.insert(cx);
		sy.insert(cy);

		vector<int> nexts;

		auto ix = lower_bound(vx.begin(), vx.end(), make_tuple(cx, index));
		if (ix != vx.begin())
		{
			nexts.push_back(get<1>(*(ix - 1)));
		}
		if (ix + 1 != vx.end())
		{
			nexts.push_back(get<1>(*(ix + 1)));
		}
		auto iy = lower_bound(vy.begin(), vy.end(), make_tuple(cy, index));
		if (iy != vy.begin())
		{
			nexts.push_back(get<1>(*(iy - 1)));
		}
		if (iy + 1 != vy.end())
		{
			nexts.push_back(get<1>(*(iy + 1)));
		}
		sort(nexts.begin(), nexts.end());
		nexts.erase(unique(nexts.begin(), nexts.end()), nexts.end());

		for (auto next : nexts)
		{
			if (used[next]) { continue; }
			q.push(make_tuple(
				-1 * min(abs(cx - get<0>(points[next])), abs(cy - get<1>(points[next]))),
				next));
		}
	}

	cout << result << endl;

#ifdef _DEBUG
	system("pause");
#endif
}


Measured memory_bytes: 13400
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include <iomanip>
using namespace std;

int main(){
	long long int n,ans=0;
	cin>>n;
	for(int i=1;i<n;i++){
		ans+=i;
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 1000000000000000
#define MOD 1000000007
#define EPS 1e-10
#define MAX_N (1<<19)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,P> PP;

int n;
bool prime[1001];
vector<int> p;
map<int,int> m;
ll po[100000];

int main(){
    po[0] = 1;
    for(int i = 1; i < 100000; i++) po[i] = po[i-1]*2%MOD;
    cin >> n;
    for(int i = 2; i <= 1000; i++){
        if(prime[i]) continue;
        for(int j = i*2; j <= 1000; j += i) prime[j] = true;
    }
    for(int i = 2; i <= 1000; i++) if(!prime[i]) p.push_back(i);
    for(int i = 2; i <= n; i++){
        int I = i;
        rep(j,p.size()){
            while(I%p[j] == 0){
                m[p[j]]++;
                I /= p[j];
            }
        }
    }
    ll ans = 1;
    map<int,int>::iterator it;
    for(it = m.begin(); it != m.end(); it++){
        ans *= ((*it).second+1);
        ans %= MOD;
    }
    cout << ans << endl;
}



Measured memory_bytes: 1024
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	static final int MD = 1000000007;
	void main() {
		byte[] cc = sc.next().getBytes();
		int n = cc.length;
		int[] pp = new int[n];
		for (int p = 1, i = 0; i < n; i++) {
			pp[i] = p;
			p = (int) (p * 3L % MD);
		}
		long ans = 0, cnt = 1;
		for (int i = 0; i < n; i++)
			if (cc[i] == '1') {
				ans = (ans + cnt * pp[n - 1 - i]) % MD;
				cnt = cnt * 2 % MD;
			}
		ans = (ans + cnt) % MD;
		println(ans);
	}
}


Measured memory_bytes: 40008
/* -> Written by <-
   -----------
  |K_A_Z_A_M_A|
  |___________|
  |    ___    |
  |   (^_^)   |
  |  /( | )\  |
  |____|_|____|
    H O A N G
*/

// i hope i get better

// Task name:
#define Task ""
using namespace std;

// Include
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <string>
#include <sstream>
#include <cstdio>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>

// Define
#define reset(x, value) memset((x), (value) ,sizeof((x)))
#define fr(i,a,b) for(int i = (a); i <= (b); i++)
#define FR(i,a,b) for(int i = (a); i < (b); i++)
#define frr(i,a,b) for(int i = (a); i >= (b); i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define nl "\n"
#define bit(x,i) (x >> i) & 1
#define all(x) (x).begin(), (x).end()
#define optimize(x) (x).resize(unique(all(x)) - (x).begin())
#define Inpf freopen(Task".inp","r",stdin)
#define Outf freopen(Task".out","w",stdout)
#define fasterIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

// typedef
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vii;
typedef vector<ll> vll;

const int base = 131;
const int MOD = 1e9 + 7;
const ll MM = 1ll * MOD * MOD;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

void AddMOD(int &x, int y)
{
    x += y;
    if (x >= MOD)
        x -= MOD;
}
int Gcd(int x, int y)
{
    if (y == 0)
        return x;
    return Gcd(y, x % y);
}
template <class T> inline void Gmax(T &x,T y)
{
    x = max((x), (y));
}
template <class T> inline void Gmin(T &x,T y)
{
    x = min((x), (y));
}

void exit_with_runtime()
{
    db x = 1.0 * clock() / CLOCKS_PER_SEC;
    cerr << "\n\n---------------------\nTime elapsed: " << x << " s.\n\n";
    if (x > 1)
        cerr << "TIME LIMIT EXCEEDED!\n\n";
    exit(0);
}

// --------------------------------------------------------------------
const int maxn = 2e5 + 5;
// --------------------------------------------------------------------

string str[] = {"Sunny", "Cloudy", "Rainy"};

void Solve()
{
    string s;
    cin >> s;
    for (int i = 0; i <= 2; i ++)
        if (s == str[i]) cout << str[(i+1)%3];


}

int main()
{
#ifndef ONLINE_JUDGE
//    Inpf;
//    Outf;
#endif // ONLINE_JUDGE
    fasterIO;
    int test = 1;
//    cin >> test;
    while (test --)
        Solve();

    // Did you check with the special test case n = 0, n = 1??
    exit_with_runtime();
}

// Goodbye, see u again


Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>

const int MN = 100005;

int N, A[MN], B[MN], Ans;

int main() {
	scanf("%d", &N);
	for (int i = 1; i <= N; ++i) scanf("%d", &A[i]), B[i] = A[i];
	std::sort(B + 1, B + N + 1);
	for (int i = 1; i <= N; ++i)
		Ans += (std::lower_bound(B + 1, B + N + 1, A[i]) - B - i) & 1;
	printf("%d\n", Ans >> 1);
	return 0;
}

Measured memory_bytes: 896