akhauriyash/Code-Regression huggingface dataset:
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#include <functional>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi   vector<int> 
#define   co(x)  cout << x << '\n' 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) a.begin(),a.end() 
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){ 
    int  n, ans = 0, cur = 0 ; 
    cin >> n ; 
    vi  a(n) ; 
    bool ok = true ; 
    for (int i=0;i<n;i++){ 
        cin >> a[i] ; 
        if (a[i] and a[i] == cur) ans++;
        else ans += a[i] ; 
        if (a[i] > cur)  ok = false ; 
        cur = a[i] + 1 ; 
    }
    cout << ( ok ? ans : -1 ) << endl ; 
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 4816
#include <iostream>
#include <set>
#include <vector>
using namespace std;
set<int> s;
vector<int> v;
int a[100010];
int main(){
	long long i,n;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	for(i=1;i*i<=a[0];i++){
		if(a[0]%i==0){
			s.insert(i); s.insert(a[0]/i);
		}
	}
	for(i=1;i*i<=a[1];i++){
		if(a[1]%i==0){
			s.insert(i); s.insert(a[1]/i);
		}
	}
	int ans = 1,j;
	for(auto x: s){
		v.push_back(x);
	}
	for(i=v.size() - 1;i>=0;i--){
		int cnt = 0,x = v[i];
		for(j=0;j<n;j++){
			if(a[j]%x!=0) cnt++;
			if(cnt>=2) break;
			if(j==n-1){
				cout << x << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 640
import java.util.*;


public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        int money = Integer.parseInt(line);
      
      if (money < 30){
            System.out.println("No");
        } else {
            System.out.println("Yes");
    }
    }
}

Measured memory_bytes: 35644
#include <iostream>
using namespace std;
using ll = long long;

int main(){
	int n,m;
	ll x[100010]={},y[100010]={};
	ll width=0,height=0;
	
	cin >> n >> m;
	for(int i=1;i<=n;i++){
		cin >> x[i];
	}
	for(int i=1;i<=m;i++){
		cin >> y[i];
	}
	
	for(int k=1;k<=n;k++){
		width+=(k-1)*x[k]-(n-k)*x[k];
		width=width%1000000007;
	}
	for(int l=1;l<=m;l++){
		height+=(l-1)*y[l]-(m-l)*y[l];
		height=height%1000000007;
	}
	
	cout << width*height%1000000007 << endl;
	return 0;
}


Measured memory_bytes: 1792
N,W=map(int,input().split())
v=[]
w=[]
for i in range(N):
  x,y=map(int,input().split())
  v.append(x)
  w.append(y)
dp=[[0 for i in range(W+1)] for j in range(N+1)]
for i in range(1,N+1):
  for j in range(W+1):
      if(j-w[i-1]>=0):
          dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1])
      else:
          dp[i][j]=dp[i-1][j]
print(dp[N][W])


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

using namespace std;

vector<int> G[100000];
int g[100000];
bool isBipartite;
int cnt;

void dfs(int v, int c){
    cnt++;
    g[v] = c;
    //cout << v << ' ' << c << endl;
    int col;
    if(c == 1) col = 2;
    else col = 1;
    for(int i = 0; i < G[v].size(); i++){
        if(g[G[v][i]] == 0)  dfs(G[v][i], col);
        else if(g[G[v][i]] != col) isBipartite = false;
    }
}

int main(){
    int N, M;
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    long cnt_b = 0;
    long cnt_s = 0;
    long cnt_nb = 0;
    for(int i = 0; i < N; i++){
        isBipartite = true;
        cnt = 0;
        if(g[i] == 0){
            dfs(i, 1);
            //cout << i << ' ' << cnt << ' ' << isBipartite << endl;
            if(isBipartite && cnt != 1) cnt_b++;
            else if(cnt != 1)cnt_nb++;
            if(cnt == 1) cnt_s++;
        }
    }
    //cout << cnt_b << ' ' << cnt_nb << ' ' << cnt_s << endl;
    long ans = cnt_b*cnt_b*2+cnt_b*cnt_nb*2+cnt_nb*cnt_nb+2*cnt_s*N-cnt_s*cnt_s;
    cout << ans << endl;
}

Measured memory_bytes: 9984
from heapq import heappush, heappop

n, m = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(n)]


jobs = [[] for _ in range(m)]
for a, b in ab:
    if a <= m:
        jobs[a - 1].append(-b)

ans = 0
available = []
for job in jobs:
    for jo in job:
        heappush(available, jo)

    if available:
        ans -= heappop(available)

print(ans)


