akhauriyash/Code-Regression huggingface dataset:
/**********************************************************************
File hoge.cpp
Author  harunaya
Date   2020-03-06(Fri)
note
**********************************************************************/

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

int main() {
  int a, b;
  cin >> a >> b;
  int ans = 0;
  if (a >= 13) {
    ans = b;
  }
  else if (6 <= a && a <= 12) {
    ans = b / 2;
  }

  cout << ans << endl;

}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
 
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define form(i, n) for (size_t i = 0; i < size_t(n); ++i)
#define forn(i, n) for (size_t i = 1; i <= size_t(n); ++i)
template<class T> using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long mod(long long a, long long b) { return (a%b+b)%b; }
long long gcd(long long x, long long y) { return __gcd(x, y); }
long long lcm(long long x, long long y) { return x * 1ll * y / gcd(x, y); }
 
 
const long long MAXN = 1e9 + 9;
const long long SIZE = 2e5 + 5;
const long long MOD = 1e9 + 7;


int N, K;
int l, m, r, res, arr[SIZE];


bool calc () {
	int k = K;
	forn (i, N) {
		if (arr[i] <= m) continue;
		int x = (arr[i] - 1) / m;
		k -= x;
	}
	return k >= 0;
}


int main() { speedhack()

	cin >> N >> K;

	forn (i, N) 
		cin >> arr[i];
	

	l = 1, r = 1e9;

	while (l <= r) {
		m = (l + r) / 2;

		if (calc ()) {
			res = m;
			r = m - 1;
		} else l = m + 1;
	}

	cout << res << endl;



	return 0;
}


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

class UnionFind {
private:
  int sz;
  vector<int> par, size_;
public:
  UnionFind() {}
  UnionFind(int n) : sz(n), par(sz), size_(sz, 1) {
    iota(par.begin(), par.end(), 0);
  }
  int root(int x) {
    if (par.at(x) == x) return x;
    else return par.at(x) = root(par.at(x));
  }
  void unit(int x,int y) {
    x = root(x), y = root(y);
    if (x == y) return;
    if (size_.at(x) < size_.at(y)) swap(x, y);
    par.at(y) = x;
    size_.at(x) += size_.at(y);
  }
  int size(int x) {
    x = root(x);
    return size_.at(x);
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
};

template<typename T> class Kruskal {
public:
  struct edge {
    int u, v;
    T cost;
    bool operator < (const edge& another) const {
      return cost < another.cost;
    }
  };
  vector<edge> es;
  int V;
  Kruskal(int n) : V(n) {}
  void add(int u, int v, T cost) {
    es.push_back((edge) {u, v, cost});
  }
  T solve() {
    UnionFind UF(V);
    T res = 0;
    int cnt = 0;
    sort(es.begin(),es.end());
    for (edge &e : es) {
      if (!UF.same(e.u, e.v)) {
        UF.unit(e.u, e.v);
        res += e.cost;
        cnt++;
        if (cnt == V - 1) break;
      }
    }
    return res;
  }
};

int main() {
  int N;
  cin >> N;
  vector<tuple<int, int, int>> V(N);
  for (int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    V.at(i) = {x, y, i};
  }
  sort(V.begin(), V.end());
  Kruskal<int> K(N);
  for (int i = 0; i + 1 < N; i++) {
    auto[a, b, c] = V.at(i);
    auto[e, f, g] = V.at(i + 1);
    K.add(c, g, min(abs(a - e), abs(b - f)));
  }
  for (int i = 0; i < N; i++) {
    auto[a, b, c] = V.at(i);
    V.at(i) = {b, a, c};
  }
  sort(V.begin(), V.end());
  for (int i = 0; i + 1 < N; i++) {
    auto[a, b, c] = V.at(i);
    auto[e, f, g] = V.at(i + 1);
    K.add(c, g, min(abs(a - e), abs(b - f)));
  }
  cout << K.solve() << "\n";
}

Measured memory_bytes: 7588
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		String a = stdIn.next();
		
		if (a.charAt(0) == 'a' || a.charAt(0) == 'i' || a.charAt(0) == 'u' || a.charAt(0) == 'e' || a.charAt(0) == 'o') {
			System.out.println("vowel");
		} else {
			System.out.println("consonant");
		}
	}
}

Measured memory_bytes: 21844
N = int(input())
ab = [list(map(int,input().split())) for _ in range(N)]
cd = [list(map(int,input().split())) for _ in range(N)]

ans = 0

ab.sort(key=lambda x:x[1],reverse=True)
cd.sort()


for c,d in cd:
    for i,(a,b) in enumerate(ab):
        if a < c and b < d:
            ans +=1 
            ab.pop(i)
            break
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
int main()
{
	int n,i;
	long long sum=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		if(i%3!=0&&i%5!=0)
		sum+=i;
	}
	printf("%lld",sum);
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define ld          long double
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define pi          3.14159265358979323

const int N = 1e5+1;
set<ll>s1[N], s2[N];

ll par[N],urank[N];

void create(ll x) { par[x]=x; urank[x]=1; }

ll fp(ll x)
{
       while(par[x]!=x)
       {
              par[x]=par[par[x]];
              x=par[x];
       }
       return x;
}

