akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#define int long long
using namespace std;

typedef pair<int, int> Pii;

void readline(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str());
}
void readline(int N, vector<double> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atof(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atof(s.c_str());
}

signed main(){

    int N, M;
    cin >> N >> M;

    vector<int> x(N), y(N), z(N);

    for(int i = 0; i < N; i++){
        cin >> x[i] >> y[i] >> z[i];
    }

    int sgn[3];
    int max = -1;
    vector<int> w(N);

    for(sgn[0] = -1; sgn[0] <= 1; sgn[0] += 2){
         for(sgn[1] = -1; sgn[1] <= 1; sgn[1] += 2){
              for(sgn[2] = -1; sgn[2] <= 1; sgn[2] += 2){
                  for(int i = 0; i < N; i++){
                      w[i] = sgn[0] * x[i] + sgn[1] * y[i] + sgn[2] * z[i];
                  }
                  sort(w.begin(), w.end());
                  int tmp = 0;
                  for(int j = 0; j < M; j++){
                      tmp += w[w.size() - 1 - j];
                  }
                  if(tmp > max) max = tmp;
              }
         }
    }

    cout << max;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <set>
using namespace std;
int main()
{
    int n,x;
    scanf("%d",&n);
    set<int> st;
    for(int i=0;i<n;i++)
    {
       scanf("%d",&x);
       if(st.count(x)==0)
            st.insert(x);
       else
        st.erase(x);
    }
    printf("%d\n",st.size());
}


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

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

  int n;
  string s;
  cin >> n >> s;

  vector<char> ans(n);
  bool ok = false;
  for (int i = 0; i < 4; i++) {
    vector<char> tmp(n);
    if(i == 0) tmp[0] = tmp[1] = 'S';
    if(i == 1) tmp[0] = tmp[1] = 'W';
    if(i == 2) tmp[0] = 'S', tmp[1] = 'W';
    if(i == 3) tmp[0] = 'W', tmp[1] = 'S';
    for (int j = 1; j < n - 1; j++) {
      if(s[j] == 'o') {
        if(tmp[j] == 'S') {
          tmp[j + 1] = tmp[j - 1];
        }
        if(tmp[j] == 'W') {
          if(tmp[j - 1] == 'W') tmp[j + 1] = 'S';
          if(tmp[j - 1] == 'S') tmp[j + 1] = 'W';
        }
      }
      if(s[j] == 'x') {
        if(tmp[j] == 'W') {
          tmp[j + 1] = tmp[j - 1];
        }
        if(tmp[j] == 'S') {
          if(tmp[j - 1] == 'W') tmp[j + 1] = 'S';
          if(tmp[j - 1] == 'S') tmp[j + 1] = 'W';
        }
      }
    }

    bool flag = true;
    for (int j = 0; j < n; j++) {
      int pre = j - 1;
      int nxt = j + 1;
      if(j == 0) pre = n - 1;
      if(j == n - 1) nxt = 0;

      if(s[j] == 'o') {
        if(tmp[j] == 'S') {
          if(tmp[pre] != tmp[nxt]) flag = false;
        }
        if(tmp[j] == 'W') {
          if(tmp[pre] == tmp[nxt]) flag = false;
        }
      }
      if(s[j] == 'x') {
        if(tmp[j] == 'S') {
          if(tmp[pre] == tmp[nxt]) flag = false;
        }
        if(tmp[j] == 'W') {
          if(tmp[pre] != tmp[nxt]) flag = false;
        }
      }
    }
    if(flag) {
      for (int j = 0; j < n; j++) ans[j] = tmp[j];
      ok = true;
      break;
    }
  }
  if(ok) {
    for (auto it : ans) cout << it;
    cout << '\n';
  } else {
    cout << -1 << '\n';
  }
}


Measured memory_bytes: 720
#include <iostream>
using namespace std;
int main(){
    int n; cin >> n;
    int a[n]; for(int i = 0; i < n; ++i) cin >> a[i];
    for(int i = 1; i < n; ++i){
        for(int j = 0;j < n; ++j){
            if(j) cout << " ";
            cout << a[j];
        }
        cout << endl;
        int val = a[i];
        int j = i-1;
        while(j >= 0 && val < a[j]){
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = val;
    }
    for(int j = 0;j < n; ++j){
        if(j) cout << " ";
        cout << a[j];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3076
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const ll mod = 1e9+7;

string s;

int main()
{
    cin >> s;
    cout << s.substr(0,4) << ' ' << s.substr(4,8) << endl;
}


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

int main(){
    int x,n; cin >> x >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    sort(ALL(p));
    int ans = 0;
    int ab = x;
    for(int i = 1;i <= 103;++i){
        if( !(binary_search(ALL(p),i)) && abs(x-i) < ab){
            ans = i;
            ab = abs(x-i);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<stdio.h>

char str[5];

int main()
{
    int i;char ch;
    scanf("%s",str);
    for(i=0;str[i];i++);
    ch=str[i-1];
    if(ch=='2'||ch=='4'||ch=='5'||ch=='7'||ch=='9')
        printf("hon\n");
    if(ch=='0'||ch=='1'||ch=='6'||ch=='8')
        printf("pon\n");
    if(ch=='3')
        printf("bon\n");
    return 0;



}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d,e,f; cin>>a>>b>>c>>d>>e>>f;
    double ma=-1;
    int a1,a2;
    rep(i,31)rep(j,31)rep(k,101)rep(l,101){
        int sum = 100*a*i+100*b*j+k*c+l*d;
        if (sum>f) continue;
        if ((a*i+b*j)*e<k*c+l*d) continue;
        if (ma<(double)(k*c+l*d)/sum){
            ma = (double)(k*c+l*d)/sum;
            a1 = sum;
            a2 = k*c+l*d;
        }
    }
    cout<<a1<<" "<<a2<<endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
p=tuple(map(int,input().split()))
q=tuple(map(int,input().split()))
import itertools
seq=tuple([i+1 for i in range(n)])
a=list(itertools.permutations(seq))
import bisect
x=bisect.bisect_left(a,p)
y=bisect.bisect_left(a,q)
print(abs(x-y))

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

using namespace std;

char grid[2019][2019];

int suffix_row_col[2019][2019];
int prefix_col[2019][2019];
int prefix_row[2019][2019];


int main() {
    int n,m;
    cin >> n >> m;
    for(int i = 1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin >> grid[i][j];
        }
    }

    int suffix = 0;

    for(int i = 1;i<=n;i++){
        suffix = 0;
        for(int j = m;j>0;j--){
            if(grid[i][j]=='#'){
                suffix = 0;
            }
            else{
                suffix++;
            }
            suffix_row_col[i][j] = suffix;
        }
    }

    for(int i = 1;i<=m;i++){
        suffix = 0;
        for(int j = n;j>0;j--){
            if(grid[j][i]=='#'){
                suffix = 0;
            }
            else{
                suffix++;
            }
            suffix_row_col[j][i] += suffix;
        }
    }

    int prefix = 0;
    for(int i = 1;i<=n;i++){
        prefix = 0;
        for(int j = 1;j<=m;j++){
            if(grid[i][j]=='#'){
                prefix = 0;
            }
            else{
                prefix++;
            }
            prefix_row[i][j] += prefix;
        }
    }

    for(int i = 1;i<=m;i++){
        prefix = 0;
        for(int j = 1;j<=n;j++){
            if(grid[j][i]=='#'){
                prefix = 0;
            }
            else{
                prefix++;
            }
            prefix_col[j][i] += prefix;
        }
    }


    int ans = 0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            //cout << prefix_col[i][j-1] << ' ' << prefix_row[i-1][j] << ' ' << suffix_row_col[i][j]<<  endl;
            int temp = prefix_col[i-1][j]+prefix_row[i][j-1]+suffix_row_col[i][j];
            ans=max(ans,temp);
        }
    }

    cout << ans-1 << endl;

    return 0;
}

Measured memory_bytes: 51968
import sys


def decode_roman_number(data):
    """ ???????????°????????¢????????¢??°??????????????????
    ????????§??????????????¨????????????????????§???I, V, X??????????????????????????????????????¢????????¢??°???????????????????????????

    ?????¬????????????????????????????????????????????????????????????????????????????????§???????????°??????????????¨???????????¨???????????§????????????????????????????????????????????????
    ?¬??????????????????????????°????????????£?????????????????§????????°(???: V ??? I)??????????????????????????§????????°??????????????¨??¨?????????????????????
    ??????????????§???????????£?????????????????§????????°(???: I ??? V)??????????????????????????§????????°??????????????¨??¨?????????????????????
    ???????????????????????°??????????¬????????????¨????????????????????????????????????
    ??¨???????????????????????????????????????????????£????????????????????¨???????????¨???
    """
    roman_num = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}  # ???????????°???????????????????????????????????????

    decoded_number = 0  # ??¢????????¢??°??????????????????????????????
    my_stack = []
    for c in data:
        try:
            if len(my_stack) == 0:  # ???????????????????????????????????§??????????????§?????¨?????????????????????????????????
                my_stack.append(c)
            else:
                while len(my_stack) > 0 and roman_num[my_stack[-1]] < roman_num[c]:  # I???V ??? X???C ??????????????±?????????????????¨
                    decoded_number -= roman_num[my_stack.pop()]
                while len(my_stack) > 0:
                    decoded_number += roman_num[my_stack.pop()]
                my_stack.append(c)  # ???????????????????¬????????????¨??????????????????????????§??????????????????????????¨???XXIV(24)???????????£????????????????????§????????????
        except KeyError:
            raise ValueError
    while len(my_stack) > 0:
        try:
            decoded_number += roman_num[my_stack.pop()]
        except KeyError:
            raise ValueError
    return decoded_number


if __name__ == '__main__':
    #
    for line in sys.stdin:
        data = line.strip()
        # data = 'CCCCLXXXXVIIII'
        # data = 'MCMXLV'

        # ???????????°???????§£???
        ans = decode_roman_number(data)

        # ???????????¨???
        print(ans)

Measured memory_bytes: 7420
import itertools
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ansa=0
ansb=0

q=list(itertools.permutations(range(1,n+1)))
for i in range(len(q)):
  if a==list(q[i]):
    ansa=i+1
  if b==list(q[i]):
    ansb=i+1
print(abs(ansa-ansb))

Measured memory_bytes: 8052
#include<iostream>
using namespace std;
int main(){
  int a,b;cin>>a>>b;
  if(a==1)a=14;
  if(b==1)b=14;
  if(a==b)cout<<"Draw"<<endl;
  else if(b<a)cout<<"Alice"<<endl;
  else cout<<"Bob"<<endl;
  return 0;
}

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

using namespace std;

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

	string ans = "";
	
	while(n) {
		n -= 1;	
		char c = (char)(n % 26 + 'a');
		ans += c;
		n /= 26;
	}

	reverse(ans.begin(), ans.end());

	cout << ans << '\n';

	return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> A(n);
    for(int i=0;i<n;i++){
        cin >> A[i];
    }
    for(int k=0;k<n;k++){
        if(k>0) cout << " ";
        cout << A[k];
    }
    cout << endl;
    for(int i=1;i<n;i++){
        int v = A[i];
        int j = i-1;
        while(j >= 0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        for(int k=0;k<n;k++){
        if(k>0) cout << " ";
        cout << A[k];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3064
N, M =map(int, input().split())
H_tree =[0]+[int(n) for n in input().split()]
GOOD_Tree = [0]+[1 for n in range(N)]
 
for i in range(M):
  A, B = map(int, input().split())
  if H_tree[A]<=H_tree[B]:GOOD_Tree[A] = 0
  if H_tree[A]>=H_tree[B]:GOOD_Tree[B] = 0
print(sum(GOOD_Tree))

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

int main()
{
    string S;
    int K;
    cin >> S;
    cin >> K;

    int count = 0;
    for (int i = 0; i < S.size(); i++)
    {
        if (S[i] == '1')
        {
            count++;
            if (count == K)
            {
                cout << 1 << endl;
                return 0;
            }
        }
        else
        {
            cout << S[i] << endl;
            return 0;
        }
    }
}


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

using namespace std;


int N, M;
int main(){
	cin >> N >> M;

	vector<long long> a(N);
	vector< pair<long long, long long> > vp;

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

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

		vp.push_back( make_pair(c, b) );
	}

	sort(a.begin(), a.end());
	sort(vp.begin(), vp.end());

	long long ans = 0;
	for(int i=0; i<N; i++){
		if(vp.empty() || vp.back().first <= a[i]){
			ans += a[i];
			continue;
		}

		ans += vp.back().first;
		vp.back().second--;
		if(vp.back().second == 0) vp.pop_back();
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
using matrix = vector<vector<uint>>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acos(-1);

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

    int N;
    cin >> N;

    vector<ll> sum(N + 1);
    for (int i = 0; i < N; ++i) {
        int A;
        cin >> A;
        sum[i + 1] = sum[i] + A;
    }

    auto func = [&](int mid, auto litr, auto ritr) -> ll {
        if (litr == sum.begin() || litr == sum.begin() + mid)
            return 1e18;
        if (ritr == sum.begin() + mid || ritr == sum.end() - 1)
            return 1e18;
        ll mi = 1e18, ma = 0;
        mi = min(*litr, mi);
        mi = min(sum[mid] - *litr, mi);
        mi = min(*ritr - sum[mid], mi);
        mi = min(sum[N] - *ritr, mi);
        ma = max(*litr, ma);
        ma = max(sum[mid] - *litr, ma);
        ma = max(*ritr - sum[mid], ma);
        ma = max(sum[N] - *ritr, ma);
        return ma - mi;
    };

    ll ans = 1e18;
    for (int i = 2; i <= N - 2; ++i) {
        auto litr = lower_bound(sum.begin() + 1, sum.begin() + i + 1, sum[i] / 2);
        auto ritr = lower_bound(sum.begin() + i + 1, sum.end(), (sum[i] + sum[N]) / 2);
        ans = min(func(i, litr, ritr), ans);
        ans = min(func(i, litr - 1, ritr), ans);
        ans = min(func(i, litr, ritr - 1), ans);
        ans = min(func(i, litr - 1, ritr - 1), ans);
    }

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


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

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

int main(){
	double R;
	cin >> R;
	cout << fixed << setprecision(12) << 2 * R * M_PI << endl;
}

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

vector<double>p;
ll n;
vector<vector<double>>dp;

double F(int idx, int diff)
{
	if (idx == n)
		return diff > 0;
	if (dp[idx][diff + n] != -1)
		return dp[idx][diff + n];
	double a = F(idx + 1, diff + 1) * p[idx];
	double b = F(idx + 1, diff - 1) * (1 - p[idx]);
	return (dp[idx][diff + n] = a + b);
}

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

	cin >> n; p = vector<double>(n);
	for (auto &it : p)
		cin >> it;
	dp = vector<vector<double>>(n, vector<double>(2 * n + 1, -1));
	cout << fixed << setprecision(11) << F(0, 0);

	return 0;
}

Measured memory_bytes: 144220
#include<iostream>
using namespace std;
int h[100000];
int a[100000], b[100000];
int hflag[100000];

int main() {
	//A
	/*char a[3];
	cin >> a;
	if (a[1] == 'B') { cout << "ARC"; }
	else { cout << "ABC"; };
	return 0;
	*/
	//B
	/*int n;
	int k;
	int d[100];
	int a[100][100];
	int sunuke[100];
	cin >> n;
	cin >> k;
	int i,j;
	for (i = 0; i < n; i++) {
		sunuke[i] = 0;
	}
	for (i = 0; i < k; i++) {
		cin >> d[i];
		for (j = 0; j < d[i]; j++)
		{
			cin >> a[i][j];
			sunuke[a[i][j]-1]++;
		}
	}
	int c = 0;
	for (i = 0; i < n; i++) {
		if (sunuke[i] == 0) { c++; }
	}
	cout << c;
	return 0;*/
	//C
	int n, m;
	cin >> n;
	cin >> m;

	int i;
	int c = 0;

	for (i = 0; i < n; i++) {
		cin >> h[i];
	}
	for (i = 0; i < m; i++) {
		cin >> a[i];
		cin >> b[i];
	}
	for (i = 0; i < 100000; i++) {
		hflag[i] = 1;
	}
	for (i = 0; i < m; i++) {
		/*cout << a[i];
		cout << ' ';
		cout << b[i];
		cout << ' ';*/
		if (h[a[i]-1] > h[b[i]-1]) {
			hflag[b[i]-1] = 0;
			//cout << b[i] - 1;
		}
		else if(h[a[i] - 1] < h[b[i] - 1]){
			hflag[a[i]-1] = 0;
			//cout << a[i] - 1;
		}
		else {
			hflag[a[i] - 1] = 0;
			hflag[b[i] - 1] = 0;
		}
		//cout << '\n';
	}
	for (i = 0; i < n; i++) {
		if (hflag[i] == 1) {
			c++;
		}
	}
	cout << c;
	return 0;
}

Measured memory_bytes: 5144
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn main() {
    input!{
        h: usize, w: usize, k: usize,
        c_vec: [Chars;h]
    }

    let mut set: HashSet<(Vec<usize>, Vec<usize>)> = HashSet::new();
    
    // bit全探索
    // h
    for h_bit in 0..1<<h {
        let mut h_set = HashSet::new();
        for i in 0..h {
            if (h_bit & (1<<i)) == 0 {
                h_set.insert(i);
            }
        }
        // w
        for w_bit in 0..1<<w {
            let mut w_set = HashSet::new();
            for i in 0..w {
                if (w_bit & (1<<i)) == 0 {
                    w_set.insert(i);
                }
            }

            // w_set and h_set
            let mut cnt = 0;
            for i in 0..h {
                if h_set.contains(&i) {
                    continue
                }
                for j in 0..w {
                    if w_set.contains(&j) {
                        continue
                    }
                    if c_vec[i][j] == '#' {
                        cnt += 1
                    }
                }
            }
            if cnt == k {
                let h_vec = h_set.clone().into_iter().collect::<Vec<usize>>();
                let w_vec = w_set.clone().into_iter().collect::<Vec<usize>>();
                set.insert((h_vec, w_vec));
            }
        }
    }

    println!("{}", set.len());
}


Measured memory_bytes: 2320
#include <stdio.h>
#include <math.h>
#include <cmath>

using namespace std;

int main(){
	int n;
	double x[100] = {0},y[100] = {0},p_1 = 0,p_2 = 0,p_3 = 0,p_infinity = -1;
	scanf("%d",&n);
	for(int i = 0; i < n; i++) scanf("%lf",&x[i]);
	for(int i = 0; i < n; i++) scanf("%lf",&y[i]);

	for(int i = 0; i < n; i++){
		p_1 += abs(x[i] - y[i]);
		p_2 += (x[i] - y[i])*(x[i] - y[i]);
		p_3 += abs((x[i] - y[i])*(x[i] - y[i])*(x[i] - y[i]));
		p_infinity = (p_infinity >= abs(x[i] - y[i]))? p_infinity:abs(x[i] - y[i]);
 	}
	printf("%.6lf\n",p_1);
	printf("%.6lf\n",sqrt(p_2));
	printf("%.6f\n",cbrt(p_3));
	printf("%.6lf\n",p_infinity);

}

//naoto


Measured memory_bytes: 2880
N = int(input())
T = list(map(int, input().split()))
ans = 0

for i in range(N):
    if T[i] % 4 == 0:
        ans += 1
    elif T[i] % 2 != 0:
        ans -= 1
    
if N % 2 != 0:
    ans += 1

print('Yes' if ans >= 0 else 'No')

Measured memory_bytes: 15020
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
void calc(vvi&v){
    ll n=v.size(),m=v[0].size();
    rep(i,n-1)rep(j,m)v[i+1][j]+=v[i][j];
    rep(i,n)rep(j,m-1)v[i][j+1]+=v[i][j];
}
int main(){
    ll n,m,q;cin>>n>>m>>q;
    vvi v(n,vi(m));
    rep(i,n){
        string s;cin>>s;
        rep(j,m)v[i][j]=s[j]-'0';
    }
    vvi tate(n+1,vi(m+1)),yoko(n+1,vi(m+1)),sum(n+1,vi(m+1));
    rep(i,n)rep(j,m)if(v[i][j])sum[i+1][j+1]++;
    rep(i,n-1)rep(j,m){
        if(v[i][j]&&v[i+1][j])tate[i+2][j+1]++;
    }
    rep(i,n)rep(j,m-1){
        if(v[i][j]&&v[i][j+1])yoko[i+1][j+2]++;
    }
    calc(sum);calc(tate);calc(yoko);
    rep(tt,q){
        ll a,b,c,d;cin>>a>>b>>c>>d;
        ll ans=sum[c][d]+sum[a-1][b-1]-sum[a-1][d]-sum[c][b-1];
        ans-=tate[c][d]+tate[a][b-1]-tate[a][d]-tate[c][b-1];
        ans-=yoko[c][d]+yoko[a-1][b]-yoko[a-1][d]-yoko[c][b];
        out(ans);
    }
}

Measured memory_bytes: 127232
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000


ll numOfBits(ll bits)
{
    ll num  = 0;

    for ( ; bits != 0 ; bits &= bits - 1 ) {
        num++;
    }

    return num;
}


int main() {
    ll n,m; cin >> n >> m;
    vector<ll> p(m);
    vector<ll> k(m);
    ll ans = 0;
    bool flag = true;

    rep(i,m){
        ll tmp; cin >> tmp;
        ll sum = 0;
        rep(j,tmp){
            ll s; cin >> s;
            sum += (1 << (s-1));
        }
        k[i] = sum;
    }

    rep(i,m) cin >> p[i];
/*
    rep(i,m){
        cout << numOfBits(k[i]&&2) << endl;
    }
*/


    for(int bit = 0; bit < (1 << n); bit ++){
        flag = true;
        rep(i,m){
            if((numOfBits(bit&k[i])%2 != p[i])) flag = false;
        }
        if(flag) {
            ans ++;
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  long long N, K;
  cin >> N >> K;
  vector<long long> V(100100, 0);
  for (int i = 0; i < N; i++)
  {
    long long a, b;
    cin >> a >> b;
    V.at(a) += b;
  }
  
  int ans;
  long long sum = 0;
  for (int i = 1; i < 100100; i++)
  {
    sum += V.at(i);
    if (sum >= K)
    {
      ans = i;
      break;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    double p[] = new double[N];
    double E[] = new double[N]; //i番目のサイコロの期待値
    
    for(int i=0;i<N;i++){
      p[i]=sc.nextDouble();
    }
    
    for(int i=0;i<N;i++){
      E[i]=(p[i]+1)/2;
    }
    double Esum[] = new double[N+1];//E[1]は1個目、E[2]は2個目まで,E[i]はi個目までの累積和...
    Esum[0]=0;
    for(int i=0;i<N;i++){
      Esum[i+1]=Esum[i]+E[i];
    }
    
    double tmp=0;
    for(int i=0;i<N-K+1;i++){
      //i個目からi+K-1個目までの和がそこまでのmaxより大きかったら書き換え
      if(tmp<Esum[i+K]-Esum[i]){
        tmp=Esum[i+K]-Esum[i];
      }
    }

    System.out.println(tmp);
    
    
  }
  

  
}

Measured memory_bytes: 161016
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
struct Node{
 
  int key;
  struct Node *parent;
  struct Node *left;
  struct Node *right;
 
};
 
struct Node *root,*NIL;
void insert(int );
void preorder(struct Node *);
void inorder(struct Node *);
struct Node *find(struct Node *, int);
int main(){
 
  int sumnode,inputdata,i,findnumber;
  char string[10];
 
 
  scanf("%d",&sumnode);
 
  for(i = 0; i < sumnode; i++){
 
    scanf("%s",string);
 
    if((strcmp(string,"insert")) == 0){
 
      scanf("%d",&inputdata);
      insert(inputdata);
 
    }
 
 
    else if((strcmp(string,"print"))==0){
 
      inorder(root);
 
      printf("\n");
 
      preorder(root);
 
      printf("\n");
    
         
    }
 
    else if((strcmp(string,"find")) == 0){
 
 
      struct Node *answer;
      scanf("%d",&findnumber);
 
      answer =  find(root,findnumber);
       
 
      if(answer !=NIL){
 
	printf("yes\n");
 
      }
 
      else{
 
	printf("no\n");
 
      }
    }
 
  }
  return 0;
}
void insert(int inputdata){
 
  struct Node *correntNode; 
  struct Node *beforeNode; 
  struct Node *newNode;
 
  newNode = (struct Node*)malloc(sizeof(struct Node));
 
  newNode -> key = inputdata;
 
  newNode->parent = NIL;
 
  newNode->left = NIL;
 
  newNode->right = NIL;
 
  correntNode = root;
  beforeNode = NIL;
 
  while(correntNode != NIL){
 
    beforeNode = correntNode;
 
    if(newNode->key < correntNode->key){
 
      correntNode = correntNode->left;
 
    }
 
    else{
 
      correntNode =  correntNode->right;
 
    }
  } 
 
  newNode->parent = beforeNode;
 
 
  if(beforeNode == NIL){ 
 
    root = newNode;;
 
  }
 
  else if(newNode->key > beforeNode->key){
 
    beforeNode->right = newNode;
 
  }
 
  else{
 
    beforeNode->left = newNode;
 
  }
 
}
 
void preorder(struct Node *inputdata){
 
  if(inputdata != NIL){
 
    printf(" %d",inputdata->key);
 
    preorder(inputdata->left);
    preorder(inputdata->right);
 
  }
 
}
 
void inorder(struct Node *inputdata){
 
  if(inputdata != NIL){
 
    inorder(inputdata->left);
 
    printf(" %d",inputdata->key);
 
    inorder(inputdata->right);
 
  }
 
}
 
 
struct Node * find(struct Node *inputdata ,int findnumber){
 
  int flag = 0;
 
  while( inputdata != NIL && inputdata->key != findnumber){
 
    if(inputdata->key < findnumber){
 
      inputdata = inputdata->right;
 
    }
 
    else if(inputdata->key > findnumber){
 
      inputdata = inputdata->left;
 
    }
  }
 
 
 
  return inputdata;
 
}

Measured memory_bytes: 19364
#include <stdio.h>

int main(void) {
	int H1, H2, M1, M2, K;
	scanf("%d%d", &H1, &M1);
	scanf("%d%d", &H2, &M2);
	scanf("%d", &K);
	printf("%d", (H2 * 60 + M2) - (H1 * 60 + M1) - K);

	return 0;
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 99999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    llong n,b[100002]={},ans=0;
    cin >> n;
    for(int i=1;i<n;i++) cin >> b[i];
    ans += b[1];
    for(int i=1;i<n-1;i++){
        ans += min(b[i],b[i+1]);
    }
    ans += b[n-1];
    cout << ans << endl;
}

Measured memory_bytes: 1024
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

use std::cmp::Ordering;
pub trait BinarySearch<T> {
    fn lower_bound(&self, x: &T) -> usize;
    fn upper_bound(&self, x: &T) -> usize;
}
impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();
        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less => {
                    low = mid + 1;
                }
                Ordering::Equal | Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
    fn upper_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();
        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less | Ordering::Equal => {
                    low = mid + 1;
                }
                Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
}

fn main() {
    input! {
        n: usize,
        l: [u32;n]
    }
    let mut l = l;
    l.sort();
    let mut res = 0;
    for i in 0..n {
        for j in i+1..n {
            let x = l.lower_bound(&(l[i] + l[j])) - 1;
            if j < x {
                res += x - j;
            }
        }
    }
    println!("{}", res);
}
/* vim:set foldmethod=marker: */


Measured memory_bytes: 4352
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<i64> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();
    let mut sum = 0i64;
    for i in 0..n {
        if i % 2 == 0 {
            sum += a[i];
        } else {
            sum -= a[i];
        }
    }
    let mut out = Vec::new();
    for i in 0..n {
        writeln!(out, "{}", sum).ok();
        sum -= a[i];
        sum *= -1;
        sum += a[i];
    }
    stdout().write_all(&out).unwrap();
}


Measured memory_bytes: 9468
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main(){
  ll N; cin >> N;
  string s; cin >> s;
  ll ans = 1e18;
  //Sのi文字目までに白が何個あるか？
  vector<ll> white(N+1,0);
  REP(i,N) white[i+1] = white[i] + (s[i]=='.');
  //Sのi文字目まで白，i+1文字目以降黒
  //(i=0,1,...,N)
  REP(i,N+1){
    ll t = (i-white[i]) + (white[N]-white[i]);
    ans = min(ans,t);
  }
  cout << ans << endl;
}

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

#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) {return b < a ? a = b, 1 : 0;}
template<typename T> inline bool chkmax(T &a, T b) {return b > a ? a = b, 1 : 0;}

inline int read() {
    int x(0), sgn(1); char ch(getchar());
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
    for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
    return x * sgn;
}

void File() {
#ifdef zjp_shadow
	freopen ("D.in", "r", stdin);
	freopen ("D.out", "w", stdout);
#endif
}

int main() {

	File();

	int n = read(), T = read();

	int ans = 0, tot = 0, minv = INT_MAX;

	For (i, 1, n) {
		int val = read();
		chkmin(minv, val);
		if (chkmax(ans, val - minv)) tot = 1;
		else if (ans == val - minv) ++ tot;
	}
	printf ("%d\n", tot);

    return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
#define ll               long long
int main(){
  ll a;
  string b;cin>>a>>b;
  if(b.size()>a){
    rep(i,a)cout<<b[i];
    cout<<"...";
  }
  else cout<<b;
  }


Measured memory_bytes: 3628
import string

N = int(input())
s = input()

MOD = 10 ** 9 + 7

d = dict()
for ss in s:
    d[ss] = d.get(ss, 0) + 1
ans = 1
for c in string.ascii_lowercase:
    ans *= (d.get(c, 0) + 1)
    ans %= MOD
ans -= 1
print(ans)


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

signed main(){
  int N,X,T;
  cin>>N>>X>>T;
  int ans=0;
  while(N>0){
    ans+=T;
    N-=X;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3640
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

void solve() {
    int N;
    cin >> N;
    multiset<int> S;
    rep(i, N) {
        int a;
        cin >> a;
        S.insert(a);
    }

    int ans = 0;
    while (!S.empty()) {
        auto it = S.end();
        --it;
        int x = *it;
        S.erase(it);
        for (int i = 30; i >= 0; --i) {
            int sum = 1 << i;
            it = S.find(sum - x);
            if (it!=S.end()) {
                ans++;
                S.erase(it);
                break;
            }
        }
    }
    cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}

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

#define MAX 25
#define NIL -1

typedef struct {
	int parent;
	int left;
	int right;
} Node, Tree;

void Preorder(Tree T[], int rootId)
{
	int id = rootId;
	
	if (id == NIL)
		return;
		
	cout << " " << id;
	Preorder(T, T[id].left);
	Preorder(T, T[id].right);
}

void Inorder(Tree T[], int rootId)
{
	int id = rootId;
	
	if (id == NIL)
		return;
	
	Inorder(T, T[id].left);
	cout << " " << id;
	Inorder(T, T[id].right);
}

void Postorder(Tree T[], int rootId)
{
	int id = rootId;
	
	if (id == NIL)
		return;
	
	Postorder(T, T[id].left);
	Postorder(T, T[id].right);
	cout << " " << id;
}

int main(void)
{
	Tree T[MAX];
	int n;
	int rootId;
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		T[i].parent = NIL;
	} 
	for (int i = 0; i < n; i++) {
		int id, l, r;
		
		cin >> id >> l >> r;
		T[id].left = l;
		T[id].right = r;
		
		T[l].parent = id;
		T[r].parent = id;
	}
	for (int i = 0; i < n; i++) {
		if (T[i].parent == NIL) {
			rootId = i;
			break;
		}
	}
	cout << "Preorder" << '\n';
	Preorder(T, rootId);
	cout << '\n';
	cout << "Inorder" << '\n';
	Inorder(T, rootId);
	cout << '\n';
	cout << "Postorder" << '\n';
	Postorder(T, rootId);
	cout << '\n';
	
	return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;
typedef long long lint;

bool isprime(int i){
    for(int j=2; j*j<=i; ++j){
        if(i % j == 0) return false;
    }
    return true;
}

lint gcd(lint p, lint q){
    if(p < 0) p = -p;
    if(q < 0) q = -q;
    if(p < q) swap(p, q);
    while(q){
        lint r = p % q;
        p = q;
        q = r;
    }
    return p;
}

int main(){
    int n; cin >> n;
    vector<lint> a(n+1); rep(i, n+1) cin >> a[n-i];
    vector<lint> prime;
    vector<lint> p;
    if(n >= 2) prime.push_back(2);
    for(int i=3; i<=n; i+=2)if(isprime(i)) prime.push_back(i);
    lint g = a[0];
    rep(i, n) g = gcd(g, a[i+1]);
    for(int i=2; i*i<=g; ++i){
        if(g % i == 0){
            while(g % i == 0) g /= i;
            p.push_back(i);
        }
    }
    if(g > 1) p.push_back(g);
    rep(i, prime.size()){
        vector<lint> b(n+1); rep(j, n+1) b[j] = a[j];
        rFor(j, n+1, prime[i]){
            b[j-prime[i]+1] += b[j];
            b[j] = 0;
        }
        bool flag = true;
        rep(j, n+1)if(b[j] % prime[i] != 0){
            flag = false;
            break;
        }
        if(!flag) continue;
        p.push_back(prime[i]);
    }
    sort(p.begin(), p.end());
    p.erase(unique(p.begin(), p.end()), p.end());
    rep(i, p.size()) cout << p[i] << endl;
}

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

#define double long double
#define int long long
#define vec vector
#define pb push_back
#define unset unordered_set
#define ii pair<int, int>
#define X first
#define Y second
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define bitcount(n) __builtin_popcountll(n)
template <typename T,typename U>
std::pair<T,U> operator+(const std::pair<T,U> & l,const std::pair<T,U> & r) {
  return {l.first+r.first,l.second+r.second};
} 
typedef void (*callback_function)(void); // type for conciseness
const long long ZERO = 0LL;
const long long INF64 = 1e18;
const int INF32 = 1e9;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0L);
const double EPS = static_cast<double>(1e-9);
typedef long long ll;

inline int Pow(int a, int k) {
  int s = 1; 
  for(; k; k >>= 1) {
    k & 1 ? s = 1LL * s * a % MOD : 0;
    a = 1LL * a * a % MOD;
  }
  return s;
}

const int N = 1e6 + 7;
int stNum[N];
int size[N];

void make(int u) {
  stNum[u] = u, size[u] = 1;
}

int find(int u) {
  if (stNum[u] != u) {
    stNum[u] = find(stNum[u]);
    size[u] = size[stNum[u]]; // same set => same size
  }
  return stNum[u];
}

void merge(int u, int v) {
  int x = find(u), y = find(v);
  if (x != y) {
    if (size[x] < size[y]) {swap(x, y);} // size keeps the tree short
    stNum[y] = x;
    size[x] += size[y]; // add size of set y to set x
    size[y] = size[x]; // same set => same size
    // modification here

    // Sometimes the merge function is modified for solving a particular
    // problem. Example: https://codeforces.com/problemset/problem/722/C
    // In this problem, I know the weight of each node and when I merge two
    // sets, I need to find the total weight of the nodes in this set. So I
    // update the sum of the set inside this merge function:
    //sum[x] += sum[y]; sum[y] = sum[x];
  }
}
// 29gg


void input() {
  //freopen("??.in", "r", stdin);
  //freopen("??.out", "w", stdout);
  // 34gg

}

void preprocess() {
 FOR(i, 1, N) {make(i);}
}

void debug() {
  //  44gg
  if (true) {
  
  }
}



void solve() {
  preprocess();
  // 50gg
  int n, m; cin >> n >> m;
  ii edge[m + 1]; FORE(i, 1, m) {cin >> edge[i].X >> edge[i].Y;}
  int C2[n + 1]; C2[0] = C2[1] = 0; C2[2] = 1;
  FORE(i, 3, n) {C2[i] = C2[i - 1] * i / (i - 2);}
  int all = C2[n];
  //cerr << "all = " << all << endl;
  stack<int> res;
  FORD(i, m, 1) {
    res.push(all);
    int u = edge[i].X, v = edge[i].Y;
    int x = find(u), y = find(v);
    if (x != y) {
      all -= size[x] * size[y];
    }
    merge(u, v);
  }
  while (!res.empty()) {
    cout << res.top() << endl; res.pop();
  }
  //debug();
  // read the question correctly (is y a vowel?)
  // look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)
}

void output() {

}

#undef int
int main() {
#define int long long
	ios_base::sync_with_stdio(false);
	cin.tie();
  //auto beginProgram = chrono::steady_clock::now();

  {
    input();
    solve();
    output();
  }

  //auto endProgram = chrono::steady_clock::now();

  return 0;
}



Measured memory_bytes: 19868
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int ar[5],i;

    for(i=0;i<5;i++) cin>>ar[i];


    for(i=0;i<5;i++){
        if(ar[i]==0){
            cout<<i+1<<endl;
            break;
        }
    }
}


Measured memory_bytes: 3520
#include<stdio.h>
int main()
{
	int N;
	scanf("%d",&N);
	int time=0;
	int a[100000];
	int i;
	int x=0;
	for(i=0;i<=N-1;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]==2)
		{
			x=1;
		}
	}
	if(x==1)
	{
		int t=0;
		while(t!=1)
		{
			t=a[t]-1;
			time+=1;
			if(time>N-1)
			{
				printf("-1");
				return 0;
			}
		}
		printf("%d",time);
	}
	else
	{
		printf("-1");		
	}
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>                   // below comment for pbds
#include<ext/pb_ds/assoc_container.hpp>   // to use it make ordered_set
#include<ext/pb_ds/tree_policy.hpp>       // all set fnct + = 1. order_of_key(x); // number of 
#define ll long long                      //element strictly smaller than it;
#define ld long double                    // 2. find_by_order(x),pointer el at x pos after sort  use as s.f();
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;                     
using namespace __gnu_pbds;
// assert(a[i]<n ) // if we want to check for special cond , used for debug
// make less_equal in order to make a multiset pbds
const ll Mod = (int)1e9;
ll CaseN=1;
ll fast_power(ll a,ll b,ll mod){
	ll ans=1;
	while(b>0){
	if(b&1){
	ans=(a*ans)%mod;
	}
	b=b>>1;
	a=(a*a)%mod;
	}
	return ans;
	}


ll nCr(ll n ,ll r)
{
ll p= n;
r = min(r,n-r);
ll a =1;
ll b=1;	
while(r)
{
	a = a*p;
	b = b*r;
	
	ll g = __gcd(a,b);
	
	a = a/g;
	b = b/g;
	
	p--;
	r--;	
}	
return a;
	
}

void solve()
{
	string s;
	cin>>s;
	bool ans=true;
	vector<ll> c(28,0);
	
	for(ll i=0;i<(ll)s.length();i++)
	{
		c[s[i]-'a']++;
	}
	for(ll i=0;i<26;i++)
	{
	if(c[i]&1)
	{
	ans = false;	
	}	
	}
	
	 if(ans)
  {
  cout<<"Yes"<<endl; 
  }
  else
   {
  cout<<"No"<<endl;
  }
 
	
    //cout<<"Case #"<<CaseN<<": ";
   CaseN++;
	// print your ans below;
return ;
}


signed main() {
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--)
	{
	solve();	
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0; i < (int)s.length(); i++) {
        ans += s[i] - '0';
        ans %= 9;
    }
    if(ans == 0) cout << "Yes";
    else cout << "No";
    return 0;
}

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

int main() {
	int h, w;
	string s[50];
	int count[52][52];
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < h + 2; i++) {
		for (int j = 0; j < w + 2; j++) {
			count[i][j] = 0;
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '#') {
				count[i][j] += 1;
				count[i][j + 1] += 1;
				count[i][j + 2] += 1;
				count[i + 1][j] += 1;
				count[i + 1][j + 2] += 1;
				count[i + 2][j] += 1;
				count[i + 2][j + 1] += 1;
				count[i + 2][j + 2] += 1;
			}
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '#') {
				cout << '#';
			}
			else {
				cout << count[i + 1][j + 1];
			}
		}
		cout << endl;
	}
}


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

int main() {
	// vector<int> vec;
	int n;
	cin >> n;
	int maxNum = 0;
	int sum = 0;
	for(int i = 0; i < n; i++) {
		int curr;
		cin >> curr;
		maxNum = max(maxNum, curr);
		sum += curr;
		// vec.push_back(curr);
	}
	sum -= maxNum;
	if(maxNum < sum) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}


Measured memory_bytes: 256