akhauriyash/Code-Regression huggingface dataset:
s = input()

for bit in range(1<<len(s)):
  f = s[0]
  ans = int(s[0])
  for i in range(1,len(s)):
    if bit & 1<<i:
      f = f + '+' + s[i]
      ans += int(s[i])
    else:
      f = f + '-' + s[i]
      ans -= int(s[i])
  
  if ans == 7:
    print(f + '=7')
    exit()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

int main(){
    int a,b;
    char op;
    while(cin >> a >> op >> b){
        if(op == '+') cout << a + b << endl;
        else if(op == '-') cout << a - b << endl;
        else if(op == '*') cout << a * b << endl;
        else if(op == '/') cout << a / b << endl;
        else if(op == '?') break;;
    }
}

Measured memory_bytes: 1160
//FPC 2.6.2
var
  n,ans,a,b : Integer;
begin
  readln(a,b);
  ans := 0;
  if (a < 10) and (b < 10) then ans := 1;
  if ans=1 then
  writeln(a*b)
  else
  writeln(-1);      
end.


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		int x=s.nextInt();
		
		if(x==1)
		{
			System.out.println(0);
		}
		else
		{
			System.out.println(1);
		}
		
	}
	
}

Measured memory_bytes: 35616
// In The Name Of GOD
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 3 * 100 + 3;

char mat[MAXN][MAXN];

bool CheckTheColumn(int A, int n);

int main() {
	int n, ans = 0;
	cin >> n;
	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++)
			cin >> mat[i][j];
	for(int i = 0; i < n; i++)
		ans += CheckTheColumn(i, n) * n;
	cout << ans;
}

bool CheckTheColumn(int A, int n) {
	//cerr << "CheckTheColumn " << A << endl;
	for (int c = 0, i = A; c < n; i++, c++, i %= n) {
		for (int j = 0, k = A; j < n; j++, k++, k %= n) {
		// n - c, n - j --> n - c + A, n - j
			if(mat[i][j] != mat[k][c])
				return false;
		}
	}
	return true;
}



Measured memory_bytes: 384
#include<cstdio>

const int MAX = 1e5, A = 1e9 + 7;
int n, m;
int x[MAX], y[MAX];

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++) scanf("%d", &x[i]);
    for (int i = 0; i < m; i++) scanf("%d", &y[i]);
    
    long sum1 = 0;
    for (int i = 0; i < n / 2 - 1; i++) {
        sum1 += (static_cast<long>(x[i + 1]) - x[i]
             + x[n - i - 1] - x[n - i - 2])
             * (i + 1) * (n - i - 1) % A;
        sum1 %= A;
    }
    sum1 += static_cast<long>(x[n / 2] - x[n / 2 - 1])
         * (n / 2) * (n - n / 2) % A;
    if (n % 2 == 1) {
        sum1 += static_cast<long>(x[n - n / 2] - x[n - n / 2 - 1])
             * (n - n / 2) * (n / 2) % A;
    }
    sum1 %= A;

    long sum2 = 0;
    for (int i = 0; i < m / 2 - 1; i++) {
        sum2 += (static_cast<long>(y[i + 1]) - y[i]
             + y[m - i - 1] - y[m - i - 2])
             * (i + 1) * (m - i - 1) % A;
        sum2 %= A;
    }
    sum2 += static_cast<long>(y[m / 2] - y[m / 2 - 1])
         * (m / 2) * (m - m / 2) % A;
    if (m % 2 == 1) {
        sum2 += static_cast<long>(y[m - m / 2] - y[m - m / 2 - 1])
             * (m - m / 2) * (m / 2) % A;
    }
    sum2 %= A;

    printf("%ld\n", sum1 * sum2 % A);
    return 0;
}


Measured memory_bytes: 896
#include<iostream>
 
using namespace std;
int main()
{
  int N;
  cin >> N;
  
  if(N%10 == 7)
  {
    cout << "Yes";
    return 0;
  }
  N /=10;
  if(N%10 == 7)
  {
    cout << "Yes";
    return 0;
  }
  N /=10;
  if(N%10 == 7)
  {
    cout << "Yes";
    return 0;
  }
  
  cout << "No";
  return 0;
  
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)


