akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
/*#define LL long long
#define DB long double*/
using namespace std;
//#define P 998244353
//inline int ad(int x,int y){return (x+y>=P)?(x+y-P):(x+y);}
//inline int mt(int x,int y){return 1ll*x*y%P;}
//inline void mo(int &x){x=(x>=P)?(x-P):x; x=(x<0)?(x+P):x;}
//template<typename T>inline void ckmx(T &x,T y){x=max(x,y);}
//template<typename T>inline void ckmi(T &x,T y){x=min(x,y);}
template<typename T>void rd(T &x){
	x=0;int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if (c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-48;
	x*=f;
}
int n;
int x[200010],y[200010];
int id[200010];
int fa[200010],cnt[200010];
int gtf(int x){
	if(fa[x]==x) return x;
		else return fa[x]=gtf(fa[x]);
}
void mg(int x,int y){
	x=gtf(x); y=gtf(y);
	fa[x]=y;cnt[y]+=cnt[x];
}
int q[200010],tp=0,mi;
int main(){
	rd(n);
	for(int i=1;i<=n;++i)
		rd(x[i]),rd(y[i]),id[x[i]]=i,fa[i]=i,cnt[i]++;
	mi=id[1];
	for(int i=2;i<=n;++i){
		int nw=id[i];
		if(y[nw]<y[mi]) q[++tp]=mi,mi=nw;
		else {
			while(tp>0&&y[nw]>y[q[tp]]) mg(nw,q[tp]),--tp;
			mg(nw,mi);
		}
	}
	for(int i=1;i<=n;++i)
		printf("%d\n",cnt[gtf(i)]);
	return 0;
}


Measured memory_bytes: 8288
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;
	vector<bool> ship1(N + 1, false);
	vector<bool> shipN(N + 1, false);
	rep(i, M)
	{
		int tmp1, tmp2;
		cin >> tmp1;
		cin >> tmp2;
		if (tmp1 == 1)ship1[tmp2] = true;
		if (tmp2 == N)shipN[tmp1] = true;
	}
	rep(i, N + 1)
	{
		bool exist = ship1[i] && shipN[i];
		if (exist)
		{
			co("POSSIBLE");
			return 0;
		}
	}
	co("IMPOSSIBLE");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
int main()
{
    int n,k;

    std::cin >> n >> k;
    std::vector<int> vec1(n);
    vec1.resize (n);

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

    std::sort(vec1.begin(),vec1.end());
    
    int a=0;
    for(int i=0;i<k;i++){
        a=a+vec1[i];
    }
    std::cout << a << std::endl;
    return 0;
}


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

using namespace std;

#define INF 210000000
#define int long long

int gcd(int a, int b) {
  int amari = a % b;
  int c = b;
  if (amari == 0) {
    return b;
  } else {
    return gcd(b, amari);
  }
}

int lcm(int a, int b) { return a * b / gcd(a, b); }

signed main() {
		int a,b,c;
		cin >> a >> b >> c;
		int sum = a + b + c;
		int ma = max(a,b);
		ma = max(ma,c);
		int ans = 0;
		if((ma * 3 - sum)%2 == 0) ans = (ma * 3 - sum) / 2;
		else ans = (ma * 3 - sum + 3) / 2;
		cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            solve(in);
        }
    }

    private static void solve(Scanner in) {
        while (true) {
            int H = in.nextInt(), W = in.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    System.out.print((i + j) % 2 == 0 ? "#" : ".");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}

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

int main() {
  int x,y,z,n,ans;
  cin >> x >> y >> z;
  n = x/(y+z);
  ans = 0;
  for(int i=0; i<=n;i++){
    if(i*(y+z) +z <= x){
      ans = i;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mem(a,x) memset(a,x,sizeof(a))
#define lp(k,a) for(int k=1;k<=a;k++)
#define lp0(k,a) for(int k=0;k<a;k++)
#define lpn(k,n,a) for(int k=n;k<=a;k++)
#define lpd(k,n,a) for(int k=n;k>=a;k--)
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d %d",&a,&b)
#define ll long long
#define MAX 100000

using namespace std;

int n,m;
ll a[100010];
char str[100010];

ll x,y;

int main()
{
    //freopen("in.txt","r",stdin);
    cin>>n;
    lp(i,n)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    x=0; y=0;
    lp(i,n-1)
    {
        if(a[i]==a[i+1])
          {
              x=max(x,a[i]);
              i++;
          }
    }
    //cout<<x<<endl;
    lp(i,n-1)
    {
        if(a[i]==x)
          {
              a[i]=0;
              a[i+1]=0;
              break;
          }
    }
    lp(i,n-1)
    {
        if(a[i]==a[i+1])
          {
              y=max(y,a[i]);
              i++;
          }
    }
    cout<<x*y<<endl;
    return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3


def next_line():
    return input()


def next_int():
    return int(input())


def next_int_array_one_line():
    return list(map(int, input().split()))


def next_int_array_multi_lines(size):
    return [int(input()) for _ in range(size)]


def next_str_array(size):
    return [input() for _ in range(size)]


def main():
    r, c, k = map(int, input().split())
    dp = [[[0] * (c+1) for i in range(r+1)] for i in range(4)]
    v = [[0] * (c+1) for i in range(r+1)]
    for i in range(k):
        row, col, val = map(int, input().split())
        v[row][col] = val

    for row in range(1, r + 1):
        for col in range(1, c + 1):
            for num in range(0, 4):
                if num == 0:
                    dp[num][row][col] = dp[3][row-1][col]  # simple down
                else:
                    
                    dp[num][row][col] = max(dp[num-1][row][col],  # str
                                            dp[num][row][col-1],  # right x
                                            dp[3][row-1][col] + \
                                            v[row][col],  # down o
                                            dp[num-1][row][col-1] + \
                                            v[row][col],  # right o
                                            )
    print(dp[3][r][c])


if __name__ == '__main__':
    main()


Measured memory_bytes: 430016
#include <iostream>
#include <algorithm>
#include <functional>

inline void
rep(int n, std::function<void(int)> f) {
    for (int i = 0; i < n; i++) {
        f(i);
    }
};

typedef std::pair<int, int> P;

int main() {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	
	int a, b, c;
	
	std::cin >> a >> b >> c;
	std::cin.ignore();

	if (a == b && b == c) {
		std::cout << "Yes" << '\n'; 
	}
	else {
		std::cout << "No" << '\n'; 
	}
	return 0;
}



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

const int N = 50;
int a[N], b[N], c[N], d[N], A[N];
int n, m, q, ret = 0;
 
void search(int pos, int low) {
  if (pos == n) {
    int cur = 0;
    for (int i = 0; i < q; ++i) {
      if (A[b[i]] - A[a[i]] == c[i])
        cur += d[i];
    }
    ret = max(cur, ret);
    return;
  }
  for (int i = low; i <= m; ++i) {
    A[pos] = i;
    search(pos + 1, i);
  }
}
 
int main() {
  cin >> n >> m >> q;
  for (int i = 0; i < q; ++i) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    --a[i]; --b[i];
  }
  search(0, 1);
  cout << ret << endl;
  return 0;
}


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



int main(){
	int n,s;
	while(cin>>n>>s&&(n||s)){
		int dp[11][11][101]={};
		dp[0][0][0] = 1;
		
		for(int i=1;i<=n;i++){
			for(int j=1;j<=10;j++){
				rep(k,s+1){
					for(int l=1;l<=j;l++){
						if(k-(j-1)<0)continue;
						dp[i][j][k]+=dp[i-1][j-l][k-(j-1)];
					}
				}
			}
		}
		int ans = 0;
		rep(i,11) ans += dp[n][i][s];
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 3108
// ARC085
// D - ABS

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

int N, Z, W;
int a[2];

int main() {
    cin >> N >> Z >> W;
    for (int i = 0; i < N; i++) {
        cin >> a[i % 2];
    }

    if (N == 1) {
        cout << abs(a[0] - W) << endl;
        return 0;
    }

    cout << max(abs(a[(N - 1) % 2] - W), abs(a[(N - 1) % 2] - a[(N - 2) % 2]))
         << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A(0), B(0);
  cin >> A >> B; 

  int nd[5];
  int cnt(0);
  for(int n = A; n <= B; n++)
  {
    int ntmp = n;
    for(int i = 0; i < 5; i++)
    {
      nd[i] = ntmp % 10;
      ntmp = (ntmp - nd[i]) / 10;
    }
    if( nd[0] == nd[4] && nd[1] == nd[3] )
    {
      cnt++;
    }	
  }
  cout << cnt << endl;
}
 

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

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

  int x=0;
  int y=N;
  string z="No";

  while(y>10){
    x+=y%10;
    y/=10;
  }
  x+=y;
  if (N%x==0)
  z = "Yes";

  cout <<z<<endl;

}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define fo(i, n) for(int i = 1; i <= n; ++i)
#define rep(i, a, b) for(int (i) = (a); (i) < (b); ++(i))

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 200200;
const int mod = 1e9 + 7;
const ll INF = 1e18;

int n, a[N];
int ans;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	fo(i, n)
		cin >> a[i];
	for(int i = 1; i <= n;)
	{
		while(i + 1 <= n && a[i + 1] == a[i]) ++i;
		if(a[i + 1] > a[i])
			while(i + 1 <= n && a[i + 1] >= a[i]) ++i;
		else                                           	
			while(i + 1 <= n && a[i + 1] <= a[i]) ++i;
		++i;
		ans++;
	}
	cout << ans;
	
	return 0;	
}

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

//----------------------------//
//約数の列挙
//----------------------------//
ll isPrime(ll x) {
  ll i;
  if(x < 2) return 0;
  else if (x == 2)  return 1;   //2は素数
  if (x % 2 == 0) return 0;     //2以外の偶数は素数ではない
  for(i = 3; i*i <= x; i += 2){ //P <= √x を満たす素因数 p を持つなら素数ではない
    if (x % i == 0) return 0;
  }
  return 1;
}

ll yaku(ll n){
  ll MXi = 1;
  for(ll i = 1; i*i <= n+1; ++i){
    if(n%i == 0) {
      //a.push_back(i);
      MXi = i;
      //a.push_back(n/i);
    }
  }
  return MXi;

  // sort(ALL(a));
  // for(auto x: a) cout << x << endl;
  //
  // return 0;
}


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

  if(isPrime(n)) {
    cout << n - 1 << endl;
    return 0;
  }

  ll a, b;
  a = yaku(n);
  b = n/a;
  ll ans = a + b -2;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rbf(a, x) for (auto& a : x)
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define drep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define Maxe(x) *max_element(all(x))
#define Mine(x) *min_element(all(x))
#define Size(x) ((ll)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
#define Fi first
#define Se second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

    template<typename Num>
        constexpr Num mypow(Num a, long long b) {
            if(b==0)return 1;
            if (a==0)return 0;
            Num x = 1;
              while (b > 0) {
                if(b & 1)x*=a;
                a*=a;
                b >>= 1;
              }
              return x;
        }

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo
//mint,dijkstra,gyakugen

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        map<ll,ll> m;
        ll n;
        cin>>n;
        vl A(n);
        rep(i,n){
            cin>>A[i];
            m[i+A[i]]++;
        }
        ll res=0;
        rep(i,n){
            res+=m[i-A[i]];
        }
        cout<<res<<endl;
    }

Measured memory_bytes: 27464
#include <iostream>
#include <algorithm>
#include <cmath>
typedef long long ll;

using namespace std;

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

  ll ans = 0;
  ll sum_cake[N];
  for (int i = 0; i < N; i++) sum_cake[i] = x[i] + y[i] + z[i];
  sort(sum_cake, sum_cake + N, greater<ll>());
  ll sum_val = 0;
  for (int i = 0; i < M; i++) sum_val += sum_cake[i];
  ans = max(ans, sum_val);

  for (int i = 0; i < N; i++) sum_cake[i] = x[i] + y[i] - z[i];
  sort(sum_cake, sum_cake + N, greater<ll>());
  sum_val = 0;
  for (int i = 0; i < M; i++) sum_val += sum_cake[i];
  ans = max(ans, sum_val);

  for (int i = 0; i < N; i++) sum_cake[i] = x[i] - y[i] + z[i];
  sort(sum_cake, sum_cake + N, greater<ll>());
  sum_val = 0;
  for (int i = 0; i < M; i++) sum_val += sum_cake[i];
  ans = max(ans, sum_val);

  for (int i = 0; i < N; i++) sum_cake[i] = x[i] - y[i] - z[i];
  sort(sum_cake, sum_cake + N, greater<ll>());
  sum_val = 0;
  for (int i = 0; i < M; i++) sum_val += sum_cake[i];
  ans = max(ans, sum_val);

  for (int i = 0; i < N; i++) sum_cake[i] = -x[i] + y[i] + z[i];
  sort(sum_cake, sum_cake + N, greater<ll>());
  sum_val = 0;
  for (int i = 0; i < M; i++) sum_val += sum_cake[i];
  ans = max(ans, sum_val);

  for (int i = 0; i < N; i++) sum_cake[i] = -x[i] + y[i] - z[i];
  sort(sum_cake, sum_cake + N, greater<ll>());
  sum_val = 0;
  for (int i = 0; i < M; i++) sum_val += sum_cake[i];
  ans = max(ans, sum_val);

  for (int i = 0; i < N; i++) sum_cake[i] = -x[i] - y[i] + z[i];
  sort(sum_cake, sum_cake + N, greater<ll>());
  sum_val = 0;
  for (int i = 0; i < M; i++) sum_val += sum_cake[i];
  ans = max(ans, sum_val);

  for (int i = 0; i < N; i++) sum_cake[i] = -x[i] - y[i] - z[i];
  sort(sum_cake, sum_cake + N, greater<ll>());
  sum_val = 0;
  for (int i = 0; i < M; i++) sum_val += sum_cake[i];
  ans = max(ans, sum_val);
  
  cout << ans << endl;
}


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

int main(void){
    // Your code here!
    long long int x, y;
    cin >> x >> y;
    int count = 0;
    while(x <= y) {
        x *= 2;
        count++;
    }
    //cout << log2(floor(y/x));
    cout << count << endl;
}


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

typedef complex<int> point;
typedef vector<point> polygon;

polygon read_polygon() {
	int m;
	cin >> m;
	polygon res(m);
	for (auto& p : res) {
		int x, y;
		cin >> x >> y;
		p = point(x, y);
	}
	point offset = res[0];
	for (auto& p : res) p -= offset;
	return res;
}

bool same(const polygon& target, polygon pol) {
	for (int j = 0; j < 2; j++) {
		for (int i = 0; i < 4; i++) {
			if (target == pol) return true;
			for (auto& p : pol) {
				p *= point(0, -1);
			}
		}
		pol = polygon(pol.rbegin(), pol.rend());
		point offset = pol[0];
		for (auto& p : pol) p -= offset;
	}
	return false;
}

int main() {
	int n;
	while (cin >> n, n) {
		polygon target = read_polygon();
		vector<polygon> pols(n);
		for (auto& p : pols) p = read_polygon();
		for (int i = 0; i < n; i++) {
			if (same(target, pols[i])) {
				cout << i + 1 << endl;
			}
		}
		cout << "+++++" << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
using namespace std;

const int INF = 1e+8; 
const int MAX_N = 14;
// 入力
int n;
string v[MAX_N];

// rm[i] := 文字列 v[i] を使わないかどうか.
bool rm[MAX_N];
// g[i][j] := v[i] => v[j] と連結するときに増える文字数.
int g[MAX_N][MAX_N];
// dp[s][i] := 使った文字列の集合s, 最後に使った文字列 v[i] のときの最小の文字列の長さ
int dp[1<<MAX_N][MAX_N];

// 初期化
void init(){
	for(int i=0 ; i < MAX_N ; i++ ){
		rm[i] = false;
		for(int j=0 ; j < MAX_N ; j++ ){
			g[i][j] = 0;
		}
	}
	for(int i=0 ; i < (1<<MAX_N) ; i++ ){
		for(int j=0 ; j < MAX_N ; j++ ){
			dp[i][j] = INF;
		}
	}
}

// 文字列 s が 文字列 t を含んでいるかどうか.
bool is_subset(const string& s, const string& t){
	return ( s.find(t,0) != string::npos );
}

// 文字列 s+t とつなげたとき, s より何文字増えるか返す
int check(string s, string t){
	if( s == t ){
		return 0;
	}
	
	for(int i=0 ; i < min(s.size(),t.size()) ; i++ ){
		bool f = true;
		for(int j=0 ; j < t.size() ; j++ ){
			int k = i + j + (s.size() - t.size());
			if( s.size() < t.size() ){
				k = i + j;
			}
			
			if( k >= s.size() ){
				break;
			}
			if( s[k] != t[j] ){
				f = false;
				break;
			}
		}
		if( f ){
			if( s.size() > t.size() ){
				return i;
			}else{
				return t.size() + i - s.size();
			}
		}
	}
	return t.size();
}

int solve(){
	// 任意の i , j について文字列を完全に含むものがあるか調べる
	for(int i=0 ; i < n ; i++ ){
		for(int j=0 ; j < n ; j++ ){
			if( i == j ) continue;
			
			if( is_subset(v[i],v[j]) ){
				rm[j] = true;
			}
		}
	}
	// 完全に含まれている文字列を取り除く
	vector<string> vs;
	for(int i=0 ; i < n ; i++ ){
		if( rm[i] ) continue;
		vs.push_back( v[i] );
	}
	
	if( vs.size() == 1 ){
		return vs[0].size();
	}
	
	// 文字列 vs[i] + vs[j] とつなげたとき, vs[i]より何文字増えるか計算
	for(int i=0 ; i < vs.size() ; i++ ){
		for(int j=0 ; j < vs.size() ; j++ ){
			if( i == j ) continue;
			 
			g[i][j] = check( vs[i] , vs[j] );
		}
	}
	// 初期化
	for(int i=0 ; i < vs.size() ; i++ ){
		dp[1<<i][i] = vs[i].size();
	}
	
	for(int i=0 ; i < (1<<vs.size()) ; i++ ){
		for(int j=0 ; j < vs.size() ; j++ ){
			if( dp[i][j] != INF ){
				for(int k=0 ; k < vs.size() ; k++ ){
					// すでに訪れているとき
					if( i & (1<<k) ) continue;
					
					int next = i | (1<<k);
					if( dp[i][j] + g[j][k] < dp[next][k] ){
						dp[next][k] = dp[i][j] + g[j][k];
						for(int l=0 ; l < vs.size() ; l++ ){
							if( next & (1<<l) ) continue;
							
							dp[next|(1<<l)][l] = min( dp[next|(1<<l)][l] , dp[next][k] + g[k][l]);
						}
					}
				}
			}
		}
	}
	
	int ans = INF;
	for(int i=0 ; i < vs.size() ; i++ ){
		ans = min( ans , dp[(1<<vs.size())-1][i] );
	}
	return ans;
}

int main(){
	while( cin >> n , n ){
		init();
		for(int i=0 ; i < n ; i++ ){
			cin >> v[i];
		}
		cout << solve() << endl;
	}
}

Measured memory_bytes: 2116
S = gets.to_i
K = gets.to_i
 
ret = 0
idx = 0
S.to_s.split('').each do |s|
  ret = s
  hoge = s.to_i**(5*(10**15)) 
  idx += hoge
  if idx >= K
    break
  end
end
p ret.to_i

Measured memory_bytes: 1788
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	string s,p;
	cin>>s>>p;
	int a=s.size(),b=p.size();
	s+=s;
	for(int i=0;i<a;i++){
		if((s.substr(i,b))==p){
			cout<<"Yes"<<endl;
			break;
		}
		else if(i==(a-1)){
			cout<<"No"<<endl;
			break;
		}
	}
}


Measured memory_bytes: 3188
// ----- In the name of ALLAH, the Most Gracious, the Most Merciful -----

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

#define NINJA ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define dloop(i,n) for(int i=n-1;i>=0;i--)
#define iii tuple<int,int,int>
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define int long long
#define ld long double
#define pb push_back
#define endl "\n"
#define setbits __builtin_popcountll
#define mp map<int,int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007
#define inf (int)1e18

int32_t main(){
	NINJA;

	int n; cin >> n;
	vi a(n);

	fo(i,n) cin >> a[i];
	sort(a.rbegin(), a.rend());

	vi v;
	fo(i,n){
		v.pb(a[i]);
		if(i) v.pb(a[i]);
	}
	int ans =0 ;

	fo(i,n-1) ans += v[i];

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

Measured memory_bytes: 8956
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc, out);

		out.flush();
	}
	
	public static void solve(FastScanner sc, PrintWriter out) {
		String s = sc.next();
		
		if(s.charAt(0) != s.charAt(1) && s.charAt(1) != s.charAt(2) && s.charAt(0) != s.charAt(2)) out.println("Yes"); else out.println("No");
		
	}
	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 23124
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n, m := scanInt(), scanInt()
	bomb := make([]pii, n)
	for i := 0; i < n; i++ {
		bomb[i] = pii{scanInt(), scanInt()}
	}
	sort.Slice(bomb, func(i, j int) bool { return bomb[i].a < bomb[j].a })
	b := make([]int, n+1)
	b[0] = bomb[0].b
	for i := 0; i < n-1; i++ {
		b[i+1] = bomb[i].b ^ bomb[i+1].b
	}
	b[n] = bomb[n-1].b

	g := make([][]pii, n+1)
	for i := 0; i < m; i++ {
		l, r := scanInt(), scanInt()
		ll := sort.Search(n, func(idx int) bool { return l <= bomb[idx].a })
		rr := sort.Search(n, func(idx int) bool { return r < bomb[idx].a })
		g[ll] = append(g[ll], pii{rr, i + 1})
		g[rr] = append(g[rr], pii{ll, i + 1})
	}

	ans := []int{}
	used := make([]bool, n+1)

	var dfs func(v int) int
	dfs = func(v int) int {
		used[v] = true
		res := b[v]
		for _, to := range g[v] {
			if used[to.a] {
				continue
			}
			c := dfs(to.a)
			res ^= c
			if c == 1 {
				ans = append(ans, to.b)
			}
		}
		return res
	}

	for i := 0; i < n+1; i++ {
		if used[i] {
			continue
		}
		if dfs(i) == 1 {
			fmt.Fprintln(wr, -1)
			return
		}
	}

	sort.Ints(ans)
	fmt.Fprintln(wr, len(ans))
	for i := 0; i < len(ans); i++ {
		fmt.Fprint(wr, ans[i], " ")
	}
	fmt.Fprintln(wr)

}

type pii struct{ a, b int }


Measured memory_bytes: 50140
/// {{{
#include "bits/stdc++.h"
#define   ALL(x)  x.begin(), x.end()
#define   iostreamBooster()  do{cin.tie(nullptr);ios::sync_with_stdio(false);}while(0)
#define   rep(i, s, t)       for(int i = int(s); i < int(t); ++i)
using namespace std;
typedef long long i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}


