akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
const static int tx[] = {0,1,1,1,0,-1,-1,-1};
const static int ty[] = {-1,-1,0,1,1,1,0,-1};
 
static const double EPS = 1e-8;


int num_of_notes;
int num_of_beauty;
ll force_of_repulsion;
ll sum[200001];
ll dp[2001][2001];
int notes[2001];
ll beauty[100001];

ll compute(int i,int j){
  ll lhs = sum[notes[i]];
  ll rhs = (notes[j] - 1 < 0 ? 0 : sum[notes[j] - 1]);

  return (lhs - rhs) / force_of_repulsion;
}

int main(){
  while(~scanf("%d %d %lld",
               &num_of_notes,
               &num_of_beauty,
               &force_of_repulsion)){

    for(int note_idx = 0; note_idx < num_of_notes; note_idx++){
      scanf("%d",notes + note_idx);
      notes[note_idx]--;
    }

    memset(sum,0,sizeof(sum));

    for(int beauty_idx = 0; beauty_idx < num_of_beauty; beauty_idx++){
      scanf("%d",beauty + beauty_idx);
      sum[beauty_idx] = (beauty_idx - 1 >= 0 ? sum[beauty_idx - 1] : 0) + beauty[beauty_idx];
    }

    sort(notes,notes + num_of_notes);
    reverse(notes,notes + num_of_notes);

    memset(dp,0x3f,sizeof(dp));

    dp[0][0] = 0;
    for(int i=0;i<num_of_notes;i++){
      int next = i + 1;
      if(next >= num_of_notes) break;
      for(int j=0;j<=i;j++){
        if(i==j && i!=0) continue;
        dp[next][j]
          = min(dp[next][j],dp[i][j] + compute(i,next));

        dp[next][i]
          = min(dp[next][i],dp[i][j] + compute(j,next));
      }
    }

    ll res = LINF;
    for(int i=0;i<num_of_notes;i++){
      res = min(dp[num_of_notes - 1][i] + compute(i,num_of_notes - 1),res);
    }
    
    printf("%lld\n",res);
  }
}

Measured memory_bytes: 34840
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MAX 300005
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1e18;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
int main()
{
	fast();
	precise(10);
	double l;
	cin>>l;
	double x,y,z;
	x=l/3.0;
	l-=x;
	y=l/2.0;
	z=l-y;
	cout<<(x*y*z);
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin

mod = 1000000007
inf = 1 << 60

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

a, p = na()

print((a * 3 + p) // 2)

Measured memory_bytes: 3060
// abc137c.cpp : Green Bin
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

	vector<ll> v;
	while (n--){
		string s; cin>>s;
		sort(s.begin(), s.end());
		ll k = 0LL, power = 1LL;
		for(int j=9; j>=0; j--){
			k += power * (s[j]-'a');
			power *= 26LL;
		}
		v.push_back(k);
	}

	sort(v.begin(), v.end());

	ll ans = 0LL, c = 1LL, d = v[0];
	for(int i=1; i<v.size(); i++){
		if(d==v[i]) c++;
		else{
			if(c>1LL) ans += c * (c-1LL) / 2LL;
			c = 1LL;
			d = v[i];
		}
	}
	if(c>1LL) ans += c * (c-1LL) / 2LL;
	cout<< ans << endl;
}

Measured memory_bytes: 1400
#include <stdio.h>
#include <algorithm>

using namespace std;

struct Item{
	int value,weight;
};

int main(){
	int N,W,ans = -1;
	scanf("%d %d",&N,&W);
	Item array[N];
	int table[W+1];
	for(int i=0; i < W+1; i++)table[i] = 0;

	for(int i=0;i<N;i++){
		scanf("%d %d",&array[i].value,&array[i].weight);
	}

	for(int i = 1; i <= W; i++){
		for(int k = 0; k < N; k++){
			if(i >= array[k].weight){
				table[i] = max(table[i],array[k].value + table[i-array[k].weight]);
				ans = max(table[i],ans);
			}
		}
	}

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

	return 0;
}



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

using namespace std;

#define int long long

void solve() {
    int cnt = 0;
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; ++i) cin >> a[i];
    int le = 1;
    for (int i = 0; i < n; ++i) {
        if (a[i] == le) {
            ++cnt;
            ++le;
        }
    }
    if (cnt) cout << n - cnt;
    else cout << -1;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 1792
import java.util.*;

class Main{
    public static void main(String[] args){
    	Scanner scn = new Scanner(System.in);
    	int n = scn.nextInt();
    	
    	for(int i=0; i<n; i++){
    		int a,b,c;
    		a = scn.nextInt();
    		b = scn.nextInt();
    		c = scn.nextInt();
    		
    		if(Math.abs(a*a-b*b) == c*c || a*a+b*b == c*c){
    			System.out.println("YES");
    		}else{
    			System.out.println("NO");
    		}
    	}
    }
}

Measured memory_bytes: 12000
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define len(n) (int)n.length()
#define pb push_back
#define ll long long
#define make_pair mkp
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) (v).begin(), (v).end()
#ifdef DBGPRT
#define dbg(n) cerr << "//" << #n << ":" << n <<endl
#else
#define dbg(n) ;
#endif
typedef pair<ll, ll> LLARR;
#define INF 999999999
const double PI = 3.1415926535897932384626433832795;

