akhauriyash/Code-Regression huggingface dataset:
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define ushi int
#define tapu main
#define nichia (
#define kunn void
#define wara )

using ll = long long;

const int INF = 1073741823;
const int MINF = -1073741823;
const ll LINF = ll(4661686018427387903);
const ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/

int main(){

	int a;
	map<int, int> b;
	rep(i, 3) {
		scanf("%d", &a);
		b[a]++;
	}
	printf("%d\n", b.size());

	Please AC;
}


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

int x, n, d = 102, m, a;
bool p[101];

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

	for (int i = 0; i < n; i++) {
		cin >> a;

		p[a] = 1;
	}

	for (int i = 0; i < 102; i++) {
		if (!p[i] && d > abs(i - x)) {
			d = abs(i - x);
			m = i;
		}
	}

	cout << m << endl;
}


Measured memory_bytes: 3604
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



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

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)









 
int main(){
    double a, b, x;
    cin >> a >> b >> x;
    const double PI = acos(-1);
    double l = 0, r = PI / 2;
    REP(i, 100){
        double t = (l + r) / 2.0, s;
        if(b * sin(t) >= a * cos(t)){
            double d = b, u = max((b * sin(t) - a * cos(t)) / sin(t), 0.0);
            double h = (d + u) / 2.0;
            s = a * a * h;
        }
        else{
            double aa = sqrt((b / cos(t)) * (b / cos(t)) - b * b);
            s = aa * a * b / 2.0;
        }
        if(s >= x){
            r = t;
        }
        else{
            l = t;
        }
    }
    printf("%.8lf\n", 90 - 180 / PI * l);
}