signed main()
{
  int N, K;
  int a[52];

  cin >> N >> K;
  rep(i, 0, N) cin >> a[i];

  i64 ans = 0;
  rep(l, 0, K+1) {
    rep(r, 0, K+1) {
      if (l + r > K || l + r > N || l > N || r > N) continue;
      vector<int> x;

      for (int i = 0; i < l; ++i) x.push_back(a[i]);
      for (int i = 0; i < r; ++i) x.push_back(a[N - i - 1]);
      sort(ALL(x));

      int rem = (K - (l + r));
      i64 sum = 0;
      for (int e : x) {
        if (rem > 0 && e < 0) {
          --rem;
        } else {
          sum += e;
        }
      }

      chmax(ans, sum);
    }
  }

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



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt(),b=scan.nextInt();
		if((a*b)%2==0) {
			System.out.println("Even");
		}
		else {
			System.out.println("Odd");
		}

	}

}

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

Measured memory_bytes: 1740
#include<stdio.h>
int main(){
	int a,b,k;
	int m=0;
	int i;
	int j,l;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&k);
	for(i=100;i>0;i--){
		j=a%i;
		l=b%i;
		if(j==0&&l==0)m++;
		if(m==k){
			printf("%d",i);
			break;
		}
	}
	return 0;
}

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