int main()
{
    int N;
    cin >> N;
     
    int *a = new int[N];
     
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
     
    int v = 0;
            for (int k = 0; k < N - 1; k++) {
            cout << a[k] << " ";
        }
        cout << a[N - 1] << endl;
    for (int i = 1; i < N; i++) {
        v = a[i];
        int j = i - 1;
        while ((j >= 0) && (a[j] > v))
        {
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
                for (int k = 0; k < N - 1; k++) {
            cout << a[k] << " ";
        }
        cout << a[N - 1] << endl;
    }
     
    delete[] a;
     
    return 0;
}

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

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

    bool s[1000] = {};
    int i;
    long long mod = 2;
    for (i = 0; n != 0; i++) {
        if (n % mod) {
            s[i] = true;
            n -= pow(-2, i);
        }
        mod *= 2;
    }

    for (i -= 1; i > 0; i--) cout << s[i];
    cout << s[0] << endl;
}

Measured memory_bytes: 888
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define MOD 998244353
#define seg_size 524288
long long dp[1000000] = {};
int main(){
	for (int i = 1; i < 1000000; ++i) {
		dp[i] = LONG_INF;
	}
	int d, g;
	cin >> d >> g;
	g /= 100;
	vector<pair<int, int>> input;
	for (int i = 1; i <= d;++i){
		int a, b;
		cin >> a >> b;
		b /= 100;
		for (int q = g; q >= 0; --q) {
			if (dp[q] != LONG_INF) {
				for (int j = 1; j < a; ++j) {
					dp[q + i * j] = min(dp[q] + j, dp[q + i * j]);
				}
				dp[q + i * a + b] = min(dp[q] + a, dp[q + i * a + b]);
			}
		}
	}
	long long ans = LONG_INF;
	for (int i = g; i < 1000000; ++i) {
		ans = min(ans, dp[i]);
	}
	cout << ans << endl;
	return 0;
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

template <ll mod>
class modint
{
public:
    constexpr modint(ll value = 0) : _value(value >= 0 ? value % mod : (value % mod) + mod) {}

    constexpr modint operator+() const { return *this; }
    constexpr modint operator-() const { return modint(-_value); }

    constexpr modint &operator+=(const modint &rhs) {
        if ((_value += rhs._value) >= mod) _value -= mod;
        return *this;
    }
    constexpr modint &operator-=(const modint &rhs) {
        if ((_value += mod - rhs._value) >= mod) _value -= mod;
        return *this;
    }
    constexpr modint &operator*=(const modint &rhs) {
        (_value *= rhs._value) %= mod;
        return *this;
    }
    constexpr modint &operator/=(const modint &rhs) {
        *this *= rhs.inv();
        return *this;
    }
    constexpr modint operator+(const modint &rhs) const { return modint(*this) += rhs; }
    constexpr modint operator-(const modint &rhs) const { return modint(*this) -= rhs; }
    constexpr modint operator*(const modint &rhs) const { return modint(*this) *= rhs; }
    constexpr modint operator/(const modint &rhs) const { return modint(*this) /= rhs; }

    constexpr modint operator++() { *this += 1; return *this; }
    constexpr modint operator--() { *this -= 1; return *this; }
    constexpr modint operator++(int) { modint tmp = *this; ++*this; return tmp; }
    constexpr modint operator--(int) { modint tmp = *this; --*this; return tmp; }

    constexpr bool operator==(const modint &rhs) const { return _value == rhs._value; }
    constexpr bool operator!=(const modint &rhs) const { return _value != rhs._value; }

    constexpr modint inv() const {
        ll a = _value, b = mod, u = 1LL, v = 0LL;
        while (b > 0) {
            ll tmp = a / b;
            a -= tmp * b; swap(a, b);
            u -= tmp * v; swap(u, v);
        }
        return modint(u);
    }

    constexpr modint pow(ll n) const {
        modint e = *this, res = 1;
        while (n) {
            if (n & 1) res *= e;
            e *= e, n >>= 1;
        }
        return res;
    }

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

    friend istream &operator>>(istream &is, modint &m) {
        ll in;
        is >> in;
        m = modint(in);
        return is;
    }

private:
    ll _value;
};
using mint = modint<1000000007>;

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

    int n, m; cin >> n >> m;
    mint xsum = 0, ysum = 0;
    for (int i = 0; i < n; i++) {
        ll x; cin >> x;
        xsum += x * (-n + 2 * i + 1);
    }
    for (int i = 0; i < m; i++) {
        ll y; cin >> y;
        ysum += y * (-m + 2 * i + 1);
    }
    cout << xsum * ysum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
	int a, b;
	double total = 0, average = 0, num = 0;
	while (scanf("%d,%d", &a, &b) != EOF) {
		total += a * b;
		average += b;
		num++;
	}
	cout << total << endl;
	cout << lround(average / num) << endl;
	return 0;
}