Measured memory_bytes: 256
#include <stdio.h>
long long n, ans;
int main() {
	scanf("%lld", &n);
	if (n % 2) {
		printf("0\n");
		return 0;
	}
	n /= 2;
	while (n) {
		ans += n / 5;
		n /= 5;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define debug(n) cout << "DEBUG1 " << n << "\n";
#define debug2(n, m) cout << "DEBUG2 " << n << ' ' << m << "\n";
#define debug3(n, m, x) cout << "DEBUG3 " << n << ' ' << m << ' ' << x << "\n";
#define ss_def stringstream ss // stringstream, do ss_def(str), then ss >> n (n is int)
#pragma GCC optimize("Ofast")
using namespace std;
ll int BtoPmodM(ll int b, ll int p, ll int m) { // (b ^ p) % m (Big Mod)
    b %= m;
    if (p == 0) return 1;
    else if (p % 2 == 0) return (BtoPmodM(b, p / 2, m) * BtoPmodM(b, p / 2, m)) % m; // a^(p/2) * a^(p/2) = a^p
    else if (p % 2 == 1) return (BtoPmodM(b, (p - 1) / 2, m) * BtoPmodM(b, (p - 1) / 2, m) * b) % m; // +1
    else return 0; // a function must return something
}
ll int euclidalgo(ll int a, ll int b) { // Euclidean Algorithm
    if (b == 0) {
        return a;
    } else {
        return euclidalgo(b,a % b);
    }
}
bool coprime(ll int a, ll int b) {
    if (euclidalgo(a, b) == 1) return true;
    else return false;
}
ll int factModP(ll int n, ll int p) {
    ll int fac[n - 1];
    fac[0] = 1;
    for (ll int i = 1;i <= n;i++) {
        fac[i] = fac[i - 1] * i % p;
    }
    return fac[n];
}
ll int power(ll int x, ll int y, ll int p) { // x ^ y % p
    ll int res = 1;
    x = x % p;
    while (y > 0) { 
        if (y & 1) res = (res * x) % p; 
        y /= 2; 
        x = (x * x) % p; 
    } 
    return res; 
}
ll int modInverse(ll int n, ll int p) {
    return power(n, p - 2, p); 
}
ll int nCrModPFermat(ll int n, ll int r, ll int p) {
    if (r == 0) return 1; 
    ll int fac[n + 1]; 
    fac[0] = 1; 
    for (ll int i = 1;i <= n;i++) {
        fac[i] = fac[i - 1] * i % p; 
    }
    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; 
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // implementation
    string str;
    cin >> str;
    if (str[2] == str[3] && str[4] == str[5]) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
//very good problem
vector<int>edge[100005];
int n;
int dfs(int v,int u){
	int cnt[20]={}; vector<int>vec;
	for(int i=0;i<edge[v].size();i++){
		if(u == edge[v][i]) continue;
		int y = dfs(edge[v][i],v);
		rep(j,20) if(((y>>j)&1)) cnt[j]++;
		vec.pb(y);
	}
	int mx = INF;
	for(int j=19;j>=0;j--){
		if(cnt[j] == 0) mx=j;
		else if(cnt[j] >= 2) break;
	}
	int ret = (1<<mx);
	for(int i=0;i<vec.size();i++){
		int x = vec[i]/(1<<mx) * (1<<mx);
		ret |= x;
	}
	return ret;
}
int main(){
	cin>>n;
	rep(i,n-1){
		int a,b;cin>>a>>b;
		edge[a].pb(b);
		edge[b].pb(a);
	}
	int x = dfs(1,-1);
	rep(i,20) if(((x>>(19-i))&1)) {cout<<19-i<<endl;return 0;}
}

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

int	main()
{
	int	K;
	cin >> K;
	queue<int64_t>	que;
	int	idx = 0;
	for (int i = 1; i < 10; ++i) {
		if (idx == K - 1) {
			cout << i << endl;
			return 0;
		}
		++idx;
		que.push(i);
	}
	int64_t	num1, num2;
	int		r;
	while (idx <= K) {
		num1 = que.front(); que.pop();
		r = static_cast<int>(num1 % 10);
		for (int i = max(r - 1, 0); i <= min(r + 1, 9); ++i) {
			num2 = num1 * 10 + i;
			if (idx == K - 1) {
				cout << num2 << endl;
				return 0;
			}
			++idx;
			que.push(num2);
		}
	}
	return 0;
}




Measured memory_bytes: 768
n,a,b,c=map(int,input().split())
s_=[input() for i in range(n)]
ans=""
for i in range(n):
    s1,s2=s_[i]
    if s2=="B":
        if a==1 and b==1 and i!=n-1:
            if s_[i+1][0]=="A":
                a,b,ans=(a+1,b-1,ans+"A")
            else:
                a,b,ans=(a-1,b+1,ans+"B")
            continue
        a,b,ans=(a-1,b+1,ans+"B") if a>b else (a+1,b-1,ans+"A")
        if min(a,b)==-1:
            print("No")
            break
    elif s1=="A":
        if a==1 and c==1 and i!=n-1:
            if s_[i+1][1]=="C":
                a,c,ans=(a-1,c+1,ans+"C")
            else:
                a,c,ans=(a+1,c-1,ans+"A")
            continue
        a,c,ans=(a-1,c+1,ans+"C") if a>c else (a+1,c-1,ans+"A")
        if min(a,c)==-1:
            print("No")
            break
    else:
        if c==1 and b==1 and i!=n-1:
            if s_[i+1][1]=="C":
                b,c,ans=(b-1,c+1,ans+"C")
            else:
                b,c,ans=(b+1,c-1,ans+"B")
            continue
        b,c,ans=(b-1,c+1,ans+"C") if b>c else (b+1,c-1,ans+"B")
        if min(b,c)==-1:
            print("No")
            break
else:
    print("Yes")
    for j in range(n):
        print(ans[j])



Measured memory_bytes: 135184
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep_start(a,i,n) for(ll i=a;i<=n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define rev1(i,n) for(ll i=n;i>0;i--)
#define sz(a) int((a).size())
#define all(c) c.begin,c.end()
#define tr(c,i) for(typeof(c).begin() i=c.begin; i!=c.end(); i++)
#define present(c,x) (c.find(x)!=c.end())
#define cpresent(c,x) (find(all(c),x)!=c.end())
#define pb push_back
#define F first
#define S second
#define INF 1e9+7
typedef long long int ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

const int N=4e3+7;
int R[N],G[N],B[N];

void solve(){
    int n;string s;
    cin>>n>>s;
    int r=0,g=0,b=0;
    rev(i,n){
        if(s[i]=='R') r++;
        if(s[i]=='G') g++;
        if(s[i]=='B') b++;
        R[i]=r;G[i]=g;B[i]=b;
    }
    ll ans=0;
    bool rr=0,gg=0,bb=0;
    rep(i,n-2)
        for(int j=i+1;j<n-1;j++)
            if(s[i]!=s[j]){
                rr=s[i]=='R' || s[j]=='R';
                gg=s[i]=='G' || s[j]=='G';
                bb=s[i]=='B' || s[j]=='B';
                //cout<<ans<<" ";
                if(!rr) ans+=R[j+1] - (j+j-i<n && s[j+j-i]=='R');
                if(!gg) ans+=G[j+1] - (j+j-i<n && s[j+j-i]=='G');
                if(!bb) ans+=B[j+1] - (j+j-i<n && s[j+j-i]=='B');
                //cout<<ans<<" "<<s[j+j-i]<<"\n";
            }
    cout<<ans;
}

signed main() {
    // your code goes here
    IOS
    ll t=1;
    //cin>>t;
    rep1(i,t){
        solve(); 
    }
}

Measured memory_bytes: 3700
use std::io::stdin;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let mut itr = s.split_whitespace().map(|e| e.parse().unwrap());
    let n: i64 = itr.next().unwrap();
    let m: i64 = itr.next().unwrap();
    s.clear();
    stdin().read_line(&mut s).ok();
    let mut itr = s.split_whitespace().map(|e| e.parse::<i64>().unwrap());
    let ans = n - itr.sum::<i64>();
    let ans = if ans >= 0 { ans } else { -1 };

    println!("{}", ans);
}


Measured memory_bytes: 2172
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	vector <char> a(4);
	int ans = 0;
	for (int i =0; i<4;i++) {
		cin >> a[i];
		if (a[i] == '+') ans++;
		else ans--;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

// Manages Weighted Union-Find Forest.
class WeightedUnionFindForest {
  std::vector<int> parent_;
  std::vector<int> rank_;
  std::vector<int> size_;
  std::vector<int> weight_;

 public:
  // Initialize forest.
  // parent_[i]=i, rank_[i]=0, size_[i]=1, weight_[i]=0.
  WeightedUnionFindForest(int n);
  // Get the number of the root of the node q.
  int Root(int q);
  // Return true if the roots of x and y is same.
  bool IsSame(int x, int y);
  // Unite the tree x and tree y(weight is w).
  // If x and y already have been united, return false.
  bool Unite(int x, int y, int w);
  // Get the number of nodes which are the same group as node q.
  int Size(int q);
  // Get the weight of node q.
  int Weight(int q);
  // Get the weights' difference of node x and y.
  int Diff(int x, int y);
};

WeightedUnionFindForest::WeightedUnionFindForest(int n) {
  for (int i = 0; i < n; i++) {
    parent_.push_back(i);
    rank_.push_back(0);
    size_.push_back(1);
    weight_.push_back(0);
  }
}
int WeightedUnionFindForest::Size(int q) {
  return size_[Root(q)];
}
int WeightedUnionFindForest::Root(int q) {
  if (parent_[q] == q) {
    return q;
  } else {
    int r = Root(parent_[q]);
    weight_[q] += weight_[parent_[q]];
    return parent_[q] = r;
  }
}

bool WeightedUnionFindForest::IsSame(int x, int y) {
  return Root(x) == Root(y);
}

int WeightedUnionFindForest::Weight(int q) {
  Root(q);  // compress path
  return weight_[q];
}
int WeightedUnionFindForest::Diff(int x, int y) {
  if (Root(x) != Root(y)) {
    // cerr << "WeightedUnionFindForest: Error" << endl;
    // cerr << "Roots of node x and y aren't same" << endl;
    return INT32_MAX;
  }
  return Weight(y) - Weight(x);
}

bool WeightedUnionFindForest::Unite(int x, int y, int w) {
  w += Weight(x);
  w -= Weight(y);
  x = Root(x);
  y = Root(y);

  if (x == y) return false;
  if (rank_[x] < rank_[y]) {
    weight_[x] = w * (-1);
    parent_[x] = y;
    size_[y] += size_[x];
    size_[x] = 0;

  } else {
    weight_[y] = w;
    parent_[y] = x;
    size_[x] += size_[y];
    size_[y] = 0;
    if (rank_[x] == rank_[y]) rank_[x]++;
  }
  return true;
}

// for verifying
// this code solves Weighted Union Find
// Trees(http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_1_B&lang=jp).

int main(void) {
  int n, q;
  cin >> n >> q;
  WeightedUnionFindForest WUFF(n);
  for (int i = 0; i < q; i++) {
    int a, x, y, z;
    cin >> a;
    switch (a) {
      case 0:
        cin >> x >> y >> z;
        WUFF.Unite(x, y, z);
        break;
      case 1:
        cin >> x >> y;
        int result = WUFF.Diff(x, y);
        if (result == INT32_MAX) {
          cout << "?" << endl;
        } else {
          cout << result << endl;
        }
    }
  }
  return 0;
}


Measured memory_bytes: 4688
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
using namespace std;
typedef long long ll;
int main(){
  int n,m;
  cin >> n >> m;
  rep(i,m){
    int a;
    cin >> a;
    n -= a;
//    cout << n <<endl;
  }
  if(n>=0) cout << n << endl;
  else cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 3628
S = input()
T = input()
lens = len(S)
lent = len(T)
mincnt = lent
for i in range(lens - lent + 1):
  parts = S[i:i+lent]
  cnt = 0
  for j in range(lent):
    if parts[j] != T[j]:
      cnt += 1
  mincnt = min(mincnt, cnt)
print(mincnt)

Measured memory_bytes: 9060
def main():
    from sys import stdin
    input = stdin.readline
    mod = 10**9+7
    n = int(input())
    ab = [list(map(int, input().split())) for _ in [0]*(n-1)]
    pow2 = [1]
    for i in range(200000):
        pow2.append(pow2[-1]*2 % mod)

    g = [set() for _ in [0]*n]
    [g[a-1].add(b-1) for a, b in ab]
    [g[b-1].add(a-1) for a, b in ab]
    root = 0
    d = [-1]*n
    d[root] = 0
    q = [root]
    cnt = 0
    while q:
        cnt += 1
        qq = []
        while q:
            i = q.pop()
            for j in g[i]:
                if d[j] == -1:
                    d[j] = cnt
                    qq.append(j)
        q = qq

    for i in range(n):
        di = d[i]
        remove_list = []
        for j in g[i]:
            if di > d[j]:
                remove_list.append(j)
        for j in remove_list:
            g[i].remove(j)
    dd = sorted([(j, i) for i, j in enumerate(d)])[::-1]
    dd = [j for i, j in dd]

    dp = [(0, 0, 1) for _ in [0]*n]
    for i in dd:
        if g:
            n = 1
            for j in g[i]:
                if j != i:
                    n += dp[j][2]
            x, y = pow(2, n-1, mod)-1, 0
            for j in g[i]:
                if j != i:
                    xj, yj, nj = dp[j]
                    p1, p2 = pow2[n-nj], pow2[nj]
                    x += xj*p1+yj*(p1-1)-p2+1
                    y += yj+p2-1
            dp[i] = (x % mod, y % mod, n)

    x = dp[0][0]
    y = pow(2, dp[0][2], mod)
    print(x*pow(y, mod-2, mod) % mod)


main()


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<a+b+c-max({a,b,c})<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e8;
const ll INF=1e16;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	string a,b,c;
	cin>>a>>b>>c;
	cout<<(char)toupper(a[0])<<(char)toupper(b[0])<<(char)toupper(c[0])<<endl;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{ 
   int n,cnt=1;
  scanf("%d",&n);
  
   string s,t;
   cin>>s>>t;
   int i,j;
   
  for(i=0,j=0;i<n || j<n;)
  {
     if(cnt%2!=0)
     { cout<<s[i];
         i++;
     }
    
     else
     {
       cout<<t[j];
       j++;
     }
    
    cnt++;
  }
    
   
  
  
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define lop(i, n) for(i=0; i<n; i++)

int main()
{
	int N, A[200000], i, j, max1=0, max2=0;
	
	scanf("%d", &N);
	
	lop(i, N){
		scanf("%d", &A[i]);
	}
	
	lop(i, N){
		if(max1<A[i]){
			max2=max1; max1=A[i];
		}else if(max2<A[i]) max2=A[i];
	}
	if(max1==max2){
		lop(i, N) printf("%d\n", max1);
	}
	else{
		lop(i,N){
			if(max1==A[i]) printf("%d\n", max2);
			else printf("%d\n", max1);
		}
	}
	return 0;
}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for(int i = (int)(n); i > 0; --i)
#define all(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rall(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)
#define sz(a) (int)(a).size()
#define mins(a,...) a = min<decltype(a)>({a, ## __VA_ARGS__})
#define maxs(a,...) a = max<decltype(a)>({a, ## __VA_ARGS__})
#define plusMod(a,b) a = (a % mod + b % mod) % mod
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) {
    return os.put(os.widen('\n'));
}
template<typename A, size_t N, typename T>
void fillArray(A(&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}

ll n;
void solve() {
    cin >> n;

    if (n == 1) {
        cout << 0 << endn;
    }
    else if (n == 2) {
        cout << 1 << endn;
    }
    else {
        cout << (2 + n - 1) * (n - 2) / 2 + 1 << endn;
    }

}


int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    solve();

    cout << flush;

    return 0;
}


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

int main() {
  int N;cin>>N;
  double ave=0;
  vector<int> A(N);
  rep(i,N) {
    cin>>A[i];
    ave += A[i];
  }
  ave/=N;
  int ans=0;
  rep(i,N) {
    if(abs(A[ans]-ave) > abs(A[i]-ave)) {
      ans=i;
    }
  }
  cout<<ans<<endl;
}

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

using namespace std;

int main()
{
    int n, m, dx[] = {-1, 0, 1, 0}, dy[]= {0, 1, 0, -1};
    char mat[51][51];
    cin >> n >> m;
    for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
        cin >> mat[i][j];
    }

    int isB, x, y;
    for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
        if (mat[i][j] == '#') {
        isB = 0;
        for (int d = 0; d < 4; ++d) {
            x = i + dx[d];
            y = j + dy[d];
            if (x != 0 && x != n + 1 && y != 0 && y != m + 1)
                if (mat[x][y] == '#')
                    isB = 1;
        }
        if (!isB) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
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; }
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
const int MAX=2e5;
const ll MOD=1e9+7;
const int INF=1<<30;
ll kiriage(ll a,ll b){return a%b==0?a/b:a/b+1;}

int main(){
  ll N; cin >> N;
  if(N%2==1) cout << 0 << endl;
  else{
    ll ans=0;
    ll waru=10;
    while(waru<=N){
      ans+=N/waru;
      waru*=5;
    }
    cout << ans << endl;
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N,K;
    cin >> N >> K;
    string S;
    cin >> S;
    long opposite_counter=0;
    for(size_t i=0;i<N; i++)
    {
        if(S.substr(i, 2) == "LR" || S.substr(i, 2) == "RL")
        {
            opposite_counter++;
        }
    }

    if(opposite_counter <= K * 2) opposite_counter = 0;
    else opposite_counter -= K*2;
    
    cout << (N-1) - opposite_counter << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
int X[MAX_N], Y[MAX_N];
int idx[MAX_N];

void solve() {
	cin >> N;
	rep(i, 0, N) {
		cin >> X[i] >> Y[i];
		idx[i] = i;
	}
	sort(idx, idx + N, [](int a, int b) {
			return atan2(Y[a], X[a]) < atan2(Y[b], X[b]);
			});
	// rep(i, 0, N) {
	// 	debug(X[idx[i]], Y[idx[i]]);
	// }
	ll res = 0;
	rep(i, 1, N + 1) {
		rep(j, 0, N) {
			ll x = 0, y = 0;
			rep(k, 0, i) {
				int id = idx[(j + k) % N];
				x += X[id]; y += Y[id];
			}
			if(res < x * x + y * y) {
				res = x * x + y * y;
			}
		}
	}
	cout << sqrt(res) << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 2432
#include <cstdio>
#define FOR(i, l, r) for(int i = l; i <= r; ++i)
using namespace std;

int n, a[310][310];
long long ans;

int main()
{
    scanf("%d", &n);
    FOR(i, 1, n) FOR(j, 1, n) scanf("%d", &a[i][j]);
    FOR(i, 1, n) FOR(j, i + 1, n)
    {
        bool fl = 1;
        FOR(k, 1, n) if (k != i && k != j)
        {
            if (a[i][k] + a[k][j] == a[i][j]) fl = 0; else
            if (a[i][k] + a[k][j] < a[i][j]) {puts("-1"); return 0;}
        }
        if (fl) ans += a[i][j];
    }
    printf("%lld\n", ans);
    return 0;
}


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

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

    if ((A[A.size() - 1] == B[0]) && (B[B.size() - 1] == C[0]))
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
	int r, D, x;
	cin >> r >> D >> x;
	vector<int> y(11);
	y[0] = x;
	rep(i, 10) {
		y[i+1] = r*y[i] - D;
		cout << y[i+1] << endl;
	}



	return 0;
}



Measured memory_bytes: 764
import sys
import bisect

n = int(input())
*l, = map(int, input().split())
l.sort()
ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        c = bisect.bisect_left(l, l[i] + l[j], j+1)
        ans += c - j - 1

print(ans)

Measured memory_bytes: 3188
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
char in[119];
int main(){
	int a,b;
	scanf("%d%s%d",&a,in,&b);
	if(in[0]=='+')printf("%d\n",a+b);
	else printf("%d\n",a-b);
}

Measured memory_bytes: 128
import scala.io.StdIn
import scala.annotation.tailrec

object Main{
  def main(args: Array[String]){
    StdIn.readLine()
    val line = StdIn.readLine().split(" ").toVector.map(_.toInt)

    val res = sSort(Vector(), line, 0)
    println(res._1.mkString(" ") + "\n" + res._2)
  }

  @tailrec
  def sSort(sorted: Vector[Int], unsorted: Vector[Int], n: Int):(Vector[Int], Int)={
    if(unsorted.sorted == unsorted) ((sorted ++ unsorted), n)
    else if(unsorted.indexWhere(_ == unsorted.min) == 0) sSort(sorted :+ unsorted.head, unsorted.tail, n)
    else {
      val pos = unsorted.indexWhere(_ == unsorted.min)
      val swapped = unsorted.updated(0, unsorted(pos)).updated(pos, unsorted.head)

      sSort(sorted :+ unsorted.min, swapped.tail, n+1)
    }
  }
}

Measured memory_bytes: 45992
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    u64 mod = 1'000'000'007;

    u64 n;
    std::cin >> n;

    u64 ans = 1;
    for (u64 i=1; i<=n; i++) {
        ans = ans * i % mod;
    }
    std::cout << ans << '\n';
}


Measured memory_bytes: 256
// Prime Flip
// * frank_c1
// * 2017 / 12 / 24

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

const int maxn = 205;
const int maxM = (int)(1e7) + 5;
int pr[maxM], chk[maxM];

void gen() {
	int mx = (int)(1e7) + 1, tot = 0;
	chk[1] = 1;
	for (int i = 2; i <= mx; ++i) {
		if (!chk[i]) {
			pr[++tot] = i;
		}
		for (int j = 1; j <= tot; ++j) {
			if (i * pr[j] > mx) break;
			chk[i * pr[j]] = 1;
			if (i % pr[j] == 0) break;
		}
	}
}

int a[maxn], b[maxn], vi[maxn], lk[maxn];
int idx;

int Find(int x) {
	for (int i = 1; i <= idx; ++i) 
		if (!vi[i] && !(b[i] & 1)) {
			if (!chk[max(b[x], b[i]) - min(b[x], b[i])]) {
				vi[i] = 1;
				if (!lk[i] || Find(lk[i])) {
					lk[i] = x; return 1;
				}
			}
		}
	return 0;
}

int main() {
	gen();
	int n;
	scanf("%d", &n); a[0] = -1;
	for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	for (int i = 1; i <= n; ++i) {
		if (a[i] - 1 != a[i - 1]) b[++idx] = a[i];
		if (a[i] + 1 != a[i + 1]) b[++idx] = a[i] + 1;
	}
	int ret = 0, cnt = 0;
	for (int i = 1; i <= idx; ++i) if (b[i] & 1) {
		memset(vi, 0, sizeof(vi)); ret += Find(i); ++cnt;
	} 
	return printf("%d\n", ret + ((cnt - ret) / 2 + (idx - cnt - ret) / 2) * 2 + ((cnt - ret) % 2) * 3), 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }

const int maxn = 1e6 + 11;

int main() {

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

  int N, D;
  cin >> N >> D;

  int i = 1;
  int ans = 0;
  while (i <= N) {
    ans++;
    i += (2*D)+1;
  }

  cout << ans << "\n";


  return 0;
}


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

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}
struct UnionFind {
  vector<ll> par;  // 親ノード
  vector<ll> rank; // ランク
  vector<ll> ren;
  UnionFind(int n = 1) { init(n); }

  void init(int n = 1) {
    par.resize(n);
    rank.resize(n);
    ren.resize(n);
    for(int i = 0; i < n; ++i) {
      par[i] = i, rank[i] = 0, ren[i] = 1;
    }
  }

  int root(int x) {
    if(par[x] == x) {
      return x;
    } else {
      int r = root(par[x]);
      return par[x] = r;
    }
  }

  bool issame(int x, int y) { return root(x) == root(y); }

  bool merge(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y)
      return false;
    if(rank[x] < rank[y])
      swap(x, y);
    if(rank[x] == rank[y])
      ++rank[x];
    par[y] = x;
    ren[x] += ren[y];
    return true;
  }

  int getSize(int x) {
    int rootX = root(x);
    return ren[rootX];
  }
};

/*ex
UnionFind uf(N);
    double hosyu = 0;
    for (auto e : edges) {
        int u = e.second.first, v = e.second.second;
        if (uf.issame(u, v)) continue;
        hosyu += e.first;
        uf.merge(u, v);
    }
    cout << fixed << setprecision(10) << all - hosyu << endl;
*/

/*ex
UnionFind uf(N);
    double hosyu = 0;
    for (auto e : edges) {
        int u = e.second.first, v = e.second.second;
        if (uf.issame(u, v)) continue;
        hosyu += e.first;
        uf.merge(u, v);
    }
    cout << fixed << setprecision(10) << all - hosyu << endl;
*/

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, m;
  cin >> n >> m;
  VLL a(m), b(m);
  rep(i, m) {
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
  }
  reverse(all(a));
  reverse(all(b));
  VLL ans;
  UnionFind uf(n);
  ll cnt = (n - 1) * n / 2ll;

  rep(i, m) {
    ans.push_back(cnt);
    if(uf.issame(a[i], b[i])) {
      continue;
    }
    cnt -= (ll(uf.getSize(a[i])) * ll(uf.getSize(b[i])));
    uf.merge(a[i], b[i]);
  }
  reverse(all(ans));
  rep(i, m) { cout << ans[i] << endl; }
  return 0;
}


Measured memory_bytes: 6132
//hi
#include<bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define inf 100000000
typedef long long int LL;
struct hashfunc {
	template<typename T, typename U>
	size_t operator()(const pair<T, U> &x) const {
		return hash<T>()(x.F) ^ hash<U>()(x.S);
	}
};
struct ND{
	pair<int,int> to;
	int c;
	ND(){}
	ND(pair<int,int> to,int c):to(to),c(c){}
};
unordered_map< pair<int,int>, int ,hashfunc> ids;
unordered_map< pair<int,int>, int ,hashfunc>::iterator it;
pair<int,int> rids[1000006];
int cnt;
vector< pair<int,int> > v[1000006];
int d[1000006];
int vis[1000006];
priority_queue< pair<LL, int > > pq; //pos, getid
int getid(int a,int c){
	pair<int,int> now=MP(a,c);
	it=ids.find(now);
	if(it==ids.end()){
		ids.insert(MP(now,cnt));
		rids[cnt]=now;
		return cnt++;
	}else{
		return it->S;
	}
}
int main(void){
    int n,m;
    scanf("%d%d",&n,&m);
    int i;
    cnt=0;
    for(i=0;i<m;i++){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		int A=getid(a,c);
		int B=getid(b,c);
		v[A].PB(MP(B,0));
		v[B].PB(MP(A,0));
	}
	int cnt2=cnt;
	for(i=0;i<cnt2;i++){
		pair<int,int> now=rids[i];
		int B=getid(now.F,0);
		v[i].PB(MP(B,1));
		v[B].PB(MP(i,0));
	}
	for(i=0;i<cnt;i++){
		d[i]=inf;
		vis[i]=0;
	}
	int st=getid(1,0);
	d[st]=1;
	pq.push(MP(-1,st));
	LL ans=inf;
	while(!pq.empty()){
		pair<LL, int > now=pq.top();
		pq.pop();
		if(vis[now.S]) continue;
		vis[now.S]=1;
		//printf("%d %d : %d\n",rids[now.S].F,rids[now.S].S,now.F);
		for(i=0;i<v[now.S].size();i++){
			int nxt=v[now.S][i].F;
			int g=v[now.S][i].S + (-now.F);
			//printf("  %d %d : %d\n",rids[nxt].F,rids[nxt].S,g);
			if(vis[nxt]) continue;
			if(d[nxt]>g){
				d[nxt]=g;
				pq.push(MP(-g, nxt));
			}
		}
	}
	int ed=getid(n,0);
	if(d[ed]==inf) printf("-1\n");
	else printf("%d\n",d[ed]-1);
    return 0;
}


Measured memory_bytes: 82420
# coding= utf-8
abN=input("")
nab=abN.split(" ")
rn=int(nab[0])
ra=int(nab[1])
rb=int(nab[2])
p=[int(s+1) for s in range(rn)]
def counting(s):
    if s<10:
        if ra<=s<=rb:
            return s
    if 10<=s<100:
        s=str(s)
        w10=int(s[0:1])
        w1=int(s[1:2])
        s=int(s)
        ww=w10+w1
        if ra<=ww<=rb:
            return s
    if 100<=s<1000:
        s=str(s)
        w100=int(s[0:1])
        w10=int(s[1:2])
        w1=int(s[2:3])
        s=int(s)
        ww=w100+w10+w1
        if ra<=ww<=rb:
            return s
    if 1000<=s<10000:
        s=str(s)
        w1000=int(s[0:1])
        w100=int(s[1:2])
        w10=int(s[2:3])
        w1=int(s[3:4])
        s=int(s)
        ww=w1000+w100+w10+w1
        if ra<=ww<=rb:
            return s
    if 10000==s:
        if ra<=1<=rb:
            return s
    else:
        return 0
r=map(counting,p)
g=list(r)
print(sum(g))

Measured memory_bytes: 9700
#include <bits/stdc++.h>
#pragma GCC target("avx2")
using namespace std;

signed main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin >> n;
	vector < bool > prime(n + 1, 1);
	vector < long long > f(n + 1, 1);
	prime[1] = prime[0] = 0;
	for (int i = 2; i <= n; ++i) {
		if (prime[i]) { 
			prime[i] = 1;
			f[i] = 2;
			for (int j = 2 * i; j <= n; j += i) {
				prime[j] = 0;
				long long cnt = 1;
				int x = j;
				while (x % i == 0)
					++cnt, x /= i;
				f[j] *= cnt;
			}
		}
	}
	long long ans = 0;
	for (long long k = 1; k <= n; ++k) 
		ans += k * f[k];
	cout << ans << '\n';
}


Measured memory_bytes: 82604
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    a = int(input())
    print(a ** 3 + a ** 2 + a)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9084
n=int(input())
A=[]
B=[]
for i in range(n):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)

A.sort()
B.sort()
if n%2==1:
    u=(n+1)//2-1 
    print(B[u]-A[u]+1)
else:
    u=n//2-1
    w=u+1 
    print(B[u]+B[w]-A[u]-A[w]+1)

Measured memory_bytes: 99008
n,k=map(int,input().split())
m=[1 for i in range(n)]
for _ in range(k):
    d=int(input())
    x=list(map(int,input().split()))
    for i in x:
        m[i-1]=0
ans=0
for i in m:
    if i==1:
        ans+=1
print(ans)


Measured memory_bytes: 9192
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    string str;
    cin >> str;
    vector<int> nums(str.size());

    // char -> int 変換
  transform(str.begin(), str.end(), nums.begin(), [](char ch) { return ch - '0';});

  const int* result = nums.data(); // int列の先頭 と
  int sum = 0;
  for (int i = 0; i < nums.size(); i++){
      sum += result[i];
  }

  if (sum % 9 == 0){
      cout << "Yes" << endl;
  }
  else{
      cout << "No" << endl;
  }


}

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



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

	long long sum ;
	sum = (x/500)*1000;

	x = x%500;

	sum += (x/5)*5;
	x = x%5;
	cout<<sum<<"\n";
	
    return 0;
		
}

