akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
#include <climits>
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;


ll n;

int main() {
    cin >> n;
    vector<ll> e(n+1);
    FOR(i,2,n+1){
        ll cur = i;
        FOR(j,2,i+1){
            while((cur%j)==0){
                e[j] += 1;
                cur /= j;
            }
        }
    }
    ll res = 0;
    REP(i,n){
        REP(j,n){
            REP(k,n){
                if(e[i]>=4&&e[j]>=4&&e[k]>=2&&i<j&&i!=k&&j!=k){
                    res += 1;
                }
                
            }
        }
    }
    REP(i,n){
        REP(j,n){
            if(e[i]>=14&&e[j]>=4&&i!=j){
                res++;
            }
            if(e[i]>=24&&e[j]>=2&&i!=j){
                res++;
            }
        }
    }
    REP(i,n){
        if(e[i]>=74){
            res++;
        }
    }
    put(res);
    return 0;
}


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

namespace kyoupuro {

    class MainClass {

        public static void Main() {
            long H = Input.NextLong();
            long W = Input.NextLong();
            long diff1 = long.MaxValue;
            long diff2 = long.MaxValue;
            long diff3 = H % 3 == 0 ? 0 : W; // ロシア型
            long diff4 = W % 3 == 0 ? 0 : H; // イタリア型

            // 右上占拠
            for (int i = 1; i <= H; i++) {
                if (W * i > (W / 2) * (H - i)) {
                    diff1 = Math.Min(diff1, Math.Max(W * i, ((W + 1) / 2) * (H - i)) - (W / 2) * (H - i));
                    break;
                } else {
                    diff1 = ((W + 1) / 2) * (H - i) - W * i;
                }
            }

            // 左下占拠
            for (int i = 1; i <= W; i++) {
                if(H*i>(H/2)*(W-i)) {
                    diff2 = Math.Min(diff2, Math.Max(H * i, ((H + 1) / 2) * (W - i)) - (H / 2) * (W - i));
                } else {
                    diff2 = ((H + 1) / 2) * (W - i) - H * i;
                }
            }

            Console.WriteLine(Math.Min(diff1, Math.Min(diff2, Math.Min(diff3, diff4))));
        }


    }

    class Input {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
#include <iomanip>
using namespace std;

constexpr double eps = 1e-8;
constexpr double INF = 1e9;

struct edge {
    int to;
    double cost;
};

using edges = vector<edge>;
using graph = vector<edges>;

struct state {
    int v;
    int t;
    double time;
    bool operator>(state const& other) const {
        return time > other.time;
    }
};

int main() {
    int n, m, p, a, b;
    while(cin >> n >> m >> p >> a >> b, n) {
        a--; b--;
        vector<int> t(n);
        for(int i=0; i<n; ++i) {
            cin >> t[i];
        }
        graph g(m);
        for(int i=0; i<p; ++i) {
            int x, y;
            double z;
            cin >> x >> y >> z;
            x--; y--;
            g[x].push_back((edge){y, z});
            g[y].push_back((edge){x, z});
        }
        priority_queue<state, vector<state>, greater<state>> que;
        vector<vector<double>> d(m, vector<double>(1<<n, INF));
        d[a][(1<<n)-1] = 0;
        que.push(state{a, (1<<n)-1, 0});
        while(!que.empty()) {
            state s = que.top(); que.pop();
            int v = s.v;
            for(auto e : g[v]) {
                int to = e.to;
                for(int i=0; i<n; ++i) {
                    if((s.t >> i) & 1) {
                        int next = (s.t & (((1 << n) - 1) ^ (1 << i)));
                        if(d[to][next] > eps + d[v][s.t] + e.cost / t[i]) {
                            d[to][next] = d[v][s.t] + e.cost / t[i];
                            que.push(state{to, next, d[to][next]});
                        }
                    }
                }
            }
        }
        double ans = *min_element(d[b].begin(), d[b].end());
        if(fabs(ans - INF) <= eps) {
            cout << "Impossible" << endl;
        } else {
            cout << fixed << setprecision(10) << ans << endl;
        }
    }
}


Measured memory_bytes: 4608
#include <stdio.h>
int n, x, y, z, t, w;
int main() {
	while(~scanf("%d", &n), n) {
		int ret = 0;
		for(int i = 0; i < n; i++) {
			scanf("%d%d%d%d", &x, &y, &z, &w); t = x + y + z;
			if(t <= 60 && w <= 2) ret += 600;
			else if(t <= 80 && w <= 5) ret += 800;
			else if(t <= 100 && w <= 10) ret += 1000;
			else if(t <= 120 && w <= 15) ret += 1200;
			else if(t <= 140 && w <= 20) ret += 1400;
			else if(t <= 160 && w <= 25) ret += 1600;
		}
		printf("%d\n", ret);
	}
	return 0;
}

Measured memory_bytes: 2664
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//int n = int.Parse(Console.ReadLine());
			//string s = Console.ReadLine();
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			long n = vs[0];
			long k = vs[1];
			long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();

			int[] bit = new int[40];
			long b = 1;
			for (int i = 0; i < bit.Length; i++) {
				foreach (var j in a) {
					if ((j & b) != 0) {
						bit[i]++;
					}
				}
				b *= 2;
			}
			//System.Diagnostics.Debug.WriteLine(string.Join(" ", bit));

