akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int main(){
   int n;
   cin >> n;
   int ans = 0;
   priority_queue<int>que;
   rep(i, 0, n){
       int p;
       cin >> p;
       ans += p;
       que.push(p);
   }
   cout << ans-(que.top()/2) << endl;
}

Measured memory_bytes: 3576
class Trio:
    __pre=None
    __val=None
    __nex=None
    def __init__(self,val,p=None,n=None):
        self.__pre=p
        self.__val=val
        self.__nex=n
    
    def get_pre(self):return self.__pre
    
    def get_nex(self):return self.__nex
    
    def set_pre(self,n):self.__pre=n
        
    def set_nex(self,n):self.__nex=n
    
    def set_val(self,n):self.__val=n
    
    def get_val(self):return self.__val
    
class Queue:
    top = back = None
    def __init__(self):
        pass
    
    def enqueue(self,n):
        if(self.top==None):
            self.top = self.back = Trio(n)
        else:
            self.back.set_nex(Trio(n,p=self.back))
            self.back=self.back.get_nex()
    
    def dequeue(self):
        if(self.top==None):
            return None
        elif(self.top==self.back):
            a=self.top.get_val()
            self.top,self.back=None,None
            return a
        else:
            self.top=self.top.get_nex()
            oldtop=self.top.get_pre()
            self.top.set_pre(None)
            return oldtop.get_val()

s = input()
n,limit=map(int,s.split())
que=Queue()
for i in range(n):
    lis=input().split()
    que.enqueue((lis[0],int(lis[1])))

time=0
while(True):
    elm=que.dequeue()
    if(elm==None):
        break
    elif(elm[1]>limit):
        que.enqueue((elm[0],elm[1]-limit))
        time+=limit
    else:
        time+=elm[1]
        print(elm[0],time)

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

int main() {
  string s;
  cin >> s;
  
  int count = 1;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == 'N') {
      if (count % 2 == 0) {
        continue;
      }
      count *= 2;
    }
    else if (s.at(i) == 'E') {
      if (count % 3 == 0) {
        continue;
      }
      count *= 3;
    }
    else if (s.at(i) == 'W') {
      if (count % 5 == 0) {
        continue;
      }
      count *= 5;
    }
    else if (s.at(i) == 'S') {
      if (count % 7 == 0) {
        continue;
      }
      count *= 7;
    }
  }
  if (count % 210 == 0) {
    cout << "Yes" << endl;
  }
  else if (count % 14 == 0 && count % 3 != 0 && count % 5 != 0) {
    cout << "Yes" << endl;
  }
  else if (count % 15 == 0 && count % 2 != 0 && count % 7 != 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}



Measured memory_bytes: 256
dp = [-1] * 2005

mod = 1000000007

def DP(S):
    if S == 0:
        return 1
    if(dp[S] != -1):
        return dp[S]
    ret = 0
    for i in range(3, S+1):
        ret = (ret + DP(S-i)) % mod
    dp[S] = ret
    return ret

n = int(input())

print(DP(n))

Measured memory_bytes: 9164
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a==1 && b==0 && c==0) {
		printf("Close\n");
	}
	if(a==0 && b==1 && c==0) {
		printf("Close\n");
	}
	if(a==1 && b==1 && c==0) {
		printf("Open\n");
	}
	if(a==0 && b==0 && c==1) {
		printf("Open\n");
	}
	if(a==0 && b==0 && c==0) {
		printf("Close\n");
	}
	return 0;
}



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

using namespace std;