Measured memory_bytes: 3616
mod = 1000000007
eps = 10**-9


def main():
    import sys
    import math
    input = sys.stdin.readline

    x = int(input())

    t = 0
    a = 100
    while True:
        t += 1
        a = math.floor(a * 1.01)
        if a >= x:
            print(t)
            break


if __name__ == '__main__':
    main()


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

int GCD(int a,int b){
    if(a<b) swap(a,b);
    //cout << a << " " << b << endl;
    if(b == 0) return a;
    else return GCD(a%b, b);
}

int LCM(int a,int b){
    int x = GCD(a,b);
    return a*b/x;
}

int main(){
    int N; cin >> N;
    int a[N];
    for(int i=0;i<N;i++) cin >> a[i];
    int ans = 0;
    for(int i=0;i<N;i++) ans += a[i];
    cout << ans-N << endl;
}



Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(unsigned x){
  int s=0;
  char f[10];
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(unsigned long long x){
  int s=0;
  char f[21];
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(double x){
  printf("%.15f",x);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
inline void wt_L(string &x){
  int i=0;
  for(i=0;x[i]!='\0';i++){
    putchar_unlocked(x[i]);
  }
}
template<class T> inline T pow3_L(T a){
  return a*a*a;
}
int main(){
  int N;
  rd(N);
  wt_L(pow3_L(N));
  wt_L('\n');
  return 0;
}
// cLay varsion 20190914-1

// --- original code ---
// {
//   int N;
//   rd(N);
//   wt(N**3);
// }


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

#define MAX_N 200000

using namespace std;

typedef long long lint;

int n, l;

int v[MAX_N + 1];

lint rez = 0;

lint st[MAX_N + 1];
lint dr[MAX_N + 2];

lint getSumSt(int s, int d)
{
    if(s > d)
        return 0;

    return (st[d] - st[s - 1]);
}

lint getSumDr(int s, int d)
{
    if(s > d)
        return 0;

    return (dr[n - d + 1] - dr[n - s + 1 + 1]);
}

void calc(int cl, int sign)
{
    lint cr;
    int i, j, h;
    for(int x = 1; x <= n; x ++)
    {
        cr = v[x];

        if(cl == 1)
            cr = l - v[n - x + 1];

        h = cl;

        i = x;
        j = 0;

        if(cl == 1)
            swap(i, j);

        cout << "AM INCEPUT " << i << " " << j << " " << h << " COST " << cr << "\n";

        while(i + j < n)
        {
            if(h == 0)
            {
                cr = cr + v[i] + l - v[n - j];
                j ++;
            }

            if(h == 1)
            {
                cr = cr + l - v[n - j + 1] + v[i + 1];
                i ++;
            }

            h = 1 - h;
        }

        cout << "AM TERMIANT " << i << " " << j << " " << h << " COST " << cr << "\n";

        rez = max(rez, cr);
    }
}

void calc2(int cl, int sign)
{
    lint cr;
    int i, j, h;
    for(int x = 1; x <= n; x ++)
    {
        cr = v[x];

        if(cl == 1)
            cr = l - v[n - x + 1];

        h = cl;

        i = x;
        j = 0;

        if(cl == 1)
            swap(i, j);

       // cout << "AM INCEPUT " << i << " " << j << " " << h << " COST " << cr << "\n";

        int oi = i;
        int oj = j;
        int inc = n - (i + j);

        if(inc > 0)
        {
            i += (inc >> 1);
            j += (inc >> 1);

            int ok = 0;
            if((inc & 1) == 1)
            {
                if(h == 1)
                    i ++;

                else
                    j ++;

                ok = 1;
            }

            cr = cr + getSumSt(oi, i) + getSumDr(oj, j) /*+ (getSumSt(oi + (1 - h), i - (1 - h)) + getSumDr(oj + h, j - h)) * (min(getSumSt(oi + (1 - h), i - (1 - h)), getSumDr(oj + h, j - h)) > 0)*/;

            if(ok == 0)
                cr = cr + getSumSt(oi + (1 - h), i - (1 - h)) + getSumDr(oj + h, j - h);

            else
                cr = cr + getSumSt(oi + (1 - h), i - h) + getSumDr(oj + h, j - (1 - h));

        }

        //cout << "AM TERMIANT " << i << " " << j << " " << h << " COST " << cr  << "\n";

        rez = max(rez, cr);
    }
}
int main()
{
    cin >> l >> n;

    for(int i = 1; i <= n; i ++)
    {
        cin >> v[i];

        st[i] = st[i  - 1] + v[i];
    }

    for(int i = n; i >= 1; i --)
        dr[i] = dr[i + 1] + (l - v[i]);

//    calc(0, 1);
   // calc(1, -1);

  //  cout << "\n";

    calc2(0, 1);
    calc2(1, -1);

    cout << rez << "\n";

    return 0;
}


Measured memory_bytes: 4096
#include <iostream> 
#define ll long long
using namespace std;
int main(){
    ll a, b, c, k, zero=0;
    cin >> a >> b >> c >> k;
    if(a==b){
        cout << zero << endl;
    }
    else if(a-b>1e18||b-a>1e18){
        cout << "UNFAIR" << endl;
    }
    else{   
        if(k%2==0){
            cout << a-b << endl;
        }
        else{
            cout << b-a << endl;
        }
    }
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a,b,c;
    cin>>a>>b>>c;
    int cnta=0;
    int cntb=0;
    int cntc=0;
    int size=0;
    size+=a.size();
    size+=b.size();
    size+=c.size();
    char pres='a';
    for(int i=0;i<size;i++){
        if (pres=='a'){
            if (cnta==a.size()){
                printf("A");
                break;
            }
            pres=a[cnta];
            cnta+=1;
        }
        else if (pres=='b'){
            if (cntb==b.size()){
                printf("B");
                break;
            }
            pres=b[cntb];
            cntb+=1;
        }
        else if (pres=='c'){
            if (cntc==c.size()){
                printf("C");
                break;
            }
            pres=c[cntc];
            cntc+=1;
        }
    }
}

Measured memory_bytes: 256