void union1(ll x, ll y)
{
       ll parx=fp(x); // parx = root node of the component in which x is located
       ll pary=fp(y);
       if(parx==pary) return;
       if(urank[parx] <= urank[par[y]])
       {
              par[parx]=pary;
              urank[pary] += urank[parx];
       }
       else
       {
              par[pary]=parx;
              urank[parx] +=  urank[pary];
       }
}

vl g[2*N];

void solve()
{
       ll n;
       cin>>n;
       rep(i,1,N) create(i); // all points have rank 1 and root set to themselves
       rep(i,1,n+1)
       {
              ll x,y; cin>>x>>y;
              s1[y].insert(x); // x co-ordinates of points lying at y-coordinate = y
              s2[x].insert(y); // y                                 x              x
       }
       ll ans=0;
       rep(i,1,N)
       {
              if(s1[i].size() <= 1) continue; // single isolated point, no other point in x or y dirn, or point not even there
              auto it1 = s1[i].begin();       // s1[i] - set of x coordinates of points having same y coordinate
              auto it2 = s1[i].begin();       // it1 - beginning, it2 - next point
              it2++;
              while(it2 != s1[i].end())
              {
                     union1(*it2, *it1);  // merge them .... setting root of the points to a single point in the y level and rank of that level ...
                     it1++;
                     it2++;
              }
       }
       rep(i,1,N)
       {
              g[fp(i)].push_back(i); // find par and push node  x x . . . x
       }
       set<ll>s3;
       rep(i,1,N)
       {
              if(g[i].size() <= 1) continue;
              s3.clear();   // new set for x
              rep(j, 0, g[i].size())     // iterate through all x coordinates which have y co-ordinate equals to i
              {
                     for(auto it : s2[g[i][j]]) // iterate through all points that have x coorinate equal to g[i][j] and include them in s3
                            s3.insert(it); // distinct y co-ordinates
              }
              rep(j, 0, g[i].size())
              {
                     ans += s3.size() - s2[g[i][j]].size(); // dis y coordinates - # y coordinates in current
              }
       }
       cout<<ans<<endl;
}


int main() {
	int T = 1;
//       pre();
	speed_up
	//cin>>T;
	while(T--)
	    solve();
	return 0;
}


Measured memory_bytes: 29560
import sys
sys.setrecursionlimit(10**6)

N, K = map(int, input().split())
*A, = map(int, input().split())
A = [a-1 for a in A]

path = []
visited = {}


def dfs(v, k):
    if v in visited:
        return v

    visited[v] = k
    path.append(v)
    return dfs(A[v], k+1)


origin = dfs(0, 0)
i = visited[origin]
loop = path[i:]


if K <= i:
    print(path[K] + 1)
else:
    j = (K - i) % len(loop)
    print(loop[j] + 1)


Measured memory_bytes: 191792
import java.util.* ;

public class Main{
  public static void main(String args[]){
       	Scanner sc = new Scanner(System.in);
    
    int K = sc.nextInt() ;
    int X = sc.nextInt() ;
      int kanousei = X + K-1 ;
      int kanouseiminus = X-K+1 ;
      for(int i=kanouseiminus;i<=kanousei;i++){
        System.out.print(i + " ");
    }
  }
}

Measured memory_bytes: 21844
N = int(input())
a = list(map(int,(input().split())))
a.insert(0,0)
a.append(0)
cost = 0
now = 0
for i in range(1,N+2):
    cost += abs(now-a[i])
    now = a[i]

for i in range(1,N+1):
    if (a[i]-a[i-1])*(a[i+1]-a[i]) < 0:
        if (a[i]-a[i-1])*(a[i+1]-a[i-1]) >= 0:
            print(cost-(abs(a[i+1]-a[i])*2))
        else:
            print(cost-(abs(a[i]-a[i-1])*2))
    else:
        print(cost)