#define         eps         10e-9
#define         pi          2*acos(0)
#define         P1          1e9+7
#define         P2          1e9+9
#define         lli         long long int

using namespace std;

///ISNNJB

/**int fx[]={+1,-1,+0,+0};
int fy[]={+0,+0,+1,-1};
int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};*/

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

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    lli t,a,b,m,n,x,total,ara[7],i;

    for (int i=1; i<=5; i++)
        cin>>ara[i];
    for ( i=1; i<=5; i++){
        if(ara[i]==0){
            x=i;
            break;
        }
    }
    cout<<x<<endl;

    return 0;
}


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

using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using pint = pair<int, int>;
#define repi(n) for (int i = 0; i < n; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define repv(itr) for (auto&& v : itr)
#define swap(x, y)    \
  {                   \
    auto ___temp = x; \
    x = y;            \
    y = ___temp;      \
  }

const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}

int v[50], c[50];
int main() {
  int n;
  cin >> n;
  repi(n) cin >> v[i];
  repi(n) cin >> c[i];
  int re = 0;
  repi(n) re += max(0, v[i] - c[i]);
  cout << re << endl;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
	char x, y;
	std::cin >> x >> y;

	char a;
	if( x > y ) {
		a = '>';
	}
	if( x < y ) {
		a = '<';
	}
	if( x == y ) {
		a = '=';
	}

	std::cout << a << std::endl;
	return 0;
}