Measured memory_bytes: 31056
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
inline bool BETWEEN(int x, int min,int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
using namespace std;
#pragma endregion
signed main() {
	int A=0;
	string S;
	cin >> S;
	rep(i, 3) {
		if (S[i] == '1')
			A++;
	}
	cout << A << endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Apolloliu
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

void get() {

}

int sum[510][510];
typedef pair<int,int> pii;

class DAtCoderExpress2 {
public:
	void solve(std::istream& in, std::ostream& out) {
		int n, m, q, x, y;
		in >> n >> m >> q;
		memset(sum, 0, sizeof(sum));

		for (int i = 0; i < m; ++i) {
			in >> x >> y;
			sum[x][y] ++;
		}

		for (int i = 1; i <= n ; ++i) {
			for (int j = 1; j <= n ; ++j) {
				sum[i][j] += sum[i][j-1];
				sum[i][j] += sum[i-1][j];
				sum[i][j] -= sum[i-1][j-1];
			}
		}
		for (int i = 0; i < q; ++i) {
			in >> x >> y;
			out << sum[y][y] - sum[y][x-1] - sum[x-1][y] + sum[x-1][x-1] << '\n';
		}
	}
};


int main() {
	DAtCoderExpress2 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

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

#define all(a) a.begin(), a.end()
#define ff first
#define ss second
#define pb push_back

using ll = long long;
using pii = pair<int, int>;

template<typename T> using V = vector<T>;

const int MAX_N = 1e5 + 5;
vector<int> adj[3 * MAX_N];
bool visit[3 * MAX_N];
int dist[3 * MAX_N];

inline void make_edge(int u, int v) {
	adj[u].pb(v);
}

int main() {
	ios::sync_with_stdio(false);cin.tie(nullptr);
	int N, M; cin >> N >> M;
	for (int i = 0; i < M; ++i) {
		int u, v; cin >> u >> v;
		make_edge(3 * u, 3 * v + 1);
		make_edge(3 * u + 1, 3 * v + 2);
		make_edge(3 * u + 2, 3 * v);
	}
	int S, T; cin >> S >> T;
	S *= 3; T *= 3;
	queue<int> Q;
	dist[S] = 0;
	Q.push(S);
	while(!Q.empty()) {
		int cur = Q.front();
		Q.pop();
		if(visit[cur])
			continue;
		visit[cur] = true;
		for (auto nxt : adj[cur]) {
			if(!visit[nxt]) {
				Q.push(nxt);
				dist[nxt] = dist[cur] + 1;
			}
		}
	}
	cout << (visit[T] ? (dist[T] / 3) : -1) << '\n';
	return 0;
}

Measured memory_bytes: 18176
//BISMILLAHIR RAHMANIR RAHIM
//RHYTHM_086_NS_01
//ALAN_IS_ON....

#include <bits/stdc++.h>

//define

#define                boost_                         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define                iter_(i,n)                     for (int i = 0; i < int(n); i++)
#define                for_n(i, n)                    for (int i = 1; i <= int(n); i++)
#define                pb                             push_back
#define                mp                             make_pair
#define                itr                            ::iterator
#define                s_sort(s)                      sort(s.begin(),s.end())
#define                n_sort(a)                      sort(a,a+n)
#define                thank_you                      return 0
#define                thanks                         return
#define                pii                            pair<int,int>
#define                precise_impact                 cout<<setprecision(10)<<fixed;

using namespace std;

//data type
typedef long long int ll;
typedef unsigned long long int ulli;
typedef double db;


//constants
#define PI acos(-1.00)
#define MOD 1000000007

ll bigmod(ll a,ll b){
    if(b==0){
        return 1;
    }
    ll tm=bigmod(a,b/2);
    tm=(tm*tm)%MOD;
    if(b%2==1)
        tm=(tm*a)%MOD;
    return tm;

}
int egcd(int a,int b,int &x,int &y){
    if(a==0){
        x=0;
        y=1;
        return b;
    }
    int x1,y1;
    int d=egcd(b%a,a,x1,y1);
    x=y1-(b/a)*x1;
    y=x1;
    return d;
}

void solve();


int main()
{
    boost_;
    precise_impact;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //Here we go...
    int t=1;
    //cin>>t;
    while(t--)
        solve();

    thank_you;
}


void solve()
{
    int n,c=0,mn=1e9;
    cin>>n;
    iter_(i,n){
        int x;
        cin>>x;
        if(x<mn)
            c++,mn=min(mn,x);
    }
    cout<<c<<endl;
}



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

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#define int long long

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 200000 + 10;
const int MOD = 1000000007;
const int LOG = 20;
const int INF = 1000000010;
const int delta = 11353;

int n, k, ans[N], TP[N], D[N];
bool Can[N];
vi V[N];
multiset<int> Tak[N];

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//freopen("soal1.in", "r", stdin);
	cin >> n >> k;
	bool f = 0;
	//freopen("soal1.in", "r", stdin);
	for (int i = 1; i <= n; i++){
		int c, v;
		cin >> c >> v;
		V[c].pb(v);
	}	
	for (int i = 1; i <= k; i++) f |= ((int)V[i].size() > 2);
	for (int i = 2; i <= n; i++){
		if (i % 2 == 0) Can[i] = 1;
		else if(f) Can[i] = 1;
	}
	vector<pair<pair<long double, int>, int>> num;
	set<pii> T3, Dou;
	multiset<int> Sol;
	multiset<int> T1;
	for (int i = 1; i <= k; i++){
		sort(all(V[i]));
		reverse(all(V[i]));
		num.pb({{(V[i][0] + V[i][1]) * 1.0 / 2.0, i}, 1});
		D[i] = V[i][0] + V[i][1];
		for (int j = 2; j < V[i].size(); j++) Tak[i].insert(V[i][j]),num.pb({{V[i][j], i}, 0});
		if (V[i].size() >= 3) TP[i] = V[i][0] + V[i][1] + V[i][2], T3.insert({TP[i], i});
	}
	sort(all(num));
	reverse(all(num));
	int sm = 0;
	int cnt = 0;
	for (auto u:num){
		//cout << u.F.F << ' ' << u.F.S << ' ' << u.S << '\n';
		if (u.S == 0){
			sm += u.F.F;
			ans[++cnt] = sm;
			Sol.insert((int)u.F.F);
			Tak[u.F.S].erase(Tak[u.F.S].find((int)u.F.F));
			T1.erase(T1.find((int)u.F.F));
			if (Tak[u.F.S].size())T1.insert(*Tak[u.F.S].rbegin());
			Dou.erase({D[u.F.S], u.F.S});
			continue;
		}
		u.F.F *= 2;
		cnt++;
		if (Can[cnt]){
			//cout << "Fuck " << sm << '\n';
			//if (cnt == 68) cout << "Fuck\n" << '\n';
			if (Sol.size()) ans[cnt] = max(ans[cnt], sm - (*Sol.begin()) + (int)u.F.F);
			//if (cnt == 7) cout << "Fuck " << ans[cnt] << '\n';
			if (Dou.size() && T3.size()){
				ans[cnt] = max(ans[cnt], sm - (*Dou.begin()).F + (*T3.rbegin()).F);
			} 
			//if (cnt == 7) cout << "Fuck " << ans[cnt] << '\n';
			if (T1.size()) ans[cnt] = max(ans[cnt], sm + (*T1.rbegin()));
			//if (cnt == 7) cout <<"Fuck " << ans[cnt] << '\n';
		}
		if (Tak[u.F.S].size() != 0) T1.insert(*Tak[u.F.S].rbegin());
		Dou.insert({(int)u.F.F, u.F.S});
		T3.erase({TP[u.F.S], u.F.S});
		sm += u.F.F;
		cnt++;
		//if (cnt == 6) return cout << "Fuck\n", 0;
		ans[cnt] = sm;
	}
	//cout << "Yes\n";
//	freopen("soal1.out", "r", stdin);
	for (int i = 1; i <= n; i++){
		cout << (Can[i] ? ans[i]:-1) << '\n';
	}

	return 0;
}


Measured memory_bytes: 40616
N,M=map(int,input().split())
H=list(map(int,input().split()))
ls=[[] for i in range(N)]
for i in range(M):
    A,B=map(int,input().split())
    ls[A-1].append(B-1)
    ls[B-1].append(A-1)
cnt=0    
for i in range(N):
    flag=True
    for j in range(len(ls[i])):
        if(H[ls[i][j]]>=H[i]):
            flag=False
    if(flag):cnt+=1        
print(cnt)    

Measured memory_bytes: 92768
#include <bits/stdc++.h>
#define ll long long
#define f(i, x, n) for(int i = x; i < n; i++)
#define dbg(x) cout << x << endl
#define dbg2(x, y) cout << x << "  " << y << endl
#define dbg3(x, y, z) cout << x << "  " << y << "  " << z << endl
#define mod 1000000007
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    int e, o;
    cin >> e >> o;
    int sum = 0;
    if(e >= 2){
        sum += (e * (e-1))/2;
    }
    if(o >= 2){
        sum += (o * (o -1))/2;
    }
    cout << sum << endl;

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long a = n / 11;
        long b = n % 11;
        long c;
        if (b == 0) {
            c = 0;
        } else if (b <= 6) {
            c = 1;
        } else {
            c = 2;
        }
        
        long answer = a * 2 + c;
        
        // 5 11 16 22 27 33 38 44
        
        System.out.println(answer);
    }
}

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