Measured memory_bytes: 61292
#include <iostream>
#include <string>
using namespace std;
int main(void) {
	string s;
	int a;
	getline(cin, s);
	a = s.size();
	for (int i = 0; i < a; i++) {
		if (s[i] >= 'a'&&s[i] <= 'z') {
			s[i] = s[i] - 'a' + 'A';
		}
		else if (s[i] >= 'A'&&s[i] <= 'Z') {
			s[i] = s[i] - 'A' + 'a';
		}
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 3140
from collections import Counter
n = int(input())
res = list(map(int,input().split()))
a = Counter(res)

sums = 0

for i in a.values():
    sums +=  i * (i - 1) // 2

for j in res:
    print(sums - a[j] * (a[j] -1) //2 + (a[j]-1) * (a[j] -2 ) // 2)

Measured memory_bytes: 87884
//まいった

#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int AS = 500000;
char cn[AS], * ci = cn, ct;
inline int getint() {
	int A = 0;
	while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
char * di = cn;
int dat[2 * AS];

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


	int N = 0;
	while ((ct = getchar_unlocked()) >= '0') N = N * 10 + ct - '0';
	fread(cn, 1, N, stdin);
	auto da = dat + AS;
	rep(i, N) *da++ = (1 << *ci++ - 'a');
	da = dat + AS - 1;
	for (auto db = dat + AS * 2 - 1; da > dat; da--) *da = *db-- | *db--;
	getchar_unlocked();
	ci = cn;
	fread(cn, 1, 320010, stdin);
	int Q = getint();

	const char a[27] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6' };

	rep(j, Q) {
		char q = *ci++;
		ci++;
		if (q == '1') {
			int i = getint() - 1 + AS;
			for (dat[i] = 1 << *ci++ - 'a'; i > 1; i >>= 1) dat[i >> 1] = dat[i] | dat[i ^ 1];
			ci++;
		}
		else {
			int ret = 0;
			for (int l = getint() - 1 + AS, r = getint() + AS; l < r; l >>= 1, r >>= 1) {
				if (l & 1) ret |= dat[l++];
				if (r & 1) ret |= dat[--r];
			}
			int kotae = __builtin_popcount(ret);
			if (kotae >= 20) *di++ = '2';
			else if (kotae >= 10) *di++ = '1';
			*di++ = a[kotae];
			*di++ = '\n';
		}
	}
	fwrite(cn, 1, di - cn, stdout);

	Would you please return 0;
}

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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

const int N = 1e5 + 10;

int n, a[N];

int main()
{
	gi(n);
	for (int i = 1; i <= n; ++i) gi(a[i]);
	sort(a + 1, a + n + 1);
	if (a[n] - a[1] > 1)
	{
		puts("No");
		return 0;
	}
	reverse(a + 1, a + n + 1);
	int j = 0;
	while (a[j + 1] == a[1]) ++j;
	a[1] -= n - j;
	if (a[1] <= 0)
	{
		puts("No");
		return 0;
	}
	if (a[1] == j - 1 && (n == j))
	{
		puts("Yes");
		return 0;
	}
	if (j / a[1] >= 2) 
	{
		puts("Yes");
		return 0;
	}
	puts("No");
	return 0;
}

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

// definitions
#define __Imperial_Lord__ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define _cps CLOCKS_PER_SEC
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i, l, r) for (long long i = (l); i < (long long)(r); i++)
#define repb(i, r, l) for (long long i = (r); i > (long long)(l); i--)
#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define high(x) __builtin_popcountll(x)
#define pb push_back
#define pf push_front
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c <<endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d <<endl
#define exec cerr<<"Time taken : "<<(ld)(clock())/_cps<<"s"<<endl
#define mod1 998244353
#define mod 1000000007
#define pi 3.1415926535897932384

using namespace std;

// alias name for common data types
typedef vector<long long> vl;
typedef vector<long double> vld;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector< pair<long long, long long> > vp;
typedef vector<tuple<long long , long long , long long> > vtup;
typedef deque <long long> dql;
typedef deque <char> dqc;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

const ll INF=1e18;

template <class ...Args>
istream &read_args(Args &...args) {return (cin >> ... >> args);}
#define read(...)   __VA_ARGS__; read_args(__VA_ARGS__)

// cin and cout overloaded for vectors
template<typename T>    istream& operator>>(istream& is,  vector<T>& v)
{
    for (auto& i : v) 
        is >> i;        
    return is;
}
template<typename T>    ostream& operator<<(ostream& os,  vector<T>& v)
{
    for (auto& i : v) 
        os << i << ' '; 
        return os;
}


// code beigns in main
int main()
{
    __Imperial_Lord__
    ll t=1;
    // cin >> t;
    
    while(t--)
    {
        ll a[(ll)1e5]; clr(a);
        rep(i,1,100)
        {
            rep(j,1,100)
            {
                rep(k,1,100)
                {
                    ll val=i*i+j*j+k*k+i*j+j*k+k*i;
                    a[val]++;
                }
            }
        }

        ll read(n);
        rep(i,1,n+1)
            p1(a[i]);
    }   
    exec;
}

Measured memory_bytes: 4556
import sys
import io
import math

datalist = input().split()

data_a = int(datalist[0])
data_b = int(datalist[1])
data_c = int(datalist[2])

data_ans = int(data_b / data_a)

if data_ans < data_c:
    print(data_ans)
else:
    print(data_c)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo (1LL<<63-1)
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >

using namespace std;

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

const long double Pi=acos(-1),e=2.718;
const int N=2e5+10, mod=1e9+7;

int main ()
{
    FASTIO
    int n,k;
    cin >> k >> n;
    vector<int> a(n+2);
    a[0]=0;
    for(int i=1;i<=n;i++){
        cin >> a[i];
    }
    a[n+1]=k;
    int ans=INT_MAX;
    for(int i=1;i<=n;i++){
        if(i==1){
            ans = min(ans,a[n]-a[1]);
        }
        else{
            ans = min(ans,a[n+1]-a[i] + a[i-1]);
        }
    }
    for(int i=1;i<=n;i++){
        if(i==n){
            ans = min(ans,a[n]-a[1]);
        }
        else{
            ans = min(ans,a[i]-a[0] + a[n+1]-a[i+1]);
        }
    }
    cout << ans << endl;

    return 0;
}
/**

*/


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
using namespace std;


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

  int n,k; cin >> n >> k;
  string s; cin >> s;
  if(s[k-1]=='A') s[k-1]='a';
  if(s[k-1]=='B') s[k-1]='b';
  if(s[k-1]=='C') s[k-1]='c';
  cout << s << endl;
}






Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib> //func147bでインクルード
#include <vector>  //func146b
using namespace std;
 
void func142b()
{
    int n, k,h;
    int count = 0;
    vector<int> v;
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> h;
        v.emplace_back(h);
    }
    for(int i=0; i<n ; ++i){
        if (v[i] >= k) count++;
    }
    cout << count << endl;
}
 
