akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<vector>
using namespace std;
int main(void){
    // Your code here!
    int N;  
    cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    for(int i=0;i<N;i++){
        cout<<A[i];
            if(i!=N-1){
                cout<<' ';
            }
            else{
                cout<<endl;
            }
        }
    for(int i=1;i<N;i++){
        int temp=A[i];
        int j=i-1;
        while(j>=0&&temp<A[j]){
            A[j+1]=A[j];
            A[j]=temp;
            j--;
        }
        for(int i=0;i<N;i++){
        cout<<A[i];
            if(i!=N-1){
                cout<<' ';
            }
            else{
                cout<<endl;
            }
        }
    }    
}



Measured memory_bytes: 3100
#include<iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include<map>
#include<iomanip>
#include <string>
#include <vector>	
#include<unordered_map>
#include<unordered_set>
using namespace std;


typedef long long unsigned llu;
typedef long double ld;
#define ll long long
#define PI 3.14159265358979323846
#define For(i, a, b) for (int i = a, sz = (int)b; i < sz; i++)
#define rFor(i, a, b, c) for (int i = (a); i >= (b); i -= (c))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fill(a, b) memset(a, b, sizeof(a))
#define IO ios_base::sync_with_stdio(false), cin.tie(0),cout.tie(0)
const ll mod = 1000000007;
const ll inf = 1000000000009;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) { return a*b/gcd(a,b);}

//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

int main()
{
	IO;
	int n{};
	cin>>n;
	vector<int>v(n+1);
	For(i,1,n+1)cin>>v[i];
	int ans{};
	For(i,1,n+1)
		if(i&1 && (v[i]*v[i])&1)ans++;
	cout<<ans<<'\n';
	//system("pause");
	return 0;

}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, (c>9)&(c!=253));
	for(a=(b=c==253)?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
int (*rd)()=read<int>;
const u32 P=1e9+7;
inline u32 &inc(u32 &a, u32 b) {return (a+=b)<P?a:(a-=P);}
inline u32 &dec(u32 &a, u32 b) {return (a-=b)&0x80000000?(a+=P):a;}
inline u32 sum(u32 a, u32 b) {return (a+=b)<P?a:a-P;}
inline u32 dif(u32 a, u32 b) {return (a-=b)&0x80000000?a+P:a;}
u64 power(u64 a, int b) {
	u64 ans=1;
	for(; b; a=a*a%P, b/=2) if(b&1) ans=ans*a%P;
	return ans;
}

const int N=3e5;
char s[N];
u32 f[N][3][3];
int main() {
	scanf("%s", s);
	int n=strlen(s);
	f[0][0][0]=1;
	for(int i=1; i<=n; ++i) {
		if(s[i-1]!='1') {
			for(int j=0; j<=2; ++j) {
				inc(f[i][j][1], f[i-1][j][0]);
				inc(f[i][j][2], f[i-1][j][1]);
				inc(f[i][j][1], f[i-1][j][2]);
			}
		}
		if(s[i-1]!='0') {
			for(int j=2, k=2; j>=0; k=j--) {
				inc(f[i][k][0], f[i-1][j][0]);
				inc(f[i][j][0], f[i-1][j][1]);
				inc(f[i][j][1], f[i-1][j][2]);
			}
		}
	}
	u32 ans=0;
	for(int i=0; i<=2; ++i)
		for(int j=0; j<=i; ++j)
			inc(ans, f[n][i][j]);
	printf("%u\n", ans);
	return 0;
}


Measured memory_bytes: 11136
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	a -= 1
	b -= 1

	if b%a == 0 {
		fmt.Println(b / a)
	} else {
		fmt.Println((b / a) + 1)
	}
}


Measured memory_bytes: 512
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

int main() {
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int x = 0;
  FOR(c,s) {
    if(c == '+') {
      x++;
    } else {
      x--;
    }
  }
  cout << x << endl;
  
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
// const ll mod= 1000000007;

int n, m;
int a[100010], b[100010];
vector<i_i> tasks;

signed main() {
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        tasks.emplace_back(make_pair(a[i], b[i]));
    }

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

    int i = 0;
    int ans = 0;
    priority_queue<int> pq;
    for (auto &it:tasks) {
        while (it.first-1 > i && i<m) {
            if (!pq.empty()) {
                ans += pq.top();
                pq.pop();
            }
            i++;
            // cout << i << " " << ans << endl;
        }
        pq.emplace(it.second);
    }

    while(i<m) {
        ans += pq.top();pq.pop();
        i++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 4084
N, L = map(int, input().split())

tastes = [L + i - 1 for i in range(1, N+1)]
sum_taste = sum(tastes)

prev_taste_diff = 10 ** 10

ans = 0
for i in range(N):
    s = sum(tastes[:i] + tastes[i+1:])
    curr_taste_diff = abs(s - sum_taste)
    if curr_taste_diff < prev_taste_diff:
        ans = s
    prev_taste_diff = curr_taste_diff
print(ans)


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

using namespace std;

struct Edge{
  int cost, x, y;
};

bool operator < (Edge a, Edge b) {
  return a.cost < b.cost;
}

vector<int> UFtree;

int root(int i) {
  if(UFtree[i] == i) return i;
  return (UFtree[i] = root(UFtree[i]));
}

bool is_same_set(int i, int j) {
  return root(i) == root(j);
}

void unite(int i, int j) {
  UFtree[root(i)] = root(j);
}

int main() {
  int n, cost, w = 0;
  cin >> n;
  for(int i = 0; i < n; i++) UFtree.push_back(i);
  vector<Edge> Edges;
  Edge e;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n; j++) {
	cin >> cost;
	if(j > i && cost != -1) {
	  e.cost = cost; e.x = i; e.y = j;
	  Edges.push_back(e);
	}
    }
  }
  sort(Edges.begin(), Edges.end());
  for(int i = 0; i < Edges.size(); i++) {
    if(!is_same_set(Edges[i].x, Edges[i].y)) {
      w += Edges[i].cost;
      unite(Edges[i].x, Edges[i].y);
    }
  }
  cout << w << endl;
  return 0;
}

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