Measured memory_bytes: 256
H,W = map(int,input().split())
s = [None]*H
for i in range(H):
    s[i] = input()

from collections import deque
def cango(x,y):
    cand =[]
    if x+1<=H-1:
        cand.append((x+1,y))
    if x-1>=0:
        cand.append((x-1,y))
    if y+1<=W-1:
        cand.append((x,y+1))
    if y-1>=0:
        cand.append((x,y-1))
    return cand
    
q = deque([(-1,-1,0,0,0)]) 
been = [[False]*W for _ in range(H)]

reach=False
while q:
    x_old,y_old,x_now,y_now,time = q.popleft()
    
    cand = cango(x_now,y_now)
    
    if x_now==H-1 and y_now==W-1:
        reach=True
        break
    
    for x_new,y_new in cand:
        if not been[x_new][y_new] and s[x_new][y_new]==".":
            q.append((x_now,y_now,x_new,y_new,time+1))
            been[x_new][y_new]=True
if reach:
    print( sum(ss.count(".") for ss in s)-time-1 )
else:
    print(-1)

Measured memory_bytes: 74192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
    int N;cin>>N;
    vector<int> a(N);
    REP(i,N)cin>>a[i];
    int res=2147483647;
    FOR(i,-200,201){
        int tmp=0;
        REP(j,N){
            tmp+=abs(a[j]-i)*abs(a[j]-i);
        }
        res=min(res,tmp);
    }
    cout<<res<<endl;
    return 0;
}

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  
  bool can = false;
  rep(i,b){
  	if(a*(i+1)%b == c) can = true;
  }
  
  if(can) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

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