Measured memory_bytes: 1268
#include<iostream>
#include<stdio.h>
using namespace std;
int yue(int a,int b){
	int min;
	int max;
	if(a==0||b==0){
		return 0;
	}else{
		if(a<b){
			min=a;max=b;
		}else{
			min=b;max=a;
		}
		int shang=max-min;
		while(shang!=min){
			if(shang<min){
				max=min;
				min=shang;
			}else{
				max=shang;
				min=min;
			}
			shang=max-min;
		}
		return shang;
	}
}
int bei(int a,int b){
	int min;
	int max;
	if(a==0||b==0){
		return 0;
	}else{
		if(a<b){
			min=a;max=b;
		}else{
			min=b;max=a;
		}
		int yu=max%min;
		int beishu=1;
		int mmax=max;
		while(yu!=0){
			beishu++;
			max=mmax*beishu;
			yu=max%min;
		}
		return max;
	}
}

long yue2(long a,long b){
	if(a==0||b==0){
		return 0;
	}else{
		long r=a%b;
		while(r!=0){
			a=b;
			b=r;
			r=a%b;
		}
		return b;
	}
}

int main(){
long a,b;
	while(scanf("%ld%ld",&a,&b)!=EOF){
		long y=yue2(a,b);
		printf("%ld %ld\n",y,bei(a,b));
	}
	return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);

int main() {
	cin.sync_with_stdio(false);
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b >= c)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A, B, C;
    cin >> A >> B >> C;
    int ma = max(A, max(B, C));
    if (ma == A){
        cout << A * 10 + B + C;
    }
    else if (ma == B){
        cout << B * 10 + A + C;
    }
    else {
        cout << C * 10 + A + B;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string s;
  ll total = 0;
  cin >> s;
  int n = s.size()-1;
  for(int bit=0;bit<(1<<n);++bit){//+挿入個数管理
    int before = 0;//１つ前に切った場所を記録しておく
    int j=0;
    ll buff = 0;
    for(j=0;j<n;++j){
      if(bit & (1<<j)){
        string cut = s.substr(before,j-before+1);
        ll num = stoll(cut);
        buff+=num;
        before=j+1;
      }
    }
      string cut = s.substr(before,j-before+1);
      ll num = stoll(cut);
      total+=(buff+num);
    } 
    cout << total << "\n";
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double pi = 2*acos(0.0);
    double deg=((h/12.0)*2*pi+((m/60.0)*(pi/6.0))-((m/60.0)*2*pi));
    double ans=sqrt(a*a+b*b-2*a*b*(cos(deg)));
    cout<<fixed<<setprecision(20)<<ans;
}

Measured memory_bytes: 4216
#include <stdio.h>
#include <math.h>
#include <string.h>
int _max(int x,int y){return x>y?x:y;}
int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a%b!=0)printf("%d\n",a);
	else printf("-1\n");
	return 0;
}

Measured memory_bytes: 128
/* AOJ0033 Ball */

#include <stdio.h>

#define N 10

int main(void)
{
    int n, ans, i;

    scanf("%d", &n);
    while(n--) {
        ans = 1;
        int a, b=-1, c=-1;
        for(i=1; i<=N; i++) {
            scanf("%d", &a);
            if(ans) {
                if(a > b)
                    b = a;
                else if(a > c)
                    c = a;
                else
                    ans = 0;
            }
        }

        printf("%s\n", ans ? "YES" : "NO");
    }

    return 0;
}

Measured memory_bytes: 2508
N = int(input())
al = [int(input()) for _ in range(N)]

num_dic = {}
for a in al:
    num = num_dic.get(a, 0)
    num_dic[a] = 1 if num == 0 else 0

ans = 0
for k, v in num_dic.items():
    if v != 0:
        ans += 1

print(ans)


Measured memory_bytes: 94500
#include<stdio.h>
#include<math.h>
int main(void){
int a,b;
double f,nu;
nu=pow(10,9);
scanf("%d%d",&a,&b);
if(1<=a&&a<=nu&&1<=b&&b<=nu){
f=(double)a/b;
printf("%d %d %f\n",a/b,a%b,f);
}
return 0;
}

Measured memory_bytes: 636
var ans,a:real;
    n,i:integer;
begin
  ans:=0.0;
  readln(n);
  for i:=1 to n do begin
    read(a);
    ans:=ans+1.0/a;
  end;
  ans:=1.0/ans;
  writeln(ans:6:6);
end.

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
   string s,t="";
   cin >> s;
  for(int i=0;i<s.size();i++){
    if(i%2==0){
      t += s.substr(i,1);
    }
  }
  cout << t << endl;

}

Measured memory_bytes: 640
// https://atcoder.jp/contests/dp/tasks
#include <bits/stdc++.h>
using namespace std;

using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T> inline void IN(T &x) {
	x = 0; T f = 1; char ch = getchar();
	while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
	while (isdigit(ch)) { x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar(); }
	x *= f;
}
template<typename A, typename B> inline void IN(A &x, B &y) { IN(x); IN(y); }
template<typename A, typename B, typename C> inline void IN(A &x, B &y, C &z) { IN(x); IN(y); IN(z); }