int main()
{
  func142b();
  return 0;
}

Measured memory_bytes: 892
N = int(input())
immi = list(map(int, input().split()))
flag = 0

for el in immi:
    if el % 2 == 0:
        if not el % 3 == 0:
            if not el % 5 == 0:
                flag = 1
                break
                
if flag == 1:
    print('DENIED')
else:
    print('APPROVED')

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

using namespace std;

typedef long long ll;

int main(){
  int N;
  cin >> N;
  char S[11111];
  cin >> S;
  ll i,j,k;
  ll r = 0;
  ll g = 0;
  ll b = 0;
  for(i=0;i<=N-1;i++){
    if(S[i]=='R') r++;
    if(S[i]=='G') g++;
    if(S[i]=='B') b++;
    }
  ll ans = r * g * b;
  for(i=0;i<=N-3;i++)
    for(j=i+1;j<=N-2;j++)
      if(2*j-i <= N-1 && S[i]!=S[j] && S[j]!=S[2*j-i] && S[2*j-i] != S[i]) ans--;
  cout << ans << endl; 
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define lowbit(x) x&(-x)
using namespace std;
const int N = 5e5 + 5;
struct Node {
    int l, r, pos;
    bool operator < (const Node &x) const
    {
        return r < x.r;
    }
}ask[N];
int a[N], b[N], c[N], ans[N];
int n, m;
inline int read () {
    int tot = 0, f = 1; char c = getchar ();
    while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar (); }
    while (c >= '0' && c <= '9') { tot = tot * 10 + c - '0'; c = getchar (); }
    return tot * f;
}
inline void update (int x, int v) {
    for (int i = x; i <= n; i += lowbit(i)) c[i] += v;
}
inline int query (int x) {
    int res = 0;
    for (int i = x; i >= 1; i -= lowbit(i)) res += c[i];
    return res;
}
signed main () {
    n = read (); m = read ();
    for (int i = 1; i <= n; i++) a[i] = read ();
    for (int i = 1; i <= m; i++) {
        ask[i].l = read (); ask[i].r = read ();
        ask[i].pos = i;
    }
    sort (ask + 1, ask + 1 + m);
    int nxt = 1;
    for (int i = 1; i <= m; i++) {
        for (int j = nxt; j <= ask[i].r; j++) {
            if (b[a[j]]) update (b[a[j]], -1);
            update (j, 1);
            b[a[j]] = j;
        }
        nxt = ask[i].r + 1;
        ans[ask[i].pos] = query (ask[i].r) - query (ask[i].l - 1);
    }
    for (int i = 1; i <= m; i++) printf ("%d\n", ans[i]);
    return 0;
}


Measured memory_bytes: 17400
using System;
using System.Linq;
using System.Collections;
					
public class Program
{
	public static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		int[] a = Console.ReadLine().Split().Select(e => int.Parse(e)).ToArray();
		
		int min = 100, max = -100;
		for(int i=0; i<n; i++)
		{
			if(a[i]<min) min = a[i];
			if(a[i]>max) max = a[i];
		}
		
		int r = 2000000000;
		for(int i=min; i<=max; i++)
		{
			int dummy = cost(a,i);
			if(dummy<r) r=dummy;
		}
		Console.WriteLine(r);
	}
	
	public static int cost(int[] x, int y)
	{
		int c = 0;
		foreach(int val in x)
		{
			c += (int)Math.Pow((val-y),2);
		}
		return c;
	}
	
}

Measured memory_bytes: 2904
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax = 1e5;
int N;
ll A[Nmax];

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

	ll sum = 0;
	ll even = 0, odd = 0;
	for(int i=0; i<N; i++){
		sum += A[i];
		if(i%2) odd += A[i];
		else even += A[i];
	}

	ll ans = sum - 2*odd;
	cout << ans << " ";
	for(int i=0; i<N-1; i++){
		ans = 2*A[i]-ans;
		cout << ans << (i==N-1?'\n':' ');
	}

	return 0;
}


Measured memory_bytes: 2048
/**
 *    author: gxfireball       
**/
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
using namespace std;

void solve(){
   ll x;
   cin >> x;
   ll amt = 100;
   for(ll i=0; i<=10000000; ++i){
	   if(amt >= x){
		   cout << i << endl;
		   return;
	   }
	   ll temp = amt/100;
	   amt += temp;
   }
}

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


Measured memory_bytes: 3648
// おまじない
#include <bits/stdc++.h>
using namespace std;
 
long int gcd(long int a,long int b)
{
	if (b==0)
	{
		return(a);
    }
	else
	{
		return(gcd(b,a%b));
    }
}