const int mod = 998244353;
inline int mul(int a, int b) {
  return (long long) a * b % mod;
}

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

  int ans = 1;
  vector<int> one(3), two(3);
  
  for (auto x : s) {
    int i, j, k;
    if (x == 'R') i = 0;
    if (x == 'G') i = 1;
    if (x == 'B') i = 2;
    j = (i + 1) % 3;
    k = (i + 2) % 3;
    
    if (two[i]) {
      ans = mul(ans, two[i]);
      two[i]--;
    } else if (one[j]) {
      ans = mul(ans, one[j]);
      one[j]--;
      two[k]++;
    } else if (one[k]) {
      ans = mul(ans, one[k]);
      one[k]--;
      two[j]++;
    } else {
      one[i]++;
    }
  }

  for (int i = 1; i <= n; i++) {
    ans = mul(ans, i);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3916
//coded by dsingh_24
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pll         pair<long long,long long>
#define vll          vector<long long>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (long long)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
	ios
    ll a,b,c,d,i,j,n;
    cin>>a>>b>>c>>d>>n;
    vector<pll> v;
    v.pb(mp(8*a,1));
    v.pb(mp(4*b,2));
    v.pb(mp(2*c,3));
    v.pb(mp(d,4));
    sort(all(v));
    ll t=v[0].S;
    ll ans=(n/2)*v[0].F;
    if(n%2!=0)
    {
    	if(t==1)ans+=(4*a);else
    	if(t==2)ans+=2*b;else
    	if(t==3)ans+=c;else
    	{
    		ll tt=v[1].S;
    		if(tt==1)ans+=(4*a);else
        	if(tt==2)ans+=2*b;else
        	if(tt==3)ans+=c;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {
  
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i,N) cin >> A[i];

  sort(A.rbegin(), A.rend());
  int ans = 0;
  rep(i,N) {
    ans += A[i] * (i % 2 == 0 ? 1 : -1);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3628
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn gcd(a: usize, b: usize) -> usize {
    if a == 0 {
        b
    } else if a > b {
        gcd(b, a)
    } else {
        gcd(b % a, a)
    }
}

fn lcm(a: usize, b: usize) -> usize {
    a / gcd(a, b) * b
}

fn main() {
    let N = get!(usize);
    let T = get!(usize; N);

    // 解は lcm(T_1, ..., T_N)
    let ans = T.into_iter().fold(1, lcm);

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


Measured memory_bytes: 4352
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
A=[[] for i in range(k)]
for i in range(k):
  A[i]=[]
for i in range(n):
  A[i%k].append(t[i])
ans=0
for i in range(k):
  a=0
  for j in range(len(A[i])):
    if j==0:
      if A[i][j]=="r":
        ans=ans+p
      elif A[i][j]=="s":
        ans=ans+r
      else:
        ans=ans+s
    else:
      if A[i][j]!=A[i][j-1]:
        a=0
        if A[i][j]=="r":
          ans=ans+p
        elif A[i][j]=="s":
          ans=ans+r
        else:
          ans=ans+s
      else:
        a=a+1
        if a%2==0:
          if A[i][j]=="r":
            ans=ans+p
          elif A[i][j]=="s":
            ans=ans+r
          else:
            ans=ans+s
print(ans)
        
        

Measured memory_bytes: 13436
#include <iostream>

using namespace std;

int main(){
  int N;
  long int sum =0;
  cin >> N;
  for(int i=1;i<=N;++i){
    if(i%3==0 || i%5==0)
      continue;
    else
     sum += i;
  }
  cout << sum ;
  return 0;
}


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

int main() {
  ll N,M;
  cin >> N >> M;
  vector< ll > A(N);
  vector< ll > AA(N,0);
  REP(i,N) cin >> A[i];
  
  sort(A.begin(), A.end());
  
  AA[0] = A[N-1];
  for(int i=1;i<N;i++) AA[i] = AA[i-1] + A[N-1-i];

  // N*Nのマスで考える。
  // 各行である数xを超える個数を数える。
  //  最初の行は二分探索でもとめて、その次の行からは尺取りで1個ずつ上に探索していく
  // その合計がMを超える最小のxを二分探索で求める。

  ll left = 1LL << 60;
  ll right = 0;
  ll mid = (left + right) / 2;
  ll xnum = 0;
  ll xtotal = 0;
  while( left - right > 1 ) {
    xnum = 0;
    xtotal = 0;
//    cout << right << " : " << mid << " : " << left << endl;
    REP(i,N) {
      ll x = max(mid - A[i], 0LL);
      auto it = lower_bound( A.begin(), A.end(), x );
      ll dist = distance( it, A.end());
      xnum += dist;
//      cout << "  " << xnum;
    }
//    cout << endl;
    if ( xnum >= M ) {
      right = mid;
    } else {
      left = mid;
    }
    mid = (left + right) / 2;
  }
  xnum = 0;
  xtotal = 0;
//  cout << right << " : " << mid << " : " << left << endl;
  REP(i,N) {
    ll x = max(right - A[i], 0LL);
    auto it = lower_bound( A.begin(), A.end(), x );
    ll dist = distance( it, A.end());
    xnum += dist;
    if (xnum>0) xtotal += (AA[dist-1] + A[i]*dist);
//    cout << "  " << xnum << " " << xtotal;
  }
//  cout << endl;

  cout << xtotal - (xnum-M)*right << endl;
}


Measured memory_bytes: 1920
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    int n,k;
    cin>>n>>k;
    for(int i=0;i<(1<<n);i++){
        set<int> st;
        for(int j=0;j<n;j++){
            if(i>>j&1) st.insert(j);
        }
        if(st.size()==k){
            cout<<i<<':';
            while(!st.empty()){
                int m=*begin(st);
                st.erase(m);
                cout<<' '<<m;
            }
            cout<<endl;
        }
    }
}


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

using namespace std;
using int64 = long long;

int main() {
    int n, m, cnt = 0;
    cin >> n >> m;
    for (int i=0; i<m; i++) {
        int a;
        cin >> a;
        cnt += a;
    }

    cout << (n-cnt>=0?n-cnt:-1) << endl;
}


Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include <bits/stdc++.h>
#include<vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <math.h>
#include <iomanip>
using namespace std;
using ll = long long;

int main(){
  int x,n;
  int p[110],q[510],r[210];
  cin >> x >> n;
  int i,j,min=10000000,ans;
  for(i=1;i<=n;i++){
    cin >> p[i];
  }
  for(i=0;i<=200;i++){
     q[i] = i;
    }
  for(i=201;i<=400;i++){
    q[i] = -(i-200);
  }
  for(i=1;i<=n;i++){
    for(j=0;j<=400;j++){
      if(p[i] == q[j]){
        q[j] = 100000;
      }
    }
  }
  sort(q,q+401);
  ans = x;
  for(j=0;j<=400;j++){
    r[j] = abs(q[j]-x);
    if(min > r[j]){
      min=r[j];
      ans=q[j];
    }
  }
  cout << ans << endl;


  }


Measured memory_bytes: 3600
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
double PI = atan(1.0) * 4.0;

int main() {
    double r;
    cin >> r;
    cout << fixed << setprecision(8)
         << PI * r * r << " " << 2 * PI * r << endl;
    return 0;
}

Measured memory_bytes: 3276
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#include <deque>
#include <cstring>
#include <functional>
#include <climits>
#include <list>
#include <ctime>
#include <complex>
#include <ext/rope>

#define F1(x,y,z) for(int x=y;x<z;x++)
#define F2(x,y,z) for(int x=y;x<=z;x++)
#define F3(x,y,z) for(int x=y;x>z;x--)
#define F4(x,y,z) for(int x=y;x>=z;x--)
#define mp make_pair
#define pb push_back
#define LL long long
#define co complex<double>
#define fi first
#define se second

#define MAX 100005
#define AMAX 1500
#define MOD 1000000007

#define f(c,d) ((1<<(c))*(d))

using namespace std;
using namespace __gnu_cxx;

int n,x[MAX],ans;

int main(){
	scanf("%d",&n);
	F2(a,1,n)scanf("%d",x+a);
	F2(a,1,n)if(x[x[a]]==a)ans++;
	printf("%d\n",ans/2);
	#ifdef LOCAL_PROJECT
	system("pause");
	#endif
	return 0;
}


Measured memory_bytes: 512
# -*- coding:utf-8 -*-
import sys
sys.setrecursionlimit(10 ** 5)
input = sys.stdin.readline
mod = 1000000007
inf = float("INF")
def I(): return int(input().rstrip())
def IR(n): return [I() for _ in range(n)]
def LI(): return list(map(int, input().rstrip().split()))
def LIR(n): return [LI() for _ in range(n)]
def LI_(): return list(map(lambda x: int(x) - 1, input().rstrip().split()))
def LIR_(n): return [LI_() for _ in range(n)]
def F(): return float(input().rstrip())
def FR(n): return [F() for _ in range(n)]
def LF(): return list(map(float, input().rstrip().split()))
def LFR(n): return [LI() for _ in range(n)]
def S(): return input().rstrip()
def SR(n): return [S() for _ in range(n)]
def LS(): return list(sys.stdin.readline().rstrip().split())
def LSR(n): return [LS() for _ in range(n)]
# ↑template↑
# ↓solution↑
a, b, c, x = IR(4)
res = 0
for a in range(a + 1):
    for b in range(b + 1):
        for c in range(c + 1):
            if 500 * a + 100 * b + 50 * c == x:
                res += 1
print(res)


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

int main(){
    ll n,d;
    cin >> n >> d;
    ll x[n], y[n];
    rep(i,n){
        cin >> x[i] >>  y[i];
    }
    int cnt = 0;
    rep(i,n){
        if(d*d >= x[i]*x[i]+y[i]*y[i]){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 6680
#include <stdio.h>

int main() {
  int x[5];
  scanf("%d %d %d %d %d",&x[0],&x[1],&x[2],&x[3],&x[4]);
  for(int i=0;i<5;i++) {
    if(x[i]==0) {
      printf("%d",i+1);
    }
  }
  return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int m = 0, s = 0;
    for (int i = 0; i < n; i++) {
        int p;
        cin >> p;
        m = max(m, p);
        s += p;
    }

    cout << s - m / 2 << endl;

    return 0;
}

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

int main()
{
  int n,k;
  cin >> n >> k;
  int a[n];
  rep(i,n) cin >> a[i];
  sort(a,a+n);
  reverse(a,a+n);
  int ans = 0;
  rep(i,n){
    if(a[i] >= k) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3896
a, b, c = gets.chomp.split.map(&:to_i)

require 'set'
memo = Set.new
cx = 0
while a.even?  && b.even?  && c.even?
  a, b, c = (b + c) / 2, (c + a) / 2, (a + b) / 2
  if memo.include? [a, b, c]
    p -1
    exit 0
  end
  memo << [a, b, c]
  cx += 1
end

p cx


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

vector<string> v;
int pl[2003][2003], pr[2003][2003], pu[2003][2003], pd[2003][2003];
int main() {
	int n, m;
	cin>> n >> m;
	int i, j;
	for(i=0;i<n;i++)  {
		string s;
		cin>>s;
		v.push_back(s);
	}

	for(i=1;i<=n;i++) {
		for(j=1;j<=m;j++) {
			char c = v[i-1][j-1];
			if(c=='#')continue;
			pl[i][j] = pl[i][j-1] + 1;
		}
	}
	for(i=1;i<=n;i++) {
		for(j=m;j>=1;j--) {
			char c = v[i-1][j-1];
			if(c=='#')continue;
			pr[i][j] = pr[i][j+1] + 1;
		}
	}

	for(i=1;i<=n;i++) {
		for(j=1;j<=m;j++) {
			char c = v[i-1][j-1];
			if(c=='#')continue;
			pd[i][j] = pd[i-1][j] + 1;
		}
	}
	for(i=n;i>=1;i--) {
		for(j=1;j<=m;j++) {
			char c = v[i-1][j-1];
			if(c=='#')continue;
			pu[i][j] = pu[i+1][j] + 1;
		}
	}
	int ans = 0;
	for(i=1;i<=n;i++) {
		for(j=1;j<=m;j++) {
			int tans = pl[i][j] + pr[i][j]  + pu[i][j] + pd[i][j] - 3;
			ans  = max(ans, tans);
		}
	}
	cout<<ans<<"\n";
	return 0;
}

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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k) {
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//================ Main Loop ================
int main() {
    COMinit();
    int n, k;
    cin >> n >> k;
    ll ans = 0;
    rep(i, min(k + 1, n + 1)) {
        ans += COM(n, i) * COM(n - 1, n - i - 1);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

Measured memory_bytes: 12160
//refer prbly sub
//refer editorial 
/* run it for
 3
 (((((
 )))))((()))(((((
 )))))
*/
#include<bits/stdc++.h>
using namespace std;
#define pb  push_back
#define pii pair<int,int>
#define ff first
#define ss second
typedef long long ll;
int main ()
{
    int n;
    cin>>n;
    vector<string>s(n);
    vector<pii> opening,closing;/*top store the opening brackets which are not counterbalancing the closing
                                 brackets and vice versa*/                                 
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
        int l=s[i].length();
        stack<char> bracket;
        for(int j=0;j<l;j++)
        {
            if(s[i][j]==')')
            {
                if(bracket.empty()==false && bracket.top()=='(') bracket.pop();
                else bracket.push(')');
            }
            else if(s[i][j]=='(')
            {
                bracket.push('(');
            }
        }
        int open=0,close=0;
        while(!bracket.empty())
        {
            char bt=bracket.top();
            bracket.pop();
            if(bt=='(') open++;
            else close++;
        }
    if(open>=close) opening.pb({close,open});
    if(open<close) closing.pb({open,close});
    }
    sort(opening.begin(),opening.end());
    sort(closing.begin(),closing.end());
    reverse(closing.begin(),closing.end());
    int total=0;
    for(auto o:opening)
    {
        total-=o.ff;
        if(total<0)
        {
            cout<<"No\n";
        return 0;
        }
        total+=o.ss;
    }
    for(auto c:closing)
    {
        total-=c.ss;
        if(total<0)
        {
            cout<<"No\n";
            return 0;
        }
        total+=c.ff;
    }
    if(total!=0)
    {
        cout<<"No\n";
    }
    else
    {
        cout<<"Yes\n";
    }
    return 0;
}

Measured memory_bytes: 42596
n,x = map(int,input().split())

if x == n:
  print("Yes")
  for i in range(1,2*n):
    print(i)
    
elif 1 < x < n:
  print("Yes")
  for i in range(x+1,n+1):
    print(i)
  for i in range(1,x+1):
    print(i)
  for i in range(n+1,2*n):
    print(i)

elif n < x < 2*n-1:
  print("Yes")
  for i in range(1,n):
    print(i)
  for i in range(x,2*n):
    print(i)
  for i in range(n,x):
    print(i)

else:
  print("No")

Measured memory_bytes: 4560
#include <bits/stdc++.h>  
using namespace std;  
#define INF 0x3f3f3f3f  
typedef long long ll;  
const int N = 310;  
#define FI first
#define SE second
typedef pair<int, int>pii;

char num[N];
bool vis[N];
int main()  
{  
 
 
   int n;
   while (~scanf("%d%s", &n, num))
   {
        memset(vis, 0, sizeof(vis));
        string pre = "";
        string end = "";
        for (int i = 0; i < n; i++) if (!vis[i])
        {
            int cur = i;
            if (num[i] == ')')
            {

               for (int j = i - 1; j >= 0; j--)
                if (num[j] == '(' && !vis[j])
                {
                    cur = j;
                    vis[j] = true;
                    break;
                }
               if (cur == i)
                pre = "(" + pre;

            }else if (num[i] == '(')
            {
                for (int j = i + 1; j < n; j++)
                    if (num[j] == ')' && !vis[j])
                    {
                        cur = j;
                        vis[j] = true;
                        break;
                    }
                if (cur == i)
                    end += ")";
            }
             vis[i] = true;
        }
        printf("%s%s%s\n", pre.c_str(), num, end.c_str());
   }
   return 0;  

}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int h,w;
vector<string> s;
bool vi[443][443];
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
ll black, white;

bool check(int y, int x)
{
    bool ret = true;
    if (y < 0 || h <= y || x < 0 || w <= x) ret = false;
    return ret;
}

// 0が白、1が黒
void dfs(int y, int x) 
{
    if (vi[y][x]) return;
    vi[y][x] = true;

    if (s[y][x] == '#') black++;
    else white++;
    
    for (int i = 0; i < 4; ++i)
    {
        int ny = y+dy[i];
        int nx = x+dx[i];
        char c = s[y][x];
        if (check(ny,nx))
        {
            char nc = s[ny][nx];
            if (c != nc) dfs(ny, nx);
        }
    }
    return;
}

int main(int argc, char const *argv[]) 
{
    cin >> h >> w;
    s.resize(h);
    REP(i,h) cin >> s[i];

    memset(vi, false, sizeof(vi));
    ll ans = 0ll;
    
    REP(i,h) 
    {
        REP(j,w) 
        {
            if (s[i][j] == '#') 
            {
                black = white = 0ll;
                dfs(i,j);
                ans += black*white;
            }
        }
    }

    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
ll mod = 1e9 + 7;

int main()
{
	int n;
	cin >> n;
	ll x1 = 1, x2 = 1, x3 = 1, x4 = 1;
	for (int i = 0; i < n; i++)
	{
		x1 *= 10;
		x1 %= mod;
	}
	for (int i = 0; i < n; i++)
	{
		x2 *= 9;
		x2 %= mod;
	}
	for (int i = 0; i < n; i++)
	{
		x3 *= 8; x3 %= mod;
	}
	cout << (x1 - 2 * x2 + mod + mod + x3) % mod;
}


Measured memory_bytes: 3620
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int a0 = sc.nextInt();
		int t = a0;
		long g = 0L;
		for ( int i=1; i<n; i++ ) {
			int a = sc.nextInt();
			if ( t > a ) {
				g += (long)(t-a);
			} else {
				t = a ;
			}
		}

		System.out.println(g);
	}
}

Measured memory_bytes: 58628
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------
int divi[1001];

int main(void) {
  ll x;
  cin >> x;
  ll ans=x/11;
  ans*=2;
  if(x%11>0) ans+=(x%11-1)/6+1;
  prt(ans);

}


Measured memory_bytes: 256
a,b,c = map(int, input().split())
#解毒剤入りの美味しくないクッキーを A枚
#解毒剤入りの美味しいクッキーを B枚
#毒入りの美味しいクッキーを C枚


if a + b + 1 >= c:
    # cを全て食べられる
    print(b + c)
else:
    # cの方が多い
    c1 = (a + b) + 1
    print(c1 + b)

Measured memory_bytes: 2940
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		String op = scanner.next();
		int b = scanner.nextInt();
        	List<Integer> list = new ArrayList<Integer>();
		String sum = "+";
		String dif = "-";
		String mul = "*";
		String div = "/";
		String fin = "?";
		int ans = 0;
		while(!(op.equals(fin)))
		{
			if (op.equals(sum))
			{
				ans = a + b;
			}
			if (op.equals(dif))
			{
				ans = a - b;
			}
			if (op.equals(mul))
			{
				ans = a * b;
			}
			if (op.equals(div))
			{
				ans = a / b;
			}
			list.add(ans);
			a = scanner.nextInt();
			op = scanner.next();
			b = scanner.nextInt();
		}
		for(Iterator it = list.iterator(); it.hasNext();) 
		{
            		System.out.println(it.next());
       		}
	}
}
		


Measured memory_bytes: 26124
#include<bits/stdc++.h>
using namespace std;
int main(){long long n;cin>>n;
double a,b=n,c;
if(n%2==1)
a=(n/2)+1;
else
a=n/2;

c=a/n;
cout.precision(10);
cout<<fixed<<c;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner scanner =new Scanner(System.in);
  while(true){
            int m = scanner.nextInt();
            int f = scanner.nextInt();
            int r = scanner.nextInt();
             
            if(m < 0 && f < 0 && r < 0){
                break;
            }
             
            if(m < 0 || f < 0){
                System.out.println('F');
            }
             
            else if(m + f >= 80){
                System.out.println('A');
            }
             
            else if(m + f >= 65){
                System.out.println('B');
            }
             
            else if(m + f >= 50){
                System.out.println('C');
            }
             
            else if(m + f >= 30){
                 
                if(r >= 50){
                    System.out.println('C');
                }
                 
                else {
                    System.out.println('D');
                }
            }
             
            else {
                System.out.println('F');
            }
        }
    }
}

Measured memory_bytes: 26260
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  string A, B;

  cin >> A >> B;

  int ans = 0;
  for (int i=0; i<A.size(); i++) {
    ans += A[i] == B[i];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque
import copy
INF = 10000000
def main():
    N, M, X = map(int, input().split())
    book = []
    ans = INF
    for i in range(N):
        info = [int(i) for i in input().split()]
        book.append(info)
    for i in range(1 << N):
        a = []
        for j in range(M + 1):
            a.append(0)    
        for j in range(N):
            if (i >> j) & 1:
                for t in range(M + 1):
                    a[t] += book[j][t]
        for j in range(1, M + 1):
            if a[j] < X:
                a[0] = INF
                break
        ans = min(ans, a[0])
    if ans >= INF:
        ans = -1
    print(ans)







if __name__ == '__main__':
    main()


Measured memory_bytes: 9580
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define R(i,a,n) for(int i=a;i<n;i++)
int main(){
  int n,a,b;
  string s;
  cin>>a>>b;
  a+=b;
  if(a>23)a-=24;
  cout<<a<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define vector_rsort(x) sort(all(x));reverse(all(x))
#define array_rsort(x,n) sort(x,x+n);reverse(x,x+n);
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))

#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
/*---------------------------------------------------*/

int n,t=0;
int d[105],f[105];
int used[105];
vi g[105];

void init(){
  rep(i,105){
    d[i]=f[i]=INF;
  }
}

void dfs(int now){
  t++;
  d[now]=t;
  used[now]=true;
  rep(i,g[now].size()){
    if(!used[g[now][i]]){
      dfs(g[now][i]);
    }
  }
  t++;
  f[now]=t;
}

int main(){
  int u,k,v;
  cin>>n;
  rep(i,n){
    cin>>u>>k;
    rep(j,k){
      cin>>v;
      g[u].pb(v);
    }
  }
  init();
  REP(i,1,n+1)if(!used[i])dfs(i);
  REP(i,1,n+1){
    cout<<i<<" "<<d[i]<<" "<<f[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3144
#include <cstdio>
using namespace std;
int n,cnt,tmp;
int main()
{
	cnt=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&tmp);
		if(tmp&1) cnt++;
	}
	if(cnt&1) printf("NO\n");
	else printf("YES\n");
	return 0;
} 

Measured memory_bytes: 128
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
 
using namespace std;
 
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define forab(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define sz(c) int((c).size())
#define all(c) (c).begin(), (c).end()
#define mp(x, y) make_pair(x, y)
#define pb push_back
#define fst first
#define snd second
 
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<pii>;

#ifdef LOCAL
#define eprintf(args...) fprintf(stderr, args), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define FILE_NAME "a"
 
int n;
vi x, y;

bool read() {
    if (!(cin >> n)) {
        return 0;
    }

    x = y = vi(2 * n);
    forn (i, 2 * n)
        cin >> x[i] >> y[i];

    return 1;
}

bool dfs (int x, const vvi &g, vi &used, vi &match)
{
    if (used[x])
        return false;
    used[x] = 1;
    
    for (int dest : g[x]) if (match[dest] == -1 || dfs(match[dest], g, used, match))
    {
        match[dest] = x;
        return true;
    }

    return false;
}
 
void solve() {
    vvi g(n);
    
    forn (i, n) forn (j_, n)
    {
        int  j = j_ + n;
        if (x[i] < x[j] && y[i] < y[j])
            g[i].pb(j_);
    }

    int cnt = 0;
    vi used(n), match(n, -1);

    forn (i, n)
    {
        fill(all(used), 0);
        cnt += dfs(i, g, used, match);
    }

    cout << cnt << endl;
}
 
int main() {
#ifdef LOCAL
    freopen(FILE_NAME ".in", "r", stdin);
//    freopen(FILE_NAME ".out", "w", stdout);
#endif

    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
 
    while (read()) {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
class UnionFind:
    __slots__ = ['id','sz']

    def __init__(self, n):
        self.id = [-1] * n
        self.sz = n

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

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

    def union(self, x, y):
        s1, s2 = self.root(x), self.root(y)
        if s1 != s2:
            if self.id[s1] <= self.id[s2]:
                self.id[s1] += self.id[s2]
                self.id[s2] = s1
            else:
                self.id[s2] += self.id[s1]
                self.id[s1] = s2
            self.sz-=1
            return True
        return False

output=[]
n,m = map(int,input().split())
ab=[list(map(int,input().split())) for i in range(m)]
uf = UnionFind(n)
ab=ab[::-1]
now=n*(n-1)//2
for a,b in ab:
    output.append(now)
    if uf.find(a-1,b-1):
        continue
    A, B =uf.id[uf.root(a-1)], uf.id[uf.root(b-1)]
    now-=A*B
    uf.union(a-1,b-1)
while output:
    print(output.pop())



    

Measured memory_bytes: 117464
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>

using namespace std;

int main()
{
	long long int x, y;
	cin >> x >> y;
	long long int ans = 1;
	for (;;)
	{
		x *= 2;
		if (x <= y)
		{
			ans++;
		}
		else
		{
			break;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
S = list(input())

if S[0] == "A" and S[2:-1].count("C") == 1:
  S.remove("A")
  S.remove("C")
  for s in S:
    if "a" <= s <= "z":
      pass
    else:
      print("WA")
      break
  else:
    print("AC")
else:
  print("WA")

Measured memory_bytes: 2940
# include <iostream>

using namespace std;

int main(){
  char b;
  cin >> b;
  if (b == 'A') cout << 'T';
  else if (b=='T') cout << 'A';
  else if(b=='C') cout << 'G';
  else if(b=='G') cout << 'C';
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
	int a, b, k;
	scanf("%d %d %d", &a, &b, &k);
	for(int i = 1; i <= k; i++)
	{
		if(i % 2 == 1) {
			if(a % 2 == 1) a--;
			b = b + a / 2;
			a = a / 2;
		}
		else {
			if(b % 2 == 1) b--;
			a = a + b / 2;
			b = b / 2;
		}
	}
	printf("%d %d\n", a, b);
}

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

bool kaibun(int x) {
	bool f = false;
	int a[5];
	for (int i = 0; i < 5; i++) {
		a[i] = x % 10;
		x = x / 10;
	}
	if (a[0] == a[4] && a[1] == a[3]) {
		f = true;
	}
	return(f);
}

int main()
{
	int A, B;
	cin >> A >> B;
	int sum = 0;
	for (int i = A; i <= B; i++) {
		if (kaibun(i)) {
			sum++;
		}
	}
	cout << sum << endl;
}

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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//---------------------------

int main(){
    ll k; string s;
    cin >> k >> s;
    ll l = min((ll)s.size(), k);
    rep(i,l){
        cout << s[i];
    }
    if((ll)s.size() > k) cout << "...";
    cout << endl;
    return 0;
}

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int h, w, n;
    cin >> h >> w >> n;
    int s = max(h, w); 
    cout << (n - 1) / s + 1 << '\n'; // n = 0!

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 256
// Vicfred
// https://atcoder.jp/contests/dp/tasks/dp_c
// dynamic programming
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.stdio;
import std.string;

void main() {
    const long n = readln.chomp.to!long;
    long[] a = new long[n+1];
    long[] b = new long[n+1];
    long[] c = new long[n+1];

    foreach(i; 1..n+1)
        readf("%s %s %s\n", &a[i], &b[i], &c[i]);

    long[][] dp = new long[][](n+1, 4);

    dp[1][1] = max(a[1], b[1], c[1]);
    dp[1][2] = max(a[1], b[1], c[1]);
    dp[1][3] = max(a[1], b[1], c[1]);

    for(int i = 2; i <= n; ++i) {
        dp[i][1] = max(
                dp[i-1][2] + b[i],
                dp[i-1][3] + c[i]);
        dp[i][2] = max(
                dp[i-1][1] + a[i],
                dp[i-1][3] + c[i]);
        dp[i][3] = max(
                dp[i-1][1] + a[i],
                dp[i-1][2] + b[i]);
    }

    const long ans = max(dp[n][1], dp[n][2], dp[n][3]);
    ans.writeln;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0;i < n;i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  int cur = a.at(0),now = 0,kekka = 0,j = 0;
  for(int i = 0;i < n;i += 0){
    int kasan = 0;
    for(int j = i;j < n;j++){
      if(a.at(j) == cur){
        kasan++;
      }
      else{
        break;
      }
    }
    if(kasan >= a.at(i)){
      kekka += kasan - a.at(i);
    }
    else{
      kekka += kasan;
    }
    i += kasan;
    if(i < n){
      cur = a.at(i);
    }
  }
  cout << kekka << endl;
}

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

using namespace std;


#define PI 3.14159265
#define int long long

const int MAXN = 1e5 + 5;

int a[MAXN];
int b[MAXN];
int g[MAXN];
int sz[MAXN];
int ans[MAXN];


int get(int v){
	if(v == g[v]) return v;

	int to = get(g[v]);
	sz[v] = sz[to];
	return g[v] = to;
}

int unite(int a, int b){
	b = get(b);
	a = get(a);

	if(a != b){
		g[a] = b;
		sz[b] += sz[a];
	}
}

main(){

	int n, m; cin >> n >> m;

	for(int i = 0; i < m; i++){
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
	}


	for(int i = 0; i < n; i++){
		sz[i] = 1;
		g[i] = i;
	}


	int current = n * (n - 1) / 2;

	for(int i = m - 1; i >= 0; i--){
		ans[i] = current;
		if(get(a[i]) != get(b[i])){
			current -= sz[a[i]] * sz[b[i]];
			unite(a[i], b[i]);
		}
	}


	for(int i = 0; i < m; i++){
		cout << ans[i] << endl;
	}





	return 0;
}

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

int	main() {
	int N;
	cin >>N;
	vector<vector<int>> A(N, vector<int> (2, 0));
	for (int i=0; i<N; i++) {
		cin >>A.at(i).at(0);
		A.at(i).at(1)=i+1;
	}
	sort(A.begin(), A.end());
	for(int i=0; i<N; i++)
		cout <<A.at(i).at(1) <<' ';
	cout <<endl;
	return 0;
};


Measured memory_bytes: 6272
use std::io::Read;
use std::cmp;

fn main() {
    let mut s = String::new();

    std::io::stdin().read_line(&mut s).unwrap();

    let vecs: Vec<char> = s.chars().collect();
    let cnt_1st_char: usize = s.match_indices(vecs[0]).count();
    let cnt_2nd_char: usize = s.match_indices(vecs[1]).count();
    let cnt_3rd_char: usize = s.match_indices(vecs[2]).count();
    let cnt_4th_char: usize = s.match_indices(vecs[3]).count();

    if cnt_1st_char == 2 && cnt_2nd_char == 2 && cnt_3rd_char == 2 && cnt_4th_char == 2 {
        println!("{}", "Yes");
    } else {
        println!("{}", "No");
    }

}

Measured memory_bytes: 4352
H, W = map(int, input().split())
while 1:
    if H == 0 and W == 0:
        break
    for i in range(H):
        for j in range(W):
            if j == W - 1:
                print("#")
            else:
                print("#", end = "")
    print()
    H, W = map(int, input().split())

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

void solve(int n, int m) {
    int a[n];
    for (auto &x : a) cin >> x;
    int ans = -1;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (a[i] + a[j] <= m) {
                ans = max(ans, a[i] + a[j]);
            }
        }
    }
    cout << (ans == -1 ? "NONE" : to_string(ans)) << endl;
}

int main() {
    int n, m;
    while (true) {
        cin >> n >> m;
        if (!n && !m) return 0;
        solve(n, m);
    }
}


Measured memory_bytes: 3220
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1000000007;
main(){
    int N,A,ocnt = 0;
    cin >> N;
    for(int i = 0;i < N;i++){
        cin >> A;
        if(A % 2)ocnt++;
    }
    if(ocnt % 2)cout << "NO" << endl;
    else cout << "YES" << endl;
}

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

int main() {
  int x1, x2, x3, x4, x5;
  cin >> x1 >> x2 >> x3 >> x4 >> x5;
  cout << 15-x1-x2-x3-x4-x5;
	return 0;
}


Measured memory_bytes: 3508
N = int(input())
A = list(map(int,input().split()))
# for i in range(N):
#     A[i] = int(i)
cMoney = 1000
stock = 0
A.append(0)
for i in range(N):
    stock = 0

    if A[i] < A[i+1]:
        stock = cMoney // A[i]
        cMoney -= stock * A[i]
    cMoney += A[i+1] * stock



    

print(cMoney)

# for i in range(N):
#     stock = 0
#     if A[i] < A[i+1]:
#         stock = cMoney // A[i]

#     cMoney += (A[i+1] - A[i]) * stock
# print(cMoney)

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

using namespace std;

typedef long long ll;

typedef struct {
    int from;
    int to;
    ll cost;
} edge;


//負の閉路がない時にはtrueを返し、dにsからの最短距離を格納する
//負の経路が存在する時にはfalseを返す
bool bellman_ford(vector<edge> G, int n, int s, ll *d) {
    ll INF = -100000000000000;
    for (int i = 0; i < n; i++)
        d[i] = INF;
    d[s] = 0;

    for (int i = 0; i < 2*n; i++) {
        bool check = false;
        for (int j = 0; j < G.size(); j++) {
            edge e = G[j];
            int u = e.from, v = e.to;
            ll c = e.cost;

            if (d[u] != INF && d[v] < d[u] + c) {
                d[v] = d[u] + c;
                if (v == n-1)
                    check = true;
            }
        }
        if (i >= n && check)
            return false;
    }
    return true;
}

int main() {
    int n, m;   cin >> n >> m;
    vector<edge> G;

    for (int i = 0; i < m; i++) {
        int a, b;   ll c;
        cin >> a >> b >> c;

        edge es = {a-1, b-1, c};
        G.push_back(es);
    }


    ll *d = new ll[n];
    if (bellman_ford(G, n, 0, d)) {
        cout << d[n-1] << endl;
    }
    else 
        cout << "inf" << endl;

    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <string.h>
using namespace std;

#define ISEQ(c) (c).begin(), (c).end()
typedef long long ll;

int main() {
  while (true) {
    int n, l;
    cin >> n >> l;
    if (n == 0) break;
    int cards[n], next[n];
    for (int i = n; i > 0; i--) {
      cards[n-i] = i;
    }

    for (int i = 0; i < l; i++) {
      int p, c;
      cin >> p >> c;
      for (int j = p-1; j < p+c-1; j++) {
	next[j-p+1] = cards[j];
      }
      for (int j = 0; j < p-1; j++) {
	next[c+j] = cards[j];
      }
      for (int j = p+c-1; j < n; j++) {
	next[j] = cards[j];
      }
      for (int j = 0; j < n; j++) {
	cards[j] = next[j];
      }
    }
    cout << cards[0] << endl;
  }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=1e5+10;
int fa[maxn],num[maxn],a[maxn];
bool vis[maxn];
ll ans;
priority_queue<int,vector<int>,greater<int> > q;
int find(int x){
	if(fa[x]==x) return x;
	return fa[x]=find(fa[x]);
}
void merge(int x,int y){
	x=find(x),y=find(y);
	if(x==y) return;
	if(a[num[x]]<a[num[y]]) num[y]=num[x];
	fa[x]=y;
}
int main(){
	int n=read(),m=read();
	if((n-1-m)*2>n){
		printf("Impossible\n");
		return 0;
	}
	if(n-1==m){
		printf("0\n");
		return 0;
	}
	int tmp=(n-1-m)*2;
	REP(i,1,n) a[i]=read(),fa[i]=num[i]=i;
	while(m--){
		int x=read()+1,y=read()+1;
		merge(x,y);
	}
//	REP(i,1,n) printf("%d %d %d\n",i,fa[i],num[i]);
	REP(i,1,n) if(fa[i]==i) ans+=a[num[i]],vis[num[i]]=1,--tmp;
	REP(i,1,n) if(!vis[i]) q.push(a[i]);
	while(!q.empty() && tmp){
		--tmp;
		int u=q.top();q.pop();
		ans+=u;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 2172