#define FastI ios_base::sync_with_stdio(0), cin.tie(0);
#define FastIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define endl '\n'
#define REP(i, l, r) for (auto i = (l); i <= (r); ++i)
#define PER(i, l, r) for (auto i = (l); i >= (r); --i)
#define FOR(i, l, r) for (auto i = (l); i < (r); ++i)
#define ROF(i, l, r) for (auto i = (l); i > (r); --i)
#define FORN(i, n) for (auto i = 0; i < (n); ++i)
#define REPN(i, n) for (auto i = 1; i <= (n); ++i)
#define FORA(i, a) for (auto &i : a)
template<class T> void cout_1d(T &v) { FORA(i, v) cout << i << " "; puts(""); }
template<class T> void cout_2d(T &vv) { FORA(v, vv) cout_1d(v); }
#define ALL(X) (X).begin(), (X).end()
#define RALL(X) (X).rbegin(), (X).rend()
#define SIZE(X) ((int)(X).size())
#define UNIQUE(x) (X).erase(unique(ALL(x), (X).end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define NEG1(a) memset(a, -1, sizeof(a))
#define MAXA(a) memset(a, 0x3f, sizeof(a))
#define MAXB(b) memset(b, 0x7f, sizeof(b))
#define MP make_pair
#define PB push_back
#define X first
#define Y second

const LD PI = acos(-1.0);
const LL MOD = 998244353;
//const LL MOD = 1e9+7;
const LL MAXN = 2e5 + 7;

int h[MAXN];
void solve1() {
	int N;  IN(N);
	REPN(i, N) IN(h[i]);
	// VI dp(N+1, 0);  dp[2] = abs(h[2] - h[1]);
	// REP(i, 3, N) dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
	VI dp(N+1, 0);
	REP(i, 2, N) dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), 
			i <= 2 ? INT_MAX : dp[i-2] + abs(h[i] - h[i-2]));
	cout << dp[N] << endl;
}

void solve2() {
	int N, K;  IN(N, K);
	REPN(i, N) IN(h[i]);
	VI dp(N+1, INT_MAX);
	dp[1] = 0;
	REP(i, 2, N) REP(j, 1, K) // if (j >= i) break;
		dp[i] = min(dp[i], i <= j ? INT_MAX : dp[i-j] + abs(h[i] - h[i-j]));
	cout << dp[N] << endl;
}