const int N=2e3+20;

int n,x;
vector <pair <int,int>> v;
long long dp[N][N];

long long f(int l,int r)
{
	long long &ans=dp[l][r];
	if(ans!=-1) return ans;

	int i=l+(n-1-r); // total i elements have been assigned position
	int old_pos=v[i].second;
	if(l==r) return ans=v[i].first*abs(l-old_pos); // only 1 position possible which is l
	//else we can put it on two ends l or r
	return ans=max(1ll*v[i].first*abs(l-old_pos)+f(l+1,r), 1ll*v[i].first*abs(r-old_pos)+f(l,r-1));
}

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&x);
		v.push_back({x,i});
	}

	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++) dp[i][j]=-1;
	sort(v.rbegin(),v.rend());
	printf("%lld",f(0,n-1));
}

Measured memory_bytes: 35444
def _calc_today_max(today, Ci, Sdi, last_day):
    today_total_bad_value = \
        sum([Ci[contest] * (today + 1 - last_day[contest]) for contest in range(26)])

    max_value = -999999999
    max_context = 0
    for contest in range(26):
        today_contest_value = Sdi[today][contest]
        today_bad_value = today_total_bad_value - Ci[contest]
        today_value = today_contest_value - today_bad_value
        if max_value < today_value:
            max_value = today_value
            max_context = contest
    return max_context


def _main(D, Ci, Sdi):
    last_day = [0] * 26
    for today in range(D):
        max_contest = _calc_today_max(today, Ci, Sdi, last_day)
        print(max_contest + 1)
        last_day[max_contest] = today + 1


def _execute():
    D = int(input())
    Ci = list(map(int, input().split()))
    Sdi = []
    for i in range(D):
        Sdi.append(list(map(int, input().split())))
    _main(D, Ci, Sdi)


if __name__ == "__main__":
    _execute()


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

int main(){
    int r,d,x;
    cin >> r >> d >> x;
    for(int i = 1; i <= 10;i++){
        x = r*x - d;
        cout << x << endl;
    }
}

Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var xn = IO.RSInt;
            if (xn[1] == 0)
            {
                WriteLine(xn[0]);
                return;
            }
            var a = IO.RSInt;
            Array.Sort(a);

            if (!a.Contains(xn[0]))
            {
                WriteLine(xn[0]);
                return;
            }

            int x1 = xn[0];
            x1--;
            int x2 = xn[0];
            x2++;
            while (true)
            {
                if (!a.Contains(x1))
                {
                    WriteLine(x1);
                    return;
                }
                x1--;
                if (!a.Contains(x2))
                {
                    WriteLine(x2);
                    return;
                }
                x2++;
            }

        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 28296
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>

using namespace std;

struct before_main{before_main(){cin.tie(0); ios::sync_with_stdio(false);}} before_main;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

string S;

unordered_set<int> X[3] = {{1,4,7},{2,8},{3,6,9}};