int main(){
  int n;
  string s,a,b;
  cin >> n >> s;
  int ans,cnt;
  ans = 0;
  for(int i = 0;i < n;i++){
    cnt = 0;
    a = s.substr(0,i+1);
    b = s.substr(i+1);
    sort(a.begin(),a.end());
    a.erase(unique(a.begin(),a.end()),a.end());
    for(int j = 0;j < a.size();j++){
      if((int)b.find(a.at(j)) > -1){
        cnt++;
      }
    }
    if(ans < cnt){
      ans = cnt;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = list(input())
numS = [0 for i in range(N)]
sumS = [0 for i in range(N)]
for i in range(N):
    if S[i] == 'E':
        numS[i] = 0
    else:
        numS[i] = 1

for i in range(N):
    sumS[i] = sumS[i-1] + numS[i]
# print(sumS)
minS = (N-1) - (sumS[N-1]-sumS[0])
for i in range(1,N):
    minS = min(minS,sumS[i-1]+(N-i-1)-(sumS[N-1]-sumS[i]))
print(minS)

Measured memory_bytes: 19916
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <map>
#include <vector>
#include <unordered_map>

#define div 1000000000+7

using ll = long long;
using namespace std;

void solve() {
    int n, count = 0, count2 = 0;
    bool flag[8];
    vector<int> a;

    for(int i = 0; i < 8; i++){
        flag[i] = true;
    }

    cin >> n;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        a.push_back(x);
        if(x < 400 && flag[0]){
            count++;
            flag[0] = false;
        }else if(x >= 400 && x < 800 && flag[1]){
            count++;
            flag[1] = false;
        }else if(x >= 800 && x < 1200 && flag[2]){
            count++;
            flag[2] = false;
        }else if(x >= 1200 && x < 1600 && flag[3]){
            count++;
            flag[3] = false;
        }else if(x >= 1600 && x < 2000 && flag[4]){
            count++;
            flag[4] = false;
        }else if(x >= 2000 && x < 2400 && flag[5]){
            count++;
            flag[5] = false;
        }else if(x >= 2400 && x < 2800 && flag[6]){
            count++;
            flag[6] = false;
        }else if(x >= 2800 && x < 3200 && flag[7]){
            count++;
            flag[7] = false;
        }else if(x >= 3200){
            count2++;
        }
    }

    if(count > 0){
        cout << count;
    }else if(count == 0 && count2 > 0){
        cout << 1;
    }
    cout << " " << count+count2;
}

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


Measured memory_bytes: 256
n = int(input())
s = str(input())
r = s.count('R')
g = s.count('G')
b = s.count('B')
cnt = r * g * b
for i in range(n // 2):
    for j in range(n - (i + 1) * 2):
        if s[j] != s[j+i+1] and s[j+i+1] != s[j+2*(i+1)] and s[j] != s[j+2*(i+1)]:
            cnt -= 1
print(cnt)


Measured memory_bytes: 9028
n,k=map(int,input().split())
#l[i][j]でi~jの美しさ
l1=list(map(int,input().split()))
l2=[]
for i in range(n):
  sum1=0
  for j in range(i,n):
    sum1+=l1[j]
    l2.append(sum1)
l2=sorted(l2)
d=[0 for i in range(50)]
bitlist=[]
for i in l2:
  bit=[]
  num=i
  for j in range(50):
    d[j]+=num%2
    bit.append(num%2)
    num//=2
  bitlist.append(bit)
index=-1
for i in range(50):
  if d[i]>=k:
    index=i
    
if index==-1:
  print(0)
  exit()
b=True
ans1=[index]
while b:
  bitsub=[]
  for i in bitlist:
    if i[index]==0:
      pass
    else:
      bitsub.append(i)
  d=[0 for i in range(50)]
  for i in bitsub:
    for j in range(50):
      d[j]+=i[j]
  b=False
  for i in range(1,index+1):
    if d[index-i]>=k and not b:
      index=index-i
      b=True
      ans1.append(index)
  bitlist=bitsub
ans=0
for j in ans1:
  ans+=bitlist[0][j]*2**j
print(ans)


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

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

  vector<vector<int>> jobs(m + 1);
  rep(i,n) {
    int a,b;
    cin >> a >> b;
    if(a > m) continue;
    jobs[a].push_back(b);
  }

  int answer = 0;
  priority_queue<int> que;
  for (int i = m - 1; i >= 0; i--) {
    // 現在i日の時にできる仕事
    for (auto &s : jobs[m - i]) {
      que.push(s);
    }

    if(!que.empty()) {
      answer += que.top();
      que.pop();
    }
  }
  cout << answer << '\n';
}


Measured memory_bytes: 8368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(first, second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 1001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T> &vector, unsigned int index)
{
   vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

// MOD確認

ll modpow(ll a,ll n,ll m){//modpow(a,n,m) := a ^ n (mod m)
  ll res = 1;
  while(n > 0){
    if(n & 1)res = res * a % m;
    a = a * a % m;
    n >>= 1;
  }
  return res;
}


ll N;
ll A[200010];

int main(){
   cin >> N;
   ll ans = 0,sum = 0;
   rep(i,N){
      cin >> A[i];
      sum += A[i];
   }
   sum %= MOD;
   rep(i,N){
      ans += (sum - A[i]) * A[i];
      ans %= MOD;
      while(ans < 0) ans += MOD * (ll)100000000;
   }
   ans %= MOD;
   ans *= modpow(2LL,(ll)(MOD-2),MOD);
   cout << ans % MOD << endl;
}

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

int main() {
    int N, K;
    int l[50];
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> l[i];
    }

    sort(l, l + N, greater<int>());
    int ans = 0;
    for (int i = 0; i < K; i++) {
        ans += l[i];
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    
    vector<int> height(n);
    for(int i = 0; i < n; i++) {
        cin >> height[i];
    }
    
    int dp[n];
    for(int i = 0; i < n; i++) {
        dp[i] = 1000000000;
    }
    dp[0] = 0;
    
    for(int i = 1; i < n; i++) {
        for(int j = max(0, i - k); j < i; j++) {
            dp[i] = min(dp[i], dp[j] + abs(height[j] - height[i]));
        }
    }
    
    cout << dp[n - 1] << endl;
}


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

typedef long long ll;

int main(){
	int n;
	cin>>n;
	vector<int>p(n),q(n),r(n);
	for(int i=0;i<n;i++){
		cin>>p[i];
		r[i]=p[i];
	}
	sort(r.begin(),r.end());
	for(int i=0;i<n;i++){
		cin>>q[i];
	}
	ll tmp=0,P,Q;
	bool ok1=true;
	bool ok2=true;
	do{
		for(int i=0;i<n;i++){
			if(r[i]!=p[i])ok1=false;
			if(r[i]!=q[i])ok2=false;
		}
		tmp++;
		if(ok1)P=tmp;
		if(ok2)Q=tmp;
		ok1=true,ok2=true;;
	}while(next_permutation(r.begin(),r.end()));
	cout<<abs(P-Q)<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define SIZE 1000010
#define rep(i, a, b) for (long long i = a; i <= b; ++i)
#define mp make_pair
#define ll long long
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
ll n, m;
int a[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
int main() {
	io(); cin >> n >> m;
	if (n > m) swap(n, m);
	if (n == 1) cout << 1;
	else cout << (n * m + 1ll) / 2ll;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <iostream>
using namespace std;
int n;
int x[100100], y[100100], dx[100100], dy[100100];

vector<double> checkpoints(int a, int b, int c) {
    vector<double> ret;
    if (-1<<30 < a && b < 1<<30 && a <= b) ret.push_back(b-a);
    if (-1<<30 < a && c < 1<<30 && a <= c) ret.push_back((c-a)/2.0);
    if (-1<<30 < b && c < 1<<30 && b <= c) ret.push_back(c-b);
    return ret;
}

double calc(double t) {
    double xmin = 1e20, xmax = -1e20, ymin = 1e20, ymax = -1e20;
    for (int i = 0; i < n; i++) {
        xmin = min(xmin, x[i] + t * dx[i]);
        ymin = min(ymin, y[i] + t * dy[i]);
        xmax = max(xmax, x[i] + t * dx[i]);
        ymax = max(ymax, y[i] + t * dy[i]);
    }
    return (xmax - xmin) * (ymax - ymin);
}

int getxmin(int d) {
    int ret = 1<<30;
    for (int i = 0; i < n; i++) if (dx[i] == d) ret = min(ret, x[i]);
    return ret;
}

int getxmax(int d) {
    int ret = -1<<30;
    for (int i = 0; i < n; i++) if (dx[i] == d) ret = max(ret, x[i]);
    return ret;
}

int getymin(int d) {
    int ret = 1<<30;
    for (int i = 0; i < n; i++) if (dy[i] == d) ret = min(ret, y[i]);
    return ret;
}

int getymax(int d) {
    int ret = -1<<30;
    for (int i = 0; i < n; i++) if (dy[i] == d) ret = max(ret, y[i]);
    return ret;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        char c;
        cin >> x[i] >> y[i] >> c;
        dx[i] = c == 'L' ? -1 : c == 'R' ? 1 : 0;
        dy[i] = c == 'U' ? 1 : c == 'D' ? -1 : 0;
    }
    double ans = calc(0);
    for (double t : checkpoints(getxmin(1), getxmin(0), getxmin(-1)))
        ans = min(ans, calc(t));
    for (double t : checkpoints(getxmax(1), getxmax(0), getxmax(-1)))
        ans = min(ans, calc(t));
    for (double t : checkpoints(getymin(1), getymin(0), getymin(-1)))
        ans = min(ans, calc(t));
    for (double t : checkpoints(getymax(1), getymax(0), getymax(-1)))
        ans = min(ans, calc(t));
    printf("%.16f\n", ans);
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n) ;i++)

using namespace std;
using p=pair<int,int>;
typedef long long ll;

int main() {
  vector<vector<int>>a(3,vector<int>(3));
  rep(i,3){
    rep(j,3){
      cin >> a[i][j];
    }
  }
  int n;
  cin >> n;
  vector<vector<int>>c(3,vector<int>(3));
  rep(i,n){
    int b;
    cin >>b;
    rep(i,3){
      rep(j,3){
        if(a[i][j]==b){
          c[i][j]++;
        }
      }
    }
  }
  if(c[0][0]!=0&&c[0][1]!=0&&c[0][2]!=0){
    cout << "Yes" << endl;
  }
  else if(c[1][0]!=0&&c[1][1]!=0&&c[1][2]!=0){
    cout << "Yes" << endl;
  }
  else if(c[2][0]!=0&&c[2][1]!=0&&c[2][2]!=0){
    cout << "Yes" << endl;
  }
  else if(c[0][0]!=0&&c[1][0]!=0&&c[2][0]!=0){
    cout << "Yes" << endl;
  }
  else if(c[0][1]!=0&&c[1][1]!=0&&c[2][1]!=0){
    cout << "Yes" << endl;
  }
  else if(c[0][2]!=0&&c[1][2]!=0&&c[2][2]!=0){
    cout << "Yes" << endl;
  }
  else if(c[0][0]!=0&&c[1][1]!=0&&c[2][2]!=0){
    cout << "Yes" << endl;
  }
  else if(c[0][2]!=0&&c[1][1]!=0&&c[2][0]!=0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }  

  return 0;

}




Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<62;
const int IINF = 1000000000;
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; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;


ll gcd(ll x, ll y){
    if (y==0) return x;
    else return gcd(y, x%y);
}


vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

struct Sieve {
  int n;
  vector<int> f, primes;
    Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};


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

    // 調和級数によりO(AlogA)で求まる。
    Sieve sieve(1e6);

    vector<ll> counter(10000005, 0);
    bool isOK = true;
    rep(i,N){
        auto P = sieve.factor(A[i]);

        for(auto p : P){
            if (counter[p.first] > 0){
                isOK = false;
            }
            counter[p.first] = p.second;
        }
    }

    if (isOK){
        cout << "pairwise coprime" << endl;
    }
    else{
        ll entire_gcd = A[0];
        for(int i = 1; i < N; i++){
            entire_gcd = gcd(entire_gcd, A[i]);
        }

        if (entire_gcd == 1){
            cout << "setwise coprime" << endl;
        }
        else{
            cout << "not coprime" << endl;
        }
    }
}


Measured memory_bytes: 93580
def add_ans(i,ans,circle):
    if circle[i] == 'o':
        if ans[i] == 'S':
            ans += ans[i-1]

        else:
            if ans[i-1] == 'S':
                ans += 'W'
            else:
                ans += 'S'
            
        
        
    if circle[i] == 'x':
        if ans[i] == 'W':
            ans += ans[i-1]
        
        else:
            if ans[i-1] == 'S':
                ans += 'W'
            else:
                ans += 'S'
            
    return ans
def check_last(ans,circle):
    if circle[0] == 'o':
        if ans[0] == 'S':
            last  = ans[1]

        else:
            if ans[1] == 'S':
                last = 'W'
            else:
                last = 'S'



    elif circle[0] == 'x':
        if ans[0] == 'W':
            last = ans[1]

        else:
            if ans[1] == 'S':
                last = 'W'
            else:
                last = 'S'
                
                
    if circle[-1] == 'o':
        if ans[-1] == 'S':
            first  = ans[-2]

        else:
            if ans[-2] == 'S':
                first = 'W'
            else:
                first = 'S'



    elif circle[-1] == 'x':
        if ans[-1] == 'W':
            first = ans[-2]

        else:
            if ans[-2] == 'S':
                first = 'W'
            else:
                first = 'S'
                
                
    if (last == ans[-1]) & (first == ans[0]):
        return 1
    else :
        return 0


flag = True
n = int(input())
circle = input()

ans_list = ['SS' , 'SW' , 'WS' , 'WW']
for ans in ans_list:
    for i in range(1,len(circle)-1):
        ans = add_ans(i,ans,circle)


    if check_last(ans , circle) == 1:
        print(ans)
        flag = False
        break

if flag:
    print('-1')

Measured memory_bytes: 3576
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<stdio.h>
#include<vector>
#include<map>
using namespace std;

int n;
int ans;
int d[100010];


int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	sort(d, d + n);
	n /= 2;
	ans = d[n] - d[n-1];


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

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

using namespace std;

#define ll long long
#define pb push_back
const int MAX (2e5+2);
#define debug2(x,y) cout << x << " " << y << "\n"

ll const mod  = 1e9+7;
vector<int>visited(MAX,0);
vector<vector<int>> adj(MAX);

int main() {
    int n,m,x,y,ans=0;
    cin >> n >> m;
    for(int i = 0; i < m ; i++){
        cin >> x >> y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    for(int i = 1; i <= n; i++){
        if(visited[i] == 1)
            continue;
        visited[i] = 1;
        queue<int>q;
        q.push(i);
        int cnt = 0;

        while(!q.empty()){
            int x = q.front();
            q.pop();
            cnt++;
            for(auto v : adj[x]){
                if(!visited[v]){
                    q.push(v);
                    visited[v] = 1;
                    // cout << v << " ";
                }
            }
        }
        ans = max(ans,cnt);
    }
    // for(int i = 1; i <= n; i++){
    //     cout << i << " -> ";
    //     for(auto j : adj[i]){
    //         cout << j << " ";
    //     }cout << "\n";
    // }
    cout << ans << "\n";
}






Measured memory_bytes: 15756
#include "bits/stdc++.h"

using namespace std;

int main() {
    int n; cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; i++) cin >> d[i];
    
    sort(d.begin(), d.end());
    int answer = d[n / 2] - d[n / 2 - 1];
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 768
#include <stdio.h>
#include <stdlib.h>

int stack[100], top;

void push(int x) {
  stack[++top] = x;
}

int pop() {
  return stack[top--];
}

int main(void) {
  int a, b;
  char op[1];
  top = 0;

  while(scanf("%s", op) != EOF) {
    if(op[0] == '+') {
      b = pop();
      a = pop();
      push(a + b);
    }
    else if(op[0] == '-') {
      b = pop();
      a = pop();
      push(a - b);
    }
    else if(op[0] == '*') {
      b = pop();
      a = pop();
      push(a * b);
    }
    else {
      push(atoi(op));
    }
  }
  printf("%d\n", pop());
  return 0;
}

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

int main(){

        vector<int> v;
        string s;
        cin >> s;
        rep(i,s.length()){
                switch(s[i]) {
                case '0':
                        v.pb(0); break;
                case '1':
                        v.pb(1); break;
                case 'B':
                        if(v.size() != 0) {v.pop_back();}
                        break;
                }
        }
        rep(i,v.size()){
                cout << v[i];
        }
        cout << endl;
        return 0;
}


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

const int N = 1e5 + 7;
int a[N];

signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif

    map <int, int> d;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        ++d[a[i]];
    }   

    if (d[0] == n) {
        cout << "Yes\n";
        exit(0);
    }   
    
    sort(a, a + n);
    int t = unique(a, a + n) - a;

    if (a[0] == 0) {
        if (t == 2 && d[a[1]] == d[0] * 2) {
            cout << "Yes\n";
        }   
        else {
            cout << "No\n";
        }   
        exit(0);
    }   

    if (t == 3 && d[a[0]] == d[a[1]] && d[a[0]] == d[a[2]] && (a[0] ^ a[1]) == a[2]) {
        cout << "Yes\n";
    }   
    else {
        cout << "No\n";
    }   
}   

Measured memory_bytes: 4224
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  long long n;
  std::cin >> n;
  std::vector<int> l(n);
  for (int i = 0; i < n; i++)std::cin >> l[i];
  sort(l.begin(),l.end());


  int ans=0;
  for (int i = 0; i < n; i++) {
    for (int i2 = i+1; i2 < n; i2++) {
      if(i2==n-1)break;
      for (int i3 = i2+1; i3 < n; i3++) {
        if(l[i3]>l[i]+l[i2])break;
        if(l[i]<l[i2]+l[i3] && l[i2]<l[i]+l[i3] && l[i3]<l[i]+l[i2]){
          ans++;
        }
      }
    }
  }

  std::cout << ans << '\n';



return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		String[] strs = str.split(" ");

		int a = Integer.parseInt(strs[0]);
		int b = Integer.parseInt(strs[1]);

		int d = a / b;
		int r = a % b;
		double f = (double)a / (double)b;



		System.out.printf("%d %d %f",d, r, f);
		sc.close();


	}

}