int main() {
#ifdef _DEBUG
    freopen("../in.txt", "r", stdin);
    freopen("../out.txt", "w", stdout);
#endif
    FastI

	solve1();
	// solve2();

    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
int main(){
	long i, j, k, ans, n, r, g, b;
	char *s;
	char si, sj, sk;

	scanf("%ld", &n);
	s = malloc(n * sizeof(char));
	scanf("%s", s);

	for(i=0, r=0, g=0, b=0; i<n; i++){
		if(s[i] == 'R') r++;
		else if(s[i] == 'G') g++;
		else if(s[i] == 'B') b++;
	}

	ans = r * g * b;

	for(j=0; j<n; j++){
		sj = s[j];
		for(i=0; i<j; i++){
			si = s[i];

			k = j + (j - i);
			sk = s[k];

			if(k < n && si != sj && sj != sk && sk != si) ans--;
		}
	}

	printf("%ld", ans);
	return 0;
}


Measured memory_bytes: 1736
import math

a, b, h, m = map(int, input().split())

b_theta = m / 60 * 2 * math.pi
a_theta = (h * 60 + m) / 720 * 2 * math.pi
bx = b * math.cos(b_theta)
by = b * math.sin(b_theta)
ax = a * math.cos(a_theta)
ay = a * math.sin(a_theta)
dx = abs(ax - bx)
dy = abs(ay - by)
print(math.sqrt(dx ** 2 + dy ** 2))

Measured memory_bytes: 9516
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

long long int INF = 1e18;
using namespace std;

typedef pair<long long int, long long int> P;

long long int DP[1001][1001] = {};

int main(){
	
	int n;
	cin >> n;
	
	for(int loop = 0; loop < n; loop++){
		
		int id, k;
		cin >> id >> k;
		id--;
		
		for(int i = 0; i < k; i++){
			int num;
			cin >> num;
			num--;
			DP[id][num] = 1;
		}
		
	}
	
	for(int i = 0; i < n; i++){
		cout << DP[i][0];
		for(int j = 1; j < n; j++){
			cout << " " << DP[i][j];
		}
		cout << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3376
#include <stdio.h>

int main(){
    int N,i,j,k;
    long CNT[5] ={0,0,0,0,0};
    char S[10];
    long ans=0;

    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%s",S);
        if(S[0]=='M') CNT[0]++;
        if(S[0]=='A') CNT[1]++;
        if(S[0]=='R') CNT[2]++;
        if(S[0]=='C') CNT[3]++;
        if(S[0]=='H') CNT[4]++;
    }
    for(i=0;i<3;i++){
        for(j=i+1;j<4;j++){
            for(k=j+1;k<5;k++){
                ans+= CNT[i]*CNT[j]*CNT[k];
            }
        }
    }
    printf("%ld",ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int N = 50 + 5;
double a[N];
int main()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a,a+n);
	for(int i = 0; i < n;i++){
		a[i+1] = (a[i+1] + a[i]) / 2;
	}
	printf("%f",a[n-1]);
	return 0;
 } 

Measured memory_bytes: 256
//Author: Pakhomovee 
#include <iostream> 
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

using namespace std;
using namespace std::chrono;

#define int long long

void solve()
{
    string s, t;
    cin >> s >> t;
    if (t.size() != s.size() + 1)
    {
        cout << "No\n";
        return;
    }
    if (s == t.substr(0, s.size()))
    {
        cout << "Yes\n";
        return;
    }
    cout << "No\n";
    return;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	auto start = system_clock::now();

    solve();

	auto end = system_clock::now();
	cerr << "Time: " << duration_cast<milliseconds> (end - start).count() << "ms" << endl;
}

Measured memory_bytes: 3656
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

int depth(int i) {
	if (i == 1) return 1;
	return 1 + depth(i / 2);
}

int N;
vector<int> V, W;

void input(void) {
	cin >> N;
	V.resize(N); W.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> V[i] >> W[i];
}

vector<vector<int>> dp;

void dfs(int s, vector<int>& res, int dep) {
	if (s > N) return;
	if (dep > 9) return;
	dp[s] = res;
	for (int w = 0; w <= 100000; ++w) 
		if (w >= W[s - 1])
			dp[s][w] = max(dp[s][w], res[w - W[s - 1]] + V[s - 1]);
	dfs(s * 2, dp[s], dep + 1);
	dfs(s * 2 + 1, dp[s], dep + 1);
}

void build(void) {
	dp.resize(N + 1);
	vector<int> dp(100001, 0);
	dfs(1, dp, 1);
}

vector<pair<int, int>> all_find(int st, int gl, int L) {
	vector<pair<int, int>> res(1, {0, 0});
	while (st > gl) {
		int v = V[st - 1], w = W[st - 1];
		vector<pair<int, int>> tmp = res;
		for (auto p : res) {
			if (p.first + w > L) continue;
			tmp.emplace_back(p.first + w, p.second + v);
		}
		res = tmp;
		st /= 2;
	}
	return res;
}

void solve(int x, int L) {
	if (depth(x) <= 9) {
		cout << dp[x][L] << endl;
		return;
	}
	int _x = x;
	int c = depth(x) - 9;
	while (c--) _x /= 2;
	auto tmp = all_find(x, _x, L);
	int res = 0;
	for (auto p : tmp) 
			res = max(res, p.second + dp[_x][L - p.first]);
	cout << res << endl;
}

int main(void) {
	input();
	build();
	int Q; cin >> Q;
	while (Q--) {
		int v, L; cin >> v >> L;
		solve(v, L);
	}
	return 0;
}

Measured memory_bytes: 212032
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T> int len(const T &v) { return v.size(); }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

/* Find the maximum x∈[low, up) such that f(x) is true
    ---*     (true)
        ---- (false)
*/
template<typename F> int binarySearchL(int low, int up, const F &f) {
  while (up - low > 1) {
    int mid = low + (up - low) / 2;
    (f(mid) ? low : up) = mid;
  }
  return low;
}

main {
  int N, Q;
  cin >> N >> Q;
  vector<int> a(N + 1);
  for (int i = 1; i <= N; i++) cin >> a[i];
  for (int i = 2; i <= N; i++) a[i] += a[i - 1];
  while (Q--) {
    int x;
    cin >> x;
    int cnt = 0;
    for (int i = 0; i < N; i++) {
      int j = binarySearchL(0, N + 1, [&](int t) { return a[t] <= a[i] + x; });
      if (j == N + 1) continue;
      cnt += j - i;
    }
    cout << cnt << endl;
  }
}



Measured memory_bytes: 3600
N = int(input())
listS = ["" for _ in range(N)]
cntAB = 0
for i in range(N):
    listS[i] = input()
    for j in range(len(listS[i])-1):
        if listS[i][j] == "A" and listS[i][j+1] == "B":
            cntAB += 1
cntA = 0
cntB = 0
BcntA = 0
for s in listS:
    if s[0] == "B" and s[-1] != "A":
        cntB += 1
    if s[0] != "B" and s[-1] == "A":
        cntA += 1
    if s[0] == "B" and s[-1] == "A":
        BcntA += 1
connect = 0
if cntA + cntB == 0 and BcntA > 0:
    connect = BcntA - 1
else:
    connect = min(cntA,cntB) + BcntA
print(connect+cntAB)


Measured memory_bytes: 3700
n = gets.chomp.to_i
a = gets.chomp.split.map{ |s| s.to_i - 1 }
b = gets.chomp.split.map(&:to_i)
c = gets.chomp.split.map(&:to_i)

sum = 0
n.times do |i|
  sum += b[a[i]]
  sum += c[a[i]] if i != n-1 && a[i+1] == a[i] + 1
end

puts(sum)

Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
    int N;
    cin>>N;
    int cnt=0,sp=0;
    rep(i,N){
        cnt=0;
        if((i+1)%2==0){
            continue;
        }
        rep(j,i+1){
            if((i+1)%(j+1)==0){
                cnt++;
            }
        }
        if(cnt==8){
            sp++;
        }
        
        
    }
    
    cout<<sp<<endl;
  
   
}

Measured memory_bytes: 3640
s = input()
k = int(input())

ns = []
for c in s[:-1]:
    if c == 'a':
        ns.append(c)
        continue

    ofstoa = ord('z')+1-ord(c)
    if k >= ofstoa:
        ns.append(chr(ord(c) + ofstoa - 26))
        k -= ofstoa
    else:
        ns.append(c)

last = ord(s[-1])
k = k%26
if last + k > ord('z'):
    ns.append(chr(last + k - 26))
else:
    ns.append(chr(last + k))
print(''.join(ns))


Measured memory_bytes: 4340
#include <iostream>

using namespace std;

int main()
{
    int a , b,c ,d;
    char s ;
    cin >> a >> s >> b ;
    c=a+b ;
    d=a-b;
    if (s=='+')
    cout << c ;
    else if (s== '-')
    cout <<d ;






    return 0;
}


Measured memory_bytes: 256
# your code goes here\
s = input()
op = ''
first = s[0:2]
second = s[2:4]
if (0 < int(first) <= 12):
	op += 'MM'
else:
	op += 'YY'
if (0 < int(second) <= 12):
	op += 'MM'
else:
	op += 'YY'

if (len(s) != 4):
	op = 'NA'
elif (op == 'MMMM'):
	op = 'AMBIGUOUS'
elif (op == 'YYYY'):
	if ((second == '00' and first == '00') or int(second) > 12 or int(first) > 12):
		op = 'NA'
print(op)
	


Measured memory_bytes: 3064
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main() {
  int n;
  readf (" %d", &n);
  auto a = new long[n];
  auto b = new long[n];
  foreach (t; 0 .. n) {
    readf (" %d %d", &a[t], &b[t]);
  }
  auto s = a.sum;
  auto c = iota (0, n).filter! (i => a[i] > b[i]).map! ( i => tuple (-b[i], i)).array;
  //auto c = a.zip(b).filter! (t => t[0] > t[1]).map! ( t => abs (t[0] - t[1])).array;
  if (c.length == 0) {
    writeln (0);
  } else {
    sort (c);
    int i = c[$-1][1];
    writeln (s - b[i]);
    //writeln (s - c.reduce! (max));
  }

  //auto s1 = a.zip(b).filter! (t => t[0] < t[1]).map! ( t => abs (t[0] - t[1])).sum;
  //auto s2 = a.zip(b).filter! (t => t[0] > t[1]).map! ( t => abs (t[0] - t[1])).sum;
  //writeln (max (s1, s2));
}


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

int main() {
	vector<int> v;
	int a, b, c;

	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);

	v.push_back(a);
	v.push_back(b);
	v.push_back(c);

	sort(v.begin(), v.end());
	printf("%d %d %d", v[0], v[1], v[2]);

	cout << endl;
	return 0;
}