			long x = 0;
			b = 0x8000000000;
			for (int i = bit.Length - 1; i >= 0; i--) {
				if (n - bit[i] > bit[i] && (x | b) <= k) {
					x |= b;
				}
				b /= 2;
			}
			//System.Diagnostics.Debug.WriteLine($"{x}");

			long ans = 0;
			foreach (var i in a) {
				ans += i ^ x;
			}
			Console.WriteLine(ans);


			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 31324
#include <stdio.h>
 
int main(void)
{
    int hen1, hen2, taikaku;
    int tyouhoukei, hishigata; 
     
    tyouhoukei = 0;
    hishigata = 0;
     
    while(scanf("%d, %d, %d" , &hen1, &hen2, &taikaku) != EOF){
         
        if ((hen1 * hen1) + (hen2 * hen2) == (taikaku * taikaku)){
            tyouhoukei++;
        }
         
        else if (hen1 == hen2){
            hishigata++;
        }
    }
     
    printf("%d\n" , tyouhoukei);
    printf("%d\n" , hishigata);
     
    return (0);
}

Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <random>
#include <ctime>
#include <bitset>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define ld long double
#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast_io cout.tie(0), cin.tie(0), ios_base::sync_with_stdio(0)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ld eps = (ld)1 / 1e9;
ll inf = 1e18, mod2 = 998244353, mod1 = 1e9 + 7;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main()
{
    fast_io;
    ld a, b, n, z;
    cin >> a >> b >> n;
    z = min(n, b - 1);
    cout << floor(z * a / b) - a * floor(z / b);
    return 0;
}

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


int main()
{
	unsigned long n, a, b;

	cin >> n >> a >> b;

	unsigned long sum = 0;
	for (unsigned long iN = 1; iN <= n; iN++)
	{
		unsigned long last = iN;

		unsigned long rank10000 = last / 10000;
		last -= rank10000 * 10000;

		unsigned long rank1000 = last / 1000;
		last -= rank1000 * 1000;

		unsigned long rank100 = last / 100;
		last -= rank100 * 100;

		unsigned long rank10 = last / 10;
		last -= rank10 * 10;

		unsigned long rank1 = last;

		unsigned long temp_sum = rank10000 + rank1000 + rank100 + rank10 + rank1;
		if (temp_sum >= a && temp_sum <= b)
		{
			sum += iN;
		}
	}

	cout << sum << endl;
}

//int main()
//{
//	int coin500, coin100, coin50;
//	int x;
//
//	cin >> coin500 >> coin100 >> coin50 >> x;
//
//	int count_pattern = 0;
//	for (int i500 = 0; i500 <= coin500; i500++)
//	{
//		for (int i100 = 0; i100 <= coin100; i100++)
//		{
//			for (int i50 = 0; i50 <= coin50; i50++)
//			{
//				if (i500 * 500 + i100 * 100 + i50 * 50 == x)
//				{
//					count_pattern++;
//				}
//			}
//		}
//	}
//
//	cout << count_pattern << endl;
//}

//int main()
//{
//	int n;
//	vector<int> list;
//
//	cin >> n;
//
//	for (int i = 0; i < n; i++)
//	{
//		int num;
//		cin >> num;
//		list.push_back(num);
//	}
//
//	int proc_count = 0;
//	while (true)
//	{
//		bool valid = true;
//		for (int i = 0; i < n; i++)
//		{
//			if (list[i] % 2 > 0)
//			{
//				valid = false;
//				break;
//			}
//			else
//			{
//				list[i] /= 2;
//			}
//		}
//
//		if (valid == true)
//		{
//			proc_count++;
//		}
//		else
//		{
//			break;
//		}
//	}
//
//	cout << proc_count << endl;
//}

//int main()
//{
//	string str;
//
//	cin >> str;
//
//	int count_one = 0;
//
//	if (str[0] == '1')
//	{
//		count_one++;
//	}
//	
//	if (str[1] == '1')
//	{
//		count_one++;
//	}
//
//	if (str[2] == '1')
//	{
//		count_one++;
//	}
//
//	cout << count_one << endl;
//}


//int main()
//{
//	int a, b;
//
//	cin >> a >> b;
//
//	int c = a * b;
//
//	if (c % 2 == 0)
//	{
//		cout << "Even" << endl;
//	}
//	else
//	{
//		cout << "Odd" << endl;
//	}
//}

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

using namespace std;
typedef long long ll;

ll ans;
int main(){
	ll n;
	cin >> n;
	map<string , int> mp;

	for(int i = 0; i < n; i++){
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		ans += mp[s];
		mp[s]++;
	}
	cout << ans << endl;
}

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

int main(void) {
    int n;
    cin >> n;
    int a[300010];
    for (int i = 0; i < n * 3; i++) {
        cin >> a[i];
    }

    ll left_sum = 0;
    priority_queue<ll, vector<ll>, greater<ll> > left_pq;
    for (int i = 0; i < n; i++) {
        left_sum += a[i];
        left_pq.push(a[i]);
    }
    ll right_sum = 0;
    priority_queue<ll> right_pq;
    for (int i = 2 * n; i < n * 3; i++) {
        right_sum += a[i];
        right_pq.push(a[i]);
    }

    ll left_p_sums[n + 1];
    left_p_sums[0] = left_sum;
    for (int i = 0; i < n; i++) {
        left_pq.push(a[i + n]);
        left_sum += a[i + n];
        left_sum -= left_pq.top();
        left_pq.pop();
        left_p_sums[i + 1] = left_sum;
    }
    ll right_p_sums[n + 1];
    right_p_sums[n] = right_sum;
    for (int i = 0; i < n; i++) {
        right_pq.push(a[2 * n - 1 - i]);
        right_sum += a[2 * n - 1 - i];
        right_sum -= right_pq.top();
        right_pq.pop();
        right_p_sums[n - 1 - i] = right_sum;
    }

    ll ans = left_p_sums[0] - right_p_sums[0];
    for (int i = 1; i <= n; i++) {
        ans = max(ans, left_p_sums[i] - right_p_sums[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4724
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define LL long long
using namespace std;
LL read() {
    LL k = 0; char c = getchar();
    while(c < '0' || c > '9') c = getchar();
    while(c >= '0' && c <= '9')
        k = k * 10 + c - 48, c = getchar();
    return k;
}
LL sum;
int main() {
    int n = read(), m = read();
    for(int i =  1; i <= m; ++i) {
        sum += read();
        if(sum >= n) {
            cout << "Yes"; return 0;
        }
    }
    cout << "No";




    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {

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

    while (true) {
      int h = sc.nextInt();
      if (h == 0) return;
      int cell[][] = new int [h][5];
      for (int i = 0; i < h; i++) {
        for (int j = 0; j < 5; j++) {
          cell[i][j] = sc.nextInt();
        }
      }
      int score = 0;
      /* 00000
         11111
         22222 */

      boolean flag;
      while (true) {
        flag = false;
        for (int i = 0; i < h; i++) {
          int num = cell[i][2];
          int count = 1;
          for (int j = 1; j >= 0 && cell[i][j] == num && cell[i][j] != 0; j--) count++;
          for (int j = 3; j < 5  && cell[i][j] == num && cell[i][j] != 0; j++) count++;
          if (count >= 3) {
            score += num * count;
            flag = true;
            cell[i][2] = 0;
            for (int j = 1; j >= 0 && cell[i][j] == num; j--) cell[i][j] = 0;
            for (int j = 3; j < 5  && cell[i][j] == num; j++) cell[i][j] = 0;
          }
        }
/*
        for (int i = 0; i < h; i++) {
          for (int j = 0; j < 5; j++) {
            System.out.print(" ");
            System.out.print((cell[i][j] == 0 ? " " : cell[i][j]));
          }
          System.out.println();
        }
        System.out.println();
*/

        if (!flag) break;

        for (int n = 0; n < h; n++) {
          for (int i = h-1; i >= 1; i--) {
            for (int j = 0; j < 5; j++) {
              if (cell[i][j] == 0) {
                for (int k = i; k >= 0; k--) {
                  if (k == 0) cell[k][j] = 0;
                  else {
                    cell[k][j] = cell[k-1][j];
                    cell[k-1][j] = 0;
                  }
                }
              }
            }
          }
        }
/*
        for (int i = 0; i < h; i++) {
          for (int j = 0; j < 5; j++) {
            System.out.print(" ");
            System.out.print((cell[i][j] == 0 ? " " : cell[i][j]));
          }
          System.out.println();
        }
        System.out.println();
        */
      }
      System.out.println(score);
    }
  }
}



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

int main(void) {
 int K;
 scanf("%d",&K);
 int array[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
 printf("%d",array[K-1]);

 return EXIT_SUCCESS;
}


Measured memory_bytes: 128
s = input()
s = s.replace('BC', 'D')
ans = []
tmp = 0
for i in reversed(range(len(s))):
    if s[i] == 'D':
        tmp += 1
    elif s[i] == 'A':
        ans.append(tmp)
    else:
        tmp = 0

print(sum(ans))

Measured memory_bytes: 10704
/* by Natsu Kinmoe */
#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define loop(i,n) for(int i=0;i<(n);i++)
#define cont(i,n) for(int i=1;i<=(n);i++)
#define circ(i,a,b) for(int i=(a);i<=(b);i++)
#define range(i,a,b,c) for(int i=(a);((c)>0?i<=(b):i>=(b));i+=(c))
#define foreach(it,v) for(__typeof((v).begin()) it=(v).begin(),_e_D_=(v).end();it!=_e_D_;it++)
#define y0 y0O0OO00OO0OO0OO0OOO00OO0OO0O0O000OO0
#define y1 y1II11II11III11I1III11II111IIII1II1I1
#define pub push_back
#define pob pop_back
#define mak make_pair

typedef long long ll;
typedef long double lf;
const int Inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3fll;
/* Source code starts here */

int n;
int a[2005];
bitset<(1<<22)> bs;

int main(){
	scanf("%d",&n);
	int sm=0;
	cont(i,n)scanf("%d",a+i),sm+=a[i];
	bs.set(0);
	cont(i,n)bs|=bs<<a[i];
	sm=(sm+1)>>1;
	while(1){
		if(bs[sm])return 0&printf("%d\n",sm);
		sm++;
	}
}

Measured memory_bytes: 5332
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;
int main(int argc, char const *argv[])
{
    int N; cin >> N;
    std::vector<int> p(N);

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

    for(int i=0; i<N; ++i) {
        if(p[i] - 1 != i) {
            int idx_from = i;
            int idx_to = p[i]-1;

            int tmp = p[idx_from];
            p[idx_from] = p[idx_to];
            p[idx_to] = tmp;
            break;
        }
    }

    for(int i=0; i<N; ++i) {
        if(p[i] - 1 != i) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#include <complex>
#define ll long long
#define INF 1000000000000000001
#define MOD 998244353
using namespace std;


int main(){
    int M;
    cin >> M;
    
    ll d[200000], c[200000];
    for(int i=0; i<M; i++){
        cin >> d[i];
        cin >> c[i];
    }
    
    ll ans = 0;
    
    
    for(int i=0; i<M; i++){
        if(d[i]==0){
            ans += c[i]-1;
            c[i]=1;
        }
        
        ll buf = 0;
        ll tempd = d[i];
        ll tempc = c[i];
        while(tempc>1){
            if(tempc%2 == 0){
                tempd = tempd*2;
                if(tempd<10){
                    ans+=tempc/2;
                }else{
                    ans+=tempc;
                    tempd = (tempd%10)+1;
                }
                tempc /= 2;
            }else{
                if(buf!=0){
                    ans++;
                }
                buf += tempd;
                if(buf>=10){
                    ans++;
                    buf = buf%10 +1;
                }
                
                tempd = tempd*2;
                if(tempd<10){
                    ans += tempc/2;
                }else{
                    ans += tempc-1;
                    tempd = (tempd%10)+1;
                }
                
                tempc /= 2;
            }
            
            //cout<<"d:"<<tempd<<" "<<"c:"<<tempc<<" buf:"<<buf<<" ans:"<<ans<<endl;
        }
        
        d[i] = tempd+buf;
        if(buf>0){
            ans++;
        }
        if(d[i]>=10){
            ans++;
            d[i] = (d[i]%10)+1;
        }
        c[i] = tempc;
    }
    
    
    
    /*
    cout<<"ans:"<<ans<<endl;
    cout<<"result"<<endl;
    for(int i=0; i<M; i++){
        cout<<d[i]<<" "<<c[i]<<endl;
    }
    */
    for(int i=0; i<M-1; i++){
        ans++;
        if(d[i]+d[i+1]>=10){
            d[i+1] = (d[i]+d[i+1])%10 +1;
            ans++;
        }else{
            d[i+1] = d[i]+d[i+1];
        }
    }
    
    cout<<ans<<endl;
    return 0;
    
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=998244353;
const LL LINF=1LL<<62;
const LL INF=1<<17;
map<P,int> ma;
map<P,int> st;

LL fpow(LL a, LL n){
    LL x = 1;
    while(n > 0){
        if(n&1){
            x=x*a%mod;
        }
        a=a*a%mod;
        n >>= 1;
    }
    return x;
}


int main(){
    LL n,m;cin >> n >> m;
    vector<LL> t(n,0);
    LL k=n*(n-1)-2*(n-1)-2*(n-2);
    for (int i = 0; i < m; i++) {
        int a,b,c;
        cin >> a >> b >> c;
        a--,b--;
        st[{a,b}]=c+2;
        if(a>b) swap(a,b);
        if(ma[{a,b}]){
            if(ma[{a,b}]!=c+2){
                if(abs(a-b)>=3){
                    puts("0");
                    return 0;
                }
                else{
                    if((a+b)%2==0){
                        if(t[(a+b)/2]==2){
                            puts("0");
                            return 0;
                        }
                        t[(a+b)/2]=3;
                    }
                }
            }
            else{
                if(abs(a-b)<3&&(a+b)%2==0){
                    if(t[(a+b)/2]==3){
                        puts("0");
                        return 0;
                    }
                    t[(a+b)/2]=2;
                }
            }
        }
        if(a==b){
            if(t[a]!=c+2&&t[a]){
                puts("0");
                return 0;
            }
            t[a]=c+2;
        }
        if(abs(a-b)>2&&ma[{a,b}]==0) k-=2;
        ma[{a,b}]=c+2;
    }
    LL dp[n][2];
    memset(dp,0,sizeof(dp));
    if(t[0]!=3) dp[0][0]=1;
    if(t[0]!=2) dp[0][1]=1;
    st[{n,n-2}]=1,st[{n-2,n}]=1;
    for (int i = 0; i < n-1; i++) {
        if(st[{i,i+1}]==0&&st[{i+1,i}]==0){
            dp[i+1][0]=(2*dp[i][0]+2*dp[i][1])%mod;
            dp[i+1][1]=(2*dp[i][0]+2*dp[i][1])%mod;
        }
        else if(st[{i,i+1}]==0||st[{i+1,i}]==0){
            dp[i+1][0]=(dp[i][0]+dp[i][1])%mod;
            dp[i+1][1]=(dp[i][0]+dp[i][1])%mod;
        }
        else{
            dp[i+1][0]=dp[i][(st[{i,i+1}]+st[{i+1,i}])%2]%mod;
            dp[i+1][1]=dp[i][(1+st[{i,i+1}]+st[{i+1,i}])%2]%mod;
        }
        if(st[{i,i+2}]==0&&st[{i+2,i}]==0){
            dp[i+1][0]*=2;
            dp[i+1][1]*=2;
        }
        if(t[i+1]==3) dp[i+1][0]=0;
        else if(t[i+1]==2) dp[i+1][1]=0;
    }
    cout << (dp[n-1][0]+dp[n-1][1])%mod*fpow(2,k/2)%mod << endl;
    return 0;
}


Measured memory_bytes: 33792
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n;
		int c[]=new int[7];
		while(true){
			n=sc.nextInt();
			if(n==0) break;
			Arrays.fill(c, 0);
			
			for(int i=0;i<n;i++){
				int k=sc.nextInt();
				int m=60;
				for(int j=0;j<7;j++){
					if(m<=k){
						c[6-j]++;
						break;
					}
					m-=10;
				}
			}
			for(int j=0;j<7;j++){
				System.out.println(c[j]);
			}
		}
	}

}

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

int main() {
  int N;
  cin>>N;
  vector<int> v(N);
  for (int i = 0; i < N; i++) {
    cin >> v.at(i);
  }
  sort(v.begin(), v.end());
  int a=0;
  for(int i=0; i<N;i++){
    for(int j=i+1; j<N;j++){
      for(int k=j+1; k<N;k++){
        if(v.at(j)<v.at(i)+v.at(k)&&v.at(k)<v.at(j)+v.at(i)){
        a++;
        }
      }
    }
  }
  cout <<a<<endl;
  
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

class Main {

	// ?????°
	static final int n = 10;

	// ?????°
	static final int m = 10;

	// ???????????´????°?
	static final String INK_SIZE_SMALL = "1";

	// ???????????´??????
	static final String INK_SIZE_MEDIUM = "2";

	// ???????????´?????§
	static final String INK_SIZE_LARGE = "3";

	public static void main(String[] args) throws IOException {

		int[][] paper = new int[n][m];

		// 1.?¨?????????????????????????
		BufferedReader bufferedReader = new BufferedReader(
				new InputStreamReader(System.in), 1);

		// 2.??????????????????
		String line;
		while ((line = bufferedReader.readLine()) != null) {
			// 2-1.??????????????????
			String inkSize = line.split(",")[2];
			int x = Integer.parseInt(line.split(",")[0]);
			int y = Integer.parseInt(line.split(",")[1]);

			// 2-2.????????????
			if (INK_SIZE_SMALL.equals(inkSize)) {
				paper = smallInk(x, y, paper);
			} else if (INK_SIZE_MEDIUM.equals(inkSize)) {
				paper = mediumInk(x, y, paper);
			} else if (INK_SIZE_LARGE.equals(inkSize)) {
				paper = largeInk(x, y, paper);
			}
		}

		// 3.????????????????????????????????°?????????
		// 4.????????????

		int colorless = 0;
		int depth = 0;

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				// ????????????????????????????????°???????????????
				if (paper[i][j] == 0) {
					colorless++;
				}
				// ???????????????????????¢???
				if (depth < paper[i][j]) {
					depth = paper[i][j];
				}
			}
		}
		System.out.println(colorless);
		System.out.println(depth);
	}

	private static int[][] smallInk(int x, int y, int[][] array) {
		if (x - 1 >= 0) {
			array[y][x - 1]++;
		}

		if (y - 1 >= 0) {
			array[y - 1][x]++;
		}
		array[y][x]++;
		if (y + 1 < n) {
			array[y + 1][x]++;
		}

		if (x + 1 < m) {
			array[y][x + 1]++;
		}
		return array;
	}

	private static int[][] mediumInk(int x, int y, int[][] array) {
		array = smallInk(x, y, array);
		if (y - 1 >= 0) {
			if (x - 1 >= 0)
				array[y - 1][x - 1]++;
			if (x + 1 < m)
				array[y - 1][x + 1]++;
		}
		if (y + 1 < n) {
			if (x - 1 >= 0)
				array[y + 1][x - 1]++;
			if (x + 1 < m)
				array[y + 1][x + 1]++;
		}

		return array;
	}

	private static int[][] largeInk(int x, int y, int[][] array) {
		array = mediumInk(x, y, array);
		if (x - 2 >= 0) {
			array[y][x - 2]++;
		}

		if (y - 2 >= 0) {
			array[y - 2][x]++;
		}
		if (y + 2 < n) {
			array[y + 2][x]++;
		}

		if (x + 2 < m) {
			array[y][x + 2]++;
		}

		return array;
	}

}

Measured memory_bytes: 16968
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			int num = stdIn.nextInt();
			if(num == 0)
			{
				break;
			}
			List<Integer> list = new ArrayList<Integer>();
			int multipleOfFive = 5;
			while(num >= multipleOfFive)
			{
				list.add(multipleOfFive);
				multipleOfFive *= 5;
			}
			int ans = 0;
			for(int i = 0; i < list.size(); ++i)
			{
				ans += num / list.get(i);
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 11000
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long N,M;
  cin >> N >> M;
  int long long ans=0; 
  for(int i=0;i<M;i++){
    int b;
    cin >> b;
    ans+=b;
  }
  if(ans<=N)cout << N-ans << endl;
  else{
    cout << -1 << endl;
  }
}

Measured memory_bytes: 3636
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;



int main(int argc, const char * argv[])
{
    int n, r, c;
    int na, nb;
    while(cin >> n >> r){
        if(n % 2 == 0){
            na = n / 2;
            nb = n / 2;
        }else{
            na = (n + 1) / 2;
            nb = (n - 1) / 2;
        }
        
        // カード置き場初期化
        int cards[n], acards[n], bcards[n];
        for(int i = 0; i < n; i++){
            cards[i] = i;
        }
        
        for(int i = 0; i < r; i++){
            cin >> c; // cを読む
            // カード分割
            for(int j = 0; j < nb; j++){
                bcards[j] = cards[j];
            }
            for(int j = 0; j < na; j++){
                acards[j] = cards[nb + j];
            }
            
            // DEBUG Code
            // cout << bcards[0] << " " << acards[0] << "\n";
            
            int p = 0, pa = 0, pb = 0;
            while(p < n){
                for(int j = 0; j < c; j++){
                    if(pa < na){
                        cards[p] = acards[pa];
                        p++;
                        pa++;
                    }
                }
                
                for(int j = 0; j < c; j++){
                    if(pb < nb){
                        cards[p] = bcards[pb];
                        p++;
                        pb++;
                    }
                }
                
                /* // DEBUG CODE
                for(int j = 0; j < n; j++){
                    cout << cards[j] << " ";
                }
                cout << "\n";
                 */
            }
        }
        cout << cards[n-1] << "\n";
    }
    return 0;
}

Measured memory_bytes: 1160
#!/usr/bin/env python3
#ABC134 E
 
import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7
 
n = int(input())
a = [int(input()) for _ in range(n)]
m = []
for i in range(n):
    r = bisect.bisect_right(m,-a[i])
    if r == len(m):
        m.append(-a[i])
    else:
        m[r] = -a[i]
print(len(m))


Measured memory_bytes: 55256
using System;
using System.Linq;
public class c
{ public static void Main()
  {
    int[] NAB = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
     if(NAB[0]*NAB[1]>NAB[2])Console.WriteLine(NAB[2]);
     else Console.WriteLine(NAB[0]*NAB[1]);
  }
}

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

using namespace  std;

int main() {
    int n ; cin>>n;
    map<string,int>mp;
    int mx = 0;
    for(int i = 0 ; i < n; ++i){
        string s ; cin>>s;
        mp[s]++;
        mx = max(mp[s] , mx);
    }
    for(auto m : mp){
        if(m.second == mx)cout<<m.first<<"\n";
    }
}

Measured memory_bytes: 25216
#include<iostream>

using namespace std;

int main(){
    int n;
    int count = 0;
    bool stopper  = 0;
    int a[220];
    cin >> n;
    
    for(int i = 0; i < n; i++) cin >> a[i];

    while(1){
        for(int k = 0; k < n; k++){
            if(a[k] % 2 != 0) {stopper = 1; break;}
            else a[k] /= 2;
        }
        if(stopper) break;
        else count++;

    }
    cout<<count<<"\n";
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int N, C, P, i, a = 0;
	scanf("%d", &N);
	scanf("%d", &C);
	for (i = 0; i < C; i++) {
		scanf("%d", &P);
		a = a + P;
	}
	if (a % (N + 1) == 0) {
		printf("%d\n", a / (N + 1));
	}
	else {
		a = a / (N + 1);
		a = a + 1;
		printf("%d\n", a);
	}
	return 0;
}


Measured memory_bytes: 2760
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int aa = Math.abs(a - b);
        int bb = Math.abs(b - c);
        int cc = Math.abs(a - c);
        if(aa <= d && bb <= d || cc <= d) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 35576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

struct Key{
    ll cost;
    ll c;
};

int main(){fastio
    ll n,m;cin>>n>>m;
    Key key[m+1];
    ll b;
    ll c;
    rep(i,1,m){
        cin>>key[i].cost;
        cin>>b;
        key[i].c=0;
        rep(j,0,b-1){
            cin>>c;
            key[i].c+=(1<<(c-1));
        }
    }
    ll dp[m+1][(1<<n)];
    rep(i,0,m)rep(j,0,(1<<n)-1)dp[i][j]=inf;
    dp[0][0]=0;
    rep(i,1,m){
        rep(j,0,(1<<n)-1){
            if(dp[i-1][j]==inf)continue;
            dp[i][j]=min(dp[i][j],dp[i-1][j]);
            dp[i][j|key[i].c]=min(dp[i][j|key[i].c],dp[i-1][j]+key[i].cost);
        }
    }
    if(dp[m][(1<<n)-1]==inf){
        cout<<-1<<endl;
    }else{
        cout<<dp[m][(1<<n)-1]<<endl;
    }
    
    return 0;
}




Measured memory_bytes: 32256
import sys

sys.setrecursionlimit(200000)


def dfs(root: int, add_duplicated=True) -> bool:
    global edges, visited, duplicated

    def body(i: int) -> bool:
        visited[i] = True
        for edge in edges[i]:
            if visited[edge]:
                if edge == root:
                    return True
                if add_duplicated:
                    duplicated.add(edge)
                continue
            if body(edge):
                return True
        return False

    return body(root)


if __name__ == "__main__":
    n, m = map(int, input().split())
    edges = [set() for _ in range(n)]  # type: ignore

    for _ in range(m):
        s, t = map(lambda x: int(x), input().split())
        edges[s].add(t)

    visited = [False] * n
    duplicated = set()  # type: ignore

    for i in range(n):
        if not visited[i]:
            if dfs(i):
                print(1)
                exit(0)
    else:
        for i in duplicated:
            visited = [False] * n
            if dfs(i, False):
                print(1)
                exit(0)
        else:
            print(0)



Measured memory_bytes: 5632
#include<stdio.h>

int main(){
  int n,m;
  int a,b,c;
  scanf("%d", &n);
  a=n%10;
  b=(n/10)%10;
  c=(n/100)%10;
  if(a==1) a=9;
  else a=1;
  if(b==1) b=9;
  else b=1;
  if(c==1) c=9;
  else c=1;
  m=a+10*b+100*c;
  printf("%d\n", m);
  return 0;
}


Measured memory_bytes: 128
package main

import "fmt"

func main() {
  var n, m int
  const q = uint64(1000000007)

  fmt.Scanf("%d %d", &n, &m)
  xs := make([]int64, n)
  ys := make([]int64, m)
  for i := 0; i < n; i++ {
    fmt.Scanf("%d", &(xs[i]))
  }
  for i := 0; i < m; i++ {
    fmt.Scanf("%d", &(ys[i]))
  }

  xsum := uint64(0)
  xp := uint64(0)
  for i := 0; i < n-1; i++ {
    xp = (xp + uint64(xs[i+1]-xs[i])*uint64(i+1)) % q
    xsum = (xsum + xp) % q
  }
  ysum := uint64(0)
  yp := uint64(0)
  for i := 0; i < m-1; i++ {
    yp = (yp + uint64(ys[i+1]-ys[i])*uint64(i+1)) % q
    ysum = (ysum + yp) % q
  }

  sum := (xsum * ysum) % q

  fmt.Println(sum)
}


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

using namespace std;

#define endl "\n"
#define F first
#define S second
#define B begin()
#define E end()
#define PB push_back
#define int long long

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

const int maxn = 1e4;
const int OO = 1e18;
const int mod = 1e7 + 9;

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

//	freopen("name.in","r",stdin);
//	freopen("name.out","w",stdout);


   int x;
   cin >> x;
    int a = 100;int cont=0;
    while(a<x)
    {
        int por = a/100;
        a+= por;
        cont++;
    }
cout << cont;
    return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define EREP(i,n) for (ll i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define EVEL 1

#ifndef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {X=X;}
#define TF(f) {f=f;}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 10000000000000000;
#define NMAX 50
#define MAX 10
    int N,K;
    ll A[20];
    ll ans=0;
    int binary(int bina){
        int an = 0;
        for (int i = 0; bina>0 ; i++)
        {
            ans = ans+(bina%2)*pow(10,i);
            bina = bina/2;
        }
        return an;
    }
int main(){
    cin>>N>>K;
    REP(i,N)cin>>A[i];
    ans=INF;
    REP(bit,(1<<N)){
        if(__builtin_popcount(bit)<K){continue;}
        ll count=0,front=0;
//cout<<binary(bit)<<endl;
        REP(i,N){
            if((bit>>i)&1){
                if(front<A[i]){front=A[i];}
                else {
                    front++;
                    count+=front-A[i];
                }
            }else{
                if(front<A[i]){count=INF;break;}
            }
DEB(count)DEB(front)END
        }

        ans=min(ans,count);
    }
    cout<<ans<<endl;
}


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

int main(){
	int A,B,C;
  cin >> A >> B >> C;
  int flag = 0;
  if((A==B && (A !=C || A != C))||(B==C && (B !=A || C != A))||(A==C && (A !=B || C != B))){
    flag = 1;
  }
  if(flag == 1){
    cout << "Yes"<< endl;
  }else{
     cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  char c;
  cin >> c;
  if('A' <= c && c <= 'Z') cout << 'A' << endl;
  else cout << 'a' << endl;
  return 0;
}

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

using namespace std;

int main()
{
    int h, w, k;
    scanf("%i%i%i", &h, &w, &k);
    vector<vector<char>> arr(h, vector<char>(w));
    for (auto &x : arr)
        for (auto &y : x)
            scanf(" %c", &y);
    int _max = 1 << (h - 1);
    int ans = INT_MAX;
    vector<int> par_map(h);
    vector<int> sum(h);
    for (int x = 0; x < _max; x++)
    {
        par_map[0] = 0;
        fill(sum.begin(), sum.end(), 0);
        int cur = 0;
        for (int y = 0; y < h - 1; y++)
        {
            if (x>>y&1)
                par_map[y+1] = y+1, cur++;
            else
                par_map[y+1] = par_map[y];
        }
        for (int z = 0; z < w; z++)
        {
            bool _passed = false;
            for (int y = 0; y < h; y++)
            {
                if (arr[y][z] == '1')
                {
                    sum[par_map[y]]++;
                    _passed |= sum[par_map[y]] > k;
                }
            }
            if (_passed)
            {
                cur++;
                for (int y = 0; y < h; y++)
                    sum[y] = 0;
                for (int y = 0; y < h; y++)
                {
                    sum[par_map[y]] += (arr[y][z] == '1');
                    if (sum[par_map[y]] > k)
                        goto SKIP;
                }
            }
        }
        ans = min(ans, cur);
SKIP:;
    }
    printf("%i\n", ans);
}


Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int H, N;
	cin >> H >> N;

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

	lint sum = accumulate(A.begin(), A.end(), 0LL);

	if (sum >= H) cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-

inputs = input().split(' ')
N = int(inputs[0])
M = int(inputs[1])

lights = []
for i in range(M):
    switch = input().split(' ')[1:]
    switch = [int(s) for s in switch]
    lights.append(switch)

p = input().split(' ')
p = [int(x) for x in p]

combi = 0
for i in range(2**N):
    i = str(bin(i)).split('0b')[1]
    if len(i) < N:
        i = '0'*(N-len(i)) + i
    flag = True
    for j, switch in enumerate(lights):
        on = 0
        for s in switch:
            if i[s-1] == '1':
                on += 1
        if (on%2) != p[j]:
            flag = False
            break
    if flag:
        combi += 1

print(combi)

Measured memory_bytes: 3188
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int R, C, a[11][11234];
int f[11][11234], cou, res, ans;

int main()
{
	while (true)
	{
		R = C = 0;
		memset(a, 0, sizeof(a));
		memset(f, 0, sizeof(f));
		cou = res = ans = 0;

		in >> R >> C;
		if (R == 0 && C == 0) { break; }
		rep(i, R) { rep(j, C) { in >> a[i][j]; } }

		rep(b, (1 << R))
		{
			res = 0;
			rep(x, R) { rep(y, C) { f[x][y] = a[x][y]; } }
			rep(i, R)
			{
				if (b & (1 << i))
				{
					rep(j, C) { f[i][j] = (f[i][j] == 0 ? 1 : 0); }
				}
			}
			rep(j, C)
			{
				cou = 0;
				rep(i, R)
				{
					if (f[i][j] == 1) { ++cou; }
				}
				if (cou > R / 2) { res += cou; }
				else { res += (R - cou); }
			}
			ans = std::max(ans, res);
		}

		out << ans << std::endl;
	}
	return 0;
}

Measured memory_bytes: 4008
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}
fn solve(ss: Vec<char>) -> usize {
    let mut ws = vec![0; ss.len()];

    for (i,&c) in ss.iter().enumerate() {
        if c == 'W' {
            ws[i] = 1;
        }

        if i > 0 {
            ws[i] += ws[i-1];
        }
    }

    let mut es = vec![0; ss.len()];

    for (i,&c) in ss.iter().rev().enumerate() {
        if c == 'E' {
            es[i] = 1;
        }

        if i > 0 {
            es[i] += es[i-1];
        }
    }

    let mut min_n = std::usize::MAX;
    let mut pos = 0;
    for i in 1..ss.len()-1 {
        let n = ws[i-1] + es[ss.len()-i-1];
        if min_n > n {
            min_n = n;
            pos = i;
        }
    }

    if ws[ss.len()-2] < min_n {
        min_n = ws[ss.len()-2];
        pos = ss.len()-1;
    }

    if es[ss.len()-2] < min_n {
        min_n = es[ss.len()-2];
        pos = 0
    }

    min_n
}

fn main() {
    read_line!();

    let s = read_line!();
    println!("{}", solve(s.chars().collect()));
}

#[test]
fn solve_test() {
    assert_eq!(solve("WEEWW".chars().collect()), 1);
    assert_eq!(solve("WEWEWEEEWWWE".chars().collect()), 4);
    assert_eq!(solve("WWWWWEEE".chars().collect()), 3);
    assert_eq!(solve("WWWW".chars().collect()), 0);
    assert_eq!(solve("EEEE".chars().collect()), 0);
}


Measured memory_bytes: 12540
n, a, b=map(int, input().split())
MOD=10**9+7

def f(x, y, MOD):
  out=1
  for i in range(x, x-y, -1):
    out=out*i%MOD
  return out

p=[0, 1]+[0]*(2*10**5-1)
for i in range(2, 2*10**5+1, 1):
  p[i]=p[i-1]*i%MOD
  
q=[0]*(2*10**5)+[pow(p[-1], MOD-2, MOD)]
for i in range(2*10**5, 0, -1):
  q[i-1]=q[i]*i%MOD

ans=(pow(2, n, MOD)-1-(f(n, a, MOD)*q[a])%MOD-(f(n, b, MOD)*q[b])%MOD)%MOD
print(ans)

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

int a[4],k;
bool x=true;

void solve(){
cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> k;
for(int i=0; i<5; i++){
  for(int j=0; j<i; j++){
    if(a[i]-a[j]>k) x=false;
  }
}
if(x) cout << "Yay!" << endl;
  else cout << ":(" << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())

using namespace std;

ll H, W, dots = 0; 
vector<vector<char>> maze;
vector<ll> dy = {0, 1, 0, -1};
vector<ll> dx = {1, 0, -1, 0};
 
ll bfs(pair<ll, ll> start, pair<ll, ll> goal)
{
	vector<vector<ll>> dist(H + 2, vector<ll>(W + 2, -1));
  	queue<pair<ll, ll>> Q;
  	dist[start.first][start.second] = 0;
  	Q.push(start);
  
  	while(!Q.empty()) {
    	pair<ll, ll> v = Q.front(); Q.pop();
      	rep(i, 0, 4) {
        	pair<ll, ll> nv = make_pair(v.first + dx[i], v.second + dy[i]);
          	if (dist[nv.first][nv.second] != -1 || maze[nv.first][nv.second] == '#') {
            	continue;
            }
          	dist[nv.first][nv.second] = dist[v.first][v.second] + 1;
          	Q.push(nv);
        }
    }
  	return dist[goal.first][goal.second];
}

int main()
{
  cin >> H >> W;
  maze = vector<vector<char>>(H + 2, vector<char>(W + 2));
  rep(j, 0, W + 2) {
  	maze[0][j] = '#';
  }
  rep(i, 1, H + 1) {
  	maze[i][0] = '#';
    rep(j, 1, W + 1) {
    	cin >> maze[i][j];
      	if (maze[i][j] == '.') dots++;
    }
    maze[i][W + 1] = '#';
  }
  rep(j, 0, W + 2) {
  	maze[H + 1][j] = '#';
  }
  ll d = bfs(make_pair(1, 1), make_pair(H, W));
  if (d == -1) cout << -1 << endl;
  else cout << dots - d - 1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int n;
  scanf("%d", &n);
  char s[n];
  bool three = true;
  for (int i=0; i<n; i++) {
    scanf("%c", s+i);
    if (s[i] == 'Y') three = false;
  }
  if (three) printf("Three\n");
  else printf("Four\n");
  return 0;
}


Measured memory_bytes: 128