void solve() {
  int N = S.size();
  int ans = inf;
  rep(o, 2) {
    int res = 0;
    int s = 0;
    rep(i, N-1) {
      if((i+o+s)&1) {
        if(S[i] == 2 && X[0].count(S[i+1])) { res ++; s++; }
        if(S[i] == 8 && X[0].count(S[i+1])) { res ++; s++; }
        if(S[i] == 3 && X[0].count(S[i+1])) { res ++; s++; }
        if(S[i] == 6 && X[0].count(S[i+1])) { res ++; s++; }
        if(S[i] == 9 && X[0].count(S[i+1])) { res ++; s++; }
        if(S[i] == 3 && X[1].count(S[i+1])) { res ++; s++; }
        if(S[i] == 6 && X[1].count(S[i+1])) { res ++; s++; }
        if(S[i] == 9 && X[1].count(S[i+1])) { res ++; s++; }
      } else {
        if(S[i] == 1 && X[1].count(S[i+1])) { res ++; s++; }
        if(S[i] == 4 && X[1].count(S[i+1])) { res ++; s++; }
        if(S[i] == 7 && X[1].count(S[i+1])) { res ++; s++; }
        if(S[i] == 1 && X[2].count(S[i+1])) { res ++; s++; }
        if(S[i] == 4 && X[2].count(S[i+1])) { res ++; s++; }
        if(S[i] == 7 && X[2].count(S[i+1])) { res ++; s++; }
        if(S[i] == 2 && X[2].count(S[i+1])) { res ++; s++; }
        if(S[i] == 8 && X[2].count(S[i+1])) { res ++; s++; }
      }
    }
    minimize(ans, res);
  }
  cout << ans << endl;
}

int main() {

  for(; cin >> S;) {
    if(S == "#") { break; }
    rep(i, S.size()) S[i] -= '0';
    solve();
  }
  
  return 0;
}

Measured memory_bytes: 3264
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
struct UnionFind {
    //自身が親であれば、その集合に属する頂点数に-1を掛けたもの
    //そうでなければ親のid
    vector<int> r;
 
    UnionFind(int N) {
        r = vector<int>(N, -1);
    }
 
    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }
 
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }
 
    int size(int x) {
        return -r[root(x)];
    }
};
 
 
int main() {
    int N, M;
    cin >> N >> M;
 
    //友達集合を作る
    UnionFind UF(N);
    for (int i = 0; i < M; i++)
    {
        int A, B;
        cin >> A >> B;
        A -= 1; B -= 1;
        UF.unite(A, B);
    }
 
    //最大の友達集合を求める
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        ans = max(ans, UF.size(i));
    }
 
    cout << ans << endl;
}


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

using namespace std;

int n, k, a[200005], b[200005], t, ans;

int main()
{
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 1; i <= n; i++)
        b[a[i]]++;
    sort (b+1, b+n+1);
    for (int i = 1; i <= n; i++)
        if (b[i] != 0)
        {
            t = i;
            break;
        }
    for (int i = t; i <= n - k; i++)
        ans += b[i];
    cout << ans;
}


Measured memory_bytes: 1792
/** @Date    : 2017-07-06 09:56:44
  * @FileName: atcoder077 D 组合.cpp
  * @Platform: Windows
  * @Author  : Lweleth (SoungEarlf@gmail.com)
  * @Link    : https://github.com/
  * @Version : $Id$
  */
#include <bits/stdc++.h>
#define LL long long
#define PII pair
#define MP(x, y) make_pair((x),(y))
#define fi first
#define se second
#define PB(x) push_back((x))
#define MMG(x) memset((x), -1,sizeof(x))
#define MMF(x) memset((x),0,sizeof(x))
#define MMI(x) memset((x), INF, sizeof(x))
using namespace std;

const int INF = 0x3f3f3f3f;
const int N = 1e5+20;
const double eps = 1e-8;
const LL mod = 1e9 + 7;

LL a[N];
LL inv[N];
LL fa[N];
LL n;

void init()
{
	fa[0] = fa[1] = 1;
    inv[1] = 1;
    for(LL i = 2; i < N; i++)
    {
        fa[i] = fa[i-1] * i % mod;
        inv[i] = (mod - mod / i) * inv[mod % i] % mod;
    }
    inv[0] = 1;
    for(int i = 1; i < N; i++)
    	(inv[i] *= inv[i - 1]) %= mod;
}