Measured memory_bytes: 26436
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>
#include <sstream>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <math.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	std::string a, b;
	std::cin >> a >> b;
	
	std::stringstream ss;
	ss << a << b;
	int v;
	ss >> v;
	int sq = (int)sqrt(v);
	if (sq * sq == v) {
		std::cout << "Yes\n";
	} else {
		std::cout << "No\n";
	}
}


Measured memory_bytes: 256
// E - Almost Everywhere Zero
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
string N;
int K;
int lt = 0, eq = 1;//lt: <, eq: =
int dp[101][2][4];// digit DP, [|N|+1: 1 origin][lt|eq][k:0~3]

int main(){
	cin>>N>>K;
	int dn = N.size();
	dp[0][eq][0] = 1;
	rp(i,0,dn){
		int di = N[i] - '0';
		rp(k,0,K+1){
			rp(dk,0,2){
				int ltk = 0, eqk = 0;
				if(dk==0) ltk = 1, eqk = di?1:0;
				else if(k) ltk = 9, eqk = max(0,di-1);
				dp[i+1][lt][k] += dp[i][lt][k-dk] * ltk + dp[i][eq][k-dk] * eqk;
			}
			if(dp[i][eq][k] & k+(di>0)<4) dp[i+1][eq][k+(di>0)] = 1;
		}
	}
	cout<< dp[dn][lt][K] + dp[dn][eq][K] <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
#include <array>
#include <bitset>
#include <cstdlib>

using int64 = long long;

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

    int N;
    std::cin >> N;

    int64 sum_s = 0,
          ans = 0;

    std::priority_queue<int64> pque;
    for (int i = 0; i < N; i++) {
        int64 x, s;
        std::cin >> x >> s;

        pque.push(x - sum_s);

        sum_s += s;

        ans = std::max(ans, sum_s - x + pque.top());
    }
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3444
a,b=map(int,input().split())
A=[]
B=[]
for i in range(a):
	A.append([int(j) for j in input().split()])

for i in range(b):
	B.append(int(input()))


for i in range(a):
	s=0
	for j in range(b):
		s+=A[i][j]*B[j]
	print(s)

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

#define pq priority_queue
#define mp make_pair
#define cauto const auto &

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define clr(ar, val) memset(ar, val, sizeof(ar))

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

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 (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T = int> T in() {
    T x;
    cin >> x;
    return (x);
}
template <class T> void print(T &x) {
    cout << x << '\n';
    return;
}

template <class T> long long iterate_sized_subset(T &comb) {
    T x = comb & -comb, y = x + comb;
    return ((comb & ~y) / x) >> 1 | y;
}

struct union_find {
    int size;
    vector<int> par;
    union_find(int N) : size(N), par(N) { REP(i, N) par[i] = i; }
    int root(int x) {
        if (par[x] == x)
            return x;
        else {
            par[x] = root(par[x]);
            return par[x];
        }
    }
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)
            return;
        else {
            par[rx] = ry;
            return;
        }
    }
    bool same(int x, int y) { return root(x) == root(y); }
};

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