Measured memory_bytes: 3252
#include <stdio.h>

int main(void)
{
	int i, j;
	int n;
	int h[16][16];
	
	while (scanf("%d", &n), n != 0){
		
		for (i = 0; i <= n; i++){
			for (j = 0; j <=n; j++){
				h[i][j] = 0;
			}
		}
		
		for (i = 0; i < n; i++){
			for (j = 0; j < n; j++){
				scanf("%d", &h[i][j]);
				h[i][n] += h[i][j];
				h[n][j] += h[i][j];
			}
		}
		
		for (i = 0; i < n; i++){
			h[n][n] += h[i][n];
		}
		for (i = 0; i <= n; i++){
			for (j = 0; j <= n; j++){
				printf("%5d", h[i][j]);
			}
			printf("\n");
		}
	}
	return (0);
}

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

int main() {

  string week[7] = {
    "Monday",
    "Tuesday",
    "Wednesday",
    "Thursday",
    "Friday",
    "Saturday",
    "Sunday",
  };
  int end_day[13] = {-1,31,29,31,30,31,30,31,31,30,31,30,31};
  int month,day;
  while(cin >> month >> day) {
    if(month == 0) break;
    int today = 3; // because, 1/1 is Thursday
    for(int m = 1;m <= month;m++) {
      for(int d = 1;d <= end_day[m];d++) {
        if(m == month && d == day) break;
        today = (today + 1) % 7;
      }
    }
    cout << week[today] << endl;
  }
}

Measured memory_bytes: 1196
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
using namespace std;

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    int cnt=1,ans=0;
    for(int i=0;i<n-1;i++){
        if(a[i] == a[i+1]) cnt++;
        else{
            ans += cnt/2;
            cnt=1;
        }
    }
    ans += cnt/2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    cout << N / 3 << endl;

    return 0;
}