typedef long long ll;

int main(void) {
	int a, b, c;
	cin >> a >> b >> c;

	bool ans = true;
	int x = c - (a + b);
	if (x <= 0)
		ans = false;
	else {
		ll y = (ll)4 * a * b;
		ll z = (ll)x * x;
		if (y >= z)
			ans = false;
	}

	cout << (ans ? "Yes\n" : "No\n");
	return 0;
}


Measured memory_bytes: 256
import sys

INF = 10 ** 9
N, M, P = map(int,input().split())

edges = []

for _ in range(M):
    A, B, C = map(int,input().split())
    edges.append([A-1, B-1, P-C])

flag1 = [0] * N
flag2 = [0] * N
flag = [0] * N

flag1[0] = 1
flag2[N-1] = 1

for i in range(N-1):
    for j in range(M):
        edge = edges[j]
        if flag1[edge[0]]:
            flag1[edge[1]] = 1
        if flag2[edge[1]]:
            flag2[edge[0]] = 1

for i in range(N):
    if flag1[i] and flag2[i]:
        flag[i] = 1

d = [INF] * N
d[0] = 0
k = None

for i in range(N):
    for j in range(M):
        edge = edges[j]
        if d[edge[1]] > d[edge[0]] + edge[2]:
            d[edge[1]] = d[edge[0]] + edge[2]
            if i == N - 1 and flag[edge[1]]:
                print(-1)
                sys.exit()

