akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Contest_01_Valeo
{
    class Program
    {
        public static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int h = int.Parse(input.Split(' ')[0]);
            int a = int.Parse(input.Split(' ')[1]);
            Console.WriteLine( GetNumberOfAttachs(h, a));
        }
        private static Int32 GetNumberOfAttachs(int h, int a)
        {
            int health = h;
            int count = 0;
            while (health > 0)
            {
                health -= a;
                count++;
            }

            return count;
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; ++i)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define PB push_back
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> Point;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1ll << 60;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

#ifdef WIN32
#define dump(x) cout << #x << " = " << (x) << "\n"
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n"
#else
#define dump(x)
#define debug(x)
#endif

int m, n;
int field[ 90 ][ 90 ];

void input() {
  cin >> m >> n;
  if ( !m && !n ) {
    return;
  }
  for ( int i = 0; i < n; i++ ) {
    for ( int j = 0; j < m; j++ ) {
      cin >> field[ i ][ j ];
    }
  }
}

int dfs( int x, int y ) {
  if ( !field[ y ][ x ] ) {
    return 0;
  }
  field[ y ][ x ] = 0;
  int res = 1;
  for ( int i = 0; i < 4; i++ ) {
    if ( y + dy[ i ] < 0 || y + dy[ i ] >= n || x + dx[ i ] < 0 || x + dx[ i ] >= m ) {
      continue;
    }
    if ( field[ y + dy[ i ] ][ x + dx[ i ] ] ) {
      res = max( res, dfs( x + dx[ i ], y + dy[ i ] ) + 1 );
    }
  }
  field[ y ][ x ] = 1;
  return res;
}

void solve() {
  int ans = 0;
  for ( int i = 0; i < n; i++ ) {
    for ( int j = 0; j < m; j++ ) {
      if ( field[ i ][ j ] ) {
        ans = max( ans, dfs( j, i ) );
      }
    }
  }
  cout << ans << "\n";
}

int main() {
  ios::sync_with_stdio( false );
  cin.tie( 0 );
  while ( true ) {
    input();
#ifdef WIN32
    clock_t stime = clock();
#endif
    if ( !n && !m ) {
      break;
    }
    solve();
#ifdef WIN32
    clock_t etime = clock();
    cout << "TIME : " << ( double ) ( etime - stime ) / CLOCKS_PER_SEC << "\n";
#endif
  }
  return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> p;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    for(int i = 0; i < ty - sy; i++) cout << 'U';
    for(int i = 0; i < tx - sx; i++) cout << 'R';

    for(int i = 0; i < ty - sy; i++) cout << 'D';
    for(int i = 0; i < tx - sx; i++) cout << 'L';

    cout << 'L';
    for(int i = 0; i < ty - sy + 1; i++) cout << 'U';
    for(int i = 0; i < tx - sx + 1; i++) cout << 'R';
    cout << 'D';

    cout << 'R';
    for(int i = 0; i < ty - sy + 1; i++) cout << 'D';
    for(int i = 0; i < tx - sx + 1; i++) cout << 'L';
    cout << 'U' << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define PPF pop_front
#define PPB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<PA>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=998244353;
//
struct poi{
  int X;int Y;int Z;
  bool operator<(const poi&R)const{
    return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
  }
};
/*
ll GCD(ll A,ll B){
  return (B==0)?(A):(GCD(B,A%B));
}
//
ll LCM(ll A,ll B){
  return A/GCD(A,B)*B;
}
*/
int main(){
  int N;
  string S;
  cin>>N>>S;
  int ans=0;
  FOR(i,1,N-1){
    set <char> X,Y;
    FOR(j,0,i){
      X.insert(S[j]);
    }
    FOR(j,i,N){
      Y.insert(S[j]);
    }
    int cnt=0;
    FOR(i,0,26){
      if(X.find('a'+i)!=X.end()&&Y.find('a'+i)!=Y.end()){
        cnt++;
      }
    }
    ans=max(ans,cnt);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back 
#define mp make_pair
#define F first
#define S second
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORR(i,a,b) for(int i=a;i<b;i++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

#define printmp(b) for(auto y:b) {printP(y);}

#define print(a) for(auto x:a) cout<<x<<' ';cout<<endl;
#define printM(b) for(auto y:b) {print(y);}
#define printP(p) cout<<p.first<<' '<<p.second<<endl;
typedef long long int ll;
typedef unsigned long long int ull;

/* 

*/
ll apowb(ll a,ll b)
{
  if(b==0)
  return 1;
  if(b==1)
  return a;
  if(b%2==0)
  {
    return apowb(a*a,b/2);

  }else
  {
    return apowb(a*a,b/2)*a;

  }
  
}

void solve()

{
  
  int n;
  cin>>n;
  vector<int> arr(n);

  int pvr=0,pos=0;

  FOR(i,n)
  cin>>arr[i];
    

ll ans=0;
  FOR(i,n)
  {
    if(i==0)
    {
      pvr=arr[i];
    continue;
    }

    if(pvr>arr[i])
    {
      ans+=(pvr-arr[i]);
    }else{

    pvr=arr[i];
    }
    
  }
cout<<ans;
   



   //cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;  
   
}


int main()
{
  /*
6
4 0
4 41
0 1000000
44 0
1 0
10000 1000000


  */
  fast;
  int t=1;
 //cin>>t;
  while(t--){
  
  solve();
 cout<<endl;
   
}
  
  
      
      return 0;
    }

Measured memory_bytes: 3936
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;// ;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max();
constexpr long long DINF = 1000000000000;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<Edge>>g;
vector<edge>ed;
vector<Pll>pv;
map<LL, LL>ma;
set<LL>st;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
LL n, m, k, p, q, w, h, ans, cnt,sum[100000], a[310000], b[310000];
string str[10000];
bool f;
char c[1100][1100];
int main() {
	cin >> n >> k;
	rep(i, n) {
		cin >> a[i];
		sum[i+1] += a[i] + sum[i];
	}
	ans = -INF;
	rep(i, k+1) {
		for (int j = 0; j <= k - i; j++) {
			if (i + j > n)continue;
			LL cur = 0;
			priority_queue<LL,vector<LL>,greater<LL>>pq;
			cnt = k - i - j;
			rep(l, i)pq.push(a[l]), cur += a[l];
			rep(l, j)pq.push(a[n - l - 1]), cur += a[n - l - 1];
			while (!pq.empty()&&cnt!=0) {
				cnt--;
				LL num=pq.top();
				if (num < 0)cur -= num;
				pq.pop();
			}
			ans = max(cur,ans);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4480
n = int(input())
a = list(map(int, input().split()))

d = {}
for ai in a:
    if d.get(ai):
        d[ai] += 1
    else:
        d[ai] = 1

t = 0
for v in d.values():
    t += v * (v-1) // 2

for ai in a:
    print(t - (d[ai]-1))

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

//const int MAX_N = 100001;
const int MAX_N = 10000001;

bool prime[MAX_N];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    for(int i = 2; i <= MAX_N; ++i){
        prime[i] = true;
    }

    for(int i = 2; i <= MAX_N; ++i){
        if(!prime[i]) continue;
        for(int j = 2; i * j <= MAX_N; ++j){
            prime[i * j] = false;
        }
    }

    int n;
    while(cin >> n && n){
        for(int i = n; i >= 13; --i){
            if(prime[i] && prime[i - 2] && prime[i - 6] && prime[i - 8]){
                cout << i << endl;
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 10956
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL N; cin >> N;
		UL ans = 0;
		while (N > 10) {
			ans += N % 10;
			N /= 10;
		}
		ans += N;
		cout << ans << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

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

int main(void)
{
	    int a;
	    int b = 0;
	    int c = 0;
	    scanf("%d",&a);            
	    int e = a;

    while(a){
    b = a % 10;
    c = c + b;
    a = a / 10;
  }

int d = e % c;
if(d == 0){
    printf("Yes\n");
    
}else{
    printf("No\n");
}

   return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair

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

const ll INF= ll (1e18);
const int MOD= 1e9+7;

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

     char arr1[55][55],arr2[55][55];

    int n,m;
    cin>>n>>m;

    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
            cin>>arr1[i][j];
    }

    for(int i=1;i<=m;i++)
    {
        for(int j=1;j<=m;j++)
            cin>>arr2[i][j];
    }
    int mainflag=0;

    for(int i=1;i<=(n-m+1);i++)
    {
        for(int j=1;j<=(n-m+1);j++)
        {
            int flag=0;

            for(int k=1;k<=m;k++)
            {
                for(int l=1;l<=m;l++)
                {
                    if(arr2[k][l]!=arr1[k+i-1][l+j-1])
                    {
                        flag=1;
                        break;
                    }
                }
                if(flag==1)
                    break;
            }

            if(flag==0)
            {
                mainflag=1;
                break;
            }
        }
        if(mainflag==1)
            break;
    }

    if(mainflag==1)
        cout<<"Yes";
    else
        cout<<"No";

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAXN 20
using namespace std;
int main(){
	int N,M;
	cin>>N>>M;
	int arr[MAXN][MAXN];
	for(int i = 0;i<M;i++){
		int k;
		cin>>k;
		arr[i][0] = k;
		for(int j =0;j<k;j++){
			int t;
			cin>>t;
			arr[i][j+1] = t;
		}
	}
	vector<int> parr;
	for(int i=0;i<M;i++){
		int t;
		// ciparr
		cin>>t;
		parr.push_back(t);
	}
	int stasum = 0;
	for(int sta = 0;sta<=(1<<N)-1;sta++){
		int flag = 1;
		
		//cerr<<sta<<endl;
		for(int i=0;i<M;i++){
			int rd = arr[i][0];
			int sum= 0;
			for(int j=0;j<rd;j++){
				int check_b = arr[i][j+1];
				if(sta&(1<<(check_b-1))){
				
					;sum+=1;}
			}
			
			if(sum%2 != parr[i]){flag = 0;break;}
		}
		if(flag)stasum++;
	}
	cout<<stasum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n-1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
#define RALL(a) rbegin(a),rend(a)
typedef long long int ll;
typedef long double ld;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
const int MAX = 510000;
const int MOD = 1000000007;
const int inf = 1<<31-1;
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; }
vector<ll> dp(2010, -1);
ll rec(int i) {
    ll ret = 0;
    if (i == 0) return 1;
    if (dp[i] != -1) return dp[i];
    rep(j, i - 2) {
        ret += rec(j);
        ret %= MOD;
    }return dp[i] = ret;
}
int main(void) {
    int n; cin >> n; dp[0] = 1;
    cout << rec(n) << endl;
}

Measured memory_bytes: 3648
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

struct Item {
  int64_t w, v;
};

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int64_t n, w;
  int64_t dp[101][100001] = {};
  cin >> n >> w;
  std::vector<Item> item;
  item.resize(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> item[i].w >> item[i].v;
  }
  for (int i = 1; i <= w; i++) {
    for (int j = 1; j <= n; j++) {
      if (i - item[j].w >= 0) {
        dp[j][i] = std::max(dp[j - 1][i], dp[j - 1][i - item[j].w] + item[j].v);
      } else {
        dp[j][i] = dp[j - 1][i];
      }
    }
  }
  cout << dp[n][w] << endl;

  return 0;
}


Measured memory_bytes: 79232
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int n;
string s;
int cnt[20000];
int main() {
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    cin >> s;
    for (int i = 0; i < n; i++) {
        cnt[s[i] - 'a']++;
    }
    int ans = 1;
    for (int i = 0; i < 26; i++) {
        ans = 1ll * ans * (cnt[i] + 1) % mod;
    }
    if (ans == 0) {
        ans = mod;
    }
    cout << ans -1 << "\n";
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define modulo 100000
#define mod(mod_x) ((((long long)mod_x)+modulo)%modulo)
#define Inf 1000000000



int main(){
	int N,D;
	cin>>N>>D;
	vector<vector<int>> X(N,vector<int>(D));
	for(int i=0;i<N;i++){
		for(int j=0;j<D;j++){
			cin>>X[i][j];
		}
	}
	
	int ans = 0;
	
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			int x = 0;
			for(int k=0;k<D;k++){
				x += (X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
			}
			double a = sqrt(x);
			int b = round(a);
			if(b*b==x)ans++;
			
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 384
while True:
	try:
		a,b,c = map(str,raw_input().replace("+","=").split("="))
		i = 1 if a!=a[0]=="X" or b!=b[0]=="X" or c!=c[0]=="X" else 0
		for x in range(i,10):
			if eval((a+"+"+b+"=="+c).replace("X",str(x))):
				print x
				break
		else:
			print "NA"
	except:
		break

Measured memory_bytes: 4252
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll n,k;
    cin >> n >> k;
    Vi a(n);
    rp(i,n) cin >> a.at(i);
    Vi kind;
    sort(all(a));
    ll ctr=1;
    rp(i,n-1){
        if(a[i]==a[i+1]) ctr++;
        else{
            kind.pb(ctr);
            ctr=1;
        }
    }
    kind.pb(ctr);
    sort(all(kind));
    ll to_delete=kind.size()-k;
    ll ans=0;
    rp(i,to_delete){
        ans+=kind[i];
    }
    print(ans);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a>b)swap(a,b);
    if(a<=0&&b>=0)puts("Zero");
    else if(a>0)puts("Positive");
    else {
        if(a-b&1)puts("Positive");
        else puts("Negative");
	}
}

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

using namespace std;

#define PI 3.14159265358979323846264338327950L

void solve()
{
    long double r,s,res,a,b,h,m;
    cin>>a>>b>>h>>m;

    res=2*PI*(h/12 + (m/60)/12 - m/60);

    r=a*a + b*b-2*a*b*cos(res);
    s=sqrt(r);

    printf("%.20Lf",s);
}


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

    solve();
    return 0;
}


Measured memory_bytes: 4152
#include <iostream>
#include <string>

using namespace std;

int main() {
  std::string s;

  cin >> s;
  int num = 0;
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] == '+') {
      num++;
    } else {
      num--;
    }
  }
  cout << num << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <functional>
#include <list>
using namespace std;

int main(){
	int n;
	int count = 0;
	cin >> n;
	vector <int> x(n);
	for (int i = 0; i < n; i++)
		cin >> x[i];
	while (1) {
		for (int j = 0; j < n; j++) {
			if (x[j] % 2 == 0)	x[j] /= 2;
			else {
				cout << count << endl;
				return 0;
			}
		}
		count++;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
using namespace std;

const int INF = 100000000;

typedef pair<int,int> P;

char maze[100][100];
int N, M;
int sx, sy;
int gx, gy;
int d[100][100];

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

int bfs() {
	queue<P> que;
	for (int i = 0; i < N; i++)
		for (int j = 0; j < M; j++) d[i][j] = INF;
	que.push(P(sx, sy));
	d[sx][sy] = 0;

	while (que.size()) {
		P p = que.front(); que.pop();
		if (p.first == gx && p.second == gy)break;
		for (int i = 0; i < 4; i++) {
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (0 <= nx && nx < N && 0 <= ny && ny < M && maze[nx][ny] != '#' && d[nx][ny] == INF) {
				que.push(P(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
	return d[gx][gy];
}

int solve() {
	int res = bfs();
	return res;
}

int main(int argc, char *args[]) {
	int counter = 0;
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			cin >> maze[i][j];
			if (maze[i][j] == '#')counter += 1;
		}
	}
	sx = 0; sy = 0;
	gx = N - 1; gy = M - 1;
	if (solve() == INF) {
		cout << -1 << endl;
	}
	else {
		cout << N*M - (solve() + 1) - counter << endl;
	}
	
	
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    long long a, min, max, sum;
    int i, n;

    sum = 0;

    scanf("%d", &n);   

    for(i = 1; i <= n; i++)
    {
        scanf("%lld", &a);

        if(i == 1)
        {
            min = max = a;
        }

        if(a < min)
        {
            min = a;
        }

        else if(a > max)
        {
            max = a;
        }

        sum = sum + a;
    }

    printf("%d %d %lld\n", min, max, sum);

    return 0;
}


Measured memory_bytes: 2104
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int n, a, b;
	scanf("%d%d%d", &n, &a, &b);
	int x = 0, y = 0, z = 0;
	for (int i = 0; i < n; i++)
	{
		int t;
		scanf("%d", &t);
		if (t <= a)x++;
		else if (t <= b)y++;
		else z++;
	}
	printf("%d\n", min(x, min(y, z)));
}

Measured memory_bytes: 128
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        q: usize,
        s: String,
        lr: [(usize1, usize1); q],
    }
    let mut v = vec![0; n];
    for i in 1..n {
        v[i] = v[i - 1] + if &s[i - 1..i + 1] == "AC" { 1 } else { 0 };
    }
    for (l, r) in lr {
        println!("{}", v[r] - v[l]);
    }
}


Measured memory_bytes: 6908
import java.util.*;
public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int num = 0;
        int [] List = new int[N];
        for(int i=0;i<N;i++) List[i]=sc.nextInt();
        Arrays.sort(List);
        for(int i=0;i<N-2;i++){
            for(int j=i+1;j<N-1;j++){
                for(int k=j+1;k<N;k++)
                    if(List[i]+List[j]>List[k]) num++;
                    else break;
            }
        }
        System.out.println(num);
    }
}

Measured memory_bytes: 28128
#include <iostream>
#include <vector>
#include <array>

using namespace std;

int main() {
    int n, i, j;
    long c;
    cin >> n >> c;

    vector<array<long, 2>> xv;
    array<long, 2> buf;
    for(i = 0; i < n; i++) {
        cin >> buf[0] >> buf[1];
        xv.push_back(buf);
    }

    long ans = 0, sum;
    for(i = 0; i < 2; i++) {
        vector<long> v_sum = {xv[0][1]};
        vector<long> f = {xv[0][1] - xv[0][0]};
        vector<long> g = {f[0]};

        for(j = 1; j < n; j++) {
            v_sum.push_back(v_sum[j-1] + xv[j][1]);
            f.push_back(v_sum[j] - xv[j][0]);
            g.push_back(g[j-1] > f[j] ? g[j-1] : f[j]);
        }

        if(ans < g[n-1]) ans = g[n-1];
        for(j = n-1; j > 0; j--) {
            sum = v_sum[n-1] - v_sum[j-1] - 2 * (c - xv[j][0]) + g[j-1];
            if(ans < sum) ans = sum; 
        }

        for(j = 0; j < n; j++) xv[j][0] = c - xv[j][0];
        reverse(xv.begin(), xv.end());
    }

    cout << ans << endl;
}

Measured memory_bytes: 8052
fun main(args: Array<String>) = abc162d()

fun abc162d() {
    val n = readLine()!!.toInt()
    val s = readLine()!!

    val counts = LongArray(3)
    var removeCount = 0L

    for (left in 0 until n) {
        counts[s[left].toInt() % 3]++
        for (mid in left + 1 until n) {
            val right = mid + (mid - left)
            if (right !in s.indices) break
            if (setOf(s[left], s[mid], s[right]).size == 3) removeCount++
        }
    }

    val answer = counts[0] * counts[1] * counts[2] - removeCount

    println(answer)
}


Measured memory_bytes: 55896
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using namespace atcoder;
using ll = long long;
using P = pair<int,int>;

int main(){
	int n, d;
	cin>>n>>d;
	vector<vector<int>> x(n);
	rep(i, n) x[i]=vector<int>(2);
	rep(i, n) cin>>x[i][0]>>x[i][1];

	two_sat ts(n);
	for(int i=0; i<n-1; i++){
		for(int j=i+1; j<n; j++){
			rep(a, 2) rep(b, 2){
				if(abs(x[i][a]-x[j][b])<d) ts.add_clause(i, !a, j, !b);
			}
		}
	}

	bool ok=ts.satisfiable();
	if(ok){
		cout<<"Yes"<<endl;
		auto vb=ts.answer();
		rep(i, n) cout<< x[i][vb[i]] <<endl;
	}
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
typedef long double ld;

int N, T, G[4005], R[4005], B[4005];
string S;

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N >> S;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'R') R[i] = 1;
		else if (S[i] == 'B') B[i] = 1;
		else G[i] = 1;
	}
	for (int i = 1; i < S.size(); i++) {
		R[i] += R[i - 1];
		G[i] += G[i - 1];
		B[i] += B[i - 1];
	}
	for (int i = 1; i < S.size(); i++)
		for (int j = i + 1; j < S.size(); j++) {
			if (S[i] == S[j]) continue;
			set<char> tmp = {'R', 'G', 'B'};
			tmp.erase(S[i]);
			tmp.erase(S[j]);
			char tmp2 = *tmp.begin();
			if (tmp2 == 'R') {
				if (i - (j - i) >= 0) T += R[i - 1] - (S[i - (j - i)] == 'R');
				else T += R[i - 1];
			} else if (tmp2 == 'B') {
				if (i - (j - i) >= 0) T += B[i - 1] - (S[i - (j - i)] == 'B');
				else T += B[i - 1];
			} else {
				if (i - (j - i) >= 0) T += G[i - 1] - (S[i - (j - i)] == 'G');
				else T += G[i - 1];
			}
		}
	cout << T << '\n';
}


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

int main() {
  int n;
  string s;
  cin >> n;
  cin >> s;

  int need_right = 0, need_left = 0;
  for ( int i = 0; i < n; i++ ) {
    if ( s[i] == '(' ) {
      need_right++;
    }
    if ( s[i] == ')' ) {
      if ( need_right > 0 ) {
        need_right--;
      } else {
        need_left++;
      }
    }
  }

  string ans = "";
  while ( need_left-- > 0 ) { ans += "("; }
  ans += s;
  while ( need_right-- > 0 ) { ans += ")"; }
  cout << ans << endl;
  return 0;
}


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

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

int N;
string s;
map<string, int> M;
ll ans;

int main()
{
    int i, j;

    cin>>N;
    for(i=1; i<=N; i++)
    {
        cin>>s;
        sort(s.begin(), s.end());
        ans+=M[s]++;
    }
    printf("%lld", ans);
}


Measured memory_bytes: 11136
//xtwakioi! xtwddYnoi(双重含义)!
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=110;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
signed main()
{
    int x,y;
    cin>>x>>y;
    if(abs(x-y)<=1) puts("Brown");
    else puts("Alice");
    return 0;
}

Measured memory_bytes: 3636
import scala.io.{ StdIn => in}

object Main extends App {
  val mod = 1000000007
  val n = in.readInt
  val arr = Array.ofDim[Int](n+1)

  in.readLine.split(" ").map(_.toInt).foreach{i => {
    arr(i) += 1
  }}

    def recEven(acc:Int, idx:Int):Int = {
      if(idx > n) acc
      else if(idx % 2 == 0) {
        if(arr(idx) == 2) recEven(acc*2%mod, idx+1)
        else 0
      }
      else if(arr(idx) == 0) recEven(acc, idx+1) else 0
    }
    def recOdd(acc:Int, idx:Int):Int = {
      if(idx > n) acc
      else if(idx % 2 == 1) {
        if(arr(idx) == 2) recOdd(acc*2%mod, idx+1)
        else 0
      }
      else if(arr(idx) == 0) recOdd(acc, idx+1) else 0
    }

  val ans = 
    if(arr(0) > 1) 0
    else if(arr(0) == 1) recEven(1,1)
    else if(arr(1) == 2) recOdd(2,2)
    else 0

  println(ans)
}

Measured memory_bytes: 42116
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

int main() {
    ll n; cin >> n;
    for(int i = (int)sqrt(n); i>0; i--) {
        if(n % i == 0) {
            cout << max(to_string(i).size(), to_string(n / i).size()) << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
 
typedef long long ll;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define DBGV(v,n) forn(i,n) cout << v[i] << " "; cout << endl
#define esta(x,c) ((c).find(x) != (c).end())
#define RAYA cerr << "===============================" << endl
#define MAXN 2005


int main()
{ 
	FIN;
	
	#ifdef input
		//freopen("test1.txt", "r", stdin);
	#endif
	
	char a;
	cin >> a;
	if(a>='a' && a<='z') cout << "a\n";
	else cout << "A\n";
	
		
		
	
	return 0;
}


Measured memory_bytes: 3580
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double[] a = new double[]{sc.nextDouble(), sc.nextDouble(), sc.nextDouble()};
        System.out.println(a[0] * a[1] * Math.sin((Math.PI / 180) * a[2]) / 2.0);
        System.out.println(
            a[0] + a[1] + Math.sqrt(a[0] * a[0] + a[1] * a[1] - 2 * a[0] * a[1] * Math.cos(Math.PI / 180 * a[2])));
        System.out.println(a[1] * Math.sin(Math.PI / 180 * a[2]));
    }
}

Measured memory_bytes: 27984
def gcd(a, b)
  if (a < b)
    tmp = a; a = b; b = tmp
  end

  while ((c = a % b) > 0)
    a = b
    b = c
  end

  return b
end

while (line = gets)
  a, b = line.chop.split(" ").map { |s| s.to_i }
  g = gcd(a, b)
  l = a * b / g

  printf("%d %d\n", g, l)
end



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

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...)
#endif

int main(){
  int N;

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

    int64_t X = 0;
    for(int i = 2; i < N; ++i) X ^= A[i];

    int64_t S = A[0] + A[1];

    int64_t D = (S - X) / 2;

    dump(X, S, D);

    if(S - X < 0 or S != X + 2 * D or (D & X) or D > A[0]){
      std::cout << -1 << "\n";
      continue;
    }

    int64_t Y = 0;

    for(int i = 50; i >= 0; --i){
      if((X & (1LL << i)) and (D ^ (Y | (1LL << i))) <= A[0]){
        Y |= 1LL << i;
      }
    }

    if((D ^ Y) == 0){
      std::cout << -1 << "\n";
      continue;
    }
    
    int64_t ans = A[0] - (D ^ Y);
    
    std::cout << ans << "\n";
  }

  return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main()
{
  ll N; cin >> N;
  ll K; cin >> K;
  vector<ll> a(N);
  for (int i=0; i<N; i++){
    cin >> a[i];
  }
  vector<vector<ll>> dp(N+1, vector<ll>(K+1, 0));
  for (int i=0; i<=N; i++) {
    dp[i][0] = 1;
  }
  for (int i=1; i<=N; i++) {
    vector<ll> cs(K+1, 0);
    for (int j=0; j<=K; j++) {
      if (j==0) cs[j] = dp[i-1][j];
      else cs[j] = (cs[j-1]+dp[i-1][j])%mod;
    }
    for (int j=1; j<=K; j++) {
      ll ad = cs[j];
      if (j > a[i-1]) ad = (ad - cs[j-a[i-1]-1] + mod)%mod;
      dp[i][j] = ad;
    }
  }
  cout << dp[N][K] << endl;

  return 0;
}


Measured memory_bytes: 80256
import sys
input=sys.stdin.readline
from collections import deque
from heapq import heappush,heappop
import re

def int_raw():
    return int(input())
 
def ss_raw():
    return input().split()
 
def ints_raw():
    return tuple(map(int, ss_raw()))


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


DIV = 10**9+7

def ncr(n, r, mod=DIV):
	r = min(r, n-r)
	ret = 1
	for i in range(1, r+1):
		ret = ret * (n-i+1) % mod
		ret = ret * mod_inv(i, mod) % mod
	return ret


def main():
    ans =0
    X,A = ints_raw()

    return 0 if X<A else 10

print(main())


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    int n;
    cin >> n;
    vector<vector<int>> a(2,vector<int>(n));
    rep(i,2){
        rep(j,n){
            cin >> a.at(i).at(j);
        }
    }
    int ans=0;
    rep(i,n){
        int sum=0;
        rep(j,i+1){
            sum+=a.at(0).at(j);
        }
        for(int k=i;k<n;k++){
            sum+=a.at(1).at(k);
        }
        ans=max(ans,sum);
    }
    cout << ans << endl;
}


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

int main()
{
    int h,w,k,cnt,ans;

    cin >> h >> w >> k;
    vector<vector<int>> v(h, vector<int>(w));
    rep(i, h) {
        string s;
        cin >> s;
        rep(j, w) {
            if (s.substr(j,1) == "#")
                v[i][j]=1;
        }
    }

    ans = 0;
    //選択セルを1にする
    for (int hbit = 0; hbit < (1 << h); ++hbit) {
        for (int wbit = 0; wbit < (1 << w); ++wbit) {
            vector<vector<int>> sel(h, vector<int>(w));
            for (int i = 0; i < h; ++i) {
                if (hbit & (1 << i)) { // 列挙に i が含まれるか
                    rep(m, w) {
                        sel[i][m] = 1;
                    }
                }
            }

            for (int j = 0; j < w; ++j) {
                if (wbit & (1 << j)) { // 列挙に i が含まれるか
                    rep(m, h) {
                        sel[m][j] = 1;
                    }
                }
            }

            cnt = 0;
            rep(i,h) {
                rep(j, w) {
                    if (sel[i][j] == 0) {
                        if (v[i][j] == 1) {
                            ++cnt;
                        }
                    }
                }
            }
            if (cnt == k) {
                ++ans;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3624
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
#define INF 9999999
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n,k;
    cin>>n>>k;
    int dp[n];
    vector<int>ar(n);
    for(int i=0; i<n; i++)
        cin>>ar[i];

    dp[0]=0;
      for(int i=1; i<n; i++)
    {
       dp[i]=INT_MAX;
        for(int j=1; j<=k; j++)
        {
            if(i-j>=0)
                dp[i]=min(dp[i],dp[i-j]+abs(ar[i]-ar[i-j]));
        }
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 4056
#include<stdio.h>

int main (void){
	
	int a,i,l,m,n,max1,max2,max3;
	
	scanf("%d",&a);
	
	for(i=0;i<a;i++){
		scanf("%d",&l);
		max1 = l;
		
		scanf("%d",&m);
		if(max1<m){
			max1 = m;
			max2 = l;
		}else{
			max1 = l;
			max2 = m;
		}
		
		scanf("%d",&n);
		if(max1<n){
			max3 = max2;
			max2 = max1;
		    max1 = n;
		}else if(max2>n){
			max3 = n;
		}else if(max2<n<max1){
			max3 = max2;
			max2 = n;
		}
	if((max1)*(max1)==(max2)*(max2)+(max3)*(max3)){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
	}
return 0 ;
}
		

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define X first
#define Y second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define ini(x, y) memset(x, y, sizeof(x))
#define endl '\n'
#define fastio cin.sync_with_stdio(false); cin.tie(nullptr)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9 + 7;
const int dx[] = { -1, 0, 1, 0, -1, 1, 1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

int H, W, K;
char bo[10][1001];

int bit_count(int n) {
	int ret = 0;
	while (n) ++ret, n -= n & -n;
	return ret;
}
bool check(int b, int cnt) {
	int sum[10]{}, ret = 0;
	for (int f, i = 0; i < W; ++i) {
		f = 0;
		bool tmp = 0;
		for (int j = 0; j < H; ++j) {
			sum[f] += bo[j][i] == '1';
			if (sum[f] > K) tmp = 1;
			if (b & 1 << j) ++f;
		}

		if (tmp) {
			++ret;
			ini(sum, 0);

			f = 0;
			for (int j = 0; j < H; ++j) {
				sum[f] += bo[j][i] == '1';
				if (sum[f] > K) return false;
				if (b & 1 << j) ++f;
			}
		}
	}

	return ret <= cnt;
}
int main() {
	fastio;
	cin >> H >> W >> K;
	for (int i = 0; i < H; ++i) cin >> bo[i];

	int ans = 0x3f3f3f3f;
	for (int i = 0; i < 1 << H - 1; ++i) {
		int t = bit_count(i);
		int s = 0, e = 2000;

		while (s <= e) {
			int m = s + e >> 1;
			if (check(i, m)) e = m - 1;
			else s = m + 1;
		}

		ans = min(ans, s + t);
	}

	cout << ans;

	return 0;
}

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

int main(){
    long long N,A,B,count[51][51];
    cin >> N >> A >> B;
    vector<long long> v(N);
    for(int i=0;i<N;i++) cin >> v[i];
    long long dp[51][51];
    for(int i=0;i<N+1;i++){ 
        dp[0][i]=0;
        count[0][i]=1;
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N+1;j++){
            dp[i+1][j]=dp[i][j];
            count[i+1][j]=count[i][j];
            if(j<=i+1&&j>0){
                long long left=dp[i][j];
                long long right=dp[i][j-1]+v[i];
                if(left==right) count[i+1][j]=count[i][j]+count[i][j-1];
                else if(left<right) count[i+1][j]=count[i][j-1];
                dp[i+1][j]=max(left,right);
            } 
        }
    }
    long long ans_a=0,ans_b=1;
    long long all=0;
    for(int i=A;i<=B;i++){
        long long a=dp[N][i];
        if(a*ans_b>ans_a *i){ 
            ans_a=a;
            ans_b=i;
            all=count[N][i];
        }
        else if(a *ans_b==ans_a *i) all+=count[N][i];
        else continue;
    }
double ans=(double)ans_a/(double) ans_b;
    printf("%.16f\n%lld",ans,all);
}


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

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

int main(){
    int n; cin >> n;
    vector<tuple<string,int,int>> a;
    for(int i = 1; i <= n; ++i){
        string s;
        int p;
        cin >> s >> p;
        p = -p;
        a.push_back(tie(s,p,i));
        sort(a.begin(),a.end());
    }
    for(int i = 0; i < n; i++){
        cout << get<2>(a[i]) << endl;
    }
}

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

using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
    char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
    vector<char*> v({token});
    while(token = strtok(NULL,", ")) v.push_back(token);
    return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
    debug() << " [" << args.back() << ": " << H << "] ";
    args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define sz(x) (int)x.size()
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
ll mod=1e9+7;
const int MX=0x3f3f3f3f;

int main(){
	IOS;
	ll n;
	cin>>n;
	int cnt=0,ans=0,temp=1;
    vi v;
	while(n%2==0) n/=2,cnt++;
    if(cnt)
	    v.EB(cnt);
	for(ll i=3;i*i<=n;i+=2) {
		cnt=0;
		while(n%i==0) n=n/i,cnt++;
		if(cnt)
            v.EB(cnt);
	}
    if(n>2) v.EB(1);
        for(auto u:v){
            int i=1;
            while(i*(i+1)/2<=u) i++;
            i--;
            ans+=i;
        }
        cout<<ans;
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    int zero = 0;
    int one = 0;
    for(int i=0 ; i<n; i++){
        if(s.at(i) == '0') zero++;
        else one++;
    }
    cout << 2*min(zero,one) << endl;
}

Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
#define dbg(var) cout<<#var<<"="<<var<<" "
#define ll long long 
#define nl cout<<"\n"
int ans[1005][1005];
int main()
{  
	int H,W,A,B;cin>>H>>W>>A>>B;
	for(int i=0;i<B;i++){
		for(int j=0;j<A;j++)
			ans[i][j]=1;
	}
	for(int i=B;i<H;i++){
		for(int j=A;j<W;j++)
			ans[i][j]=1;
	}
  	for(int i=0;i<H;i++){
  		for(int j=0;j<W;j++)
  			cout<<ans[i][j];
  		nl;
  	}
}

Measured memory_bytes: 5120
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	string S;
	cin >> S;
	int t[15] = {0};

	for (int i = 0; i < S.size(); i++) {
		if(S[i]=='A'||S[i]=='T'||S[i]=='G'||S[i]=='C'){
			t[i] = 1;
		}
	}

	for (int i = 1; i < 15; i++)
	{
		if(t[i]==0){
			continue;
		}
		t[i] = t[i - 1] + 1;
	}

	cout << *max_element(t, t + 15) << endl;

	return 0;
}

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

int main(){
    int N,K;
    cin >> N >> K;
    string S;
    cin >> S;
    
    vector<int> v; // 1-0-1-.....-0-1
    int count=0;
    char now01 = '1';//最初が0だった時にv[0]に0が入る
    
    for(int i=0; i<N; i++){
        if(S[i]==now01){
            count++;
            
        }else{
            v.push_back(count);
            count = 1;
            now01 = S[i];
        }
    }
    if(count != 0)v.push_back(count);
    if(v.size() % 2 == 0)v.push_back(0); //1-0-1-...-0の時に最後に0を入れる
    
    int L = (int)v.size();
    
    vector<int> sum_array;
    int sum=0;
    for(int i=0; i<L; i++){
        sum += v[i];
        sum_array.push_back(sum);
    }
    
    int max_v=0;

    if(K*2 >= L){
        max_v = max(max_v, sum_array[L-1]);
    }
    
    for(int i=0; i<L-K*2; i+=2){
        if(i==0){
            max_v = max(max_v, sum_array[i+K*2]);
        }else{
            max_v = max(max_v, sum_array[i+K*2] - sum_array[i-1]);
        }
    }
    
    cout << max_v << endl;

    return 0;
}



Measured memory_bytes: 1528
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include <set>
#define ll long long
using namespace std;
int a[200011];
int p[1000011];
int  sum=0;
int main()
{
    int n;
    int maxs=0;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        maxs=max(maxs,a[i]);
    }
    sort(a,a+n);
    for(int i=0; i<n; i++)
    {
        if(a[i]==a[i+1])
        {
            p[a[i]]=1;
            continue;
        }
        int k=0;
        for(int j=2*a[i]; j<=maxs; j+=a[i])
        {
            p[j]=1;
        }
    }

    for(int  i=0; i<n; i++)
    {
        if(p[a[i]]==0)
        {
            sum++;
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 8212
using System.Collections.Generic;
using System.Linq;
using System;

public class hello
{
    public static void Main()
    {
        var mt = new List<int>();
        for (int i = 0; i < 10; i++)
        {
            var h = int.Parse(Console.ReadLine().Trim());
            mt.Add(h);
        }
        var best3 = mt.OrderByDescending(x => x).Take(3).ToList();
        foreach (var x in best3)
            Console.WriteLine(x);
    }
}

Measured memory_bytes: 9940