int main() {
    int n;
    double a, ans=0;
    cin>>n;
    for (int i = 0; i < n; i++) {
        cin>>a;
        a=1/a;
        ans+=a;
    }
    cout<<1/ans<<endl;
}


Measured memory_bytes: 256
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
road = []
for m in range(M):
    a, b = list(map(int, input().split()))
    road.append((a - 1, b - 1))

check_h = [1] * N

for i in range(len(road)):
    a, b = road[i]
    if H[a] <= H[b]:
        check_h[a] = 0
    if H[b] <= H[a]:
        check_h[b] = 0
print(sum(check_h))

Measured memory_bytes: 86492
#include<stdio.h>

int n;
int k;
int h[100100];
int c[100100];

int min(int a, int b){
    if(a<b) return(a);
    return(b);
}

int abs(int a){
    if(a<0) return(-1*a);
    return(a);
}

int main(void){
    scanf("%d %d",&n,&k);
    for(int i=0; i<n; i++){
        scanf("%d",h+i);
    }
    c[0]=0;
    for(int i=1;i<n;i++){
        c[i]=1000000000;
    }
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n && j<i+k+1; j++){
            c[j]=min(c[j],c[i]+abs(h[i]-h[j]));
        }
    }
    printf("%d",c[n-1]);
}