print(max(-1 * d[N-1], 0))

Measured memory_bytes: 52696
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
 
int main(){
 ll h ,w ;cin>>h>>w ;
 char d[h][w] ;
 queue<P> q ;
 ll dist[h][w] ;
 ll cnt =0 ;
 rep(i,h){
   rep(j,w) {
     cin>> d[i][j];
    if(d[i][j]=='#') {
     dist[i][j] =0 ;
     q.push(mpa(i,j)) ;
    }else cnt++ ;
    }
 }
  ll ans= 0;
  ll dx[] = {1, -1, 0, 0};
	ll dy[] = {0, 0, -1, 1};
  while(cnt>0){
  
  while(!q.empty()){
    P now=q.front() ;
  q.pop() ;
  ll a=now.first ;
  ll b=now.second ;
    rep(i,4){
     
     ll nowx= a+dx[i];
     ll nowy= b+dy[i] ;
    if (nowx < 0 ||nowx >= h || nowy < 0 || nowy >= w)
					continue;
    if(d[nowx][nowy]=='.') {
      q.push(mpa(nowx,nowy) ) ;
      d[nowx][nowy]='#' ;
      dist[nowx][nowy] =dist[a][b]+1 ;
        ans=dist[nowx][nowy] ;
            cnt-- ;
    }

    }
  }
  
  }

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

Measured memory_bytes: 17168
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int N; cin >> N;
    vi A(N); REP(i, N) cin >> A[i];

    map<int, int> mp;
    REP(i, N) mp[A[i]]++;

    bool ok = false;
    if (mp.size() == 1){
        if (mp[0] == N) ok = true;
    }
    else if (mp.size() == 2) {
        ok = true;
        for(auto p : mp) {
            if (p.first == 0 && p.second * 3 == N) continue;
            else if (p.second * 3 == N * 2) continue;
            ok = false;
            break;
        }
    } 
    else if (mp.size() == 3) {
        ok = true;
        vi num;
        for(auto p : mp) {
            num.push_back(p.first);
            if (p.second * 3 == N) continue;
            ok = false;
            break;
        }
        if (ok && (num[0] ^ num[1] ^ num[2]) != 0) ok = false;
    }

    string ans = ok ? "Yes" : "No";
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
int main()
{
string s;int k;
  cin>>k>>s;
  if(k>=s.length())
  cout<<s<<endl;
  else
  {
  	string ss="";ss=s.substr(0,k);
    ss+="...";
  	cout<<ss<<endl;
  }
	return 0;
 } 

Measured memory_bytes: 3600
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  int a[N][3];
  REP(i,N)REP(j,3)cin>>a[i][j];
  int dp[N+1][3];
  REP(j,3)dp[0][j]=0;
  FOR(i,1,N+1){
    REP(j,3){
      int temp=0;
      REP(k,3){
        if(j==k)continue;
        temp=max(temp,dp[i-1][k]+a[i-1][j]);
      }
      dp[i][j]=temp;
    }
  }
  int ans=0;
  REP(j,3)ans=max(ans,dp[N][j]);
  cout<<ans<<endl;
  // REP(i,N+1){
  //   REP(j,3)cerr<<dp[i][j]<<" ";
  //   cerr<<endl;
  // }
  return 0;
}