int main() {
  long int a,b,c,d;
  cin>>a>>b>>c>>d;
  long int lcm;
  if(c>d){
     lcm=c*d/gcd(c,d);}
  else{
    lcm=c*d/gcd(d,c);}
  
  long int koa=(a-1)-(a-1)/c-(a-1)/d+(a-1)/lcm;
  
  long int kob=b-b/c-b/d+b/lcm;
  
  cout<<kob-koa<<endl;
}


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

struct V {
  double x, y;

  V(double x = 0, double y = 0) : x(x), y(y) {}

  V& operator+=(const V& v) {
    x += v.x;
    y += v.y;
    return *this;
  }

  V operator+(const V& v) const { 
    return V(*this) += v;
  }

  int orthant() const {
    if (y > 0) return x > 0 ? 1 : 2;
    return x <= 0 ? 3 : 4;
  }
  
  double dot(const V& v) const { return x * v.x + y * v.y; }
  double cross(const V& v) const { return x * v.y - y * v.x; }
  double norm2() const { return x * x + y * y; }
  double norm() const { return sqrt(norm2()); }
  bool operator<(const V& v) const {
    int o = orthant();
    int vo = v.orthant();
    if (o != vo) return o < vo;
    return cross(v) > 0;
  }
};

istream& operator>>(istream& is, V& v) {
  is >> v.x >> v.y;
  return is;
}

ostream& operator<<(ostream& os, const V& v) {
  os << "(" << v.x << ", " << v.y << ")";
  return os;
}

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

  int n;
  cin >> n;
  vector<V> v(n);
  rep(i, n) { cin >> v[i]; }
  sort(v.begin(), v.end());
  double ans = 0;
  rep(l, n) {
    int r = l;
    V now;
    rep(i, n) {
      now += v[r];
      ans = max(ans, now.norm());
      r = (r+1)%n;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  if(b <= a) cout << "delicious" << endl;
  else if(a < b && b <= x+a) cout << "safe" << endl;
  else if(a+x < b) cout << "dangerous" << endl;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(N), B(N);
    for(int i = 0; i < N; i++)
        cin >> A[i] >> B[i];
    
    vector<pair<int, int>> AB(N);
    for(int i = 0; i < N; i++)
        AB[i] = {A[i], B[i]};
    
    sort(AB.begin(), AB.end()); //pairのソートは前の要素が対象

    int j = 0;
    long long ans = 0;
    while(M > 0){
        long long num = min(M, AB[j].second);

        ans += num * AB[j].first;     
        j++;
        M -= num;
    }

    cout << ans << endl;

    return 0;
}

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

typedef long long ll;
ll n, c, mn = 1e9;
int main()
{
	ll i, j;
	cin >> n;
	for (i = 1; i * i <= n; i++) {
		if (n % i != 0) continue;
		for (j = n / i, c = 0; j; j /= 10, c++);
		mn = min(mn, c);
	}
    cout << mn << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m;
  cin>>n>>m;
  vector<int64_t> H(n);
  vector<int> A(m),B(m),check(n);
  int i=0,j=0,tmp;
  for(i=0;i<n;i++){
    cin>>H.at(i);
  }
  for(i=0;i<m;i++){
    cin>>A.at(i)>>B.at(i);
    if(H.at(A.at(i)-1)>H.at(B.at(i)-1)){check.at(B.at(i)-1)=1;}
    else if(H.at(A.at(i)-1)<H.at(B.at(i)-1)){check.at(A.at(i)-1)=1;}
    else {check.at(A.at(i)-1)=check.at(B.at(i)-1)=1;}
  }
  int count=0;
  for(i=0;i<n;i++){
  	if(check.at(i)==0){count++;}
  }
  cout <<count<< endl;
  return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

bool check(const vector<int> &p) {
    const int n = p.size();
    for (int i = 0; i + 1 < n; ++i)
        if (p[i] > p[i + 1]) return false;
    return true;
}

bool solve() {
    int n;
    cin >> n;

    vector<int> p(n);
    for (auto &p_i : p) cin >> p_i;

    if (check(p)) return true;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            swap(p[i], p[j]);
            if (check(p)) return true;
            swap(p[i], p[j]);
        }
    }

    return false;
}

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

    if (solve()) cout << "YES\n";
    else cout << "NO\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define MAX(a, b, c) max(max(a, b), c)
using namespace std;

int main(){
  int n;
  scanf("%d", &n);
  int h[n];
  REP(i,n) scanf("%d", &h[i]);
  int ans = 1;
  int max_h = h[0];
  FOR(i,1,n){
    if(h[i] >= max_h){
      ans++;
      max_h = h[i];
    }
  }
  cout << ans << endl;
}

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

using namespace std;

using int64 = long long;