Measured memory_bytes: 3628
def abp(a, b, p):
    if b == 0:
        return 1
    if b % 2 == 0:
        tmp = abp(a, b // 2, p)
        return (tmp * tmp) % p
    if b % 2 == 1:
        return (a * abp(a, b - 1, p)) % p

def nCr(n, r, p):
    total = 1
    for i in range(r):
        total *= (n - i) * abp(r - i, p - 2, p)
        total %= p
    return total

n, a, b = map(int, input().split())
p = 1000000007
ret = abp(2, n, p) - nCr(n, a, p) - nCr(n, b, p) - 1
print(ret % p)


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

#define rep(i,x,y) for(long long int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

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

void solve(){
    ll x_size,y_size,z_size,a,b,c,n;
    cin >> x_size >> y_size >> z_size >> a >> b >> c >> n;

    vector<ll> cnt1(n);
    rep(i,0,n) cnt1[i]+=(x_size-a)/n;
    rep(x,a+n*((x_size-a)/n),x_size) ++cnt1[(x-a)%n];
    rep(i,0,n) cnt1[i]+=(a+1)/n;
    for(ll x=a-n*((a+1)/n); x>=0; --x) ++cnt1[(a-x)%n];
    --cnt1[0];

    vector<ll> cnt2(n);
    rep(i,0,n) cnt2[i]-=cnt1[i];
    rep(i,0,n) cnt2[i]+=x_size*((y_size-b)/n);
    {
        vector<ll> tmp1=cnt1;
        rep(y,b+n*((y_size-b)/n),y_size){
            rep(i,0,n) cnt2[i]+=tmp1[i];
            vector<ll> tmp2(n);
            rep(i,0,n) tmp2[i]=tmp1[(i-1+n)%n];
            swap(tmp1,tmp2);
        }
    }
    rep(i,0,n) cnt2[i]+=x_size*((b+1)/n);
    {
        vector<ll> tmp1=cnt1;
        for(ll y=b-n*((b+1)/n); y>=0; --y){
            rep(i,0,n) cnt2[i]+=tmp1[i];
            vector<ll> tmp2(n);
            rep(i,0,n) tmp2[i]=tmp1[(i-1+n)%n];
            swap(tmp1,tmp2);
        }
    }

    vector<ll> cnt3(n);
    rep(i,0,n) cnt3[i]-=cnt2[i];
    rep(i,0,n) cnt3[i]+=x_size*y_size*((z_size-c)/n);
    {
        vector<ll> tmp1=cnt2;
        rep(z,c+n*((z_size-c)/n),z_size){
            rep(i,0,n) cnt3[i]+=tmp1[i];
            vector<ll> tmp2(n);
            rep(i,0,n) tmp2[i]=tmp1[(i-1+n)%n];
            swap(tmp1,tmp2);
        }
    }
    rep(i,0,n) cnt3[i]+=x_size*y_size*((c+1)/n);
    {
        vector<ll> tmp1=cnt2;
        for(ll z=c-n*((c+1)/n); z>=0; --z){
            rep(i,0,n) cnt3[i]+=tmp1[i];
            vector<ll> tmp2(n);
            rep(i,0,n) tmp2[i]=tmp1[(i-1+n)%n];
            swap(tmp1,tmp2);
        }
    }

    rep(i,0,n) cout << cnt3[i] << (i==n-1?"\n":" ");
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}

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

int n, a, b, dec_d, dec_a, ind;
string str, temp_ans;

int main() {
  cin >> n >> a >> b;
  cin >> str;
  vector<string> ans(n);
  dec_d = 0;dec_a = 0;ind = -1;
  while (dec_d + dec_a != a + b && ind != n - 1) {
    ind++;
    temp_ans = "No";
    if (str.at(ind) == 'a') {
      dec_d++;
      temp_ans = "Yes";
    }else if (str.at(ind) == 'b' && dec_a < b) {
      dec_a++;
      temp_ans = "Yes";
    }
    ans.at(ind) = temp_ans;
  }
  for (size_t i = ind + 1; i < n; i++) {
    ans.at(i) = "No";
  }
  rep (i, n) {
    cout << ans.at(i) << endl;
  }
  return 0;
}


Measured memory_bytes: 6144
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

int n, m, q;
int a[55], b[55], c[55], d[55];

int score(vector<int> A) {
    int ret = 0;
    for (int i = 0; i < q; i++) {
        if (A[b[i]] - A[a[i]] == c[i]) ret += d[i];
    }
    return ret;
}

int dfs(vector<int> A, int last) {
    if (A.size() >= n) {
        return score(A);
    }
    int mx = -1 * numeric_limits<int>::max();
    for (int i = last; i <= m; i++) {
        A.push_back(i);
        mx = max(mx, dfs(A, i));
        A.pop_back();
    }
    return mx;
}


int main(){
    cin >> n >> m >> q;
    
    for (int i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;
        b[i]--;
    }
    vector<int> A;
    cout << dfs(A, 1) << endl;
}

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;



int main() {
    int N, D; cin >> N >> D;
    cout << N / (2 * D + 1) + (N % (2 * D + 1) != 0) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define int long long int
#define N 200005
 
main(){
    // ios_base::sync_with_stdio(false); 
    // cin.tie(NULL);
    int n;
	cin>>n;
	cout<<pow(n,3)<<endl;
}

Measured memory_bytes: 512
import numpy as np


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N,M = list( map(int, input().split()) )

uf = UnionFind(N)
A = [0]*M
B = [0]*M
for i in range(M):
    a,b = list( map(int, input().split()) )
    A[i]=a-1
    B[i]=b-1

#print(A)
#print(B)

cmax = int(N*(N-1)/2)
FD = [cmax]*(M+1)
#print(FD)
for i in range(M):
    #print(uf)
    if uf.same(A[M-i-1],B[M-i-1]):
        FD[M-i-1] = FD[M-i]
    else:
        cless = uf.size(A[M-i-1])*uf.size(B[M-i-1])
        FD[M-i-1] = FD[M-i] - cless
        if FD[M-i-1]<0: FD[M-i-1]=0
    uf.union(A[M-1-i],B[M-1-i])

#print(uf)
#print(FD[1:])
for fd in FD[1:]:
    print(fd)




Measured memory_bytes: 40028
import java.util.Scanner;

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

		if(x == 1) {
			System.out.println(1);
			return;
		}

		int ans = 0;
		for (int b = 2; b <= 1000; b++) {
			int p = 2;
			while(Math.pow(b, p) <= x) {
				int num = (int)Math.pow(b, p);
				p++;
				ans = Math.max(ans, num);
			}
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <map>

using namespace std;

int main() {
  int N;
  cin >> N;
  int result[10000+10];
  for (int i = 0; i < 10010; i++) result[i] = 0;
  for (int x = 1; x < 100; x++) {
    for (int y = 1; y < 100; y++) {
      for (int z = 1; z < 100; z++) {
        int n = x*x + y*y + z*z + x*y + y*z + z*x;
        if (n < 10010) result[n]++;
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    cout << result[i] << endl;
  }
}


Measured memory_bytes: 3648
import sys
import math

mod = 10 ** 9 + 7

X, Y = map(int, input().split())
if ((2 * Y - X) % 3) != 0 or ((2 * X - Y) % 3) != 0:
  print(0)
  sys.exit()

l = int((2 * Y - X) / 3)
m = int((2 * X - Y) / 3)

# nCk mod p を求める
# n = m + l
# k = m
# p = 10 ** 9 + 7

maximum = 700000

fac = [0] * maximum
finv = [0] * maximum
inv = [0] * maximum

fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1
for i in range(2, maximum):
  fac[i] = fac[i - 1] * i % mod
  inv[i] = mod - inv[mod % i] * (mod // i) % mod
  finv[i] = finv[i - 1] * inv[i] % mod

def com(n, k):
  if n < k:
    return 0
  if n < 0 or k < 0:
    return 0
  return fac[n] * (finv[k] * finv[n - k] % mod) % mod

print(com(m + l, m))
# print(com(100, 1))


Measured memory_bytes: 86132
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

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

    LL n, a, b;
    cin >> n >> a >> b;
    if( a > b ) {
        cout << 0 << endl;
        return 0;

    }
    if( a == b ) {
        cout << 1 << endl;
        return 0;

    }

    LL mn = a * ( n - 1 ) + b;
    LL mx = b * ( n - 1 ) + a;

    cout << max( mx - mn + 1, 0ll ) << endl;
    return 0;
}


Measured memory_bytes: 256
s = list(map(int,input().split()))

if s[0] == 0:
    if s[1] == 100:
        print('101')
    else:
        print(s[1])
elif s[0] == 1:
    if s[1] == 100:
        print('10100')
    else:
        print(s[1]*100)
elif s[0] == 2:
    if s[1] == 100:
        print('1010000')
    else:
        print(s[1]*10000)


Measured memory_bytes: 3060
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2019-12-10 21:17:03
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<class T> ostream& operator<<(ostream& os, vector<T>& _) { os << '{'; for (T& x : _) { os << x; if (&x != &_.back()) os << ','; } os << '}'; return os; }
template<class T, class U> ostream& operator<<(ostream& os, pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

constexpr int INF = 1e9;

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

  int n, m; cin >> n >> m;
  vector<vector<int>> dis(n, vector<int>(n, INF));

  for (int i = 0; i < m; ++i) {
    int s, t, d; cin >> s >> t >> d;
    dis[s][t] = d;
  }

  int dp[1 << n][n];
  fill(dp[0], dp[1 << n], INF);

  dp[(1 << n) - 1][0] = 0;
  for (int bit = (1 << n) - 2; bit >= 0; --bit) {
    bitset<16> bs(bit);
    for (int i = 0; i < n; ++i) {
      if (i != 0 && !bs.test(i)) continue;
      for (int j = 0; j < n; ++j) {
        if (!bs.test(j)) {
          dp[bit][i] = min(dp[bit][i], dp[bit | (1 << j)][j] + dis[i][j]);
        }
      }
    }
  }

  if (dp[0][0] == INF) {
    cout << -1 << endl;
  } else {
    cout << dp[0][0] << endl;
  }

  return 0;
}



Measured memory_bytes: 5060
#include<iostream>
#include<vector>

using namespace std;

int main() {
  vector<int> a(5);
  int k;
  cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> k;

  bool ans = true;
  for(int i=0; i<4; i++) {
    for(int j=i+1; j<5; j++)
      if(abs(a[i] - a[j]) > k) {
        ans = false;
        break;
      }
  }

  string out = ans ? "Yay!" : ":(";
  cout << out << endl;
}

Measured memory_bytes: 256
#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(){
    int N, A;
    cin >> N >> A;
    cout << N*N-A << endl;
    return 0;
}


Measured memory_bytes: 256