Measured memory_bytes: 2560
n,m = map(int,input().split())
lis = []
for i in range(n):
  lis.append(str(input()))
tate = [0]*n
yoko = [0]*m
for k in range(n):
  for h in range(m):
    if lis[k][h] == "#":
      tate[k] = 1
      yoko[h] = 1
li = []
cou = n
for i in range(n):
  s = []
  for k in range(m):
    if tate[i] != 0 and yoko[k] != 0:s.append(lis[i][k])
  if s == []:
    cou -= 1
  else:
    li.append(s)
for i in range(cou):print("".join(li[i]))

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

using namespace std;

int main(){
  int N; cin >> N;
  
  vector<pair<pair<string, int>, int>> r(N);
  for(int i = 0; i < N; i++){
    string s; int p; cin >> s >> p;
    r[i] = make_pair(make_pair(s, -p), i + 1);
  }
  sort(r.begin(), r.end());
  
  for(int i = 0; i < N; i++){
    cout << r[i].second << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<functional>
#include<string>
#include<cmath>

using namespace std;
using ll  = long long;
template <typename T> T In() {
    T t;
    cin >> t;
    return t;
}
template <typename T> vector<T> ReadVec1(int N) { 
    vector<T> vec(N);
    for(int i = 0; i < N; i++)
        vec[i] = In<T>();
    return move(vec);
}
template <typename T> vector<vector<T>> Vec2(int i, int j, T ini = 0) {
    vector<vector<T>> vec(i, vector<T>(j, ini));
    return move(vec);
}
template <typename T> vector<vector<vector<T>>> Vec3(int i, int j, int k, T ini = 0) {
    vector<vector<vector<T>>> vec(i, vector<vector<T>>(j, vector<T>(k, ini)));
    return move(vec);
}

int count(const vector<int> &bs, int i) { 
    int c = 0;
    for(int n = 1; i*n < bs.size(); n++){
        if(bs[i*n]==1)
            c++;
    }
    return c;
}

int main() { 
    int N = In<int>();
    vector<int> as(N + 1, 0);
    vector<int> bs(N + 1, 0);
    for(int i = 1; i <= N; i++){
        as[i] = In<int>();
    }

    int num = 0;
    for(int i = N; i > 0; i--) {
        if(count(bs, i) % 2 == as[i]) {
            bs[i] = 0;
        } else {
            bs[i] = 1;
            num++;
        }
    }

    cout << num << endl;
    for(int i = 1; i <= N; i++) {
        if(bs[i]==1)
            cout << i << endl;
    }
}


Measured memory_bytes: 2432
use proconio::{input, fastout};

#[fastout]
fn main() {
  input!{
    N: i32,
    K: i32,
    A: [i32; N]
  }
  for i in K..N {
      println!("{}",if A[i as usize] > A[(i-K) as usize] {"Yes"}else{"No"});
  }
}


Measured memory_bytes: 4812
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

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

  int ans = 0;
  auto dfs = [&](auto&& dfs, int i, int sum)->void{
    if(i == n){
      ans += sum%2 == 0;
      return;
    }
    dfs(dfs, i+1, sum * (a[i]-1));
    dfs(dfs, i+1, sum * a[i]);
    dfs(dfs, i+1, sum * (a[i]+1));
  };
  dfs(dfs, 0, 1);
  cout << ans << endl;

  return 0;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO  cout << "NO"  << endl
#define No  cout << "No"  << endl

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    string S; cin >> S;
    int ans = INF;
    int count = 0;
    REP(i, S.length())
    {
        if(i % 2 == 0)
        {
            if(S[i] == '0') count++;
        }
        else
        {
            if(S[i] == '1') count++; 
        }
    }
    ans = min(ans, count);

    count = 0;
    REP(i, S.length())
    {
        if(i % 2 == 0)
        {
            if(S[i] == '1') count++;
        }
        else
        {
            if(S[i] == '0') count++; 
        }
    }
    ans = min(ans, count);

    cout << ans << endl;
} 
    
int main() 
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ctype.h>
using namespace std;
 
int main() {
string a,b,c;
cin >> a >> b>> c;
a[0] -=32; b[0] -=32; c[0] -=32;
cout << a[0] << b[0] << c[0] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18

priority_queue<int,vector<int>,greater<int>> que;


int a,b,c;

void solve(){
	cin >> a >> b >> c;
	printf("%d %d %d\n",c,a,b);
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <cstdint>
#include <iostream>

int main(void)
{
    uint32_t a;

    std::cin >> a;

    uint32_t mod = a % 3;

    if (mod <= 2) std::cout << a/3 << std::endl;
    else std::cout << a/3 + 1 << std::endl;

    return 0;
}

Measured memory_bytes: 384
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

A,B = inpl()
S = input()

def solve():
	for i in range(A+B+1):
		if i == A:
			if S[i] != '-':
				return False
		else:
			if S[i] == '-':
				return False

	return True

if solve():
	print('Yes')
else:
	print('No')


Measured memory_bytes: 4212
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return {i for i in range(n + 1) if is_prime[i]}



n = 10 ** 5
prime_set = primes(n)
q = I()
C = [0] * (n + 1)
for i in range(n + 1):
    if i % 2 and i in prime_set and (i + 1) // 2 in prime_set:
        C[i] = 1


for j in range(1, n + 1):
    C[j] += C[j - 1]

for i in range(q):
    l, r = LI()
    print(C[r] - C[l - 1])

Measured memory_bytes: 52312
// Sandglass
// * frank_c1
// * 2017 / 11/ 07

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

const int maxn = (int)(1e5) + 5;
pair<int, pair<int, int> > w[maxn];
int res[maxn], ri[maxn];

int main() {
	int X, K;
	scanf("%d%d", &X, &K);
	for (int i = 1; i <= K; ++i) scanf("%d", &ri[i]);
	int m; scanf("%d", &m);
	for (int i = 1; i <= m; ++i) {
		int t, a; scanf("%d%d", &t, &a); w[i] = make_pair(t, make_pair(a, i));
	} 
	sort(w + 1, w + m + 1);
	int v = 0, l = 0, r = X, ps = 1;
	for (int i = 0; i <= K; ++i) {
		for (; ps <= m && (i == K || w[ps].first < ri[i + 1]); ++ps) {
			int t = w[ps].first - ri[i], a = w[ps].second.first, id = w[ps].second.second;
			if (i & 1) {
				if (l < 0) res[id] = min(X, v + t); 
				else {
					int nv = v, nl = l, nr = r;
					int c = min(t, X - (nv + nr - nl)); nv += c; t -= c;
					c = min(t, nr - nl); nv += c; nr -= c; t -= c; if (nl == nr) nl = nr = -1;
					if (nl < 0) res[id] = nv; else if (a <= nl) res[id] = nv; else if (a <= nr) res[id] = nv + a - nl; else res[id] = nv + nr - nl;
				}
			} else {
				if (l < 0) res[id] = max(0, v - t);
				else {
					int nv = v, nl = l, nr = r;
					int c = min(t, nv); nv -= c; t -= c;
					c = min(t, nr - nl); nl += c; t -= c; if (nl == nr) nl = nr = -1;
					if (nl < 0) res[id] = nv; else if (a <= nl) res[id] = nv; else if (a <= nr) res[id] = nv + a - nl; else res[id] = nv + nr - nl;
				}
			}
		}
		if (i < K) {
			int t = ri[i + 1] - ri[i];
			if (i & 1) {
				if (l < 0) v = min(X, v + t);
				else {
					int c = min(t, X - (v + r - l)); v += c; t -= c;
					c = min(t, r - l); v += c; r -= c; t -= c; if (l == r) l = r = -1;
				} 
			} else {
				if (l < 0) v = max(0, v - t);
				else {
					int c = min(t, v); v -= c; t -= c;
					c = min(t, r - l); l += c; t -= c; if (l == r) l = r = -1;
				}
			}
		}
	}
	for (int i = 1; i <= m; ++i) printf("%d\n", res[i]);
	return 0;
}

Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long a[] = new long[n];

        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }

        long odd = f(a, n, 1);
        long even = f(a, n, -1);

        System.out.println(Math.min(odd, even));
    }

    static long f(long a[], int n, int sign) {
        long total = 0;
        long man = 0;
        for (int i = 0; i < n; i++) {
            total += a[i];
            if (total * sign <= 0) {
                long x = Math.abs(total) + 1;
                total += sign * x;
                man += x;
            }
            sign = -sign;
        }
        return man;
    }
}