int64 Solve() {
  int n;
  cin >> n;
  vector<int> as(n);
  vector<int> bs(n);
  for (int i = 0; i < n; i++) cin >> as[i];
  for (int i = 0; i < n; i++) cin >> bs[i];

  int64 cost = 0;
  int match_count = 0;
  for (int i = 0; i < n; i++) {
    if (as[i] == bs[i]) {
      match_count++;
    }
  }

  deque<int> queue;
  for (int i = 0; i < n; i++) {
    queue.push_back(i);
  }


  while (!queue.empty()) {
    int i = queue.front();
    queue.pop_front();
    if (bs[i] - (bs[(i + n - 1) % n] + bs[(i + 1) % n]) >= as[i]) {
      int q = (bs[i] - as[i]) / (bs[(i + n - 1) % n] + bs[(i + 1) % n]);
      bs[i] -= q * (bs[(i + n - 1) % n] + bs[(i + 1) % n]);
      cost += q;
      if (bs[i] == as[i]) {
        match_count++;
        if (match_count == n) {
          return cost;
        }
      }
      queue.push_back((i + n - 1) % n);
      queue.push_back(i);
      queue.push_back((i + 1) % n);
    }
  }
  return -1;
}

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

  cout << Solve() << endl;
}

Measured memory_bytes: 3072
#include<algorithm>
#include<cstdio>

using namespace std;

int read()
{
    int x=0;        bool f=0;        char k=getchar();
    while(k< '0'||k> '9') (k=='-')&&(f=1),k=getchar();
    while(k>='0'&&k<='9') x=(x*10)+(k&15),k=getchar();
    return (f)?(-x):(x);
}

signed main()
{
    int n=read();
    if(n&1)printf("%f",1.0*(n/2+1)/n);
    else printf("%f",0.5);
}

Measured memory_bytes: 128
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

#define mem(arr, i) fill(arr, arr + sizeof(arr), i)
#define MEM(arr, i) memset(arr, i, sizeof(arr))
#define Push push_back
#define Pair make_pair
#define ALL(x) x.begin(), x.end()
#define X first
#define Y second
#define ACCEL \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL); \
	cout.tie(NULL)
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef pair<pll,lli> p3l;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
typedef vector<p3l> v3L;
typedef vector<vcL> vvL;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
      lli   mod = 1000000007;

/// templates ///

const lli maxN = 2E5;

vcL inv(maxN+5, 1);

void ADD(lli &x, lli y) {
	x += y;
	if (x >= mod) x -= mod;
	if (x < 0) x += mod;
}

void MUL(lli &x, lli y) {
	x *= y;
	x = (x % mod + mod) % mod;
}

lli mypow(lli b, lli e) {
	if (b == 0) return 0;
	lli ans = 1;
	while (e) {
		if (e & 1) MUL(ans, b);
		MUL(b, b);
		e >>= 1;
	}
	return ans;
}

lli modinv(lli n) {
	return mypow(n, mod - 2);
}

void calcInv(lli n) {
	for (int i = 2; i <= n; ++i) {
		inv[i] = (mod - mod / i) * inv[mod % i] % mod;
	}
}

/// coding area ///

const lli maxn = 1E5;

void solve() {
	lli a, b;
	cin >> a >> b;
	cout << (b == 1 ? 0 : (b - 2) / (a - 1) + 1) << '\n';
}

int main() {
//	precal();
	int t = 1;
	#ifdef LOCAL
		t = INT_MAX;
	#else
		ACCEL;
	#endif
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		cout << "Case #" << i << ": ";
		solve();
	}
	return 0;
}



Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
int main(){
  string s,t,temp;
  cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.rbegin(),t.rend());
  if(s<t){
    cout << "Yes";
  }else{
    cout << "No";
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1;} return 0;}
struct init{init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}}init_;

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

// ACL template
int main() {
    ll N, M;
    cin >> N >> M;

    scc_graph g(N);
    
    rep(i, M) {
        ll u, v;
        cin >> u >> v;
        g.add_edge(u, v);
    }

    auto scc = g.scc();

    cout << scc.size() << '\n';

    repa(V, scc){
        cout << V.size();
        repa(v, V) cout << " " << v;
        cout << '\n';
    }
}

Measured memory_bytes: 40088
#include <iostream>
#include <sstream>

template<class T> void dwrite(T& o){
	std::cout << o << std::endl;
}

std::string itos(int);

int main(){
	int n;
	while(std::cin >> n, n){
		std::string s, res;
		std::cin >> s;
		while(n--){
			res = "";
			for(int i=0;i<s.size();i++){
				int c = 1;
				for(int j=1;i+j<s.size();j++){
					if(s[i] != s[i+j])break;
					c++;
				}
				res += itos(c) + s[i];
				i += c - 1;
				//dwrite(c);
				//dwrite(res);
			}
			s = res;
		}
		std::cout << res << std::endl;
	}
}

std::string itos(int i){
	std::stringstream ss;
	ss << i;
	return ss.str();
}

Measured memory_bytes: 1048
a = str(input())

if a == "SUN":
  print("7")
elif a == "MON":
  print("6")
elif a == "TUE":
  print("5")
elif a == "WED":
  print("4")
elif a == "THU":
  print("3")
elif a == "FRI":
  print("2")
else:
  print("1")