LL C(LL n, LL k)
{
	LL ans = 0;
	if(k > n)
		return ans;
	ans = ((fa[n] * inv[k] % mod) * inv[n - k]) % mod;
	return ans;
}
int main()
{
	init();
	while(cin >> n)
	{
		map<LL, int>q;
		LL p = 0;
		for(int i = 1; i <= n + 1; i++)
		{
			scanf("%lld", a + i);
			if(!q[a[i]])
				q[a[i]] = i;
			else 
				p = i;
		}
		for(int i = 0; i <= n; i++)
		{
			LL ans = 0;
			ans = (ans + C(n + 1, i + 1)) % mod;
			ans = (ans - C(n - p + q[a[p]], i)) % mod;
			while(ans < 0)
				ans += mod;
			printf("%lld\n", ans);
		}
	}
    return 0;
}


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

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

    int R, C, K;
    cin >> R >> C >> K;
    vector<vector<int>> item(R + 5, vector<int>(C + 5));
    for (int i = 0; i < K; ++i) {
        int r, c, v;
        cin >> r >> c >> v;
        r--, c--;
        item[r][c] = v;
    }

    static ll dp[3005][3005][5];
    for (int i = 0; i < R; ++i) {
        for (int j = 0; j < C; ++j) {
            for (int k = 3; k >= 0; --k) {
                if (k > 0)
                    dp[i][j][k] = max(dp[i][j][k], dp[i][j][k - 1] + item[i][j]);
                dp[i][j + 1][k] = max(dp[i][j + 1][k], dp[i][j][k]);
                dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][k]);
            }
        }
    }

    ll ans = 0;
    for (int i = 0; i <= 3; ++i)
        ans = max(ans, dp[R - 1][C - 1][i]);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 390892
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define kill _z_kill
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define User_Time ((double)clock()/CLOCKS_PER_SEC)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int mod=1e9+7;
int Pow(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=(LL)x*x%mod)
		if (y&1)
			ans=(LL)ans*x%mod;
	return ans;
}
void Add(int &x,int y){
	if ((x+=y)>=mod)
		x-=mod;
}
void Del(int &x,int y){
	if ((x-=y)<0)
		x+=mod;
}
int Add(int x){
	return x>=mod?x-mod:x;
}
int Del(int x){
	return x<0?x+mod:x;
}
const int N=5005;
int n,A,B;
int dp[N][N];
int s1[N][N],s2[N][N];
int pw2[N];
int main(){
	n=read(),A=read(),B=read();
	pw2[0]=1;
	For(i,1,n+1)
		pw2[i]=Add(pw2[i-1]<<1);
	if (A<B)
		swap(A,B);
	dp[0][0]=1;
	int ans=0;
	For(i,0,n-1)
		For(j,0,i){
			int &v=dp[i][j];
			if (i>0)
				Add(s1[i][j],s1[i-1][j]);
			Add(v,s1[i][j]);
			if (i>0&&j>0)
				Add(s2[i][j],s2[i-1][j-1]);
			Add(v,s2[i][j]);
//			printf("dp[%d][%d]=%d\n",i,j,v);
			if (!v)
				continue;
			int L=0,R=n-i-1;
			if (j+1>=A)
				Add(ans,(LL)v*pw2[n-i-1]%mod);
			else
				Add(dp[i+1][j+1],v);
			L=1;
			int b=max(L-1,min(B-1,R));
			Add(s1[i+L+1][1],v);
			Del(s1[i+b+2][1],v);
			L=b+1;
			if (L<=R){
				int a=min(R+1,max(L,A-j-1));
				//[a~R]
				if (a<=R){
					//pw2[n-i-1-R]+..+pw2[n-i-1-a]
					int x=n-i-1-R,y=n-i-1-a;
					Add(ans,(LL)v*Del(pw2[y+1]-pw2[x])%mod);
				}
				R=a-1;
				if (L<=R){
					Add(s2[i+L+1][j+L+1],v);
					Del(s2[i+R+2][j+R+2],v);
				}
			}
//			For(k,0,n-i-1){
//				if (0<k&&k<B)
//					Add(dp[i+k+1][1],v);
//				else if (j+k+1>=A)
//					Add(ans,(LL)v*Pow(2,n-i-k-1)%mod);
//				else
//					Add(dp[i+k+1][j+k+1],v);
//			}
			if (n-i>=B&&j+n-i>=A)
				Add(ans,v);
		}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 204092
<?php
$n = (int)trim(fgets(STDIN));
$str = '';
for ($i=3; $i<=$n; ++$i) {
  if (($i % 3 === 0) || (strpos((string)$i, '3') !== false) ) $str .= " $i";
}
echo $str, PHP_EOL;

Measured memory_bytes: 15316
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

int h, w;

bool isIN(int y, int x){
    return (0<=y&&y<h && 0<=x&&x<w);
}

char m[21][21];

int ans = 0;

int dy[] = {0, 0, -1, 1};
int dx[] = {-1, 1, 0, 0};
void bfs(int sy, int sx){
    int d[21][21];
    rep(i, 21)rep(j, 21) d[i][j] = INF;

    using P = pair<int, int>;
    queue<P> que;
    d[sy][sx] = 0;
    que.push({sy, sx});
    while(que.size() != 0){
        P next = que.front();
        que.pop();
        int y = next.first;
        int x = next.second;
        rep(i, 4){
            int ny = next.first + dy[i];
            int nx = next.second + dx[i];
            if(isIN(ny, nx) && m[ny][nx] != '#' && d[ny][nx] > d[y][x]+1){
                que.push({ny, nx});
                d[ny][nx] = d[y][x] + 1;
            }
        }
    }
    int tmp = 0;
    rep(i, h){
        rep(j, w) if(d[i][j] != INF)chmax(tmp, d[i][j]);
    }
    chmax(ans, tmp);
}

int main(){
    cin >> h >> w;
    rep(i, h){
        rep(j, w) cin >> m[i][j];
    }

    rep(i, h){
        rep(j, w) if(m[i][j] != '#') bfs(i, j);
    }
    cout << ans << endl;
} 

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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

bool sieve[1000001];
bool dp[1000001];

int main() {
    sieve[0] = sieve[1] = true;
    FOR(i, 2, 1000001) {
        if (sieve[i]) continue;
        for (int j = i + i; j < 1000001; j += i) {
            sieve[j] = true;
        }
    }

    int n, money;
    while (cin >> n >> money, n|money) {
        fill_n((bool *)dp, 1000001, false);
        dp[0] = true;
        REP(i, n) {
            int food;
            cin >> food;
            REP(j, money-food+1) {
                if (dp[j]) dp[j+food] = true;
            }
        }
        for (int i = money; i >= 0; i--) {
            if (!sieve[i] && dp[i]) {
                cout << i << endl;
                goto END;
            }
        }
        cout << "NA" << endl;
END: {}
    }
}

Measured memory_bytes: 3112
n, q = gets.chomp.split(' ').map(&:to_i)
tree = Array.new(n) { [] }
result = Array.new(n, 0)
(n - 1).times do
  a, b = gets.chomp.split(' ').map(&:to_i)
  tree[a - 1].push(b - 1)
  tree[b - 1].push(a - 1)
end
q.times do
  x, p = gets.chomp.split(' ').map(&:to_i)
  result[x - 1] += p
end

queue = [0]
visited = Hash.new(false)
while queue.count > 0 do
  i = queue.shift
  visited[i] = true
  tree[i].each do |j|
    next if visited[j]
    result[j] += result[i]
    visited[j] = true
    queue.push(j)
  end
end
print result.join(' ')

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

int main(void){
	char s[101];
	int k,len;
    
    scanf("%d",&k);
	scanf("%s",s);
	len=strlen(s);
	
	if(len>k){
		int i;
		for(i=0;i<k;i++)printf("%c",s[i]);
		printf("...\n");
	}else
		printf("%s\n",s);

    return 0;
}

Measured memory_bytes: 1648
#include <stdio.h>

int main(int argc, const char * argv[]){
    int w,h,x,y,r;
    scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
    
    if (0 <= x - r && x + r <= w && 0 <= y - r && y + r <= h) printf("Yes\n");
    else printf("No\n");
}



Measured memory_bytes: 2140
n = gets.to_i
t, a = gets.split.map(&:to_i)
list = gets.split.map(&:to_i)
ans = tmp = 0
dis = 100000

list.each_with_index do |h, i|
    tmp = t - h*0.006
    if (a-tmp).abs < dis
        ans = i+1
        dis = (a-tmp).abs
    end
end

puts ans

Measured memory_bytes: 1788
#include <stdio.h>

int main(void){
  int i, k, x;
  
  scanf("%d %d",&k,&x);
  
  if(k==1){
    printf("%d\n",x);
  }
  
  else{
  	for(i=k-1;i>=0;i--){
    	printf("%d ", x-i);
  	}
    
    for(i=1;i<=k-1;i++){
      printf("%d ", x+i);
    }
    
    printf("\n");
  }
  
  return 0;
}

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

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

const int MOD = 1e9 + 7;
const int N = 1e5 + 5;
int A[N];
ll fac[N], inv[N];
int n, k, t;
unordered_map<int, int> ma;

ll power(ll a, ll b) {
  ll res = 1;
  while (b) {
    if (b & 1) {
      res = res * a % MOD;
    }
    a = a * a % MOD;
    b >>= 1;
  }
  return res;
}

void init() {
  fac[0] = 1;
  for (int i = 1; i < N; ++i) {
    fac[i] = fac[i - 1] * i % MOD;
  }
  inv[N - 1] = power(fac[N - 1], MOD - 2);
  for (int i = N - 2; i >= 0; --i) {
    inv[i] = inv[i + 1] * (i + 1) % MOD;
  }
}

ll C(ll a, ll b) {
  return fac[a] * inv[b] % MOD * inv[a - b] % MOD;
}

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

  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> t;
    ++ma[t];
  }
  vector<ii> v(ma.begin(), ma.end());
  sort(v.rbegin(), v.rend());

  ll res = 0;
  int tt = n;
  for (auto p : v) {
    if (tt < k) break;
    int value = p.first;
    int cnt = p.second;
    for (int i = 1; i <= min(k, cnt); ++i) {
      if (k - i > tt - cnt) continue;
      res = (res + (C(cnt, i) * C(tt - cnt, k - i) % MOD) * value % MOD) % MOD;
    }
    tt -= cnt;
  }
  tt = n;

  for (auto it = v.rbegin(); it != v.rend(); ++it) {
    if (tt < k) break;
    int value = it->first;
    int cnt = it->second;

    for (int i = 1; i <= min(k, cnt); ++i) {
      if (k - i > tt - cnt) continue;
      res = (res - (C(cnt, i) * C(tt - cnt, k - i) % MOD) * value % MOD) % MOD;
    }
    tt -= cnt;
  }
  if (res < 0)
    res += MOD;

  cout << res << endl;

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(), A.end());
  int i = 0;
  ll ans = 1;
  if (N % 2 == 1) {
    if (A[0] == 0)
      i++;
    else {
      cout << 0 << endl;
      return 0;
    }
  }
  for (; i < N; i += 2) {
    if (A[i] == A[i + 1] && A[i] == i + 1) {
      ans = ans * 2 % (ll)(1e9 + 7);
    } else {
      cout << 0 << endl;
      return 0;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<stack>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#define rep(a,b) for(int a=0;a<b;++a)
#define REP(a,b,c,d) for(int a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_i = pair<int, int>;
int main() {
	vector<int> N(3);
	rep(i, 3)cin >> N[i];
	sort(N.begin(), N.end());
	cout << N[0] * N[1] * 1 / 2 << endl;
	cin >> N[0];
}

Measured memory_bytes: 256
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = LIST()
dp = [[0]*n for i in range(2)]
# dp[0][i]: {a[i], a[i+1]}に-1を乗算しないときのa[i]までの和の最大値
# dp[1][i]: {a[i], a[i+1]}に-1を乗算したときのa[i]までの和の最大値

for i in range(n):
    if i == 0:
        dp[0][i] = a[i]
        dp[1][i] = -a[i]
    else:
        dp[0][i] = max(dp[0][i-1]+a[i], dp[1][i-1]-a[i])
        dp[1][i] = max(dp[0][i-1]-a[i], dp[1][i-1]+a[i])

print(dp[0][-1])

Measured memory_bytes: 25800
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <functional>
using namespace std;
#define Mod 10007

int num[10] = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };

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

    //桁数
    for (int i = 1; i < N+1; i++) {
        for (int j = 0; j < M; j++) {
            if (i >= num[A[j]]) { 
                if (digit[i - num[A[j]]] >= 0) {
                    digit[i] = max(digit[i], digit[i - num[A[j]]] + 1);
                }
            }
        }
    }

    int n = N;
    while (n!=0) {
        for (int i = 0; i < M; i++) {
            if (n >= num[A[i]]) {
                if (digit[n - num[A[i]]] == digit[n] - 1) {
                    cout << A[i];
                    n -= num[A[i]];
                    break;
                }
            }
        }
    }
    cout << "\n";

    return 0;
}

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