Measured memory_bytes: 61972
n, m, q = map(int, input().split())
abcd = []
for _ in range(q):
    a, b, c, d = map(int, input().split())
    abcd.append([a-1, b-1, c, d])

def score(A):
    tmp = 0
    for a, b, c, d in abcd:
        if A[b] - A[a] == c:
            tmp += d
    return tmp
    
def dfs(A):
    if len(A) == n: return score(A)
    res = 0
    last = A[-1] if A else 0
    for i in range(last, m):
        A.append(i)
        res = max(res, dfs(A))
        A.pop()
    return res

print(dfs([]))

Measured memory_bytes: 9268
#include <iostream>
using namespace std;
int n, a[2][9]; bool used[10];
int rec(int dep, int s) {
	if (dep == 9) return (s > 0 ? 1 : 0);
	int ret = 0;
	for (int i = 0; i < 9; i++) {
		if (!used[i]) {
			used[i] = true;
			if (a[0][i] > a[1][dep]) ret += rec(dep + 1, s + a[0][i] + a[1][dep]);
			else ret += rec(dep + 1, s - a[0][i] - a[1][dep]);
			used[i] = false;
		}
	}
	return ret;
}
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int i = 0; i < 18; i++) cin >> a[i / 9][i % 9];
		double r = 1.0 * rec(0, 0) / 362880;
		printf("%.12f %.12f\n", r, 1.0 - r);
	}
	return 0;
}

Measured memory_bytes: 3168