int main(){
    string s;
    cin>>s;
    cout<<*s.begin()<<s.size()-2<<s[s.size()-1]<<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;
typedef long long ll;

int main() {
  int N, ans;
  cin >> N;
  int a[N];
  rep(i, N) {
    a[i] = 0;
  }

  int b[N-1];
  rep(i, N-1) {
    cin >> b[i];
  }

  rep(i, N-1) {
    if (i == 0) a[i] = b[i];
    if (i > 0 && b[i] < b[i-1]) a[i] = b[i];
    a[i+1] = b[i];
  }

  ans = 0;
  rep(i, N) {
    ans += a[i];
  }
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OJcsharp
{
    class Program
    {
        static void Main(string[] args)
        {
            double[] ans = new double[10000];
            int count = 0;
            string str=Console.ReadLine();
            do
            {
                double v = double.Parse(str);
                ans[count] = Math.Ceiling((Math.Pow(v / 9.8, 2) * 4.9) / 5) + 1;
                count++;
                str=Console.ReadLine();
            }while(string.IsNullOrEmpty(str)==false);
            for (int n = 0; n < count; n++)
            {
                Console.WriteLine((int)ans[n]);
            }
        }
    }
}

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

using ll = long long;

ll a[100010],b[100010];

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

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

    ll ans=0;

    for(int i=n-1;i>=0;i--)
    {
        ans+=(b[i]-(a[i]+ans)%b[i])%b[i];
    }

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 5172
n = input()
a = [int(n[i]) for i in range(4)]

li = [(0,0,0), (0,0,1), (0,1,0), (0,1,1), (1,0,0), (1,0,1), (1,1,0), (1,1,1)]

for i in li:
    sum1 = a[0]
    for j in range(3):
        if i[j] == 0:
            sum1 += a[j+1]
        else:
            sum1 -= a[j+1]
    if sum1 == 7:
        ans = ''
        for j in range(3):
            ans += str(a[j])
            if i[j] == 0:
                ans += '+'
            else:
                ans += '-'
        ans += str(a[3]) + '=7'
        print(ans)
        exit()


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

vector <int> S;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	S.resize(n);
	cin >> S[0];
	for (int i = 1; i < n; i++){
		int y;
		cin >> y;
		S[i] = S[i - 1] + y;
	}
	int ans = 1e9;
	for (int i = 0; i < n; i++){
		ans = min(ans, abs(S[n - 1] - S[i] - S[i]));
	}
	cout << ans;
}

Measured memory_bytes: 256
import fileinput

s = list(input())

if s[0] != "A" or s[1].isupper() or s[len(s) - 1].isupper():
    print("WA")
    exit()

cc = False
for i in range(2, len(s) - 1):
    if s[i] == "C" and not cc:
        cc = True
        continue
    if s[i] == "C" and cc:
        print("WA")
        exit()
    if s[i].isupper() and s[i] != "C":
        print("WA")
        exit()

if cc:
    print("AC")
else:
    print("WA")





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

int k, m, n, h, w, a, b, c;
ll t[1 << 17], d[1 << 17];

main(){
    cin >> a >> b;
    if(b%a==0)cout << a + b << endl;
    else cout << b - a << endl;
}

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

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

using namespace std;

int main() {
    int a,b;
    cin >>a>>b;
    if (b == 1) cout <<0<<endl; 
    else cout <<a-b<<endl;   
}

Measured memory_bytes: 256
def power(a, n, M):
    tmp = 1
    if n > 0:
        tmp = power(a, n/2, M)
        if n % 2 == 0:
            tmp =(tmp*tmp)%M
        else:
            tmp = (((tmp*tmp)%M)*a)%M
    return tmp
m, n = map(int, raw_input().split())
print power(m, n, 1000000007)

Measured memory_bytes: 6408
#include<iostream>
#include<cstdio>
#include<cstring>
#define INF 0x3f3f3f3f
typedef long long ll;
using namespace std;
const int inf = 100005;
int main()
{int a,b;
 cin>>a>>b;
 int c,d;
if(a%b==0)cout<<0;
else cout<<1;



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
typedef long double ld;
using ll=long long;
using namespace std;
const int mod=1e9+7;
const ll inf = 1LL << 60;
const ld pi = (acos(-1));
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; }




int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  int n; cin >> n;
  string s;  cin >> s;
  int ans=0;
  rep(i,0,n-2){
    if(s[i]=='A' and s[i+1]=='B' and s[i+2]=='C'){
      ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <list>
#define INF 0x3f3f3f3f
#define maxn 205000
#define maxnn 6000
#define juzheng 300
#define line cout << "-------------------------" << endl;
#define PI acos(-1.0)
#define mem(a,b) memset(a,b,sizeof(a))
#define fill_(a,b,n) fill(a,a + n,b)
#define esp 1e-9
 
#define ri(n) scanf("%d",&n)
#define ri2(a,b) scanf("%d %d",&a,&b)
#define ri3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define rd(n) scanf("%lf",&n)
#define rd2(a,b) scanf("%lf %lf",&a,&b)
#define rd3(a,b,c) scanf("%lf %lf %lf",&a,&b,&c)
#define rl(n) scanf("%lld",&n)
#define rl2(a,b) scanf("%lld %lld",&a,&b)
#define rl3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pr(n) cout << n << endl
#define ll long long
#define int64 __int64

using namespace std;

//Date:2018-8-4
//Author：HarryBlackCat

string s,t,temp;

int main() {
	//cin.sync_with_stdio(false);//降低cin，cout时间
	while(cin >> s){
		cin >> t;
		bool flag = false;
		for(int i = 0;i < s.size();i++){
			//pr((s==t));
			if(s == t){
				flag = true;
				break;
			}
			
			temp = s.substr(s.size() - 1) + s.substr(0,s.size() - 1);
			s = temp;
			//pr(temp);
		}
		
		if(flag) 
			puts("Yes");
		else
			puts("No");
	}
}

Measured memory_bytes: 256
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <map>

using namespace std;



int main(int argc, const char * argv[]) {
    
    int n;
    
    cin >> n;
    
    vector<int> p(n), q(n);
    
    for(int i=0; i<n; i++)
    {
        cin >> p[i];
    }
    
    for(int i=0; i<n; i++)
    {
        cin >> q[i];
    }
    
    vector<int> a(n);
    
    for(int i=0; i<n; i++) a[i] = i + 1;
    
    map<vector<int>, int> mp;
    
    do{
        mp[a] = mp.size();
    } while (next_permutation(a.begin(), a.end()));
    
    int ans = abs(mp[p] - mp[q]);
    
    cout << ans << endl;
    
    
    
    return 0;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
int main() {
  
  int N;
  cin >> N;
  
  vector<int64_t> A(N+1);
  vector<int64_t> B(N);
  
  for(int i = 0 ; i < N+1 ; i++){
    
    cin >> A.at(i);
    
  }
  
  for(int i = 0 ; i < N ; i++){
    
    cin >> B.at(i);
    
  }
  
  int64_t sum = 0;
  
  for(int i = 0 ; i < N ; i++){
    
    if( B.at(i) >= A.at(i) ){
      
      sum += A.at(i);
      B.at(i) -= A.at(i);
      
    }else{
      
      sum += B.at(i);
      continue;
      
    }
    
    if( B.at(i) >= A.at(i+1)){
      
      sum += A.at(i+1);
      A.at(i+1) = 0;
      
    }else{
      sum += B.at(i);
      A.at(i+1) -= B.at(i);
    }
  }
  
  cout << sum << endl;
}
  
  
  
  
  


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
  
// #define int long long
#define pb push_back
#define print(Target) cout << Target << '\n'
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;

bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}

signed main()
{
  ios::sync_with_stdio(false);
    
  int a, b;
  while (cin >> a >> b, a || b){
    int n, dp[17][17] = {0};
    bool check[17][17] = {false};
    cin >> n;
    REP(i, n){
      int x, y;
      cin >> x >> y;
      check[y][x] = true;
    }

    dp[1][1] = 1;
    REPS(i, 1, b + 1){
      REPS(j, 1, a + 1){
        if (!check[i][j] && (i != 1 || j != 1)){
          dp[i][j] = dp[i][j - 1] + dp[i - 1][j];
        }
      }
    }
    print(dp[b][a]);
  }

  return (0);
}

Measured memory_bytes: 1192
n, k = (int(x) for x in input().split())

w = []
w = [int(input()) for i in range(n)]

def f(x):
    count = 0
    for i in range(k):
        s = 0
        while s + w[count] <= x:
            s += w[count]
            count += 1
            if count == n:
                return n
    return count

left = 0
right = 100000 * 100000

while right - left > 1:
    mid = (left + right) // 2
    v = f(mid)
    if v >= n:
        right = mid
    else:
        left = mid

print(right)


Measured memory_bytes: 9560
#include <bits/stdc++.h>
using namespace std;
int main(){
	int i,a[10001],b[10001];
	for(a[0]=1,b[0]=1,i=1;a[i-1]!=0||b[i-1]!=0;i++) cin>>a[i]>>b[i];
	i--;
	for(int j=1;j<i;j++){
		for(int h=0;h<a[j];h++){
			for(int w=0;w<b[j];w++){
				if(h%2==w%2) cout<<'#';
				else cout<<'.';
			}
			cout<<endl;
		}
		cout<<endl;
	}
	return 0;
}



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

//// C
int main(){
    int n; cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    int pre = -999;
    rep(i,n){
        if(pre <= v[i]-1){
            pre = v[i]-1;
        }else if(pre <= v[i]){
            pre = v[i];
        } else{
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        System.out.println(str);
    }

    public static void main(String[] args) {

        long A;
        long B;

        try (Scanner sc = new Scanner(System.in)) {
            A = sc.nextLong();
            B = sc.nextLong();
        }
        int cnt = 0;

        System.out.println( (int)Math.ceil((double)(B-1)/(A-1) ));
    }

}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>k>>x>>y;
    rrep(i,1,n+1){
        if(i<=k)ans+=x;
        else ans+=y;
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 764
import numpy as np
from sys import stdin
n,m,c = [int(x) for x in stdin.readline().rstrip().split()]
b = [int(x) for x in stdin.readline().rstrip().split()]
data = [stdin.readline().rstrip().split() for _ in range(n)]
data = [[int(i) for i in l] for l in data]
result = 0
for d in data:
    if sum(np.array(d)*np.array(b))+c > 0:
      result+=1
print(result)

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

int main() {
  int n;cin>>n;
  int an[n];
  int s=0;
  rep(i,n) {
    cin>>an[i];
    s^=an[i];
  }
  rep(i,n){
    cout<<(s^an[i])<<" ";
  }
}


Measured memory_bytes: 4380
#include <iostream>

using namespace std;
using int64 = long long;

const int MOD = 1000000007;

int64 mpow(int64 n, int64 i) {
    int64 res = 1;
    while(i != 0) {
        if (i&1) {
            res *= n;
            res %= MOD;
        }
        n *= n;
        n %= MOD;
        i /= 2;
    }
    return res;
}
int64 inv(int64 n) {
    return mpow(n, MOD-2);
}

int64 nCr(int n, int r) {
    if (n < r) return 0;
    int64 x = 1;
    int64 y = 1;
    for (int i=1; i<=r; i++) {
        x *= (n - i + 1); x %= MOD;
        y *= i; y %= MOD;
    }

    int64 res = x * inv(y);
    res %= MOD;
    return res;
}

int main() {
    int x,y;
    cin >> x >> y;
    if ((x+y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }

    int a = (2*x - y) / 3;
    int b = (2*y - x) / 3;
    if (a < 0 || b < 0) {
        cout << 0 << endl;
        return 0;
    }

    int64 ans = nCr(a+b, a);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#define llint long long

using namespace std;

llint N;
llint data[25][25];
llint array[60000];
llint p[] = {13, 17, 19, 23};

int main(void)
{
	while(1){
		cin >> N;
		if(N == 0) break;
		
		for(int i = 1; i <= 24; i++){
			for(int j = 0; j <= 24; j++){
				data[i][j] = 0;
			}
		}
		for(int i = 0; i < 60000; i++) array[i] = 0;
		
		llint d, t, q[25];
		for(int i = 1; i <= N; i++){
			cin >> d >> t;
			for(int j = 0; j < d; j++) cin >> q[j];
			for(int j = 0; j < d; j++) data[d][j] += q[(j+t)%d];
		}
		
		for(int i = 1; i <= 24; i++){
			for(int j = 0; j < 4; j++) if(i == p[j]) goto pass;
			for(int j = 0; j < 60000; j++) array[j] += data[i][j%i];
			pass:;
		}
		
		llint ans = 0;
		for(int i = 0; i < 60000; i++) ans = max(ans, array[i]);
		for(int i = 0; i < 4; i++){
			llint tmp = 0;
			for(int j = 0; j < p[i]; j++) tmp = max(tmp, data[p[i]][j]);
			ans += tmp;
		}
		cout << ans << endl;
	}
	
	return 0;
}


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

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

  std::vector<int> f(N, 0), s(N, 0);

  for (int i = 0; i < N; i++) {
    int a;
    std::cin >> a;

    f[i] = a + (i == 0 ? 0 : f[i-1]);
  }

  std::vector<int> A(N);
  for (int i = 0; i < N; i++) {
    std::cin >> A[i];
  }

  for (int i = N-1; i >= 0; i--) {
    s[i] = A[i] + (i == N-1 ? 0 : s[i+1]);
  }

  int answer = 0;

  for (int i = 0; i < N; i++) {
    answer = std::max(answer, f[i] + s[i]);
  }

  std::cout << answer << std::endl;
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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



void func(long long N, std::vector<long long> A){

    SORT(A);
    lli now = A[0];
    if(now==0){
        cout<<0<<endl;
        return;
    }
    lli border = 1;
    REP(i,0,18)border*=10;
    REP(i,1,N){
        now *= A[i];
        if(now>border || now<=0){
            cout<<-1<<endl;
            return;
        }
    }
    if(now>border || now<=0){
            cout<<-1<<endl;
            return;
        }

    cout<<now<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    func(N, std::move(A));
    return 0;
}


Measured memory_bytes: 4060
#A

"""
s = input().split("/")
if int(s[1]) <= 4:
    print("Heisei")
else:
    print("TBD")
"""
#B
"""
n = int(input())
ans = 0
for i in range(n):
    a = input().split()
    if a[1] == "JPY":
        ans += int(a[0])
    else:
        ans +=  float(a[0]) * 380000
print(ans)
"""

#C
import itertools

n, a, b, c = map(int, input().split())
abc = [a, b, c]
ans = float("INF")
x = [int(input()) for i in range(n)]
nums = list(itertools.product([0, 1, 2, 3], repeat = n))
#print(nums)
for i in nums:
    tmp = 0
    aa = 0
    ba = 0
    ca = 0
    for number, k in enumerate(i):
        if k == 1:
            if aa != 0:
                tmp += 10
            aa += x[number]
        if k == 2:
            if ba != 0:
                tmp += 10
            ba += x[number]
        if k == 3:
            if ca != 0:
                tmp += 10
            ca += x[number]
    if aa == 0 or ba == 0 or ca == 0:
        tmp = float("INF")
    else:
        tmp += abs(aa - a)
        tmp += abs(ba - b)
        tmp += abs(ca - c)
    ans = min(tmp, ans)
print(ans)
        
        
            


#D

"""
a, b, q = map(int, input().split())
s = [int(input()) for i in range(a)]
t = [int(input()) for i in range(b)]
s.sort()
t.sort()

import bisect


for i in range(q):
    x = int(input())
    s_l = bisect.bisect_left(s, x) - 1
    t_l = bisect.bisect_left(t, x) - 1
    s_r = s_l + 1
    t_r = t_l + 1
    if s_l == -1:
        s_l = 0
    if t_l == -1:
        t_l = 0
    if s_l == a :
        s_l = a - 1
        s_r = a - 1
    if s_r == a:
        s_r = a - 1
    if t_l == b:
        t_l = b - 1
        t_r = b - 1
    if t_r == b:
        t_r = b - 1
    ans = min(abs(t[t_l] - s[s_r]) + min(abs(t[t_l] - x), abs(s[s_r] - x)),
    abs(s[s_l] - t[t_r]) + min(abs(s[s_l] - x), abs(t[t_r] - x)),
    abs(s[s_l] - t[t_l]) + min(abs(s[s_l] - x), abs(t[t_l] - x)),
    abs(s[s_r] - t[t_r]) + min(abs(s[s_r] - x), abs(t[t_r] - x)),
    )
    
    print(ans)
"""


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


int main(){
  long n,w;
  cin>>n>>w;
  long a[n],b[n];
  for (int i=0;i<n;i++)
     cin>>a[i]>>b[i];
  long x[n+1][w+1];
  for (long i=0;i<=n;i++){
     for (long j=0;j<=w;j++){
         if (i==0||j==0)
           x[i][j]=0;
         else if (j<a[i-1])
           x[i][j]=x[i-1][j];
         else
           x[i][j]=max(x[i-1][j],b[i-1]+x[i-1][j-a[i-1]]);
     }}
 cout<<x[n][w]<<endl;
 return 0; 
}

Measured memory_bytes: 79104
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;

    return 0;
}


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

int N, M;
int A[10000], B[10000];

bool liner_search(int x) {
    A[N] = x;
    int i = 0;
    while (A[i] != x)
        i++;
    return i != N;
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++)
        cin >> A[i];
    cin >> M;
    for (int i = 0; i < M; i++)
        cin >> B[i];

    int res = 0;
    for (int i = 0; i < M; i++) {
        if (liner_search(B[i]))
            res++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3140
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>

//using namespace __gnu_pbds;
using namespace std;

#define sz(x)                 x.size()
#define all(x)                x.begin(), x.end()
#define tr(x, it)             for(auto it = x.begin();it != x.end();it++)
#define fo(i, k, n)           for(int i = k;i < n;i++)
#define Fo(i, k, n)           for(int i = k;i >= n;i--)
#define el                    "\n"
#define ff                    first
#define ss                    second
#define ll                    long long
#define pb                    push_back
#define mp                    make_pair
#define pii                   pair<int, int>
#define vi                    vector<int>
#define mii                   map<int, int>
//#define pqb                   priority_queue<int>
//#define pqs                   priority_queue<int, vi, greater<int>>
//#define pc(x)                 putchar(x);
//#define setbits(x)            __builtin_popcountll(x)
//#define zrobits(x)            __builtin_ctzll(x)
#define mod                   1000000007
#define inf                   1e18
#define deb(x)                cout<<#x<< " = "<< x<<"\n";
//#define ps(x, y)              fixed<<setprecision(y)<<x
//#define mk(arr, n, type)      type *arr = new type[n];
//#define w(x)                  int x; cin>>x; while(x--)

void solve(){
	int n;
	cin>>n;
	if(n>= 400 && n<600) cout<<8;
	else if(n>= 600 && n<800) cout<<7;
	else if(n>= 800 && n<1000) cout<<6;
	else if(n>= 1000 && n<1200) cout<<5;
	else if(n>= 1200 && n<1400) cout<<4;
	else if(n>= 1400 && n<1600) cout<<3;
	else if(n>= 1600 && n<1800) cout<<2;
	else if(n>= 1800 && n<2000) cout<<1;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t = 1;
//	cin>>t;
	while(t--){
		solve();
		cout<<el;
	}
	return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    int n, m;
    cin >> n;
    map<int, int> prob;
    rep(i, n){
        int d; cin >> d;
        prob[d]++;
    }
    cin >> m;
    rep(i, m){
        int t; cin >> t;
        if(prob[t] <= 0){
            puts("NO");
            return;
        }
        prob[t]--;
    }
    puts("YES");
    return;
}

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

Measured memory_bytes: 13012
#include <bits/stdc++.h>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
int main(void){
    ll n,m,ans=1;
    cin>>n>>m;
    if(n==m){
        for(ll i=1;i<=n;i++){
            ans=(ans*i)%INF;
        }
        ans=ans*ans%INF;
        ans=2*ans%INF;
    }else if(abs(n-m)==1){
        for(ll i=1;i<=n;i++){
            ans=(ans*i)%INF;
        }
        for(ll i=1;i<=m;i++){
            ans=(ans*i)%INF;
        }
        ans=ans%INF;
    }else ans=0;
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define all(c) (c).begin(), (c).end()
const int INF = (1 << 30) - 1;
const ll LINF = (1L << 62) - 1;
const ll MOD = 1000000007;
template <class T> inline void chmin(T& a, T& x) { a = a < x ? a : x; }
template <class T> inline void chmax(T& a, T& x) { a = a > x ? a : x; }

vector<P> prime_factor(ll n) {
  vector<P> ret;
  int f = 2, sq = sqrt(n);
  while (n > 1 && f <= sq) {
    int e = 0;
    while (n % f == 0) {
      ++e;
      n /= f;
    }
    if (e > 0) ret.push_back(P(f, e));
    ++f;
  }
  if (n > 1) ret.push_back(P(n, 1));
  return ret;
}

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

  ll n, ans = 1;
  cin >> n;
  auto factor = prime_factor(n - 1);
  for (auto p : factor) {
    ans *= p.second + 1;
  }
  for (ll i = 2; i * i <= n; ++i) {
    if ((n - 1) % i == 0) continue;
    if (n % i == 0) {
      ll k = n;
      while (k % i == 0) k /= i;
      if (k % i == 1) {
        ++ans;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const int dx[2] = {1,0};
const int dy[2] = {0,1};
int dp[110][110];
int main(){
    int height,width;
    cin >> height >> width;
    vector<string> maze(height);
    for(int h=0;h<height;++h) cin >> maze[h];
    for(int h=0;h<height;++h){
        for(int w=0;w<width;++w){
            dp[h][w] = INF;
        }
    }
    if(maze[0][0] == '#') dp[0][0] = 1;
    else dp[0][0] =0;
    for(int h=0;h<height;++h){
        for(int w=0;w<width;++w){
            for(int dir=0;dir<2;++dir){
                int next_y = h + dy[dir];
                int next_x = w + dx[dir];
                if(next_x < 0 || next_x >= width || next_y < 0 || next_y >= height) continue;
                if(maze[next_y][next_x] == '#' && maze[h][w] == '.') dp[next_y][next_x] = min(dp[next_y][next_x],dp[h][w] + 1);
                else/* if(maze[next_y][next_x] == '.' )*/ dp[next_y][next_x] = min(dp[next_y][next_x],dp[h][w]);
            }
        }
    }
    cout << dp[height-1][width-1] << endl;
    return 0;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
	return 0;
}

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

const int MAX_N = 1e5;
int n, m, v, p;
int a[MAX_N];

int main() {
    scanf("%d %d %d %d", &n, &m, &v, &p);
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    sort(a, a + n);
    long sum = static_cast<long>(m) * (v - n + 1), diff = 0;
    int ans = p;
    for (int i = n - p - 1; i >= 0; i--) {
        if (a[i] + m >= a[n - p]) {
            if (diff + static_cast<long>(a[i] + m - a[n - p])
                     * (n - p - i) >= sum) ans++;
        }
        else break;
        diff += a[n - p] - a[i];
        sum += m;
    }
    printf("%d\n", ans);
    return 0;
}


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

int main(){
    int n,i;
    cin >> n;
    int a[n];
    for( i = 0; i < n; i++){
        cin >> a[i];
    }
    std::sort(a, a+n);
    int ans = a[n-1] - a[0];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=1000000007;
const long double PI=3.1415926535;
const ll MAX=1000000;

ll modpow(ll x,ll y){
  long long ans=1;
  while(y>0){
    if(y&1){
      ans*=x%MOD;
    }
    x*=x%MOD;
    x%=MOD;
    ans%=MOD;
    y>>=1;
  }
  return ans;
}


ll fac[MAX];
ll faci[MAX];

void modCf(){
  fac[0]=1;
  faci[0]=1;
  for(int i=1;i<MAX;i++){
    fac[i]=fac[i-1]*i%MOD;
    faci[i]=modpow(fac[i],MOD-2);
  }
  return;
}

ll modC( ll x,ll y){
  ll ans=fac[x];
  ans*=faci[y]%MOD;
  ans%=MOD;
  ans*=faci[x-y]%MOD;
  return ans%MOD;
}


int main() {
  modCf();
  ll X,Y;
  cin>>X>>Y;
  ll tate=0,yoko=0;
  while(Y>0){
    if(X*4==Y*2){
      yoko=X;
      break;
    }
    X-=2;Y--;
    tate++;
  }
  if(yoko==0&&X!=0){
    cout<<0;
  }
  else{
    cout<<modC(yoko+tate,yoko);
    //cout<<" "<<modC(66666,33333);
  }
}

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

#define ll long long

void solve(){
    ll w, h;
    cin >> w >> h;
    if(w == 1 || h == 1){
        cout << 1 << endl;
        return;
    }
    ll num = (w*h + 1)/2;
    cout << num << endl;
    return;
}
int main(){
    solve();
}

Measured memory_bytes: 256
module.exports=function(r){var e={};function t(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return r[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=r,t.c=e,t.d=function(r,e,n){t.o(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:n})},t.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},t.t=function(r,e){if(1&e&&(r=t(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var o in r)t.d(n,o,function(e){return r[e]}.bind(null,o));return n},t.n=function(r){var e=r&&r.__esModule?function(){return r.default}:function(){return r};return t.d(e,"a",e),e},t.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},t.p="",t(t.s=0)}([function(r,e,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8").split("\n"))},function(r,e){function t(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=[],n=!0,o=!1,u=void 0;try{for(var i,f=r[Symbol.iterator]();!(n=(i=f.next()).done)&&(t.push(i.value),!e||t.length!==e);n=!0);}catch(r){o=!0,u=r}finally{try{n||null==f.return||f.return()}finally{if(o)throw u}}return t}(r,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}r.exports=function(r){for(var e=Number(r[0]),n=[],o=[],u=[],i=0;i<e-1;i++){var f=t(r[i+1].split(" ").map(function(r){return Number(r)}),3),l=f[0],a=f[1],c=f[2];n.push(l),o.push(a),u.push(c)}for(var p=0;p<e;p++)console.log(s(p+1));function s(r){for(var t=new Array(e).fill(0),i=r;i<e;i++){var f=t[i-1];f<=o[i-1]?t[i]=o[i-1]+n[i-1]:f%u[i-1]==0?t[i]=f+n[i-1]:t[i]=Math.ceil(f/u[i-1])*u[i-1]+n[i-1]}return t[e-1]}}},function(r,e){r.exports=require("fs")}]);

Measured memory_bytes: 10832
#In[]:
a,b,c,k = map(int,input().split())

ans = 0

ans += min(a,k)
k -= min(a,k)
ans += min(b,k) * 0
k -= min(b,k)
ans += min(c,k) * -1
k -= min(c,k)

print(ans)

Measured memory_bytes: 80684
import sys
from collections import Counter, deque, defaultdict
from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
from functools import reduce
from math import ceil, floor, log10, log2, factorial
from pprint import pprint

sys.setrecursionlimit(1000000)
# MOD = 10 ** 9 + 7
# N = int(input())
# A = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]

S = input()

if S[0] == S[1] or S[1] == S[2] or S[2] == S[3]:
    print("Bad")
    sys.exit()

print("Good")
sys.exit()

Measured memory_bytes: 3948
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
    
int main() {
  string s;
  cin>>s;
  int i;
  for (i=2; i<s.size(); i+=2) {
    if (s.substr(0,(s.size()-i)/2)==s.substr((s.size()-i)/2,(s.size()-i)/2))
      break;
  }
  
  cout<<s.size()-i<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n, k;
    cin >> n >> k;
    vll vec(n);
    REP(i, n) cin >> vec.at(i);
    sort(ALL(vec));
    auto it = vec.rbegin();
    ll total = 0;
    REP(i, k) {
        total += *it;
        it++;
    }
    cout << total << endl;
    return 0;
}

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

int main(int argc, char const *argv[]) {
  int m, f, r;

  cin >> m >> f >> r;

  while (!(m == -1 && f == -1 && r == -1)) {
    if (m == -1 || f == -1) {
      cout << "F";
    } else {
      if (m + f >= 80)
        cout << "A";
      else if (m + f >= 65)
        cout << "B";
      else if (m + f >= 50)
        cout << "C";
      else if (m + f >= 30) {
        if (r >= 50)
          cout << "C";
        else
          cout << "D";
      } else
        cout << "F";
    }
    cout << endl;
    cin >> m >> f >> r;
  }

  return 0;
}



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

typedef long long ll;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;

ll N,M,L,R,Lm,Rm,ans;


int main(){
  cin >> N >> M;
  Lm=-1;
  Rm=N+1;
  for (ll i=0;i<M;i++){
    cin >> L >> R;
    if (L>Lm)Lm=L;
    if (R<Rm)Rm=R;
  }
  ans=Rm-Lm+1;
  if (ans<0)ans=0;

  cout << ans << endl;
}


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

#define ll long long
#define ld long double
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define int long long

using namespace std;
const int INF = 2e9;
const int MB = 30;
const int MOD = 1e9 + 7;

struct FenvickTree {
	vector<int> t;
	FenvickTree(int n) {
		t.resize(n + 1);
	}

	int get(int i) {
		i++;
		int res = 0;
		for (; i > 0; i-=(i & (-i))) {
			res += t[i];
		}
		return res;
	}

	void update(int i, int v) {
		i++;
		for (; i < t.size(); i += (i & (-i))) {
			t[i] += v;
		}
	}
};

void solve() {
	int n, q;
	cin >> n >> q;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i]--;
	}

	vector<vector<pair<int, int>>> b(n);
	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;
		l--; r--;
		b[r].push_back({ l, i });
	}

	vector<int> last(n, -1);
	vector<int> ans(q);
	FenvickTree tree(n);
	for (int i = 0; i < n; i++) {
		if (last[a[i]] != -1) tree.update(last[a[i]], -1);
		tree.update(i, 1);
		last[a[i]] = i;
		for (auto& p : b[i]) {
			ans[p.second] = tree.get(i) - (p.first ? tree.get(p.first - 1) : 0);
		}
	}
	for (int i : ans) cout << i << '\n';
}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	srand(time(0));
	int t = 1;
	//int t;
	//cin >> t;
	while (t--) solve();
}

Measured memory_bytes: 44192
#include<iostream>
using namespace std;
int main(){
	string s1;
	string s2;
	while(cin>>s1>>s2){
		int sum1,sum2;
		cin>>sum1>>sum2;
		string com;
		cin>>com;
		if(com==s1){
			sum1--;
		}else{
			sum2--;
		}
		cout<<sum1<<" "<<sum2<<endl;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
int main()
{
	ll n,ansnum=0;
	cin >> n;
	vector<int> a(n+1, 0);
	vector<int> ans(n + 1, 0);
	for (ll i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	for (ll i = n; i >= 1; i--)
	{
		ll sum = 0;
		for (ll j = 2*i; j <= n; j += i)
		{
			sum += ans[j];
		}
		if (sum % 2 != a[i])
		{
			ans[i] = 1;
			ansnum++;
		}
	}
	cout << ansnum << endl;
	for (ll i = 1; i <= n; i++)
	{
		if (ans[i] == 1) cout << i<<' ';
	}
}


Measured memory_bytes: 2432
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
public class Hello
{
    private const long INF = 1000000007;
    private struct Pair { public long x, y; public Pair(long xx, long yy) { x = xx; y = yy; } }
    public static void Main()
    {
        int N = NextInt();
        int K = NextInt();
        long[] a = LineLong();

        long[] b = new long[N + 1];
        for (int i = 1; i <= N; i++) b[i] = b[i - 1] + a[i - 1];

        //とりまN^2で全列挙
        List<long> next = new List<long>();
        for (int i = 0; i <= N; i++)
            for (int j = i + 1; j <= N; j++) next.Add(b[j] - b[i]);

        //各bitについて、立っているものが何個あるか数える
        //log_2(10^12) = 40
        for (int bit = 40; bit >= 0; bit--)
        {
            List<long> A = new List<long>();
            List<long> B = new List<long>();
            foreach (var C in next) {
                if ((1 & C >> bit) == 1) A.Add(C);
                else B.Add(C);
            }
            if (A.Count() >= K) next = A;
        }
        long ans = next[0];
        next.ForEach(v => ans &= v);
        Console.WriteLine(ans);

    }

}

public class Input
{
    private static Queue<string> queue = new Queue<string>();
    private static void Confirm() { if (queue.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) queue.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(queue.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(queue.Dequeue()); }
    public static string NextString() { Confirm(); return queue.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(queue.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 35544
a=int(input())
b=input().split(" ")
sequence=[]
for i in range(0,a):
    sequence.append(int(b[i]))
error=[]
for q in range(0,a-1):
    if sequence[q]-sequence[q+1]>0:
        error.append(q)
        error.append(q+1)

if len(error)==0:
    print("YES")

elif len(error)==2:
    if a==2:
        print("YES")
    elif error[0]==0:
        if sequence[error[0]+2]-sequence[error[0]]>0:
            print("YES")
        else:
            print("NO")
    elif error[1]==a-1:
        if sequence[error[1]]-sequence[error[1]-2]>0:
            print("YES")
        else:
            print("NO")
    else:
        if  sequence[error[1]]-sequence[error[1]-2]>0 and sequence[error[0]+2]-sequence[error[0]]>0:
            print("YES")
        else:
            print("NO")

elif len(error)==4:
    if error[1]==error[2]:
        if sequence[error[0]]>sequence[error[3]]:
            if error[0]==0 and error[3]==a-1:
                if sequence[error[0]]-sequence[error[3]-1]>0 and sequence[error[0]+1]-sequence[error[3]]>0:
                    print("YES")
                else:
                    print("NO")
            elif error[0]==0:
                if sequence[error[0]+3]-sequence[error[0]]>0:
                    print("YES")
                else:
                    print("NO")
            elif error[1]==a-1:
                if sequence[error[3]]-sequence[error[3]-3]>0:
                    print("YES")
                else:
                    print("NO")
            else:
                if  sequence[error[3]]-sequence[error[3]-3]>0 and sequence[error[0]+3]-sequence[error[0]]>0:
                    print("YES")
                else:
                    print("NO")
    elif sequence[error[0]]-sequence[error[2]]>0 and sequence[error[1]]-sequence[error[3]]>0:
        if error[0]==0 and error[3]==a-1:
            if sequence[error[0]]-sequence[error[3]-1]>0 and sequence[error[0]+1]-sequence[error[3]]>0:
                print("YES")
            else:
                print("NO")
        elif error[0]==0:
            if sequence[error[3]+1]-sequence[error[0]]>0:
                print("YES")
            else:
                print("NO")
        elif error[3]==a-1:
            if sequence[error[3]]-sequence[error[0]-1]>0:
                print("YES")
            else:
                print("NO")
        elif sequence[error[3]]-sequence[error[0]-1]>0 and sequence[error[3]+1]-sequence[error[0]]>0:
            print("YES")
        else:
            print("NO")
    else:
        print("NO")

else:
    print("NO")

Measured memory_bytes: 3192
import java.io.*;
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        int N = Integer.parseInt(br.readLine());
 
        for (int i = 0; i < N; i++) {
            int base = 0;
            int out = 0;
            int point = 0;
 
            while (out < 3) {
                String str = br.readLine();
 
                switch (str) {
                case "HIT":
                    point += base & 1;
                    base = (base | 8) >> 1;
             
                    break;
                case "HOMERUN":
                    point += Integer.bitCount(base)+1;
                    base = 0;
                     
                    break;
                case "OUT":
                    out++;
                    break;
                }
            }
             
            System.out.println(point);
        }
 
    }
}

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

int main(void){
    int N, K;
    
    cin >> N >> K;
    
    vector<int> A(N);
    
    for (int i = 0;i < N;i++) {
        cin >> A[i];
    }
    
    for (int i = K;i < N;i++) {
        if (A[i - K] < A[i]) {
            cout << "Yes" << endl;
        } else {
            cout << "No"  << endl;
        }
    }


    return 0;    
}

Measured memory_bytes: 4016
#include <stdio.h>
#include <string.h>

void bubble(char [],int [],int);
void selection(char [],int [],int);

int main()
{
  int number[36],Number[36];
  char array[36],Array[36];
  char blak;
  int i,n,flag=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%c%c%d",&blak,&array[i],&number[i]);
    Number[i]=number[i];
    Array[i]=array[i];
  }


  bubble(array,number,n);
  selection(Array,Number,n);

  for(i=0;i<n;i++)
    {
      if(array[i]!=Array[i]) {
      printf("Not stable\n");
      flag=1;
      break;
      }
    }
  if(flag==0) printf("Stable\n");
  return 0;
}

void bubble(char array[],int number[],int n)
{
  int i,j;
  int temp;
  char Temp;

  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(number[j]<number[j-1]){
	temp=number[j];
	Temp=array[j];
	number[j]=number[j-1];
	array[j]=array[j-1];
	number[j-1]=temp;
	array[j-1]=Temp;
      }
    }
  }
  for(i=0;i<n-1;i++){
    printf("%c%d ",array[i],number[i]);
  }
  printf("%c%d\n",array[i],number[i]);
  printf("Stable\n");

}


void selection(char array[],int number[],int n)
{
  int i,j,min;
  int temp;
  char Temp;

  for(i=0;i<n;i++){
    min=i;
    for(j=i;j<n;j++){
      if(number[j]<number[min]){
	min=j;
      }
    }
	temp=number[i];
	Temp=array[i];
	number[i]=number[min];
	array[i]=array[min];
	number[min]=temp;
	array[min]=Temp;
  }

  for(i=0;i<n-1;i++){
    printf("%c%d ",array[i],number[i]);
  }
  printf("%c%d\n",array[i],number[i]);    
}

Measured memory_bytes: 608
import sys
sys.setrecursionlimit(200000)
N = int(input())
ans = [0] * (N - 1)
AB = []
for i in range(N-1):
    a,b = map(int,input().split())
    AB.append([a-1,b-1])
G = [list() for _ in range(N)]
for i in range(N-1):
    G[AB[i][1]].append([AB[i][0],i])
    G[AB[i][0]].append([AB[i][1],i])

def dfs(v,c = -1,p = -1):
    k = 1
    for i in range(len(G[v])):
        u = G[v][i][0];ei = G[v][i][1]
        if u == p:continue
        if k == c:
            k += 1
        ans[ei] = k
        k += 1
        dfs(u,ans[ei],v)
dfs(0)
mx = 0
for i in range(N):
    mx = max(mx,len(G[i]))
print(mx)
for i in range(N-1):
    print(ans[i])

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


	}
        return 0;
}



Measured memory_bytes: 1960
n,k = map(int, input().split())
t = [int(input()) for i in range(n)]

def check(p):
    """
    :param p: 最大積載量
    :return: 積むことができる荷物の数
    """
    global k # トラックの台数
    global t # 荷物の重さのリスト
    i = 0
    for _ in range(k):
        remaining = p
        while remaining >= t[i]:
            remaining -= t[i]
            i += 1
            if  i == len(t):
                return i
    return i

lo = 0
hi = 10**6 * 10**4

p = 0

while hi - lo > 1:
    mid = (lo + hi) // 2
    if check(mid) < n:
        lo = mid
    else:
        hi = mid
ans = hi
print(ans)


Measured memory_bytes: 9564