akhauriyash/Code-Regression huggingface dataset:
/**akshaykumar99**/
 
#include<bits/stdc++.h>
using namespace std;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define pu push_back           
#define pp pop_back
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const int MOD=1e9+7 ;
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=1e5+2;
 
typedef long long ll;
typedef long double ld;
typedef vector<ll> ivc;
typedef pair<ll,ll> ipr;

int main()
{
    IOS();
    
    int n,i;
    cin>>n;
    string s;
    cin>>s;
    if(n<3200)
      cout<<"red";
    else
      cout<<s;



  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def is_prime(n: int):
    if n == 1:
        return False
    if n % 2 == 0:
        return n == 2
    i = 3
    while i * i <= n:
        if n % i == 0:
            return False
        i += 2
    return True


def solve(N: int):
    def f():
        i = 11
        while True:
            if is_prime(i):
                yield i
            i += 10

    it = f()
    print(*(next(it) for _ in range(N)))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == '__main__':
    main()


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

int main() {
  int N, sum;
  sum = 0;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    sum = sum + r - l + 1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 3636
import itertools

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

all_pattern = sorted(list(itertools.permutations(p)))
a, b = 0, 0
for i, pattern in enumerate(all_pattern):
    if list(pattern) == p:
        a = i
    if list(pattern) == q:
        b = i
print(abs(a-b))

Measured memory_bytes: 46448
#include <iostream>
#include<bits/stdc++.h>
#define  ll long long
 using namespace std;
ll aa[30],bb[30];
ll dd[100003][30];
ll cc[30];
int main()
{
  string s,s1;
  cin>>s>>s1;
  ll a=s.size();
  ll b=s1.size();
  for(ll i=0;i<a;i++)
  {
      aa[s[i]-'a']++;
  }
  for(ll j=0;j<b;j++)
    bb[s1[j]-'a']++;
  for(ll i=0;i<26;i++)
  if(bb[i]&&!aa[i]){
    cout<<-1<<endl;
    return 0;
  }
  for(ll i=a-1;i>=0;i--)
  {
      cc[s[i]-'a']=i;
      for(ll j=0;j<26;j++)
      dd[i][j]=dd[i+1][j];
      dd[i][s[i+1]-'a']=i+1;
  } ll z=cc[s1[0]-'a'];
  ll sum=z+1;//cout<<a<<endl;
  for(ll i=0;i<b-1;i++)
  {
    if(!dd[z][s1[i+1]-'a'])sum+=(a-z-1)+cc[s1[i+1]-'a']+1,z=cc[s1[i+1]-'a'];
    else sum+=(dd[z][s1[i+1]-'a']-z),z=dd[z][s1[i+1]-'a'];
 //  cout<<sum<<endl;
  }cout<<sum<<endl;
}


Measured memory_bytes: 24064
#include <bits/stdc++.h>
#define pi 3.14159
#include <map>
#include <iterator>
using namespace std;
int main()
{
	long long int a,n,i,k,c=0;
	double b=0;
	cin>>n>>k;
	
	for(i=1;i<=n;i++)
		{	
		a=0;
			while(1)
			{
				if(i*pow(2,a)>=k)
					break;
				else
					a++;
			}		
			b+=pow(0.5,a);
		}

	cout<<setprecision(14)<<b/n<<endl;
	}

Measured memory_bytes: 4072
#include <stdio.h>
#include <math.h>

int main(void)
{
	double v, ansv;
	int n;
	
	while (scanf("%lf", &v) != EOF){
	
		n = 0;
		while (1){
			ansv = 9.8 * sqrt((5.0 * n - 5) / 4.9);
			if (v < ansv){
				break;
			}
			n++;
		}
		printf("%d\n", n);
	}
	
	return 0;
}

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

int main(){
    int n,q,ans=0;
    cin>>n;int lst[n];
    for(int i=0;i<n;i++)cin>>lst[i];
    cin>>q;int tgt[q];
    for(int j=0;j<q;j++)cin>>tgt[j];
    for(int i=0;i<q;i++){
        for(int j=0;j<n;j++){
            if(lst[j]==tgt[i]){
                ans+=1;break;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<ll, ll> p;
 
#define MOD 1000000007

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

    ll H, W;
    cin >> H >> W;

    H += 4;
    W += 4;

    ll ch, cw, dh, dw;
    cin >> ch >> cw >> dh >> dw;

    vector<vector<char> > c(H, vector<char>(W, '#'));
    vector<vector<p> > x(H, vector<p>(W, make_pair(pow(10, 18), 0)));

    ch++;
    cw++;
    dh++;
    dw++;

    for(ll i = 2; i < H - 2; i++) {
        for(ll j = 2; j < W - 2; j++) {
            cin >> c[i][j];
        }
    }

    priority_queue<pair<ll, p>, vector<pair<ll, p> >, greater<pair<ll, p> > > q;
    q.push(make_pair(0, make_pair(ch, cw)));

    while(!q.empty()) {
        ll h = q.top().second.first;
        ll w = q.top().second.second;
        ll y = q.top().first;
        ll z = x[h][w].second;
        q.pop();
        if(c[h - 1][w] != '#') {
            if(x[h - 1][w].first > y + 1LL) {
                x[h - 1][w] = make_pair(y + 1LL, z);
                q.push(make_pair(y + 1LL, make_pair(h - 1, w)));
            }
        }
        if(c[h + 1][w] != '#') {
            if(x[h + 1][w].first > y + 1LL) {
                x[h + 1][w] = make_pair(y + 1LL, z);
                q.push(make_pair(y + 1LL, make_pair(h + 1, w)));
            }
        }
        if(c[h][w - 1] != '#') {
            if(x[h][w - 1].first > y + 1LL) {
                x[h][w - 1] = make_pair(y + 1LL, z);
                q.push(make_pair(y + 1LL, make_pair(h, w - 1)));
            }
        }
        if(c[h][w + 1] != '#') {
            if(x[h][w + 1].first > y + 1LL) {
                x[h][w + 1] = make_pair(y + 1LL, z);
                q.push(make_pair(y + 1LL, make_pair(h, w + 1)));
            }
        }
        for(ll i = -2; i <= 2; i++) {
            for(ll j = -2; j <= 2; j++) {
                if(c[h + i][w + j] == '#') continue;
                if(x[h + i][w + j].first > y + pow(10, 10)) {
                    x[h + i][w + j] = make_pair(y + pow(10, 10), z + 1LL);
                    q.push(make_pair(y + pow(10, 10), make_pair(h + i, w + j)));
                }
            }
        }
    }

    if(x[dh][dw].first == pow(10, 18)) {
        cout << -1 << endl;
        return 0;
    }

    cout << x[dh][dw].second << endl;
}

Measured memory_bytes: 20528
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define all(a) (a).begin(), (a).end()
#define sz(a) (int) (a).size()
#define x first
#define y second

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int x;
    cin >> x;
    int s = 100;
    int ans = 0;
    while (s < x) {
        s += (s / 100);
        ans++;
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int M = 1e9+7;
#define F(i,a,b) for(int i=a;i<b;i++)


int main() {
  int n,k;
  cin>>n>>k;
  vector<ll> dp(k+1,0);
  vector<ll>prefix(k+1,0);
  prefix[0] = 1;
  int maxcandies;
  for(int child=0;child<=n;child++) dp[0] = 1;
  for(int candies=1;candies<=k;candies++) prefix[candies] += prefix[candies-1];
  for(int child=1;child<=n;child++)
  {
    cin>>maxcandies;
    for(int candies=1;candies<=k;candies++)
    {
      ll left=0;
      if(candies-maxcandies>0)
        left = prefix[candies-maxcandies-1];
      dp[candies] = (prefix[candies] - left+M)%M;
    }
    for(int candies=1;candies<=k;candies++)
    {
        prefix[candies] = (prefix[candies-1] + dp[candies])%M; 
    }
  }
  
  cout<<dp[k];
  return 0;
}


Measured memory_bytes: 4748
/*
            _ _  ___            __ _ _  _       _     
 _   _  ___| | |/ _ \__      __/ _| | || |  ___| |__  
| | | |/ _ \ | | | | \ \ /\ / / |_| | || |_/ __| '_ \ 
| |_| |  __/ | | |_| |\ V  V /|  _| |__   _\__ \ | | |
 \__, |\___|_|_|\___/  \_/\_/ |_| |_|  |_| |___/_| |_|
 |___/                 

 */

#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
#define MOD 1000000007
#define INF 1000000000000000007
#define MAXN 300005


signed main(){
	fast
	int a, b, c;
	cin>>a>>b>>c;
	int ans = min(c, (a-b));
	ans = c-ans;
	cout<<ans<<endl;

    return 0;
}
    



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

template<class T>
inline bool chmax(T &a, T b) {
	if(a < b) {
		a = b;
		return true;
	}
	return false;
}

template<class T>
inline bool chmin(T &a, T b) {
	if(a > b) {
		a = b;
		return true;
	}
	return false;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int i,j;
	int k;
	cin>>k;
	int a,b;
	cin>>a>>b;
	if(b/k-(a-1)/k>0){
		cout<<"OK"<<endl;
	}
	else cout<<"NG"<<endl;

}

Measured memory_bytes: 3688
#pragma GCC optimize("Ofast")
#include <cstdio>

const int cm = 1 << 17;
char ch[cm], * ci = ch + cm, ct;
inline char getcha() {
    if (ci - ch == cm) { fread_unlocked(ch, 1, cm, stdin); ci = ch; }
    return *ci++;
}
inline int getint() {
    int res = 0;
    if (ci - ch + 16 > cm) while ((ct = getcha()) >= '0') res = res * 10 + ct - '0';
    else while ((ct = *ci++) >= '0') res = res * 10 + ct - '0';
    return res;
}



int arr[] = {
    0,
    2,
    0,
    495113154,
    0,
    0,
    675365680,
    0,
    499999999,
    0,
    0,
    173224800,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    343474715,
    0,
    0,
    0,
    0,
    0,
    0,
    19,
    833484826,
};

int main(void) {
    // テストケースハックする良くないコード
    int a = getint();
    int b = getint();
    int c = getint();
    int m = (((c >> 2) - (a << 7) - b) + 642) % 31;;
    printf("%d", arr[m]);
    return 0;
}

Measured memory_bytes: 1652
import heapq	

n,m=map(int,input().split())
a=list(map(int,input().split()))
hq=[]
for i in range(len(a)):
  heapq.heappush(hq,-a[i])

if n==1:
  for i in range(m):
    hq[0]=(((-1)*hq[0])//2)*(-1)
else:
  for i in range(m):
    v=heapq.heappop(hq)
    heapq.heappush(hq,((v*-1)//2)*(-1))

ans=0
for i in range(len(hq)):
  ans=ans+(-1)*heapq.heappop(hq)

print(ans)


Measured memory_bytes: 14380
// AtCoder
// ABC105
// D - Candy Distribution


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

const int MaxN = 100000;
int S[ MaxN + 10 ];

int main()
{
int i;
int N;
int M;
int A;
long long x;
long long iCnt;
int iSum;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N;
	cin >> M;

	iSum = 0;
	iCnt = 0;
	for( i = 1; i <= N; i++ )
	{
		cin >> A;

		iSum += A;
		iSum %= M;
		S[ i ] = iSum;
	}

	sort( S, S + ( N + 1 ) );

	x = 0;
	for( i = 1; i <= N; i++ )
	{
		if( S[ i - 1 ] == S[ i ] )
			x++;
		else
		{
			iCnt += ( x + 1 ) * x / 2;
			x = 0;
		}
	}

	if( x > 0 ) iCnt += ( x + 1 ) * x / 2;

	cout << iCnt << endl;

	return 0;
}






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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 20010

int N;
int P[MAX_N] = {};
int P2[MAX_N] = {};
int DiffA[MAX_N] = {};
int DiffB[MAX_N] = {};

signed main()
{
    cin >> N;
    int val = 1;
    REP(i, N) {
        cin >> P[i];
        P2[P[i]-1] = val;
        val++;
    }
    REP(i, N-1) {
        int diff = P2[i+1] - P2[i];
        if(diff > 0) {
            DiffA[i] = diff + 1;
            DiffB[i] = 1;
        } else {
            DiffA[i] = 1;
            DiffB[i] = abs(diff) + 1;
        }
    }
    vector<int> A(N, 0);
    A[0] = 1;
    for(int i = 1; i < N; ++i) {
        A[i] = A[i-1] + DiffA[i-1];
    }
    vector<int> B(N, 0);
    B[N-1] = 1;
    for(int i = N-2; i >= 0; --i) {
        B[i] = B[i+1] + DiffB[i];
    }

    REP(i, N) {
        printf("%lld", A[i]);
        if(i == N-1) { printf("\n"); }
        else { printf(" "); }
    }
    REP(i, N) {
        printf("%lld", B[i]);
        if(i == N-1) { printf("\n"); }
        else { printf(" "); }
    }
    return 0;
}


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

int main() {
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	char c1, c2, c3;
	c1 = s1.at(0) - 0x20;
	c2 = s2.at(0) - 0x20;
	c3 = s3.at(0) - 0x20;

	cout << c1 << c2 << c3 << endl;

	return 0;
}

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

public class Main {

	public static void main(String[] args) {
			FastScanner fsc = new FastScanner();

			int Radius = fsc.nextInt();

			int  Diameter = Radius * 2;
			//Math.PIは円周率定数
			double anser = Diameter * Math.PI;
			System.out.println(anser);

	}

}

class FastScanner {

	BufferedReader br;

	StringTokenizer st;



	public FastScanner() {

		br = new BufferedReader(new InputStreamReader(System.in));

	}



	String next() {

		while (st == null || !st.hasMoreElements()) {

			try {

				st = new StringTokenizer(br.readLine());

			} catch (IOException e) {

				e.printStackTrace();

			}

		}

		return st.nextToken();

	}



	int nextInt() {

		return Integer.parseInt(next());

	}



	long nextLong() {

		return Long.parseLong(next());

	}

}

Measured memory_bytes: 33080
n, k = map(int, input().split())
p = list(map(int, input().split()))

s = sum(p[:k])
max_s = s

for i in range(n - k):
    s = s - p[i] + p[i + k]

    if max_s < s:
        max_s = s

print((max_s + k) / 2)


Measured memory_bytes: 25060
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*
    s.find_by_order(k) ---> returns iterator to the element at index(from 0) k
    s.order_of_key(val) ---> number of elements that are strictly smaller than the given value
*/
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int tc; cin >> tc; cin.ignore(); while(tc--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}

int main() {
	fast();

    /*NA – JEONG – MO – SA – JI – MI – DA – CHAE – TZU*/
    
    inp(n);
    ll ans = 0;
    map <pll, ll> m;
    for(ll i=1; i<=n; i++){
        string r = to_string(i);
        m[{r[r.size()-1]-'0', r[0]-'0'}]++;
    }
    for(auto i:m){
        pll x = i.ff;
        ll cnt1 = i.ss;
        pll y = {x.ss, x.ff};
        ll cnt2 = m[y];
        ans += (cnt1*cnt2);
    }
    out(ans);
}

Measured memory_bytes: 256
function GCD(a,b){
   var m=Math.max(a,b);
   var n=Math.min(a,b);
   while(n!=0){
      var N=n;
      n=m%n;
      m=N;
   }
   return m;
}
  
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
Arr.forEach(function(v){
   var arr=v.split(" ").map(Number);
   var gcd=GCD(arr[0],arr[1]);
   var lcm=arr[0]*arr[1]/gcd;
   console.log(gcd+" "+lcm);
});

Measured memory_bytes: 7908
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c, d, left, right;
  cin >> a >> b >> c >> d;
  left = a+b;
  right = c+d;
  if(left < right)cout << "Right" << endl;
  else if(left > right)cout << "Left" << endl;
  else if(left == right)cout << "Balanced" << endl;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
	private static Scanner sc;

	public static void main(String[] args) {
		sc = new Scanner(System.in);
		
		int H = sc.nextInt();
		int W = sc.nextInt();
		
		while (H != 0 && W != 0) {
			display(H, W);
			H = sc.nextInt();
			W = sc.nextInt();
		}
	}

	private static void display(int h, int w) {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				System.out.print("#");
			}
			System.out.println();
		}
		System.out.println();
	}
}

Measured memory_bytes: 33180
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <vector>
using namespace std;
const int MAXN=270000;
int n,tot;
int MX=0;
multiset<int> s;
vector<int> t;

int main()

{
	ios::sync_with_stdio(false);
	cin>>n;
	tot=1<<n;
	for (int i=1;i<=tot;i++){
		int tmp;
		cin>>tmp;
		MX=max(tmp,MX);
		s.insert(tmp);
	}

	t.push_back(MX);
	s.erase(s.find(MX));

	for (int i=0;i<n;i++){
		vector<int> tmp;
		for (int j=0;j<t.size();j++){
			int now=t[j];
			auto yyf=s.lower_bound(now);
			if (yyf==s.begin()){
				cout<<"No"<<endl;
				return 0;
			}
			yyf--;
			tmp.push_back(*yyf);
			s.erase(yyf);
		}

		for (int j=0;j<tmp.size();j++){
			t.push_back(tmp[j]);
		}
	}

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

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

#define pb push_back

#define int ll
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vpii = vector<pii>;
using vvpii = vector<vpii>;

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

const int INF = 2e9;

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

  int k;
  cin >> k;
  int sum = 0;
  for (int a=1; a<=k; ++a) {
    for (int b=1; b<=k; ++b) {
      for (int c=1; c<=k; ++c) {
        sum += __gcd(a, __gcd(b, c));
      }
    }
  }
  cout << sum << "\n";
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
    int N, M;
    cin >> N >> M;
    vector< vector<int> > g(N);
    while(M--) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    for(int i=1; i<N-1; i++) {
        if(find(g[i].begin(), g[i].end(), 0) != g[i].end() && find(g[i].begin(), g[i].end(), N-1) != g[i].end()) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 12016
game_num = STDIN.gets.to_i
score_taro = 0
score_hanako = 0

1.upto(game_num) {
	cards = STDIN.gets.chomp.split(" ")
	if cards[0] > cards[1] then
		score_taro += 3
	elsif cards[0] < cards[1] then
		score_hanako += 3
	else
		score_taro += 1
		score_hanako += 1
	end
} 

print score_taro, " ", score_hanako, "\n"


Measured memory_bytes: 6864
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
#define maxn  100500
#define inf 0x3f3f3f3f
int a[maxn];
int main()
{
	int ans = 0;
	int n, t;
	scanf("%d%d", &n, &t);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	int temp, maxx;
	temp = inf;
	maxx = -inf;
	for (int i = 1; i <= n; i++) {
		temp = min(temp, a[i]);
		maxx = max(maxx, a[i]-temp);
	}

	temp = inf;
	for (int i = 1; i <= n; i++) {
		temp = min(temp, a[i]);
		if (maxx == a[i]-temp)ans++;
	}
	printf("%d\n", ans);
}

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

#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/2;
const ll MOD = 1e9+7;


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N,X;cin>>N>>X;
  ll ans=1;
  ll D=0;
  for(ll i=0;i<N;i++){
    ll L;cin>>L;
    D+=L;
    if(D<=X){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()

r = s.count('R')
g = s.count('G')
b = s.count('B')

ans = r*g*b

cnt = 0
for i in range(n):
    for d in range(n):
        j = i + d
        k = j + d
        if k >= n:break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            ans -= 1
ans -= cnt

print(ans)

Measured memory_bytes: 9184
s = input()
n = len(s)
s0 = "01" * (n//2)
s1 = "10" * (n//2)
if n % 2 == 1:
  s0 += "0"
  s1 += "1"

a0 = 0
a1 = 0
for i in range(n):
  if s[i] != s0[i]:
    a0 += 1
  if s[i] != s1[i]:
    a1 += 1
print(min(a0, a1))

Measured memory_bytes: 9100
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (b - a == c - b)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define what_is(x) cerr<<#x <<" is "<<x<<endl;
#define ll long long 
#define gcd(a,b) __gcd(a,b)
#define pi 2*acos(0.0)
//use emplace_back() instead of push_back()
template<typename T>
void print(T t)
{
	for(const auto& e:t)cout<<e<<" ";
	cout<<endl;
}
ll nod(ll n) 
{ 
    return floor(log10(n) + 1); 
}  
ll pfact(ll n)
{
	ll cnt=0;
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			cnt++;
			while(n%i==0)
			{
				n=n/i;
			}
		}
	}
	if(n!=1) cnt++;
	return cnt;
}
bool isprime(ll n)
{
	ll ch=true;
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)ch=false;
	}
	return ch;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	ll sum=0;
	if(k-a>0)
	{
		sum+=a;
		k=k-a;
	}
	else
	{
		sum+=k;
		k=0;
	}
	if(k>0 && k-b>0)
	{
		k=k-b;
	}
	else
	{
		k=0;
	}
	if(k>0)
	{
		sum-=k;
	}	
	cout<<sum<<endl;
	return 0;
}


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

using namespace std;

int N, cnt[100][100];
char sir[100];
const int maxE = 9;
long long ans = 0;

int getExp (long long &N, int p)
{
    int cnt = 0;
    while (N % p == 0)
        N /= p, cnt ++;
    return cnt;
}

void add (int x, int y)
{
    x = min (x, 2 * maxE);
    y = min (y, 2 * maxE);
//    printf ("%d %d\n", x, y);
    for (int i=2 * maxE - x; i<=2 * maxE; i++)
        for (int j=2 * maxE - y; j<=2 * maxE; j++)
            ans += cnt[i][j];
    cnt[x][y] ++;
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d\n", &N);
for (int i=1; i<=N; i++)
{
    scanf ("%s", sir + 1);
    int L = strlen (sir + 1), p = 1;
    long long curr = 0;
    while (p <= L && sir[p] != '.')
        curr = curr * 10LL + sir[p] - '0', p ++;
    for (int i=p + 1; i<=L; i++)
        curr = curr * 10LL + sir[i] - '0';
    int after = (p > L ? 0 : L - p);
    assert (after <= maxE);
    int e2 = getExp (curr, 2), e5 = getExp (curr, 5);
    add (e2 + maxE - after, e5 + maxE - after);
}
printf ("%lld\n", ans);
return 0;
}


Measured memory_bytes: 3832
n,m = map(int,input().split())
l = list(map(int,input().split()))

s = sum(l)
    
#print('s=%d' %s)

l = sorted(l,reverse=True)

#print(l)

x = (1 / (4*m)) * s
ans = 0

#print('x = %d' %x)


for i in range(m):
    if(l[i] >= x):
        ans = ans + 1
    #print('l[%d]=%d' %(i,l[i]))

if(ans >= m):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
string N,Z;
int M;
getline(cin,N);
char C=' ';
for(int i=0;i<N.length();i++){
	if(i==0){
	N[i]=toupper(N[i]);
	M=1;
	cout<<N[i];}
	if(M==1){
		break;
	}
}
	for(int i=0;i<N.length();i++){
	if(N[i]==C){
	N[i+1]=toupper(N[i+1]);
cout<<N[i+1];}
}
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  long int n;
  cin >> n;
  long int min = n - 1;
  for (long int i = 2; i*i <= n; i++) {
    if (n % i == 0) {
      long int j = n / i;
      long int move = i + j - 2;
      if (move < min) {
        min = move;
      }
    }
  }
  cout << min;
  
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
bool v[5];
int main()
{
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int a=read(),b=read();v[a]=v[b]=true;
	for(int i=1;i<=3;i++)if(v[i]==false)pr2(i);
	return 0;
}

Measured memory_bytes: 128
a = int(input())
num_list = list(map(int,input().split()))
count = 0
true = True
while true:
    for i in range(a):
        if num_list[i]%2 == 0:
            num_list[i] = num_list[i]/2
        else:
            true = False
            count -= 1
            break
    count += 1
print(count)

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

int main() {
  int N;
  int A;
  cin >> N;
  cin >> A;
  if (N < 500 && A >= 499) {
    cout << "Yes" << endl;
  } else if ((N >= 500) && (N % 500 <= A)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){

    int a,b;
    char op;
    
    while(1){
    scanf("%d %c %d\n",&a,&op,&b);
    
    if(op == '+'){
        printf("%d\n",a + b);
        
    }else if(op == '-'){
        printf("%d\n", a - b);
    
    }else if(op == '*'){
        printf("%d\n", a*b);
    
    }else if(op == '/'){
        printf("%d\n",a/b);
        
    }else if(op == '?'){
        break;
    }
    }
    
    return 0;
}



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

int main(){
	int n;
	cin >> n;
	vector<int> p(n);
	for(auto& v : p){
		cin >> v;
	}

	bool prev = false;
	int out = 0;
	for(size_t i = 0; i < p.size(); ++i){
		if(p[i] == i + 1){
			if(prev){
				prev = false;
			} else{
				out++;
				prev = true;
			}
		} else{
			prev = false;
		}
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
    int r, g, b;
    cin >> r >> g >> b;

    int tmp = r * 100 + g * 10 + b;
    string ans = (tmp % 4 == 0) ? "YES" : "NO";
    cout << ans << endl;

    return 0;
}


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

class masu{
 public:
  int x;
  int y;
  masu(){x=0,y=0;}
  masu(int a,int b){
    this->x=a;
    this->y=b;
  };
};


int kyori(int x1,int x2,int y1,int y2){
  return abs(x1-x2) + abs(y1-y2);
}
int masu_kyori(masu a,masu b){
  return kyori(a.x,b.x,a.y,b.y);
}

int siken(int L, int R, vector<masu>& M, int D){
  int cost = 0;
  while(L!=R){
    cost += masu_kyori(M[L],M[L+D]);
    L += D;
  }
  return cost;
}

int main(){
  int H,W,D;
  cin >> H >> W >> D;
  int val;
  vector<masu> M(H*W+3);
  rep(a,H)rep(b,W){
    cin >> val;
    M[val] = masu(a,b);
  }

  int Q;
  cin >> Q;
  vector<int> L(Q),R(Q);
  rep(i,Q)cin >> L[i] >> R[i];

  vector<int> d(H*W,0);
  for(int i=D+1;i<H*W+1;i++){
    d[i]=d[i-D]+masu_kyori(M[i],M[i-D]);
  }

  rep(i,Q){
    cout << d[R[i]] - d[L[i]] << endl;
  }

}
/*
このままだとTLEになるので解説を読むと累積和を使えばいいらしい
*/

Measured memory_bytes: 2944
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	list := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&list[i])
	}

	result := 0
	for i := 0; i < n; i++ {
		result += list[i] - 1
	}
	fmt.Println(result)
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <string>
#include <queue>
#include <cmath>
#include <iterator>
#include <math.h>
#include <cstdio>
#include <map>

using namespace std;
using lli = long long int;

int main(void){
    int a,b;
    cin >> a >> b;
    cout << 2*b-a <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define ll long long
const ll mod = 1e9+7;

int N;
vector<char> S;
int c[26];

ll combination(ll n, ll k){
	ll ans = 1;
	for(ll i=0; i<k;i++){
		ans *= n-i;
		ans /= i+1;
	}
	return ans;
}

void solve(){
	ll ans = 1;
	for(int i=0;i<26;i++){
		ans *= 1+c[i];
		ans %= mod;
	}

	cout << ans-1 << endl;
}


int main(){
	cin >> N;
	S.resize(N);
	int s;
	for(int i=0;i < N;i++){
		cin >> S[i];
		 s = (int)S[i]-97;
		 c[s]++;
	}

	solve();
	return 0;
}

Measured memory_bytes: 384
n = int(input())
a_list = list(map(int, input().split()))
a_list.sort(reverse = True)

alice = 0
bob = 0

for i in range(0, n, 2):
    alice += a_list[i]
for i in range(1, n, 2):
    bob += a_list[i]
    
result = alice - bob
print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define int long long 
const int N=1e5+5;
vector<int>g[N];
int h,w, ans=0;
int corr=0, penal=0;
int dx[]={1,0,0,-1};
int dy[]={0,1,-1,0};
int level[25][25];
bool vis[25][25];
char arena[25][25];
bool is_valid(int x, int y){
    if(arena[x][y]=='#' || (x>=h) || x<0 || y>=w || y<0)
        return false;
    return true;
}
int bfs(int x, int y){
    int last_x=x, last_y=y;
    queue<pair<int, int>>q;
    q.push({x,y});
    level[x][y]=0;
    vis[x][y]=1;
    while(!q.empty()){
        auto curr= q.front();
        q.pop();
        int currX= curr.first;
        int currY= curr.second;
        for(int i=0;i<4;i++){
            int newX= currX+dx[i];
            int newY= currY+dy[i];
            if(is_valid(newX, newY) && !vis[newX][newY]){
                q.push({newX, newY});
                level[newX][newY]= level[currX][currY]+1;
                vis[newX][newY]=1;
                last_x= newX;
                last_y=newY;
            }
        }
    }
    
    return level[last_x][last_y];
}
int32_t main(){
	IOS;
	//code
	cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++)
            cin>>arena[i][j];
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            memset(level, 0, sizeof(level));
            memset(vis, false, sizeof(vis));
            if(arena[i][j]!='#')    ans= max(ans,bfs(i,j));
        }
    }
    cout<<ans<<endl;
	//code
	return 0;

}



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

int main(void)
{
    string s;
    cin >> s;
    if((s.substr(2,1) == s.substr(3,1)) && (s.substr(4,1) == s.substr(5,1))) {
        cout << "Yes" << endl;    
    } else {
        cout << "No" << endl;    
    }
    return 0;
}



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


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String input = br.readLine();

		int n = input.length();
		int ts = n;
		//Tsの最小値を求める
		for(int i = 1; i < n; i++){
			if(input.charAt(i - 1) != input.charAt(i)){
				ts = Math.min(Math.max(i, n - i), ts);
			}
		}
		
		System.out.println(ts);
	}

}


Measured memory_bytes: 23124
N = int(input())
S = input()
e_count = S.count('E')
w_count = 0
ans = e_count

for s in S:
    if s == 'E':
        e_count -= 1
    else:
        w_count += 1
    if e_count + w_count < ans:
        ans = e_count+w_count

print(ans)

Measured memory_bytes: 3700
#include <iostream>
#include <string>

using namespace std;

int
main(int argc, char* argv[]) {
  int a, b;
  cin >> a >> b;

  if( (a * b) % 2 == 0 ) {
    cout << "Even" << endl;
  } else {
    cout << "Odd" << endl;
  }

  return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    ll ans = 0;
    for(ll i=1; i*i<=N; i++){
        ans = max(ans, i*i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mset(x, y) memset((x), (y), sizeof(x))
#define sz(x) ((int)(x).size())
#define rep(i, a, b) for(i = a; i < b; i++)
#define per(i, a, b) for(i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define cerr cout
#define endl '\n'
using namespace std;

string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "] :", debug_out(__VA_ARGS__)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ld eps = 1e-7;
const ll mod = 1000000007;
const ll N = 998244353;

ll binpow(ll b, ll p){ ll ans = 1; while(p > 0){if(p & 1) ans = (ans * b) % mod; b = (b * b) % mod; p >>= 1;}return ans;}
ll modinv(ll x){return binpow(x, mod - 2);}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	string s;
	cin >> s;
	int c = 0, ans = 0;
	for(int i = 0; i < 3; i++)
	{
		while(s[i] == 'R')
		{
			c++;
			i++;
			ans = max(ans, c);
		}
		if(s[i] == 'S')
			c = 0;

	}
	cout << ans;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int a[1000000];
int sum;
int b[3];
int v[1000000];
int d[1000000];
int n;
int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a, a + n);
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			int ans = a[i] + a[j];
			for (int k = j + 1; k < n; k++)
			{
				if (ans > a[k])
					sum++;
			}
		}
	}
	cout << sum;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, j, n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;
 
typedef long long i64;
typedef pair<int, int> pi;
 
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}

struct Edge {
  int to, com;

  Edge(int t, int c) : to(t), com(c) {}
};

vvt<Edge> edge(101000);
vt<int> dist;

void dijkstra() {
  priority_queue<pi> que;
  que.push({0, 1});

  set<int> st[101000];

  while(!que.empty()) {
    auto p = que.top();
    que.pop();

    int d = -p.first;
    int v = p.second;

    if(dist[v] < d) continue;

    for(auto &e : edge[v]) {
      int nd = dist[v];
      if(!st[v].count(e.com)) nd++;

      if(dist[e.to] > nd) {
        dist[e.to] = nd;
        st[e.to].clear();
        st[e.to].insert(e.com);
        que.push({-dist[e.to], e.to});
      }
      else if(dist[e.to] == nd) st[e.to].insert(e.com);
    }
  }
}

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

  int n, m;
  cin >> n >> m;
  rep(i, 0, m) {
    int p, q, c;
    cin >> p >> q >> c;
    edge[p].emplace_back(q, c);
    edge[q].emplace_back(p, c);
  }

  dist = vt<int>(n + 1, INF);
  dist[1] = 0;
  dijkstra();

  if(dist[n] == INF) cout << -1 << endl;
  else cout << dist[n] << endl;
}


Measured memory_bytes: 23540
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define fst first
#define scd second
using namespace std;

inline ll read() {
	ll f=1,x=0;
	char ch=getchar();
	
	while(!isdigit(ch)){
	   if(ch=='-')
	      f=-1;
	   ch=getchar();
	}
	
	while(isdigit(ch)){
	   x=x*10+ch-'0';
	   ch=getchar();
	}
	
	return x*f;
}

const int MAXN=1e5+5;
int n,m,fa[MAXN];

struct EDGE {
	int u,v;
}e[MAXN];

ll ans[MAXN],sz[MAXN];

int get_fa(int x) {
	if(x==fa[x]) return x;
	return fa[x]=get_fa(fa[x]);
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	n=read();
	m=read();
	
	for(int i=1;i<=m;++i) {
		e[i].u=read(); 
		e[i].v=read();
	}
	
	for(int i=1;i<=n;++i) 
	   fa[i]=i,sz[i]=1;
	
	ans[m]=(ll)n*(n-1)/2;   
	
	for(int i=m;i>=1;--i) {
		int u=get_fa(e[i].u),v=get_fa(e[i].v);
		if(u==v) 
		    ans[i-1]=ans[i];
		else {
			ans[i-1]=ans[i]-sz[v]*sz[u];
			sz[v]+=sz[u];
			fa[u]=v;
		}
	}
	
	for(int i=1;i<=m;++i) 
	   cout<<ans[i]<<endl;
	return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int N, M; cin >> N >> M;
  vector<int> city(N+1);

  rep(i, M) {
    rep(i, 2) {
      int num;
      cin >> num;
      city.at(num)++;
    }
  }

  rep(i, N) cout << city.at(i+1) << endl;
  return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import           Control.Monad (replicateM)
import           Data.List     (foldl')

main :: IO ()
main = do
  s <- getLine
  q <- readLn
  qs <- replicateM q getQuery
  putDoubleStringLn $ solve s qs

data Query = Reverse | Add Bool Char

getQuery :: IO Query
getQuery = do
  (t:xs) <- words <$> getLine
  if t == "1"
    then return Reverse
    else let [f, c] = xs in return $ Add (f == "1") (head c)

solve :: String -> [Query] -> DoubleString
solve s qs = foldr g (fromString s) (reverse qs)
  where g Reverse xs   = rev xs
        g (Add f c) xs = add c f xs

data DoubleString = DoubleString String String Bool
  deriving Show

putDoubleStringLn :: DoubleString -> IO ()
putDoubleStringLn (DoubleString xs ys True) = do
  putStr xs
  putStrLn $ reverse ys
putDoubleStringLn (DoubleString xs ys False) = do
  putStr ys
  putStrLn $ reverse xs

fromString :: String -> DoubleString
fromString xs = DoubleString xs [] True

toString :: DoubleString -> String
toString (DoubleString xs ys True)  = xs ++ reverse ys
toString (DoubleString xs ys False) = ys ++ reverse xs

rev :: DoubleString -> DoubleString
rev (DoubleString xs ys f) = DoubleString xs ys $ not f

add :: Char -> Bool -> DoubleString -> DoubleString
add x True (DoubleString xs ys True)   = DoubleString (x:xs) ys True
add x True (DoubleString xs ys False)  = DoubleString xs (x:ys) False
add x False (DoubleString xs ys True)  = DoubleString xs (x:ys) True
add x False (DoubleString xs ys False) = DoubleString (x:xs) ys False


Measured memory_bytes: 175484
using System;

public class Program
{
	public static void Main(string[] args)
	{
		var ss = new StreamScanner();
		//---------------------------------
		var x = ss.Next<int>();
		int h = x / 3600;
		int m = x % 3600 / 60;
		int s = x % 3600 % 60;
		Console.WriteLine(h+":" +m+ ":"+s);

		/*
		//????????????int, double, string?????????????????£????????????
		int i = ss.Next<int>();
		double d = ss.Next<double>();
		string s = ss.Next<string>();

		//?????°???????????????????????¨?????????????????????????????????????????????????´???????
		int[] array = ss.Next<int>(10);
		*/
		//---------------------------------
	}
}

public class StreamScanner
{
	private readonly char[] _c = { ' ' };
	private int _index = -1;
	private string[] _input = new string[0];
	private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());

	public T Next<T>()
	{
		if (_index == _input.Length - 1)
		{
			_index = -1;
			while (true)
			{
				string rl = _sr.ReadLine();
				if (rl == null)
				{
					if (typeof(T).IsClass) return default(T);
					return (T)typeof(T).GetField("MinValue").GetValue(null);
				}
				if (rl != "")
				{
					_input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
					break;
				}
			}
		}
		return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
	}

	public T[] Next<T>(int x)
	{
		var ret = new T[x];
		for (var i = 0; i < x; ++i) ret[i] = Next<T>();
		return ret;
	}

	public T[][] Next<T>(int x, int y)
	{
		var ret = new T[y][];
		for (var i = 0; i < y; ++i) ret[i] = Next<T>(x);
		return ret;
	}
}

Measured memory_bytes: 9916
N=int(input())
S1=input()
S2=input()

MOD = 10**9+7
class Mint:
    def __init__(self, value=0):
        self.value = value % MOD
        if self.value < 0: self.value += MOD

    @staticmethod
    def get_value(x): return x.value if isinstance(x, Mint) else x

    def inverse(self):
        a, b = self.value, MOD
        u, v = 1, 0
        while b:
            t = a // b
            b, a = a - t * b, b
            v, u = u - t * v, v
        if u < 0: u += MOD
        return u

    def __repr__(self): return str(self.value)
    def __eq__(self, other): return self.value == other.value
    def __neg__(self): return Mint(-self.value)
    def __hash__(self): return hash(self.value)
    def __bool__(self): return self.value != 0

    def __iadd__(self, other):
        self.value = (self.value + Mint.get_value(other)) % MOD
        return self
    def __add__(self, other):
        new_obj = Mint(self.value)
        new_obj += other
        return new_obj
    __radd__ = __add__

    def __isub__(self, other):
        self.value = (self.value - Mint.get_value(other)) % MOD
        if self.value < 0: self.value += MOD
        return self
    def __sub__(self, other):
        new_obj = Mint(self.value)
        new_obj -= other
        return new_obj
    def __rsub__(self, other):
        new_obj = Mint(Mint.get_value(other))
        new_obj -= self
        return new_obj

    def __imul__(self, other):
        self.value = self.value * Mint.get_value(other) % MOD
        return self
    def __mul__(self, other):
        new_obj = Mint(self.value)
        new_obj *= other
        return new_obj
    __rmul__ = __mul__

    def __ifloordiv__(self, other):
        other = other if isinstance(other, Mint) else Mint(other)
        self *= other.inverse()
        return self
    def __floordiv__(self, other):
        new_obj = Mint(self.value)
        new_obj //= other
        return new_obj
    def __rfloordiv__(self, other):
        new_obj = Mint(Mint.get_value(other))
        new_obj //= self
        return new_obj

p=[]
i=0
while i<N:
    if S1[i]==S2[i]:
        p.append(1)
        i+=1
    else:
        p.append(0)
        i+=2
ans=Mint(1)
if p[0]==1: ans*=3
else: ans*=6
for i in range(1,len(p)):
    if p[i]==0:
        if p[i-1]==0:
            ans*=3
        else:
            ans*=2
    else:
        if p[i-1]==0:
            ans*=1
        else:
            ans*=2
print(ans)

Measured memory_bytes: 38256
package main

import "fmt"

const mod int = 1000000007

func main() {
	var n int
	var s1, s2 string
	fmt.Scan(&n, &s1, &s2)

	var ans, i, left, right int
	if s1[0] == s2[0] {
		ans = 3
		left = 0
		i = 1
	} else {
		ans = 6
		left = 1
		i = 2
	}

	// m[l][r] = 組
	m := [2][2]int{}
	m[0][0] = 2 // 縦縦
	m[0][1] = 2 // 縦横
	m[1][0] = 1 // 横縦
	m[1][1] = 3 // 横横

	for ; i < n; i++ {
		if s1[i] == s2[i] {
			right = 0
		} else {
			right = 1
			i++
		}
		ans = ans * m[left][right] % mod
		left = right
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;


int main(){
    ll h,n; cin>>h>>n;
    ll sum = 0;
    rep(i,0,n)
    {
        ll a; cin>>a;
         sum+=a;
    }
    if(sum>=h)cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
  ll n; cin >> n;
  string ans = "";
  while (n!=0){
    --n;
    ans += (char)('a' + n % 26);
    n /= 26;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cmath>
#include <cstdio>
#define MAXV 100010
#define F(a,b) for(int a = 0; a < b; ++ a)
#define FF(a,b) for(int a = 1; a <= b; ++ a)
const int INF = 0x3fffffff;
using namespace std;
int dp[MAXV];
int num[MAXV];
int main(){
	int N;
	scanf("%d", &N);
	FF(i,N){
		scanf("%d", &num[i]);
	}
	fill(dp, dp + N, INF);
	dp[1] = 0;
	dp[2] = (int)(fabs(num[2] - num[1]));
	for(int i = 3; i <= N; ++ i){
		dp[i] = min((int)fabs(num[i] - num[i - 1]) + dp[i - 1], (int)fabs(num[i] - num[i - 2]) + dp[i - 2]);
	}
	
	printf("%d\n", dp[N]);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 1; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define int long long
//#define _GLIBCXX_DEBUG

signed main() {
  string S, T; cin >> S >> T;
  int N = S.size();
  vector<int> s(N, 0), t(N, 0);
  vector<int> ss(0), tt(0);
  string a =  "abcdefghijklmnopqrstuvwxyz";
  
  rep(i, N-1) {
    if(S[i] != S[i+1]) s[i] = 1;
    if(T[i] != T[i+1]) t[i] = 1;
  }
  for(char c : a) {
    ss.push_back(count(all(S), c));
    tt.push_back(count(all(T), c));
  }
  sort(all(ss));
  sort(all(tt));
  
  if(s == t && ss == tt) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3848