Measured memory_bytes: 896
s=input()
dp0=[0]*(len(s)+1)
dp1=[0]*(len(s)+1)
dp1[0]=1
for i in range(1,len(s)+1):
  n=int(s[i-1:i])
  dp0[i]=min(dp0[i-1]+n,dp1[i-1]+10-n)
  dp1[i]=min(dp0[i-1]+(1 if n+1==10 else n+1),dp1[i-1]+10-n-1)
print(dp0[-1])

Measured memory_bytes: 83232
#include <cstdio>
#include <cstring>
using namespace std;
#define def 1000

int main(void){
  int i,j,n,len,tmp,max,digits,A[def],B[def],C[def];
  char str[def];

  fgets(str,sizeof(str),stdin);
  sscanf(str,"%d",&n);
  for(i=0;i<n;i++){
    memset(A,0,sizeof(A));
    memset(B,0,sizeof(B));
    memset(C,0,sizeof(C));
    tmp = 0;
    digits = 0;
    /*for(j=0;j<5;j++){
      printf("%d",A[j]);
    }
    printf("\n");*/
    fgets(str,sizeof(str),stdin);
    len = strlen(str)-2;
    max = len;
    digits = max+1;
    //printf("%d\n",len);
    for(j=len;j>=0;j--){
      A[len-j] = str[j]%48;
      //printf("%d",A[len-j]);
    }
    //printf("\n");
    fgets(str,sizeof(str),stdin);
    len = strlen(str)-2;
    if(len>max){
      max = len;
      digits = max+1;
    }
    for(j=len;j>=0;j--){
      B[len-j] = str[j]%48;
      //printf("%d",A[len-j]);
    }
    for(j=0;j<=max;j++){
      //printf("%d ",(A[j] + B[j] + tmp)%10);
      C[max+1-j] = (A[j] + B[j] + tmp)%10;
      tmp = (A[j] + B[j] + tmp)/10;
      //printf("%d\n",tmp);
      if(j==max && tmp!=0){
        C[0] = tmp;
        digits += 1;
      }
      if(digits>80){
        printf("overflow");
        goto end;
      }
      //printf("%d",B[len-j]);
    }
    for(j=0;j<=max+1;j++){
      if(j==0 && C[j]==0) continue;
      printf("%d",C[j]);
    }
    end:;
    printf("\n");
    //Calculation(A,B);
  }
  return 0;
}

