akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

char s[100010];
int n, ans;

int main()
{
    scanf("%s", s + 1);
    ans = n = strlen(s + 1);
    for(int i = 2; i <= n; ++i) if (s[i] ^ s[i - 1])
        ans = min(ans, max(i - 1, n + 1 - i));
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 1000000

int key[MAX+1],n;

void maxheap(int i){
    int r,l,largest;
    l = 2*i;
    r = 2*i+1;
    if(l <= n&&key[l] > key[i])largest = l;
    else largest = i;
    if(r <= n&&key[r] > key[largest])largest = r;
    if(largest != i){
    swap(key[i],key[largest]);
        maxheap(largest);
    }
}
int main(){
    
    cin >> n;
    
    for(int i = 1;i <= n;i++)cin >> key[i];
    for(int i = n/2;i >= 1;i--)maxheap(i);
    for(int i = 1;i <= n;i++)cout << " " << key[i];
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 4944
//
/*==========================================================*/
/*    Template ver 2017-0720    |    Created by JollyBee    */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
const double EPS=(double)1e-9;
const double PI=(double)acos(-1.0);
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define FOR(i,n) for(int i=0;i<n;i++)
#define REPP(i,l,r,c) for(int i=l;i<=r;i+=c)
#define REP(i,l,r) REPP(i,l,r,1)
#define FORD(i,n) for(int i=n-1;i>=0;i--)
#define REVV(i,l,r,c) for(int i=l;i>=r;i-=c)
#define REV(i,l,r) REVV(i,l,r,1)
//random
int irand(int lo, int hi){
    return (((double)rand())/(RAND_MAX+1.0)) * (hi-lo+1) + lo;
}
//ll to string
string toString(ll x) {
    stringstream ss;
    ss << x;
    return ss.str();
}
//string to ll
ll toNumber(string S) {
    ll ret;
    sscanf(S.c_str(),"%lld",&ret);
    return ret;
}
// std::fill(start, end, value);
// for(auto it: DS){}

const int INF=(int)2e9;
const ll MOD=(ll)1e9+7;
/*==========================================================*/
/*                     END OF TEMPLATE                      */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/

int main(){
    char s[3][105]; FOR(i,3) scanf("%s", s[i]);
    FOR(i,3) printf("%c", s[i][0]); puts("");
    return 0;
}


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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const string S = "RGBY";

int H, W, d;
int c[510][510];

int main() {
	cin >> H >> W >> d;
	rep(i, H) {
		rep(j, W) {
			int x = (i+j)/d;
			int y = (i-j+1000)/d;
			int f = ((x&1)<<1)+(y&1);
			c[i][j] = f;
		}
	}

	rep(i, H) {
		rep(j, W) {
			printf("%c", S[c[i][j]]);
		}
		puts("");
	}
	
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <iomanip>

int main(int argc, char *argv[])
{
    int x[5];

    for (int i = 0; i < 5; i++) {
        std::cin >> x[i];
    }

    for (int i = 0; i < 5; i++) {
        if (x[i] == 0) {
            std::cout << i + 1 << std::endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3584
s = list(map(int,input()))
s.reverse()
t = len(s)
mod = 2019

arr = [0] * (t+1)
arr[-2] = s[0]
for i in range(1,t):
    arr[t-i-1] = (arr[t-i] + s[i]*pow(10,i,mod)) % mod

from collections import Counter
arr = Counter(arr)

ans = 0
for i in arr:
    ans += (arr[i] - 1) * arr[i] // 2

print(ans)

Measured memory_bytes: 17840
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for(ll i = a; i < (ll)(b); i++)

#define ALL(x) (x).begin(), (x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

using namespace std;
using ll = long long;
using vel = vector<ll>;
using ves = vector<string>;

int main() {
    long double pi = 3.14159265358979323846;
    long double A, B, H, M, kakudo;
    cin >> A >> B >> H >> M;
    kakudo = abs((M * 6) - (H * 30 + (M / 2.000000000000)));
    kakudo = min(360 - kakudo, kakudo);
    cout << fixed << setprecision(20) << sqrt((A*A) + (B*B) - (2*A*B*cos(kakudo * pi / 180.00000000000))) << endl;
}

Measured memory_bytes: 4164
import java.util.Scanner;

/**
 *
 * @author cs18097
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int ans = sc.nextInt();
        ans += sc.nextInt();
        ans += sc.nextInt();
        if(ans > 21){
            System.out.print("bust");
        }else{
            System.out.print("win");
        }
        
    }
    
}


Measured memory_bytes: 20948
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>
#define sz(s) s.size()
#define all(s) (s.begin(),s.end())

const int maxn=100005;
int n,ans;
int a[maxn];

int main(){
	scanf("%d",&n);
	REP(i,n)scanf("%d",&a[i]);
	REP(i,n){
		if(i!=n){
			if(a[i]==i)swap(a[i],a[i+1]),ans++;
		}
		else{
			if(a[i]==i)swap(a[i],a[i-1]),ans++;
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout << (#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> row;
typedef vector<row> matrix;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
int main() {
	//file();
	fast();
	int n; cin >> n;
	int ans = 0;
	string str; cin >> str;
	for (int i = 0; i < n; i++) {
		int j = i;
		while (j < n && str[j] == str[i])
			j++;
		i = j - 1;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
string S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	N=S.size();
	int ret=0;
	FOR(i,N) if(S[i]!=S[N-1-i]) {
		ret++;
		S[i]=S[N-1-i];
	}
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(int(i) for i in input().split())
B = []
B.append(0)
n = 1
cnt = 0

for i in A:
    B[0] += i
    B.append(B[0])
B[0] = 0
B.sort()

for i in range(1,N+1):
    if B[i] == B[i-1]:
        n += 1
    else:
        cnt += int(n*(n-1)/2)
        n = 1

cnt += int(n*(n-1)/2)

print(cnt)

Measured memory_bytes: 26136
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    int n; cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    int now = 0;
    int ans = 0;
    while(now < n){
        if(p[now] != now + 1){
            now++;
        }
        else{
            ans++;
            now += 2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>

int main(){
    int i,x,y,buff;

    for(i=0;i<10000;i++){

        std::cin>>x>>y;

        if(x>y){
            buff=y;
            y=x;
            x=buff;
        }else if(x==0&&y==0){
            break;
        }
        std::cout<<x<<" "<<y<<std::endl;
    }
}


Measured memory_bytes: 3092
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define WHITE 0
#define GRAY 1
#define BLUCK 2

void DepthFirstSearch();
void visit(int);

int matrix[200][200];
int color[200];
int SumVirtex;
int Time;
int FirstVirtexTime[200];
int LastVirtexTime[200];

/*ここからがmain関数*/
int main()
{
  int i, j, VirtexNum, ConnectSum, connect;

  scanf("%d",&SumVirtex);

  for(i = 1; i <= SumVirtex; i++){
    scanf("%d",&VirtexNum);
    scanf("%d",&ConnectSum);
    for(j = 1; j <= ConnectSum; j++){
      scanf("%d",&connect);
      matrix[i][connect] = matrix[i][connect] + 1;
    }
  }

  DepthFirstSearch();

  for(i = 1; i <= SumVirtex; i++){
    printf("%d %d %d\n", i, FirstVirtexTime[i], LastVirtexTime[i]);
  }
  return 0;
}

/*ここからがvisit関数*/
void visit(int i)
{
  int j;

  color[i] = GRAY;

  FirstVirtexTime[i] = ++Time;

  for(j = 1; j <= SumVirtex; j++){
    if(color[j] == WHITE && matrix[i][j] == 1){
      visit(j);
    }
  }
  color[i] = BLUCK;
  LastVirtexTime[i] = ++Time;
}

/*ここからがDepthFirstSearch関数*/
void DepthFirstSearch()
{
  int i;
  
  Time = 0;
 
  for(i = 1; i <= SumVirtex; i++)
    color[i] = WHITE;

  for(i =1 ; i <= SumVirtex; i++){
    if(color[i] == WHITE)
      visit(i);
  }
}



Measured memory_bytes: 2104
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  string s;
  cin >> s;
  ll n = SZ(s);
  vll a(n);
  rep(i, n){
    a[i] = s[i]-'0';
  }
  reverse(ALL(a));
  ll ans = 0;
  ll m = 1<<(n-1);
  rep(i, m){
    ll k = 1;
    rep(j, n){
      if(j >= 1 && ((i>>(j-1))&1)){
        k *= 10;
      }else{
        k = 1;
      }
      ans += a[j] * k;
    }
  }
  print(ans);
}


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

using namespace std;

typedef long long int ll;

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

  ll t1, t2, a1, a2, b1, b2;
  cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;

  ll p = (b1 - a1) * t1, q = (b2 - a2) * t2;

  if(p + q == 0){
    cout << "infinity" << endl;
    return 0;
  }
  ll shift = p + q;
  if((p > 0 && shift < 0) || (p < 0 && shift > 0)){
    ll k = p / shift;
    k = abs(k);
    ll ans = 2 * k + 1;
    if(abs(k * shift) == abs(p)) ans--;
    cout << ans << endl;
  }else{
    cout << 0 << endl;
  }
}


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

def mergeSortInversions(arr):
    if len(arr) == 1:
        return arr, 0
    else:
        a = arr[:len(arr)//2]
        b = arr[len(arr)//2:]
        a, ai = mergeSortInversions(a)
        b, bi = mergeSortInversions(b)
        c = []
        i = 0
        j = 0
        inversions = 0 + ai + bi
    while i < len(a) and j < len(b):
        if a[i] <= b[j]:
            c.append(a[i])
            i += 1
        else:
            c.append(b[j])
            j += 1
            inversions += (len(a)-i)
    c += a[i:]
    c += b[j:]
    return c, inversions

c, inversions = mergeSortInversions(A)
print(inversions)


Measured memory_bytes: 27476
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<string>
#include<set>
#include<utility>
#include<vector>
using namespace std;

double GetDistance(pair<double, double> s, pair<double, double> g){
  return sqrt(pow(g.first - s.first, 2) + pow(g.second - s.second, 2));
}
int nFactorial(int n){
  if(n==1)  return 1;
  return n * nFactorial(n-1);
}

int solve(){
  int n;  cin >> n;
  vector<pair<double, double>> vp(n);
  vector<int> route(n);
  for(int i=0; i<n; i++){
    int x, y; cin >> x >> y;
    vp[i] = make_pair(x, y);
    route[i] = i;
  }
  double total = 0;
  do{
    for(int i=0; i<n-1; i++){
      total += GetDistance(vp[route[i]], vp[route[i+1]]);
    }
  }while(next_permutation(route.begin(), route.end()));

  printf("%.6lf\n", total/nFactorial(n));
}

int main(){
  solve();
  return 0;
}


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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define MAX_LEN 50

string solve()
{
	int h, w;
	cin >> h >> w;
	char figure[MAX_LEN][MAX_LEN];
	rep(y, 0, h)
	{
		string s; cin >> s;
		rep(x, 0, w) figure[y][x] = s[x];
	}

	set<char> items, ok_items;
	map<char, int> xmin, xmax, ymin, ymax;
	rep(y, 0, h) rep(x, 0, w)
	{
		char c = figure[y][x];
		if (items.find(c) == items.end())
		{
			items.insert(c);
			xmin[c] = xmax[c] = x;
			ymin[c] = ymax[c] = y;
		}
		else
		{
			xmin[c] = min(xmin[c], x);
			xmax[c] = max(xmax[c], x);
			ymin[c] = min(ymin[c], y);
			ymax[c] = max(ymax[c], y);
		}
	}

	for (char c : items)
	{
		bool ok = true;
		rep(y, ymin[c], ymax[c] + 1) rep(x, xmin[c], xmax[c] + 1)
		{
			if (figure[y][x] != c) ok = false;
		}
		if (ok) ok_items.insert(c);
	}

	while (items.size() != ok_items.size())
	{
		bool change = false;

		for (char c : items)
		{
			if (ok_items.find(c) != ok_items.end()) continue;
			
			bool ok = true;
			rep(y, ymin[c], ymax[c] + 1) rep(x, xmin[c], xmax[c] + 1)
			{
				if (figure[y][x] == c)
				{
					// do nothing
				}
				else if (ok_items.find(figure[y][x]) != ok_items.end())
				{
					// do nothing
				}
				else
				{
					ok = false;
				}
			}
			if (ok)
			{
				ok_items.insert(c);
				change = true;
			}
		}

		if (!change) return "SUSPICIOUS";
	}

	return "SAFE";
}

int main()
{
	int n; cin >> n;
	rep(nn, 0, n)
	{
		cout << solve() << endl;
	}
}

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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << p.first << " " << p.second; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  int n; cin >> n;
  for(int i = 1; i <= n; i++){
    int tmp = int(i * 1.08);
    if(tmp == n){
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	string S;
	cin >> S;
	sort(S);
	if (S[0] == S[2]) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}


Measured memory_bytes: 764
function Main(input) {
  const lines = input.split('\n');
  const [a, b, c, d] = lines[0].split(' ').map(s => parseInt(s));
  console.log(Math.max(Math.min(b, d) - Math.max(a, c), 0));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29588
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  int n,k;
  cin >> n >> k;
  vector<ll> v(n);
  rep(i,n) cin >> v[i];
  ll ans = 1LL;
  rep(i,n-k){
    if (v[i] < v[i+k]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  

  return 0;
}


Measured memory_bytes: 4824
#include <iostream>
using namespace std;
typedef long long LL; 
int main()
{
	string s;
	cin>>s;
	LL n=s.length(),sum=0;
	if(n==1)sum=0;
	else{
		LL pre=0;
		for(LL i=0;i<n;i++){
			if(s[i]=='B')pre++;
			else sum+=pre;
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 640
#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; 
    #define lli long long int
    #define fr(i,a,b) for(lli i=a;i<b;i++)
    #define bfr(i,a,b) for(lli i=a;i>=b;i--)
    #define fio ios_base::sync_with_stdio(false); cin.tie(NULL),cout.tie(NULL);
    #define tc int t;cin>>t;while(t--)
    #define mod 1000000007LL
    #define mod2 998244353LL
    #define all(vec) vec.begin(),vec.end()  
    #define ld long double
    #define pb push_back

    #define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update> 


    int main()
    {
                           
             

             
              fio

             lli n,k;
             cin>>n>>k;
             lli h=n%k;
             cout<<max(0LL,min(h,k-h));




              
              
return 0;}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::HashMap;
use std::collections::HashSet;
use std::process;

fn main() {
    input! {
        S: chars,
        T: chars,
    }
    let mut map1: HashMap<char, char> = HashMap::new();
    let mut map2: HashMap<char, char> = HashMap::new();
    for (&c1, &c2) in S.iter().zip(T.iter()) {
        if let Some(c) = map1.insert(c1, c2) {
            if c != c2 {
                println!("No");
                process::exit(0);
            }
        }
        if let Some(c) = map2.insert(c2, c1) {
            if c != c1 {
                println!("No");
                process::exit(0);
            }
        }
    }
    println!("Yes");
}


Measured memory_bytes: 6396
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  l='1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51'
  a=l.split(', ')
  k=I()
  return a[k-1]

# main()
print(main())


Measured memory_bytes: 5700
#include <bits/stdc++.h>
using namespace std;
int main(){
while(1){
int a,b,count=0;
cin>>a>>b;
if(a==0 && b==0) break;
int x,y;

if(a >= b) x = a,y = b;
else x = b, y = a;
while(1){
x = x % y; 
swap(x,y); count++;
if(y == 0 ) break;
}cout<<x<<" "<<count<<endl;
}
return 0;
}




Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>


using namespace std;

int main() {
    long long int A, B, C, X, Y, P1, P2, P3;
    cin >> A >> B >> C >> X >> Y;

    P1 = C * max(X, Y) * 2;
    P2 = A * X + B * Y;

    if (X >= Y) {
        P3 = C * Y * 2 + A * (X - Y);
    }
    else {
        P3 = C * X * 2 + B * (Y - X);
    }

    cout << min(min(P1, P2), P3);

}



Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll a,b,c,i,j,k,l,m,n,ans,tmp,hoge,fuga,piyo,f;
ll x[10010],y[10010];
string s,str;
int main(){
  cin>>k>>s;
  if(s.length()<=k)cout<<s;
  else{
    for(int i=0;i<k;i++){
      cout<<s[i];
    }
    cout<<"...";
  }
  return 0;
}

Measured memory_bytes: 3636
import fractions
N,X = map(int,input().split())
x = list(map(int,input().split()))
x.append(X)
b = list(sorted(x))
c = list()
for i in range(N):
    c.append(b[i+1]-b[i])

t = 0
for i in range(N):
    t = fractions.gcd(t, c[i])
print(t)

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

int main() {
    int n, k, ans=1000000000;
    cin >> n >> k;
    vector<int> h(n);
    for(int i=0; i<n; i++) {
        cin >> h[i];
    }
    sort(h.begin(), h.end());
    for(int i=0; i<n-k+1; i++) {
        ans=min(ans, h[i+k-1]-h[i]);
    }
    cout << ans;
}

Measured memory_bytes: 640
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
 
def main():
  n = int(input())
  s = list(input())
  
  mid = [len(set(s[:i]) & set(s[i:])) for i in range(0,n)]
  print(max(mid))
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
@n, @a, @b, @c = gets.split.map(&:to_i)
@l = @n.times.map {gets.to_i}

def calc(i, x, y, z)
    if i == @n
        x * y * z == 0 ? 1<<20 : (x-@a).abs + (y-@b).abs + (z-@c).abs - 30
    else
        c1 = calc(i+1, x, y, z)
        c2 = calc(i+1, x+@l[i], y, z) + 10
        c3 = calc(i+1, x, y+@l[i], z) + 10
        c4 = calc(i+1, x, y, z+@l[i]) + 10
        [c1, c2, c3, c4].min
    end
end

p calc(0,0,0,0)

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
int main(){
        long long n,x,y;
        cin >> n >> x >> y;
        vector<int>ans(n,0);
        for(long long i = 1;i < n;i++){
            for(long long  j = i + 1;j <= n;j++){
                long long mn = min(j - i,abs(x - i) + abs(y - j) + 1);
                ans[mn]++;
            }
        }
        for(int i = 1; i < n;i++){
            cout << ans[i] << endl;
        }
}


Measured memory_bytes: 3636
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <random>
#include <cassert>
#include <limits>

using namespace std;

#define mp make_pair
#define pb push_back
#define repi(i, p, q) for (long i = p; i < q; i++)
#define repd(i, p, q) for (long i = p; i >= q; i--)
#define sz(x) x.size()
#define INF 2000000000
#define MOD 1000000007

typedef map<int, int> MI;
typedef pair<int, int> PI;
typedef long long int LLI;
typedef long int LI;
typedef int I;

int main()
{
    int n;
    cin >> n;
    int a[n+3];
    for(int i = 0 ; i < n ; i++){
        cin >> a[i];
    }
    int b[100003] = {0};
    int c[100003] = {0};
    for(int i = 0 ; i < n ; i++){
        if(i%2 == 0) {
            b[a[i]]++;
        } else {
            c[a[i]]++;
        }
    }
    int fi_count = 0, se_count = 0, fi = 0, se = 0;
    for(int i = 1 ; i < 100001 ; i++){
        if(b[i] > fi_count){
            fi_count = b[i];
            fi = i;
        }
        if(c[i] > se_count) {
            se_count = c[i];
            se = i;
        }
    }
    int ans = 0;

    int ans1 = 0,ans2 = 0;
    ans1 = ans1 + n/2 - fi_count;
    if(fi == se) {
        se = 0,se_count = 0;
        for(int i = 1 ; i < 100001 ; i++){
            if(c[i] > se_count && i != fi) {
                se_count = c[i];
                se = i;
            }
        }
    }
    ans1 = ans1 + n/2 - se_count;

    se = 0,se_count = 0;
    for(int i = 1 ; i < 100001 ; i++){
        if(c[i] > se_count) {
            se_count = c[i];
            se = i;
        }
    }
    ans2 = ans2 + n/2 - se_count;
    if(fi == se) {
        fi = 0,fi_count = 0;
        for(int i = 1 ; i < 100001 ; i++){
            if(b[i] > fi_count && i != se) {
                fi_count = b[i];
                fi = i;
            }
        }
    }
    ans2 = ans2 + n/2 - fi_count;
    ans = min(ans1, ans2);

    cout << ans;
    return 0;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>

using namespace std;

#define int long long

signed main() {
	int K, S;
	cin >> K >> S;
	int ans = 0;
	for (int i = 0; i <= K; i++) {
		for (int j = 0; j <= K; j++) {
			if (S-(i + j)<=K&&S-(i + j) >=0)ans++;
		}
	}
	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++)

#define MAX 50
#define NIL -1

int F[MAX];

int fib(int n){
    if(n == 0 || n == 1){
       return F[n] = 1;
    }
    if(F[n] != NIL){
        return F[n];
    }

    return F[n] = fib(n-1) + fib(n-2);
}

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

    rep(i,MAX) F[i] = NIL;

    cout << fib(n) << endl;

    return 0;
}


Measured memory_bytes: 3092
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	S := ReadString()
	prev := S[0]
	c := 0
	for i := 1; i < len(S); i++ {
		if prev != S[i] {
			c++
		}
		prev = S[i]
	}
	fmt.Println(c)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 2496
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int x[100], y[100];
int mini[100], rr[100];
int main()
{
	int num;
	scanf("%d", &num);
	int r = 0;
	for (int i = 0; i < num; i++)
	{
		int za, zb;
		scanf("%d%d", &za, &zb);
		r += zb - za + 1;
	}
	printf("%d\n", r);
}

Measured memory_bytes: 256
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

hands = []
points = 0

hand_for_win = {'r': 'p', 's': 'r', 'p': 's'}
point_for_win = {'r': R, 's': S, 'p': P}

for i in range(N):
    game_count = i+1
    
    if game_count <= K:
        hands.append(hand_for_win[T[i]])
        points += point_for_win[hand_for_win[T[i]]]
    else:
        if hand_for_win[T[i]] == hands[i-K]:
            hands.append('U') #あいこor負けになるような手
        else:
            hands.append(hand_for_win[T[i]])
            points += point_for_win[hand_for_win[T[i]]]

print(points)

Measured memory_bytes: 4212
import java.util.*;

public class Main {
	 
	
	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		int num = in.nextInt();
		
		//graph instantiation
		int[][] graph = new int[num][num];
		for(int i = 0; i < num; i++) {
			int index = in.nextInt();
			int num_of_neighbors = in.nextInt();
			for(int j = 0; j < num_of_neighbors; j++) {
				graph[index-1][in.nextInt() -1] = 1;
			}
		}
		
		in.close();
		
		
		// to keep track of visited numbers
		Boolean[] visited = new Boolean[num];
		for(int i = 0; i < num; i++) {
			visited[i] = false;
		}
		
		int[] timings = new int[num];
		int[] finish_time = new int[num];
		int curr = 0;
		for(int i = 0; i < num; i++) {
			if(!visited[i])
			curr = DFS(graph, visited, timings, finish_time, curr + 1, i);
		}
		for(int i = 0; i < num; i++) {
			System.out.print((i + 1) + " " + timings[i] + " " + finish_time[i]);
			System.out.println();
		}
	}

	
	public static int DFS(int[][] graph, Boolean[] v, int[] timings, int[] finish_time, int curr, int node) {
		v[node] = true;
		timings[node] = curr;
		for(int i = 0; i < graph.length; i++) {
			if(graph[node][i] == 1 && !v[i]) {
				curr = DFS(graph, v, timings, finish_time, curr + 1, i);
			}
		}	
		curr++;
		finish_time[node] = curr;
		return curr;
	}
	
	
}


Measured memory_bytes: 28440
#include <iostream>

using namespace std;

int main()
{
    
    for(int loop = 0; ; ++loop)
    {
        int a, b;
        cin >> a >> b;
        
        if(a == 0 && b == 0)
        { break; }
        
        //if(loop > 0)
        //cout << endl;
        
        for(int i = 0; i < a; ++i)
        {
            for(int j = 0; j < b; ++j)
            {
                cout << "#";
            }
            
            cout << endl;
        }
        
        cout << endl;
    }
    
    return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N,A,B,C,D;
  string S;
  cin>>N>>A>>B>>C>>D>>S;
  A--;
  B--;
  C--;
  D--;
  bool okb=true;
  for(int i=B;i<D;i++){
    if(S[i]=='#'&&S[i+1]=='#')okb=false;
  }
  bool oka=true;
  for(int i=A;i<C;i++){
    if(S[i]=='#'&&S[i+1]=='#')oka=false;
  }
  bool one=(oka&&okb);

  okb=true;
  for(int i=B;i<D;i++){
    if(S[i]=='#'&&S[i+1]=='#')okb=false;
  }
  S[D]='#';
  oka=true;
  for(int i=A;i<C;i++){
    if(S[i]=='#'&&S[i+1]=='#')oka=false;
  }
  bool two=(oka&&okb);

  S[D]='.';
  bool three=false;
  for(int i=B-1;i<D;i++){
    if(S[i]=='.'&&S[i+1]=='.'&&S[i+2]=='.')three=true;
  }
  if(C<D&&one)cout<<"Yes"<<endl;
  else if(D<C&&three&&one)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 592
def solve(n: int) -> int:
    mod = 1e9 + 7
    n_bin = '0' + bin(n)[2:]

    dp = [[0, 0, 0] for _ in range(len(n_bin))]
    dp[-1][0] = 1
    for i in range(len(n_bin) - 2, -1, -1):
        for s in range(3):
            for k in range(3):
                s2 = min(2, 2 * s + int(n_bin[len(n_bin) - i - 1]) - k)
                if s2 >= 0:
                    dp[i][s2] = int((dp[i][s2] + dp[i + 1][s]) % mod)

    return int(sum(dp[0]) % mod)

n = int(input())
print(solve(n))

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

#define ALL(obj) (obj).begin(),(obj).end()
template<class T> using priority_queue_reverse = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = 1'000'000'000LL + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
vector<string> split(const string &str, const char delemiter) {vector<string> res;stringstream ss(str);string buffer; while( getline(ss, buffer, delemiter) ) res.push_back(buffer); return res;}
int msb(int x) {return x?31-__builtin_clz(x):-1;}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int K; cin >> K;
    string S = "ACL",T="";
    for(int i=0;i<K;++i) T+=S;
    cout << T << endl;
    return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>
#include<stack>
#include<iomanip>
#include<cstdint>
#include<bits/stdc++.h>
using namespace std;

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SORTVG(v) sort(v.begin(),v.end(),greater<>())
#define SORTV(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define INF LLONG_MAX/2
#define int long long

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef pair<int,int> Pii;
typedef vector<int> Vi;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}
template<class T> void AorB(T& a, string A,string B) {if(a){cout << A << ENT;}else{cout << B << ENT;}}

struct UnionFind {
    vector<int> data;
    vector<int> sizes;
    
    UnionFind(int n) : data(n) ,sizes(n, 1){
        for(int i = 0; i < n; i++) data[i] = i;
    }
    
    int root(int x) {
        if (data[x] == x) return x;
        return data[x] = root(data[x]);
    }
    
    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (y < x) swap(x, y);
        data[y] = x;
        sizes[x] += sizes[y];
    }
    
    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    int size(int x) {
        return sizes[root(x)];
    }
};

int atcoder(){
    int n,m;
    cin >> n >> m;
    vector<int> a(m),b(m);
    REP(i,0,m){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }
    
    Vi ans(m,0);
    ans[0]=n*(n-1)/2;
    UnionFind UF(n);
    REP(i,1,m){
        if(UF.same(a[m-i],b[m-i])){
            ans[i]=ans[i-1];
        }else{
            ans[i]=ans[i-1]-UF.size(a[m-i])*UF.size(b[m-i]);
            UF.unite(a[m-i],b[m-i]);
        }
    }
    REP(i,0,m) cout<<ans[m-i-1]<<ENT;
    return 0;
}


signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    atcoder();
    return 0;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define INF (1LL<<61)
#define int long long

using namespace std;

int dp[1010][1010], d[1010], c[1010];

signed main() {
  fill(dp[0], dp[1010], INF);
  int n, m;
  cin >> n >> m;

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

  for (int i = 1; i <= m; ++i)
    cin >> c[i];

  dp[1][0] = 0;
  for (int i = 1; i <= m; ++i) {
    for (int j = 0; j <= n; ++j) {
      if (dp[i][j] == INF) continue;

      int nx = i+1;
      dp[nx][j] = min(dp[nx][j], dp[i][j]);
      dp[nx][j+1] = min(dp[nx][j+1], dp[i][j] + d[j+1]*c[i]);
    }
  }

  int ans = INF;
  for (int i = 1; i <= m + 1; ++i) {
    if (dp[i][n] < ans) ans = dp[i][n];
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 9140
#define _USE_MA_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

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

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,h,w;
    cin>>n>>h>>w;
    vi x(n);
    rep(i,n)cin>>x[i];
    int ans=0;
    for(int i=0;i<n;i+=2){
        ans+=min(w+w-x[i]-x[i+1],x[i]+x[i+1]);
    }
    cout<<ans*h<<endl;
}


Measured memory_bytes: 3228
#include <cstdio>
#include <set>
#include <vector>
#include <list>
#include <algorithm>
#include <utility>
using namespace std;

typedef pair<int,int> pii;

int main(){
	int n;
	while(scanf("%d", &n), n){
		list<pii> ls;
		list<pii>::iterator it;
		set<int> st;

		char ch;
		int L, S;
		for(int i = 0; i < n; ++i){
			scanf(" %c", &ch);
			if(ch == 'W'){
				scanf("%d%d", &L, &S);
				st.insert(L);
				for(it = ls.begin(); S > 0 && it != ls.end(); ++it){
					if(!st.count(it->first)){
						if(S < it->second){
							it->second -= S;
							ls.insert(it, pii(L, S));
							S = 0;
						}
						else{
							it->first = L;
							S -= it->second;
						}
					}
				}
				if(S > 0){
					ls.push_back(pii(L, S));
				}
			}
			else if(ch == 'D'){
				scanf("%d", &L);
				st.erase(L);
			}
			else{
				scanf("%d", &S);
				int sum = 0;
				int res = -1;
				for(it = ls.begin(); it != ls.end(); ++it){
					if(sum + it->second > S){
						if(st.count(it->first)){ res = it->first; }
						break;
					}
					sum += it->second;
				}
				printf("%d\n", res);
			}
		}
		puts("");
	}
}

Measured memory_bytes: 1304
#include <iostream>

int main(void) {
    int N;
    char* S;
    std::cin >> N;
    S = new char[N+1];

    std::cin >> S;

    int* nb = new int[N+1];

    nb[0] = 0;
    for(int i=1; i<=N; i++) {
        nb[i] = nb[i-1] + (S[i-1] == '#');
    }

//  ########## (N=10, i=0)
//  ...####### (N=10, i=3)

    int min = N;
    for(int i=0; i<=N; i++) {
    //    int c = nb[i] + ((N - i) - (nb[N] - nb[i]))
        int c = 2 * nb[i] + N - i - nb[N];
        if(min > c) min = c;
    }

    std::cout << min << "\n";
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
const int inf=1e9;
const double eps=1e-9;
typedef vector<int> vi;
typedef long long ll;
int ans=-inf;
int N,T,S;
int dp[3005][6005];
int A[3005];
int B[3005];
int main(void)
{
  cin >> N >> T >> S;
  for(int i=0;i<=3000;i++)
    {
      for(int j=0;j<=6000;j++)
	{
	  if(i!=0) dp[i][j]=-inf;
	  else dp[i][j]=0;
	}
    }
  for(int i=1;i<=N;i++)
    {
      cin >> A[i] >> B[i];
    }
  for(int i=1;i<=N;i++)
    {
      for(int Time=0;Time<=T;Time++)
	{
	  dp[i][Time]=max(dp[i-1][Time],dp[i][Time]);
	  if(Time<S && Time+B[i]>S) continue;
	  dp[i][Time+B[i]]=max(dp[i-1][Time]+A[i],dp[i-1][Time+B[i]]);
	}
    }
  for(int Time=0;Time<=T;Time++)
    {
      ans=max(ans,dp[N][Time]);
      //cout << "Time " << Time << " Finished & Value is " <<dp[N][Time] << endl;
    }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 73516
using System;

using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');

            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            int c = int.Parse(s[2]);


            if(a<b&&b<c)    // ??????
            {
                Console.WriteLine("Yes");

            }
            else
            {
                Console.WriteLine("No");

            }

            //if(a<b||b<c)    // ?????????
            //{

            //}
            //else
            //{ 
            //}
       


            


            //int a = int.Parse(s[0]);
            //int b = int.Parse(s[1]);

            //if (a < b)
            //{
            //    Console.WriteLine("a < b");

            //}

            //else if (a >b)
            //{
            //    Console.WriteLine("a > b");

            //}
            //else if (a == b)
            //{
            //    Console.WriteLine("a == b");
            //}




            //int n = int.Parse(s);

            //int h = n / 3600;
            //int m = (n - h * 3600) / 60;
            //int s2 = n % 60;


            //Console.WriteLine(h+":"+m+":"+s2);



            //int tate = int.Parse(s[0]);
            //int yoko = int.Parse(s[1]);

            //int area = tate * yoko;
            //int rect = (tate + yoko )* 2;

            //Console.WriteLine(area + " "+rect);
        }
    }
}

Measured memory_bytes: 5296