Measured memory_bytes: 3060
#include <iostream>
#include <cctype>
#include <string>
#include <string.h>
using namespace std;
int main(){
    string a,b = "";
    int l[26] = {};
    while(cin >> a){
        for(int i = 0; i < a.length(); i++){
            if(a[i] >= 'a' && a[i] <= 'z' ){
                l[a[i] - 'a'] += 1; 
            } else if(a[i] >= 'A' && a[i] <= 'Z' ) {
                l[a[i] - 'A'] += 1;
            }
        }
    }
    char k[26], sai = 'a';
    for(int i = 0; i < 26; i++){
        k[i] = sai;
        sai += 1;
    }
    for(int i = 0; i < 26; i++){
        cout << k[i] << " : " <<  l[i] << endl;
    }
    return 0;
}


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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> cnts(1e5 + 3, 0);
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    cnts[a]++;
    cnts[a + 1]++;
    if (a != 0) cnts[a - 1]++;
  }

  int ans = 0;
  for (int i = 0; i < (int)cnts.size(); ++i) {
    ans = max(ans, cnts[i]);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 640
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return


ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }


/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////

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

    if(a <= b)P("unsafe");
    else P("safe");
    return  0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>


using namespace std;

// vector<vector<int>> mat(N, vector<int>(M, 0));

int main(int argc, const char *argv[])
{
    //ABC138
    int N;
    cin>>N;
    int Q;
    cin>>Q;
    vector<vector<int> > GRAPH(N,vector<int>(0,0));
    vector<int> NODE(N,0);

    int A,B;


    for (int i = 0; i < N -1 ; i++)
    {
        /* code */
        cin>>A>>B;
        GRAPH[ A - 1].push_back(B - 1);
        GRAPH[B - 1].push_back(A - 1);
    }

    int P,X;

    for (int i = 0; i < Q; i++)
    {
        /* code */
        cin>>P>>X;
        NODE[P-1] += X;
    }

    vector<bool> used(N);
    
    


    stack<int> stack;
    stack.push(0);
    int t ;
    while (stack.size())
    {
        t = stack.top();
        stack.pop();
        if(used[t]) continue; //trueならスキップ
        used[t] = true;
        for(auto i : GRAPH[t])//Graph[t]の要素iについて
        {
            if(!used[i])//探索済みでなければ
            {
                NODE[i] += NODE[t];//親の値を子に足す
                stack.push(i);//キューに子の値を追加
            }
        }
    }

    for (int i = 0; i < N; i++)
    {
        cout << NODE[i] << " ";
    }

    return 0;

}





Measured memory_bytes: 15604
function Main(input) {
  var s = input.split('');
  var result = 0;
  for (var i = 0; i < s.length; i++) {
    result = result + +s[i];
  }
  
  if(input % result === 0) {
    console.log('Yes');
  } else {
    console.log('No');
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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


int main(void){
    string S;
    cin >> S;
    
    int cnt = 0;
    vector<int> A(S.size() + 1);
    A[0] = 0;
    for (int i = 0; i < S.size(); i++){
        if (S[i] == '<')
            cnt++;
        else
            cnt = 0;
        A[i + 1] = cnt;
    }

    cnt = 0;
    for (int i = S.size() - 1; i >= 0; i--){
        if (S[i] == '>')
            cnt++;
        else
            cnt = 0;
        A[i] = max(A[i], cnt);
    }

    cout << accumulate(A.begin(), A.end(), 0L) << endl;

}


Measured memory_bytes: 2820
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;
const int INF = 1 << 25;
const LL MOD = 1000000007LL;
using namespace std;
typedef pair<int, int> P;
int r[20000];
int main() {
	int N;
	cin >> N;
	rep(i, N) {
		int p;
		cin >> p;
		p--;
		r[p] = i;
	}
	rep(i, N) {
		if (i > 0) cout << " ";
		cout << 30000 * (i + 1);
	}
	cout << endl;
	rep(i, N) {
		if (i > 0) cout << " ";
		cout << 30000 * (N - i) + r[i];
	}
	cout << endl;
}

Measured memory_bytes: 640
/*
 *
 * Author: r3gz3n
 * 
 * 3b 13 12 9 56 4e
 * 6 56 a a 5f f
 * 6 56 47 18 56 d
 * 13 46 14 1f 13 27
 * 52 52 a 5a 47 1
 * 1d 13 b 1b 49 17
 *
 */


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;


#define all(x) (x).begin(),(x).end()

#define rep(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)


#define endl '\n'


template<typename T> bool chmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }


template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }


typedef vector<int> vii;