Measured memory_bytes: 2588
#include <iostream>
using namespace std;
int main(void){
	long long int n,a[200010],i,ans=0;
	cin >> n;
	for (i=0;i<n;i++) {
		cin >> a[i];
	}
	for (i=1;i<n;i++) {
		if (a[i] < a[i-1]) {
			ans += (a[i-1]-a[i]);
			a[i] = a[i-1];
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 5124
import java.util.Scanner;
import java.io.IOException;

class Main{
  public static void main(String... args)throws IOException{
    Scanner scan = new Scanner(System.in);
    String str = scan.next();
    int N = scan.nextInt();
    char[] ch = str.toCharArray();
    int i;
    for(i=0;i<str.length()-1;i++){
      int diff = 'z' - ch[i];
      if(ch[i] != 'a' && N > diff ) {
        ch[i] = 'a';
        N-=(diff+1);
      }
    }
    ch[i] += (N%26);
    if(ch[i] > 'z') ch[i] -=26;
    for(char a: ch) System.out.print(a);
    System.out.println();


  }
}


Measured memory_bytes: 35392
N, K = map(int, input().split())
a = list(map(int, input().split()))
mod = 10**9 + 7
dp = [[0]*(K+1) for i in range(N+1)]

for i in range(K+1):
    dp[0][i] = 1

for i in range(1, N+1):
    v = a[i-1]
    dp[i][0] += dp[i-1][0]
    dp[i][0] %= mod
    for j in range(1,K+1):
        if j-1-v >= 0:
            dp[i][j] += (dp[i][j-1] + dp[i-1][j] - dp[i-1][j-1-v]) % mod
        else:
            dp[i][j] += (dp[i][j-1] + dp[i-1][j]) % mod
if K>0:            
    ans = (dp[N][K] - dp[N][K-1]) % mod
else:
    ans = dp[N][K] % mod
print(ans)

Measured memory_bytes: 146732
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     .      '                    Udit Gupta @luctivud         ,              
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                            ##      ##  #######  # #  ######
                            ##      ##  ##   ##  ###    ##
                            ##      ##  ##    #  # #    ##
                            ####### ##  #######  # #    ##
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| WORSHIPPER OF GREED |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

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

const long long int MODPRIME {1000000007};

#define FASTINPUTOUTPUTLIKELIGHT()    ios_base::sync_with_stdio(false);
#define TESTCASES()                   long long int TestCases; cin>>TestCases; while(TestCases--)
#define mems(arr,val)                 memset((arr), val, sizeof((arr)))
#define endl                          "\n"

// ///////////////////////////////////////////////////////////////////////////////////////////////
//               : AREA TO DEFINE ALL THE HELPER FUNCTIONS USED IN THE PROGRAM :                //
// ///////////////////////////////////////////////////////////////////////////////////////////////


// ///////////////////////////////////////////////////////////////////////////////////////////////
//                                 : MAIN PROGRAM STARTS HERE :                                 //
// ///////////////////////////////////////////////////////////////////////////////////////////////

void solve() {
    long int n;
    cin >> n;
    long int count[n] = {0};

    for (long int i=0; i<n-1; i++) {
        long int x;
        cin >> x;
        count[x-1] += 1;
    }

    for (long int i=0; i<n; i++) {
        cout << count[i] << endl;
    }
    
    return;
}

signed main() {
    FASTINPUTOUTPUTLIKELIGHT()
    // TESTCASES()
        solve();
    return 0;
}
/*
THE LOGIC AND APPROACH WAS DEVELOPED BY ME @luctivud.
SOME PARTS OF THE CODE HAS BEEN TAKEN FROM WEBSITES LIKE::
(I Own the code if no link is provided here or I may have missed mentioning it)
PLEASE DO NOT PLAGIARISE.
*/

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

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

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

const int MAX = 1e5 + 5;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int N, A[MAX];

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

    set<P> S;
    rep(i, N){
        S.insert( P(A[i], i));
    }

    auto itr = S.begin();
    rep(i, N){
        cout << (*itr).second + 1 << " ";
        itr++;
    }
}

Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
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 (b<a) { a=b; return 1; } return 0; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;


int main(){

string a,b,c;
cin >> a >> b >> c;

if(a.at(a.size()-1)==b.at(0) and b.at(b.size()-1)==c.at(0))cout << "YES" << endl;
else cout << "NO" << endl;
return 0;

}



Measured memory_bytes: 256
N,x = map(int,input().split())
A = sorted(list(map(int,input().split())))
if x>=2*sum(A):
    print(0)
else:
    ind = N
    for i in range(N):
        x -= A[i]
        if x<0:
            ind = i
            break
    if ind==N and x>0:
        A = sorted(A,reverse=True)
        for i in range(N):
            x -= A[i]
            if x<0:
                ind -= 1
                break
    print(ind)

Measured memory_bytes: 61964
N = int(input())
a = list(map(int,input().split()))

if N == 2:
  print(abs(a[0]-a[1]))
else:
  s = sum(a)
  i = 0
  b = 0
  for i in range(N):
    if b<s/2:
      b += a[i]
    else:
      b = b-a[i-1]
      c = a[i-1]
      break
  h = s-b-c
  if h>b:
    print(b+c-h)
  elif b>h:
    print(h+c-b)
  else:
    if N%2==0:
      print(0)
    else:
      print(c)

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

int main()
{
  string s;
  cin >> s;
  bool can = true;
  sort(s.begin(), s.end());
  
  
  for (int i=0; i<s.size()-1; i++) {
    if (s.at(i) == s.at(i+1)) {
      can = false;
      break;
    }
  }
  
  if (can) cout << "yes" << endl;
  else cout << "no" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>
#include <bitset>
#include <numeric>
#ifdef DEBUG
#include "./Lib/debug.hpp"
#else
#define dump(...)
#pragma GCC optimize ("O3")
template<class T>inline auto d_val(T a, T b) { return a; }
#endif

/* (=＾o＾=) */
#define int ll

/* macro */
#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define REPI2(it,b,e) for(auto it = (b); it != (e); ++it)
#define REPI(it,c) REPI2(it, (c).begin(), (c).end())
#define RREPI(it,c) REPI2(it, (c).rbegin(), (c).rend())
#define REPI_ERACE2(it, b, e) for(auto it = (b); it != (e);)
#define REPI_ERACE(it, c) REPI_ERACE2(it, (c).begin(), (c).end())
#define ALL(x) (x).begin(),(x).end()
#define cauto const auto&
/* macro func */
#define SORT(x) do{sort(ALL(x));}while(false)
#define RSORT(x) do{sort((x).rbegin(),(x).rend());}while(false)
#define UNIQUE(v) do{v.erase( unique(v.begin(), v.end()), v.end() );}while(false)
#define MAX(x,y) do{x = std::max(x,y);}while(false)
#define MIN(x,y) do{x = std::min(x,y);}while(false)
#define BR do{cout<<"\n";}while(false)

/* type define */
using ll = long long;
using PAIR = std::pair<ll, ll>;
using VS = std::vector<std::string>;
using VL = std::vector<long long>;
using VVL = std::vector<VL>;
using VVVL = std::vector<VVL>;
using VD = std::vector<double>;

/* using std */
using std::cout;
constexpr char endl = '\n';
using std::cin;
using std::sort;
using std::pair;
using std::string;
using std::stack;
using std::queue;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::unordered_multiset;
using std::multiset;
using std::bitset;
using std::priority_queue;

/* constant value */
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;

/* Initial processing  */
struct Preprocessing { Preprocessing() { std::cin.tie(0); std::ios::sync_with_stdio(0); }; }_Preprocessing;

/* define hash */
namespace std { template <>	class hash<std::pair<ll, ll>> { public:	size_t operator()(const std::pair<ll, ll>& x) const { return hash<ll>()(1000000000 * x.first + x.second); } }; }

/* input */
template<class T> std::istream& operator >> (std::istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }

//=============================================================================================


signed main() {
	ll n;
	cin >> n;
	cout << 3 * n * n << endl;
}

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

int main(){
	long long N;
	long long K;
	cin>>N>>K;
	long long ans;
	ans=pow(N/K,3);
	if(K%2==0){
		ans+=pow((N+K/2)/K,3);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var NMC = Sarray();
            var N = NMC[0];
            var M = NMC[1];
            var C = NMC[2];
            var Bi = Sarray();
            var ans = 0L;
            for (var i = 0; i < N; ++i)
            {
                var Ai = Sarray();
                var sum = 0L;
                for(var j=0;j<M;++j)
                {
                    sum += Ai[j] * Bi[j];
                }
                if (0 < sum + C)
                {
                    ++ans;
                }
            }
            WriteLine(ans);

            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
#include "bits/stdc++.h"
using namespace std;

const int maxn = 2e5 + 5;
long long arr[maxn];
int solve(int n) 
{ 
    multiset<long long> last; 
    for (int i = 0; i < n; i++) { 
        multiset<long long>::iterator it = last.lower_bound(arr[i]); 
        if (it == last.begin()) 
            last.insert(arr[i]); 
  
        else { 
            it--;
            last.erase(it); 
            last.insert(arr[i]); 
        } 
    } 
    return last.size();
} 

int main(int argc, char const *argv[])
{
//    freopen("in.txt", "r", stdin);
    int n;
    scanf("%d", &n);
    int ans = 0;
    for(int i=0; i<n; i++){
        scanf("%lld", &arr[i]);
    }cout << solve(n) <<endl;

    return 0;
}

Measured memory_bytes: 5760
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;

  map<ll, ll> mp;

  rep(i, n - 1) {
    ll a;
    cin >> a;
    a--;
    mp[a]++;
  }
  rep(i, n) {
    ll ans;
    if (mp.count(i) == 0)
      ans = 0;
    else
      ans = mp[i];
    cout << ans << endl;
  }
};


Measured memory_bytes: 16120