using namespace std;

int main() {

    int s; cin >> s;

    int a[1000000];
    int ans = 0;
    a[0] = s;


    for (int i = 1; i <= 1000000; ++i) {
        if (a[i-1] % 2 == 0) {
            a[i] = a[i-1] / 2;
        } else {
            a[i] = 3 * a[i-1] + 1;
        }

        for (int j = 0; j < i; ++j) {
            if (a[j] == a[i]) {
                ans = i + 1;
                break;
            }
        }

        if (ans > 0) {
            break;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
mod = 10 ** 9 + 7

from math import factorial

def comb(n, k):
    return factorial(n) // factorial(n - k) // factorial(k)

def f2(n, k):
    return comb(n + k - 1, k - 1)

def f(n, k):
    if n < k:
        return 0
    if n == 0 and k == 0:
        return 1
    if k < 1:
        return 0
    return f2(n - k, k)

for i in range(1, k + 1):
    blue = f(k, i)
    red = f(n - k, i - 1) + f(n - k, i) + \
          f(n - k, i) + f(n - k, i + 1)
    print(int(blue * red % mod))

Measured memory_bytes: 71896
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

xyc= [list(map(int, input().split())) for _ in range(M)]

minmoney = min(a) + min(b)

for obj in xyc:
    summoney = a[obj[0] - 1] + b[obj[1] - 1] - obj[2]
    minmoney = min(minmoney, summoney)

print(minmoney)

Measured memory_bytes: 38768
#include<stdio.h>

int main(){
    int n,ji,hun,byou,h,m,s;
    scanf("%d",&n);
    hun=n%3600;
    byou=hun%60;

    if(n>=3600)ji=(n-hun);
    else ji=0;

    h=ji/3600;
    m=(hun-byou)/60;
    s=byou;

    printf("%d:%d:%d\n",h,m,s);
    return 0;
    }
    


Measured memory_bytes: 2148
import sys
A,B = map(int,input().split())

if not ( 1 <= A <= 100 and 1 <= B <= 100 ): sys.exit()
if not ( isinstance(A,int) and isinstance(B,int) ): sys.exit()

print( A - (B * 2)) if A - (B * 2) >= 0 else print(0)



Measured memory_bytes: 9156
#include <stdio.h>

int main(){
  long n;
  long a[100001] = {};
  long count = 0;
  long maxt = 0;

  scanf("%ld", &n);

  for(long i = 0; i < n; i++){
    long t;
    scanf("%ld", &t);
    a[t]++;
    if(maxt < t) maxt = t;
  }
  // printf("%d" , maxt);

  for(long i = 0; i <= maxt; i++){
    if(a[i] >= 2) count += a[i] - 1;
  }

  if(count%2 == 1) count++;

  long ans;
  ans = n - count;

  printf("%ld", ans);
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
const ll mLINF=-LINF;
int main(){
    int n;cin >> n;
    vector<vector<ll>> f(n,vector<ll>(10));
    vector<vector<ll>> p(n,vector<ll>(11));
    for(int i=0; i<n; i++){
        for(int j=0; j<10; j++){
            cin >> f[i][j];
        }
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<11; j++){
            cin >> p[i][j];
        }
    }
    ll ans=mLINF;
    for(int bit=1; bit<1<<10; bit++){
        vector<int> open;
        for(int j=0; j<10; j++){
            if(bit>>j&1) open.push_back(j);
        }
        vector<int> cnt(n);
        for(auto d: open){
            for(int i=0; i<n; i++){
                if(f[i][d]==1) cnt[i]++;
            }
        }
        ll sum=0;
        for(int i=0; i<n; i++){
            sum+=p[i][cnt[i]];
        }
        ans=max(ans,sum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

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

class Solver {
	int maxA, maxB, minA, minB;

public:
	Solver() {
		maxA = maxB = -INF;
		minA = minB = INF;
	}

	void update(int x, int y) {
		int a = x + y, b = x - y;
		chmax(maxA, a);
		chmax(maxB, b);
		chmin(minA, a);
		chmin(minB, b);
	}

	int Ans() {
		return max(maxA - minA, maxB - minB);
	}
};

int main(void) {
	int num, i, x, y;
	Solver d;
	cin >> num;
	rep(i, num) {
		cin >> x >> y;
		d.update(x, y);
	}
	cout << d.Ans() << "\n";
	return 0;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <stack>
#include <utility>

using namespace std;

int main() {
	int H, W;
	scanf("%d %d", &H, &W);

	int A[H][W];
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			scanf("%d", &A[i][j]);
		}
	}
	int V[H + 1][W + 1];
	for (int i = 0; i <= H; ++i) {
		for (int j = 0; j <= W; ++j) {
			V[i][j] = 0;
		}
	}
	for (int j = 0; j < W; ++j) {
		for (int i = 1; i <= H; ++i) {
			if (A[i - 1][j] == 0)
				V[i][j] = V[i - 1][j] + 1;
			else {
				V[i][j] = 0;
			}
		}
	}

	int maxArea = 0;
	for (int i = 1; i <= H; ++i) {
		stack<pair<int, int>> S;
		S.push(make_pair(0, V[i][0]));
		for (int j = 1; j <= W; ++j) {
			pair<int, int> p = S.top();
			if (V[i][j] > p.second) {
				S.push(make_pair(j, V[i][j]));
			} else if (V[i][j] < p.second) {
				int pos;
				while (!S.empty() && V[i][j] <= p.second) {
					S.pop();
					if (p.second > 0)
						pos = p.first;
					int area = (j - p.first) * p.second;
					maxArea = max(maxArea, area);
					if (!S.empty())
						p = S.top();
				}
				S.push(make_pair(pos, V[i][j]));
			}
		}
	}
	cout << maxArea << endl;

	return 0;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

static const ll INF = 1e15;

const ll mod = 1000000007;

const int zero = 5000;

bool ok(char c, char d) {
	if (c == '?' || d == '?') return true;
	if (c == d) return true;
	return false;
}

int main(void)
{
	string a, b, c;
	cin >> a >> b >> c;
	vector<bool> ab(10000, true);
	vector<bool> bc(10000, true);
	vector<bool> ac(10000, true);
	rep(i, a.size()) rep(j, b.size()) {
		if (!ok(a[i], b[j])) ab[zero + i - j] = false;
	}
	rep(i, b.size()) rep(j, c.size()) {
		if (!ok(b[i], c[j])) bc[zero + i - j] = false;
	}
	rep(i, a.size()) rep(j, c.size()) {
		if (!ok(a[i], c[j])) ac[zero + i - j] = false;
	}
	int s = a.size() + b.size() + c.size();
	int u = s;
	for (int bIndex = -s; bIndex <= s;bIndex++) {
		for (int cIndex = -s; cIndex <= s; cIndex++) {
			auto left = min(min(0, (int)bIndex), (int)cIndex);
			auto right = max(max((int)a.size(), bIndex + (int)b.size()), cIndex + (int)c.size());
			int r = right - left;
			if (r >= u) continue;
			if (ab[zero + bIndex]) {
				if (ac[zero + cIndex]) {
					if (bc[zero - bIndex + cIndex]) {
						u = r;
					}
				}
			}
		}
	}
	cout << u << endl;
	return 0;
}


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

using namespace std;
using ll = long long;
constexpr int mod = 1e9+7;
constexpr int md = mod;
int main(){
    int n;
    cin>>n;
    vector<int> w(n);
    for(auto &a : w)cin>>a;
    int s1 = 0;
    int s2 = accumulate(w.begin(),w.end(),0);
    int ret = s2;
    for(int i=0;i<n;++i){
        s1 += w[i];
        s2 -= w[i];
        ret = min(abs(s1-s2),ret);
    }
    cout << ret << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <cmath>
#include <cstdio>

using namespace std;

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

typedef long long ll;

int main(){
    int a,b,c;
    int d,e,f;
    d = e = f = 0;
    while(true){
        cin >> a >> b >> c;
        if(!(a < b + c && b < a + c && c < a + b)){
            break;
        }
        vector<int> vec;
        vec.push_back(a);
        vec.push_back(b);
        vec.push_back(c);
        sort(vec.begin(),vec.end());
        int p = vec[0] * vec[0] + vec[1] * vec[1];
        int g = vec[2];
        if(p == g*g){
            d++;
        }else if(p>g*g){
            e++;
        }else{
            f++;
        }
    }
    cout << d + e + f << " " << d <<  " " << e << " " << f << endl;
    return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

ll l;
int n;
ll x[200001];
ll sl[200005],sr[200005];
int main(){
    cin>>l>>n;
    rep(i,n) cin>>x[i];
    rep(i,n){
        sl[i+1]=sl[i]+x[i];
        sr[i+1]=sr[i]+l-x[n-i-1];
    }
    ll ans=0;
    rep(i,n){
        int m=min(i,n-i-1);
        int r=n-i;
        ll dist=(sl[i]-sl[i-m])*2;
        dist+=(sr[r]-sr[r-m-1])*2;
        dist-=sr[r]-sr[r-1];
        ans=max(ans,dist);

        m=min(i,n-i);
        dist=(sl[i]-sl[i-m])*2;
        dist+=(sr[r]-sr[r-m])*2;
        dist-=sr[r]-sr[r-1];
        ans=max(ans,dist);
    }
    rep(i,n) swap(sl[i+1],sr[i+1]);
    rep(i,n){
        int m=min(i,n-i-1);
        int r=n-i;
        ll dist=(sl[i]-sl[i-m])*2;
        dist+=(sr[r]-sr[r-m-1])*2;
        dist-=sr[r]-sr[r-1];
        ans=max(ans,dist);

        m=min(i,n-i);
        dist=(sl[i]-sl[i-m])*2;
        dist+=(sr[r]-sr[r-m])*2;
        dist-=sr[r]-sr[r-1];
        ans=max(ans,dist);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define ll long long
#define increase(a) sort(a.begin(), a.end())
#define decrease(a) sort(a.rbegin(), a.rend())
#define loop(n) for(ll i = 0; i<n; i++)
using namespace std;

int main(){
    int a, b;
    cin>>a>>b;
    string A = "", B = "";
    for(int i = 0; i<a; i++){
        A = A + to_string(b);
    }
    for(int i = 0; i<b; i++){
        B = B + to_string(a);
    }
    if(A<B) cout<<A;
    else cout<<B;
    return 0;
}

Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

int main() {
    int N;
    cin >> N;
    ll ans = 0;
    for (int i = 1; i <= N; i++) {
        if(i % 3 == 0 || i % 5 == 0) {
            continue;
        }
        ans += i;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3640