class Solution {
public:
    void solve(std::istream& in, std::ostream& out) {
        int h, w, k, ans = 1e9;
        in >> h >> w >> k;
        vector<string> s(h);
        in >> s;
        rep(bs, 0, 1 << (h-1), 1) {
            int bitcount = 1 + __builtin_popcount(bs);
            vii cnt(bitcount);
            int tmp = bitcount - 1;
            bool suc = false;
            rep(j, 0, w, 1) {
                int now = 0;
                rep(i, 0, h, 1) {
                    if (s[i][j] == '1') cnt[now]++;
                    if ((bs >> i) & 1) now++;
                }
                if (*max_element(all(cnt)) > k) {
                    if (suc) {
                        tmp = 1e9;
                        break;
                    }
                    tmp++;
                    for(auto &x: cnt) x = 0;
                    j--;
                    suc = true;
                    continue;
                }
                suc = false;
            }
            chmin(ans, tmp);
        }
        out << ans << endl;
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


    istream& in = cin;


    ostream& out = cout;

    solve(in, out);
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    ll n; cin >> n;
    vector<ll> a(n),b(n),c(n);
    for(ll i=0;i<n;i++) cin >> a[i];
    for(ll i=0;i<n;i++) cin >> b[i];
    for(ll i=0;i<n;i++) cin >> c[i];
    sort(ALL(a));
    sort(ALL(b));
    sort(ALL(c));

    ll ans = 0;

    for(ll i=0;i<n;i++){
        auto A = lower_bound(ALL(a),b[i]);
        auto B = upper_bound(ALL(c),b[i]);
        //cout << A - a.begin() << " " << c.end() - B << endl;
        ans += (A - a.begin()) * (c.end() - B);
    }

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


Measured memory_bytes: 5584
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> mp;
    for(auto &x : a){
        cin >> x;
        mp[x]++;
    }
    sort(ALL(a));
    uni(a);
    int ans = 0;
    for(auto &x : a){
        if(mp[x] > x){
            ans += mp[x] - x;
        }else if(mp[x] < x){
            ans += mp[x];
        }
    }
    cout << ans;
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 8224
#include <stdio.h>

#include <algorithm>

using namespace std;

int getGcd(int a, int b) {
  if (a < b) {
    swap(a, b);
  }
  int rem = a % b;
  while (rem != 0) {
    a = b;
    b = rem;
    rem = a % b;
  }
  return b;
}

int main() {
  //freopen("GcdAndLcm.in", "r", stdin);
  int a, b;
  while (scanf("%d%d", &a, &b) == 2) {
    int gcd = getGcd(a, b);
    int lcm = (long long)a * b / gcd;
    printf("%d %d\n", gcd, lcm);
  }
  return 0;
}

Measured memory_bytes: 1024
line = raw_input()
N = int(line)
W = [raw_input() for i in range(0, N)]
ret = True
if len(W) != len(set(W)):
    ret = False
else:
    last = W[0][0]
    for word in W:
        if last != word[0]:
            ret = False
            break
        last = word[-1]

print 'Yes' if ret else 'No'


Measured memory_bytes: 2568
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <stack>
#include <queue>

using namespace std;
#define Fill(a, b) memset(a, b, sizeof(a))
#define Debug(x) cout << #x << "=" << (x) << endl;
typedef long long LL;
const LL inf = 1LL << 61;
const LL mod = 1000000007;
//Fill(dp,0x3f3f3f3f)
#define DEBUG
#ifdef DEBUG
#endif
const int maxn = 210;
struct edge
{
    int to;
    LL cap;
    int rev;
};

LL arr[maxn];
vector<edge> G[maxn];
bool used[maxn];
LL dfs(int v, int t, LL f);
int main()
{
    std::ios::sync_with_stdio(false);
    int n;
    LL ans = 0;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)
    {
    	scanf("%lld", &arr[i]);
    	if(arr[i]>=0)ans += arr[i];
    }
    int s = 1, t = n+2;
    for(int i = 1; i <= n; i++)
    {
    	int a, b;
    	LL c; 
    	if(arr[i] < 0)
    	{
    		a = s, b = i+1, c = -arr[i];
    	}
    	else
    	{
    		a = i+1, b = t, c = arr[i];
    	}
    	G[a].push_back((edge)
        {
            b, c, G[b].size()
        });
        G[b].push_back((edge)
        {
            a, 0, G[a].size()-1
        });
    }
    for(int i = 1; i <= n; i++)
    {
    	for(int j = i+i; j <= n; j+=i)
    	{
    		int a = i+1, b = j+1;
    		LL c = inf;
    		G[a].push_back((edge)
	        {
	            b, c, G[b].size()
	        });
	        G[b].push_back((edge)
	        {
	            a, 0, G[a].size()-1
	        });
    	}
    }
    LL mxflow = 0;
    for(;;)
    {
        Fill(used, 0);
        LL f = dfs(s, t, inf);
        if(f == 0)
            break;
        mxflow += f;
    }
    ans = ans-mxflow;
    printf("%lld\n", ans);


    return 0;
}
LL dfs(int v, int t, LL f)
{//cout << v << " " << f << endl;
    if(v == t)
        return f;
    used[v] = true;
    int i;
    for(i = 0; i < G[v].size(); i++)
    {
        edge &e = G[v][i];
        if(!used[e.to] && e.cap > 0)
        {
            LL d = dfs(e.to, t, min(f, e.cap));
            if(d > 0)
            {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
    using namespace std;

    int H, W;

    while (1)
    {
        cin >> H >> W;

        if (H == 0 && W == 0)
        {
            return 0;
        }

        string top_under = string(W, '#');

        string middle = '#' + string(W - 2, '.') + '#';

        for (int i = 0; i < H; i++)
        {
            if(i==0 || i==H-1){
            
            cout << top_under << endl;
            }
            else
            {
                cout << middle << endl;
            }
        }
        cout << endl;
    }
}


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

int main(){
    string s, t;
    cin >> s;
    cin >> t;
    int sum = 0;
    for (auto i = 0; i < 3; i++)
    {
        if(s[i] == t[i]){
            sum += 1;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256